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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- var bC=Object.defineProperty;var i=(t,e)=>bC(t,"name",{value:e,configurable:!0});import{EventSeverity as Aee,RouteEventType as Nee,StepEventType as Bee,StepExecutionBlockedEventStatus as Wee,StepExecutionEventStatus as Mee}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Pee}from"@rango-dev/wallets-core/legacy";import{useWallets as Yi,Events as Dee}from"@rango-dev/wallets-react";import{Networks as Fee,WalletTypes as Oee}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as zee}from"rango-types";import{Divider as Vk}from"@rango-dev/ui";import po,{useEffect as Kk,useRef as jk,useState as wd}from"react";import{WalletState as EC}from"@rango-dev/ui";import{useWallets as IC}from"@rango-dev/wallets-react";import{useReducer as AC}from"react";function Op(t){return!!t.derivationPath}i(Op,"isStateOnDerivationPathStep");function Up(t){return!!t.namespace}i(Up,"isStateOnNamespace");var Jr={status:"init",namespace:null,derivationPath:null,selectedNamespaces:null};function zp(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 Jr;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:Jr;default:throw new Error("Action hasn't been defined.")}}i(zp,"reducer");function en(){let{state:t,disconnect:e,connect:o}=IC(),[n,r]=AC(zp,Jr),a=i(async(d,f,h)=>{r({type:"reset"});try{let g=f?.map(m=>({...m,network:void 0}));return await o(d.type,g),{status:"connected"}}catch(g){let m=g?.message?`Error: ${g.message}`:"An unknown error happened during connecting wallet.";if(h?.disconnectOnError)try{await u(d)}catch{console.warn("An error happened during disconnecting wallet after error on connecting.")}throw new Error(m,{cause:g})}},"runConnect"),s=i(async(d,f)=>{let h=d.state===EC.DISCONNECTED,g=f?.forceConnectToNamespaces;if(h){let m=!!d.isHub,y=m?d.properties?.find(C=>C.name==="namespaces")?.value:d.needsNamespace,S=m?d.properties?.find(C=>C.name==="derivationPath")?.value:d.needsDerivationPath;if(g){let C=g.find(k=>!y?.data?.map(x=>x.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:d.type,providerImage:d.image,namespace:g[0]}}),{status:"derivation-path"}):await a(d,g.map(k=>({namespace:k})),{...f,disconnectOnError:!0})}if(!y?.data?.length)return await a(d,void 0,f);if(y?.data.length&&y.data.length>1)return r({type:"needsNamespace",payload:{targetWallet:d,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:d.type,providerImage:d.image,namespace:C.value}}),{status:"derivation-path"}}return await a(d,y?.data?.map(C=>({namespace:C.value})),f)}}if(d.isHub&&!f?.forceConnectToNamespaces){let m=d.properties?.find(y=>y.name==="namespaces")?.value;if(m?.data.length&&m.data.length>1)return r({type:"detached",payload:{targetWallet:d,selectedNamespaces:null}}),{status:"Detached"}}return f?.disconnectIfConnected?(await u(d),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),c=i(async(d,f)=>{let h=!!d.isHub,g=h?d.properties?.find(k=>k.name==="namespaces")?.value:d.needsNamespace,m=h?d.properties?.find(k=>k.name==="derivationPath")?.value:d.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&&m)return r({type:"needsDerivationPath",payload:{providerType:d.type,providerImage:d.image,namespace:S}}),{status:"derivation-path"};if(!Up(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:d,selectedNamespaces:C??null}}),{status:"Detached"}},"handleNamespace"),l=i(async(d,f,h)=>{if(!f)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!Op(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let m=[{namespace:n.derivationPath.namespace,derivationPath:f}],S=!!d.isHub?d.properties?.find(x=>x.name==="namespaces")?.value:d.needsNamespace,C=!!S?.data&&S.data.length>1,k=!!h?.forceConnectToNamespaces;return C&&!k?(r({type:"detached",payload:{targetWallet:d,selectedNamespaces:m??null,derivationPath:f}}),{status:"Detached"}):await a(d,m)},"handleDerivationPath"),p=i(()=>n,"getState"),u=i(async d=>{let f=t(d.type);return f.connected||f.connecting?(await e(d.type),Ao(p)?(r({type:"needsNamespace",payload:{targetWallet:d}}),{status:"namespace"}):{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:c,handleDerivationPath:l,getState:p,resetState:d=>{r(d==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(en,"useStatefulConnect");import{WalletState as Es}from"@rango-dev/ui";import{useWallets as OT}from"@rango-dev/wallets-react";import{detectMobileScreens as UT,KEPLR_COMPATIBLE_WALLETS as zT,WalletTypes as Jn}from"@rango-dev/wallets-shared";import{useCallback as HT,useEffect as QT}from"react";import PT,{createContext as _T,useContext as DT,useEffect as $T,useRef as FT}from"react";import{create as MT}from"zustand";import{persist as LT}from"zustand/middleware";import{allProviders as NC}from"@rango-dev/provider-all";var ns=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()}},tn=new ns;import{defineVersions as Qp,pickVersion as qp,Provider as rs}from"@rango-dev/wallets-core";function Gp({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=is(a);return s instanceof rs?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 rs?o.push(Qp().version("1.0.0",n).build()):o.push(Qp().version("0.0.0",n).build())}),o}return t}i(Gp,"matchAndGenerateProviders");function is(t){try{return qp(t,"1.0.0")[1]}catch{return qp(t,"0.0.0")[1]}}i(is,"pickProviderVersionWithFallbackToLegacy");function Vp(t){return t.map(o=>is(o)).map(o=>o instanceof rs?o.id:o.config.type)}i(Vp,"configWalletsToWalletName");function Rr(t,e){return e.find(o=>o.name===t)?.displayName}i(Rr,"getBlockchainDisplayNameFor");function yt(t,e){return e.find(o=>o.name===t)?.shortName}i(yt,"getBlockchainShortNameFor");function Kp(t,e){return e.find(o=>o.name===t)?.logo}i(Kp,"getBlockchainImage");function Qn(t,e){return e.find(o=>o.id===t)?.title}i(Qn,"getSwapperDisplayName");function No(t,e){return e.find(o=>o.name===t)??null}i(No,"findBlockchain");function as(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(as,"isTokenNative");function St(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(St,"createTokenHash");function on(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(on,"isValidTokenAddress");function qn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(c=>{c.forEach(l=>{typeof l!="string"&&(l=St(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=St(p);delete n[u]})):a(l.tokens))}),Object.values(n)}i(qn,"matchTokensFromConfigWithMeta");function ei(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(ei,"getSupportedBlockchainsFromConfig");function Xp(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(Xp,"makeProvidersOptionsFromConfig");var nn={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"},tonConnect:{manifestUrl:"https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/manifests/tonconnect-manifest.json"}},BC={clientUrl:void 0},WC={liquiditySources:void 0};function jp(t){let e=Xp(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 NC(o).map(a=>a())}i(jp,"generateProviders");var Yp=i((t,e,o)=>{let n=jp({...nn,...t});return{config:{...nn,...t},iframe:BC,campaignMode:WC,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=qn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:c,tokensMapByTokenHash:s}}),p=qn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:c,tokensMapByTokenHash:s}});tn.set("supportedSourceTokens",l),tn.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=jp(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=Xp(a);return Gp({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as Zp}from"rango-types";var Jp=[Zp.EVM,Zp.SOLANA],ti="https://raw.githubusercontent.com/rango-exchange/assets/refs/heads/main/common/unknown-image.png";import{RangoClient as KC}from"rango-sdk";import{UI_ID as MC}from"@rango-dev/ui";var oi="c6381a79-2817-4602-83bf-6a641a409e32",Rp="https://api.rango.exchange",eu="https://explorer.rango.exchange",Re={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...MC};import{BlockchainCategories as OC,WalletState as lt}from"@rango-dev/ui";import{legacyReadAccountAddress as UC}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as zC,getCosmosExperimentalChainInfo as HC,isEvmAddress as QC,KEPLR_COMPATIBLE_WALLETS as _W,Networks as vu}from"@rango-dev/wallets-shared";import an from"bignumber.js";import{isCosmosBlockchain as qC}from"rango-types";import LC from"bignumber.js";var pe=new LC(0);import{WalletTypes as PC}from"@rango-dev/wallets-shared";var Bo="~",tu=[PC.LEAP];import{BlockchainCategories as ls,WalletState as FC}from"@rango-dev/ui";import{TransactionType as ni}from"rango-sdk";var ou="Roboto",ss=[{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 rn(t){return Array.from(new Set(t))}i(rn,"removeDuplicateFrom");function ri(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(ri,"debounce");function st(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(st,"containsText");function iu(t,e){return t.toLowerCase()===e.toLowerCase()}i(iu,"exactText");function au(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(au,"startWithText");var B=i(()=>document.getElementById(Re.SWAP_BOX_ID),"getContainer"),Wo=i(()=>document.getElementById(Re.EXPANDED_BOX_ID),"getExpanded");function su(t,e,o){let n=!!e&&iu(e,t),r=!!o&&iu(o,t);return n!==r?n?-1:1:0}i(su,"compareExactMatchText");function cs(t,e,o){let n=!!e&&st(e,t),r=!!o&&st(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(cs,"compareContainsText");function ps(t,e,o){let n=!!e&&au(e,t),r=!!o&&au(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ps,"compareStartWithText");function lu(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=ps(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=cs(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ps(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=cs(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=ps(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=cs(o,t.address,e.address);if(r!==0)return r}return 0}i(lu,"compareWithSearchFor");var ii=i((t,e)=>{switch(e){case ls.ALL:return!0;case ls.UTXO:return t===ni.TRANSFER;case ls.OTHER:return t!==ni.TRANSFER&&t!==ni.COSMOS&&t!==ni.EVM;default:return t===e}},"isBlockchainTypeInCategory"),cu=i(t=>ss.find(o=>o.value===t)?.url,"getFontUrlByName");function pu(t,e){let o=!!t.find(n=>n.state===FC.CONNECTED);return e===!1&&o}i(pu,"isSingleWalletActive");function uu(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(uu,"memoizedResult");function du(t,e){let o=new Set;return e.forEach(n=>{o.add(n.blockchain)}),t.filter(n=>o.has(n.name))}i(du,"filterBlockchainsWithAtLeastOneToken");import{BigNumber as ku}from"bignumber.js";function mu(t){return t.replace(/^0+(?=\d)/g,"")}i(mu,"removeLeadingZeros");function fu(t){return t.replace(/^\.(\d+)/,"0.$1")}i(fu,"ensureLeadingZeroForDecimal");function gu(t){return t.replace(/\B(?=(\d{3})+(?!\d))/g,",")}i(gu,"formatThousandsWithCommas");function hu(t){return t.replace(/\s+/g,"-")}i(hu,"replaceSpacesWithDash");function yu(t){return t.replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"")}i(yu,"stripTrailingZeros");function Su(t){return t=t.replace(/[^\d.]/g,"").replace(/\./g,(e,o,n)=>n.indexOf(".")===o?".":""),t}i(Su,"parseNumericValue");function ai(t){return/^0+(?:\.0+)?$/.test(t)}i(ai,"isZeroValue");function Cu(t,e=2){let o=`^(?:0|[1-9]\\d*)(?:\\.\\d{1,${e}})?$`;return new RegExp(o).test(t)}i(Cu,"isValidCurrencyFormat");function Tu(t){return/\d+$/.test(t)}i(Tu,"isColorKeyOverridden");var Gn=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"),_=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new ku(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new ku(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 si=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var Pt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),Vn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function wu(t){return ai(t)?"0":t.endsWith(".")?t.slice(0,-1):yu(t)}i(wu,"sanitizeInputAmount");function Kn(t,e){return VC(t,e)?lt.PARTIALLY_CONNECTED:e.connected?lt.CONNECTED:e.connecting?lt.CONNECTING:e.installed?lt.DISCONNECTED:lt.NOT_INSTALLED}i(Kn,"getWalletConnectionStatus");function xu(t,e,o,n){return o.filter(r=>!tu.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:d,properties:f,isHub:h}=e(r),g=rn(u.map(y=>y.type)),m=Kn(e(r),t(r));return{title:a,image:s,link:zC(c),state:m,type:r,showOnMobile:l,needsNamespace:p,blockchainTypes:g,needsDerivationPath:d,properties:f,isHub:h}})}i(xu,"mapWalletTypesToWalletInfo");function jn(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(jn,"walletAndSupportedChainsNames");function ds(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}=UC(l),d=c.length>0,f=c.includes(u),h=u===vu.Unknown;if(d&&!f&&!h)return;let m=u===vu.Unknown&&QC(p);if(h&&!m)return;o.includes(u)||m?r?s(u,p.toLowerCase(),r):c.filter(C=>o.includes(C)).forEach(C=>{s(C,p.toLowerCase())}):s(u,p)}),a}i(ds,"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 d=p.from.blockchain,f=p.to.blockchain,h=a===o.swaps.length-1,g=u===l.length-1;(!h&&!g||h&&c!==d||e==="all")&&n.add(d),e==="all"&&n.add(f)})}e==="all"&&n.add(c)}),Array.from(n)}i(Mo,"getQuoteChains");function Xn(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(Xn,"isAccountAndWalletMatched");var bu=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?us(n.usdValue,n.decimals):pe.toFixed();return o.plus(r)},new an(pe));return GC(e.toString())},"calculateWalletUsdValue");function GC(t){let e=t.toString().split(".");return e[0]&&(e[0]=gu(e[0])),e.join(".")}i(GC,"numberWithThousandSeparator");var pi=i((t,e)=>{let o=HC(Object.entries(t).map(([,n])=>n).filter(qC));return o&&!!o[e]?.experimental},"isExperimentalChain");function us(t,e){return new an(t).shiftedBy(-e).toFixed()}i(us,"representAmountInNumber");function ui(t){if(!t)return null;let e=us(t.amount,t.decimals),o=t.usdValue?us(t.usdValue,t.decimals):null,n=_(e,8,8),r=o?_(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(ui,"formatBalance");function Eu(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new an(t.usdValue).shiftedBy(-t.decimals):pe,n=e&&e.usdValue?new an(e.usdValue).shiftedBy(-e.decimals):pe;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new an(t.amount).shiftedBy(-t.decimals):pe,n=e&&e.amount?new an(e.amount).shiftedBy(-e.decimals):pe;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Eu,"compareTokenBalance");function qt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(qt,"areTokensEqual");function Iu(t){return t.sort((e,o)=>+(o.state===lt.CONNECTED)-+(e.state===lt.CONNECTED)||+(o.state===lt.PARTIALLY_CONNECTED)-+(e.state===lt.PARTIALLY_CONNECTED)||+(o.state===lt.DISCONNECTED||o.state===lt.CONNECTING)-+(e.state===lt.DISCONNECTED||e.state===lt.CONNECTING))}i(Iu,"sortWalletsBasedOnConnectionState");function lo(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(lo,"getConciseAddress");function Au({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Au,"getAddress");var Nu=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Bu(t){return t.map(e=>e.state).join("-")}i(Bu,"hashWalletsState");function Wu(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(Wu,"filterBlockchainsByWalletTypes");function Mu(t,e){return e===OC.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(ii(n,e))return!0;return!1})}i(Mu,"filterWalletsByCategory");function VC(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(VC,"checkIsWalletPartiallyConnected");var ms={API_KEY:oi};function Gt(t){return ms[t]||""}i(Gt,"getConfig");function Lu(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ms=e,ms}i(Lu,"initConfig");var Pu=20,_u=25,fs="theme-widget",gs=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>qt(n,t));else if(!Array.isArray(e)){let n=e[t.blockchain];if(n){o=!!n.tokens.some(a=>qt(a,t));let r=n.isExcluded;return!r&&!o||r&&o}}}return o},"isTokenExcludedInConfig"),hs=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Du=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var di,ct=i(()=>di||(di=new KC(Gt("API_KEY"),Gt("BASE_URL")),di),"httpService");import{i18n as Fu}from"@lingui/core";var mi=[.5,1,3],fi=1,sn=5,Yn=30,gi=0;var Xe=(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))(Xe||{});import{WidgetEvents as $u}from"@rango-dev/queue-manager-rango-preset";var ys=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ys||{}),Ss=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(Ss||{}),Cs=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(Cs||{}),ln=(a=>(a[a.RouteEvent=$u.RouteEvent]="RouteEvent",a[a.StepEvent=$u.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(ln||{});function hi(t,e){let o=t.map(a=>a.swapperGroup),n=[];return rn(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(hi,"getUniqueSwappersGroups");function Ou(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Ou,"sortLiquiditySourcesByGroupTitle");function et(t,e){return e?.[t]==="hidden"}i(et,"isFeatureHidden");function cn(t,e){return e?.[t]==="enabled"}i(cn,"isRoutingEnabled");var Uu=i((t,e,o)=>et("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");function pn(t){return t==gi?{type:"error",message:Fu.t("Slippage must be greater than or equal to 0.01")}:t>sn&&t<=Yn?{type:"warning",message:Fu.t("Your transaction is at risk of being frontrun due to high slippage tolerance."),quoteValidation:{type:3,slippage:t.toString()}}:null}i(pn,"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=ei({config:a}),p=r;return l.length>0&&(p=p.filter(u=>l.includes(u.name))),p.filter(u=>Jp.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",d=tn.get(u);d?.length||(d=qn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),tn.set(u,d)),d=Uu(d,s,a.features);let f=e().blockchains({type:o.type});return d.filter(g=>o.blockchain&&g.blockchain!==o.blockchain||!f.some(m=>m.name===g.blockchain)?!1:o.searchFor?!!(st(g.symbol,o.searchFor)||st(g.address||"",o.searchFor)||st(g.name||"",o.searchFor)):!0).sort((g,m)=>{let y=e().isTokenPinned(g,o.type),S=e().isTokenPinned(m,o.type);if(y!==S)return y?-1:1;if(o.getBalanceFor){let I=o.getBalanceFor(g),A=o.getBalanceFor(m),b=Eu(I,A);if(b!==0)return b}let C=l.get(g.blockchain),k=l.get(m.blockchain),x=as(g,C),w=as(m,k);if(x!==w)return x?-1:1;if(g.isPopular!==m.isPopular)return g.isPopular?-1:1;if(o.searchFor){let I=lu(g,m,o.searchFor);if(I)return I}return g.isSecondaryCoin!==m.isSecondaryCoin?g.isSecondaryCoin?1:-1:C&&k?C.sort-k.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=St(o),s=n.get(a);return s||(s=r.find(c=>St(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=>qt(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(Ou)},fetch:async()=>{try{let{routing:o}=e().config,n=cn("enableCentralizedSwappers",o),r=await ct().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,c={},l=r.popularTokens,p=r.swappers.filter(d=>d.enabled);r.blockchains.sort((d,f)=>d.sort-f.sort).forEach(d=>{d.enabled&&a.set(d.name,d)}),r.tokens.forEach(d=>{let f=St(d);c[d.blockchain]||(c[d.blockchain]=[]),s.set(f,d),c[d.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 jC,Catalonia as XC,Chinese as Hu,Denmark as YC,English as ZC,Finland as JC,French as RC,German as eT,Greece as tT,Hungary as oT,India as nT,Indonesian as rT,Italian as iT,Japanese as aT,Korea as sT,Lithuania as lT,Malay as cT,Netherlands as pT,Pakistan as uT,Philippines as dT,Poland as mT,Portuguese as fT,Russian as gT,SaudiArabia as hT,Serbia as yT,Slovakia as ST,SouthAfrica as CT,Spanish as TT,Swahili as kT,Swedish as wT,Thai as vT,Turkish as xT,Ukrainian as bT,Vietnamese as ET}from"@rango-dev/ui";var Qu=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:CT},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:hT},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:jC},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:XC},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Hu},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Hu},{title:"Danish",label:"Dansk",local:"da",SVGFlag:YC},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:pT},{title:"English",label:"English",local:"en",SVGFlag:ZC},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:dT},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:JC},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:RC},{title:"German",label:"Deutsch",local:"de",SVGFlag:eT},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:tT},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:nT},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:oT},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:rT},{title:"Italian",label:"Italiana",local:"it",SVGFlag:iT},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:aT},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:sT},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:lT},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:cT},{title:"Polish",label:"Polski",local:"pl",SVGFlag:mT},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:fT},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:gT},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:yT},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:ST},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:TT},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:kT},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:wT},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:vT},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:xT},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:bT},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:uT},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:ET}],un="en";var qu=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:fi,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=rn(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=et("theme",n),s=et("language",n),c=et("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||un},...c&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||un}})},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=ei({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import bs from"bignumber.js";import IT from"mitt";var ve=IT(),AT={on:ve.on,off:ve.off};var Gu=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 Vu from"bignumber.js";function Vt(t){return`${t.blockchain}${Bo}${t.address}${Bo}${t.symbol}`}i(Vt,"createAssetKey");function Ku(t,e){return`${Vt(e)}${Bo}${t}`}i(Ku,"createBalanceKey");function Zn(t){let[e,o,n]=t.split(Bo);return!e||!o||!n?null:{address:o==="null"?null:o,blockchain:e,symbol:n}}i(Zn,"extractAssetFromBalanceKey");function ks(t,e,o){return e.balances?.forEach(n=>{let r=n.price??t.findToken(n.asset)?.usdPrice;t._aggregatedBalances[Vt(n.asset)]?.forEach(s=>{o[s]&&(o[s]={...o[s],usdValue:r?new Vu(r??pe).multipliedBy(o[s].amount).toString():""})})}),o}i(ks,"computeNextBalancesWithNewPrices");function ws(t,e){let o={};return t.balances?.forEach(n=>{let r=Ku(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,c=n.price??e().findToken(n.asset)?.usdPrice,l=c?new Vu(c??pe).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:l};o[r]=p}),o}i(ws,"createBalanceStateForNewAccount");function vs(t,e){for(let o in e){let n=Zn(o);if(n){let r=Vt(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}}return t}i(vs,"updateAggregatedBalanceStateForNewAccount");function NT(t,e){let o=Zn(e);if(!o)return t;let n=Vt(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(NT,"removeBalanceFromAggregatedBalance");function xs(t,e,o){let n=t.connectedWallets.filter(l=>l.walletType===e);t.connectedWallets.forEach(l=>{l.walletType!==e&&(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=Zn(l);if(!p)return;!!n.find(d=>Ku(d.address,{address:p.address,blockchain:d.chain,symbol:p.symbol})===l)?a=NT(a,l):s[l]&&(r[l]=s[l])}),{_balances:r,_aggregatedBalances:a}}i(xs,"computeNextStateAfterWalletBalanceRemoval");function BT(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(BT,"matchWalletDetailsWithConnectedWallet");var WT=uu(),ju=Gu((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,lastUpdatedAt:+new Date,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>o.find(a=>Xn(a,r))?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>o.find(s=>Xn(s,a))?{...a,loading:!1,error:!1,explorerUrl:BT(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>o.find(a=>Xn(a,r))?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n,r)=>{let a=e().connectedWallets,s=o.filter(c=>!a.some(l=>Xn(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(d=>d.walletType===u.walletType&&d.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 ct().getMultipleTokenBalance({assets:p.map(({symbol:d,address:f,blockchain:h})=>({symbol:d,address:f,blockchain:h})),walletAddress:l});if(u){let d=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},m={_aggregatedBalances:e()._aggregatedBalances,findToken:e().findToken};ks(m,g,d);let y=ws(g,e);f=vs(f,y),d={...d,...y}}),t(h=>({_balances:{...h._balances,...d},_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)=>{let a=o[0];a&&(ve.emit("walletEvent",{type:"connect",payload:{walletType:a.walletType,accounts:o}}),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}=xs(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(ve.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=o[0].walletType;e().setConnectedWalletAsRefetching(o);let a=o.map(l=>({address:l.address,blockchain:l.chain})),s;try{s=await ct().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(d=>{if(d.failed)return;let f={_balances:l,_aggregatedBalances:p,connectedWallets:e().connectedWallets,findToken:e().findToken};ks(f,d,l);let{_balances:h,_aggregatedBalances:g}=xs(f,r,{chains:[d.blockChain]});if(p=g,l=h,!e().connectedWallets.find(y=>y.walletType===r&&y.address===d.address&&y.chain===d.blockChain))return;let m=ws(d,e);p=vs(p,m),l={...l,...m}}),t(d=>({_balances:{...d._balances,...l},_aggregatedBalances:p})),e().setConnectedWalletRetrievedData(o,c);let{retryOnFailedBalances:u=!0}=n||{};if(u){let d=c.filter(f=>f.failed).map(f=>({chain:f.blockChain,walletType:r,address:f.address}));d.length>0&&await e().fetchMainTokensBalances(d,{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=Vt(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 d=new bs(u.amount),f=new bs(l.amount);d.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(Bo);return l&&p===o&&(s[c]=l),s},{})},getConnectedWalletsDetails:()=>WT(()=>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=Zn(c);if(p&&p.blockchain===n.chain&&l){let u=e().findToken(p),d=l?.amount?new bs(l.amount).shiftedBy(-l.decimals):pe;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:l.amount,decimal:l.decimals,amount:d.toString(),isSupported:!!u,logo:u?.image||null,usdPrice:u?.usdPrice||null})}return s},[])}}),e().lastUpdatedAt)}));function Xu(t){return MT()(LT((...e)=>({...ju(...e),...zu(...e),...qu(...e),...Yp(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(Xu,"createAppStore");var Yu=_T(null);function T(){let t=DT(Yu);if($T(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(T,"useAppStore");function Zu(t){let e=FT();return e.current||(e.current=Xu(t.config)),PT.createElement(Yu.Provider,{value:e.current},t.children)}i(Zu,"AppStoreProvider");function bt(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=T(),{state:r,getWalletInfo:a}=OT(),s=T().blockchains(),{handleDisconnect:c}=en(),l=Vp(n()),p=xu(r,a,l,e);p=UT()?p.filter(m=>m.showOnMobile!==!1&&r(m.type).installed):p;let u=Iu(p),d=i(m=>!o.find(y=>y.walletType===m&&y.chain===e),"isExperimentalChainNotAdded"),f=HT(()=>{let m=p?.filter(y=>y.state===Es.CONNECTING)||[];for(let y of m)c(y)},[Bu(p)]);QT(()=>()=>{f()},[]);let h=i(m=>{let y=m.find(C=>C.type===Jn.DEFAULT);return!y||y.state===Es.NOT_INSTALLED?!1:m.filter(C=>C.state!=Es.NOT_INSTALLED&&![Jn.DEFAULT,Jn.WALLET_CONNECT_2,Jn.LEDGER].includes(C.type)&&a(C.type).supportedChains.filter(k=>k.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),g=i((m,y,S)=>pi(S,y)&&d(m)&&!zT.includes(m)||m==Jn.DEFAULT&&!h(p),"shouldExcludeWallet");return{list:u.filter(m=>!g(m.type,e??"",s)),terminateConnectingWallets:f}}i(bt,"useWalletList");import{Modal as KT}from"@rango-dev/ui";import jT from"react";import{create as VT}from"zustand";var Ju="rango-widget";var Rn=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(Ju),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 GT=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"),co=GT;var ne=co(VT()((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})}}))),Po=new Rn({onInit:()=>ne.setState({tabManagerInitiated:!0}),onClaim:()=>ne.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>ne.setState({isActiveTab:!1})});function ee(t){let{watermark:e}=ne();return jT.createElement(KT,{hasWatermark:e==="FULL",...t},t.children)}i(ee,"WatermarkedModal");import{i18n as fn}from"@lingui/core";import{Alert as lk,Button as ck,Divider as gn,Image as pk,MessageBox as uk,RadioRoot as dk,WalletImageContainer as mk}from"@rango-dev/ui";import le,{useEffect as fk,useMemo as gk,useState as hk}from"react";import{i18n as JT}from"@lingui/core";import{Typography as ad}from"@rango-dev/ui";import dn from"react";function yi(t,e){return t.find(o=>o.name===e)?.logo}i(yi,"getBlockchainLogo");import{darkTheme as XT,Image as YT,styled as Kt,Typography as ZT}from"@rango-dev/ui";var Si=Kt("li",{backgroundColor:"$neutral200",padding:"$16",borderRadius:"$sm",variants:{clickable:{true:{cursor:"pointer"}},hasError:{true:{background:"$error100",[`.${XT} &`]:{backgroundColor:"$error700"}}},unsupported:{true:{cursor:"not-allowed",paddingTop:"$8",paddingBottom:"$8"}}}}),Ci=Kt("div",{display:"flex",gap:"$8",alignItems:"center"}),ed=Kt("div",{flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between",height:"$40",variants:{showSupportedChains:{true:{justifyContent:"space-between"},false:{justifyContent:"center"}}}}),td=Kt("div",{flex:"1",display:"flex",alignItems:"center",gap:"$4",opacity:"0.5"}),od=Kt("div",{display:"flex",gap:"$6",alignItems:"center"}),nd=Kt("div",{paddingLeft:"48px"}),rd=Kt("div",{display:"flex",gap:"$2",cursor:"pointer",alignItems:"center",width:"fit-content"}),id=Kt(ZT,{maxWidth:"100px"}),Ti=Kt(YT,{variants:{disabled:{true:{opacity:"0.5"}}}});function ki(t){let{namespace:e}=t,o=T().blockchains();return dn.createElement(Si,{unsupported:!0},dn.createElement(Ci,null,dn.createElement(Ti,{src:yi(o,e.id),size:40,disabled:!0}),dn.createElement(td,null,dn.createElement(ad,{variant:"label",size:"large"},e.label),dn.createElement(ad,{variant:"body",size:"xsmall"},JT.t("(Currently not supported)")))))}i(ki,"NamespaceUnsupportedItem");import{Checkbox as ik,Radio as ak}from"@rango-dev/ui";import Bs from"react";import{i18n as Ns}from"@lingui/core";import{ChevronDownIcon as ek,ChevronUpIcon as tk,Divider as ok,Typography as er}from"@rango-dev/ui";import Ae,{useEffect as nk,useState as rk}from"react";import{Image as ld,Tooltip as cd,Typography as RT}from"@rango-dev/ui";import _t from"react";import{styled as sd}from"@rango-dev/ui";var Is=sd("div",{display:"flex",alignItems:"center",padding:0,margin:0}),wi=sd("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 As=3;function pd(t){let{chains:e}=t;return _t.createElement(Is,{id:"widget-supported-chains-container"},e.slice(0,As).map((o,n)=>_t.createElement(cd,{key:o.name,container:B(),side:"bottom",align:"start",content:o.name,sideOffset:4},_t.createElement(wi,{firstItem:n===0},_t.createElement(ld,{src:o.logo,size:15})))),e.length>As&&_t.createElement(cd,{container:B(),side:"bottom",align:"start",sideOffset:4,content:_t.createElement(Is,null,e.map((o,n)=>_t.createElement(wi,{key:o.name,firstItem:n===0},_t.createElement(ld,{src:o.logo,size:15}))))},_t.createElement(wi,null,_t.createElement(RT,{variant:"body",size:"xsmall"},"+",e.length-As))))}i(pd,"SupportedChainsList");function _o(t){let{namespace:e,error:o,suffix:n,connected:r,address:a,onClick:s}=t,[c,l]=rk(!1),p=T().blockchains();nk(()=>l(!1),[o]);let u=e.getSupportedChains(p),d=!o&&!r&&u.length>1;return Ae.createElement(Si,{hasError:!!o,clickable:!!s,onClick:s},Ae.createElement(Ci,null,Ae.createElement(Ti,{src:yi(p,e.id),size:40}),Ae.createElement(ed,{showSupportedChains:d||r||!!o},Ae.createElement(od,null,Ae.createElement(er,{variant:"label",size:"large"},e.label),r&&Ae.createElement(er,{variant:"body",size:"small",color:"success500"},Ns.t("Connected")),!!o&&Ae.createElement(er,{variant:"body",size:"small",color:"error500"},Ns.t("Connection failed"))),d&&Ae.createElement(pd,{chains:u}),r&&Ae.createElement(id,{variant:"body",size:"small",color:"neutral700"},a),o&&Ae.createElement(rd,{onClick:()=>l(f=>!f)},Ae.createElement(er,{variant:"body",size:"small",color:"neutral700",style:{textDecoration:"underline",userSelect:"none",textDecorationSkipInk:"none"}},Ns.t("See why")),c?Ae.createElement(tk,{size:12,color:"gray"}):Ae.createElement(ek,{size:12,color:"gray"}))),n),!!o&&c&&Ae.createElement(Ae.Fragment,null,Ae.createElement(ok,{size:4}),Ae.createElement(nd,null,Ae.createElement(er,{variant:"body",size:"small",color:"neutral700"},o))))}i(_o,"NamespaceItem");function ud(t){let{onClick:e,type:o,namespace:n}=t;return Bs.createElement(_o,{namespace:n,onClick:e,suffix:o==="radio"?Bs.createElement(ak,{value:n.value}):Bs.createElement(ik,{checked:t.value})})}i(ud,"NamespaceListItem");import{Button as sk,styled as dd}from"@rango-dev/ui";var vi=dd("ul",{padding:0,paddingBottom:"$20",margin:0}),mn=dd(sk,{minHeight:"$40"});function tr(t){let{targetWallet:e}=t.value,o=e.properties?.find(m=>m.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]=hk([]),u=gk(()=>a?.data.filter(m=>!m.unsupported),[e?.type]),d=i(m=>{p(r?[m]:y=>y.includes(m)?y.filter(S=>S!==m):y.concat(m))},"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(m=>m.value))},"onSelectAll"),g=i(m=>r?le.createElement(dk,{value:l?.[0]},m):le.createElement(le.Fragment,null,m),"wrapRadioRoot");return fk(()=>{if(!r&&u)if(t.value.defaultSelectedChains?.length){let m=u.filter(y=>y.getSupportedChains(c).some(S=>t.value.defaultSelectedChains?.includes(S.name)));p(m.map(y=>y.value))}else p(u.map(m=>m.value))},[]),le.createElement(le.Fragment,null,le.createElement(uk,{type:"info",title:fn.t("Connect {wallet}",{wallet:e.title}),description:fn.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect."),icon:le.createElement(mk,null,le.createElement(pk,{src:s,size:45}))}),r?le.createElement(le.Fragment,null,le.createElement(gn,{size:20,className:"_initial_namespace_list_header_alert_top_divider"}),le.createElement(lk,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:fn.t("This wallet can only connect to one chain at a time. ")}),le.createElement(gn,{size:30,className:"_initial_namespace_list_header_alert_bottom_divider"})):le.createElement(le.Fragment,null,le.createElement(gn,{size:30,className:"_initial_namespace_list_header_button_top_divider"}),le.createElement(ck,{style:{marginLeft:"auto"},id:"widget-name-space-select-all-btn",size:"xsmall",variant:"ghost",type:"primary",onClick:h},f?fn.t("Deselect all"):fn.t("Select all")),le.createElement(gn,{size:10,className:"_initial_namespace_list_header_button_bottom_divider"})),le.createElement(vi,null,g(le.createElement(le.Fragment,null,a?.data.map((m,y,S)=>le.createElement(le.Fragment,{key:m.id},m.unsupported?le.createElement(ki,{namespace:m}):le.createElement(ud,{value:l.includes(m.value),namespace:m,type:r?"radio":"checkbox",onClick:()=>d(m.value)}),y!==S.length-1&&le.createElement(gn,{size:10})))))),le.createElement(gn,{size:20}),le.createElement(mn,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!l.length,onClick:()=>t.onConfirm(l)},fn.t("Connect")))}i(tr,"Namespaces");import{i18n as or}from"@lingui/core";import{Alert as vk,Button as xk,Divider as hn,Image as bk,MessageBox as Ek,WalletImageContainer as Ik}from"@rango-dev/ui";import{useWallets as Ak}from"@rango-dev/wallets-react";import de from"react";import{styled as yk}from"@rango-dev/ui";var md=yk("div",{display:"flex",justifyContent:"end"});import{i18n as Ws}from"@lingui/core";import{Button as Sk,Spinner as Ck}from"@rango-dev/ui";import Ms,{useLayoutEffect as Tk,useRef as kk,useState as wk}from"react";function fd(t){let{namespace:e,initialConnect:o,disabled:n,state:r,handleConnect:a,handleDisconnect:s}=t,[c,l]=wk(null),p=kk(!1);Tk(()=>{o&&!p.current&&u()},[]);let u=i(async g=>{try{p.current=!0,await a(g)}catch(m){l(m)}finally{p.current=!1}},"handleConnectNamespace"),d=i(async()=>{l(null),r.connected?await s():u({shouldAskForDerivationPath:!0})},"handleButtonClick"),f=i(()=>{let g=r.accounts?.[0]?.split(":"),m=g?.[g.length-1];return!r.connected||!m?null:lo(m)},"getConnectedAddress"),h=i(()=>r.connected?Ws.t("Disconnect"):c?Ws.t("Try again"):Ws.t("Connect"),"getButtonText");return Ms.createElement(_o,{namespace:e,connected:r.connected,error:c?.message,address:f(),suffix:r.connecting?Ms.createElement(Ck,{color:"info"}):Ms.createElement(Sk,{id:"widget-name-space-connect-btn",variant:"ghost",type:r.connected?"error":"primary",size:"xsmall",onClick:async()=>d(),disabled:n},h())})}i(fd,"NamespaceDetachedItem");function nr(t){let{value:e,selectedNamespaces:o,onConfirm:n,confirmText:r=or.t("Done"),onDisconnectWallet:a,navigateToDerivationPath:s}=t,{targetWallet:c}=e,{connect:l,disconnect:p,state:u}=Ak(),d=c.type,f=u(d),h=c.properties?.find(x=>x.name==="namespaces"),g=c.properties?.find(x=>x.name==="derivationPath"),m=h?.value.selection==="single",y=i(async(x,w)=>{m&&await p(d),g&&w?.shouldAskForDerivationPath?s(x):await l(d,[{namespace:x,network:"",derivationPath:w?.derivationPath??void 0}])},"handleConnectNamespace"),S=i(async x=>{await p(d,[x])},"handleDisconnectNamespace"),C=i(()=>m?de.createElement(de.Fragment,null,de.createElement(hn,{size:20,className:"_detached_namespace_list_header_alert_top_divider"}),de.createElement(vk,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:or.t("This wallet can only connect to one chain at a time.")}),de.createElement(hn,{size:30,className:"_detached_namespace_list_header_alert_bottom_divider"})):de.createElement(de.Fragment,null,de.createElement(hn,{size:30,className:"_detached_namespace_list_header_button_top_divider"}),de.createElement(md,null,de.createElement(xk,{id:"widget-detached-disconnect-wallet-btn",variant:"ghost",type:"error",size:"xsmall",disabled:f.connecting||!f.connected,onClick:a},or.t("Disconnect wallet"))),de.createElement(hn,{size:16,className:"_detached_namespace_list_header_button_bottom_divider"})),"renderNamespaceListHeader"),k=i(x=>{if(x.unsupported)return de.createElement(ki,{namespace:x});let w=o?.find(b=>b.namespace===x.value),I=f.namespaces?.get(x.value);if(!I)throw new Error(`State for ${x.value} was not found!`);let A=m&&f.connecting;return de.createElement(fd,{namespace:x,initialConnect:!!w,disabled:A,state:I,handleConnect:async b=>y(x.value,{derivationPath:w?.derivationPath,shouldAskForDerivationPath:b?.shouldAskForDerivationPath}),handleDisconnect:async()=>S(x.value)})},"renderNamespaceItem");return de.createElement(de.Fragment,null,de.createElement(Ek,{type:"info",title:or.t("Connect {wallet}",{wallet:c.type}),description:or.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect or disconnect."),icon:de.createElement(Ik,null,de.createElement(bk,{src:c.image,size:45}))}),C(),de.createElement(vi,{id:"widget-detached-namespace-list"},c.needsNamespace?.data.map((x,w,I)=>de.createElement(de.Fragment,{key:x.id},k(x),w!==I.length-1&&de.createElement(hn,{size:10})))),de.createElement(hn,{size:20}),de.createElement(mn,{id:"widget-name-space-confirm-btn",type:"primary",onClick:n},r))}i(nr,"Detached");import{i18n as yn}from"@lingui/core";import{Divider as Mk,Image as Lk,MessageBox as Pk,Select as _k,TextField as Dk}from"@rango-dev/ui";import Et,{useEffect as $k,useState as hd}from"react";import{namespaces as Nk}from"@rango-dev/wallets-shared";var xi={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Ls(t){let e=t?Nk[t]?.derivationPaths:null;return e?[...e,xi]:[]}i(Ls,"getDerivationPaths");import{Button as Bk,styled as Ps,Typography as Wk}from"@rango-dev/ui";var gd=Ps("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),_s=Ps(Wk,{paddingLeft:"$10"}),Ds={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"},s_=Ps(Bk,{minHeight:"$40"});var yd="0";function rr(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=hd(null),[c,l]=hd(yd),p=a===xi.id,u=Ls(o),d=i(({value:h})=>{let g=u?.find(m=>m.id===h);g&&(a===xi.id&&Number.isNaN(Number(c))&&l(yd),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 $k(()=>{s(Ls(o)[0]?.id||null)},[o]),Et.createElement(Et.Fragment,null,Et.createElement(Pk,{type:"info",title:yn.t("Select Derivation Path"),description:yn.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Et.createElement(Lk,{src:n,size:45})}),Et.createElement(gd,{className:"_derivation_path_inputs_container"},Et.createElement(_s,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},yn.t("Choose Derivation Path Template")),Et.createElement(_k,{id:"widget-derivation-path-template-select",value:a||"",options:u.map(h=>({value:h.id,label:h.label})),variant:"filled",handleItemClick:d,styles:{trigger:Ds}}),Et.createElement(Mk,{size:20}),Et.createElement(_s,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},p?yn.t("Enter Path"):yn.t("Enter Index")),Et.createElement(Dk,{id:"widget-derivation-path-template-input",type:p?"text":"number",variant:"contained",value:c,onChange:h=>l(h.target.value),style:Ds})),Et.createElement(mn,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:f,disabled:!u||!a||!c},yn.t("Confirm")))}i(rr,"DerivationPath");import{i18n as Sn}from"@lingui/core";import{Image as Uk,MessageBox as Fs,WalletImageContainer as zk,WalletState as Hk}from"@rango-dev/ui";import{useWallets as Qk}from"@rango-dev/wallets-react";import Do from"react";import{keyframes as Fk,styled as $s}from"@rango-dev/ui";var S_=$s("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Sd=$s("div",{position:"relative"}),Ok=Fk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Cd=$s("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${Ok} 1s linear infinite`,top:0,bottom:0,right:0,left:0});function Os(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a,getWalletInfo:s}=Qk();return Kn(s(n),a(n))===Hk.CONNECTED?Do.createElement(Fs,{type:"success",title:Sn.t("Wallet Connected"),description:Sn.t("Your wallet is connected, you can use it to swap.")}):o?Do.createElement(Fs,{type:"error",title:Sn.t("Failed to Connect"),description:o||Sn.t("Your wallet is not connected. Please try again.")}):Do.createElement(Fs,{type:"loading",title:Sn.t("Connecting to your wallet"),description:Sn.t("Click connect in your wallet popup."),icon:Do.createElement(Sd,null,Do.createElement(zk,null,Do.createElement(Uk,{src:r,size:45})),Do.createElement(Cd,null))})}i(Os,"ConnectStatus");import{i18n as Us}from"@lingui/core";import{Button as qk,Divider as Td,MessageBox as Gk}from"@rango-dev/ui";import bi from"react";function zs(t){let{displayName:e,onConfirm:o,id:n}=t;return bi.createElement(Gk,{id:n,title:Us.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:Us.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},bi.createElement(Td,{size:18}),bi.createElement(Td,{size:32}),bi.createElement(qk,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},Us.t("Confirm")))}i(zs,"ExperimentalChain");function kd(t,e){return t().status==="init"&&!!e}i(kd,"isOnStatus");function ir(t){return t().status==="namespace"}i(ir,"isOnNamespace");function ar(t){return t().status==="derivationPath"}i(ar,"isOnDerivationPath");function Ao(t){return t().status==="detached"}i(Ao,"isOnDetached");var Xk=3e3,Yk=300;function sr(t){let e=jk(),[o,n]=wd(!1),[r,a]=wd(),s=i(w=>{a(w.message)},"catchErrorOnHandle"),{terminateConnectingWallets:c}=bt(),{handleConnect:l,handleDerivationPath:p,handleNamespace:u,getState:d,resetState:f,handleDisconnect:h}=en(),g=i(w=>{u(t.wallet,w).then(k).catch(s)},"handleConfirmNamespaces"),m=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",b=["disconnected","disconnected-unhandled"].includes(w.status);A?(t.onConnect?.(),I||(e.current=setTimeout(S,Xk))):b&&S()},"afterConnected"),x=i(w=>{t.wallet?.needsDerivationPath&&u(t.wallet,[w])},"handleNavigateToDerivationPath");return Kk(()=>{if(t.wallet){C();let w=!1,I=!0;i(()=>{setTimeout(()=>{I=!1,w||n(!0)},Yk)},"beforeConnecting")(),l(t.wallet,{disconnectIfConnected:!0,defaultSelectedChains:t.options?.defaultSelectedChains}).then(b=>{["namespace","Detached","derivation-path"].includes(b.status)||(w=!0),k(b,I)}).catch(s)}},[t.wallet]),po.createElement(ee,{id:t.id,open:o,onClose:S,onExit:()=>{C(),c(),t.onClose&&t.onClose()},container:B()},kd(d,t.wallet)&&po.createElement(po.Fragment,null,po.createElement(Os,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),po.createElement(Vk,{direction:"vertical",size:32})),ir(d)&&po.createElement(tr,{onConfirm:g,value:d().namespace}),ar(d)&&po.createElement(rr,{onConfirm:y,value:d().derivationPath}),Ao(d)&&po.createElement(nr,{onConfirm:m,onDisconnectWallet:()=>void h(d().namespace.targetWallet),value:d().namespace,selectedNamespaces:d().selectedNamespaces,navigateToDerivationPath:x}))}i(sr,"StatefulConnectModal");import es from"react";import Zk,{Fragment as Jk}from"react";import{MemoryRouter as Rk,useInRouterContext as ew}from"react-router";function Ei({children:t}){let o=ew()?Jk:Rk;return Zk.createElement(o,null,t)}i(Ei,"AppRouter");import{I18nManager as tB}from"@rango-dev/ui";import Pp from"react";import Ue from"react";import{useRoutes as L0}from"react-router-dom";var $={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as Tn,useRef as Li}from"react";import ot from"bignumber.js";import{create as tm}from"zustand";import{subscribeWithSelector as om}from"zustand/middleware";import{createContext as tw,useContext as ow}from"react";var vd=tw({swapMode:"swap",isMultiMode:!1});function tt(){let{swapMode:t,isMultiMode:e}=ow(vd);return{swapMode:t,isMultiMode:e}}i(tt,"useSwapMode");import{i18n as Tt}from"@lingui/core";import{getRelatedWalletOrNull as iw,RouteEventType as _D}from"@rango-dev/queue-manager-rango-preset";import He from"bignumber.js";import{PendingSwapNetworkStatus as cr}from"rango-types";import{i18n as ze}from"@lingui/core";var re=i(()=>({genericServerError:ze.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:ze.t("Please reset your liquidity sources."),description:ze.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:ze.t("No Routes Found."),description:ze.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:ze.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:ze.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:ze.t("High Price Impact"),title:ze.t("Price impact is too high!"),description:ze.t("The price impact is significantly higher than the allowed amount."),confirmMessage:ze.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:ze.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:ze.t("USD Price Unknown"),title:ze.t("USD Price Unknown, Cannot calculate Price Impact."),description:ze.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:ze.t("Confirm USD Price Unknown")}}),"errorMessages");function xd(t){return t.type===0?t.diagnosisMessage??re().noResultError.title:t.type===1?t.diagnosisMessage??re().genericServerError:""}i(xd,"getQuoteErrorMessage");import{i18n as Ii}from"@lingui/core";var $o=i(()=>({connectWallet:Ii.t("Connect Wallet"),swap:Ii.t("Swap"),swapAnyway:Ii.t("Swap anyway"),ethWarning:Ii.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function Hs(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(Hs,"getFeeLabel");var Qs=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],bd=100,Ed=30,Id=15,Ad=60;var Nd=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Bd=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as rw}from"@rango-dev/queue-manager-rango-preset";import kD from"bignumber.js";function Md(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(Md,"getRequiredBalanceOfWallet");function Xt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Xt,"getPriceImpactLevel");function Ai(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=rw(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=No(a?a.toBlockchain:n.fromBlockchain,e),l=No(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),d=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:c,fromToken:p,toBlockchain:l,toToken:u,inputAmount:d}}i(Ai,"createRetryQuote");function Cn(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=lr(o),s=Ct(o);if(o&&a&&s){let p=jt(a.toString(),s.toString());if(!!p&&$d(a,p)){let d=Bi(o?.swaps,n),f=Xt(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:d,warningLevel:f}}}if(e&&Ud(e,o))return{type:4,usdValueChange:_(Ct(o)?.minus(Ct(e)??0).toString()??"0",null,2),percentageChange:_(jt(Ct(e)??"1",Ct(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let c=Wi(o.swaps),l=r>sn;if(Od(t.userSlippage.toString(),c)){if(l&&parseFloat(c??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:Fd(o,r),minRequiredSlippage:c};return null}i(Cn,"generateQuoteWarnings");function Ld(t){return![4].includes(t.type)}i(Ld,"isQuoteWarningConfirmationRequired");function jt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:qs(t.toString(),e.toString());return n&&n<0?n:null}i(jt,"getPriceImpact");var Pd=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"),Ni=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"),_d=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"),Dd=i(t=>{let e=i((o,n)=>{let r=Qs.indexOf(o.value),a=Qs.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function $d(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Nd.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new He(r)))}i($d,"hasHighValueLoss");function zd(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new He(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new He(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(zd,"hasLimitError");function Hd(t){let e=(t||[]).filter(c=>{let l=c.fromAmountMinValue?new He(c.fromAmountMinValue):null,p=c.fromAmountMaxValue?new He(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 He(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new He(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=Tt.t({id:"Required: >= {min} {symbol}",values:{min:_(o,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=Tt.t({id:"Required: > {min} {symbol}",values:{min:_(o,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=Tt.t({id:"Required: <= {max} {symbol}",values:{max:_(n,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=Tt.t({id:"Required: < {max} {symbol}",values:{max:_(n,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(Hd,"getLimitErrorMessage");function Qd(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:c,needsToWarnEthOnPath:l}=t;return e!=="success"?{title:$o().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||c||!r||r==="0"?{title:$o().swap,action:"confirm-swap",disabled:!0}:s?{title:$o().swapAnyway,action:"confirm-warning",disabled:!1}:l?{title:$o().ethWarning,action:"confirm-warning",disabled:!1}:{title:$o().swap,action:"confirm-swap",disabled:!1}:{title:$o().connectWallet,action:"connect-wallet",disabled:!1}}i(Qd,"getSwapButtonState");function Gs(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(pe))&&e&&e!=="0"&&n!==0)}i(Gs,"canComputePriceImpact");function Vs(t,e){let o=pe;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 He(r.amount).multipliedBy(a||0))}return o}i(Vs,"getUsdFeeOfStep");function Bi(t,e){return t.reduce((o,n)=>o.plus(Vs(n,e)),pe)}i(Bi,"getTotalFeeInUsd");function Ks(t){let e=pe,o=new He(t.price||0);return e=e.plus(new He(t.amount).multipliedBy(o)),e}i(Ks,"getUsdFee");function qd(t){return t.reduce((e,o)=>e.plus(Ks(o)),pe)}i(qd,"getTotalFeesInUsd");function Gd(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(Gd,"getFeesGroup");function Vd(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(Vd,"checkSlippageErrors");function Fd(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(Fd,"checkSlippageWarnings");function Wi(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(Wi,"getMinRequiredSlippage");function Od(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(Od,"hasProperSlippage");function Kd(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:c,excludeLiquiditySources:l,slippage:p,affiliateRef:u,affiliatePercent:d,affiliateWallets:f,destination:h,contractCall:g}=t,m=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:d??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:m??{},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(Kd,"createQuoteRequestBody");function jd(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType,derivationPath:n.derivationPath},o),{})}i(jd,"getWalletsForNewSwap");function lr(t){let e=t.requestAmount,o=t.swaps[0]?.from.usdPrice;if(!(!e||!o))return new He(e).multipliedBy(o)}i(lr,"getUsdInputFrom");function Ct(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1]?.to.usdPrice;if(!(!e||!o))return new He(e).multipliedBy(o)}i(Ct,"getUsdOutputFrom");function qs(t,e){return new He(e).div(new He(t)).minus(1).multipliedBy(bd).toNumber()}i(qs,"getPercentageChange");function Ud(t,e){let o=lr(t),n=Ct(t),r=Ct(e);if(!o||!n||!r)return!1;let a=qs(n.toString(),r.toString());return Bd.some(({threshold:s,minInput:c})=>a<=s&&o.isGreaterThanOrEqualTo(c))}i(Ud,"isOutputAmountChangedExcessively");function Xd(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=>Md(s,n)||[]).filter(s=>!s.ok).map(s=>{let c=s.asset.symbol,l=_(new He(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=_(new He(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=Tt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=Tt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=Tt.t(" for input and network fee")),Tt.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:yt(s.asset.blockchain,o)}})})}i(Xd,"generateBalanceWarnings");function pr(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==cr.NetworkChanged}i(pr,"isNetworkStatusInWarningState");function Yd(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,"")),pr(e)){r=t.networkStatusExtraMessage||"",a=t.networkStatusExtraMessageDetail||"";let p=(e?iw(t,e):null)?.walletType,u=p?o?.(p)?.name:null;switch(e?.networkStatus){case cr.WaitingForConnectingWallet:r=u?Tt.t("Connect {wallet}",{wallet:u}):r;break;case cr.WaitingForQueue:r=r||Tt.t("Waiting for other running tasks to be finished");break;case cr.WaitingForNetworkChange:r=r||Tt.t("Waiting for changing wallet network");break;case cr.NetworkChangeFailed:r=r||Tt.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(Yd,"getSwapMessages");function Zd(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(Zd,"getLastConvertedTokenInFailedSwap");function Jd(t){return t.status==="failed"}i(Jd,"shouldRetrySwap");function Rd(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(d=>r.some(f=>f.chain===d)),p=c.every(d=>r.some(f=>f.chain===d)),u=o&&a?on(a,o):!1;return!e&&!l||e&&!o||e&&!!o&&(!u||!p)}i(Rd,"isConfirmSwapDisabled");function em(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(em,"isTokensIdentical");var Mi=i((t,e)=>t?.usdPrice?new ot(e||pe).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),nm=i(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new ot(0),outputUsdValue:new ot(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=pe,a=o.inputUsdValue;return Vn(o.inputAmount)?(e&&(n=e?.outputAmount?new ot(e?.outputAmount):null,a=lr(e)??pe,r=Ct(e)??pe),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new ot(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new ot(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new ot(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:Mi(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 ot(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=wu(e);t(()=>({inputAmount:o}))},setInputAmount:e=>{let o=Su(e);ai(e)||(o=mu(o),o=fu(o)),t(n=>({inputAmount:o,...!o&&{outputAmount:null,outputUsdValue:new ot(0),selectedQuote:null},...!!n.fromToken&&{inputUsdValue:Mi(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:Mi(n??null,s),outputUsdValue:new ot(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?Mi(e.toToken,e.outputAmount?.toString()||""):new ot(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new ot(0),inputUsdValue:new ot(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new ot(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"),rm=tm()(om(nm)),im=tm()(om(nm)),aw=co(rm),sw=co(im);function H(){let{swapMode:t}=tt();return co(t==="refuel"?im:rm)}i(H,"useQuoteStore");var am=i((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&ve.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&&ve.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"),sm=aw.subscribe(am),lm=sw.subscribe(am);function cm(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:c,fromBlockchain:l,toBlockchain:p}=H()(),u=T().config,d=T().fetchStatus,f=T().blockchains(),{findToken:h}=T(),{setAffiliateRef:g,setAffiliatePercent:m,setAffiliateWallets:y}=T(),S=u?.from?.tokens,C=u?.from?.blockchains,k=u?.to?.tokens,x=u?.to?.blockchains,w=Li(void 0),I=Li(void 0),A=Li(void 0),b=Li(void 0);Tn(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),Tn(()=>{if(d==="success"){r();let E=f.find(M=>M.name===u?.from?.blockchain),v=u?.from?.token,N=v&&h(v);(E||!E&&A.current)&&n(E??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,d]),Tn(()=>{gs(s,S)&&a({token:null}),hs(l,C)&&n(null)},[S,C]),Tn(()=>{gs(c,k)&&a({token:null}),hs(p,x)&&o(null)},[k,x]),Tn(()=>{if(d==="success"){r();let E=f.find(M=>M.name===u?.to?.blockchain),v=u?.to?.token,N=v&&h(v);(E||!E&&b.current)&&o(E??null),N?e({token:N,meta:{blockchains:f}}):!N&&I.current&&e({token:null}),b.current=u?.to?.blockchain,I.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,d]),Tn(()=>{g(u?.affiliate?.ref??null),m(u?.affiliate?.percent??null),y(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(cm,"useSyncStoresWithConfig");import{useEffect as Ys,useRef as lw}from"react";import{useInRouterContext as cw,useLocation as pw,useSearchParams as uw}from"react-router-dom";function js(t,e){let o=t.split("--");return o[0]?{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}:null}i(js,"convertTokenSearchParamToAsset");function Xs(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Xs,"tokenToSearchParam");function Js(){let t=pw(),[e,o]=uw(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:c,setFromBlockchain:l,setToBlockchain:p,setFromToken:u,setToToken:d,setInputAmount:f}=H()(),h=T().fetchStatus,g=T().blockchains(),m=cw(),{updateIframe:y,updateCampaignMode:S}=T(),C=T().isInCampaignMode(),k=lw(),{findToken:x}=T(),w=i(()=>{let A={};for(let[W,J]of e.entries())(W.startsWith("utm_")||W.startsWith("privy_"))&&(A[W]=J);let b=e.get("fromAmount"),E=e.get("fromBlockchain"),v=e.get("fromToken"),N=e.get("toBlockchain"),M=e.get("toToken"),P=e.get("autoConnect"),U=e.get("clientUrl"),Q=e.get("liquiditySources"),Z=e.get("blockchain");return{fromAmount:b,fromBlockchain:E,fromToken:v,toBlockchain:N,toToken:M,autoConnect:P,clientUrl:U,liquiditySources:Q,extraQueryParams:A,blockchain:Z}},"getUrlSearchParams"),I=i(A=>{for(let b in A)A[b]||delete A[b];o(A,{replace:!0})},"updateUrlSearchParams");Ys(()=>{let{autoConnect:A,clientUrl:b,extraQueryParams:E,blockchain:v}=w();m&&h==="success"&&I({fromBlockchain:n?.name,fromToken:Xs(a),toBlockchain:r?.name,toToken:Xs(s),fromAmount:c,autoConnect:A??void 0,clientUrl:b??void 0,blockchain:v??void 0,liquiditySources:C?k.current:void 0,...E})},[t.pathname,c,n,a,r,s,C,h]),Ys(()=>{if(!m)return;let A=w();if(!k.current&&A.liquiditySources&&(k.current=A.liquiditySources),A.fromAmount&&f(A.fromAmount),h==="success"){let b=g.find(U=>U.name===A.fromBlockchain),E=A.fromToken&&b&&js(A.fromToken,b),v=E?x(E):void 0,N=g.find(U=>U.name===A.toBlockchain),M=A.toToken&&N&&js(A.toToken,N),P=M?x(M):void 0;b&&(l(b),v&&u({token:v,meta:{blockchains:g}})),N&&(p(N),P&&d({token:P,meta:{blockchains:g}}))}},[h]),Ys(()=>{let{clientUrl:A,liquiditySources:b}=w();y("clientUrl",A||void 0),S("liquiditySources",b?.split(",")??void 0)},[])}i(Js,"useSyncUrlAndStore");import{i18n as vn}from"@lingui/core";import{Alert as Mv,Button as Lv,darkTheme as Pv,Divider as Al,DoneIcon as _v,styled as Dv,TextField as $v,Typography as Fv}from"@rango-dev/ui";import qe,{useState as Ov}from"react";import{useNavigate as Uv,useSearchParams as zv}from"react-router-dom";import{ChevronRightIcon as dw,Divider as fm,Image as mw,Typography as gm}from"@rango-dev/ui";import It from"react";import{darkTheme as pm,styled as Rs}from"@rango-dev/ui";var um=Rs("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${pm} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${pm} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),dm=Rs("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),mm=Rs("div",{display:"flex"});function el(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return It.createElement(dm,null,It.createElement(gm,{size:"large",variant:"label"},n),It.createElement(fm,{size:10}),It.createElement(um,{onClick:s?void 0:e,disabled:s,id:"widget-blockchain-selector-container"},It.createElement(mm,null,r&&It.createElement(It.Fragment,null,It.createElement(mw,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),It.createElement(fm,{size:4,direction:"horizontal"})),It.createElement(gm,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),It.createElement(dw,{size:12,color:"black"})))}i(el,"BlockchainSelectorButton");import{i18n as rl}from"@lingui/core";import{Button as kw,Divider as km,MessageBox as ww}from"@rango-dev/ui";import uo,{useEffect as wm,useState as il}from"react";import{i18n as Pi}from"@lingui/core";import{Divider as Fo,ExternalLinkIcon as hw,Image as yw,InfoIcon as Sw,Tooltip as Cw,Typography as dr}from"@rango-dev/ui";import me from"react";var hm="https://blog.rango.exchange/understanding-the-risks-of-using-custom-token-contract-addresses-96022308eca4";function ym(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(ym,"generateExplorerLink");import{Button as fw,darkTheme as kn,styled as ur,Typography as gw}from"@rango-dev/ui";var tl=ur("a",{textDecoration:"none",color:"$colors$neutral700",[`.${kn} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${kn} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${kn} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${kn} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),Sm=ur("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${kn} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${kn} &`]:{color:"$colors$neutral900"}}}),ol=ur(fw,{minHeight:"$40"}),Cm=ur(gw,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"96px"}),Tm=ur("div",{display:"flex",justifyContent:"center",alignItems:"center"});var Tw=9;function nl(t){let{open:e,onClose:o,token:n,onExit:r,onSubmitClick:a,blockchain:s}=t,c=ym(n.address,s),l=i(()=>window.open(hm,"_blank"),"onClickLearnMore");return me.createElement(ee,{open:e,id:"widget-custom-token-watermarked-modal",dismissible:!0,onClose:o,onExit:r,container:B()},me.createElement(Sm,null,me.createElement(yw,{src:n.image===""?ti:n.image,size:45,type:"circular"}),me.createElement(Fo,{size:4}),me.createElement(Tm,null,me.createElement(Cm,{variant:"title",size:"medium"},n.symbol),n.symbol.length>Tw&&me.createElement(Cw,{content:n.symbol,container:B()},me.createElement(Sw,{size:12,color:"gray"}))),me.createElement(dr,{variant:"body",size:"small",className:"_blockchain-name"},s.displayName),me.createElement(Fo,{size:4}),me.createElement(dr,{variant:"body",size:"medium"},c?me.createElement(tl,{hasHover:!0,href:c,target:"_blank",rel:"nofollow noreferrer"},n.address,me.createElement(hw,{size:12,color:"gray"})):me.createElement(tl,null,n.address)),me.createElement(Fo,{size:4}),n.coinSource&&me.createElement(dr,{className:"_coin-source",variant:"body",size:"xsmall"},Pi.t("via")," ",me.createElement(dr,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),me.createElement(Fo,{size:"32"}),me.createElement(dr,{size:"medium",variant:"body",className:"_custom-token-description"},Pi.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."))),me.createElement(Fo,{size:40}),me.createElement(Fo,{size:10}),me.createElement(ol,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:a},Pi.t("Import Anyway")),me.createElement(Fo,{size:10}),me.createElement(ol,{id:"widget-custom-token-modal-learn-more-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:l},Pi.t("Learn More")))}i(nl,"CustomTokenModal");function mr(t){let{token:e,blockchain:o,error:n,address:r,fetchCustomToken:a,onCloseErrorModal:s,onImport:c,onExitErrorModal:l,onExitImportModal:p}=t,{setCustomToken:u}=T(),[d,f]=il(!1),[h,g]=il(!1),[m,y]=il(!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"),x=i(()=>{m&&n?.type==="network-error"&&(y(!1),S()),l()},"handleExit"),w=i(()=>{e&&(u(e),c())},"handleSubmit");return wm(()=>{n&&f(!0)},[n]),wm(()=>{o&&e&&g(!0)},[o,e]),uo.createElement(uo.Fragment,null,uo.createElement(ee,{open:d,dismissible:!0,id:"widget-add-custom-token-modal",onClose:C,onExit:x,container:B()},uo.createElement(ww,{title:n?.title??"",type:"error",description:n?.message||rl.t("Failed Network, Please retry.")},uo.createElement(km,{size:40}),uo.createElement(km,{size:10}),uo.createElement(kw,{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"?rl.t("Retry"):rl.t("Add another custom token")))),o&&e&&uo.createElement(nl,{blockchain:o,token:e,onSubmitClick:w,onClose:()=>g(!1),open:h,onExit:p}))}i(mr,"ImportCustomToken");import{useManager as Ev}from"@rango-dev/queue-manager-react";import{BottomLogo as Iv,Divider as of,Header as Av}from"@rango-dev/ui";import Be,{useEffect as qi,useLayoutEffect as Nv,useRef as nf,useState as rf}from"react";import{useRef as vw}from"react";function _i(){return window.self!==window.top}i(_i,"isAppLoadedIntoIframe");function al(){let t=vw(null),{iframe:e}=T(),o=_i()&&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(al,"useIframe");import{useNavigate as xw}from"react-router-dom";function Qe(){let t=xw();return()=>t(-1)}i(Qe,"useNavigateBack");import{createTheme as ml,darkTheme as $w,lightTheme as Fw}from"@rango-dev/ui";import{useEffect as Ow,useState as Uw}from"react";import{theme as _w,darkColors as Dw}from"@rango-dev/ui";import ul from"react";var Di=16,$i=255,vm=.11;function bw(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(bw,"expandShortHexColor");function Ew(t,e){return t.padStart(e,"0")}i(Ew,"pad");function sl(t){let e=Math.min(Math.max(Math.round(t),0),$i);return Ew(e.toString(Di),2)}i(sl,"intToHex");function Iw(t){return`#${sl(t.red)}${sl(t.green)}${sl(t.blue)}`}i(Iw,"rgbToHex");function Aw(t){let e=parseInt(t.slice(1,3),Di),o=parseInt(t.slice(3,5),Di),n=parseInt(t.slice(5,7),Di);return{red:e,green:o,blue:n}}i(Aw,"hexToRGB");function Nw(t,e){let o=1-vm*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(Nw,"generateShade");function Bw(t,e){let o=vm*e;return{red:t.red+($i-t.red)*o,green:t.green+($i-t.green)*o,blue:t.blue+($i-t.blue)*o}}i(Bw,"generateTint");function Ww(t){return xm(t,Nw)}i(Ww,"calculateShades");function Mw(t){return xm(t,Bw)}i(Mw,"calculateTints");function xm(t,e){let o=Aw(t),n=[];for(let r=1;r<9;r++)n.push(Iw(e(o,r)));return n}i(xm,"calculateColors");function ll(t,e,o){let a=Mw(t).reverse().concat(t),s=Ww(t),c=a.concat(s),l={},p=c.length;for(let u=0;u<p;u++){let d=100+(o?p-1-u:u)*50,f=c[u];f&&(l[`${e}${d}`]=f)}return l}i(ll,"createTintsAndShades");function cl(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)&&!Tu(r)){let l=bw(a);Object.assign(n,ll(l,r,s))}}return{...n,...e}}i(cl,"expandToGenerateThemeColors");var bm=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),Lw=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=bm(o%52)+e;return bm(o%52)+e},"toAlphabeticName"),Pw=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),pl=i(t=>Lw(Pw(5381,JSON.stringify(t))>>>0),"toHash");function dl(t){let e=_w.colors,o={...e,...Dw},n,r;if(t?.light){let s={colors:cl(e,t.light)};n={id:`${fs}-light-${pl(s)}`,tokens:s}}if(t?.dark){let s={colors:cl(o,t.dark,{reverseNeutralRange:!0})};r={id:`${fs}-dark-${pl(s)}`,tokens:s}}return{light:n,dark:r}}i(dl,"customizedThemeTokens");function Em(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>ul.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(ul.cloneElement(a,{key:s})),r<t.length-1){let c=`divider-${r}`;o.push(ul.cloneElement(e,{key:c}))}}),o}i(Em,"joinList");function Im(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Im,"doesWindowPreferDarkColorScheme");function mo(t){let{colors:e,fontFamily:o=ou,borderRadius:n=Pu,secondaryBorderRadius:r=_u}=t,[a,s]=Uw(Im()?"dark":"light"),{theme:c}=T(),{dark:l,light:p}=dl(e),u=ml({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),d=[u.className,Fw.className],f=[u.className,$w.className];if(p){let g=ml(p.id,p.tokens);d.push(g.className)}if(l){let g=ml(l.id,l.tokens);f.push(g.className)}return Ow(()=>{let g=i(m=>{m.matches?s("dark"):s("light")},"switchThemeListener");return Im()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",g),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",g)}},[]),{activeTheme:i(()=>{let g=d.join(" "),m=f.join(" ");return c==="auto"?a==="dark"?m:g:c==="dark"?m:g},"getActiveTheme"),mode:c==="auto"?a:c}}i(mo,"useTheme");var kt=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 Am}from"@lingui/core";import{Alert as zw,Button as Hw}from"@rango-dev/ui";import Nm from"react";function fl(t){return Nm.createElement(zw,{action:Nm.createElement(Hw,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Am.t("Activate this tab")),type:"warning",variant:"alarm",title:Am.t("Another tab is open and handles transactions.")})}i(fl,"ActivateTabAlert");import{i18n as gl}from"@lingui/core";import{Button as Qw,Divider as qw,MessageBox as Gw}from"@rango-dev/ui";import Fi from"react";function hl(t){let{open:e,onClose:o,onConfirm:n}=t;return Fi.createElement(ee,{open:e,dismissible:!0,onClose:o,id:"widget-active-tab-modal",container:B()},Fi.createElement(Gw,{title:gl.t("Activate current tab"),type:"warning",description:gl.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.")},Fi.createElement(qw,{size:20}),Fi.createElement(Qw,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},gl.t("Confirm"))))}i(hl,"ActivateTabModal");import{ChevronLeftIcon as jw}from"@rango-dev/ui";import $m from"react";import{css as Vw,darkTheme as Bm,IconButton as Kw,styled as Oo}from"@rango-dev/ui";var Dt=Oo(Kw,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${Bm} &`]:{backgroundColor:"$neutral"}}}),Wm=Oo("div",{position:"absolute",background:"$secondary500",[`.${Bm} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),fo=Oo("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),Mm=Oo("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"}}}}),Lm=Oo("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Pm=Oo("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),_m=Vw({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Dm=Oo("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});function yl(t){return $m.createElement(Dt,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},$m.createElement(jw,{color:"black",size:16}))}i(yl,"BackButton");import{i18n as Xw}from"@lingui/core";import{Button as Yw,Typography as Zw}from"@rango-dev/ui";import Sl from"react";function Cl(t){return Sl.createElement(fo,null,Sl.createElement(Yw,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},Sl.createElement(Zw,{variant:"label",size:"medium",color:"error500"},Xw.t("Cancel"))))}i(Cl,"CancelButton");import{i18n as Jw}from"@lingui/core";import{Image as Rw,Tooltip as ev,WalletIcon as tv,WalletState as Fm}from"@rango-dev/ui";import Uo from"react";function Tl(t){let{list:e}=bt(),o=e.filter(r=>r.state===Fm.CONNECTED||r.state===Fm.PARTIALLY_CONNECTED),n=o.length?Uo.createElement("div",{className:_m()},o.map(r=>Uo.createElement(Dm,{key:r.title},Uo.createElement(Rw,{src:r.image,size:14})))):Jw.t("Connect Wallet");return Uo.createElement(ev,{container:t.container,side:"bottom",content:n},Uo.createElement(Dt,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&Uo.createElement(Wm,null),Uo.createElement(tv,{size:18,color:"black"})))}i(Tl,"WalletButton");import{i18n as Ui}from"@lingui/core";import{NotificationsIcon as yv,Popover as Sv,SettingsIcon as Cv,Tooltip as zi,TransactionIcon as Tv}from"@rango-dev/ui";import Le from"react";import{Notifications as iv}from"@rango-dev/ui";import av from"react";import{useNavigate as sv}from"react-router-dom";import{create as ov}from"zustand";import{persist as nv,subscribeWithSelector as rv}from"zustand/middleware";var Ne=co(ov()(nv(rv((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 kl(){let t=sv(),{getNotifications:e,clearNotifications:o}=Ne(),n=e(),r=T().blockchains(),{findToken:a}=T();return av.createElement(iv,{id:"widget-notifications-container",list:n,getBlockchainImage:c=>Kp(c,r),getTokenImage:c=>a(c)?.image,onClickItem:i(c=>{t(`${$.swaps}/${c}`)},"onClickItem"),onClearAll:o})}i(kl,"NotificationContent");import{useManager as lv}from"@rango-dev/queue-manager-react";import{InProgressIcon as cv}from"@rango-dev/ui";import Om from"react";var pv=i(()=>{let{manager:t}=lv();return kt(t).map(({swap:o})=>o).find(o=>o.status==="running")?Om.createElement(Pm,{id:"widget-header-history-badge-container"},Om.createElement(cv,{color:"info",size:6})):null},"InProgressTransactionBadge"),Um=pv;import{EventSeverity as uv}from"@rango-dev/queue-manager-rango-preset";import{Typography as dv}from"@rango-dev/ui";import zm from"react";function Hm(){let{getNotifications:t}=Ne(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===uv.WARNING);return o?zm.createElement(Mm,{isSever:n},zm.createElement(dv,{variant:"body",size:"xsmall",color:"$background",id:"widget-header-notifications-badge-container"},o)):null}i(Hm,"NotificationsBadge");import{RefreshProgressButton as mv}from"@rango-dev/ui";import wl,{useEffect as fv,useState as Qm}from"react";var gv=1e3,qm=60,hv=100;function Oi({onClick:t}){let[e,o]=Qm(0),[n,r]=Qm(!1),a=i(l=>{document.hidden&&l&&s(l)},"handleVisibilityChange");fv(()=>{let l;return t?l=window.setInterval(()=>{o(p=>p+1),e===qm&&c()},gv):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(Dt,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:c,disabled:!t},wl.createElement(Lm,{onTransitionEnd:()=>r(!1),isRefetched:n},wl.createElement(mv,{size:22,color:t?"black":"gray",progress:e/qm*hv})))}i(Oi,"RefreshButton");function zo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=T(),c=et("notification",s)||r.includes("notifications");return Le.createElement(Le.Fragment,null,!r.includes("refresh")&&Le.createElement(zi,{container:a||B(),side:"top",content:Ui.t("Refresh")},Le.createElement(Oi,{onClick:e})),!c&&Le.createElement(Sv,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:B(),content:Le.createElement(kl,null)},Le.createElement("div",null,Le.createElement(zi,{container:B(),side:"top",content:Ui.t("Notifications")},Le.createElement(Dt,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Le.createElement(yv,{size:18,color:"black"}),Le.createElement(Hm,null))))),!r.includes("settings")&&Le.createElement(zi,{container:B(),side:"top",content:Ui.t("Settings")},Le.createElement(Dt,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Le.createElement(Cv,{size:18,color:"black"}))),!r.includes("history")&&Le.createElement(zi,{container:B(),side:"top",content:Ui.t("History")},Le.createElement(Dt,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Le.createElement(Tv,{size:18,color:"black"}),Le.createElement(Um,null))))}i(zo,"HeaderButtons");import{i18n as vl}from"@lingui/core";import{Divider as Vm,MessageBox as vv,RefreshIcon as xv}from"@rango-dev/ui";import wn from"react";import{Button as kv,styled as wv}from"@rango-dev/ui";var Gm=wv(kv,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function xl(t){let{open:e,onClose:o}=t;return wn.createElement(ee,{open:e,dismissible:!0,onClose:o,id:"widget-refresh-modal",container:B()},wn.createElement(vv,{title:vl.t("Something went wrong"),type:"error",description:vl.t("Something went wrong. Please refresh the app.")},wn.createElement(Vm,{size:30}),wn.createElement(Gm,{variant:"outlined",id:"widget-refresh-modal-refresh-btn",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},wn.createElement(xv,{size:20,color:"primary"}),wn.createElement(Vm,{size:4,direction:"horizontal"}),vl.t("Refresh"))))}i(xl,"RefreshModal");var Km="700px",jm="425px",Xm="550px",Ym="640px",Zm="800px";function bl(t){let e=t.target;if(e){let o=e.scrollTop,n=B();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(bl,"onScrollContentAttachStatusToContainer");import{css as bv,styled as Hi}from"@rango-dev/ui";var Qi=bv({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Jm=Hi("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",maxHeight:Km,variants:{height:{auto:{height:"auto"},fixed:{height:"100%",minHeight:jm,[`@media screen and (min-height: ${Zm})`]:{minHeight:Xm}}},showBanner:{true:{overflow:"visible"}}}}),Rm=Hi("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),ef=Hi("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"}}}),tf=Hi("div",{width:"100%",position:"absolute",bottom:"-$10",transform:"translateY(100%)",overflow:"hidden"});function se(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=al(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:c,connectedWallets:l,config:{__UNSTABLE_OR_INTERNAL__:p}}=T(),[u,d]=rf(!1),{config:{features:f,theme:h}}=T(),{watermark:g}=ne(),m=g==="FULL",{activeTheme:y}=mo(h||{}),[S,C]=rf(!1),k=et("connectWalletButton",f),{isActiveTab:x,tabManagerInitiated:w,showActivateTabModal:I,setShowActivateTabModal:A,activateCurrentTab:b,setShowCompactTokenSelector:E}=ne(),v=Qe(),{manager:N}=Ev(),P=kt(N).map(({swap:X})=>X).some(X=>X.status==="running"),U=i(()=>b(Po.forceClaim,P),"onActivateTab"),Q=i(()=>{r.onWallet?.()},"onConnectWallet"),Z=typeof r.hasBackButton>"u"||r.hasBackButton,W=nf(null),J=nf(null);return qi(()=>{let X=(p?.swapBoxBanner?.routes?.length??0)===0,ae=!!p?.swapBoxBanner?.routes?.some(Se=>location.pathname.endsWith(Se));C(!!p?.swapBoxBanner&&(X||ae))},[p?.swapBoxBanner?.routes?.toString(),location.pathname]),qi(()=>(_i()&&J.current&&e(J.current),()=>{o()}),[]),qi(()=>(W.current?.addEventListener("scroll",bl),()=>{W.current?.removeEventListener("scroll",bl)}),[]),qi(()=>{d(c==="failed")},[c]),Nv(()=>{if(!J.current)return;let X=new ResizeObserver(ae=>{for(let Se of ae)Se.contentRect&&E(Se.contentRect.height<parseInt(Ym))});return X.observe(J.current),()=>X.disconnect()},[]),Be.createElement(Jm,{height:s,id:Re.SWAP_BOX_ID,className:`${y()} ${Qi()}`,ref:J,showBanner:S},Be.createElement(Av,{prefix:Z?Be.createElement(yl,{onClick:()=>{v(),r.onBack?.()}}):null,title:r.title,suffix:Be.createElement(Be.Fragment,null,r.suffix,r.onWallet&&!k&&Be.createElement(Tl,{container:B(),onClick:Q,isConnected:!!l?.length}),r.onCancel&&Be.createElement(Cl,{onClick:r.onCancel}))}),Be.createElement(Rm,{ref:W},n),Be.createElement(hl,{open:I,onClose:()=>A(!1),onConfirm:U}),Be.createElement(ef,null,Be.createElement("div",{className:"footer__content"},w&&!x&&Be.createElement("div",{className:"footer__alert"},Be.createElement(fl,{onActivateTab:U}),Be.createElement(of,{size:10})),a),Be.createElement(of,{size:12}),Be.createElement("div",{className:`footer__logo ${m?"logo__show":"logo__hidden"}`},Be.createElement(Iv,null))),S&&Be.createElement(tf,null,p?.swapBoxBanner?.element),Be.createElement(xl,{open:u,onClose:()=>d(!1)}))}i(se,"Layout");import{styled as Bv}from"@rango-dev/ui";var af="$20 $20 $10 $20",El=Bv("div",{padding:af,overflowY:"auto",flexGrow:1});import{styled as Wv}from"@rango-dev/ui";var ce=Wv("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 go}from"@lingui/core";import{useState as Il}from"react";function sf(){let[t,e]=Il(!1),[o,n]=Il(null),[r,a]=Il(null),{findToken:s}=T(),c=T().customTokens(),l=i(()=>{a(null),e(!1),n(null)},"resetState");function p(d,f){switch(d){case"duplicated":return{type:d,title:go.t("Duplicate Token"),message:go.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{type:d,title:go.t("Token Already Exists"),message:go.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{type:d,title:go.t("Token Not Found"),message:go.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:d,title:go.t("Network error"),message:go.t("An error occurred while retrieving token data.")}}}return i(p,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:d,tokenAddress:f})=>{e(!0);try{if(c.some(S=>S.address?.toLowerCase()===f.toLowerCase())){let S=p("duplicated");n(S);return}let g=await ct().getCustomToken({blockchain:d,address:f});if(!g||!g.token||g.error){let S=p("not-found",d);n(S);return}let m=g.token;if(s({blockchain:m.blockchain,address:m.address,symbol:m.symbol})){let S=p("token-exist");n(S);return}return a({...m,warning:!0})}catch(h){if(h.code==="ERR_BAD_REQUEST"){let g=p("not-found",d);n(g);return}n(p("network-error"));return}finally{e(!1)}},"fetchCustomToken"),token:r,loading:t,error:o,resetState:l}}i(sf,"useFetchCustomToken");var Hv=Dv("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $12",backgroundColor:"$neutral300","& input":{padding:"0"},[`.${Pv} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}});function lf(){let t=Uv(),[e]=zv(),o=Qe(),n=T().blockchains(),r=e.get("blockchain")||"",a=No(r,n),[s,c]=Ov(""),{fetchCustomToken:l,token:p,loading:u,error:d,resetState:f}=sf(),h=!!a&&on(a,s),g=!a||!s||!h,m=i(()=>{a&&l({blockchain:r,tokenAddress:s})},"getCustomToken");return qe.createElement(se,{header:{title:vn.t("Add Custom Token")}},qe.createElement(ce,null,qe.createElement(Hv,null,qe.createElement("div",null,qe.createElement(el,{onClick:()=>t($.blockchains,{replace:!0}),hasLogo:!!a?.logo,value:a?{name:a.displayName,logo:a.logo}:void 0,title:vn.t("Select chain"),placeholder:vn.t("Select chain")}),qe.createElement(Al,{size:"24"}),qe.createElement(Fv,{size:"large",variant:"label"},vn.t("Enter Address")),qe.createElement(Al,{size:10}),qe.createElement($v,{fullWidth:!0,id:"widget-add-custom-token-token-address-input",disabled:!a,variant:"contained",placeholder:vn.t("Enter token address"),size:"large",value:s,suffix:!!s&&h&&qe.createElement(_v,{color:"success",size:12}),onChange:y=>c(y.target.value)}),!h&&!!s&&qe.createElement(qe.Fragment,null,qe.createElement(Al,{size:4}),qe.createElement(Mv,{id:"widget-add-custom-token-invalid-address-alert",type:"error",variant:"alarm",title:"Invalid Address"}))),qe.createElement(Lv,{id:"widget-add-custom-token-import-btn",disabled:g,type:"primary",variant:"contained",loading:u,size:"large",onClick:m},vn.t("Import"))),qe.createElement(mr,{token:p,blockchain:a??void 0,address:s,error:d??void 0,fetchCustomToken:l,onCloseErrorModal:()=>{d?.type!=="network-error"&&c("")},onImport:o,onExitErrorModal:f,onExitImportModal:f})))}i(lf,"AddCustomTokenPage");import{i18n as cc}from"@lingui/core";import{useManager as Mb}from"@rango-dev/queue-manager-react";import{Alert as Lb,Button as Pb,css as uc,Divider as pc,IconButton as eh,styled as _b,Typography as Db,WalletIcon as $b}from"@rango-dev/ui";import De,{useEffect as Sa,useLayoutEffect as Fb,useRef as Ob,useState as br}from"react";import{useNavigate as Ub}from"react-router-dom";import{i18n as Ho}from"@lingui/core";import{Alert as fx,BalanceErrors as gx,Button as Pf,ChevronLeftIcon as hx,Divider as Dl,MessageBox as yx,Typography as $l}from"@rango-dev/ui";import ie,{useCallback as Sx,useEffect as _f,useMemo as Cx,useState as In}from"react";import{useNavigate as Tx}from"react-router-dom";import{i18n as Ml}from"@lingui/core";import{Alert as Kv,ChevronDownIcon as jv,CloseIcon as Xv,Divider as gf,IconButton as hf,PasteIcon as Yv,Typography as Zv,WalletIcon as Jv}from"@rango-dev/ui";import Pe,{useEffect as Rv,useRef as ex}from"react";import ji,{useRef as Gv}from"react";import*as xn from"@radix-ui/react-collapsible";import{keyframes as cf,styled as Gi}from"@rango-dev/ui";var Nl=300,Qv=cf({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),qv=cf({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),pf=Gi(xn.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),Bl=Gi(xn.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Vi=Gi(xn.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Qv} ${Nl}ms ease-out`},false:{animation:`${qv} ${Nl}ms ease-out`}}}}),Ki=Gi("div",{transition:`all ${Nl}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Xi(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:c}=t,l=Gv(null);return ji.createElement(pf,{ref:l,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},c==="top"&&ji.createElement(Bl,{className:"collapsible_trigger",onClick:a},s),ji.createElement(Vi,{className:"collapsible_content",open:e},r),c==="bottom"&&ji.createElement(Bl,{className:"collapsible_trigger",onClick:a},s))}i(Xi,"CustomCollapsible");import{darkTheme as uf,styled as Wl,TextField as Vv}from"@rango-dev/ui";var df=Wl("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"},"& input":{padding:"$15"}}),mf=Wl(Vv,{backgroundColor:"$neutral100"}),ff=Wl("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${uf} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${uf} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function yf(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=H()(),{config:s}=T(),c=T().blockchains(),l=Rr(e.name,c),p=ex(null),u=s?.defaultCustomDestinations?.[e.name],d=navigator?.userAgent.includes("Firefox"),h=n&&!!r&&e&&!on(e,r),g=i(()=>{a("")},"handleClear"),m=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let C=await navigator.clipboard.readText();a(C),p?.current?.focus()}},"handlePaste"),y=i(()=>r?Pe.createElement(hf,{id:"widget-custom-destination-close-icon-btn",onClick:g,variant:"ghost"},Pe.createElement(Xv,{size:12,color:"gray"})):d?null:Pe.createElement(hf,{id:"widget-custom-destination-paste-icon-btn",onClick:m,variant:"ghost"},Pe.createElement(Yv,{size:16})),"renderSuffix");return Rv(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),Pe.createElement(df,null,Pe.createElement(Xi,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Pe.createElement(ff,{id:"widget-custom-destination-collapsible-btn"},Pe.createElement("div",{className:"button__content"},Pe.createElement(Jv,{size:18,color:"info"}),Pe.createElement(gf,{size:4,direction:"horizontal"}),Pe.createElement(Zv,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Ml.t("Send to a different address"))),Pe.createElement(Ki,{orientation:n?"up":"down"},Pe.createElement(jv,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Pe.createElement(mf,{id:"widget-custom-destination-blockchain-address-input",ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Ml.t("Enter {blockchainName} address",{blockchainName:l}),value:r||"",suffix:y(),onChange:S=>{let C=S.target.value;a(C)}})),h&&Pe.createElement(Pe.Fragment,null,Pe.createElement(gf,{size:4}),Pe.createElement(Kv,{variant:"alarm",type:"error",title:Ml.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(yf,"CustomDestination");import{css as tx,IconButton as ox,SelectableWalletButton as nx,styled as ho}from"@rango-dev/ui";var Sf=ho("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),Cf=ho("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Tf=ho(nx,{justifyContent:"center"}),kf=ho("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),wf=ho(ox,{position:"absolute",left:"$20"}),vf=ho("div",{paddingTop:"$20"}),xf=tx({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),bf=ho("div",{display:"flex"}),Ef=ho("div",{overflow:"visible",width:"100%"});import{i18n as Pl}from"@lingui/core";import{warn as lx}from"@rango-dev/logging-core";import{Divider as cx,makeInfo as px,SelectableWallet as ux,Typography as Mf,WalletState as En}from"@rango-dev/ui";import nt,{useEffect as Lf,useState as gr}from"react";import{Image as ax,MessageBox as sx}from"@rango-dev/ui";import fr from"react";import{keyframes as rx,styled as Ll}from"@rango-dev/ui";var If=Ll("div",{position:"relative"}),ix=rx({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Af=Ll("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${ix} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Nf=Ll("div",{"& img":{borderRadius:"50%"}});import{i18n as bn}from"@lingui/core";function Bf(t,e){switch(t){case"in-progress":return{type:"loading",title:bn.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:bn.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:bn.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:bn.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:bn.t("Request Rejected"),description:bn.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(Bf,"generateMessageByStatus");function Wf(t){let{status:e,displayName:o,image:n}=t,r=Bf(e,o),a=e=="in-progress";return fr.createElement(sx,{type:r.type,title:r.title,description:r.description,icon:a?fr.createElement(If,null,fr.createElement(Nf,null,fr.createElement(ax,{src:n,size:45})),fr.createElement(Af,null)):void 0})}i(Wf,"ExperimentalChainStatus");var dx=7,mx=3e3;function _l(t){let{chain:e,quoteChains:o,isSelected:n,selectWallet:r,limit:a,onShowMore:s}=t,c=ne.use.isActiveTab(),{blockchains:l,connectedWallets:p}=T(),[u,d]=gr(),[f,h]=gr(null),[g,m]=gr(!1),[y,S]=gr(null),{suggestAndConnect:C}=Yi(),{list:k}=bt({chain:e}),[x,w]=gr(k),I=k.length,A=a&&I-a>0,b=i(async v=>{m(!1),S("in-progress");try{let N=k.find(Q=>Q.type===Q.type),M=N?.isHub?N.properties?.find(Q=>Q.name==="namespaces")?.value:N?.needsNamespace,P=l(),U=M?.data.find(Q=>Q.getSupportedChains(P).some(Z=>Z.name===v.chain));if(!U)throw new Error("Requested chain is not supported");await C(v.walletType,{namespace:U.value,network:v.chain}),S("completed")}catch{S("rejected")}},"addExperimentalChain");Lf(()=>{w(v=>{let N=k.findIndex(M=>n(M.type,e));return A&&N>1?[k[N]].concat(k.filter((M,P)=>P!==N)):v.map(M=>k.find(P=>P.type===M.type)??M)})},[JSON.stringify(k)]);let E=document.getElementById(Re.SWAP_BOX_ID);return Lf(()=>{let v=null;return(y==="completed"||y==="rejected")&&(v=setTimeout(()=>S(null),mx)),()=>{v&&clearTimeout(v)}},[y]),nt.createElement(nt.Fragment,null,x.slice(0,a).map(v=>{let N=Au({connectedWallets:p,walletType:v.type,chain:e}),M=v.state===En.CONNECTED||v.state===En.PARTIALLY_CONNECTED,P=N?lo(N,dx):"",U=M&&!!v.needsNamespace&&!P,Q=pi(l(),e),Z=!p.find(ue=>ue.walletType===v.type&&ue.chain===e),W=Q&&Z&&v.state===En.CONNECTED,J=i(async()=>{v.state===En.DISCONNECTED||U&&!W?d(v):W?(h({walletType:v.type,chain:e,address:N??""}),m(!0)):r({walletType:v.type,chain:e,address:N??""})},"onSelectableWalletClick"),X=px(v.state),ae=i(()=>W?Pl.t({id:"Add {chain} chain",values:{chain:e}}):U?Pl.t("Chain not connected"):P||X.description,"getWalletDescription"),Se=i(()=>v.state===En.CONNECTED||v.state===En.PARTIALLY_CONNECTED?U?"neutral600":"neutral700":X.color,"getWalletDescriptionColor"),at=f?.chain?Rr(f.chain,l()):void 0;return nt.createElement(nt.Fragment,{key:`${v.title}_${at}`},!!f&&nt.createElement(ee,{id:"widget-wallets-list-watermarked-modal",open:!!f&&g,container:E,onClose:()=>{h(null)}},nt.createElement(zs,{id:"widget-wallets-list-experimental-chain-container",displayName:at,onConfirm:()=>{b(f)}})),y&&nt.createElement(ee,{id:"widget-wallets-list-experimental-chain-watermarked-modal",open:!!y,onClose:S.bind(null,null),container:E},nt.createElement(Wf,{status:y,displayName:at,image:v.image}),nt.createElement(cx,{direction:"vertical",size:32})),nt.createElement(ux,{key:v.type,id:"widget-wallets-list-selectable-wallet-btn",description:ae(),descriptionColor:Se(),onClick:J,selected:n(v.type,e),disabled:!c,...v}))}),nt.createElement(sr,{id:"widget-wallets-list-stateful-connect-modal",wallet:u,options:{defaultSelectedChains:o||[e]},onClose:()=>{d(void 0)},onConnect:()=>{t.onConnect&&(u?.type?t.onConnect(u.type):lx(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),A&&nt.createElement(Tf,{selected:!1,onClick:s,id:"widget-wallets-list-show-more-wallets-btn"},nt.createElement(Mf,{variant:"label",size:"medium"},Pl.t("Show more wallets"),nt.createElement(Mf,{variant:"label",size:"medium",color:"$primary"},"\xA0+",I-(a??0)))))}i(_l,"WalletList");var kx=2;function Df(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=Tx(),c=T().blockchains(),{selectedQuote:l,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:d,customDestination:f,setCustomDestination:h}=H()(),{config:g,connectedWallets:m,setWalletsAsSelected:y}=T(),[S,C]=In(""),[k,x]=In([]),[w,I]=In(""),[A,b]=In(!!f),E=Cx(()=>Mo({filter:"all",quote:l}),[l]),v=Mo({filter:"required",quote:l}),N=c.find(O=>O.name===l?.swaps[l?.swaps.length-1]?.to.blockchain),M=i(O=>v.includes(O),"isWalletRequiredFor"),P=Sx(()=>m.filter(O=>O.selected&&E.includes(O.chain)),[m,E]),[U,Q]=In(P()),[Z,W]=In([]),J=i((O,z)=>W(Y=>Y.concat({blockchain:O,walletType:z})),"addNextSelectedWallets"),X=k.length>0,ae=i((O,z)=>!!U.find(Y=>Y.walletType===O&&Y.chain===z&&Y.selected&&(M(z)||!M(z)&&!f)),"isSelected"),Se=i((O,z,Y)=>{let te=!1;return O.map(j=>{if(j.chain===z){let G=j.selected;return!te&&Y?(te=!0,G=!0):Y||(G=!1),{...j,selected:G}}return j})},"updateSelectableWallets"),at=i(O=>{b(O),O?M(N?.name??"")||Q(z=>Se(z,N?.name||"",!1)):(h(""),Q(z=>Se(z,N?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),ue=i(O=>{if(S&&C(""),ae(O.walletType,O.chain))return;let Y=m.find(te=>te.walletType===O.walletType&&te.chain===O.chain);Y&&(n(),O.chain===N?.name&&A&&!M(N.name)&&(b(!1),h(null)),Q(te=>te.filter(j=>j.chain!==O.chain).concat({...Y,selected:!0})))},"onChange"),gt=i(()=>{let O=U.filter(z=>z.selected);y(O),p(O),d(!0),o()},"onConfirmBalance"),vt=i(async()=>{x([]),I("");let O=await r?.({selectedWallets:U.filter(Y=>Y.selected),customDestination:f}),z=O.warnings;z?.balance?.messages&&x(z.balance.messages),O.error&&I(xd(O.error)),!O.error&&!z?.balance?.messages.length?gt():x(z?.balance?.messages??[])},"onConfirmWallets");_f(()=>{Q(O=>{let z=[];return O.forEach(Y=>{!m.some(j=>j.chain===Y.chain&&j.walletType===Y.walletType&&j.address===Y.address)||z.push(Y)}),z=z.concat(m.filter(Y=>!!!z.find(j=>j.chain===Y.chain)&&Y.selected&&E.includes(Y.chain))),z})},[m,E]),_f(()=>{let O=[];Z.length>0&&(Z.forEach(z=>{let Y=m.find(te=>te.chain===z.blockchain&&te.walletType===z.walletType);Y?ue(Y):O.push(z)}),W(O))},[m,Z]);let xt=document.getElementById(Re.SWAP_BOX_ID);return ie.createElement(ee,{id:"widget-confirm-wallets-modal",open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!S,container:xt,...!S&&{styles:{container:{height:"100%"}},footer:ie.createElement(bf,null,ie.createElement(Pf,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:Rd(a,A,f,l,U,N),onClick:vt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},Ho.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:ie.createElement(kf,null,ie.createElement(wf,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:C.bind(null,"")},ie.createElement(hx,{size:16})),ie.createElement($l,{variant:"headline",size:"small"},Ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:yt(S,c)}})))},anchor:"center"},ie.createElement(ee,{id:'"widget-confirm-wallets-insufficient-account-balance-modal',open:X,onClose:x.bind(null,[]),container:xt},ie.createElement(yx,{title:Ho.t("Insufficient account balance"),type:"error",description:ie.createElement(gx,{messages:k??[]})},ie.createElement(Pf,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:gt},Ho.t("Proceed anyway")))),S&&ie.createElement(vf,null,ie.createElement("div",{className:xf()},ie.createElement(_l,{chain:S,quoteChains:E,isSelected:ae,selectWallet:ue,onShowMore:()=>C(S),onConnect:O=>{J(S,O)}}))),!S&&ie.createElement(ie.Fragment,null,w&&ie.createElement(ie.Fragment,null,ie.createElement(fx,{id:"widget-confirm-wallet-modal-error-alert",variant:"alarm",type:"error",title:Ho.t(w)}),ie.createElement(Dl,{size:12})),ie.createElement(Ef,null,E.map((O,z)=>{let Y=c.find(Ve=>Ve.name===O),te=`wallet-${z}`,j=z===E.length-1,G=j&&N&&g?.customDestination!==!1;return ie.createElement("div",{key:te},ie.createElement(Sf,null,ie.createElement($l,{variant:"title",size:"xmedium"},Ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:Y?.shortName}})),ie.createElement($l,{variant:"label",color:"$neutral700",size:"medium"},Ho.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:Y?.shortName}}))),ie.createElement(Dl,{size:24}),ie.createElement(Cf,null,ie.createElement(_l,{chain:O,quoteChains:E,isSelected:ae,selectWallet:ue,limit:kx,onShowMore:()=>C(Y?.name??""),onConnect:Ve=>{J(O,Ve)}})),!j&&ie.createElement(Dl,{size:32}),G&&ie.createElement(yf,{blockchain:N,open:A,handleOpenChange:at}))}))))}i(Df,"ConfirmWalletsModal");import{i18n as Kx}from"@lingui/core";import{Alert as jx,Button as Xx,Divider as og,InfoIcon as Yx}from"@rango-dev/ui";import Fe from"react";import{Alert as xx,Button as bx,Divider as Ul,NoRouteIcon as Ex,RefreshIcon as Ix,Typography as Qf}from"@rango-dev/ui";import pt from"react";import{i18n as $f}from"@lingui/core";var wx=24,vx=60;function Ff(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:re().genericServerError,action:{onClick:n,title:$f.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:re().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:$f.t("Reset")}},description:re().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:re().noResultError.description}}i(Ff,"makeInfo");var Fl=(o=>(o[o.small=wx]="small",o[o.large=vx]="large",o))(Fl||{}),Ol=(o=>(o.small="small",o.large="medium",o))(Ol||{});import{styled as Zi}from"@rango-dev/ui";var Of=Zi("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Uf=Zi("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),zf=Zi("div",{variants:{size:{small:{width:"100%"},large:{}}}}),Hf=Zi("div",{padding:"$6 $0"});function hr(t){let{fetch:e,error:o,size:n="small",skipAlerts:r}=t,a=T().getDisabledLiquiditySources(),s=T().toggleAllLiquiditySources,c=T().swappers(),l=Ff(o,a,()=>s(c,!0),e);return r&&(l.alert=null),pt.createElement(Of,{id:"widget-no-result-container"},pt.createElement(Ex,{size:Fl[n],color:"gray"}),pt.createElement(Ul,{size:4}),pt.createElement(Qf,{variant:"title",size:Ol[n]},re().noResultError.title),n==="large"&&pt.createElement(Ul,{size:4}),!!l.description&&pt.createElement(Uf,{size:n},pt.createElement(Qf,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),pt.createElement(Ul,{size:n==="large"?"24":"4"}),!!l.alert&&pt.createElement(zf,{size:n},pt.createElement(xx,{id:"widget-no-result-alert",type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&pt.createElement(bx,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:pt.createElement(Hf,null,pt.createElement(Ix,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(hr,"NoResult");import{i18n as yr}from"@lingui/core";import{Button as _x,Divider as Dx,MessageBox as $x,Typography as Fx,WarningIcon as Ox}from"@rango-dev/ui";import Yt from"react";import{InfoIcon as Wx,Tooltip as Mx,Typography as Lx}from"@rango-dev/ui";import An from"react";import{Button as Ax,darkTheme as Nx,styled as Qo,Typography as Bx}from"@rango-dev/ui";var qf=Qo("div",{width:"100%"}),zl=Qo("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Gf=Qo("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${Nx} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Vf=Qo("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$2"}),Kf=Qo(Bx,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"250px"}),jf=Qo("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"}),Xf=Qo(Ax,{"& ._text":{gap:"$5",display:"flex",alignItems:"center",justifyContent:"center"}});var Px=35;function Yf(t){let{title:e,value:o,valueColor:n}=t,r=B();return An.createElement(Gf,null,An.createElement(Lx,{size:"medium",variant:"label",className:"_title"},e),An.createElement(Vf,null,An.createElement(Kf,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`),o.length>Px&&An.createElement(Mx,{content:o,container:r},An.createElement(Wx,{size:12,color:"gray"}))))}i(Yf,"QuoteErrorsModalItem");function Zf(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",c=[{title:yr.t("Swapping"),value:_(r.inputUsdValue)},{title:yr.t("Gas cost"),value:_(r.totalFee,2,2)},{title:yr.t("Receiving"),value:_(r.outputUsdValue)},{title:yr.t("Price impact"),value:_(r.priceImpact,2,2),valueColor:`${s}500`}];return Yt.createElement(ee,{id:"widget-high-value-loss-warning-modal",footer:Yt.createElement(_x,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Yt.createElement(Ox,null),fullWidth:!0,disabled:a,onClick:n},re().highValueLossError.confirmMessage),open:e,onClose:o,container:B()},Yt.createElement($x,{type:s,title:re().highValueLossError.impactTitle,description:re().highValueLossError.description}),Yt.createElement(zl,null,Yt.createElement(Dx,{size:"4"}),Yt.createElement(Fx,{size:"small",variant:"title"},yr.t("Details")),Yt.createElement(zl,null,c.map((l,p)=>Yt.createElement(Yf,{key:p,...l})))))}i(Zf,"HighValueLossWarningModal");import{i18n as Nn}from"@lingui/core";function Jf(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=Nn.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-slippage",o.actionButtonTitle=Nn.t("Increase")),o;if(t){switch(t.type){case 0:{Xt(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=re().highValueLossError.title;break}case 4:{o.title=Nn.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=re().unknownPriceError.title;break}case 2:{o.title=Nn.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=Nn.t("Increase");break}case 3:{o.title=Nn.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(Jf,"makeAlerts");function Rf(t,e){return e?.type===4?Number(e.minRequiredSlippage):t?.type===2?Number(t.minRequiredSlippage):null}i(Rf,"getRequiredSlippage");import{i18n as Bn}from"@lingui/core";import{Button as Ux,Divider as Hl,MessageBox as zx,WarningIcon as Hx}from"@rango-dev/ui";import Co from"react";import{useNavigate as Qx}from"react-router-dom";function eg(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=Qx();return Co.createElement(ee,{id:"widget-slippage-warning-modal",anchor:"bottom",open:e,container:B(),onClose:o},Co.createElement(zx,{type:"warning",title:r.type===3?Bn.t("High slippage"):Bn.t("Low slippage"),description:r.type===3?Bn.t("Caution, your slippage is high. Your trade may be front run."):Bn.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:r.minRequiredSlippage}})},Co.createElement(Hl,{size:18}),Co.createElement(Hl,{size:32}),Co.createElement(Xf,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:a,onClick:n},Co.createElement(Hx,{color:"white",size:16}),Bn.t("Swap anyway")),Co.createElement(Hl,{size:10}),Co.createElement(Ux,{id:"widget-slippage-warning-modal-change-slippage-btn",size:"large",type:"primary",variant:"outlined",fullWidth:!0,disabled:a,onClick:()=>s("../"+$.settings)},Bn.t("Change Slippage"))))}i(eg,"SlippageWarningModal");import{Button as qx,MessageBox as Gx,WarningIcon as Vx}from"@rango-dev/ui";import Ji from"react";function tg(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return Ji.createElement(ee,{id:"widget-unknown-price-warning-modal",footer:Ji.createElement(qx,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Ji.createElement(Vx,null),fullWidth:!0,disabled:r,onClick:n},re().unknownPriceError.confirmMessage),open:e,onClose:o,container:B()},Ji.createElement(Gx,{type:"warning",title:re().unknownPriceError.impactTitle,description:re().unknownPriceError.description}))}i(tg,"UnknownPriceWarningModal");function Sr(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,skipAlerts:s,refetchQuote:c,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:d,onChangeSlippage:f}=t,h={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},g=o?.type===0||o?.type===1,m=Jf(e,o?.type===3||o?.type===4?o:null);m&&!n&&(m.action=null);let y=!!m&&!s,S=i(C=>{if(C==="change-slippage"){let k=o?.type===3||o?.type===4?o:null,x=Rf(e,k);f?.(x)}else C==="change-settings"&&d()},"onclickActionButton");return Fe.createElement(Fe.Fragment,null,g&&Fe.createElement(Fe.Fragment,null,Fe.createElement(og,{size:10}),Fe.createElement(hr,{skipAlerts:s,error:o,fetch:c})),y&&Fe.createElement(qf,null,Fe.createElement(og,{size:10}),Fe.createElement(jx,{id:"widget-quote-warning-and-errors-alert",title:m.title,type:m.alertType,variant:"alarm",...m.action==="show-info"&&{action:Fe.createElement(jf,{onClick:l},Fe.createElement(Yx,{size:12,color:"gray"}))},...(m.action==="change-settings"||m.action==="change-slippage")&&{action:Fe.createElement(Xx,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:m.alertType,onClick:()=>S(m.action)},m.actionButtonTitle||Kx.t("Change"))}})),e&&Fe.createElement(Fe.Fragment,null,e.type===0&&Fe.createElement(Zf,{...h,warning:e}),(e.type===3||e.type===2)&&Fe.createElement(eg,{...h,warning:e}),e.type===1&&Fe.createElement(tg,{...h,warning:e})))}i(Sr,"QuoteWarningsAndErrors");import bb from"bignumber.js";import fa from"react";import{i18n as qo}from"@lingui/core";import{Alert as mb,CampaignQuoteTag as fb,Divider as Mn,FullExpandedQuote as gb,InfoIcon as Rl,NumericTooltip as ec,QuoteTag as hb,StepDetails as yb,TokenAmount as Sb,Typography as Ln,useIsTruncated as tc}from"@rango-dev/ui";import oc from"bignumber.js";import F,{useRef as ua,useState as Cb}from"react";import{styled as Ql}from"@rango-dev/ui";var ql=Ql("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),ng=Ql("div",{paddingBottom:"$15","& .from-amount-text":{wordBreak:"break-word"},variants:{dense:{true:{paddingBottom:0}}}}),rg=Ql("div",{width:"100%",display:"flex"});import*as Ri from"@radix-ui/react-collapsible";import{Button as Zx,css as ea,darkTheme as _e,Image as ig,styled as Ge,Typography as Gl}from"@rango-dev/ui";var Jx=300,ag=Ge(Ri.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${_e} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${_e} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${_e} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),sg=ea({padding:"$10 $15"}),lg=Ge(Zx,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${_e} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${_e} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${_e} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),cg=Ge("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",[`.${_e} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${_e} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${_e} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${_e} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${_e} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${_e} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${_e} &`]:{backgroundColor:"$neutral400"}}}}]}),pg=ea({width:"100%",padding:"$15 $15 $10 $15"}),ug=ea({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Wn=ea({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),dg=Ge(Ri.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:{[`& ${ig}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${ig}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${_e} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${_e} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${_e} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),mg=Ge("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"}}}}),fg=Ge(Vi,{width:"100%",background:"inherit"}),Vl=Ge("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${Jx}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),EQ=Ge("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),gg=Ge("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${_e} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),hg=Ge("div",{display:"flex",flexDirection:"row",alignItems:"center",gap:"$2",flex:"1 1 auto",minWidth:0}),Kl=Ge(Gl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"$30"}),jl=Ge(Gl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,flex:"0 1 auto"}),Xl=Ge("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"}}}}),yg=Ge("div",{display:"flex"}),ta=Ge("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${_e} &`]:{borderTopColor:"$neutral800"}}),Sg=Ge(Gl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",minWidth:0,flexShrink:3});import{i18n as $t}from"@lingui/core";import{ChevronDownIcon as eb,CloseIcon as tb,Divider as ra,IconButton as ob,NumericTooltip as nb,QuoteCost as rb,Typography as At}from"@rango-dev/ui";import R,{useState as wg}from"react";import{css as Rx,styled as oa}from"@rango-dev/ui";var na=oa("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Yl=oa("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),Cg=oa("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),Tg=oa("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),kg=Rx({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var ib=i(t=>t.fee.isZero()?null:R.createElement(na,null,R.createElement(At,{variant:"label",size:"medium",color:"neutral600"},t.label),R.createElement(At,{variant:"label",size:"medium"},"$",_(t.fee,4,4))),"NonPayableFee");function Zl(t){let[e,o]=wg(!1),[n,r]=wg(!1),{steps:a,quote:s,fee:c,time:l,feeWarning:p,timeWarning:u,showModalFee:d,fullExpandedMode:f=!1}=t,h=s?.swaps??[],g=f?Wo():B(),m=Gd(h),y=_(c,2,2);return R.createElement(R.Fragment,null,R.createElement(rb,{onClickFee:d?S=>{S.stopPropagation(),o(!e)}:void 0,fee:y,feeWarning:p,timeWarning:u,time:l,steps:a,tooltipGas:d?$t.t("View more info"):void 0,tooltipContainer:g}),R.createElement(ee,{id:"widget-quote-cost-explanation-modal",container:g,open:e,anchor:f?"center":"bottom",styles:{container:{maxWidth:f?"484px":"unset"}},header:R.createElement(Tg,{style:{textAlign:f?"left":"center"}},R.createElement(At,{variant:"title",size:"medium"},$t.t("Gas & Fee Explanation")),R.createElement(ob,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},R.createElement(tb,{color:"gray",size:14}))),onClose:()=>{o(!1)}},R.createElement(Cg,null,R.createElement(At,{variant:"title",size:"small"},$t.t("Details")),R.createElement(ra,{size:10}),Object.entries(m.payable).flatMap(([S,C])=>C.map((k,x)=>{let w=`payable-fee-${x}`,I=Ks(k);return R.createElement(na,{key:w},R.createElement(At,{variant:"label",size:"medium",color:"neutral600"},Hs(S,$t.t)),R.createElement(nb,{content:k.amount,container:g},R.createElement(At,{variant:"label",size:"medium"},_(k.amount,2,2),k.asset.symbol," ($",_(I,4,4),")")))})),R.createElement(na,{className:"total_payable_fee"},R.createElement(At,{variant:"label",size:"medium"},$t.t("Total Payable Fee")),R.createElement(At,{variant:"label",size:"medium"},"$",_(c,4,4))),R.createElement(Yl,null),!!Object.keys(m.nonePayable).length&&R.createElement(Xi,{triggerAnchor:"bottom",onClickTrigger:()=>r(S=>!S),trigger:R.createElement("div",{className:kg()},R.createElement(At,{size:"small",variant:"body",color:"neutral700"},n?$t.t("Hide non-payable fees"):$t.t("Show non-payable fees")),R.createElement(ra,{size:4,direction:"horizontal"}),R.createElement(Ki,{orientation:n?"up":"down"},R.createElement(eb,{size:12,color:"gray"}))),open:n},R.createElement(At,{size:"small",variant:"title"},$t.t("Description")),R.createElement(ra,{size:4}),R.createElement(At,{size:"small",variant:"body",color:"neutral700"},$t.t(`The following fees are considered in the transaction output and
2
- you won\u2019t need to pay extra gas for them.`)),R.createElement(ra,{size:10}),Object.entries(m.nonePayable).map(([S,C],k)=>{let x=qd(C),w=Hs(S,$t.t),I=`non-payable-fee-${k}`;return R.createElement(ib,{key:I,fee:x,label:w})}),R.createElement(Yl,null)))))}i(Zl,"QuoteCostDetails");import{i18n as bg}from"@lingui/core";import{TokenAmount as Eg}from"@rango-dev/ui";import ia from"react";import{css as ab,styled as sb}from"@rango-dev/ui";var vg=sb("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),xg=ab({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function Cr(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return ia.createElement(vg,null,ia.createElement(Eg,{direction:"horizontal",label:bg.t("Swap input"),id:"widget-quote-summary-swap-input",type:"input",tooltipContainer:B(),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}}),ia.createElement("div",{className:xg()}),ia.createElement(Eg,{id:"widget-quote-summary-estimated-input",direction:"horizontal",tooltipContainer:B(),label:bg.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(Cr,"QuoteSummary");import{i18n as Wg}from"@lingui/core";import{ChevronDownIcon as pb,ChevronRightIcon as ub,Divider as Jl,Image as db,Tooltip as pa,Typography as sa}from"@rango-dev/ui";import q from"react";import{useLayoutEffect as lb,useState as Tr}from"react";var Ig=480,Ag=768,Ng=1024,Bg=1200,cb=i(()=>{let[t,e]=Tr(!1),[o,n]=Tr(!1),[r,a]=Tr(!1),[s,c]=Tr(!1),[l,p]=Tr(!1),u=i(()=>{e(window.innerWidth<=Ig),n(window.innerWidth>Ig&&window.innerWidth<=Ag),a(window.innerWidth>Ag&&window.innerWidth<=Ng),c(window.innerWidth>Ng&&window.innerWidth<=Bg),p(window.innerWidth>Bg)},"handleResize");return lb(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:l}},"useScreenDetect"),aa=cb;var la=4,ca=6,kr=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,c=s||B();return q.createElement(pa,{container:c,side:"bottom",sideOffset:4,open:r,content:e},q.createElement(mg,{className:n,state:a},q.createElement(db,{src:o,size:16})))},"ImageComponent");function Mg(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:c}=t,l=c||B(),p=r.length,u=Pd(r),{isTablet:d,isMobile:f}=aa();return q.createElement(dg,{className:"widget-quote-trigger-btn",listItem:s==="list-item",ref:h=>e.current=h,selected:o,onClick:h=>{h.stopPropagation(),n(g=>!g)}},q.createElement("div",{className:Wn()},q.createElement(sa,{variant:"body",size:"xsmall"},Wg.t("Via:")),q.createElement(Jl,{direction:"horizontal",size:4}),r.map((h,g)=>{let m=`item-${g}`,y=q.createElement(Vl,null,q.createElement(ub,{size:12,color:"black"}));return f||d?q.createElement(q.Fragment,{key:m},q.createElement(kr,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&q.createElement(q.Fragment,null,y)):q.createElement(q.Fragment,{key:m},p<=la||p>la&&g<la-1?q.createElement(q.Fragment,null,q.createElement(kr,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&q.createElement(q.Fragment,null,y)):g===la-1&&q.createElement(pa,{container:l,side:"bottom",align:"end",sideOffset:4,content:q.createElement("div",{className:Wn()},y,r.map((S,C)=>{let k=`image-${C}`;return C>=g&&q.createElement(q.Fragment,{key:k},q.createElement(kr,{content:S.swapper.displayName,src:S.swapper.image??"",state:S.state,open:!1}),C!==p-1&&q.createElement(q.Fragment,null,y))}))},q.createElement(Xl,{state:r.find((S,C)=>C>=g&&(S.state==="error"||S.state==="warning"))?.state},q.createElement(sa,{size:"xsmall",variant:"body"},"+",p-g))))})),q.createElement("div",{className:Wn()},q.createElement("div",{className:"blockchains_section"},q.createElement("div",{className:Wn()},q.createElement(sa,{variant:"body",size:"xsmall"},Wg.t("Chains:")),q.createElement(Jl,{direction:"horizontal",size:4}),u.map((h,g)=>q.createElement(q.Fragment,{key:h.displayName},u.length<=ca||u.length>ca&&g<ca-1?q.createElement(pa,{container:l,side:"bottom",content:h.displayName,sideOffset:4},q.createElement(kr,{content:"",src:h.image??"",open:!1,className:g!==0?"blockchainImage":""})):g===ca-1&&q.createElement(pa,{container:l,side:"bottom",align:"end",sideOffset:4,content:q.createElement("div",{className:Wn()},u.map((m,y)=>y>=g&&q.createElement(kr,{key:m.displayName,content:"",src:m.image??"",open:!1,className:y>g?"blockchainImage":"",container:c})))},q.createElement(Xl,{className:"blockchainImage"},q.createElement(sa,{size:"xsmall",variant:"body"},"+",u.length-g))))),q.createElement(Jl,{direction:"horizontal",size:32}))),q.createElement(Vl,{orientation:a?"up":"down"},q.createElement(pb,{size:12,color:"black"}))))}i(Mg,"QuoteTrigger");function nc(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:d=!1,container:f}=t,h=T().blockchains(),{findToken:g}=T(),m=T().swappers(),{customSlippage:y,slippage:S}=T(),C=y||S,[k,x]=Cb(t.expanded),w=ua(null),I=_(n.value,6,6),A=n.usdValue?_(n.usdValue,4,4):"",{config:{__UNSTABLE_OR_INTERNAL__:b}}=T(),E=jt(o.usdValue,n.usdValue??null),v=_(E,2,2),N=Xt(E??0),M=i((G,Ve)=>G.map((V,Ce)=>{let Je,ht=r?.type===3&&r.swap.swapperId===V.swapperId,so=r?.type===4&&!!r.recommendedSlippages?.[Ce],zn=a?.type===2&&!!a.recommendedSlippages?.[Ce],Io=ht||so,Zr=zn;Io?Je="error":Zr&&(Je="warning");let Ro=Io?qo.t("Slippage Error"):qo.t("Slippage Warning");return ht&&(Ro=qo.t("Bridge Limit Error")),{swapper:{displayName:Qn(V.swapperId,m)??"",image:V.swapperLogo},from:{token:{displayName:V.from.symbol,image:V.from.logo},chain:{displayName:yt(V.from.blockchain,h)??"",image:V.from.blockchainLogo},price:{value:Ce===0&&!Ve?_(o.value,6,6):_(V.fromAmount,6,6),usdValue:_((V.from.usdPrice??0)*parseFloat(V.fromAmount),4,4),realValue:Ce===0?o.value:V.fromAmount,realUsdValue:new oc(V.from.usdPrice??0).multipliedBy(V.fromAmount).toString()}},to:{token:{displayName:V.to.symbol,image:V.to.logo},chain:{displayName:yt(V.to.blockchain,h)||"",image:V.to.blockchainLogo},price:{value:_(V.toAmount,6,6),usdValue:_((V.to.usdPrice??0)*parseFloat(V.toAmount),4,4),realValue:V.toAmount,realUsdValue:new oc(V.to.usdPrice??0).multipliedBy(V.toAmount).toString()}},state:Je,alerts:Io||Zr?F.createElement(ng,{dense:d},F.createElement(mb,{variant:"alarm",type:Io?"error":"warning",title:Ro,id:"widget-quote-footer-step-alarm-alert",footer:F.createElement(rg,null,ht&&F.createElement("div",null,F.createElement(Ln,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Mn,{direction:"vertical",size:2}),F.createElement(Ln,{size:"xsmall",variant:"body",className:"from-amount-text",color:"neutral900"},qo.t({id:"Yours: {amount} {symbol}",values:{amount:_(V.fromAmount,6,6),symbol:V?.from.symbol}}))),(so||zn)&&!ht&&F.createElement("div",null,F.createElement(Ln,{size:"xsmall",variant:"body",color:"neutral900"},qo.t({id:"Minimum suggested slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.[Ce]},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.[Ce]}}})),F.createElement(Mn,{direction:"vertical",size:2}),F.createElement(Ln,{size:"xsmall",variant:"body",color:"neutral900"},qo.t({id:"Yours: {userSlippage}",values:{userSlippage:C}}))))})):void 0,time:Gn(V.estimatedTimeInSeconds),fee:_(Vs(V,g),2,2),internalSwaps:V.internalSwaps?M(V.internalSwaps):void 0}}),"getQuoteSteps"),P=M(e?.swaps??[]),U=P.length,Q=f||B(),Z=Dd(t.quote.tags||[]),W=!!u,J=si(e?.swaps),X=Gn(J),ae=Bi(e?.swaps??[],g),Se=_(ae,2,2),at=ae.gte(new oc(Ed)),ue=J/Ad>=Id,gt=ua(null),vt=tc(o.value,gt),xt=ua(null),O=tc(n.value,xt),z=ua(null),Y=tc(A,z),te=P[U-1],j=P[0];return!j||!te?null:d?F.createElement(gb,{selected:c,fee:Se,time:X,tooltipContainer:Wo(),steps:P,tags:Z,campaignTag:b?.campaignTag,id:"widget-quote-full-expanded-quote-container",quoteCost:F.createElement(Zl,{quote:e,fullExpandedMode:!0,time:X,fee:ae,feeWarning:at,timeWarning:ue,showModalFee:p,steps:U}),percentageChange:v,warningLevel:N,outputPrice:{value:I,usdValue:A,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(cg,{id:"widget-quote-summary-container",selected:c,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:pg()},!l&&Z.length?F.createElement(F.Fragment,null,F.createElement(yg,null,Z.map((G,Ve)=>{let V=`${G.value}_${Ve}`;return F.createElement(F.Fragment,{key:V},G.value=="CAMPAIGN"&&b?.campaignTag?F.createElement(fb,{routeTag:G,...b.campaignTag}):F.createElement(hb,{label:G.label,value:G.value}),F.createElement(Mn,{size:4,direction:"horizontal"}))})),F.createElement(ta,null),!W&&F.createElement(Mn,{size:4})):null,F.createElement("div",{id:"portal-root",className:ug()},F.createElement(Zl,{quote:e,time:X,fee:ae,feeWarning:at,timeWarning:ue,showModalFee:p,steps:U}),W&&F.createElement(lg,{onClick:G=>{G.stopPropagation(),u()},id:"widget-quote-all-routes-btn",size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Ln,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},qo.t("See All Routes")))),s==="basic"&&F.createElement(hg,null,F.createElement(jl,{ref:gt,size:"small",variant:"body"},o.value),vt&&F.createElement(ec,{content:o.value,container:Q,open:o.value?void 0:!1},F.createElement(Rl,{size:12,color:"gray"})),F.createElement(Kl,{size:"small",variant:"body"},P[0]?.from.token.displayName),F.createElement(Ln,{size:"small",variant:"body"},"="),F.createElement(jl,{ref:xt,size:"small",variant:"body"},n.value),O&&F.createElement(ec,{content:n.value,container:Q,open:n.value?void 0:!1},F.createElement(Rl,{size:12,color:"gray"})),F.createElement(Kl,{size:"small",variant:"body"},te?.to.token.displayName),F.createElement(Mn,{size:2,direction:"horizontal"}),F.createElement(Sg,{ref:z,color:"$neutral600",size:"xsmall",variant:"body"},`($${A})`),Y&&F.createElement(ec,{content:n.usdValue,container:Q},F.createElement(Rl,{size:12,color:"gray"}))),s==="list-item"&&F.createElement(Sb,{id:"widget-quote-token-amount-container",tooltipContainer:Q,type:"output",direction:"vertical",price:{value:I,usdValue:A,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:te.to.token.displayName,image:te.to.token.image},chain:{image:te.to.chain.image},percentageChange:v,warningLevel:N}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(Cr,{from:j.from,to:te.to,percentageChange:v,warningLevel:N}),F.createElement(Mn,{size:4}))),F.createElement(ag,{selected:c,listItem:s==="list-item",open:k,className:"quote_container",onOpenChange:x},F.createElement(Mg,{type:s,quoteRef:w,selected:c,setExpanded:x,container:Q,expanded:k,steps:P}),F.createElement(fg,{open:k},F.createElement(gg,null),F.createElement("div",{className:sg()},P.map((G,Ve)=>{let V=`item-${Ve}`;return F.createElement(yb,{type:"quote-details",className:"widget-quote-step-details-container",key:V,tooltipContainer:Q,step:G,hasSeparator:Ve!==P.length-1,state:G.state})})))))}i(nc,"Quote");import{Divider as vb,Skeleton as xb}from"@rango-dev/ui";import eo from"react";import{darkTheme as Tb,styled as da}from"@rango-dev/ui";var Lg=da("div",{$$color:"$colors$neutral100",[`.${Tb} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Pg=da("div",{paddingTop:"$2"}),_g=da("div",{paddingLeft:"$8"}),Dg=da("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Vg,Divider as Nt,Skeleton as ut}from"@rango-dev/ui";import K from"react";import{css as kb,styled as Rt}from"@rango-dev/ui";var rc=Rt("div",{display:"flex"}),$g=Rt("div",{padding:"$10 $0 $20"}),Fg=Rt("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Og=Rt("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Ug=Rt("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),zg=Rt("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),Hg=Rt("div",{width:"65%",display:"flex",justifyContent:"start"}),Qg=Rt("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),qg=Rt("div",{padding:"$15 $0 $15 $0"}),Gg=kb({display:"flex",justifyContent:"space-between",alignItems:"center"});function wr(t){let{type:e,tagHidden:o=!0}=t,n=K.createElement(Ug,null,K.createElement(Hg,null,K.createElement(Vg,{loading:!0,size:"medium"}),K.createElement(Nt,{size:8,direction:"horizontal"}),K.createElement(Qg,null,K.createElement(ut,{height:10,width:60,variant:"rounded"}),K.createElement(Nt,{size:4}),K.createElement(ut,{height:15,variant:"rounded"}))),K.createElement(ut,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return K.createElement("div",null,!o&&K.createElement(K.Fragment,null,K.createElement(rc,null,K.createElement(ut,{width:65,height:20,variant:"rounded"}),K.createElement(Nt,{size:4,direction:"horizontal"}),K.createElement(ut,{width:65,height:20,variant:"rounded"}),K.createElement(Nt,{size:4,direction:"horizontal"}),K.createElement(ut,{width:65,height:20,variant:"rounded"})),K.createElement(ta,null),!r&&K.createElement(Nt,{size:4})),K.createElement("div",{className:Gg()},K.createElement(rc,null,K.createElement(ut,{width:60,height:10,variant:"rounded"}),K.createElement(Nt,{size:4,direction:"horizontal"}),K.createElement(ut,{width:60,height:10,variant:"rounded"}),K.createElement(Nt,{size:4,direction:"horizontal"}),K.createElement(ut,{width:60,height:10,variant:"rounded"})),r&&K.createElement(ut,{width:85,height:24,variant:"rounded"})),e==="basic"&&K.createElement($g,null,K.createElement(ut,{height:15,width:148,variant:"rounded"})),e==="list-item"&&K.createElement(Fg,null,K.createElement(Og,null,K.createElement(Vg,{loading:!0,size:"medium"}),K.createElement(Nt,{direction:"horizontal",size:4}),K.createElement(ut,{height:15,width:150,variant:"rounded"})),K.createElement(Nt,{size:10}),K.createElement(ut,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&K.createElement(K.Fragment,null,K.createElement(Nt,{size:4}),K.createElement(qg,null,n,K.createElement(zg,null),n),K.createElement(Nt,{size:12})))}i(wr,"QuoteSummarySkeleton");import{ChainToken as Zg,Divider as ac,NextIcon as wb,Skeleton as ma}from"@rango-dev/ui";import We from"react";import{styled as vr}from"@rango-dev/ui";var Kg=vr("div",{display:"flex",alignItems:"start"}),jg=vr("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),ic=vr("div",{display:"flex",alignItems:"center",flexGrow:1}),Xg=vr("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Yg=vr("div",{display:"flex",alignItems:"center"});function Ft(t){let{separator:e=!0}=t;return We.createElement(We.Fragment,null,We.createElement(Yg,null,We.createElement(ma,{height:22,width:22,variant:"circular"}),We.createElement(ac,{direction:"horizontal",size:8}),We.createElement(ma,{height:15,width:148,variant:"rounded"})),We.createElement(Kg,null,We.createElement(Dg,{hideSeparator:!e}),We.createElement(jg,{extraSpace:e},We.createElement(ic,null,We.createElement(Zg,{size:"small",loading:!0}),We.createElement(ac,{direction:"horizontal",size:8}),We.createElement(ma,{height:12,variant:"rounded"})),We.createElement(Xg,null,We.createElement(wb,{color:"gray",size:16})),We.createElement(ic,null,We.createElement(Zg,{size:"small",loading:!0}),We.createElement(ac,{direction:"horizontal",size:8}),We.createElement(ma,{height:12,variant:"rounded"})))))}i(Ft,"StepSkeleton");function xr(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return eo.createElement(Lg,{expanded:o,rounded:e!=="basic"},eo.createElement(wr,{type:e,tagHidden:n}),eo.createElement(Pg,null,eo.createElement(xb,{height:15,variant:"rounded"})),o&&eo.createElement(_g,null,eo.createElement(vb,{size:24}),eo.createElement(Ft,null),eo.createElement(Ft,null),eo.createElement(Ft,{separator:!1})))}i(xr,"QuoteSkeleton");function Go(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:c,onClick:l,showModalFee:p,selected:u,id:d,onClickAllRoutes:f,fullExpandedMode:h=!1,container:g}=t,{inputAmount:m,inputUsdValue:y}=H()(),S=e?.outputAmount?new bb(e?.outputAmount):null,C=e?Ct(e):null,x=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?fa.createElement(ql,null,fa.createElement(xr,{tagHidden:c,type:o,expanded:s})):x?fa.createElement(ql,{onClick:()=>l?.(e),id:d},fa.createElement(nc,{quote:e,error:r,container:g,showModalFee:p,warning:a,tagHidden:c,selected:u,type:o,expanded:s,onClickAllRoutes:f,fullExpandedMode:h,input:{value:m,usdValue:y?.toString()??""},output:{value:S?.toString()??"",usdValue:C?.toString()??""}})):null}i(Go,"QuoteInfo");import{warn as Nb}from"@rango-dev/logging-core";import{calculatePendingSwap as Bb}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Wb}from"react";import{useRef as Eb,useState as Ib}from"react";var Ab=2e3;function ga({request:t}){let[e,o]=Ib(!1),n=Eb(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async c=>(await new Promise(l=>setTimeout(l,Ab)),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(ga,"useFetch");function Jg(){let{fetch:t,loading:e,cancelFetch:o}=ga({request:async(n,r)=>await ct().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Jg,"useFetchConfirmQuote");function ha(t){if(!t.swaps)throw new Error(re().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=sc(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(ha,"throwErrorIfResponseIsNotValid");function sc(t){if(zd(t)){let{swap:n,fromAmountRangeError:r,recommendation:a}=Hd(t);return n?{message:"bridge limit error",options:{type:3,swap:n,recommendation:a,fromAmountRangeError:r}}:null}let o=Vd(t);if(o){let n=Wi(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(sc,"getQuoteError");function Rg(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,c={quote:null,balance:null},l=Cn({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});l&&(c.quote=l);let p=Xd(e,r,n.blockchains);return p.length===0||(c.balance={messages:p}),c}i(Rg,"generateWarnings");function ya(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(ya,"handleQuoteErrors");function lc(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:c}=H()(),{slippage:l,customSlippage:p}=T(),u=T().getDisabledLiquiditySources(),d=T().blockchains(),f=T().tokens(),{findToken:h}=T(),{swapMode:g}=tt(),m=p||l,{fetch:y,cancelFetch:S,loading:C}=Jg();return Wb(()=>S,[]),{loading:C,fetch:i(async x=>{let w=x.selectedWallets,I=x?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=w.reduce((E,v)=>(E[v.chain]=v.address,E),{}),b={requestId:a?.requestId||"",selectedWallets:A,destination:I||void 0};try{return await y(b,!0).then(E=>{let{result:v}=E;if(!v)throw new Error(E.error??"Error fetching updated quote");ha({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 M={slippage:m.toString(),disabledSwappersGroups:u},P=Rg({previousQuote:a??void 0,currentQuote:N,meta:{blockchains:d},selectedWallets:w,userSlippage:m,inputUsdValue:n,findToken:h});c();let U=!!P.balance,Q=Bb({inputAmount:o.toString(),bestRoute:v,wallets:jd(w),settings:M,validateBalanceOrFee:!U,meta:{blockchains:d,tokens:f},swapMode:g});return{quote:N,swap:Q,error:null,warnings:P}})}catch(E){let v=ya(E);return v.type!==2&&Nb(new Error("confirm swap error"),{tags:{...v,type:Xe[v.type],initialQuote:a,requestBody:b}}),{swap:null,error:v,warnings:null}}},"fetch"),cancelFetch:S}}i(lc,"useConfirmSwap");var zb=_b("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${eh}`]:{width:"$48",height:"$48"}}),Hb=uc({flexGrow:1,paddingRight:"$10"}),Qb=uc({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),qb=uc({display:"flex",justifyContent:"space-between",alignItems:"center"});function th(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=H()(),s=Ub(),[c,l]=br(""),p=!n,[u,d]=br(!1),[f,h]=br(!1),{isActiveTab:g}=ne(),m=T().getDisabledLiquiditySources(),y=Ob(m),{manager:S}=Mb(),{fetch:C,loading:k,cancelFetch:x}=lc(),[w,I]=br({swap:null,error:null,warnings:null}),[A,b]=br(!1),E=i(async({selectedWallets:W,customDestination:J})=>{let X=await C?.({selectedWallets:W,customDestination:J});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 W=`../${$.swaps}/${w.swap.requestId}`;s(W,{replace:!0}),setTimeout(()=>{e("")},0)}catch(W){l("Error: "+W?.message)}},"addNewSwap"),N=i(async()=>{h(!0),await v(),h(!1)},"onConfirm"),M=i(async()=>{w.warnings?.quote&&Ld(w.warnings.quote)&&!a?b(!0):await N()},"onStartConfirmSwap"),P=i(async()=>{I({error:null,swap:null,warnings:null}),C({selectedWallets:o,customDestination:r}).then(W=>{I(W)}).catch(W=>console.error(W))},"onRefresh");Sa(()=>{!!y.current.length&&!m.length&&P(),y.current=m},[m.length]),Sa(()=>{p&&x()},[p]),Sa(()=>{p&&d(p)},[p]),Sa(()=>{p||C({selectedWallets:o,customDestination:r}).then(W=>I(W)).catch(W=>console.error(W))},[]),Fb(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let U=w.warnings?.quote??null,Q=w.error,Z=[];if(c&&Z.push(De.createElement(Lb,{id:"widget-confirm-swap-db-error-alert",type:"error",variant:"alarm",title:c})),U||Q){let W=`../${$.settings}`;Z.push(De.createElement(Sr,{warning:U,error:Q,couldChangeSettings:!1,refetchQuote:P,skipAlerts:Q?.type===4||U?.type===2,showWarningModal:A,confirmationDisabled:!g,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:async()=>{b(!1),await v()},onChangeSettings:()=>s(W)}))}return De.createElement(se,{header:{title:cc.t("Confirm Swap"),onWallet:()=>{let W=`../${$.wallets}`;s(W)}},footer:De.createElement(zb,null,De.createElement("div",{className:Hb()},De.createElement(Pb,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:k||f,disabled:!!w.error||!g,onClick:M},cc.t("Start Swap"))),De.createElement(eh,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:k||f,disabled:!g,onClick:d.bind(null,!0)},De.createElement($b,{size:24})))},u&&De.createElement(Df,{open:u,onClose:()=>d(!1),onCancel:x,loading:k,onCheckBalance:E}),De.createElement(ce,null,De.createElement("div",{className:qb()},De.createElement(Db,{variant:"title",size:"small"},cc.t("You get")),De.createElement("div",{className:Qb()},De.createElement(Oi,{onClick:!k&&!u&&!A?P:void 0}))),De.createElement(pc,{size:"12"}),Em(Z.map((W,J)=>({element:W,key:`alert-${J}`})),De.createElement(pc,{size:10})),Z.length>0?De.createElement(pc,{size:10}):null,De.createElement(Go,{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(th,"ConfirmSwapPage");import{i18n as oo}from"@lingui/core";import{Button as vc,CustomTokensZeroStateDarkIcon as pE,CustomTokensZeroStateIcon as uE,DeleteIcon as dE,Divider as Br,IconButton as mE,MessageBox as fE,NotFound as gE,styled as bc}from"@rango-dev/ui";import he,{useState as xc}from"react";import{useNavigate as hE}from"react-router-dom";import{CloseIcon as Gb,IconButton as Vb,SearchIcon as Kb,TextField as jb}from"@rango-dev/ui";import Pn from"react";import{styled as oh}from"@rango-dev/ui";var nh=oh("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"}),rh=oh("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,...d}=t,f=s.length?Pn.createElement(Vb,{id:`${u}\u06F0icon-btn`,variant:"ghost",onClick:()=>l?.(""),size:"small"},Pn.createElement(Gb,{color:"gray",size:10})):null;return p&&(f=p),Pn.createElement(rh,null,Pn.createElement(jb,{prefix:Pn.createElement(nh,null,Pn.createElement(Kb,{color:"black"})),id:u,suffix:f,fullWidth:o,color:n,variant:e,style:{borderRadius:25,alignItems:"center",...c},size:r,value:s,onChange:a,...d}))}i(Bt,"SearchInput");import{i18n as wc}from"@lingui/core";import{Button as Jb,CustomTokenWarning as Rb,darkTheme as hh,Divider as to,ExternalLinkIcon as eE,Image as tE,ListItem as oE,NotFound as nE,PinIcon as rE,Skeleton as Vo,Typography as Ar,VirtualizedList as iE}from"@rango-dev/ui";import L,{useState as aE}from"react";import{useTranslation as sE}from"react-i18next";import{Divider as fh,ListItem as Zb,Skeleton as Ir}from"@rango-dev/ui";import Wt from"react";import{css as _n,darkTheme as dc,ImageContainer as Xb,ListItemButton as Yb,styled as rt,Typography as ih}from"@rango-dev/ui";var mc=_n({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),fc=_n({position:"relative",height:12,width:"30%",maxWidth:"150px"}),gc=_n({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),hc=_n({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${dc} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),yc=_n({}),Sc=_n(),ah=rt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Cc=rt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Ca=rt("ul",{flexGrow:1,height:"100%",padding:0,margin:0,display:"flex",flexDirection:"column",listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${fc}`]:{[`& .${hc}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${yc}`]:{bottom:"-15px"},[`& .${mc}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${gc}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),sh=rt(Yb,{variants:{customToken:{true:{"&:hover":{cursor:"unset"}}}}}),Tc=rt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),kc=rt(ih,{}),lh=rt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Sc}`]:{$$color:"$colors$neutral600",[`.${dc} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Er=rt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),xV=rt("div",{display:"flex",alignItems:"center"}),ch=rt("div",{position:"relative",[`& ${Xb}`]:{borderRadius:"$xm",overflow:"hidden"}}),ph=rt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),uh=rt(ih,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),dh=rt("a",{"& svg:hover":{color:"$colors$info"}}),mh=rt("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":{[`.${dc} &`]:{color:"$foreground"}}}});function gh(t){return Wt.createElement(Ca,null,Array.from(Array(t.size),e=>Wt.createElement(Zb,{key:e,hasDivider:!0,start:Wt.createElement(Ir,{variant:"circular",width:35,height:35}),end:Wt.createElement(Er,null,Wt.createElement(Ir,{variant:"text",size:"large",width:70}),Wt.createElement(fh,{size:4}),Wt.createElement(Ir,{variant:"text",size:"medium",width:50})),title:Wt.createElement("div",null,Wt.createElement(Ir,{variant:"text",size:"large",width:90}),Wt.createElement(fh,{size:4}),Wt.createElement(Ir,{variant:"text",size:"medium",width:90}))})))}i(gh,"LoadingTokenList");var lE=20,cE=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,c=e.length;return L.createElement("div",{className:fc()},o?L.createElement("div",{className:mc()},o):L.createElement(Cc,{className:gc()},L.createElement(Ar,{variant:"title",size:"xmedium"},r.symbol),L.createElement(to,{direction:"horizontal",size:4}),L.createElement(Tc,{css:a},L.createElement(kc,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&L.createElement("div",{className:`${hc()} ${!o&&yc()}`},c>10?`${e.slice(0,5)}...${e.slice(c-6,c)}`:e," ",L.createElement(to,{size:4,direction:"horizontal"}),L.createElement(dh,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:l=>l.stopPropagation()},L.createElement(eE,{size:12}))))},"renderDesc");function Nr(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:d,fetchingWallets:f}=T(),{isTokenPinned:h}=T(),{setFromToken:g,setToToken:m}=H()(),{t:y}=sE(),S=Qe(),[C,k]=aE(null),x=i(()=>{c==="source"?g({token:C,meta:{blockchains:u}}):m({token:C,meta:{blockchains:u}})},"updateToken"),w=i(()=>{x(),S()},"handleImportToken"),I=i(E=>{if(E.customToken){let{customToken:N,...M}=E;return L.createElement(Jb,{variant:"contained",type:"primary",size:"small",className:"widget-token-list-item-import-btn",onClick:i(U=>{U.stopPropagation(),k({...M,warning:!0})},"handleClick")},L.createElement(Ar,{variant:"body",size:"xsmall",color:"background"},y("import")))}let v=ui(d(E));return s?s(E):f?L.createElement(Er,null,L.createElement(Vo,{variant:"text",size:"large",width:70}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:50})):v&&L.createElement(lh,null,L.createElement(uh,{variant:"title",size:"small"},v.amount),L.createElement("div",null),v.usdValue&&L.createElement(Ar,{variant:"body",className:Sc(),size:"xsmall"},`$${v.usdValue}`))},"endRenderer"),A=i(()=>L.createElement(iE,{style:{flexGrow:1,minHeight:0},itemContent:E=>{let v=e[E];if(v==="skeleton")return L.createElement(oE,{hasDivider:!0,start:L.createElement(Vo,{variant:"circular",width:35,height:35}),end:L.createElement(Er,null,L.createElement(Vo,{variant:"text",size:"large",width:70}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:50})),title:L.createElement("div",null,L.createElement(Vo,{variant:"text",size:"large",width:90}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:90}))});let N=u.find(W=>W.name===v?.blockchain);if(!N||!v)return null;let M=v.address,P=ll(N.color,"main"),U={$$color:P.main150,[`.${hh} &`]:{$$color:P.main750},backgroundColor:"$$color"},Q={$$color:P.main750,[`.${hh} &`]:{$$color:P.main150},color:"$$color"},Z=i(()=>{typeof v!="string"&&!v.customToken&&n?.(v)},"handleClick");return L.createElement(mh,null,L.createElement(sh,{"tab-index":E,key:`${v.symbol}${M}`,id:`${v.symbol}${M}`,className:"widget-token-list-item-btn",hasDivider:!0,customToken:v?.customToken,onClick:Z,start:L.createElement(ch,null,L.createElement(tE,{src:v.image===""?ti:v.image,size:30}),t.type!=="custom-token"&&v&&h(v,t.type)&&L.createElement(ph,null,L.createElement(rE,{size:12,color:"gray"}))),title:N.type==="COSMOS"||v.name||!v.name&&!M?L.createElement(Cc,null,L.createElement(Ar,{variant:"title",size:"xmedium"},v.symbol),L.createElement(to,{direction:"horizontal",size:4}),L.createElement(Tc,{css:U},L.createElement(kc,{variant:"body",size:"xsmall",css:Q},v.blockchain)),l&&v.warning&&L.createElement(L.Fragment,null,L.createElement(to,{direction:"horizontal",size:4}),L.createElement(Rb,{container:B()}))):void 0,description:typeof v!="string"&&N.info&&M&&N.type!=="COSMOS"?cE({address:M,token:v,customCssForTag:U,customCssForTagTitle:Q,name:v.name,url:N.info.addressUrl.split("{wallet}").join(M)}):v.name||void 0,end:I(v)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList"),b=C?No(C?.blockchain,u):null;return L.createElement(L.Fragment,null,a&&L.createElement(L.Fragment,null,L.createElement(Ar,{variant:"label",size:"large"},wc.t("Select Token")),L.createElement(to,{size:4})),L.createElement(ah,null,L.createElement(to,{size:4}),p==="loading"&&L.createElement(gh,{size:lE}),p==="success"&&(e.length?L.createElement(L.Fragment,null,L.createElement(mr,{token:C,address:C?.address??"",blockchain:b??void 0,onImport:w,onExitErrorModal:()=>k(null),onExitImportModal:()=>k(null)}),L.createElement(Ca,{as:"ul"},A())):!!o&&L.createElement(nE,{title:wc.t("No results found"),description:wc.t("Try using different keywords")}))))}i(Nr,"TokenList");var yE=bc("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),SE=bc("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),CE=bc(mE,{"&:hover":{"& svg":{color:"$secondary550"}}});function yh(){let[t,e]=xc(""),{deleteCustomToken:o}=T(),n=T().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:c}=H()(),{mode:l}=mo({}),p=hE(),[u,d]=xc(!1),[f,h]=xc(),g=i(C=>{let k=C.target.value;e(k)},"handleSearch"),m=l==="dark",y=n.filter(C=>st(C.symbol,t)||st(C.address||"",t)||st(C.name||"",t)),S=i(()=>{if(f){let C=a?St(a):null,k=r?St(r):null,x=St(f);C===x?c({token:null}):k===x&&s({token:null}),o(f)}d(!1)},"handleDeleteCustomToken");return he.createElement(se,{header:{title:oo.t("Custom Tokens")}},he.createElement(ce,null,he.createElement(yE,null,n.length?he.createElement(he.Fragment,null,he.createElement(Bt,{id:"widget-custom-tokens-search-token-input",value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:oo.t("Search Token"),onChange:g}),he.createElement(Br,{size:16}),he.createElement(Nr,{list:y,type:"custom-token",searchedFor:t,showTitle:!1,showWarning:!1,action:C=>he.createElement(CE,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{d(!0),h(C)}},he.createElement(dE,{size:12,color:"gray"}))})):he.createElement(SE,null,he.createElement(gE,{icon:m?he.createElement(pE,{size:200}):he.createElement(uE,{size:200}),title:oo.t("No custom tokens"),description:oo.t("press the button to add your custom token")})),he.createElement(Br,{size:20}),he.createElement(vc,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p($.addCustomTokens)},oo.t("Add Custom Token"))),he.createElement(ee,{open:u,id:"widget-custom-tokens-delete-modal",dismissible:!0,onClose:()=>d(!1),container:B()},he.createElement(fE,{title:oo.t("Delete Custom Token"),type:"error",description:oo.t("Are you sure you want to Delete this Token?")},he.createElement(Br,{size:40}),he.createElement(Br,{size:10}),he.createElement(vc,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},oo.t("Yes, Delete it")),he.createElement(Br,{size:12}),he.createElement(vc,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>d(!1)},oo.t("No, Continue"))))))}i(yh,"CustomTokensPage");import{i18n as $e}from"@lingui/core";import{useManager as OE}from"@rango-dev/queue-manager-react";import{Button as Mc,darkTheme as UE,Divider as To,MessageBox as zE,NotFound as HE,styled as Lc,Tabs as QE,Typography as wa}from"@rango-dev/ui";import{TransactionStatus as Lr}from"rango-types";import oe,{useMemo as Dh,useState as Pr}from"react";import{useNavigate as qE}from"react-router-dom";import{FilterIcon as EE,Popover as IE}from"@rango-dev/ui";import Ko from"react";import{css as TE,darkTheme as Ta,IconButton as kE,styled as Wr}from"@rango-dev/ui";var Ec=Wr("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${Ta} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),Sh=Wr(kE,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${Ta} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Ta} &`]:{backgroundColor:"$neutral"},[`& ${Ec}::before`]:{backgroundColor:"$secondary100",[`.${Ta} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),Ch=Wr("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),Th=Wr("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),kh=TE({display:"flex",justifyContent:"space-between",alignItems:"center"}),wh=Wr("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as vh}from"@lingui/core";import{Button as wE,Divider as xh,ListItemButton as vE,Radio as xE,RadioRoot as bE,Typography as bh}from"@rango-dev/ui";import dt from"react";function Eh(t){let{filterBy:e,onClickItem:o}=t;return dt.createElement(Th,null,dt.createElement("div",{className:kh()},dt.createElement(bh,{size:"small",variant:"body"},vh.t("Status")),dt.createElement(wE,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},vh.t("Reset"))),dt.createElement(xh,{size:10}),dt.createElement(bE,{value:e},dt.createElement(wh,null,t.list.map((n,r)=>dt.createElement(vE,{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:dt.createElement(dt.Fragment,null,dt.createElement(xh,{direction:"horizontal",size:4}),dt.createElement(bh,{size:"medium",variant:"body"},n.title)),start:dt.createElement(xE,{value:n.id}),onClick:o})))))}i(Eh,"FilterSelectorContent");function Ic(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return Ko.createElement("div",null,Ko.createElement(IE,{open:a,align:"end",onOpenChange:o,container:B(),content:Ko.createElement(Eh,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},Ko.createElement(Sh,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},Ko.createElement(Ec,{isSelect:!!n},Ko.createElement(EE,{size:16,color:"black"}),!!n&&Ko.createElement(Ch,null)))))}i(Ic,"FilterSelector");import{i18n as BE}from"@lingui/core";import{getCurrentStep as WE}from"@rango-dev/queue-manager-rango-preset";import{Divider as Wh,GroupedVirtualizedList as ME,Skeleton as LE,SwapListItem as Mh,Typography as PE}from"@rango-dev/ui";import Ye,{useCallback as Lh,useEffect as _E,useRef as DE,useState as $E}from"react";function Ih(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(Ih,"calculateGroupsSoFar");import{css as AE,darkTheme as NE,styled as Mr}from"@rango-dev/ui";var Ac=AE(),Ah=Mr("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),Nc=Mr("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${Ac}`]:{$$color:"$colors$neutral600",[`.${NE} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Bc=Mr("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),Nh=Mr("div",{gap:"$10",display:"flex",flexDirection:"column"}),Bh=Mr("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var FE=10;function Wc(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=$E([]),c=DE(0),{swaps:l,groupCounts:p,groups:u}=n(e),d=Lh(Ih,[]),f=Lh(()=>{let h=e.length-c.current;h&&(c.current+=Math.min(h,FE),s(d(p,c.current)))},[e.length]);if(_E(()=>{r||f()},[r,f]),r){let h=[1,2];return Ye.createElement(Ye.Fragment,null,[h,h].map((m,y)=>Ye.createElement(Nc,{key:y},Ye.createElement(Bc,null,Ye.createElement(LE,{variant:"text",width:60,size:"small"}),Ye.createElement(Wh,{size:16})),Ye.createElement(Wh,{size:4}),Ye.createElement(Nh,null,m.map((C,k)=>Ye.createElement(Mh,{isLoading:!0,key:k}))))))}return Ye.createElement(ME,{style:{flexGrow:1,minHeight:0},endReached:()=>{c.current<e.length&&f()},groupCounts:a,groupContent:h=>Ye.createElement(Nc,null,Ye.createElement(Bc,null,Ye.createElement(PE,{variant:"label",size:"medium",className:Ac()},u[h]))),itemContent:(h,g)=>{let m=l[h];if(!m)return null;let y=WE(m),S=m.steps[0],C=m.steps[m.steps.length-1];return!S||!C?null:Ye.createElement(Ah,{key:m.requestId},Ye.createElement(Mh,{className:"widget-history-group-list-swap-item-btn",requestId:m.requestId,creationTime:m.creationTime,status:m.status,onClick:o,currentStep:y,tooltipContainer:B(),onlyShowTime:u[g]===BE.t("Today"),swapTokenData:{from:{token:{image:S.fromLogo,displayName:S.fromSymbol},blockchain:{image:S.fromBlockchainLogo||""},amount:_(m.inputAmount,6,6),realAmount:m.inputAmount},to:{token:{image:C.toLogo,displayName:C.toSymbol},blockchain:{image:C.toBlockchainLogo||""},amount:_(C.outputAmount||C.expectedOutputAmountHumanReadable||"",6,6),realAmount:C.outputAmount||C.expectedOutputAmountHumanReadable||""}}}))}})}i(Wc,"HistoryGroupedList");import{i18n as ka}from"@lingui/core";import Ph from"dayjs";var _h=i(t=>{let e=new Map([["today",{title:ka.t("Today"),swaps:[]}],["week",{title:ka.t("This week"),swaps:[]}],["month",{title:ka.t("This month"),swaps:[]}],["year",{title:ka.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=Ph();t.forEach(l=>{let p=Number(l.creationTime),u=Ph(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 d=new Date(p).getFullYear().toString();o(d,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 GE=Lc("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%",minHeight:0,flexGrow:1}),VE=Lc("div",{display:"flex",justifyContent:"center",alignItems:"center"}),KE=Lc("div",{"._typography":{color:"$neutral700",[`.${UE}&`]:{color:"$neutral900"}}}),jE=i((t,e)=>t?.length?t.filter(o=>Pt(o.fromBlockchain,e)||Pt(o.toBlockchain,e)||Pt(o.toSymbol,e)||Pt(o.fromSymbol,e)).length:!1,"isStepContainsText");function $h(){let t=qE(),{manager:e,state:o}=OE(),n=kt(e).map(({swap:b})=>b),[r,a]=Pr(""),[s,c]=Pr(!1),l=!o.loadedFromPersistor,[p,u]=Pr(""),[d,f]=Pr(!1),[h,g]=Pr("all"),m=i(b=>{let E=b.target.value;a(E)},"handleSearch"),{isMultiMode:y}=tt(),S=[{id:Lr.SUCCESS,title:$e.t("Complete")},{id:Lr.RUNNING,title:$e.t("Running")},{id:Lr.FAILED,title:$e.t("Failed")}],C=[{id:"all",title:$e.t("All")},{id:"swap",title:$e.t("Swap")},{id:"refuel",title:$e.t("Refuel")}],k=Dh(()=>!r&&!p&&h==="all"?n:n.filter(b=>{let{inputAmount:E,status:v,steps:N,requestId:M,mode:P}=b;return(!r||Pt(E,r)||Pt(v,r)||jE(N,r)||Pt(M,r))&&(!p||p===v)&&(h==="all"?!0:h==="swap"?!P||P==="swap":h==="refuel"?P==="refuel":!1)}),[n,r,p,h]),x=!k?.length&&!l,w=i(()=>f(!1),"onCloseModal"),I=i(async()=>{try{await e?.clearQueue(),f(!1)}catch(b){console.log(b)}},"onClear"),A=Dh(()=>!n.some(b=>b.status===Lr.SUCCESS||b.status===Lr.FAILED),[n]);return oe.createElement(se,{header:{title:$e.t("History"),suffix:oe.createElement(fo,null,oe.createElement(Mc,{id:"widget-history-clear-btn",disabled:A,variant:"ghost",size:"xsmall",onClick:()=>f(!0)},oe.createElement(wa,{size:"medium",variant:"label",color:"error"},$e.t("Clear"))))}},oe.createElement(ce,null,oe.createElement(VE,null,oe.createElement(Bt,{setValue:a,fullWidth:!0,variant:"contained",placeholder:$e.t("Search Transaction"),id:"widget-history-search-transaction-input",autoFocus:!0,onChange:m,style:{height:36},value:r}),oe.createElement(To,{size:10,direction:"horizontal"}),oe.createElement(Ic,{filterBy:p,open:s,onOpenChange:b=>c(b),onClickItem:b=>u(b),list:S})),oe.createElement(To,{size:"16"}),y&&!l&&oe.createElement(oe.Fragment,null,oe.createElement(QE,{items:C,onChange:b=>g(b.id),value:h,type:"secondary"}),oe.createElement(To,{size:"12"})),oe.createElement(GE,null,x&&oe.createElement(Bh,null,oe.createElement(To,{size:32}),oe.createElement(HE,{title:r?$e.t("No results found"):$e.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?$e.t("Try using different keywords"):$e.t("Your transaction history is stored locally and will appear here after you start a swap")})),!x&&oe.createElement(Wc,{list:k,onSwapClick:t,groupBy:_h,isLoading:l}))),oe.createElement(ee,{open:d,onClose:w,id:"widget-history-clear-modal",container:B()},oe.createElement(To,{size:20}),oe.createElement(zE,{type:"warning",title:$e.t("Clear Transaction History"),description:oe.createElement(KE,null,oe.createElement(wa,{variant:"body",size:"medium"},$e.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),oe.createElement(To,{size:"24"}),oe.createElement(wa,{variant:"body",size:"small"},$e.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),oe.createElement(To,{size:30}),oe.createElement(Mc,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:I},$e.t("Yes, Clear the history")),oe.createElement(To,{size:10}),oe.createElement(Mc,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:w},oe.createElement(wa,{variant:"title",size:"medium",color:"primary"},$e.t("No, Cancel")))))}i($h,"HistoryPage");import{i18n as my}from"@lingui/core";import{Button as BI,Divider as Kc,styled as WI,WarningIcon as MI}from"@rango-dev/ui";import LI from"bignumber.js";import Te,{useEffect as fy,useState as gy}from"react";import{useNavigate as PI}from"react-router-dom";import{i18n as Oh}from"@lingui/core";import{Alert as YE,Divider as Pc,NoRouteIcon as ZE,Typography as JE}from"@rango-dev/ui";import jo from"react";import{styled as XE}from"@rango-dev/ui";var Fh=XE("div",{display:"flex",flexDirection:"column",alignItems:"center"});function _c(){let{fromToken:t,toToken:e}=H()();return!!t&&!!e&&qt(t,e)?jo.createElement(Fh,null,jo.createElement(Pc,{size:10}),jo.createElement(ZE,{size:24,color:"gray"}),jo.createElement(Pc,{size:4}),jo.createElement(JE,{variant:"title",size:"small"},Oh.t("No Routes Found")),jo.createElement(Pc,{size:4}),jo.createElement(YE,{title:Oh.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(_c,"SameTokensWarning");import{Alert as RE,Button as eI}from"@rango-dev/ui";import zh from"react";import{i18n as va}from"@lingui/core";function Uh(t){let e=null;return t===gi?(e={alertType:"error",action:"reset-slippage",actionButtonTitle:va.t("Reset"),title:va.t("Slippage cannot be set lower than 0.01%.")},e):t>sn?(e={alertType:"warning",action:"change-settings",actionButtonTitle:va.t("Change"),title:va.t("Caution, your slippage is high!")},e):null}i(Uh,"makeAlerts");function Hh(t){let{slippage:e,customSlippage:o,setSlippage:n,setCustomSlippage:r}=T(),{onChangeSettings:a}=t,c=Uh(o!==null?o:e),l=i(p=>{p==="reset-slippage"?(n(fi),r(null)):p==="change-settings"&&a()},"onClickActionButton");return c?zh.createElement(RE,{title:c.title,type:c.alertType,variant:"alarm",action:zh.createElement(eI,{id:"widget-slippage-warning-error-change-settings-or-reset-slippage-btn",size:"xxsmall",type:c.alertType,onClick:()=>l(c.action)},c.actionButtonTitle)}):null}i(Hh,"SlippageWarningsAndErrors");import{i18n as iI}from"@lingui/core";import{IconButton as aI,ReverseIcon as sI,Skeleton as lI,Tooltip as cI,Typography as _r}from"@rango-dev/ui";import mt from"react";import xa from"bignumber.js";function qh(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(qh,"getSlippageColor");function Gh(t){let{toTokenUsdPrice:e,fromTokenUsdPrice:o}=t;if(!e||!o)return{rawValue:"0",displayValue:"0"};let n=new xa(e),r=new xa(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(Gh,"getUsdExchangeRate");function Vh(t,e){let o=new xa(t).multipliedBy(e);return o.isLessThan(.001)?"$0":`$${o.decimalPlaces(2,xa.ROUND_DOWN).toFormat(2)}`}i(Vh,"formatTokenValueInUsd");import{darkTheme as nI,styled as $c,Typography as rI}from"@rango-dev/ui";var Kh=$c("div",{display:"flex",padding:"$4",justifyContent:"space-between",alignItems:"center"}),jh=$c("div",{display:"flex",alignItems:"center",gap:"$2","& .rate-text":{color:"$neutral700",[`.${nI} &`]:{color:"$neutral700"}},"& ._icon-button":{transform:"rotate(90deg)",width:"$16",height:"$16"}}),Fc=$c(rI,{maxWidth:"$32",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});function Oc(t){let{slippage:e,customSlippage:o,quoteTokensRate:n,changeQuoteTokensRate:r}=T(),{quoteError:a,quoteWarning:s,fromToken:c,toToken:l,quote:p,loading:u}=t,d=o!==null?o:e,{mode:f}=mo({}),h=pn(d),g=f==="dark",m=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,x=m?C:k,w=m?k:C,I=Number(m?p?.outputAmount:p?.requestAmount),A=Number(m?p?.requestAmount:p?.outputAmount),b=I||x.usdPrice,E=A||w.usdPrice,{rawValue:v,displayValue:N}=Gh({toTokenUsdPrice:E,fromTokenUsdPrice:b});return mt.createElement(Kh,null,mt.createElement(_r,{variant:y||S?"label":"body",size:y||S?"medium":"small",color:qh({error:y,warning:S,isDarkTheme:g})},iI.t("Slippage:")," ",d,"%"),u?mt.createElement(lI,{height:16,width:104,variant:"rounded"}):b&&E&&mt.createElement(jh,null,mt.createElement(_r,{className:"rate-text",variant:"body",size:"small"},"1"),mt.createElement(Fc,{className:"rate-text",variant:"body",size:"small"},w.symbol),mt.createElement(aI,{id:"widget-home-page-change-rate-button",onClick:r},mt.createElement(sI,{size:14,color:"secondary"})),mt.createElement(cI,{container:B(),side:"top",sideOffset:4,content:mt.createElement(_r,{className:"rate-text",variant:"body",size:"small"},v)},mt.createElement(_r,{className:"rate-text",variant:"body",size:"small"},N)),mt.createElement(Fc,{className:"rate-text",variant:"body",size:"small"},x.symbol),x.usdPrice&&mt.createElement(_r,{color:"neutral600",variant:"body",size:"small"},"~",Vh(Number(v),x.usdPrice))))}i(Oc,"SwapMetrics");import{i18n as gI}from"@lingui/core";import{Header as hI}from"@rango-dev/ui";import ko,{useEffect as yI,useState as SI}from"react";import{i18n as uI}from"@lingui/core";import{Divider as zc,FullExpandedQuote as dI,Typography as mI}from"@rango-dev/ui";import xe from"react";import{styled as Uc}from"@rango-dev/ui";var Xh=Uc("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Yh=Uc("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Zh=Uc("div",{width:"146px"});import{i18n as Dr}from"@lingui/core";import{Select as pI}from"@rango-dev/ui";import Jh from"react";function ba(t){let{updateQuotePartialState:e,sortStrategy:o}=H()(),n=[{value:"SMART",label:Dr.t("Smart Routing")},{value:"FEE",label:Dr.t("Lowest Fee")},{value:"SPEED",label:Dr.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Dr.t("Maximum Return")},{value:"PRICE",label:Dr.t("Maximum Output")}];return Jh.createElement(Zh,null,Jh.createElement(pI,{id:"widget-quotes-strategy-select",container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(ba,"SelectStrategy");var Rh=3;function $r(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:d,toToken:f,sortStrategy:h,error:g}=H()(),{slippage:m,customSlippage:y}=T(),{findToken:S}=T(),C=c||B(),k=!!p&&p.results.length,x=y??m,{config:{__UNSTABLE_OR_INTERNAL__:w}}=T(),I=i(E=>{if(!d||!f||!p)return null;let v={requestAmount:p.requestAmount,validationStatus:null,...E};return Cn({currentQuote:v,userSlippage:x,findToken:S})},"getQuoteWarning"),A=g?.type===0||g?.type===1,b=p?.results?Ni(h,p?.results):[];return xe.createElement(xe.Fragment,null,a&&xe.createElement(xe.Fragment,null,xe.createElement(Yh,null,xe.createElement(mI,{size:"xmedium",variant:"title"},uI.t("Sort by")),xe.createElement(ba,{container:C})),xe.createElement(zc,{size:"10"})),e&&Array.from({length:Rh},(E,v)=>xe.createElement(xe.Fragment,{key:v},s?xe.createElement(dI,{campaignTag:w?.campaignTag,loading:!0}):xe.createElement(xr,{tagHidden:!1,type:"list-item",expanded:!1}),v!==Rh-1&&xe.createElement(zc,{size:16}))),!e&&xe.createElement(xe.Fragment,null,k?b.map((E,v)=>{let N=I(E),M=sc(E.swaps),P=b.length-1===v;return xe.createElement(xe.Fragment,{key:E.requestId},xe.createElement(Go,{id:"widget-quotes-quote-info-container",showModalFee:r,container:C,selected:l?.requestId===E.requestId,tagHidden:!1,quote:{...E,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:M?.options||null,warning:N,fullExpandedMode:s,onClick:U=>{M||u("warning",N),u("error",M?.options||null),o(U)},type:"list-item"}),!P&&xe.createElement(zc,{size:16}))}):A&&xe.createElement(Xh,null,xe.createElement(hr,{size:s?"large":"small",error:g,fetch:n}))))}i($r,"Quotes");import{darkTheme as fI,styled as ey}from"@rango-dev/ui";var ty=ey("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${fI} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),oy=ey("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var CI=100;function Hc(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,c]=SI(!1),l=s?"":"is-hidden",{config:p}=T(),u=p?.variant==="full-expanded",d=Wo();return yI(()=>{let f=null;return a?f=setTimeout(()=>{c(!0)},CI):(c(!1),f&&clearTimeout(f)),()=>{f&&clearTimeout(f)}},[a]),ko.createElement(ty,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${l} ${Qi()} widget-expanded-quotes-container`,id:Re.EXPANDED_BOX_ID},ko.createElement(hI,{title:gI.t("Routes"),suffix:ko.createElement(ko.Fragment,null,ko.createElement(ba,{container:d}),ko.createElement(zo,{container:d,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),ko.createElement(oy,null,ko.createElement($r,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:Wo(),onClickOnQuote:n,fullExpandedMode:u})))}i(Hc,"ExpandedQuotes");import{i18n as cy}from"@lingui/core";import{SwapInput as py}from"@rango-dev/ui";import vI from"bignumber.js";import Fr from"react";import{ReverseIcon as wI}from"@rango-dev/ui";import qc from"react";import{keyframes as TI,styled as ny}from"@rango-dev/ui";var Qc=450,kI=TI({"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)"}}),ry=ny("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),iy=ny("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${kI} ${Qc}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 Gc(){let t=H().use.switchFromAndTo();return qc.createElement(ry,null,qc.createElement(iy,{id:"widget-switch-from-and-to-btn",onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Qc),t()}},qc.createElement(wI,{size:12})))}i(Gc,"SwitchFromAndToButton");import{styled as ay}from"@rango-dev/ui";var sy=ay("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),ly=ay("div",{position:"relative"});function Vc(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:c,toBlockchain:l,setInputAmount:p,sanitizeInputAmount:u,inputAmount:d,inputUsdValue:f,outputAmount:h,outputUsdValue:g,selectedQuote:m}=H()(),{swapMode:y}=tt(),{connectedWallets:S,getBalanceFor:C}=T(),k=a?C(a):null,x=ui(k)?.amount??"0",w=k?new vI(k.amount).shiftedBy(-k.decimals):pe,I=!!s&&Nu(S,s.name),A=!Gs(m,d,f),b=!Gs(m,d,g),E=!f||!g||!g.gt(0)?null:jt(f.toString(),g.toString());return Fr.createElement(sy,null,Fr.createElement(ly,null,Fr.createElement(py,{label:cy.t("From"),id:"widget-swap-from",mode:"From",onInputChange:p,onInputBlur:u,balance:x,chain:{displayName:s?.displayName||"",image:s?.logo},token:{displayName:a?.symbol||"",image:a?.image,securityWarning:!!a?.warning},onClickToken:()=>n("from"),price:{value:d,usdValue:A?void 0:_(f,4,4),realUsdValue:A?void 0:f?.toString(),error:A?re().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:I,tooltipContainer:B(),onSelectMaxBalance:()=>{let v=w.isGreaterThan(pe)?w.toFixed():"";p(v)},anyWalletConnected:S.length>0}),y==="swap"&&Fr.createElement(Gc,null)),Fr.createElement(py,{selectionType:y==="swap"?"token":"chain",sharpBottomStyle:!r&&(!!m||e),label:cy.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:_(jt(f,g),2,2),warningLevel:Xt(E??0),price:{value:_(h,6,6),usdValue:b?void 0:_(g,4,4),realValue:h?.toString(),realUsdValue:b?void 0:g?.toString(),error:b?re().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:B()}))}i(Vc,"Inputs");import{warn as xI}from"@rango-dev/logging-core";import{useCallback as bI,useEffect as EI,useRef as II,useState as AI}from"react";function uy(){let{fetch:t,loading:e,cancelFetch:o}=ga({request:async(n,r)=>await ct().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(uy,"useFetchAllQuotes");var NI=600;function Ea({refetchQuote:t}){let{fetch:e,cancelFetch:o}=uy(),{excludeLiquiditySources:n,routing:r}=T().config,{connectedWallets:a}=T(),c=a.some(ue=>ue.isContractWallet),{fromToken:l,toToken:p,inputAmount:u,inputUsdValue:d,selectedQuote:f,sortStrategy:h,resetQuote:g,error:m,warning:y,setSelectedQuote:S,updateQuotePartialState:C}=H()(),{slippage:k,customSlippage:x,affiliatePercent:w,affiliateRef:I,affiliateWallets:A,fetchStatus:b}=T(),E=T().getLiquiditySources(),v=T().getDisabledLiquiditySources(),N=T().excludeLiquiditySources(),{findToken:M}=T(),{swapMode:P}=tt(),[U,Q]=AI(!0),Z=II(u),W=x??k,X=!l||!p||qt(l,p)||!Vn(u),ae=i(ue=>{Q(ue)},"resetState"),Se=i(ue=>{let{fromToken:gt,toToken:vt,inputAmount:xt,liquiditySources:O,excludeLiquiditySources:z,disabledLiquiditySources:Y,slippage:te,affiliateRef:j,affiliatePercent:G,affiliateWallets:Ve}=ue;if(U||ae(!0),!X&&gt&&vt){g();let V=Kd({fromToken:gt,toToken:vt,inputAmount:xt,liquiditySources:O,excludeLiquiditySources:z,disabledLiquiditySources:Y,wallets:a,slippage:te,affiliateRef:j,affiliatePercent:G,affiliateWallets:Ve,contractCall:c});cn("experimental",r)&&(V.experimental=!0),cn("avoidNativeFee",r)&&(V.avoidNativeFee=!0),cn("enableCentralizedSwappers",r)&&(V.enableCentralizedSwappers=!0),r?.maxLength&&(V.maxLength=r.maxLength),P==="refuel"&&(V.maxLength=1),e(V).then(Ce=>{let Je=Ni(h,Ce.results),ht=_d(f,Je,Ce.requestAmount);Q(!1),C("quotes",Ce),S(ht),ha({diagnosisMessages:Ce.diagnosisMessages,requestId:ht?.requestId||"",swaps:ht?.swaps});let so=ht&&Cn({currentQuote:ht,userSlippage:W,findToken:M});C("warning",so)}).catch(Ce=>{let Je=ya(Ce);(Je.type===0||Je.type===1)&&g(),Je.type!==2&&(C("error",Je),Q(!1),xI(new Error("quote error"),{tags:{...Je,type:Xe[Je.type],requestBody:V}}))})}},"fetch"),at=bI(ri(ue=>{Se(ue)},NI),[X]);return EI(()=>{if(!t){Q(!1);return}if(b!=="success")return;if(X){Q(!1),(f||m||y)&&g();return}if(!Vn(u)&&d?.eq(0)){ae(!1),o();return}g(),ae(!0);let ue=Se;return Z.current&&Z.current!=u&&(ue=at),Z.current=u,ue({inputAmount:u,fromToken:l,toToken:p,liquiditySources:E,excludeLiquiditySources:N,disabledLiquiditySources:v,slippage:W,affiliateRef:I,affiliatePercent:w,affiliateWallets:A,contractCall:c}),o},[b,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,X,E?.length,n,v.length,W,I,w,c,JSON.stringify(A)]),{fetch:()=>Se({inputAmount:u,fromToken:l,toToken:p,liquiditySources:E,excludeLiquiditySources:N,disabledLiquiditySources:v,slippage:W,affiliateRef:I,affiliatePercent:w,affiliateWallets:A,contractCall:c}),loading:U}}i(Ea,"useSwapInput");function dy(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};ve.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(dy,"emitPreventableEvent");var _I=WI("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),DI=300;function hy(){let t=PI(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:c,quotes:l,setSelectedQuote:p,resetQuoteWallets:u,setQuoteWarningsConfirmed:d,updateQuotePartialState:f}=H()(),[h,g]=gy(!1),{isLargeScreen:m,isExtraLargeScreen:y}=aa(),{fetch:S,loading:C}=Ea({refetchQuote:a}),{config:k,fetchStatus:x,connectedWallets:w,customSlippage:I,slippage:A,setSlippage:b,setCustomSlippage:E}=T(),{isActiveTab:v}=ne(),[N,M]=gy(!1),P=I!==null?I:A,{swapMode:U}=tt(),Q=pn(P),W=Qd({fetchMetaStatus:x,fetchingQuote:C,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:c,needsToWarnEthOnPath:!1}),J=Du(m,y,k?.variant),X=!!n&&!!e&&!!o&&new LI(n).gt(0)&&!em(e,o),ae=X&&x==="success"&&C,Se=Q?.quoteValidation||c,gt=(!J||J&&l?.results.length)&&(Se||s),vt=!!e&&!!o,xt=vt&&!!Q,O=(r||s)&&!N?S:void 0,z=i(G=>{J&&h?(g(!1),setTimeout(()=>{t(G)},DI)):t(G)},"onHandleNavigation"),Y=i(G=>{r?.requestId!==G.requestId&&(M(!1),p(G))},"onClickOnQuote"),te=i(G=>{if(G){if(mi.includes(G)){b(G),E(null);return}E(G)}},"onChangeSlippage"),j=i(G=>{z(G==="from"?$.fromSwap:U==="swap"?$.toSwap:$.toSwap+"/"+$.blockchains)},"handleInputTokenClick");return fy(()=>{u(),f("refetchQuote",!0)},[]),fy(()=>{g(X)},[X]),Te.createElement(_I,null,Te.createElement(se,{height:"auto",footer:Te.createElement(BI,{id:`widget-swap-${W.action}-btn`,type:"primary",size:"large",disabled:W.disabled||!v,prefix:W.action==="confirm-warning"&&Te.createElement(MI,null),fullWidth:!0,onClick:()=>{W.action==="connect-wallet"?dy({type:"clickConnectWallet"},()=>z($.wallets)):W.action==="confirm-warning"?M(!0):z($.confirmSwap)}},W.title),header:{onWallet:()=>{z($.wallets)},hasBackButton:!1,title:k.title||(U==="swap"?my.t("Swap"):my.t("Refuel")),suffix:Te.createElement(zo,{hidden:J?["refresh"]:void 0,onClickRefresh:O,onClickHistory:()=>z($.swaps),onClickSettings:()=>{z($.settings)}})}},Te.createElement(ce,null,Te.createElement(Vc,{fetchingQuote:ae,fetchMetaStatus:x,isExpandable:J,onClickToken:j}),Te.createElement(Kc,{size:"2"}),J?null:Te.createElement(Go,{quote:r,loading:ae,error:s,id:"widget-home-expandable-quote-container",tagHidden:!1,warning:Se,type:"basic",onClickAllRoutes:l&&l.results.length>1?()=>{f("refetchQuote",!1),z($.routes)}:void 0}),vt&&Te.createElement(Te.Fragment,null,Te.createElement(Kc,{size:8}),Te.createElement(Oc,{quoteError:s,quoteWarning:Se,fromToken:e,toToken:o,quote:r,loading:ae})),gt?Te.createElement(Te.Fragment,null,Te.createElement(Sr,{warning:Se,error:s,skipAlerts:!!Q,couldChangeSettings:!0,refetchQuote:S,showWarningModal:N,confirmationDisabled:!v,onOpenWarningModal:()=>M(!0),onCloseWarningModal:()=>M(!1),onChangeSlippage:te,onConfirmWarningModal:()=>{M(!1),d(!0),z($.confirmSwap)},onChangeSettings:()=>z($.settings)})):null,xt&&Te.createElement(Te.Fragment,null,Te.createElement(Kc,{size:"10"}),Te.createElement(Hh,{onChangeSettings:()=>z($.settings)})),Te.createElement(_c,null))),J?Te.createElement(Hc,{loading:ae,onClickOnQuote:Y,fetch:S,onClickRefresh:O,isVisible:h}):null)}i(hy,"Home");import{i18n as yy}from"@lingui/core";import{Alert as $I,Divider as FI,List as OI,ListItemButton as UI,Radio as zI,RadioRoot as HI,Typography as QI}from"@rango-dev/ui";import Ot from"react";function wo(){let{setLanguage:t,language:e,config:o}=T(),n=Qu,r=o?.language||un;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||un),resetLanguage:()=>t(null)}}i(wo,"useLanguage");function Sy(){let{activeLanguage:t,changeLanguage:e,languages:o}=wo(),n=Qe(),r=o.map(a=>{let{local:s,label:c,SVGFlag:l}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Ot.createElement(QI,{variant:"title",size:"xmedium"},c),onClick:()=>{e(a.local),n()},end:Ot.createElement(zI,{value:s}),start:Ot.createElement(l,null)}});return Ot.createElement(se,{header:{title:yy.t("Language")}},Ot.createElement(ce,null,Ot.createElement($I,{type:"warning",id:"widget-language-machine-translation-alarm-alert",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Ot.createElement(FI,{size:"8"}),Ot.createElement(HI,{value:t},Ot.createElement(OI,{type:Ot.createElement(UI,{title:yy.t("language"),className:"widget-language-list-item-btn",id:"_",onClick:()=>console.log()}),items:r}))))}i(Sy,"LanguagePage");import{i18n as no}from"@lingui/core";import{Button as jI,Checkbox as XI,Image as YI,ListItemButton as ZI,NotFound as JI,Typography as RI}from"@rango-dev/ui";import Ze,{useState as eA}from"react";import{Checkbox as VI,Skeleton as Ty}from"@rango-dev/ui";import Ur from"react";import{styled as jc}from"@rango-dev/ui";var Or=jc("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),Xc=jc("div",{width:80,display:"flex",justifyContent:"flex-end"}),Yc=jc("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as qI,styled as GI}from"@rango-dev/ui";var Cy=GI(qI,{height:61});var KI=30;function Zc(){return Ur.createElement(Or,null,Array.from(Array(KI),(t,e)=>Ur.createElement(Cy,{hasDivider:!0,key:e,start:Ur.createElement(Ty,{variant:"circular",width:35,height:35}),title:Ur.createElement(Ty,{variant:"text",size:"large",width:90}),end:Ur.createElement(VI,{checked:!1})})))}i(Zc,"LoadingLiquiditySourceList");function Jc({sourceType:t}){let e=T().fetchStatus,o=T().swappers(),n=T().getDisabledLiquiditySources(),[r,a]=eA(""),s=T().toggleLiquiditySource,c=T().isInCampaignMode(),l=hi(o,n),p={Exchanges:no.t("Exchanges"),Bridges:no.t("Bridges")},u=[];t==="Exchanges"&&u.push("DEX"),t==="Bridges"&&u.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let d=l.filter(S=>u.includes(S.type)),f=d.length===d.filter(S=>S.selected).length,h=i(()=>{d.forEach(S=>{f?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),g=d.map(S=>{let{selected:C,groupTitle:k,logo:x,id:w,...I}=S;return{id:`widget-setting-liquidity-source-${hu(w.toLowerCase())}-item-btn`,start:Ze.createElement(YI,{src:x,size:22,type:"circular"}),onClick:()=>{c||s(k)},end:Ze.createElement(XI,{checked:C,disabled:c}),title:Ze.createElement(RI,{variant:"title",size:"xmedium"},no.t(k)),selected:C,groupTitle:k,logo:x,...I}}),m=i(S=>{let C=S.target.value;a(C)},"handleSearch"),y=g;return r&&(y=g.filter(S=>Pt(S.groupTitle,r))),Ze.createElement(se,{header:{title:no.t(t),suffix:Ze.createElement(Xc,null,Ze.createElement(jI,{id:`widget-liquidity-source-${f?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:h},f?no.t("Deselect all"):no.t("Select all")))}},Ze.createElement(ce,{view:!0},Ze.createElement(Bt,{value:r,setValue:a,id:"widget-liquidity-source-search-input",fullWidth:!0,color:"light",variant:"contained",placeholder:no.t("Search {sourceType}",{sourceType:p[t]}),onChange:m}),e==="loading"&&Ze.createElement(Zc,null),!y.length&&r?Ze.createElement(Yc,null,Ze.createElement(JI,{title:no.t("No results found"),description:no.t("Try using different keywords")})):e==="success"&&Ze.createElement(Or,{disabled:c,className:"widget-liquidity-source-list"},y.map(S=>{let{groupTitle:C,...k}=S;return Ze.createElement(Ze.Fragment,{key:S.id},Ze.createElement(ZI,{style:{height:"61px"},...k,selected:!1,className:"widget-liquidity-source-list-item-btn",hasDivider:!0}))}))))}i(Jc,"LiquiditySourcePage");import{i18n as tA}from"@lingui/core";import Ia from"react";import{useNavigate as oA}from"react-router-dom";function ky(){let t=oA(),e=Qe(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=H()(),{fetch:c,loading:l}=Ea({refetchQuote:n}),p=i(f=>{r(f),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${$.settings}`,d=`../${$.wallets}`;return Ia.createElement(se,{header:{onWallet:()=>{t(d),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:tA.t("Routes"),suffix:Ia.createElement(zo,{onClickRefresh:o||s?c:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},Ia.createElement(ce,null,Ia.createElement($r,{fetch:c,loading:l,onClickOnQuote:p})))}i(ky,"RoutesPage");import{i18n as Ay}from"@lingui/core";import{Divider as Ny,getCategoriesCount as dA,SelectableCategoryList as mA}from"@rango-dev/ui";import ro,{useMemo as fA,useState as By}from"react";import{useNavigate as gA}from"react-router-dom";import{i18n as Rc}from"@lingui/core";import{Divider as aA,Image as sA,ListItemButton as lA,NotFound as cA,Typography as Iy}from"@rango-dev/ui";import ft,{useEffect as pA,useState as uA}from"react";var wy=i((t,e,o)=>t.filter(n=>ii(n.type,o)).filter(n=>st(n.name,e)||st(n.displayName,e)),"filterBlockchains");import{ImageContainer as nA,styled as vy}from"@rango-dev/ui";var xy=vy("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Aa=vy(El,{padding:0,margin:0,listStyle:"none",[`& ${nA}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as rA,Skeleton as by}from"@rango-dev/ui";import Na from"react";var iA=20;function Ey(){return Na.createElement(Aa,{id:"widget-blockchain-loading-list",as:"ul"},Array.from(Array(iA),t=>Na.createElement(rA,{key:t,hasDivider:!0,start:Na.createElement(by,{variant:"circular",width:35,height:35}),title:Na.createElement(by,{variant:"text",size:"large",width:90})})))}i(Ey,"LoadingBlockchainList");function ep(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,c]=uA(e),{fetchStatus:l}=T();pA(()=>{c([...wy(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?ft.createElement(cA,{title:Rc.t("No results found"),description:Rc.t("Try using different keywords")}):ft.createElement(Aa,{as:"ul",key:`${r}-${o}`,id:"widget-blockchain-list"},s.map(u=>ft.createElement(lA,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:ft.createElement(sA,{src:u.logo,size:30}),title:ft.createElement(Iy,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return ft.createElement(ft.Fragment,null,a&&ft.createElement(ft.Fragment,null,ft.createElement(Iy,{variant:"label",size:"large"},Rc.t("Select Chain")),ft.createElement(aA,{size:4})),ft.createElement(xy,null,l==="loading"&&ft.createElement(Ey,null),l==="success"&&p()))}i(ep,"BlockchainList");function Ba(t){let{type:e}=t,o=Qe(),[n,r]=By(""),[a,s]=By("ALL"),c=H().use.setToBlockchain(),l=H().use.setFromBlockchain(),p=H().use.setToToken(),{fetchStatus:u,findNativeToken:d}=T(),f=gA(),{swapMode:h}=tt(),g=T().blockchains({type:e}),m=T().tokens(),y=fA(()=>du(g,m),[g.length,m.length]),S=dA(y),C=!t.hideCategory&&S!==1,k=i(x=>{if(e==="custom-token")f(`..?blockchain=${x.name}`,{replace:!0});else{if(e==="source")l(x);else if(h==="swap")c(x);else{let w=d(x);w&&p({token:w,meta:{blockchains:g}})}o()}},"handleBlockchainChange");return ro.createElement(se,{header:{title:Ay.t("Select Chain")}},ro.createElement(ce,{view:!0},C&&ro.createElement(ro.Fragment,null,ro.createElement(mA,{setCategory:s,category:a,blockchains:y,isLoading:u==="loading"}),ro.createElement(Ny,{size:24})),ro.createElement(Bt,{value:n,autoFocus:!0,placeholder:Ay.t("Search Chain"),id:"widget-select-blockchain-search-input",color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:x=>r(x.target.value)}),ro.createElement(Ny,{size:16}),ro.createElement(ep,{list:y,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:k})))}i(Ba,"SelectBlockchainPage");import{i18n as La}from"@lingui/core";import{Divider as $y,Spinner as BA}from"@rango-dev/ui";import vo,{useEffect as WA,useState as MA}from"react";import{useNavigate as LA}from"react-router-dom";import{i18n as np}from"@lingui/core";import{BlockchainsChip as Wa,Divider as Py,Image as _y,Skeleton as kA,Tooltip as wA,Typography as rp}from"@rango-dev/ui";import be from"react";import{useEffect as SA}from"react";var Wy=["ETH","COSMOS","OSMOSIS"];function tp(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(hA),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(yA(s)),r=n.splice(a)}return{list:n,more:r}}i(tp,"prepare");function hA(t,e){let o=Wy,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(hA,"sortByMostUsedBlockchains");function yA(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(yA,"generateSortByPreferredBlockchainsFor");function My(t,e){return!!e.list.find(o=>o.name===t)}i(My,"isInVisibleList");function op(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=T();SA(()=>{if(e?.selected){let a=tp(t,o,e);My(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=tp(t,o,e);return{list:r.list,more:r.more,history:[]}}i(op,"usePrepareBlockchainList");import{styled as CA}from"@rango-dev/ui";var Ly=CA("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var vA=6,xA=12;function ip(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,{showCompactTokenSelector:s}=ne(),c=op(e,{limit:s?4:10,selected:n?.name}),{fetchStatus:l}=T(),p=H().use.resetToBlockchain(),u=H().use.resetFromBlockchain(),d=c.more.length>0,f=c.more[0],h=c.more.length===1&&f,g=!h&&d;return be.createElement(be.Fragment,null,!s&&be.createElement(be.Fragment,null,be.createElement(Py,{size:12}),be.createElement(rp,{variant:"label",size:"large"},np.t("Select Chain"))),be.createElement(Py,{size:12}),be.createElement(Ly,{id:"widget-blockchains-section-container"},l==="loading"&&Array.from(Array(s?vA:xA),(m,y)=>be.createElement(kA,{key:y,variant:"rounded",height:50})),l==="success"&&be.createElement(be.Fragment,null,be.createElement(Wa,{className:"widget-blockchains-section-all-btn",selected:!n,onClick:()=>{o==="from"?u():p()}},be.createElement(rp,{variant:"body",size:"xsmall",color:"secondary500"},np.t("All"))),c.list.map(m=>be.createElement(wA,{key:m.name,content:m.shortName,side:"bottom",sideOffset:2,container:B()},be.createElement(Wa,{className:"widget-blockchains-section-item-btn",key:m.name,selected:!!n&&n.name===m.name,onClick:()=>r(m)},be.createElement(_y,{src:m.logo,size:30})))),h?be.createElement(Wa,{className:"widget-blockchains-section-only-item-btn",key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},be.createElement(_y,{src:f.logo,size:30})):null,g?be.createElement(Wa,{onClick:a,key:"more-blockchains",className:"widget-blockchains-section-more-items-btn"},be.createElement(rp,{variant:"body",size:"xsmall",color:"secondary500"},np._("More +{count}",{count:c.more.length}))):null)))}i(ip,"BlockchainsSection");import{useCallback as EA,useRef as IA,useState as ap}from"react";function sp(){let t=T().blockchains(),e=IA(null),{customTokens:o}=T(),[n,r]=ap(!1),[a,s]=ap([]),[c,l]=ap(null),p=i(async(f,h)=>{l(null),r(!0),s([]);try{let g=await ct().searchCustomTokens({query:f,blockchain:h},{signal:e.current?.signal}),m=new Set(o().map(C=>Vt(C))),y=new Set(t.map(C=>C.name)),S=g.tokens.filter(C=>y.has(C.blockchain)&&!m.has(Vt(C)));s(S),r(!1)}catch(g){l(g instanceof Error?g.message:"something went wrong"),s([]),g?.name!=="CanceledError"&&r(!1)}},"fetch"),u=EA(ri((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(sp,"useSearchCustomTokens");function Ma(t,e,o){return o&&t.length===1&&t[0]?.address===e?!1:t.length<20&&e.trim().length>=3}i(Ma,"shouldSearchForCustomTokens");function Dy(t,e,o,n,r){let a=[...t];return Ma(t,o,r)&&(a=n?[...a,"skeleton","skeleton","skeleton"]:[...a,...e.map(s=>({...s,customToken:!0,warning:!0}))]),a}i(Dy,"prepareTokensList");function Pa(t){let{type:e}=t,o=LA(),n=Qe(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:c,setFromBlockchain:l,setToBlockchain:p}=H()(),{getBalanceFor:u}=T(),{fetch:d,loading:f,tokens:h,cancel:g}=sp(),[m,y]=MA(""),S=e==="source"?r:a,C=S?.name??"",k=T().blockchains({type:e}),x=T().tokens({type:e,blockchain:C,searchFor:m,getBalanceFor:u}),w=Dy(x,h,m,f,S?.name),I=i(E=>{e==="source"?l(E):p(E)},"updateBlockchain"),A=i(E=>{e==="source"?s({token:E,meta:{blockchains:k}}):c({token:E,meta:{blockchains:k}})},"updateToken"),b={source:La.t("Source"),destination:La.t("Destination")};return WA(()=>(Ma(x,m,S?.name)&&d(m,S?.name??void 0),()=>{g()}),[x.length,m,S?.name]),vo.createElement(se,{header:{title:La.t("Swap {type}",{type:b[e]})}},vo.createElement(ce,null,vo.createElement(ip,{blockchains:k,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o($.blockchains),onChange:E=>{I(E)}}),vo.createElement($y,{size:24}),vo.createElement(Bt,{value:m,id:"widget-select-swap-item-search-input",autoFocus:!0,placeholder:La.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>y(""),onChange:E=>y(E.target.value),suffix:Ma(x,m,S?.name)&&f?vo.createElement(BA,{size:12,color:"secondary"}):void 0}),vo.createElement($y,{size:16}),vo.createElement(Nr,{list:w,selectedBlockchain:C,searchedFor:m,type:e,onChange:E=>{A(E);let v=k.find(N=>E.blockchain===N.name);v&&I(v),n()}})))}i(Pa,"SelectSwapItemsPage");import{i18n as up}from"@lingui/core";import{Alert as aN,Button as sN,styled as lN}from"@rango-dev/ui";import Xo from"react";import{useInRouterContext as cN,useSearchParams as pN}from"react-router-dom";import{i18n as Qy}from"@lingui/core";import{Alert as $A,Divider as cp,InfoIcon as FA,SlippageIcon as OA,TextField as UA,Tooltip as zA,Typography as qy}from"@rango-dev/ui";import Oe from"react";import{Chip as PA,styled as zr,TextField as _A}from"@rango-dev/ui";var Fy=zr("div",{paddingTop:"$5",padding:"$10 $5"}),Oy=zr("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${_A}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px",paddingLeft:"$2"}}),Uy=zr("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),_a=zr("div",{maxWidth:"280px",padding:"$10"}),zy=zr(PA,{width:"61px",flexShrink:0});import{i18n as lp}from"@lingui/core";import{Typography as DA}from"@rango-dev/ui";import Hr from"react";function Hy(){return Hr.createElement(_a,null,Hr.createElement(DA,{variant:"label",size:"medium",color:"neutral700"},lp.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Hr.createElement("br",null),Hr.createElement("br",null),Hr.createElement("b",null,lp.t("Warning")),":\xA0",lp.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(Hy,"SlippageTooltipContent");function pp(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=T(),r=o!==null?pn(o):null,a=i(l=>{let p=l.target.value,u=parseFloat(p);if(isNaN(u))return n(null);let d=u;u>Yn&&(d=Yn),n(d)},"onSlippageValueChange"),s=i(l=>{o!==null&&n(null),e(l)},"onClickSlippageChip"),c=i(l=>{let p=l.target,u=p.value;Cu(u)||(p.value=u.slice(0,-1))},"onInput");return Oe.createElement(Fy,null,Oe.createElement(Uy,null,Oe.createElement(OA,{size:16,color:"gray"}),Oe.createElement(cp,{direction:"horizontal",size:4}),Oe.createElement(qy,{variant:"title",size:"xmedium"},Qy.t("Slippage tolerance per swap")),Oe.createElement(cp,{direction:"horizontal",size:4}),Oe.createElement(zA,{container:B(),side:"top",sideOffset:4,content:Oe.createElement(Hy,null)},Oe.createElement(FA,{color:"gray"}))),Oe.createElement(Oy,null,mi.map((l,p)=>{let u=`slippage-${p}`;return Oe.createElement(zy,{id:`widget-slippage-chip-${l.toString()}%-btn`,key:u,onClick:()=>s(l),selected:o===null&&l===t,label:`${l.toString()}%`})}),Oe.createElement(UA,{type:"number",min:"0.01",max:"30",step:"0.01",status:r?.type||(o?"success":"default"),id:"widget-slippage-chip-text-input",onInput:c,fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:a,suffix:o&&Oe.createElement(qy,{variant:"body",size:"small"},"%"),placeholder:Qy.t("Custom")})),r&&Oe.createElement(Oe.Fragment,null,Oe.createElement(cp,{size:10}),Oe.createElement($A,{id:"widget-slippage-alert",variant:"alarm",type:r.type,title:r.message})))}i(pp,"Slippage");import{i18n as wt}from"@lingui/core";import{AutoThemeIcon as Gy,BridgesIcon as HA,ChevronRightIcon as Da,DarkModeIcon as Vy,Divider as Qr,ExchangeIcon as QA,InfinityIcon as qA,InfoIcon as GA,LanguageIcon as VA,LightModeIcon as Ky,List as KA,ListItem as jA,ListItemButton as XA,Skeleton as YA,styled as ZA,Switch as JA,Tabs as RA,TargetIcon as eN,Tooltip as tN,Typography as it}from"@rango-dev/ui";import D from"react";import{useNavigate as oN}from"react-router-dom";var nN=ZA("div",{width:"202px",height:"$40"}),rN=[{id:"light",icon:D.createElement(Ky,{color:"black",size:24}),tooltip:D.createElement(it,{size:"xsmall",variant:"body"},wt.t("Light"))},{id:"dark",icon:D.createElement(Vy,{color:"black",size:24}),tooltip:D.createElement(it,{size:"xsmall",variant:"body"},wt.t("Dark"))},{id:"auto",icon:D.createElement(Gy,{color:"black",size:24}),tooltip:D.createElement(it,{size:"xsmall",variant:"body"},wt.t("Auto"))}],iN=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return D.createElement(Gy,{...e});case"dark":return D.createElement(Vy,{...e});default:return D.createElement(Ky,{...e})}},"getThemeIcon");function jy(){let t=oN(),{theme:e}=T().config,{setTheme:o,theme:n}=T(),{activeLanguage:r,languages:a}=wo(),s=a.find(W=>W.local===r)?.label,c=T().fetchStatus,l=T().swappers(),p=T().getDisabledLiquiditySources(),{config:{features:u}}=T(),d=T().customTokens(),f=et("theme",u),h=et("liquiditySource",u),g=et("language",u),m=et("customTokens",u),y=T().infiniteApprove,S=T().toggleInfiniteApprove,C=hi(l,p),k=C.filter(W=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(W.type)),x=k.length,w=k.filter(W=>W.selected).length,I=C.filter(W=>W.type==="DEX"),A=I.length,b=I.filter(W=>W.selected).length,E=i((W,J)=>{switch(c){case"loading":return D.createElement(YA,{variant:"text",size:"medium",width:50});case"failed":return D.createElement(it,{variant:"body",size:"medium",color:"$error500"},wt.t("Loading failed"));default:return D.createElement(it,{variant:"body",size:"medium"},`${W} / ${J}`)}},"handleSwapperEndItem"),v={id:"widget-setting-bridge-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Bridges")),end:D.createElement(D.Fragment,null,E(w,x),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(Da,{color:"black"})),onClick:()=>t($.bridges),start:D.createElement(HA,{color:"gray",size:16})},N={id:"widget-setting-exchange-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Exchanges")),end:D.createElement(D.Fragment,null,E(b,A),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(Da,{color:"black"})),start:D.createElement(QA,{color:"gray",size:16}),onClick:()=>t($.exchanges)},M={id:"widget-setting-custom-tokens-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Custom Tokens")),end:D.createElement(D.Fragment,null,D.createElement(it,{variant:"body",size:"medium"},`${d.length}`),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(Da,{color:"black"})),start:D.createElement(eN,{color:"gray",size:16}),onClick:()=>t($.customTokens)},P={id:"widget-setting-language-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Language")),start:D.createElement(VA,{color:"gray",size:16}),end:D.createElement(D.Fragment,null,D.createElement(it,{variant:"body",size:"medium"},s),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(Da,{color:"black"})),onClick:()=>t($.languages)},U={id:"widget-setting-infinite-approval-item-btn",title:D.createElement(D.Fragment,null,D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Infinite approval")),D.createElement(Qr,{direction:"horizontal",size:4}),D.createElement(tN,{side:"top",sideOffset:4,container:B(),content:D.createElement(_a,null,D.createElement(it,{variant:"label",size:"medium",color:"neutral700"},D.createElement("b",null,wt.t("Warning")),":\xA0",wt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},D.createElement(GA,{color:"gray"}))),start:D.createElement(qA,{color:"gray",size:16}),end:D.createElement(JA,{checked:y}),onClick:S},Q={id:"widget-setting-theme-item-btn",type:D.createElement(jA,null),title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Theme")),end:D.createElement(nN,null,D.createElement(RA,{container:B(),items:rN,value:n,className:"widget-setting-theme-item-tabs-container",onChange:W=>o(W.id),type:"primary",borderRadius:"small"})),start:iN(n)},Z=h?[]:[v,N];return m||Z.push(M),g||Z.push(P),Z.push(U),!e?.singleTheme&&!f&&Z.push(Q),D.createElement(KA,{type:D.createElement(XA,{className:"widget-settings-list-item-btn",hasDivider:!0,id:"_",onClick:()=>console.log()}),items:Z})}i(jy,"SettingsLists");var uN=lN("div",{paddingLeft:"$8"});function Xy(){let{isInCampaignMode:t,updateCampaignMode:e}=T(),o=t(),[,n]=pN(),r=cN(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Xo.createElement(se,{header:{title:up.t("Settings")}},Xo.createElement(ce,null,o&&Xo.createElement(aN,{type:"info",variant:"alarm",id:"widget-settings-campaign-mode-alert",title:up.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:Xo.createElement(uN,null,Xo.createElement(sN,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},up.t("Reset")))}),Xo.createElement(pp,null),Xo.createElement(jy,null)))}i(Xy,"SettingsPage");import{i18n as k0}from"@lingui/core";import{cancelSwap as w0}from"@rango-dev/queue-manager-rango-preset";import{useManager as v0}from"@rango-dev/queue-manager-react";import{Alert as x0}from"@rango-dev/ui";import Ap from"react";import{useParams as b0}from"react-router-dom";import{i18n as zt}from"@lingui/core";import{getCurrentNamespaceOfOrNull as s0,getCurrentStep as l0,getRelatedWalletOrNull as c0}from"@rango-dev/queue-manager-rango-preset";import{Button as QS,Divider as p0,QuoteCost as u0,StepDetails as d0,Typography as wp}from"@rango-dev/ui";import{useWallets as m0}from"@rango-dev/wallets-react";import qS from"bignumber.js";import{PendingSwapNetworkStatus as Fn}from"rango-types";import we,{useEffect as vp,useRef as xp,useState as Ga}from"react";import{useNavigate as f0}from"react-router-dom";import{i18n as xo}from"@lingui/core";var dN=[xo.t("Sunday"),xo.t("Monday"),xo.t("Tuesday"),xo.t("Wednesday"),xo.t("Thursday"),xo.t("Friday"),xo.t("Saturday")];function Yy(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"):`${dN[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Yy,"timeSince");function Zy(t){return t.finishTime?Yy(parseInt(t.finishTime)):Yy(parseInt(t.creationTime))}i(Zy,"getSwapDate");import qr from"react";import{i18n as $a}from"@lingui/core";import{Button as Jy,Divider as dp,MessageBox as mN}from"@rango-dev/ui";import bo from"react";var Ry=i(({onCancel:t,onClose:e})=>bo.createElement(bo.Fragment,null,bo.createElement(dp,{size:20}),bo.createElement(mN,{type:"error",title:$a.t("Cancel Swap"),description:$a.t("Are you sure you want to cancel this swap?")}),bo.createElement(dp,{size:32}),bo.createElement(Jy,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},$a.t("Yes, Cancel it")),bo.createElement(dp,{size:12}),bo.createElement(Jy,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},$a.t("No, Continue"))),"CancelContent");import{i18n as Fa}from"@lingui/core";import{Button as eS,Divider as mp,MessageBox as fN,Typography as gN}from"@rango-dev/ui";import io from"react";var tS=i(({onDelete:t,onClose:e})=>io.createElement(io.Fragment,null,io.createElement(mp,{size:20}),io.createElement(fN,{type:"error",title:Fa.t("Delete Transaction"),description:Fa.t("Are you sure you want to delete this swap?")}),io.createElement(mp,{size:32}),io.createElement(eS,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Fa.t("Yes, Delete it")),io.createElement(mp,{size:12}),io.createElement(eS,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},io.createElement(gN,{variant:"title",size:"medium",color:"primary"},Fa.t("No, Cancel")))),"DeleteContent");import{i18n as hN}from"@lingui/core";import{Button as yN,Divider as SN,MessageBox as CN}from"@rango-dev/ui";import Yo from"react";var oS=i(t=>{let{switchNetworkModalState:e,handleSwitchNetwork:o}=t;return Yo.createElement(Yo.Fragment,null,Yo.createElement(CN,{type:e.type,title:e.title,description:e.description}),e.type==="error"&&Yo.createElement(Yo.Fragment,null,Yo.createElement(SN,{size:"30"}),Yo.createElement(yN,{id:"widget-switch-network-try-again",type:"primary",size:"large",onClick:o},hN.t("Try Again"))))},"NetworkStateContent");import{getCurrentNamespaceOfOrNull as $N,getCurrentStep as FN,getRelatedWalletOrNull as ON}from"@rango-dev/queue-manager-rango-preset";import{WalletState as UN}from"@rango-dev/ui";import{useWallets as zN}from"@rango-dev/wallets-react";import cS from"react";import{i18n as Dn}from"@lingui/core";import{Alert as iS,Button as wN,Checkbox as vN,Divider as za,Image as xN,MessageBox as bN,Spinner as EN,WarningIcon as IN}from"@rango-dev/ui";import{useWallets as AN}from"@rango-dev/wallets-react";import ye,{useState as NN}from"react";import{css as TN,darkTheme as kN,styled as fp}from"@rango-dev/ui";var nS=TN({wordWrap:"break-word",display:"block"}),rS=fp("img",{width:"100%"}),Oa=fp("div",{position:"relative"}),Ua=fp("span",{position:"absolute",top:0,right:0,borderRadius:"50%",width:"14px",height:"14px",display:"flex",padding:"$2",backgroundColor:"$warning300",[`.${kN} &`]:{$$color:"$warning600"}});var aS=i(t=>{let{wallet:e,namespace:o,onClose:n}=t,[r,a]=NN(null),{list:s}=bt(),c=ne.use.isActiveTab(),{state:l,connect:p}=AN(),u=s.find(w=>w.type===e.walletType),d=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,m=u.isHub?h?.connected:f.connected,y=i(()=>m?Dn.t("Done"):r?Dn.t("Try again"):Dn.t("Connect"),"getButtonTitle"),S=i(()=>g?ye.createElement(EN,{color:"info"}):r||m?null:ye.createElement(vN,{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(m){n();return}C()},"handleClickButton"),x=i(()=>{if(!m)return null;let w=u?.isHub?h?.accounts?.[0]?.split(":"):f?.accounts?.[0]?.split(":"),I=w?.[w?.length-1];return I?lo(I):null},"getAddress");return ye.createElement(ye.Fragment,null,ye.createElement(bN,{type:"warning",title:Dn.t("Connect {wallet}",{wallet:u.title}),description:Dn.t("The connection of your wallet or some networks has been disconnected. Connect to continue the swap"),icon:ye.createElement(Oa,null,ye.createElement(xN,{src:u.image,size:45}),ye.createElement(Ua,null,ye.createElement(IN,{color:"warning",size:10})))}),m&&!d&&ye.createElement(ye.Fragment,null,ye.createElement(za,{size:10}),ye.createElement(iS,{type:"success",variant:"alarm",title:Dn.t("Wallet connected successfully.")})),r&&!d&&ye.createElement(ye.Fragment,null,ye.createElement(za,{size:10}),ye.createElement(iS,{type:"error",title:r?.message,variant:"alarm"})),d&&ye.createElement(ye.Fragment,null,ye.createElement(za,{size:30}),ye.createElement(_o,{namespace:d,suffix:S(),error:r?.message,connected:m,address:x()})),ye.createElement(za,{size:"40"}),ye.createElement(wN,{loading:g,type:"primary",id:"widget-connect-wallet-btn",onClick:k,disabled:!c},y()))},"ConnectWalletContent");import{i18n as sS}from"@lingui/core";import{Button as BN,Divider as WN,Image as MN,MessageBox as LN,WarningIcon as PN}from"@rango-dev/ui";import{useWallets as _N}from"@rango-dev/wallets-react";import{detectInstallLink as DN}from"@rango-dev/wallets-shared";import ao from"react";var lS=i(t=>{let{walletType:e}=t,{getWalletInfo:o}=_N(),n=e?o(e):null;if(!n)return null;let r=i(()=>window.open(DN(n.installLink),"_blank"),"handleButtonClick");return ao.createElement(ao.Fragment,null,ao.createElement(LN,{type:"warning",title:sS.t("Install {wallet}",{wallet:n.name}),description:"Your wallet is not installed. Please install it to continue the swap. ",icon:ao.createElement(Oa,null,ao.createElement(MN,{src:n.img,size:45}),ao.createElement(Ua,null,ao.createElement(PN,{color:"warning",size:10})))}),ao.createElement(WN,{size:"40"}),ao.createElement(BN,{type:"primary",id:"widget-install-wallet-btn",onClick:r},sS.t("Install")))},"InstallWalletContent");var pS=i(t=>{let{swap:e,onClose:o}=t,{state:n,getWalletInfo:r}=zN(),a=FN(e),s=a?ON(e,a):null,c=s?.walletType,l=c?Kn(r(c),n(c)):null,p=a?$N(e,a):null;return c?l===UN.NOT_INSTALLED?cS.createElement(lS,{walletType:c}):cS.createElement(aS,{wallet:s,namespace:p,onClose:o}):null},"WalletStateContent");function gp(t){let{isOpen:e,state:o,switchNetworkModalState:n,onClose:r,onDelete:a,onCancel:s,swap:c,message:l,handleSwitchNetwork:p}=t;return qr.createElement(ee,{open:e,onClose:r,container:B()},o==="connectWallet"&&qr.createElement(pS,{swap:c,message:l,onClose:r}),o==="switchNetwork"&&n&&qr.createElement(oS,{message:l,switchNetworkModalState:n,handleSwitchNetwork:p}),o==="delete"&&qr.createElement(tS,{onClose:r,onDelete:()=>{r(),a()}}),o==="cancel"&&qr.createElement(Ry,{onClose:r,onCancel:()=>{r(),s()}}))}i(gp,"SwapDetailsModal");import{i18n as Gr}from"@lingui/core";import{Button as hp,Divider as Vr,MessageBox as mS,TokenAmount as HN,Typography as fS}from"@rango-dev/ui";import ke from"react";import{Link as QN,useNavigate as qN}from"react-router-dom";var uS="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",dS="/profile";function yp(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:c,token:l,chain:p,percentageChange:u,description:d,diagnosisUrl:f}=t,h=qN(),{showProfileBanner:g}=ne();return ke.createElement(ee,{open:e,onClose:o,id:"widget-swap-details-complete-modal",container:document.getElementById(Re.SWAP_BOX_ID)||document.body},n==="success"?ke.createElement(mS,{type:"success",title:Gr.t("Swap Successful")},ke.createElement(HN,{direction:"vertical",tooltipContainer:B(),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}),ke.createElement(Vr,{size:12}),ke.createElement(fS,{className:nS(),variant:"body",size:"medium",color:"neutral700",align:"center"},d)):ke.createElement(mS,{type:"error",title:Gr.t("Transaction Failed"),description:d}),ke.createElement(Vr,{size:30}),n==="success"&&ke.createElement(ke.Fragment,null,g&&ke.createElement(ke.Fragment,null,ke.createElement(QN,{to:dS},ke.createElement(rS,{src:uS,alt:"Profile Banner"})),ke.createElement(Vr,{size:30})),ke.createElement(hp,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{h("../../")}},Gr.t("Done"))),ke.createElement(Vr,{size:12}),f&&ke.createElement(ke.Fragment,null,ke.createElement(hp,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(f,"_blank")},Gr.t("Diagnosis")),ke.createElement(Vr,{size:12})),ke.createElement(hp,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},ke.createElement(fS,{variant:"title",size:"medium",color:"primary"},Gr.t("See Details"))))}i(yp,"SwapDetailsCompleteModal");import{i18n as qa}from"@lingui/core";import{CopyIcon as o0,DoneIcon as n0,IconButton as r0,RangoExplorerIcon as i0,Tooltip as $S,Typography as FS,useCopyToClipboard as a0}from"@rango-dev/ui";import Mt from"react";import t0 from"react";import{i18n as ZN}from"@lingui/core";import{Alert as LS,IconButton as JN,LinkIcon as RN}from"@rango-dev/ui";import Eo,{Fragment as e0}from"react";import{Alert as VN,ChevronDownIcon as KN,IconButton as jN}from"@rango-dev/ui";import $n,{useState as XN}from"react";import{css as Kr,darkTheme as gS,styled as Ut,Typography as GN}from"@rango-dev/ui";var hS=Ut(ce,{overflowY:"auto","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${gS} &`]:{color:"$secondary500"}}}}}),yS=Ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),SS=Ut("div",{position:"sticky",top:0,zIndex:10,backgroundColor:"$background"}),CS=Ut("div",{padding:"$0 $20 $20 $20"}),AY=Ut("div",{display:"flex",flexDirection:"column",gap:"$10"}),TS=Ut("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),NY=Ut("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),Zo=Kr({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${gS} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),kS=Kr({padding:"$5 0"}),Ha=Kr({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),wS=Kr({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),vS=Kr({width:"100%",padding:"0 $20 $10"}),xS=Ut("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),bS=Ut("div",{display:"flex",flexDirection:"column",gap:"$5"}),Qa=Ut(GN,{wordBreak:"break-word"});import{styled as Sp}from"@rango-dev/ui";var ES=Sp("div",{display:"flex",flexDirection:"column",gap:"$10"}),IS=Sp("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),AS=Sp("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function NS(t){let{message:e}=t,[o,n]=XN(!1);return $n.createElement(VN,{id:"widget-failed-swap-details-alert",type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&$n.createElement(jN,{id:"widget-swap-details-failed-btn",onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},$n.createElement(IS,{rotated:o},$n.createElement(KN,{size:12,color:"gray"}))),footer:$n.createElement(AS,{open:o},$n.createElement(Qa,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(NS,"FailedAlert");import{i18n as BS}from"@lingui/core";import{Alert as Cp,Button as WS}from"@rango-dev/ui";import{PendingSwapNetworkStatus as YN}from"rango-types";import jr from"react";function MS(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,setNetworkModal:n,message:r,showNetworkModal:a}=t;return e?jr.createElement(Cp,{type:"warning",id:"widget-swap-details-change-network-alert",title:r.shortMessage,action:jr.createElement(WS,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{n("switchNetwork"),o()}},BS.t("Change"))}):a===YN.WaitingForConnectingWallet?jr.createElement(Cp,{type:"warning",title:r.shortMessage,id:"widget-swap-details-warning-alert-connect-wallet-alert",action:jr.createElement(WS,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{n("connectWallet")}},BS.t("Connect"))}):jr.createElement(Cp,{id:"widget-swap-details-short-alert",type:"warning",title:r.shortMessage})}i(MS,"WarningAlert");function Tp(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a,step:s,hasAlreadyProceededToSign:c}=t,l=pr(s),p=s.status==="waitingForApproval"&&!l,u=s.status==="running"&&!l,d=u&&!c||p&&!s.explorerUrl?.length;return Eo.createElement(ES,null,s.explorerUrl?.map((f,h,g)=>{let m=h+f.url,y=h===g.length-1,S=(y&&u||p)&&!d,C=y&&s.status==="failed";return Eo.createElement(e0,{key:m},Eo.createElement(LS,{id:"widget-swap-details-tx-alert",type:y&&(S&&"loading"||C&&"error")||"success",title:f.description?`${f.description} Tx`:ZN.t("View transaction"),action:f.url&&Eo.createElement(JN,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(f.url,"_blank")},Eo.createElement(RN,{size:12}))}))}),d&&Eo.createElement(LS,{id:"widget-swap-details-loading-alert",type:"loading",title:a.shortMessage}),s.status!=="failed"&&l&&Eo.createElement(MS,{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a}),s.status==="failed"&&Eo.createElement(NS,{message:a}))}i(Tp,"SwapDetailsAlerts");var PS=2e3;var _S=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:yt(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:_(c,6,6),realValue:c??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:yt(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:_(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:Qn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(l=>({from:{chain:{displayName:yt(l.fromBlockchain,e)??"",image:l.fromBlockchainLogo??""}},to:{chain:{displayName:yt(l.toBlockchain,e)??"",image:l.toBlockchainLogo??""}},swapper:{displayName:Qn(l.swapperId,o)??"",image:l.swapperLogo??"",type:l.swapperType}})):[],alerts:t0.createElement(Tp,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function DS(t){if(pr(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(DS,"getStepState");function OS(t){let{requestId:e}=t,[o,n]=a0(PS);return Mt.createElement(SS,{className:Zo()},Mt.createElement(FS,{variant:"label",size:"large",color:"neutral700"},qa.t("Request ID")),Mt.createElement("div",{className:Ha()},Mt.createElement(FS,{variant:"label",size:"small",color:"neutral700"},e),Mt.createElement($S,{container:B(),content:o?qa.t("Copied To Clipboard"):qa.t("Copy Request ID"),open:o||void 0,side:"bottom",alignOffset:-16,align:"end"},Mt.createElement(r0,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:n.bind(null,e||"")},o?Mt.createElement(n0,{size:16,color:"secondary"}):Mt.createElement(o0,{size:16,color:"gray"}))),Mt.createElement(xS,{target:"_blank",href:`${eu}/swap/${e}`},Mt.createElement($S,{container:B(),content:qa.t("View on Rango Explorer"),side:"bottom"},Mt.createElement(i0,{size:20})))))}i(OS,"RequestIdRow");import{i18n as US}from"@lingui/core";import{Typography as zS}from"@rango-dev/ui";import kp from"react";function HS(t){let{date:e,isFinished:o}=t;return kp.createElement("div",{className:Zo()},kp.createElement(zS,{variant:"label",size:"large",color:"neutral700"},o?US.t("Finished at"):US.t("Created at")),kp.createElement(zS,{variant:"label",size:"small",color:"neutral700"},e))}i(HS,"SwapDateRow");var g0=3e3;function bp(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:c}=m0(),l=T().blockchains(),p=T().swappers(),{findToken:u}=T(),d=H().use.retry(),f=f0(),h=xp(null),[g,m]=Ga(!1),[y,S]=Ga(null),[C,k]=Ga(null),[x,w]=Ga(null),I=xp(y),A=xp(C),b=Ne.use.getNotifications(),E=Ne.use.removeNotification(),v=b(),N=l0(e),M=N?.networkStatus,P=i(Me=>{m(!0),S(Me)},"handleChangeModalState"),U=i(()=>{m(!1)},"handleCloseModal"),Q=i(()=>{k({type:"loading",title:zt.t("Change Network"),description:`We\u2019re switching the connected network to ${X?.network}. Please check your wallet.`})},"handleShowSwitchNetworkLoading"),Z=i(()=>{k({type:"success",title:zt.t("Network Changed"),description:"The network has been successfully changed."})},"handleShowSwitchNetworkSucceeded"),W=i(Me=>{k({type:"error",title:zt.t("Network Switch Failed"),description:Me?.message||te.detailedMessage.content})},"handleShowSwitchNetworkFailed"),J=Zd(e),X=N?s0(e,N):null,ae=N?c0(e,N):null,Se=Zy(e),at=Jd(e),ue=i(Me=>!!c(Me)?.mobileWallet,"checkIsMobileWallet"),gt=!!M&&[Fn.WaitingForNetworkChange,Fn.NetworkChangeFailed].includes(M),vt=!!ae?.walletType&&ue(ae.walletType),xt=!!ae&&!!X&&a(ae.walletType,X.network,X),O=!!X&&gt&&(vt||xt),z=i(()=>{O&&(Q(),s(ae.walletType,[{namespace:X.namespace,network:X.network}]).then(()=>{Z()}).catch(Me=>{W(Me)}))},"handleSwitchNetwork"),Y=i(()=>{P("switchNetwork"),z()},"handleSwitchNetworkClick"),te=Yd(e,N,c),j=_S({swap:e,switchNetworkIsAvailable:O,handleSwitchNetworkClick:Y,showNetworkModal:M,setNetworkModal:P,message:te,blockchains:l,swappers:p}),G=j.length,[Ve,V]=[e.steps[0],e.steps[G-1]],Ce=V?.outputAmount||V?.expectedOutputAmountHumanReadable,Je=e.steps.reduce((Me,Lt)=>Me+parseFloat(Lt.feeInUsd||""),0),ht=e.steps.find(Me=>Me.diagnosisUrl)?.diagnosisUrl,so=_(parseFloat(Ce||"0")*(V?.toUsdPrice||0),4,4),zn=_(parseFloat(e.inputAmount)*(Ve?.fromUsdPrice||0),4,4),Io=Ce?new qS(Ce).multipliedBy(V.toUsdPrice||0).toString():"",Zr=new qS(e.inputAmount).multipliedBy(Ve?.fromUsdPrice||0).toString(),Ro=jt(zn,so),os=te.detailedMessage.content||te.shortMessage,vC=e.status==="success"?zt.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:_(Ce,6,6),token:j[G-1]?.to.token.displayName,conciseAddress:lo(e.wallets[j[G-1]?.to.chain.displayName||""]?.address||""),chain:j[G-1]?.to.chain.displayName}}):we.createElement(bS,null,we.createElement(wp,{variant:"body",size:"medium",color:"neutral700",align:"center"},os?"":zt.t("Transaction was not sent."),J?`${zt.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:J.outputAmount,symbol:J.symbol,blockchain:J.blockchain}})}`:""),os&&we.createElement(Qa,{align:"center",variant:"body",size:"medium",color:"neutral700"},we.createElement("b",null,"Reason:")," ",os));return vp(()=>{v.find(Lt=>Lt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(w(e.status),E(e.requestId),U()):x&&w(null))},[e.status,e.requestId]),vp(()=>{if(O){if(P("switchNetwork"),M===Fn.WaitingForNetworkChange){Q();return}if(M===Fn.NetworkChangeFailed){W();return}return}if(M===Fn.WaitingForConnectingWallet){P("connectWallet");return}if(M===Fn.NetworkChanged){P("switchNetwork"),Z();return}y&&["connectWallet","switchNetwork"].includes(y)&&U()},[M]),vp(()=>{if(I.current=y,A.current=C,y==="switchNetwork"&&C?.type==="success"){let Me=setTimeout(()=>{I.current==="switchNetwork"&&A.current?.type==="success"&&U()},g0);return()=>clearTimeout(Me)}},[y,C]),we.createElement(se,{header:{title:zt.t("Swap Details"),onCancel:e.status==="running"?()=>P("cancel"):void 0,suffix:e.status!=="running"&&we.createElement(fo,null,we.createElement(QS,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>P("delete")},we.createElement(wp,{size:"medium",variant:"label",color:"error"},zt.t("Delete"))))},footer:at&&!x&&we.createElement(QS,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let Me=Ai(e,l,u);d(Me),setTimeout(()=>{f("../../")},0)}},zt.t("Try again"))},we.createElement(hS,{compact:!0,ref:h},we.createElement(OS,{requestId:o}),we.createElement(HS,{date:Se,isFinished:!!e.finishTime}),we.createElement("div",{className:wS()},we.createElement(u0,{fee:_(String(Je),2,2),time:Gn(si(e.steps)),steps:G}),we.createElement(Cr,{from:{price:{value:_(e.inputAmount,6,6),usdValue:zn,realUsdValue:Zr,realValue:e.inputAmount},token:{displayName:j[0]?.from.token.displayName||"",image:j[0]?.from.token.image},chain:{image:j[0]?.from.chain.image,displayName:j[0]?.from.chain.displayName||""}},to:{price:{value:_(Ce,6,6),usdValue:so,realUsdValue:Io,realValue:Ce||""},token:{displayName:j[G-1]?.to.token.displayName||"",image:j[G-1]?.to.token.image},chain:{image:j[G-1]?.to.chain.image,displayName:j[G-1]?.to.chain.displayName||""}},percentageChange:_(Ro,2,2),warningLevel:Xt(Ro??0)})),we.createElement("div",{className:vS()},we.createElement(wp,{variant:"title",size:"small"},zt.t("Swaps steps"))),we.createElement(p0,{size:8}),we.createElement(CS,null,j.map((Me,Lt)=>{let Fp=Lt,Hn=e.steps[Lt]&&DS(e.steps[Lt]),xC=Hn==="error"||Hn==="in-progress"||Hn==="warning"||Hn==="completed"&&Lt===j.length-1;return we.createElement(d0,{className:"widget-swap-details-step-item-container",key:Fp,step:Me,type:"swap-progress",ref:h,state:Hn,hasSeparator:Lt!==0,tabIndex:Fp,isFocused:xC,tooltipContainer:B()})}))),we.createElement(gp,{isOpen:g,state:y,switchNetworkModalState:C,onClose:U,onCancel:r,onDelete:n,message:te.detailedMessage.content,swap:e,handleSwitchNetwork:Y}),we.createElement(yp,{open:!!x,diagnosisUrl:ht,onClose:()=>w(null),status:e.status==="success"?"success":"failed",priceValue:_(Ce,6,6),usdValue:so,realUsdValue:Io,realValue:Ce||"",percentageChange:_(Ro,2,2),token:{displayName:j[G-1]?.to.token.displayName||"",image:j[G-1]?.to.token.image},chain:{image:j[G-1]?.to.chain.image},description:vC}))}i(bp,"SwapDetails");import{i18n as Ka}from"@lingui/core";import{Divider as KS,NotFound as T0,Skeleton as Yr,Typography as ja}from"@rango-dev/ui";import Ie from"react";import{i18n as h0}from"@lingui/core";import{Divider as y0,Skeleton as S0,Typography as C0}from"@rango-dev/ui";import Ee from"react";import{css as Ht,styled as Ep}from"@rango-dev/ui";var GS=Ep("div",{width:"100%",height:"100%",padding:"$10 $20"}),Xr=Ep("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Va=Ep("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),o9=Ht({display:"flex",justifyContent:"space-between",alignItems:"center"}),n9=Ht({paddingTop:"$15",display:"flex"}),r9=Ht({padding:"$15 $0"}),i9=Ht({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),a9=Ht({paddingBottom:"$10"}),s9=Ht({display:"flex",justifyContent:"start",alignItems:"center"}),l9=Ht({paddingTop:"$5",display:"flex",alignItems:"center"}),c9=Ht({display:"flex",alignItems:"center"}),p9=Ht({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),VS=Ht({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Ip(){return Ee.createElement(GS,null,Ee.createElement(wr,{type:"swap-preview"}),Ee.createElement("div",{className:"swaps-steps"},Ee.createElement(C0,{variant:"title",size:"small"},h0.t("Swaps steps"))),Ee.createElement(Ee.Fragment,null,Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1}),Ee.createElement("div",{className:VS()},Ee.createElement(y0,{direction:"horizontal",size:20}),Ee.createElement(S0,{height:22,variant:"rectangular"}))),Ee.createElement(Va,null),Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1})),Ee.createElement(Va,null),Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1})),Ee.createElement(Va,null),Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1}))))}i(Ip,"LoadingSwapDetails");function jS(t){let{requestId:e,showSkeleton:o}=t;return Ie.createElement(se,{header:{title:Ka.t("Swap Details"),suffix:Ie.createElement(fo,null)}},o&&Ie.createElement(yS,null,Ie.createElement("div",{className:Zo()},Ie.createElement(ja,{variant:"label",size:"large",color:"neutral700"},`${Ka.t("Request ID")}`),Ie.createElement("div",{className:Ha()},Ie.createElement(ja,{variant:"label",size:"small",color:"neutral700"},Ie.createElement(Yr,{width:60,height:10,variant:"rounded"})),Ie.createElement(KS,{direction:"horizontal",size:4}),Ie.createElement(Yr,{width:16,height:16,variant:"rectangular"}),Ie.createElement(KS,{direction:"horizontal",size:4}),Ie.createElement(Yr,{width:16,height:16,variant:"rectangular"}))),Ie.createElement("div",{className:Zo()},Ie.createElement(ja,{className:kS(),variant:"label",size:"large",color:"neutral700"},Ie.createElement(Yr,{width:60,height:10,variant:"rounded"})),Ie.createElement(ja,{variant:"label",size:"small",color:"neutral700"},Ie.createElement(Yr,{width:60,height:10,variant:"rounded"}))),Ie.createElement(Ip,null)),!o&&Ie.createElement(TS,null,Ie.createElement(T0,{title:Ka.t("Not found"),description:Ka.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(jS,"SwapDetailsPlaceholder");function XS(){let{manager:t,state:e}=v0(),o=!e.loadedFromPersistor,n=kt(t),{requestId:r}=b0(),a=Qe(),{fetchStatus:s}=T();if(!r)return Ap.createElement(x0,{containerStyles:{margin:"20px"},type:"error",title:k0.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&&w0(f)}},"onCancel"),u=i(async()=>{if(l?.id)try{t?.deleteQueue(l.id),a()}catch(f){console.log(f)}},"onDelete"),d=l?.swap;return!d||c?Ap.createElement(jS,{requestId:r,showSkeleton:c}):Ap.createElement(bp,{swap:d,requestId:r,onCancel:p,onDelete:u})}i(XS,"SwapDetailsPage");import{i18n as YS}from"@lingui/core";import{Divider as E0,getCategoriesCount as I0,SelectableCategoryList as A0,styled as JS,Typography as N0,Wallet as B0}from"@rango-dev/ui";import Qt,{useState as ZS}from"react";var W0=JS("div",{display:"flex",justifyContent:"center",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5"}),M0=JS(ce,{textAlign:"center"});function RS(){let{fetchStatus:t}=T(),[e,o]=ZS("ALL"),n=T().blockchains(),{config:r}=T(),[a,s]=ZS(),c=ne.use.isActiveTab(),{list:l}=bt(),p=Wu(l,n),d=I0(p)!==1,f=Mu(l,e),h=i(g=>{pu(l,r.multiWallets)||s(g)},"handleWalletItemClick");return Qt.createElement(se,{header:{title:YS.t("Connect Wallets")}},Qt.createElement(M0,null,d&&Qt.createElement(Qt.Fragment,null,Qt.createElement(A0,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Qt.createElement(E0,{size:24})),Qt.createElement(N0,{variant:"title",size:"xmedium",align:"center"},YS.t("Choose a wallet to connect.")),Qt.createElement(W0,null,f.map((g,m)=>{let y=`wallet-${m}-${g.type}`;return Qt.createElement(B0,{key:y,...g,state:g.state,container:B(),onClick:()=>h(g),isLoading:t==="loading",disabled:!c})}),Qt.createElement(sr,{id:"widget-state-full-connect-modal",wallet:a,onClose:()=>{s(void 0)}}))))}i(RS,"WalletsPage");function eC(){return cm(),Js(),L0([{path:$.home,element:Ue.createElement(hy,null)},{path:$.routes,element:Ue.createElement(ky,null)},{path:$.fromSwap,children:[{index:!0,element:Ue.createElement(Pa,{type:"source"})},{path:$.blockchains,element:Ue.createElement(Ba,{type:"source"})}]},{path:$.toSwap,children:[{index:!0,element:Ue.createElement(Pa,{type:"destination"})},{path:$.blockchains,element:Ue.createElement(Ba,{type:"destination"})}]},{path:$.settings,children:[{index:!0,element:Ue.createElement(Xy,null)},{path:$.languages,element:Ue.createElement(Sy,null)},{path:$.exchanges,element:Ue.createElement(Jc,{sourceType:"Exchanges"})},{path:$.bridges,element:Ue.createElement(Jc,{sourceType:"Bridges"})},{path:$.customTokens,children:[{index:!0,element:Ue.createElement(yh,null)},{path:$.addCustomTokens,children:[{index:!0,element:Ue.createElement(lf,null)},{path:$.blockchains,element:Ue.createElement(Ba,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:Ue.createElement($h,null)},{path:$.swapDetails,element:Ue.createElement(XS,null)}]},{path:$.wallets,element:Ue.createElement(RS,null)},{path:$.confirmSwap,element:Ue.createElement(th,null)}])}i(eC,"AppRoutes");import{useQueueManager as Z0}from"@rango-dev/queue-manager-rango-preset";import{isEvmBlockchain as J0}from"rango-sdk";import{useContext as R0,useEffect as Mp,useState as dC}from"react";import{Provider as O0}from"@rango-dev/wallets-react";import Xa,{createContext as U0,useEffect as iC,useMemo as z0,useRef as aC}from"react";import{useEffect as _0}from"react";import{Provider as P0}from"@rango-dev/wallets-core";function tC(t){return t.map(e=>typeof e=="string"?e:e instanceof P0?e.id:e.config.type).join("-")}i(tC,"hashProviders");function Np(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=T(),a=n();return _0(()=>{o(),r()},[tC(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(Np,"useWalletProviders");import{legacyFormatAddressWithNetwork as D0,legacyReadAccountAddress as oC}from"@rango-dev/wallets-core/legacy";import{Events as On}from"@rango-dev/wallets-react";import{isEvmBlockchain as $0}from"rango-sdk";function nC(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=T(),{onConnectWalletHandler:c,onDisconnectWalletHandler:l}=t,p=s().filter($0).map(m=>m.name),u=i((m,y)=>{let[S,,C,k,x]=m,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=ds(S,C,p,y.supportedChainNames,x.isContractWallet);I.length&&e(I,x.namespace,k.derivationPath)},"onAccountsEvent"),d=i((m,y,S,C,k)=>{if(y===On.ACCOUNTS){let x=jn(k.supportedBlockchains);S&&u([m,y,S,C,k],{supportedChainNames:x})}y===On.PROVIDER_DISCONNECTED&&(o(m),l.current?l.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),y===On.NAMESPACE_DISCONNECTED&&n(m,S)},"handleUpdatesForHub"),f=i((m,y,S,C,k)=>{if(y===On.ACCOUNTS){let x=jn(k.supportedBlockchains),w=[],I=[];if(S?.forEach(b=>{let{network:E}=oC(b);p.includes(E)?w.push(b):I.push(b)}),r.filter(b=>b.walletType===m).map(b=>D0(b.address,b.chain)).length>0){if(w.length>0){let b=ds(m,w,p,x,k.isContractWallet);a(m,{chains:b.map(E=>E.chain)})}I.length>0&&a(m,{chains:I.map(b=>{let{network:E}=oC(b);return E})})}S?u([m,y,S,C,k],{supportedChainNames:x}):(o(m),l.current?l.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}},"handleUpdatesForLegacy"),h=i((m,y,S,C,k)=>{if(y===On.CONNECTED&&S){let x={walletType:m,network:C.network??void 0,accounts:C.accounts??void 0};c.current?c.current(x):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(y===On.NETWORK&&S){let x={walletType:m,network:S,accounts:C.accounts??void 0};c.current?c.current(x):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((m,y,S,C,k)=>{k.isHub?d(m,y,S,C,k):f(m,y,S,C,k),h(m,y,S,C,k)},"handler")}}i(nC,"useUpdates");import{LegacyEvents as F0}from"@rango-dev/wallets-core/legacy";function rC(t,e){let[o,n,r,a,s]=e;n!==F0.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i(rC,"propagateEvents");var Ya=U0({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function H0(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}=Np(s.wallets,c),p=aC(),u=aC(),{handler:d}=nC({onConnectWalletHandler:p,onDisconnectWalletHandler:u});iC(()=>{n().catch(console.log)},[]),iC(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let f=ne.use.isActiveTab(),h=z0(()=>({onConnectWallet:g=>{p.current=g},onDisconnectWallet:g=>{u.current=g}}),[]);return Xa.createElement(Ya.Provider,{value:h},Xa.createElement(O0,{allBlockChains:a,providers:l,onUpdateState:(g,m,y,S,C)=>{let k=[g,m,y,S,C];d(...k),t.onUpdateState&&rC(t.onUpdateState,k)},autoConnect:!!f,configs:{wallets:s.wallets}},t.children))}i(H0,"Main");function Za(t){let{config:e,...o}=t;return Xa.createElement(Zu,{config:e},Xa.createElement(H0,{...o,config:e}))}i(Za,"WidgetWallets");import{globalCss as Q0}from"@rango-dev/ui";var sC=i(()=>Q0({"@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 q0}from"@rango-dev/wallets-react";import{useEffect as G0,useRef as V0}from"react";function lC(){let{connect:t,state:e}=q0(),o=V0({}),{fetchStatus:n}=T(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);G0(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(lC,"useForceAutoConnect");import{isApprovalTX as K0,RouteEventType as cC,StepEventType as pC,StepExecutionEventStatus as j0,WidgetEvents as Ja}from"@rango-dev/queue-manager-rango-preset";import{useEffect as uC}from"react";function Bp(){let t=Ne.use.setNotification(),{connectedWallets:e,fetchBalances:o,customTokens:n}=T();uC(()=>{let r=i(a=>{let{event:s,step:c,route:l}=a;if(s.type===pC.TX_EXECUTION&&s.status===j0.TX_SENT&&!K0(c)||s.type===pC.SUCCEEDED){let u=[],d=l.wallets[c?.fromBlockchain];if(d){let f=e.find(h=>h.address?.toLocaleLowerCase()===d.address?.toLocaleLowerCase()&&h.walletType===d.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(m=>f.some(y=>y.blockchain===m.blockchain&&y.address?.toLocaleLowerCase()===m.address?.toLocaleLowerCase()&&y.symbol?.toLocaleLowerCase()===m.symbol?.toLocaleLowerCase()));o(u,{selectedCustomTokens:g,shouldFetchCustomTokens:g.length>0})}}t(s,l)},"handleStepEvent");return ve.on(Ja.StepEvent,r),()=>ve.off(Ja.StepEvent,r)},[ve,e]),uC(()=>{let r=i(a=>{let{event:s,route:c}=a;(s.type===cC.FAILED||s.type===cC.SUCCEEDED)&&t(s,c)},"handleRouteEvent");return ve.on(Ja.RouteEvent,r),()=>ve.off(Ja.RouteEvent,r)},[ve])}i(Bp,"useSubscribeToWidgetEvents");import{useManager as X0}from"@rango-dev/queue-manager-react";import{useEffect as Y0}from"react";function Wp(){let{isSynced:t,syncNotifications:e}=Ne(),{manager:o,state:n}=X0();Y0(()=>{Ne.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(kt(o))},[Ne.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Wp,"useSyncNotifications");function Lp(){lC(),sC(),Bp(),Wp();let t=T().blockchains(),{canSwitchNetworkTo:e}=Yi(),[o,n]=dC(null),[r,a]=dC(),s=R0(Ya),c=t.filter(J0);Mp(()=>()=>sm(),[]),Mp(()=>()=>lm(),[]),Z0({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:c,canSwitchNetworkTo:e}),Mp(()=>(Po.init(),Ne.persist.hasHydrated()||Ne.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)}),Po.destroy),[])}i(Lp,"useBootstrap");import{styled as eB}from"@rango-dev/ui";var mC=eB("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 Jo(){Lp();let{config:t}=T(),{activeTheme:e}=mo(t?.theme||{}),{activeLanguage:o}=wo();return Pp.createElement(tB,{language:o},Pp.createElement(mC,{id:"swap-container",className:e()},Pp.createElement(eC,null)))}i(Jo,"Main");import{setSolanaSignerConfig as kB}from"@rango-dev/signer-solana";import Dp,{useEffect as $p,useMemo as wB}from"react";function fC(){let{setWatermark:t,setShowProfileBanner:e}=ne();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Gt("BASE_URL")}/meta/dapp/config?apiKey=${Gt("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(fC,"useFetchApiConfig");import{useState as oB}from"react";var nB=i(()=>{let[t,e]=oB(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=cu(a);if(s){let c=o(s);e(c)}},"handleLoadCustomFont")}},"useFontLoader"),gC=nB;import{checkWaitingForNetworkChange as rB,makeQueueDefinition as iB}from"@rango-dev/queue-manager-rango-preset";import{Provider as aB}from"@rango-dev/queue-manager-react";import{useWallets as sB}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as lB}from"@rango-dev/wallets-shared";import{isEvmBlockchain as cB}from"rango-types";import pB,{useMemo as uB}from"react";function dB(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s,hubProvider:c}=sB(),l=uB(()=>iB({API_KEY:t.apiKey||Gt("API_KEY"),BASE_URL:Gt("BASE_URL"),emitter:{emit:ve.emit}}),[t.apiKey]),{blockchains:p,connectedWallets:u}=T(),d=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"),m=d.filter(w=>w.enabled).reduce((w,I)=>(w[I.name]=I,w),{}),y=d.filter(cB),S=i(w=>{let{supportedChains:I}=s(w);return jn(I)},"getSupportedChainNames"),C=e(),k={meta:{blockchains:m,evmBasedChains:y,evmNetworkChainInfo:lB(y),getSupportedChainNames:S},getSigners:o,wallets:f,providers:C,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:g,hubProvider:c},x=ne.use.isActiveTab();return pB.createElement(aB,{queuesDefs:[l],context:k,onPersistedDataLoaded:w=>{rB(w)},isPaused:!x},t.children)}i(dB,"QueueManager");var hC=dB;import{useManager as yB}from"@rango-dev/queue-manager-react";import SB,{createContext as CB,useContext as TB}from"react";function yC(){let{findToken:t}=T(),e=T().blockchains(),o=T().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:c}=H()();return i(p=>{let{fromBlockchain:u,fromToken:d,toBlockchain:f,toToken:h,requestAmount:g}=p,m={blockchains:e,tokens:o};if(u!==void 0){let y=e.find(S=>S.name===u)??null;n(y)}if(d!==void 0){let y=d?t(d)??null:null;r({meta:m,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:m,token:y})}g!==void 0&&c(g)},"updateQuoteInputs")}i(yC,"useUpdateQuoteInputs");import{cancelSwap as mB,getCurrentNamespaceOfOrNull as fB,getCurrentStep as gB,getRelatedWalletOrNull as hB}from"@rango-dev/queue-manager-rango-preset";var Ra=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return kt(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=Ai(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&mB(o)}getCurrentStepInfo(e){let o=gB(e);return{step:o,wallet:o?hB(e,o):null,network:o?fB(e,o)?.network:null}}};var SC=CB(void 0);function _p(t){let{manager:e}=yB(),o=ne.use.isActiveTab(),n=H().use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:c}=T(),l=new Ra(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=T(),u=bu(a()),d=T().blockchains(),f=T().tokens(),h=T().swappers(),g=T().fetchStatus,m=wo().resetLanguage,y=Ne().getNotifications(),S=Ne().clearNotifications,C=yC(),{fromBlockchain:k,toBlockchain:x,fromToken:w,toToken:I,inputAmount:A}=H()(),b={isActiveTab:o,setCurrentTabAsActive:Po.forceClaim,history:l,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async E=>c(E)},meta:{blockchains:d,tokens:f,swappers:h,loadingStatus:g,findToken:r},resetLanguage:m,notifications:{list:y,clearAll:S},quote:{quoteInputs:{fromBlockchain:k?.name??null,fromToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,toBlockchain:x?.name??null,toToken:I?{symbol:I.symbol,blockchain:I.blockchain,address:I.address}:null,requestAmount:A},updateQuoteInputs:C}};return SB.createElement(SC.Provider,{value:b},t.children)}i(_p,"WidgetInfo");function CC(){let t=TB(SC);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(CC,"useWidget");function Un(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{fetchApiConfig:r}=fC(),{handleLoadCustomFont:a}=gC();return $p(()=>{r().catch(console.log)},[]),$p(()=>{n&&a(n)},[n]),wB(()=>{Lu({API_KEY:o?.apiKey||oi,BASE_URL:o?.apiUrl||Rp})},[o.apiKey,o.apiUrl]),$p(()=>{t.config?.signers?.customSolanaRPC&&kB("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),Dp.createElement(Za,{config:o,onUpdateState:e},Dp.createElement(hC,{apiKey:o.apiKey},Dp.createElement(_p,null,t.children)))}i(Un,"WidgetProvider");function TC(t){let e=t.config?.externalWallets;return es.createElement(Ei,null,e?es.createElement(Jo,null):es.createElement(Un,{config:t.config??nn},es.createElement(Jo,null)))}i(TC,"Refuel");import ts from"react";function kC(t){let e=t.config?.externalWallets;return ts.createElement(Ei,null,e?ts.createElement(Jo,null):ts.createElement(Un,{config:t.config??nn},ts.createElement(Jo,null)))}i(kC,"Widget");function wC(){let{on:t,off:e}=ve;return{on:t,off:e}}i(wC,"useWidgetEvents");var ite={DerivationPath:rr,Namespaces:tr,Detached:nr,isOnDerivationPath:ar,isOnNamespace:ir,isOnDetached:Ao};export{Aee as EventSeverity,ln as MainEvents,Fee as Networks,zee as PendingSwapNetworkStatus,ys as QuoteEventTypes,TC as Refuel,Nee as RouteEventType,ss as SUPPORTED_FONTS,ite as StatefulConnect,Bee as StepEventType,Wee as StepExecutionBlockedEventStatus,Mee as StepExecutionEventStatus,vd as SwapModeContext,Re as UI_ID,Cs as UiEventTypes,Ss as WalletEventTypes,Dee as WalletEvents,Oee as WalletTypes,kC as Widget,ln as WidgetEvents,Un as WidgetProvider,Za as WidgetWallets,dl as customizedThemeTokens,is as pickProviderVersionWithFallbackToLegacy,Pee as readAccountAddress,en as useStatefulConnect,bt as useWalletList,Yi as useWallets,CC as useWidget,wC as useWidgetEvents,AT as widgetEventEmitter};
1
+ var IC=Object.defineProperty;var i=(t,e)=>IC(t,"name",{value:e,configurable:!0});import{EventSeverity as Lee,RouteEventType as Pee,StepEventType as _ee,StepExecutionBlockedEventStatus as Dee,StepExecutionEventStatus as $ee}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Oee}from"@rango-dev/wallets-core/legacy";import{useWallets as Xi,Events as zee}from"@rango-dev/wallets-react";import{Networks as Qee,WalletTypes as qee}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as Vee}from"rango-types";import{Divider as jk}from"@rango-dev/ui";import po,{useEffect as Xk,useRef as Yk,useState as xd}from"react";import{WalletState as AC}from"@rango-dev/ui";import{useWallets as NC}from"@rango-dev/wallets-react";import{useReducer as BC}from"react";function Fp(t){return!!t.derivationPath}i(Fp,"isStateOnDerivationPathStep");function Op(t){return!!t.namespace}i(Op,"isStateOnNamespace");var Jr={status:"init",namespace:null,derivationPath:null,selectedNamespaces:null};function Up(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 Jr;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:Jr;default:throw new Error("Action hasn't been defined.")}}i(Up,"reducer");function en(){let{state:t,disconnect:e,connect:o}=NC(),[n,r]=BC(Up,Jr),a=i(async(d,f,h)=>{r({type:"reset"});try{let g=f?.map(m=>({...m,network:void 0}));return await o(d.type,g),{status:"connected"}}catch(g){let m=g?.message?`Error: ${g.message}`:"An unknown error happened during connecting wallet.";if(h?.disconnectOnError)try{await u(d)}catch{console.warn("An error happened during disconnecting wallet after error on connecting.")}throw new Error(m,{cause:g})}},"runConnect"),s=i(async(d,f)=>{let h=d.state===AC.DISCONNECTED,g=f?.forceConnectToNamespaces;if(h){let m=!!d.isHub,y=m?d.properties?.find(C=>C.name==="namespaces")?.value:d.needsNamespace,S=m?d.properties?.find(C=>C.name==="derivationPath")?.value:d.needsDerivationPath;if(g){let C=g.find(k=>!y?.data?.map(x=>x.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:d.type,providerImage:d.image,namespace:g[0]}}),{status:"derivation-path"}):await a(d,g.map(k=>({namespace:k})),{...f,disconnectOnError:!0})}if(!y?.data?.length)return await a(d,void 0,f);if(y?.data.length&&y.data.length>1)return r({type:"needsNamespace",payload:{targetWallet:d,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:d.type,providerImage:d.image,namespace:C.value}}),{status:"derivation-path"}}return await a(d,y?.data?.map(C=>({namespace:C.value})),f)}}if(d.isHub&&!f?.forceConnectToNamespaces){let m=d.properties?.find(y=>y.name==="namespaces")?.value;if(m?.data.length&&m.data.length>1)return r({type:"detached",payload:{targetWallet:d,selectedNamespaces:null}}),{status:"Detached"}}return f?.disconnectIfConnected?(await u(d),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),c=i(async(d,f)=>{let h=!!d.isHub,g=h?d.properties?.find(k=>k.name==="namespaces")?.value:d.needsNamespace,m=h?d.properties?.find(k=>k.name==="derivationPath")?.value:d.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&&m)return r({type:"needsDerivationPath",payload:{providerType:d.type,providerImage:d.image,namespace:S}}),{status:"derivation-path"};if(!Op(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:d,selectedNamespaces:C??null}}),{status:"Detached"}},"handleNamespace"),l=i(async(d,f,h)=>{if(!f)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!Fp(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let m=[{namespace:n.derivationPath.namespace,derivationPath:f}],S=!!d.isHub?d.properties?.find(x=>x.name==="namespaces")?.value:d.needsNamespace,C=!!S?.data&&S.data.length>1,k=!!h?.forceConnectToNamespaces;return C&&!k?(r({type:"detached",payload:{targetWallet:d,selectedNamespaces:m??null,derivationPath:f}}),{status:"Detached"}):await a(d,m)},"handleDerivationPath"),p=i(()=>n,"getState"),u=i(async d=>{let f=t(d.type);return f.connected||f.connecting?(await e(d.type),Ao(p)?(r({type:"needsNamespace",payload:{targetWallet:d}}),{status:"namespace"}):{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:c,handleDerivationPath:l,getState:p,resetState:d=>{r(d==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(en,"useStatefulConnect");import{WalletState as bs}from"@rango-dev/ui";import{useWallets as zT}from"@rango-dev/wallets-react";import{detectMobileScreens as HT,KEPLR_COMPATIBLE_WALLETS as QT,WalletTypes as Jn}from"@rango-dev/wallets-shared";import{useCallback as qT,useEffect as GT}from"react";import DT,{createContext as $T,useContext as FT,useEffect as OT,useRef as UT}from"react";import{create as PT}from"zustand";import{persist as _T}from"zustand/middleware";import{allProviders as WC}from"@rango-dev/provider-all";var os=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()}},tn=new os;import{defineVersions as Hp,pickVersion as Qp,Provider as ns}from"@rango-dev/wallets-core";function qp({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=rs(a);return s instanceof ns?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 ns?o.push(Hp().version("1.0.0",n).build()):o.push(Hp().version("0.0.0",n).build())}),o}return t}i(qp,"matchAndGenerateProviders");function rs(t){try{return Qp(t,"1.0.0")[1]}catch{return Qp(t,"0.0.0")[1]}}i(rs,"pickProviderVersionWithFallbackToLegacy");function Gp(t){return t.map(o=>rs(o)).map(o=>o instanceof ns?o.id:o.config.type)}i(Gp,"configWalletsToWalletName");function Rr(t,e){return e.find(o=>o.name===t)?.displayName}i(Rr,"getBlockchainDisplayNameFor");function yt(t,e){return e.find(o=>o.name===t)?.shortName}i(yt,"getBlockchainShortNameFor");function Vp(t,e){return e.find(o=>o.name===t)?.logo}i(Vp,"getBlockchainImage");function Qn(t,e){return e.find(o=>o.id===t)?.title}i(Qn,"getSwapperDisplayName");function No(t,e){return e.find(o=>o.name===t)??null}i(No,"findBlockchain");function is(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(is,"isTokenNative");function St(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(St,"createTokenHash");function on(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(on,"isValidTokenAddress");function qn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(c=>{c.forEach(l=>{typeof l!="string"&&(l=St(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=St(p);delete n[u]})):a(l.tokens))}),Object.values(n)}i(qn,"matchTokensFromConfigWithMeta");function ei(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(ei,"getSupportedBlockchainsFromConfig");function jp(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(jp,"makeProvidersOptionsFromConfig");var nn={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"},tonConnect:{manifestUrl:"https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/manifests/tonconnect-manifest.json"}},MC={clientUrl:void 0},LC={liquiditySources:void 0};function Kp(t){let e=jp(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 WC(o).map(a=>a())}i(Kp,"generateProviders");var Xp=i((t,e,o)=>{let n=Kp({...nn,...t});return{config:{...nn,...t},iframe:MC,campaignMode:LC,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=qn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:c,tokensMapByTokenHash:s}}),p=qn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:c,tokensMapByTokenHash:s}});tn.set("supportedSourceTokens",l),tn.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=Kp(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=jp(a);return qp({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as Yp}from"rango-types";var Zp=[Yp.EVM,Yp.SOLANA],ti="https://raw.githubusercontent.com/rango-exchange/assets/refs/heads/main/common/unknown-image.png";import{RangoClient as XC}from"rango-sdk";function Jp(){return process.env.REACT_APP_RANGO_API_KEY}i(Jp,"getApiKeyFromEnv");function Rp(){let t=Jp();if(t)return t;throw new Error("Ensure you have set REACT_APP_RANGO_API_KEY in your env variables.")}i(Rp,"getApiKeyFromEnvOrThrow");function eu(){return Jp()||"NOT_SET"}i(eu,"getApiKeyFromEnvOrNotSet");import{BlockchainCategories as zC,WalletState as lt}from"@rango-dev/ui";import{legacyReadAccountAddress as HC}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as QC,getCosmosExperimentalChainInfo as qC,isEvmAddress as GC,KEPLR_COMPATIBLE_WALLETS as OW,Networks as bu}from"@rango-dev/wallets-shared";import an from"bignumber.js";import{isCosmosBlockchain as VC}from"rango-types";import PC from"bignumber.js";var pe=new PC(0);import{WalletTypes as _C}from"@rango-dev/wallets-shared";var Bo="~",tu=[_C.LEAP];import{BlockchainCategories as ss,WalletState as UC}from"@rango-dev/ui";import{TransactionType as oi}from"rango-sdk";import{UI_ID as DC}from"@rango-dev/ui";var ou="https://api.rango.exchange",nu="https://explorer.rango.exchange",Re={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...DC};var ru="Roboto",as=[{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 rn(t){return Array.from(new Set(t))}i(rn,"removeDuplicateFrom");function ni(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(ni,"debounce");function st(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(st,"containsText");function su(t,e){return t.toLowerCase()===e.toLowerCase()}i(su,"exactText");function lu(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(lu,"startWithText");var B=i(()=>document.getElementById(Re.SWAP_BOX_ID),"getContainer"),Wo=i(()=>document.getElementById(Re.EXPANDED_BOX_ID),"getExpanded");function cu(t,e,o){let n=!!e&&su(e,t),r=!!o&&su(o,t);return n!==r?n?-1:1:0}i(cu,"compareExactMatchText");function ls(t,e,o){let n=!!e&&st(e,t),r=!!o&&st(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ls,"compareContainsText");function cs(t,e,o){let n=!!e&&lu(e,t),r=!!o&&lu(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(cs,"compareStartWithText");function pu(t,e,o){if(!o)return 0;let n=cu(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=cu(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=ls(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=ls(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=ls(o,t.address,e.address);if(r!==0)return r}return 0}i(pu,"compareWithSearchFor");var ri=i((t,e)=>{switch(e){case ss.ALL:return!0;case ss.UTXO:return t===oi.TRANSFER;case ss.OTHER:return t!==oi.TRANSFER&&t!==oi.COSMOS&&t!==oi.EVM;default:return t===e}},"isBlockchainTypeInCategory"),uu=i(t=>as.find(o=>o.value===t)?.url,"getFontUrlByName");function du(t,e){let o=!!t.find(n=>n.state===UC.CONNECTED);return e===!1&&o}i(du,"isSingleWalletActive");function mu(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(mu,"memoizedResult");function fu(t,e){let o=new Set;return e.forEach(n=>{o.add(n.blockchain)}),t.filter(n=>o.has(n.name))}i(fu,"filterBlockchainsWithAtLeastOneToken");import{BigNumber as vu}from"bignumber.js";function gu(t){return t.replace(/^0+(?=\d)/g,"")}i(gu,"removeLeadingZeros");function hu(t){return t.replace(/^\.(\d+)/,"0.$1")}i(hu,"ensureLeadingZeroForDecimal");function yu(t){return t.replace(/\B(?=(\d{3})+(?!\d))/g,",")}i(yu,"formatThousandsWithCommas");function Su(t){return t.replace(/\s+/g,"-")}i(Su,"replaceSpacesWithDash");function Cu(t){return t.replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"")}i(Cu,"stripTrailingZeros");function Tu(t){return t=t.replace(/[^\d.]/g,"").replace(/\./g,(e,o,n)=>n.indexOf(".")===o?".":""),t}i(Tu,"parseNumericValue");function ii(t){return/^0+(?:\.0+)?$/.test(t)}i(ii,"isZeroValue");function ku(t,e=2){let o=`^(?:0|[1-9]\\d*)(?:\\.\\d{1,${e}})?$`;return new RegExp(o).test(t)}i(ku,"isValidCurrencyFormat");function wu(t){return/\d+$/.test(t)}i(wu,"isColorKeyOverridden");var Gn=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"),_=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new vu(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new vu(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 ai=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var Pt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),Vn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function xu(t){return ii(t)?"0":t.endsWith(".")?t.slice(0,-1):Cu(t)}i(xu,"sanitizeInputAmount");function Kn(t,e){return jC(t,e)?lt.PARTIALLY_CONNECTED:e.connected?lt.CONNECTED:e.connecting?lt.CONNECTING:e.installed?lt.DISCONNECTED:lt.NOT_INSTALLED}i(Kn,"getWalletConnectionStatus");function Eu(t,e,o,n){return o.filter(r=>!tu.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:d,properties:f,isHub:h}=e(r),g=rn(u.map(y=>y.type)),m=Kn(e(r),t(r));return{title:a,image:s,link:QC(c),state:m,type:r,showOnMobile:l,needsNamespace:p,blockchainTypes:g,needsDerivationPath:d,properties:f,isHub:h}})}i(Eu,"mapWalletTypesToWalletInfo");function jn(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(jn,"walletAndSupportedChainsNames");function us(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}=HC(l),d=c.length>0,f=c.includes(u),h=u===bu.Unknown;if(d&&!f&&!h)return;let m=u===bu.Unknown&&GC(p);if(h&&!m)return;o.includes(u)||m?r?s(u,p.toLowerCase(),r):c.filter(C=>o.includes(C)).forEach(C=>{s(C,p.toLowerCase())}):s(u,p)}),a}i(us,"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 d=p.from.blockchain,f=p.to.blockchain,h=a===o.swaps.length-1,g=u===l.length-1;(!h&&!g||h&&c!==d||e==="all")&&n.add(d),e==="all"&&n.add(f)})}e==="all"&&n.add(c)}),Array.from(n)}i(Mo,"getQuoteChains");function Xn(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(Xn,"isAccountAndWalletMatched");var Iu=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?ps(n.usdValue,n.decimals):pe.toFixed();return o.plus(r)},new an(pe));return KC(e.toString())},"calculateWalletUsdValue");function KC(t){let e=t.toString().split(".");return e[0]&&(e[0]=yu(e[0])),e.join(".")}i(KC,"numberWithThousandSeparator");var ci=i((t,e)=>{let o=qC(Object.entries(t).map(([,n])=>n).filter(VC));return o&&!!o[e]?.experimental},"isExperimentalChain");function ps(t,e){return new an(t).shiftedBy(-e).toFixed()}i(ps,"representAmountInNumber");function pi(t){if(!t)return null;let e=ps(t.amount,t.decimals),o=t.usdValue?ps(t.usdValue,t.decimals):null,n=_(e,8,8),r=o?_(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(pi,"formatBalance");function Au(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new an(t.usdValue).shiftedBy(-t.decimals):pe,n=e&&e.usdValue?new an(e.usdValue).shiftedBy(-e.decimals):pe;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new an(t.amount).shiftedBy(-t.decimals):pe,n=e&&e.amount?new an(e.amount).shiftedBy(-e.decimals):pe;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Au,"compareTokenBalance");function qt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(qt,"areTokensEqual");function Nu(t){return t.sort((e,o)=>+(o.state===lt.CONNECTED)-+(e.state===lt.CONNECTED)||+(o.state===lt.PARTIALLY_CONNECTED)-+(e.state===lt.PARTIALLY_CONNECTED)||+(o.state===lt.DISCONNECTED||o.state===lt.CONNECTING)-+(e.state===lt.DISCONNECTED||e.state===lt.CONNECTING))}i(Nu,"sortWalletsBasedOnConnectionState");function lo(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(lo,"getConciseAddress");function Bu({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Bu,"getAddress");var Wu=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Mu(t){return t.map(e=>e.state).join("-")}i(Mu,"hashWalletsState");function Lu(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(Lu,"filterBlockchainsByWalletTypes");function Pu(t,e){return e===zC.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(ri(n,e))return!0;return!1})}i(Pu,"filterWalletsByCategory");function jC(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(jC,"checkIsWalletPartiallyConnected");var ds={API_KEY:eu()};function Gt(t){return ds[t]||""}i(Gt,"getConfig");function _u(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ds=e,ds}i(_u,"initConfig");var Du=20,$u=25,ms="theme-widget",fs=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>qt(n,t));else if(!Array.isArray(e)){let n=e[t.blockchain];if(n){o=!!n.tokens.some(a=>qt(a,t));let r=n.isExcluded;return!r&&!o||r&&o}}}return o},"isTokenExcludedInConfig"),gs=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Fu=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var ui,ct=i(()=>ui||(ui=new XC(Gt("API_KEY"),Gt("BASE_URL")),ui),"httpService");import{i18n as Uu}from"@lingui/core";var di=[.5,1,3],mi=1,sn=5,Yn=30,fi=0;var Xe=(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))(Xe||{});import{WidgetEvents as Ou}from"@rango-dev/queue-manager-rango-preset";var hs=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(hs||{}),ys=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(ys||{}),Ss=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(Ss||{}),ln=(a=>(a[a.RouteEvent=Ou.RouteEvent]="RouteEvent",a[a.StepEvent=Ou.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(ln||{});function gi(t,e){let o=t.map(a=>a.swapperGroup),n=[];return rn(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(gi,"getUniqueSwappersGroups");function zu(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(zu,"sortLiquiditySourcesByGroupTitle");function et(t,e){return e?.[t]==="hidden"}i(et,"isFeatureHidden");function cn(t,e){return e?.[t]==="enabled"}i(cn,"isRoutingEnabled");var Hu=i((t,e,o)=>et("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");function pn(t){return t==fi?{type:"error",message:Uu.t("Slippage must be greater than or equal to 0.01")}:t>sn&&t<=Yn?{type:"warning",message:Uu.t("Your transaction is at risk of being frontrun due to high slippage tolerance."),quoteValidation:{type:3,slippage:t.toString()}}:null}i(pn,"getSlippageValidation");var Qu=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=ei({config:a}),p=r;return l.length>0&&(p=p.filter(u=>l.includes(u.name))),p.filter(u=>Zp.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",d=tn.get(u);d?.length||(d=qn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),tn.set(u,d)),d=Hu(d,s,a.features);let f=e().blockchains({type:o.type});return d.filter(g=>o.blockchain&&g.blockchain!==o.blockchain||!f.some(m=>m.name===g.blockchain)?!1:o.searchFor?!!(st(g.symbol,o.searchFor)||st(g.address||"",o.searchFor)||st(g.name||"",o.searchFor)):!0).sort((g,m)=>{let y=e().isTokenPinned(g,o.type),S=e().isTokenPinned(m,o.type);if(y!==S)return y?-1:1;if(o.getBalanceFor){let I=o.getBalanceFor(g),A=o.getBalanceFor(m),b=Au(I,A);if(b!==0)return b}let C=l.get(g.blockchain),k=l.get(m.blockchain),x=is(g,C),w=is(m,k);if(x!==w)return x?-1:1;if(g.isPopular!==m.isPopular)return g.isPopular?-1:1;if(o.searchFor){let I=pu(g,m,o.searchFor);if(I)return I}return g.isSecondaryCoin!==m.isSecondaryCoin?g.isSecondaryCoin?1:-1:C&&k?C.sort-k.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=St(o),s=n.get(a);return s||(s=r.find(c=>St(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=>qt(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(zu)},fetch:async()=>{try{let{routing:o}=e().config,n=cn("enableCentralizedSwappers",o),r=await ct().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,c={},l=r.popularTokens,p=r.swappers.filter(d=>d.enabled);r.blockchains.sort((d,f)=>d.sort-f.sort).forEach(d=>{d.enabled&&a.set(d.name,d)}),r.tokens.forEach(d=>{let f=St(d);c[d.blockchain]||(c[d.blockchain]=[]),s.set(f,d),c[d.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 YC,Catalonia as ZC,Chinese as qu,Denmark as JC,English as RC,Finland as eT,French as tT,German as oT,Greece as nT,Hungary as rT,India as iT,Indonesian as aT,Italian as sT,Japanese as lT,Korea as cT,Lithuania as pT,Malay as uT,Netherlands as dT,Pakistan as mT,Philippines as fT,Poland as gT,Portuguese as hT,Russian as yT,SaudiArabia as ST,Serbia as CT,Slovakia as TT,SouthAfrica as kT,Spanish as wT,Swahili as vT,Swedish as xT,Thai as bT,Turkish as ET,Ukrainian as IT,Vietnamese as AT}from"@rango-dev/ui";var Gu=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:kT},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:ST},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:YC},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:ZC},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:qu},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:qu},{title:"Danish",label:"Dansk",local:"da",SVGFlag:JC},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:dT},{title:"English",label:"English",local:"en",SVGFlag:RC},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:fT},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:eT},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:tT},{title:"German",label:"Deutsch",local:"de",SVGFlag:oT},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:nT},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:iT},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:rT},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:aT},{title:"Italian",label:"Italiana",local:"it",SVGFlag:sT},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:lT},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:cT},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:pT},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:uT},{title:"Polish",label:"Polski",local:"pl",SVGFlag:gT},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:hT},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:yT},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:CT},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:TT},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:wT},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:vT},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:xT},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:bT},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:ET},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:IT},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:mT},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:AT}],un="en";var Vu=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:mi,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=rn(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=et("theme",n),s=et("language",n),c=et("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||un},...c&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||un}})},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=ei({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import xs from"bignumber.js";import NT from"mitt";var ve=NT(),BT={on:ve.on,off:ve.off};var Ku=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 ju from"bignumber.js";function Vt(t){return`${t.blockchain}${Bo}${t.address}${Bo}${t.symbol}`}i(Vt,"createAssetKey");function Xu(t,e){return`${Vt(e)}${Bo}${t}`}i(Xu,"createBalanceKey");function Zn(t){let[e,o,n]=t.split(Bo);return!e||!o||!n?null:{address:o==="null"?null:o,blockchain:e,symbol:n}}i(Zn,"extractAssetFromBalanceKey");function Ts(t,e,o){return e.balances?.forEach(n=>{let r=n.price??t.findToken(n.asset)?.usdPrice;t._aggregatedBalances[Vt(n.asset)]?.forEach(s=>{o[s]&&(o[s]={...o[s],usdValue:r?new ju(r??pe).multipliedBy(o[s].amount).toString():""})})}),o}i(Ts,"computeNextBalancesWithNewPrices");function ks(t,e){let o={};return t.balances?.forEach(n=>{let r=Xu(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,c=n.price??e().findToken(n.asset)?.usdPrice,l=c?new ju(c??pe).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:l};o[r]=p}),o}i(ks,"createBalanceStateForNewAccount");function ws(t,e){for(let o in e){let n=Zn(o);if(n){let r=Vt(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}}return t}i(ws,"updateAggregatedBalanceStateForNewAccount");function WT(t,e){let o=Zn(e);if(!o)return t;let n=Vt(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(WT,"removeBalanceFromAggregatedBalance");function vs(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=Zn(l);if(!p)return;!!n.find(d=>Xu(d.address,{address:p.address,blockchain:d.chain,symbol:p.symbol})===l)?a=WT(a,l):s[l]&&(r[l]=s[l])}),{_balances:r,_aggregatedBalances:a}}i(vs,"computeNextStateAfterWalletBalanceRemoval");function MT(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(MT,"matchWalletDetailsWithConnectedWallet");var LT=mu(),Yu=Ku((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,lastUpdatedAt:+new Date,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>o.find(a=>Xn(a,r))?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>o.find(s=>Xn(s,a))?{...a,loading:!1,error:!1,explorerUrl:MT(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>o.find(a=>Xn(a,r))?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n,r)=>{let a=e().connectedWallets,s=o.filter(c=>!a.some(l=>Xn(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(d=>d.walletType===u.walletType&&d.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 ct().getMultipleTokenBalance({assets:p.map(({symbol:d,address:f,blockchain:h})=>({symbol:d,address:f,blockchain:h})),walletAddress:l});if(u){let d=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},m={_aggregatedBalances:e()._aggregatedBalances,findToken:e().findToken};Ts(m,g,d);let y=ks(g,e);f=ws(f,y),d={...d,...y}}),t(h=>({_balances:{...h._balances,...d},_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)=>{let a=o[0];a&&(ve.emit("walletEvent",{type:"connect",payload:{walletType:a.walletType,accounts:o}}),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}=vs(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(ve.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 ct().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(d=>{if(d.failed)return;let f={_balances:l,_aggregatedBalances:p,connectedWallets:e().connectedWallets,findToken:e().findToken};Ts(f,d,l);let{_balances:h,_aggregatedBalances:g}=vs(f,r,{chains:[d.blockChain]});if(p=g,l=h,!e().connectedWallets.find(y=>r.includes(y.walletType)&&y.address===d.address&&y.chain===d.blockChain))return;let m=ks(d,e);p=ws(p,m),l={...l,...m}}),t(d=>({_balances:{...d._balances,...l},_aggregatedBalances:p})),e().setConnectedWalletRetrievedData(o,c);let{retryOnFailedBalances:u=!0}=n||{};if(u){let d=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);d.length>0&&await e().fetchMainTokensBalances(d,{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=Vt(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 d=new xs(u.amount),f=new xs(l.amount);d.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(Bo);return l&&p===o&&(s[c]=l),s},{})},getConnectedWalletsDetails:()=>LT(()=>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=Zn(c);if(p&&p.blockchain===n.chain&&l){let u=e().findToken(p),d=l?.amount?new xs(l.amount).shiftedBy(-l.decimals):pe;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:l.amount,decimal:l.decimals,amount:d.toString(),isSupported:!!u,logo:u?.image||null,usdPrice:u?.usdPrice||null})}return s},[])}}),e().lastUpdatedAt)}));function Zu(t){return PT()(_T((...e)=>({...Yu(...e),...Qu(...e),...Vu(...e),...Xp(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(Zu,"createAppStore");var Ju=$T(null);function T(){let t=FT(Ju);if(OT(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(T,"useAppStore");function Ru(t){let e=UT();return e.current||(e.current=Zu(t.config)),DT.createElement(Ju.Provider,{value:e.current},t.children)}i(Ru,"AppStoreProvider");function bt(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=T(),{state:r,getWalletInfo:a}=zT(),s=T().blockchains(),{handleDisconnect:c}=en(),l=Gp(n()),p=Eu(r,a,l,e);p=HT()?p.filter(m=>m.showOnMobile!==!1&&r(m.type).installed):p;let u=Nu(p),d=i(m=>!o.find(y=>y.walletType===m&&y.chain===e),"isExperimentalChainNotAdded"),f=qT(()=>{let m=p?.filter(y=>y.state===bs.CONNECTING)||[];for(let y of m)c(y)},[Mu(p)]);GT(()=>()=>{f()},[]);let h=i(m=>{let y=m.find(C=>C.type===Jn.DEFAULT);return!y||y.state===bs.NOT_INSTALLED?!1:m.filter(C=>C.state!=bs.NOT_INSTALLED&&![Jn.DEFAULT,Jn.WALLET_CONNECT_2,Jn.LEDGER].includes(C.type)&&a(C.type).supportedChains.filter(k=>k.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),g=i((m,y,S)=>ci(S,y)&&d(m)&&!QT.includes(m)||m==Jn.DEFAULT&&!h(p),"shouldExcludeWallet");return{list:u.filter(m=>!g(m.type,e??"",s)),terminateConnectingWallets:f}}i(bt,"useWalletList");import{Modal as XT}from"@rango-dev/ui";import YT from"react";import{create as jT}from"zustand";var ed="rango-widget";var Rn=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(ed),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 KT=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"),co=KT;var ne=co(jT()((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})}}))),Po=new Rn({onInit:()=>ne.setState({tabManagerInitiated:!0}),onClaim:()=>ne.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>ne.setState({isActiveTab:!1})});function ee(t){let{watermark:e}=ne();return YT.createElement(XT,{hasWatermark:e==="FULL",...t},t.children)}i(ee,"WatermarkedModal");import{i18n as fn}from"@lingui/core";import{Alert as pk,Button as uk,Divider as gn,Image as dk,MessageBox as mk,RadioRoot as fk,WalletImageContainer as gk}from"@rango-dev/ui";import le,{useEffect as hk,useMemo as yk,useState as Sk}from"react";import{i18n as ek}from"@lingui/core";import{Typography as ld}from"@rango-dev/ui";import dn from"react";function hi(t,e){return t.find(o=>o.name===e)?.logo}i(hi,"getBlockchainLogo");import{darkTheme as ZT,Image as JT,styled as Kt,Typography as RT}from"@rango-dev/ui";var yi=Kt("li",{backgroundColor:"$neutral200",padding:"$16",borderRadius:"$sm",variants:{clickable:{true:{cursor:"pointer"}},hasError:{true:{background:"$error100",[`.${ZT} &`]:{backgroundColor:"$error700"}}},unsupported:{true:{cursor:"not-allowed",paddingTop:"$8",paddingBottom:"$8"}}}}),Si=Kt("div",{display:"flex",gap:"$8",alignItems:"center"}),od=Kt("div",{flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between",height:"$40",variants:{showSupportedChains:{true:{justifyContent:"space-between"},false:{justifyContent:"center"}}}}),nd=Kt("div",{flex:"1",display:"flex",alignItems:"center",gap:"$4",opacity:"0.5"}),rd=Kt("div",{display:"flex",gap:"$6",alignItems:"center"}),id=Kt("div",{paddingLeft:"48px"}),ad=Kt("div",{display:"flex",gap:"$2",cursor:"pointer",alignItems:"center",width:"fit-content"}),sd=Kt(RT,{maxWidth:"100px"}),Ci=Kt(JT,{variants:{disabled:{true:{opacity:"0.5"}}}});function Ti(t){let{namespace:e}=t,o=T().blockchains();return dn.createElement(yi,{unsupported:!0},dn.createElement(Si,null,dn.createElement(Ci,{src:hi(o,e.id),size:40,disabled:!0}),dn.createElement(nd,null,dn.createElement(ld,{variant:"label",size:"large"},e.label),dn.createElement(ld,{variant:"body",size:"xsmall"},ek.t("(Currently not supported)")))))}i(Ti,"NamespaceUnsupportedItem");import{Checkbox as sk,Radio as lk}from"@rango-dev/ui";import Ns from"react";import{i18n as As}from"@lingui/core";import{ChevronDownIcon as ok,ChevronUpIcon as nk,Divider as rk,Typography as er}from"@rango-dev/ui";import Ae,{useEffect as ik,useState as ak}from"react";import{Image as pd,Tooltip as ud,Typography as tk}from"@rango-dev/ui";import _t from"react";import{styled as cd}from"@rango-dev/ui";var Es=cd("div",{display:"flex",alignItems:"center",padding:0,margin:0}),ki=cd("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 Is=3;function dd(t){let{chains:e}=t;return _t.createElement(Es,{id:"widget-supported-chains-container"},e.slice(0,Is).map((o,n)=>_t.createElement(ud,{key:o.name,container:B(),side:"bottom",align:"start",content:o.name,sideOffset:4},_t.createElement(ki,{firstItem:n===0},_t.createElement(pd,{src:o.logo,size:15})))),e.length>Is&&_t.createElement(ud,{container:B(),side:"bottom",align:"start",sideOffset:4,content:_t.createElement(Es,null,e.map((o,n)=>_t.createElement(ki,{key:o.name,firstItem:n===0},_t.createElement(pd,{src:o.logo,size:15}))))},_t.createElement(ki,null,_t.createElement(tk,{variant:"body",size:"xsmall"},"+",e.length-Is))))}i(dd,"SupportedChainsList");function _o(t){let{namespace:e,error:o,suffix:n,connected:r,address:a,onClick:s}=t,[c,l]=ak(!1),p=T().blockchains();ik(()=>l(!1),[o]);let u=e.getSupportedChains(p),d=!o&&!r&&u.length>1;return Ae.createElement(yi,{hasError:!!o,clickable:!!s,onClick:s},Ae.createElement(Si,null,Ae.createElement(Ci,{src:hi(p,e.id),size:40}),Ae.createElement(od,{showSupportedChains:d||r||!!o},Ae.createElement(rd,null,Ae.createElement(er,{variant:"label",size:"large"},e.label),r&&Ae.createElement(er,{variant:"body",size:"small",color:"success500"},As.t("Connected")),!!o&&Ae.createElement(er,{variant:"body",size:"small",color:"error500"},As.t("Connection failed"))),d&&Ae.createElement(dd,{chains:u}),r&&Ae.createElement(sd,{variant:"body",size:"small",color:"neutral700"},a),o&&Ae.createElement(ad,{onClick:()=>l(f=>!f)},Ae.createElement(er,{variant:"body",size:"small",color:"neutral700",style:{textDecoration:"underline",userSelect:"none",textDecorationSkipInk:"none"}},As.t("See why")),c?Ae.createElement(nk,{size:12,color:"gray"}):Ae.createElement(ok,{size:12,color:"gray"}))),n),!!o&&c&&Ae.createElement(Ae.Fragment,null,Ae.createElement(rk,{size:4}),Ae.createElement(id,null,Ae.createElement(er,{variant:"body",size:"small",color:"neutral700"},o))))}i(_o,"NamespaceItem");function md(t){let{onClick:e,type:o,namespace:n}=t;return Ns.createElement(_o,{namespace:n,onClick:e,suffix:o==="radio"?Ns.createElement(lk,{value:n.value}):Ns.createElement(sk,{checked:t.value})})}i(md,"NamespaceListItem");import{Button as ck,styled as fd}from"@rango-dev/ui";var wi=fd("ul",{padding:0,paddingBottom:"$20",margin:0}),mn=fd(ck,{minHeight:"$40"});function tr(t){let{targetWallet:e}=t.value,o=e.properties?.find(m=>m.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]=Sk([]),u=yk(()=>a?.data.filter(m=>!m.unsupported),[e?.type]),d=i(m=>{p(r?[m]:y=>y.includes(m)?y.filter(S=>S!==m):y.concat(m))},"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(m=>m.value))},"onSelectAll"),g=i(m=>r?le.createElement(fk,{value:l?.[0]},m):le.createElement(le.Fragment,null,m),"wrapRadioRoot");return hk(()=>{if(!r&&u)if(t.value.defaultSelectedChains?.length){let m=u.filter(y=>y.getSupportedChains(c).some(S=>t.value.defaultSelectedChains?.includes(S.name)));p(m.map(y=>y.value))}else p(u.map(m=>m.value))},[]),le.createElement(le.Fragment,null,le.createElement(mk,{type:"info",title:fn.t("Connect {wallet}",{wallet:e.title}),description:fn.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect."),icon:le.createElement(gk,null,le.createElement(dk,{src:s,size:45}))}),r?le.createElement(le.Fragment,null,le.createElement(gn,{size:20,className:"_initial_namespace_list_header_alert_top_divider"}),le.createElement(pk,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:fn.t("This wallet can only connect to one chain at a time. ")}),le.createElement(gn,{size:30,className:"_initial_namespace_list_header_alert_bottom_divider"})):le.createElement(le.Fragment,null,le.createElement(gn,{size:30,className:"_initial_namespace_list_header_button_top_divider"}),le.createElement(uk,{style:{marginLeft:"auto"},id:"widget-name-space-select-all-btn",size:"xsmall",variant:"ghost",type:"primary",onClick:h},f?fn.t("Deselect all"):fn.t("Select all")),le.createElement(gn,{size:10,className:"_initial_namespace_list_header_button_bottom_divider"})),le.createElement(wi,null,g(le.createElement(le.Fragment,null,a?.data.map((m,y,S)=>le.createElement(le.Fragment,{key:m.id},m.unsupported?le.createElement(Ti,{namespace:m}):le.createElement(md,{value:l.includes(m.value),namespace:m,type:r?"radio":"checkbox",onClick:()=>d(m.value)}),y!==S.length-1&&le.createElement(gn,{size:10})))))),le.createElement(gn,{size:20}),le.createElement(mn,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!l.length,onClick:()=>t.onConfirm(l)},fn.t("Connect")))}i(tr,"Namespaces");import{i18n as or}from"@lingui/core";import{Alert as bk,Button as Ek,Divider as hn,Image as Ik,MessageBox as Ak,WalletImageContainer as Nk}from"@rango-dev/ui";import{useWallets as Bk}from"@rango-dev/wallets-react";import de from"react";import{styled as Ck}from"@rango-dev/ui";var gd=Ck("div",{display:"flex",justifyContent:"end"});import{i18n as Bs}from"@lingui/core";import{Button as Tk,Spinner as kk}from"@rango-dev/ui";import Ws,{useLayoutEffect as wk,useRef as vk,useState as xk}from"react";function hd(t){let{namespace:e,initialConnect:o,disabled:n,state:r,handleConnect:a,handleDisconnect:s}=t,[c,l]=xk(null),p=vk(!1);wk(()=>{o&&!p.current&&u()},[]);let u=i(async g=>{try{p.current=!0,await a(g)}catch(m){l(m)}finally{p.current=!1}},"handleConnectNamespace"),d=i(async()=>{l(null),r.connected?await s():u({shouldAskForDerivationPath:!0})},"handleButtonClick"),f=i(()=>{let g=r.accounts?.[0]?.split(":"),m=g?.[g.length-1];return!r.connected||!m?null:lo(m)},"getConnectedAddress"),h=i(()=>r.connected?Bs.t("Disconnect"):c?Bs.t("Try again"):Bs.t("Connect"),"getButtonText");return Ws.createElement(_o,{namespace:e,connected:r.connected,error:c?.message,address:f(),suffix:r.connecting?Ws.createElement(kk,{color:"info"}):Ws.createElement(Tk,{id:"widget-name-space-connect-btn",variant:"ghost",type:r.connected?"error":"primary",size:"xsmall",onClick:async()=>d(),disabled:n},h())})}i(hd,"NamespaceDetachedItem");function nr(t){let{value:e,selectedNamespaces:o,onConfirm:n,confirmText:r=or.t("Done"),onDisconnectWallet:a,navigateToDerivationPath:s}=t,{targetWallet:c}=e,{connect:l,disconnect:p,state:u}=Bk(),d=c.type,f=u(d),h=c.properties?.find(x=>x.name==="namespaces"),g=c.properties?.find(x=>x.name==="derivationPath"),m=h?.value.selection==="single",y=i(async(x,w)=>{m&&await p(d),g&&w?.shouldAskForDerivationPath?s(x):await l(d,[{namespace:x,network:"",derivationPath:w?.derivationPath??void 0}])},"handleConnectNamespace"),S=i(async x=>{await p(d,[x])},"handleDisconnectNamespace"),C=i(()=>m?de.createElement(de.Fragment,null,de.createElement(hn,{size:20,className:"_detached_namespace_list_header_alert_top_divider"}),de.createElement(bk,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:or.t("This wallet can only connect to one chain at a time.")}),de.createElement(hn,{size:30,className:"_detached_namespace_list_header_alert_bottom_divider"})):de.createElement(de.Fragment,null,de.createElement(hn,{size:30,className:"_detached_namespace_list_header_button_top_divider"}),de.createElement(gd,null,de.createElement(Ek,{id:"widget-detached-disconnect-wallet-btn",variant:"ghost",type:"error",size:"xsmall",disabled:f.connecting||!f.connected,onClick:a},or.t("Disconnect wallet"))),de.createElement(hn,{size:16,className:"_detached_namespace_list_header_button_bottom_divider"})),"renderNamespaceListHeader"),k=i(x=>{if(x.unsupported)return de.createElement(Ti,{namespace:x});let w=o?.find(b=>b.namespace===x.value),I=f.namespaces?.get(x.value);if(!I)throw new Error(`State for ${x.value} was not found!`);let A=m&&f.connecting;return de.createElement(hd,{namespace:x,initialConnect:!!w,disabled:A,state:I,handleConnect:async b=>y(x.value,{derivationPath:w?.derivationPath,shouldAskForDerivationPath:b?.shouldAskForDerivationPath}),handleDisconnect:async()=>S(x.value)})},"renderNamespaceItem");return de.createElement(de.Fragment,null,de.createElement(Ak,{type:"info",title:or.t("Connect {wallet}",{wallet:c.type}),description:or.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect or disconnect."),icon:de.createElement(Nk,null,de.createElement(Ik,{src:c.image,size:45}))}),C(),de.createElement(wi,{id:"widget-detached-namespace-list"},c.needsNamespace?.data.map((x,w,I)=>de.createElement(de.Fragment,{key:x.id},k(x),w!==I.length-1&&de.createElement(hn,{size:10})))),de.createElement(hn,{size:20}),de.createElement(mn,{id:"widget-name-space-confirm-btn",type:"primary",onClick:n},r))}i(nr,"Detached");import{i18n as yn}from"@lingui/core";import{Divider as Pk,Image as _k,MessageBox as Dk,Select as $k,TextField as Fk}from"@rango-dev/ui";import Et,{useEffect as Ok,useState as Sd}from"react";import{namespaces as Wk}from"@rango-dev/wallets-shared";var vi={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Ms(t){let e=t?Wk[t]?.derivationPaths:null;return e?[...e,vi]:[]}i(Ms,"getDerivationPaths");import{Button as Mk,styled as Ls,Typography as Lk}from"@rango-dev/ui";var yd=Ls("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Ps=Ls(Lk,{paddingLeft:"$10"}),_s={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"},u_=Ls(Mk,{minHeight:"$40"});var Cd="0";function rr(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=Sd(null),[c,l]=Sd(Cd),p=a===vi.id,u=Ms(o),d=i(({value:h})=>{let g=u?.find(m=>m.id===h);g&&(a===vi.id&&Number.isNaN(Number(c))&&l(Cd),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 Ok(()=>{s(Ms(o)[0]?.id||null)},[o]),Et.createElement(Et.Fragment,null,Et.createElement(Dk,{type:"info",title:yn.t("Select Derivation Path"),description:yn.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Et.createElement(_k,{src:n,size:45})}),Et.createElement(yd,{className:"_derivation_path_inputs_container"},Et.createElement(Ps,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},yn.t("Choose Derivation Path Template")),Et.createElement($k,{id:"widget-derivation-path-template-select",value:a||"",options:u.map(h=>({value:h.id,label:h.label})),variant:"filled",handleItemClick:d,styles:{trigger:_s}}),Et.createElement(Pk,{size:20}),Et.createElement(Ps,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},p?yn.t("Enter Path"):yn.t("Enter Index")),Et.createElement(Fk,{id:"widget-derivation-path-template-input",type:p?"text":"number",variant:"contained",value:c,onChange:h=>l(h.target.value),style:_s})),Et.createElement(mn,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:f,disabled:!u||!a||!c},yn.t("Confirm")))}i(rr,"DerivationPath");import{i18n as Sn}from"@lingui/core";import{Image as Hk,MessageBox as $s,WalletImageContainer as Qk,WalletState as qk}from"@rango-dev/ui";import{useWallets as Gk}from"@rango-dev/wallets-react";import Do from"react";import{keyframes as Uk,styled as Ds}from"@rango-dev/ui";var w_=Ds("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Td=Ds("div",{position:"relative"}),zk=Uk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),kd=Ds("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${zk} 1s linear infinite`,top:0,bottom:0,right:0,left:0});function Fs(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a,getWalletInfo:s}=Gk();return Kn(s(n),a(n))===qk.CONNECTED?Do.createElement($s,{type:"success",title:Sn.t("Wallet Connected"),description:Sn.t("Your wallet is connected, you can use it to swap.")}):o?Do.createElement($s,{type:"error",title:Sn.t("Failed to Connect"),description:o||Sn.t("Your wallet is not connected. Please try again.")}):Do.createElement($s,{type:"loading",title:Sn.t("Connecting to your wallet"),description:Sn.t("Click connect in your wallet popup."),icon:Do.createElement(Td,null,Do.createElement(Qk,null,Do.createElement(Hk,{src:r,size:45})),Do.createElement(kd,null))})}i(Fs,"ConnectStatus");import{i18n as Os}from"@lingui/core";import{Button as Vk,Divider as wd,MessageBox as Kk}from"@rango-dev/ui";import xi from"react";function Us(t){let{displayName:e,onConfirm:o,id:n}=t;return xi.createElement(Kk,{id:n,title:Os.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:Os.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},xi.createElement(wd,{size:18}),xi.createElement(wd,{size:32}),xi.createElement(Vk,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},Os.t("Confirm")))}i(Us,"ExperimentalChain");function vd(t,e){return t().status==="init"&&!!e}i(vd,"isOnStatus");function ir(t){return t().status==="namespace"}i(ir,"isOnNamespace");function ar(t){return t().status==="derivationPath"}i(ar,"isOnDerivationPath");function Ao(t){return t().status==="detached"}i(Ao,"isOnDetached");var Zk=3e3,Jk=300;function sr(t){let e=Yk(),[o,n]=xd(!1),[r,a]=xd(),s=i(w=>{a(w.message)},"catchErrorOnHandle"),{terminateConnectingWallets:c}=bt(),{handleConnect:l,handleDerivationPath:p,handleNamespace:u,getState:d,resetState:f,handleDisconnect:h}=en(),g=i(w=>{u(t.wallet,w).then(k).catch(s)},"handleConfirmNamespaces"),m=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",b=["disconnected","disconnected-unhandled"].includes(w.status);A?(t.onConnect?.(),I||(e.current=setTimeout(S,Zk))):b&&S()},"afterConnected"),x=i(w=>{t.wallet?.needsDerivationPath&&u(t.wallet,[w])},"handleNavigateToDerivationPath");return Xk(()=>{if(t.wallet){C();let w=!1,I=!0;i(()=>{setTimeout(()=>{I=!1,w||n(!0)},Jk)},"beforeConnecting")(),l(t.wallet,{disconnectIfConnected:!0,defaultSelectedChains:t.options?.defaultSelectedChains}).then(b=>{["namespace","Detached","derivation-path"].includes(b.status)||(w=!0),k(b,I)}).catch(s)}},[t.wallet]),po.createElement(ee,{id:t.id,open:o,onClose:S,onExit:()=>{C(),c(),t.onClose&&t.onClose()},container:B()},vd(d,t.wallet)&&po.createElement(po.Fragment,null,po.createElement(Fs,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),po.createElement(jk,{direction:"vertical",size:32})),ir(d)&&po.createElement(tr,{onConfirm:g,value:d().namespace}),ar(d)&&po.createElement(rr,{onConfirm:y,value:d().derivationPath}),Ao(d)&&po.createElement(nr,{onConfirm:m,onDisconnectWallet:()=>void h(d().namespace.targetWallet),value:d().namespace,selectedNamespaces:d().selectedNamespaces,navigateToDerivationPath:x}))}i(sr,"StatefulConnectModal");import Ra from"react";import Rk,{Fragment as ew}from"react";import{MemoryRouter as tw,useInRouterContext as ow}from"react-router";function bi({children:t}){let o=ow()?ew:tw;return Rk.createElement(o,null,t)}i(bi,"AppRouter");import{I18nManager as nB}from"@rango-dev/ui";import Lp from"react";import Ue from"react";import{useRoutes as _0}from"react-router-dom";var $={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as Tn,useRef as Mi}from"react";import ot from"bignumber.js";import{create as nm}from"zustand";import{subscribeWithSelector as rm}from"zustand/middleware";import{createContext as nw,useContext as rw}from"react";var bd=nw({swapMode:"swap",isMultiMode:!1});function tt(){let{swapMode:t,isMultiMode:e}=rw(bd);return{swapMode:t,isMultiMode:e}}i(tt,"useSwapMode");import{i18n as Tt}from"@lingui/core";import{getRelatedWalletOrNull as sw,RouteEventType as OD}from"@rango-dev/queue-manager-rango-preset";import He from"bignumber.js";import{PendingSwapNetworkStatus as cr}from"rango-types";import{i18n as ze}from"@lingui/core";var re=i(()=>({genericServerError:ze.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:ze.t("Please reset your liquidity sources."),description:ze.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:ze.t("No Routes Found."),description:ze.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:ze.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:ze.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:ze.t("High Price Impact"),title:ze.t("Price impact is too high!"),description:ze.t("The price impact is significantly higher than the allowed amount."),confirmMessage:ze.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:ze.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:ze.t("USD Price Unknown"),title:ze.t("USD Price Unknown, Cannot calculate Price Impact."),description:ze.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:ze.t("Confirm USD Price Unknown")}}),"errorMessages");function Ed(t){return t.type===0?t.diagnosisMessage??re().noResultError.title:t.type===1?t.diagnosisMessage??re().genericServerError:""}i(Ed,"getQuoteErrorMessage");import{i18n as Ei}from"@lingui/core";var $o=i(()=>({connectWallet:Ei.t("Connect Wallet"),swap:Ei.t("Swap"),swapAnyway:Ei.t("Swap anyway"),ethWarning:Ei.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function zs(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(zs,"getFeeLabel");var Hs=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Id=100,Ad=30,Nd=15,Bd=60;var Wd=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Md=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as aw}from"@rango-dev/queue-manager-rango-preset";import bD from"bignumber.js";function Pd(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(Pd,"getRequiredBalanceOfWallet");function Xt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Xt,"getPriceImpactLevel");function Ii(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=aw(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=No(a?a.toBlockchain:n.fromBlockchain,e),l=No(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),d=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:c,fromToken:p,toBlockchain:l,toToken:u,inputAmount:d}}i(Ii,"createRetryQuote");function Cn(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=lr(o),s=Ct(o);if(o&&a&&s){let p=jt(a.toString(),s.toString());if(!!p&&Od(a,p)){let d=Ni(o?.swaps,n),f=Xt(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:d,warningLevel:f}}}if(e&&Hd(e,o))return{type:4,usdValueChange:_(Ct(o)?.minus(Ct(e)??0).toString()??"0",null,2),percentageChange:_(jt(Ct(e)??"1",Ct(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let c=Bi(o.swaps),l=r>sn;if(zd(t.userSlippage.toString(),c)){if(l&&parseFloat(c??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:Ud(o,r),minRequiredSlippage:c};return null}i(Cn,"generateQuoteWarnings");function _d(t){return![4].includes(t.type)}i(_d,"isQuoteWarningConfirmationRequired");function jt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Qs(t.toString(),e.toString());return n&&n<0?n:null}i(jt,"getPriceImpact");var Dd=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"),Ai=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"),$d=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"),Fd=i(t=>{let e=i((o,n)=>{let r=Hs.indexOf(o.value),a=Hs.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function Od(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Wd.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new He(r)))}i(Od,"hasHighValueLoss");function Qd(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new He(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new He(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(Qd,"hasLimitError");function qd(t){let e=(t||[]).filter(c=>{let l=c.fromAmountMinValue?new He(c.fromAmountMinValue):null,p=c.fromAmountMaxValue?new He(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 He(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new He(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=Tt.t({id:"Required: >= {min} {symbol}",values:{min:_(o,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=Tt.t({id:"Required: > {min} {symbol}",values:{min:_(o,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=Tt.t({id:"Required: <= {max} {symbol}",values:{max:_(n,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=Tt.t({id:"Required: < {max} {symbol}",values:{max:_(n,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(qd,"getLimitErrorMessage");function Gd(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:c,needsToWarnEthOnPath:l}=t;return e!=="success"?{title:$o().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||c||!r||r==="0"?{title:$o().swap,action:"confirm-swap",disabled:!0}:s?{title:$o().swapAnyway,action:"confirm-warning",disabled:!1}:l?{title:$o().ethWarning,action:"confirm-warning",disabled:!1}:{title:$o().swap,action:"confirm-swap",disabled:!1}:{title:$o().connectWallet,action:"connect-wallet",disabled:!1}}i(Gd,"getSwapButtonState");function qs(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(pe))&&e&&e!=="0"&&n!==0)}i(qs,"canComputePriceImpact");function Gs(t,e){let o=pe;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 He(r.amount).multipliedBy(a||0))}return o}i(Gs,"getUsdFeeOfStep");function Ni(t,e){return t.reduce((o,n)=>o.plus(Gs(n,e)),pe)}i(Ni,"getTotalFeeInUsd");function Vs(t){let e=pe,o=new He(t.price||0);return e=e.plus(new He(t.amount).multipliedBy(o)),e}i(Vs,"getUsdFee");function Vd(t){return t.reduce((e,o)=>e.plus(Vs(o)),pe)}i(Vd,"getTotalFeesInUsd");function Kd(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(Kd,"getFeesGroup");function jd(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(jd,"checkSlippageErrors");function Ud(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(Ud,"checkSlippageWarnings");function Bi(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(Bi,"getMinRequiredSlippage");function zd(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(zd,"hasProperSlippage");function Xd(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:c,excludeLiquiditySources:l,slippage:p,affiliateRef:u,affiliatePercent:d,affiliateWallets:f,destination:h,contractCall:g}=t,m=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:d??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:m??{},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(Xd,"createQuoteRequestBody");function Yd(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType,derivationPath:n.derivationPath},o),{})}i(Yd,"getWalletsForNewSwap");function lr(t){let e=t.requestAmount,o=t.swaps[0]?.from.usdPrice;if(!(!e||!o))return new He(e).multipliedBy(o)}i(lr,"getUsdInputFrom");function Ct(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1]?.to.usdPrice;if(!(!e||!o))return new He(e).multipliedBy(o)}i(Ct,"getUsdOutputFrom");function Qs(t,e){return new He(e).div(new He(t)).minus(1).multipliedBy(Id).toNumber()}i(Qs,"getPercentageChange");function Hd(t,e){let o=lr(t),n=Ct(t),r=Ct(e);if(!o||!n||!r)return!1;let a=Qs(n.toString(),r.toString());return Md.some(({threshold:s,minInput:c})=>a<=s&&o.isGreaterThanOrEqualTo(c))}i(Hd,"isOutputAmountChangedExcessively");function Zd(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=>Pd(s,n)||[]).filter(s=>!s.ok).map(s=>{let c=s.asset.symbol,l=_(new He(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=_(new He(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=Tt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=Tt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=Tt.t(" for input and network fee")),Tt.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:yt(s.asset.blockchain,o)}})})}i(Zd,"generateBalanceWarnings");function pr(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==cr.NetworkChanged}i(pr,"isNetworkStatusInWarningState");function Jd(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,"")),pr(e)){r=t.networkStatusExtraMessage||"",a=t.networkStatusExtraMessageDetail||"";let p=(e?sw(t,e):null)?.walletType,u=p?o?.(p)?.name:null;switch(e?.networkStatus){case cr.WaitingForConnectingWallet:r=u?Tt.t("Connect {wallet}",{wallet:u}):r;break;case cr.WaitingForQueue:r=r||Tt.t("Waiting for other running tasks to be finished");break;case cr.WaitingForNetworkChange:r=r||Tt.t("Waiting for changing wallet network");break;case cr.NetworkChangeFailed:r=r||Tt.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(Jd,"getSwapMessages");function Rd(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(Rd,"getLastConvertedTokenInFailedSwap");function em(t){return t.status==="failed"}i(em,"shouldRetrySwap");function tm(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(d=>r.some(f=>f.chain===d)),p=c.every(d=>r.some(f=>f.chain===d)),u=o&&a?on(a,o):!1;return!e&&!l||e&&!o||e&&!!o&&(!u||!p)}i(tm,"isConfirmSwapDisabled");function om(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(om,"isTokensIdentical");var Wi=i((t,e)=>t?.usdPrice?new ot(e||pe).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),im=i(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new ot(0),outputUsdValue:new ot(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=pe,a=o.inputUsdValue;return Vn(o.inputAmount)?(e&&(n=e?.outputAmount?new ot(e?.outputAmount):null,a=lr(e)??pe,r=Ct(e)??pe),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new ot(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new ot(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new ot(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:Wi(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 ot(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=xu(e);t(()=>({inputAmount:o}))},setInputAmount:e=>{let o=Tu(e);ii(e)||(o=gu(o),o=hu(o)),t(n=>({inputAmount:o,...!o&&{outputAmount:null,outputUsdValue:new ot(0),selectedQuote:null},...!!n.fromToken&&{inputUsdValue:Wi(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:Wi(n??null,s),outputUsdValue:new ot(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?Wi(e.toToken,e.outputAmount?.toString()||""):new ot(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new ot(0),inputUsdValue:new ot(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new ot(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"),am=nm()(rm(im)),sm=nm()(rm(im)),lw=co(am),cw=co(sm);function H(){let{swapMode:t}=tt();return co(t==="refuel"?sm:am)}i(H,"useQuoteStore");var lm=i((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&ve.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&&ve.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"),cm=lw.subscribe(lm),pm=cw.subscribe(lm);function um(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:c,fromBlockchain:l,toBlockchain:p}=H()(),u=T().config,d=T().fetchStatus,f=T().blockchains(),{findToken:h}=T(),{setAffiliateRef:g,setAffiliatePercent:m,setAffiliateWallets:y}=T(),S=u?.from?.tokens,C=u?.from?.blockchains,k=u?.to?.tokens,x=u?.to?.blockchains,w=Mi(void 0),I=Mi(void 0),A=Mi(void 0),b=Mi(void 0);Tn(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),Tn(()=>{if(d==="success"){r();let E=f.find(M=>M.name===u?.from?.blockchain),v=u?.from?.token,N=v&&h(v);(E||!E&&A.current)&&n(E??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,d]),Tn(()=>{fs(s,S)&&a({token:null}),gs(l,C)&&n(null)},[S,C]),Tn(()=>{fs(c,k)&&a({token:null}),gs(p,x)&&o(null)},[k,x]),Tn(()=>{if(d==="success"){r();let E=f.find(M=>M.name===u?.to?.blockchain),v=u?.to?.token,N=v&&h(v);(E||!E&&b.current)&&o(E??null),N?e({token:N,meta:{blockchains:f}}):!N&&I.current&&e({token:null}),b.current=u?.to?.blockchain,I.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,d]),Tn(()=>{g(u?.affiliate?.ref??null),m(u?.affiliate?.percent??null),y(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(um,"useSyncStoresWithConfig");import{useEffect as Xs,useRef as pw}from"react";import{useInRouterContext as uw,useLocation as dw,useSearchParams as mw}from"react-router-dom";function Ks(t,e){let o=t.split("--");return o[0]?{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}:null}i(Ks,"convertTokenSearchParamToAsset");function js(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(js,"tokenToSearchParam");function Zs(){let t=dw(),[e,o]=mw(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:c,setFromBlockchain:l,setToBlockchain:p,setFromToken:u,setToToken:d,setInputAmount:f}=H()(),h=T().fetchStatus,g=T().blockchains(),m=uw(),{updateIframe:y,updateCampaignMode:S}=T(),C=T().isInCampaignMode(),k=pw(),{findToken:x}=T(),w=i(()=>{let A={};for(let[W,J]of e.entries())(W.startsWith("utm_")||W.startsWith("privy_"))&&(A[W]=J);let b=e.get("fromAmount"),E=e.get("fromBlockchain"),v=e.get("fromToken"),N=e.get("toBlockchain"),M=e.get("toToken"),P=e.get("autoConnect"),U=e.get("clientUrl"),Q=e.get("liquiditySources"),Z=e.get("blockchain");return{fromAmount:b,fromBlockchain:E,fromToken:v,toBlockchain:N,toToken:M,autoConnect:P,clientUrl:U,liquiditySources:Q,extraQueryParams:A,blockchain:Z}},"getUrlSearchParams"),I=i(A=>{for(let b in A)A[b]||delete A[b];o(A,{replace:!0})},"updateUrlSearchParams");Xs(()=>{let{autoConnect:A,clientUrl:b,extraQueryParams:E,blockchain:v}=w();m&&h==="success"&&I({fromBlockchain:n?.name,fromToken:js(a),toBlockchain:r?.name,toToken:js(s),fromAmount:c,autoConnect:A??void 0,clientUrl:b??void 0,blockchain:v??void 0,liquiditySources:C?k.current:void 0,...E})},[t.pathname,c,n,a,r,s,C,h]),Xs(()=>{if(!m)return;let A=w();if(!k.current&&A.liquiditySources&&(k.current=A.liquiditySources),A.fromAmount&&f(A.fromAmount),h==="success"){let b=g.find(U=>U.name===A.fromBlockchain),E=A.fromToken&&b&&Ks(A.fromToken,b),v=E?x(E):void 0,N=g.find(U=>U.name===A.toBlockchain),M=A.toToken&&N&&Ks(A.toToken,N),P=M?x(M):void 0;b&&(l(b),v&&u({token:v,meta:{blockchains:g}})),N&&(p(N),P&&d({token:P,meta:{blockchains:g}}))}},[h]),Xs(()=>{let{clientUrl:A,liquiditySources:b}=w();y("clientUrl",A||void 0),S("liquiditySources",b?.split(",")??void 0)},[])}i(Zs,"useSyncUrlAndStore");import{i18n as vn}from"@lingui/core";import{Alert as Pv,Button as _v,darkTheme as Dv,Divider as Il,DoneIcon as $v,styled as Fv,TextField as Ov,Typography as Uv}from"@rango-dev/ui";import qe,{useState as zv}from"react";import{useNavigate as Hv,useSearchParams as Qv}from"react-router-dom";import{ChevronRightIcon as fw,Divider as hm,Image as gw,Typography as ym}from"@rango-dev/ui";import It from"react";import{darkTheme as dm,styled as Js}from"@rango-dev/ui";var mm=Js("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${dm} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${dm} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),fm=Js("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),gm=Js("div",{display:"flex"});function Rs(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return It.createElement(fm,null,It.createElement(ym,{size:"large",variant:"label"},n),It.createElement(hm,{size:10}),It.createElement(mm,{onClick:s?void 0:e,disabled:s,id:"widget-blockchain-selector-container"},It.createElement(gm,null,r&&It.createElement(It.Fragment,null,It.createElement(gw,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),It.createElement(hm,{size:4,direction:"horizontal"})),It.createElement(ym,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),It.createElement(fw,{size:12,color:"black"})))}i(Rs,"BlockchainSelectorButton");import{i18n as nl}from"@lingui/core";import{Button as vw,Divider as vm,MessageBox as xw}from"@rango-dev/ui";import uo,{useEffect as xm,useState as rl}from"react";import{i18n as Li}from"@lingui/core";import{Divider as Fo,ExternalLinkIcon as Sw,Image as Cw,InfoIcon as Tw,Tooltip as kw,Typography as dr}from"@rango-dev/ui";import me from"react";var Sm="https://blog.rango.exchange/understanding-the-risks-of-using-custom-token-contract-addresses-96022308eca4";function Cm(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(Cm,"generateExplorerLink");import{Button as hw,darkTheme as kn,styled as ur,Typography as yw}from"@rango-dev/ui";var el=ur("a",{textDecoration:"none",color:"$colors$neutral700",[`.${kn} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${kn} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${kn} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${kn} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),Tm=ur("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${kn} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${kn} &`]:{color:"$colors$neutral900"}}}),tl=ur(hw,{minHeight:"$40"}),km=ur(yw,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"96px"}),wm=ur("div",{display:"flex",justifyContent:"center",alignItems:"center"});var ww=9;function ol(t){let{open:e,onClose:o,token:n,onExit:r,onSubmitClick:a,blockchain:s}=t,c=Cm(n.address,s),l=i(()=>window.open(Sm,"_blank"),"onClickLearnMore");return me.createElement(ee,{open:e,id:"widget-custom-token-watermarked-modal",dismissible:!0,onClose:o,onExit:r,container:B()},me.createElement(Tm,null,me.createElement(Cw,{src:n.image===""?ti:n.image,size:45,type:"circular"}),me.createElement(Fo,{size:4}),me.createElement(wm,null,me.createElement(km,{variant:"title",size:"medium"},n.symbol),n.symbol.length>ww&&me.createElement(kw,{content:n.symbol,container:B()},me.createElement(Tw,{size:12,color:"gray"}))),me.createElement(dr,{variant:"body",size:"small",className:"_blockchain-name"},s.displayName),me.createElement(Fo,{size:4}),me.createElement(dr,{variant:"body",size:"medium"},c?me.createElement(el,{hasHover:!0,href:c,target:"_blank",rel:"nofollow noreferrer"},n.address,me.createElement(Sw,{size:12,color:"gray"})):me.createElement(el,null,n.address)),me.createElement(Fo,{size:4}),n.coinSource&&me.createElement(dr,{className:"_coin-source",variant:"body",size:"xsmall"},Li.t("via")," ",me.createElement(dr,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),me.createElement(Fo,{size:"32"}),me.createElement(dr,{size:"medium",variant:"body",className:"_custom-token-description"},Li.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."))),me.createElement(Fo,{size:40}),me.createElement(Fo,{size:10}),me.createElement(tl,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:a},Li.t("Import Anyway")),me.createElement(Fo,{size:10}),me.createElement(tl,{id:"widget-custom-token-modal-learn-more-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:l},Li.t("Learn More")))}i(ol,"CustomTokenModal");function mr(t){let{token:e,blockchain:o,error:n,address:r,fetchCustomToken:a,onCloseErrorModal:s,onImport:c,onExitErrorModal:l,onExitImportModal:p}=t,{setCustomToken:u}=T(),[d,f]=rl(!1),[h,g]=rl(!1),[m,y]=rl(!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"),x=i(()=>{m&&n?.type==="network-error"&&(y(!1),S()),l()},"handleExit"),w=i(()=>{e&&(u(e),c())},"handleSubmit");return xm(()=>{n&&f(!0)},[n]),xm(()=>{o&&e&&g(!0)},[o,e]),uo.createElement(uo.Fragment,null,uo.createElement(ee,{open:d,dismissible:!0,id:"widget-add-custom-token-modal",onClose:C,onExit:x,container:B()},uo.createElement(xw,{title:n?.title??"",type:"error",description:n?.message||nl.t("Failed Network, Please retry.")},uo.createElement(vm,{size:40}),uo.createElement(vm,{size:10}),uo.createElement(vw,{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"?nl.t("Retry"):nl.t("Add another custom token")))),o&&e&&uo.createElement(ol,{blockchain:o,token:e,onSubmitClick:w,onClose:()=>g(!1),open:h,onExit:p}))}i(mr,"ImportCustomToken");import{useManager as Av}from"@rango-dev/queue-manager-react";import{BottomLogo as Nv,Divider as rf,Header as Bv}from"@rango-dev/ui";import Be,{useEffect as Qi,useLayoutEffect as Wv,useRef as af,useState as sf}from"react";import{useRef as bw}from"react";function Pi(){return window.self!==window.top}i(Pi,"isAppLoadedIntoIframe");function il(){let t=bw(null),{iframe:e}=T(),o=Pi()&&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(il,"useIframe");import{useNavigate as Ew}from"react-router-dom";function Qe(){let t=Ew();return()=>t(-1)}i(Qe,"useNavigateBack");import{createTheme as dl,darkTheme as Ow,lightTheme as Uw}from"@rango-dev/ui";import{useEffect as zw,useState as Hw}from"react";import{theme as $w,darkColors as Fw}from"@rango-dev/ui";import pl from"react";var _i=16,Di=255,bm=.11;function Iw(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(Iw,"expandShortHexColor");function Aw(t,e){return t.padStart(e,"0")}i(Aw,"pad");function al(t){let e=Math.min(Math.max(Math.round(t),0),Di);return Aw(e.toString(_i),2)}i(al,"intToHex");function Nw(t){return`#${al(t.red)}${al(t.green)}${al(t.blue)}`}i(Nw,"rgbToHex");function Bw(t){let e=parseInt(t.slice(1,3),_i),o=parseInt(t.slice(3,5),_i),n=parseInt(t.slice(5,7),_i);return{red:e,green:o,blue:n}}i(Bw,"hexToRGB");function Ww(t,e){let o=1-bm*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(Ww,"generateShade");function Mw(t,e){let o=bm*e;return{red:t.red+(Di-t.red)*o,green:t.green+(Di-t.green)*o,blue:t.blue+(Di-t.blue)*o}}i(Mw,"generateTint");function Lw(t){return Em(t,Ww)}i(Lw,"calculateShades");function Pw(t){return Em(t,Mw)}i(Pw,"calculateTints");function Em(t,e){let o=Bw(t),n=[];for(let r=1;r<9;r++)n.push(Nw(e(o,r)));return n}i(Em,"calculateColors");function sl(t,e,o){let a=Pw(t).reverse().concat(t),s=Lw(t),c=a.concat(s),l={},p=c.length;for(let u=0;u<p;u++){let d=100+(o?p-1-u:u)*50,f=c[u];f&&(l[`${e}${d}`]=f)}return l}i(sl,"createTintsAndShades");function ll(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)&&!wu(r)){let l=Iw(a);Object.assign(n,sl(l,r,s))}}return{...n,...e}}i(ll,"expandToGenerateThemeColors");var Im=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),_w=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=Im(o%52)+e;return Im(o%52)+e},"toAlphabeticName"),Dw=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),cl=i(t=>_w(Dw(5381,JSON.stringify(t))>>>0),"toHash");function ul(t){let e=$w.colors,o={...e,...Fw},n,r;if(t?.light){let s={colors:ll(e,t.light)};n={id:`${ms}-light-${cl(s)}`,tokens:s}}if(t?.dark){let s={colors:ll(o,t.dark,{reverseNeutralRange:!0})};r={id:`${ms}-dark-${cl(s)}`,tokens:s}}return{light:n,dark:r}}i(ul,"customizedThemeTokens");function Am(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>pl.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(pl.cloneElement(a,{key:s})),r<t.length-1){let c=`divider-${r}`;o.push(pl.cloneElement(e,{key:c}))}}),o}i(Am,"joinList");function Nm(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Nm,"doesWindowPreferDarkColorScheme");function mo(t){let{colors:e,fontFamily:o=ru,borderRadius:n=Du,secondaryBorderRadius:r=$u}=t,[a,s]=Hw(Nm()?"dark":"light"),{theme:c}=T(),{dark:l,light:p}=ul(e),u=dl({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),d=[u.className,Uw.className],f=[u.className,Ow.className];if(p){let g=dl(p.id,p.tokens);d.push(g.className)}if(l){let g=dl(l.id,l.tokens);f.push(g.className)}return zw(()=>{let g=i(m=>{m.matches?s("dark"):s("light")},"switchThemeListener");return Nm()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",g),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",g)}},[]),{activeTheme:i(()=>{let g=d.join(" "),m=f.join(" ");return c==="auto"?a==="dark"?m:g:c==="dark"?m:g},"getActiveTheme"),mode:c==="auto"?a:c}}i(mo,"useTheme");var kt=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 Bm}from"@lingui/core";import{Alert as Qw,Button as qw}from"@rango-dev/ui";import Wm from"react";function ml(t){return Wm.createElement(Qw,{action:Wm.createElement(qw,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Bm.t("Activate this tab")),type:"warning",variant:"alarm",title:Bm.t("Another tab is open and handles transactions.")})}i(ml,"ActivateTabAlert");import{i18n as fl}from"@lingui/core";import{Button as Gw,Divider as Vw,MessageBox as Kw}from"@rango-dev/ui";import $i from"react";function gl(t){let{open:e,onClose:o,onConfirm:n}=t;return $i.createElement(ee,{open:e,dismissible:!0,onClose:o,id:"widget-active-tab-modal",container:B()},$i.createElement(Kw,{title:fl.t("Activate current tab"),type:"warning",description:fl.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.")},$i.createElement(Vw,{size:20}),$i.createElement(Gw,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},fl.t("Confirm"))))}i(gl,"ActivateTabModal");import{ChevronLeftIcon as Yw}from"@rango-dev/ui";import Om from"react";import{css as jw,darkTheme as Mm,IconButton as Xw,styled as Oo}from"@rango-dev/ui";var Dt=Oo(Xw,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${Mm} &`]:{backgroundColor:"$neutral"}}}),Lm=Oo("div",{position:"absolute",background:"$secondary500",[`.${Mm} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),fo=Oo("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),Pm=Oo("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"}}}}),_m=Oo("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Dm=Oo("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),$m=jw({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Fm=Oo("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});function hl(t){return Om.createElement(Dt,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Om.createElement(Yw,{color:"black",size:16}))}i(hl,"BackButton");import{i18n as Zw}from"@lingui/core";import{Button as Jw,Typography as Rw}from"@rango-dev/ui";import yl from"react";function Sl(t){return yl.createElement(fo,null,yl.createElement(Jw,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},yl.createElement(Rw,{variant:"label",size:"medium",color:"error500"},Zw.t("Cancel"))))}i(Sl,"CancelButton");import{i18n as ev}from"@lingui/core";import{Image as tv,Tooltip as ov,WalletIcon as nv,WalletState as Um}from"@rango-dev/ui";import Uo from"react";function Cl(t){let{list:e}=bt(),o=e.filter(r=>r.state===Um.CONNECTED||r.state===Um.PARTIALLY_CONNECTED),n=o.length?Uo.createElement("div",{className:$m()},o.map(r=>Uo.createElement(Fm,{key:r.title},Uo.createElement(tv,{src:r.image,size:14})))):ev.t("Connect Wallet");return Uo.createElement(ov,{container:t.container,side:"bottom",content:n},Uo.createElement(Dt,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&Uo.createElement(Lm,null),Uo.createElement(nv,{size:18,color:"black"})))}i(Cl,"WalletButton");import{i18n as Oi}from"@lingui/core";import{NotificationsIcon as Cv,Popover as Tv,SettingsIcon as kv,Tooltip as Ui,TransactionIcon as wv}from"@rango-dev/ui";import Le from"react";import{Notifications as sv}from"@rango-dev/ui";import lv from"react";import{useNavigate as cv}from"react-router-dom";import{create as rv}from"zustand";import{persist as iv,subscribeWithSelector as av}from"zustand/middleware";var Ne=co(rv()(iv(av((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 Tl(){let t=cv(),{getNotifications:e,clearNotifications:o}=Ne(),n=e(),r=T().blockchains(),{findToken:a}=T();return lv.createElement(sv,{id:"widget-notifications-container",list:n,getBlockchainImage:c=>Vp(c,r),getTokenImage:c=>a(c)?.image,onClickItem:i(c=>{t(`${$.swaps}/${c}`)},"onClickItem"),onClearAll:o})}i(Tl,"NotificationContent");import{useManager as pv}from"@rango-dev/queue-manager-react";import{InProgressIcon as uv}from"@rango-dev/ui";import zm from"react";var dv=i(()=>{let{manager:t}=pv();return kt(t).map(({swap:o})=>o).find(o=>o.status==="running")?zm.createElement(Dm,{id:"widget-header-history-badge-container"},zm.createElement(uv,{color:"info",size:6})):null},"InProgressTransactionBadge"),Hm=dv;import{EventSeverity as mv}from"@rango-dev/queue-manager-rango-preset";import{Typography as fv}from"@rango-dev/ui";import Qm from"react";function qm(){let{getNotifications:t}=Ne(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===mv.WARNING);return o?Qm.createElement(Pm,{isSever:n},Qm.createElement(fv,{variant:"body",size:"xsmall",color:"$background",id:"widget-header-notifications-badge-container"},o)):null}i(qm,"NotificationsBadge");import{RefreshProgressButton as gv}from"@rango-dev/ui";import kl,{useEffect as hv,useState as Gm}from"react";var yv=1e3,Vm=60,Sv=100;function Fi({onClick:t}){let[e,o]=Gm(0),[n,r]=Gm(!1),a=i(l=>{document.hidden&&l&&s(l)},"handleVisibilityChange");hv(()=>{let l;return t?l=window.setInterval(()=>{o(p=>p+1),e===Vm&&c()},yv):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 kl.createElement(Dt,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:c,disabled:!t},kl.createElement(_m,{onTransitionEnd:()=>r(!1),isRefetched:n},kl.createElement(gv,{size:22,color:t?"black":"gray",progress:e/Vm*Sv})))}i(Fi,"RefreshButton");function zo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=T(),c=et("notification",s)||r.includes("notifications");return Le.createElement(Le.Fragment,null,!r.includes("refresh")&&Le.createElement(Ui,{container:a||B(),side:"top",content:Oi.t("Refresh")},Le.createElement(Fi,{onClick:e})),!c&&Le.createElement(Tv,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:B(),content:Le.createElement(Tl,null)},Le.createElement("div",null,Le.createElement(Ui,{container:B(),side:"top",content:Oi.t("Notifications")},Le.createElement(Dt,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Le.createElement(Cv,{size:18,color:"black"}),Le.createElement(qm,null))))),!r.includes("settings")&&Le.createElement(Ui,{container:B(),side:"top",content:Oi.t("Settings")},Le.createElement(Dt,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Le.createElement(kv,{size:18,color:"black"}))),!r.includes("history")&&Le.createElement(Ui,{container:B(),side:"top",content:Oi.t("History")},Le.createElement(Dt,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Le.createElement(wv,{size:18,color:"black"}),Le.createElement(Hm,null))))}i(zo,"HeaderButtons");import{i18n as wl}from"@lingui/core";import{Divider as jm,MessageBox as bv,RefreshIcon as Ev}from"@rango-dev/ui";import wn from"react";import{Button as vv,styled as xv}from"@rango-dev/ui";var Km=xv(vv,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function vl(t){let{open:e,onClose:o}=t;return wn.createElement(ee,{open:e,dismissible:!0,onClose:o,id:"widget-refresh-modal",container:B()},wn.createElement(bv,{title:wl.t("Something went wrong"),type:"error",description:wl.t("Something went wrong. Please refresh the app.")},wn.createElement(jm,{size:30}),wn.createElement(Km,{variant:"outlined",id:"widget-refresh-modal-refresh-btn",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},wn.createElement(Ev,{size:20,color:"primary"}),wn.createElement(jm,{size:4,direction:"horizontal"}),wl.t("Refresh"))))}i(vl,"RefreshModal");var Xm="700px",Ym="425px",Zm="550px",Jm="640px",Rm="800px";function xl(t){let e=t.target;if(e){let o=e.scrollTop,n=B();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(xl,"onScrollContentAttachStatusToContainer");import{css as Iv,styled as zi}from"@rango-dev/ui";var Hi=Iv({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),ef=zi("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",maxHeight:Xm,variants:{height:{auto:{height:"auto"},fixed:{height:"100%",minHeight:Ym,[`@media screen and (min-height: ${Rm})`]:{minHeight:Zm}}},showBanner:{true:{overflow:"visible"}}}}),tf=zi("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),of=zi("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"}}}),nf=zi("div",{width:"100%",position:"absolute",bottom:"-$10",transform:"translateY(100%)",overflow:"hidden"});function se(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=il(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:c,connectedWallets:l,config:{__UNSTABLE_OR_INTERNAL__:p}}=T(),[u,d]=sf(!1),{config:{features:f,theme:h}}=T(),{watermark:g}=ne(),m=g==="FULL",{activeTheme:y}=mo(h||{}),[S,C]=sf(!1),k=et("connectWalletButton",f),{isActiveTab:x,tabManagerInitiated:w,showActivateTabModal:I,setShowActivateTabModal:A,activateCurrentTab:b,setShowCompactTokenSelector:E}=ne(),v=Qe(),{manager:N}=Av(),P=kt(N).map(({swap:X})=>X).some(X=>X.status==="running"),U=i(()=>b(Po.forceClaim,P),"onActivateTab"),Q=i(()=>{r.onWallet?.()},"onConnectWallet"),Z=typeof r.hasBackButton>"u"||r.hasBackButton,W=af(null),J=af(null);return Qi(()=>{let X=(p?.swapBoxBanner?.routes?.length??0)===0,ae=!!p?.swapBoxBanner?.routes?.some(Se=>location.pathname.endsWith(Se));C(!!p?.swapBoxBanner&&(X||ae))},[p?.swapBoxBanner?.routes?.toString(),location.pathname]),Qi(()=>(Pi()&&J.current&&e(J.current),()=>{o()}),[]),Qi(()=>(W.current?.addEventListener("scroll",xl),()=>{W.current?.removeEventListener("scroll",xl)}),[]),Qi(()=>{d(c==="failed")},[c]),Wv(()=>{if(!J.current)return;let X=new ResizeObserver(ae=>{for(let Se of ae)Se.contentRect&&E(Se.contentRect.height<parseInt(Jm))});return X.observe(J.current),()=>X.disconnect()},[]),Be.createElement(ef,{height:s,id:Re.SWAP_BOX_ID,className:`${y()} ${Hi()}`,ref:J,showBanner:S},Be.createElement(Bv,{prefix:Z?Be.createElement(hl,{onClick:()=>{v(),r.onBack?.()}}):null,title:r.title,suffix:Be.createElement(Be.Fragment,null,r.suffix,r.onWallet&&!k&&Be.createElement(Cl,{container:B(),onClick:Q,isConnected:!!l?.length}),r.onCancel&&Be.createElement(Sl,{onClick:r.onCancel}))}),Be.createElement(tf,{ref:W},n),Be.createElement(gl,{open:I,onClose:()=>A(!1),onConfirm:U}),Be.createElement(of,null,Be.createElement("div",{className:"footer__content"},w&&!x&&Be.createElement("div",{className:"footer__alert"},Be.createElement(ml,{onActivateTab:U}),Be.createElement(rf,{size:10})),a),Be.createElement(rf,{size:12}),Be.createElement("div",{className:`footer__logo ${m?"logo__show":"logo__hidden"}`},Be.createElement(Nv,null))),S&&Be.createElement(nf,null,p?.swapBoxBanner?.element),Be.createElement(vl,{open:u,onClose:()=>d(!1)}))}i(se,"Layout");import{styled as Mv}from"@rango-dev/ui";var lf="$20 $20 $10 $20",bl=Mv("div",{padding:lf,overflowY:"auto",flexGrow:1});import{styled as Lv}from"@rango-dev/ui";var ce=Lv("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 go}from"@lingui/core";import{useState as El}from"react";function cf(){let[t,e]=El(!1),[o,n]=El(null),[r,a]=El(null),{findToken:s}=T(),c=T().customTokens(),l=i(()=>{a(null),e(!1),n(null)},"resetState");function p(d,f){switch(d){case"duplicated":return{type:d,title:go.t("Duplicate Token"),message:go.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{type:d,title:go.t("Token Already Exists"),message:go.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{type:d,title:go.t("Token Not Found"),message:go.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:d,title:go.t("Network error"),message:go.t("An error occurred while retrieving token data.")}}}return i(p,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:d,tokenAddress:f})=>{e(!0);try{if(c.some(S=>S.address?.toLowerCase()===f.toLowerCase())){let S=p("duplicated");n(S);return}let g=await ct().getCustomToken({blockchain:d,address:f});if(!g||!g.token||g.error){let S=p("not-found",d);n(S);return}let m=g.token;if(s({blockchain:m.blockchain,address:m.address,symbol:m.symbol})){let S=p("token-exist");n(S);return}return a({...m,warning:!0})}catch(h){if(h.code==="ERR_BAD_REQUEST"){let g=p("not-found",d);n(g);return}n(p("network-error"));return}finally{e(!1)}},"fetchCustomToken"),token:r,loading:t,error:o,resetState:l}}i(cf,"useFetchCustomToken");var qv=Fv("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $12",backgroundColor:"$neutral300","& input":{padding:"0"},[`.${Dv} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}});function pf(){let t=Hv(),[e]=Qv(),o=Qe(),n=T().blockchains(),r=e.get("blockchain")||"",a=No(r,n),[s,c]=zv(""),{fetchCustomToken:l,token:p,loading:u,error:d,resetState:f}=cf(),h=!!a&&on(a,s),g=!a||!s||!h,m=i(()=>{a&&l({blockchain:r,tokenAddress:s})},"getCustomToken");return qe.createElement(se,{header:{title:vn.t("Add Custom Token")}},qe.createElement(ce,null,qe.createElement(qv,null,qe.createElement("div",null,qe.createElement(Rs,{onClick:()=>t($.blockchains,{replace:!0}),hasLogo:!!a?.logo,value:a?{name:a.displayName,logo:a.logo}:void 0,title:vn.t("Select chain"),placeholder:vn.t("Select chain")}),qe.createElement(Il,{size:"24"}),qe.createElement(Uv,{size:"large",variant:"label"},vn.t("Enter Address")),qe.createElement(Il,{size:10}),qe.createElement(Ov,{fullWidth:!0,id:"widget-add-custom-token-token-address-input",disabled:!a,variant:"contained",placeholder:vn.t("Enter token address"),size:"large",value:s,suffix:!!s&&h&&qe.createElement($v,{color:"success",size:12}),onChange:y=>c(y.target.value)}),!h&&!!s&&qe.createElement(qe.Fragment,null,qe.createElement(Il,{size:4}),qe.createElement(Pv,{id:"widget-add-custom-token-invalid-address-alert",type:"error",variant:"alarm",title:"Invalid Address"}))),qe.createElement(_v,{id:"widget-add-custom-token-import-btn",disabled:g,type:"primary",variant:"contained",loading:u,size:"large",onClick:m},vn.t("Import"))),qe.createElement(mr,{token:p,blockchain:a??void 0,address:s,error:d??void 0,fetchCustomToken:l,onCloseErrorModal:()=>{d?.type!=="network-error"&&c("")},onImport:o,onExitErrorModal:f,onExitImportModal:f})))}i(pf,"AddCustomTokenPage");import{i18n as lc}from"@lingui/core";import{useManager as Pb}from"@rango-dev/queue-manager-react";import{Alert as _b,Button as Db,css as pc,Divider as cc,IconButton as oh,styled as $b,Typography as Fb,WalletIcon as Ob}from"@rango-dev/ui";import De,{useEffect as ya,useLayoutEffect as Ub,useRef as zb,useState as br}from"react";import{useNavigate as Hb}from"react-router-dom";import{i18n as Ho}from"@lingui/core";import{Alert as hx,BalanceErrors as yx,Button as Df,ChevronLeftIcon as Sx,Divider as _l,MessageBox as Cx,Typography as Dl}from"@rango-dev/ui";import ie,{useCallback as Tx,useEffect as $f,useMemo as kx,useState as In}from"react";import{useNavigate as wx}from"react-router-dom";import{i18n as Wl}from"@lingui/core";import{Alert as Xv,ChevronDownIcon as Yv,CloseIcon as Zv,Divider as yf,IconButton as Sf,PasteIcon as Jv,Typography as Rv,WalletIcon as ex}from"@rango-dev/ui";import Pe,{useEffect as tx,useRef as ox}from"react";import Ki,{useRef as Kv}from"react";import*as xn from"@radix-ui/react-collapsible";import{keyframes as uf,styled as qi}from"@rango-dev/ui";var Al=300,Gv=uf({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Vv=uf({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),df=qi(xn.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),Nl=qi(xn.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Gi=qi(xn.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Gv} ${Al}ms ease-out`},false:{animation:`${Vv} ${Al}ms ease-out`}}}}),Vi=qi("div",{transition:`all ${Al}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function ji(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:c}=t,l=Kv(null);return Ki.createElement(df,{ref:l,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},c==="top"&&Ki.createElement(Nl,{className:"collapsible_trigger",onClick:a},s),Ki.createElement(Gi,{className:"collapsible_content",open:e},r),c==="bottom"&&Ki.createElement(Nl,{className:"collapsible_trigger",onClick:a},s))}i(ji,"CustomCollapsible");import{darkTheme as mf,styled as Bl,TextField as jv}from"@rango-dev/ui";var ff=Bl("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"},"& input":{padding:"$15"}}),gf=Bl(jv,{backgroundColor:"$neutral100"}),hf=Bl("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${mf} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${mf} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function Cf(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=H()(),{config:s}=T(),c=T().blockchains(),l=Rr(e.name,c),p=ox(null),u=s?.defaultCustomDestinations?.[e.name],d=navigator?.userAgent.includes("Firefox"),h=n&&!!r&&e&&!on(e,r),g=i(()=>{a("")},"handleClear"),m=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let C=await navigator.clipboard.readText();a(C),p?.current?.focus()}},"handlePaste"),y=i(()=>r?Pe.createElement(Sf,{id:"widget-custom-destination-close-icon-btn",onClick:g,variant:"ghost"},Pe.createElement(Zv,{size:12,color:"gray"})):d?null:Pe.createElement(Sf,{id:"widget-custom-destination-paste-icon-btn",onClick:m,variant:"ghost"},Pe.createElement(Jv,{size:16})),"renderSuffix");return tx(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),Pe.createElement(ff,null,Pe.createElement(ji,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Pe.createElement(hf,{id:"widget-custom-destination-collapsible-btn"},Pe.createElement("div",{className:"button__content"},Pe.createElement(ex,{size:18,color:"info"}),Pe.createElement(yf,{size:4,direction:"horizontal"}),Pe.createElement(Rv,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Wl.t("Send to a different address"))),Pe.createElement(Vi,{orientation:n?"up":"down"},Pe.createElement(Yv,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Pe.createElement(gf,{id:"widget-custom-destination-blockchain-address-input",ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Wl.t("Enter {blockchainName} address",{blockchainName:l}),value:r||"",suffix:y(),onChange:S=>{let C=S.target.value;a(C)}})),h&&Pe.createElement(Pe.Fragment,null,Pe.createElement(yf,{size:4}),Pe.createElement(Xv,{variant:"alarm",type:"error",title:Wl.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(Cf,"CustomDestination");import{css as nx,IconButton as rx,SelectableWalletButton as ix,styled as ho}from"@rango-dev/ui";var Tf=ho("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),kf=ho("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),wf=ho(ix,{justifyContent:"center"}),vf=ho("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),xf=ho(rx,{position:"absolute",left:"$20"}),bf=ho("div",{paddingTop:"$20"}),Ef=nx({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),If=ho("div",{display:"flex"}),Af=ho("div",{overflow:"visible",width:"100%"});import{i18n as Ll}from"@lingui/core";import{warn as px}from"@rango-dev/logging-core";import{Divider as ux,makeInfo as dx,SelectableWallet as mx,Typography as Pf,WalletState as En}from"@rango-dev/ui";import nt,{useEffect as _f,useState as gr}from"react";import{Image as lx,MessageBox as cx}from"@rango-dev/ui";import fr from"react";import{keyframes as ax,styled as Ml}from"@rango-dev/ui";var Nf=Ml("div",{position:"relative"}),sx=ax({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Bf=Ml("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${sx} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Wf=Ml("div",{"& img":{borderRadius:"50%"}});import{i18n as bn}from"@lingui/core";function Mf(t,e){switch(t){case"in-progress":return{type:"loading",title:bn.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:bn.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:bn.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:bn.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:bn.t("Request Rejected"),description:bn.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(Mf,"generateMessageByStatus");function Lf(t){let{status:e,displayName:o,image:n}=t,r=Mf(e,o),a=e=="in-progress";return fr.createElement(cx,{type:r.type,title:r.title,description:r.description,icon:a?fr.createElement(Nf,null,fr.createElement(Wf,null,fr.createElement(lx,{src:n,size:45})),fr.createElement(Bf,null)):void 0})}i(Lf,"ExperimentalChainStatus");var fx=7,gx=3e3;function Pl(t){let{chain:e,quoteChains:o,isSelected:n,selectWallet:r,limit:a,onShowMore:s}=t,c=ne.use.isActiveTab(),{blockchains:l,connectedWallets:p}=T(),[u,d]=gr(),[f,h]=gr(null),[g,m]=gr(!1),[y,S]=gr(null),{suggestAndConnect:C}=Xi(),{list:k}=bt({chain:e}),[x,w]=gr(k),I=k.length,A=a&&I-a>0,b=i(async v=>{m(!1),S("in-progress");try{let N=k.find(Q=>Q.type===Q.type),M=N?.isHub?N.properties?.find(Q=>Q.name==="namespaces")?.value:N?.needsNamespace,P=l(),U=M?.data.find(Q=>Q.getSupportedChains(P).some(Z=>Z.name===v.chain));if(!U)throw new Error("Requested chain is not supported");await C(v.walletType,{namespace:U.value,network:v.chain}),S("completed")}catch{S("rejected")}},"addExperimentalChain");_f(()=>{w(v=>{let N=k.findIndex(M=>n(M.type,e));return A&&N>1?[k[N]].concat(k.filter((M,P)=>P!==N)):v.map(M=>k.find(P=>P.type===M.type)??M)})},[JSON.stringify(k)]);let E=document.getElementById(Re.SWAP_BOX_ID);return _f(()=>{let v=null;return(y==="completed"||y==="rejected")&&(v=setTimeout(()=>S(null),gx)),()=>{v&&clearTimeout(v)}},[y]),nt.createElement(nt.Fragment,null,x.slice(0,a).map(v=>{let N=Bu({connectedWallets:p,walletType:v.type,chain:e}),M=v.state===En.CONNECTED||v.state===En.PARTIALLY_CONNECTED,P=N?lo(N,fx):"",U=M&&!!v.needsNamespace&&!P,Q=ci(l(),e),Z=!p.find(ue=>ue.walletType===v.type&&ue.chain===e),W=Q&&Z&&v.state===En.CONNECTED,J=i(async()=>{v.state===En.DISCONNECTED||U&&!W?d(v):W?(h({walletType:v.type,chain:e,address:N??""}),m(!0)):r({walletType:v.type,chain:e,address:N??""})},"onSelectableWalletClick"),X=dx(v.state),ae=i(()=>W?Ll.t({id:"Add {chain} chain",values:{chain:e}}):U?Ll.t("Chain not connected"):P||X.description,"getWalletDescription"),Se=i(()=>v.state===En.CONNECTED||v.state===En.PARTIALLY_CONNECTED?U?"neutral600":"neutral700":X.color,"getWalletDescriptionColor"),at=f?.chain?Rr(f.chain,l()):void 0;return nt.createElement(nt.Fragment,{key:`${v.title}_${at}`},!!f&&nt.createElement(ee,{id:"widget-wallets-list-watermarked-modal",open:!!f&&g,container:E,onClose:()=>{h(null)}},nt.createElement(Us,{id:"widget-wallets-list-experimental-chain-container",displayName:at,onConfirm:()=>{b(f)}})),y&&nt.createElement(ee,{id:"widget-wallets-list-experimental-chain-watermarked-modal",open:!!y,onClose:S.bind(null,null),container:E},nt.createElement(Lf,{status:y,displayName:at,image:v.image}),nt.createElement(ux,{direction:"vertical",size:32})),nt.createElement(mx,{key:v.type,id:"widget-wallets-list-selectable-wallet-btn",description:ae(),descriptionColor:Se(),onClick:J,selected:n(v.type,e),disabled:!c,...v}))}),nt.createElement(sr,{id:"widget-wallets-list-stateful-connect-modal",wallet:u,options:{defaultSelectedChains:o||[e]},onClose:()=>{d(void 0)},onConnect:()=>{t.onConnect&&(u?.type?t.onConnect(u.type):px(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),A&&nt.createElement(wf,{selected:!1,onClick:s,id:"widget-wallets-list-show-more-wallets-btn"},nt.createElement(Pf,{variant:"label",size:"medium"},Ll.t("Show more wallets"),nt.createElement(Pf,{variant:"label",size:"medium",color:"$primary"},"\xA0+",I-(a??0)))))}i(Pl,"WalletList");var vx=2;function Ff(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=wx(),c=T().blockchains(),{selectedQuote:l,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:d,customDestination:f,setCustomDestination:h}=H()(),{config:g,connectedWallets:m,setWalletsAsSelected:y}=T(),[S,C]=In(""),[k,x]=In([]),[w,I]=In(""),[A,b]=In(!!f),E=kx(()=>Mo({filter:"all",quote:l}),[l]),v=Mo({filter:"required",quote:l}),N=c.find(O=>O.name===l?.swaps[l?.swaps.length-1]?.to.blockchain),M=i(O=>v.includes(O),"isWalletRequiredFor"),P=Tx(()=>m.filter(O=>O.selected&&E.includes(O.chain)),[m,E]),[U,Q]=In(P()),[Z,W]=In([]),J=i((O,z)=>W(Y=>Y.concat({blockchain:O,walletType:z})),"addNextSelectedWallets"),X=k.length>0,ae=i((O,z)=>!!U.find(Y=>Y.walletType===O&&Y.chain===z&&Y.selected&&(M(z)||!M(z)&&!f)),"isSelected"),Se=i((O,z,Y)=>{let te=!1;return O.map(j=>{if(j.chain===z){let G=j.selected;return!te&&Y?(te=!0,G=!0):Y||(G=!1),{...j,selected:G}}return j})},"updateSelectableWallets"),at=i(O=>{b(O),O?M(N?.name??"")||Q(z=>Se(z,N?.name||"",!1)):(h(""),Q(z=>Se(z,N?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),ue=i(O=>{if(S&&C(""),ae(O.walletType,O.chain))return;let Y=m.find(te=>te.walletType===O.walletType&&te.chain===O.chain);Y&&(n(),O.chain===N?.name&&A&&!M(N.name)&&(b(!1),h(null)),Q(te=>te.filter(j=>j.chain!==O.chain).concat({...Y,selected:!0})))},"onChange"),gt=i(()=>{let O=U.filter(z=>z.selected);y(O),p(O),d(!0),o()},"onConfirmBalance"),vt=i(async()=>{x([]),I("");let O=await r?.({selectedWallets:U.filter(Y=>Y.selected),customDestination:f}),z=O.warnings;z?.balance?.messages&&x(z.balance.messages),O.error&&I(Ed(O.error)),!O.error&&!z?.balance?.messages.length?gt():x(z?.balance?.messages??[])},"onConfirmWallets");$f(()=>{Q(O=>{let z=[];return O.forEach(Y=>{!m.some(j=>j.chain===Y.chain&&j.walletType===Y.walletType&&j.address===Y.address)||z.push(Y)}),z=z.concat(m.filter(Y=>!!!z.find(j=>j.chain===Y.chain)&&Y.selected&&E.includes(Y.chain))),z})},[m,E]),$f(()=>{let O=[];Z.length>0&&(Z.forEach(z=>{let Y=m.find(te=>te.chain===z.blockchain&&te.walletType===z.walletType);Y?ue(Y):O.push(z)}),W(O))},[m,Z]);let xt=document.getElementById(Re.SWAP_BOX_ID);return ie.createElement(ee,{id:"widget-confirm-wallets-modal",open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!S,container:xt,...!S&&{styles:{container:{height:"100%"}},footer:ie.createElement(If,null,ie.createElement(Df,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:tm(a,A,f,l,U,N),onClick:vt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},Ho.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:ie.createElement(vf,null,ie.createElement(xf,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:C.bind(null,"")},ie.createElement(Sx,{size:16})),ie.createElement(Dl,{variant:"headline",size:"small"},Ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:yt(S,c)}})))},anchor:"center"},ie.createElement(ee,{id:'"widget-confirm-wallets-insufficient-account-balance-modal',open:X,onClose:x.bind(null,[]),container:xt},ie.createElement(Cx,{title:Ho.t("Insufficient account balance"),type:"error",description:ie.createElement(yx,{messages:k??[]})},ie.createElement(Df,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:gt},Ho.t("Proceed anyway")))),S&&ie.createElement(bf,null,ie.createElement("div",{className:Ef()},ie.createElement(Pl,{chain:S,quoteChains:E,isSelected:ae,selectWallet:ue,onShowMore:()=>C(S),onConnect:O=>{J(S,O)}}))),!S&&ie.createElement(ie.Fragment,null,w&&ie.createElement(ie.Fragment,null,ie.createElement(hx,{id:"widget-confirm-wallet-modal-error-alert",variant:"alarm",type:"error",title:Ho.t(w)}),ie.createElement(_l,{size:12})),ie.createElement(Af,null,E.map((O,z)=>{let Y=c.find(Ve=>Ve.name===O),te=`wallet-${z}`,j=z===E.length-1,G=j&&N&&g?.customDestination!==!1;return ie.createElement("div",{key:te},ie.createElement(Tf,null,ie.createElement(Dl,{variant:"title",size:"xmedium"},Ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:Y?.shortName}})),ie.createElement(Dl,{variant:"label",color:"$neutral700",size:"medium"},Ho.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:Y?.shortName}}))),ie.createElement(_l,{size:24}),ie.createElement(kf,null,ie.createElement(Pl,{chain:O,quoteChains:E,isSelected:ae,selectWallet:ue,limit:vx,onShowMore:()=>C(Y?.name??""),onConnect:Ve=>{J(O,Ve)}})),!j&&ie.createElement(_l,{size:32}),G&&ie.createElement(Cf,{blockchain:N,open:A,handleOpenChange:at}))}))))}i(Ff,"ConfirmWalletsModal");import{i18n as Xx}from"@lingui/core";import{Alert as Yx,Button as Zx,Divider as rg,InfoIcon as Jx}from"@rango-dev/ui";import Fe from"react";import{Alert as Ex,Button as Ix,Divider as Ol,NoRouteIcon as Ax,RefreshIcon as Nx,Typography as Gf}from"@rango-dev/ui";import pt from"react";import{i18n as Of}from"@lingui/core";var xx=24,bx=60;function Uf(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:re().genericServerError,action:{onClick:n,title:Of.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:re().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Of.t("Reset")}},description:re().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:re().noResultError.description}}i(Uf,"makeInfo");var $l=(o=>(o[o.small=xx]="small",o[o.large=bx]="large",o))($l||{}),Fl=(o=>(o.small="small",o.large="medium",o))(Fl||{});import{styled as Yi}from"@rango-dev/ui";var zf=Yi("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Hf=Yi("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Qf=Yi("div",{variants:{size:{small:{width:"100%"},large:{}}}}),qf=Yi("div",{padding:"$6 $0"});function hr(t){let{fetch:e,error:o,size:n="small",skipAlerts:r}=t,a=T().getDisabledLiquiditySources(),s=T().toggleAllLiquiditySources,c=T().swappers(),l=Uf(o,a,()=>s(c,!0),e);return r&&(l.alert=null),pt.createElement(zf,{id:"widget-no-result-container"},pt.createElement(Ax,{size:$l[n],color:"gray"}),pt.createElement(Ol,{size:4}),pt.createElement(Gf,{variant:"title",size:Fl[n]},re().noResultError.title),n==="large"&&pt.createElement(Ol,{size:4}),!!l.description&&pt.createElement(Hf,{size:n},pt.createElement(Gf,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),pt.createElement(Ol,{size:n==="large"?"24":"4"}),!!l.alert&&pt.createElement(Qf,{size:n},pt.createElement(Ex,{id:"widget-no-result-alert",type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&pt.createElement(Ix,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:pt.createElement(qf,null,pt.createElement(Nx,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(hr,"NoResult");import{i18n as yr}from"@lingui/core";import{Button as $x,Divider as Fx,MessageBox as Ox,Typography as Ux,WarningIcon as zx}from"@rango-dev/ui";import Yt from"react";import{InfoIcon as Lx,Tooltip as Px,Typography as _x}from"@rango-dev/ui";import An from"react";import{Button as Bx,darkTheme as Wx,styled as Qo,Typography as Mx}from"@rango-dev/ui";var Vf=Qo("div",{width:"100%"}),Ul=Qo("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Kf=Qo("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${Wx} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),jf=Qo("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$2"}),Xf=Qo(Mx,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"250px"}),Yf=Qo("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"}),Zf=Qo(Bx,{"& ._text":{gap:"$5",display:"flex",alignItems:"center",justifyContent:"center"}});var Dx=35;function Jf(t){let{title:e,value:o,valueColor:n}=t,r=B();return An.createElement(Kf,null,An.createElement(_x,{size:"medium",variant:"label",className:"_title"},e),An.createElement(jf,null,An.createElement(Xf,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`),o.length>Dx&&An.createElement(Px,{content:o,container:r},An.createElement(Lx,{size:12,color:"gray"}))))}i(Jf,"QuoteErrorsModalItem");function Rf(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",c=[{title:yr.t("Swapping"),value:_(r.inputUsdValue)},{title:yr.t("Gas cost"),value:_(r.totalFee,2,2)},{title:yr.t("Receiving"),value:_(r.outputUsdValue)},{title:yr.t("Price impact"),value:_(r.priceImpact,2,2),valueColor:`${s}500`}];return Yt.createElement(ee,{id:"widget-high-value-loss-warning-modal",footer:Yt.createElement($x,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Yt.createElement(zx,null),fullWidth:!0,disabled:a,onClick:n},re().highValueLossError.confirmMessage),open:e,onClose:o,container:B()},Yt.createElement(Ox,{type:s,title:re().highValueLossError.impactTitle,description:re().highValueLossError.description}),Yt.createElement(Ul,null,Yt.createElement(Fx,{size:"4"}),Yt.createElement(Ux,{size:"small",variant:"title"},yr.t("Details")),Yt.createElement(Ul,null,c.map((l,p)=>Yt.createElement(Jf,{key:p,...l})))))}i(Rf,"HighValueLossWarningModal");import{i18n as Nn}from"@lingui/core";function eg(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=Nn.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-slippage",o.actionButtonTitle=Nn.t("Increase")),o;if(t){switch(t.type){case 0:{Xt(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=re().highValueLossError.title;break}case 4:{o.title=Nn.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=re().unknownPriceError.title;break}case 2:{o.title=Nn.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=Nn.t("Increase");break}case 3:{o.title=Nn.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(eg,"makeAlerts");function tg(t,e){return e?.type===4?Number(e.minRequiredSlippage):t?.type===2?Number(t.minRequiredSlippage):null}i(tg,"getRequiredSlippage");import{i18n as Bn}from"@lingui/core";import{Button as Hx,Divider as zl,MessageBox as Qx,WarningIcon as qx}from"@rango-dev/ui";import Co from"react";import{useNavigate as Gx}from"react-router-dom";function og(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=Gx();return Co.createElement(ee,{id:"widget-slippage-warning-modal",anchor:"bottom",open:e,container:B(),onClose:o},Co.createElement(Qx,{type:"warning",title:r.type===3?Bn.t("High slippage"):Bn.t("Low slippage"),description:r.type===3?Bn.t("Caution, your slippage is high. Your trade may be front run."):Bn.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:r.minRequiredSlippage}})},Co.createElement(zl,{size:18}),Co.createElement(zl,{size:32}),Co.createElement(Zf,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:a,onClick:n},Co.createElement(qx,{color:"white",size:16}),Bn.t("Swap anyway")),Co.createElement(zl,{size:10}),Co.createElement(Hx,{id:"widget-slippage-warning-modal-change-slippage-btn",size:"large",type:"primary",variant:"outlined",fullWidth:!0,disabled:a,onClick:()=>s("../"+$.settings)},Bn.t("Change Slippage"))))}i(og,"SlippageWarningModal");import{Button as Vx,MessageBox as Kx,WarningIcon as jx}from"@rango-dev/ui";import Zi from"react";function ng(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return Zi.createElement(ee,{id:"widget-unknown-price-warning-modal",footer:Zi.createElement(Vx,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Zi.createElement(jx,null),fullWidth:!0,disabled:r,onClick:n},re().unknownPriceError.confirmMessage),open:e,onClose:o,container:B()},Zi.createElement(Kx,{type:"warning",title:re().unknownPriceError.impactTitle,description:re().unknownPriceError.description}))}i(ng,"UnknownPriceWarningModal");function Sr(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,skipAlerts:s,refetchQuote:c,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:d,onChangeSlippage:f}=t,h={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},g=o?.type===0||o?.type===1,m=eg(e,o?.type===3||o?.type===4?o:null);m&&!n&&(m.action=null);let y=!!m&&!s,S=i(C=>{if(C==="change-slippage"){let k=o?.type===3||o?.type===4?o:null,x=tg(e,k);f?.(x)}else C==="change-settings"&&d()},"onclickActionButton");return Fe.createElement(Fe.Fragment,null,g&&Fe.createElement(Fe.Fragment,null,Fe.createElement(rg,{size:10}),Fe.createElement(hr,{skipAlerts:s,error:o,fetch:c})),y&&Fe.createElement(Vf,null,Fe.createElement(rg,{size:10}),Fe.createElement(Yx,{id:"widget-quote-warning-and-errors-alert",title:m.title,type:m.alertType,variant:"alarm",...m.action==="show-info"&&{action:Fe.createElement(Yf,{onClick:l},Fe.createElement(Jx,{size:12,color:"gray"}))},...(m.action==="change-settings"||m.action==="change-slippage")&&{action:Fe.createElement(Zx,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:m.alertType,onClick:()=>S(m.action)},m.actionButtonTitle||Xx.t("Change"))}})),e&&Fe.createElement(Fe.Fragment,null,e.type===0&&Fe.createElement(Rf,{...h,warning:e}),(e.type===3||e.type===2)&&Fe.createElement(og,{...h,warning:e}),e.type===1&&Fe.createElement(ng,{...h,warning:e})))}i(Sr,"QuoteWarningsAndErrors");import Ib from"bignumber.js";import ma from"react";import{i18n as qo}from"@lingui/core";import{Alert as gb,CampaignQuoteTag as hb,Divider as Mn,FullExpandedQuote as yb,InfoIcon as Jl,NumericTooltip as Rl,QuoteTag as Sb,StepDetails as Cb,TokenAmount as Tb,Typography as Ln,useIsTruncated as ec}from"@rango-dev/ui";import tc from"bignumber.js";import F,{useRef as pa,useState as kb}from"react";import{styled as Hl}from"@rango-dev/ui";var Ql=Hl("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),ig=Hl("div",{paddingBottom:"$15","& .from-amount-text":{wordBreak:"break-word"},variants:{dense:{true:{paddingBottom:0}}}}),ag=Hl("div",{width:"100%",display:"flex"});import*as Ji from"@radix-ui/react-collapsible";import{Button as Rx,css as Ri,darkTheme as _e,Image as sg,styled as Ge,Typography as ql}from"@rango-dev/ui";var eb=300,lg=Ge(Ji.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${_e} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${_e} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${_e} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),cg=Ri({padding:"$10 $15"}),pg=Ge(Rx,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${_e} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${_e} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${_e} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),ug=Ge("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",[`.${_e} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${_e} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${_e} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${_e} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${_e} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${_e} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${_e} &`]:{backgroundColor:"$neutral400"}}}}]}),dg=Ri({width:"100%",padding:"$15 $15 $10 $15"}),mg=Ri({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Wn=Ri({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),fg=Ge(Ji.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:{[`& ${sg}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${sg}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${_e} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${_e} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${_e} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),gg=Ge("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"}}}}),hg=Ge(Gi,{width:"100%",background:"inherit"}),Gl=Ge("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${eb}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),BQ=Ge("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),yg=Ge("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${_e} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),Sg=Ge("div",{display:"flex",flexDirection:"row",alignItems:"center",gap:"$2",flex:"1 1 auto",minWidth:0}),Vl=Ge(ql,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"$30"}),Kl=Ge(ql,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,flex:"0 1 auto"}),jl=Ge("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"}}}}),Cg=Ge("div",{display:"flex"}),ea=Ge("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${_e} &`]:{borderTopColor:"$neutral800"}}),Tg=Ge(ql,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",minWidth:0,flexShrink:3});import{i18n as $t}from"@lingui/core";import{ChevronDownIcon as ob,CloseIcon as nb,Divider as na,IconButton as rb,NumericTooltip as ib,QuoteCost as ab,Typography as At}from"@rango-dev/ui";import R,{useState as xg}from"react";import{css as tb,styled as ta}from"@rango-dev/ui";var oa=ta("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Xl=ta("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),kg=ta("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),wg=ta("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),vg=tb({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var sb=i(t=>t.fee.isZero()?null:R.createElement(oa,null,R.createElement(At,{variant:"label",size:"medium",color:"neutral600"},t.label),R.createElement(At,{variant:"label",size:"medium"},"$",_(t.fee,4,4))),"NonPayableFee");function Yl(t){let[e,o]=xg(!1),[n,r]=xg(!1),{steps:a,quote:s,fee:c,time:l,feeWarning:p,timeWarning:u,showModalFee:d,fullExpandedMode:f=!1}=t,h=s?.swaps??[],g=f?Wo():B(),m=Kd(h),y=_(c,2,2);return R.createElement(R.Fragment,null,R.createElement(ab,{onClickFee:d?S=>{S.stopPropagation(),o(!e)}:void 0,fee:y,feeWarning:p,timeWarning:u,time:l,steps:a,tooltipGas:d?$t.t("View more info"):void 0,tooltipContainer:g}),R.createElement(ee,{id:"widget-quote-cost-explanation-modal",container:g,open:e,anchor:f?"center":"bottom",styles:{container:{maxWidth:f?"484px":"unset"}},header:R.createElement(wg,{style:{textAlign:f?"left":"center"}},R.createElement(At,{variant:"title",size:"medium"},$t.t("Gas & Fee Explanation")),R.createElement(rb,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},R.createElement(nb,{color:"gray",size:14}))),onClose:()=>{o(!1)}},R.createElement(kg,null,R.createElement(At,{variant:"title",size:"small"},$t.t("Details")),R.createElement(na,{size:10}),Object.entries(m.payable).flatMap(([S,C])=>C.map((k,x)=>{let w=`payable-fee-${x}`,I=Vs(k);return R.createElement(oa,{key:w},R.createElement(At,{variant:"label",size:"medium",color:"neutral600"},zs(S,$t.t)),R.createElement(ib,{content:k.amount,container:g},R.createElement(At,{variant:"label",size:"medium"},_(k.amount,2,2),k.asset.symbol," ($",_(I,4,4),")")))})),R.createElement(oa,{className:"total_payable_fee"},R.createElement(At,{variant:"label",size:"medium"},$t.t("Total Payable Fee")),R.createElement(At,{variant:"label",size:"medium"},"$",_(c,4,4))),R.createElement(Xl,null),!!Object.keys(m.nonePayable).length&&R.createElement(ji,{triggerAnchor:"bottom",onClickTrigger:()=>r(S=>!S),trigger:R.createElement("div",{className:vg()},R.createElement(At,{size:"small",variant:"body",color:"neutral700"},n?$t.t("Hide non-payable fees"):$t.t("Show non-payable fees")),R.createElement(na,{size:4,direction:"horizontal"}),R.createElement(Vi,{orientation:n?"up":"down"},R.createElement(ob,{size:12,color:"gray"}))),open:n},R.createElement(At,{size:"small",variant:"title"},$t.t("Description")),R.createElement(na,{size:4}),R.createElement(At,{size:"small",variant:"body",color:"neutral700"},$t.t(`The following fees are considered in the transaction output and
2
+ you won\u2019t need to pay extra gas for them.`)),R.createElement(na,{size:10}),Object.entries(m.nonePayable).map(([S,C],k)=>{let x=Vd(C),w=zs(S,$t.t),I=`non-payable-fee-${k}`;return R.createElement(sb,{key:I,fee:x,label:w})}),R.createElement(Xl,null)))))}i(Yl,"QuoteCostDetails");import{i18n as Ig}from"@lingui/core";import{TokenAmount as Ag}from"@rango-dev/ui";import ra from"react";import{css as lb,styled as cb}from"@rango-dev/ui";var bg=cb("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),Eg=lb({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function Cr(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return ra.createElement(bg,null,ra.createElement(Ag,{direction:"horizontal",label:Ig.t("Swap input"),id:"widget-quote-summary-swap-input",type:"input",tooltipContainer:B(),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}}),ra.createElement("div",{className:Eg()}),ra.createElement(Ag,{id:"widget-quote-summary-estimated-input",direction:"horizontal",tooltipContainer:B(),label:Ig.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(Cr,"QuoteSummary");import{i18n as Lg}from"@lingui/core";import{ChevronDownIcon as db,ChevronRightIcon as mb,Divider as Zl,Image as fb,Tooltip as ca,Typography as aa}from"@rango-dev/ui";import q from"react";import{useLayoutEffect as pb,useState as Tr}from"react";var Ng=480,Bg=768,Wg=1024,Mg=1200,ub=i(()=>{let[t,e]=Tr(!1),[o,n]=Tr(!1),[r,a]=Tr(!1),[s,c]=Tr(!1),[l,p]=Tr(!1),u=i(()=>{e(window.innerWidth<=Ng),n(window.innerWidth>Ng&&window.innerWidth<=Bg),a(window.innerWidth>Bg&&window.innerWidth<=Wg),c(window.innerWidth>Wg&&window.innerWidth<=Mg),p(window.innerWidth>Mg)},"handleResize");return pb(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:l}},"useScreenDetect"),ia=ub;var sa=4,la=6,kr=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,c=s||B();return q.createElement(ca,{container:c,side:"bottom",sideOffset:4,open:r,content:e},q.createElement(gg,{className:n,state:a},q.createElement(fb,{src:o,size:16})))},"ImageComponent");function Pg(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:c}=t,l=c||B(),p=r.length,u=Dd(r),{isTablet:d,isMobile:f}=ia();return q.createElement(fg,{className:"widget-quote-trigger-btn",listItem:s==="list-item",ref:h=>e.current=h,selected:o,onClick:h=>{h.stopPropagation(),n(g=>!g)}},q.createElement("div",{className:Wn()},q.createElement(aa,{variant:"body",size:"xsmall"},Lg.t("Via:")),q.createElement(Zl,{direction:"horizontal",size:4}),r.map((h,g)=>{let m=`item-${g}`,y=q.createElement(Gl,null,q.createElement(mb,{size:12,color:"black"}));return f||d?q.createElement(q.Fragment,{key:m},q.createElement(kr,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&q.createElement(q.Fragment,null,y)):q.createElement(q.Fragment,{key:m},p<=sa||p>sa&&g<sa-1?q.createElement(q.Fragment,null,q.createElement(kr,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&q.createElement(q.Fragment,null,y)):g===sa-1&&q.createElement(ca,{container:l,side:"bottom",align:"end",sideOffset:4,content:q.createElement("div",{className:Wn()},y,r.map((S,C)=>{let k=`image-${C}`;return C>=g&&q.createElement(q.Fragment,{key:k},q.createElement(kr,{content:S.swapper.displayName,src:S.swapper.image??"",state:S.state,open:!1}),C!==p-1&&q.createElement(q.Fragment,null,y))}))},q.createElement(jl,{state:r.find((S,C)=>C>=g&&(S.state==="error"||S.state==="warning"))?.state},q.createElement(aa,{size:"xsmall",variant:"body"},"+",p-g))))})),q.createElement("div",{className:Wn()},q.createElement("div",{className:"blockchains_section"},q.createElement("div",{className:Wn()},q.createElement(aa,{variant:"body",size:"xsmall"},Lg.t("Chains:")),q.createElement(Zl,{direction:"horizontal",size:4}),u.map((h,g)=>q.createElement(q.Fragment,{key:h.displayName},u.length<=la||u.length>la&&g<la-1?q.createElement(ca,{container:l,side:"bottom",content:h.displayName,sideOffset:4},q.createElement(kr,{content:"",src:h.image??"",open:!1,className:g!==0?"blockchainImage":""})):g===la-1&&q.createElement(ca,{container:l,side:"bottom",align:"end",sideOffset:4,content:q.createElement("div",{className:Wn()},u.map((m,y)=>y>=g&&q.createElement(kr,{key:m.displayName,content:"",src:m.image??"",open:!1,className:y>g?"blockchainImage":"",container:c})))},q.createElement(jl,{className:"blockchainImage"},q.createElement(aa,{size:"xsmall",variant:"body"},"+",u.length-g))))),q.createElement(Zl,{direction:"horizontal",size:32}))),q.createElement(Gl,{orientation:a?"up":"down"},q.createElement(db,{size:12,color:"black"}))))}i(Pg,"QuoteTrigger");function oc(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:d=!1,container:f}=t,h=T().blockchains(),{findToken:g}=T(),m=T().swappers(),{customSlippage:y,slippage:S}=T(),C=y||S,[k,x]=kb(t.expanded),w=pa(null),I=_(n.value,6,6),A=n.usdValue?_(n.usdValue,4,4):"",{config:{__UNSTABLE_OR_INTERNAL__:b}}=T(),E=jt(o.usdValue,n.usdValue??null),v=_(E,2,2),N=Xt(E??0),M=i((G,Ve)=>G.map((V,Ce)=>{let Je,ht=r?.type===3&&r.swap.swapperId===V.swapperId,so=r?.type===4&&!!r.recommendedSlippages?.[Ce],zn=a?.type===2&&!!a.recommendedSlippages?.[Ce],Io=ht||so,Zr=zn;Io?Je="error":Zr&&(Je="warning");let Ro=Io?qo.t("Slippage Error"):qo.t("Slippage Warning");return ht&&(Ro=qo.t("Bridge Limit Error")),{swapper:{displayName:Qn(V.swapperId,m)??"",image:V.swapperLogo},from:{token:{displayName:V.from.symbol,image:V.from.logo},chain:{displayName:yt(V.from.blockchain,h)??"",image:V.from.blockchainLogo},price:{value:Ce===0&&!Ve?_(o.value,6,6):_(V.fromAmount,6,6),usdValue:_((V.from.usdPrice??0)*parseFloat(V.fromAmount),4,4),realValue:Ce===0?o.value:V.fromAmount,realUsdValue:new tc(V.from.usdPrice??0).multipliedBy(V.fromAmount).toString()}},to:{token:{displayName:V.to.symbol,image:V.to.logo},chain:{displayName:yt(V.to.blockchain,h)||"",image:V.to.blockchainLogo},price:{value:_(V.toAmount,6,6),usdValue:_((V.to.usdPrice??0)*parseFloat(V.toAmount),4,4),realValue:V.toAmount,realUsdValue:new tc(V.to.usdPrice??0).multipliedBy(V.toAmount).toString()}},state:Je,alerts:Io||Zr?F.createElement(ig,{dense:d},F.createElement(gb,{variant:"alarm",type:Io?"error":"warning",title:Ro,id:"widget-quote-footer-step-alarm-alert",footer:F.createElement(ag,null,ht&&F.createElement("div",null,F.createElement(Ln,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Mn,{direction:"vertical",size:2}),F.createElement(Ln,{size:"xsmall",variant:"body",className:"from-amount-text",color:"neutral900"},qo.t({id:"Yours: {amount} {symbol}",values:{amount:_(V.fromAmount,6,6),symbol:V?.from.symbol}}))),(so||zn)&&!ht&&F.createElement("div",null,F.createElement(Ln,{size:"xsmall",variant:"body",color:"neutral900"},qo.t({id:"Minimum suggested slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.[Ce]},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.[Ce]}}})),F.createElement(Mn,{direction:"vertical",size:2}),F.createElement(Ln,{size:"xsmall",variant:"body",color:"neutral900"},qo.t({id:"Yours: {userSlippage}",values:{userSlippage:C}}))))})):void 0,time:Gn(V.estimatedTimeInSeconds),fee:_(Gs(V,g),2,2),internalSwaps:V.internalSwaps?M(V.internalSwaps):void 0}}),"getQuoteSteps"),P=M(e?.swaps??[]),U=P.length,Q=f||B(),Z=Fd(t.quote.tags||[]),W=!!u,J=ai(e?.swaps),X=Gn(J),ae=Ni(e?.swaps??[],g),Se=_(ae,2,2),at=ae.gte(new tc(Ad)),ue=J/Bd>=Nd,gt=pa(null),vt=ec(o.value,gt),xt=pa(null),O=ec(n.value,xt),z=pa(null),Y=ec(A,z),te=P[U-1],j=P[0];return!j||!te?null:d?F.createElement(yb,{selected:c,fee:Se,time:X,tooltipContainer:Wo(),steps:P,tags:Z,campaignTag:b?.campaignTag,id:"widget-quote-full-expanded-quote-container",quoteCost:F.createElement(Yl,{quote:e,fullExpandedMode:!0,time:X,fee:ae,feeWarning:at,timeWarning:ue,showModalFee:p,steps:U}),percentageChange:v,warningLevel:N,outputPrice:{value:I,usdValue:A,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(ug,{id:"widget-quote-summary-container",selected:c,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:dg()},!l&&Z.length?F.createElement(F.Fragment,null,F.createElement(Cg,null,Z.map((G,Ve)=>{let V=`${G.value}_${Ve}`;return F.createElement(F.Fragment,{key:V},G.value=="CAMPAIGN"&&b?.campaignTag?F.createElement(hb,{routeTag:G,...b.campaignTag}):F.createElement(Sb,{label:G.label,value:G.value}),F.createElement(Mn,{size:4,direction:"horizontal"}))})),F.createElement(ea,null),!W&&F.createElement(Mn,{size:4})):null,F.createElement("div",{id:"portal-root",className:mg()},F.createElement(Yl,{quote:e,time:X,fee:ae,feeWarning:at,timeWarning:ue,showModalFee:p,steps:U}),W&&F.createElement(pg,{onClick:G=>{G.stopPropagation(),u()},id:"widget-quote-all-routes-btn",size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Ln,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},qo.t("See All Routes")))),s==="basic"&&F.createElement(Sg,null,F.createElement(Kl,{ref:gt,size:"small",variant:"body"},o.value),vt&&F.createElement(Rl,{content:o.value,container:Q,open:o.value?void 0:!1},F.createElement(Jl,{size:12,color:"gray"})),F.createElement(Vl,{size:"small",variant:"body"},P[0]?.from.token.displayName),F.createElement(Ln,{size:"small",variant:"body"},"="),F.createElement(Kl,{ref:xt,size:"small",variant:"body"},n.value),O&&F.createElement(Rl,{content:n.value,container:Q,open:n.value?void 0:!1},F.createElement(Jl,{size:12,color:"gray"})),F.createElement(Vl,{size:"small",variant:"body"},te?.to.token.displayName),F.createElement(Mn,{size:2,direction:"horizontal"}),F.createElement(Tg,{ref:z,color:"$neutral600",size:"xsmall",variant:"body"},`($${A})`),Y&&F.createElement(Rl,{content:n.usdValue,container:Q},F.createElement(Jl,{size:12,color:"gray"}))),s==="list-item"&&F.createElement(Tb,{id:"widget-quote-token-amount-container",tooltipContainer:Q,type:"output",direction:"vertical",price:{value:I,usdValue:A,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:te.to.token.displayName,image:te.to.token.image},chain:{image:te.to.chain.image},percentageChange:v,warningLevel:N}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(Cr,{from:j.from,to:te.to,percentageChange:v,warningLevel:N}),F.createElement(Mn,{size:4}))),F.createElement(lg,{selected:c,listItem:s==="list-item",open:k,className:"quote_container",onOpenChange:x},F.createElement(Pg,{type:s,quoteRef:w,selected:c,setExpanded:x,container:Q,expanded:k,steps:P}),F.createElement(hg,{open:k},F.createElement(yg,null),F.createElement("div",{className:cg()},P.map((G,Ve)=>{let V=`item-${Ve}`;return F.createElement(Cb,{type:"quote-details",className:"widget-quote-step-details-container",key:V,tooltipContainer:Q,step:G,hasSeparator:Ve!==P.length-1,state:G.state})})))))}i(oc,"Quote");import{Divider as bb,Skeleton as Eb}from"@rango-dev/ui";import eo from"react";import{darkTheme as wb,styled as ua}from"@rango-dev/ui";var _g=ua("div",{$$color:"$colors$neutral100",[`.${wb} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Dg=ua("div",{paddingTop:"$2"}),$g=ua("div",{paddingLeft:"$8"}),Fg=ua("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as jg,Divider as Nt,Skeleton as ut}from"@rango-dev/ui";import K from"react";import{css as vb,styled as Rt}from"@rango-dev/ui";var nc=Rt("div",{display:"flex"}),Og=Rt("div",{padding:"$10 $0 $20"}),Ug=Rt("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),zg=Rt("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Hg=Rt("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Qg=Rt("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),qg=Rt("div",{width:"65%",display:"flex",justifyContent:"start"}),Gg=Rt("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Vg=Rt("div",{padding:"$15 $0 $15 $0"}),Kg=vb({display:"flex",justifyContent:"space-between",alignItems:"center"});function wr(t){let{type:e,tagHidden:o=!0}=t,n=K.createElement(Hg,null,K.createElement(qg,null,K.createElement(jg,{loading:!0,size:"medium"}),K.createElement(Nt,{size:8,direction:"horizontal"}),K.createElement(Gg,null,K.createElement(ut,{height:10,width:60,variant:"rounded"}),K.createElement(Nt,{size:4}),K.createElement(ut,{height:15,variant:"rounded"}))),K.createElement(ut,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return K.createElement("div",null,!o&&K.createElement(K.Fragment,null,K.createElement(nc,null,K.createElement(ut,{width:65,height:20,variant:"rounded"}),K.createElement(Nt,{size:4,direction:"horizontal"}),K.createElement(ut,{width:65,height:20,variant:"rounded"}),K.createElement(Nt,{size:4,direction:"horizontal"}),K.createElement(ut,{width:65,height:20,variant:"rounded"})),K.createElement(ea,null),!r&&K.createElement(Nt,{size:4})),K.createElement("div",{className:Kg()},K.createElement(nc,null,K.createElement(ut,{width:60,height:10,variant:"rounded"}),K.createElement(Nt,{size:4,direction:"horizontal"}),K.createElement(ut,{width:60,height:10,variant:"rounded"}),K.createElement(Nt,{size:4,direction:"horizontal"}),K.createElement(ut,{width:60,height:10,variant:"rounded"})),r&&K.createElement(ut,{width:85,height:24,variant:"rounded"})),e==="basic"&&K.createElement(Og,null,K.createElement(ut,{height:15,width:148,variant:"rounded"})),e==="list-item"&&K.createElement(Ug,null,K.createElement(zg,null,K.createElement(jg,{loading:!0,size:"medium"}),K.createElement(Nt,{direction:"horizontal",size:4}),K.createElement(ut,{height:15,width:150,variant:"rounded"})),K.createElement(Nt,{size:10}),K.createElement(ut,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&K.createElement(K.Fragment,null,K.createElement(Nt,{size:4}),K.createElement(Vg,null,n,K.createElement(Qg,null),n),K.createElement(Nt,{size:12})))}i(wr,"QuoteSummarySkeleton");import{ChainToken as Rg,Divider as ic,NextIcon as xb,Skeleton as da}from"@rango-dev/ui";import We from"react";import{styled as vr}from"@rango-dev/ui";var Xg=vr("div",{display:"flex",alignItems:"start"}),Yg=vr("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),rc=vr("div",{display:"flex",alignItems:"center",flexGrow:1}),Zg=vr("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Jg=vr("div",{display:"flex",alignItems:"center"});function Ft(t){let{separator:e=!0}=t;return We.createElement(We.Fragment,null,We.createElement(Jg,null,We.createElement(da,{height:22,width:22,variant:"circular"}),We.createElement(ic,{direction:"horizontal",size:8}),We.createElement(da,{height:15,width:148,variant:"rounded"})),We.createElement(Xg,null,We.createElement(Fg,{hideSeparator:!e}),We.createElement(Yg,{extraSpace:e},We.createElement(rc,null,We.createElement(Rg,{size:"small",loading:!0}),We.createElement(ic,{direction:"horizontal",size:8}),We.createElement(da,{height:12,variant:"rounded"})),We.createElement(Zg,null,We.createElement(xb,{color:"gray",size:16})),We.createElement(rc,null,We.createElement(Rg,{size:"small",loading:!0}),We.createElement(ic,{direction:"horizontal",size:8}),We.createElement(da,{height:12,variant:"rounded"})))))}i(Ft,"StepSkeleton");function xr(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return eo.createElement(_g,{expanded:o,rounded:e!=="basic"},eo.createElement(wr,{type:e,tagHidden:n}),eo.createElement(Dg,null,eo.createElement(Eb,{height:15,variant:"rounded"})),o&&eo.createElement($g,null,eo.createElement(bb,{size:24}),eo.createElement(Ft,null),eo.createElement(Ft,null),eo.createElement(Ft,{separator:!1})))}i(xr,"QuoteSkeleton");function Go(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:c,onClick:l,showModalFee:p,selected:u,id:d,onClickAllRoutes:f,fullExpandedMode:h=!1,container:g}=t,{inputAmount:m,inputUsdValue:y}=H()(),S=e?.outputAmount?new Ib(e?.outputAmount):null,C=e?Ct(e):null,x=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?ma.createElement(Ql,null,ma.createElement(xr,{tagHidden:c,type:o,expanded:s})):x?ma.createElement(Ql,{onClick:()=>l?.(e),id:d},ma.createElement(oc,{quote:e,error:r,container:g,showModalFee:p,warning:a,tagHidden:c,selected:u,type:o,expanded:s,onClickAllRoutes:f,fullExpandedMode:h,input:{value:m,usdValue:y?.toString()??""},output:{value:S?.toString()??"",usdValue:C?.toString()??""}})):null}i(Go,"QuoteInfo");import{warn as Wb}from"@rango-dev/logging-core";import{calculatePendingSwap as Mb}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Lb}from"react";import{useRef as Ab,useState as Nb}from"react";var Bb=2e3;function fa({request:t}){let[e,o]=Nb(!1),n=Ab(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async c=>(await new Promise(l=>setTimeout(l,Bb)),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(fa,"useFetch");function eh(){let{fetch:t,loading:e,cancelFetch:o}=fa({request:async(n,r)=>await ct().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(eh,"useFetchConfirmQuote");function ga(t){if(!t.swaps)throw new Error(re().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=ac(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(ga,"throwErrorIfResponseIsNotValid");function ac(t){if(Qd(t)){let{swap:n,fromAmountRangeError:r,recommendation:a}=qd(t);return n?{message:"bridge limit error",options:{type:3,swap:n,recommendation:a,fromAmountRangeError:r}}:null}let o=jd(t);if(o){let n=Bi(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(ac,"getQuoteError");function th(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,c={quote:null,balance:null},l=Cn({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});l&&(c.quote=l);let p=Zd(e,r,n.blockchains);return p.length===0||(c.balance={messages:p}),c}i(th,"generateWarnings");function ha(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(ha,"handleQuoteErrors");function sc(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:c}=H()(),{slippage:l,customSlippage:p}=T(),u=T().getDisabledLiquiditySources(),d=T().blockchains(),f=T().tokens(),{findToken:h}=T(),{swapMode:g}=tt(),m=p||l,{fetch:y,cancelFetch:S,loading:C}=eh();return Lb(()=>S,[]),{loading:C,fetch:i(async x=>{let w=x.selectedWallets,I=x?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=w.reduce((E,v)=>(E[v.chain]=v.address,E),{}),b={requestId:a?.requestId||"",selectedWallets:A,destination:I||void 0};try{return await y(b,!0).then(E=>{let{result:v}=E;if(!v)throw new Error(E.error??"Error fetching updated quote");ga({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 M={slippage:m.toString(),disabledSwappersGroups:u},P=th({previousQuote:a??void 0,currentQuote:N,meta:{blockchains:d},selectedWallets:w,userSlippage:m,inputUsdValue:n,findToken:h});c();let U=!!P.balance,Q=Mb({inputAmount:o.toString(),bestRoute:v,wallets:Yd(w),settings:M,validateBalanceOrFee:!U,meta:{blockchains:d,tokens:f},swapMode:g});return{quote:N,swap:Q,error:null,warnings:P}})}catch(E){let v=ha(E);return v.type!==2&&Wb(new Error("confirm swap error"),{tags:{...v,type:Xe[v.type],initialQuote:a,requestBody:b}}),{swap:null,error:v,warnings:null}}},"fetch"),cancelFetch:S}}i(sc,"useConfirmSwap");var Qb=$b("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${oh}`]:{width:"$48",height:"$48"}}),qb=pc({flexGrow:1,paddingRight:"$10"}),Gb=pc({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Vb=pc({display:"flex",justifyContent:"space-between",alignItems:"center"});function nh(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=H()(),s=Hb(),[c,l]=br(""),p=!n,[u,d]=br(!1),[f,h]=br(!1),{isActiveTab:g}=ne(),m=T().getDisabledLiquiditySources(),y=zb(m),{manager:S}=Pb(),{fetch:C,loading:k,cancelFetch:x}=sc(),[w,I]=br({swap:null,error:null,warnings:null}),[A,b]=br(!1),E=i(async({selectedWallets:W,customDestination:J})=>{let X=await C?.({selectedWallets:W,customDestination:J});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 W=`../${$.swaps}/${w.swap.requestId}`;s(W,{replace:!0}),setTimeout(()=>{e("")},0)}catch(W){l("Error: "+W?.message)}},"addNewSwap"),N=i(async()=>{h(!0),await v(),h(!1)},"onConfirm"),M=i(async()=>{w.warnings?.quote&&_d(w.warnings.quote)&&!a?b(!0):await N()},"onStartConfirmSwap"),P=i(async()=>{I({error:null,swap:null,warnings:null}),C({selectedWallets:o,customDestination:r}).then(W=>{I(W)}).catch(W=>console.error(W))},"onRefresh");ya(()=>{!!y.current.length&&!m.length&&P(),y.current=m},[m.length]),ya(()=>{p&&x()},[p]),ya(()=>{p&&d(p)},[p]),ya(()=>{p||C({selectedWallets:o,customDestination:r}).then(W=>I(W)).catch(W=>console.error(W))},[]),Ub(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let U=w.warnings?.quote??null,Q=w.error,Z=[];if(c&&Z.push(De.createElement(_b,{id:"widget-confirm-swap-db-error-alert",type:"error",variant:"alarm",title:c})),U||Q){let W=`../${$.settings}`;Z.push(De.createElement(Sr,{warning:U,error:Q,couldChangeSettings:!1,refetchQuote:P,skipAlerts:Q?.type===4||U?.type===2,showWarningModal:A,confirmationDisabled:!g,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:async()=>{b(!1),await v()},onChangeSettings:()=>s(W)}))}return De.createElement(se,{header:{title:lc.t("Confirm Swap"),onWallet:()=>{let W=`../${$.wallets}`;s(W)}},footer:De.createElement(Qb,null,De.createElement("div",{className:qb()},De.createElement(Db,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:k||f,disabled:!!w.error||!g,onClick:M},lc.t("Start Swap"))),De.createElement(oh,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:k||f,disabled:!g,onClick:d.bind(null,!0)},De.createElement(Ob,{size:24})))},u&&De.createElement(Ff,{open:u,onClose:()=>d(!1),onCancel:x,loading:k,onCheckBalance:E}),De.createElement(ce,null,De.createElement("div",{className:Vb()},De.createElement(Fb,{variant:"title",size:"small"},lc.t("You get")),De.createElement("div",{className:Gb()},De.createElement(Fi,{onClick:!k&&!u&&!A?P:void 0}))),De.createElement(cc,{size:"12"}),Am(Z.map((W,J)=>({element:W,key:`alert-${J}`})),De.createElement(cc,{size:10})),Z.length>0?De.createElement(cc,{size:10}):null,De.createElement(Go,{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(nh,"ConfirmSwapPage");import{i18n as oo}from"@lingui/core";import{Button as wc,CustomTokensZeroStateDarkIcon as dE,CustomTokensZeroStateIcon as mE,DeleteIcon as fE,Divider as Br,IconButton as gE,MessageBox as hE,NotFound as yE,styled as xc}from"@rango-dev/ui";import he,{useState as vc}from"react";import{useNavigate as SE}from"react-router-dom";import{CloseIcon as Kb,IconButton as jb,SearchIcon as Xb,TextField as Yb}from"@rango-dev/ui";import Pn from"react";import{styled as rh}from"@rango-dev/ui";var ih=rh("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"}),ah=rh("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,...d}=t,f=s.length?Pn.createElement(jb,{id:`${u}\u06F0icon-btn`,variant:"ghost",onClick:()=>l?.(""),size:"small"},Pn.createElement(Kb,{color:"gray",size:10})):null;return p&&(f=p),Pn.createElement(ah,null,Pn.createElement(Yb,{prefix:Pn.createElement(ih,null,Pn.createElement(Xb,{color:"black"})),id:u,suffix:f,fullWidth:o,color:n,variant:e,style:{borderRadius:25,alignItems:"center",...c},size:r,value:s,onChange:a,...d}))}i(Bt,"SearchInput");import{i18n as kc}from"@lingui/core";import{Button as eE,CustomTokenWarning as tE,darkTheme as Sh,Divider as to,ExternalLinkIcon as oE,Image as nE,ListItem as rE,NotFound as iE,PinIcon as aE,Skeleton as Vo,Typography as Ar,VirtualizedList as sE}from"@rango-dev/ui";import L,{useState as lE}from"react";import{useTranslation as cE}from"react-i18next";import{Divider as hh,ListItem as Rb,Skeleton as Ir}from"@rango-dev/ui";import Wt from"react";import{css as _n,darkTheme as uc,ImageContainer as Zb,ListItemButton as Jb,styled as rt,Typography as sh}from"@rango-dev/ui";var dc=_n({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),mc=_n({position:"relative",height:12,width:"30%",maxWidth:"150px"}),fc=_n({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),gc=_n({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${uc} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),hc=_n({}),yc=_n(),lh=rt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Sc=rt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Sa=rt("ul",{flexGrow:1,height:"100%",padding:0,margin:0,display:"flex",flexDirection:"column",listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${mc}`]:{[`& .${gc}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${hc}`]:{bottom:"-15px"},[`& .${dc}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${fc}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),ch=rt(Jb,{variants:{customToken:{true:{"&:hover":{cursor:"unset"}}}}}),Cc=rt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),Tc=rt(sh,{}),ph=rt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${yc}`]:{$$color:"$colors$neutral600",[`.${uc} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Er=rt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),AV=rt("div",{display:"flex",alignItems:"center"}),uh=rt("div",{position:"relative",[`& ${Zb}`]:{borderRadius:"$xm",overflow:"hidden"}}),dh=rt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),mh=rt(sh,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),fh=rt("a",{"& svg:hover":{color:"$colors$info"}}),gh=rt("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":{[`.${uc} &`]:{color:"$foreground"}}}});function yh(t){return Wt.createElement(Sa,null,Array.from(Array(t.size),e=>Wt.createElement(Rb,{key:e,hasDivider:!0,start:Wt.createElement(Ir,{variant:"circular",width:35,height:35}),end:Wt.createElement(Er,null,Wt.createElement(Ir,{variant:"text",size:"large",width:70}),Wt.createElement(hh,{size:4}),Wt.createElement(Ir,{variant:"text",size:"medium",width:50})),title:Wt.createElement("div",null,Wt.createElement(Ir,{variant:"text",size:"large",width:90}),Wt.createElement(hh,{size:4}),Wt.createElement(Ir,{variant:"text",size:"medium",width:90}))})))}i(yh,"LoadingTokenList");var pE=20,uE=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,c=e.length;return L.createElement("div",{className:mc()},o?L.createElement("div",{className:dc()},o):L.createElement(Sc,{className:fc()},L.createElement(Ar,{variant:"title",size:"xmedium"},r.symbol),L.createElement(to,{direction:"horizontal",size:4}),L.createElement(Cc,{css:a},L.createElement(Tc,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&L.createElement("div",{className:`${gc()} ${!o&&hc()}`},c>10?`${e.slice(0,5)}...${e.slice(c-6,c)}`:e," ",L.createElement(to,{size:4,direction:"horizontal"}),L.createElement(fh,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:l=>l.stopPropagation()},L.createElement(oE,{size:12}))))},"renderDesc");function Nr(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:d,fetchingWallets:f}=T(),{isTokenPinned:h}=T(),{setFromToken:g,setToToken:m}=H()(),{t:y}=cE(),S=Qe(),[C,k]=lE(null),x=i(()=>{c==="source"?g({token:C,meta:{blockchains:u}}):m({token:C,meta:{blockchains:u}})},"updateToken"),w=i(()=>{x(),S()},"handleImportToken"),I=i(E=>{if(E.customToken){let{customToken:N,...M}=E;return L.createElement(eE,{variant:"contained",type:"primary",size:"small",className:"widget-token-list-item-import-btn",onClick:i(U=>{U.stopPropagation(),k({...M,warning:!0})},"handleClick")},L.createElement(Ar,{variant:"body",size:"xsmall",color:"background"},y("import")))}let v=pi(d(E));return s?s(E):f?L.createElement(Er,null,L.createElement(Vo,{variant:"text",size:"large",width:70}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:50})):v&&L.createElement(ph,null,L.createElement(mh,{variant:"title",size:"small"},v.amount),L.createElement("div",null),v.usdValue&&L.createElement(Ar,{variant:"body",className:yc(),size:"xsmall"},`$${v.usdValue}`))},"endRenderer"),A=i(()=>L.createElement(sE,{style:{flexGrow:1,minHeight:0},itemContent:E=>{let v=e[E];if(v==="skeleton")return L.createElement(rE,{hasDivider:!0,start:L.createElement(Vo,{variant:"circular",width:35,height:35}),end:L.createElement(Er,null,L.createElement(Vo,{variant:"text",size:"large",width:70}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:50})),title:L.createElement("div",null,L.createElement(Vo,{variant:"text",size:"large",width:90}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:90}))});let N=u.find(W=>W.name===v?.blockchain);if(!N||!v)return null;let M=v.address,P=sl(N.color,"main"),U={$$color:P.main150,[`.${Sh} &`]:{$$color:P.main750},backgroundColor:"$$color"},Q={$$color:P.main750,[`.${Sh} &`]:{$$color:P.main150},color:"$$color"},Z=i(()=>{typeof v!="string"&&!v.customToken&&n?.(v)},"handleClick");return L.createElement(gh,null,L.createElement(ch,{"tab-index":E,key:`${v.symbol}${M}`,id:`${v.symbol}${M}`,className:"widget-token-list-item-btn",hasDivider:!0,customToken:v?.customToken,onClick:Z,start:L.createElement(uh,null,L.createElement(nE,{src:v.image===""?ti:v.image,size:30}),t.type!=="custom-token"&&v&&h(v,t.type)&&L.createElement(dh,null,L.createElement(aE,{size:12,color:"gray"}))),title:N.type==="COSMOS"||v.name||!v.name&&!M?L.createElement(Sc,null,L.createElement(Ar,{variant:"title",size:"xmedium"},v.symbol),L.createElement(to,{direction:"horizontal",size:4}),L.createElement(Cc,{css:U},L.createElement(Tc,{variant:"body",size:"xsmall",css:Q},v.blockchain)),l&&v.warning&&L.createElement(L.Fragment,null,L.createElement(to,{direction:"horizontal",size:4}),L.createElement(tE,{container:B()}))):void 0,description:typeof v!="string"&&N.info&&M&&N.type!=="COSMOS"?uE({address:M,token:v,customCssForTag:U,customCssForTagTitle:Q,name:v.name,url:N.info.addressUrl.split("{wallet}").join(M)}):v.name||void 0,end:I(v)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList"),b=C?No(C?.blockchain,u):null;return L.createElement(L.Fragment,null,a&&L.createElement(L.Fragment,null,L.createElement(Ar,{variant:"label",size:"large"},kc.t("Select Token")),L.createElement(to,{size:4})),L.createElement(lh,null,L.createElement(to,{size:4}),p==="loading"&&L.createElement(yh,{size:pE}),p==="success"&&(e.length?L.createElement(L.Fragment,null,L.createElement(mr,{token:C,address:C?.address??"",blockchain:b??void 0,onImport:w,onExitErrorModal:()=>k(null),onExitImportModal:()=>k(null)}),L.createElement(Sa,{as:"ul"},A())):!!o&&L.createElement(iE,{title:kc.t("No results found"),description:kc.t("Try using different keywords")}))))}i(Nr,"TokenList");var CE=xc("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),TE=xc("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),kE=xc(gE,{"&:hover":{"& svg":{color:"$secondary550"}}});function Ch(){let[t,e]=vc(""),{deleteCustomToken:o}=T(),n=T().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:c}=H()(),{mode:l}=mo({}),p=SE(),[u,d]=vc(!1),[f,h]=vc(),g=i(C=>{let k=C.target.value;e(k)},"handleSearch"),m=l==="dark",y=n.filter(C=>st(C.symbol,t)||st(C.address||"",t)||st(C.name||"",t)),S=i(()=>{if(f){let C=a?St(a):null,k=r?St(r):null,x=St(f);C===x?c({token:null}):k===x&&s({token:null}),o(f)}d(!1)},"handleDeleteCustomToken");return he.createElement(se,{header:{title:oo.t("Custom Tokens")}},he.createElement(ce,null,he.createElement(CE,null,n.length?he.createElement(he.Fragment,null,he.createElement(Bt,{id:"widget-custom-tokens-search-token-input",value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:oo.t("Search Token"),onChange:g}),he.createElement(Br,{size:16}),he.createElement(Nr,{list:y,type:"custom-token",searchedFor:t,showTitle:!1,showWarning:!1,action:C=>he.createElement(kE,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{d(!0),h(C)}},he.createElement(fE,{size:12,color:"gray"}))})):he.createElement(TE,null,he.createElement(yE,{icon:m?he.createElement(dE,{size:200}):he.createElement(mE,{size:200}),title:oo.t("No custom tokens"),description:oo.t("press the button to add your custom token")})),he.createElement(Br,{size:20}),he.createElement(wc,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p($.addCustomTokens)},oo.t("Add Custom Token"))),he.createElement(ee,{open:u,id:"widget-custom-tokens-delete-modal",dismissible:!0,onClose:()=>d(!1),container:B()},he.createElement(hE,{title:oo.t("Delete Custom Token"),type:"error",description:oo.t("Are you sure you want to Delete this Token?")},he.createElement(Br,{size:40}),he.createElement(Br,{size:10}),he.createElement(wc,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},oo.t("Yes, Delete it")),he.createElement(Br,{size:12}),he.createElement(wc,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>d(!1)},oo.t("No, Continue"))))))}i(Ch,"CustomTokensPage");import{i18n as $e}from"@lingui/core";import{useManager as zE}from"@rango-dev/queue-manager-react";import{Button as Wc,darkTheme as HE,Divider as To,MessageBox as QE,NotFound as qE,styled as Mc,Tabs as GE,Typography as ka}from"@rango-dev/ui";import{TransactionStatus as Lr}from"rango-types";import oe,{useMemo as Fh,useState as Pr}from"react";import{useNavigate as VE}from"react-router-dom";import{FilterIcon as AE,Popover as NE}from"@rango-dev/ui";import Ko from"react";import{css as wE,darkTheme as Ca,IconButton as vE,styled as Wr}from"@rango-dev/ui";var bc=Wr("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${Ca} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),Th=Wr(vE,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${Ca} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Ca} &`]:{backgroundColor:"$neutral"},[`& ${bc}::before`]:{backgroundColor:"$secondary100",[`.${Ca} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),kh=Wr("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),wh=Wr("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),vh=wE({display:"flex",justifyContent:"space-between",alignItems:"center"}),xh=Wr("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as bh}from"@lingui/core";import{Button as xE,Divider as Eh,ListItemButton as bE,Radio as EE,RadioRoot as IE,Typography as Ih}from"@rango-dev/ui";import dt from"react";function Ah(t){let{filterBy:e,onClickItem:o}=t;return dt.createElement(wh,null,dt.createElement("div",{className:vh()},dt.createElement(Ih,{size:"small",variant:"body"},bh.t("Status")),dt.createElement(xE,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},bh.t("Reset"))),dt.createElement(Eh,{size:10}),dt.createElement(IE,{value:e},dt.createElement(xh,null,t.list.map((n,r)=>dt.createElement(bE,{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:dt.createElement(dt.Fragment,null,dt.createElement(Eh,{direction:"horizontal",size:4}),dt.createElement(Ih,{size:"medium",variant:"body"},n.title)),start:dt.createElement(EE,{value:n.id}),onClick:o})))))}i(Ah,"FilterSelectorContent");function Ec(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return Ko.createElement("div",null,Ko.createElement(NE,{open:a,align:"end",onOpenChange:o,container:B(),content:Ko.createElement(Ah,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},Ko.createElement(Th,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},Ko.createElement(bc,{isSelect:!!n},Ko.createElement(AE,{size:16,color:"black"}),!!n&&Ko.createElement(kh,null)))))}i(Ec,"FilterSelector");import{i18n as ME}from"@lingui/core";import{getCurrentStep as LE}from"@rango-dev/queue-manager-rango-preset";import{Divider as Lh,GroupedVirtualizedList as PE,Skeleton as _E,SwapListItem as Ph,Typography as DE}from"@rango-dev/ui";import Ye,{useCallback as _h,useEffect as $E,useRef as FE,useState as OE}from"react";function Nh(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(Nh,"calculateGroupsSoFar");import{css as BE,darkTheme as WE,styled as Mr}from"@rango-dev/ui";var Ic=BE(),Bh=Mr("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),Ac=Mr("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${Ic}`]:{$$color:"$colors$neutral600",[`.${WE} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Nc=Mr("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),Wh=Mr("div",{gap:"$10",display:"flex",flexDirection:"column"}),Mh=Mr("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var UE=10;function Bc(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=OE([]),c=FE(0),{swaps:l,groupCounts:p,groups:u}=n(e),d=_h(Nh,[]),f=_h(()=>{let h=e.length-c.current;h&&(c.current+=Math.min(h,UE),s(d(p,c.current)))},[e.length]);if($E(()=>{r||f()},[r,f]),r){let h=[1,2];return Ye.createElement(Ye.Fragment,null,[h,h].map((m,y)=>Ye.createElement(Ac,{key:y},Ye.createElement(Nc,null,Ye.createElement(_E,{variant:"text",width:60,size:"small"}),Ye.createElement(Lh,{size:16})),Ye.createElement(Lh,{size:4}),Ye.createElement(Wh,null,m.map((C,k)=>Ye.createElement(Ph,{isLoading:!0,key:k}))))))}return Ye.createElement(PE,{style:{flexGrow:1,minHeight:0},endReached:()=>{c.current<e.length&&f()},groupCounts:a,groupContent:h=>Ye.createElement(Ac,null,Ye.createElement(Nc,null,Ye.createElement(DE,{variant:"label",size:"medium",className:Ic()},u[h]))),itemContent:(h,g)=>{let m=l[h];if(!m)return null;let y=LE(m),S=m.steps[0],C=m.steps[m.steps.length-1];return!S||!C?null:Ye.createElement(Bh,{key:m.requestId},Ye.createElement(Ph,{className:"widget-history-group-list-swap-item-btn",requestId:m.requestId,creationTime:m.creationTime,status:m.status,onClick:o,currentStep:y,tooltipContainer:B(),onlyShowTime:u[g]===ME.t("Today"),swapTokenData:{from:{token:{image:S.fromLogo,displayName:S.fromSymbol},blockchain:{image:S.fromBlockchainLogo||""},amount:_(m.inputAmount,6,6),realAmount:m.inputAmount},to:{token:{image:C.toLogo,displayName:C.toSymbol},blockchain:{image:C.toBlockchainLogo||""},amount:_(C.outputAmount||C.expectedOutputAmountHumanReadable||"",6,6),realAmount:C.outputAmount||C.expectedOutputAmountHumanReadable||""}}}))}})}i(Bc,"HistoryGroupedList");import{i18n as Ta}from"@lingui/core";import Dh from"dayjs";var $h=i(t=>{let e=new Map([["today",{title:Ta.t("Today"),swaps:[]}],["week",{title:Ta.t("This week"),swaps:[]}],["month",{title:Ta.t("This month"),swaps:[]}],["year",{title:Ta.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=Dh();t.forEach(l=>{let p=Number(l.creationTime),u=Dh(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 d=new Date(p).getFullYear().toString();o(d,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 KE=Mc("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%",minHeight:0,flexGrow:1}),jE=Mc("div",{display:"flex",justifyContent:"center",alignItems:"center"}),XE=Mc("div",{"._typography":{color:"$neutral700",[`.${HE}&`]:{color:"$neutral900"}}}),YE=i((t,e)=>t?.length?t.filter(o=>Pt(o.fromBlockchain,e)||Pt(o.toBlockchain,e)||Pt(o.toSymbol,e)||Pt(o.fromSymbol,e)).length:!1,"isStepContainsText");function Oh(){let t=VE(),{manager:e,state:o}=zE(),n=kt(e).map(({swap:b})=>b),[r,a]=Pr(""),[s,c]=Pr(!1),l=!o.loadedFromPersistor,[p,u]=Pr(""),[d,f]=Pr(!1),[h,g]=Pr("all"),m=i(b=>{let E=b.target.value;a(E)},"handleSearch"),{isMultiMode:y}=tt(),S=[{id:Lr.SUCCESS,title:$e.t("Complete")},{id:Lr.RUNNING,title:$e.t("Running")},{id:Lr.FAILED,title:$e.t("Failed")}],C=[{id:"all",title:$e.t("All")},{id:"swap",title:$e.t("Swap")},{id:"refuel",title:$e.t("Refuel")}],k=Fh(()=>!r&&!p&&h==="all"?n:n.filter(b=>{let{inputAmount:E,status:v,steps:N,requestId:M,mode:P}=b;return(!r||Pt(E,r)||Pt(v,r)||YE(N,r)||Pt(M,r))&&(!p||p===v)&&(h==="all"?!0:h==="swap"?!P||P==="swap":h==="refuel"?P==="refuel":!1)}),[n,r,p,h]),x=!k?.length&&!l,w=i(()=>f(!1),"onCloseModal"),I=i(async()=>{try{await e?.clearQueue(),f(!1)}catch(b){console.log(b)}},"onClear"),A=Fh(()=>!n.some(b=>b.status===Lr.SUCCESS||b.status===Lr.FAILED),[n]);return oe.createElement(se,{header:{title:$e.t("History"),suffix:oe.createElement(fo,null,oe.createElement(Wc,{id:"widget-history-clear-btn",disabled:A,variant:"ghost",size:"xsmall",onClick:()=>f(!0)},oe.createElement(ka,{size:"medium",variant:"label",color:"error"},$e.t("Clear"))))}},oe.createElement(ce,null,oe.createElement(jE,null,oe.createElement(Bt,{setValue:a,fullWidth:!0,variant:"contained",placeholder:$e.t("Search Transaction"),id:"widget-history-search-transaction-input",autoFocus:!0,onChange:m,style:{height:36},value:r}),oe.createElement(To,{size:10,direction:"horizontal"}),oe.createElement(Ec,{filterBy:p,open:s,onOpenChange:b=>c(b),onClickItem:b=>u(b),list:S})),oe.createElement(To,{size:"16"}),y&&!l&&oe.createElement(oe.Fragment,null,oe.createElement(GE,{items:C,onChange:b=>g(b.id),value:h,type:"secondary"}),oe.createElement(To,{size:"12"})),oe.createElement(KE,null,x&&oe.createElement(Mh,null,oe.createElement(To,{size:32}),oe.createElement(qE,{title:r?$e.t("No results found"):$e.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?$e.t("Try using different keywords"):$e.t("Your transaction history is stored locally and will appear here after you start a swap")})),!x&&oe.createElement(Bc,{list:k,onSwapClick:t,groupBy:$h,isLoading:l}))),oe.createElement(ee,{open:d,onClose:w,id:"widget-history-clear-modal",container:B()},oe.createElement(To,{size:20}),oe.createElement(QE,{type:"warning",title:$e.t("Clear Transaction History"),description:oe.createElement(XE,null,oe.createElement(ka,{variant:"body",size:"medium"},$e.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),oe.createElement(To,{size:"24"}),oe.createElement(ka,{variant:"body",size:"small"},$e.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),oe.createElement(To,{size:30}),oe.createElement(Wc,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:I},$e.t("Yes, Clear the history")),oe.createElement(To,{size:10}),oe.createElement(Wc,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:w},oe.createElement(ka,{variant:"title",size:"medium",color:"primary"},$e.t("No, Cancel")))))}i(Oh,"HistoryPage");import{i18n as gy}from"@lingui/core";import{Button as MI,Divider as Vc,styled as LI,WarningIcon as PI}from"@rango-dev/ui";import _I from"bignumber.js";import Te,{useEffect as hy,useState as yy}from"react";import{useNavigate as DI}from"react-router-dom";import{i18n as zh}from"@lingui/core";import{Alert as JE,Divider as Lc,NoRouteIcon as RE,Typography as eI}from"@rango-dev/ui";import jo from"react";import{styled as ZE}from"@rango-dev/ui";var Uh=ZE("div",{display:"flex",flexDirection:"column",alignItems:"center"});function Pc(){let{fromToken:t,toToken:e}=H()();return!!t&&!!e&&qt(t,e)?jo.createElement(Uh,null,jo.createElement(Lc,{size:10}),jo.createElement(RE,{size:24,color:"gray"}),jo.createElement(Lc,{size:4}),jo.createElement(eI,{variant:"title",size:"small"},zh.t("No Routes Found")),jo.createElement(Lc,{size:4}),jo.createElement(JE,{title:zh.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(Pc,"SameTokensWarning");import{Alert as tI,Button as oI}from"@rango-dev/ui";import Qh from"react";import{i18n as wa}from"@lingui/core";function Hh(t){let e=null;return t===fi?(e={alertType:"error",action:"reset-slippage",actionButtonTitle:wa.t("Reset"),title:wa.t("Slippage cannot be set lower than 0.01%.")},e):t>sn?(e={alertType:"warning",action:"change-settings",actionButtonTitle:wa.t("Change"),title:wa.t("Caution, your slippage is high!")},e):null}i(Hh,"makeAlerts");function qh(t){let{slippage:e,customSlippage:o,setSlippage:n,setCustomSlippage:r}=T(),{onChangeSettings:a}=t,c=Hh(o!==null?o:e),l=i(p=>{p==="reset-slippage"?(n(mi),r(null)):p==="change-settings"&&a()},"onClickActionButton");return c?Qh.createElement(tI,{title:c.title,type:c.alertType,variant:"alarm",action:Qh.createElement(oI,{id:"widget-slippage-warning-error-change-settings-or-reset-slippage-btn",size:"xxsmall",type:c.alertType,onClick:()=>l(c.action)},c.actionButtonTitle)}):null}i(qh,"SlippageWarningsAndErrors");import{i18n as sI}from"@lingui/core";import{IconButton as lI,ReverseIcon as cI,Skeleton as pI,Tooltip as uI,Typography as _r}from"@rango-dev/ui";import mt from"react";import va from"bignumber.js";function Vh(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(Vh,"getSlippageColor");function Kh(t){let{toTokenUsdPrice:e,fromTokenUsdPrice:o}=t;if(!e||!o)return{rawValue:"0",displayValue:"0"};let n=new va(e),r=new va(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(Kh,"getUsdExchangeRate");function jh(t,e){let o=new va(t).multipliedBy(e);return o.isLessThan(.001)?"$0":`$${o.decimalPlaces(2,va.ROUND_DOWN).toFormat(2)}`}i(jh,"formatTokenValueInUsd");import{darkTheme as iI,styled as Dc,Typography as aI}from"@rango-dev/ui";var Xh=Dc("div",{display:"flex",padding:"$4",justifyContent:"space-between",alignItems:"center"}),Yh=Dc("div",{display:"flex",alignItems:"center",gap:"$2","& .rate-text":{color:"$neutral700",[`.${iI} &`]:{color:"$neutral700"}},"& ._icon-button":{transform:"rotate(90deg)",width:"$16",height:"$16"}}),$c=Dc(aI,{maxWidth:"$32",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});function Fc(t){let{slippage:e,customSlippage:o,quoteTokensRate:n,changeQuoteTokensRate:r}=T(),{quoteError:a,quoteWarning:s,fromToken:c,toToken:l,quote:p,loading:u}=t,d=o!==null?o:e,{mode:f}=mo({}),h=pn(d),g=f==="dark",m=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,x=m?C:k,w=m?k:C,I=Number(m?p?.outputAmount:p?.requestAmount),A=Number(m?p?.requestAmount:p?.outputAmount),b=I||x.usdPrice,E=A||w.usdPrice,{rawValue:v,displayValue:N}=Kh({toTokenUsdPrice:E,fromTokenUsdPrice:b});return mt.createElement(Xh,null,mt.createElement(_r,{variant:y||S?"label":"body",size:y||S?"medium":"small",color:Vh({error:y,warning:S,isDarkTheme:g})},sI.t("Slippage:")," ",d,"%"),u?mt.createElement(pI,{height:16,width:104,variant:"rounded"}):b&&E&&mt.createElement(Yh,null,mt.createElement(_r,{className:"rate-text",variant:"body",size:"small"},"1"),mt.createElement($c,{className:"rate-text",variant:"body",size:"small"},w.symbol),mt.createElement(lI,{id:"widget-home-page-change-rate-button",onClick:r},mt.createElement(cI,{size:14,color:"secondary"})),mt.createElement(uI,{container:B(),side:"top",sideOffset:4,content:mt.createElement(_r,{className:"rate-text",variant:"body",size:"small"},v)},mt.createElement(_r,{className:"rate-text",variant:"body",size:"small"},N)),mt.createElement($c,{className:"rate-text",variant:"body",size:"small"},x.symbol),x.usdPrice&&mt.createElement(_r,{color:"neutral600",variant:"body",size:"small"},"~",jh(Number(v),x.usdPrice))))}i(Fc,"SwapMetrics");import{i18n as yI}from"@lingui/core";import{Header as SI}from"@rango-dev/ui";import ko,{useEffect as CI,useState as TI}from"react";import{i18n as mI}from"@lingui/core";import{Divider as Uc,FullExpandedQuote as fI,Typography as gI}from"@rango-dev/ui";import xe from"react";import{styled as Oc}from"@rango-dev/ui";var Zh=Oc("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Jh=Oc("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Rh=Oc("div",{width:"146px"});import{i18n as Dr}from"@lingui/core";import{Select as dI}from"@rango-dev/ui";import ey from"react";function xa(t){let{updateQuotePartialState:e,sortStrategy:o}=H()(),n=[{value:"SMART",label:Dr.t("Smart Routing")},{value:"FEE",label:Dr.t("Lowest Fee")},{value:"SPEED",label:Dr.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Dr.t("Maximum Return")},{value:"PRICE",label:Dr.t("Maximum Output")}];return ey.createElement(Rh,null,ey.createElement(dI,{id:"widget-quotes-strategy-select",container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(xa,"SelectStrategy");var ty=3;function $r(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:d,toToken:f,sortStrategy:h,error:g}=H()(),{slippage:m,customSlippage:y}=T(),{findToken:S}=T(),C=c||B(),k=!!p&&p.results.length,x=y??m,{config:{__UNSTABLE_OR_INTERNAL__:w}}=T(),I=i(E=>{if(!d||!f||!p)return null;let v={requestAmount:p.requestAmount,validationStatus:null,...E};return Cn({currentQuote:v,userSlippage:x,findToken:S})},"getQuoteWarning"),A=g?.type===0||g?.type===1,b=p?.results?Ai(h,p?.results):[];return xe.createElement(xe.Fragment,null,a&&xe.createElement(xe.Fragment,null,xe.createElement(Jh,null,xe.createElement(gI,{size:"xmedium",variant:"title"},mI.t("Sort by")),xe.createElement(xa,{container:C})),xe.createElement(Uc,{size:"10"})),e&&Array.from({length:ty},(E,v)=>xe.createElement(xe.Fragment,{key:v},s?xe.createElement(fI,{campaignTag:w?.campaignTag,loading:!0}):xe.createElement(xr,{tagHidden:!1,type:"list-item",expanded:!1}),v!==ty-1&&xe.createElement(Uc,{size:16}))),!e&&xe.createElement(xe.Fragment,null,k?b.map((E,v)=>{let N=I(E),M=ac(E.swaps),P=b.length-1===v;return xe.createElement(xe.Fragment,{key:E.requestId},xe.createElement(Go,{id:"widget-quotes-quote-info-container",showModalFee:r,container:C,selected:l?.requestId===E.requestId,tagHidden:!1,quote:{...E,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:M?.options||null,warning:N,fullExpandedMode:s,onClick:U=>{M||u("warning",N),u("error",M?.options||null),o(U)},type:"list-item"}),!P&&xe.createElement(Uc,{size:16}))}):A&&xe.createElement(Zh,null,xe.createElement(hr,{size:s?"large":"small",error:g,fetch:n}))))}i($r,"Quotes");import{darkTheme as hI,styled as oy}from"@rango-dev/ui";var ny=oy("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${hI} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),ry=oy("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var kI=100;function zc(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,c]=TI(!1),l=s?"":"is-hidden",{config:p}=T(),u=p?.variant==="full-expanded",d=Wo();return CI(()=>{let f=null;return a?f=setTimeout(()=>{c(!0)},kI):(c(!1),f&&clearTimeout(f)),()=>{f&&clearTimeout(f)}},[a]),ko.createElement(ny,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${l} ${Hi()} widget-expanded-quotes-container`,id:Re.EXPANDED_BOX_ID},ko.createElement(SI,{title:yI.t("Routes"),suffix:ko.createElement(ko.Fragment,null,ko.createElement(xa,{container:d}),ko.createElement(zo,{container:d,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),ko.createElement(ry,null,ko.createElement($r,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:Wo(),onClickOnQuote:n,fullExpandedMode:u})))}i(zc,"ExpandedQuotes");import{i18n as uy}from"@lingui/core";import{SwapInput as dy}from"@rango-dev/ui";import bI from"bignumber.js";import Fr from"react";import{ReverseIcon as xI}from"@rango-dev/ui";import Qc from"react";import{keyframes as wI,styled as iy}from"@rango-dev/ui";var Hc=450,vI=wI({"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)"}}),ay=iy("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),sy=iy("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${vI} ${Hc}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 qc(){let t=H().use.switchFromAndTo();return Qc.createElement(ay,null,Qc.createElement(sy,{id:"widget-switch-from-and-to-btn",onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Hc),t()}},Qc.createElement(xI,{size:12})))}i(qc,"SwitchFromAndToButton");import{styled as ly}from"@rango-dev/ui";var cy=ly("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),py=ly("div",{position:"relative"});function Gc(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:c,toBlockchain:l,setInputAmount:p,sanitizeInputAmount:u,inputAmount:d,inputUsdValue:f,outputAmount:h,outputUsdValue:g,selectedQuote:m}=H()(),{swapMode:y}=tt(),{connectedWallets:S,getBalanceFor:C}=T(),k=a?C(a):null,x=pi(k)?.amount??"0",w=k?new bI(k.amount).shiftedBy(-k.decimals):pe,I=!!s&&Wu(S,s.name),A=!qs(m,d,f),b=!qs(m,d,g),E=!f||!g||!g.gt(0)?null:jt(f.toString(),g.toString());return Fr.createElement(cy,null,Fr.createElement(py,null,Fr.createElement(dy,{label:uy.t("From"),id:"widget-swap-from",mode:"From",onInputChange:p,onInputBlur:u,balance:x,chain:{displayName:s?.displayName||"",image:s?.logo},token:{displayName:a?.symbol||"",image:a?.image,securityWarning:!!a?.warning},onClickToken:()=>n("from"),price:{value:d,usdValue:A?void 0:_(f,4,4),realUsdValue:A?void 0:f?.toString(),error:A?re().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:I,tooltipContainer:B(),onSelectMaxBalance:()=>{let v=w.isGreaterThan(pe)?w.toFixed():"";p(v)},anyWalletConnected:S.length>0}),y==="swap"&&Fr.createElement(qc,null)),Fr.createElement(dy,{selectionType:y==="swap"?"token":"chain",sharpBottomStyle:!r&&(!!m||e),label:uy.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:_(jt(f,g),2,2),warningLevel:Xt(E??0),price:{value:_(h,6,6),usdValue:b?void 0:_(g,4,4),realValue:h?.toString(),realUsdValue:b?void 0:g?.toString(),error:b?re().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:B()}))}i(Gc,"Inputs");import{warn as EI}from"@rango-dev/logging-core";import{useCallback as II,useEffect as AI,useRef as NI,useState as BI}from"react";function my(){let{fetch:t,loading:e,cancelFetch:o}=fa({request:async(n,r)=>await ct().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(my,"useFetchAllQuotes");var WI=600;function ba({refetchQuote:t}){let{fetch:e,cancelFetch:o}=my(),{excludeLiquiditySources:n,routing:r}=T().config,{connectedWallets:a}=T(),c=a.some(ue=>ue.isContractWallet),{fromToken:l,toToken:p,inputAmount:u,inputUsdValue:d,selectedQuote:f,sortStrategy:h,resetQuote:g,error:m,warning:y,setSelectedQuote:S,updateQuotePartialState:C}=H()(),{slippage:k,customSlippage:x,affiliatePercent:w,affiliateRef:I,affiliateWallets:A,fetchStatus:b}=T(),E=T().getLiquiditySources(),v=T().getDisabledLiquiditySources(),N=T().excludeLiquiditySources(),{findToken:M}=T(),{swapMode:P}=tt(),[U,Q]=BI(!0),Z=NI(u),W=x??k,X=!l||!p||qt(l,p)||!Vn(u),ae=i(ue=>{Q(ue)},"resetState"),Se=i(ue=>{let{fromToken:gt,toToken:vt,inputAmount:xt,liquiditySources:O,excludeLiquiditySources:z,disabledLiquiditySources:Y,slippage:te,affiliateRef:j,affiliatePercent:G,affiliateWallets:Ve}=ue;if(U||ae(!0),!X&&gt&&vt){g();let V=Xd({fromToken:gt,toToken:vt,inputAmount:xt,liquiditySources:O,excludeLiquiditySources:z,disabledLiquiditySources:Y,wallets:a,slippage:te,affiliateRef:j,affiliatePercent:G,affiliateWallets:Ve,contractCall:c});cn("experimental",r)&&(V.experimental=!0),cn("avoidNativeFee",r)&&(V.avoidNativeFee=!0),cn("enableCentralizedSwappers",r)&&(V.enableCentralizedSwappers=!0),r?.maxLength&&(V.maxLength=r.maxLength),P==="refuel"&&(V.maxLength=1),e(V).then(Ce=>{let Je=Ai(h,Ce.results),ht=$d(f,Je,Ce.requestAmount);Q(!1),C("quotes",Ce),S(ht),ga({diagnosisMessages:Ce.diagnosisMessages,requestId:ht?.requestId||"",swaps:ht?.swaps});let so=ht&&Cn({currentQuote:ht,userSlippage:W,findToken:M});C("warning",so)}).catch(Ce=>{let Je=ha(Ce);(Je.type===0||Je.type===1)&&g(),Je.type!==2&&(C("error",Je),Q(!1),EI(new Error("quote error"),{tags:{...Je,type:Xe[Je.type],requestBody:V}}))})}},"fetch"),at=II(ni(ue=>{Se(ue)},WI),[X]);return AI(()=>{if(!t){Q(!1);return}if(b!=="success")return;if(X){Q(!1),(f||m||y)&&g();return}if(!Vn(u)&&d?.eq(0)){ae(!1),o();return}g(),ae(!0);let ue=Se;return Z.current&&Z.current!=u&&(ue=at),Z.current=u,ue({inputAmount:u,fromToken:l,toToken:p,liquiditySources:E,excludeLiquiditySources:N,disabledLiquiditySources:v,slippage:W,affiliateRef:I,affiliatePercent:w,affiliateWallets:A,contractCall:c}),o},[b,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,X,E?.length,n,v.length,W,I,w,c,JSON.stringify(A)]),{fetch:()=>Se({inputAmount:u,fromToken:l,toToken:p,liquiditySources:E,excludeLiquiditySources:N,disabledLiquiditySources:v,slippage:W,affiliateRef:I,affiliatePercent:w,affiliateWallets:A,contractCall:c}),loading:U}}i(ba,"useSwapInput");function fy(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};ve.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(fy,"emitPreventableEvent");var $I=LI("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),FI=300;function Sy(){let t=DI(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:c,quotes:l,setSelectedQuote:p,resetQuoteWallets:u,setQuoteWarningsConfirmed:d,updateQuotePartialState:f}=H()(),[h,g]=yy(!1),{isLargeScreen:m,isExtraLargeScreen:y}=ia(),{fetch:S,loading:C}=ba({refetchQuote:a}),{config:k,fetchStatus:x,connectedWallets:w,customSlippage:I,slippage:A,setSlippage:b,setCustomSlippage:E}=T(),{isActiveTab:v}=ne(),[N,M]=yy(!1),P=I!==null?I:A,{swapMode:U}=tt(),Q=pn(P),W=Gd({fetchMetaStatus:x,fetchingQuote:C,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:c,needsToWarnEthOnPath:!1}),J=Fu(m,y,k?.variant),X=!!n&&!!e&&!!o&&new _I(n).gt(0)&&!om(e,o),ae=X&&x==="success"&&C,Se=Q?.quoteValidation||c,gt=(!J||J&&l?.results.length)&&(Se||s),vt=!!e&&!!o,xt=vt&&!!Q,O=(r||s)&&!N?S:void 0,z=i(G=>{J&&h?(g(!1),setTimeout(()=>{t(G)},FI)):t(G)},"onHandleNavigation"),Y=i(G=>{r?.requestId!==G.requestId&&(M(!1),p(G))},"onClickOnQuote"),te=i(G=>{if(G){if(di.includes(G)){b(G),E(null);return}E(G)}},"onChangeSlippage"),j=i(G=>{z(G==="from"?$.fromSwap:U==="swap"?$.toSwap:$.toSwap+"/"+$.blockchains)},"handleInputTokenClick");return hy(()=>{u(),f("refetchQuote",!0)},[]),hy(()=>{g(X)},[X]),Te.createElement($I,null,Te.createElement(se,{height:"auto",footer:Te.createElement(MI,{id:`widget-swap-${W.action}-btn`,type:"primary",size:"large",disabled:W.disabled||!v,prefix:W.action==="confirm-warning"&&Te.createElement(PI,null),fullWidth:!0,onClick:()=>{W.action==="connect-wallet"?fy({type:"clickConnectWallet"},()=>z($.wallets)):W.action==="confirm-warning"?M(!0):z($.confirmSwap)}},W.title),header:{onWallet:()=>{z($.wallets)},hasBackButton:!1,title:k.title||(U==="swap"?gy.t("Swap"):gy.t("Refuel")),suffix:Te.createElement(zo,{hidden:J?["refresh"]:void 0,onClickRefresh:O,onClickHistory:()=>z($.swaps),onClickSettings:()=>{z($.settings)}})}},Te.createElement(ce,null,Te.createElement(Gc,{fetchingQuote:ae,fetchMetaStatus:x,isExpandable:J,onClickToken:j}),Te.createElement(Vc,{size:"2"}),J?null:Te.createElement(Go,{quote:r,loading:ae,error:s,id:"widget-home-expandable-quote-container",tagHidden:!1,warning:Se,type:"basic",onClickAllRoutes:l&&l.results.length>1?()=>{f("refetchQuote",!1),z($.routes)}:void 0}),vt&&Te.createElement(Te.Fragment,null,Te.createElement(Vc,{size:8}),Te.createElement(Fc,{quoteError:s,quoteWarning:Se,fromToken:e,toToken:o,quote:r,loading:ae})),gt?Te.createElement(Te.Fragment,null,Te.createElement(Sr,{warning:Se,error:s,skipAlerts:!!Q,couldChangeSettings:!0,refetchQuote:S,showWarningModal:N,confirmationDisabled:!v,onOpenWarningModal:()=>M(!0),onCloseWarningModal:()=>M(!1),onChangeSlippage:te,onConfirmWarningModal:()=>{M(!1),d(!0),z($.confirmSwap)},onChangeSettings:()=>z($.settings)})):null,xt&&Te.createElement(Te.Fragment,null,Te.createElement(Vc,{size:"10"}),Te.createElement(qh,{onChangeSettings:()=>z($.settings)})),Te.createElement(Pc,null))),J?Te.createElement(zc,{loading:ae,onClickOnQuote:Y,fetch:S,onClickRefresh:O,isVisible:h}):null)}i(Sy,"Home");import{i18n as Cy}from"@lingui/core";import{Alert as OI,Divider as UI,List as zI,ListItemButton as HI,Radio as QI,RadioRoot as qI,Typography as GI}from"@rango-dev/ui";import Ot from"react";function wo(){let{setLanguage:t,language:e,config:o}=T(),n=Gu,r=o?.language||un;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||un),resetLanguage:()=>t(null)}}i(wo,"useLanguage");function Ty(){let{activeLanguage:t,changeLanguage:e,languages:o}=wo(),n=Qe(),r=o.map(a=>{let{local:s,label:c,SVGFlag:l}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Ot.createElement(GI,{variant:"title",size:"xmedium"},c),onClick:()=>{e(a.local),n()},end:Ot.createElement(QI,{value:s}),start:Ot.createElement(l,null)}});return Ot.createElement(se,{header:{title:Cy.t("Language")}},Ot.createElement(ce,null,Ot.createElement(OI,{type:"warning",id:"widget-language-machine-translation-alarm-alert",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Ot.createElement(UI,{size:"8"}),Ot.createElement(qI,{value:t},Ot.createElement(zI,{type:Ot.createElement(HI,{title:Cy.t("language"),className:"widget-language-list-item-btn",id:"_",onClick:()=>console.log()}),items:r}))))}i(Ty,"LanguagePage");import{i18n as no}from"@lingui/core";import{Button as YI,Checkbox as ZI,Image as JI,ListItemButton as RI,NotFound as eA,Typography as tA}from"@rango-dev/ui";import Ze,{useState as oA}from"react";import{Checkbox as jI,Skeleton as wy}from"@rango-dev/ui";import Ur from"react";import{styled as Kc}from"@rango-dev/ui";var Or=Kc("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),jc=Kc("div",{width:80,display:"flex",justifyContent:"flex-end"}),Xc=Kc("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as VI,styled as KI}from"@rango-dev/ui";var ky=KI(VI,{height:61});var XI=30;function Yc(){return Ur.createElement(Or,null,Array.from(Array(XI),(t,e)=>Ur.createElement(ky,{hasDivider:!0,key:e,start:Ur.createElement(wy,{variant:"circular",width:35,height:35}),title:Ur.createElement(wy,{variant:"text",size:"large",width:90}),end:Ur.createElement(jI,{checked:!1})})))}i(Yc,"LoadingLiquiditySourceList");function Zc({sourceType:t}){let e=T().fetchStatus,o=T().swappers(),n=T().getDisabledLiquiditySources(),[r,a]=oA(""),s=T().toggleLiquiditySource,c=T().isInCampaignMode(),l=gi(o,n),p={Exchanges:no.t("Exchanges"),Bridges:no.t("Bridges")},u=[];t==="Exchanges"&&u.push("DEX"),t==="Bridges"&&u.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let d=l.filter(S=>u.includes(S.type)),f=d.length===d.filter(S=>S.selected).length,h=i(()=>{d.forEach(S=>{f?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),g=d.map(S=>{let{selected:C,groupTitle:k,logo:x,id:w,...I}=S;return{id:`widget-setting-liquidity-source-${Su(w.toLowerCase())}-item-btn`,start:Ze.createElement(JI,{src:x,size:22,type:"circular"}),onClick:()=>{c||s(k)},end:Ze.createElement(ZI,{checked:C,disabled:c}),title:Ze.createElement(tA,{variant:"title",size:"xmedium"},no.t(k)),selected:C,groupTitle:k,logo:x,...I}}),m=i(S=>{let C=S.target.value;a(C)},"handleSearch"),y=g;return r&&(y=g.filter(S=>Pt(S.groupTitle,r))),Ze.createElement(se,{header:{title:no.t(t),suffix:Ze.createElement(jc,null,Ze.createElement(YI,{id:`widget-liquidity-source-${f?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:h},f?no.t("Deselect all"):no.t("Select all")))}},Ze.createElement(ce,{view:!0},Ze.createElement(Bt,{value:r,setValue:a,id:"widget-liquidity-source-search-input",fullWidth:!0,color:"light",variant:"contained",placeholder:no.t("Search {sourceType}",{sourceType:p[t]}),onChange:m}),e==="loading"&&Ze.createElement(Yc,null),!y.length&&r?Ze.createElement(Xc,null,Ze.createElement(eA,{title:no.t("No results found"),description:no.t("Try using different keywords")})):e==="success"&&Ze.createElement(Or,{disabled:c,className:"widget-liquidity-source-list"},y.map(S=>{let{groupTitle:C,...k}=S;return Ze.createElement(Ze.Fragment,{key:S.id},Ze.createElement(RI,{style:{height:"61px"},...k,selected:!1,className:"widget-liquidity-source-list-item-btn",hasDivider:!0}))}))))}i(Zc,"LiquiditySourcePage");import{i18n as nA}from"@lingui/core";import Ea from"react";import{useNavigate as rA}from"react-router-dom";function vy(){let t=rA(),e=Qe(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=H()(),{fetch:c,loading:l}=ba({refetchQuote:n}),p=i(f=>{r(f),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${$.settings}`,d=`../${$.wallets}`;return Ea.createElement(se,{header:{onWallet:()=>{t(d),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:nA.t("Routes"),suffix:Ea.createElement(zo,{onClickRefresh:o||s?c:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},Ea.createElement(ce,null,Ea.createElement($r,{fetch:c,loading:l,onClickOnQuote:p})))}i(vy,"RoutesPage");import{i18n as By}from"@lingui/core";import{Divider as Wy,getCategoriesCount as fA,SelectableCategoryList as gA}from"@rango-dev/ui";import ro,{useMemo as hA,useState as My}from"react";import{useNavigate as yA}from"react-router-dom";import{i18n as Jc}from"@lingui/core";import{Divider as lA,Image as cA,ListItemButton as pA,NotFound as uA,Typography as Ny}from"@rango-dev/ui";import ft,{useEffect as dA,useState as mA}from"react";var xy=i((t,e,o)=>t.filter(n=>ri(n.type,o)).filter(n=>st(n.name,e)||st(n.displayName,e)),"filterBlockchains");import{ImageContainer as iA,styled as by}from"@rango-dev/ui";var Ey=by("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Ia=by(bl,{padding:0,margin:0,listStyle:"none",[`& ${iA}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as aA,Skeleton as Iy}from"@rango-dev/ui";import Aa from"react";var sA=20;function Ay(){return Aa.createElement(Ia,{id:"widget-blockchain-loading-list",as:"ul"},Array.from(Array(sA),t=>Aa.createElement(aA,{key:t,hasDivider:!0,start:Aa.createElement(Iy,{variant:"circular",width:35,height:35}),title:Aa.createElement(Iy,{variant:"text",size:"large",width:90})})))}i(Ay,"LoadingBlockchainList");function Rc(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,c]=mA(e),{fetchStatus:l}=T();dA(()=>{c([...xy(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?ft.createElement(uA,{title:Jc.t("No results found"),description:Jc.t("Try using different keywords")}):ft.createElement(Ia,{as:"ul",key:`${r}-${o}`,id:"widget-blockchain-list"},s.map(u=>ft.createElement(pA,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:ft.createElement(cA,{src:u.logo,size:30}),title:ft.createElement(Ny,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return ft.createElement(ft.Fragment,null,a&&ft.createElement(ft.Fragment,null,ft.createElement(Ny,{variant:"label",size:"large"},Jc.t("Select Chain")),ft.createElement(lA,{size:4})),ft.createElement(Ey,null,l==="loading"&&ft.createElement(Ay,null),l==="success"&&p()))}i(Rc,"BlockchainList");function Na(t){let{type:e}=t,o=Qe(),[n,r]=My(""),[a,s]=My("ALL"),c=H().use.setToBlockchain(),l=H().use.setFromBlockchain(),p=H().use.setToToken(),{fetchStatus:u,findNativeToken:d}=T(),f=yA(),{swapMode:h}=tt(),g=T().blockchains({type:e}),m=T().tokens(),y=hA(()=>fu(g,m),[g.length,m.length]),S=fA(y),C=!t.hideCategory&&S!==1,k=i(x=>{if(e==="custom-token")f(`..?blockchain=${x.name}`,{replace:!0});else{if(e==="source")l(x);else if(h==="swap")c(x);else{let w=d(x);w&&p({token:w,meta:{blockchains:g}})}o()}},"handleBlockchainChange");return ro.createElement(se,{header:{title:By.t("Select Chain")}},ro.createElement(ce,{view:!0},C&&ro.createElement(ro.Fragment,null,ro.createElement(gA,{setCategory:s,category:a,blockchains:y,isLoading:u==="loading"}),ro.createElement(Wy,{size:24})),ro.createElement(Bt,{value:n,autoFocus:!0,placeholder:By.t("Search Chain"),id:"widget-select-blockchain-search-input",color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:x=>r(x.target.value)}),ro.createElement(Wy,{size:16}),ro.createElement(Rc,{list:y,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:k})))}i(Na,"SelectBlockchainPage");import{i18n as Ma}from"@lingui/core";import{Divider as Oy,Spinner as MA}from"@rango-dev/ui";import vo,{useEffect as LA,useState as PA}from"react";import{useNavigate as _A}from"react-router-dom";import{i18n as op}from"@lingui/core";import{BlockchainsChip as Ba,Divider as Dy,Image as $y,Skeleton as vA,Tooltip as xA,Typography as np}from"@rango-dev/ui";import be from"react";import{useEffect as TA}from"react";var Ly=["ETH","COSMOS","OSMOSIS"];function ep(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(SA),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(CA(s)),r=n.splice(a)}return{list:n,more:r}}i(ep,"prepare");function SA(t,e){let o=Ly,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(SA,"sortByMostUsedBlockchains");function CA(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(CA,"generateSortByPreferredBlockchainsFor");function Py(t,e){return!!e.list.find(o=>o.name===t)}i(Py,"isInVisibleList");function tp(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=T();TA(()=>{if(e?.selected){let a=ep(t,o,e);Py(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=ep(t,o,e);return{list:r.list,more:r.more,history:[]}}i(tp,"usePrepareBlockchainList");import{styled as kA}from"@rango-dev/ui";var _y=kA("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var bA=6,EA=12;function rp(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,{showCompactTokenSelector:s}=ne(),c=tp(e,{limit:s?4:10,selected:n?.name}),{fetchStatus:l}=T(),p=H().use.resetToBlockchain(),u=H().use.resetFromBlockchain(),d=c.more.length>0,f=c.more[0],h=c.more.length===1&&f,g=!h&&d;return be.createElement(be.Fragment,null,!s&&be.createElement(be.Fragment,null,be.createElement(Dy,{size:12}),be.createElement(np,{variant:"label",size:"large"},op.t("Select Chain"))),be.createElement(Dy,{size:12}),be.createElement(_y,{id:"widget-blockchains-section-container"},l==="loading"&&Array.from(Array(s?bA:EA),(m,y)=>be.createElement(vA,{key:y,variant:"rounded",height:50})),l==="success"&&be.createElement(be.Fragment,null,be.createElement(Ba,{className:"widget-blockchains-section-all-btn",selected:!n,onClick:()=>{o==="from"?u():p()}},be.createElement(np,{variant:"body",size:"xsmall",color:"secondary500"},op.t("All"))),c.list.map(m=>be.createElement(xA,{key:m.name,content:m.shortName,side:"bottom",sideOffset:2,container:B()},be.createElement(Ba,{className:"widget-blockchains-section-item-btn",key:m.name,selected:!!n&&n.name===m.name,onClick:()=>r(m)},be.createElement($y,{src:m.logo,size:30})))),h?be.createElement(Ba,{className:"widget-blockchains-section-only-item-btn",key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},be.createElement($y,{src:f.logo,size:30})):null,g?be.createElement(Ba,{onClick:a,key:"more-blockchains",className:"widget-blockchains-section-more-items-btn"},be.createElement(np,{variant:"body",size:"xsmall",color:"secondary500"},op._("More +{count}",{count:c.more.length}))):null)))}i(rp,"BlockchainsSection");import{useCallback as AA,useRef as NA,useState as ip}from"react";function ap(){let t=T().blockchains(),e=NA(null),{customTokens:o}=T(),[n,r]=ip(!1),[a,s]=ip([]),[c,l]=ip(null),p=i(async(f,h)=>{l(null),r(!0),s([]);try{let g=await ct().searchCustomTokens({query:f,blockchain:h},{signal:e.current?.signal}),m=new Set(o().map(C=>Vt(C))),y=new Set(t.map(C=>C.name)),S=g.tokens.filter(C=>y.has(C.blockchain)&&!m.has(Vt(C)));s(S),r(!1)}catch(g){l(g instanceof Error?g.message:"something went wrong"),s([]),g?.name!=="CanceledError"&&r(!1)}},"fetch"),u=AA(ni((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(ap,"useSearchCustomTokens");function Wa(t,e,o){return o&&t.length===1&&t[0]?.address===e?!1:t.length<20&&e.trim().length>=3}i(Wa,"shouldSearchForCustomTokens");function Fy(t,e,o,n,r){let a=[...t];return Wa(t,o,r)&&(a=n?[...a,"skeleton","skeleton","skeleton"]:[...a,...e.map(s=>({...s,customToken:!0,warning:!0}))]),a}i(Fy,"prepareTokensList");function La(t){let{type:e}=t,o=_A(),n=Qe(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:c,setFromBlockchain:l,setToBlockchain:p}=H()(),{getBalanceFor:u}=T(),{fetch:d,loading:f,tokens:h,cancel:g}=ap(),[m,y]=PA(""),S=e==="source"?r:a,C=S?.name??"",k=T().blockchains({type:e}),x=T().tokens({type:e,blockchain:C,searchFor:m,getBalanceFor:u}),w=Fy(x,h,m,f,S?.name),I=i(E=>{e==="source"?l(E):p(E)},"updateBlockchain"),A=i(E=>{e==="source"?s({token:E,meta:{blockchains:k}}):c({token:E,meta:{blockchains:k}})},"updateToken"),b={source:Ma.t("Source"),destination:Ma.t("Destination")};return LA(()=>(Wa(x,m,S?.name)&&d(m,S?.name??void 0),()=>{g()}),[x.length,m,S?.name]),vo.createElement(se,{header:{title:Ma.t("Swap {type}",{type:b[e]})}},vo.createElement(ce,null,vo.createElement(rp,{blockchains:k,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o($.blockchains),onChange:E=>{I(E)}}),vo.createElement(Oy,{size:24}),vo.createElement(Bt,{value:m,id:"widget-select-swap-item-search-input",autoFocus:!0,placeholder:Ma.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>y(""),onChange:E=>y(E.target.value),suffix:Wa(x,m,S?.name)&&f?vo.createElement(MA,{size:12,color:"secondary"}):void 0}),vo.createElement(Oy,{size:16}),vo.createElement(Nr,{list:w,selectedBlockchain:C,searchedFor:m,type:e,onChange:E=>{A(E);let v=k.find(N=>E.blockchain===N.name);v&&I(v),n()}})))}i(La,"SelectSwapItemsPage");import{i18n as pp}from"@lingui/core";import{Alert as lN,Button as cN,styled as pN}from"@rango-dev/ui";import Xo from"react";import{useInRouterContext as uN,useSearchParams as dN}from"react-router-dom";import{i18n as Gy}from"@lingui/core";import{Alert as OA,Divider as lp,InfoIcon as UA,SlippageIcon as zA,TextField as HA,Tooltip as QA,Typography as Vy}from"@rango-dev/ui";import Oe from"react";import{Chip as DA,styled as zr,TextField as $A}from"@rango-dev/ui";var Uy=zr("div",{paddingTop:"$5",padding:"$10 $5"}),zy=zr("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${$A}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px",paddingLeft:"$2"}}),Hy=zr("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Pa=zr("div",{maxWidth:"280px",padding:"$10"}),Qy=zr(DA,{width:"61px",flexShrink:0});import{i18n as sp}from"@lingui/core";import{Typography as FA}from"@rango-dev/ui";import Hr from"react";function qy(){return Hr.createElement(Pa,null,Hr.createElement(FA,{variant:"label",size:"medium",color:"neutral700"},sp.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Hr.createElement("br",null),Hr.createElement("br",null),Hr.createElement("b",null,sp.t("Warning")),":\xA0",sp.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(qy,"SlippageTooltipContent");function cp(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=T(),r=o!==null?pn(o):null,a=i(l=>{let p=l.target.value,u=parseFloat(p);if(isNaN(u))return n(null);let d=u;u>Yn&&(d=Yn),n(d)},"onSlippageValueChange"),s=i(l=>{o!==null&&n(null),e(l)},"onClickSlippageChip"),c=i(l=>{let p=l.target,u=p.value;ku(u)||(p.value=u.slice(0,-1))},"onInput");return Oe.createElement(Uy,null,Oe.createElement(Hy,null,Oe.createElement(zA,{size:16,color:"gray"}),Oe.createElement(lp,{direction:"horizontal",size:4}),Oe.createElement(Vy,{variant:"title",size:"xmedium"},Gy.t("Slippage tolerance per swap")),Oe.createElement(lp,{direction:"horizontal",size:4}),Oe.createElement(QA,{container:B(),side:"top",sideOffset:4,content:Oe.createElement(qy,null)},Oe.createElement(UA,{color:"gray"}))),Oe.createElement(zy,null,di.map((l,p)=>{let u=`slippage-${p}`;return Oe.createElement(Qy,{id:`widget-slippage-chip-${l.toString()}%-btn`,key:u,onClick:()=>s(l),selected:o===null&&l===t,label:`${l.toString()}%`})}),Oe.createElement(HA,{type:"number",min:"0.01",max:"30",step:"0.01",status:r?.type||(o?"success":"default"),id:"widget-slippage-chip-text-input",onInput:c,fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:a,suffix:o&&Oe.createElement(Vy,{variant:"body",size:"small"},"%"),placeholder:Gy.t("Custom")})),r&&Oe.createElement(Oe.Fragment,null,Oe.createElement(lp,{size:10}),Oe.createElement(OA,{id:"widget-slippage-alert",variant:"alarm",type:r.type,title:r.message})))}i(cp,"Slippage");import{i18n as wt}from"@lingui/core";import{AutoThemeIcon as Ky,BridgesIcon as qA,ChevronRightIcon as _a,DarkModeIcon as jy,Divider as Qr,ExchangeIcon as GA,InfinityIcon as VA,InfoIcon as KA,LanguageIcon as jA,LightModeIcon as Xy,List as XA,ListItem as YA,ListItemButton as ZA,Skeleton as JA,styled as RA,Switch as eN,Tabs as tN,TargetIcon as oN,Tooltip as nN,Typography as it}from"@rango-dev/ui";import D from"react";import{useNavigate as rN}from"react-router-dom";var iN=RA("div",{width:"202px",height:"$40"}),aN=[{id:"light",icon:D.createElement(Xy,{color:"black",size:24}),tooltip:D.createElement(it,{size:"xsmall",variant:"body"},wt.t("Light"))},{id:"dark",icon:D.createElement(jy,{color:"black",size:24}),tooltip:D.createElement(it,{size:"xsmall",variant:"body"},wt.t("Dark"))},{id:"auto",icon:D.createElement(Ky,{color:"black",size:24}),tooltip:D.createElement(it,{size:"xsmall",variant:"body"},wt.t("Auto"))}],sN=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return D.createElement(Ky,{...e});case"dark":return D.createElement(jy,{...e});default:return D.createElement(Xy,{...e})}},"getThemeIcon");function Yy(){let t=rN(),{theme:e}=T().config,{setTheme:o,theme:n}=T(),{activeLanguage:r,languages:a}=wo(),s=a.find(W=>W.local===r)?.label,c=T().fetchStatus,l=T().swappers(),p=T().getDisabledLiquiditySources(),{config:{features:u}}=T(),d=T().customTokens(),f=et("theme",u),h=et("liquiditySource",u),g=et("language",u),m=et("customTokens",u),y=T().infiniteApprove,S=T().toggleInfiniteApprove,C=gi(l,p),k=C.filter(W=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(W.type)),x=k.length,w=k.filter(W=>W.selected).length,I=C.filter(W=>W.type==="DEX"),A=I.length,b=I.filter(W=>W.selected).length,E=i((W,J)=>{switch(c){case"loading":return D.createElement(JA,{variant:"text",size:"medium",width:50});case"failed":return D.createElement(it,{variant:"body",size:"medium",color:"$error500"},wt.t("Loading failed"));default:return D.createElement(it,{variant:"body",size:"medium"},`${W} / ${J}`)}},"handleSwapperEndItem"),v={id:"widget-setting-bridge-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Bridges")),end:D.createElement(D.Fragment,null,E(w,x),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(_a,{color:"black"})),onClick:()=>t($.bridges),start:D.createElement(qA,{color:"gray",size:16})},N={id:"widget-setting-exchange-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Exchanges")),end:D.createElement(D.Fragment,null,E(b,A),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(_a,{color:"black"})),start:D.createElement(GA,{color:"gray",size:16}),onClick:()=>t($.exchanges)},M={id:"widget-setting-custom-tokens-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Custom Tokens")),end:D.createElement(D.Fragment,null,D.createElement(it,{variant:"body",size:"medium"},`${d.length}`),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(_a,{color:"black"})),start:D.createElement(oN,{color:"gray",size:16}),onClick:()=>t($.customTokens)},P={id:"widget-setting-language-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Language")),start:D.createElement(jA,{color:"gray",size:16}),end:D.createElement(D.Fragment,null,D.createElement(it,{variant:"body",size:"medium"},s),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(_a,{color:"black"})),onClick:()=>t($.languages)},U={id:"widget-setting-infinite-approval-item-btn",title:D.createElement(D.Fragment,null,D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Infinite approval")),D.createElement(Qr,{direction:"horizontal",size:4}),D.createElement(nN,{side:"top",sideOffset:4,container:B(),content:D.createElement(Pa,null,D.createElement(it,{variant:"label",size:"medium",color:"neutral700"},D.createElement("b",null,wt.t("Warning")),":\xA0",wt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},D.createElement(KA,{color:"gray"}))),start:D.createElement(VA,{color:"gray",size:16}),end:D.createElement(eN,{checked:y}),onClick:S},Q={id:"widget-setting-theme-item-btn",type:D.createElement(YA,null),title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Theme")),end:D.createElement(iN,null,D.createElement(tN,{container:B(),items:aN,value:n,className:"widget-setting-theme-item-tabs-container",onChange:W=>o(W.id),type:"primary",borderRadius:"small"})),start:sN(n)},Z=h?[]:[v,N];return m||Z.push(M),g||Z.push(P),Z.push(U),!e?.singleTheme&&!f&&Z.push(Q),D.createElement(XA,{type:D.createElement(ZA,{className:"widget-settings-list-item-btn",hasDivider:!0,id:"_",onClick:()=>console.log()}),items:Z})}i(Yy,"SettingsLists");var mN=pN("div",{paddingLeft:"$8"});function Zy(){let{isInCampaignMode:t,updateCampaignMode:e}=T(),o=t(),[,n]=dN(),r=uN(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Xo.createElement(se,{header:{title:pp.t("Settings")}},Xo.createElement(ce,null,o&&Xo.createElement(lN,{type:"info",variant:"alarm",id:"widget-settings-campaign-mode-alert",title:pp.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:Xo.createElement(mN,null,Xo.createElement(cN,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},pp.t("Reset")))}),Xo.createElement(cp,null),Xo.createElement(Yy,null)))}i(Zy,"SettingsPage");import{i18n as v0}from"@lingui/core";import{cancelSwap as x0}from"@rango-dev/queue-manager-rango-preset";import{useManager as b0}from"@rango-dev/queue-manager-react";import{Alert as E0}from"@rango-dev/ui";import Ip from"react";import{useParams as I0}from"react-router-dom";import{i18n as zt}from"@lingui/core";import{getCurrentNamespaceOfOrNull as c0,getCurrentStep as p0,getRelatedWalletOrNull as u0}from"@rango-dev/queue-manager-rango-preset";import{Button as GS,Divider as d0,QuoteCost as m0,StepDetails as f0,Typography as kp}from"@rango-dev/ui";import{useWallets as g0}from"@rango-dev/wallets-react";import VS from"bignumber.js";import{PendingSwapNetworkStatus as Fn}from"rango-types";import we,{useEffect as wp,useRef as vp,useState as qa}from"react";import{useNavigate as h0}from"react-router-dom";import{i18n as xo}from"@lingui/core";var fN=[xo.t("Sunday"),xo.t("Monday"),xo.t("Tuesday"),xo.t("Wednesday"),xo.t("Thursday"),xo.t("Friday"),xo.t("Saturday")];function Jy(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"):`${fN[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Jy,"timeSince");function Ry(t){return t.finishTime?Jy(parseInt(t.finishTime)):Jy(parseInt(t.creationTime))}i(Ry,"getSwapDate");import qr from"react";import{i18n as Da}from"@lingui/core";import{Button as eS,Divider as up,MessageBox as gN}from"@rango-dev/ui";import bo from"react";var tS=i(({onCancel:t,onClose:e})=>bo.createElement(bo.Fragment,null,bo.createElement(up,{size:20}),bo.createElement(gN,{type:"error",title:Da.t("Cancel Swap"),description:Da.t("Are you sure you want to cancel this swap?")}),bo.createElement(up,{size:32}),bo.createElement(eS,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Da.t("Yes, Cancel it")),bo.createElement(up,{size:12}),bo.createElement(eS,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Da.t("No, Continue"))),"CancelContent");import{i18n as $a}from"@lingui/core";import{Button as oS,Divider as dp,MessageBox as hN,Typography as yN}from"@rango-dev/ui";import io from"react";var nS=i(({onDelete:t,onClose:e})=>io.createElement(io.Fragment,null,io.createElement(dp,{size:20}),io.createElement(hN,{type:"error",title:$a.t("Delete Transaction"),description:$a.t("Are you sure you want to delete this swap?")}),io.createElement(dp,{size:32}),io.createElement(oS,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},$a.t("Yes, Delete it")),io.createElement(dp,{size:12}),io.createElement(oS,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},io.createElement(yN,{variant:"title",size:"medium",color:"primary"},$a.t("No, Cancel")))),"DeleteContent");import{i18n as SN}from"@lingui/core";import{Button as CN,Divider as TN,MessageBox as kN}from"@rango-dev/ui";import Yo from"react";var rS=i(t=>{let{switchNetworkModalState:e,handleSwitchNetwork:o}=t;return Yo.createElement(Yo.Fragment,null,Yo.createElement(kN,{type:e.type,title:e.title,description:e.description}),e.type==="error"&&Yo.createElement(Yo.Fragment,null,Yo.createElement(TN,{size:"30"}),Yo.createElement(CN,{id:"widget-switch-network-try-again",type:"primary",size:"large",onClick:o},SN.t("Try Again"))))},"NetworkStateContent");import{getCurrentNamespaceOfOrNull as ON,getCurrentStep as UN,getRelatedWalletOrNull as zN}from"@rango-dev/queue-manager-rango-preset";import{WalletState as HN}from"@rango-dev/ui";import{useWallets as QN}from"@rango-dev/wallets-react";import uS from"react";import{i18n as Dn}from"@lingui/core";import{Alert as sS,Button as xN,Checkbox as bN,Divider as Ua,Image as EN,MessageBox as IN,Spinner as AN,WarningIcon as NN}from"@rango-dev/ui";import{useWallets as BN}from"@rango-dev/wallets-react";import ye,{useState as WN}from"react";import{css as wN,darkTheme as vN,styled as mp}from"@rango-dev/ui";var iS=wN({wordWrap:"break-word",display:"block"}),aS=mp("img",{width:"100%"}),Fa=mp("div",{position:"relative"}),Oa=mp("span",{position:"absolute",top:0,right:0,borderRadius:"50%",width:"14px",height:"14px",display:"flex",padding:"$2",backgroundColor:"$warning300",[`.${vN} &`]:{$$color:"$warning600"}});var lS=i(t=>{let{wallet:e,namespace:o,onClose:n}=t,[r,a]=WN(null),{list:s}=bt(),c=ne.use.isActiveTab(),{state:l,connect:p}=BN(),u=s.find(w=>w.type===e.walletType),d=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,m=u.isHub?h?.connected:f.connected,y=i(()=>m?Dn.t("Done"):r?Dn.t("Try again"):Dn.t("Connect"),"getButtonTitle"),S=i(()=>g?ye.createElement(AN,{color:"info"}):r||m?null:ye.createElement(bN,{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(m){n();return}C()},"handleClickButton"),x=i(()=>{if(!m)return null;let w=u?.isHub?h?.accounts?.[0]?.split(":"):f?.accounts?.[0]?.split(":"),I=w?.[w?.length-1];return I?lo(I):null},"getAddress");return ye.createElement(ye.Fragment,null,ye.createElement(IN,{type:"warning",title:Dn.t("Connect {wallet}",{wallet:u.title}),description:Dn.t("The connection of your wallet or some networks has been disconnected. Connect to continue the swap"),icon:ye.createElement(Fa,null,ye.createElement(EN,{src:u.image,size:45}),ye.createElement(Oa,null,ye.createElement(NN,{color:"warning",size:10})))}),m&&!d&&ye.createElement(ye.Fragment,null,ye.createElement(Ua,{size:10}),ye.createElement(sS,{type:"success",variant:"alarm",title:Dn.t("Wallet connected successfully.")})),r&&!d&&ye.createElement(ye.Fragment,null,ye.createElement(Ua,{size:10}),ye.createElement(sS,{type:"error",title:r?.message,variant:"alarm"})),d&&ye.createElement(ye.Fragment,null,ye.createElement(Ua,{size:30}),ye.createElement(_o,{namespace:d,suffix:S(),error:r?.message,connected:m,address:x()})),ye.createElement(Ua,{size:"40"}),ye.createElement(xN,{loading:g,type:"primary",id:"widget-connect-wallet-btn",onClick:k,disabled:!c},y()))},"ConnectWalletContent");import{i18n as cS}from"@lingui/core";import{Button as MN,Divider as LN,Image as PN,MessageBox as _N,WarningIcon as DN}from"@rango-dev/ui";import{useWallets as $N}from"@rango-dev/wallets-react";import{detectInstallLink as FN}from"@rango-dev/wallets-shared";import ao from"react";var pS=i(t=>{let{walletType:e}=t,{getWalletInfo:o}=$N(),n=e?o(e):null;if(!n)return null;let r=i(()=>window.open(FN(n.installLink),"_blank"),"handleButtonClick");return ao.createElement(ao.Fragment,null,ao.createElement(_N,{type:"warning",title:cS.t("Install {wallet}",{wallet:n.name}),description:"Your wallet is not installed. Please install it to continue the swap. ",icon:ao.createElement(Fa,null,ao.createElement(PN,{src:n.img,size:45}),ao.createElement(Oa,null,ao.createElement(DN,{color:"warning",size:10})))}),ao.createElement(LN,{size:"40"}),ao.createElement(MN,{type:"primary",id:"widget-install-wallet-btn",onClick:r},cS.t("Install")))},"InstallWalletContent");var dS=i(t=>{let{swap:e,onClose:o}=t,{state:n,getWalletInfo:r}=QN(),a=UN(e),s=a?zN(e,a):null,c=s?.walletType,l=c?Kn(r(c),n(c)):null,p=a?ON(e,a):null;return c?l===HN.NOT_INSTALLED?uS.createElement(pS,{walletType:c}):uS.createElement(lS,{wallet:s,namespace:p,onClose:o}):null},"WalletStateContent");function fp(t){let{isOpen:e,state:o,switchNetworkModalState:n,onClose:r,onDelete:a,onCancel:s,swap:c,message:l,handleSwitchNetwork:p}=t;return qr.createElement(ee,{open:e,onClose:r,container:B()},o==="connectWallet"&&qr.createElement(dS,{swap:c,message:l,onClose:r}),o==="switchNetwork"&&n&&qr.createElement(rS,{message:l,switchNetworkModalState:n,handleSwitchNetwork:p}),o==="delete"&&qr.createElement(nS,{onClose:r,onDelete:()=>{r(),a()}}),o==="cancel"&&qr.createElement(tS,{onClose:r,onCancel:()=>{r(),s()}}))}i(fp,"SwapDetailsModal");import{i18n as Gr}from"@lingui/core";import{Button as gp,Divider as Vr,MessageBox as gS,TokenAmount as qN,Typography as hS}from"@rango-dev/ui";import ke from"react";import{Link as GN,useNavigate as VN}from"react-router-dom";var mS="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",fS="/profile";function hp(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:c,token:l,chain:p,percentageChange:u,description:d,diagnosisUrl:f}=t,h=VN(),{showProfileBanner:g}=ne();return ke.createElement(ee,{open:e,onClose:o,id:"widget-swap-details-complete-modal",container:document.getElementById(Re.SWAP_BOX_ID)||document.body},n==="success"?ke.createElement(gS,{type:"success",title:Gr.t("Swap Successful")},ke.createElement(qN,{direction:"vertical",tooltipContainer:B(),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}),ke.createElement(Vr,{size:12}),ke.createElement(hS,{className:iS(),variant:"body",size:"medium",color:"neutral700",align:"center"},d)):ke.createElement(gS,{type:"error",title:Gr.t("Transaction Failed"),description:d}),ke.createElement(Vr,{size:30}),n==="success"&&ke.createElement(ke.Fragment,null,g&&ke.createElement(ke.Fragment,null,ke.createElement(GN,{to:fS},ke.createElement(aS,{src:mS,alt:"Profile Banner"})),ke.createElement(Vr,{size:30})),ke.createElement(gp,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{h("../../")}},Gr.t("Done"))),ke.createElement(Vr,{size:12}),f&&ke.createElement(ke.Fragment,null,ke.createElement(gp,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(f,"_blank")},Gr.t("Diagnosis")),ke.createElement(Vr,{size:12})),ke.createElement(gp,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},ke.createElement(hS,{variant:"title",size:"medium",color:"primary"},Gr.t("See Details"))))}i(hp,"SwapDetailsCompleteModal");import{i18n as Qa}from"@lingui/core";import{CopyIcon as r0,DoneIcon as i0,IconButton as a0,RangoExplorerIcon as s0,Tooltip as OS,Typography as US,useCopyToClipboard as l0}from"@rango-dev/ui";import Mt from"react";import n0 from"react";import{i18n as RN}from"@lingui/core";import{Alert as _S,IconButton as e0,LinkIcon as t0}from"@rango-dev/ui";import Eo,{Fragment as o0}from"react";import{Alert as jN,ChevronDownIcon as XN,IconButton as YN}from"@rango-dev/ui";import $n,{useState as ZN}from"react";import{css as Kr,darkTheme as yS,styled as Ut,Typography as KN}from"@rango-dev/ui";var SS=Ut(ce,{overflowY:"auto","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${yS} &`]:{color:"$secondary500"}}}}}),CS=Ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),TS=Ut("div",{position:"sticky",top:0,zIndex:10,backgroundColor:"$background"}),kS=Ut("div",{padding:"$0 $20 $20 $20"}),MY=Ut("div",{display:"flex",flexDirection:"column",gap:"$10"}),wS=Ut("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),LY=Ut("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),Zo=Kr({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${yS} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),vS=Kr({padding:"$5 0"}),za=Kr({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),xS=Kr({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),bS=Kr({width:"100%",padding:"0 $20 $10"}),ES=Ut("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),IS=Ut("div",{display:"flex",flexDirection:"column",gap:"$5"}),Ha=Ut(KN,{wordBreak:"break-word"});import{styled as yp}from"@rango-dev/ui";var AS=yp("div",{display:"flex",flexDirection:"column",gap:"$10"}),NS=yp("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),BS=yp("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function WS(t){let{message:e}=t,[o,n]=ZN(!1);return $n.createElement(jN,{id:"widget-failed-swap-details-alert",type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&$n.createElement(YN,{id:"widget-swap-details-failed-btn",onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},$n.createElement(NS,{rotated:o},$n.createElement(XN,{size:12,color:"gray"}))),footer:$n.createElement(BS,{open:o},$n.createElement(Ha,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(WS,"FailedAlert");import{i18n as MS}from"@lingui/core";import{Alert as Sp,Button as LS}from"@rango-dev/ui";import{PendingSwapNetworkStatus as JN}from"rango-types";import jr from"react";function PS(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,setNetworkModal:n,message:r,showNetworkModal:a}=t;return e?jr.createElement(Sp,{type:"warning",id:"widget-swap-details-change-network-alert",title:r.shortMessage,action:jr.createElement(LS,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{n("switchNetwork"),o()}},MS.t("Change"))}):a===JN.WaitingForConnectingWallet?jr.createElement(Sp,{type:"warning",title:r.shortMessage,id:"widget-swap-details-warning-alert-connect-wallet-alert",action:jr.createElement(LS,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{n("connectWallet")}},MS.t("Connect"))}):jr.createElement(Sp,{id:"widget-swap-details-short-alert",type:"warning",title:r.shortMessage})}i(PS,"WarningAlert");function Cp(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a,step:s,hasAlreadyProceededToSign:c}=t,l=pr(s),p=s.status==="waitingForApproval"&&!l,u=s.status==="running"&&!l,d=u&&!c||p&&!s.explorerUrl?.length;return Eo.createElement(AS,null,s.explorerUrl?.map((f,h,g)=>{let m=h+f.url,y=h===g.length-1,S=(y&&u||p)&&!d,C=y&&s.status==="failed";return Eo.createElement(o0,{key:m},Eo.createElement(_S,{id:"widget-swap-details-tx-alert",type:y&&(S&&"loading"||C&&"error")||"success",title:f.description?`${f.description} Tx`:RN.t("View transaction"),action:f.url&&Eo.createElement(e0,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(f.url,"_blank")},Eo.createElement(t0,{size:12}))}))}),d&&Eo.createElement(_S,{id:"widget-swap-details-loading-alert",type:"loading",title:a.shortMessage}),s.status!=="failed"&&l&&Eo.createElement(PS,{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a}),s.status==="failed"&&Eo.createElement(WS,{message:a}))}i(Cp,"SwapDetailsAlerts");var DS=2e3;var $S=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:yt(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:_(c,6,6),realValue:c??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:yt(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:_(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:Qn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(l=>({from:{chain:{displayName:yt(l.fromBlockchain,e)??"",image:l.fromBlockchainLogo??""}},to:{chain:{displayName:yt(l.toBlockchain,e)??"",image:l.toBlockchainLogo??""}},swapper:{displayName:Qn(l.swapperId,o)??"",image:l.swapperLogo??"",type:l.swapperType}})):[],alerts:n0.createElement(Cp,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function FS(t){if(pr(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(FS,"getStepState");function zS(t){let{requestId:e}=t,[o,n]=l0(DS);return Mt.createElement(TS,{className:Zo()},Mt.createElement(US,{variant:"label",size:"large",color:"neutral700"},Qa.t("Request ID")),Mt.createElement("div",{className:za()},Mt.createElement(US,{variant:"label",size:"small",color:"neutral700"},e),Mt.createElement(OS,{container:B(),content:o?Qa.t("Copied To Clipboard"):Qa.t("Copy Request ID"),open:o||void 0,side:"bottom",alignOffset:-16,align:"end"},Mt.createElement(a0,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:n.bind(null,e||"")},o?Mt.createElement(i0,{size:16,color:"secondary"}):Mt.createElement(r0,{size:16,color:"gray"}))),Mt.createElement(ES,{target:"_blank",href:`${nu}/swap/${e}`},Mt.createElement(OS,{container:B(),content:Qa.t("View on Rango Explorer"),side:"bottom"},Mt.createElement(s0,{size:20})))))}i(zS,"RequestIdRow");import{i18n as HS}from"@lingui/core";import{Typography as QS}from"@rango-dev/ui";import Tp from"react";function qS(t){let{date:e,isFinished:o}=t;return Tp.createElement("div",{className:Zo()},Tp.createElement(QS,{variant:"label",size:"large",color:"neutral700"},o?HS.t("Finished at"):HS.t("Created at")),Tp.createElement(QS,{variant:"label",size:"small",color:"neutral700"},e))}i(qS,"SwapDateRow");var y0=3e3;function xp(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:c}=g0(),l=T().blockchains(),p=T().swappers(),{findToken:u}=T(),d=H().use.retry(),f=h0(),h=vp(null),[g,m]=qa(!1),[y,S]=qa(null),[C,k]=qa(null),[x,w]=qa(null),I=vp(y),A=vp(C),b=Ne.use.getNotifications(),E=Ne.use.removeNotification(),v=b(),N=p0(e),M=N?.networkStatus,P=i(Me=>{m(!0),S(Me)},"handleChangeModalState"),U=i(()=>{m(!1)},"handleCloseModal"),Q=i(()=>{k({type:"loading",title:zt.t("Change Network"),description:`We\u2019re switching the connected network to ${X?.network}. Please check your wallet.`})},"handleShowSwitchNetworkLoading"),Z=i(()=>{k({type:"success",title:zt.t("Network Changed"),description:"The network has been successfully changed."})},"handleShowSwitchNetworkSucceeded"),W=i(Me=>{k({type:"error",title:zt.t("Network Switch Failed"),description:Me?.message||te.detailedMessage.content})},"handleShowSwitchNetworkFailed"),J=Rd(e),X=N?c0(e,N):null,ae=N?u0(e,N):null,Se=Ry(e),at=em(e),ue=i(Me=>!!c(Me)?.mobileWallet,"checkIsMobileWallet"),gt=!!M&&[Fn.WaitingForNetworkChange,Fn.NetworkChangeFailed].includes(M),vt=!!ae?.walletType&&ue(ae.walletType),xt=!!ae&&!!X&&a(ae.walletType,X.network,X),O=!!X&&gt&&(vt||xt),z=i(()=>{O&&(Q(),s(ae.walletType,[{namespace:X.namespace,network:X.network}]).then(()=>{Z()}).catch(Me=>{W(Me)}))},"handleSwitchNetwork"),Y=i(()=>{P("switchNetwork"),z()},"handleSwitchNetworkClick"),te=Jd(e,N,c),j=$S({swap:e,switchNetworkIsAvailable:O,handleSwitchNetworkClick:Y,showNetworkModal:M,setNetworkModal:P,message:te,blockchains:l,swappers:p}),G=j.length,[Ve,V]=[e.steps[0],e.steps[G-1]],Ce=V?.outputAmount||V?.expectedOutputAmountHumanReadable,Je=e.steps.reduce((Me,Lt)=>Me+parseFloat(Lt.feeInUsd||""),0),ht=e.steps.find(Me=>Me.diagnosisUrl)?.diagnosisUrl,so=_(parseFloat(Ce||"0")*(V?.toUsdPrice||0),4,4),zn=_(parseFloat(e.inputAmount)*(Ve?.fromUsdPrice||0),4,4),Io=Ce?new VS(Ce).multipliedBy(V.toUsdPrice||0).toString():"",Zr=new VS(e.inputAmount).multipliedBy(Ve?.fromUsdPrice||0).toString(),Ro=jt(zn,so),ts=te.detailedMessage.content||te.shortMessage,bC=e.status==="success"?zt.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:_(Ce,6,6),token:j[G-1]?.to.token.displayName,conciseAddress:lo(e.wallets[j[G-1]?.to.chain.displayName||""]?.address||""),chain:j[G-1]?.to.chain.displayName}}):we.createElement(IS,null,we.createElement(kp,{variant:"body",size:"medium",color:"neutral700",align:"center"},ts?"":zt.t("Transaction was not sent."),J?`${zt.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:J.outputAmount,symbol:J.symbol,blockchain:J.blockchain}})}`:""),ts&&we.createElement(Ha,{align:"center",variant:"body",size:"medium",color:"neutral700"},we.createElement("b",null,"Reason:")," ",ts));return wp(()=>{v.find(Lt=>Lt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(w(e.status),E(e.requestId),U()):x&&w(null))},[e.status,e.requestId]),wp(()=>{if(O){if(P("switchNetwork"),M===Fn.WaitingForNetworkChange){Q();return}if(M===Fn.NetworkChangeFailed){W();return}return}if(M===Fn.WaitingForConnectingWallet){P("connectWallet");return}if(M===Fn.NetworkChanged){P("switchNetwork"),Z();return}y&&["connectWallet","switchNetwork"].includes(y)&&U()},[M]),wp(()=>{if(I.current=y,A.current=C,y==="switchNetwork"&&C?.type==="success"){let Me=setTimeout(()=>{I.current==="switchNetwork"&&A.current?.type==="success"&&U()},y0);return()=>clearTimeout(Me)}},[y,C]),we.createElement(se,{header:{title:zt.t("Swap Details"),onCancel:e.status==="running"?()=>P("cancel"):void 0,suffix:e.status!=="running"&&we.createElement(fo,null,we.createElement(GS,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>P("delete")},we.createElement(kp,{size:"medium",variant:"label",color:"error"},zt.t("Delete"))))},footer:at&&!x&&we.createElement(GS,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let Me=Ii(e,l,u);d(Me),setTimeout(()=>{f("../../")},0)}},zt.t("Try again"))},we.createElement(SS,{compact:!0,ref:h},we.createElement(zS,{requestId:o}),we.createElement(qS,{date:Se,isFinished:!!e.finishTime}),we.createElement("div",{className:xS()},we.createElement(m0,{fee:_(String(Je),2,2),time:Gn(ai(e.steps)),steps:G}),we.createElement(Cr,{from:{price:{value:_(e.inputAmount,6,6),usdValue:zn,realUsdValue:Zr,realValue:e.inputAmount},token:{displayName:j[0]?.from.token.displayName||"",image:j[0]?.from.token.image},chain:{image:j[0]?.from.chain.image,displayName:j[0]?.from.chain.displayName||""}},to:{price:{value:_(Ce,6,6),usdValue:so,realUsdValue:Io,realValue:Ce||""},token:{displayName:j[G-1]?.to.token.displayName||"",image:j[G-1]?.to.token.image},chain:{image:j[G-1]?.to.chain.image,displayName:j[G-1]?.to.chain.displayName||""}},percentageChange:_(Ro,2,2),warningLevel:Xt(Ro??0)})),we.createElement("div",{className:bS()},we.createElement(kp,{variant:"title",size:"small"},zt.t("Swaps steps"))),we.createElement(d0,{size:8}),we.createElement(kS,null,j.map((Me,Lt)=>{let $p=Lt,Hn=e.steps[Lt]&&FS(e.steps[Lt]),EC=Hn==="error"||Hn==="in-progress"||Hn==="warning"||Hn==="completed"&&Lt===j.length-1;return we.createElement(f0,{className:"widget-swap-details-step-item-container",key:$p,step:Me,type:"swap-progress",ref:h,state:Hn,hasSeparator:Lt!==0,tabIndex:$p,isFocused:EC,tooltipContainer:B()})}))),we.createElement(fp,{isOpen:g,state:y,switchNetworkModalState:C,onClose:U,onCancel:r,onDelete:n,message:te.detailedMessage.content,swap:e,handleSwitchNetwork:Y}),we.createElement(hp,{open:!!x,diagnosisUrl:ht,onClose:()=>w(null),status:e.status==="success"?"success":"failed",priceValue:_(Ce,6,6),usdValue:so,realUsdValue:Io,realValue:Ce||"",percentageChange:_(Ro,2,2),token:{displayName:j[G-1]?.to.token.displayName||"",image:j[G-1]?.to.token.image},chain:{image:j[G-1]?.to.chain.image},description:bC}))}i(xp,"SwapDetails");import{i18n as Va}from"@lingui/core";import{Divider as XS,NotFound as w0,Skeleton as Yr,Typography as Ka}from"@rango-dev/ui";import Ie from"react";import{i18n as S0}from"@lingui/core";import{Divider as C0,Skeleton as T0,Typography as k0}from"@rango-dev/ui";import Ee from"react";import{css as Ht,styled as bp}from"@rango-dev/ui";var KS=bp("div",{width:"100%",height:"100%",padding:"$10 $20"}),Xr=bp("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Ga=bp("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),a9=Ht({display:"flex",justifyContent:"space-between",alignItems:"center"}),s9=Ht({paddingTop:"$15",display:"flex"}),l9=Ht({padding:"$15 $0"}),c9=Ht({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),p9=Ht({paddingBottom:"$10"}),u9=Ht({display:"flex",justifyContent:"start",alignItems:"center"}),d9=Ht({paddingTop:"$5",display:"flex",alignItems:"center"}),m9=Ht({display:"flex",alignItems:"center"}),f9=Ht({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),jS=Ht({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Ep(){return Ee.createElement(KS,null,Ee.createElement(wr,{type:"swap-preview"}),Ee.createElement("div",{className:"swaps-steps"},Ee.createElement(k0,{variant:"title",size:"small"},S0.t("Swaps steps"))),Ee.createElement(Ee.Fragment,null,Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1}),Ee.createElement("div",{className:jS()},Ee.createElement(C0,{direction:"horizontal",size:20}),Ee.createElement(T0,{height:22,variant:"rectangular"}))),Ee.createElement(Ga,null),Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1})),Ee.createElement(Ga,null),Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1})),Ee.createElement(Ga,null),Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1}))))}i(Ep,"LoadingSwapDetails");function YS(t){let{requestId:e,showSkeleton:o}=t;return Ie.createElement(se,{header:{title:Va.t("Swap Details"),suffix:Ie.createElement(fo,null)}},o&&Ie.createElement(CS,null,Ie.createElement("div",{className:Zo()},Ie.createElement(Ka,{variant:"label",size:"large",color:"neutral700"},`${Va.t("Request ID")}`),Ie.createElement("div",{className:za()},Ie.createElement(Ka,{variant:"label",size:"small",color:"neutral700"},Ie.createElement(Yr,{width:60,height:10,variant:"rounded"})),Ie.createElement(XS,{direction:"horizontal",size:4}),Ie.createElement(Yr,{width:16,height:16,variant:"rectangular"}),Ie.createElement(XS,{direction:"horizontal",size:4}),Ie.createElement(Yr,{width:16,height:16,variant:"rectangular"}))),Ie.createElement("div",{className:Zo()},Ie.createElement(Ka,{className:vS(),variant:"label",size:"large",color:"neutral700"},Ie.createElement(Yr,{width:60,height:10,variant:"rounded"})),Ie.createElement(Ka,{variant:"label",size:"small",color:"neutral700"},Ie.createElement(Yr,{width:60,height:10,variant:"rounded"}))),Ie.createElement(Ep,null)),!o&&Ie.createElement(wS,null,Ie.createElement(w0,{title:Va.t("Not found"),description:Va.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(YS,"SwapDetailsPlaceholder");function ZS(){let{manager:t,state:e}=b0(),o=!e.loadedFromPersistor,n=kt(t),{requestId:r}=I0(),a=Qe(),{fetchStatus:s}=T();if(!r)return Ip.createElement(E0,{containerStyles:{margin:"20px"},type:"error",title:v0.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&&x0(f)}},"onCancel"),u=i(async()=>{if(l?.id)try{t?.deleteQueue(l.id),a()}catch(f){console.log(f)}},"onDelete"),d=l?.swap;return!d||c?Ip.createElement(YS,{requestId:r,showSkeleton:c}):Ip.createElement(xp,{swap:d,requestId:r,onCancel:p,onDelete:u})}i(ZS,"SwapDetailsPage");import{i18n as JS}from"@lingui/core";import{Divider as A0,getCategoriesCount as N0,SelectableCategoryList as B0,styled as eC,Typography as W0,Wallet as M0}from"@rango-dev/ui";import Qt,{useState as RS}from"react";var L0=eC("div",{display:"flex",justifyContent:"center",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5"}),P0=eC(ce,{textAlign:"center"});function tC(){let{fetchStatus:t}=T(),[e,o]=RS("ALL"),n=T().blockchains(),{config:r}=T(),[a,s]=RS(),c=ne.use.isActiveTab(),{list:l}=bt(),p=Lu(l,n),d=N0(p)!==1,f=Pu(l,e),h=i(g=>{du(l,r.multiWallets)||s(g)},"handleWalletItemClick");return Qt.createElement(se,{header:{title:JS.t("Connect Wallets")}},Qt.createElement(P0,null,d&&Qt.createElement(Qt.Fragment,null,Qt.createElement(B0,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Qt.createElement(A0,{size:24})),Qt.createElement(W0,{variant:"title",size:"xmedium",align:"center"},JS.t("Choose a wallet to connect.")),Qt.createElement(L0,null,f.map((g,m)=>{let y=`wallet-${m}-${g.type}`;return Qt.createElement(M0,{key:y,...g,state:g.state,container:B(),onClick:()=>h(g),isLoading:t==="loading",disabled:!c})}),Qt.createElement(sr,{id:"widget-state-full-connect-modal",wallet:a,onClose:()=>{s(void 0)}}))))}i(tC,"WalletsPage");function oC(){return um(),Zs(),_0([{path:$.home,element:Ue.createElement(Sy,null)},{path:$.routes,element:Ue.createElement(vy,null)},{path:$.fromSwap,children:[{index:!0,element:Ue.createElement(La,{type:"source"})},{path:$.blockchains,element:Ue.createElement(Na,{type:"source"})}]},{path:$.toSwap,children:[{index:!0,element:Ue.createElement(La,{type:"destination"})},{path:$.blockchains,element:Ue.createElement(Na,{type:"destination"})}]},{path:$.settings,children:[{index:!0,element:Ue.createElement(Zy,null)},{path:$.languages,element:Ue.createElement(Ty,null)},{path:$.exchanges,element:Ue.createElement(Zc,{sourceType:"Exchanges"})},{path:$.bridges,element:Ue.createElement(Zc,{sourceType:"Bridges"})},{path:$.customTokens,children:[{index:!0,element:Ue.createElement(Ch,null)},{path:$.addCustomTokens,children:[{index:!0,element:Ue.createElement(pf,null)},{path:$.blockchains,element:Ue.createElement(Na,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:Ue.createElement(Oh,null)},{path:$.swapDetails,element:Ue.createElement(ZS,null)}]},{path:$.wallets,element:Ue.createElement(tC,null)},{path:$.confirmSwap,element:Ue.createElement(nh,null)}])}i(oC,"AppRoutes");import{useQueueManager as R0}from"@rango-dev/queue-manager-rango-preset";import{isEvmBlockchain as eB}from"rango-sdk";import{useContext as tB,useEffect as Wp,useState as fC}from"react";import{Provider as z0}from"@rango-dev/wallets-react";import ja,{createContext as H0,useEffect as sC,useMemo as Q0,useRef as lC}from"react";import{useEffect as $0}from"react";import{Provider as D0}from"@rango-dev/wallets-core";function nC(t){return t.map(e=>typeof e=="string"?e:e instanceof D0?e.id:e.config.type).join("-")}i(nC,"hashProviders");function Ap(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=T(),a=n();return $0(()=>{o(),r()},[nC(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(Ap,"useWalletProviders");import{legacyFormatAddressWithNetwork as F0,legacyReadAccountAddress as rC}from"@rango-dev/wallets-core/legacy";import{Events as On}from"@rango-dev/wallets-react";import{isEvmBlockchain as O0}from"rango-sdk";function iC(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=T(),{onConnectWalletHandler:c,onDisconnectWalletHandler:l}=t,p=s().filter(O0).map(m=>m.name),u=i((m,y)=>{let[S,,C,k,x]=m,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=us(S,C,p,y.supportedChainNames,x.isContractWallet);I.length&&e(I,x.namespace,k.derivationPath)},"onAccountsEvent"),d=i((m,y,S,C,k)=>{if(y===On.ACCOUNTS){let x=jn(k.supportedBlockchains);S&&u([m,y,S,C,k],{supportedChainNames:x})}y===On.PROVIDER_DISCONNECTED&&(o(m),l.current?l.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),y===On.NAMESPACE_DISCONNECTED&&n(m,S)},"handleUpdatesForHub"),f=i((m,y,S,C,k)=>{if(y===On.ACCOUNTS){let x=jn(k.supportedBlockchains),w=[],I=[];if(S?.forEach(b=>{let{network:E}=rC(b);p.includes(E)?w.push(b):I.push(b)}),r.filter(b=>b.walletType===m).map(b=>F0(b.address,b.chain)).length>0){if(w.length>0){let b=us(m,w,p,x,k.isContractWallet);a(m,{chains:b.map(E=>E.chain)})}I.length>0&&a(m,{chains:I.map(b=>{let{network:E}=rC(b);return E})})}S?u([m,y,S,C,k],{supportedChainNames:x}):(o(m),l.current?l.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}},"handleUpdatesForLegacy"),h=i((m,y,S,C,k)=>{if(y===On.CONNECTED&&S){let x={walletType:m,network:C.network??void 0,accounts:C.accounts??void 0};c.current?c.current(x):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(y===On.NETWORK&&S){let x={walletType:m,network:S,accounts:C.accounts??void 0};c.current?c.current(x):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((m,y,S,C,k)=>{k.isHub?d(m,y,S,C,k):f(m,y,S,C,k),h(m,y,S,C,k)},"handler")}}i(iC,"useUpdates");import{LegacyEvents as U0}from"@rango-dev/wallets-core/legacy";function aC(t,e){let[o,n,r,a,s]=e;n!==U0.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i(aC,"propagateEvents");var Xa=H0({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function q0(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}=Ap(s.wallets,c),p=lC(),u=lC(),{handler:d}=iC({onConnectWalletHandler:p,onDisconnectWalletHandler:u});sC(()=>{n().catch(console.log)},[]),sC(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let f=ne.use.isActiveTab(),h=Q0(()=>({onConnectWallet:g=>{p.current=g},onDisconnectWallet:g=>{u.current=g}}),[]);return ja.createElement(Xa.Provider,{value:h},ja.createElement(z0,{allBlockChains:a,providers:l,onUpdateState:(g,m,y,S,C)=>{let k=[g,m,y,S,C];d(...k),t.onUpdateState&&aC(t.onUpdateState,k)},autoConnect:!!f,configs:{wallets:s.wallets}},t.children))}i(q0,"Main");function Ya(t){let{config:e,...o}=t;return ja.createElement(Ru,{config:e},ja.createElement(q0,{...o,config:e}))}i(Ya,"WidgetWallets");import{globalCss as G0}from"@rango-dev/ui";var cC=i(()=>G0({"@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 V0}from"@rango-dev/wallets-react";import{useEffect as K0,useRef as j0}from"react";function pC(){let{connect:t,state:e}=V0(),o=j0({}),{fetchStatus:n}=T(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);K0(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(pC,"useForceAutoConnect");import{isApprovalTX as X0,RouteEventType as uC,StepEventType as dC,StepExecutionEventStatus as Y0,WidgetEvents as Za}from"@rango-dev/queue-manager-rango-preset";import{useEffect as mC}from"react";function Np(){let t=Ne.use.setNotification(),{connectedWallets:e,fetchBalances:o,customTokens:n}=T();mC(()=>{let r=i(a=>{let{event:s,step:c,route:l}=a;if(s.type===dC.TX_EXECUTION&&s.status===Y0.TX_SENT&&!X0(c)||s.type===dC.SUCCEEDED){let u=[],d=l.wallets[c?.fromBlockchain];if(d){let f=e.find(h=>h.address?.toLocaleLowerCase()===d.address?.toLocaleLowerCase()&&h.walletType===d.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(m=>f.some(y=>y.blockchain===m.blockchain&&y.address?.toLocaleLowerCase()===m.address?.toLocaleLowerCase()&&y.symbol?.toLocaleLowerCase()===m.symbol?.toLocaleLowerCase()));o(u,{selectedCustomTokens:g,shouldFetchCustomTokens:g.length>0})}}t(s,l)},"handleStepEvent");return ve.on(Za.StepEvent,r),()=>ve.off(Za.StepEvent,r)},[ve,e]),mC(()=>{let r=i(a=>{let{event:s,route:c}=a;(s.type===uC.FAILED||s.type===uC.SUCCEEDED)&&t(s,c)},"handleRouteEvent");return ve.on(Za.RouteEvent,r),()=>ve.off(Za.RouteEvent,r)},[ve])}i(Np,"useSubscribeToWidgetEvents");import{useManager as Z0}from"@rango-dev/queue-manager-react";import{useEffect as J0}from"react";function Bp(){let{isSynced:t,syncNotifications:e}=Ne(),{manager:o,state:n}=Z0();J0(()=>{Ne.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(kt(o))},[Ne.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Bp,"useSyncNotifications");function Mp(){pC(),cC(),Np(),Bp();let t=T().blockchains(),{canSwitchNetworkTo:e}=Xi(),[o,n]=fC(null),[r,a]=fC(),s=tB(Xa),c=t.filter(eB);Wp(()=>()=>cm(),[]),Wp(()=>()=>pm(),[]),R0({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:c,canSwitchNetworkTo:e}),Wp(()=>(Po.init(),Ne.persist.hasHydrated()||Ne.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)}),Po.destroy),[])}i(Mp,"useBootstrap");import{styled as oB}from"@rango-dev/ui";var gC=oB("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 Jo(){Mp();let{config:t}=T(),{activeTheme:e}=mo(t?.theme||{}),{activeLanguage:o}=wo();return Lp.createElement(nB,{language:o},Lp.createElement(gC,{id:"swap-container",className:e()},Lp.createElement(oC,null)))}i(Jo,"Main");import{setSolanaSignerConfig as vB}from"@rango-dev/signer-solana";import _p,{useEffect as Dp,useMemo as xB}from"react";function hC(){let{setWatermark:t,setShowProfileBanner:e}=ne();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Gt("BASE_URL")}/meta/dapp/config?apiKey=${Gt("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(hC,"useFetchApiConfig");import{useState as rB}from"react";var iB=i(()=>{let[t,e]=rB(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=uu(a);if(s){let c=o(s);e(c)}},"handleLoadCustomFont")}},"useFontLoader"),yC=iB;import{checkWaitingForNetworkChange as aB,makeQueueDefinition as sB}from"@rango-dev/queue-manager-rango-preset";import{Provider as lB}from"@rango-dev/queue-manager-react";import{useWallets as cB}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as pB}from"@rango-dev/wallets-shared";import{isEvmBlockchain as uB}from"rango-types";import dB,{useMemo as mB}from"react";function fB(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s,hubProvider:c}=cB(),l=mB(()=>sB({API_KEY:t.apiKey||Gt("API_KEY"),BASE_URL:Gt("BASE_URL"),emitter:{emit:ve.emit}}),[t.apiKey]),{blockchains:p,connectedWallets:u}=T(),d=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"),m=d.filter(w=>w.enabled).reduce((w,I)=>(w[I.name]=I,w),{}),y=d.filter(uB),S=i(w=>{let{supportedChains:I}=s(w);return jn(I)},"getSupportedChainNames"),C=e(),k={meta:{blockchains:m,evmBasedChains:y,evmNetworkChainInfo:pB(y),getSupportedChainNames:S},getSigners:o,wallets:f,providers:C,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:g,hubProvider:c},x=ne.use.isActiveTab();return dB.createElement(lB,{queuesDefs:[l],context:k,onPersistedDataLoaded:w=>{aB(w)},isPaused:!x},t.children)}i(fB,"QueueManager");var SC=fB;import{useManager as CB}from"@rango-dev/queue-manager-react";import TB,{createContext as kB,useContext as wB}from"react";function CC(){let{findToken:t}=T(),e=T().blockchains(),o=T().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:c}=H()();return i(p=>{let{fromBlockchain:u,fromToken:d,toBlockchain:f,toToken:h,requestAmount:g}=p,m={blockchains:e,tokens:o};if(u!==void 0){let y=e.find(S=>S.name===u)??null;n(y)}if(d!==void 0){let y=d?t(d)??null:null;r({meta:m,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:m,token:y})}g!==void 0&&c(g)},"updateQuoteInputs")}i(CC,"useUpdateQuoteInputs");import{cancelSwap as gB,getCurrentNamespaceOfOrNull as hB,getCurrentStep as yB,getRelatedWalletOrNull as SB}from"@rango-dev/queue-manager-rango-preset";var Ja=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return kt(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=Ii(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&gB(o)}getCurrentStepInfo(e){let o=yB(e);return{step:o,wallet:o?SB(e,o):null,network:o?hB(e,o)?.network:null}}};var TC=kB(void 0);function Pp(t){let{manager:e}=CB(),o=ne.use.isActiveTab(),n=H().use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:c}=T(),l=new Ja(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=T(),u=Iu(a()),d=T().blockchains(),f=T().tokens(),h=T().swappers(),g=T().fetchStatus,m=wo().resetLanguage,y=Ne().getNotifications(),S=Ne().clearNotifications,C=CC(),{fromBlockchain:k,toBlockchain:x,fromToken:w,toToken:I,inputAmount:A}=H()(),b={isActiveTab:o,setCurrentTabAsActive:Po.forceClaim,history:l,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async E=>c(E)},meta:{blockchains:d,tokens:f,swappers:h,loadingStatus:g,findToken:r},resetLanguage:m,notifications:{list:y,clearAll:S},quote:{quoteInputs:{fromBlockchain:k?.name??null,fromToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,toBlockchain:x?.name??null,toToken:I?{symbol:I.symbol,blockchain:I.blockchain,address:I.address}:null,requestAmount:A},updateQuoteInputs:C}};return TB.createElement(TC.Provider,{value:b},t.children)}i(Pp,"WidgetInfo");function kC(){let t=wB(TC);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(kC,"useWidget");function Un(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{fetchApiConfig:r}=hC(),{handleLoadCustomFont:a}=yC();return Dp(()=>{r().catch(console.log)},[]),Dp(()=>{n&&a(n)},[n]),xB(()=>{_u({API_KEY:o?.apiKey||Rp(),BASE_URL:o?.apiUrl||ou})},[o.apiKey,o.apiUrl]),Dp(()=>{t.config?.signers?.customSolanaRPC&&vB("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),_p.createElement(Ya,{config:o,onUpdateState:e},_p.createElement(SC,{apiKey:o.apiKey},_p.createElement(Pp,null,t.children)))}i(Un,"WidgetProvider");function wC(t){let e=t.config?.externalWallets;return Ra.createElement(bi,null,e?Ra.createElement(Jo,null):Ra.createElement(Un,{config:t.config??nn},Ra.createElement(Jo,null)))}i(wC,"Refuel");import es from"react";function vC(t){let e=t.config?.externalWallets;return es.createElement(bi,null,e?es.createElement(Jo,null):es.createElement(Un,{config:t.config??nn},es.createElement(Jo,null)))}i(vC,"Widget");function xC(){let{on:t,off:e}=ve;return{on:t,off:e}}i(xC,"useWidgetEvents");var pte={DerivationPath:rr,Namespaces:tr,Detached:nr,isOnDerivationPath:ar,isOnNamespace:ir,isOnDetached:Ao};export{Lee as EventSeverity,ln as MainEvents,Qee as Networks,Vee as PendingSwapNetworkStatus,hs as QuoteEventTypes,wC as Refuel,Pee as RouteEventType,as as SUPPORTED_FONTS,pte as StatefulConnect,_ee as StepEventType,Dee as StepExecutionBlockedEventStatus,$ee as StepExecutionEventStatus,bd as SwapModeContext,Re as UI_ID,Ss as UiEventTypes,ys as WalletEventTypes,zee as WalletEvents,qee as WalletTypes,vC as Widget,ln as WidgetEvents,Un as WidgetProvider,Ya as WidgetWallets,ul as customizedThemeTokens,rs as pickProviderVersionWithFallbackToLegacy,Oee as readAccountAddress,en as useStatefulConnect,bt as useWalletList,Xi as useWallets,kC as useWidget,xC as useWidgetEvents,BT as widgetEventEmitter};
3
3
  //# sourceMappingURL=index.js.map