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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- var xC=Object.defineProperty;var i=(t,e)=>xC(t,"name",{value:e,configurable:!0});import{EventSeverity as Iee,RouteEventType as Aee,StepEventType as Nee,StepExecutionBlockedEventStatus as Bee,StepExecutionEventStatus as Wee}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Lee}from"@rango-dev/wallets-core/legacy";import{useWallets as Yi,Events as _ee}from"@rango-dev/wallets-react";import{Networks as $ee,WalletTypes as Fee}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as Uee}from"rango-types";import{Divider as Gk}from"@rango-dev/ui";import po,{useEffect as Vk,useRef as Kk,useState as kd}from"react";import{WalletState as bC}from"@rango-dev/ui";import{useWallets as EC}from"@rango-dev/wallets-react";import{useReducer as IC}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}=EC(),[n,r]=IC(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===bC.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 FT}from"@rango-dev/wallets-react";import{detectMobileScreens as OT,KEPLR_COMPATIBLE_WALLETS as UT,WalletTypes as Jn}from"@rango-dev/wallets-shared";import{useCallback as zT,useEffect as HT}from"react";import LT,{createContext as PT,useContext as _T,useEffect as DT,useRef as $T}from"react";import{create as WT}from"zustand";import{persist as MT}from"zustand/middleware";import{allProviders as AC}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"}},NC={clientUrl:void 0},BC={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 AC(o).map(a=>a())}i(jp,"generateProviders");var Yp=i((t,e,o)=>{let n=jp({...nn,...t});return{config:{...nn,...t},iframe:NC,campaignMode:BC,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 VC}from"rango-sdk";import{UI_ID as WC}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",...WC};import{BlockchainCategories as FC,WalletState as lt}from"@rango-dev/ui";import{legacyReadAccountAddress as OC}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as UC,getCosmosExperimentalChainInfo as zC,isEvmAddress as HC,KEPLR_COMPATIBLE_WALLETS as PW,Networks as wu}from"@rango-dev/wallets-shared";import an from"bignumber.js";import{isCosmosBlockchain as QC}from"rango-types";import MC from"bignumber.js";var pe=new MC(0);import{WalletTypes as LC}from"@rango-dev/wallets-shared";var Bo="~",tu=[LC.LEAP];import{BlockchainCategories as ls,WalletState as $C}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===$C.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 Tu}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 ai(t){return/^0+(?:\.0+)?$/.test(t)}i(ai,"isZeroValue");function Su(t,e=2){let o=`^(?:0|[1-9]\\d*)(?:\\.\\d{1,${e}})?$`;return new RegExp(o).test(t)}i(Su,"isValidCurrencyFormat");function Cu(t){return/\d+$/.test(t)}i(Cu,"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 Tu(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Tu(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 ku(t){return ai(t)?"0":yu(t)}i(ku,"sanitizeInputAmount");function Kn(t,e){return GC(t,e)?lt.PARTIALLY_CONNECTED:e.connected?lt.CONNECTED:e.connecting?lt.CONNECTING:e.installed?lt.DISCONNECTED:lt.NOT_INSTALLED}i(Kn,"getWalletConnectionStatus");function vu(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:UC(c),state:m,type:r,showOnMobile:l,needsNamespace:p,blockchainTypes:g,needsDerivationPath:d,properties:f,isHub:h}})}i(vu,"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}=OC(l),d=c.length>0,f=c.includes(u),h=u===wu.Unknown;if(d&&!f&&!h)return;let m=u===wu.Unknown&&HC(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 xu=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 qC(e.toString())},"calculateWalletUsdValue");function qC(t){let e=t.toString().split(".");return e[0]&&(e[0]=gu(e[0])),e.join(".")}i(qC,"numberWithThousandSeparator");var pi=i((t,e)=>{let o=zC(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 bu(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(bu,"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 Eu(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(Eu,"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 Iu({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Iu,"getAddress");var Au=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Nu(t){return t.map(e=>e.state).join("-")}i(Nu,"hashWalletsState");function Bu(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(Bu,"filterBlockchainsByWalletTypes");function Wu(t,e){return e===FC.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(ii(n,e))return!0;return!1})}i(Wu,"filterWalletsByCategory");function GC(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(GC,"checkIsWalletPartiallyConnected");var ms={API_KEY:oi};function Gt(t){return ms[t]||""}i(Gt,"getConfig");function Mu(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ms=e,ms}i(Mu,"initConfig");var Lu=20,Pu=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"),_u=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var di,ct=i(()=>di||(di=new VC(Gt("API_KEY"),Gt("BASE_URL")),di),"httpService");import{i18n as $u}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 Du}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=Du.RouteEvent]="RouteEvent",a[a.StepEvent=Du.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 Fu(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Fu,"sortLiquiditySourcesByGroupTitle");function et(t,e){return e?.[t]==="hidden"}i(et,"isFeatureHidden");function cn(t,e){return e?.[t]==="enabled"}i(cn,"isRoutingEnabled");var Ou=i((t,e,o)=>et("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");function pn(t){return t==gi?{type:"error",message:$u.t("Slippage must be greater than or equal to 0.01")}:t>sn&&t<=Yn?{type:"warning",message:$u.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 Uu=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=Ou(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),N=o.getBalanceFor(m),b=bu(I,N);if(b!==0)return b}let C=l.get(g.blockchain),k=l.get(m.blockchain),x=as(g,C),v=as(m,k);if(x!==v)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(Fu)},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 KC,Catalonia as jC,Chinese as zu,Denmark as XC,English as YC,Finland as ZC,French as JC,German as RC,Greece as eT,Hungary as tT,India as oT,Indonesian as nT,Italian as rT,Japanese as iT,Korea as aT,Lithuania as sT,Malay as lT,Netherlands as cT,Pakistan as pT,Philippines as uT,Poland as dT,Portuguese as mT,Russian as fT,SaudiArabia as gT,Serbia as hT,Slovakia as yT,SouthAfrica as ST,Spanish as CT,Swahili as TT,Swedish as kT,Thai as wT,Turkish as vT,Ukrainian as xT,Vietnamese as bT}from"@rango-dev/ui";var Hu=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:ST},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:gT},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:KC},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:jC},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:zu},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:zu},{title:"Danish",label:"Dansk",local:"da",SVGFlag:XC},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:cT},{title:"English",label:"English",local:"en",SVGFlag:YC},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:uT},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:ZC},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:JC},{title:"German",label:"Deutsch",local:"de",SVGFlag:RC},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:eT},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:oT},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:tT},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:nT},{title:"Italian",label:"Italiana",local:"it",SVGFlag:rT},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:iT},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:aT},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:sT},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:lT},{title:"Polish",label:"Polski",local:"pl",SVGFlag:dT},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:mT},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:fT},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:hT},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:yT},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:CT},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:TT},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:kT},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:wT},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:vT},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:xT},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:pT},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:bT}],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 ET from"mitt";var ve=ET(),IT={on:ve.on,off:ve.off};var qu=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 Gu from"bignumber.js";function Vt(t){return`${t.blockchain}${Bo}${t.address}${Bo}${t.symbol}`}i(Vt,"createAssetKey");function Vu(t,e){return`${Vt(e)}${Bo}${t}`}i(Vu,"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 Gu(r??pe).multipliedBy(o[s].amount).toString():""})})}),o}i(ks,"computeNextBalancesWithNewPrices");function ws(t,e){let o={};return t.balances?.forEach(n=>{let r=Vu(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,c=n.price??e().findToken(n.asset)?.usdPrice,l=c?new Gu(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 AT(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(AT,"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=>Vu(d.address,{address:p.address,blockchain:d.chain,symbol:p.symbol})===l)?a=AT(a,l):s[l]&&(r[l]=s[l])}),{_balances:r,_aggregatedBalances:a}}i(xs,"computeNextStateAfterWalletBalanceRemoval");function NT(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(NT,"matchWalletDetailsWithConnectedWallet");var BT=uu(),Ku=qu((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:NT(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:()=>BT(()=>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 ju(t){return WT()(MT((...e)=>({...Ku(...e),...Uu(...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(ju,"createAppStore");var Xu=PT(null);function T(){let t=_T(Xu);if(DT(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(T,"useAppStore");function Yu(t){let e=$T();return e.current||(e.current=ju(t.config)),LT.createElement(Xu.Provider,{value:e.current},t.children)}i(Yu,"AppStoreProvider");function bt(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=T(),{state:r,getWalletInfo:a}=FT(),s=T().blockchains(),{handleDisconnect:c}=en(),l=Vp(n()),p=vu(r,a,l,e);p=OT()?p.filter(m=>m.showOnMobile!==!1&&r(m.type).installed):p;let u=Eu(p),d=i(m=>!o.find(y=>y.walletType===m&&y.chain===e),"isExperimentalChainNotAdded"),f=zT(()=>{let m=p?.filter(y=>y.state===Es.CONNECTING)||[];for(let y of m)c(y)},[Nu(p)]);HT(()=>()=>{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)&&!UT.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 VT}from"@rango-dev/ui";import KT from"react";import{create as GT}from"zustand";var Zu="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(Zu),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 qT=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=qT;var ne=co(GT()((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 KT.createElement(VT,{hasWatermark:e==="FULL",...t},t.children)}i(ee,"WatermarkedModal");import{i18n as fn}from"@lingui/core";import{Alert as sk,Button as lk,Divider as gn,Image as ck,MessageBox as pk,RadioRoot as uk,WalletImageContainer as dk}from"@rango-dev/ui";import le,{useEffect as mk,useMemo as fk,useState as gk}from"react";import{i18n as ZT}from"@lingui/core";import{Typography as id}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 jT,Image as XT,styled as Kt,Typography as YT}from"@rango-dev/ui";var Si=Kt("li",{backgroundColor:"$neutral200",padding:"$16",borderRadius:"$sm",variants:{clickable:{true:{cursor:"pointer"}},hasError:{true:{background:"$error100",[`.${jT} &`]:{backgroundColor:"$error700"}}},unsupported:{true:{cursor:"not-allowed",paddingTop:"$8",paddingBottom:"$8"}}}}),Ci=Kt("div",{display:"flex",gap:"$8",alignItems:"center"}),Ru=Kt("div",{flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between",height:"$40",variants:{showSupportedChains:{true:{justifyContent:"space-between"},false:{justifyContent:"center"}}}}),ed=Kt("div",{flex:"1",display:"flex",alignItems:"center",gap:"$4",opacity:"0.5"}),td=Kt("div",{display:"flex",gap:"$6",alignItems:"center"}),od=Kt("div",{paddingLeft:"48px"}),nd=Kt("div",{display:"flex",gap:"$2",cursor:"pointer",alignItems:"center",width:"fit-content"}),rd=Kt(YT,{maxWidth:"100px"}),Ti=Kt(XT,{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(ed,null,dn.createElement(id,{variant:"label",size:"large"},e.label),dn.createElement(id,{variant:"body",size:"xsmall"},ZT.t("(Currently not supported)")))))}i(ki,"NamespaceUnsupportedItem");import{Checkbox as rk,Radio as ik}from"@rango-dev/ui";import Bs from"react";import{i18n as Ns}from"@lingui/core";import{ChevronDownIcon as RT,ChevronUpIcon as ek,Divider as tk,Typography as er}from"@rango-dev/ui";import Ae,{useEffect as ok,useState as nk}from"react";import{Image as sd,Tooltip as ld,Typography as JT}from"@rango-dev/ui";import _t from"react";import{styled as ad}from"@rango-dev/ui";var Is=ad("div",{display:"flex",alignItems:"center",padding:0,margin:0}),wi=ad("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 cd(t){let{chains:e}=t;return _t.createElement(Is,{id:"widget-supported-chains-container"},e.slice(0,As).map((o,n)=>_t.createElement(ld,{key:o.name,container:B(),side:"bottom",align:"start",content:o.name,sideOffset:4},_t.createElement(wi,{firstItem:n===0},_t.createElement(sd,{src:o.logo,size:15})))),e.length>As&&_t.createElement(ld,{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(sd,{src:o.logo,size:15}))))},_t.createElement(wi,null,_t.createElement(JT,{variant:"body",size:"xsmall"},"+",e.length-As))))}i(cd,"SupportedChainsList");function _o(t){let{namespace:e,error:o,suffix:n,connected:r,address:a,onClick:s}=t,[c,l]=nk(!1),p=T().blockchains();ok(()=>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(Ru,{showSupportedChains:d||r||!!o},Ae.createElement(td,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(cd,{chains:u}),r&&Ae.createElement(rd,{variant:"body",size:"small",color:"neutral700"},a),o&&Ae.createElement(nd,{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(ek,{size:12,color:"gray"}):Ae.createElement(RT,{size:12,color:"gray"}))),n),!!o&&c&&Ae.createElement(Ae.Fragment,null,Ae.createElement(tk,{size:4}),Ae.createElement(od,null,Ae.createElement(er,{variant:"body",size:"small",color:"neutral700"},o))))}i(_o,"NamespaceItem");function pd(t){let{onClick:e,type:o,namespace:n}=t;return Bs.createElement(_o,{namespace:n,onClick:e,suffix:o==="radio"?Bs.createElement(ik,{value:n.value}):Bs.createElement(rk,{checked:t.value})})}i(pd,"NamespaceListItem");import{Button as ak,styled as ud}from"@rango-dev/ui";var vi=ud("ul",{padding:0,paddingBottom:"$20",margin:0}),mn=ud(ak,{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]=gk([]),u=fk(()=>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(uk,{value:l?.[0]},m):le.createElement(le.Fragment,null,m),"wrapRadioRoot");return mk(()=>{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(pk,{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(dk,null,le.createElement(ck,{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(sk,{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(lk,{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(pd,{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 wk,Button as vk,Divider as hn,Image as xk,MessageBox as bk,WalletImageContainer as Ek}from"@rango-dev/ui";import{useWallets as Ik}from"@rango-dev/wallets-react";import de from"react";import{styled as hk}from"@rango-dev/ui";var dd=hk("div",{display:"flex",justifyContent:"end"});import{i18n as Ws}from"@lingui/core";import{Button as yk,Spinner as Sk}from"@rango-dev/ui";import Ms,{useLayoutEffect as Ck,useRef as Tk,useState as kk}from"react";function md(t){let{namespace:e,initialConnect:o,disabled:n,state:r,handleConnect:a,handleDisconnect:s}=t,[c,l]=kk(null),p=Tk(!1);Ck(()=>{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(Sk,{color:"info"}):Ms.createElement(yk,{id:"widget-name-space-connect-btn",variant:"ghost",type:r.connected?"error":"primary",size:"xsmall",onClick:async()=>d(),disabled:n},h())})}i(md,"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}=Ik(),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,v)=>{m&&await p(d),g&&v?.shouldAskForDerivationPath?s(x):await l(d,[{namespace:x,network:"",derivationPath:v?.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(wk,{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(dd,null,de.createElement(vk,{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 v=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 N=m&&f.connecting;return de.createElement(md,{namespace:x,initialConnect:!!v,disabled:N,state:I,handleConnect:async b=>y(x.value,{derivationPath:v?.derivationPath,shouldAskForDerivationPath:b?.shouldAskForDerivationPath}),handleDisconnect:async()=>S(x.value)})},"renderNamespaceItem");return de.createElement(de.Fragment,null,de.createElement(bk,{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(Ek,null,de.createElement(xk,{src:c.image,size:45}))}),C(),de.createElement(vi,{id:"widget-detached-namespace-list"},c.needsNamespace?.data.map((x,v,I)=>de.createElement(de.Fragment,{key:x.id},k(x),v!==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 Wk,Image as Mk,MessageBox as Lk,Select as Pk,TextField as _k}from"@rango-dev/ui";import Et,{useEffect as Dk,useState as gd}from"react";import{namespaces as Ak}from"@rango-dev/wallets-shared";var xi={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Ls(t){let e=t?Ak[t]?.derivationPaths:null;return e?[...e,xi]:[]}i(Ls,"getDerivationPaths");import{Button as Nk,styled as Ps,Typography as Bk}from"@rango-dev/ui";var fd=Ps("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),_s=Ps(Bk,{paddingLeft:"$10"}),Ds={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"},a_=Ps(Nk,{minHeight:"$40"});var hd="0";function rr(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=gd(null),[c,l]=gd(hd),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(hd),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 Dk(()=>{s(Ls(o)[0]?.id||null)},[o]),Et.createElement(Et.Fragment,null,Et.createElement(Lk,{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(Mk,{src:n,size:45})}),Et.createElement(fd,{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(Pk,{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(Wk,{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(_k,{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 Ok,MessageBox as Fs,WalletImageContainer as Uk,WalletState as zk}from"@rango-dev/ui";import{useWallets as Hk}from"@rango-dev/wallets-react";import Do from"react";import{keyframes as $k,styled as $s}from"@rango-dev/ui";var y_=$s("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),yd=$s("div",{position:"relative"}),Fk=$k({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Sd=$s("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${Fk} 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}=Hk();return Kn(s(n),a(n))===zk.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(yd,null,Do.createElement(Uk,null,Do.createElement(Ok,{src:r,size:45})),Do.createElement(Sd,null))})}i(Os,"ConnectStatus");import{i18n as Us}from"@lingui/core";import{Button as Qk,Divider as Cd,MessageBox as qk}from"@rango-dev/ui";import bi from"react";function zs(t){let{displayName:e,onConfirm:o,id:n}=t;return bi.createElement(qk,{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(Cd,{size:18}),bi.createElement(Cd,{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 Td(t,e){return t().status==="init"&&!!e}i(Td,"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 jk=3e3,Xk=300;function sr(t){let e=Kk(),[o,n]=kd(!1),[r,a]=kd(),s=i(v=>{a(v.message)},"catchErrorOnHandle"),{terminateConnectingWallets:c}=bt(),{handleConnect:l,handleDerivationPath:p,handleNamespace:u,getState:d,resetState:f,handleDisconnect:h}=en(),g=i(v=>{u(t.wallet,v).then(k).catch(s)},"handleConfirmNamespaces"),m=i(()=>{S()},"handleDetachedConfirm"),y=i(v=>{if(!v)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");p(t.wallet,v).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((v,I)=>{let N=v.status==="connected",b=["disconnected","disconnected-unhandled"].includes(v.status);N?(t.onConnect?.(),I||(e.current=setTimeout(S,jk))):b&&S()},"afterConnected"),x=i(v=>{t.wallet?.needsDerivationPath&&u(t.wallet,[v])},"handleNavigateToDerivationPath");return Vk(()=>{if(t.wallet){C();let v=!1,I=!0;i(()=>{setTimeout(()=>{I=!1,v||n(!0)},Xk)},"beforeConnecting")(),l(t.wallet,{disconnectIfConnected:!0,defaultSelectedChains:t.options?.defaultSelectedChains}).then(b=>{["namespace","Detached","derivation-path"].includes(b.status)||(v=!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()},Td(d,t.wallet)&&po.createElement(po.Fragment,null,po.createElement(Os,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),po.createElement(Gk,{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 Yk,{Fragment as Zk}from"react";import{MemoryRouter as Jk,useInRouterContext as Rk}from"react-router";function Ei({children:t}){let o=Rk()?Zk:Jk;return Yk.createElement(o,null,t)}i(Ei,"AppRouter");import{I18nManager as eB}from"@rango-dev/ui";import Pp from"react";import Ue from"react";import{useRoutes as M0}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 em}from"zustand";import{subscribeWithSelector as tm}from"zustand/middleware";import{createContext as ew,useContext as tw}from"react";var wd=ew({swapMode:"swap",isMultiMode:!1});function tt(){let{swapMode:t,isMultiMode:e}=tw(wd);return{swapMode:t,isMultiMode:e}}i(tt,"useSwapMode");import{i18n as Tt}from"@lingui/core";import{getRelatedWalletOrNull as rw,RouteEventType as PD}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 vd(t){return t.type===0?t.diagnosisMessage??re().noResultError.title:t.type===1?t.diagnosisMessage??re().genericServerError:""}i(vd,"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"],xd=100,bd=30,Ed=15,Id=60;var Ad=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Nd=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as nw}from"@rango-dev/queue-manager-rango-preset";import TD from"bignumber.js";function Wd(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(Wd,"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=nw(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&&Dd(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&&Od(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(Fd(t.userSlippage.toString(),c)){if(l&&parseFloat(c??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:$d(o,r),minRequiredSlippage:c};return null}i(Cn,"generateQuoteWarnings");function Md(t){return![4].includes(t.type)}i(Md,"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 Ld=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"),Pd=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"),_d=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 Dd(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Ad.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new He(r)))}i(Dd,"hasHighValueLoss");function Ud(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(Ud,"hasLimitError");function zd(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(zd,"getLimitErrorMessage");function Hd(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(Hd,"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 qd(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(qd,"getFeesGroup");function Gd(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(Gd,"checkSlippageErrors");function $d(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($d,"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 Fd(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(Fd,"hasProperSlippage");function Vd(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(Vd,"createQuoteRequestBody");function Kd(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType,derivationPath:n.derivationPath},o),{})}i(Kd,"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(xd).toNumber()}i(qs,"getPercentageChange");function Od(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 Nd.some(({threshold:s,minInput:c})=>a<=s&&o.isGreaterThanOrEqualTo(c))}i(Od,"isOutputAmountChangedExcessively");function jd(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=>Wd(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(jd,"generateBalanceWarnings");function pr(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==cr.NetworkChanged}i(pr,"isNetworkStatusInWarningState");function Xd(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?rw(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(Xd,"getSwapMessages");function Yd(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(Yd,"getLastConvertedTokenInFailedSwap");function Zd(t){return t.status==="failed"}i(Zd,"shouldRetrySwap");function Jd(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(Jd,"isConfirmSwapDisabled");function Rd(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(Rd,"isTokensIdentical");var Mi=i((t,e)=>t?.usdPrice?new ot(e||pe).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),om=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=ku(e);t(()=>({inputAmount:o}))},setInputAmount:e=>{let o=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"),nm=em()(tm(om)),rm=em()(tm(om)),iw=co(nm),aw=co(rm);function H(){let{swapMode:t}=tt();return co(t==="refuel"?rm:nm)}i(H,"useQuoteStore");var im=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"),am=iw.subscribe(im),sm=aw.subscribe(im);function lm(){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,v=Li(void 0),I=Li(void 0),N=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),w=u?.from?.token,A=w&&h(w);(E||!E&&N.current)&&n(E??null),A?a({token:A,meta:{blockchains:f}}):!A&&v.current&&a({token:null}),N.current=u?.from?.blockchain,v.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),w=u?.to?.token,A=w&&h(w);(E||!E&&b.current)&&o(E??null),A?e({token:A,meta:{blockchains:f}}):!A&&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(lm,"useSyncStoresWithConfig");import{useEffect as Ys,useRef as sw}from"react";import{useInRouterContext as lw,useLocation as cw,useSearchParams as pw}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=cw(),[e,o]=pw(),{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=lw(),{updateIframe:y,updateCampaignMode:S}=T(),C=T().isInCampaignMode(),k=sw(),{findToken:x}=T(),v=i(()=>{let N={};for(let[W,J]of e.entries())(W.startsWith("utm_")||W.startsWith("privy_"))&&(N[W]=J);let b=e.get("fromAmount"),E=e.get("fromBlockchain"),w=e.get("fromToken"),A=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:w,toBlockchain:A,toToken:M,autoConnect:P,clientUrl:U,liquiditySources:Q,extraQueryParams:N,blockchain:Z}},"getUrlSearchParams"),I=i(N=>{for(let b in N)N[b]||delete N[b];o(N,{replace:!0})},"updateUrlSearchParams");Ys(()=>{let{autoConnect:N,clientUrl:b,extraQueryParams:E,blockchain:w}=v();m&&h==="success"&&I({fromBlockchain:n?.name,fromToken:Xs(a),toBlockchain:r?.name,toToken:Xs(s),fromAmount:c,autoConnect:N??void 0,clientUrl:b??void 0,blockchain:w??void 0,liquiditySources:C?k.current:void 0,...E})},[t.pathname,c,n,a,r,s,C,h]),Ys(()=>{if(!m)return;let N=v();if(!k.current&&N.liquiditySources&&(k.current=N.liquiditySources),N.fromAmount&&f(N.fromAmount),h==="success"){let b=g.find(U=>U.name===N.fromBlockchain),E=N.fromToken&&b&&js(N.fromToken,b),w=E?x(E):void 0,A=g.find(U=>U.name===N.toBlockchain),M=N.toToken&&A&&js(N.toToken,A),P=M?x(M):void 0;b&&(l(b),w&&u({token:w,meta:{blockchains:g}})),A&&(p(A),P&&d({token:P,meta:{blockchains:g}}))}},[h]),Ys(()=>{let{clientUrl:N,liquiditySources:b}=v();y("clientUrl",N||void 0),S("liquiditySources",b?.split(",")??void 0)},[])}i(Js,"useSyncUrlAndStore");import{i18n as vn}from"@lingui/core";import{Alert as Wv,Button as Mv,darkTheme as Lv,Divider as Al,DoneIcon as Pv,styled as _v,TextField as Dv,Typography as $v}from"@rango-dev/ui";import qe,{useState as Fv}from"react";import{useNavigate as Ov,useSearchParams as Uv}from"react-router-dom";import{ChevronRightIcon as uw,Divider as mm,Image as dw,Typography as fm}from"@rango-dev/ui";import It from"react";import{darkTheme as cm,styled as Rs}from"@rango-dev/ui";var pm=Rs("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${cm} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${cm} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),um=Rs("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),dm=Rs("div",{display:"flex"});function el(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return It.createElement(um,null,It.createElement(fm,{size:"large",variant:"label"},n),It.createElement(mm,{size:10}),It.createElement(pm,{onClick:s?void 0:e,disabled:s,id:"widget-blockchain-selector-container"},It.createElement(dm,null,r&&It.createElement(It.Fragment,null,It.createElement(dw,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),It.createElement(mm,{size:4,direction:"horizontal"})),It.createElement(fm,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),It.createElement(uw,{size:12,color:"black"})))}i(el,"BlockchainSelectorButton");import{i18n as rl}from"@lingui/core";import{Button as Tw,Divider as Tm,MessageBox as kw}from"@rango-dev/ui";import uo,{useEffect as km,useState as il}from"react";import{i18n as Pi}from"@lingui/core";import{Divider as Fo,ExternalLinkIcon as gw,Image as hw,InfoIcon as yw,Tooltip as Sw,Typography as dr}from"@rango-dev/ui";import me from"react";var gm="https://blog.rango.exchange/understanding-the-risks-of-using-custom-token-contract-addresses-96022308eca4";function hm(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(hm,"generateExplorerLink");import{Button as mw,darkTheme as kn,styled as ur,Typography as fw}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:{}}}}),ym=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(mw,{minHeight:"$40"}),Sm=ur(fw,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"96px"}),Cm=ur("div",{display:"flex",justifyContent:"center",alignItems:"center"});var Cw=9;function nl(t){let{open:e,onClose:o,token:n,onExit:r,onSubmitClick:a,blockchain:s}=t,c=hm(n.address,s),l=i(()=>window.open(gm,"_blank"),"onClickLearnMore");return me.createElement(ee,{open:e,id:"widget-custom-token-watermarked-modal",dismissible:!0,onClose:o,onExit:r,container:B()},me.createElement(ym,null,me.createElement(hw,{src:n.image===""?ti:n.image,size:45,type:"circular"}),me.createElement(Fo,{size:4}),me.createElement(Cm,null,me.createElement(Sm,{variant:"title",size:"medium"},n.symbol),n.symbol.length>Cw&&me.createElement(Sw,{content:n.symbol,container:B()},me.createElement(yw,{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(gw,{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"),v=i(()=>{e&&(u(e),c())},"handleSubmit");return km(()=>{n&&f(!0)},[n]),km(()=>{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(kw,{title:n?.title??"",type:"error",description:n?.message||rl.t("Failed Network, Please retry.")},uo.createElement(Tm,{size:40}),uo.createElement(Tm,{size:10}),uo.createElement(Tw,{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:v,onClose:()=>g(!1),open:h,onExit:p}))}i(mr,"ImportCustomToken");import{useManager as bv}from"@rango-dev/queue-manager-react";import{BottomLogo as Ev,Divider as tf,Header as Iv}from"@rango-dev/ui";import Be,{useEffect as qi,useLayoutEffect as Av,useRef as of,useState as nf}from"react";import{useRef as ww}from"react";function _i(){return window.self!==window.top}i(_i,"isAppLoadedIntoIframe");function al(){let t=ww(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 vw}from"react-router-dom";function Qe(){let t=vw();return()=>t(-1)}i(Qe,"useNavigateBack");import{createTheme as ml,darkTheme as Dw,lightTheme as $w}from"@rango-dev/ui";import{useEffect as Fw,useState as Ow}from"react";import{theme as Pw,darkColors as _w}from"@rango-dev/ui";import ul from"react";var Di=16,$i=255,wm=.11;function xw(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(xw,"expandShortHexColor");function bw(t,e){return t.padStart(e,"0")}i(bw,"pad");function sl(t){let e=Math.min(Math.max(Math.round(t),0),$i);return bw(e.toString(Di),2)}i(sl,"intToHex");function Ew(t){return`#${sl(t.red)}${sl(t.green)}${sl(t.blue)}`}i(Ew,"rgbToHex");function Iw(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(Iw,"hexToRGB");function Aw(t,e){let o=1-wm*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(Aw,"generateShade");function Nw(t,e){let o=wm*e;return{red:t.red+($i-t.red)*o,green:t.green+($i-t.green)*o,blue:t.blue+($i-t.blue)*o}}i(Nw,"generateTint");function Bw(t){return vm(t,Aw)}i(Bw,"calculateShades");function Ww(t){return vm(t,Nw)}i(Ww,"calculateTints");function vm(t,e){let o=Iw(t),n=[];for(let r=1;r<9;r++)n.push(Ew(e(o,r)));return n}i(vm,"calculateColors");function ll(t,e,o){let a=Ww(t).reverse().concat(t),s=Bw(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)&&!Cu(r)){let l=xw(a);Object.assign(n,ll(l,r,s))}}return{...n,...e}}i(cl,"expandToGenerateThemeColors");var xm=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),Mw=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=xm(o%52)+e;return xm(o%52)+e},"toAlphabeticName"),Lw=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),pl=i(t=>Mw(Lw(5381,JSON.stringify(t))>>>0),"toHash");function dl(t){let e=Pw.colors,o={...e,..._w},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 bm(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(bm,"joinList");function Em(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Em,"doesWindowPreferDarkColorScheme");function mo(t){let{colors:e,fontFamily:o=ou,borderRadius:n=Lu,secondaryBorderRadius:r=Pu}=t,[a,s]=Ow(Em()?"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,$w.className],f=[u.className,Dw.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 Fw(()=>{let g=i(m=>{m.matches?s("dark"):s("light")},"switchThemeListener");return Em()&&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 Im}from"@lingui/core";import{Alert as Uw,Button as zw}from"@rango-dev/ui";import Am from"react";function fl(t){return Am.createElement(Uw,{action:Am.createElement(zw,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Im.t("Activate this tab")),type:"warning",variant:"alarm",title:Im.t("Another tab is open and handles transactions.")})}i(fl,"ActivateTabAlert");import{i18n as gl}from"@lingui/core";import{Button as Hw,Divider as Qw,MessageBox as qw}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(qw,{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(Hw,{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 Kw}from"@rango-dev/ui";import Dm from"react";import{css as Gw,darkTheme as Nm,IconButton as Vw,styled as Oo}from"@rango-dev/ui";var Dt=Oo(Vw,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${Nm} &`]:{backgroundColor:"$neutral"}}}),Bm=Oo("div",{position:"absolute",background:"$secondary500",[`.${Nm} &`]:{$$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}}),Wm=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"}}}}),Mm=Oo("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Lm=Oo("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),Pm=Gw({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),_m=Oo("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});function yl(t){return Dm.createElement(Dt,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Dm.createElement(Kw,{color:"black",size:16}))}i(yl,"BackButton");import{i18n as jw}from"@lingui/core";import{Button as Xw,Typography as Yw}from"@rango-dev/ui";import Sl from"react";function Cl(t){return Sl.createElement(fo,null,Sl.createElement(Xw,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},Sl.createElement(Yw,{variant:"label",size:"medium",color:"error500"},jw.t("Cancel"))))}i(Cl,"CancelButton");import{i18n as Zw}from"@lingui/core";import{Image as Jw,Tooltip as Rw,WalletIcon as ev,WalletState as $m}from"@rango-dev/ui";import Uo from"react";function Tl(t){let{list:e}=bt(),o=e.filter(r=>r.state===$m.CONNECTED||r.state===$m.PARTIALLY_CONNECTED),n=o.length?Uo.createElement("div",{className:Pm()},o.map(r=>Uo.createElement(_m,{key:r.title},Uo.createElement(Jw,{src:r.image,size:14})))):Zw.t("Connect Wallet");return Uo.createElement(Rw,{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(Bm,null),Uo.createElement(ev,{size:18,color:"black"})))}i(Tl,"WalletButton");import{i18n as Ui}from"@lingui/core";import{NotificationsIcon as hv,Popover as yv,SettingsIcon as Sv,Tooltip as zi,TransactionIcon as Cv}from"@rango-dev/ui";import Le from"react";import{Notifications as rv}from"@rango-dev/ui";import iv from"react";import{useNavigate as av}from"react-router-dom";import{create as tv}from"zustand";import{persist as ov,subscribeWithSelector as nv}from"zustand/middleware";var Ne=co(tv()(ov(nv((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=av(),{getNotifications:e,clearNotifications:o}=Ne(),n=e(),r=T().blockchains(),{findToken:a}=T();return iv.createElement(rv,{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 sv}from"@rango-dev/queue-manager-react";import{InProgressIcon as lv}from"@rango-dev/ui";import Fm from"react";var cv=i(()=>{let{manager:t}=sv();return kt(t).map(({swap:o})=>o).find(o=>o.status==="running")?Fm.createElement(Lm,{id:"widget-header-history-badge-container"},Fm.createElement(lv,{color:"info",size:6})):null},"InProgressTransactionBadge"),Om=cv;import{EventSeverity as pv}from"@rango-dev/queue-manager-rango-preset";import{Typography as uv}from"@rango-dev/ui";import Um from"react";function zm(){let{getNotifications:t}=Ne(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===pv.WARNING);return o?Um.createElement(Wm,{isSever:n},Um.createElement(uv,{variant:"body",size:"xsmall",color:"$background",id:"widget-header-notifications-badge-container"},o)):null}i(zm,"NotificationsBadge");import{RefreshProgressButton as dv}from"@rango-dev/ui";import wl,{useEffect as mv,useState as Hm}from"react";var fv=1e3,Qm=60,gv=100;function Oi({onClick:t}){let[e,o]=Hm(0),[n,r]=Hm(!1),a=i(l=>{document.hidden&&l&&s(l)},"handleVisibilityChange");mv(()=>{let l;return t?l=window.setInterval(()=>{o(p=>p+1),e===Qm&&c()},fv):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(Mm,{onTransitionEnd:()=>r(!1),isRefetched:n},wl.createElement(dv,{size:22,color:t?"black":"gray",progress:e/Qm*gv})))}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(yv,{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(hv,{size:18,color:"black"}),Le.createElement(zm,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(Sv,{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(Cv,{size:18,color:"black"}),Le.createElement(Om,null))))}i(zo,"HeaderButtons");import{i18n as vl}from"@lingui/core";import{Divider as Gm,MessageBox as wv,RefreshIcon as vv}from"@rango-dev/ui";import wn from"react";import{Button as Tv,styled as kv}from"@rango-dev/ui";var qm=kv(Tv,{"& 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(wv,{title:vl.t("Something went wrong"),type:"error",description:vl.t("Something went wrong. Please refresh the app.")},wn.createElement(Gm,{size:30}),wn.createElement(qm,{variant:"outlined",id:"widget-refresh-modal-refresh-btn",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},wn.createElement(vv,{size:20,color:"primary"}),wn.createElement(Gm,{size:4,direction:"horizontal"}),vl.t("Refresh"))))}i(xl,"RefreshModal");var Vm="700px",Km="425px",jm="550px",Xm="640px",Ym="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 xv,styled as Hi}from"@rango-dev/ui";var Qi=xv({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Zm=Hi("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",maxHeight:Vm,variants:{height:{auto:{height:"auto"},fixed:{height:"100%",minHeight:Km,[`@media screen and (min-height: ${Ym})`]:{minHeight:jm}}},showBanner:{true:{overflow:"visible"}}}}),Jm=Hi("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Rm=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"}}}),ef=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]=nf(!1),{config:{features:f,theme:h}}=T(),{watermark:g}=ne(),m=g==="FULL",{activeTheme:y}=mo(h||{}),[S,C]=nf(!1),k=et("connectWalletButton",f),{isActiveTab:x,tabManagerInitiated:v,showActivateTabModal:I,setShowActivateTabModal:N,activateCurrentTab:b,setShowCompactTokenSelector:E}=ne(),w=Qe(),{manager:A}=bv(),P=kt(A).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=of(null),J=of(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]),Av(()=>{if(!J.current)return;let X=new ResizeObserver(ae=>{for(let Se of ae)Se.contentRect&&E(Se.contentRect.height<parseInt(Xm))});return X.observe(J.current),()=>X.disconnect()},[]),Be.createElement(Zm,{height:s,id:Re.SWAP_BOX_ID,className:`${y()} ${Qi()}`,ref:J,showBanner:S},Be.createElement(Iv,{prefix:Z?Be.createElement(yl,{onClick:()=>{w(),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(Jm,{ref:W},n),Be.createElement(hl,{open:I,onClose:()=>N(!1),onConfirm:U}),Be.createElement(Rm,null,Be.createElement("div",{className:"footer__content"},v&&!x&&Be.createElement("div",{className:"footer__alert"},Be.createElement(fl,{onActivateTab:U}),Be.createElement(tf,{size:10})),a),Be.createElement(tf,{size:12}),Be.createElement("div",{className:`footer__logo ${m?"logo__show":"logo__hidden"}`},Be.createElement(Ev,null))),S&&Be.createElement(ef,null,p?.swapBoxBanner?.element),Be.createElement(xl,{open:u,onClose:()=>d(!1)}))}i(se,"Layout");import{styled as Nv}from"@rango-dev/ui";var rf="$20 $20 $10 $20",El=Nv("div",{padding:rf,overflowY:"auto",flexGrow:1});import{styled as Bv}from"@rango-dev/ui";var ce=Bv("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 af(){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(af,"useFetchCustomToken");var zv=_v("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $12",backgroundColor:"$neutral300","& input":{padding:"0"},[`.${Lv} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}});function sf(){let t=Ov(),[e]=Uv(),o=Qe(),n=T().blockchains(),r=e.get("blockchain")||"",a=No(r,n),[s,c]=Fv(""),{fetchCustomToken:l,token:p,loading:u,error:d,resetState:f}=af(),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(zv,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($v,{size:"large",variant:"label"},vn.t("Enter Address")),qe.createElement(Al,{size:10}),qe.createElement(Dv,{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(Pv,{color:"success",size:12}),onChange:y=>c(y.target.value)}),!h&&!!s&&qe.createElement(qe.Fragment,null,qe.createElement(Al,{size:4}),qe.createElement(Wv,{id:"widget-add-custom-token-invalid-address-alert",type:"error",variant:"alarm",title:"Invalid Address"}))),qe.createElement(Mv,{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(sf,"AddCustomTokenPage");import{i18n as cc}from"@lingui/core";import{useManager as Wb}from"@rango-dev/queue-manager-react";import{Alert as Mb,Button as Lb,css as uc,Divider as pc,IconButton as Rg,styled as Pb,Typography as _b,WalletIcon as Db}from"@rango-dev/ui";import De,{useEffect as Sa,useLayoutEffect as $b,useRef as Fb,useState as br}from"react";import{useNavigate as Ob}from"react-router-dom";import{i18n as Ho}from"@lingui/core";import{Alert as mx,BalanceErrors as fx,Button as Lf,ChevronLeftIcon as gx,Divider as Dl,MessageBox as hx,Typography as $l}from"@rango-dev/ui";import ie,{useCallback as yx,useEffect as Pf,useMemo as Sx,useState as In}from"react";import{useNavigate as Cx}from"react-router-dom";import{i18n as Ml}from"@lingui/core";import{Alert as Vv,ChevronDownIcon as Kv,CloseIcon as jv,Divider as ff,IconButton as gf,PasteIcon as Xv,Typography as Yv,WalletIcon as Zv}from"@rango-dev/ui";import Pe,{useEffect as Jv,useRef as Rv}from"react";import ji,{useRef as qv}from"react";import*as xn from"@radix-ui/react-collapsible";import{keyframes as lf,styled as Gi}from"@rango-dev/ui";var Nl=300,Hv=lf({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Qv=lf({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),cf=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:`${Hv} ${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=qv(null);return ji.createElement(cf,{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 pf,styled as Wl,TextField as Gv}from"@rango-dev/ui";var uf=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"}}),df=Wl(Gv,{backgroundColor:"$neutral100"}),mf=Wl("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${pf} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${pf} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function hf(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=Rv(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(gf,{id:"widget-custom-destination-close-icon-btn",onClick:g,variant:"ghost"},Pe.createElement(jv,{size:12,color:"gray"})):d?null:Pe.createElement(gf,{id:"widget-custom-destination-paste-icon-btn",onClick:m,variant:"ghost"},Pe.createElement(Xv,{size:16})),"renderSuffix");return Jv(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),Pe.createElement(uf,null,Pe.createElement(Xi,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Pe.createElement(mf,{id:"widget-custom-destination-collapsible-btn"},Pe.createElement("div",{className:"button__content"},Pe.createElement(Zv,{size:18,color:"info"}),Pe.createElement(ff,{size:4,direction:"horizontal"}),Pe.createElement(Yv,{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(Kv,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Pe.createElement(df,{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(ff,{size:4}),Pe.createElement(Vv,{variant:"alarm",type:"error",title:Ml.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(hf,"CustomDestination");import{css as ex,IconButton as tx,SelectableWalletButton as ox,styled as ho}from"@rango-dev/ui";var yf=ho("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),Sf=ho("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Cf=ho(ox,{justifyContent:"center"}),Tf=ho("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),kf=ho(tx,{position:"absolute",left:"$20"}),wf=ho("div",{paddingTop:"$20"}),vf=ex({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),xf=ho("div",{display:"flex"}),bf=ho("div",{overflow:"visible",width:"100%"});import{i18n as Pl}from"@lingui/core";import{warn as sx}from"@rango-dev/logging-core";import{Divider as lx,makeInfo as cx,SelectableWallet as px,Typography as Wf,WalletState as En}from"@rango-dev/ui";import nt,{useEffect as Mf,useState as gr}from"react";import{Image as ix,MessageBox as ax}from"@rango-dev/ui";import fr from"react";import{keyframes as nx,styled as Ll}from"@rango-dev/ui";var Ef=Ll("div",{position:"relative"}),rx=nx({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),If=Ll("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${rx} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Af=Ll("div",{"& img":{borderRadius:"50%"}});import{i18n as bn}from"@lingui/core";function Nf(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(Nf,"generateMessageByStatus");function Bf(t){let{status:e,displayName:o,image:n}=t,r=Nf(e,o),a=e=="in-progress";return fr.createElement(ax,{type:r.type,title:r.title,description:r.description,icon:a?fr.createElement(Ef,null,fr.createElement(Af,null,fr.createElement(ix,{src:n,size:45})),fr.createElement(If,null)):void 0})}i(Bf,"ExperimentalChainStatus");var ux=7,dx=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,v]=gr(k),I=k.length,N=a&&I-a>0,b=i(async w=>{m(!1),S("in-progress");try{let A=k.find(Q=>Q.type===Q.type),M=A?.isHub?A.properties?.find(Q=>Q.name==="namespaces")?.value:A?.needsNamespace,P=l(),U=M?.data.find(Q=>Q.getSupportedChains(P).some(Z=>Z.name===w.chain));if(!U)throw new Error("Requested chain is not supported");await C(w.walletType,{namespace:U.value,network:w.chain}),S("completed")}catch{S("rejected")}},"addExperimentalChain");Mf(()=>{v(w=>{let A=k.findIndex(M=>n(M.type,e));return N&&A>1?[k[A]].concat(k.filter((M,P)=>P!==A)):w.map(M=>k.find(P=>P.type===M.type)??M)})},[JSON.stringify(k)]);let E=document.getElementById(Re.SWAP_BOX_ID);return Mf(()=>{let w=null;return(y==="completed"||y==="rejected")&&(w=setTimeout(()=>S(null),dx)),()=>{w&&clearTimeout(w)}},[y]),nt.createElement(nt.Fragment,null,x.slice(0,a).map(w=>{let A=Iu({connectedWallets:p,walletType:w.type,chain:e}),M=w.state===En.CONNECTED||w.state===En.PARTIALLY_CONNECTED,P=A?lo(A,ux):"",U=M&&!!w.needsNamespace&&!P,Q=pi(l(),e),Z=!p.find(ue=>ue.walletType===w.type&&ue.chain===e),W=Q&&Z&&w.state===En.CONNECTED,J=i(async()=>{w.state===En.DISCONNECTED||U&&!W?d(w):W?(h({walletType:w.type,chain:e,address:A??""}),m(!0)):r({walletType:w.type,chain:e,address:A??""})},"onSelectableWalletClick"),X=cx(w.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(()=>w.state===En.CONNECTED||w.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:`${w.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(Bf,{status:y,displayName:at,image:w.image}),nt.createElement(lx,{direction:"vertical",size:32})),nt.createElement(px,{key:w.type,id:"widget-wallets-list-selectable-wallet-btn",description:ae(),descriptionColor:Se(),onClick:J,selected:n(w.type,e),disabled:!c,...w}))}),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):sx(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),N&&nt.createElement(Cf,{selected:!1,onClick:s,id:"widget-wallets-list-show-more-wallets-btn"},nt.createElement(Wf,{variant:"label",size:"medium"},Pl.t("Show more wallets"),nt.createElement(Wf,{variant:"label",size:"medium",color:"$primary"},"\xA0+",I-(a??0)))))}i(_l,"WalletList");var Tx=2;function _f(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=Cx(),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([]),[v,I]=In(""),[N,b]=In(!!f),E=Sx(()=>Mo({filter:"all",quote:l}),[l]),w=Mo({filter:"required",quote:l}),A=c.find(O=>O.name===l?.swaps[l?.swaps.length-1]?.to.blockchain),M=i(O=>w.includes(O),"isWalletRequiredFor"),P=yx(()=>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(A?.name??"")||Q(z=>Se(z,A?.name||"",!1)):(h(""),Q(z=>Se(z,A?.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===A?.name&&N&&!M(A.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(vd(O.error)),!O.error&&!z?.balance?.messages.length?gt():x(z?.balance?.messages??[])},"onConfirmWallets");Pf(()=>{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]),Pf(()=>{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(xf,null,ie.createElement(Lf,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:Jd(a,N,f,l,U,A),onClick:vt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},Ho.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:ie.createElement(Tf,null,ie.createElement(kf,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:C.bind(null,"")},ie.createElement(gx,{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(hx,{title:Ho.t("Insufficient account balance"),type:"error",description:ie.createElement(fx,{messages:k??[]})},ie.createElement(Lf,{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(wf,null,ie.createElement("div",{className:vf()},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,v&&ie.createElement(ie.Fragment,null,ie.createElement(mx,{id:"widget-confirm-wallet-modal-error-alert",variant:"alarm",type:"error",title:Ho.t(v)}),ie.createElement(Dl,{size:12})),ie.createElement(bf,null,E.map((O,z)=>{let Y=c.find(Ve=>Ve.name===O),te=`wallet-${z}`,j=z===E.length-1,G=j&&A&&g?.customDestination!==!1;return ie.createElement("div",{key:te},ie.createElement(yf,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(Sf,null,ie.createElement(_l,{chain:O,quoteChains:E,isSelected:ae,selectWallet:ue,limit:Tx,onShowMore:()=>C(Y?.name??""),onConnect:Ve=>{J(O,Ve)}})),!j&&ie.createElement(Dl,{size:32}),G&&ie.createElement(hf,{blockchain:A,open:N,handleOpenChange:at}))}))))}i(_f,"ConfirmWalletsModal");import{i18n as Vx}from"@lingui/core";import{Alert as Kx,Button as jx,Divider as tg,InfoIcon as Xx}from"@rango-dev/ui";import Fe from"react";import{Alert as vx,Button as xx,Divider as Ul,NoRouteIcon as bx,RefreshIcon as Ex,Typography as Hf}from"@rango-dev/ui";import pt from"react";import{i18n as Df}from"@lingui/core";var kx=24,wx=60;function $f(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:re().genericServerError,action:{onClick:n,title:Df.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:re().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Df.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($f,"makeInfo");var Fl=(o=>(o[o.small=kx]="small",o[o.large=wx]="large",o))(Fl||{}),Ol=(o=>(o.small="small",o.large="medium",o))(Ol||{});import{styled as Zi}from"@rango-dev/ui";var Ff=Zi("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Of=Zi("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Uf=Zi("div",{variants:{size:{small:{width:"100%"},large:{}}}}),zf=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=$f(o,a,()=>s(c,!0),e);return r&&(l.alert=null),pt.createElement(Ff,{id:"widget-no-result-container"},pt.createElement(bx,{size:Fl[n],color:"gray"}),pt.createElement(Ul,{size:4}),pt.createElement(Hf,{variant:"title",size:Ol[n]},re().noResultError.title),n==="large"&&pt.createElement(Ul,{size:4}),!!l.description&&pt.createElement(Of,{size:n},pt.createElement(Hf,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),pt.createElement(Ul,{size:n==="large"?"24":"4"}),!!l.alert&&pt.createElement(Uf,{size:n},pt.createElement(vx,{id:"widget-no-result-alert",type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&pt.createElement(xx,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:pt.createElement(zf,null,pt.createElement(Ex,{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 Px,Divider as _x,MessageBox as Dx,Typography as $x,WarningIcon as Fx}from"@rango-dev/ui";import Yt from"react";import{InfoIcon as Bx,Tooltip as Wx,Typography as Mx}from"@rango-dev/ui";import An from"react";import{Button as Ix,darkTheme as Ax,styled as Qo,Typography as Nx}from"@rango-dev/ui";var Qf=Qo("div",{width:"100%"}),zl=Qo("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),qf=Qo("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${Ax} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Gf=Qo("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$2"}),Vf=Qo(Nx,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"250px"}),Kf=Qo("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"}),jf=Qo(Ix,{"& ._text":{gap:"$5",display:"flex",alignItems:"center",justifyContent:"center"}});var Lx=35;function Xf(t){let{title:e,value:o,valueColor:n}=t,r=B();return An.createElement(qf,null,An.createElement(Mx,{size:"medium",variant:"label",className:"_title"},e),An.createElement(Gf,null,An.createElement(Vf,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`),o.length>Lx&&An.createElement(Wx,{content:o,container:r},An.createElement(Bx,{size:12,color:"gray"}))))}i(Xf,"QuoteErrorsModalItem");function Yf(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(Px,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Yt.createElement(Fx,null),fullWidth:!0,disabled:a,onClick:n},re().highValueLossError.confirmMessage),open:e,onClose:o,container:B()},Yt.createElement(Dx,{type:s,title:re().highValueLossError.impactTitle,description:re().highValueLossError.description}),Yt.createElement(zl,null,Yt.createElement(_x,{size:"4"}),Yt.createElement($x,{size:"small",variant:"title"},yr.t("Details")),Yt.createElement(zl,null,c.map((l,p)=>Yt.createElement(Xf,{key:p,...l})))))}i(Yf,"HighValueLossWarningModal");import{i18n as Nn}from"@lingui/core";function Zf(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(Zf,"makeAlerts");function Jf(t,e){return e?.type===4?Number(e.minRequiredSlippage):t?.type===2?Number(t.minRequiredSlippage):null}i(Jf,"getRequiredSlippage");import{i18n as Bn}from"@lingui/core";import{Button as Ox,Divider as Hl,MessageBox as Ux,WarningIcon as zx}from"@rango-dev/ui";import Co from"react";import{useNavigate as Hx}from"react-router-dom";function Rf(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=Hx();return Co.createElement(ee,{id:"widget-slippage-warning-modal",anchor:"bottom",open:e,container:B(),onClose:o},Co.createElement(Ux,{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(jf,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:a,onClick:n},Co.createElement(zx,{color:"white",size:16}),Bn.t("Swap anyway")),Co.createElement(Hl,{size:10}),Co.createElement(Ox,{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(Rf,"SlippageWarningModal");import{Button as Qx,MessageBox as qx,WarningIcon as Gx}from"@rango-dev/ui";import Ji from"react";function eg(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(Gx,null),fullWidth:!0,disabled:r,onClick:n},re().unknownPriceError.confirmMessage),open:e,onClose:o,container:B()},Ji.createElement(qx,{type:"warning",title:re().unknownPriceError.impactTitle,description:re().unknownPriceError.description}))}i(eg,"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=Zf(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=Jf(e,k);f?.(x)}else C==="change-settings"&&d()},"onclickActionButton");return Fe.createElement(Fe.Fragment,null,g&&Fe.createElement(Fe.Fragment,null,Fe.createElement(tg,{size:10}),Fe.createElement(hr,{skipAlerts:s,error:o,fetch:c})),y&&Fe.createElement(Qf,null,Fe.createElement(tg,{size:10}),Fe.createElement(Kx,{id:"widget-quote-warning-and-errors-alert",title:m.title,type:m.alertType,variant:"alarm",...m.action==="show-info"&&{action:Fe.createElement(Kf,{onClick:l},Fe.createElement(Xx,{size:12,color:"gray"}))},...(m.action==="change-settings"||m.action==="change-slippage")&&{action:Fe.createElement(jx,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:m.alertType,onClick:()=>S(m.action)},m.actionButtonTitle||Vx.t("Change"))}})),e&&Fe.createElement(Fe.Fragment,null,e.type===0&&Fe.createElement(Yf,{...h,warning:e}),(e.type===3||e.type===2)&&Fe.createElement(Rf,{...h,warning:e}),e.type===1&&Fe.createElement(eg,{...h,warning:e})))}i(Sr,"QuoteWarningsAndErrors");import xb from"bignumber.js";import fa from"react";import{i18n as qo}from"@lingui/core";import{Alert as db,CampaignQuoteTag as mb,Divider as Mn,FullExpandedQuote as fb,InfoIcon as Rl,NumericTooltip as ec,QuoteTag as gb,StepDetails as hb,TokenAmount as yb,Typography as Ln,useIsTruncated as tc}from"@rango-dev/ui";import oc from"bignumber.js";import F,{useRef as ua,useState as Sb}from"react";import{styled as Ql}from"@rango-dev/ui";var ql=Ql("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),og=Ql("div",{paddingBottom:"$15","& .from-amount-text":{wordBreak:"break-word"},variants:{dense:{true:{paddingBottom:0}}}}),ng=Ql("div",{width:"100%",display:"flex"});import*as Ri from"@radix-ui/react-collapsible";import{Button as Yx,css as ea,darkTheme as _e,Image as rg,styled as Ge,Typography as Gl}from"@rango-dev/ui";var Zx=300,ig=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"}}]}),ag=ea({padding:"$10 $15"}),sg=Ge(Yx,{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"}}}),lg=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"}}}}]}),cg=ea({width:"100%",padding:"$15 $15 $10 $15"}),pg=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"}}),ug=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:{[`& ${rg}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${rg}`]:{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"}}}),dg=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"}}}}),mg=Ge(Vi,{width:"100%",background:"inherit"}),Vl=Ge("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${Zx}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"}),fg=Ge("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${_e} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),gg=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"}}}}),hg=Ge("div",{display:"flex"}),ta=Ge("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${_e} &`]:{borderTopColor:"$neutral800"}}),yg=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 Rx,CloseIcon as eb,Divider as ra,IconButton as tb,NumericTooltip as ob,QuoteCost as nb,Typography as At}from"@rango-dev/ui";import R,{useState as kg}from"react";import{css as Jx,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"}),Sg=oa("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),Cg=oa("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),Tg=Jx({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var rb=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]=kg(!1),[n,r]=kg(!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=qd(h),y=_(c,2,2);return R.createElement(R.Fragment,null,R.createElement(nb,{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(Cg,{style:{textAlign:f?"left":"center"}},R.createElement(At,{variant:"title",size:"medium"},$t.t("Gas & Fee Explanation")),R.createElement(tb,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},R.createElement(eb,{color:"gray",size:14}))),onClose:()=>{o(!1)}},R.createElement(Sg,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 v=`payable-fee-${x}`,I=Ks(k);return R.createElement(na,{key:v},R.createElement(At,{variant:"label",size:"medium",color:"neutral600"},Hs(S,$t.t)),R.createElement(ob,{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:Tg()},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(Rx,{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),v=Hs(S,$t.t),I=`non-payable-fee-${k}`;return R.createElement(rb,{key:I,fee:x,label:v})}),R.createElement(Yl,null)))))}i(Zl,"QuoteCostDetails");import{i18n as xg}from"@lingui/core";import{TokenAmount as bg}from"@rango-dev/ui";import ia from"react";import{css as ib,styled as ab}from"@rango-dev/ui";var wg=ab("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),vg=ib({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(wg,null,ia.createElement(bg,{direction:"horizontal",label:xg.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:vg()}),ia.createElement(bg,{id:"widget-quote-summary-estimated-input",direction:"horizontal",tooltipContainer:B(),label:xg.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 Bg}from"@lingui/core";import{ChevronDownIcon as cb,ChevronRightIcon as pb,Divider as Jl,Image as ub,Tooltip as pa,Typography as sa}from"@rango-dev/ui";import q from"react";import{useLayoutEffect as sb,useState as Tr}from"react";var Eg=480,Ig=768,Ag=1024,Ng=1200,lb=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<=Eg),n(window.innerWidth>Eg&&window.innerWidth<=Ig),a(window.innerWidth>Ig&&window.innerWidth<=Ag),c(window.innerWidth>Ag&&window.innerWidth<=Ng),p(window.innerWidth>Ng)},"handleResize");return sb(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:l}},"useScreenDetect"),aa=lb;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(dg,{className:n,state:a},q.createElement(ub,{src:o,size:16})))},"ImageComponent");function Wg(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:c}=t,l=c||B(),p=r.length,u=Ld(r),{isTablet:d,isMobile:f}=aa();return q.createElement(ug,{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"},Bg.t("Via:")),q.createElement(Jl,{direction:"horizontal",size:4}),r.map((h,g)=>{let m=`item-${g}`,y=q.createElement(Vl,null,q.createElement(pb,{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"},Bg.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(cb,{size:12,color:"black"}))))}i(Wg,"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]=Sb(t.expanded),v=ua(null),I=_(n.value,6,6),N=n.usdValue?_(n.usdValue,4,4):"",{config:{__UNSTABLE_OR_INTERNAL__:b}}=T(),E=jt(o.usdValue,n.usdValue??null),w=_(E,2,2),A=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(og,{dense:d},F.createElement(db,{variant:"alarm",type:Io?"error":"warning",title:Ro,id:"widget-quote-footer-step-alarm-alert",footer:F.createElement(ng,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=_d(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(bd)),ue=J/Id>=Ed,gt=ua(null),vt=tc(o.value,gt),xt=ua(null),O=tc(n.value,xt),z=ua(null),Y=tc(N,z),te=P[U-1],j=P[0];return!j||!te?null:d?F.createElement(fb,{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:w,warningLevel:A,outputPrice:{value:I,usdValue:N,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(lg,{id:"widget-quote-summary-container",selected:c,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:cg()},!l&&Z.length?F.createElement(F.Fragment,null,F.createElement(hg,null,Z.map((G,Ve)=>{let V=`${G.value}_${Ve}`;return F.createElement(F.Fragment,{key:V},G.value=="CAMPAIGN"&&b?.campaignTag?F.createElement(mb,{routeTag:G,...b.campaignTag}):F.createElement(gb,{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:pg()},F.createElement(Zl,{quote:e,time:X,fee:ae,feeWarning:at,timeWarning:ue,showModalFee:p,steps:U}),W&&F.createElement(sg,{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(gg,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(yg,{ref:z,color:"$neutral600",size:"xsmall",variant:"body"},`($${N})`),Y&&F.createElement(ec,{content:n.usdValue,container:Q},F.createElement(Rl,{size:12,color:"gray"}))),s==="list-item"&&F.createElement(yb,{id:"widget-quote-token-amount-container",tooltipContainer:Q,type:"output",direction:"vertical",price:{value:I,usdValue:N,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:te.to.token.displayName,image:te.to.token.image},chain:{image:te.to.chain.image},percentageChange:w,warningLevel:A}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(Cr,{from:j.from,to:te.to,percentageChange:w,warningLevel:A}),F.createElement(Mn,{size:4}))),F.createElement(ig,{selected:c,listItem:s==="list-item",open:k,className:"quote_container",onOpenChange:x},F.createElement(Wg,{type:s,quoteRef:v,selected:c,setExpanded:x,container:Q,expanded:k,steps:P}),F.createElement(mg,{open:k},F.createElement(fg,null),F.createElement("div",{className:ag()},P.map((G,Ve)=>{let V=`item-${Ve}`;return F.createElement(hb,{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 wb,Skeleton as vb}from"@rango-dev/ui";import eo from"react";import{darkTheme as Cb,styled as da}from"@rango-dev/ui";var Mg=da("div",{$$color:"$colors$neutral100",[`.${Cb} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Lg=da("div",{paddingTop:"$2"}),Pg=da("div",{paddingLeft:"$8"}),_g=da("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Gg,Divider as Nt,Skeleton as ut}from"@rango-dev/ui";import K from"react";import{css as Tb,styled as Rt}from"@rango-dev/ui";var rc=Rt("div",{display:"flex"}),Dg=Rt("div",{padding:"$10 $0 $20"}),$g=Rt("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Fg=Rt("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Og=Rt("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Ug=Rt("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),zg=Rt("div",{width:"65%",display:"flex",justifyContent:"start"}),Hg=Rt("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Qg=Rt("div",{padding:"$15 $0 $15 $0"}),qg=Tb({display:"flex",justifyContent:"space-between",alignItems:"center"});function wr(t){let{type:e,tagHidden:o=!0}=t,n=K.createElement(Og,null,K.createElement(zg,null,K.createElement(Gg,{loading:!0,size:"medium"}),K.createElement(Nt,{size:8,direction:"horizontal"}),K.createElement(Hg,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:qg()},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(Dg,null,K.createElement(ut,{height:15,width:148,variant:"rounded"})),e==="list-item"&&K.createElement($g,null,K.createElement(Fg,null,K.createElement(Gg,{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(Ug,null),n),K.createElement(Nt,{size:12})))}i(wr,"QuoteSummarySkeleton");import{ChainToken as Yg,Divider as ac,NextIcon as kb,Skeleton as ma}from"@rango-dev/ui";import We from"react";import{styled as vr}from"@rango-dev/ui";var Vg=vr("div",{display:"flex",alignItems:"start"}),Kg=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}),jg=vr("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Xg=vr("div",{display:"flex",alignItems:"center"});function Ft(t){let{separator:e=!0}=t;return We.createElement(We.Fragment,null,We.createElement(Xg,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(Vg,null,We.createElement(_g,{hideSeparator:!e}),We.createElement(Kg,{extraSpace:e},We.createElement(ic,null,We.createElement(Yg,{size:"small",loading:!0}),We.createElement(ac,{direction:"horizontal",size:8}),We.createElement(ma,{height:12,variant:"rounded"})),We.createElement(jg,null,We.createElement(kb,{color:"gray",size:16})),We.createElement(ic,null,We.createElement(Yg,{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(Mg,{expanded:o,rounded:e!=="basic"},eo.createElement(wr,{type:e,tagHidden:n}),eo.createElement(Lg,null,eo.createElement(vb,{height:15,variant:"rounded"})),o&&eo.createElement(Pg,null,eo.createElement(wb,{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 xb(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 Ab}from"@rango-dev/logging-core";import{calculatePendingSwap as Nb}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Bb}from"react";import{useRef as bb,useState as Eb}from"react";var Ib=2e3;function ga({request:t}){let[e,o]=Eb(!1),n=bb(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async c=>(await new Promise(l=>setTimeout(l,Ib)),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 Zg(){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(Zg,"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(Ud(t)){let{swap:n,fromAmountRangeError:r,recommendation:a}=zd(t);return n?{message:"bridge limit error",options:{type:3,swap:n,recommendation:a,fromAmountRangeError:r}}:null}let o=Gd(t);if(o){let n=Wi(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(sc,"getQuoteError");function Jg(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=jd(e,r,n.blockchains);return p.length===0||(c.balance={messages:p}),c}i(Jg,"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}=Zg();return Bb(()=>S,[]),{loading:C,fetch:i(async x=>{let v=x.selectedWallets,I=x?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let N=v.reduce((E,w)=>(E[w.chain]=w.address,E),{}),b={requestId:a?.requestId||"",selectedWallets:N,destination:I||void 0};try{return await y(b,!0).then(E=>{let{result:w}=E;if(!w)throw new Error(E.error??"Error fetching updated quote");ha({diagnosisMessages:w.diagnosisMessages,requestId:w.requestId,swaps:w.result?.swaps});let A={outputAmount:w.result?.outputAmount,requestId:w.requestId,resultType:w.result?.resultType,swaps:w.result?.swaps||[],validationStatus:w.validationStatus,requestAmount:w.requestAmount};r(A);let M={slippage:m.toString(),disabledSwappersGroups:u},P=Jg({previousQuote:a??void 0,currentQuote:A,meta:{blockchains:d},selectedWallets:v,userSlippage:m,inputUsdValue:n,findToken:h});c();let U=!!P.balance,Q=Nb({inputAmount:o.toString(),bestRoute:w,wallets:Kd(v),settings:M,validateBalanceOrFee:!U,meta:{blockchains:d,tokens:f},swapMode:g});return{quote:A,swap:Q,error:null,warnings:P}})}catch(E){let w=ya(E);return w.type!==2&&Ab(new Error("confirm swap error"),{tags:{...w,type:Xe[w.type],initialQuote:a,requestBody:b}}),{swap:null,error:w,warnings:null}}},"fetch"),cancelFetch:S}}i(lc,"useConfirmSwap");var Ub=Pb("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Rg}`]:{width:"$48",height:"$48"}}),zb=uc({flexGrow:1,paddingRight:"$10"}),Hb=uc({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Qb=uc({display:"flex",justifyContent:"space-between",alignItems:"center"});function eh(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=H()(),s=Ob(),[c,l]=br(""),p=!n,[u,d]=br(!1),[f,h]=br(!1),{isActiveTab:g}=ne(),m=T().getDisabledLiquiditySources(),y=Fb(m),{manager:S}=Wb(),{fetch:C,loading:k,cancelFetch:x}=lc(),[v,I]=br({swap:null,error:null,warnings:null}),[N,b]=br(!1),E=i(async({selectedWallets:W,customDestination:J})=>{let X=await C?.({selectedWallets:W,customDestination:J});return I(X),X},"onConfirmSwap"),w=i(async()=>{if(v.swap&&n)try{await S?.create("swap",{swapDetails:v.swap},{id:v.swap.requestId});let W=`../${$.swaps}/${v.swap.requestId}`;s(W,{replace:!0}),setTimeout(()=>{e("")},0)}catch(W){l("Error: "+W?.message)}},"addNewSwap"),A=i(async()=>{h(!0),await w(),h(!1)},"onConfirm"),M=i(async()=>{v.warnings?.quote&&Md(v.warnings.quote)&&!a?b(!0):await A()},"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))},[]),$b(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let U=v.warnings?.quote??null,Q=v.error,Z=[];if(c&&Z.push(De.createElement(Mb,{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:N,confirmationDisabled:!g,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:async()=>{b(!1),await w()},onChangeSettings:()=>s(W)}))}return De.createElement(se,{header:{title:cc.t("Confirm Swap"),onWallet:()=>{let W=`../${$.wallets}`;s(W)}},footer:De.createElement(Ub,null,De.createElement("div",{className:zb()},De.createElement(Lb,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:k||f,disabled:!!v.error||!g,onClick:M},cc.t("Start Swap"))),De.createElement(Rg,{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(Db,{size:24})))},u&&De.createElement(_f,{open:u,onClose:()=>d(!1),onCancel:x,loading:k,onCheckBalance:E}),De.createElement(ce,null,De.createElement("div",{className:Qb()},De.createElement(_b,{variant:"title",size:"small"},cc.t("You get")),De.createElement("div",{className:Hb()},De.createElement(Oi,{onClick:!k&&!u&&!N?P:void 0}))),De.createElement(pc,{size:"12"}),bm(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:v.error,loading:k,warning:v.warnings?.quote??null})))}i(eh,"ConfirmSwapPage");import{i18n as oo}from"@lingui/core";import{Button as vc,CustomTokensZeroStateDarkIcon as cE,CustomTokensZeroStateIcon as pE,DeleteIcon as uE,Divider as Br,IconButton as dE,MessageBox as mE,NotFound as fE,styled as bc}from"@rango-dev/ui";import he,{useState as xc}from"react";import{useNavigate as gE}from"react-router-dom";import{CloseIcon as qb,IconButton as Gb,SearchIcon as Vb,TextField as Kb}from"@rango-dev/ui";import Pn from"react";import{styled as th}from"@rango-dev/ui";var oh=th("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"}),nh=th("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(Gb,{id:`${u}\u06F0icon-btn`,variant:"ghost",onClick:()=>l?.(""),size:"small"},Pn.createElement(qb,{color:"gray",size:10})):null;return p&&(f=p),Pn.createElement(nh,null,Pn.createElement(Kb,{prefix:Pn.createElement(oh,null,Pn.createElement(Vb,{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 Zb,CustomTokenWarning as Jb,darkTheme as gh,Divider as to,ExternalLinkIcon as Rb,Image as eE,ListItem as tE,NotFound as oE,PinIcon as nE,Skeleton as Vo,Typography as Ar,VirtualizedList as rE}from"@rango-dev/ui";import L,{useState as iE}from"react";import{useTranslation as aE}from"react-i18next";import{Divider as mh,ListItem as Yb,Skeleton as Ir}from"@rango-dev/ui";import Wt from"react";import{css as _n,darkTheme as dc,ImageContainer as jb,ListItemButton as Xb,styled as rt,Typography as rh}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(),ih=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"}}}}}),ah=rt(Xb,{variants:{customToken:{true:{"&:hover":{cursor:"unset"}}}}}),Tc=rt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),kc=rt(rh,{}),sh=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"}),vV=rt("div",{display:"flex",alignItems:"center"}),lh=rt("div",{position:"relative",[`& ${jb}`]:{borderRadius:"$xm",overflow:"hidden"}}),ch=rt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),ph=rt(rh,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),uh=rt("a",{"& svg:hover":{color:"$colors$info"}}),dh=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 fh(t){return Wt.createElement(Ca,null,Array.from(Array(t.size),e=>Wt.createElement(Yb,{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(mh,{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(mh,{size:4}),Wt.createElement(Ir,{variant:"text",size:"medium",width:90}))})))}i(fh,"LoadingTokenList");var sE=20,lE=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(uh,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:l=>l.stopPropagation()},L.createElement(Rb,{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}=aE(),S=Qe(),[C,k]=iE(null),x=i(()=>{c==="source"?g({token:C,meta:{blockchains:u}}):m({token:C,meta:{blockchains:u}})},"updateToken"),v=i(()=>{x(),S()},"handleImportToken"),I=i(E=>{if(E.customToken){let{customToken:A,...M}=E;return L.createElement(Zb,{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 w=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})):w&&L.createElement(sh,null,L.createElement(ph,{variant:"title",size:"small"},w.amount),L.createElement("div",null),w.usdValue&&L.createElement(Ar,{variant:"body",className:Sc(),size:"xsmall"},`$${w.usdValue}`))},"endRenderer"),N=i(()=>L.createElement(rE,{style:{flexGrow:1,minHeight:0},itemContent:E=>{let w=e[E];if(w==="skeleton")return L.createElement(tE,{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 A=u.find(W=>W.name===w?.blockchain);if(!A||!w)return null;let M=w.address,P=ll(A.color,"main"),U={$$color:P.main150,[`.${gh} &`]:{$$color:P.main750},backgroundColor:"$$color"},Q={$$color:P.main750,[`.${gh} &`]:{$$color:P.main150},color:"$$color"},Z=i(()=>{typeof w!="string"&&!w.customToken&&n?.(w)},"handleClick");return L.createElement(dh,null,L.createElement(ah,{"tab-index":E,key:`${w.symbol}${M}`,id:`${w.symbol}${M}`,className:"widget-token-list-item-btn",hasDivider:!0,customToken:w?.customToken,onClick:Z,start:L.createElement(lh,null,L.createElement(eE,{src:w.image===""?ti:w.image,size:30}),t.type!=="custom-token"&&w&&h(w,t.type)&&L.createElement(ch,null,L.createElement(nE,{size:12,color:"gray"}))),title:A.type==="COSMOS"||w.name||!w.name&&!M?L.createElement(Cc,null,L.createElement(Ar,{variant:"title",size:"xmedium"},w.symbol),L.createElement(to,{direction:"horizontal",size:4}),L.createElement(Tc,{css:U},L.createElement(kc,{variant:"body",size:"xsmall",css:Q},w.blockchain)),l&&w.warning&&L.createElement(L.Fragment,null,L.createElement(to,{direction:"horizontal",size:4}),L.createElement(Jb,{container:B()}))):void 0,description:typeof w!="string"&&A.info&&M&&A.type!=="COSMOS"?lE({address:M,token:w,customCssForTag:U,customCssForTagTitle:Q,name:w.name,url:A.info.addressUrl.split("{wallet}").join(M)}):w.name||void 0,end:I(w)}))},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(ih,null,L.createElement(to,{size:4}),p==="loading"&&L.createElement(fh,{size:sE}),p==="success"&&(e.length?L.createElement(L.Fragment,null,L.createElement(mr,{token:C,address:C?.address??"",blockchain:b??void 0,onImport:v,onExitErrorModal:()=>k(null),onExitImportModal:()=>k(null)}),L.createElement(Ca,{as:"ul"},N())):!!o&&L.createElement(oE,{title:wc.t("No results found"),description:wc.t("Try using different keywords")}))))}i(Nr,"TokenList");var hE=bc("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),yE=bc("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),SE=bc(dE,{"&:hover":{"& svg":{color:"$secondary550"}}});function hh(){let[t,e]=xc(""),{deleteCustomToken:o}=T(),n=T().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:c}=H()(),{mode:l}=mo({}),p=gE(),[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(hE,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(SE,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{d(!0),h(C)}},he.createElement(uE,{size:12,color:"gray"}))})):he.createElement(yE,null,he.createElement(fE,{icon:m?he.createElement(cE,{size:200}):he.createElement(pE,{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(mE,{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(hh,"CustomTokensPage");import{i18n as $e}from"@lingui/core";import{useManager as FE}from"@rango-dev/queue-manager-react";import{Button as Mc,darkTheme as OE,Divider as To,MessageBox as UE,NotFound as zE,styled as Lc,Tabs as HE,Typography as wa}from"@rango-dev/ui";import{TransactionStatus as Lr}from"rango-types";import oe,{useMemo as _h,useState as Pr}from"react";import{useNavigate as QE}from"react-router-dom";import{FilterIcon as bE,Popover as EE}from"@rango-dev/ui";import Ko from"react";import{css as CE,darkTheme as Ta,IconButton as TE,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:""}}}}}),yh=Wr(TE,{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"}}}}),Sh=Wr("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),Ch=Wr("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),Th=CE({display:"flex",justifyContent:"space-between",alignItems:"center"}),kh=Wr("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as wh}from"@lingui/core";import{Button as kE,Divider as vh,ListItemButton as wE,Radio as vE,RadioRoot as xE,Typography as xh}from"@rango-dev/ui";import dt from"react";function bh(t){let{filterBy:e,onClickItem:o}=t;return dt.createElement(Ch,null,dt.createElement("div",{className:Th()},dt.createElement(xh,{size:"small",variant:"body"},wh.t("Status")),dt.createElement(kE,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},wh.t("Reset"))),dt.createElement(vh,{size:10}),dt.createElement(xE,{value:e},dt.createElement(kh,null,t.list.map((n,r)=>dt.createElement(wE,{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(vh,{direction:"horizontal",size:4}),dt.createElement(xh,{size:"medium",variant:"body"},n.title)),start:dt.createElement(vE,{value:n.id}),onClick:o})))))}i(bh,"FilterSelectorContent");function Ic(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return Ko.createElement("div",null,Ko.createElement(EE,{open:a,align:"end",onOpenChange:o,container:B(),content:Ko.createElement(bh,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},Ko.createElement(yh,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},Ko.createElement(Ec,{isSelect:!!n},Ko.createElement(bE,{size:16,color:"black"}),!!n&&Ko.createElement(Sh,null)))))}i(Ic,"FilterSelector");import{i18n as NE}from"@lingui/core";import{getCurrentStep as BE}from"@rango-dev/queue-manager-rango-preset";import{Divider as Bh,GroupedVirtualizedList as WE,Skeleton as ME,SwapListItem as Wh,Typography as LE}from"@rango-dev/ui";import Ye,{useCallback as Mh,useEffect as PE,useRef as _E,useState as DE}from"react";function Eh(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(Eh,"calculateGroupsSoFar");import{css as IE,darkTheme as AE,styled as Mr}from"@rango-dev/ui";var Ac=IE(),Ih=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",[`.${AE} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Bc=Mr("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),Ah=Mr("div",{gap:"$10",display:"flex",flexDirection:"column"}),Nh=Mr("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var $E=10;function Wc(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=DE([]),c=_E(0),{swaps:l,groupCounts:p,groups:u}=n(e),d=Mh(Eh,[]),f=Mh(()=>{let h=e.length-c.current;h&&(c.current+=Math.min(h,$E),s(d(p,c.current)))},[e.length]);if(PE(()=>{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(ME,{variant:"text",width:60,size:"small"}),Ye.createElement(Bh,{size:16})),Ye.createElement(Bh,{size:4}),Ye.createElement(Ah,null,m.map((C,k)=>Ye.createElement(Wh,{isLoading:!0,key:k}))))))}return Ye.createElement(WE,{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(LE,{variant:"label",size:"medium",className:Ac()},u[h]))),itemContent:(h,g)=>{let m=l[h];if(!m)return null;let y=BE(m),S=m.steps[0],C=m.steps[m.steps.length-1];return!S||!C?null:Ye.createElement(Ih,{key:m.requestId},Ye.createElement(Wh,{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]===NE.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 Lh from"dayjs";var Ph=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=Lh();t.forEach(l=>{let p=Number(l.creationTime),u=Lh(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 qE=Lc("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%",minHeight:0,flexGrow:1}),GE=Lc("div",{display:"flex",justifyContent:"center",alignItems:"center"}),VE=Lc("div",{"._typography":{color:"$neutral700",[`.${OE}&`]:{color:"$neutral900"}}}),KE=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 Dh(){let t=QE(),{manager:e,state:o}=FE(),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=_h(()=>!r&&!p&&h==="all"?n:n.filter(b=>{let{inputAmount:E,status:w,steps:A,requestId:M,mode:P}=b;return(!r||Pt(E,r)||Pt(w,r)||KE(A,r)||Pt(M,r))&&(!p||p===w)&&(h==="all"?!0:h==="swap"?!P||P==="swap":h==="refuel"?P==="refuel":!1)}),[n,r,p,h]),x=!k?.length&&!l,v=i(()=>f(!1),"onCloseModal"),I=i(async()=>{try{await e?.clearQueue(),f(!1)}catch(b){console.log(b)}},"onClear"),N=_h(()=>!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:N,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(GE,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(HE,{items:C,onChange:b=>g(b.id),value:h,type:"secondary"}),oe.createElement(To,{size:"12"})),oe.createElement(qE,null,x&&oe.createElement(Nh,null,oe.createElement(To,{size:32}),oe.createElement(zE,{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:Ph,isLoading:l}))),oe.createElement(ee,{open:d,onClose:v,id:"widget-history-clear-modal",container:B()},oe.createElement(To,{size:20}),oe.createElement(UE,{type:"warning",title:$e.t("Clear Transaction History"),description:oe.createElement(VE,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:v},oe.createElement(wa,{variant:"title",size:"medium",color:"primary"},$e.t("No, Cancel")))))}i(Dh,"HistoryPage");import{i18n as dy}from"@lingui/core";import{Button as NI,Divider as Kc,styled as BI,WarningIcon as WI}from"@rango-dev/ui";import MI from"bignumber.js";import Te,{useEffect as my,useState as fy}from"react";import{useNavigate as LI}from"react-router-dom";import{i18n as Fh}from"@lingui/core";import{Alert as XE,Divider as Pc,NoRouteIcon as YE,Typography as ZE}from"@rango-dev/ui";import jo from"react";import{styled as jE}from"@rango-dev/ui";var $h=jE("div",{display:"flex",flexDirection:"column",alignItems:"center"});function _c(){let{fromToken:t,toToken:e}=H()();return!!t&&!!e&&qt(t,e)?jo.createElement($h,null,jo.createElement(Pc,{size:10}),jo.createElement(YE,{size:24,color:"gray"}),jo.createElement(Pc,{size:4}),jo.createElement(ZE,{variant:"title",size:"small"},Fh.t("No Routes Found")),jo.createElement(Pc,{size:4}),jo.createElement(XE,{title:Fh.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(_c,"SameTokensWarning");import{Alert as JE,Button as RE}from"@rango-dev/ui";import Uh from"react";import{i18n as va}from"@lingui/core";function Oh(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(Oh,"makeAlerts");function zh(t){let{slippage:e,customSlippage:o,setSlippage:n,setCustomSlippage:r}=T(),{onChangeSettings:a}=t,c=Oh(o!==null?o:e),l=i(p=>{p==="reset-slippage"?(n(fi),r(null)):p==="change-settings"&&a()},"onClickActionButton");return c?Uh.createElement(JE,{title:c.title,type:c.alertType,variant:"alarm",action:Uh.createElement(RE,{id:"widget-slippage-warning-error-change-settings-or-reset-slippage-btn",size:"xxsmall",type:c.alertType,onClick:()=>l(c.action)},c.actionButtonTitle)}):null}i(zh,"SlippageWarningsAndErrors");import{i18n as rI}from"@lingui/core";import{IconButton as iI,ReverseIcon as aI,Skeleton as sI,Tooltip as lI,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 qh(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(qh,"getUsdExchangeRate");function Gh(t,e){let o=new xa(t).multipliedBy(e);return o.isLessThan(.001)?"$0":`$${o.decimalPlaces(2,xa.ROUND_DOWN).toFormat(2)}`}i(Gh,"formatTokenValueInUsd");import{darkTheme as oI,styled as $c,Typography as nI}from"@rango-dev/ui";var Vh=$c("div",{display:"flex",padding:"$4",justifyContent:"space-between",alignItems:"center"}),Kh=$c("div",{display:"flex",alignItems:"center",gap:"$2","& .rate-text":{color:"$neutral700",[`.${oI} &`]:{color:"$neutral700"}},"& ._icon-button":{transform:"rotate(90deg)",width:"$16",height:"$16"}}),Fc=$c(nI,{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,v=m?k:C,I=Number(m?p?.outputAmount:p?.requestAmount),N=Number(m?p?.requestAmount:p?.outputAmount),b=I||x.usdPrice,E=N||v.usdPrice,{rawValue:w,displayValue:A}=qh({toTokenUsdPrice:E,fromTokenUsdPrice:b});return mt.createElement(Vh,null,mt.createElement(_r,{variant:y||S?"label":"body",size:y||S?"medium":"small",color:Qh({error:y,warning:S,isDarkTheme:g})},rI.t("Slippage:")," ",d,"%"),u?mt.createElement(sI,{height:16,width:104,variant:"rounded"}):b&&E&&mt.createElement(Kh,null,mt.createElement(_r,{className:"rate-text",variant:"body",size:"small"},"1"),mt.createElement(Fc,{className:"rate-text",variant:"body",size:"small"},v.symbol),mt.createElement(iI,{id:"widget-home-page-change-rate-button",onClick:r},mt.createElement(aI,{size:14,color:"secondary"})),mt.createElement(lI,{container:B(),side:"top",sideOffset:4,content:mt.createElement(_r,{className:"rate-text",variant:"body",size:"small"},w)},mt.createElement(_r,{className:"rate-text",variant:"body",size:"small"},A)),mt.createElement(Fc,{className:"rate-text",variant:"body",size:"small"},x.symbol),x.usdPrice&&mt.createElement(_r,{color:"neutral600",variant:"body",size:"small"},"~",Gh(Number(w),x.usdPrice))))}i(Oc,"SwapMetrics");import{i18n as fI}from"@lingui/core";import{Header as gI}from"@rango-dev/ui";import ko,{useEffect as hI,useState as yI}from"react";import{i18n as pI}from"@lingui/core";import{Divider as zc,FullExpandedQuote as uI,Typography as dI}from"@rango-dev/ui";import xe from"react";import{styled as Uc}from"@rango-dev/ui";var jh=Uc("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Xh=Uc("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Yh=Uc("div",{width:"146px"});import{i18n as Dr}from"@lingui/core";import{Select as cI}from"@rango-dev/ui";import Zh 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 Zh.createElement(Yh,null,Zh.createElement(cI,{id:"widget-quotes-strategy-select",container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(ba,"SelectStrategy");var Jh=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__:v}}=T(),I=i(E=>{if(!d||!f||!p)return null;let w={requestAmount:p.requestAmount,validationStatus:null,...E};return Cn({currentQuote:w,userSlippage:x,findToken:S})},"getQuoteWarning"),N=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(Xh,null,xe.createElement(dI,{size:"xmedium",variant:"title"},pI.t("Sort by")),xe.createElement(ba,{container:C})),xe.createElement(zc,{size:"10"})),e&&Array.from({length:Jh},(E,w)=>xe.createElement(xe.Fragment,{key:w},s?xe.createElement(uI,{campaignTag:v?.campaignTag,loading:!0}):xe.createElement(xr,{tagHidden:!1,type:"list-item",expanded:!1}),w!==Jh-1&&xe.createElement(zc,{size:16}))),!e&&xe.createElement(xe.Fragment,null,k?b.map((E,w)=>{let A=I(E),M=sc(E.swaps),P=b.length-1===w;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:A,fullExpandedMode:s,onClick:U=>{M||u("warning",A),u("error",M?.options||null),o(U)},type:"list-item"}),!P&&xe.createElement(zc,{size:16}))}):N&&xe.createElement(jh,null,xe.createElement(hr,{size:s?"large":"small",error:g,fetch:n}))))}i($r,"Quotes");import{darkTheme as mI,styled as Rh}from"@rango-dev/ui";var ey=Rh("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${mI} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),ty=Rh("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var SI=100;function Hc(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,c]=yI(!1),l=s?"":"is-hidden",{config:p}=T(),u=p?.variant==="full-expanded",d=Wo();return hI(()=>{let f=null;return a?f=setTimeout(()=>{c(!0)},SI):(c(!1),f&&clearTimeout(f)),()=>{f&&clearTimeout(f)}},[a]),ko.createElement(ey,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${l} ${Qi()} widget-expanded-quotes-container`,id:Re.EXPANDED_BOX_ID},ko.createElement(gI,{title:fI.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(ty,null,ko.createElement($r,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:Wo(),onClickOnQuote:n,fullExpandedMode:u})))}i(Hc,"ExpandedQuotes");import{i18n as ly}from"@lingui/core";import{SwapInput as cy}from"@rango-dev/ui";import wI from"bignumber.js";import Fr from"react";import{ReverseIcon as kI}from"@rango-dev/ui";import qc from"react";import{keyframes as CI,styled as oy}from"@rango-dev/ui";var Qc=450,TI=CI({"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)"}}),ny=oy("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),ry=oy("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${TI} ${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(ny,null,qc.createElement(ry,{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(kI,{size:12})))}i(Gc,"SwitchFromAndToButton");import{styled as iy}from"@rango-dev/ui";var ay=iy("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),sy=iy("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",v=k?new wI(k.amount).shiftedBy(-k.decimals):pe,I=!!s&&Au(S,s.name),N=!Gs(m,d,f),b=!Gs(m,d,g),E=!f||!g||!g.gt(0)?null:jt(f.toString(),g.toString());return Fr.createElement(ay,null,Fr.createElement(sy,null,Fr.createElement(cy,{label:ly.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:N?void 0:_(f,4,4),realUsdValue:N?void 0:f?.toString(),error:N?re().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:I,tooltipContainer:B(),onSelectMaxBalance:()=>{let w=_(v,k?.decimals),A=k?.amount?w.split(",").join(""):"";p(A)},anyWalletConnected:S.length>0}),y==="swap"&&Fr.createElement(Gc,null)),Fr.createElement(cy,{selectionType:y==="swap"?"token":"chain",sharpBottomStyle:!r&&(!!m||e),label:ly.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 vI}from"@rango-dev/logging-core";import{useCallback as xI,useEffect as bI,useRef as EI,useState as II}from"react";function py(){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(py,"useFetchAllQuotes");var AI=600;function Ea({refetchQuote:t}){let{fetch:e,cancelFetch:o}=py(),{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:v,affiliateRef:I,affiliateWallets:N,fetchStatus:b}=T(),E=T().getLiquiditySources(),w=T().getDisabledLiquiditySources(),A=T().excludeLiquiditySources(),{findToken:M}=T(),{swapMode:P}=tt(),[U,Q]=II(!0),Z=EI(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=Vd({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=Pd(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),vI(new Error("quote error"),{tags:{...Je,type:Xe[Je.type],requestBody:V}}))})}},"fetch"),at=xI(ri(ue=>{Se(ue)},AI),[X]);return bI(()=>{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:A,disabledLiquiditySources:w,slippage:W,affiliateRef:I,affiliatePercent:v,affiliateWallets:N,contractCall:c}),o},[b,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,X,E?.length,n,w.length,W,I,v,c,JSON.stringify(N)]),{fetch:()=>Se({inputAmount:u,fromToken:l,toToken:p,liquiditySources:E,excludeLiquiditySources:A,disabledLiquiditySources:w,slippage:W,affiliateRef:I,affiliatePercent:v,affiliateWallets:N,contractCall:c}),loading:U}}i(Ea,"useSwapInput");function uy(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(uy,"emitPreventableEvent");var PI=BI("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),_I=300;function gy(){let t=LI(),{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]=fy(!1),{isLargeScreen:m,isExtraLargeScreen:y}=aa(),{fetch:S,loading:C}=Ea({refetchQuote:a}),{config:k,fetchStatus:x,connectedWallets:v,customSlippage:I,slippage:N,setSlippage:b,setCustomSlippage:E}=T(),{isActiveTab:w}=ne(),[A,M]=fy(!1),P=I!==null?I:N,{swapMode:U}=tt(),Q=pn(P),W=Hd({fetchMetaStatus:x,fetchingQuote:C,inputAmount:n,quote:r,anyWalletConnected:v.length>0,error:s,warning:c,needsToWarnEthOnPath:!1}),J=_u(m,y,k?.variant),X=!!n&&!!e&&!!o&&new MI(n).gt(0)&&!Rd(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)&&!A?S:void 0,z=i(G=>{J&&h?(g(!1),setTimeout(()=>{t(G)},_I)):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 my(()=>{u(),f("refetchQuote",!0)},[]),my(()=>{g(X)},[X]),Te.createElement(PI,null,Te.createElement(se,{height:"auto",footer:Te.createElement(NI,{id:`widget-swap-${W.action}-btn`,type:"primary",size:"large",disabled:W.disabled||!w,prefix:W.action==="confirm-warning"&&Te.createElement(WI,null),fullWidth:!0,onClick:()=>{W.action==="connect-wallet"?uy({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"?dy.t("Swap"):dy.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:A,confirmationDisabled:!w,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(zh,{onChangeSettings:()=>z($.settings)})),Te.createElement(_c,null))),J?Te.createElement(Hc,{loading:ae,onClickOnQuote:Y,fetch:S,onClickRefresh:O,isVisible:h}):null)}i(gy,"Home");import{i18n as hy}from"@lingui/core";import{Alert as DI,Divider as $I,List as FI,ListItemButton as OI,Radio as UI,RadioRoot as zI,Typography as HI}from"@rango-dev/ui";import Ot from"react";function wo(){let{setLanguage:t,language:e,config:o}=T(),n=Hu,r=o?.language||un;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||un),resetLanguage:()=>t(null)}}i(wo,"useLanguage");function yy(){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(HI,{variant:"title",size:"xmedium"},c),onClick:()=>{e(a.local),n()},end:Ot.createElement(UI,{value:s}),start:Ot.createElement(l,null)}});return Ot.createElement(se,{header:{title:hy.t("Language")}},Ot.createElement(ce,null,Ot.createElement(DI,{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($I,{size:"8"}),Ot.createElement(zI,{value:t},Ot.createElement(FI,{type:Ot.createElement(OI,{title:hy.t("language"),className:"widget-language-list-item-btn",id:"_",onClick:()=>console.log()}),items:r}))))}i(yy,"LanguagePage");import{i18n as no}from"@lingui/core";import{Button as KI,Checkbox as jI,Image as XI,ListItemButton as YI,NotFound as ZI,Typography as JI}from"@rango-dev/ui";import Ze,{useState as RI}from"react";import{Checkbox as GI,Skeleton as Cy}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 qI}from"@rango-dev/ui";var Sy=qI(QI,{height:61});var VI=30;function Zc(){return Ur.createElement(Or,null,Array.from(Array(VI),(t,e)=>Ur.createElement(Sy,{hasDivider:!0,key:e,start:Ur.createElement(Cy,{variant:"circular",width:35,height:35}),title:Ur.createElement(Cy,{variant:"text",size:"large",width:90}),end:Ur.createElement(GI,{checked:!1})})))}i(Zc,"LoadingLiquiditySourceList");function Jc({sourceType:t}){let e=T().fetchStatus,o=T().swappers(),n=T().getDisabledLiquiditySources(),[r,a]=RI(""),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:v,...I}=S;return{id:`widget-setting-liquidity-source-${hu(v.toLowerCase())}-item-btn`,start:Ze.createElement(XI,{src:x,size:22,type:"circular"}),onClick:()=>{c||s(k)},end:Ze.createElement(jI,{checked:C,disabled:c}),title:Ze.createElement(JI,{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(KI,{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(ZI,{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(YI,{style:{height:"61px"},...k,selected:!1,className:"widget-liquidity-source-list-item-btn",hasDivider:!0}))}))))}i(Jc,"LiquiditySourcePage");import{i18n as eA}from"@lingui/core";import Ia from"react";import{useNavigate as tA}from"react-router-dom";function Ty(){let t=tA(),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:eA.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(Ty,"RoutesPage");import{i18n as Iy}from"@lingui/core";import{Divider as Ay,getCategoriesCount as uA,SelectableCategoryList as dA}from"@rango-dev/ui";import ro,{useMemo as mA,useState as Ny}from"react";import{useNavigate as fA}from"react-router-dom";import{i18n as Rc}from"@lingui/core";import{Divider as iA,Image as aA,ListItemButton as sA,NotFound as lA,Typography as Ey}from"@rango-dev/ui";import ft,{useEffect as cA,useState as pA}from"react";var ky=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 oA,styled as wy}from"@rango-dev/ui";var vy=wy("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Aa=wy(El,{padding:0,margin:0,listStyle:"none",[`& ${oA}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as nA,Skeleton as xy}from"@rango-dev/ui";import Na from"react";var rA=20;function by(){return Na.createElement(Aa,{id:"widget-blockchain-loading-list",as:"ul"},Array.from(Array(rA),t=>Na.createElement(nA,{key:t,hasDivider:!0,start:Na.createElement(xy,{variant:"circular",width:35,height:35}),title:Na.createElement(xy,{variant:"text",size:"large",width:90})})))}i(by,"LoadingBlockchainList");function ep(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,c]=pA(e),{fetchStatus:l}=T();cA(()=>{c([...ky(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?ft.createElement(lA,{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(sA,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:ft.createElement(aA,{src:u.logo,size:30}),title:ft.createElement(Ey,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return ft.createElement(ft.Fragment,null,a&&ft.createElement(ft.Fragment,null,ft.createElement(Ey,{variant:"label",size:"large"},Rc.t("Select Chain")),ft.createElement(iA,{size:4})),ft.createElement(vy,null,l==="loading"&&ft.createElement(by,null),l==="success"&&p()))}i(ep,"BlockchainList");function Ba(t){let{type:e}=t,o=Qe(),[n,r]=Ny(""),[a,s]=Ny("ALL"),c=H().use.setToBlockchain(),l=H().use.setFromBlockchain(),p=H().use.setToToken(),{fetchStatus:u,findNativeToken:d}=T(),f=fA(),{swapMode:h}=tt(),g=T().blockchains({type:e}),m=T().tokens(),y=mA(()=>du(g,m),[g.length,m.length]),S=uA(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 v=d(x);v&&p({token:v,meta:{blockchains:g}})}o()}},"handleBlockchainChange");return ro.createElement(se,{header:{title:Iy.t("Select Chain")}},ro.createElement(ce,{view:!0},C&&ro.createElement(ro.Fragment,null,ro.createElement(dA,{setCategory:s,category:a,blockchains:y,isLoading:u==="loading"}),ro.createElement(Ay,{size:24})),ro.createElement(Bt,{value:n,autoFocus:!0,placeholder:Iy.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(Ay,{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 Dy,Spinner as NA}from"@rango-dev/ui";import vo,{useEffect as BA,useState as WA}from"react";import{useNavigate as MA}from"react-router-dom";import{i18n as np}from"@lingui/core";import{BlockchainsChip as Wa,Divider as Ly,Image as Py,Skeleton as TA,Tooltip as kA,Typography as rp}from"@rango-dev/ui";import be from"react";import{useEffect as yA}from"react";var By=["ETH","COSMOS","OSMOSIS"];function tp(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(gA),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(hA(s)),r=n.splice(a)}return{list:n,more:r}}i(tp,"prepare");function gA(t,e){let o=By,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(gA,"sortByMostUsedBlockchains");function hA(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(hA,"generateSortByPreferredBlockchainsFor");function Wy(t,e){return!!e.list.find(o=>o.name===t)}i(Wy,"isInVisibleList");function op(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=T();yA(()=>{if(e?.selected){let a=tp(t,o,e);Wy(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 SA}from"@rango-dev/ui";var My=SA("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var wA=6,vA=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(Ly,{size:12}),be.createElement(rp,{variant:"label",size:"large"},np.t("Select Chain"))),be.createElement(Ly,{size:12}),be.createElement(My,{id:"widget-blockchains-section-container"},l==="loading"&&Array.from(Array(s?wA:vA),(m,y)=>be.createElement(TA,{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(kA,{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(Py,{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(Py,{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 bA,useRef as EA,useState as ap}from"react";function sp(){let t=T().blockchains(),e=EA(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=bA(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 _y(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(_y,"prepareTokensList");function Pa(t){let{type:e}=t,o=MA(),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]=WA(""),S=e==="source"?r:a,C=S?.name??"",k=T().blockchains({type:e}),x=T().tokens({type:e,blockchain:C,searchFor:m,getBalanceFor:u}),v=_y(x,h,m,f,S?.name),I=i(E=>{e==="source"?l(E):p(E)},"updateBlockchain"),N=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 BA(()=>(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(Dy,{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(NA,{size:12,color:"secondary"}):void 0}),vo.createElement(Dy,{size:16}),vo.createElement(Nr,{list:v,selectedBlockchain:C,searchedFor:m,type:e,onChange:E=>{N(E);let w=k.find(A=>E.blockchain===A.name);w&&I(w),n()}})))}i(Pa,"SelectSwapItemsPage");import{i18n as up}from"@lingui/core";import{Alert as iN,Button as aN,styled as sN}from"@rango-dev/ui";import Xo from"react";import{useInRouterContext as lN,useSearchParams as cN}from"react-router-dom";import{i18n as Hy}from"@lingui/core";import{Alert as DA,Divider as cp,InfoIcon as $A,SlippageIcon as FA,TextField as OA,Tooltip as UA,Typography as Qy}from"@rango-dev/ui";import Oe from"react";import{Chip as LA,styled as zr,TextField as PA}from"@rango-dev/ui";var $y=zr("div",{paddingTop:"$5",padding:"$10 $5"}),Fy=zr("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${PA}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px",paddingLeft:"$2"}}),Oy=zr("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),_a=zr("div",{maxWidth:"280px",padding:"$10"}),Uy=zr(LA,{width:"61px",flexShrink:0});import{i18n as lp}from"@lingui/core";import{Typography as _A}from"@rango-dev/ui";import Hr from"react";function zy(){return Hr.createElement(_a,null,Hr.createElement(_A,{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(zy,"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;Su(u)||(p.value=u.slice(0,-1))},"onInput");return Oe.createElement($y,null,Oe.createElement(Oy,null,Oe.createElement(FA,{size:16,color:"gray"}),Oe.createElement(cp,{direction:"horizontal",size:4}),Oe.createElement(Qy,{variant:"title",size:"xmedium"},Hy.t("Slippage tolerance per swap")),Oe.createElement(cp,{direction:"horizontal",size:4}),Oe.createElement(UA,{container:B(),side:"top",sideOffset:4,content:Oe.createElement(zy,null)},Oe.createElement($A,{color:"gray"}))),Oe.createElement(Fy,null,mi.map((l,p)=>{let u=`slippage-${p}`;return Oe.createElement(Uy,{id:`widget-slippage-chip-${l.toString()}%-btn`,key:u,onClick:()=>s(l),selected:o===null&&l===t,label:`${l.toString()}%`})}),Oe.createElement(OA,{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:Hy.t("Custom")})),r&&Oe.createElement(Oe.Fragment,null,Oe.createElement(cp,{size:10}),Oe.createElement(DA,{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 qy,BridgesIcon as zA,ChevronRightIcon as Da,DarkModeIcon as Gy,Divider as Qr,ExchangeIcon as HA,InfinityIcon as QA,InfoIcon as qA,LanguageIcon as GA,LightModeIcon as Vy,List as VA,ListItem as KA,ListItemButton as jA,Skeleton as XA,styled as YA,Switch as ZA,Tabs as JA,TargetIcon as RA,Tooltip as eN,Typography as it}from"@rango-dev/ui";import D from"react";import{useNavigate as tN}from"react-router-dom";var oN=YA("div",{width:"202px",height:"$40"}),nN=[{id:"light",icon:D.createElement(Vy,{color:"black",size:24}),tooltip:D.createElement(it,{size:"xsmall",variant:"body"},wt.t("Light"))},{id:"dark",icon:D.createElement(Gy,{color:"black",size:24}),tooltip:D.createElement(it,{size:"xsmall",variant:"body"},wt.t("Dark"))},{id:"auto",icon:D.createElement(qy,{color:"black",size:24}),tooltip:D.createElement(it,{size:"xsmall",variant:"body"},wt.t("Auto"))}],rN=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return D.createElement(qy,{...e});case"dark":return D.createElement(Gy,{...e});default:return D.createElement(Vy,{...e})}},"getThemeIcon");function Ky(){let t=tN(),{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,v=k.filter(W=>W.selected).length,I=C.filter(W=>W.type==="DEX"),N=I.length,b=I.filter(W=>W.selected).length,E=i((W,J)=>{switch(c){case"loading":return D.createElement(XA,{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"),w={id:"widget-setting-bridge-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Bridges")),end:D.createElement(D.Fragment,null,E(v,x),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(Da,{color:"black"})),onClick:()=>t($.bridges),start:D.createElement(zA,{color:"gray",size:16})},A={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,N),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(Da,{color:"black"})),start:D.createElement(HA,{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(RA,{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(GA,{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(eN,{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(qA,{color:"gray"}))),start:D.createElement(QA,{color:"gray",size:16}),end:D.createElement(ZA,{checked:y}),onClick:S},Q={id:"widget-setting-theme-item-btn",type:D.createElement(KA,null),title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Theme")),end:D.createElement(oN,null,D.createElement(JA,{container:B(),items:nN,value:n,className:"widget-setting-theme-item-tabs-container",onChange:W=>o(W.id),type:"primary",borderRadius:"small"})),start:rN(n)},Z=h?[]:[w,A];return m||Z.push(M),g||Z.push(P),Z.push(U),!e?.singleTheme&&!f&&Z.push(Q),D.createElement(VA,{type:D.createElement(jA,{className:"widget-settings-list-item-btn",hasDivider:!0,id:"_",onClick:()=>console.log()}),items:Z})}i(Ky,"SettingsLists");var pN=sN("div",{paddingLeft:"$8"});function jy(){let{isInCampaignMode:t,updateCampaignMode:e}=T(),o=t(),[,n]=cN(),r=lN(),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(iN,{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(pN,null,Xo.createElement(aN,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},up.t("Reset")))}),Xo.createElement(pp,null),Xo.createElement(Ky,null)))}i(jy,"SettingsPage");import{i18n as T0}from"@lingui/core";import{cancelSwap as k0}from"@rango-dev/queue-manager-rango-preset";import{useManager as w0}from"@rango-dev/queue-manager-react";import{Alert as v0}from"@rango-dev/ui";import Ap from"react";import{useParams as x0}from"react-router-dom";import{i18n as zt}from"@lingui/core";import{getCurrentNamespaceOfOrNull as a0,getCurrentStep as s0,getRelatedWalletOrNull as l0}from"@rango-dev/queue-manager-rango-preset";import{Button as HS,Divider as c0,QuoteCost as p0,StepDetails as u0,Typography as wp}from"@rango-dev/ui";import{useWallets as d0}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 m0}from"react-router-dom";import{i18n as xo}from"@lingui/core";var uN=[xo.t("Sunday"),xo.t("Monday"),xo.t("Tuesday"),xo.t("Wednesday"),xo.t("Thursday"),xo.t("Friday"),xo.t("Saturday")];function Xy(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"):`${uN[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Xy,"timeSince");function Yy(t){return t.finishTime?Xy(parseInt(t.finishTime)):Xy(parseInt(t.creationTime))}i(Yy,"getSwapDate");import qr from"react";import{i18n as $a}from"@lingui/core";import{Button as Zy,Divider as dp,MessageBox as dN}from"@rango-dev/ui";import bo from"react";var Jy=i(({onCancel:t,onClose:e})=>bo.createElement(bo.Fragment,null,bo.createElement(dp,{size:20}),bo.createElement(dN,{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(Zy,{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(Zy,{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 Ry,Divider as mp,MessageBox as mN,Typography as fN}from"@rango-dev/ui";import io from"react";var eS=i(({onDelete:t,onClose:e})=>io.createElement(io.Fragment,null,io.createElement(mp,{size:20}),io.createElement(mN,{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(Ry,{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(Ry,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},io.createElement(fN,{variant:"title",size:"medium",color:"primary"},Fa.t("No, Cancel")))),"DeleteContent");import{i18n as gN}from"@lingui/core";import{Button as hN,Divider as yN,MessageBox as SN}from"@rango-dev/ui";import Yo from"react";var tS=i(t=>{let{switchNetworkModalState:e,handleSwitchNetwork:o}=t;return Yo.createElement(Yo.Fragment,null,Yo.createElement(SN,{type:e.type,title:e.title,description:e.description}),e.type==="error"&&Yo.createElement(Yo.Fragment,null,Yo.createElement(yN,{size:"30"}),Yo.createElement(hN,{id:"widget-switch-network-try-again",type:"primary",size:"large",onClick:o},gN.t("Try Again"))))},"NetworkStateContent");import{getCurrentNamespaceOfOrNull as DN,getCurrentStep as $N,getRelatedWalletOrNull as FN}from"@rango-dev/queue-manager-rango-preset";import{WalletState as ON}from"@rango-dev/ui";import{useWallets as UN}from"@rango-dev/wallets-react";import lS from"react";import{i18n as Dn}from"@lingui/core";import{Alert as rS,Button as kN,Checkbox as wN,Divider as za,Image as vN,MessageBox as xN,Spinner as bN,WarningIcon as EN}from"@rango-dev/ui";import{useWallets as IN}from"@rango-dev/wallets-react";import ye,{useState as AN}from"react";import{css as CN,darkTheme as TN,styled as fp}from"@rango-dev/ui";var oS=CN({wordWrap:"break-word",display:"block"}),nS=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",[`.${TN} &`]:{$$color:"$warning600"}});var iS=i(t=>{let{wallet:e,namespace:o,onClose:n}=t,[r,a]=AN(null),{list:s}=bt(),c=ne.use.isActiveTab(),{state:l,connect:p}=IN(),u=s.find(v=>v.type===e.walletType),d=u?.needsNamespace?.data.find(v=>v.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(bN,{color:"info"}):r||m?null:ye.createElement(wN,{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(v){a(v)}},"handleConnect"),k=i(async()=>{if(m){n();return}C()},"handleClickButton"),x=i(()=>{if(!m)return null;let v=u?.isHub?h?.accounts?.[0]?.split(":"):f?.accounts?.[0]?.split(":"),I=v?.[v?.length-1];return I?lo(I):null},"getAddress");return ye.createElement(ye.Fragment,null,ye.createElement(xN,{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(vN,{src:u.image,size:45}),ye.createElement(Ua,null,ye.createElement(EN,{color:"warning",size:10})))}),m&&!d&&ye.createElement(ye.Fragment,null,ye.createElement(za,{size:10}),ye.createElement(rS,{type:"success",variant:"alarm",title:Dn.t("Wallet connected successfully.")})),r&&!d&&ye.createElement(ye.Fragment,null,ye.createElement(za,{size:10}),ye.createElement(rS,{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(kN,{loading:g,type:"primary",id:"widget-connect-wallet-btn",onClick:k,disabled:!c},y()))},"ConnectWalletContent");import{i18n as aS}from"@lingui/core";import{Button as NN,Divider as BN,Image as WN,MessageBox as MN,WarningIcon as LN}from"@rango-dev/ui";import{useWallets as PN}from"@rango-dev/wallets-react";import{detectInstallLink as _N}from"@rango-dev/wallets-shared";import ao from"react";var sS=i(t=>{let{walletType:e}=t,{getWalletInfo:o}=PN(),n=e?o(e):null;if(!n)return null;let r=i(()=>window.open(_N(n.installLink),"_blank"),"handleButtonClick");return ao.createElement(ao.Fragment,null,ao.createElement(MN,{type:"warning",title:aS.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(WN,{src:n.img,size:45}),ao.createElement(Ua,null,ao.createElement(LN,{color:"warning",size:10})))}),ao.createElement(BN,{size:"40"}),ao.createElement(NN,{type:"primary",id:"widget-install-wallet-btn",onClick:r},aS.t("Install")))},"InstallWalletContent");var cS=i(t=>{let{swap:e,onClose:o}=t,{state:n,getWalletInfo:r}=UN(),a=$N(e),s=a?FN(e,a):null,c=s?.walletType,l=c?Kn(r(c),n(c)):null,p=a?DN(e,a):null;return c?l===ON.NOT_INSTALLED?lS.createElement(sS,{walletType:c}):lS.createElement(iS,{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(cS,{swap:c,message:l,onClose:r}),o==="switchNetwork"&&n&&qr.createElement(tS,{message:l,switchNetworkModalState:n,handleSwitchNetwork:p}),o==="delete"&&qr.createElement(eS,{onClose:r,onDelete:()=>{r(),a()}}),o==="cancel"&&qr.createElement(Jy,{onClose:r,onCancel:()=>{r(),s()}}))}i(gp,"SwapDetailsModal");import{i18n as Gr}from"@lingui/core";import{Button as hp,Divider as Vr,MessageBox as dS,TokenAmount as zN,Typography as mS}from"@rango-dev/ui";import ke from"react";import{Link as HN,useNavigate as QN}from"react-router-dom";var pS="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",uS="/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(dS,{type:"success",title:Gr.t("Swap Successful")},ke.createElement(zN,{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(mS,{className:oS(),variant:"body",size:"medium",color:"neutral700",align:"center"},d)):ke.createElement(dS,{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(HN,{to:uS},ke.createElement(nS,{src:pS,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(mS,{variant:"title",size:"medium",color:"primary"},Gr.t("See Details"))))}i(yp,"SwapDetailsCompleteModal");import{i18n as qa}from"@lingui/core";import{CopyIcon as t0,DoneIcon as o0,IconButton as n0,RangoExplorerIcon as r0,Tooltip as DS,Typography as $S,useCopyToClipboard as i0}from"@rango-dev/ui";import Mt from"react";import e0 from"react";import{i18n as YN}from"@lingui/core";import{Alert as MS,IconButton as ZN,LinkIcon as JN}from"@rango-dev/ui";import Eo,{Fragment as RN}from"react";import{Alert as GN,ChevronDownIcon as VN,IconButton as KN}from"@rango-dev/ui";import $n,{useState as jN}from"react";import{css as Kr,darkTheme as fS,styled as Ut,Typography as qN}from"@rango-dev/ui";var gS=Ut(ce,{overflowY:"auto","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${fS} &`]:{color:"$secondary500"}}}}}),hS=Ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),yS=Ut("div",{position:"sticky",top:0,zIndex:10,backgroundColor:"$background"}),SS=Ut("div",{padding:"$0 $20 $20 $20"}),IY=Ut("div",{display:"flex",flexDirection:"column",gap:"$10"}),CS=Ut("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),AY=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",[`.${fS} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),TS=Kr({padding:"$5 0"}),Ha=Kr({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),kS=Kr({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),wS=Kr({width:"100%",padding:"0 $20 $10"}),vS=Ut("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),xS=Ut("div",{display:"flex",flexDirection:"column",gap:"$5"}),Qa=Ut(qN,{wordBreak:"break-word"});import{styled as Sp}from"@rango-dev/ui";var bS=Sp("div",{display:"flex",flexDirection:"column",gap:"$10"}),ES=Sp("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),IS=Sp("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function AS(t){let{message:e}=t,[o,n]=jN(!1);return $n.createElement(GN,{id:"widget-failed-swap-details-alert",type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&$n.createElement(KN,{id:"widget-swap-details-failed-btn",onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},$n.createElement(ES,{rotated:o},$n.createElement(VN,{size:12,color:"gray"}))),footer:$n.createElement(IS,{open:o},$n.createElement(Qa,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(AS,"FailedAlert");import{i18n as NS}from"@lingui/core";import{Alert as Cp,Button as BS}from"@rango-dev/ui";import{PendingSwapNetworkStatus as XN}from"rango-types";import jr from"react";function WS(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(BS,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{n("switchNetwork"),o()}},NS.t("Change"))}):a===XN.WaitingForConnectingWallet?jr.createElement(Cp,{type:"warning",title:r.shortMessage,id:"widget-swap-details-warning-alert-connect-wallet-alert",action:jr.createElement(BS,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{n("connectWallet")}},NS.t("Connect"))}):jr.createElement(Cp,{id:"widget-swap-details-short-alert",type:"warning",title:r.shortMessage})}i(WS,"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(bS,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(RN,{key:m},Eo.createElement(MS,{id:"widget-swap-details-tx-alert",type:y&&(S&&"loading"||C&&"error")||"success",title:f.description?`${f.description} Tx`:YN.t("View transaction"),action:f.url&&Eo.createElement(ZN,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(f.url,"_blank")},Eo.createElement(JN,{size:12}))}))}),d&&Eo.createElement(MS,{id:"widget-swap-details-loading-alert",type:"loading",title:a.shortMessage}),s.status!=="failed"&&l&&Eo.createElement(WS,{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a}),s.status==="failed"&&Eo.createElement(AS,{message:a}))}i(Tp,"SwapDetailsAlerts");var LS=2e3;var PS=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:e0.createElement(Tp,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function _S(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(_S,"getStepState");function FS(t){let{requestId:e}=t,[o,n]=i0(LS);return Mt.createElement(yS,{className:Zo()},Mt.createElement($S,{variant:"label",size:"large",color:"neutral700"},qa.t("Request ID")),Mt.createElement("div",{className:Ha()},Mt.createElement($S,{variant:"label",size:"small",color:"neutral700"},e),Mt.createElement(DS,{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(n0,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:n.bind(null,e||"")},o?Mt.createElement(o0,{size:16,color:"secondary"}):Mt.createElement(t0,{size:16,color:"gray"}))),Mt.createElement(vS,{target:"_blank",href:`${eu}/swap/${e}`},Mt.createElement(DS,{container:B(),content:qa.t("View on Rango Explorer"),side:"bottom"},Mt.createElement(r0,{size:20})))))}i(FS,"RequestIdRow");import{i18n as OS}from"@lingui/core";import{Typography as US}from"@rango-dev/ui";import kp from"react";function zS(t){let{date:e,isFinished:o}=t;return kp.createElement("div",{className:Zo()},kp.createElement(US,{variant:"label",size:"large",color:"neutral700"},o?OS.t("Finished at"):OS.t("Created at")),kp.createElement(US,{variant:"label",size:"small",color:"neutral700"},e))}i(zS,"SwapDateRow");var f0=3e3;function bp(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:c}=d0(),l=T().blockchains(),p=T().swappers(),{findToken:u}=T(),d=H().use.retry(),f=m0(),h=xp(null),[g,m]=Ga(!1),[y,S]=Ga(null),[C,k]=Ga(null),[x,v]=Ga(null),I=xp(y),N=xp(C),b=Ne.use.getNotifications(),E=Ne.use.removeNotification(),w=b(),A=s0(e),M=A?.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=Yd(e),X=A?a0(e,A):null,ae=A?l0(e,A):null,Se=Yy(e),at=Zd(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=Xd(e,A,c),j=PS({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,wC=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(xS,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(()=>{w.find(Lt=>Lt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),E(e.requestId),U()):x&&v(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,N.current=C,y==="switchNetwork"&&C?.type==="success"){let Me=setTimeout(()=>{I.current==="switchNetwork"&&N.current?.type==="success"&&U()},f0);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(HS,{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(HS,{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(gS,{compact:!0,ref:h},we.createElement(FS,{requestId:o}),we.createElement(zS,{date:Se,isFinished:!!e.finishTime}),we.createElement("div",{className:kS()},we.createElement(p0,{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:wS()},we.createElement(wp,{variant:"title",size:"small"},zt.t("Swaps steps"))),we.createElement(c0,{size:8}),we.createElement(SS,null,j.map((Me,Lt)=>{let Fp=Lt,Hn=e.steps[Lt]&&_S(e.steps[Lt]),vC=Hn==="error"||Hn==="in-progress"||Hn==="warning"||Hn==="completed"&&Lt===j.length-1;return we.createElement(u0,{className:"widget-swap-details-step-item-container",key:Fp,step:Me,type:"swap-progress",ref:h,state:Hn,hasSeparator:Lt!==0,tabIndex:Fp,isFocused:vC,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:()=>v(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:wC}))}i(bp,"SwapDetails");import{i18n as Ka}from"@lingui/core";import{Divider as VS,NotFound as C0,Skeleton as Yr,Typography as ja}from"@rango-dev/ui";import Ie from"react";import{i18n as g0}from"@lingui/core";import{Divider as h0,Skeleton as y0,Typography as S0}from"@rango-dev/ui";import Ee from"react";import{css as Ht,styled as Ep}from"@rango-dev/ui";var qS=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"}),t9=Ht({display:"flex",justifyContent:"space-between",alignItems:"center"}),o9=Ht({paddingTop:"$15",display:"flex"}),n9=Ht({padding:"$15 $0"}),r9=Ht({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),i9=Ht({paddingBottom:"$10"}),a9=Ht({display:"flex",justifyContent:"start",alignItems:"center"}),s9=Ht({paddingTop:"$5",display:"flex",alignItems:"center"}),l9=Ht({display:"flex",alignItems:"center"}),c9=Ht({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),GS=Ht({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Ip(){return Ee.createElement(qS,null,Ee.createElement(wr,{type:"swap-preview"}),Ee.createElement("div",{className:"swaps-steps"},Ee.createElement(S0,{variant:"title",size:"small"},g0.t("Swaps steps"))),Ee.createElement(Ee.Fragment,null,Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1}),Ee.createElement("div",{className:GS()},Ee.createElement(h0,{direction:"horizontal",size:20}),Ee.createElement(y0,{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 KS(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(hS,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(VS,{direction:"horizontal",size:4}),Ie.createElement(Yr,{width:16,height:16,variant:"rectangular"}),Ie.createElement(VS,{direction:"horizontal",size:4}),Ie.createElement(Yr,{width:16,height:16,variant:"rectangular"}))),Ie.createElement("div",{className:Zo()},Ie.createElement(ja,{className:TS(),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(CS,null,Ie.createElement(C0,{title:Ka.t("Not found"),description:Ka.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(KS,"SwapDetailsPlaceholder");function jS(){let{manager:t,state:e}=w0(),o=!e.loadedFromPersistor,n=kt(t),{requestId:r}=x0(),a=Qe(),{fetchStatus:s}=T();if(!r)return Ap.createElement(v0,{containerStyles:{margin:"20px"},type:"error",title:T0.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&&k0(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(KS,{requestId:r,showSkeleton:c}):Ap.createElement(bp,{swap:d,requestId:r,onCancel:p,onDelete:u})}i(jS,"SwapDetailsPage");import{i18n as XS}from"@lingui/core";import{Divider as b0,getCategoriesCount as E0,SelectableCategoryList as I0,styled as ZS,Typography as A0,Wallet as N0}from"@rango-dev/ui";import Qt,{useState as YS}from"react";var B0=ZS("div",{display:"flex",justifyContent:"center",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5"}),W0=ZS(ce,{textAlign:"center"});function JS(){let{fetchStatus:t}=T(),[e,o]=YS("ALL"),n=T().blockchains(),{config:r}=T(),[a,s]=YS(),c=ne.use.isActiveTab(),{list:l}=bt(),p=Bu(l,n),d=E0(p)!==1,f=Wu(l,e),h=i(g=>{pu(l,r.multiWallets)||s(g)},"handleWalletItemClick");return Qt.createElement(se,{header:{title:XS.t("Connect Wallets")}},Qt.createElement(W0,null,d&&Qt.createElement(Qt.Fragment,null,Qt.createElement(I0,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Qt.createElement(b0,{size:24})),Qt.createElement(A0,{variant:"title",size:"xmedium",align:"center"},XS.t("Choose a wallet to connect.")),Qt.createElement(B0,null,f.map((g,m)=>{let y=`wallet-${m}-${g.type}`;return Qt.createElement(N0,{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(JS,"WalletsPage");function RS(){return lm(),Js(),M0([{path:$.home,element:Ue.createElement(gy,null)},{path:$.routes,element:Ue.createElement(Ty,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(jy,null)},{path:$.languages,element:Ue.createElement(yy,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(hh,null)},{path:$.addCustomTokens,children:[{index:!0,element:Ue.createElement(sf,null)},{path:$.blockchains,element:Ue.createElement(Ba,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:Ue.createElement(Dh,null)},{path:$.swapDetails,element:Ue.createElement(jS,null)}]},{path:$.wallets,element:Ue.createElement(JS,null)},{path:$.confirmSwap,element:Ue.createElement(eh,null)}])}i(RS,"AppRoutes");import{useQueueManager as Y0}from"@rango-dev/queue-manager-rango-preset";import{isEvmBlockchain as Z0}from"rango-sdk";import{useContext as J0,useEffect as Mp,useState as uC}from"react";import{Provider as F0}from"@rango-dev/wallets-react";import Xa,{createContext as O0,useEffect as rC,useMemo as U0,useRef as iC}from"react";import{useEffect as P0}from"react";import{Provider as L0}from"@rango-dev/wallets-core";function eC(t){return t.map(e=>typeof e=="string"?e:e instanceof L0?e.id:e.config.type).join("-")}i(eC,"hashProviders");function Np(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=T(),a=n();return P0(()=>{o(),r()},[eC(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(Np,"useWalletProviders");import{legacyFormatAddressWithNetwork as _0,legacyReadAccountAddress as tC}from"@rango-dev/wallets-core/legacy";import{Events as On}from"@rango-dev/wallets-react";import{isEvmBlockchain as D0}from"rango-sdk";function oC(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=T(),{onConnectWalletHandler:c,onDisconnectWalletHandler:l}=t,p=s().filter(D0).map(m=>m.name),u=i((m,y)=>{let[S,,C,k,x]=m,v={walletType:S,network:k.network??void 0,accounts:C};c.current?c.current(v):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),v=[],I=[];if(S?.forEach(b=>{let{network:E}=tC(b);p.includes(E)?v.push(b):I.push(b)}),r.filter(b=>b.walletType===m).map(b=>_0(b.address,b.chain)).length>0){if(v.length>0){let b=ds(m,v,p,x,k.isContractWallet);a(m,{chains:b.map(E=>E.chain)})}I.length>0&&a(m,{chains:I.map(b=>{let{network:E}=tC(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(oC,"useUpdates");import{LegacyEvents as $0}from"@rango-dev/wallets-core/legacy";function nC(t,e){let[o,n,r,a,s]=e;n!==$0.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i(nC,"propagateEvents");var Ya=O0({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function z0(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=iC(),u=iC(),{handler:d}=oC({onConnectWalletHandler:p,onDisconnectWalletHandler:u});rC(()=>{n().catch(console.log)},[]),rC(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let f=ne.use.isActiveTab(),h=U0(()=>({onConnectWallet:g=>{p.current=g},onDisconnectWallet:g=>{u.current=g}}),[]);return Xa.createElement(Ya.Provider,{value:h},Xa.createElement(F0,{allBlockChains:a,providers:l,onUpdateState:(g,m,y,S,C)=>{let k=[g,m,y,S,C];d(...k),t.onUpdateState&&nC(t.onUpdateState,k)},autoConnect:!!f,configs:{wallets:s.wallets}},t.children))}i(z0,"Main");function Za(t){let{config:e,...o}=t;return Xa.createElement(Yu,{config:e},Xa.createElement(z0,{...o,config:e}))}i(Za,"WidgetWallets");import{globalCss as H0}from"@rango-dev/ui";var aC=i(()=>H0({"@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 q0,useRef as G0}from"react";function sC(){let{connect:t,state:e}=Q0(),o=G0({}),{fetchStatus:n}=T(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);q0(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(sC,"useForceAutoConnect");import{isApprovalTX as V0,RouteEventType as lC,StepEventType as cC,StepExecutionEventStatus as K0,WidgetEvents as Ja}from"@rango-dev/queue-manager-rango-preset";import{useEffect as pC}from"react";function Bp(){let t=Ne.use.setNotification(),{connectedWallets:e,fetchBalances:o,customTokens:n}=T();pC(()=>{let r=i(a=>{let{event:s,step:c,route:l}=a;if(s.type===cC.TX_EXECUTION&&s.status===K0.TX_SENT&&!V0(c)||s.type===cC.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]),pC(()=>{let r=i(a=>{let{event:s,route:c}=a;(s.type===lC.FAILED||s.type===lC.SUCCEEDED)&&t(s,c)},"handleRouteEvent");return ve.on(Ja.RouteEvent,r),()=>ve.off(Ja.RouteEvent,r)},[ve])}i(Bp,"useSubscribeToWidgetEvents");import{useManager as j0}from"@rango-dev/queue-manager-react";import{useEffect as X0}from"react";function Wp(){let{isSynced:t,syncNotifications:e}=Ne(),{manager:o,state:n}=j0();X0(()=>{Ne.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(kt(o))},[Ne.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Wp,"useSyncNotifications");function Lp(){sC(),aC(),Bp(),Wp();let t=T().blockchains(),{canSwitchNetworkTo:e}=Yi(),[o,n]=uC(null),[r,a]=uC(),s=J0(Ya),c=t.filter(Z0);Mp(()=>()=>am(),[]),Mp(()=>()=>sm(),[]),Y0({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 R0}from"@rango-dev/ui";var dC=R0("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(eB,{language:o},Pp.createElement(dC,{id:"swap-container",className:e()},Pp.createElement(RS,null)))}i(Jo,"Main");import{setSolanaSignerConfig as TB}from"@rango-dev/signer-solana";import Dp,{useEffect as $p,useMemo as kB}from"react";function mC(){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(mC,"useFetchApiConfig");import{useState as tB}from"react";var oB=i(()=>{let[t,e]=tB(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"),fC=oB;import{checkWaitingForNetworkChange as nB,makeQueueDefinition as rB}from"@rango-dev/queue-manager-rango-preset";import{Provider as iB}from"@rango-dev/queue-manager-react";import{useWallets as aB}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as sB}from"@rango-dev/wallets-shared";import{isEvmBlockchain as lB}from"rango-types";import cB,{useMemo as pB}from"react";function uB(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s,hubProvider:c}=aB(),l=pB(()=>rB({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(v=>({accounts:[v],name:v.chain}))},h=i(async(v,I)=>a(v,I.network,I)?await r(v,[I]):void 0,"switchNetwork"),g=i(v=>!!s(v).mobileWallet,"isMobileWallet"),m=d.filter(v=>v.enabled).reduce((v,I)=>(v[I.name]=I,v),{}),y=d.filter(lB),S=i(v=>{let{supportedChains:I}=s(v);return jn(I)},"getSupportedChainNames"),C=e(),k={meta:{blockchains:m,evmBasedChains:y,evmNetworkChainInfo:sB(y),getSupportedChainNames:S},getSigners:o,wallets:f,providers:C,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:g,hubProvider:c},x=ne.use.isActiveTab();return cB.createElement(iB,{queuesDefs:[l],context:k,onPersistedDataLoaded:v=>{nB(v)},isPaused:!x},t.children)}i(uB,"QueueManager");var gC=uB;import{useManager as hB}from"@rango-dev/queue-manager-react";import yB,{createContext as SB,useContext as CB}from"react";function hC(){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(hC,"useUpdateQuoteInputs");import{cancelSwap as dB,getCurrentNamespaceOfOrNull as mB,getCurrentStep as fB,getRelatedWalletOrNull as gB}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&&dB(o)}getCurrentStepInfo(e){let o=fB(e);return{step:o,wallet:o?gB(e,o):null,network:o?mB(e,o)?.network:null}}};var yC=SB(void 0);function _p(t){let{manager:e}=hB(),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=xu(a()),d=T().blockchains(),f=T().tokens(),h=T().swappers(),g=T().fetchStatus,m=wo().resetLanguage,y=Ne().getNotifications(),S=Ne().clearNotifications,C=hC(),{fromBlockchain:k,toBlockchain:x,fromToken:v,toToken:I,inputAmount:N}=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:v?{symbol:v.symbol,blockchain:v.blockchain,address:v.address}:null,toBlockchain:x?.name??null,toToken:I?{symbol:I.symbol,blockchain:I.blockchain,address:I.address}:null,requestAmount:N},updateQuoteInputs:C}};return yB.createElement(yC.Provider,{value:b},t.children)}i(_p,"WidgetInfo");function SC(){let t=CB(yC);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(SC,"useWidget");function Un(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{fetchApiConfig:r}=mC(),{handleLoadCustomFont:a}=fC();return $p(()=>{r().catch(console.log)},[]),$p(()=>{n&&a(n)},[n]),kB(()=>{Mu({API_KEY:o?.apiKey||oi,BASE_URL:o?.apiUrl||Rp})},[o.apiKey,o.apiUrl]),$p(()=>{t.config?.signers?.customSolanaRPC&&TB("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),Dp.createElement(Za,{config:o,onUpdateState:e},Dp.createElement(gC,{apiKey:o.apiKey},Dp.createElement(_p,null,t.children)))}i(Un,"WidgetProvider");function CC(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(CC,"Refuel");import ts from"react";function TC(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(TC,"Widget");function kC(){let{on:t,off:e}=ve;return{on:t,off:e}}i(kC,"useWidgetEvents");var rte={DerivationPath:rr,Namespaces:tr,Detached:nr,isOnDerivationPath:ar,isOnNamespace:ir,isOnDetached:Ao};export{Iee as EventSeverity,ln as MainEvents,$ee as Networks,Uee as PendingSwapNetworkStatus,ys as QuoteEventTypes,CC as Refuel,Aee as RouteEventType,ss as SUPPORTED_FONTS,rte as StatefulConnect,Nee as StepEventType,Bee as StepExecutionBlockedEventStatus,Wee as StepExecutionEventStatus,wd as SwapModeContext,Re as UI_ID,Cs as UiEventTypes,Ss as WalletEventTypes,_ee as WalletEvents,Fee as WalletTypes,TC as Widget,ln as WidgetEvents,Un as WidgetProvider,Za as WidgetWallets,dl as customizedThemeTokens,is as pickProviderVersionWithFallbackToLegacy,Lee as readAccountAddress,en as useStatefulConnect,bt as useWalletList,Yi as useWallets,SC as useWidget,kC as useWidgetEvents,IT as widgetEventEmitter};
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};
3
3
  //# sourceMappingURL=index.js.map