@rango-dev/widget-embedded 0.50.1-next.5 → 0.50.1-next.7
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/components/WalletStatefulConnect/ConnectStatus.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/ConnectStatus.styles.d.ts +0 -160
- package/dist/components/WalletStatefulConnect/ConnectStatus.styles.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Detached.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +7 -7
- package/src/components/WalletStatefulConnect/ConnectStatus.styles.ts +0 -6
- package/src/components/WalletStatefulConnect/ConnectStatus.tsx +7 -6
- package/src/components/WalletStatefulConnect/Detached.tsx +13 -2
- package/src/components/WalletStatefulConnect/Namespaces.tsx +6 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var TC=Object.defineProperty;var i=(t,e)=>TC(t,"name",{value:e,configurable:!0});import{EventSeverity as Bee,RouteEventType as Lee,StepEventType as Mee,StepExecutionBlockedEventStatus as Pee,StepExecutionEventStatus as _ee}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as $ee}from"@rango-dev/wallets-core/legacy";import{useWallets as Ri,Events as Oee}from"@rango-dev/wallets-react";import{Networks as zee,WalletTypes as Hee}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as qee}from"rango-types";import{Divider as UT}from"@rango-dev/ui";import po,{useEffect as zT,useRef as HT,useState as bd}from"react";import{WalletState as wC}from"@rango-dev/ui";import{useWallets as vC}from"@rango-dev/wallets-react";import{useReducer as bC}from"react";function zp(t){return!!t.derivationPath}i(zp,"isStateOnDerivationPathStep");function Hp(t){return!!t.namespace}i(Hp,"isStateOnNamespace");var ei={status:"init",namespace:null,derivationPath:null,selectedNamespaces:null};function Qp(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 ei;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:ei;default:throw new Error("Action hasn't been defined.")}}i(Qp,"reducer");function Ro(){let{state:t,disconnect:e,connect:o}=vC(),[n,r]=bC(Qp,ei),a=i(async(d,f,h)=>{r({type:"reset"});try{let g=f?.map(m=>({...m,network:void 0}));return await o(d,g),{status:"connected"}}catch(g){let m=g?.message?`Error: ${g.message}`:"An unknown error happened during connecting wallet.";throw new Error(m,{cause:g})}},"runConnect"),s=i(async(d,f)=>{if(d.state===wC.DISCONNECTED){let g=!!d.isHub,m=g?d.properties?.find(y=>y.name==="namespaces")?.value:d.needsNamespace,C=g?d.properties?.find(y=>y.name==="derivationPath")?.value:d.needsDerivationPath;if(!m?.data?.length)return await a(d.type,void 0,f);if(m?.data.length&&m.data.length>1)return r({type:"needsNamespace",payload:{targetWallet:d,defaultSelectedChains:f?.defaultSelectedChains}}),{status:"namespace"};if(m?.data.length===1&&m.data[0]){if(C){let y=m.data[0];return r({type:"needsDerivationPath",payload:{providerType:d.type,providerImage:d.image,namespace:y.value}}),{status:"derivation-path"}}return await a(d.type,m?.data?.map(y=>({namespace:y.value})),f)}}if(d.isHub){let g=d.properties?.find(m=>m.name==="namespaces")?.value;if(g?.data.length&&g.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(T=>T.name==="namespaces")?.value:d.needsNamespace,m=h?d.properties?.find(T=>T.name==="derivationPath")?.value:d.needsDerivationPath,C=g?.selection==="single",y=f[0];if(!y)throw new Error("To confirm a namespace, you should select at least one namespace.");if(C&&m)return r({type:"needsDerivationPath",payload:{providerType:d.type,providerImage:d.image,namespace:y}}),{status:"derivation-path"};if(!Hp(n))throw new Error("Something went wrong on handling namespace. Please retry.");let S=f.map(T=>({namespace:T}));return r({type:"detached",payload:{targetWallet:d,selectedNamespaces:S??null}}),{status:"Detached"}},"handleNamespace"),l=i(async(d,f)=>{if(!f)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!zp(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let h=n.derivationPath.providerType,m=[{namespace:n.derivationPath.namespace,derivationPath:f}],y=!!d.isHub?d.properties?.find(S=>S.name==="namespaces")?.value:d.needsNamespace;return y?.data&&y.data.length>1?(r({type:"detached",payload:{targetWallet:d,selectedNamespaces:m??null,derivationPath:f}}),{status:"Detached"}):await a(h,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(Ro,"useStatefulConnect");import{WalletState as Ns}from"@rango-dev/ui";import{useWallets as Dk}from"@rango-dev/wallets-react";import{detectMobileScreens as $k,KEPLR_COMPATIBLE_WALLETS as Fk,WalletTypes as Jn}from"@rango-dev/wallets-shared";import{useCallback as Ok,useEffect as Uk}from"react";import Nk,{createContext as Wk,useContext as Bk,useEffect as Lk,useRef as Mk}from"react";import{create as Ik}from"zustand";import{persist as Ak}from"zustand/middleware";import{allProviders as xC}from"@rango-dev/provider-all";var as=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()}},en=new as;import{defineVersions as Gp,pickVersion as Vp,Provider as ss}from"@rango-dev/wallets-core";function Kp({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=jp(a);return s instanceof ss?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 ss?o.push(Gp().version("1.0.0",n).build()):o.push(Gp().version("0.0.0",n).build())}),o}return t}i(Kp,"matchAndGenerateProviders");function jp(t){try{return Vp(t,"1.0.0")[1]}catch{return Vp(t,"0.0.0")[1]}}i(jp,"pickProviderVersionWithFallbackToLegacy");function Xp(t){return t.map(o=>jp(o)).map(o=>o instanceof ss?o.id:o.config.type)}i(Xp,"configWalletsToWalletName");function ti(t,e){return e.find(o=>o.name===t)?.displayName}i(ti,"getBlockchainDisplayNameFor");function yt(t,e){return e.find(o=>o.name===t)?.shortName}i(yt,"getBlockchainShortNameFor");function Yp(t,e){return e.find(o=>o.name===t)?.logo}i(Yp,"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 ls(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(ls,"isTokenNative");function St(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(St,"createTokenHash");function tn(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(tn,"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 oi(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(oi,"getSupportedBlockchainsFromConfig");function Jp(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(Jp,"makeProvidersOptionsFromConfig");var on={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"}},EC={clientUrl:void 0},IC={liquiditySources:void 0};function Zp(t){let e=Jp(t),o={walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t.wallets,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0,tonConnect:e?.tonConnect?.manifestUrl?{manifestUrl:e?.tonConnect.manifestUrl}:void 0};return xC(o).map(a=>a())}i(Zp,"generateProviders");var Rp=i((t,e,o)=>{let n=Zp({...on,...t});return{config:{...on,...t},iframe:EC,campaignMode:IC,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}});en.set("supportedSourceTokens",l),en.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=Zp(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=Jp(a);return Kp({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as eu}from"rango-types";var tu=[eu.EVM,eu.SOLANA],ni="https://raw.githubusercontent.com/rango-exchange/assets/refs/heads/main/common/unknown-image.png";import{RangoClient as HC}from"rango-sdk";import{UI_ID as AC}from"@rango-dev/ui";var ri="c6381a79-2817-4602-83bf-6a641a409e32",ou="https://api.rango.exchange",nu="https://explorer.rango.exchange",ot={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...AC};import{BlockchainCategories as _C,WalletState as pt}from"@rango-dev/ui";import{legacyReadAccountAddress as DC}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as $C,getCosmosExperimentalChainInfo as FC,isEvmAddress as OC,KEPLR_COMPATIBLE_WALLETS as WB,Networks as bu}from"@rango-dev/wallets-shared";import rn from"bignumber.js";import{isCosmosBlockchain as UC}from"rango-types";import NC from"bignumber.js";var de=new NC(0);import{WalletTypes as WC}from"@rango-dev/wallets-shared";var Wo="~",ru=[WC.LEAP];import{BlockchainCategories as ps,WalletState as PC}from"@rango-dev/ui";import{TransactionType as ii}from"rango-sdk";var iu="Roboto",cs=[{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 nn(t){return Array.from(new Set(t))}i(nn,"removeDuplicateFrom");function ai(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(ai,"debounce");function ct(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(ct,"containsText");function lu(t,e){return t.toLowerCase()===e.toLowerCase()}i(lu,"exactText");function cu(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(cu,"startWithText");var W=i(()=>document.getElementById(ot.SWAP_BOX_ID),"getContainer"),Bo=i(()=>document.getElementById(ot.EXPANDED_BOX_ID),"getExpanded");function pu(t,e,o){let n=!!e&&lu(e,t),r=!!o&&lu(o,t);return n!==r?n?-1:1:0}i(pu,"compareExactMatchText");function us(t,e,o){let n=!!e&&ct(e,t),r=!!o&&ct(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(us,"compareContainsText");function ds(t,e,o){let n=!!e&&cu(e,t),r=!!o&&cu(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ds,"compareStartWithText");function uu(t,e,o){if(!o)return 0;let n=pu(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=pu(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=ds(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=us(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ds(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=us(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=ds(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=us(o,t.address,e.address);if(r!==0)return r}return 0}i(uu,"compareWithSearchFor");var si=i((t,e)=>{switch(e){case ps.ALL:return!0;case ps.UTXO:return t===ii.TRANSFER;case ps.OTHER:return t!==ii.TRANSFER&&t!==ii.COSMOS&&t!==ii.EVM;default:return t===e}},"isBlockchainTypeInCategory"),du=i(t=>cs.find(o=>o.value===t)?.url,"getFontUrlByName");function mu(t,e){let o=!!t.find(n=>n.state===PC.CONNECTED);return e===!1&&o}i(mu,"isSingleWalletActive");function fu(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(fu,"memoizedResult");import{BigNumber as wu}from"bignumber.js";function gu(t){return t.replace(/^0+(?=\d)/g,"")}i(gu,"removeLeadingZeros");function hu(t){return t.replace(/^\.(\d+)/,"0.$1")}i(hu,"ensureLeadingZeroForDecimal");function yu(t){return t.replace(/\B(?=(\d{3})+(?!\d))/g,",")}i(yu,"formatThousandsWithCommas");function Su(t){return t.replace(/\s+/g,"-")}i(Su,"replaceSpacesWithDash");function Cu(t){return t.replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"")}i(Cu,"stripTrailingZeros");function li(t){return/^0+(?:\.0+)?$/.test(t)}i(li,"isZeroValue");function ku(t,e=2){let o=`^(?:0|[1-9]\\d*)(?:\\.\\d{1,${e}})?$`;return new RegExp(o).test(t)}i(ku,"isValidCurrencyFormat");function 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"),P=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new wu(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new wu(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 ci=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 vu(t){return li(t)?"0":Cu(t)}i(vu,"sanitizeInputAmount");function Kn(t){return t.connected?pt.CONNECTED:t.connecting?pt.CONNECTING:t.installed?pt.DISCONNECTED:pt.NOT_INSTALLED}i(Kn,"mapStatusToWalletState");function xu(t,e,o,n){return o.filter(r=>!ru.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=nn(u.map(C=>C.type)),m=Kn(t(r));return{title:a,image:s,link:$C(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 fs(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}=DC(l),d=c.length>0,f=c.includes(u),h=u===bu.Unknown;if(d&&!f&&!h)return;let m=u===bu.Unknown&&OC(p);if(h&&!m)return;o.includes(u)||m?r?s(u,p.toLowerCase(),r):c.filter(S=>o.includes(S)).forEach(S=>{s(S,p.toLowerCase())}):s(u,p)}),a}i(fs,"prepareAccountsForWalletStore");function Lo(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(Lo,"getQuoteChains");function Xn(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(Xn,"isAccountAndWalletMatched");var Eu=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?ms(n.usdValue,n.decimals):de.toFixed();return o.plus(r)},new rn(de));return zC(e.toString())},"calculateWalletUsdValue");function zC(t){let e=t.toString().split(".");return e[0]&&(e[0]=yu(e[0])),e.join(".")}i(zC,"numberWithThousandSeparator");var di=i((t,e)=>{let o=FC(Object.entries(t).map(([,n])=>n).filter(UC));return o&&!!o[e]?.experimental},"isExperimentalChain");function ms(t,e){return new rn(t).shiftedBy(-e).toFixed()}i(ms,"representAmountInNumber");function mi(t){if(!t)return null;let e=ms(t.amount,t.decimals),o=t.usdValue?ms(t.usdValue,t.decimals):null,n=P(e,8,8),r=o?P(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(mi,"formatBalance");function Iu(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new rn(t.usdValue).shiftedBy(-t.decimals):de,n=e&&e.usdValue?new rn(e.usdValue).shiftedBy(-e.decimals):de;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new rn(t.amount).shiftedBy(-t.decimals):de,n=e&&e.amount?new rn(e.amount).shiftedBy(-e.decimals):de;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Iu,"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 Au(t,e){return t.map(o=>({isPartiallyConnected:gs(o,e(o.type).namespaces),...o})).sort((o,n)=>+(n.state===pt.CONNECTED&&!n.isPartiallyConnected)-+(o.state===pt.CONNECTED&&!o.isPartiallyConnected)||+(n.state===pt.CONNECTED)-+(o.state===pt.CONNECTED)||+(n.state===pt.DISCONNECTED||n.state===pt.CONNECTING)-+(o.state===pt.DISCONNECTED||o.state===pt.CONNECTING)).map(({isPartiallyConnected:o,...n})=>n)}i(Au,"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 Nu({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Nu,"getAddress");var Wu=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 Lu(t,e){let o=new Set;return t.forEach(r=>{r.blockchainTypes.forEach(a=>{o.add(a)})}),e.filter(r=>o.has(r.type))}i(Lu,"filterBlockchainsByWalletTypes");function Mu(t,e){return e===_C.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(si(n,e))return!0;return!1})}i(Mu,"filterWalletsByCategory");function gs(t,e){if(!t.isHub||!t.needsNamespace||t.state!==pt.CONNECTED)return!1;let n=t.needsNamespace.data.filter(r=>!r.unsupported);return t.needsNamespace.selection==="multiple"&&n.some(r=>!e?.get(r.value)?.connected)}i(gs,"checkIsWalletPartiallyConnected");var hs={API_KEY:ri};function Gt(t){return hs[t]||""}i(Gt,"getConfig");function Pu(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),hs=e,hs}i(Pu,"initConfig");var _u=20,Du=25,ys="theme-widget",Ss=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"),Cs=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 fi,ut=i(()=>fi||(fi=new HC(Gt("API_KEY"),Gt("BASE_URL")),fi),"httpService");import{i18n as Ou}from"@lingui/core";var gi=[.5,1,3],hi=1,an=5,Yn=30,yi=0;var Re=(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))(Re||{});import{WidgetEvents as Fu}from"@rango-dev/queue-manager-rango-preset";var ks=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ks||{}),Ts=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(Ts||{}),ws=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(ws||{}),sn=(a=>(a[a.RouteEvent=Fu.RouteEvent]="RouteEvent",a[a.StepEvent=Fu.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(sn||{});function Si(t,e){let o=t.map(a=>a.swapperGroup),n=[];return nn(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(Si,"getUniqueSwappersGroups");function Uu(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Uu,"sortLiquiditySourcesByGroupTitle");function nt(t,e){return e?.[t]==="hidden"}i(nt,"isFeatureHidden");function ln(t,e){return e?.[t]==="enabled"}i(ln,"isRoutingEnabled");var zu=i((t,e,o)=>nt("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");function cn(t){return t==yi?{type:"error",message:Ou.t("Slippage must be greater than or equal to 0.01")}:t>an&&t<=Yn?{type:"warning",message:Ou.t("Your transaction is at risk of being frontrun due to high slippage tolerance."),quoteValidation:{type:3,slippage:t.toString()}}:null}i(cn,"getSlippageValidation");var Hu=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=oi({config:a}),p=r;return l.length>0&&(p=p.filter(u=>l.includes(u.name))),p.filter(u=>tu.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=en.get(u);d?.length||(d=qn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),en.set(u,d)),d=zu(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?!!(ct(g.symbol,o.searchFor)||ct(g.address||"",o.searchFor)||ct(g.name||"",o.searchFor)):!0).sort((g,m)=>{let C=e().isTokenPinned(g,o.type),y=e().isTokenPinned(m,o.type);if(C!==y)return C?-1:1;if(o.getBalanceFor){let A=o.getBalanceFor(g),N=o.getBalanceFor(m),b=Iu(A,N);if(b!==0)return b}let S=l.get(g.blockchain),T=l.get(m.blockchain),v=ls(g,S),w=ls(m,T);if(v!==w)return v?-1:1;if(g.isPopular!==m.isPopular)return g.isPopular?-1:1;if(o.searchFor){let A=uu(g,m,o.searchFor);if(A)return A}return g.isSecondaryCoin!==m.isSecondaryCoin?g.isSecondaryCoin?1:-1:S&&T?S.sort-T.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(Uu)},fetch:async()=>{try{let{routing:o}=e().config,n=ln("enableCentralizedSwappers",o),r=await ut().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,c={},l=[],p=r.popularTokens,u=r.swappers.filter(h=>h.enabled),d=new Set;r.tokens.forEach(h=>{d.add(h.blockchain),l.push(h)}),r.blockchains.sort((h,g)=>h.sort-g.sort).forEach(h=>{h.enabled&&d.has(h.name)&&a.set(h.name,h)}),l.forEach(h=>{let g=St(h);c[h.blockchain]||(c[h.blockchain]=[]),s.set(g,h),c[h.blockchain]?.push(g)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:c,_popularTokens:p,_swappers:u})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as QC,Catalonia as qC,Chinese as Qu,Denmark as GC,English as VC,Finland as KC,French as jC,German as XC,Greece as YC,Hungary as ZC,India as JC,Indonesian as RC,Italian as ek,Japanese as tk,Korea as ok,Lithuania as nk,Malay as rk,Netherlands as ik,Pakistan as ak,Philippines as sk,Poland as lk,Portuguese as ck,Russian as pk,SaudiArabia as uk,Serbia as dk,Slovakia as mk,SouthAfrica as fk,Spanish as gk,Swahili as hk,Swedish as yk,Thai as Sk,Turkish as Ck,Ukrainian as kk,Vietnamese as Tk}from"@rango-dev/ui";var qu=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:fk},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:uk},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:QC},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:qC},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Qu},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Qu},{title:"Danish",label:"Dansk",local:"da",SVGFlag:GC},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:ik},{title:"English",label:"English",local:"en",SVGFlag:VC},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:sk},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:KC},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:jC},{title:"German",label:"Deutsch",local:"de",SVGFlag:XC},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:YC},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:JC},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:ZC},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:RC},{title:"Italian",label:"Italiana",local:"it",SVGFlag:ek},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:tk},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:ok},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:nk},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:rk},{title:"Polish",label:"Polski",local:"pl",SVGFlag:lk},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:ck},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:pk},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:dk},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:mk},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:gk},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:hk},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:yk},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:Sk},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:Ck},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:kk},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:ak},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:Tk}],pn="en";var Gu=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:hi,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=nn(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=nt("theme",n),s=nt("language",n),c=nt("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||pn},...c&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||pn}})},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=oi({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import As from"bignumber.js";import wk from"mitt";var we=wk(),vk={on:we.on,off:we.off};var Vu=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 Ku from"bignumber.js";function Vt(t){return`${t.blockchain}${Wo}${t.address}${Wo}${t.symbol}`}i(Vt,"createAssetKey");function ju(t,e){return`${Vt(e)}${Wo}${t}`}i(ju,"createBalanceKey");function Zn(t){let[e,o,n]=t.split(Wo);return!e||!o||!n?null:{address:o==="null"?null:o,blockchain:e,symbol:n}}i(Zn,"extractAssetFromBalanceKey");function bs(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 Ku(r??de).multipliedBy(o[s].amount).toString():""})})}),o}i(bs,"computeNextBalancesWithNewPrices");function xs(t,e){let o={};return t.balances?.forEach(n=>{let r=ju(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,c=n.price??e().findToken(n.asset)?.usdPrice,l=c?new Ku(c??de).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:l};o[r]=p}),o}i(xs,"createBalanceStateForNewAccount");function Es(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(Es,"updateAggregatedBalanceStateForNewAccount");function bk(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(bk,"removeBalanceFromAggregatedBalance");function Is(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=>ju(d.address,{address:p.address,blockchain:d.chain,symbol:p.symbol})===l)?a=bk(a,l):s[l]&&(r[l]=s[l])}),{_balances:r,_aggregatedBalances:a}}i(Is,"computeNextStateAfterWalletBalanceRemoval");function xk(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(xk,"matchWalletDetailsWithConnectedWallet");var Ek=fu(),Xu=Vu((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:xk(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 ut().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};bs(m,g,d);let C=xs(g,e);f=Es(f,C),d={...d,...C}}),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&&(we.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}=Is(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(we.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 ut().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};bs(f,d,l);let{_balances:h,_aggregatedBalances:g}=Is(f,r,{chains:[d.blockChain]});if(p=g,l=h,!e().connectedWallets.find(C=>C.walletType===r&&C.address===d.address&&C.chain===d.blockChain))return;let m=xs(d,e);p=Es(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 As(u.amount),f=new As(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(Wo);return l&&p===o&&(s[c]=l),s},{})},getConnectedWalletsDetails:()=>Ek(()=>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 As(l.amount).shiftedBy(-l.decimals):de;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 Yu(t){return Ik()(Ak((...e)=>({...Xu(...e),...Hu(...e),...Gu(...e),...Rp(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(Yu,"createAppStore");var Zu=Wk(null);function k(){let t=Bk(Zu);if(Lk(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(k,"useAppStore");function Ju(t){let e=Mk();return e.current||(e.current=Yu(t.config)),Nk.createElement(Zu.Provider,{value:e.current},t.children)}i(Ju,"AppStoreProvider");import{useWallets as Pk}from"@rango-dev/wallets-react";import{detectMobileScreens as _k}from"@rango-dev/wallets-shared";function un(){let{getWalletInfo:t}=Pk(),{config:e}=k(),o=_k();function n(s){let c=t(s),l=e.deepLinking?.appHost,p=e.deepLinking?.targetUrl;if(!(!l||!p))return c.generateDeepLink?.({appHost:l,targetUrl:p})}i(n,"getWalletDeepLink");function r(s){let c=n(s);return c&&o?c:t(s).installLink}i(r,"getWalletLink");function a(s){return!!n(s)&&o}return i(a,"checkHasDeepLink"),{getWalletDeepLink:n,getWalletLink:r,checkHasDeepLink:a}}i(un,"useDeepLink");function vt(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=k(),{state:r,getWalletInfo:a}=Dk(),s=k().blockchains(),{handleDisconnect:c}=Ro(),{checkHasDeepLink:l}=un(),p=Xp(n()),u=xu(r,a,p,e);u=$k()?u.filter(C=>C.showOnMobile!==!1&&(r(C.type).installed||l(C.type))):u;let d=Au(u,r),f=i(C=>!o.find(y=>y.walletType===C&&y.chain===e),"isExperimentalChainNotAdded"),h=Ok(()=>{let C=u?.filter(y=>y.state===Ns.CONNECTING)||[];for(let y of C)c(y)},[Bu(u)]);Uk(()=>()=>{h()},[]);let g=i(C=>{let y=C.find(T=>T.type===Jn.DEFAULT);return!y||y.state===Ns.NOT_INSTALLED?!1:C.filter(T=>T.state!=Ns.NOT_INSTALLED&&![Jn.DEFAULT,Jn.WALLET_CONNECT_2,Jn.LEDGER].includes(T.type)&&a(T.type).supportedChains.filter(v=>v.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),m=i((C,y,S)=>di(S,y)&&f(C)&&!Fk.includes(C)||C==Jn.DEFAULT&&!g(u),"shouldExcludeWallet");return{list:d.filter(C=>!m(C.type,e??"",s)),terminateConnectingWallets:h}}i(vt,"useWalletList");import{Modal as qk}from"@rango-dev/ui";import Gk from"react";import{create as Qk}from"zustand";var Ru="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(Ru),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 Hk=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=Hk;var ne=co(Qk()((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 R(t){let{watermark:e}=ne();return Gk.createElement(qk,{hasWatermark:e==="FULL",...t},t.children)}i(R,"WatermarkedModal");import{i18n as fn}from"@lingui/core";import{Alert as iT,Button as aT,Divider as gn,Image as sT,MessageBox as lT,RadioRoot as cT}from"@rango-dev/ui";import pe,{useEffect as pT,useMemo as uT,useState as dT}from"react";import{i18n as Xk}from"@lingui/core";import{Typography as sd}from"@rango-dev/ui";import dn from"react";function Ci(t,e){return t.find(o=>o.name===e)?.logo}i(Ci,"getBlockchainLogo");import{darkTheme as Vk,Image as Kk,styled as Kt,Typography as jk}from"@rango-dev/ui";var ki=Kt("li",{backgroundColor:"$neutral200",padding:"$16",borderRadius:"$sm",variants:{clickable:{true:{cursor:"pointer"}},hasError:{true:{background:"$error100",[`.${Vk} &`]:{backgroundColor:"$error700"}}},unsupported:{true:{cursor:"not-allowed",paddingTop:"$8",paddingBottom:"$8"}}}}),Ti=Kt("div",{display:"flex",gap:"$8",alignItems:"center"}),td=Kt("div",{flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between",height:"$40",variants:{showSupportedChains:{true:{justifyContent:"space-between"},false:{justifyContent:"center"}}}}),od=Kt("div",{flex:"1",display:"flex",alignItems:"center",gap:"$4",opacity:"0.5"}),nd=Kt("div",{display:"flex",gap:"$6",alignItems:"center"}),rd=Kt("div",{paddingLeft:"48px"}),id=Kt("div",{display:"flex",gap:"$2",cursor:"pointer",alignItems:"center",width:"fit-content"}),ad=Kt(jk,{maxWidth:"100px"}),wi=Kt(Kk,{variants:{disabled:{true:{opacity:"0.5"}}}});function vi(t){let{namespace:e}=t,o=k().blockchains();return dn.createElement(ki,{unsupported:!0},dn.createElement(Ti,null,dn.createElement(wi,{src:Ci(o,e.id),size:40,disabled:!0}),dn.createElement(od,null,dn.createElement(sd,{variant:"label",size:"large"},e.label),dn.createElement(sd,{variant:"body",size:"xsmall"},Xk.t("(Currently not supported)")))))}i(vi,"NamespaceUnsupportedItem");import{Checkbox as oT,Radio as nT}from"@rango-dev/ui";import Ms from"react";import{i18n as Ls}from"@lingui/core";import{ChevronDownIcon as Zk,ChevronUpIcon as Jk,Divider as Rk,Typography as er}from"@rango-dev/ui";import Ne,{useEffect as eT,useState as tT}from"react";import{Image as cd,Tooltip as pd,Typography as Yk}from"@rango-dev/ui";import _t from"react";import{styled as ld}from"@rango-dev/ui";var Ws=ld("div",{display:"flex",alignItems:"center",padding:0,margin:0}),bi=ld("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 Bs=3;function ud(t){let{chains:e}=t;return _t.createElement(Ws,{id:"widget-supported-chains-container"},e.slice(0,Bs).map((o,n)=>_t.createElement(pd,{key:o.name,container:W(),side:"bottom",align:"start",content:o.name,sideOffset:4},_t.createElement(bi,{firstItem:n===0},_t.createElement(cd,{src:o.logo,size:15})))),e.length>Bs&&_t.createElement(pd,{container:W(),side:"bottom",align:"start",sideOffset:4,content:_t.createElement(Ws,null,e.map((o,n)=>_t.createElement(bi,{key:o.name,firstItem:n===0},_t.createElement(cd,{src:o.logo,size:15}))))},_t.createElement(bi,null,_t.createElement(Yk,{variant:"body",size:"xsmall"},"+",e.length-Bs))))}i(ud,"SupportedChainsList");function _o(t){let{namespace:e,error:o,suffix:n,connected:r,address:a,onClick:s}=t,[c,l]=tT(!1),p=k().blockchains();eT(()=>l(!1),[o]);let u=e.getSupportedChains(p),d=!o&&!r&&u.length>1;return Ne.createElement(ki,{hasError:!!o,clickable:!!s,onClick:s},Ne.createElement(Ti,null,Ne.createElement(wi,{src:Ci(p,e.id),size:40}),Ne.createElement(td,{showSupportedChains:d||r||!!o},Ne.createElement(nd,null,Ne.createElement(er,{variant:"label",size:"large"},e.label),r&&Ne.createElement(er,{variant:"body",size:"small",color:"success500"},Ls.t("Connected")),!!o&&Ne.createElement(er,{variant:"body",size:"small",color:"error500"},Ls.t("Connection failed"))),d&&Ne.createElement(ud,{chains:u}),r&&Ne.createElement(ad,{variant:"body",size:"small",color:"neutral700"},a),o&&Ne.createElement(id,{onClick:()=>l(f=>!f)},Ne.createElement(er,{variant:"body",size:"small",color:"neutral700",style:{textDecoration:"underline",userSelect:"none",textDecorationSkipInk:"none"}},Ls.t("See why")),c?Ne.createElement(Jk,{size:12,color:"gray"}):Ne.createElement(Zk,{size:12,color:"gray"}))),n),!!o&&c&&Ne.createElement(Ne.Fragment,null,Ne.createElement(Rk,{size:4}),Ne.createElement(rd,null,Ne.createElement(er,{variant:"body",size:"small",color:"neutral700"},o))))}i(_o,"NamespaceItem");function dd(t){let{onClick:e,type:o,namespace:n}=t;return Ms.createElement(_o,{namespace:n,onClick:e,suffix:o==="radio"?Ms.createElement(nT,{value:n.value}):Ms.createElement(oT,{checked:t.value})})}i(dd,"NamespaceListItem");import{Button as rT,styled as md}from"@rango-dev/ui";var xi=md("ul",{padding:0,paddingBottom:"$20",margin:0}),mn=md(rT,{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=k().blockchains(),[l,p]=dT([]),u=uT(()=>a?.data.filter(m=>!m.unsupported),[e?.type]),d=i(m=>{p(r?[m]:C=>C.includes(m)?C.filter(y=>y!==m):C.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?pe.createElement(cT,{value:l?.[0]},m):pe.createElement(pe.Fragment,null,m),"wrapRadioRoot");return pT(()=>{if(!r&&u)if(t.value.defaultSelectedChains?.length){let m=u.filter(C=>C.getSupportedChains(c).some(y=>t.value.defaultSelectedChains?.includes(y.name)));p(m.map(C=>C.value))}else p(u.map(m=>m.value))},[]),pe.createElement(pe.Fragment,null,pe.createElement(lT,{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:pe.createElement(sT,{src:s,size:45})}),r?pe.createElement(pe.Fragment,null,pe.createElement(gn,{size:20}),pe.createElement(iT,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:fn.t("This wallet can only connect to one chain at a time. ")}),pe.createElement(gn,{size:30})):pe.createElement(pe.Fragment,null,pe.createElement(gn,{size:30}),pe.createElement(aT,{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")),pe.createElement(gn,{size:10})),pe.createElement(xi,null,g(pe.createElement(pe.Fragment,null,a?.data.map((m,C,y)=>pe.createElement(pe.Fragment,{key:m.id},m.unsupported?pe.createElement(vi,{namespace:m}):pe.createElement(dd,{value:l.includes(m.value),namespace:m,type:r?"radio":"checkbox",onClick:()=>d(m.value)}),C!==y.length-1&&pe.createElement(gn,{size:10})))))),pe.createElement(gn,{size:20}),pe.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 CT,Button as kT,Divider as hn,Image as TT,MessageBox as wT}from"@rango-dev/ui";import{useWallets as vT}from"@rango-dev/wallets-react";import fe from"react";import{styled as mT}from"@rango-dev/ui";var fd=mT("div",{display:"flex",justifyContent:"end"});import{i18n as Ps}from"@lingui/core";import{Button as fT,Spinner as gT}from"@rango-dev/ui";import _s,{useLayoutEffect as hT,useRef as yT,useState as ST}from"react";function gd(t){let{namespace:e,initialConnect:o,disabled:n,state:r,handleConnect:a,handleDisconnect:s}=t,[c,l]=ST(null),p=yT(!1);hT(()=>{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?Ps.t("Disconnect"):c?Ps.t("Try again"):Ps.t("Connect"),"getButtonText");return _s.createElement(_o,{namespace:e,connected:r.connected,error:c?.message,address:f(),suffix:r.connecting?_s.createElement(gT,{color:"info"}):_s.createElement(fT,{id:"widget-name-space-connect-btn",variant:"ghost",type:r.connected?"error":"primary",size:"xsmall",onClick:async()=>d(),disabled:n},h())})}i(gd,"NamespaceDetachedItem");function nr(t){let{value:e,selectedNamespaces:o,onConfirm:n,onDisconnectWallet:r,navigateToDerivationPath:a}=t,{targetWallet:s}=e,{connect:c,disconnect:l,state:p}=vT(),u=s.type,d=p(u),f=s.properties?.find(T=>T.name==="namespaces"),h=s.properties?.find(T=>T.name==="derivationPath"),g=f?.value.selection==="single",m=i(async(T,v)=>{g&&await l(u),h&&v?.shouldAskForDerivationPath?a(T):await c(u,[{namespace:T,network:"",derivationPath:v?.derivationPath??void 0}])},"handleConnectNamespace"),C=i(async T=>{await l(u,[T])},"handleDisconnectNamespace"),y=i(()=>g?fe.createElement(fe.Fragment,null,fe.createElement(hn,{size:20}),fe.createElement(CT,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:or.t("This wallet can only connect to one chain at a time.")}),fe.createElement(hn,{size:30})):fe.createElement(fe.Fragment,null,fe.createElement(hn,{size:30}),fe.createElement(fd,null,fe.createElement(kT,{id:"widget-detached-disconnect-wallet-btn",variant:"ghost",type:"error",size:"xsmall",disabled:d.connecting||!d.connected,onClick:r},or.t("Disconnect wallet"))),fe.createElement(hn,{size:16})),"renderNamespaceListHeader"),S=i(T=>{if(T.unsupported)return fe.createElement(vi,{namespace:T});let v=o?.find(N=>N.namespace===T.value),w=d.namespaces?.get(T.value);if(!w)throw new Error(`State for ${T.value} was not found!`);let A=g&&d.connecting;return fe.createElement(gd,{namespace:T,initialConnect:!!v,disabled:A,state:w,handleConnect:async N=>m(T.value,{derivationPath:v?.derivationPath,shouldAskForDerivationPath:N?.shouldAskForDerivationPath}),handleDisconnect:async()=>C(T.value)})},"renderNamespaceItem");return fe.createElement(fe.Fragment,null,fe.createElement(wT,{type:"info",title:or.t("Connect {wallet}",{wallet:s.type}),description:or.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect or disconnect."),icon:fe.createElement(TT,{src:s.image,size:45})}),y(),fe.createElement(xi,{id:"widget-detached-namespace-list"},s.needsNamespace?.data.map((T,v,w)=>fe.createElement(fe.Fragment,{key:T.id},S(T),v!==w.length-1&&fe.createElement(hn,{size:10})))),fe.createElement(hn,{size:20}),fe.createElement(mn,{id:"widget-name-space-confirm-btn",type:"primary",onClick:n},or.t("Done")))}i(nr,"Detached");import{i18n as yn}from"@lingui/core";import{Divider as IT,Image as AT,MessageBox as NT,Select as WT,TextField as BT}from"@rango-dev/ui";import bt,{useEffect as LT,useState as yd}from"react";import{namespaces as bT}from"@rango-dev/wallets-shared";var Ei={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Ds(t){let e=t?bT[t]?.derivationPaths:null;return e?[...e,Ei]:[]}i(Ds,"getDerivationPaths");import{Button as xT,styled as $s,Typography as ET}from"@rango-dev/ui";var hd=$s("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Fs=$s(ET,{paddingLeft:"$10"}),Os={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"},l_=$s(xT,{minHeight:"$40"});var Sd="0";function rr(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=yd(null),[c,l]=yd(Sd),p=a===Ei.id,u=Ds(o),d=i(({value:h})=>{let g=u?.find(m=>m.id===h);g&&(a===Ei.id&&Number.isNaN(Number(c))&&l(Sd),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 LT(()=>{s(Ds(o)[0]?.id||null)},[o]),bt.createElement(bt.Fragment,null,bt.createElement(NT,{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:bt.createElement(AT,{src:n,size:45})}),bt.createElement(hd,{className:"_derivation_path_inputs_container"},bt.createElement(Fs,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},yn.t("Choose Derivation Path Template")),bt.createElement(WT,{id:"widget-derivation-path-template-select",value:a||"",options:u.map(h=>({value:h.id,label:h.label})),variant:"filled",handleItemClick:d,styles:{trigger:Os}}),bt.createElement(IT,{size:20}),bt.createElement(Fs,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},p?yn.t("Enter Path"):yn.t("Enter Index")),bt.createElement(BT,{id:"widget-derivation-path-template-input",type:p?"text":"number",variant:"contained",value:c,onChange:h=>l(h.target.value),style:Os})),bt.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 _T,MessageBox as Us,WalletState as DT}from"@rango-dev/ui";import{useWallets as $T}from"@rango-dev/wallets-react";import Do from"react";import{keyframes as MT,styled as Ii}from"@rango-dev/ui";var C_=Ii("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Cd=Ii("div",{position:"relative"}),PT=MT({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),kd=Ii("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${PT} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Td=Ii("div",{"& img":{borderRadius:"50%"}});function zs(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=$T();return Kn(a(n))===DT.CONNECTED?Do.createElement(Us,{type:"success",title:Sn.t("Wallet Connected"),description:Sn.t("Your wallet is connected, you can use it to swap.")}):o?Do.createElement(Us,{type:"error",title:Sn.t("Failed to Connect"),description:o||Sn.t("Your wallet is not connected. Please try again.")}):Do.createElement(Us,{type:"loading",title:Sn.t("Connecting to your wallet"),description:Sn.t("Click connect in your wallet popup."),icon:Do.createElement(Cd,null,Do.createElement(Td,null,Do.createElement(_T,{src:r,size:45})),Do.createElement(kd,null))})}i(zs,"ConnectStatus");import{i18n as Hs}from"@lingui/core";import{Button as FT,Divider as wd,MessageBox as OT}from"@rango-dev/ui";import Ai from"react";function Qs(t){let{displayName:e,onConfirm:o,id:n}=t;return Ai.createElement(OT,{id:n,title:Hs.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:Hs.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},Ai.createElement(wd,{size:18}),Ai.createElement(wd,{size:32}),Ai.createElement(FT,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},Hs.t("Confirm")))}i(Qs,"ExperimentalChain");function vd(t,e){return t().status==="init"&&!!e}i(vd,"isOnStatus");function ir(t){return t().status==="namespace"}i(ir,"isOnNamespace");function ar(t){return t().status==="derivationPath"}i(ar,"isOnDerivationPath");function Ao(t){return t().status==="detached"}i(Ao,"isOnDetached");var QT=3e3,qT=300;function sr(t){let e=HT(),[o,n]=bd(!1),[r,a]=bd(),s=i(w=>{a(w.message)},"catchErrorOnHandle"),{terminateConnectingWallets:c}=vt(),{handleConnect:l,handleDerivationPath:p,handleNamespace:u,getState:d,resetState:f,handleDisconnect:h}=Ro(),g=i(w=>{u(t.wallet,w).then(T).catch(s)},"handleConfirmNamespaces"),m=i(()=>{y()},"handleDetachedConfirm"),C=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(T).catch(s)},"handleDerivationPathConfirm"),y=i(()=>{n(!1)},"handleClosingModal"),S=i(()=>{a(void 0),f(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),T=i((w,A)=>{let N=w.status==="connected",b=["disconnected","disconnected-unhandled"].includes(w.status);N?(t.onConnect?.(),A||(e.current=setTimeout(y,QT))):b&&y()},"afterConnected"),v=i(w=>{t.wallet?.needsDerivationPath&&u(t.wallet,[w])},"handleNavigateToDerivationPath");return zT(()=>{if(t.wallet){S();let w=!1,A=!0;i(()=>{setTimeout(()=>{A=!1,w||n(!0)},qT)},"beforeConnecting")(),l(t.wallet,{disconnectIfConnected:!0,defaultSelectedChains:t.options?.defaultSelectedChains}).then(b=>{["namespace","Detached","derivation-path"].includes(b.status)||(w=!0),T(b,A)}).catch(s)}},[t.wallet]),po.createElement(R,{id:t.id,open:o,onClose:y,onExit:()=>{S(),c(),t.onClose&&t.onClose()},container:W()},vd(d,t.wallet)&&po.createElement(po.Fragment,null,po.createElement(zs,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),po.createElement(UT,{direction:"vertical",size:32})),ir(d)&&po.createElement(tr,{onConfirm:g,value:d().namespace}),ar(d)&&po.createElement(rr,{onConfirm:C,value:d().derivationPath}),Ao(d)&&po.createElement(nr,{onConfirm:m,onDisconnectWallet:()=>void h(d().namespace.targetWallet),value:d().namespace,selectedNamespaces:d().selectedNamespaces,navigateToDerivationPath:v}))}i(sr,"StatefulConnectModal");import os from"react";import GT,{Fragment as VT}from"react";import{MemoryRouter as KT,useInRouterContext as jT}from"react-router";function Ni({children:t}){let o=jT()?VT:KT;return GT.createElement(o,null,t)}i(Ni,"AppRouter");import{I18nManager as Y0}from"@rango-dev/ui";import Dp from"react";import ze from"react";import{useRoutes as N0}from"react-router-dom";var F={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 kn,useRef as Di}from"react";import it from"bignumber.js";import{create as nm}from"zustand";import{subscribeWithSelector as rm}from"zustand/middleware";import{createContext as XT,useContext as YT}from"react";var xd=XT({swapMode:"swap",isMultiMode:!1});function rt(){let{swapMode:t,isMultiMode:e}=YT(xd);return{swapMode:t,isMultiMode:e}}i(rt,"useSwapMode");import{i18n as kt}from"@lingui/core";import{getRelatedWalletOrNull as RT,RouteEventType as DD}from"@rango-dev/queue-manager-rango-preset";import qe from"bignumber.js";import{PendingSwapNetworkStatus as cr}from"rango-types";import{i18n as Qe}from"@lingui/core";var re=i(()=>({genericServerError:Qe.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:Qe.t("Please reset your liquidity sources."),description:Qe.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:Qe.t("No Routes Found."),description:Qe.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:Qe.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:Qe.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:Qe.t("High Price Impact"),title:Qe.t("Price impact is too high!"),description:Qe.t("The price impact is significantly higher than the allowed amount."),confirmMessage:Qe.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:Qe.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:Qe.t("USD Price Unknown"),title:Qe.t("USD Price Unknown, Cannot calculate Price Impact."),description:Qe.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:Qe.t("Confirm USD Price Unknown")}}),"errorMessages");function Ed(t){return t.type===0?t.diagnosisMessage??re().noResultError.title:t.type===1?t.diagnosisMessage??re().genericServerError:""}i(Ed,"getQuoteErrorMessage");import{i18n as Wi}from"@lingui/core";var $o=i(()=>({connectWallet:Wi.t("Connect Wallet"),swap:Wi.t("Swap"),swapAnyway:Wi.t("Swap anyway"),ethWarning:Wi.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function qs(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(qs,"getFeeLabel");var Gs=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Id=100,Ad=30,Nd=15,Wd=60;var Bd=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Ld=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as JT}from"@rango-dev/queue-manager-rango-preset";import wD from"bignumber.js";function Pd(t,e){if(e===null)return null;let o=e?.find(n=>n.blockchain===t.chain)?.wallets.find(n=>n.address?.toLowerCase()===t.address.toLowerCase());return o?o.requiredAssets:null}i(Pd,"getRequiredBalanceOfWallet");function Xt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Xt,"getPriceImpactLevel");function Bi(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=JT(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(Bi,"createRetryQuote");function Cn(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=lr(o),s=Ct(o);if(o&&a&&s){let p=jt(a.toString(),s.toString());if(!!p&&Od(a,p)){let d=Mi(o?.swaps,n),f=Xt(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:d,warningLevel:f}}}if(e&&Hd(e,o))return{type:4,usdValueChange:P(Ct(o)?.minus(Ct(e)??0).toString()??"0",null,2),percentageChange:P(jt(Ct(e)??"1",Ct(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let c=Pi(o.swaps),l=r>an;if(zd(t.userSlippage.toString(),c)){if(l&&parseFloat(c??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:Ud(o,r),minRequiredSlippage:c};return null}i(Cn,"generateQuoteWarnings");function _d(t){return![4].includes(t.type)}i(_d,"isQuoteWarningConfirmationRequired");function jt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Vs(t.toString(),e.toString());return n&&n<0?n:null}i(jt,"getPriceImpact");var Dd=i(t=>{let e=new Set,o=[];return t.forEach(n=>{e.has(n.from.chain.displayName)||(e.add(n.from.chain.displayName),o.push(n.from.chain)),e.has(n.to.chain.displayName)||(e.add(n.to.chain.displayName),o.push(n.to.chain))}),o},"getUniqueBlockchains"),Li=i((t,e)=>e.sort((o,n)=>{let r=i(p=>p.scores?.find(u=>u.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let c=o.requestId.toLowerCase(),l=n.requestId.toLowerCase();return c.localeCompare(l)}),"sortQuotesBy"),$d=i((t,e,o)=>{let n=e[0];if(!e.length||!n)return null;if(!t)return{requestAmount:o,validationStatus:null,...n};let r=new Set(t.swaps.map(s=>s.swapperId)),a=e.find(s=>{let c=new Set(s.swaps.map(l=>l.swapperId));return Array.from(r).every(l=>c.has(l))});return{requestAmount:o,validationStatus:null,...a||n}},"getDefaultQuote"),Fd=i(t=>{let e=i((o,n)=>{let r=Gs.indexOf(o.value),a=Gs.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function Od(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Bd.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new qe(r)))}i(Od,"hasHighValueLoss");function Qd(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new qe(e.fromAmountMaxValue):null;return e.fromAmountRestrictionType==="EXCLUSIVE"?o?.gte(e.fromAmount)||n?.lte(e.fromAmount):o?.gt(e.fromAmount)||n?.lt(e.fromAmount)}).length>0}i(Qd,"hasLimitError");function qd(t){let e=(t||[]).filter(c=>{let l=c.fromAmountMinValue?new qe(c.fromAmountMinValue):null,p=c.fromAmountMaxValue?new qe(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 qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new qe(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=kt.t({id:"Required: >= {min} {symbol}",values:{min:P(o,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=kt.t({id:"Required: > {min} {symbol}",values:{min:P(o,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=kt.t({id:"Required: <= {max} {symbol}",values:{max:P(n,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=kt.t({id:"Required: < {max} {symbol}",values:{max:P(n,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(qd,"getLimitErrorMessage");function Gd(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:c,needsToWarnEthOnPath:l}=t;return e!=="success"?{title:$o().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||c||!r||r==="0"?{title:$o().swap,action:"confirm-swap",disabled:!0}:s?{title:$o().swapAnyway,action:"confirm-warning",disabled:!1}:l?{title:$o().ethWarning,action:"confirm-warning",disabled:!1}:{title:$o().swap,action:"confirm-swap",disabled:!1}:{title:$o().connectWallet,action:"connect-wallet",disabled:!1}}i(Gd,"getSwapButtonState");function Ks(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(de))&&e&&e!=="0"&&n!==0)}i(Ks,"canComputePriceImpact");function js(t,e){let o=de;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 qe(r.amount).multipliedBy(a||0))}return o}i(js,"getUsdFeeOfStep");function Mi(t,e){return t.reduce((o,n)=>o.plus(js(n,e)),de)}i(Mi,"getTotalFeeInUsd");function Xs(t){let e=de,o=new qe(t.price||0);return e=e.plus(new qe(t.amount).multipliedBy(o)),e}i(Xs,"getUsdFee");function Vd(t){return t.reduce((e,o)=>e.plus(Xs(o)),de)}i(Vd,"getTotalFeesInUsd");function Kd(t){return t.reduce((e,o)=>{for(let n of o.fee){let r=n.name,a=n.expenseType!=="DECREASE_FROM_OUTPUT"?e.payable:e.nonePayable;a[r]=[...a[r]||[],n]}return e},{payable:{},nonePayable:{}})}i(Kd,"getFeesGroup");function jd(t){let e=new Map;return t.forEach((o,n)=>{o.recommendedSlippage?.error&&e.set(n,o.recommendedSlippage.slippage)}),e.size>0?Object.fromEntries(e):null}i(jd,"checkSlippageErrors");function Ud(t,e){let o=new Map;return t?.swaps.forEach((n,r)=>{n.recommendedSlippage?.slippage&&parseFloat(n.recommendedSlippage.slippage)>e&&o.set(r,n.recommendedSlippage.slippage)}),o.size>0?Object.fromEntries(o):null}i(Ud,"checkSlippageWarnings");function Pi(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(Pi,"getMinRequiredSlippage");function zd(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(zd,"hasProperSlippage");function Xd(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:c,excludeLiquiditySources:l,slippage:p,affiliateRef:u,affiliatePercent:d,affiliateWallets:f,destination:h,contractCall:g}=t,m=a?.reduce((S,T)=>(S[T.chain]=T.address,S),{}),C=[];return r?.forEach(S=>{C.push({blockchain:S.chain,addresses:[S.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:C,selectedWallets:m??{},slippage:p.toString(),contractCall:g,...h&&{destination:h},...l&&{swapperGroups:s.concat(c??[]),swappersGroupsExclude:!0},...!l&&{swapperGroups:c?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}i(Xd,"createQuoteRequestBody");function Yd(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType,derivationPath:n.derivationPath},o),{})}i(Yd,"getWalletsForNewSwap");function lr(t){let e=t.requestAmount,o=t.swaps[0]?.from.usdPrice;if(!(!e||!o))return new qe(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 qe(e).multipliedBy(o)}i(Ct,"getUsdOutputFrom");function Vs(t,e){return new qe(e).div(new qe(t)).minus(1).multipliedBy(Id).toNumber()}i(Vs,"getPercentageChange");function Hd(t,e){let o=lr(t),n=Ct(t),r=Ct(e);if(!o||!n||!r)return!1;let a=Vs(n.toString(),r.toString());return Ld.some(({threshold:s,minInput:c})=>a<=s&&o.isGreaterThanOrEqualTo(c))}i(Hd,"isOutputAmountChangedExcessively");function Zd(t,e,o){let n=t.validationStatus,r=Lo({filter:"required",quote:t});return e.sort((s,c)=>r.indexOf(s.chain)-r.indexOf(c.chain)).flatMap(s=>Pd(s,n)||[]).filter(s=>!s.ok).map(s=>{let c=s.asset.symbol,l=P(new qe(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=P(new qe(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=kt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=kt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=kt.t(" for input and network fee")),kt.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:p,symbol:c,reason:u,currentAmount:l,blockchain:yt(s.asset.blockchain,o)}})})}i(Zd,"generateBalanceWarnings");function pr(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==cr.NetworkChanged}i(pr,"isNetworkStatusInWarningState");function Jd(t,e,o){let n="bellow button or",r=t.extraMessage,a=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(n)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(n,"")),pr(e)){r=t.networkStatusExtraMessage||"",a=t.networkStatusExtraMessageDetail||"";let p=(e?RT(t,e):null)?.walletType,u=p?o?.(p)?.name:null;switch(e?.networkStatus){case cr.WaitingForConnectingWallet:r=u?kt.t("Connect {wallet}",{wallet:u}):r;break;case cr.WaitingForQueue:r=r||kt.t("Waiting for other running tasks to be finished");break;case cr.WaitingForNetworkChange:r=r||kt.t("Waiting for changing wallet network");break;case cr.NetworkChangeFailed:r=r||kt.t("The network switch could not be completed. Please try again, or switch the network manually in your wallet.");break;default:r=r||"";break}}a=a||"",r=r||"";let c=r?.indexOf("code")!==-1&&r?.indexOf("reason")!==-1;return{shortMessage:r,detailedMessage:{content:a,long:c}}}i(Jd,"getSwapMessages");function Rd(t){let e=null;if(t.status==="failed"){let o=t.steps.slice().reverse().filter(n=>n.status==="success")[0];o&&(e={blockchain:o.toBlockchain,symbol:o.toSymbol,outputAmount:o.outputAmount,address:o.toSymbolAddress})}return e}i(Rd,"getLastConvertedTokenInFailedSwap");function em(t){return t.status==="failed"}i(em,"shouldRetrySwap");function tm(t,e,o,n,r,a){if(!n||t)return!0;let s=Lo({filter:"all",quote:n}),c=Lo({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?tn(a,o):!1;return!e&&!l||e&&!o||e&&!!o&&(!u||!p)}i(tm,"isConfirmSwapDisabled");function om(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(om,"isTokensIdentical");var _i=i((t,e)=>t?.usdPrice?new it(e||de).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),im=i(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new it(0),outputUsdValue:new it(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=de,a=o.inputUsdValue;return Vn(o.inputAmount)?(e&&(n=e?.outputAmount?new it(e?.outputAmount):null,a=lr(e)??de,r=Ct(e)??de),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new it(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new it(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new it(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:_i(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 it(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=vu(e);t(()=>({inputAmount:o}))},setInputAmount:e=>{let o=e;li(e)||(o=gu(o),o=hu(o)),t(n=>({inputAmount:o,...!o&&{outputAmount:null,outputUsdValue:new it(0),selectedQuote:null},...!!n.fromToken&&{inputUsdValue:_i(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:_i(n??null,s),outputUsdValue:new it(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?_i(e.toToken,e.outputAmount?.toString()||""):new it(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new it(0),inputUsdValue:new it(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new it(0),selectedQuote:null})),setQuoteWalletConfirmed:e=>t({quoteWalletsConfirmed:e}),setSelectedWallets:e=>t({selectedWallets:e}),setCustomDestination:e=>t({customDestination:e}),resetQuoteWallets:()=>t({quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null}),setQuoteWarningsConfirmed:e=>t({quoteWarningsConfirmed:e})}),"initializer"),am=nm()(rm(im)),sm=nm()(rm(im)),ew=co(am),tw=co(sm);function H(){let{swapMode:t}=rt();return co(t==="refuel"?sm:am)}i(H,"useQuoteStore");var lm=i((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&we.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&&we.emit("quoteEvent",{type:"quoteOutputUpdate",payload:t.selectedQuote?{requestAmount:t.selectedQuote.requestAmount,swaps:t.selectedQuote.swaps,outputAmount:t.selectedQuote.outputAmount,resultType:t.selectedQuote.resultType,tags:t.selectedQuote.tags}:null})},"subscribeCallback"),cm=ew.subscribe(lm),pm=tw.subscribe(lm);function um(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:c,fromBlockchain:l,toBlockchain:p}=H()(),u=k().config,d=k().fetchStatus,f=k().blockchains(),{findToken:h}=k(),{setAffiliateRef:g,setAffiliatePercent:m,setAffiliateWallets:C}=k(),y=u?.from?.tokens,S=u?.from?.blockchains,T=u?.to?.tokens,v=u?.to?.blockchains,w=Di(void 0),A=Di(void 0),N=Di(void 0),b=Di(void 0);kn(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),kn(()=>{if(d==="success"){r();let x=f.find(I=>I.name===u?.from?.blockchain),E=u?.from?.token,B=E&&h(E);(x||!x&&N.current)&&n(x??null),B?a({token:B,meta:{blockchains:f}}):!B&&w.current&&a({token:null}),N.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]),kn(()=>{Ss(s,y)&&a({token:null}),Cs(l,S)&&n(null)},[y,S]),kn(()=>{Ss(c,T)&&a({token:null}),Cs(p,v)&&o(null)},[T,v]),kn(()=>{if(d==="success"){r();let x=f.find(I=>I.name===u?.to?.blockchain),E=u?.to?.token,B=E&&h(E);(x||!x&&b.current)&&o(x??null),B?e({token:B,meta:{blockchains:f}}):!B&&A.current&&e({token:null}),b.current=u?.to?.blockchain,A.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,d]),kn(()=>{g(u?.affiliate?.ref??null),m(u?.affiliate?.percent??null),C(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(um,"useSyncStoresWithConfig");import{useEffect as Js,useRef as ow}from"react";import{useInRouterContext as nw,useLocation as rw,useSearchParams as iw}from"react-router-dom";function Ys(t,e){let o=t.split("--");return o[0]?{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}:null}i(Ys,"convertTokenSearchParamToAsset");function Zs(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Zs,"tokenToSearchParam");function el(){let t=rw(),[e,o]=iw(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:c,setFromBlockchain:l,setToBlockchain:p,setFromToken:u,setToToken:d,setInputAmount:f}=H()(),h=k().fetchStatus,g=k().blockchains(),m=nw(),{updateIframe:C,updateCampaignMode:y}=k(),S=k().isInCampaignMode(),T=ow(),{findToken:v}=k(),w=i(()=>{let N={};for(let[L,ee]of e.entries())L.startsWith("utm_")&&(N[L]=ee);let b=e.get("fromAmount"),x=e.get("fromBlockchain"),E=e.get("fromToken"),B=e.get("toBlockchain"),I=e.get("toToken"),_=e.get("autoConnect"),U=e.get("clientUrl"),G=e.get("liquiditySources"),Y=e.get("blockchain");return{fromAmount:b,fromBlockchain:x,fromToken:E,toBlockchain:B,toToken:I,autoConnect:_,clientUrl:U,liquiditySources:G,utmQueryParams:N,blockchain:Y}},"getUrlSearchParams"),A=i(N=>{for(let b in N)N[b]||delete N[b];o(N,{replace:!0})},"updateUrlSearchParams");Js(()=>{let{autoConnect:N,clientUrl:b,utmQueryParams:x,blockchain:E}=w();m&&h==="success"&&A({fromBlockchain:n?.name,fromToken:Zs(a),toBlockchain:r?.name,toToken:Zs(s),fromAmount:c,autoConnect:N??void 0,clientUrl:b??void 0,blockchain:E??void 0,liquiditySources:S?T.current:void 0,...x})},[t.pathname,c,n,a,r,s,S,h]),Js(()=>{if(!m)return;let N=w();if(!T.current&&N.liquiditySources&&(T.current=N.liquiditySources),N.fromAmount&&f(N.fromAmount),h==="success"){let b=g.find(U=>U.name===N.fromBlockchain),x=N.fromToken&&b&&Ys(N.fromToken,b),E=x?v(x):void 0,B=g.find(U=>U.name===N.toBlockchain),I=N.toToken&&B&&Ys(N.toToken,B),_=I?v(I):void 0;b&&(l(b),E&&u({token:E,meta:{blockchains:g}})),B&&(p(B),_&&d({token:_,meta:{blockchains:g}}))}},[h]),Js(()=>{let{clientUrl:N,liquiditySources:b}=w();C("clientUrl",N||void 0),y("liquiditySources",b?.split(",")??void 0)},[])}i(el,"useSyncUrlAndStore");import{i18n as bn}from"@lingui/core";import{Alert as Wv,Button as Bv,darkTheme as Lv,Divider as Wl,DoneIcon as Mv,styled as Pv,TextField as _v,Typography as Dv}from"@rango-dev/ui";import Ve,{useState as $v}from"react";import{useNavigate as Fv,useSearchParams as Ov}from"react-router-dom";import{ChevronRightIcon as aw,Divider as hm,Image as sw,Typography as ym}from"@rango-dev/ui";import xt from"react";import{darkTheme as dm,styled as tl}from"@rango-dev/ui";var mm=tl("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${dm} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${dm} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),fm=tl("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),gm=tl("div",{display:"flex"});function ol(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return xt.createElement(fm,null,xt.createElement(ym,{size:"large",variant:"label"},n),xt.createElement(hm,{size:10}),xt.createElement(mm,{onClick:s?void 0:e,disabled:s,id:"widget-blockchain-selector-container"},xt.createElement(gm,null,r&&xt.createElement(xt.Fragment,null,xt.createElement(sw,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),xt.createElement(hm,{size:4,direction:"horizontal"})),xt.createElement(ym,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),xt.createElement(aw,{size:12,color:"black"})))}i(ol,"BlockchainSelectorButton");import{i18n as al}from"@lingui/core";import{Button as gw,Divider as vm,MessageBox as hw}from"@rango-dev/ui";import uo,{useEffect as bm,useState as sl}from"react";import{i18n as $i}from"@lingui/core";import{Divider as Fo,ExternalLinkIcon as pw,Image as uw,InfoIcon as dw,Tooltip as mw,Typography as dr}from"@rango-dev/ui";import me from"react";var Sm="https://blog.rango.exchange/understanding-the-risks-of-using-custom-token-contract-addresses-96022308eca4";function Cm(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(Cm,"generateExplorerLink");import{Button as lw,darkTheme as Tn,styled as ur,Typography as cw}from"@rango-dev/ui";var nl=ur("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Tn} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Tn} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Tn} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Tn} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),km=ur("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Tn} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Tn} &`]:{color:"$colors$neutral900"}}}),rl=ur(lw,{minHeight:"$40"}),Tm=ur(cw,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"96px"}),wm=ur("div",{display:"flex",justifyContent:"center",alignItems:"center"});var fw=9;function il(t){let{open:e,onClose:o,token:n,onExit:r,onSubmitClick:a,blockchain:s}=t,c=Cm(n.address,s),l=i(()=>window.open(Sm,"_blank"),"onClickLearnMore");return me.createElement(R,{open:e,id:"widget-custom-token-watermarked-modal",dismissible:!0,onClose:o,onExit:r,container:W()},me.createElement(km,null,me.createElement(uw,{src:n.image===""?ni:n.image,size:45,type:"circular"}),me.createElement(Fo,{size:4}),me.createElement(wm,null,me.createElement(Tm,{variant:"title",size:"medium"},n.symbol),n.symbol.length>fw&&me.createElement(mw,{content:n.symbol,container:W()},me.createElement(dw,{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(nl,{hasHover:!0,href:c,target:"_blank",rel:"nofollow noreferrer"},n.address,me.createElement(pw,{size:12,color:"gray"})):me.createElement(nl,null,n.address)),me.createElement(Fo,{size:4}),n.coinSource&&me.createElement(dr,{className:"_coin-source",variant:"body",size:"xsmall"},$i.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"},$i.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(rl,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:a},$i.t("Import Anyway")),me.createElement(Fo,{size:10}),me.createElement(rl,{id:"widget-custom-token-modal-learn-more-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:l},$i.t("Learn More")))}i(il,"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}=k(),[d,f]=sl(!1),[h,g]=sl(!1),[m,C]=sl(!1),y=i(()=>{o&&a?.({blockchain:o.name,tokenAddress:r})},"getCustomToken"),S=i(()=>{n?.type!=="network-error"&&s?.(),f(!1)},"closeErrorModal"),T=i(()=>{C(!0),S()},"handleErrorModalButtonClick"),v=i(()=>{m&&n?.type==="network-error"&&(C(!1),y()),l()},"handleExit"),w=i(()=>{e&&(u(e),c())},"handleSubmit");return bm(()=>{n&&f(!0)},[n]),bm(()=>{o&&e&&g(!0)},[o,e]),uo.createElement(uo.Fragment,null,uo.createElement(R,{open:d,dismissible:!0,id:"widget-add-custom-token-modal",onClose:S,onExit:v,container:W()},uo.createElement(hw,{title:n?.title??"",type:"error",description:n?.message||al.t("Failed Network, Please retry.")},uo.createElement(vm,{size:40}),uo.createElement(vm,{size:10}),uo.createElement(gw,{id:`widget-add-custom-token-${n?.type==="network-error"?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:T},n?.type==="network-error"?al.t("Retry"):al.t("Add another custom token")))),o&&e&&uo.createElement(il,{blockchain:o,token:e,onSubmitClick:w,onClose:()=>g(!1),open:h,onExit:p}))}i(mr,"ImportCustomToken");import{useManager as bv}from"@rango-dev/queue-manager-react";import{BottomLogo as xv,Divider as of,Header as Ev}from"@rango-dev/ui";import Be,{useEffect as Vi,useLayoutEffect as Iv,useRef as nf,useState as rf}from"react";import{useRef as yw}from"react";function fr(){return window.self!==window.top}i(fr,"isAppLoadedIntoIframe");function ll(){let t=yw(null),{iframe:e}=k(),o=fr()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(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(ll,"useIframe");import{useNavigate as Sw}from"react-router-dom";function Ge(){let t=Sw();return()=>t(-1)}i(Ge,"useNavigateBack");import{useLayoutEffect as Cw,useState as gr}from"react";var xm=480,Em=768,Im=1024,Am=1200,kw=i(()=>{let[t,e]=gr(!1),[o,n]=gr(!1),[r,a]=gr(!1),[s,c]=gr(!1),[l,p]=gr(!1),u=i(()=>{e(window.innerWidth<=xm),n(window.innerWidth>xm&&window.innerWidth<=Em),a(window.innerWidth>Em&&window.innerWidth<=Im),c(window.innerWidth>Im&&window.innerWidth<=Am),p(window.innerWidth>Am)},"handleResize");return Cw(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:l}},"useScreenDetect"),wn=kw;import{createTheme as gl,darkTheme as Mw,lightTheme as Pw}from"@rango-dev/ui";import{useEffect as _w,useState as Dw}from"react";import{theme as Bw,darkColors as Lw}from"@rango-dev/ui";import ml from"react";var Fi=16,Oi=255,Nm=.11;function Tw(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(Tw,"expandShortHexColor");function ww(t,e){return t.padStart(e,"0")}i(ww,"pad");function cl(t){let e=Math.min(Math.max(Math.round(t),0),Oi);return ww(e.toString(Fi),2)}i(cl,"intToHex");function vw(t){return`#${cl(t.red)}${cl(t.green)}${cl(t.blue)}`}i(vw,"rgbToHex");function bw(t){let e=parseInt(t.slice(1,3),Fi),o=parseInt(t.slice(3,5),Fi),n=parseInt(t.slice(5,7),Fi);return{red:e,green:o,blue:n}}i(bw,"hexToRGB");function xw(t,e){let o=1-Nm*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(xw,"generateShade");function Ew(t,e){let o=Nm*e;return{red:t.red+(Oi-t.red)*o,green:t.green+(Oi-t.green)*o,blue:t.blue+(Oi-t.blue)*o}}i(Ew,"generateTint");function Iw(t){return Wm(t,xw)}i(Iw,"calculateShades");function Aw(t){return Wm(t,Ew)}i(Aw,"calculateTints");function Wm(t,e){let o=bw(t),n=[];for(let r=1;r<9;r++)n.push(vw(e(o,r)));return n}i(Wm,"calculateColors");function pl(t,e,o){let a=Aw(t).reverse().concat(t),s=Iw(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(pl,"createTintsAndShades");function ul(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=Tw(a);Object.assign(n,pl(l,r,s))}}return{...n,...e}}i(ul,"expandToGenerateThemeColors");var Bm=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),Nw=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"),Ww=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),dl=i(t=>Nw(Ww(5381,JSON.stringify(t))>>>0),"toHash");function fl(t){let e=Bw.colors,o={...e,...Lw},n,r;if(t?.light){let s={colors:ul(e,t.light)};n={id:`${ys}-light-${dl(s)}`,tokens:s}}if(t?.dark){let s={colors:ul(o,t.dark,{reverseNeutralRange:!0})};r={id:`${ys}-dark-${dl(s)}`,tokens:s}}return{light:n,dark:r}}i(fl,"customizedThemeTokens");function Lm(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>ml.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(ml.cloneElement(a,{key:s})),r<t.length-1){let c=`divider-${r}`;o.push(ml.cloneElement(e,{key:c}))}}),o}i(Lm,"joinList");function Mm(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Mm,"doesWindowPreferDarkColorScheme");function mo(t){let{colors:e,fontFamily:o=iu,borderRadius:n=_u,secondaryBorderRadius:r=Du}=t,[a,s]=Dw(Mm()?"dark":"light"),{theme:c}=k(),{dark:l,light:p}=fl(e),u=gl({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),d=[u.className,Pw.className],f=[u.className,Mw.className];if(p){let g=gl(p.id,p.tokens);d.push(g.className)}if(l){let g=gl(l.id,l.tokens);f.push(g.className)}return _w(()=>{let g=i(m=>{m.matches?s("dark"):s("light")},"switchThemeListener");return Mm()&&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 Tt=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 Pm}from"@lingui/core";import{Alert as $w,Button as Fw}from"@rango-dev/ui";import _m from"react";function hl(t){return _m.createElement($w,{action:_m.createElement(Fw,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Pm.t("Activate this tab")),type:"warning",variant:"alarm",title:Pm.t("Another tab is open and handles transactions.")})}i(hl,"ActivateTabAlert");import{i18n as yl}from"@lingui/core";import{Button as Ow,Divider as Uw,MessageBox as zw}from"@rango-dev/ui";import Ui from"react";function Sl(t){let{open:e,onClose:o,onConfirm:n}=t;return Ui.createElement(R,{open:e,dismissible:!0,onClose:o,id:"widget-active-tab-modal",container:W()},Ui.createElement(zw,{title:yl.t("Activate current tab"),type:"warning",description:yl.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.")},Ui.createElement(Uw,{size:20}),Ui.createElement(Ow,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},yl.t("Confirm"))))}i(Sl,"ActivateTabModal");import{ChevronLeftIcon as qw}from"@rango-dev/ui";import Qm from"react";import{css as Hw,darkTheme as Dm,IconButton as Qw,styled as Oo}from"@rango-dev/ui";var Dt=Oo(Qw,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${Dm} &`]:{backgroundColor:"$neutral"}}}),$m=Oo("div",{position:"absolute",background:"$secondary500",[`.${Dm} &`]:{$$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}}),Fm=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"}}}}),Om=Oo("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Um=Oo("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),zm=Hw({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Hm=Oo("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});function Cl(t){return Qm.createElement(Dt,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Qm.createElement(qw,{color:"black",size:16}))}i(Cl,"BackButton");import{i18n as Gw}from"@lingui/core";import{Button as Vw,Typography as Kw}from"@rango-dev/ui";import kl from"react";function Tl(t){return kl.createElement(fo,null,kl.createElement(Vw,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},kl.createElement(Kw,{variant:"label",size:"medium",color:"error500"},Gw.t("Cancel"))))}i(Tl,"CancelButton");import{i18n as jw}from"@lingui/core";import{Image as Xw,Tooltip as Yw,WalletIcon as Zw}from"@rango-dev/ui";import Uo from"react";function wl(t){let{list:e}=vt(),o=e.filter(r=>r.state==="connected"),n=o.length?Uo.createElement("div",{className:zm()},o.map(r=>Uo.createElement(Hm,{key:r.title},Uo.createElement(Xw,{src:r.image,size:14})))):jw.t("Connect Wallet");return Uo.createElement(Yw,{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($m,null),Uo.createElement(Zw,{size:18,color:"black"})))}i(wl,"WalletButton");import{i18n as Hi}from"@lingui/core";import{NotificationsIcon as mv,Popover as fv,SettingsIcon as gv,Tooltip as Qi,TransactionIcon as hv}from"@rango-dev/ui";import Pe from"react";import{Notifications as tv}from"@rango-dev/ui";import ov from"react";import{useNavigate as nv}from"react-router-dom";import{create as Jw}from"zustand";import{persist as Rw,subscribeWithSelector as ev}from"zustand/middleware";var We=co(Jw()(Rw(ev((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 vl(){let t=nv(),{getNotifications:e,clearNotifications:o}=We(),n=e(),r=k().blockchains(),{findToken:a}=k();return ov.createElement(tv,{id:"widget-notifications-container",list:n,getBlockchainImage:c=>Yp(c,r),getTokenImage:c=>a(c)?.image,onClickItem:i(c=>{t(`${F.swaps}/${c}`)},"onClickItem"),onClearAll:o})}i(vl,"NotificationContent");import{useManager as rv}from"@rango-dev/queue-manager-react";import{InProgressIcon as iv}from"@rango-dev/ui";import qm from"react";var av=i(()=>{let{manager:t}=rv();return Tt(t).map(({swap:o})=>o).find(o=>o.status==="running")?qm.createElement(Um,{id:"widget-header-history-badge-container"},qm.createElement(iv,{color:"info",size:6})):null},"InProgressTransactionBadge"),Gm=av;import{EventSeverity as sv}from"@rango-dev/queue-manager-rango-preset";import{Typography as lv}from"@rango-dev/ui";import Vm from"react";function Km(){let{getNotifications:t}=We(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===sv.WARNING);return o?Vm.createElement(Fm,{isSever:n},Vm.createElement(lv,{variant:"body",size:"xsmall",color:"$background",id:"widget-header-notifications-badge-container"},o)):null}i(Km,"NotificationsBadge");import{RefreshProgressButton as cv}from"@rango-dev/ui";import bl,{useEffect as pv,useState as jm}from"react";var uv=1e3,Xm=60,dv=100;function zi({onClick:t}){let[e,o]=jm(0),[n,r]=jm(!1),a=i(l=>{document.hidden&&l&&s(l)},"handleVisibilityChange");pv(()=>{let l;return t?l=window.setInterval(()=>{o(p=>p+1),e===Xm&&c()},uv):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 bl.createElement(Dt,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:c,disabled:!t},bl.createElement(Om,{onTransitionEnd:()=>r(!1),isRefetched:n},bl.createElement(cv,{size:22,color:t?"black":"gray",progress:e/Xm*dv})))}i(zi,"RefreshButton");function zo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=k(),c=nt("notification",s)||r.includes("notifications");return Pe.createElement(Pe.Fragment,null,!r.includes("refresh")&&Pe.createElement(Qi,{container:a||W(),side:"top",content:Hi.t("Refresh")},Pe.createElement(zi,{onClick:e})),!c&&Pe.createElement(fv,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:W(),content:Pe.createElement(vl,null)},Pe.createElement("div",null,Pe.createElement(Qi,{container:W(),side:"top",content:Hi.t("Notifications")},Pe.createElement(Dt,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Pe.createElement(mv,{size:18,color:"black"}),Pe.createElement(Km,null))))),!r.includes("settings")&&Pe.createElement(Qi,{container:W(),side:"top",content:Hi.t("Settings")},Pe.createElement(Dt,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Pe.createElement(gv,{size:18,color:"black"}))),!r.includes("history")&&Pe.createElement(Qi,{container:W(),side:"top",content:Hi.t("History")},Pe.createElement(Dt,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Pe.createElement(hv,{size:18,color:"black"}),Pe.createElement(Gm,null))))}i(zo,"HeaderButtons");import{i18n as xl}from"@lingui/core";import{Divider as Zm,MessageBox as Cv,RefreshIcon as kv}from"@rango-dev/ui";import vn from"react";import{Button as yv,styled as Sv}from"@rango-dev/ui";var Ym=Sv(yv,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function El(t){let{open:e,onClose:o}=t;return vn.createElement(R,{open:e,dismissible:!0,onClose:o,id:"widget-refresh-modal",container:W()},vn.createElement(Cv,{title:xl.t("Something went wrong"),type:"error",description:xl.t("Something went wrong. Please refresh the app.")},vn.createElement(Zm,{size:30}),vn.createElement(Ym,{variant:"outlined",id:"widget-refresh-modal-refresh-btn",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},vn.createElement(kv,{size:20,color:"primary"}),vn.createElement(Zm,{size:4,direction:"horizontal"}),xl.t("Refresh"))))}i(El,"RefreshModal");function Il(t){let e=t.target;if(e){let o=e.scrollTop,n=W();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(Il,"onScrollContentAttachStatusToContainer");import{css as wv,styled as qi}from"@rango-dev/ui";var Gi=wv({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Jm=qi("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:700},fixed:{minHeight:425,maxHeight:700,height:700}},showBanner:{true:{overflow:"visible"}}}}),Rm=qi("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),ef=qi("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=qi("div",{width:"100%",position:"absolute",bottom:"-$10",transform:"translateY(100%)",overflow:"hidden"});function ae(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=ll(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:c,connectedWallets:l,config:{__UNSTABLE_OR_INTERNAL__:p}}=k(),[u,d]=rf(!1),{config:{features:f,theme:h}}=k(),{watermark:g,setShowCompactTokenSelector:m}=ne(),C=g==="FULL",{activeTheme:y}=mo(h||{}),[S,T]=rf(!1),v=nt("connectWalletButton",f),{isActiveTab:w,tabManagerInitiated:A,showActivateTabModal:N,setShowActivateTabModal:b,activateCurrentTab:x}=ne(),E=Ge(),{manager:B}=bv(),{isTablet:I,isMobile:_}=wn(),G=Tt(B).map(({swap:se})=>se).some(se=>se.status==="running"),Y=i(()=>x(Po.forceClaim,G),"onActivateTab"),L=i(()=>{r.onWallet?.()},"onConnectWallet"),ee=typeof r.hasBackButton>"u"||r.hasBackButton,J=nf(null),te=nf(null);return Vi(()=>{let se=(p?.swapBoxBanner?.routes?.length??0)===0,je=!!p?.swapBoxBanner?.routes?.some(le=>location.pathname.endsWith(le));T(!!p?.swapBoxBanner&&(se||je))},[p?.swapBoxBanner?.routes?.toString(),location.pathname]),Vi(()=>(fr()&&te.current&&e(te.current),()=>{o()}),[]),Vi(()=>(J.current?.addEventListener("scroll",Il),()=>{J.current?.removeEventListener("scroll",Il)}),[]),Vi(()=>{d(c==="failed")},[c]),Iv(()=>{let se=s==="auto"||!te.current||fr(),je=_||I,le=i(()=>{se||(je?te.current.style.height=`${window.innerHeight-te.current.offsetTop}px`:te.current.style.height=`${700}px`,m(parseFloat(te.current.style.height)<640))},"handler");return le(),window.addEventListener("resize",le),()=>window.removeEventListener("resize",le)},[s,_,I]),Be.createElement(Jm,{height:s,id:ot.SWAP_BOX_ID,className:`${y()} ${Gi()}`,ref:te,showBanner:S},Be.createElement(Ev,{prefix:ee?Be.createElement(Cl,{onClick:()=>{E(),r.onBack?.()}}):null,title:r.title,suffix:Be.createElement(Be.Fragment,null,r.suffix,r.onWallet&&!v&&Be.createElement(wl,{container:W(),onClick:L,isConnected:!!l?.length}),r.onCancel&&Be.createElement(Tl,{onClick:r.onCancel}))}),Be.createElement(Rm,{ref:J},n),Be.createElement(Sl,{open:N,onClose:()=>b(!1),onConfirm:Y}),Be.createElement(ef,null,Be.createElement("div",{className:"footer__content"},A&&!w&&Be.createElement("div",{className:"footer__alert"},Be.createElement(hl,{onActivateTab:Y}),Be.createElement(of,{size:10})),a),Be.createElement(of,{size:12}),Be.createElement("div",{className:`footer__logo ${C?"logo__show":"logo__hidden"}`},Be.createElement(xv,null))),S&&Be.createElement(tf,null,p?.swapBoxBanner?.element),Be.createElement(El,{open:u,onClose:()=>d(!1)}))}i(ae,"Layout");import{styled as Av}from"@rango-dev/ui";var af="$20 $20 $10 $20",Al=Av("div",{padding:af,overflowY:"auto",flexGrow:1});import{styled as Nv}from"@rango-dev/ui";var ue=Nv("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 Nl}from"react";function sf(){let[t,e]=Nl(!1),[o,n]=Nl(null),[r,a]=Nl(null),{findToken:s}=k(),c=k().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(y=>y.address?.toLowerCase()===f.toLowerCase())){let y=p("duplicated");n(y);return}let g=await ut().getCustomToken({blockchain:d,address:f});if(!g||!g.token||g.error){let y=p("not-found",d);n(y);return}let m=g.token;if(s({blockchain:m.blockchain,address:m.address,symbol:m.symbol})){let y=p("token-exist");n(y);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 Uv=Pv("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 lf(){let t=Fv(),[e]=Ov(),o=Ge(),n=k().blockchains(),r=e.get("blockchain")||"",a=No(r,n),[s,c]=$v(""),{fetchCustomToken:l,token:p,loading:u,error:d,resetState:f}=sf(),h=!!a&&tn(a,s),g=!a||!s||!h,m=i(()=>{a&&l({blockchain:r,tokenAddress:s})},"getCustomToken");return Ve.createElement(ae,{header:{title:bn.t("Add Custom Token")}},Ve.createElement(ue,null,Ve.createElement(Uv,null,Ve.createElement("div",null,Ve.createElement(ol,{onClick:()=>t(F.blockchains,{replace:!0}),hasLogo:!!a?.logo,value:a?{name:a.displayName,logo:a.logo}:void 0,title:bn.t("Select chain"),placeholder:bn.t("Select chain")}),Ve.createElement(Wl,{size:"24"}),Ve.createElement(Dv,{size:"large",variant:"label"},bn.t("Enter Address")),Ve.createElement(Wl,{size:10}),Ve.createElement(_v,{fullWidth:!0,id:"widget-add-custom-token-token-address-input",disabled:!a,variant:"contained",placeholder:bn.t("Enter token address"),size:"large",value:s,suffix:!!s&&h&&Ve.createElement(Mv,{color:"success",size:12}),onChange:C=>c(C.target.value)}),!h&&!!s&&Ve.createElement(Ve.Fragment,null,Ve.createElement(Wl,{size:4}),Ve.createElement(Wv,{id:"widget-add-custom-token-invalid-address-alert",type:"error",variant:"alarm",title:"Invalid Address"}))),Ve.createElement(Bv,{id:"widget-add-custom-token-import-btn",disabled:g,type:"primary",variant:"contained",loading:u,size:"large",onClick:m},bn.t("Import"))),Ve.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 uc}from"@lingui/core";import{useManager as Ix}from"@rango-dev/queue-manager-react";import{Alert as Ax,Button as Nx,css as mc,Divider as dc,IconButton as Yg,styled as Wx,Typography as Bx,WalletIcon as Lx}from"@rango-dev/ui";import $e,{useEffect as ka,useLayoutEffect as Mx,useRef as Px,useState as Ir}from"react";import{useNavigate as _x}from"react-router-dom";import{i18n as Ho}from"@lingui/core";import{Alert as db,BalanceErrors as mb,Button as Pf,ChevronLeftIcon as fb,Divider as Fl,MessageBox as gb,Typography as Ol}from"@rango-dev/ui";import ie,{useCallback as hb,useEffect as _f,useMemo as yb,useState as In}from"react";import{useNavigate as Sb}from"react-router-dom";import{i18n as Pl}from"@lingui/core";import{Alert as Gv,ChevronDownIcon as Vv,CloseIcon as Kv,Divider as gf,IconButton as hf,PasteIcon as jv,Typography as Xv,WalletIcon as Yv}from"@rango-dev/ui";import _e,{useEffect as Zv,useRef as Jv}from"react";import Yi,{useRef as Qv}from"react";import*as xn from"@radix-ui/react-collapsible";import{keyframes as cf,styled as Ki}from"@rango-dev/ui";var Bl=300,zv=cf({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Hv=cf({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),pf=Ki(xn.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),Ll=Ki(xn.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),ji=Ki(xn.Content,{overflow:"hidden",variants:{open:{true:{animation:`${zv} ${Bl}ms ease-out`},false:{animation:`${Hv} ${Bl}ms ease-out`}}}}),Xi=Ki("div",{transition:`all ${Bl}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Zi(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:c}=t,l=Qv(null);return Yi.createElement(pf,{ref:l,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},c==="top"&&Yi.createElement(Ll,{className:"collapsible_trigger",onClick:a},s),Yi.createElement(ji,{className:"collapsible_content",open:e},r),c==="bottom"&&Yi.createElement(Ll,{className:"collapsible_trigger",onClick:a},s))}i(Zi,"CustomCollapsible");import{darkTheme as uf,styled as Ml,TextField as qv}from"@rango-dev/ui";var df=Ml("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=Ml(qv,{backgroundColor:"$neutral100"}),ff=Ml("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}=k(),c=k().blockchains(),l=ti(e.name,c),p=Jv(null),u=s?.defaultCustomDestinations?.[e.name],d=navigator?.userAgent.includes("Firefox"),h=n&&!!r&&e&&!tn(e,r),g=i(()=>{a("")},"handleClear"),m=i(async y=>{if(y.preventDefault(),navigator.clipboard!==void 0){let S=await navigator.clipboard.readText();a(S),p?.current?.focus()}},"handlePaste"),C=i(()=>r?_e.createElement(hf,{id:"widget-custom-destination-close-icon-btn",onClick:g,variant:"ghost"},_e.createElement(Kv,{size:12,color:"gray"})):d?null:_e.createElement(hf,{id:"widget-custom-destination-paste-icon-btn",onClick:m,variant:"ghost"},_e.createElement(jv,{size:16})),"renderSuffix");return Zv(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),_e.createElement(df,null,_e.createElement(Zi,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:_e.createElement(ff,{id:"widget-custom-destination-collapsible-btn"},_e.createElement("div",{className:"button__content"},_e.createElement(Yv,{size:18,color:"info"}),_e.createElement(gf,{size:4,direction:"horizontal"}),_e.createElement(Xv,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Pl.t("Send to a different address"))),_e.createElement(Xi,{orientation:n?"up":"down"},_e.createElement(Vv,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},_e.createElement(mf,{id:"widget-custom-destination-blockchain-address-input",ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Pl.t("Enter {blockchainName} address",{blockchainName:l}),value:r||"",suffix:C(),onChange:y=>{let S=y.target.value;a(S)}})),h&&_e.createElement(_e.Fragment,null,_e.createElement(gf,{size:4}),_e.createElement(Gv,{variant:"alarm",type:"error",title:Pl.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(yf,"CustomDestination");import{css as Rv,IconButton as eb,SelectableWalletButton as tb,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%"}),kf=ho(tb,{justifyContent:"center"}),Tf=ho("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),wf=ho(eb,{position:"absolute",left:"$20"}),vf=ho("div",{paddingTop:"$20"}),bf=Rv({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),xf=ho("div",{display:"flex"}),Ef=ho("div",{overflow:"visible",width:"100%"});import{i18n as Dl}from"@lingui/core";import{warn as ab}from"@rango-dev/logging-core";import{Divider as sb,makeInfo as lb,SelectableWallet as cb,Typography as Lf,WalletState as Ji}from"@rango-dev/ui";import at,{useEffect as Mf,useState as Sr}from"react";import{Image as rb,MessageBox as ib}from"@rango-dev/ui";import yr from"react";import{keyframes as ob,styled as _l}from"@rango-dev/ui";var If=_l("div",{position:"relative"}),nb=ob({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Af=_l("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${nb} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Nf=_l("div",{"& img":{borderRadius:"50%"}});import{i18n as En}from"@lingui/core";function Wf(t,e){switch(t){case"in-progress":return{type:"loading",title:En.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:En.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:En.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:En.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:En.t("Request Rejected"),description:En.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(Wf,"generateMessageByStatus");function Bf(t){let{status:e,displayName:o,image:n}=t,r=Wf(e,o),a=e=="in-progress";return yr.createElement(ib,{type:r.type,title:r.title,description:r.description,icon:a?yr.createElement(If,null,yr.createElement(Nf,null,yr.createElement(rb,{src:n,size:45})),yr.createElement(Af,null)):void 0})}i(Bf,"ExperimentalChainStatus");var pb=7,ub=3e3;function $l(t){let{chain:e,quoteChains:o,isSelected:n,selectWallet:r,limit:a,onShowMore:s}=t,c=ne.use.isActiveTab(),{checkHasDeepLink:l,getWalletLink:p}=un(),{blockchains:u,connectedWallets:d}=k(),[f,h]=Sr(),[g,m]=Sr(null),[C,y]=Sr(!1),[S,T]=Sr(null),{suggestAndConnect:v}=Ri(),{list:w}=vt({chain:e}),[A,N]=Sr(w),b=w.length,x=a&&b-a>0,E=i(async I=>{y(!1),T("in-progress");try{await v(I.walletType,I.chain),T("completed")}catch{T("rejected")}},"addExperimentalChain");Mf(()=>{N(I=>{let _=w.findIndex(U=>n(U.type,e));return x&&_>1?[w[_]].concat(w.filter((U,G)=>G!==_)):I.map(U=>w.find(G=>G.type===U.type)??U)})},[JSON.stringify(w)]);let B=document.getElementById(ot.SWAP_BOX_ID);return Mf(()=>{let I=null;return(S==="completed"||S==="rejected")&&(I=setTimeout(()=>T(null),ub)),()=>{I&&clearTimeout(I)}},[S]),at.createElement(at.Fragment,null,A.slice(0,a).map(I=>{let _=Nu({connectedWallets:d,walletType:I.type,chain:e}),U=I.state===Ji.CONNECTED,G=_?lo(_,pb):"",Y=U&&!!I.needsNamespace&&!G,L=di(u(),e),ee=!d.find(He=>He.walletType===I.type&&He.chain===e),J=L&&ee&&I.state===Ji.CONNECTED,te=i(async()=>{I.state===Ji.DISCONNECTED||Y?h(I):J?(m({walletType:I.type,chain:e,address:_??""}),y(!0)):r({walletType:I.type,chain:e,address:_??""})},"onSelectableWalletClick"),se=lb(I.state,{hasDeepLink:l(I.type)}),je=i(()=>J?Dl.t({id:"Add {chain} chain",values:{chain:e}}):Y?Dl.t("Chain not connected"):G||se.description,"getWalletDescription"),le=i(()=>I.state===Ji.CONNECTED?Y?"neutral600":"neutral700":se.color,"getWalletDescriptionColor"),Xe=g?.chain?ti(g.chain,u()):void 0;return at.createElement(at.Fragment,{key:`${I.title}_${Xe}`},!!g&&at.createElement(R,{id:"widget-wallets-list-watermarked-modal",open:!!g&&C,container:B,onClose:()=>{m(null)}},at.createElement(Qs,{id:"widget-wallets-list-experimental-chain-container",displayName:Xe,onConfirm:()=>{E(g)}})),S&&at.createElement(R,{id:"widget-wallets-list-experimental-chain-watermarked-modal",open:!!S,onClose:T.bind(null,null),container:B},at.createElement(Bf,{status:S,displayName:Xe,image:I.image}),at.createElement(sb,{direction:"vertical",size:32})),at.createElement(cb,{hasDeepLink:l(I.type),key:I.type,id:"widget-wallets-list-selectable-wallet-btn",description:je(),descriptionColor:le(),onClick:te,selected:n(I.type,e),disabled:!c,...I,link:p(I.type)}))}),at.createElement(sr,{id:"widget-wallets-list-stateful-connect-modal",wallet:f,options:{defaultSelectedChains:o||[e]},onClose:()=>{h(void 0)},onConnect:()=>{t.onConnect&&(f?.type?t.onConnect(f.type):ab(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),x&&at.createElement(kf,{selected:!1,onClick:s,id:"widget-wallets-list-show-more-wallets-btn"},at.createElement(Lf,{variant:"label",size:"medium"},Dl.t("Show more wallets"),at.createElement(Lf,{variant:"label",size:"medium",color:"$primary"},"\xA0+",b-(a??0)))))}i($l,"WalletList");var Cb=2;function Df(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=Sb(),c=k().blockchains(),{selectedQuote:l,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:d,customDestination:f,setCustomDestination:h}=H()(),{config:g,connectedWallets:m,setWalletsAsSelected:C}=k(),[y,S]=In(""),[T,v]=In([]),[w,A]=In(""),[N,b]=In(!!f),x=yb(()=>Lo({filter:"all",quote:l}),[l]),E=Lo({filter:"required",quote:l}),B=c.find($=>$.name===l?.swaps[l?.swaps.length-1]?.to.blockchain),I=i($=>E.includes($),"isWalletRequiredFor"),_=hb(()=>m.filter($=>$.selected&&x.includes($.chain)),[m,x]),[U,G]=In(_()),[Y,L]=In([]),ee=i(($,z)=>L(V=>V.concat({blockchain:$,walletType:z})),"addNextSelectedWallets"),J=T.length>0,te=i(($,z)=>!!U.find(V=>V.walletType===$&&V.chain===z&&V.selected&&(I(z)||!I(z)&&!f)),"isSelected"),se=i(($,z,V)=>{let ce=!1;return $.map(Q=>{if(Q.chain===z){let X=Q.selected;return!ce&&V?(ce=!0,X=!0):V||(X=!1),{...Q,selected:X}}return Q})},"updateSelectableWallets"),je=i($=>{b($),$?I(B?.name??"")||G(z=>se(z,B?.name||"",!1)):(h(""),G(z=>se(z,B?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),le=i($=>{if(y&&S(""),te($.walletType,$.chain))return;let V=m.find(ce=>ce.walletType===$.walletType&&ce.chain===$.chain);V&&(n(),$.chain===B?.name&&N&&!I(B.name)&&(b(!1),h(null)),G(ce=>ce.filter(Q=>Q.chain!==$.chain).concat({...V,selected:!0})))},"onChange"),Xe=i(()=>{let $=U.filter(z=>z.selected);C($),p($),d(!0),o()},"onConfirmBalance"),He=i(async()=>{v([]),A("");let $=await r?.({selectedWallets:U.filter(V=>V.selected),customDestination:f}),z=$.warnings;z?.balance?.messages&&v(z.balance.messages),$.error&&A(Ed($.error)),!$.error&&!z?.balance?.messages.length?Xe():v(z?.balance?.messages??[])},"onConfirmWallets");_f(()=>{G($=>{let z=[];return $.forEach(V=>{!m.some(Q=>Q.chain===V.chain&&Q.walletType===V.walletType&&Q.address===V.address)||z.push(V)}),z=z.concat(m.filter(V=>!!!z.find(Q=>Q.chain===V.chain)&&V.selected&&x.includes(V.chain))),z})},[m,x]),_f(()=>{let $=[];Y.length>0&&(Y.forEach(z=>{let V=m.find(ce=>ce.chain===z.blockchain&&ce.walletType===z.walletType);V?le(V):$.push(z)}),L($))},[m,Y]);let Bt=document.getElementById(ot.SWAP_BOX_ID);return ie.createElement(R,{id:"widget-confirm-wallets-modal",open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!y,container:Bt,...!y&&{styles:{container:{height:"100%"}},footer:ie.createElement(xf,null,ie.createElement(Pf,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:tm(a,N,f,l,U,B),onClick:He,variant:"contained",type:"primary",fullWidth:!0,size:"large"},Ho.t("Confirm")))},...y&&{styles:{container:{height:"100%",padding:"$0"}},header:ie.createElement(Tf,null,ie.createElement(wf,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:S.bind(null,"")},ie.createElement(fb,{size:16})),ie.createElement(Ol,{variant:"headline",size:"small"},Ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:yt(y,c)}})))},anchor:"center"},ie.createElement(R,{id:'"widget-confirm-wallets-insufficient-account-balance-modal',open:J,onClose:v.bind(null,[]),container:Bt},ie.createElement(gb,{title:Ho.t("Insufficient account balance"),type:"error",description:ie.createElement(mb,{messages:T??[]})},ie.createElement(Pf,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:Xe},Ho.t("Proceed anyway")))),y&&ie.createElement(vf,null,ie.createElement("div",{className:bf()},ie.createElement($l,{chain:y,quoteChains:x,isSelected:te,selectWallet:le,onShowMore:()=>S(y),onConnect:$=>{ee(y,$)}}))),!y&&ie.createElement(ie.Fragment,null,w&&ie.createElement(ie.Fragment,null,ie.createElement(db,{id:"widget-confirm-wallet-modal-error-alert",variant:"alarm",type:"error",title:Ho.t(w)}),ie.createElement(Fl,{size:12})),ie.createElement(Ef,null,x.map(($,z)=>{let V=c.find(j=>j.name===$),ce=`wallet-${z}`,Q=z===x.length-1,X=Q&&B&&g?.customDestination!==!1;return ie.createElement("div",{key:ce},ie.createElement(Sf,null,ie.createElement(Ol,{variant:"title",size:"xmedium"},Ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:V?.shortName}})),ie.createElement(Ol,{variant:"label",color:"$neutral700",size:"medium"},Ho.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:V?.shortName}}))),ie.createElement(Fl,{size:24}),ie.createElement(Cf,null,ie.createElement($l,{chain:$,quoteChains:x,isSelected:te,selectWallet:le,limit:Cb,onShowMore:()=>S(V?.name??""),onConnect:j=>{ee($,j)}})),!Q&&ie.createElement(Fl,{size:32}),X&&ie.createElement(yf,{blockchain:B,open:N,handleOpenChange:je}))}))))}i(Df,"ConfirmWalletsModal");import{i18n as Gb}from"@lingui/core";import{Alert as Vb,Button as Kb,Divider as og,InfoIcon as jb}from"@rango-dev/ui";import Oe from"react";import{Alert as wb,Button as vb,Divider as Hl,NoRouteIcon as bb,RefreshIcon as xb,Typography as Qf}from"@rango-dev/ui";import dt from"react";import{i18n as $f}from"@lingui/core";var kb=24,Tb=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 Ul=(o=>(o[o.small=kb]="small",o[o.large=Tb]="large",o))(Ul||{}),zl=(o=>(o.small="small",o.large="medium",o))(zl||{});import{styled as ea}from"@rango-dev/ui";var Of=ea("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Uf=ea("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),zf=ea("div",{variants:{size:{small:{width:"100%"},large:{}}}}),Hf=ea("div",{padding:"$6 $0"});function Cr(t){let{fetch:e,error:o,size:n="small",skipAlerts:r}=t,a=k().getDisabledLiquiditySources(),s=k().toggleAllLiquiditySources,c=k().swappers(),l=Ff(o,a,()=>s(c,!0),e);return r&&(l.alert=null),dt.createElement(Of,{id:"widget-no-result-container"},dt.createElement(bb,{size:Ul[n],color:"gray"}),dt.createElement(Hl,{size:4}),dt.createElement(Qf,{variant:"title",size:zl[n]},re().noResultError.title),n==="large"&&dt.createElement(Hl,{size:4}),!!l.description&&dt.createElement(Uf,{size:n},dt.createElement(Qf,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),dt.createElement(Hl,{size:n==="large"?"24":"4"}),!!l.alert&&dt.createElement(zf,{size:n},dt.createElement(wb,{id:"widget-no-result-alert",type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&dt.createElement(vb,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:dt.createElement(Hf,null,dt.createElement(xb,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(Cr,"NoResult");import{i18n as kr}from"@lingui/core";import{Button as Mb,Divider as Pb,MessageBox as _b,Typography as Db,WarningIcon as $b}from"@rango-dev/ui";import Yt from"react";import{InfoIcon as Nb,Tooltip as Wb,Typography as Bb}from"@rango-dev/ui";import An from"react";import{Button as Eb,darkTheme as Ib,styled as Qo,Typography as Ab}from"@rango-dev/ui";var qf=Qo("div",{width:"100%"}),Ql=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",[`.${Ib} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Vf=Qo("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$2"}),Kf=Qo(Ab,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"250px"}),jf=Qo("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"}),Xf=Qo(Eb,{"& ._text":{gap:"$5",display:"flex",alignItems:"center",justifyContent:"center"}});var Lb=35;function Yf(t){let{title:e,value:o,valueColor:n}=t,r=W();return An.createElement(Gf,null,An.createElement(Bb,{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>Lb&&An.createElement(Wb,{content:o,container:r},An.createElement(Nb,{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:kr.t("Swapping"),value:P(r.inputUsdValue)},{title:kr.t("Gas cost"),value:P(r.totalFee,2,2)},{title:kr.t("Receiving"),value:P(r.outputUsdValue)},{title:kr.t("Price impact"),value:P(r.priceImpact,2,2),valueColor:`${s}500`}];return Yt.createElement(R,{id:"widget-high-value-loss-warning-modal",footer:Yt.createElement(Mb,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Yt.createElement($b,null),fullWidth:!0,disabled:a,onClick:n},re().highValueLossError.confirmMessage),open:e,onClose:o,container:W()},Yt.createElement(_b,{type:s,title:re().highValueLossError.impactTitle,description:re().highValueLossError.description}),Yt.createElement(Ql,null,Yt.createElement(Pb,{size:"4"}),Yt.createElement(Db,{size:"small",variant:"title"},kr.t("Details")),Yt.createElement(Ql,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 Wn}from"@lingui/core";import{Button as Fb,Divider as ql,MessageBox as Ob,WarningIcon as Ub}from"@rango-dev/ui";import Co from"react";import{useNavigate as zb}from"react-router-dom";function eg(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=zb();return Co.createElement(R,{id:"widget-slippage-warning-modal",anchor:"bottom",open:e,container:W(),onClose:o},Co.createElement(Ob,{type:"warning",title:r.type===3?Wn.t("High slippage"):Wn.t("Low slippage"),description:r.type===3?Wn.t("Caution, your slippage is high. Your trade may be front run."):Wn.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:r.minRequiredSlippage}})},Co.createElement(ql,{size:18}),Co.createElement(ql,{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(Ub,{color:"white",size:16}),Wn.t("Swap anyway")),Co.createElement(ql,{size:10}),Co.createElement(Fb,{id:"widget-slippage-warning-modal-change-slippage-btn",size:"large",type:"primary",variant:"outlined",fullWidth:!0,disabled:a,onClick:()=>s("../"+F.settings)},Wn.t("Change Slippage"))))}i(eg,"SlippageWarningModal");import{Button as Hb,MessageBox as Qb,WarningIcon as qb}from"@rango-dev/ui";import ta from"react";function tg(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return ta.createElement(R,{id:"widget-unknown-price-warning-modal",footer:ta.createElement(Hb,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:ta.createElement(qb,null),fullWidth:!0,disabled:r,onClick:n},re().unknownPriceError.confirmMessage),open:e,onClose:o,container:W()},ta.createElement(Qb,{type:"warning",title:re().unknownPriceError.impactTitle,description:re().unknownPriceError.description}))}i(tg,"UnknownPriceWarningModal");function Tr(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 C=!!m&&!s,y=i(S=>{if(S==="change-slippage"){let T=o?.type===3||o?.type===4?o:null,v=Rf(e,T);f?.(v)}else S==="change-settings"&&d()},"onclickActionButton");return Oe.createElement(Oe.Fragment,null,g&&Oe.createElement(Oe.Fragment,null,Oe.createElement(og,{size:10}),Oe.createElement(Cr,{skipAlerts:s,error:o,fetch:c})),C&&Oe.createElement(qf,null,Oe.createElement(og,{size:10}),Oe.createElement(Vb,{id:"widget-quote-warning-and-errors-alert",title:m.title,type:m.alertType,variant:"alarm",...m.action==="show-info"&&{action:Oe.createElement(jf,{onClick:l},Oe.createElement(jb,{size:12,color:"gray"}))},...(m.action==="change-settings"||m.action==="change-slippage")&&{action:Oe.createElement(Kb,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:m.alertType,onClick:()=>y(m.action)},m.actionButtonTitle||Gb.t("Change"))}})),e&&Oe.createElement(Oe.Fragment,null,e.type===0&&Oe.createElement(Zf,{...h,warning:e}),(e.type===3||e.type===2)&&Oe.createElement(eg,{...h,warning:e}),e.type===1&&Oe.createElement(tg,{...h,warning:e})))}i(Tr,"QuoteWarningsAndErrors");import kx from"bignumber.js";import ha from"react";import{i18n as qo}from"@lingui/core";import{Alert as cx,Divider as Ln,FullExpandedQuote as px,InfoIcon as tc,NumericTooltip as oc,QuoteTag as ux,StepDetails as dx,TokenAmount as mx,Typography as Mn,useIsTruncated as nc}from"@rango-dev/ui";import rc from"bignumber.js";import O,{useRef as ma,useState as fx}from"react";import{styled as Gl}from"@rango-dev/ui";var Vl=Gl("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),ng=Gl("div",{paddingBottom:"$15","& .from-amount-text":{wordBreak:"break-word"},variants:{dense:{true:{paddingBottom:0}}}}),rg=Gl("div",{width:"100%",display:"flex"});import*as oa from"@radix-ui/react-collapsible";import{Button as Xb,css as na,darkTheme as De,Image as ig,styled as Ke,Typography as Kl}from"@rango-dev/ui";var Yb=300,ag=Ke(oa.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${De} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),sg=na({padding:"$10 $15"}),lg=Ke(Xb,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${De} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${De} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${De} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),cg=Ke("div",{borderRadius:"$xm",display:"flex",flexDirection:"column",alignItems:"start",justifyContent:"space-between",color:"$foreground",boxSizing:"border-box",position:"relative",variants:{selected:{true:{},false:{$$color:"$colors$neutral200",[`.${De} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${De} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${De} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${De} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${De} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${De} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${De} &`]:{backgroundColor:"$neutral400"}}}}]}),pg=na({width:"100%",padding:"$15 $15 $10 $15"}),ug=na({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Bn=na({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),dg=Ke(oa.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",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${De} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),mg=Ke("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=Ke(ji,{width:"100%",background:"inherit"}),jl=Ke("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${Yb}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),LQ=Ke("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),gg=Ke("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${De} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),hg=Ke("div",{display:"flex",flexDirection:"row",alignItems:"center",gap:"$2",flex:"1 1 auto",minWidth:0}),Xl=Ke(Kl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"$30"}),Yl=Ke(Kl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,flex:"0 1 auto"}),Zl=Ke("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=Ke("div",{display:"flex"}),ra=Ke("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${De} &`]:{borderTopColor:"$neutral800"}}),Sg=Ke(Kl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",minWidth:0,flexShrink:3});import{i18n as $t}from"@lingui/core";import{ChevronDownIcon as Jb,CloseIcon as Rb,Divider as sa,IconButton as ex,NumericTooltip as tx,QuoteCost as ox,Typography as Et}from"@rango-dev/ui";import Z,{useState as wg}from"react";import{css as Zb,styled as ia}from"@rango-dev/ui";var aa=ia("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Jl=ia("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),Cg=ia("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),kg=ia("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),Tg=Zb({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var nx=i(t=>t.fee.isZero()?null:Z.createElement(aa,null,Z.createElement(Et,{variant:"label",size:"medium",color:"neutral600"},t.label),Z.createElement(Et,{variant:"label",size:"medium"},"$",P(t.fee,4,4))),"NonPayableFee");function Rl(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?Bo():W(),m=Kd(h),C=P(c,2,2);return Z.createElement(Z.Fragment,null,Z.createElement(ox,{onClickFee:d?y=>{y.stopPropagation(),o(!e)}:void 0,fee:C,feeWarning:p,timeWarning:u,time:l,steps:a,tooltipGas:d?$t.t("View more info"):void 0,tooltipContainer:g}),Z.createElement(R,{id:"widget-quote-cost-explanation-modal",container:g,open:e,anchor:f?"center":"bottom",styles:{container:{maxWidth:f?"484px":"unset"}},header:Z.createElement(kg,{style:{textAlign:f?"left":"center"}},Z.createElement(Et,{variant:"title",size:"medium"},$t.t("Gas & Fee Explanation")),Z.createElement(ex,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Z.createElement(Rb,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Z.createElement(Cg,null,Z.createElement(Et,{variant:"title",size:"small"},$t.t("Details")),Z.createElement(sa,{size:10}),Object.entries(m.payable).flatMap(([y,S])=>S.map((T,v)=>{let w=`payable-fee-${v}`,A=Xs(T);return Z.createElement(aa,{key:w},Z.createElement(Et,{variant:"label",size:"medium",color:"neutral600"},qs(y,$t.t)),Z.createElement(tx,{content:T.amount,container:g},Z.createElement(Et,{variant:"label",size:"medium"},P(T.amount,2,2),T.asset.symbol," ($",P(A,4,4),")")))})),Z.createElement(aa,{className:"total_payable_fee"},Z.createElement(Et,{variant:"label",size:"medium"},$t.t("Total Payable Fee")),Z.createElement(Et,{variant:"label",size:"medium"},"$",P(c,4,4))),Z.createElement(Jl,null),!!Object.keys(m.nonePayable).length&&Z.createElement(Zi,{triggerAnchor:"bottom",onClickTrigger:()=>r(y=>!y),trigger:Z.createElement("div",{className:Tg()},Z.createElement(Et,{size:"small",variant:"body",color:"neutral700"},n?$t.t("Hide non-payable fees"):$t.t("Show non-payable fees")),Z.createElement(sa,{size:4,direction:"horizontal"}),Z.createElement(Xi,{orientation:n?"up":"down"},Z.createElement(Jb,{size:12,color:"gray"}))),open:n},Z.createElement(Et,{size:"small",variant:"title"},$t.t("Description")),Z.createElement(sa,{size:4}),Z.createElement(Et,{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.`)),Z.createElement(sa,{size:10}),Object.entries(m.nonePayable).map(([y,S],T)=>{let v=Vd(S),w=qs(y,$t.t),A=`non-payable-fee-${T}`;return Z.createElement(nx,{key:A,fee:v,label:w})}),Z.createElement(Jl,null)))))}i(Rl,"QuoteCostDetails");import{i18n as xg}from"@lingui/core";import{TokenAmount as Eg}from"@rango-dev/ui";import la from"react";import{css as rx,styled as ix}from"@rango-dev/ui";var vg=ix("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),bg=rx({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function wr(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return la.createElement(vg,null,la.createElement(Eg,{direction:"horizontal",label:xg.t("Swap input"),id:"widget-quote-summary-swap-input",type:"input",tooltipContainer:W(),price:{value:e.price.value,usdValue:e.price.usdValue,realValue:e.price.realValue,realUsdValue:e.price.realUsdValue},token:{displayName:e.token.displayName,image:e.token.image},chain:{image:e.chain.image}}),la.createElement("div",{className:bg()}),la.createElement(Eg,{id:"widget-quote-summary-estimated-input",direction:"horizontal",tooltipContainer:W(),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(wr,"QuoteSummary");import{i18n as Ig}from"@lingui/core";import{ChevronDownIcon as ax,ChevronRightIcon as sx,Divider as ec,Image as lx,Tooltip as da,Typography as ca}from"@rango-dev/ui";import q from"react";var pa=4,ua=6,vr=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,c=s||W();return q.createElement(da,{container:c,side:"bottom",sideOffset:4,open:r,content:e},q.createElement(mg,{className:n,state:a},q.createElement(lx,{src:o,size:16})))},"ImageComponent");function Ag(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:c}=t,l=c||W(),p=r.length,u=Dd(r),{isTablet:d,isMobile:f}=wn();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:Bn()},q.createElement(ca,{variant:"body",size:"xsmall"},Ig.t("Via:")),q.createElement(ec,{direction:"horizontal",size:4}),r.map((h,g)=>{let m=`item-${g}`,C=q.createElement(jl,null,q.createElement(sx,{size:12,color:"black"}));return f||d?q.createElement(q.Fragment,{key:m},q.createElement(vr,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&q.createElement(q.Fragment,null,C)):q.createElement(q.Fragment,{key:m},p<=pa||p>pa&&g<pa-1?q.createElement(q.Fragment,null,q.createElement(vr,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&q.createElement(q.Fragment,null,C)):g===pa-1&&q.createElement(da,{container:l,side:"bottom",align:"end",sideOffset:4,content:q.createElement("div",{className:Bn()},C,r.map((y,S)=>{let T=`image-${S}`;return S>=g&&q.createElement(q.Fragment,{key:T},q.createElement(vr,{content:y.swapper.displayName,src:y.swapper.image??"",state:y.state,open:!1}),S!==p-1&&q.createElement(q.Fragment,null,C))}))},q.createElement(Zl,{state:r.find((y,S)=>S>=g&&(y.state==="error"||y.state==="warning"))?.state},q.createElement(ca,{size:"xsmall",variant:"body"},"+",p-g))))})),q.createElement("div",{className:Bn()},q.createElement("div",{className:"blockchains_section"},q.createElement("div",{className:Bn()},q.createElement(ca,{variant:"body",size:"xsmall"},Ig.t("Chains:")),q.createElement(ec,{direction:"horizontal",size:4}),u.map((h,g)=>q.createElement(q.Fragment,{key:h.displayName},u.length<=ua||u.length>ua&&g<ua-1?q.createElement(da,{container:l,side:"bottom",content:h.displayName,sideOffset:4},q.createElement(vr,{content:"",src:h.image??"",open:!1,className:g!==0?"blockchainImage":""})):g===ua-1&&q.createElement(da,{container:l,side:"bottom",align:"end",sideOffset:4,content:q.createElement("div",{className:Bn()},u.map((m,C)=>C>=g&&q.createElement(vr,{key:m.displayName,content:"",src:m.image??"",open:!1,className:C>g?"blockchainImage":"",container:c})))},q.createElement(Zl,{className:"blockchainImage"},q.createElement(ca,{size:"xsmall",variant:"body"},"+",u.length-g))))),q.createElement(ec,{direction:"horizontal",size:32}))),q.createElement(jl,{orientation:a?"up":"down"},q.createElement(ax,{size:12,color:"black"}))))}i(Ag,"QuoteTrigger");function ic(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=k().blockchains(),{findToken:g}=k(),m=k().swappers(),{customSlippage:C,slippage:y}=k(),S=C||y,[T,v]=fx(t.expanded),w=ma(null),A=P(n.value,6,6),N=n.usdValue?P(n.usdValue,4,4):"",b=jt(o.usdValue,n.usdValue??null),x=P(b,2,2),E=Xt(b??0),B=i((Q,X)=>Q.map((j,Ie)=>{let Ae,Ye=r?.type===3&&r.swap.swapperId===j.swapperId,Lt=r?.type===4&&!!r.recommendedSlippages?.[Ie],so=a?.type===2&&!!a.recommendedSlippages?.[Ie],Io=Ye||Lt,zn=so;Io?Ae="error":zn&&(Ae="warning");let Rr=Io?qo.t("Slippage Error"):qo.t("Slippage Warning");return Ye&&(Rr=qo.t("Bridge Limit Error")),{swapper:{displayName:Qn(j.swapperId,m)??"",image:j.swapperLogo},from:{token:{displayName:j.from.symbol,image:j.from.logo},chain:{displayName:yt(j.from.blockchain,h)??"",image:j.from.blockchainLogo},price:{value:Ie===0&&!X?P(o.value,6,6):P(j.fromAmount,6,6),usdValue:P((j.from.usdPrice??0)*parseFloat(j.fromAmount),4,4),realValue:Ie===0?o.value:j.fromAmount,realUsdValue:new rc(j.from.usdPrice??0).multipliedBy(j.fromAmount).toString()}},to:{token:{displayName:j.to.symbol,image:j.to.logo},chain:{displayName:yt(j.to.blockchain,h)||"",image:j.to.blockchainLogo},price:{value:P(j.toAmount,6,6),usdValue:P((j.to.usdPrice??0)*parseFloat(j.toAmount),4,4),realValue:j.toAmount,realUsdValue:new rc(j.to.usdPrice??0).multipliedBy(j.toAmount).toString()}},state:Ae,alerts:Io||zn?O.createElement(ng,{dense:d},O.createElement(cx,{variant:"alarm",type:Io?"error":"warning",title:Rr,id:"widget-quote-footer-step-alarm-alert",footer:O.createElement(rg,null,Ye&&O.createElement("div",null,O.createElement(Mn,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),O.createElement(Ln,{direction:"vertical",size:2}),O.createElement(Mn,{size:"xsmall",variant:"body",className:"from-amount-text",color:"neutral900"},qo.t({id:"Yours: {amount} {symbol}",values:{amount:P(j.fromAmount,6,6),symbol:j?.from.symbol}}))),(Lt||so)&&!Ye&&O.createElement("div",null,O.createElement(Mn,{size:"xsmall",variant:"body",color:"neutral900"},qo.t({id:"Minimum suggested slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.[Ie]},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.[Ie]}}})),O.createElement(Ln,{direction:"vertical",size:2}),O.createElement(Mn,{size:"xsmall",variant:"body",color:"neutral900"},qo.t({id:"Yours: {userSlippage}",values:{userSlippage:S}}))))})):void 0,time:Gn(j.estimatedTimeInSeconds),fee:P(js(j,g),2,2),internalSwaps:j.internalSwaps?B(j.internalSwaps):void 0}}),"getQuoteSteps"),I=B(e?.swaps??[]),_=I.length,U=f||W(),G=Fd(t.quote.tags||[]),Y=!!u,L=ci(e?.swaps),ee=Gn(L),J=Mi(e?.swaps??[],g),te=P(J,2,2),se=J.gte(new rc(Ad)),je=L/Wd>=Nd,le=ma(null),Xe=nc(o.value,le),He=ma(null),Bt=nc(n.value,He),$=ma(null),z=nc(N,$),V=I[_-1],ce=I[0];return!ce||!V?null:d?O.createElement(px,{selected:c,fee:te,time:ee,tooltipContainer:Bo(),steps:I,tags:G,id:"widget-quote-full-expanded-quote-container",quoteCost:O.createElement(Rl,{quote:e,fullExpandedMode:!0,time:ee,fee:J,feeWarning:se,timeWarning:je,showModalFee:p,steps:_}),percentageChange:x,warningLevel:E,outputPrice:{value:A,usdValue:N,realValue:n.value,realUsdValue:n.usdValue}}):O.createElement(cg,{id:"widget-quote-summary-container",selected:c,listItem:s==="list-item",basic:s==="basic"},O.createElement("div",{className:pg()},!l&&G.length?O.createElement(O.Fragment,null,O.createElement(yg,null,G.map((Q,X)=>{let j=`${Q.value}_${X}`;return O.createElement(O.Fragment,{key:j},O.createElement(ux,{label:Q.label,value:Q.value}),O.createElement(Ln,{size:4,direction:"horizontal"}))})),O.createElement(ra,null),!Y&&O.createElement(Ln,{size:4})):null,O.createElement("div",{id:"portal-root",className:ug()},O.createElement(Rl,{quote:e,time:ee,fee:J,feeWarning:se,timeWarning:je,showModalFee:p,steps:_}),Y&&O.createElement(lg,{onClick:Q=>{Q.stopPropagation(),u()},id:"widget-quote-all-routes-btn",size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},O.createElement(Mn,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},qo.t("See All Routes")))),s==="basic"&&O.createElement(hg,null,O.createElement(Yl,{ref:le,size:"small",variant:"body"},o.value),Xe&&O.createElement(oc,{content:o.value,container:U,open:o.value?void 0:!1},O.createElement(tc,{size:12,color:"gray"})),O.createElement(Xl,{size:"small",variant:"body"},I[0]?.from.token.displayName),O.createElement(Mn,{size:"small",variant:"body"},"="),O.createElement(Yl,{ref:He,size:"small",variant:"body"},n.value),Bt&&O.createElement(oc,{content:n.value,container:U,open:n.value?void 0:!1},O.createElement(tc,{size:12,color:"gray"})),O.createElement(Xl,{size:"small",variant:"body"},V?.to.token.displayName),O.createElement(Ln,{size:2,direction:"horizontal"}),O.createElement(Sg,{ref:$,color:"$neutral600",size:"xsmall",variant:"body"},`($${N})`),z&&O.createElement(oc,{content:n.usdValue,container:U},O.createElement(tc,{size:12,color:"gray"}))),s==="list-item"&&O.createElement(mx,{id:"widget-quote-token-amount-container",tooltipContainer:U,type:"output",direction:"vertical",price:{value:A,usdValue:N,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:V.to.token.displayName,image:V.to.token.image},chain:{image:V.to.chain.image},percentageChange:x,warningLevel:E}),s==="swap-preview"&&O.createElement(O.Fragment,null,O.createElement(wr,{from:ce.from,to:V.to,percentageChange:x,warningLevel:E}),O.createElement(Ln,{size:4}))),O.createElement(ag,{selected:c,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:v},O.createElement(Ag,{type:s,quoteRef:w,selected:c,setExpanded:v,container:U,expanded:T,steps:I}),O.createElement(fg,{open:T},O.createElement(gg,null),O.createElement("div",{className:sg()},I.map((Q,X)=>{let j=`item-${X}`;return O.createElement(dx,{type:"quote-details",className:"widget-quote-step-details-container",key:j,tooltipContainer:U,step:Q,hasSeparator:X!==I.length-1,state:Q.state})})))))}i(ic,"Quote");import{Divider as Sx,Skeleton as Cx}from"@rango-dev/ui";import eo from"react";import{darkTheme as gx,styled as fa}from"@rango-dev/ui";var Ng=fa("div",{$$color:"$colors$neutral100",[`.${gx} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Wg=fa("div",{paddingTop:"$2"}),Bg=fa("div",{paddingLeft:"$8"}),Lg=fa("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Hg,Divider as It,Skeleton as mt}from"@rango-dev/ui";import K from"react";import{css as hx,styled as Rt}from"@rango-dev/ui";var ac=Rt("div",{display:"flex"}),Mg=Rt("div",{padding:"$10 $0 $20"}),Pg=Rt("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),_g=Rt("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Dg=Rt("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),$g=Rt("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),Fg=Rt("div",{width:"65%",display:"flex",justifyContent:"start"}),Og=Rt("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Ug=Rt("div",{padding:"$15 $0 $15 $0"}),zg=hx({display:"flex",justifyContent:"space-between",alignItems:"center"});function br(t){let{type:e,tagHidden:o=!0}=t,n=K.createElement(Dg,null,K.createElement(Fg,null,K.createElement(Hg,{loading:!0,size:"medium"}),K.createElement(It,{size:8,direction:"horizontal"}),K.createElement(Og,null,K.createElement(mt,{height:10,width:60,variant:"rounded"}),K.createElement(It,{size:4}),K.createElement(mt,{height:15,variant:"rounded"}))),K.createElement(mt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return K.createElement("div",null,!o&&K.createElement(K.Fragment,null,K.createElement(ac,null,K.createElement(mt,{width:65,height:20,variant:"rounded"}),K.createElement(It,{size:4,direction:"horizontal"}),K.createElement(mt,{width:65,height:20,variant:"rounded"}),K.createElement(It,{size:4,direction:"horizontal"}),K.createElement(mt,{width:65,height:20,variant:"rounded"})),K.createElement(ra,null),!r&&K.createElement(It,{size:4})),K.createElement("div",{className:zg()},K.createElement(ac,null,K.createElement(mt,{width:60,height:10,variant:"rounded"}),K.createElement(It,{size:4,direction:"horizontal"}),K.createElement(mt,{width:60,height:10,variant:"rounded"}),K.createElement(It,{size:4,direction:"horizontal"}),K.createElement(mt,{width:60,height:10,variant:"rounded"})),r&&K.createElement(mt,{width:85,height:24,variant:"rounded"})),e==="basic"&&K.createElement(Mg,null,K.createElement(mt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&K.createElement(Pg,null,K.createElement(_g,null,K.createElement(Hg,{loading:!0,size:"medium"}),K.createElement(It,{direction:"horizontal",size:4}),K.createElement(mt,{height:15,width:150,variant:"rounded"})),K.createElement(It,{size:10}),K.createElement(mt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&K.createElement(K.Fragment,null,K.createElement(It,{size:4}),K.createElement(Ug,null,n,K.createElement($g,null),n),K.createElement(It,{size:12})))}i(br,"QuoteSummarySkeleton");import{ChainToken as Kg,Divider as lc,NextIcon as yx,Skeleton as ga}from"@rango-dev/ui";import Le from"react";import{styled as xr}from"@rango-dev/ui";var Qg=xr("div",{display:"flex",alignItems:"start"}),qg=xr("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),sc=xr("div",{display:"flex",alignItems:"center",flexGrow:1}),Gg=xr("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Vg=xr("div",{display:"flex",alignItems:"center"});function Ft(t){let{separator:e=!0}=t;return Le.createElement(Le.Fragment,null,Le.createElement(Vg,null,Le.createElement(ga,{height:22,width:22,variant:"circular"}),Le.createElement(lc,{direction:"horizontal",size:8}),Le.createElement(ga,{height:15,width:148,variant:"rounded"})),Le.createElement(Qg,null,Le.createElement(Lg,{hideSeparator:!e}),Le.createElement(qg,{extraSpace:e},Le.createElement(sc,null,Le.createElement(Kg,{size:"small",loading:!0}),Le.createElement(lc,{direction:"horizontal",size:8}),Le.createElement(ga,{height:12,variant:"rounded"})),Le.createElement(Gg,null,Le.createElement(yx,{color:"gray",size:16})),Le.createElement(sc,null,Le.createElement(Kg,{size:"small",loading:!0}),Le.createElement(lc,{direction:"horizontal",size:8}),Le.createElement(ga,{height:12,variant:"rounded"})))))}i(Ft,"StepSkeleton");function Er(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return eo.createElement(Ng,{expanded:o,rounded:e!=="basic"},eo.createElement(br,{type:e,tagHidden:n}),eo.createElement(Wg,null,eo.createElement(Cx,{height:15,variant:"rounded"})),o&&eo.createElement(Bg,null,eo.createElement(Sx,{size:24}),eo.createElement(Ft,null),eo.createElement(Ft,null),eo.createElement(Ft,{separator:!1})))}i(Er,"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:C}=H()(),y=e?.outputAmount?new kx(e?.outputAmount):null,S=e?Ct(e):null,v=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?ha.createElement(Vl,null,ha.createElement(Er,{tagHidden:c,type:o,expanded:s})):v?ha.createElement(Vl,{onClick:()=>l?.(e),id:d},ha.createElement(ic,{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:C?.toString()??""},output:{value:y?.toString()??"",usdValue:S?.toString()??""}})):null}i(Go,"QuoteInfo");import{warn as bx}from"@rango-dev/logging-core";import{calculatePendingSwap as xx}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Ex}from"react";import{useRef as Tx,useState as wx}from"react";var vx=2e3;function ya({request:t}){let[e,o]=wx(!1),n=Tx(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async c=>(await new Promise(l=>setTimeout(l,vx)),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(ya,"useFetch");function jg(){let{fetch:t,loading:e,cancelFetch:o}=ya({request:async(n,r)=>await ut().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(jg,"useFetchConfirmQuote");function Sa(t){if(!t.swaps)throw new Error(re().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=cc(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(Sa,"throwErrorIfResponseIsNotValid");function cc(t){if(Qd(t)){let{swap:n,fromAmountRangeError:r,recommendation:a}=qd(t);return n?{message:"bridge limit error",options:{type:3,swap:n,recommendation:a,fromAmountRangeError:r}}:null}let o=jd(t);if(o){let n=Pi(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(cc,"getQuoteError");function Xg(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,c={quote:null,balance:null},l=Cn({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});l&&(c.quote=l);let p=Zd(e,r,n.blockchains);return p.length===0||(c.balance={messages:p}),c}i(Xg,"generateWarnings");function Ca(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(Ca,"handleQuoteErrors");function pc(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:c}=H()(),{slippage:l,customSlippage:p}=k(),u=k().getDisabledLiquiditySources(),d=k().blockchains(),f=k().tokens(),{findToken:h}=k(),{swapMode:g}=rt(),m=p||l,{fetch:C,cancelFetch:y,loading:S}=jg();return Ex(()=>y,[]),{loading:S,fetch:i(async v=>{let w=v.selectedWallets,A=v?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let N=w.reduce((x,E)=>(x[E.chain]=E.address,x),{}),b={requestId:a?.requestId||"",selectedWallets:N,destination:A||void 0};try{return await C(b,!0).then(x=>{let{result:E}=x;if(!E)throw new Error(x.error??"Error fetching updated quote");Sa({diagnosisMessages:E.diagnosisMessages,requestId:E.requestId,swaps:E.result?.swaps});let B={outputAmount:E.result?.outputAmount,requestId:E.requestId,resultType:E.result?.resultType,swaps:E.result?.swaps||[],validationStatus:E.validationStatus,requestAmount:E.requestAmount};r(B);let I={slippage:m.toString(),disabledSwappersGroups:u},_=Xg({previousQuote:a??void 0,currentQuote:B,meta:{blockchains:d},selectedWallets:w,userSlippage:m,inputUsdValue:n,findToken:h});c();let U=!!_.balance,G=xx({inputAmount:o.toString(),bestRoute:E,wallets:Yd(w),settings:I,validateBalanceOrFee:!U,meta:{blockchains:d,tokens:f},swapMode:g});return{quote:B,swap:G,error:null,warnings:_}})}catch(x){let E=Ca(x);return E.type!==2&&bx(new Error("confirm swap error"),{tags:{...E,type:Re[E.type],initialQuote:a,requestBody:b}}),{swap:null,error:E,warnings:null}}},"fetch"),cancelFetch:y}}i(pc,"useConfirmSwap");var Dx=Wx("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Yg}`]:{width:"$48",height:"$48"}}),$x=mc({flexGrow:1,paddingRight:"$10"}),Fx=mc({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Ox=mc({display:"flex",justifyContent:"space-between",alignItems:"center"});function Zg(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=H()(),s=_x(),[c,l]=Ir(""),p=!n,[u,d]=Ir(!1),[f,h]=Ir(!1),{isActiveTab:g}=ne(),m=k().getDisabledLiquiditySources(),C=Px(m),{manager:y}=Ix(),{fetch:S,loading:T,cancelFetch:v}=pc(),[w,A]=Ir({swap:null,error:null,warnings:null}),[N,b]=Ir(!1),x=i(async({selectedWallets:L,customDestination:ee})=>{let J=await S?.({selectedWallets:L,customDestination:ee});return A(J),J},"onConfirmSwap"),E=i(async()=>{if(w.swap&&n)try{await y?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let L=`../${F.swaps}/${w.swap.requestId}`;s(L,{replace:!0}),setTimeout(()=>{e("")},0)}catch(L){l("Error: "+L?.message)}},"addNewSwap"),B=i(async()=>{h(!0),await E(),h(!1)},"onConfirm"),I=i(async()=>{w.warnings?.quote&&_d(w.warnings.quote)&&!a?b(!0):await B()},"onStartConfirmSwap"),_=i(async()=>{A({error:null,swap:null,warnings:null}),S({selectedWallets:o,customDestination:r}).then(L=>{A(L)}).catch(L=>console.error(L))},"onRefresh");ka(()=>{!!C.current.length&&!m.length&&_(),C.current=m},[m.length]),ka(()=>{p&&v()},[p]),ka(()=>{p&&d(p)},[p]),ka(()=>{p||S({selectedWallets:o,customDestination:r}).then(L=>A(L)).catch(L=>console.error(L))},[]),Mx(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let U=w.warnings?.quote??null,G=w.error,Y=[];if(c&&Y.push($e.createElement(Ax,{id:"widget-confirm-swap-db-error-alert",type:"error",variant:"alarm",title:c})),U||G){let L=`../${F.settings}`;Y.push($e.createElement(Tr,{warning:U,error:G,couldChangeSettings:!1,refetchQuote:_,skipAlerts:G?.type===4||U?.type===2,showWarningModal:N,confirmationDisabled:!g,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:async()=>{b(!1),await E()},onChangeSettings:()=>s(L)}))}return $e.createElement(ae,{header:{title:uc.t("Confirm Swap"),onWallet:()=>{let L=`../${F.wallets}`;s(L)}},footer:$e.createElement(Dx,null,$e.createElement("div",{className:$x()},$e.createElement(Nx,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||f,disabled:!!w.error||!g,onClick:I},uc.t("Start Swap"))),$e.createElement(Yg,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:T||f,disabled:!g,onClick:d.bind(null,!0)},$e.createElement(Lx,{size:24})))},u&&$e.createElement(Df,{open:u,onClose:()=>d(!1),onCancel:v,loading:T,onCheckBalance:x}),$e.createElement(ue,null,$e.createElement("div",{className:Ox()},$e.createElement(Bx,{variant:"title",size:"small"},uc.t("You get")),$e.createElement("div",{className:Fx()},$e.createElement(zi,{onClick:!T&&!u&&!N?_:void 0}))),$e.createElement(dc,{size:"12"}),Lm(Y.map((L,ee)=>({element:L,key:`alert-${ee}`})),$e.createElement(dc,{size:10})),Y.length>0?$e.createElement(dc,{size:10}):null,$e.createElement(Go,{quote:t,type:"swap-preview",id:"widget-confirm-swap-quote-container",expanded:!0,tagHidden:!0,error:w.error,loading:T,warning:w.warnings?.quote??null})))}i(Zg,"ConfirmSwapPage");import{i18n as oo}from"@lingui/core";import{Button as xc,CustomTokensZeroStateDarkIcon as iE,CustomTokensZeroStateIcon as aE,DeleteIcon as sE,Divider as Lr,IconButton as lE,MessageBox as cE,NotFound as pE,styled as Ic}from"@rango-dev/ui";import ye,{useState as Ec}from"react";import{useNavigate as uE}from"react-router-dom";import{CloseIcon as Ux,IconButton as zx,SearchIcon as Hx,TextField as Qx}from"@rango-dev/ui";import Pn from"react";import{styled as Jg}from"@rango-dev/ui";var Rg=Jg("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"}),eh=Jg("div",{width:"100%","& ._text-field":{paddingLeft:"$10","& input":{paddingLeft:"$2",paddingTop:"$12",paddingBottom:"$12"}}});function At(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(zx,{id:`${u}\u06F0icon-btn`,variant:"ghost",onClick:()=>l?.(""),size:"small"},Pn.createElement(Ux,{color:"gray",size:10})):null;return p&&(f=p),Pn.createElement(eh,null,Pn.createElement(Qx,{prefix:Pn.createElement(Rg,null,Pn.createElement(Hx,{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(At,"SearchInput");import{i18n as bc}from"@lingui/core";import{Button as Kx,CustomTokenWarning as jx,darkTheme as dh,Divider as to,ExternalLinkIcon as Xx,Image as Yx,ListItem as Zx,NotFound as Jx,PinIcon as Rx,Skeleton as Vo,Typography as Wr,VirtualizedList as eE}from"@rango-dev/ui";import M,{useState as tE}from"react";import{useTranslation as oE}from"react-i18next";import{Divider as ph,ListItem as Vx,Skeleton as Nr}from"@rango-dev/ui";import Nt from"react";import{css as _n,darkTheme as fc,ImageContainer as qx,ListItemButton as Gx,styled as st,Typography as th}from"@rango-dev/ui";var gc=_n({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),hc=_n({position:"relative",height:12,width:"30%",maxWidth:"150px"}),yc=_n({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Sc=_n({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${fc} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Cc=_n({}),kc=_n(),oh=st("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Tc=st("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Ta=st("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${hc}`]:{[`& .${Sc}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Cc}`]:{bottom:"-15px"},[`& .${gc}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${yc}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),nh=st(Gx,{variants:{customToken:{true:{"&:hover":{cursor:"unset"}}}}}),wc=st("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),vc=st(th,{}),rh=st("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${kc}`]:{$$color:"$colors$neutral600",[`.${fc} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Ar=st("div",{display:"flex",alignItems:"end",flexDirection:"column"}),IV=st("div",{display:"flex",alignItems:"center"}),ih=st("div",{position:"relative",[`& ${qx}`]:{borderRadius:"$xm",overflow:"hidden"}}),ah=st("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),sh=st(th,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),lh=st("a",{"& svg:hover":{color:"$colors$info"}}),ch=st("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":{[`.${fc} &`]:{color:"$foreground"}}}});function uh(t){return Nt.createElement(Ta,null,Array.from(Array(t.size),e=>Nt.createElement(Vx,{key:e,hasDivider:!0,start:Nt.createElement(Nr,{variant:"circular",width:35,height:35}),end:Nt.createElement(Ar,null,Nt.createElement(Nr,{variant:"text",size:"large",width:70}),Nt.createElement(ph,{size:4}),Nt.createElement(Nr,{variant:"text",size:"medium",width:50})),title:Nt.createElement("div",null,Nt.createElement(Nr,{variant:"text",size:"large",width:90}),Nt.createElement(ph,{size:4}),Nt.createElement(Nr,{variant:"text",size:"medium",width:90}))})))}i(uh,"LoadingTokenList");var nE=20,rE=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,c=e.length;return M.createElement("div",{className:hc()},o?M.createElement("div",{className:gc()},o):M.createElement(Tc,{className:yc()},M.createElement(Wr,{variant:"title",size:"xmedium"},r.symbol),M.createElement(to,{direction:"horizontal",size:4}),M.createElement(wc,{css:a},M.createElement(vc,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&M.createElement("div",{className:`${Sc()} ${!o&&Cc()}`},c>10?`${e.slice(0,5)}...${e.slice(c-6,c)}`:e," ",M.createElement(to,{size:4,direction:"horizontal"}),M.createElement(lh,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:l=>l.stopPropagation()},M.createElement(Xx,{size:12}))))},"renderDesc");function Br(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s,type:c,showWarning:l=!0}=t,p=k().fetchStatus,u=k().blockchains(),{getBalanceFor:d,fetchingWallets:f}=k(),{isTokenPinned:h}=k(),{setFromToken:g,setToToken:m}=H()(),{t:C}=oE(),y=Ge(),[S,T]=tE(null),v=i(()=>{c==="source"?g({token:S,meta:{blockchains:u}}):m({token:S,meta:{blockchains:u}})},"updateToken"),w=i(()=>{v(),y()},"handleImportToken"),A=i(x=>{if(x.customToken){let{customToken:B,...I}=x;return M.createElement(Kx,{variant:"contained",type:"primary",size:"small",className:"widget-token-list-item-import-btn",onClick:i(U=>{U.stopPropagation(),T({...I,warning:!0})},"handleClick")},M.createElement(Wr,{variant:"body",size:"xsmall",color:"background"},C("import")))}let E=mi(d(x));return s?s(x):f?M.createElement(Ar,null,M.createElement(Vo,{variant:"text",size:"large",width:70}),M.createElement(to,{size:4}),M.createElement(Vo,{variant:"text",size:"medium",width:50})):E&&M.createElement(rh,null,M.createElement(sh,{variant:"title",size:"small"},E.amount),M.createElement("div",null),E.usdValue&&M.createElement(Wr,{variant:"body",className:kc(),size:"xsmall"},`$${E.usdValue}`))},"endRenderer"),N=i(()=>M.createElement(eE,{itemContent:x=>{let E=e[x];if(E==="skeleton")return M.createElement(Zx,{hasDivider:!0,start:M.createElement(Vo,{variant:"circular",width:35,height:35}),end:M.createElement(Ar,null,M.createElement(Vo,{variant:"text",size:"large",width:70}),M.createElement(to,{size:4}),M.createElement(Vo,{variant:"text",size:"medium",width:50})),title:M.createElement("div",null,M.createElement(Vo,{variant:"text",size:"large",width:90}),M.createElement(to,{size:4}),M.createElement(Vo,{variant:"text",size:"medium",width:90}))});let B=u.find(L=>L.name===E?.blockchain);if(!B||!E)return null;let I=E.address,_=pl(B.color,"main"),U={$$color:_.main150,[`.${dh} &`]:{$$color:_.main750},backgroundColor:"$$color"},G={$$color:_.main750,[`.${dh} &`]:{$$color:_.main150},color:"$$color"},Y=i(()=>{typeof E!="string"&&!E.customToken&&n?.(E)},"handleClick");return M.createElement(ch,null,M.createElement(nh,{"tab-index":x,key:`${E.symbol}${I}`,id:`${E.symbol}${I}`,className:"widget-token-list-item-btn",hasDivider:!0,customToken:E?.customToken,onClick:Y,start:M.createElement(ih,null,M.createElement(Yx,{src:E.image===""?ni:E.image,size:30}),t.type!=="custom-token"&&E&&h(E,t.type)&&M.createElement(ah,null,M.createElement(Rx,{size:12,color:"gray"}))),title:B.type==="COSMOS"||E.name||!E.name&&!I?M.createElement(Tc,null,M.createElement(Wr,{variant:"title",size:"xmedium"},E.symbol),M.createElement(to,{direction:"horizontal",size:4}),M.createElement(wc,{css:U},M.createElement(vc,{variant:"body",size:"xsmall",css:G},E.blockchain)),l&&E.warning&&M.createElement(M.Fragment,null,M.createElement(to,{direction:"horizontal",size:4}),M.createElement(jx,{container:W()}))):void 0,description:typeof E!="string"&&B.info&&I&&B.type!=="COSMOS"?rE({address:I,token:E,customCssForTag:U,customCssForTagTitle:G,name:E.name,url:B.info.addressUrl.split("{wallet}").join(I)}):E.name||void 0,end:A(E)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList"),b=S?No(S?.blockchain,u):null;return M.createElement(M.Fragment,null,a&&M.createElement(M.Fragment,null,M.createElement(Wr,{variant:"label",size:"large"},bc.t("Select Token")),M.createElement(to,{size:4})),M.createElement(oh,null,M.createElement(to,{size:4}),p==="loading"&&M.createElement(uh,{size:nE}),p==="success"&&(e.length?M.createElement(M.Fragment,null,M.createElement(mr,{token:S,address:S?.address??"",blockchain:b??void 0,onImport:w,onExitErrorModal:()=>T(null),onExitImportModal:()=>T(null)}),M.createElement(Ta,{as:"ul"},N())):!!o&&M.createElement(Jx,{title:bc.t("No results found"),description:bc.t("Try using different keywords")}))))}i(Br,"TokenList");var dE=Ic("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),mE=Ic("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),fE=Ic(lE,{"&:hover":{"& svg":{color:"$secondary550"}}});function mh(){let[t,e]=Ec(""),{deleteCustomToken:o}=k(),n=k().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:c}=H()(),{mode:l}=mo({}),p=uE(),[u,d]=Ec(!1),[f,h]=Ec(),g=i(S=>{let T=S.target.value;e(T)},"handleSearch"),m=l==="dark",C=n.filter(S=>ct(S.symbol,t)||ct(S.address||"",t)||ct(S.name||"",t)),y=i(()=>{if(f){let S=a?St(a):null,T=r?St(r):null,v=St(f);S===v?c({token:null}):T===v&&s({token:null}),o(f)}d(!1)},"handleDeleteCustomToken");return ye.createElement(ae,{header:{title:oo.t("Custom Tokens")}},ye.createElement(ue,null,ye.createElement(dE,null,n.length?ye.createElement(ye.Fragment,null,ye.createElement(At,{id:"widget-custom-tokens-search-token-input",value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:oo.t("Search Token"),onChange:g}),ye.createElement(Lr,{size:16}),ye.createElement(Br,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,showWarning:!1,action:S=>ye.createElement(fE,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{d(!0),h(S)}},ye.createElement(sE,{size:12,color:"gray"}))})):ye.createElement(mE,null,ye.createElement(pE,{icon:m?ye.createElement(iE,{size:200}):ye.createElement(aE,{size:200}),title:oo.t("No custom tokens"),description:oo.t("press the button to add your custom token")})),ye.createElement(Lr,{size:20}),ye.createElement(xc,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p(F.addCustomTokens)},oo.t("Add Custom Token"))),ye.createElement(R,{open:u,id:"widget-custom-tokens-delete-modal",dismissible:!0,onClose:()=>d(!1),container:W()},ye.createElement(cE,{title:oo.t("Delete Custom Token"),type:"error",description:oo.t("Are you sure you want to Delete this Token?")},ye.createElement(Lr,{size:40}),ye.createElement(Lr,{size:10}),ye.createElement(xc,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:y},oo.t("Yes, Delete it")),ye.createElement(Lr,{size:12}),ye.createElement(xc,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>d(!1)},oo.t("No, Continue"))))))}i(mh,"CustomTokensPage");import{i18n as Fe}from"@lingui/core";import{useManager as PE}from"@rango-dev/queue-manager-react";import{Button as Pc,darkTheme as _E,Divider as ko,MessageBox as DE,NotFound as $E,styled as _c,Tabs as FE,Typography as ba}from"@rango-dev/ui";import{TransactionStatus as _r}from"rango-types";import oe,{useMemo as Lh,useState as Dr}from"react";import{useNavigate as OE}from"react-router-dom";import{FilterIcon as TE,Popover as wE}from"@rango-dev/ui";import Ko from"react";import{css as gE,darkTheme as wa,IconButton as hE,styled as Mr}from"@rango-dev/ui";var Ac=Mr("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${wa} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),fh=Mr(hE,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${wa} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${wa} &`]:{backgroundColor:"$neutral"},[`& ${Ac}::before`]:{backgroundColor:"$secondary100",[`.${wa} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),gh=Mr("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),hh=Mr("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),yh=gE({display:"flex",justifyContent:"space-between",alignItems:"center"}),Sh=Mr("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as Ch}from"@lingui/core";import{Button as yE,Divider as kh,ListItemButton as SE,Radio as CE,RadioRoot as kE,Typography as Th}from"@rango-dev/ui";import ft from"react";function wh(t){let{filterBy:e,onClickItem:o}=t;return ft.createElement(hh,null,ft.createElement("div",{className:yh()},ft.createElement(Th,{size:"small",variant:"body"},Ch.t("Status")),ft.createElement(yE,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},Ch.t("Reset"))),ft.createElement(kh,{size:10}),ft.createElement(kE,{value:e},ft.createElement(Sh,null,t.list.map((n,r)=>ft.createElement(SE,{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:ft.createElement(ft.Fragment,null,ft.createElement(kh,{direction:"horizontal",size:4}),ft.createElement(Th,{size:"medium",variant:"body"},n.title)),start:ft.createElement(CE,{value:n.id}),onClick:o})))))}i(wh,"FilterSelectorContent");function Nc(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return Ko.createElement("div",null,Ko.createElement(wE,{open:a,align:"end",onOpenChange:o,container:W(),content:Ko.createElement(wh,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},Ko.createElement(fh,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},Ko.createElement(Ac,{isSelect:!!n},Ko.createElement(TE,{size:16,color:"black"}),!!n&&Ko.createElement(gh,null)))))}i(Nc,"FilterSelector");import{i18n as xE}from"@lingui/core";import{getCurrentStep as EE}from"@rango-dev/queue-manager-rango-preset";import{Divider as Ih,GroupedVirtualizedList as IE,Skeleton as AE,SwapListItem as Ah,Typography as NE}from"@rango-dev/ui";import et,{useCallback as Nh,useEffect as WE,useRef as BE,useState as LE}from"react";function vh(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(vh,"calculateGroupsSoFar");import{css as vE,darkTheme as bE,styled as Pr}from"@rango-dev/ui";var Wc=vE(),bh=Pr("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),Bc=Pr("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${Wc}`]:{$$color:"$colors$neutral600",[`.${bE} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Lc=Pr("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),xh=Pr("div",{gap:"$10",display:"flex",flexDirection:"column"}),Eh=Pr("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var ME=10;function Mc(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=LE([]),c=BE(0),{swaps:l,groupCounts:p,groups:u}=n(e),d=Nh(vh,[]),f=Nh(()=>{let h=e.length-c.current;h&&(c.current+=Math.min(h,ME),s(d(p,c.current)))},[e.length]);if(WE(()=>{r||f()},[r,f]),r){let h=[1,2];return et.createElement(et.Fragment,null,[h,h].map((m,C)=>et.createElement(Bc,{key:C},et.createElement(Lc,null,et.createElement(AE,{variant:"text",width:60,size:"small"}),et.createElement(Ih,{size:16})),et.createElement(Ih,{size:4}),et.createElement(xh,null,m.map((S,T)=>et.createElement(Ah,{isLoading:!0,key:T}))))))}return et.createElement(IE,{endReached:()=>{c.current<e.length&&f()},groupCounts:a,groupContent:h=>et.createElement(Bc,null,et.createElement(Lc,null,et.createElement(NE,{variant:"label",size:"medium",className:Wc()},u[h]))),itemContent:(h,g)=>{let m=l[h];if(!m)return null;let C=EE(m),y=m.steps[0],S=m.steps[m.steps.length-1];return!y||!S?null:et.createElement(bh,{key:m.requestId},et.createElement(Ah,{className:"widget-history-group-list-swap-item-btn",requestId:m.requestId,creationTime:m.creationTime,status:m.status,onClick:o,currentStep:C,tooltipContainer:W(),onlyShowTime:u[g]===xE.t("Today"),swapTokenData:{from:{token:{image:y.fromLogo,displayName:y.fromSymbol},blockchain:{image:y.fromBlockchainLogo||""},amount:P(m.inputAmount,6,6),realAmount:m.inputAmount},to:{token:{image:S.toLogo,displayName:S.toSymbol},blockchain:{image:S.toBlockchainLogo||""},amount:P(S.outputAmount||S.expectedOutputAmountHumanReadable||"",6,6),realAmount:S.outputAmount||S.expectedOutputAmountHumanReadable||""}}}))}})}i(Mc,"HistoryGroupedList");import{i18n as va}from"@lingui/core";import Wh from"dayjs";var Bh=i(t=>{let e=new Map([["today",{title:va.t("Today"),swaps:[]}],["week",{title:va.t("This week"),swaps:[]}],["month",{title:va.t("This month"),swaps:[]}],["year",{title:va.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=Wh();t.forEach(l=>{let p=Number(l.creationTime),u=Wh(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 UE=_c("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),zE=_c("div",{display:"flex",justifyContent:"center",alignItems:"center"}),HE=_c("div",{"._typography":{color:"$neutral700",[`.${_E}&`]:{color:"$neutral900"}}}),QE=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 Mh(){let t=OE(),{manager:e,state:o}=PE(),n=Tt(e).map(({swap:b})=>b),[r,a]=Dr(""),[s,c]=Dr(!1),l=!o.loadedFromPersistor,[p,u]=Dr(""),[d,f]=Dr(!1),[h,g]=Dr("all"),m=i(b=>{let x=b.target.value;a(x)},"handleSearch"),{isMultiMode:C}=rt(),y=[{id:_r.SUCCESS,title:Fe.t("Complete")},{id:_r.RUNNING,title:Fe.t("Running")},{id:_r.FAILED,title:Fe.t("Failed")}],S=[{id:"all",title:Fe.t("All")},{id:"swap",title:Fe.t("Swap")},{id:"refuel",title:Fe.t("Refuel")}],T=Lh(()=>!r&&!p&&h==="all"?n:n.filter(b=>{let{inputAmount:x,status:E,steps:B,requestId:I,mode:_}=b;return(!r||Pt(x,r)||Pt(E,r)||QE(B,r)||Pt(I,r))&&(!p||p===E)&&(h==="all"?!0:h==="swap"?!_||_==="swap":h==="refuel"?_==="refuel":!1)}),[n,r,p,h]),v=!T?.length&&!l,w=i(()=>f(!1),"onCloseModal"),A=i(async()=>{try{await e?.clearQueue(),f(!1)}catch(b){console.log(b)}},"onClear"),N=Lh(()=>!n.some(b=>b.status===_r.SUCCESS||b.status===_r.FAILED),[n]);return oe.createElement(ae,{header:{title:Fe.t("History"),suffix:oe.createElement(fo,null,oe.createElement(Pc,{id:"widget-history-clear-btn",disabled:N,variant:"ghost",size:"xsmall",onClick:()=>f(!0)},oe.createElement(ba,{size:"medium",variant:"label",color:"error"},Fe.t("Clear"))))}},oe.createElement(ue,null,oe.createElement(zE,null,oe.createElement(At,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Fe.t("Search Transaction"),id:"widget-history-search-transaction-input",autoFocus:!0,onChange:m,style:{height:36},value:r}),oe.createElement(ko,{size:10,direction:"horizontal"}),oe.createElement(Nc,{filterBy:p,open:s,onOpenChange:b=>c(b),onClickItem:b=>u(b),list:y})),oe.createElement(ko,{size:"16"}),C&&!l&&oe.createElement(oe.Fragment,null,oe.createElement(FE,{items:S,onChange:b=>g(b.id),value:h,type:"secondary"}),oe.createElement(ko,{size:"12"})),oe.createElement(UE,null,v&&oe.createElement(Eh,null,oe.createElement(ko,{size:32}),oe.createElement($E,{title:r?Fe.t("No results found"):Fe.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Fe.t("Try using different keywords"):Fe.t("Your transaction history is stored locally and will appear here after you start a swap")})),!v&&oe.createElement(Mc,{list:T,onSwapClick:t,groupBy:Bh,isLoading:l}))),oe.createElement(R,{open:d,onClose:w,id:"widget-history-clear-modal",container:W()},oe.createElement(ko,{size:20}),oe.createElement(DE,{type:"warning",title:Fe.t("Clear Transaction History"),description:oe.createElement(HE,null,oe.createElement(ba,{variant:"body",size:"medium"},Fe.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),oe.createElement(ko,{size:"24"}),oe.createElement(ba,{variant:"body",size:"small"},Fe.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),oe.createElement(ko,{size:30}),oe.createElement(Pc,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:A},Fe.t("Yes, Clear the history")),oe.createElement(ko,{size:10}),oe.createElement(Pc,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:w},oe.createElement(ba,{variant:"title",size:"medium",color:"primary"},Fe.t("No, Cancel")))))}i(Mh,"HistoryPage");import{i18n as cy}from"@lingui/core";import{Button as xI,Divider as Xc,styled as EI,WarningIcon as II}from"@rango-dev/ui";import AI from"bignumber.js";import Ce,{useEffect as py,useState as uy}from"react";import{useNavigate as NI}from"react-router-dom";import{i18n as _h}from"@lingui/core";import{Alert as GE,Divider as Dc,NoRouteIcon as VE,Typography as KE}from"@rango-dev/ui";import jo from"react";import{styled as qE}from"@rango-dev/ui";var Ph=qE("div",{display:"flex",flexDirection:"column",alignItems:"center"});function $c(){let{fromToken:t,toToken:e}=H()();return!!t&&!!e&&qt(t,e)?jo.createElement(Ph,null,jo.createElement(Dc,{size:10}),jo.createElement(VE,{size:24,color:"gray"}),jo.createElement(Dc,{size:4}),jo.createElement(KE,{variant:"title",size:"small"},_h.t("No Routes Found")),jo.createElement(Dc,{size:4}),jo.createElement(GE,{title:_h.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 XE}from"@rango-dev/ui";import $h from"react";import{i18n as xa}from"@lingui/core";function Dh(t){let e=null;return t===yi?(e={alertType:"error",action:"reset-slippage",actionButtonTitle:xa.t("Reset"),title:xa.t("Slippage cannot be set lower than 0.01%.")},e):t>an?(e={alertType:"warning",action:"change-settings",actionButtonTitle:xa.t("Change"),title:xa.t("Caution, your slippage is high!")},e):null}i(Dh,"makeAlerts");function Fh(t){let{slippage:e,customSlippage:o,setSlippage:n,setCustomSlippage:r}=k(),{onChangeSettings:a}=t,c=Dh(o!==null?o:e),l=i(p=>{p==="reset-slippage"?(n(hi),r(null)):p==="change-settings"&&a()},"onClickActionButton");return c?$h.createElement(jE,{title:c.title,type:c.alertType,variant:"alarm",action:$h.createElement(XE,{id:"widget-slippage-warning-error-change-settings-or-reset-slippage-btn",size:"xxsmall",type:c.alertType,onClick:()=>l(c.action)},c.actionButtonTitle)}):null}i(Fh,"SlippageWarningsAndErrors");import{i18n as eI}from"@lingui/core";import{IconButton as tI,ReverseIcon as oI,Skeleton as nI,Tooltip as rI,Typography as $r}from"@rango-dev/ui";import gt from"react";import Ea from"bignumber.js";function Uh(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(Uh,"getSlippageColor");function zh(t){let{toTokenUsdPrice:e,fromTokenUsdPrice:o}=t;if(!e||!o)return{rawValue:"0",displayValue:"0"};let n=new Ea(e),r=new Ea(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(zh,"getUsdExchangeRate");function Hh(t,e){let o=new Ea(t).multipliedBy(e);return o.isLessThan(.001)?"$0":`$${o.decimalPlaces(2,Ea.ROUND_DOWN).toFormat(2)}`}i(Hh,"formatTokenValueInUsd");import{darkTheme as JE,styled as Oc,Typography as RE}from"@rango-dev/ui";var Qh=Oc("div",{display:"flex",padding:"$4",justifyContent:"space-between",alignItems:"center"}),qh=Oc("div",{display:"flex",alignItems:"center",gap:"$2","& .rate-text":{color:"$neutral700",[`.${JE} &`]:{color:"$neutral700"}},"& ._icon-button":{transform:"rotate(90deg)",width:"$16",height:"$16"}}),Uc=Oc(RE,{maxWidth:"$32",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});function zc(t){let{slippage:e,customSlippage:o,quoteTokensRate:n,changeQuoteTokensRate:r}=k(),{quoteError:a,quoteWarning:s,fromToken:c,toToken:l,quote:p,loading:u}=t,d=o!==null?o:e,{mode:f}=mo({}),h=cn(d),g=f==="dark",m=n==="default",C={quoteError:a,slippageError:h?.type==="error"?h.message:null},y={quoteWarning:s,slippageWarning:h?.type==="warning"?h.message:null},S=p?.swaps[0]?.from||c,T=p?.swaps[p?.swaps.length-1]?.to||l,v=m?S:T,w=m?T:S,A=Number(m?p?.outputAmount:p?.requestAmount),N=Number(m?p?.requestAmount:p?.outputAmount),b=A||v.usdPrice,x=N||w.usdPrice,{rawValue:E,displayValue:B}=zh({toTokenUsdPrice:x,fromTokenUsdPrice:b});return gt.createElement(Qh,null,gt.createElement($r,{variant:C||y?"label":"body",size:C||y?"medium":"small",color:Uh({error:C,warning:y,isDarkTheme:g})},eI.t("Slippage:")," ",d,"%"),u?gt.createElement(nI,{height:16,width:104,variant:"rounded"}):b&&x&>.createElement(qh,null,gt.createElement($r,{className:"rate-text",variant:"body",size:"small"},"1"),gt.createElement(Uc,{className:"rate-text",variant:"body",size:"small"},w.symbol),gt.createElement(tI,{id:"widget-home-page-change-rate-button",onClick:r},gt.createElement(oI,{size:14,color:"secondary"})),gt.createElement(rI,{container:W(),side:"top",sideOffset:4,content:gt.createElement($r,{className:"rate-text",variant:"body",size:"small"},E)},gt.createElement($r,{className:"rate-text",variant:"body",size:"small"},B)),gt.createElement(Uc,{className:"rate-text",variant:"body",size:"small"},v.symbol),v.usdPrice&>.createElement($r,{color:"neutral600",variant:"body",size:"small"},"~",Hh(Number(E),v.usdPrice))))}i(zc,"SwapMetrics");import{i18n as pI}from"@lingui/core";import{Header as uI}from"@rango-dev/ui";import To,{useEffect as dI,useState as mI}from"react";import{i18n as aI}from"@lingui/core";import{Divider as Qc,FullExpandedQuote as sI,Typography as lI}from"@rango-dev/ui";import ve from"react";import{styled as Hc}from"@rango-dev/ui";var Gh=Hc("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Vh=Hc("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Kh=Hc("div",{width:"146px"});import{i18n as Fr}from"@lingui/core";import{Select as iI}from"@rango-dev/ui";import jh from"react";function Ia(t){let{updateQuotePartialState:e,sortStrategy:o}=H()(),n=[{value:"SMART",label:Fr.t("Smart Routing")},{value:"FEE",label:Fr.t("Lowest Fee")},{value:"SPEED",label:Fr.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Fr.t("Maximum Return")},{value:"PRICE",label:Fr.t("Maximum Output")}];return jh.createElement(Kh,null,jh.createElement(iI,{id:"widget-quotes-strategy-select",container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Ia,"SelectStrategy");var Xh=3;function Or(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:C}=k(),{findToken:y}=k(),S=c||W(),T=!!p&&p.results.length,v=C??m,w=i(b=>{if(!d||!f||!p)return null;let x={requestAmount:p.requestAmount,validationStatus:null,...b};return Cn({currentQuote:x,userSlippage:v,findToken:y})},"getQuoteWarning"),A=g?.type===0||g?.type===1,N=p?.results?Li(h,p?.results):[];return ve.createElement(ve.Fragment,null,a&&ve.createElement(ve.Fragment,null,ve.createElement(Vh,null,ve.createElement(lI,{size:"xmedium",variant:"title"},aI.t("Sort by")),ve.createElement(Ia,{container:S})),ve.createElement(Qc,{size:"10"})),e&&Array.from({length:Xh},(b,x)=>ve.createElement(ve.Fragment,{key:x},s?ve.createElement(sI,{loading:!0}):ve.createElement(Er,{tagHidden:!1,type:"list-item",expanded:!1}),x!==Xh-1&&ve.createElement(Qc,{size:16}))),!e&&ve.createElement(ve.Fragment,null,T?N.map((b,x)=>{let E=w(b),B=cc(b.swaps),I=N.length-1===x;return ve.createElement(ve.Fragment,{key:b.requestId},ve.createElement(Go,{id:"widget-quotes-quote-info-container",showModalFee:r,container:S,selected:l?.requestId===b.requestId,tagHidden:!1,quote:{...b,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:B?.options||null,warning:E,fullExpandedMode:s,onClick:_=>{B||u("warning",E),u("error",B?.options||null),o(_)},type:"list-item"}),!I&&ve.createElement(Qc,{size:16}))}):A&&ve.createElement(Gh,null,ve.createElement(Cr,{size:s?"large":"small",error:g,fetch:n}))))}i(Or,"Quotes");import{darkTheme as cI,styled as Yh}from"@rango-dev/ui";var Zh=Yh("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${cI} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Jh=Yh("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var fI=100;function qc(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,c]=mI(!1),l=s?"":"is-hidden",{config:p}=k(),u=p?.variant==="full-expanded",d=Bo();return dI(()=>{let f=null;return a?f=setTimeout(()=>{c(!0)},fI):(c(!1),f&&clearTimeout(f)),()=>{f&&clearTimeout(f)}},[a]),To.createElement(Zh,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${l} ${Gi()} widget-expanded-quotes-container`,id:ot.EXPANDED_BOX_ID},To.createElement(uI,{title:pI.t("Routes"),suffix:To.createElement(To.Fragment,null,To.createElement(Ia,{container:d}),To.createElement(zo,{container:d,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),To.createElement(Jh,null,To.createElement(Or,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:Bo(),onClickOnQuote:n,fullExpandedMode:u})))}i(qc,"ExpandedQuotes");import{i18n as iy}from"@lingui/core";import{SwapInput as ay}from"@rango-dev/ui";import SI from"bignumber.js";import Ur from"react";import{ReverseIcon as yI}from"@rango-dev/ui";import Vc from"react";import{keyframes as gI,styled as Rh}from"@rango-dev/ui";var Gc=450,hI=gI({"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)"}}),ey=Rh("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),ty=Rh("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${hI} ${Gc}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 Kc(){let t=H().use.switchFromAndTo();return Vc.createElement(ey,null,Vc.createElement(ty,{id:"widget-switch-from-and-to-btn",onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Gc),t()}},Vc.createElement(yI,{size:12})))}i(Kc,"SwitchFromAndToButton");import{styled as oy}from"@rango-dev/ui";var ny=oy("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),ry=oy("div",{position:"relative"});function jc(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:C}=rt(),{connectedWallets:y,getBalanceFor:S}=k(),T=a?S(a):null,v=mi(T)?.amount??"0",w=T?new SI(T.amount).shiftedBy(-T.decimals):de,A=!!s&&Wu(y,s.name),N=!Ks(m,d,f),b=!Ks(m,d,g),x=!f||!g||!g.gt(0)?null:jt(f.toString(),g.toString());return Ur.createElement(ny,null,Ur.createElement(ry,null,Ur.createElement(ay,{label:iy.t("From"),id:"widget-swap-from",mode:"From",onInputChange:p,onInputBlur:u,balance:v,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:P(f,4,4),realUsdValue:N?void 0:f?.toString(),error:N?re().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:A,tooltipContainer:W(),onSelectMaxBalance:()=>{let E=P(w,T?.decimals),B=T?.amount?E.split(",").join(""):"";p(B)},anyWalletConnected:y.length>0}),C==="swap"&&Ur.createElement(Kc,null)),Ur.createElement(ay,{selectionType:C==="swap"?"token":"chain",sharpBottomStyle:!r&&(!!m||e),label:iy.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:P(jt(f,g),2,2),warningLevel:Xt(x??0),price:{value:P(h,6,6),usdValue:b?void 0:P(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:W()}))}i(jc,"Inputs");import{warn as CI}from"@rango-dev/logging-core";import{useCallback as kI,useEffect as TI,useRef as wI,useState as vI}from"react";function sy(){let{fetch:t,loading:e,cancelFetch:o}=ya({request:async(n,r)=>await ut().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(sy,"useFetchAllQuotes");var bI=600;function Aa({refetchQuote:t}){let{fetch:e,cancelFetch:o}=sy(),{excludeLiquiditySources:n,routing:r}=k().config,{connectedWallets:a}=k(),c=a.some(le=>le.isContractWallet),{fromToken:l,toToken:p,inputAmount:u,inputUsdValue:d,selectedQuote:f,sortStrategy:h,resetQuote:g,error:m,warning:C,setSelectedQuote:y,updateQuotePartialState:S}=H()(),{slippage:T,customSlippage:v,affiliatePercent:w,affiliateRef:A,affiliateWallets:N,fetchStatus:b}=k(),x=k().getLiquiditySources(),E=k().getDisabledLiquiditySources(),B=k().excludeLiquiditySources(),{findToken:I}=k(),{swapMode:_}=rt(),[U,G]=vI(!0),Y=wI(u),L=v??T,J=!l||!p||qt(l,p)||!Vn(u),te=i(le=>{G(le)},"resetState"),se=i(le=>{let{fromToken:Xe,toToken:He,inputAmount:Bt,liquiditySources:$,excludeLiquiditySources:z,disabledLiquiditySources:V,slippage:ce,affiliateRef:Q,affiliatePercent:X,affiliateWallets:j}=le;if(U||te(!0),!J&&Xe&&He){g();let Ie=Xd({fromToken:Xe,toToken:He,inputAmount:Bt,liquiditySources:$,excludeLiquiditySources:z,disabledLiquiditySources:V,wallets:a,slippage:ce,affiliateRef:Q,affiliatePercent:X,affiliateWallets:j,contractCall:c});ln("experimental",r)&&(Ie.experimental=!0),ln("avoidNativeFee",r)&&(Ie.avoidNativeFee=!0),ln("enableCentralizedSwappers",r)&&(Ie.enableCentralizedSwappers=!0),r?.maxLength&&(Ie.maxLength=r.maxLength),_==="refuel"&&(Ie.maxLength=1),e(Ie).then(Ae=>{let Ye=Li(h,Ae.results),Lt=$d(f,Ye,Ae.requestAmount);G(!1),S("quotes",Ae),y(Lt),Sa({diagnosisMessages:Ae.diagnosisMessages,requestId:Lt?.requestId||"",swaps:Lt?.swaps});let so=Lt&&Cn({currentQuote:Lt,userSlippage:L,findToken:I});S("warning",so)}).catch(Ae=>{let Ye=Ca(Ae);(Ye.type===0||Ye.type===1)&&g(),Ye.type!==2&&(S("error",Ye),G(!1),CI(new Error("quote error"),{tags:{...Ye,type:Re[Ye.type],requestBody:Ie}}))})}},"fetch"),je=kI(ai(le=>{se(le)},bI),[J]);return TI(()=>{if(!t){G(!1);return}if(b!=="success")return;if(J){G(!1),(f||m||C)&&g();return}if(!Vn(u)&&d?.eq(0)){te(!1),o();return}g(),te(!0);let le=se;return Y.current&&Y.current!=u&&(le=je),Y.current=u,le({inputAmount:u,fromToken:l,toToken:p,liquiditySources:x,excludeLiquiditySources:B,disabledLiquiditySources:E,slippage:L,affiliateRef:A,affiliatePercent:w,affiliateWallets:N,contractCall:c}),o},[b,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,J,x?.length,n,E.length,L,A,w,c,JSON.stringify(N)]),{fetch:()=>se({inputAmount:u,fromToken:l,toToken:p,liquiditySources:x,excludeLiquiditySources:B,disabledLiquiditySources:E,slippage:L,affiliateRef:A,affiliatePercent:w,affiliateWallets:N,contractCall:c}),loading:U}}i(Aa,"useSwapInput");function ly(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};we.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(ly,"emitPreventableEvent");var WI=EI("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),BI=300;function dy(){let t=NI(),{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]=uy(!1),{isLargeScreen:m,isExtraLargeScreen:C}=wn(),{fetch:y,loading:S}=Aa({refetchQuote:a}),{config:T,fetchStatus:v,connectedWallets:w,customSlippage:A,slippage:N,setSlippage:b,setCustomSlippage:x}=k(),{isActiveTab:E}=ne(),[B,I]=uy(!1),_=A!==null?A:N,{swapMode:U}=rt(),G=cn(_),L=Gd({fetchMetaStatus:v,fetchingQuote:S,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:c,needsToWarnEthOnPath:!1}),ee=$u(m,C,T?.variant),J=!!n&&!!e&&!!o&&new AI(n).gt(0)&&!om(e,o),te=J&&v==="success"&&S,se=G?.quoteValidation||c,Xe=(!ee||ee&&l?.results.length)&&(se||s),He=!!e&&!!o,Bt=He&&!!G,$=(r||s)&&!B?y:void 0,z=i(X=>{ee&&h?(g(!1),setTimeout(()=>{t(X)},BI)):t(X)},"onHandleNavigation"),V=i(X=>{r?.requestId!==X.requestId&&(I(!1),p(X))},"onClickOnQuote"),ce=i(X=>{if(X){if(gi.includes(X)){b(X),x(null);return}x(X)}},"onChangeSlippage"),Q=i(X=>{z(X==="from"?F.fromSwap:U==="swap"?F.toSwap:F.toSwap+"/"+F.blockchains)},"handleInputTokenClick");return py(()=>{u(),f("refetchQuote",!0)},[]),py(()=>{g(J)},[J]),Ce.createElement(WI,null,Ce.createElement(ae,{height:"auto",footer:Ce.createElement(xI,{id:`widget-swap-${L.action}-btn`,type:"primary",size:"large",disabled:L.disabled||!E,prefix:L.action==="confirm-warning"&&Ce.createElement(II,null),fullWidth:!0,onClick:()=>{L.action==="connect-wallet"?ly({type:"clickConnectWallet"},()=>z(F.wallets)):L.action==="confirm-warning"?I(!0):z(F.confirmSwap)}},L.title),header:{onWallet:()=>{z(F.wallets)},hasBackButton:!1,title:T.title||(U==="swap"?cy.t("Swap"):cy.t("Refuel")),suffix:Ce.createElement(zo,{hidden:ee?["refresh"]:void 0,onClickRefresh:$,onClickHistory:()=>z(F.swaps),onClickSettings:()=>{z(F.settings)}})}},Ce.createElement(ue,null,Ce.createElement(jc,{fetchingQuote:te,fetchMetaStatus:v,isExpandable:ee,onClickToken:Q}),Ce.createElement(Xc,{size:"2"}),ee?null:Ce.createElement(Go,{quote:r,loading:te,error:s,id:"widget-home-expandable-quote-container",tagHidden:!1,warning:se,type:"basic",onClickAllRoutes:l&&l.results.length>1?()=>{f("refetchQuote",!1),z(F.routes)}:void 0}),He&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Xc,{size:8}),Ce.createElement(zc,{quoteError:s,quoteWarning:se,fromToken:e,toToken:o,quote:r,loading:te})),Xe?Ce.createElement(Ce.Fragment,null,Ce.createElement(Tr,{warning:se,error:s,skipAlerts:!!G,couldChangeSettings:!0,refetchQuote:y,showWarningModal:B,confirmationDisabled:!E,onOpenWarningModal:()=>I(!0),onCloseWarningModal:()=>I(!1),onChangeSlippage:ce,onConfirmWarningModal:()=>{I(!1),d(!0),z(F.confirmSwap)},onChangeSettings:()=>z(F.settings)})):null,Bt&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Xc,{size:"10"}),Ce.createElement(Fh,{onChangeSettings:()=>z(F.settings)})),Ce.createElement($c,null))),ee?Ce.createElement(qc,{loading:te,onClickOnQuote:V,fetch:y,onClickRefresh:$,isVisible:h}):null)}i(dy,"Home");import{i18n as my}from"@lingui/core";import{Alert as LI,Divider as MI,List as PI,ListItemButton as _I,Radio as DI,RadioRoot as $I,Typography as FI}from"@rango-dev/ui";import Ot from"react";function wo(){let{setLanguage:t,language:e,config:o}=k(),n=qu,r=o?.language||pn;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||pn),resetLanguage:()=>t(null)}}i(wo,"useLanguage");function fy(){let{activeLanguage:t,changeLanguage:e,languages:o}=wo(),n=Ge(),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(FI,{variant:"title",size:"xmedium"},c),onClick:()=>{e(a.local),n()},end:Ot.createElement(DI,{value:s}),start:Ot.createElement(l,null)}});return Ot.createElement(ae,{header:{title:my.t("Language")}},Ot.createElement(ue,null,Ot.createElement(LI,{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(MI,{size:"8"}),Ot.createElement($I,{value:t},Ot.createElement(PI,{type:Ot.createElement(_I,{title:my.t("language"),className:"widget-language-list-item-btn",id:"_",onClick:()=>console.log()}),items:r}))))}i(fy,"LanguagePage");import{i18n as no}from"@lingui/core";import{Button as QI,Checkbox as qI,Image as GI,ListItemButton as VI,NotFound as KI,Typography as jI}from"@rango-dev/ui";import tt,{useState as XI}from"react";import{Checkbox as zI,Skeleton as hy}from"@rango-dev/ui";import Hr from"react";import{styled as Yc}from"@rango-dev/ui";var zr=Yc("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),Zc=Yc("div",{width:80,display:"flex",justifyContent:"flex-end"}),Jc=Yc("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as OI,styled as UI}from"@rango-dev/ui";var gy=UI(OI,{height:61});var HI=30;function Rc(){return Hr.createElement(zr,null,Array.from(Array(HI),(t,e)=>Hr.createElement(gy,{hasDivider:!0,key:e,start:Hr.createElement(hy,{variant:"circular",width:35,height:35}),title:Hr.createElement(hy,{variant:"text",size:"large",width:90}),end:Hr.createElement(zI,{checked:!1})})))}i(Rc,"LoadingLiquiditySourceList");function ep({sourceType:t}){let e=k().fetchStatus,o=k().swappers(),n=k().getDisabledLiquiditySources(),[r,a]=XI(""),s=k().toggleLiquiditySource,c=k().isInCampaignMode(),l=Si(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(y=>u.includes(y.type)),f=d.length===d.filter(y=>y.selected).length,h=i(()=>{d.forEach(y=>{f?s(y.groupTitle):y.selected||s(y.groupTitle)})},"toggleAllSources"),g=d.map(y=>{let{selected:S,groupTitle:T,logo:v,id:w,...A}=y;return{id:`widget-setting-liquidity-source-${Su(w.toLowerCase())}-item-btn`,start:tt.createElement(GI,{src:v,size:22,type:"circular"}),onClick:()=>{c||s(T)},end:tt.createElement(qI,{checked:S,disabled:c}),title:tt.createElement(jI,{variant:"title",size:"xmedium"},no.t(T)),selected:S,groupTitle:T,logo:v,...A}}),m=i(y=>{let S=y.target.value;a(S)},"handleSearch"),C=g;return r&&(C=g.filter(y=>Pt(y.groupTitle,r))),tt.createElement(ae,{header:{title:no.t(t),suffix:tt.createElement(Zc,null,tt.createElement(QI,{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")))}},tt.createElement(ue,{view:!0},tt.createElement(At,{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"&&tt.createElement(Rc,null),!C.length&&r?tt.createElement(Jc,null,tt.createElement(KI,{title:no.t("No results found"),description:no.t("Try using different keywords")})):e==="success"&&tt.createElement(zr,{disabled:c,className:"widget-liquidity-source-list"},C.map(y=>{let{groupTitle:S,...T}=y;return tt.createElement(tt.Fragment,{key:y.id},tt.createElement(VI,{style:{height:"61px"},...T,selected:!1,className:"widget-liquidity-source-list-item-btn",hasDivider:!0}))}))))}i(ep,"LiquiditySourcePage");import{i18n as YI}from"@lingui/core";import Na from"react";import{useNavigate as ZI}from"react-router-dom";function yy(){let t=ZI(),e=Ge(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=H()(),{fetch:c,loading:l}=Aa({refetchQuote:n}),p=i(f=>{r(f),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${F.settings}`,d=`../${F.wallets}`;return Na.createElement(ae,{header:{onWallet:()=>{t(d),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:YI.t("Routes"),suffix:Na.createElement(zo,{onClickRefresh:o||s?c:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},Na.createElement(ue,null,Na.createElement(Or,{fetch:c,loading:l,onClickOnQuote:p})))}i(yy,"RoutesPage");import{i18n as by}from"@lingui/core";import{Divider as xy,getCategoriesCount as sA,SelectableCategoryList as lA}from"@rango-dev/ui";import ro,{useState as Ey}from"react";import{useNavigate as cA}from"react-router-dom";import{i18n as tp}from"@lingui/core";import{Divider as tA,Image as oA,ListItemButton as nA,NotFound as rA,Typography as vy}from"@rango-dev/ui";import ht,{useEffect as iA,useState as aA}from"react";var Sy=i((t,e,o)=>t.filter(n=>si(n.type,o)).filter(n=>ct(n.name,e)||ct(n.displayName,e)),"filterBlockchains");import{ImageContainer as JI,styled as Cy}from"@rango-dev/ui";var ky=Cy("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Wa=Cy(Al,{padding:0,margin:0,listStyle:"none",[`& ${JI}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as RI,Skeleton as Ty}from"@rango-dev/ui";import Ba from"react";var eA=20;function wy(){return Ba.createElement(Wa,{id:"widget-blockchain-loading-list",as:"ul"},Array.from(Array(eA),t=>Ba.createElement(RI,{key:t,hasDivider:!0,start:Ba.createElement(Ty,{variant:"circular",width:35,height:35}),title:Ba.createElement(Ty,{variant:"text",size:"large",width:90})})))}i(wy,"LoadingBlockchainList");function op(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,c]=aA(e),{fetchStatus:l}=k();iA(()=>{c([...Sy(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?ht.createElement(rA,{title:tp.t("No results found"),description:tp.t("Try using different keywords")}):ht.createElement(Wa,{as:"ul",key:`${r}-${o}`,id:"widget-blockchain-list"},s.map(u=>ht.createElement(nA,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:ht.createElement(oA,{src:u.logo,size:30}),title:ht.createElement(vy,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return ht.createElement(ht.Fragment,null,a&&ht.createElement(ht.Fragment,null,ht.createElement(vy,{variant:"label",size:"large"},tp.t("Select Chain")),ht.createElement(tA,{size:4})),ht.createElement(ky,null,l==="loading"&&ht.createElement(wy,null),l==="success"&&p()))}i(op,"BlockchainList");function La(t){let{type:e}=t,o=Ge(),[n,r]=Ey(""),[a,s]=Ey("ALL"),c=H().use.setToBlockchain(),l=H().use.setFromBlockchain(),p=H().use.setToToken(),{fetchStatus:u,findNativeToken:d}=k(),f=cA(),{swapMode:h}=rt(),g=k().blockchains({type:e}),m=sA(g),C=!t.hideCategory&&m!==1,y=i(S=>{if(e==="custom-token")f(`..?blockchain=${S.name}`,{replace:!0});else{if(e==="source")l(S);else if(h==="swap")c(S);else{let T=d(S);T&&p({token:T,meta:{blockchains:g}})}o()}},"handleBlockchainChange");return ro.createElement(ae,{header:{title:by.t("Select Chain")}},ro.createElement(ue,{view:!0},C&&ro.createElement(ro.Fragment,null,ro.createElement(lA,{setCategory:s,category:a,blockchains:g,isLoading:u==="loading"}),ro.createElement(xy,{size:24})),ro.createElement(At,{value:n,autoFocus:!0,placeholder:by.t("Search Chain"),id:"widget-select-blockchain-search-input",color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:S=>r(S.target.value)}),ro.createElement(xy,{size:16}),ro.createElement(op,{list:g,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:y})))}i(La,"SelectBlockchainPage");import{i18n as _a}from"@lingui/core";import{Divider as My,Spinner as bA}from"@rango-dev/ui";import vo,{useEffect as xA,useState as EA}from"react";import{useNavigate as IA}from"react-router-dom";import{i18n as ip}from"@lingui/core";import{BlockchainsChip as Ma,Divider as Wy,Image as By,Skeleton as gA,Tooltip as hA,Typography as ap}from"@rango-dev/ui";import be from"react";import{useEffect as dA}from"react";var Iy=["ETH","COSMOS","OSMOSIS"];function np(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(pA),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let c=o.limit-e.length;for(let l=0;l<=c;l++){let p=n[l];s=s.filter(u=>p?.name!==u)}}n.sort(uA(s)),r=n.splice(a)}return{list:n,more:r}}i(np,"prepare");function pA(t,e){let o=Iy,n=o.findIndex(c=>c===t.name),r=o.findIndex(c=>c===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(pA,"sortByMostUsedBlockchains");function uA(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(uA,"generateSortByPreferredBlockchainsFor");function Ay(t,e){return!!e.list.find(o=>o.name===t)}i(Ay,"isInVisibleList");function rp(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=k();dA(()=>{if(e?.selected){let a=np(t,o,e);Ay(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=np(t,o,e);return{list:r.list,more:r.more,history:[]}}i(rp,"usePrepareBlockchainList");import{styled as mA}from"@rango-dev/ui";var Ny=mA("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var yA=6,SA=12;function sp(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,{showCompactTokenSelector:s}=ne(),c=rp(e,{limit:s?4:10,selected:n?.name}),{fetchStatus:l}=k(),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(Wy,{size:12}),be.createElement(ap,{variant:"label",size:"large"},ip.t("Select Chain"))),be.createElement(Wy,{size:12}),be.createElement(Ny,{id:"widget-blockchains-section-container"},l==="loading"&&Array.from(Array(s?yA:SA),(m,C)=>be.createElement(gA,{key:C,variant:"rounded",height:50})),l==="success"&&be.createElement(be.Fragment,null,be.createElement(Ma,{className:"widget-blockchains-section-all-btn",selected:!n,onClick:()=>{o==="from"?u():p()}},be.createElement(ap,{variant:"body",size:"xsmall",color:"secondary500"},ip.t("All"))),c.list.map(m=>be.createElement(hA,{key:m.name,content:m.shortName,side:"bottom",sideOffset:2,container:W()},be.createElement(Ma,{className:"widget-blockchains-section-item-btn",key:m.name,selected:!!n&&n.name===m.name,onClick:()=>r(m)},be.createElement(By,{src:m.logo,size:30})))),h?be.createElement(Ma,{className:"widget-blockchains-section-only-item-btn",key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},be.createElement(By,{src:f.logo,size:30})):null,g?be.createElement(Ma,{onClick:a,key:"more-blockchains",className:"widget-blockchains-section-more-items-btn"},be.createElement(ap,{variant:"body",size:"xsmall",color:"secondary500"},ip._("More +{count}",{count:c.more.length}))):null)))}i(sp,"BlockchainsSection");import{useCallback as kA,useRef as TA,useState as lp}from"react";function cp(){let t=k().blockchains(),e=TA(null),{customTokens:o}=k(),[n,r]=lp(!1),[a,s]=lp([]),[c,l]=lp(null),p=i(async(f,h)=>{l(null),r(!0),s([]);try{let g=await ut().searchCustomTokens({query:f,blockchain:h},{signal:e.current?.signal}),m=new Set(o().map(S=>Vt(S))),C=new Set(t.map(S=>S.name)),y=g.tokens.filter(S=>C.has(S.blockchain)&&!m.has(Vt(S)));s(y),r(!1)}catch(g){l(g instanceof Error?g.message:"something went wrong"),s([]),g?.name!=="CanceledError"&&r(!1)}},"fetch"),u=kA(ai((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(cp,"useSearchCustomTokens");function Pa(t,e,o){return o&&t.length===1&&t[0]?.address===e?!1:t.length<20&&e.trim().length>=3}i(Pa,"shouldSearchForCustomTokens");function Ly(t,e,o,n,r){let a=[...t];return Pa(t,o,r)&&(a=n?[...a,"skeleton","skeleton","skeleton"]:[...a,...e.map(s=>({...s,customToken:!0,warning:!0}))]),a}i(Ly,"prepareTokensList");function Da(t){let{type:e}=t,o=IA(),n=Ge(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:c,setFromBlockchain:l,setToBlockchain:p}=H()(),{getBalanceFor:u}=k(),{fetch:d,loading:f,tokens:h,cancel:g}=cp(),[m,C]=EA(""),y=e==="source"?r:a,S=y?.name??"",T=k().blockchains({type:e}),v=k().tokens({type:e,blockchain:S,searchFor:m,getBalanceFor:u}),w=Ly(v,h,m,f,y?.name),A=i(x=>{e==="source"?l(x):p(x)},"updateBlockchain"),N=i(x=>{e==="source"?s({token:x,meta:{blockchains:T}}):c({token:x,meta:{blockchains:T}})},"updateToken"),b={source:_a.t("Source"),destination:_a.t("Destination")};return xA(()=>(Pa(v,m,y?.name)&&d(m,y?.name??void 0),()=>{g()}),[v.length,m,y?.name]),vo.createElement(ae,{header:{title:_a.t("Swap {type}",{type:b[e]})}},vo.createElement(ue,null,vo.createElement(sp,{blockchains:T,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o(F.blockchains),onChange:x=>{A(x)}}),vo.createElement(My,{size:24}),vo.createElement(At,{value:m,id:"widget-select-swap-item-search-input",autoFocus:!0,placeholder:_a.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>C(""),onChange:x=>C(x.target.value),suffix:Pa(v,m,y?.name)&&f?vo.createElement(bA,{size:12,color:"secondary"}):void 0}),vo.createElement(My,{size:16}),vo.createElement(Br,{list:w,selectedBlockchain:S,searchedFor:m,type:e,onChange:x=>{N(x);let E=T.find(B=>x.blockchain===B.name);E&&A(E),n()}})))}i(Da,"SelectSwapItemsPage");import{i18n as mp}from"@lingui/core";import{Alert as eN,Button as tN,styled as oN}from"@rango-dev/ui";import Xo from"react";import{useInRouterContext as nN,useSearchParams as rN}from"react-router-dom";import{i18n as Oy}from"@lingui/core";import{Alert as BA,Divider as up,InfoIcon as LA,SlippageIcon as MA,TextField as PA,Tooltip as _A,Typography as Uy}from"@rango-dev/ui";import Ue from"react";import{Chip as AA,styled as Qr,TextField as NA}from"@rango-dev/ui";var Py=Qr("div",{paddingTop:"$5",padding:"$10 $5"}),_y=Qr("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${NA}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px",paddingLeft:"$2"}}),Dy=Qr("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),$a=Qr("div",{maxWidth:"280px",padding:"$10"}),$y=Qr(AA,{width:"61px",flexShrink:0});import{i18n as pp}from"@lingui/core";import{Typography as WA}from"@rango-dev/ui";import qr from"react";function Fy(){return qr.createElement($a,null,qr.createElement(WA,{variant:"label",size:"medium",color:"neutral700"},pp.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),qr.createElement("br",null),qr.createElement("br",null),qr.createElement("b",null,pp.t("Warning")),":\xA0",pp.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(Fy,"SlippageTooltipContent");function dp(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=k(),r=o!==null?cn(o):null,a=i(l=>{let p=l.target.value,u=parseFloat(p);if(isNaN(u))return n(null);let d=u;u>Yn&&(d=Yn),n(d)},"onSlippageValueChange"),s=i(l=>{o!==null&&n(null),e(l)},"onClickSlippageChip"),c=i(l=>{let p=l.target,u=p.value;ku(u)||(p.value=u.slice(0,-1))},"onInput");return Ue.createElement(Py,null,Ue.createElement(Dy,null,Ue.createElement(MA,{size:16,color:"gray"}),Ue.createElement(up,{direction:"horizontal",size:4}),Ue.createElement(Uy,{variant:"title",size:"xmedium"},Oy.t("Slippage tolerance per swap")),Ue.createElement(up,{direction:"horizontal",size:4}),Ue.createElement(_A,{container:W(),side:"top",sideOffset:4,content:Ue.createElement(Fy,null)},Ue.createElement(LA,{color:"gray"}))),Ue.createElement(_y,null,gi.map((l,p)=>{let u=`slippage-${p}`;return Ue.createElement($y,{id:`widget-slippage-chip-${l.toString()}%-btn`,key:u,onClick:()=>s(l),selected:o===null&&l===t,label:`${l.toString()}%`})}),Ue.createElement(PA,{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&&Ue.createElement(Uy,{variant:"body",size:"small"},"%"),placeholder:Oy.t("Custom")})),r&&Ue.createElement(Ue.Fragment,null,Ue.createElement(up,{size:10}),Ue.createElement(BA,{id:"widget-slippage-alert",variant:"alarm",type:r.type,title:r.message})))}i(dp,"Slippage");import{i18n as wt}from"@lingui/core";import{AutoThemeIcon as zy,BridgesIcon as DA,ChevronRightIcon as Fa,DarkModeIcon as Hy,Divider as Gr,ExchangeIcon as $A,InfinityIcon as FA,InfoIcon as OA,LanguageIcon as UA,LightModeIcon as Qy,List as zA,ListItem as HA,ListItemButton as QA,Skeleton as qA,styled as GA,Switch as VA,Tabs as KA,TargetIcon as jA,Tooltip as XA,Typography as lt}from"@rango-dev/ui";import D from"react";import{useNavigate as YA}from"react-router-dom";var ZA=GA("div",{width:"202px",height:"$40"}),JA=[{id:"light",icon:D.createElement(Qy,{color:"black",size:24}),tooltip:D.createElement(lt,{size:"xsmall",variant:"body"},wt.t("Light"))},{id:"dark",icon:D.createElement(Hy,{color:"black",size:24}),tooltip:D.createElement(lt,{size:"xsmall",variant:"body"},wt.t("Dark"))},{id:"auto",icon:D.createElement(zy,{color:"black",size:24}),tooltip:D.createElement(lt,{size:"xsmall",variant:"body"},wt.t("Auto"))}],RA=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return D.createElement(zy,{...e});case"dark":return D.createElement(Hy,{...e});default:return D.createElement(Qy,{...e})}},"getThemeIcon");function qy(){let t=YA(),{theme:e}=k().config,{setTheme:o,theme:n}=k(),{activeLanguage:r,languages:a}=wo(),s=a.find(L=>L.local===r)?.label,c=k().fetchStatus,l=k().swappers(),p=k().getDisabledLiquiditySources(),{config:{features:u}}=k(),d=k().customTokens(),f=nt("theme",u),h=nt("liquiditySource",u),g=nt("language",u),m=nt("customTokens",u),C=k().infiniteApprove,y=k().toggleInfiniteApprove,S=Si(l,p),T=S.filter(L=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(L.type)),v=T.length,w=T.filter(L=>L.selected).length,A=S.filter(L=>L.type==="DEX"),N=A.length,b=A.filter(L=>L.selected).length,x=i((L,ee)=>{switch(c){case"loading":return D.createElement(qA,{variant:"text",size:"medium",width:50});case"failed":return D.createElement(lt,{variant:"body",size:"medium",color:"$error500"},wt.t("Loading failed"));default:return D.createElement(lt,{variant:"body",size:"medium"},`${L} / ${ee}`)}},"handleSwapperEndItem"),E={id:"widget-setting-bridge-item-btn",title:D.createElement(lt,{variant:"title",size:"xmedium"},wt.t("Bridges")),end:D.createElement(D.Fragment,null,x(w,v),D.createElement(Gr,{direction:"horizontal",size:8}),D.createElement(Fa,{color:"black"})),onClick:()=>t(F.bridges),start:D.createElement(DA,{color:"gray",size:16})},B={id:"widget-setting-exchange-item-btn",title:D.createElement(lt,{variant:"title",size:"xmedium"},wt.t("Exchanges")),end:D.createElement(D.Fragment,null,x(b,N),D.createElement(Gr,{direction:"horizontal",size:8}),D.createElement(Fa,{color:"black"})),start:D.createElement($A,{color:"gray",size:16}),onClick:()=>t(F.exchanges)},I={id:"widget-setting-custom-tokens-item-btn",title:D.createElement(lt,{variant:"title",size:"xmedium"},wt.t("Custom Tokens")),end:D.createElement(D.Fragment,null,D.createElement(lt,{variant:"body",size:"medium"},`${d.length}`),D.createElement(Gr,{direction:"horizontal",size:8}),D.createElement(Fa,{color:"black"})),start:D.createElement(jA,{color:"gray",size:16}),onClick:()=>t(F.customTokens)},_={id:"widget-setting-language-item-btn",title:D.createElement(lt,{variant:"title",size:"xmedium"},wt.t("Language")),start:D.createElement(UA,{color:"gray",size:16}),end:D.createElement(D.Fragment,null,D.createElement(lt,{variant:"body",size:"medium"},s),D.createElement(Gr,{direction:"horizontal",size:8}),D.createElement(Fa,{color:"black"})),onClick:()=>t(F.languages)},U={id:"widget-setting-infinite-approval-item-btn",title:D.createElement(D.Fragment,null,D.createElement(lt,{variant:"title",size:"xmedium"},wt.t("Infinite approval")),D.createElement(Gr,{direction:"horizontal",size:4}),D.createElement(XA,{side:"top",sideOffset:4,container:W(),content:D.createElement($a,null,D.createElement(lt,{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(OA,{color:"gray"}))),start:D.createElement(FA,{color:"gray",size:16}),end:D.createElement(VA,{checked:C}),onClick:y},G={id:"widget-setting-theme-item-btn",type:D.createElement(HA,null),title:D.createElement(lt,{variant:"title",size:"xmedium"},wt.t("Theme")),end:D.createElement(ZA,null,D.createElement(KA,{container:W(),items:JA,value:n,className:"widget-setting-theme-item-tabs-container",onChange:L=>o(L.id),type:"primary",borderRadius:"small"})),start:RA(n)},Y=h?[]:[E,B];return m||Y.push(I),g||Y.push(_),Y.push(U),!e?.singleTheme&&!f&&Y.push(G),D.createElement(zA,{type:D.createElement(QA,{className:"widget-settings-list-item-btn",hasDivider:!0,id:"_",onClick:()=>console.log()}),items:Y})}i(qy,"SettingsLists");var iN=oN("div",{paddingLeft:"$8"});function Gy(){let{isInCampaignMode:t,updateCampaignMode:e}=k(),o=t(),[,n]=rN(),r=nN(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Xo.createElement(ae,{header:{title:mp.t("Settings")}},Xo.createElement(ue,null,o&&Xo.createElement(eN,{type:"info",variant:"alarm",id:"widget-settings-campaign-mode-alert",title:mp.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(iN,null,Xo.createElement(tN,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},mp.t("Reset")))}),Xo.createElement(dp,null),Xo.createElement(qy,null)))}i(Gy,"SettingsPage");import{i18n as g0}from"@lingui/core";import{cancelSwap as h0}from"@rango-dev/queue-manager-rango-preset";import{useManager as y0}from"@rango-dev/queue-manager-react";import{Alert as S0}from"@rango-dev/ui";import Wp from"react";import{useParams as C0}from"react-router-dom";import{i18n as zt}from"@lingui/core";import{getCurrentNamespaceOfOrNull as t0,getCurrentStep as o0,getRelatedWalletOrNull as n0}from"@rango-dev/queue-manager-rango-preset";import{Button as OS,Divider as r0,QuoteCost as i0,StepDetails as a0,Typography as bp}from"@rango-dev/ui";import{useWallets as s0}from"@rango-dev/wallets-react";import US from"bignumber.js";import{PendingSwapNetworkStatus as Fn}from"rango-types";import Te,{useEffect as xp,useRef as Ep,useState as Ka}from"react";import{useNavigate as l0}from"react-router-dom";import{i18n as bo}from"@lingui/core";var aN=[bo.t("Sunday"),bo.t("Monday"),bo.t("Tuesday"),bo.t("Wednesday"),bo.t("Thursday"),bo.t("Friday"),bo.t("Saturday")];function Vy(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?bo.t("Today"):`${aN[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Vy,"timeSince");function Ky(t){return t.finishTime?Vy(parseInt(t.finishTime)):Vy(parseInt(t.creationTime))}i(Ky,"getSwapDate");import Vr from"react";import{i18n as Oa}from"@lingui/core";import{Button as jy,Divider as fp,MessageBox as sN}from"@rango-dev/ui";import xo from"react";var Xy=i(({onCancel:t,onClose:e})=>xo.createElement(xo.Fragment,null,xo.createElement(fp,{size:20}),xo.createElement(sN,{type:"error",title:Oa.t("Cancel Swap"),description:Oa.t("Are you sure you want to cancel this swap?")}),xo.createElement(fp,{size:32}),xo.createElement(jy,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Oa.t("Yes, Cancel it")),xo.createElement(fp,{size:12}),xo.createElement(jy,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Oa.t("No, Continue"))),"CancelContent");import{i18n as Ua}from"@lingui/core";import{Button as Yy,Divider as gp,MessageBox as lN,Typography as cN}from"@rango-dev/ui";import io from"react";var Zy=i(({onDelete:t,onClose:e})=>io.createElement(io.Fragment,null,io.createElement(gp,{size:20}),io.createElement(lN,{type:"error",title:Ua.t("Delete Transaction"),description:Ua.t("Are you sure you want to delete this swap?")}),io.createElement(gp,{size:32}),io.createElement(Yy,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Ua.t("Yes, Delete it")),io.createElement(gp,{size:12}),io.createElement(Yy,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},io.createElement(cN,{variant:"title",size:"medium",color:"primary"},Ua.t("No, Cancel")))),"DeleteContent");import{i18n as pN}from"@lingui/core";import{Button as uN,Divider as dN,MessageBox as mN}from"@rango-dev/ui";import Yo from"react";var Jy=i(t=>{let{switchNetworkModalState:e,handleSwitchNetwork:o}=t;return Yo.createElement(Yo.Fragment,null,Yo.createElement(mN,{type:e.type,title:e.title,description:e.description}),e.type==="error"&&Yo.createElement(Yo.Fragment,null,Yo.createElement(dN,{size:"30"}),Yo.createElement(uN,{id:"widget-switch-network-try-again",type:"primary",size:"large",onClick:o},pN.t("Try Again"))))},"NetworkStateContent");import{getCurrentNamespaceOfOrNull as BN,getCurrentStep as LN,getRelatedWalletOrNull as MN}from"@rango-dev/queue-manager-rango-preset";import{WalletState as PN}from"@rango-dev/ui";import{useWallets as _N}from"@rango-dev/wallets-react";import iS from"react";import{i18n as Dn}from"@lingui/core";import{Alert as tS,Button as hN,Checkbox as yN,Divider as Qa,Image as SN,MessageBox as CN,Spinner as kN,WarningIcon as TN}from"@rango-dev/ui";import{useWallets as wN}from"@rango-dev/wallets-react";import Se,{useState as vN}from"react";import{css as fN,darkTheme as gN,styled as hp}from"@rango-dev/ui";var Ry=fN({wordWrap:"break-word",display:"block"}),eS=hp("img",{width:"100%"}),za=hp("div",{position:"relative"}),Ha=hp("span",{position:"absolute",top:0,right:0,borderRadius:"50%",width:"14px",height:"14px",display:"flex",padding:"$2",backgroundColor:"$warning300",[`.${gN} &`]:{$$color:"$warning600"}});var oS=i(t=>{let{wallet:e,namespace:o,onClose:n}=t,[r,a]=vN(null),{list:s}=vt(),c=ne.use.isActiveTab(),{state:l,connect:p}=wN(),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,C=i(()=>m?Dn.t("Done"):r?Dn.t("Try again"):Dn.t("Connect"),"getButtonTitle"),y=i(()=>g?Se.createElement(kN,{color:"info"}):r||m?null:Se.createElement(yN,{checked:!0,disabled:!0}),"getNamespaceSuffix"),S=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"),T=i(async()=>{if(m){n();return}S()},"handleClickButton"),v=i(()=>{if(!m)return null;let w=u?.isHub?h?.accounts?.[0]?.split(":"):f?.accounts?.[0]?.split(":"),A=w?.[w?.length-1];return A?lo(A):null},"getAddress");return Se.createElement(Se.Fragment,null,Se.createElement(CN,{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:Se.createElement(za,null,Se.createElement(SN,{src:u.image,size:45}),Se.createElement(Ha,null,Se.createElement(TN,{color:"warning",size:10})))}),m&&!d&&Se.createElement(Se.Fragment,null,Se.createElement(Qa,{size:10}),Se.createElement(tS,{type:"success",variant:"alarm",title:Dn.t("Wallet connected successfully.")})),r&&!d&&Se.createElement(Se.Fragment,null,Se.createElement(Qa,{size:10}),Se.createElement(tS,{type:"error",title:r?.message,variant:"alarm"})),d&&Se.createElement(Se.Fragment,null,Se.createElement(Qa,{size:30}),Se.createElement(_o,{namespace:d,suffix:y(),error:r?.message,connected:m,address:v()})),Se.createElement(Qa,{size:"40"}),Se.createElement(hN,{loading:g,type:"primary",id:"widget-connect-wallet-btn",onClick:T,disabled:!c},C()))},"ConnectWalletContent");import{i18n as nS}from"@lingui/core";import{Button as bN,Divider as xN,Image as EN,MessageBox as IN,WarningIcon as AN}from"@rango-dev/ui";import{useWallets as NN}from"@rango-dev/wallets-react";import{detectInstallLink as WN}from"@rango-dev/wallets-shared";import ao from"react";var rS=i(t=>{let{walletType:e}=t,{getWalletInfo:o}=NN(),n=e?o(e):null;if(!n)return null;let r=i(()=>window.open(WN(n.installLink),"_blank"),"handleButtonClick");return ao.createElement(ao.Fragment,null,ao.createElement(IN,{type:"warning",title:nS.t("Install {wallet}",{wallet:n.name}),description:"Your wallet is not installed. Please install it to continue the swap. ",icon:ao.createElement(za,null,ao.createElement(EN,{src:n.img,size:45}),ao.createElement(Ha,null,ao.createElement(AN,{color:"warning",size:10})))}),ao.createElement(xN,{size:"40"}),ao.createElement(bN,{type:"primary",id:"widget-install-wallet-btn",onClick:r},nS.t("Install")))},"InstallWalletContent");var aS=i(t=>{let{swap:e,onClose:o}=t,{state:n}=_N(),r=LN(e),a=r?MN(e,r):null,s=a?.walletType,c=s?Kn(n(s)):null,l=r?BN(e,r):null;return s?c===PN.NOT_INSTALLED?iS.createElement(rS,{walletType:s}):iS.createElement(oS,{wallet:a,namespace:l,onClose:o}):null},"WalletStateContent");function yp(t){let{isOpen:e,state:o,switchNetworkModalState:n,onClose:r,onDelete:a,onCancel:s,swap:c,message:l,handleSwitchNetwork:p}=t;return Vr.createElement(R,{open:e,onClose:r,container:W()},o==="connectWallet"&&Vr.createElement(aS,{swap:c,message:l,onClose:r}),o==="switchNetwork"&&n&&Vr.createElement(Jy,{message:l,switchNetworkModalState:n,handleSwitchNetwork:p}),o==="delete"&&Vr.createElement(Zy,{onClose:r,onDelete:()=>{r(),a()}}),o==="cancel"&&Vr.createElement(Xy,{onClose:r,onCancel:()=>{r(),s()}}))}i(yp,"SwapDetailsModal");import{i18n as Kr}from"@lingui/core";import{Button as Sp,Divider as jr,MessageBox as cS,TokenAmount as DN,Typography as pS}from"@rango-dev/ui";import ke from"react";import{Link as $N,useNavigate as FN}from"react-router-dom";var sS="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",lS="/profile";function Cp(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=FN(),{showProfileBanner:g}=ne();return ke.createElement(R,{open:e,onClose:o,id:"widget-swap-details-complete-modal",container:document.getElementById(ot.SWAP_BOX_ID)||document.body},n==="success"?ke.createElement(cS,{type:"success",title:Kr.t("Swap Successful")},ke.createElement(DN,{direction:"vertical",tooltipContainer:W(),id:"widget-swap-details-complete-modal-success-token-amount-container",type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:c},token:l,chain:p,percentageChange:u}),ke.createElement(jr,{size:12}),ke.createElement(pS,{className:Ry(),variant:"body",size:"medium",color:"neutral700",align:"center"},d)):ke.createElement(cS,{type:"error",title:Kr.t("Transaction Failed"),description:d}),ke.createElement(jr,{size:30}),n==="success"&&ke.createElement(ke.Fragment,null,g&&ke.createElement(ke.Fragment,null,ke.createElement($N,{to:lS},ke.createElement(eS,{src:sS,alt:"Profile Banner"})),ke.createElement(jr,{size:30})),ke.createElement(Sp,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{h("../../")}},Kr.t("Done"))),ke.createElement(jr,{size:12}),f&&ke.createElement(ke.Fragment,null,ke.createElement(Sp,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(f,"_blank")},Kr.t("Diagnosis")),ke.createElement(jr,{size:12})),ke.createElement(Sp,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},ke.createElement(pS,{variant:"title",size:"medium",color:"primary"},Kr.t("See Details"))))}i(Cp,"SwapDetailsCompleteModal");import{i18n as Va}from"@lingui/core";import{CopyIcon as YN,DoneIcon as ZN,IconButton as JN,RangoExplorerIcon as RN,Tooltip as MS,Typography as PS,useCopyToClipboard as e0}from"@rango-dev/ui";import Wt from"react";import XN from"react";import{i18n as GN}from"@lingui/core";import{Alert as NS,IconButton as VN,LinkIcon as KN}from"@rango-dev/ui";import Eo,{Fragment as jN}from"react";import{Alert as UN,ChevronDownIcon as zN,IconButton as HN}from"@rango-dev/ui";import $n,{useState as QN}from"react";import{css as Xr,darkTheme as uS,styled as Ut,Typography as ON}from"@rango-dev/ui";var dS=Ut(ue,{overflowY:"auto","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${uS} &`]:{color:"$secondary500"}}}}}),mS=Ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),fS=Ut("div",{position:"sticky",top:0,zIndex:10,backgroundColor:"$background"}),gS=Ut("div",{padding:"$0 $20 $20 $20"}),WY=Ut("div",{display:"flex",flexDirection:"column",gap:"$10"}),hS=Ut("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),BY=Ut("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),Zo=Xr({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${uS} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),yS=Xr({padding:"$5 0"}),qa=Xr({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),SS=Xr({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),CS=Xr({width:"100%",padding:"0 $20 $10"}),kS=Ut("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),TS=Ut("div",{display:"flex",flexDirection:"column",gap:"$5"}),Ga=Ut(ON,{wordBreak:"break-word"});import{styled as kp}from"@rango-dev/ui";var wS=kp("div",{display:"flex",flexDirection:"column",gap:"$10"}),vS=kp("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),bS=kp("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function xS(t){let{message:e}=t,[o,n]=QN(!1);return $n.createElement(UN,{id:"widget-failed-swap-details-alert",type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&$n.createElement(HN,{id:"widget-swap-details-failed-btn",onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},$n.createElement(vS,{rotated:o},$n.createElement(zN,{size:12,color:"gray"}))),footer:$n.createElement(bS,{open:o},$n.createElement(Ga,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(xS,"FailedAlert");import{i18n as ES}from"@lingui/core";import{Alert as Tp,Button as IS}from"@rango-dev/ui";import{PendingSwapNetworkStatus as qN}from"rango-types";import Yr from"react";function AS(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,setNetworkModal:n,message:r,showNetworkModal:a}=t;return e?Yr.createElement(Tp,{type:"warning",id:"widget-swap-details-change-network-alert",title:r.shortMessage,action:Yr.createElement(IS,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{n("switchNetwork"),o()}},ES.t("Change"))}):a===qN.WaitingForConnectingWallet?Yr.createElement(Tp,{type:"warning",title:r.shortMessage,id:"widget-swap-details-warning-alert-connect-wallet-alert",action:Yr.createElement(IS,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{n("connectWallet")}},ES.t("Connect"))}):Yr.createElement(Tp,{id:"widget-swap-details-short-alert",type:"warning",title:r.shortMessage})}i(AS,"WarningAlert");function wp(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(wS,null,s.explorerUrl?.map((f,h,g)=>{let m=h+f.url,C=h===g.length-1,y=(C&&u||p)&&!d,S=C&&s.status==="failed";return Eo.createElement(jN,{key:m},Eo.createElement(NS,{id:"widget-swap-details-tx-alert",type:C&&(y&&"loading"||S&&"error")||"success",title:f.description?`${f.description} Tx`:GN.t("View transaction"),action:f.url&&Eo.createElement(VN,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(f.url,"_blank")},Eo.createElement(KN,{size:12}))}))}),d&&Eo.createElement(NS,{id:"widget-swap-details-loading-alert",type:"loading",title:a.shortMessage}),s.status!=="failed"&&l&&Eo.createElement(AS,{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a}),s.status==="failed"&&Eo.createElement(xS,{message:a}))}i(wp,"SwapDetailsAlerts");var WS=2e3;var BS=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:P(c,6,6),realValue:c??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:yt(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:P(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:XN.createElement(wp,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function LS(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(LS,"getStepState");function _S(t){let{requestId:e}=t,[o,n]=e0(WS);return Wt.createElement(fS,{className:Zo()},Wt.createElement(PS,{variant:"label",size:"large",color:"neutral700"},Va.t("Request ID")),Wt.createElement("div",{className:qa()},Wt.createElement(PS,{variant:"label",size:"small",color:"neutral700"},e),Wt.createElement(MS,{container:W(),content:o?Va.t("Copied To Clipboard"):Va.t("Copy Request ID"),open:o||void 0,side:"bottom",alignOffset:-16,align:"end"},Wt.createElement(JN,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:n.bind(null,e||"")},o?Wt.createElement(ZN,{size:16,color:"secondary"}):Wt.createElement(YN,{size:16,color:"gray"}))),Wt.createElement(kS,{target:"_blank",href:`${nu}/swap/${e}`},Wt.createElement(MS,{container:W(),content:Va.t("View on Rango Explorer"),side:"bottom"},Wt.createElement(RN,{size:20})))))}i(_S,"RequestIdRow");import{i18n as DS}from"@lingui/core";import{Typography as $S}from"@rango-dev/ui";import vp from"react";function FS(t){let{date:e,isFinished:o}=t;return vp.createElement("div",{className:Zo()},vp.createElement($S,{variant:"label",size:"large",color:"neutral700"},o?DS.t("Finished at"):DS.t("Created at")),vp.createElement($S,{variant:"label",size:"small",color:"neutral700"},e))}i(FS,"SwapDateRow");var c0=3e3;function Ip(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:c}=s0(),l=k().blockchains(),p=k().swappers(),{findToken:u}=k(),d=H().use.retry(),f=l0(),h=Ep(null),[g,m]=Ka(!1),[C,y]=Ka(null),[S,T]=Ka(null),[v,w]=Ka(null),A=Ep(C),N=Ep(S),b=We.use.getNotifications(),x=We.use.removeNotification(),E=b(),B=o0(e),I=B?.networkStatus,_=i(Me=>{m(!0),y(Me)},"handleChangeModalState"),U=i(()=>{m(!1)},"handleCloseModal"),G=i(()=>{T({type:"loading",title:zt.t("Change Network"),description:`We\u2019re switching the connected network to ${J?.network}. Please check your wallet.`})},"handleShowSwitchNetworkLoading"),Y=i(()=>{T({type:"success",title:zt.t("Network Changed"),description:"The network has been successfully changed."})},"handleShowSwitchNetworkSucceeded"),L=i(Me=>{T({type:"error",title:zt.t("Network Switch Failed"),description:Me?.message||ce.detailedMessage.content})},"handleShowSwitchNetworkFailed"),ee=Rd(e),J=B?t0(e,B):null,te=B?n0(e,B):null,se=Ky(e),je=em(e),le=i(Me=>!!c(Me)?.mobileWallet,"checkIsMobileWallet"),Xe=!!I&&[Fn.WaitingForNetworkChange,Fn.NetworkChangeFailed].includes(I),He=!!te?.walletType&&le(te.walletType),Bt=!!te&&!!J&&a(te.walletType,J.network,J),$=!!J&&Xe&&(He||Bt),z=i(()=>{$&&(G(),s(te.walletType,[{namespace:J.namespace,network:J.network}]).then(()=>{Y()}).catch(Me=>{L(Me)}))},"handleSwitchNetwork"),V=i(()=>{_("switchNetwork"),z()},"handleSwitchNetworkClick"),ce=Jd(e,B,c),Q=BS({swap:e,switchNetworkIsAvailable:$,handleSwitchNetworkClick:V,showNetworkModal:I,setNetworkModal:_,message:ce,blockchains:l,swappers:p}),X=Q.length,[j,Ie]=[e.steps[0],e.steps[X-1]],Ae=Ie?.outputAmount||Ie?.expectedOutputAmountHumanReadable,Ye=e.steps.reduce((Me,Mt)=>Me+parseFloat(Mt.feeInUsd||""),0),Lt=e.steps.find(Me=>Me.diagnosisUrl)?.diagnosisUrl,so=P(parseFloat(Ae||"0")*(Ie?.toUsdPrice||0),4,4),Io=P(parseFloat(e.inputAmount)*(j?.fromUsdPrice||0),4,4),zn=Ae?new US(Ae).multipliedBy(Ie.toUsdPrice||0).toString():"",Rr=new US(e.inputAmount).multipliedBy(j?.fromUsdPrice||0).toString(),rs=jt(Io,so),is=ce.detailedMessage.content||ce.shortMessage,CC=e.status==="success"?zt.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:P(Ae,6,6),token:Q[X-1]?.to.token.displayName,conciseAddress:lo(e.wallets[Q[X-1]?.to.chain.displayName||""]?.address||""),chain:Q[X-1]?.to.chain.displayName}}):Te.createElement(TS,null,Te.createElement(bp,{variant:"body",size:"medium",color:"neutral700",align:"center"},is?"":zt.t("Transaction was not sent."),ee?`${zt.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:ee.outputAmount,symbol:ee.symbol,blockchain:ee.blockchain}})}`:""),is&&Te.createElement(Ga,{align:"center",variant:"body",size:"medium",color:"neutral700"},Te.createElement("b",null,"Reason:")," ",is));return xp(()=>{E.find(Mt=>Mt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(w(e.status),x(e.requestId),U()):v&&w(null))},[e.status,e.requestId]),xp(()=>{if($){if(_("switchNetwork"),I===Fn.WaitingForNetworkChange){G();return}if(I===Fn.NetworkChangeFailed){L();return}return}if(I===Fn.WaitingForConnectingWallet){_("connectWallet");return}if(I===Fn.NetworkChanged){_("switchNetwork"),Y();return}C&&["connectWallet","switchNetwork"].includes(C)&&U()},[I]),xp(()=>{if(A.current=C,N.current=S,C==="switchNetwork"&&S?.type==="success"){let Me=setTimeout(()=>{A.current==="switchNetwork"&&N.current?.type==="success"&&U()},c0);return()=>clearTimeout(Me)}},[C,S]),Te.createElement(ae,{header:{title:zt.t("Swap Details"),onCancel:e.status==="running"?()=>_("cancel"):void 0,suffix:e.status!=="running"&&Te.createElement(fo,null,Te.createElement(OS,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>_("delete")},Te.createElement(bp,{size:"medium",variant:"label",color:"error"},zt.t("Delete"))))},footer:je&&!v&&Te.createElement(OS,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let Me=Bi(e,l,u);d(Me),setTimeout(()=>{f("../../")},0)}},zt.t("Try again"))},Te.createElement(dS,{compact:!0,ref:h},Te.createElement(_S,{requestId:o}),Te.createElement(FS,{date:se,isFinished:!!e.finishTime}),Te.createElement("div",{className:SS()},Te.createElement(i0,{fee:P(String(Ye),2,2),time:Gn(ci(e.steps)),steps:X}),Te.createElement(wr,{from:{price:{value:P(e.inputAmount,6,6),usdValue:Io,realUsdValue:Rr,realValue:e.inputAmount},token:{displayName:Q[0]?.from.token.displayName||"",image:Q[0]?.from.token.image},chain:{image:Q[0]?.from.chain.image,displayName:Q[0]?.from.chain.displayName||""}},to:{price:{value:P(Ae,6,6),usdValue:so,realUsdValue:zn,realValue:Ae||""},token:{displayName:Q[X-1]?.to.token.displayName||"",image:Q[X-1]?.to.token.image},chain:{image:Q[X-1]?.to.chain.image,displayName:Q[X-1]?.to.chain.displayName||""}},percentageChange:P(rs,2,2),warningLevel:Xt(rs??0)})),Te.createElement("div",{className:CS()},Te.createElement(bp,{variant:"title",size:"small"},zt.t("Swaps steps"))),Te.createElement(r0,{size:8}),Te.createElement(gS,null,Q.map((Me,Mt)=>{let Up=Mt,Hn=e.steps[Mt]&&LS(e.steps[Mt]),kC=Hn==="error"||Hn==="in-progress"||Hn==="warning"||Hn==="completed"&&Mt===Q.length-1;return Te.createElement(a0,{className:"widget-swap-details-step-item-container",key:Up,step:Me,type:"swap-progress",ref:h,state:Hn,hasSeparator:Mt!==0,tabIndex:Up,isFocused:kC,tooltipContainer:W()})}))),Te.createElement(yp,{isOpen:g,state:C,switchNetworkModalState:S,onClose:U,onCancel:r,onDelete:n,message:ce.detailedMessage.content,swap:e,handleSwitchNetwork:V}),Te.createElement(Cp,{open:!!v,diagnosisUrl:Lt,onClose:()=>w(null),status:e.status==="success"?"success":"failed",priceValue:P(Ae,6,6),usdValue:so,realUsdValue:zn,realValue:Ae||"",percentageChange:P(rs,2,2),token:{displayName:Q[X-1]?.to.token.displayName||"",image:Q[X-1]?.to.token.image},chain:{image:Q[X-1]?.to.chain.image},description:CC}))}i(Ip,"SwapDetails");import{i18n as Xa}from"@lingui/core";import{Divider as QS,NotFound as f0,Skeleton as Jr,Typography as Ya}from"@rango-dev/ui";import Ee from"react";import{i18n as p0}from"@lingui/core";import{Divider as u0,Skeleton as d0,Typography as m0}from"@rango-dev/ui";import xe from"react";import{css as Ht,styled as Ap}from"@rango-dev/ui";var zS=Ap("div",{width:"100%",height:"100%",padding:"$10 $20"}),Zr=Ap("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),ja=Ap("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),r9=Ht({display:"flex",justifyContent:"space-between",alignItems:"center"}),i9=Ht({paddingTop:"$15",display:"flex"}),a9=Ht({padding:"$15 $0"}),s9=Ht({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),l9=Ht({paddingBottom:"$10"}),c9=Ht({display:"flex",justifyContent:"start",alignItems:"center"}),p9=Ht({paddingTop:"$5",display:"flex",alignItems:"center"}),u9=Ht({display:"flex",alignItems:"center"}),d9=Ht({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),HS=Ht({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Np(){return xe.createElement(zS,null,xe.createElement(br,{type:"swap-preview"}),xe.createElement("div",{className:"swaps-steps"},xe.createElement(m0,{variant:"title",size:"small"},p0.t("Swaps steps"))),xe.createElement(xe.Fragment,null,xe.createElement(Zr,null,xe.createElement(Ft,{separator:!1}),xe.createElement("div",{className:HS()},xe.createElement(u0,{direction:"horizontal",size:20}),xe.createElement(d0,{height:22,variant:"rectangular"}))),xe.createElement(ja,null),xe.createElement(Zr,null,xe.createElement(Ft,{separator:!1})),xe.createElement(ja,null),xe.createElement(Zr,null,xe.createElement(Ft,{separator:!1})),xe.createElement(ja,null),xe.createElement(Zr,null,xe.createElement(Ft,{separator:!1}))))}i(Np,"LoadingSwapDetails");function qS(t){let{requestId:e,showSkeleton:o}=t;return Ee.createElement(ae,{header:{title:Xa.t("Swap Details"),suffix:Ee.createElement(fo,null)}},o&&Ee.createElement(mS,null,Ee.createElement("div",{className:Zo()},Ee.createElement(Ya,{variant:"label",size:"large",color:"neutral700"},`${Xa.t("Request ID")}`),Ee.createElement("div",{className:qa()},Ee.createElement(Ya,{variant:"label",size:"small",color:"neutral700"},Ee.createElement(Jr,{width:60,height:10,variant:"rounded"})),Ee.createElement(QS,{direction:"horizontal",size:4}),Ee.createElement(Jr,{width:16,height:16,variant:"rectangular"}),Ee.createElement(QS,{direction:"horizontal",size:4}),Ee.createElement(Jr,{width:16,height:16,variant:"rectangular"}))),Ee.createElement("div",{className:Zo()},Ee.createElement(Ya,{className:yS(),variant:"label",size:"large",color:"neutral700"},Ee.createElement(Jr,{width:60,height:10,variant:"rounded"})),Ee.createElement(Ya,{variant:"label",size:"small",color:"neutral700"},Ee.createElement(Jr,{width:60,height:10,variant:"rounded"}))),Ee.createElement(Np,null)),!o&&Ee.createElement(hS,null,Ee.createElement(f0,{title:Xa.t("Not found"),description:Xa.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(qS,"SwapDetailsPlaceholder");function GS(){let{manager:t,state:e}=y0(),o=!e.loadedFromPersistor,n=Tt(t),{requestId:r}=C0(),a=Ge(),{fetchStatus:s}=k();if(!r)return Wp.createElement(S0,{containerStyles:{margin:"20px"},type:"error",title:g0.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&&h0(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?Wp.createElement(qS,{requestId:r,showSkeleton:c}):Wp.createElement(Ip,{swap:d,requestId:r,onCancel:p,onDelete:u})}i(GS,"SwapDetailsPage");import{i18n as VS}from"@lingui/core";import{Divider as k0,getCategoriesCount as T0,SelectableCategoryList as w0,styled as jS,Typography as v0,Wallet as b0,WalletState as x0}from"@rango-dev/ui";import{useWallets as E0}from"@rango-dev/wallets-react";import Qt,{useState as KS}from"react";var I0=jS("div",{display:"flex",justifyContent:"center",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5"}),A0=jS(ue,{textAlign:"center"});function XS(){let{fetchStatus:t}=k(),[e,o]=KS("ALL"),n=k().blockchains(),{config:r}=k(),{state:a}=E0(),{checkHasDeepLink:s,getWalletLink:c}=un(),[l,p]=KS(),u=ne.use.isActiveTab(),{list:d}=vt(),f=Lu(d,n),g=T0(f)!==1,m=Mu(d,e),C=i(y=>{mu(d,r.multiWallets)||p(y)},"handleWalletItemClick");return Qt.createElement(ae,{header:{title:VS.t("Connect Wallets")}},Qt.createElement(A0,null,g&&Qt.createElement(Qt.Fragment,null,Qt.createElement(w0,{setCategory:o,category:e,blockchains:f,isLoading:t==="loading"}),Qt.createElement(k0,{size:24})),Qt.createElement(v0,{variant:"title",size:"xmedium",align:"center"},VS.t("Choose a wallet to connect.")),Qt.createElement(I0,null,m.map((y,S)=>{let T=a(y.type).namespaces,v=`wallet-${S}-${y.type}`,w=gs(y,T),A=y.state;return w&&(A=x0.PARTIALLY_CONNECTED),Qt.createElement(b0,{key:v,...y,state:A,hasDeepLink:s(y.type),link:c(y.type),container:W(),onClick:()=>C(y),isLoading:t==="loading",disabled:!u})}),Qt.createElement(sr,{id:"widget-state-full-connect-modal",wallet:l,onClose:()=>{p(void 0)}}))))}i(XS,"WalletsPage");function YS(){return um(),el(),N0([{path:F.home,element:ze.createElement(dy,null)},{path:F.routes,element:ze.createElement(yy,null)},{path:F.fromSwap,children:[{index:!0,element:ze.createElement(Da,{type:"source"})},{path:F.blockchains,element:ze.createElement(La,{type:"source"})}]},{path:F.toSwap,children:[{index:!0,element:ze.createElement(Da,{type:"destination"})},{path:F.blockchains,element:ze.createElement(La,{type:"destination"})}]},{path:F.settings,children:[{index:!0,element:ze.createElement(Gy,null)},{path:F.languages,element:ze.createElement(fy,null)},{path:F.exchanges,element:ze.createElement(ep,{sourceType:"Exchanges"})},{path:F.bridges,element:ze.createElement(ep,{sourceType:"Bridges"})},{path:F.customTokens,children:[{index:!0,element:ze.createElement(mh,null)},{path:F.addCustomTokens,children:[{index:!0,element:ze.createElement(lf,null)},{path:F.blockchains,element:ze.createElement(La,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:F.swaps,children:[{index:!0,element:ze.createElement(Mh,null)},{path:F.swapDetails,element:ze.createElement(GS,null)}]},{path:F.wallets,element:ze.createElement(XS,null)},{path:F.confirmSwap,element:ze.createElement(Zg,null)}])}i(YS,"AppRoutes");import{useQueueManager as V0}from"@rango-dev/queue-manager-rango-preset";import{isEvmBlockchain as K0}from"rango-sdk";import{useContext as j0,useEffect as Pp,useState as lC}from"react";import{Provider as P0}from"@rango-dev/wallets-react";import Za,{createContext as _0,useEffect as tC,useMemo as D0,useRef as oC}from"react";import{useEffect as W0}from"react";function ZS(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(ZS,"hashProviders");function Bp(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=k(),a=n();return W0(()=>{o(),r()},[ZS(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(Bp,"useWalletProviders");import{legacyFormatAddressWithNetwork as B0,legacyReadAccountAddress as JS}from"@rango-dev/wallets-core/legacy";import{Events as On}from"@rango-dev/wallets-react";import{isEvmBlockchain as L0}from"rango-sdk";function RS(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=k(),{onConnectWalletHandler:c,onDisconnectWalletHandler:l}=t,p=s().filter(L0).map(m=>m.name),u=i((m,C)=>{let[y,,S,T,v]=m,w={walletType:y,network:T.network??void 0,accounts:S};c.current?c.current(w):console.warn("onConnectWallet handler hasn't been set. Are you sure?");let A=fs(y,S,p,C.supportedChainNames,v.isContractWallet);A.length&&e(A,v.namespace,T.derivationPath)},"onAccountsEvent"),d=i((m,C,y,S,T)=>{if(C===On.ACCOUNTS){let v=jn(T.supportedBlockchains);y&&u([m,C,y,S,T],{supportedChainNames:v})}C===On.PROVIDER_DISCONNECTED&&(o(m),l.current?l.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),C===On.NAMESPACE_DISCONNECTED&&n(m,y)},"handleUpdatesForHub"),f=i((m,C,y,S,T)=>{if(C===On.ACCOUNTS){let v=jn(T.supportedBlockchains),w=[],A=[];if(y?.forEach(b=>{let{network:x}=JS(b);p.includes(x)?w.push(b):A.push(b)}),r.filter(b=>b.walletType===m).map(b=>B0(b.address,b.chain)).length>0){if(w.length>0){let b=fs(m,w,p,v,T.isContractWallet);a(m,{chains:b.map(x=>x.chain)})}A.length>0&&a(m,{chains:A.map(b=>{let{network:x}=JS(b);return x})})}y?u([m,C,y,S,T],{supportedChainNames:v}):(o(m),l.current?l.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}},"handleUpdatesForLegacy"),h=i((m,C,y,S,T)=>{if(C===On.CONNECTED&&y){let v={walletType:m,network:S.network??void 0,accounts:S.accounts??void 0};c.current?c.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(C===On.NETWORK&&y){let v={walletType:m,network:y,accounts:S.accounts??void 0};c.current?c.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((m,C,y,S,T)=>{T.isHub?d(m,C,y,S,T):f(m,C,y,S,T),h(m,C,y,S,T)},"handler")}}i(RS,"useUpdates");import{LegacyEvents as M0}from"@rango-dev/wallets-core/legacy";function eC(t,e){let[o,n,r,a,s]=e;n!==M0.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i(eC,"propagateEvents");var Ja=_0({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function $0(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=k(),a=k().blockchains(),s=k().config,c={walletConnectProjectId:s?.walletConnectProjectId,trezorManifest:s?.trezorManifest,tonConnect:s.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:l}=Bp(s.wallets,c),p=oC(),u=oC(),{handler:d}=RS({onConnectWalletHandler:p,onDisconnectWalletHandler:u});tC(()=>{n().catch(console.log)},[]),tC(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let f=ne.use.isActiveTab(),h=D0(()=>({onConnectWallet:g=>{p.current=g},onDisconnectWallet:g=>{u.current=g}}),[]);return Za.createElement(Ja.Provider,{value:h},Za.createElement(P0,{allBlockChains:a,providers:l,onUpdateState:(g,m,C,y,S)=>{let T=[g,m,C,y,S];d(...T),t.onUpdateState&&eC(t.onUpdateState,T)},autoConnect:!!f,configs:{wallets:s.wallets}},t.children))}i($0,"Main");function Ra(t){let{config:e,...o}=t;return Za.createElement(Ju,{config:e},Za.createElement($0,{...o,config:e}))}i(Ra,"WidgetWallets");import{globalCss as F0}from"@rango-dev/ui";var nC=i(()=>F0({"@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 O0}from"@rango-dev/wallets-react";import{useEffect as U0,useRef as z0}from"react";function rC(){let{connect:t,state:e}=O0(),o=z0({}),{fetchStatus:n}=k(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);U0(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(rC,"useForceAutoConnect");import{isApprovalTX as H0,RouteEventType as iC,StepEventType as aC,StepExecutionEventStatus as Q0,WidgetEvents as es}from"@rango-dev/queue-manager-rango-preset";import{useEffect as sC}from"react";function Lp(){let t=We.use.setNotification(),{connectedWallets:e,fetchBalances:o,customTokens:n}=k();sC(()=>{let r=i(a=>{let{event:s,step:c,route:l}=a;if(s.type===aC.TX_EXECUTION&&s.status===Q0.TX_SENT&&!H0(c)||s.type===aC.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(C=>C.blockchain===m.blockchain&&C.address?.toLocaleLowerCase()===m.address?.toLocaleLowerCase()&&C.symbol?.toLocaleLowerCase()===m.symbol?.toLocaleLowerCase()));o(u,{selectedCustomTokens:g,shouldFetchCustomTokens:g.length>0})}}t(s,l)},"handleStepEvent");return we.on(es.StepEvent,r),()=>we.off(es.StepEvent,r)},[we,e]),sC(()=>{let r=i(a=>{let{event:s,route:c}=a;(s.type===iC.FAILED||s.type===iC.SUCCEEDED)&&t(s,c)},"handleRouteEvent");return we.on(es.RouteEvent,r),()=>we.off(es.RouteEvent,r)},[we])}i(Lp,"useSubscribeToWidgetEvents");import{useManager as q0}from"@rango-dev/queue-manager-react";import{useEffect as G0}from"react";function Mp(){let{isSynced:t,syncNotifications:e}=We(),{manager:o,state:n}=q0();G0(()=>{We.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(Tt(o))},[We.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Mp,"useSyncNotifications");function _p(){rC(),nC(),Lp(),Mp();let t=k().blockchains(),{canSwitchNetworkTo:e}=Ri(),[o,n]=lC(null),[r,a]=lC(),s=j0(Ja),c=t.filter(K0);Pp(()=>()=>cm(),[]),Pp(()=>()=>pm(),[]),V0({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:c,canSwitchNetworkTo:e}),Pp(()=>(Po.init(),We.persist.hasHydrated()||We.persist.rehydrate(),s.onConnectWallet(l=>{n(p=>{if(!p||p.walletType!==l.walletType)return l;let u={...p};return l.network&&(u.network=l.network),l.accounts&&(u.accounts=l.accounts),u})}),s.onDisconnectWallet(l=>{a(l),n(p=>l===p?.walletType?null:p)}),Po.destroy),[])}i(_p,"useBootstrap");import{styled as X0}from"@rango-dev/ui";var cC=X0("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Jo(){_p();let{config:t}=k(),{activeTheme:e}=mo(t?.theme||{}),{activeLanguage:o}=wo();return Dp.createElement(Y0,{language:o},Dp.createElement(cC,{id:"swap-container",className:e()},Dp.createElement(YS,null)))}i(Jo,"Main");import{setSolanaSignerConfig as hW}from"@rango-dev/signer-solana";import Fp,{useEffect as Op,useMemo as yW}from"react";function pC(){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(pC,"useFetchApiConfig");import{useState as Z0}from"react";var J0=i(()=>{let[t,e]=Z0(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=du(a);if(s){let c=o(s);e(c)}},"handleLoadCustomFont")}},"useFontLoader"),uC=J0;import{checkWaitingForNetworkChange as R0,makeQueueDefinition as eW}from"@rango-dev/queue-manager-rango-preset";import{Provider as tW}from"@rango-dev/queue-manager-react";import{useWallets as oW}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as nW}from"@rango-dev/wallets-shared";import{isEvmBlockchain as rW}from"rango-types";import iW,{useMemo as aW}from"react";function sW(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=oW(),c=aW(()=>eW({API_KEY:t.apiKey||Gt("API_KEY"),BASE_URL:Gt("BASE_URL"),emitter:{emit:we.emit}}),[t.apiKey]),{blockchains:l,connectedWallets:p}=k(),u=l(),d={blockchains:p.map(v=>({accounts:[v],name:v.chain}))},f=i(async(v,w)=>a(v,w.network,w)?await r(v,[w]):void 0,"switchNetwork"),h=i(v=>!!s(v).mobileWallet,"isMobileWallet"),g=u.filter(v=>v.enabled).reduce((v,w)=>(v[w.name]=w,v),{}),m=u.filter(rW),C=i(v=>{let{supportedChains:w}=s(v);return jn(w)},"getSupportedChainNames"),y=e(),S={meta:{blockchains:g,evmBasedChains:m,evmNetworkChainInfo:nW(m),getSupportedChainNames:C},getSigners:o,wallets:d,providers:y,switchNetwork:f,canSwitchNetworkTo:a,state:n,isMobileWallet:h},T=ne.use.isActiveTab();return iW.createElement(tW,{queuesDefs:[c],context:S,onPersistedDataLoaded:v=>{R0(v)},isPaused:!T},t.children)}i(sW,"QueueManager");var dC=sW;import{useManager as dW}from"@rango-dev/queue-manager-react";import mW,{createContext as fW,useContext as gW}from"react";function mC(){let{findToken:t}=k(),e=k().blockchains(),o=k().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 C=e.find(y=>y.name===u)??null;n(C)}if(d!==void 0){let C=d?t(d)??null:null;r({meta:m,token:C})}if(f!==void 0){let C=e.find(y=>y.name===f)??null;a(C)}if(h!==void 0){let C=h?t(h)??null:null;s({meta:m,token:C})}g!==void 0&&c(g)},"updateQuoteInputs")}i(mC,"useUpdateQuoteInputs");import{cancelSwap as lW,getCurrentNamespaceOfOrNull as cW,getCurrentStep as pW,getRelatedWalletOrNull as uW}from"@rango-dev/queue-manager-rango-preset";var ts=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return Tt(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=Bi(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&lW(o)}getCurrentStepInfo(e){let o=pW(e);return{step:o,wallet:o?uW(e,o):null,network:o?cW(e,o)?.network:null}}};var fC=fW(void 0);function $p(t){let{manager:e}=dW(),o=ne.use.isActiveTab(),n=H().use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:c}=k(),l=new ts(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=k(),u=Eu(a()),d=k().blockchains(),f=k().tokens(),h=k().swappers(),g=k().fetchStatus,m=wo().resetLanguage,C=We().getNotifications(),y=We().clearNotifications,S=mC(),{fromBlockchain:T,toBlockchain:v,fromToken:w,toToken:A,inputAmount:N}=H()(),b={isActiveTab:o,setCurrentTabAsActive:Po.forceClaim,history:l,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async x=>c(x)},meta:{blockchains:d,tokens:f,swappers:h,loadingStatus:g,findToken:r},resetLanguage:m,notifications:{list:C,clearAll:y},quote:{quoteInputs:{fromBlockchain:T?.name??null,fromToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,toBlockchain:v?.name??null,toToken:A?{symbol:A.symbol,blockchain:A.blockchain,address:A.address}:null,requestAmount:N},updateQuoteInputs:S}};return mW.createElement(fC.Provider,{value:b},t.children)}i($p,"WidgetInfo");function gC(){let t=gW(fC);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(gC,"useWidget");function Un(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{fetchApiConfig:r}=pC(),{handleLoadCustomFont:a}=uC();return Op(()=>{r().catch(console.log)},[]),Op(()=>{n&&a(n)},[n]),yW(()=>{Pu({API_KEY:o?.apiKey||ri,BASE_URL:o?.apiUrl||ou})},[o.apiKey,o.apiUrl]),Op(()=>{t.config?.signers?.customSolanaRPC&&hW("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),Fp.createElement(Ra,{config:o,onUpdateState:e},Fp.createElement(dC,{apiKey:o.apiKey},Fp.createElement($p,null,t.children)))}i(Un,"WidgetProvider");function hC(t){let e=t.config?.externalWallets;return os.createElement(Ni,null,e?os.createElement(Jo,null):os.createElement(Un,{config:t.config??on},os.createElement(Jo,null)))}i(hC,"Refuel");import ns from"react";function yC(t){let e=t.config?.externalWallets;return ns.createElement(Ni,null,e?ns.createElement(Jo,null):ns.createElement(Un,{config:t.config??on},ns.createElement(Jo,null)))}i(yC,"Widget");function SC(){let{on:t,off:e}=we;return{on:t,off:e}}i(SC,"useWidgetEvents");var ste={DerivationPath:rr,Namespaces:tr,Detached:nr,isOnDerivationPath:ar,isOnNamespace:ir,isOnDetached:Ao};export{Bee as EventSeverity,sn as MainEvents,zee as Networks,qee as PendingSwapNetworkStatus,ks as QuoteEventTypes,hC as Refuel,Lee as RouteEventType,cs as SUPPORTED_FONTS,ste as StatefulConnect,Mee as StepEventType,Pee as StepExecutionBlockedEventStatus,_ee as StepExecutionEventStatus,xd as SwapModeContext,ot as UI_ID,ws as UiEventTypes,Ts as WalletEventTypes,Oee as WalletEvents,Hee as WalletTypes,yC as Widget,sn as WidgetEvents,Un as WidgetProvider,Ra as WidgetWallets,fl as customizedThemeTokens,$ee as readAccountAddress,Ro as useStatefulConnect,vt as useWalletList,Ri as useWallets,gC as useWidget,SC as useWidgetEvents,vk as widgetEventEmitter};
|
|
1
|
+
var kC=Object.defineProperty;var i=(t,e)=>kC(t,"name",{value:e,configurable:!0});import{EventSeverity as Mee,RouteEventType as Pee,StepEventType as _ee,StepExecutionBlockedEventStatus as Dee,StepExecutionEventStatus as $ee}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Oee}from"@rango-dev/wallets-core/legacy";import{useWallets as Ji,Events as zee}from"@rango-dev/wallets-react";import{Networks as Qee,WalletTypes as qee}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as Vee}from"rango-types";import{Divider as HT}from"@rango-dev/ui";import po,{useEffect as QT,useRef as qT,useState as vd}from"react";import{WalletState as TC}from"@rango-dev/ui";import{useWallets as wC}from"@rango-dev/wallets-react";import{useReducer as vC}from"react";function zp(t){return!!t.derivationPath}i(zp,"isStateOnDerivationPathStep");function Hp(t){return!!t.namespace}i(Hp,"isStateOnNamespace");var ei={status:"init",namespace:null,derivationPath:null,selectedNamespaces:null};function Qp(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 ei;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:ei;default:throw new Error("Action hasn't been defined.")}}i(Qp,"reducer");function Ro(){let{state:t,disconnect:e,connect:o}=wC(),[n,r]=vC(Qp,ei),a=i(async(d,f,h)=>{r({type:"reset"});try{let g=f?.map(m=>({...m,network:void 0}));return await o(d,g),{status:"connected"}}catch(g){let m=g?.message?`Error: ${g.message}`:"An unknown error happened during connecting wallet.";throw new Error(m,{cause:g})}},"runConnect"),s=i(async(d,f)=>{if(d.state===TC.DISCONNECTED){let g=!!d.isHub,m=g?d.properties?.find(y=>y.name==="namespaces")?.value:d.needsNamespace,C=g?d.properties?.find(y=>y.name==="derivationPath")?.value:d.needsDerivationPath;if(!m?.data?.length)return await a(d.type,void 0,f);if(m?.data.length&&m.data.length>1)return r({type:"needsNamespace",payload:{targetWallet:d,defaultSelectedChains:f?.defaultSelectedChains}}),{status:"namespace"};if(m?.data.length===1&&m.data[0]){if(C){let y=m.data[0];return r({type:"needsDerivationPath",payload:{providerType:d.type,providerImage:d.image,namespace:y.value}}),{status:"derivation-path"}}return await a(d.type,m?.data?.map(y=>({namespace:y.value})),f)}}if(d.isHub){let g=d.properties?.find(m=>m.name==="namespaces")?.value;if(g?.data.length&&g.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(T=>T.name==="namespaces")?.value:d.needsNamespace,m=h?d.properties?.find(T=>T.name==="derivationPath")?.value:d.needsDerivationPath,C=g?.selection==="single",y=f[0];if(!y)throw new Error("To confirm a namespace, you should select at least one namespace.");if(C&&m)return r({type:"needsDerivationPath",payload:{providerType:d.type,providerImage:d.image,namespace:y}}),{status:"derivation-path"};if(!Hp(n))throw new Error("Something went wrong on handling namespace. Please retry.");let S=f.map(T=>({namespace:T}));return r({type:"detached",payload:{targetWallet:d,selectedNamespaces:S??null}}),{status:"Detached"}},"handleNamespace"),l=i(async(d,f)=>{if(!f)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!zp(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let h=n.derivationPath.providerType,m=[{namespace:n.derivationPath.namespace,derivationPath:f}],y=!!d.isHub?d.properties?.find(S=>S.name==="namespaces")?.value:d.needsNamespace;return y?.data&&y.data.length>1?(r({type:"detached",payload:{targetWallet:d,selectedNamespaces:m??null,derivationPath:f}}),{status:"Detached"}):await a(h,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(Ro,"useStatefulConnect");import{WalletState as As}from"@rango-dev/ui";import{useWallets as _k}from"@rango-dev/wallets-react";import{detectMobileScreens as Dk,KEPLR_COMPATIBLE_WALLETS as $k,WalletTypes as Jn}from"@rango-dev/wallets-shared";import{useCallback as Fk,useEffect as Ok}from"react";import Ak,{createContext as Nk,useContext as Wk,useEffect as Bk,useRef as Lk}from"react";import{create as Ek}from"zustand";import{persist as Ik}from"zustand/middleware";import{allProviders as bC}from"@rango-dev/provider-all";var is=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()}},en=new is;import{defineVersions as Gp,pickVersion as Vp,Provider as as}from"@rango-dev/wallets-core";function Kp({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=jp(a);return s instanceof as?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 as?o.push(Gp().version("1.0.0",n).build()):o.push(Gp().version("0.0.0",n).build())}),o}return t}i(Kp,"matchAndGenerateProviders");function jp(t){try{return Vp(t,"1.0.0")[1]}catch{return Vp(t,"0.0.0")[1]}}i(jp,"pickProviderVersionWithFallbackToLegacy");function Xp(t){return t.map(o=>jp(o)).map(o=>o instanceof as?o.id:o.config.type)}i(Xp,"configWalletsToWalletName");function ti(t,e){return e.find(o=>o.name===t)?.displayName}i(ti,"getBlockchainDisplayNameFor");function yt(t,e){return e.find(o=>o.name===t)?.shortName}i(yt,"getBlockchainShortNameFor");function Yp(t,e){return e.find(o=>o.name===t)?.logo}i(Yp,"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 ss(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(ss,"isTokenNative");function St(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(St,"createTokenHash");function tn(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(tn,"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 oi(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(oi,"getSupportedBlockchainsFromConfig");function Jp(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(Jp,"makeProvidersOptionsFromConfig");var on={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"}},xC={clientUrl:void 0},EC={liquiditySources:void 0};function Zp(t){let e=Jp(t),o={walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t.wallets,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0,tonConnect:e?.tonConnect?.manifestUrl?{manifestUrl:e?.tonConnect.manifestUrl}:void 0};return bC(o).map(a=>a())}i(Zp,"generateProviders");var Rp=i((t,e,o)=>{let n=Zp({...on,...t});return{config:{...on,...t},iframe:xC,campaignMode:EC,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}});en.set("supportedSourceTokens",l),en.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=Zp(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=Jp(a);return Kp({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as eu}from"rango-types";var tu=[eu.EVM,eu.SOLANA],ni="https://raw.githubusercontent.com/rango-exchange/assets/refs/heads/main/common/unknown-image.png";import{RangoClient as zC}from"rango-sdk";import{UI_ID as IC}from"@rango-dev/ui";var ri="c6381a79-2817-4602-83bf-6a641a409e32",ou="https://api.rango.exchange",nu="https://explorer.rango.exchange",ot={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...IC};import{BlockchainCategories as PC,WalletState as pt}from"@rango-dev/ui";import{legacyReadAccountAddress as _C}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as DC,getCosmosExperimentalChainInfo as $C,isEvmAddress as FC,KEPLR_COMPATIBLE_WALLETS as LB,Networks as bu}from"@rango-dev/wallets-shared";import rn from"bignumber.js";import{isCosmosBlockchain as OC}from"rango-types";import AC from"bignumber.js";var de=new AC(0);import{WalletTypes as NC}from"@rango-dev/wallets-shared";var Wo="~",ru=[NC.LEAP];import{BlockchainCategories as cs,WalletState as MC}from"@rango-dev/ui";import{TransactionType as ii}from"rango-sdk";var iu="Roboto",ls=[{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 nn(t){return Array.from(new Set(t))}i(nn,"removeDuplicateFrom");function ai(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(ai,"debounce");function ct(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(ct,"containsText");function lu(t,e){return t.toLowerCase()===e.toLowerCase()}i(lu,"exactText");function cu(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(cu,"startWithText");var W=i(()=>document.getElementById(ot.SWAP_BOX_ID),"getContainer"),Bo=i(()=>document.getElementById(ot.EXPANDED_BOX_ID),"getExpanded");function pu(t,e,o){let n=!!e&&lu(e,t),r=!!o&&lu(o,t);return n!==r?n?-1:1:0}i(pu,"compareExactMatchText");function ps(t,e,o){let n=!!e&&ct(e,t),r=!!o&&ct(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ps,"compareContainsText");function us(t,e,o){let n=!!e&&cu(e,t),r=!!o&&cu(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(us,"compareStartWithText");function uu(t,e,o){if(!o)return 0;let n=pu(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=pu(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=us(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ps(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=us(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=ps(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=us(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=ps(o,t.address,e.address);if(r!==0)return r}return 0}i(uu,"compareWithSearchFor");var si=i((t,e)=>{switch(e){case cs.ALL:return!0;case cs.UTXO:return t===ii.TRANSFER;case cs.OTHER:return t!==ii.TRANSFER&&t!==ii.COSMOS&&t!==ii.EVM;default:return t===e}},"isBlockchainTypeInCategory"),du=i(t=>ls.find(o=>o.value===t)?.url,"getFontUrlByName");function mu(t,e){let o=!!t.find(n=>n.state===MC.CONNECTED);return e===!1&&o}i(mu,"isSingleWalletActive");function fu(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(fu,"memoizedResult");import{BigNumber as wu}from"bignumber.js";function gu(t){return t.replace(/^0+(?=\d)/g,"")}i(gu,"removeLeadingZeros");function hu(t){return t.replace(/^\.(\d+)/,"0.$1")}i(hu,"ensureLeadingZeroForDecimal");function yu(t){return t.replace(/\B(?=(\d{3})+(?!\d))/g,",")}i(yu,"formatThousandsWithCommas");function Su(t){return t.replace(/\s+/g,"-")}i(Su,"replaceSpacesWithDash");function Cu(t){return t.replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"")}i(Cu,"stripTrailingZeros");function li(t){return/^0+(?:\.0+)?$/.test(t)}i(li,"isZeroValue");function ku(t,e=2){let o=`^(?:0|[1-9]\\d*)(?:\\.\\d{1,${e}})?$`;return new RegExp(o).test(t)}i(ku,"isValidCurrencyFormat");function 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"),P=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new wu(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new wu(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 ci=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 vu(t){return li(t)?"0":Cu(t)}i(vu,"sanitizeInputAmount");function Kn(t){return t.connected?pt.CONNECTED:t.connecting?pt.CONNECTING:t.installed?pt.DISCONNECTED:pt.NOT_INSTALLED}i(Kn,"mapStatusToWalletState");function xu(t,e,o,n){return o.filter(r=>!ru.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=nn(u.map(C=>C.type)),m=Kn(t(r));return{title:a,image:s,link:DC(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 ms(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}=_C(l),d=c.length>0,f=c.includes(u),h=u===bu.Unknown;if(d&&!f&&!h)return;let m=u===bu.Unknown&&FC(p);if(h&&!m)return;o.includes(u)||m?r?s(u,p.toLowerCase(),r):c.filter(S=>o.includes(S)).forEach(S=>{s(S,p.toLowerCase())}):s(u,p)}),a}i(ms,"prepareAccountsForWalletStore");function Lo(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(Lo,"getQuoteChains");function Xn(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(Xn,"isAccountAndWalletMatched");var Eu=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?ds(n.usdValue,n.decimals):de.toFixed();return o.plus(r)},new rn(de));return UC(e.toString())},"calculateWalletUsdValue");function UC(t){let e=t.toString().split(".");return e[0]&&(e[0]=yu(e[0])),e.join(".")}i(UC,"numberWithThousandSeparator");var di=i((t,e)=>{let o=$C(Object.entries(t).map(([,n])=>n).filter(OC));return o&&!!o[e]?.experimental},"isExperimentalChain");function ds(t,e){return new rn(t).shiftedBy(-e).toFixed()}i(ds,"representAmountInNumber");function mi(t){if(!t)return null;let e=ds(t.amount,t.decimals),o=t.usdValue?ds(t.usdValue,t.decimals):null,n=P(e,8,8),r=o?P(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(mi,"formatBalance");function Iu(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new rn(t.usdValue).shiftedBy(-t.decimals):de,n=e&&e.usdValue?new rn(e.usdValue).shiftedBy(-e.decimals):de;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new rn(t.amount).shiftedBy(-t.decimals):de,n=e&&e.amount?new rn(e.amount).shiftedBy(-e.decimals):de;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Iu,"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 Au(t,e){return t.map(o=>({isPartiallyConnected:fs(o,e(o.type).namespaces),...o})).sort((o,n)=>+(n.state===pt.CONNECTED&&!n.isPartiallyConnected)-+(o.state===pt.CONNECTED&&!o.isPartiallyConnected)||+(n.state===pt.CONNECTED)-+(o.state===pt.CONNECTED)||+(n.state===pt.DISCONNECTED||n.state===pt.CONNECTING)-+(o.state===pt.DISCONNECTED||o.state===pt.CONNECTING)).map(({isPartiallyConnected:o,...n})=>n)}i(Au,"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 Nu({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Nu,"getAddress");var Wu=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 Lu(t,e){let o=new Set;return t.forEach(r=>{r.blockchainTypes.forEach(a=>{o.add(a)})}),e.filter(r=>o.has(r.type))}i(Lu,"filterBlockchainsByWalletTypes");function Mu(t,e){return e===PC.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(si(n,e))return!0;return!1})}i(Mu,"filterWalletsByCategory");function fs(t,e){if(!t.isHub||!t.needsNamespace||t.state!==pt.CONNECTED)return!1;let n=t.needsNamespace.data.filter(r=>!r.unsupported);return t.needsNamespace.selection==="multiple"&&n.some(r=>!e?.get(r.value)?.connected)}i(fs,"checkIsWalletPartiallyConnected");var gs={API_KEY:ri};function Gt(t){return gs[t]||""}i(Gt,"getConfig");function Pu(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),gs=e,gs}i(Pu,"initConfig");var _u=20,Du=25,hs="theme-widget",ys=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"),Ss=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 fi,ut=i(()=>fi||(fi=new zC(Gt("API_KEY"),Gt("BASE_URL")),fi),"httpService");import{i18n as Ou}from"@lingui/core";var gi=[.5,1,3],hi=1,an=5,Yn=30,yi=0;var Re=(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))(Re||{});import{WidgetEvents as Fu}from"@rango-dev/queue-manager-rango-preset";var Cs=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(Cs||{}),ks=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(ks||{}),Ts=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(Ts||{}),sn=(a=>(a[a.RouteEvent=Fu.RouteEvent]="RouteEvent",a[a.StepEvent=Fu.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(sn||{});function Si(t,e){let o=t.map(a=>a.swapperGroup),n=[];return nn(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(Si,"getUniqueSwappersGroups");function Uu(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Uu,"sortLiquiditySourcesByGroupTitle");function nt(t,e){return e?.[t]==="hidden"}i(nt,"isFeatureHidden");function ln(t,e){return e?.[t]==="enabled"}i(ln,"isRoutingEnabled");var zu=i((t,e,o)=>nt("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");function cn(t){return t==yi?{type:"error",message:Ou.t("Slippage must be greater than or equal to 0.01")}:t>an&&t<=Yn?{type:"warning",message:Ou.t("Your transaction is at risk of being frontrun due to high slippage tolerance."),quoteValidation:{type:3,slippage:t.toString()}}:null}i(cn,"getSlippageValidation");var Hu=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=oi({config:a}),p=r;return l.length>0&&(p=p.filter(u=>l.includes(u.name))),p.filter(u=>tu.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=en.get(u);d?.length||(d=qn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),en.set(u,d)),d=zu(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?!!(ct(g.symbol,o.searchFor)||ct(g.address||"",o.searchFor)||ct(g.name||"",o.searchFor)):!0).sort((g,m)=>{let C=e().isTokenPinned(g,o.type),y=e().isTokenPinned(m,o.type);if(C!==y)return C?-1:1;if(o.getBalanceFor){let A=o.getBalanceFor(g),N=o.getBalanceFor(m),b=Iu(A,N);if(b!==0)return b}let S=l.get(g.blockchain),T=l.get(m.blockchain),v=ss(g,S),w=ss(m,T);if(v!==w)return v?-1:1;if(g.isPopular!==m.isPopular)return g.isPopular?-1:1;if(o.searchFor){let A=uu(g,m,o.searchFor);if(A)return A}return g.isSecondaryCoin!==m.isSecondaryCoin?g.isSecondaryCoin?1:-1:S&&T?S.sort-T.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(Uu)},fetch:async()=>{try{let{routing:o}=e().config,n=ln("enableCentralizedSwappers",o),r=await ut().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,c={},l=[],p=r.popularTokens,u=r.swappers.filter(h=>h.enabled),d=new Set;r.tokens.forEach(h=>{d.add(h.blockchain),l.push(h)}),r.blockchains.sort((h,g)=>h.sort-g.sort).forEach(h=>{h.enabled&&d.has(h.name)&&a.set(h.name,h)}),l.forEach(h=>{let g=St(h);c[h.blockchain]||(c[h.blockchain]=[]),s.set(g,h),c[h.blockchain]?.push(g)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:c,_popularTokens:p,_swappers:u})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as HC,Catalonia as QC,Chinese as Qu,Denmark as qC,English as GC,Finland as VC,French as KC,German as jC,Greece as XC,Hungary as YC,India as ZC,Indonesian as JC,Italian as RC,Japanese as ek,Korea as tk,Lithuania as ok,Malay as nk,Netherlands as rk,Pakistan as ik,Philippines as ak,Poland as sk,Portuguese as lk,Russian as ck,SaudiArabia as pk,Serbia as uk,Slovakia as dk,SouthAfrica as mk,Spanish as fk,Swahili as gk,Swedish as hk,Thai as yk,Turkish as Sk,Ukrainian as Ck,Vietnamese as kk}from"@rango-dev/ui";var qu=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:mk},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:pk},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:HC},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:QC},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Qu},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Qu},{title:"Danish",label:"Dansk",local:"da",SVGFlag:qC},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:rk},{title:"English",label:"English",local:"en",SVGFlag:GC},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:ak},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:VC},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:KC},{title:"German",label:"Deutsch",local:"de",SVGFlag:jC},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:XC},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:ZC},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:YC},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:JC},{title:"Italian",label:"Italiana",local:"it",SVGFlag:RC},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:ek},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:tk},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:ok},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:nk},{title:"Polish",label:"Polski",local:"pl",SVGFlag:sk},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:lk},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:ck},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:uk},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:dk},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:fk},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:gk},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:hk},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:yk},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:Sk},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:Ck},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:ik},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:kk}],pn="en";var Gu=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:hi,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=nn(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=nt("theme",n),s=nt("language",n),c=nt("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||pn},...c&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||pn}})},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=oi({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import Is from"bignumber.js";import Tk from"mitt";var we=Tk(),wk={on:we.on,off:we.off};var Vu=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 Ku from"bignumber.js";function Vt(t){return`${t.blockchain}${Wo}${t.address}${Wo}${t.symbol}`}i(Vt,"createAssetKey");function ju(t,e){return`${Vt(e)}${Wo}${t}`}i(ju,"createBalanceKey");function Zn(t){let[e,o,n]=t.split(Wo);return!e||!o||!n?null:{address:o==="null"?null:o,blockchain:e,symbol:n}}i(Zn,"extractAssetFromBalanceKey");function vs(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 Ku(r??de).multipliedBy(o[s].amount).toString():""})})}),o}i(vs,"computeNextBalancesWithNewPrices");function bs(t,e){let o={};return t.balances?.forEach(n=>{let r=ju(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,c=n.price??e().findToken(n.asset)?.usdPrice,l=c?new Ku(c??de).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:l};o[r]=p}),o}i(bs,"createBalanceStateForNewAccount");function xs(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(xs,"updateAggregatedBalanceStateForNewAccount");function vk(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(vk,"removeBalanceFromAggregatedBalance");function Es(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=>ju(d.address,{address:p.address,blockchain:d.chain,symbol:p.symbol})===l)?a=vk(a,l):s[l]&&(r[l]=s[l])}),{_balances:r,_aggregatedBalances:a}}i(Es,"computeNextStateAfterWalletBalanceRemoval");function bk(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(bk,"matchWalletDetailsWithConnectedWallet");var xk=fu(),Xu=Vu((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:bk(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 ut().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};vs(m,g,d);let C=bs(g,e);f=xs(f,C),d={...d,...C}}),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&&(we.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}=Es(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(we.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 ut().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};vs(f,d,l);let{_balances:h,_aggregatedBalances:g}=Es(f,r,{chains:[d.blockChain]});if(p=g,l=h,!e().connectedWallets.find(C=>C.walletType===r&&C.address===d.address&&C.chain===d.blockChain))return;let m=bs(d,e);p=xs(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 Is(u.amount),f=new Is(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(Wo);return l&&p===o&&(s[c]=l),s},{})},getConnectedWalletsDetails:()=>xk(()=>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 Is(l.amount).shiftedBy(-l.decimals):de;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 Yu(t){return Ek()(Ik((...e)=>({...Xu(...e),...Hu(...e),...Gu(...e),...Rp(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(Yu,"createAppStore");var Zu=Nk(null);function k(){let t=Wk(Zu);if(Bk(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(k,"useAppStore");function Ju(t){let e=Lk();return e.current||(e.current=Yu(t.config)),Ak.createElement(Zu.Provider,{value:e.current},t.children)}i(Ju,"AppStoreProvider");import{useWallets as Mk}from"@rango-dev/wallets-react";import{detectMobileScreens as Pk}from"@rango-dev/wallets-shared";function un(){let{getWalletInfo:t}=Mk(),{config:e}=k(),o=Pk();function n(s){let c=t(s),l=e.deepLinking?.appHost,p=e.deepLinking?.targetUrl;if(!(!l||!p))return c.generateDeepLink?.({appHost:l,targetUrl:p})}i(n,"getWalletDeepLink");function r(s){let c=n(s);return c&&o?c:t(s).installLink}i(r,"getWalletLink");function a(s){return!!n(s)&&o}return i(a,"checkHasDeepLink"),{getWalletDeepLink:n,getWalletLink:r,checkHasDeepLink:a}}i(un,"useDeepLink");function vt(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=k(),{state:r,getWalletInfo:a}=_k(),s=k().blockchains(),{handleDisconnect:c}=Ro(),{checkHasDeepLink:l}=un(),p=Xp(n()),u=xu(r,a,p,e);u=Dk()?u.filter(C=>C.showOnMobile!==!1&&(r(C.type).installed||l(C.type))):u;let d=Au(u,r),f=i(C=>!o.find(y=>y.walletType===C&&y.chain===e),"isExperimentalChainNotAdded"),h=Fk(()=>{let C=u?.filter(y=>y.state===As.CONNECTING)||[];for(let y of C)c(y)},[Bu(u)]);Ok(()=>()=>{h()},[]);let g=i(C=>{let y=C.find(T=>T.type===Jn.DEFAULT);return!y||y.state===As.NOT_INSTALLED?!1:C.filter(T=>T.state!=As.NOT_INSTALLED&&![Jn.DEFAULT,Jn.WALLET_CONNECT_2,Jn.LEDGER].includes(T.type)&&a(T.type).supportedChains.filter(v=>v.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),m=i((C,y,S)=>di(S,y)&&f(C)&&!$k.includes(C)||C==Jn.DEFAULT&&!g(u),"shouldExcludeWallet");return{list:d.filter(C=>!m(C.type,e??"",s)),terminateConnectingWallets:h}}i(vt,"useWalletList");import{Modal as Qk}from"@rango-dev/ui";import qk from"react";import{create as Hk}from"zustand";var Ru="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(Ru),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 zk=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=zk;var ne=co(Hk()((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 R(t){let{watermark:e}=ne();return qk.createElement(Qk,{hasWatermark:e==="FULL",...t},t.children)}i(R,"WatermarkedModal");import{i18n as fn}from"@lingui/core";import{Alert as rT,Button as iT,Divider as gn,Image as aT,MessageBox as sT,RadioRoot as lT,WalletImageContainer as cT}from"@rango-dev/ui";import ce,{useEffect as pT,useMemo as uT,useState as dT}from"react";import{i18n as jk}from"@lingui/core";import{Typography as sd}from"@rango-dev/ui";import dn from"react";function Ci(t,e){return t.find(o=>o.name===e)?.logo}i(Ci,"getBlockchainLogo");import{darkTheme as Gk,Image as Vk,styled as Kt,Typography as Kk}from"@rango-dev/ui";var ki=Kt("li",{backgroundColor:"$neutral200",padding:"$16",borderRadius:"$sm",variants:{clickable:{true:{cursor:"pointer"}},hasError:{true:{background:"$error100",[`.${Gk} &`]:{backgroundColor:"$error700"}}},unsupported:{true:{cursor:"not-allowed",paddingTop:"$8",paddingBottom:"$8"}}}}),Ti=Kt("div",{display:"flex",gap:"$8",alignItems:"center"}),td=Kt("div",{flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between",height:"$40",variants:{showSupportedChains:{true:{justifyContent:"space-between"},false:{justifyContent:"center"}}}}),od=Kt("div",{flex:"1",display:"flex",alignItems:"center",gap:"$4",opacity:"0.5"}),nd=Kt("div",{display:"flex",gap:"$6",alignItems:"center"}),rd=Kt("div",{paddingLeft:"48px"}),id=Kt("div",{display:"flex",gap:"$2",cursor:"pointer",alignItems:"center",width:"fit-content"}),ad=Kt(Kk,{maxWidth:"100px"}),wi=Kt(Vk,{variants:{disabled:{true:{opacity:"0.5"}}}});function vi(t){let{namespace:e}=t,o=k().blockchains();return dn.createElement(ki,{unsupported:!0},dn.createElement(Ti,null,dn.createElement(wi,{src:Ci(o,e.id),size:40,disabled:!0}),dn.createElement(od,null,dn.createElement(sd,{variant:"label",size:"large"},e.label),dn.createElement(sd,{variant:"body",size:"xsmall"},jk.t("(Currently not supported)")))))}i(vi,"NamespaceUnsupportedItem");import{Checkbox as tT,Radio as oT}from"@rango-dev/ui";import Ls from"react";import{i18n as Bs}from"@lingui/core";import{ChevronDownIcon as Yk,ChevronUpIcon as Zk,Divider as Jk,Typography as er}from"@rango-dev/ui";import Ne,{useEffect as Rk,useState as eT}from"react";import{Image as cd,Tooltip as pd,Typography as Xk}from"@rango-dev/ui";import _t from"react";import{styled as ld}from"@rango-dev/ui";var Ns=ld("div",{display:"flex",alignItems:"center",padding:0,margin:0}),bi=ld("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 Ws=3;function ud(t){let{chains:e}=t;return _t.createElement(Ns,{id:"widget-supported-chains-container"},e.slice(0,Ws).map((o,n)=>_t.createElement(pd,{key:o.name,container:W(),side:"bottom",align:"start",content:o.name,sideOffset:4},_t.createElement(bi,{firstItem:n===0},_t.createElement(cd,{src:o.logo,size:15})))),e.length>Ws&&_t.createElement(pd,{container:W(),side:"bottom",align:"start",sideOffset:4,content:_t.createElement(Ns,null,e.map((o,n)=>_t.createElement(bi,{key:o.name,firstItem:n===0},_t.createElement(cd,{src:o.logo,size:15}))))},_t.createElement(bi,null,_t.createElement(Xk,{variant:"body",size:"xsmall"},"+",e.length-Ws))))}i(ud,"SupportedChainsList");function _o(t){let{namespace:e,error:o,suffix:n,connected:r,address:a,onClick:s}=t,[c,l]=eT(!1),p=k().blockchains();Rk(()=>l(!1),[o]);let u=e.getSupportedChains(p),d=!o&&!r&&u.length>1;return Ne.createElement(ki,{hasError:!!o,clickable:!!s,onClick:s},Ne.createElement(Ti,null,Ne.createElement(wi,{src:Ci(p,e.id),size:40}),Ne.createElement(td,{showSupportedChains:d||r||!!o},Ne.createElement(nd,null,Ne.createElement(er,{variant:"label",size:"large"},e.label),r&&Ne.createElement(er,{variant:"body",size:"small",color:"success500"},Bs.t("Connected")),!!o&&Ne.createElement(er,{variant:"body",size:"small",color:"error500"},Bs.t("Connection failed"))),d&&Ne.createElement(ud,{chains:u}),r&&Ne.createElement(ad,{variant:"body",size:"small",color:"neutral700"},a),o&&Ne.createElement(id,{onClick:()=>l(f=>!f)},Ne.createElement(er,{variant:"body",size:"small",color:"neutral700",style:{textDecoration:"underline",userSelect:"none",textDecorationSkipInk:"none"}},Bs.t("See why")),c?Ne.createElement(Zk,{size:12,color:"gray"}):Ne.createElement(Yk,{size:12,color:"gray"}))),n),!!o&&c&&Ne.createElement(Ne.Fragment,null,Ne.createElement(Jk,{size:4}),Ne.createElement(rd,null,Ne.createElement(er,{variant:"body",size:"small",color:"neutral700"},o))))}i(_o,"NamespaceItem");function dd(t){let{onClick:e,type:o,namespace:n}=t;return Ls.createElement(_o,{namespace:n,onClick:e,suffix:o==="radio"?Ls.createElement(oT,{value:n.value}):Ls.createElement(tT,{checked:t.value})})}i(dd,"NamespaceListItem");import{Button as nT,styled as md}from"@rango-dev/ui";var xi=md("ul",{padding:0,paddingBottom:"$20",margin:0}),mn=md(nT,{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=k().blockchains(),[l,p]=dT([]),u=uT(()=>a?.data.filter(m=>!m.unsupported),[e?.type]),d=i(m=>{p(r?[m]:C=>C.includes(m)?C.filter(y=>y!==m):C.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?ce.createElement(lT,{value:l?.[0]},m):ce.createElement(ce.Fragment,null,m),"wrapRadioRoot");return pT(()=>{if(!r&&u)if(t.value.defaultSelectedChains?.length){let m=u.filter(C=>C.getSupportedChains(c).some(y=>t.value.defaultSelectedChains?.includes(y.name)));p(m.map(C=>C.value))}else p(u.map(m=>m.value))},[]),ce.createElement(ce.Fragment,null,ce.createElement(sT,{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:ce.createElement(cT,null,ce.createElement(aT,{src:s,size:45}))}),r?ce.createElement(ce.Fragment,null,ce.createElement(gn,{size:20}),ce.createElement(rT,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:fn.t("This wallet can only connect to one chain at a time. ")}),ce.createElement(gn,{size:30})):ce.createElement(ce.Fragment,null,ce.createElement(gn,{size:30}),ce.createElement(iT,{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")),ce.createElement(gn,{size:10})),ce.createElement(xi,null,g(ce.createElement(ce.Fragment,null,a?.data.map((m,C,y)=>ce.createElement(ce.Fragment,{key:m.id},m.unsupported?ce.createElement(vi,{namespace:m}):ce.createElement(dd,{value:l.includes(m.value),namespace:m,type:r?"radio":"checkbox",onClick:()=>d(m.value)}),C!==y.length-1&&ce.createElement(gn,{size:10})))))),ce.createElement(gn,{size:20}),ce.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 CT,Button as kT,Divider as hn,Image as TT,MessageBox as wT,WalletImageContainer as vT}from"@rango-dev/ui";import{useWallets as bT}from"@rango-dev/wallets-react";import me from"react";import{styled as mT}from"@rango-dev/ui";var fd=mT("div",{display:"flex",justifyContent:"end"});import{i18n as Ms}from"@lingui/core";import{Button as fT,Spinner as gT}from"@rango-dev/ui";import Ps,{useLayoutEffect as hT,useRef as yT,useState as ST}from"react";function gd(t){let{namespace:e,initialConnect:o,disabled:n,state:r,handleConnect:a,handleDisconnect:s}=t,[c,l]=ST(null),p=yT(!1);hT(()=>{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?Ms.t("Disconnect"):c?Ms.t("Try again"):Ms.t("Connect"),"getButtonText");return Ps.createElement(_o,{namespace:e,connected:r.connected,error:c?.message,address:f(),suffix:r.connecting?Ps.createElement(gT,{color:"info"}):Ps.createElement(fT,{id:"widget-name-space-connect-btn",variant:"ghost",type:r.connected?"error":"primary",size:"xsmall",onClick:async()=>d(),disabled:n},h())})}i(gd,"NamespaceDetachedItem");function nr(t){let{value:e,selectedNamespaces:o,onConfirm:n,onDisconnectWallet:r,navigateToDerivationPath:a}=t,{targetWallet:s}=e,{connect:c,disconnect:l,state:p}=bT(),u=s.type,d=p(u),f=s.properties?.find(T=>T.name==="namespaces"),h=s.properties?.find(T=>T.name==="derivationPath"),g=f?.value.selection==="single",m=i(async(T,v)=>{g&&await l(u),h&&v?.shouldAskForDerivationPath?a(T):await c(u,[{namespace:T,network:"",derivationPath:v?.derivationPath??void 0}])},"handleConnectNamespace"),C=i(async T=>{await l(u,[T])},"handleDisconnectNamespace"),y=i(()=>g?me.createElement(me.Fragment,null,me.createElement(hn,{size:20}),me.createElement(CT,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:or.t("This wallet can only connect to one chain at a time.")}),me.createElement(hn,{size:30})):me.createElement(me.Fragment,null,me.createElement(hn,{size:30}),me.createElement(fd,null,me.createElement(kT,{id:"widget-detached-disconnect-wallet-btn",variant:"ghost",type:"error",size:"xsmall",disabled:d.connecting||!d.connected,onClick:r},or.t("Disconnect wallet"))),me.createElement(hn,{size:16})),"renderNamespaceListHeader"),S=i(T=>{if(T.unsupported)return me.createElement(vi,{namespace:T});let v=o?.find(N=>N.namespace===T.value),w=d.namespaces?.get(T.value);if(!w)throw new Error(`State for ${T.value} was not found!`);let A=g&&d.connecting;return me.createElement(gd,{namespace:T,initialConnect:!!v,disabled:A,state:w,handleConnect:async N=>m(T.value,{derivationPath:v?.derivationPath,shouldAskForDerivationPath:N?.shouldAskForDerivationPath}),handleDisconnect:async()=>C(T.value)})},"renderNamespaceItem");return me.createElement(me.Fragment,null,me.createElement(wT,{type:"info",title:or.t("Connect {wallet}",{wallet:s.type}),description:or.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect or disconnect."),icon:me.createElement(vT,null,me.createElement(TT,{src:s.image,size:45}))}),y(),me.createElement(xi,{id:"widget-detached-namespace-list"},s.needsNamespace?.data.map((T,v,w)=>me.createElement(me.Fragment,{key:T.id},S(T),v!==w.length-1&&me.createElement(hn,{size:10})))),me.createElement(hn,{size:20}),me.createElement(mn,{id:"widget-name-space-confirm-btn",type:"primary",onClick:n},or.t("Done")))}i(nr,"Detached");import{i18n as yn}from"@lingui/core";import{Divider as AT,Image as NT,MessageBox as WT,Select as BT,TextField as LT}from"@rango-dev/ui";import bt,{useEffect as MT,useState as yd}from"react";import{namespaces as xT}from"@rango-dev/wallets-shared";var Ei={id:"custom",label:"Custom",generateDerivationPath:t=>t};function _s(t){let e=t?xT[t]?.derivationPaths:null;return e?[...e,Ei]:[]}i(_s,"getDerivationPaths");import{Button as ET,styled as Ds,Typography as IT}from"@rango-dev/ui";var hd=Ds("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),$s=Ds(IT,{paddingLeft:"$10"}),Fs={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"},p_=Ds(ET,{minHeight:"$40"});var Sd="0";function rr(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=yd(null),[c,l]=yd(Sd),p=a===Ei.id,u=_s(o),d=i(({value:h})=>{let g=u?.find(m=>m.id===h);g&&(a===Ei.id&&Number.isNaN(Number(c))&&l(Sd),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 MT(()=>{s(_s(o)[0]?.id||null)},[o]),bt.createElement(bt.Fragment,null,bt.createElement(WT,{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:bt.createElement(NT,{src:n,size:45})}),bt.createElement(hd,{className:"_derivation_path_inputs_container"},bt.createElement($s,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},yn.t("Choose Derivation Path Template")),bt.createElement(BT,{id:"widget-derivation-path-template-select",value:a||"",options:u.map(h=>({value:h.id,label:h.label})),variant:"filled",handleItemClick:d,styles:{trigger:Fs}}),bt.createElement(AT,{size:20}),bt.createElement($s,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},p?yn.t("Enter Path"):yn.t("Enter Index")),bt.createElement(LT,{id:"widget-derivation-path-template-input",type:p?"text":"number",variant:"contained",value:c,onChange:h=>l(h.target.value),style:Fs})),bt.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 DT,MessageBox as Us,WalletImageContainer as $T,WalletState as FT}from"@rango-dev/ui";import{useWallets as OT}from"@rango-dev/wallets-react";import Do from"react";import{keyframes as PT,styled as Os}from"@rango-dev/ui";var T_=Os("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Cd=Os("div",{position:"relative"}),_T=PT({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),kd=Os("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${_T} 1s linear infinite`,top:0,bottom:0,right:0,left:0});function zs(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=OT();return Kn(a(n))===FT.CONNECTED?Do.createElement(Us,{type:"success",title:Sn.t("Wallet Connected"),description:Sn.t("Your wallet is connected, you can use it to swap.")}):o?Do.createElement(Us,{type:"error",title:Sn.t("Failed to Connect"),description:o||Sn.t("Your wallet is not connected. Please try again.")}):Do.createElement(Us,{type:"loading",title:Sn.t("Connecting to your wallet"),description:Sn.t("Click connect in your wallet popup."),icon:Do.createElement(Cd,null,Do.createElement($T,null,Do.createElement(DT,{src:r,size:45})),Do.createElement(kd,null))})}i(zs,"ConnectStatus");import{i18n as Hs}from"@lingui/core";import{Button as UT,Divider as Td,MessageBox as zT}from"@rango-dev/ui";import Ii from"react";function Qs(t){let{displayName:e,onConfirm:o,id:n}=t;return Ii.createElement(zT,{id:n,title:Hs.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:Hs.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},Ii.createElement(Td,{size:18}),Ii.createElement(Td,{size:32}),Ii.createElement(UT,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},Hs.t("Confirm")))}i(Qs,"ExperimentalChain");function wd(t,e){return t().status==="init"&&!!e}i(wd,"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 GT=3e3,VT=300;function sr(t){let e=qT(),[o,n]=vd(!1),[r,a]=vd(),s=i(w=>{a(w.message)},"catchErrorOnHandle"),{terminateConnectingWallets:c}=vt(),{handleConnect:l,handleDerivationPath:p,handleNamespace:u,getState:d,resetState:f,handleDisconnect:h}=Ro(),g=i(w=>{u(t.wallet,w).then(T).catch(s)},"handleConfirmNamespaces"),m=i(()=>{y()},"handleDetachedConfirm"),C=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(T).catch(s)},"handleDerivationPathConfirm"),y=i(()=>{n(!1)},"handleClosingModal"),S=i(()=>{a(void 0),f(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),T=i((w,A)=>{let N=w.status==="connected",b=["disconnected","disconnected-unhandled"].includes(w.status);N?(t.onConnect?.(),A||(e.current=setTimeout(y,GT))):b&&y()},"afterConnected"),v=i(w=>{t.wallet?.needsDerivationPath&&u(t.wallet,[w])},"handleNavigateToDerivationPath");return QT(()=>{if(t.wallet){S();let w=!1,A=!0;i(()=>{setTimeout(()=>{A=!1,w||n(!0)},VT)},"beforeConnecting")(),l(t.wallet,{disconnectIfConnected:!0,defaultSelectedChains:t.options?.defaultSelectedChains}).then(b=>{["namespace","Detached","derivation-path"].includes(b.status)||(w=!0),T(b,A)}).catch(s)}},[t.wallet]),po.createElement(R,{id:t.id,open:o,onClose:y,onExit:()=>{S(),c(),t.onClose&&t.onClose()},container:W()},wd(d,t.wallet)&&po.createElement(po.Fragment,null,po.createElement(zs,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),po.createElement(HT,{direction:"vertical",size:32})),ir(d)&&po.createElement(tr,{onConfirm:g,value:d().namespace}),ar(d)&&po.createElement(rr,{onConfirm:C,value:d().derivationPath}),Ao(d)&&po.createElement(nr,{onConfirm:m,onDisconnectWallet:()=>void h(d().namespace.targetWallet),value:d().namespace,selectedNamespaces:d().selectedNamespaces,navigateToDerivationPath:v}))}i(sr,"StatefulConnectModal");import ts from"react";import KT,{Fragment as jT}from"react";import{MemoryRouter as XT,useInRouterContext as YT}from"react-router";function Ai({children:t}){let o=YT()?jT:XT;return KT.createElement(o,null,t)}i(Ai,"AppRouter");import{I18nManager as J0}from"@rango-dev/ui";import Dp from"react";import ze from"react";import{useRoutes as B0}from"react-router-dom";var F={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 kn,useRef as _i}from"react";import it from"bignumber.js";import{create as om}from"zustand";import{subscribeWithSelector as nm}from"zustand/middleware";import{createContext as ZT,useContext as JT}from"react";var bd=ZT({swapMode:"swap",isMultiMode:!1});function rt(){let{swapMode:t,isMultiMode:e}=JT(bd);return{swapMode:t,isMultiMode:e}}i(rt,"useSwapMode");import{i18n as kt}from"@lingui/core";import{getRelatedWalletOrNull as tw,RouteEventType as FD}from"@rango-dev/queue-manager-rango-preset";import qe from"bignumber.js";import{PendingSwapNetworkStatus as cr}from"rango-types";import{i18n as Qe}from"@lingui/core";var re=i(()=>({genericServerError:Qe.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:Qe.t("Please reset your liquidity sources."),description:Qe.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:Qe.t("No Routes Found."),description:Qe.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:Qe.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:Qe.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:Qe.t("High Price Impact"),title:Qe.t("Price impact is too high!"),description:Qe.t("The price impact is significantly higher than the allowed amount."),confirmMessage:Qe.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:Qe.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:Qe.t("USD Price Unknown"),title:Qe.t("USD Price Unknown, Cannot calculate Price Impact."),description:Qe.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:Qe.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 Ni}from"@lingui/core";var $o=i(()=>({connectWallet:Ni.t("Connect Wallet"),swap:Ni.t("Swap"),swapAnyway:Ni.t("Swap anyway"),ethWarning:Ni.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function qs(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(qs,"getFeeLabel");var Gs=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Ed=100,Id=30,Ad=15,Nd=60;var Wd=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Bd=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as ew}from"@rango-dev/queue-manager-rango-preset";import bD 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 Wi(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=ew(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(Wi,"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&&Fd(a,p)){let d=Li(o?.swaps,n),f=Xt(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:d,warningLevel:f}}}if(e&&zd(e,o))return{type:4,usdValueChange:P(Ct(o)?.minus(Ct(e)??0).toString()??"0",null,2),percentageChange:P(jt(Ct(e)??"1",Ct(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let c=Mi(o.swaps),l=r>an;if(Ud(t.userSlippage.toString(),c)){if(l&&parseFloat(c??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:Od(o,r),minRequiredSlippage:c};return null}i(Cn,"generateQuoteWarnings");function Pd(t){return![4].includes(t.type)}i(Pd,"isQuoteWarningConfirmationRequired");function jt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Vs(t.toString(),e.toString());return n&&n<0?n:null}i(jt,"getPriceImpact");var _d=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"),Bi=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"),Dd=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=Gs.indexOf(o.value),a=Gs.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function Fd(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Wd.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new qe(r)))}i(Fd,"hasHighValueLoss");function Hd(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new qe(e.fromAmountMaxValue):null;return e.fromAmountRestrictionType==="EXCLUSIVE"?o?.gte(e.fromAmount)||n?.lte(e.fromAmount):o?.gt(e.fromAmount)||n?.lt(e.fromAmount)}).length>0}i(Hd,"hasLimitError");function Qd(t){let e=(t||[]).filter(c=>{let l=c.fromAmountMinValue?new qe(c.fromAmountMinValue):null,p=c.fromAmountMaxValue?new qe(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 qe(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new qe(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=kt.t({id:"Required: >= {min} {symbol}",values:{min:P(o,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=kt.t({id:"Required: > {min} {symbol}",values:{min:P(o,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=kt.t({id:"Required: <= {max} {symbol}",values:{max:P(n,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=kt.t({id:"Required: < {max} {symbol}",values:{max:P(n,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(Qd,"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 Ks(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(de))&&e&&e!=="0"&&n!==0)}i(Ks,"canComputePriceImpact");function js(t,e){let o=de;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 qe(r.amount).multipliedBy(a||0))}return o}i(js,"getUsdFeeOfStep");function Li(t,e){return t.reduce((o,n)=>o.plus(js(n,e)),de)}i(Li,"getTotalFeeInUsd");function Xs(t){let e=de,o=new qe(t.price||0);return e=e.plus(new qe(t.amount).multipliedBy(o)),e}i(Xs,"getUsdFee");function Gd(t){return t.reduce((e,o)=>e.plus(Xs(o)),de)}i(Gd,"getTotalFeesInUsd");function Vd(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(Vd,"getFeesGroup");function Kd(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(Kd,"checkSlippageErrors");function Od(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(Od,"checkSlippageWarnings");function Mi(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(Mi,"getMinRequiredSlippage");function Ud(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(Ud,"hasProperSlippage");function jd(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((S,T)=>(S[T.chain]=T.address,S),{}),C=[];return r?.forEach(S=>{C.push({blockchain:S.chain,addresses:[S.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:C,selectedWallets:m??{},slippage:p.toString(),contractCall:g,...h&&{destination:h},...l&&{swapperGroups:s.concat(c??[]),swappersGroupsExclude:!0},...!l&&{swapperGroups:c?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}i(jd,"createQuoteRequestBody");function Xd(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType,derivationPath:n.derivationPath},o),{})}i(Xd,"getWalletsForNewSwap");function lr(t){let e=t.requestAmount,o=t.swaps[0]?.from.usdPrice;if(!(!e||!o))return new qe(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 qe(e).multipliedBy(o)}i(Ct,"getUsdOutputFrom");function Vs(t,e){return new qe(e).div(new qe(t)).minus(1).multipliedBy(Ed).toNumber()}i(Vs,"getPercentageChange");function zd(t,e){let o=lr(t),n=Ct(t),r=Ct(e);if(!o||!n||!r)return!1;let a=Vs(n.toString(),r.toString());return Bd.some(({threshold:s,minInput:c})=>a<=s&&o.isGreaterThanOrEqualTo(c))}i(zd,"isOutputAmountChangedExcessively");function Yd(t,e,o){let n=t.validationStatus,r=Lo({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=P(new qe(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=P(new qe(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=kt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=kt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=kt.t(" for input and network fee")),kt.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(Yd,"generateBalanceWarnings");function pr(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==cr.NetworkChanged}i(pr,"isNetworkStatusInWarningState");function Zd(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?tw(t,e):null)?.walletType,u=p?o?.(p)?.name:null;switch(e?.networkStatus){case cr.WaitingForConnectingWallet:r=u?kt.t("Connect {wallet}",{wallet:u}):r;break;case cr.WaitingForQueue:r=r||kt.t("Waiting for other running tasks to be finished");break;case cr.WaitingForNetworkChange:r=r||kt.t("Waiting for changing wallet network");break;case cr.NetworkChangeFailed:r=r||kt.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(Zd,"getSwapMessages");function Jd(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(Jd,"getLastConvertedTokenInFailedSwap");function Rd(t){return t.status==="failed"}i(Rd,"shouldRetrySwap");function em(t,e,o,n,r,a){if(!n||t)return!0;let s=Lo({filter:"all",quote:n}),c=Lo({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?tn(a,o):!1;return!e&&!l||e&&!o||e&&!!o&&(!u||!p)}i(em,"isConfirmSwapDisabled");function tm(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(tm,"isTokensIdentical");var Pi=i((t,e)=>t?.usdPrice?new it(e||de).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),rm=i(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new it(0),outputUsdValue:new it(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=de,a=o.inputUsdValue;return Vn(o.inputAmount)?(e&&(n=e?.outputAmount?new it(e?.outputAmount):null,a=lr(e)??de,r=Ct(e)??de),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new it(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new it(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new it(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:Pi(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 it(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=vu(e);t(()=>({inputAmount:o}))},setInputAmount:e=>{let o=e;li(e)||(o=gu(o),o=hu(o)),t(n=>({inputAmount:o,...!o&&{outputAmount:null,outputUsdValue:new it(0),selectedQuote:null},...!!n.fromToken&&{inputUsdValue:Pi(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:Pi(n??null,s),outputUsdValue:new it(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?Pi(e.toToken,e.outputAmount?.toString()||""):new it(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new it(0),inputUsdValue:new it(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new it(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"),im=om()(nm(rm)),am=om()(nm(rm)),ow=co(im),nw=co(am);function H(){let{swapMode:t}=rt();return co(t==="refuel"?am:im)}i(H,"useQuoteStore");var sm=i((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&we.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&&we.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"),lm=ow.subscribe(sm),cm=nw.subscribe(sm);function pm(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:c,fromBlockchain:l,toBlockchain:p}=H()(),u=k().config,d=k().fetchStatus,f=k().blockchains(),{findToken:h}=k(),{setAffiliateRef:g,setAffiliatePercent:m,setAffiliateWallets:C}=k(),y=u?.from?.tokens,S=u?.from?.blockchains,T=u?.to?.tokens,v=u?.to?.blockchains,w=_i(void 0),A=_i(void 0),N=_i(void 0),b=_i(void 0);kn(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),kn(()=>{if(d==="success"){r();let x=f.find(I=>I.name===u?.from?.blockchain),E=u?.from?.token,B=E&&h(E);(x||!x&&N.current)&&n(x??null),B?a({token:B,meta:{blockchains:f}}):!B&&w.current&&a({token:null}),N.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]),kn(()=>{ys(s,y)&&a({token:null}),Ss(l,S)&&n(null)},[y,S]),kn(()=>{ys(c,T)&&a({token:null}),Ss(p,v)&&o(null)},[T,v]),kn(()=>{if(d==="success"){r();let x=f.find(I=>I.name===u?.to?.blockchain),E=u?.to?.token,B=E&&h(E);(x||!x&&b.current)&&o(x??null),B?e({token:B,meta:{blockchains:f}}):!B&&A.current&&e({token:null}),b.current=u?.to?.blockchain,A.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,d]),kn(()=>{g(u?.affiliate?.ref??null),m(u?.affiliate?.percent??null),C(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(pm,"useSyncStoresWithConfig");import{useEffect as Js,useRef as rw}from"react";import{useInRouterContext as iw,useLocation as aw,useSearchParams as sw}from"react-router-dom";function Ys(t,e){let o=t.split("--");return o[0]?{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}:null}i(Ys,"convertTokenSearchParamToAsset");function Zs(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Zs,"tokenToSearchParam");function el(){let t=aw(),[e,o]=sw(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:c,setFromBlockchain:l,setToBlockchain:p,setFromToken:u,setToToken:d,setInputAmount:f}=H()(),h=k().fetchStatus,g=k().blockchains(),m=iw(),{updateIframe:C,updateCampaignMode:y}=k(),S=k().isInCampaignMode(),T=rw(),{findToken:v}=k(),w=i(()=>{let N={};for(let[L,ee]of e.entries())L.startsWith("utm_")&&(N[L]=ee);let b=e.get("fromAmount"),x=e.get("fromBlockchain"),E=e.get("fromToken"),B=e.get("toBlockchain"),I=e.get("toToken"),_=e.get("autoConnect"),U=e.get("clientUrl"),G=e.get("liquiditySources"),Y=e.get("blockchain");return{fromAmount:b,fromBlockchain:x,fromToken:E,toBlockchain:B,toToken:I,autoConnect:_,clientUrl:U,liquiditySources:G,utmQueryParams:N,blockchain:Y}},"getUrlSearchParams"),A=i(N=>{for(let b in N)N[b]||delete N[b];o(N,{replace:!0})},"updateUrlSearchParams");Js(()=>{let{autoConnect:N,clientUrl:b,utmQueryParams:x,blockchain:E}=w();m&&h==="success"&&A({fromBlockchain:n?.name,fromToken:Zs(a),toBlockchain:r?.name,toToken:Zs(s),fromAmount:c,autoConnect:N??void 0,clientUrl:b??void 0,blockchain:E??void 0,liquiditySources:S?T.current:void 0,...x})},[t.pathname,c,n,a,r,s,S,h]),Js(()=>{if(!m)return;let N=w();if(!T.current&&N.liquiditySources&&(T.current=N.liquiditySources),N.fromAmount&&f(N.fromAmount),h==="success"){let b=g.find(U=>U.name===N.fromBlockchain),x=N.fromToken&&b&&Ys(N.fromToken,b),E=x?v(x):void 0,B=g.find(U=>U.name===N.toBlockchain),I=N.toToken&&B&&Ys(N.toToken,B),_=I?v(I):void 0;b&&(l(b),E&&u({token:E,meta:{blockchains:g}})),B&&(p(B),_&&d({token:_,meta:{blockchains:g}}))}},[h]),Js(()=>{let{clientUrl:N,liquiditySources:b}=w();C("clientUrl",N||void 0),y("liquiditySources",b?.split(",")??void 0)},[])}i(el,"useSyncUrlAndStore");import{i18n as bn}from"@lingui/core";import{Alert as Lv,Button as Mv,darkTheme as Pv,Divider as Wl,DoneIcon as _v,styled as Dv,TextField as $v,Typography as Fv}from"@rango-dev/ui";import Ve,{useState as Ov}from"react";import{useNavigate as Uv,useSearchParams as zv}from"react-router-dom";import{ChevronRightIcon as lw,Divider as gm,Image as cw,Typography as hm}from"@rango-dev/ui";import xt from"react";import{darkTheme as um,styled as tl}from"@rango-dev/ui";var dm=tl("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${um} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${um} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),mm=tl("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),fm=tl("div",{display:"flex"});function ol(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return xt.createElement(mm,null,xt.createElement(hm,{size:"large",variant:"label"},n),xt.createElement(gm,{size:10}),xt.createElement(dm,{onClick:s?void 0:e,disabled:s,id:"widget-blockchain-selector-container"},xt.createElement(fm,null,r&&xt.createElement(xt.Fragment,null,xt.createElement(cw,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),xt.createElement(gm,{size:4,direction:"horizontal"})),xt.createElement(hm,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),xt.createElement(lw,{size:12,color:"black"})))}i(ol,"BlockchainSelectorButton");import{i18n as al}from"@lingui/core";import{Button as yw,Divider as wm,MessageBox as Sw}from"@rango-dev/ui";import uo,{useEffect as vm,useState as sl}from"react";import{i18n as Di}from"@lingui/core";import{Divider as Fo,ExternalLinkIcon as dw,Image as mw,InfoIcon as fw,Tooltip as gw,Typography as dr}from"@rango-dev/ui";import fe from"react";var ym="https://blog.rango.exchange/understanding-the-risks-of-using-custom-token-contract-addresses-96022308eca4";function Sm(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(Sm,"generateExplorerLink");import{Button as pw,darkTheme as Tn,styled as ur,Typography as uw}from"@rango-dev/ui";var nl=ur("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Tn} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Tn} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Tn} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Tn} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),Cm=ur("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Tn} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Tn} &`]:{color:"$colors$neutral900"}}}),rl=ur(pw,{minHeight:"$40"}),km=ur(uw,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"96px"}),Tm=ur("div",{display:"flex",justifyContent:"center",alignItems:"center"});var hw=9;function il(t){let{open:e,onClose:o,token:n,onExit:r,onSubmitClick:a,blockchain:s}=t,c=Sm(n.address,s),l=i(()=>window.open(ym,"_blank"),"onClickLearnMore");return fe.createElement(R,{open:e,id:"widget-custom-token-watermarked-modal",dismissible:!0,onClose:o,onExit:r,container:W()},fe.createElement(Cm,null,fe.createElement(mw,{src:n.image===""?ni:n.image,size:45,type:"circular"}),fe.createElement(Fo,{size:4}),fe.createElement(Tm,null,fe.createElement(km,{variant:"title",size:"medium"},n.symbol),n.symbol.length>hw&&fe.createElement(gw,{content:n.symbol,container:W()},fe.createElement(fw,{size:12,color:"gray"}))),fe.createElement(dr,{variant:"body",size:"small",className:"_blockchain-name"},s.displayName),fe.createElement(Fo,{size:4}),fe.createElement(dr,{variant:"body",size:"medium"},c?fe.createElement(nl,{hasHover:!0,href:c,target:"_blank",rel:"nofollow noreferrer"},n.address,fe.createElement(dw,{size:12,color:"gray"})):fe.createElement(nl,null,n.address)),fe.createElement(Fo,{size:4}),n.coinSource&&fe.createElement(dr,{className:"_coin-source",variant:"body",size:"xsmall"},Di.t("via")," ",fe.createElement(dr,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),fe.createElement(Fo,{size:"32"}),fe.createElement(dr,{size:"medium",variant:"body",className:"_custom-token-description"},Di.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."))),fe.createElement(Fo,{size:40}),fe.createElement(Fo,{size:10}),fe.createElement(rl,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:a},Di.t("Import Anyway")),fe.createElement(Fo,{size:10}),fe.createElement(rl,{id:"widget-custom-token-modal-learn-more-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:l},Di.t("Learn More")))}i(il,"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}=k(),[d,f]=sl(!1),[h,g]=sl(!1),[m,C]=sl(!1),y=i(()=>{o&&a?.({blockchain:o.name,tokenAddress:r})},"getCustomToken"),S=i(()=>{n?.type!=="network-error"&&s?.(),f(!1)},"closeErrorModal"),T=i(()=>{C(!0),S()},"handleErrorModalButtonClick"),v=i(()=>{m&&n?.type==="network-error"&&(C(!1),y()),l()},"handleExit"),w=i(()=>{e&&(u(e),c())},"handleSubmit");return vm(()=>{n&&f(!0)},[n]),vm(()=>{o&&e&&g(!0)},[o,e]),uo.createElement(uo.Fragment,null,uo.createElement(R,{open:d,dismissible:!0,id:"widget-add-custom-token-modal",onClose:S,onExit:v,container:W()},uo.createElement(Sw,{title:n?.title??"",type:"error",description:n?.message||al.t("Failed Network, Please retry.")},uo.createElement(wm,{size:40}),uo.createElement(wm,{size:10}),uo.createElement(yw,{id:`widget-add-custom-token-${n?.type==="network-error"?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:T},n?.type==="network-error"?al.t("Retry"):al.t("Add another custom token")))),o&&e&&uo.createElement(il,{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 tf,Header as Av}from"@rango-dev/ui";import Be,{useEffect as Gi,useLayoutEffect as Nv,useRef as of,useState as nf}from"react";import{useRef as Cw}from"react";function fr(){return window.self!==window.top}i(fr,"isAppLoadedIntoIframe");function ll(){let t=Cw(null),{iframe:e}=k(),o=fr()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(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(ll,"useIframe");import{useNavigate as kw}from"react-router-dom";function Ge(){let t=kw();return()=>t(-1)}i(Ge,"useNavigateBack");import{useLayoutEffect as Tw,useState as gr}from"react";var bm=480,xm=768,Em=1024,Im=1200,ww=i(()=>{let[t,e]=gr(!1),[o,n]=gr(!1),[r,a]=gr(!1),[s,c]=gr(!1),[l,p]=gr(!1),u=i(()=>{e(window.innerWidth<=bm),n(window.innerWidth>bm&&window.innerWidth<=xm),a(window.innerWidth>xm&&window.innerWidth<=Em),c(window.innerWidth>Em&&window.innerWidth<=Im),p(window.innerWidth>Im)},"handleResize");return Tw(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:l}},"useScreenDetect"),wn=ww;import{createTheme as gl,darkTheme as _w,lightTheme as Dw}from"@rango-dev/ui";import{useEffect as $w,useState as Fw}from"react";import{theme as Mw,darkColors as Pw}from"@rango-dev/ui";import ml from"react";var $i=16,Fi=255,Am=.11;function vw(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(vw,"expandShortHexColor");function bw(t,e){return t.padStart(e,"0")}i(bw,"pad");function cl(t){let e=Math.min(Math.max(Math.round(t),0),Fi);return bw(e.toString($i),2)}i(cl,"intToHex");function xw(t){return`#${cl(t.red)}${cl(t.green)}${cl(t.blue)}`}i(xw,"rgbToHex");function Ew(t){let e=parseInt(t.slice(1,3),$i),o=parseInt(t.slice(3,5),$i),n=parseInt(t.slice(5,7),$i);return{red:e,green:o,blue:n}}i(Ew,"hexToRGB");function Iw(t,e){let o=1-Am*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(Iw,"generateShade");function Aw(t,e){let o=Am*e;return{red:t.red+(Fi-t.red)*o,green:t.green+(Fi-t.green)*o,blue:t.blue+(Fi-t.blue)*o}}i(Aw,"generateTint");function Nw(t){return Nm(t,Iw)}i(Nw,"calculateShades");function Ww(t){return Nm(t,Aw)}i(Ww,"calculateTints");function Nm(t,e){let o=Ew(t),n=[];for(let r=1;r<9;r++)n.push(xw(e(o,r)));return n}i(Nm,"calculateColors");function pl(t,e,o){let a=Ww(t).reverse().concat(t),s=Nw(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(pl,"createTintsAndShades");function ul(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=vw(a);Object.assign(n,pl(l,r,s))}}return{...n,...e}}i(ul,"expandToGenerateThemeColors");var Wm=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),Bw=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=Wm(o%52)+e;return Wm(o%52)+e},"toAlphabeticName"),Lw=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),dl=i(t=>Bw(Lw(5381,JSON.stringify(t))>>>0),"toHash");function fl(t){let e=Mw.colors,o={...e,...Pw},n,r;if(t?.light){let s={colors:ul(e,t.light)};n={id:`${hs}-light-${dl(s)}`,tokens:s}}if(t?.dark){let s={colors:ul(o,t.dark,{reverseNeutralRange:!0})};r={id:`${hs}-dark-${dl(s)}`,tokens:s}}return{light:n,dark:r}}i(fl,"customizedThemeTokens");function Bm(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>ml.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(ml.cloneElement(a,{key:s})),r<t.length-1){let c=`divider-${r}`;o.push(ml.cloneElement(e,{key:c}))}}),o}i(Bm,"joinList");function Lm(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Lm,"doesWindowPreferDarkColorScheme");function mo(t){let{colors:e,fontFamily:o=iu,borderRadius:n=_u,secondaryBorderRadius:r=Du}=t,[a,s]=Fw(Lm()?"dark":"light"),{theme:c}=k(),{dark:l,light:p}=fl(e),u=gl({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),d=[u.className,Dw.className],f=[u.className,_w.className];if(p){let g=gl(p.id,p.tokens);d.push(g.className)}if(l){let g=gl(l.id,l.tokens);f.push(g.className)}return $w(()=>{let g=i(m=>{m.matches?s("dark"):s("light")},"switchThemeListener");return Lm()&&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 Tt=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 Mm}from"@lingui/core";import{Alert as Ow,Button as Uw}from"@rango-dev/ui";import Pm from"react";function hl(t){return Pm.createElement(Ow,{action:Pm.createElement(Uw,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Mm.t("Activate this tab")),type:"warning",variant:"alarm",title:Mm.t("Another tab is open and handles transactions.")})}i(hl,"ActivateTabAlert");import{i18n as yl}from"@lingui/core";import{Button as zw,Divider as Hw,MessageBox as Qw}from"@rango-dev/ui";import Oi from"react";function Sl(t){let{open:e,onClose:o,onConfirm:n}=t;return Oi.createElement(R,{open:e,dismissible:!0,onClose:o,id:"widget-active-tab-modal",container:W()},Oi.createElement(Qw,{title:yl.t("Activate current tab"),type:"warning",description:yl.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.")},Oi.createElement(Hw,{size:20}),Oi.createElement(zw,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},yl.t("Confirm"))))}i(Sl,"ActivateTabModal");import{ChevronLeftIcon as Vw}from"@rango-dev/ui";import Hm from"react";import{css as qw,darkTheme as _m,IconButton as Gw,styled as Oo}from"@rango-dev/ui";var Dt=Oo(Gw,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${_m} &`]:{backgroundColor:"$neutral"}}}),Dm=Oo("div",{position:"absolute",background:"$secondary500",[`.${_m} &`]:{$$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}}),$m=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"}}}}),Fm=Oo("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Om=Oo("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),Um=qw({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),zm=Oo("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});function Cl(t){return Hm.createElement(Dt,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Hm.createElement(Vw,{color:"black",size:16}))}i(Cl,"BackButton");import{i18n as Kw}from"@lingui/core";import{Button as jw,Typography as Xw}from"@rango-dev/ui";import kl from"react";function Tl(t){return kl.createElement(fo,null,kl.createElement(jw,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},kl.createElement(Xw,{variant:"label",size:"medium",color:"error500"},Kw.t("Cancel"))))}i(Tl,"CancelButton");import{i18n as Yw}from"@lingui/core";import{Image as Zw,Tooltip as Jw,WalletIcon as Rw}from"@rango-dev/ui";import Uo from"react";function wl(t){let{list:e}=vt(),o=e.filter(r=>r.state==="connected"),n=o.length?Uo.createElement("div",{className:Um()},o.map(r=>Uo.createElement(zm,{key:r.title},Uo.createElement(Zw,{src:r.image,size:14})))):Yw.t("Connect Wallet");return Uo.createElement(Jw,{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(Dm,null),Uo.createElement(Rw,{size:18,color:"black"})))}i(wl,"WalletButton");import{i18n as zi}from"@lingui/core";import{NotificationsIcon as gv,Popover as hv,SettingsIcon as yv,Tooltip as Hi,TransactionIcon as Sv}from"@rango-dev/ui";import Pe from"react";import{Notifications as nv}from"@rango-dev/ui";import rv from"react";import{useNavigate as iv}from"react-router-dom";import{create as ev}from"zustand";import{persist as tv,subscribeWithSelector as ov}from"zustand/middleware";var We=co(ev()(tv(ov((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 vl(){let t=iv(),{getNotifications:e,clearNotifications:o}=We(),n=e(),r=k().blockchains(),{findToken:a}=k();return rv.createElement(nv,{id:"widget-notifications-container",list:n,getBlockchainImage:c=>Yp(c,r),getTokenImage:c=>a(c)?.image,onClickItem:i(c=>{t(`${F.swaps}/${c}`)},"onClickItem"),onClearAll:o})}i(vl,"NotificationContent");import{useManager as av}from"@rango-dev/queue-manager-react";import{InProgressIcon as sv}from"@rango-dev/ui";import Qm from"react";var lv=i(()=>{let{manager:t}=av();return Tt(t).map(({swap:o})=>o).find(o=>o.status==="running")?Qm.createElement(Om,{id:"widget-header-history-badge-container"},Qm.createElement(sv,{color:"info",size:6})):null},"InProgressTransactionBadge"),qm=lv;import{EventSeverity as cv}from"@rango-dev/queue-manager-rango-preset";import{Typography as pv}from"@rango-dev/ui";import Gm from"react";function Vm(){let{getNotifications:t}=We(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===cv.WARNING);return o?Gm.createElement($m,{isSever:n},Gm.createElement(pv,{variant:"body",size:"xsmall",color:"$background",id:"widget-header-notifications-badge-container"},o)):null}i(Vm,"NotificationsBadge");import{RefreshProgressButton as uv}from"@rango-dev/ui";import bl,{useEffect as dv,useState as Km}from"react";var mv=1e3,jm=60,fv=100;function Ui({onClick:t}){let[e,o]=Km(0),[n,r]=Km(!1),a=i(l=>{document.hidden&&l&&s(l)},"handleVisibilityChange");dv(()=>{let l;return t?l=window.setInterval(()=>{o(p=>p+1),e===jm&&c()},mv):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 bl.createElement(Dt,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:c,disabled:!t},bl.createElement(Fm,{onTransitionEnd:()=>r(!1),isRefetched:n},bl.createElement(uv,{size:22,color:t?"black":"gray",progress:e/jm*fv})))}i(Ui,"RefreshButton");function zo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=k(),c=nt("notification",s)||r.includes("notifications");return Pe.createElement(Pe.Fragment,null,!r.includes("refresh")&&Pe.createElement(Hi,{container:a||W(),side:"top",content:zi.t("Refresh")},Pe.createElement(Ui,{onClick:e})),!c&&Pe.createElement(hv,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:W(),content:Pe.createElement(vl,null)},Pe.createElement("div",null,Pe.createElement(Hi,{container:W(),side:"top",content:zi.t("Notifications")},Pe.createElement(Dt,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Pe.createElement(gv,{size:18,color:"black"}),Pe.createElement(Vm,null))))),!r.includes("settings")&&Pe.createElement(Hi,{container:W(),side:"top",content:zi.t("Settings")},Pe.createElement(Dt,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Pe.createElement(yv,{size:18,color:"black"}))),!r.includes("history")&&Pe.createElement(Hi,{container:W(),side:"top",content:zi.t("History")},Pe.createElement(Dt,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Pe.createElement(Sv,{size:18,color:"black"}),Pe.createElement(qm,null))))}i(zo,"HeaderButtons");import{i18n as xl}from"@lingui/core";import{Divider as Ym,MessageBox as Tv,RefreshIcon as wv}from"@rango-dev/ui";import vn from"react";import{Button as Cv,styled as kv}from"@rango-dev/ui";var Xm=kv(Cv,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function El(t){let{open:e,onClose:o}=t;return vn.createElement(R,{open:e,dismissible:!0,onClose:o,id:"widget-refresh-modal",container:W()},vn.createElement(Tv,{title:xl.t("Something went wrong"),type:"error",description:xl.t("Something went wrong. Please refresh the app.")},vn.createElement(Ym,{size:30}),vn.createElement(Xm,{variant:"outlined",id:"widget-refresh-modal-refresh-btn",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},vn.createElement(wv,{size:20,color:"primary"}),vn.createElement(Ym,{size:4,direction:"horizontal"}),xl.t("Refresh"))))}i(El,"RefreshModal");function Il(t){let e=t.target;if(e){let o=e.scrollTop,n=W();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(Il,"onScrollContentAttachStatusToContainer");import{css as bv,styled as Qi}from"@rango-dev/ui";var qi=bv({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Zm=Qi("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:700},fixed:{minHeight:425,maxHeight:700,height:700}},showBanner:{true:{overflow:"visible"}}}}),Jm=Qi("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Rm=Qi("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=Qi("div",{width:"100%",position:"absolute",bottom:"-$10",transform:"translateY(100%)",overflow:"hidden"});function ae(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=ll(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:c,connectedWallets:l,config:{__UNSTABLE_OR_INTERNAL__:p}}=k(),[u,d]=nf(!1),{config:{features:f,theme:h}}=k(),{watermark:g,setShowCompactTokenSelector:m}=ne(),C=g==="FULL",{activeTheme:y}=mo(h||{}),[S,T]=nf(!1),v=nt("connectWalletButton",f),{isActiveTab:w,tabManagerInitiated:A,showActivateTabModal:N,setShowActivateTabModal:b,activateCurrentTab:x}=ne(),E=Ge(),{manager:B}=Ev(),{isTablet:I,isMobile:_}=wn(),G=Tt(B).map(({swap:se})=>se).some(se=>se.status==="running"),Y=i(()=>x(Po.forceClaim,G),"onActivateTab"),L=i(()=>{r.onWallet?.()},"onConnectWallet"),ee=typeof r.hasBackButton>"u"||r.hasBackButton,J=of(null),te=of(null);return Gi(()=>{let se=(p?.swapBoxBanner?.routes?.length??0)===0,je=!!p?.swapBoxBanner?.routes?.some(le=>location.pathname.endsWith(le));T(!!p?.swapBoxBanner&&(se||je))},[p?.swapBoxBanner?.routes?.toString(),location.pathname]),Gi(()=>(fr()&&te.current&&e(te.current),()=>{o()}),[]),Gi(()=>(J.current?.addEventListener("scroll",Il),()=>{J.current?.removeEventListener("scroll",Il)}),[]),Gi(()=>{d(c==="failed")},[c]),Nv(()=>{let se=s==="auto"||!te.current||fr(),je=_||I,le=i(()=>{se||(je?te.current.style.height=`${window.innerHeight-te.current.offsetTop}px`:te.current.style.height=`${700}px`,m(parseFloat(te.current.style.height)<640))},"handler");return le(),window.addEventListener("resize",le),()=>window.removeEventListener("resize",le)},[s,_,I]),Be.createElement(Zm,{height:s,id:ot.SWAP_BOX_ID,className:`${y()} ${qi()}`,ref:te,showBanner:S},Be.createElement(Av,{prefix:ee?Be.createElement(Cl,{onClick:()=>{E(),r.onBack?.()}}):null,title:r.title,suffix:Be.createElement(Be.Fragment,null,r.suffix,r.onWallet&&!v&&Be.createElement(wl,{container:W(),onClick:L,isConnected:!!l?.length}),r.onCancel&&Be.createElement(Tl,{onClick:r.onCancel}))}),Be.createElement(Jm,{ref:J},n),Be.createElement(Sl,{open:N,onClose:()=>b(!1),onConfirm:Y}),Be.createElement(Rm,null,Be.createElement("div",{className:"footer__content"},A&&!w&&Be.createElement("div",{className:"footer__alert"},Be.createElement(hl,{onActivateTab:Y}),Be.createElement(tf,{size:10})),a),Be.createElement(tf,{size:12}),Be.createElement("div",{className:`footer__logo ${C?"logo__show":"logo__hidden"}`},Be.createElement(Iv,null))),S&&Be.createElement(ef,null,p?.swapBoxBanner?.element),Be.createElement(El,{open:u,onClose:()=>d(!1)}))}i(ae,"Layout");import{styled as Wv}from"@rango-dev/ui";var rf="$20 $20 $10 $20",Al=Wv("div",{padding:rf,overflowY:"auto",flexGrow:1});import{styled as Bv}from"@rango-dev/ui";var ue=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 Nl}from"react";function af(){let[t,e]=Nl(!1),[o,n]=Nl(null),[r,a]=Nl(null),{findToken:s}=k(),c=k().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(y=>y.address?.toLowerCase()===f.toLowerCase())){let y=p("duplicated");n(y);return}let g=await ut().getCustomToken({blockchain:d,address:f});if(!g||!g.token||g.error){let y=p("not-found",d);n(y);return}let m=g.token;if(s({blockchain:m.blockchain,address:m.address,symbol:m.symbol})){let y=p("token-exist");n(y);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 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 sf(){let t=Uv(),[e]=zv(),o=Ge(),n=k().blockchains(),r=e.get("blockchain")||"",a=No(r,n),[s,c]=Ov(""),{fetchCustomToken:l,token:p,loading:u,error:d,resetState:f}=af(),h=!!a&&tn(a,s),g=!a||!s||!h,m=i(()=>{a&&l({blockchain:r,tokenAddress:s})},"getCustomToken");return Ve.createElement(ae,{header:{title:bn.t("Add Custom Token")}},Ve.createElement(ue,null,Ve.createElement(Hv,null,Ve.createElement("div",null,Ve.createElement(ol,{onClick:()=>t(F.blockchains,{replace:!0}),hasLogo:!!a?.logo,value:a?{name:a.displayName,logo:a.logo}:void 0,title:bn.t("Select chain"),placeholder:bn.t("Select chain")}),Ve.createElement(Wl,{size:"24"}),Ve.createElement(Fv,{size:"large",variant:"label"},bn.t("Enter Address")),Ve.createElement(Wl,{size:10}),Ve.createElement($v,{fullWidth:!0,id:"widget-add-custom-token-token-address-input",disabled:!a,variant:"contained",placeholder:bn.t("Enter token address"),size:"large",value:s,suffix:!!s&&h&&Ve.createElement(_v,{color:"success",size:12}),onChange:C=>c(C.target.value)}),!h&&!!s&&Ve.createElement(Ve.Fragment,null,Ve.createElement(Wl,{size:4}),Ve.createElement(Lv,{id:"widget-add-custom-token-invalid-address-alert",type:"error",variant:"alarm",title:"Invalid Address"}))),Ve.createElement(Mv,{id:"widget-add-custom-token-import-btn",disabled:g,type:"primary",variant:"contained",loading:u,size:"large",onClick:m},bn.t("Import"))),Ve.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 uc}from"@lingui/core";import{useManager as Nx}from"@rango-dev/queue-manager-react";import{Alert as Wx,Button as Bx,css as mc,Divider as dc,IconButton as Xg,styled as Lx,Typography as Mx,WalletIcon as Px}from"@rango-dev/ui";import $e,{useEffect as Ca,useLayoutEffect as _x,useRef as Dx,useState as Ir}from"react";import{useNavigate as $x}from"react-router-dom";import{i18n as Ho}from"@lingui/core";import{Alert as fb,BalanceErrors as gb,Button as Mf,ChevronLeftIcon as hb,Divider as Fl,MessageBox as yb,Typography as Ol}from"@rango-dev/ui";import ie,{useCallback as Sb,useEffect as Pf,useMemo as Cb,useState as In}from"react";import{useNavigate as kb}from"react-router-dom";import{i18n as Pl}from"@lingui/core";import{Alert as Kv,ChevronDownIcon as jv,CloseIcon as Xv,Divider as ff,IconButton as gf,PasteIcon as Yv,Typography as Zv,WalletIcon as Jv}from"@rango-dev/ui";import _e,{useEffect as Rv,useRef as eb}from"react";import Xi,{useRef as Gv}from"react";import*as xn from"@radix-ui/react-collapsible";import{keyframes as lf,styled as Vi}from"@rango-dev/ui";var Bl=300,Qv=lf({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),qv=lf({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),cf=Vi(xn.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),Ll=Vi(xn.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Ki=Vi(xn.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Qv} ${Bl}ms ease-out`},false:{animation:`${qv} ${Bl}ms ease-out`}}}}),ji=Vi("div",{transition:`all ${Bl}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Yi(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:c}=t,l=Gv(null);return Xi.createElement(cf,{ref:l,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},c==="top"&&Xi.createElement(Ll,{className:"collapsible_trigger",onClick:a},s),Xi.createElement(Ki,{className:"collapsible_content",open:e},r),c==="bottom"&&Xi.createElement(Ll,{className:"collapsible_trigger",onClick:a},s))}i(Yi,"CustomCollapsible");import{darkTheme as pf,styled as Ml,TextField as Vv}from"@rango-dev/ui";var uf=Ml("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=Ml(Vv,{backgroundColor:"$neutral100"}),mf=Ml("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}=k(),c=k().blockchains(),l=ti(e.name,c),p=eb(null),u=s?.defaultCustomDestinations?.[e.name],d=navigator?.userAgent.includes("Firefox"),h=n&&!!r&&e&&!tn(e,r),g=i(()=>{a("")},"handleClear"),m=i(async y=>{if(y.preventDefault(),navigator.clipboard!==void 0){let S=await navigator.clipboard.readText();a(S),p?.current?.focus()}},"handlePaste"),C=i(()=>r?_e.createElement(gf,{id:"widget-custom-destination-close-icon-btn",onClick:g,variant:"ghost"},_e.createElement(Xv,{size:12,color:"gray"})):d?null:_e.createElement(gf,{id:"widget-custom-destination-paste-icon-btn",onClick:m,variant:"ghost"},_e.createElement(Yv,{size:16})),"renderSuffix");return Rv(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),_e.createElement(uf,null,_e.createElement(Yi,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:_e.createElement(mf,{id:"widget-custom-destination-collapsible-btn"},_e.createElement("div",{className:"button__content"},_e.createElement(Jv,{size:18,color:"info"}),_e.createElement(ff,{size:4,direction:"horizontal"}),_e.createElement(Zv,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Pl.t("Send to a different address"))),_e.createElement(ji,{orientation:n?"up":"down"},_e.createElement(jv,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},_e.createElement(df,{id:"widget-custom-destination-blockchain-address-input",ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Pl.t("Enter {blockchainName} address",{blockchainName:l}),value:r||"",suffix:C(),onChange:y=>{let S=y.target.value;a(S)}})),h&&_e.createElement(_e.Fragment,null,_e.createElement(ff,{size:4}),_e.createElement(Kv,{variant:"alarm",type:"error",title:Pl.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(hf,"CustomDestination");import{css as tb,IconButton as ob,SelectableWalletButton as nb,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(nb,{justifyContent:"center"}),kf=ho("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),Tf=ho(ob,{position:"absolute",left:"$20"}),wf=ho("div",{paddingTop:"$20"}),vf=tb({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),bf=ho("div",{display:"flex"}),xf=ho("div",{overflow:"visible",width:"100%"});import{i18n as Dl}from"@lingui/core";import{warn as lb}from"@rango-dev/logging-core";import{Divider as cb,makeInfo as pb,SelectableWallet as ub,Typography as Bf,WalletState as Zi}from"@rango-dev/ui";import at,{useEffect as Lf,useState as Sr}from"react";import{Image as ab,MessageBox as sb}from"@rango-dev/ui";import yr from"react";import{keyframes as rb,styled as _l}from"@rango-dev/ui";var Ef=_l("div",{position:"relative"}),ib=rb({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),If=_l("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${ib} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Af=_l("div",{"& img":{borderRadius:"50%"}});import{i18n as En}from"@lingui/core";function Nf(t,e){switch(t){case"in-progress":return{type:"loading",title:En.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:En.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:En.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:En.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:En.t("Request Rejected"),description:En.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 Wf(t){let{status:e,displayName:o,image:n}=t,r=Nf(e,o),a=e=="in-progress";return yr.createElement(sb,{type:r.type,title:r.title,description:r.description,icon:a?yr.createElement(Ef,null,yr.createElement(Af,null,yr.createElement(ab,{src:n,size:45})),yr.createElement(If,null)):void 0})}i(Wf,"ExperimentalChainStatus");var db=7,mb=3e3;function $l(t){let{chain:e,quoteChains:o,isSelected:n,selectWallet:r,limit:a,onShowMore:s}=t,c=ne.use.isActiveTab(),{checkHasDeepLink:l,getWalletLink:p}=un(),{blockchains:u,connectedWallets:d}=k(),[f,h]=Sr(),[g,m]=Sr(null),[C,y]=Sr(!1),[S,T]=Sr(null),{suggestAndConnect:v}=Ji(),{list:w}=vt({chain:e}),[A,N]=Sr(w),b=w.length,x=a&&b-a>0,E=i(async I=>{y(!1),T("in-progress");try{await v(I.walletType,I.chain),T("completed")}catch{T("rejected")}},"addExperimentalChain");Lf(()=>{N(I=>{let _=w.findIndex(U=>n(U.type,e));return x&&_>1?[w[_]].concat(w.filter((U,G)=>G!==_)):I.map(U=>w.find(G=>G.type===U.type)??U)})},[JSON.stringify(w)]);let B=document.getElementById(ot.SWAP_BOX_ID);return Lf(()=>{let I=null;return(S==="completed"||S==="rejected")&&(I=setTimeout(()=>T(null),mb)),()=>{I&&clearTimeout(I)}},[S]),at.createElement(at.Fragment,null,A.slice(0,a).map(I=>{let _=Nu({connectedWallets:d,walletType:I.type,chain:e}),U=I.state===Zi.CONNECTED,G=_?lo(_,db):"",Y=U&&!!I.needsNamespace&&!G,L=di(u(),e),ee=!d.find(He=>He.walletType===I.type&&He.chain===e),J=L&&ee&&I.state===Zi.CONNECTED,te=i(async()=>{I.state===Zi.DISCONNECTED||Y?h(I):J?(m({walletType:I.type,chain:e,address:_??""}),y(!0)):r({walletType:I.type,chain:e,address:_??""})},"onSelectableWalletClick"),se=pb(I.state,{hasDeepLink:l(I.type)}),je=i(()=>J?Dl.t({id:"Add {chain} chain",values:{chain:e}}):Y?Dl.t("Chain not connected"):G||se.description,"getWalletDescription"),le=i(()=>I.state===Zi.CONNECTED?Y?"neutral600":"neutral700":se.color,"getWalletDescriptionColor"),Xe=g?.chain?ti(g.chain,u()):void 0;return at.createElement(at.Fragment,{key:`${I.title}_${Xe}`},!!g&&at.createElement(R,{id:"widget-wallets-list-watermarked-modal",open:!!g&&C,container:B,onClose:()=>{m(null)}},at.createElement(Qs,{id:"widget-wallets-list-experimental-chain-container",displayName:Xe,onConfirm:()=>{E(g)}})),S&&at.createElement(R,{id:"widget-wallets-list-experimental-chain-watermarked-modal",open:!!S,onClose:T.bind(null,null),container:B},at.createElement(Wf,{status:S,displayName:Xe,image:I.image}),at.createElement(cb,{direction:"vertical",size:32})),at.createElement(ub,{hasDeepLink:l(I.type),key:I.type,id:"widget-wallets-list-selectable-wallet-btn",description:je(),descriptionColor:le(),onClick:te,selected:n(I.type,e),disabled:!c,...I,link:p(I.type)}))}),at.createElement(sr,{id:"widget-wallets-list-stateful-connect-modal",wallet:f,options:{defaultSelectedChains:o||[e]},onClose:()=>{h(void 0)},onConnect:()=>{t.onConnect&&(f?.type?t.onConnect(f.type):lb(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),x&&at.createElement(Cf,{selected:!1,onClick:s,id:"widget-wallets-list-show-more-wallets-btn"},at.createElement(Bf,{variant:"label",size:"medium"},Dl.t("Show more wallets"),at.createElement(Bf,{variant:"label",size:"medium",color:"$primary"},"\xA0+",b-(a??0)))))}i($l,"WalletList");var Tb=2;function _f(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=kb(),c=k().blockchains(),{selectedQuote:l,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:d,customDestination:f,setCustomDestination:h}=H()(),{config:g,connectedWallets:m,setWalletsAsSelected:C}=k(),[y,S]=In(""),[T,v]=In([]),[w,A]=In(""),[N,b]=In(!!f),x=Cb(()=>Lo({filter:"all",quote:l}),[l]),E=Lo({filter:"required",quote:l}),B=c.find($=>$.name===l?.swaps[l?.swaps.length-1]?.to.blockchain),I=i($=>E.includes($),"isWalletRequiredFor"),_=Sb(()=>m.filter($=>$.selected&&x.includes($.chain)),[m,x]),[U,G]=In(_()),[Y,L]=In([]),ee=i(($,z)=>L(V=>V.concat({blockchain:$,walletType:z})),"addNextSelectedWallets"),J=T.length>0,te=i(($,z)=>!!U.find(V=>V.walletType===$&&V.chain===z&&V.selected&&(I(z)||!I(z)&&!f)),"isSelected"),se=i(($,z,V)=>{let pe=!1;return $.map(Q=>{if(Q.chain===z){let X=Q.selected;return!pe&&V?(pe=!0,X=!0):V||(X=!1),{...Q,selected:X}}return Q})},"updateSelectableWallets"),je=i($=>{b($),$?I(B?.name??"")||G(z=>se(z,B?.name||"",!1)):(h(""),G(z=>se(z,B?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),le=i($=>{if(y&&S(""),te($.walletType,$.chain))return;let V=m.find(pe=>pe.walletType===$.walletType&&pe.chain===$.chain);V&&(n(),$.chain===B?.name&&N&&!I(B.name)&&(b(!1),h(null)),G(pe=>pe.filter(Q=>Q.chain!==$.chain).concat({...V,selected:!0})))},"onChange"),Xe=i(()=>{let $=U.filter(z=>z.selected);C($),p($),d(!0),o()},"onConfirmBalance"),He=i(async()=>{v([]),A("");let $=await r?.({selectedWallets:U.filter(V=>V.selected),customDestination:f}),z=$.warnings;z?.balance?.messages&&v(z.balance.messages),$.error&&A(xd($.error)),!$.error&&!z?.balance?.messages.length?Xe():v(z?.balance?.messages??[])},"onConfirmWallets");Pf(()=>{G($=>{let z=[];return $.forEach(V=>{!m.some(Q=>Q.chain===V.chain&&Q.walletType===V.walletType&&Q.address===V.address)||z.push(V)}),z=z.concat(m.filter(V=>!!!z.find(Q=>Q.chain===V.chain)&&V.selected&&x.includes(V.chain))),z})},[m,x]),Pf(()=>{let $=[];Y.length>0&&(Y.forEach(z=>{let V=m.find(pe=>pe.chain===z.blockchain&&pe.walletType===z.walletType);V?le(V):$.push(z)}),L($))},[m,Y]);let Bt=document.getElementById(ot.SWAP_BOX_ID);return ie.createElement(R,{id:"widget-confirm-wallets-modal",open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!y,container:Bt,...!y&&{styles:{container:{height:"100%"}},footer:ie.createElement(bf,null,ie.createElement(Mf,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:em(a,N,f,l,U,B),onClick:He,variant:"contained",type:"primary",fullWidth:!0,size:"large"},Ho.t("Confirm")))},...y&&{styles:{container:{height:"100%",padding:"$0"}},header:ie.createElement(kf,null,ie.createElement(Tf,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:S.bind(null,"")},ie.createElement(hb,{size:16})),ie.createElement(Ol,{variant:"headline",size:"small"},Ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:yt(y,c)}})))},anchor:"center"},ie.createElement(R,{id:'"widget-confirm-wallets-insufficient-account-balance-modal',open:J,onClose:v.bind(null,[]),container:Bt},ie.createElement(yb,{title:Ho.t("Insufficient account balance"),type:"error",description:ie.createElement(gb,{messages:T??[]})},ie.createElement(Mf,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:Xe},Ho.t("Proceed anyway")))),y&&ie.createElement(wf,null,ie.createElement("div",{className:vf()},ie.createElement($l,{chain:y,quoteChains:x,isSelected:te,selectWallet:le,onShowMore:()=>S(y),onConnect:$=>{ee(y,$)}}))),!y&&ie.createElement(ie.Fragment,null,w&&ie.createElement(ie.Fragment,null,ie.createElement(fb,{id:"widget-confirm-wallet-modal-error-alert",variant:"alarm",type:"error",title:Ho.t(w)}),ie.createElement(Fl,{size:12})),ie.createElement(xf,null,x.map(($,z)=>{let V=c.find(j=>j.name===$),pe=`wallet-${z}`,Q=z===x.length-1,X=Q&&B&&g?.customDestination!==!1;return ie.createElement("div",{key:pe},ie.createElement(yf,null,ie.createElement(Ol,{variant:"title",size:"xmedium"},Ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:V?.shortName}})),ie.createElement(Ol,{variant:"label",color:"$neutral700",size:"medium"},Ho.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:V?.shortName}}))),ie.createElement(Fl,{size:24}),ie.createElement(Sf,null,ie.createElement($l,{chain:$,quoteChains:x,isSelected:te,selectWallet:le,limit:Tb,onShowMore:()=>S(V?.name??""),onConnect:j=>{ee($,j)}})),!Q&&ie.createElement(Fl,{size:32}),X&&ie.createElement(hf,{blockchain:B,open:N,handleOpenChange:je}))}))))}i(_f,"ConfirmWalletsModal");import{i18n as Kb}from"@lingui/core";import{Alert as jb,Button as Xb,Divider as tg,InfoIcon as Yb}from"@rango-dev/ui";import Oe from"react";import{Alert as bb,Button as xb,Divider as Hl,NoRouteIcon as Eb,RefreshIcon as Ib,Typography as Hf}from"@rango-dev/ui";import dt from"react";import{i18n as Df}from"@lingui/core";var wb=24,vb=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 Ul=(o=>(o[o.small=wb]="small",o[o.large=vb]="large",o))(Ul||{}),zl=(o=>(o.small="small",o.large="medium",o))(zl||{});import{styled as Ri}from"@rango-dev/ui";var Ff=Ri("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Of=Ri("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Uf=Ri("div",{variants:{size:{small:{width:"100%"},large:{}}}}),zf=Ri("div",{padding:"$6 $0"});function Cr(t){let{fetch:e,error:o,size:n="small",skipAlerts:r}=t,a=k().getDisabledLiquiditySources(),s=k().toggleAllLiquiditySources,c=k().swappers(),l=$f(o,a,()=>s(c,!0),e);return r&&(l.alert=null),dt.createElement(Ff,{id:"widget-no-result-container"},dt.createElement(Eb,{size:Ul[n],color:"gray"}),dt.createElement(Hl,{size:4}),dt.createElement(Hf,{variant:"title",size:zl[n]},re().noResultError.title),n==="large"&&dt.createElement(Hl,{size:4}),!!l.description&&dt.createElement(Of,{size:n},dt.createElement(Hf,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),dt.createElement(Hl,{size:n==="large"?"24":"4"}),!!l.alert&&dt.createElement(Uf,{size:n},dt.createElement(bb,{id:"widget-no-result-alert",type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&dt.createElement(xb,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:dt.createElement(zf,null,dt.createElement(Ib,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(Cr,"NoResult");import{i18n as kr}from"@lingui/core";import{Button as _b,Divider as Db,MessageBox as $b,Typography as Fb,WarningIcon as Ob}from"@rango-dev/ui";import Yt from"react";import{InfoIcon as Bb,Tooltip as Lb,Typography as Mb}from"@rango-dev/ui";import An from"react";import{Button as Ab,darkTheme as Nb,styled as Qo,Typography as Wb}from"@rango-dev/ui";var Qf=Qo("div",{width:"100%"}),Ql=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",[`.${Nb} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Gf=Qo("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$2"}),Vf=Qo(Wb,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"250px"}),Kf=Qo("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"}),jf=Qo(Ab,{"& ._text":{gap:"$5",display:"flex",alignItems:"center",justifyContent:"center"}});var Pb=35;function Xf(t){let{title:e,value:o,valueColor:n}=t,r=W();return An.createElement(qf,null,An.createElement(Mb,{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>Pb&&An.createElement(Lb,{content:o,container:r},An.createElement(Bb,{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:kr.t("Swapping"),value:P(r.inputUsdValue)},{title:kr.t("Gas cost"),value:P(r.totalFee,2,2)},{title:kr.t("Receiving"),value:P(r.outputUsdValue)},{title:kr.t("Price impact"),value:P(r.priceImpact,2,2),valueColor:`${s}500`}];return Yt.createElement(R,{id:"widget-high-value-loss-warning-modal",footer:Yt.createElement(_b,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Yt.createElement(Ob,null),fullWidth:!0,disabled:a,onClick:n},re().highValueLossError.confirmMessage),open:e,onClose:o,container:W()},Yt.createElement($b,{type:s,title:re().highValueLossError.impactTitle,description:re().highValueLossError.description}),Yt.createElement(Ql,null,Yt.createElement(Db,{size:"4"}),Yt.createElement(Fb,{size:"small",variant:"title"},kr.t("Details")),Yt.createElement(Ql,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 Wn}from"@lingui/core";import{Button as Ub,Divider as ql,MessageBox as zb,WarningIcon as Hb}from"@rango-dev/ui";import Co from"react";import{useNavigate as Qb}from"react-router-dom";function Rf(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=Qb();return Co.createElement(R,{id:"widget-slippage-warning-modal",anchor:"bottom",open:e,container:W(),onClose:o},Co.createElement(zb,{type:"warning",title:r.type===3?Wn.t("High slippage"):Wn.t("Low slippage"),description:r.type===3?Wn.t("Caution, your slippage is high. Your trade may be front run."):Wn.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:r.minRequiredSlippage}})},Co.createElement(ql,{size:18}),Co.createElement(ql,{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(Hb,{color:"white",size:16}),Wn.t("Swap anyway")),Co.createElement(ql,{size:10}),Co.createElement(Ub,{id:"widget-slippage-warning-modal-change-slippage-btn",size:"large",type:"primary",variant:"outlined",fullWidth:!0,disabled:a,onClick:()=>s("../"+F.settings)},Wn.t("Change Slippage"))))}i(Rf,"SlippageWarningModal");import{Button as qb,MessageBox as Gb,WarningIcon as Vb}from"@rango-dev/ui";import ea from"react";function eg(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return ea.createElement(R,{id:"widget-unknown-price-warning-modal",footer:ea.createElement(qb,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:ea.createElement(Vb,null),fullWidth:!0,disabled:r,onClick:n},re().unknownPriceError.confirmMessage),open:e,onClose:o,container:W()},ea.createElement(Gb,{type:"warning",title:re().unknownPriceError.impactTitle,description:re().unknownPriceError.description}))}i(eg,"UnknownPriceWarningModal");function Tr(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 C=!!m&&!s,y=i(S=>{if(S==="change-slippage"){let T=o?.type===3||o?.type===4?o:null,v=Jf(e,T);f?.(v)}else S==="change-settings"&&d()},"onclickActionButton");return Oe.createElement(Oe.Fragment,null,g&&Oe.createElement(Oe.Fragment,null,Oe.createElement(tg,{size:10}),Oe.createElement(Cr,{skipAlerts:s,error:o,fetch:c})),C&&Oe.createElement(Qf,null,Oe.createElement(tg,{size:10}),Oe.createElement(jb,{id:"widget-quote-warning-and-errors-alert",title:m.title,type:m.alertType,variant:"alarm",...m.action==="show-info"&&{action:Oe.createElement(Kf,{onClick:l},Oe.createElement(Yb,{size:12,color:"gray"}))},...(m.action==="change-settings"||m.action==="change-slippage")&&{action:Oe.createElement(Xb,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:m.alertType,onClick:()=>y(m.action)},m.actionButtonTitle||Kb.t("Change"))}})),e&&Oe.createElement(Oe.Fragment,null,e.type===0&&Oe.createElement(Yf,{...h,warning:e}),(e.type===3||e.type===2)&&Oe.createElement(Rf,{...h,warning:e}),e.type===1&&Oe.createElement(eg,{...h,warning:e})))}i(Tr,"QuoteWarningsAndErrors");import wx from"bignumber.js";import ga from"react";import{i18n as qo}from"@lingui/core";import{Alert as ux,Divider as Ln,FullExpandedQuote as dx,InfoIcon as tc,NumericTooltip as oc,QuoteTag as mx,StepDetails as fx,TokenAmount as gx,Typography as Mn,useIsTruncated as nc}from"@rango-dev/ui";import rc from"bignumber.js";import O,{useRef as da,useState as hx}from"react";import{styled as Gl}from"@rango-dev/ui";var Vl=Gl("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),og=Gl("div",{paddingBottom:"$15","& .from-amount-text":{wordBreak:"break-word"},variants:{dense:{true:{paddingBottom:0}}}}),ng=Gl("div",{width:"100%",display:"flex"});import*as ta from"@radix-ui/react-collapsible";import{Button as Zb,css as oa,darkTheme as De,Image as rg,styled as Ke,Typography as Kl}from"@rango-dev/ui";var Jb=300,ig=Ke(ta.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${De} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),ag=oa({padding:"$10 $15"}),sg=Ke(Zb,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${De} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${De} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${De} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),lg=Ke("div",{borderRadius:"$xm",display:"flex",flexDirection:"column",alignItems:"start",justifyContent:"space-between",color:"$foreground",boxSizing:"border-box",position:"relative",variants:{selected:{true:{},false:{$$color:"$colors$neutral200",[`.${De} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${De} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${De} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${De} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${De} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${De} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${De} &`]:{backgroundColor:"$neutral400"}}}}]}),cg=oa({width:"100%",padding:"$15 $15 $10 $15"}),pg=oa({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Bn=oa({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),ug=Ke(ta.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",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${De} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${De} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),dg=Ke("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=Ke(Ki,{width:"100%",background:"inherit"}),jl=Ke("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${Jb}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),PQ=Ke("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),fg=Ke("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${De} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),gg=Ke("div",{display:"flex",flexDirection:"row",alignItems:"center",gap:"$2",flex:"1 1 auto",minWidth:0}),Xl=Ke(Kl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"$30"}),Yl=Ke(Kl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,flex:"0 1 auto"}),Zl=Ke("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=Ke("div",{display:"flex"}),na=Ke("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${De} &`]:{borderTopColor:"$neutral800"}}),yg=Ke(Kl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",minWidth:0,flexShrink:3});import{i18n as $t}from"@lingui/core";import{ChevronDownIcon as ex,CloseIcon as tx,Divider as aa,IconButton as ox,NumericTooltip as nx,QuoteCost as rx,Typography as Et}from"@rango-dev/ui";import Z,{useState as Tg}from"react";import{css as Rb,styled as ra}from"@rango-dev/ui";var ia=ra("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Jl=ra("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),Sg=ra("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),Cg=ra("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),kg=Rb({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var ix=i(t=>t.fee.isZero()?null:Z.createElement(ia,null,Z.createElement(Et,{variant:"label",size:"medium",color:"neutral600"},t.label),Z.createElement(Et,{variant:"label",size:"medium"},"$",P(t.fee,4,4))),"NonPayableFee");function Rl(t){let[e,o]=Tg(!1),[n,r]=Tg(!1),{steps:a,quote:s,fee:c,time:l,feeWarning:p,timeWarning:u,showModalFee:d,fullExpandedMode:f=!1}=t,h=s?.swaps??[],g=f?Bo():W(),m=Vd(h),C=P(c,2,2);return Z.createElement(Z.Fragment,null,Z.createElement(rx,{onClickFee:d?y=>{y.stopPropagation(),o(!e)}:void 0,fee:C,feeWarning:p,timeWarning:u,time:l,steps:a,tooltipGas:d?$t.t("View more info"):void 0,tooltipContainer:g}),Z.createElement(R,{id:"widget-quote-cost-explanation-modal",container:g,open:e,anchor:f?"center":"bottom",styles:{container:{maxWidth:f?"484px":"unset"}},header:Z.createElement(Cg,{style:{textAlign:f?"left":"center"}},Z.createElement(Et,{variant:"title",size:"medium"},$t.t("Gas & Fee Explanation")),Z.createElement(ox,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Z.createElement(tx,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Z.createElement(Sg,null,Z.createElement(Et,{variant:"title",size:"small"},$t.t("Details")),Z.createElement(aa,{size:10}),Object.entries(m.payable).flatMap(([y,S])=>S.map((T,v)=>{let w=`payable-fee-${v}`,A=Xs(T);return Z.createElement(ia,{key:w},Z.createElement(Et,{variant:"label",size:"medium",color:"neutral600"},qs(y,$t.t)),Z.createElement(nx,{content:T.amount,container:g},Z.createElement(Et,{variant:"label",size:"medium"},P(T.amount,2,2),T.asset.symbol," ($",P(A,4,4),")")))})),Z.createElement(ia,{className:"total_payable_fee"},Z.createElement(Et,{variant:"label",size:"medium"},$t.t("Total Payable Fee")),Z.createElement(Et,{variant:"label",size:"medium"},"$",P(c,4,4))),Z.createElement(Jl,null),!!Object.keys(m.nonePayable).length&&Z.createElement(Yi,{triggerAnchor:"bottom",onClickTrigger:()=>r(y=>!y),trigger:Z.createElement("div",{className:kg()},Z.createElement(Et,{size:"small",variant:"body",color:"neutral700"},n?$t.t("Hide non-payable fees"):$t.t("Show non-payable fees")),Z.createElement(aa,{size:4,direction:"horizontal"}),Z.createElement(ji,{orientation:n?"up":"down"},Z.createElement(ex,{size:12,color:"gray"}))),open:n},Z.createElement(Et,{size:"small",variant:"title"},$t.t("Description")),Z.createElement(aa,{size:4}),Z.createElement(Et,{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.`)),Z.createElement(aa,{size:10}),Object.entries(m.nonePayable).map(([y,S],T)=>{let v=Gd(S),w=qs(y,$t.t),A=`non-payable-fee-${T}`;return Z.createElement(ix,{key:A,fee:v,label:w})}),Z.createElement(Jl,null)))))}i(Rl,"QuoteCostDetails");import{i18n as bg}from"@lingui/core";import{TokenAmount as xg}from"@rango-dev/ui";import sa from"react";import{css as ax,styled as sx}from"@rango-dev/ui";var wg=sx("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),vg=ax({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function wr(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return sa.createElement(wg,null,sa.createElement(xg,{direction:"horizontal",label:bg.t("Swap input"),id:"widget-quote-summary-swap-input",type:"input",tooltipContainer:W(),price:{value:e.price.value,usdValue:e.price.usdValue,realValue:e.price.realValue,realUsdValue:e.price.realUsdValue},token:{displayName:e.token.displayName,image:e.token.image},chain:{image:e.chain.image}}),sa.createElement("div",{className:vg()}),sa.createElement(xg,{id:"widget-quote-summary-estimated-input",direction:"horizontal",tooltipContainer:W(),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(wr,"QuoteSummary");import{i18n as Eg}from"@lingui/core";import{ChevronDownIcon as lx,ChevronRightIcon as cx,Divider as ec,Image as px,Tooltip as ua,Typography as la}from"@rango-dev/ui";import q from"react";var ca=4,pa=6,vr=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,c=s||W();return q.createElement(ua,{container:c,side:"bottom",sideOffset:4,open:r,content:e},q.createElement(dg,{className:n,state:a},q.createElement(px,{src:o,size:16})))},"ImageComponent");function Ig(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:c}=t,l=c||W(),p=r.length,u=_d(r),{isTablet:d,isMobile:f}=wn();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:Bn()},q.createElement(la,{variant:"body",size:"xsmall"},Eg.t("Via:")),q.createElement(ec,{direction:"horizontal",size:4}),r.map((h,g)=>{let m=`item-${g}`,C=q.createElement(jl,null,q.createElement(cx,{size:12,color:"black"}));return f||d?q.createElement(q.Fragment,{key:m},q.createElement(vr,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&q.createElement(q.Fragment,null,C)):q.createElement(q.Fragment,{key:m},p<=ca||p>ca&&g<ca-1?q.createElement(q.Fragment,null,q.createElement(vr,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&q.createElement(q.Fragment,null,C)):g===ca-1&&q.createElement(ua,{container:l,side:"bottom",align:"end",sideOffset:4,content:q.createElement("div",{className:Bn()},C,r.map((y,S)=>{let T=`image-${S}`;return S>=g&&q.createElement(q.Fragment,{key:T},q.createElement(vr,{content:y.swapper.displayName,src:y.swapper.image??"",state:y.state,open:!1}),S!==p-1&&q.createElement(q.Fragment,null,C))}))},q.createElement(Zl,{state:r.find((y,S)=>S>=g&&(y.state==="error"||y.state==="warning"))?.state},q.createElement(la,{size:"xsmall",variant:"body"},"+",p-g))))})),q.createElement("div",{className:Bn()},q.createElement("div",{className:"blockchains_section"},q.createElement("div",{className:Bn()},q.createElement(la,{variant:"body",size:"xsmall"},Eg.t("Chains:")),q.createElement(ec,{direction:"horizontal",size:4}),u.map((h,g)=>q.createElement(q.Fragment,{key:h.displayName},u.length<=pa||u.length>pa&&g<pa-1?q.createElement(ua,{container:l,side:"bottom",content:h.displayName,sideOffset:4},q.createElement(vr,{content:"",src:h.image??"",open:!1,className:g!==0?"blockchainImage":""})):g===pa-1&&q.createElement(ua,{container:l,side:"bottom",align:"end",sideOffset:4,content:q.createElement("div",{className:Bn()},u.map((m,C)=>C>=g&&q.createElement(vr,{key:m.displayName,content:"",src:m.image??"",open:!1,className:C>g?"blockchainImage":"",container:c})))},q.createElement(Zl,{className:"blockchainImage"},q.createElement(la,{size:"xsmall",variant:"body"},"+",u.length-g))))),q.createElement(ec,{direction:"horizontal",size:32}))),q.createElement(jl,{orientation:a?"up":"down"},q.createElement(lx,{size:12,color:"black"}))))}i(Ig,"QuoteTrigger");function ic(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=k().blockchains(),{findToken:g}=k(),m=k().swappers(),{customSlippage:C,slippage:y}=k(),S=C||y,[T,v]=hx(t.expanded),w=da(null),A=P(n.value,6,6),N=n.usdValue?P(n.usdValue,4,4):"",b=jt(o.usdValue,n.usdValue??null),x=P(b,2,2),E=Xt(b??0),B=i((Q,X)=>Q.map((j,Ie)=>{let Ae,Ye=r?.type===3&&r.swap.swapperId===j.swapperId,Lt=r?.type===4&&!!r.recommendedSlippages?.[Ie],so=a?.type===2&&!!a.recommendedSlippages?.[Ie],Io=Ye||Lt,zn=so;Io?Ae="error":zn&&(Ae="warning");let Rr=Io?qo.t("Slippage Error"):qo.t("Slippage Warning");return Ye&&(Rr=qo.t("Bridge Limit Error")),{swapper:{displayName:Qn(j.swapperId,m)??"",image:j.swapperLogo},from:{token:{displayName:j.from.symbol,image:j.from.logo},chain:{displayName:yt(j.from.blockchain,h)??"",image:j.from.blockchainLogo},price:{value:Ie===0&&!X?P(o.value,6,6):P(j.fromAmount,6,6),usdValue:P((j.from.usdPrice??0)*parseFloat(j.fromAmount),4,4),realValue:Ie===0?o.value:j.fromAmount,realUsdValue:new rc(j.from.usdPrice??0).multipliedBy(j.fromAmount).toString()}},to:{token:{displayName:j.to.symbol,image:j.to.logo},chain:{displayName:yt(j.to.blockchain,h)||"",image:j.to.blockchainLogo},price:{value:P(j.toAmount,6,6),usdValue:P((j.to.usdPrice??0)*parseFloat(j.toAmount),4,4),realValue:j.toAmount,realUsdValue:new rc(j.to.usdPrice??0).multipliedBy(j.toAmount).toString()}},state:Ae,alerts:Io||zn?O.createElement(og,{dense:d},O.createElement(ux,{variant:"alarm",type:Io?"error":"warning",title:Rr,id:"widget-quote-footer-step-alarm-alert",footer:O.createElement(ng,null,Ye&&O.createElement("div",null,O.createElement(Mn,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),O.createElement(Ln,{direction:"vertical",size:2}),O.createElement(Mn,{size:"xsmall",variant:"body",className:"from-amount-text",color:"neutral900"},qo.t({id:"Yours: {amount} {symbol}",values:{amount:P(j.fromAmount,6,6),symbol:j?.from.symbol}}))),(Lt||so)&&!Ye&&O.createElement("div",null,O.createElement(Mn,{size:"xsmall",variant:"body",color:"neutral900"},qo.t({id:"Minimum suggested slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.[Ie]},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.[Ie]}}})),O.createElement(Ln,{direction:"vertical",size:2}),O.createElement(Mn,{size:"xsmall",variant:"body",color:"neutral900"},qo.t({id:"Yours: {userSlippage}",values:{userSlippage:S}}))))})):void 0,time:Gn(j.estimatedTimeInSeconds),fee:P(js(j,g),2,2),internalSwaps:j.internalSwaps?B(j.internalSwaps):void 0}}),"getQuoteSteps"),I=B(e?.swaps??[]),_=I.length,U=f||W(),G=$d(t.quote.tags||[]),Y=!!u,L=ci(e?.swaps),ee=Gn(L),J=Li(e?.swaps??[],g),te=P(J,2,2),se=J.gte(new rc(Id)),je=L/Nd>=Ad,le=da(null),Xe=nc(o.value,le),He=da(null),Bt=nc(n.value,He),$=da(null),z=nc(N,$),V=I[_-1],pe=I[0];return!pe||!V?null:d?O.createElement(dx,{selected:c,fee:te,time:ee,tooltipContainer:Bo(),steps:I,tags:G,id:"widget-quote-full-expanded-quote-container",quoteCost:O.createElement(Rl,{quote:e,fullExpandedMode:!0,time:ee,fee:J,feeWarning:se,timeWarning:je,showModalFee:p,steps:_}),percentageChange:x,warningLevel:E,outputPrice:{value:A,usdValue:N,realValue:n.value,realUsdValue:n.usdValue}}):O.createElement(lg,{id:"widget-quote-summary-container",selected:c,listItem:s==="list-item",basic:s==="basic"},O.createElement("div",{className:cg()},!l&&G.length?O.createElement(O.Fragment,null,O.createElement(hg,null,G.map((Q,X)=>{let j=`${Q.value}_${X}`;return O.createElement(O.Fragment,{key:j},O.createElement(mx,{label:Q.label,value:Q.value}),O.createElement(Ln,{size:4,direction:"horizontal"}))})),O.createElement(na,null),!Y&&O.createElement(Ln,{size:4})):null,O.createElement("div",{id:"portal-root",className:pg()},O.createElement(Rl,{quote:e,time:ee,fee:J,feeWarning:se,timeWarning:je,showModalFee:p,steps:_}),Y&&O.createElement(sg,{onClick:Q=>{Q.stopPropagation(),u()},id:"widget-quote-all-routes-btn",size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},O.createElement(Mn,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},qo.t("See All Routes")))),s==="basic"&&O.createElement(gg,null,O.createElement(Yl,{ref:le,size:"small",variant:"body"},o.value),Xe&&O.createElement(oc,{content:o.value,container:U,open:o.value?void 0:!1},O.createElement(tc,{size:12,color:"gray"})),O.createElement(Xl,{size:"small",variant:"body"},I[0]?.from.token.displayName),O.createElement(Mn,{size:"small",variant:"body"},"="),O.createElement(Yl,{ref:He,size:"small",variant:"body"},n.value),Bt&&O.createElement(oc,{content:n.value,container:U,open:n.value?void 0:!1},O.createElement(tc,{size:12,color:"gray"})),O.createElement(Xl,{size:"small",variant:"body"},V?.to.token.displayName),O.createElement(Ln,{size:2,direction:"horizontal"}),O.createElement(yg,{ref:$,color:"$neutral600",size:"xsmall",variant:"body"},`($${N})`),z&&O.createElement(oc,{content:n.usdValue,container:U},O.createElement(tc,{size:12,color:"gray"}))),s==="list-item"&&O.createElement(gx,{id:"widget-quote-token-amount-container",tooltipContainer:U,type:"output",direction:"vertical",price:{value:A,usdValue:N,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:V.to.token.displayName,image:V.to.token.image},chain:{image:V.to.chain.image},percentageChange:x,warningLevel:E}),s==="swap-preview"&&O.createElement(O.Fragment,null,O.createElement(wr,{from:pe.from,to:V.to,percentageChange:x,warningLevel:E}),O.createElement(Ln,{size:4}))),O.createElement(ig,{selected:c,listItem:s==="list-item",open:T,className:"quote_container",onOpenChange:v},O.createElement(Ig,{type:s,quoteRef:w,selected:c,setExpanded:v,container:U,expanded:T,steps:I}),O.createElement(mg,{open:T},O.createElement(fg,null),O.createElement("div",{className:ag()},I.map((Q,X)=>{let j=`item-${X}`;return O.createElement(fx,{type:"quote-details",className:"widget-quote-step-details-container",key:j,tooltipContainer:U,step:Q,hasSeparator:X!==I.length-1,state:Q.state})})))))}i(ic,"Quote");import{Divider as kx,Skeleton as Tx}from"@rango-dev/ui";import eo from"react";import{darkTheme as yx,styled as ma}from"@rango-dev/ui";var Ag=ma("div",{$$color:"$colors$neutral100",[`.${yx} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Ng=ma("div",{paddingTop:"$2"}),Wg=ma("div",{paddingLeft:"$8"}),Bg=ma("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as zg,Divider as It,Skeleton as mt}from"@rango-dev/ui";import K from"react";import{css as Sx,styled as Rt}from"@rango-dev/ui";var ac=Rt("div",{display:"flex"}),Lg=Rt("div",{padding:"$10 $0 $20"}),Mg=Rt("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Pg=Rt("div",{display:"flex",justifyContent:"start",alignItems:"center"}),_g=Rt("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Dg=Rt("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),$g=Rt("div",{width:"65%",display:"flex",justifyContent:"start"}),Fg=Rt("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Og=Rt("div",{padding:"$15 $0 $15 $0"}),Ug=Sx({display:"flex",justifyContent:"space-between",alignItems:"center"});function br(t){let{type:e,tagHidden:o=!0}=t,n=K.createElement(_g,null,K.createElement($g,null,K.createElement(zg,{loading:!0,size:"medium"}),K.createElement(It,{size:8,direction:"horizontal"}),K.createElement(Fg,null,K.createElement(mt,{height:10,width:60,variant:"rounded"}),K.createElement(It,{size:4}),K.createElement(mt,{height:15,variant:"rounded"}))),K.createElement(mt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return K.createElement("div",null,!o&&K.createElement(K.Fragment,null,K.createElement(ac,null,K.createElement(mt,{width:65,height:20,variant:"rounded"}),K.createElement(It,{size:4,direction:"horizontal"}),K.createElement(mt,{width:65,height:20,variant:"rounded"}),K.createElement(It,{size:4,direction:"horizontal"}),K.createElement(mt,{width:65,height:20,variant:"rounded"})),K.createElement(na,null),!r&&K.createElement(It,{size:4})),K.createElement("div",{className:Ug()},K.createElement(ac,null,K.createElement(mt,{width:60,height:10,variant:"rounded"}),K.createElement(It,{size:4,direction:"horizontal"}),K.createElement(mt,{width:60,height:10,variant:"rounded"}),K.createElement(It,{size:4,direction:"horizontal"}),K.createElement(mt,{width:60,height:10,variant:"rounded"})),r&&K.createElement(mt,{width:85,height:24,variant:"rounded"})),e==="basic"&&K.createElement(Lg,null,K.createElement(mt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&K.createElement(Mg,null,K.createElement(Pg,null,K.createElement(zg,{loading:!0,size:"medium"}),K.createElement(It,{direction:"horizontal",size:4}),K.createElement(mt,{height:15,width:150,variant:"rounded"})),K.createElement(It,{size:10}),K.createElement(mt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&K.createElement(K.Fragment,null,K.createElement(It,{size:4}),K.createElement(Og,null,n,K.createElement(Dg,null),n),K.createElement(It,{size:12})))}i(br,"QuoteSummarySkeleton");import{ChainToken as Vg,Divider as lc,NextIcon as Cx,Skeleton as fa}from"@rango-dev/ui";import Le from"react";import{styled as xr}from"@rango-dev/ui";var Hg=xr("div",{display:"flex",alignItems:"start"}),Qg=xr("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),sc=xr("div",{display:"flex",alignItems:"center",flexGrow:1}),qg=xr("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Gg=xr("div",{display:"flex",alignItems:"center"});function Ft(t){let{separator:e=!0}=t;return Le.createElement(Le.Fragment,null,Le.createElement(Gg,null,Le.createElement(fa,{height:22,width:22,variant:"circular"}),Le.createElement(lc,{direction:"horizontal",size:8}),Le.createElement(fa,{height:15,width:148,variant:"rounded"})),Le.createElement(Hg,null,Le.createElement(Bg,{hideSeparator:!e}),Le.createElement(Qg,{extraSpace:e},Le.createElement(sc,null,Le.createElement(Vg,{size:"small",loading:!0}),Le.createElement(lc,{direction:"horizontal",size:8}),Le.createElement(fa,{height:12,variant:"rounded"})),Le.createElement(qg,null,Le.createElement(Cx,{color:"gray",size:16})),Le.createElement(sc,null,Le.createElement(Vg,{size:"small",loading:!0}),Le.createElement(lc,{direction:"horizontal",size:8}),Le.createElement(fa,{height:12,variant:"rounded"})))))}i(Ft,"StepSkeleton");function Er(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return eo.createElement(Ag,{expanded:o,rounded:e!=="basic"},eo.createElement(br,{type:e,tagHidden:n}),eo.createElement(Ng,null,eo.createElement(Tx,{height:15,variant:"rounded"})),o&&eo.createElement(Wg,null,eo.createElement(kx,{size:24}),eo.createElement(Ft,null),eo.createElement(Ft,null),eo.createElement(Ft,{separator:!1})))}i(Er,"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:C}=H()(),y=e?.outputAmount?new wx(e?.outputAmount):null,S=e?Ct(e):null,v=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?ga.createElement(Vl,null,ga.createElement(Er,{tagHidden:c,type:o,expanded:s})):v?ga.createElement(Vl,{onClick:()=>l?.(e),id:d},ga.createElement(ic,{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:C?.toString()??""},output:{value:y?.toString()??"",usdValue:S?.toString()??""}})):null}i(Go,"QuoteInfo");import{warn as Ex}from"@rango-dev/logging-core";import{calculatePendingSwap as Ix}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Ax}from"react";import{useRef as vx,useState as bx}from"react";var xx=2e3;function ha({request:t}){let[e,o]=bx(!1),n=vx(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async c=>(await new Promise(l=>setTimeout(l,xx)),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(ha,"useFetch");function Kg(){let{fetch:t,loading:e,cancelFetch:o}=ha({request:async(n,r)=>await ut().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Kg,"useFetchConfirmQuote");function ya(t){if(!t.swaps)throw new Error(re().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=cc(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(ya,"throwErrorIfResponseIsNotValid");function cc(t){if(Hd(t)){let{swap:n,fromAmountRangeError:r,recommendation:a}=Qd(t);return n?{message:"bridge limit error",options:{type:3,swap:n,recommendation:a,fromAmountRangeError:r}}:null}let o=Kd(t);if(o){let n=Mi(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(cc,"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=Yd(e,r,n.blockchains);return p.length===0||(c.balance={messages:p}),c}i(jg,"generateWarnings");function Sa(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(Sa,"handleQuoteErrors");function pc(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:c}=H()(),{slippage:l,customSlippage:p}=k(),u=k().getDisabledLiquiditySources(),d=k().blockchains(),f=k().tokens(),{findToken:h}=k(),{swapMode:g}=rt(),m=p||l,{fetch:C,cancelFetch:y,loading:S}=Kg();return Ax(()=>y,[]),{loading:S,fetch:i(async v=>{let w=v.selectedWallets,A=v?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let N=w.reduce((x,E)=>(x[E.chain]=E.address,x),{}),b={requestId:a?.requestId||"",selectedWallets:N,destination:A||void 0};try{return await C(b,!0).then(x=>{let{result:E}=x;if(!E)throw new Error(x.error??"Error fetching updated quote");ya({diagnosisMessages:E.diagnosisMessages,requestId:E.requestId,swaps:E.result?.swaps});let B={outputAmount:E.result?.outputAmount,requestId:E.requestId,resultType:E.result?.resultType,swaps:E.result?.swaps||[],validationStatus:E.validationStatus,requestAmount:E.requestAmount};r(B);let I={slippage:m.toString(),disabledSwappersGroups:u},_=jg({previousQuote:a??void 0,currentQuote:B,meta:{blockchains:d},selectedWallets:w,userSlippage:m,inputUsdValue:n,findToken:h});c();let U=!!_.balance,G=Ix({inputAmount:o.toString(),bestRoute:E,wallets:Xd(w),settings:I,validateBalanceOrFee:!U,meta:{blockchains:d,tokens:f},swapMode:g});return{quote:B,swap:G,error:null,warnings:_}})}catch(x){let E=Sa(x);return E.type!==2&&Ex(new Error("confirm swap error"),{tags:{...E,type:Re[E.type],initialQuote:a,requestBody:b}}),{swap:null,error:E,warnings:null}}},"fetch"),cancelFetch:y}}i(pc,"useConfirmSwap");var Fx=Lx("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Xg}`]:{width:"$48",height:"$48"}}),Ox=mc({flexGrow:1,paddingRight:"$10"}),Ux=mc({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),zx=mc({display:"flex",justifyContent:"space-between",alignItems:"center"});function Yg(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=H()(),s=$x(),[c,l]=Ir(""),p=!n,[u,d]=Ir(!1),[f,h]=Ir(!1),{isActiveTab:g}=ne(),m=k().getDisabledLiquiditySources(),C=Dx(m),{manager:y}=Nx(),{fetch:S,loading:T,cancelFetch:v}=pc(),[w,A]=Ir({swap:null,error:null,warnings:null}),[N,b]=Ir(!1),x=i(async({selectedWallets:L,customDestination:ee})=>{let J=await S?.({selectedWallets:L,customDestination:ee});return A(J),J},"onConfirmSwap"),E=i(async()=>{if(w.swap&&n)try{await y?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let L=`../${F.swaps}/${w.swap.requestId}`;s(L,{replace:!0}),setTimeout(()=>{e("")},0)}catch(L){l("Error: "+L?.message)}},"addNewSwap"),B=i(async()=>{h(!0),await E(),h(!1)},"onConfirm"),I=i(async()=>{w.warnings?.quote&&Pd(w.warnings.quote)&&!a?b(!0):await B()},"onStartConfirmSwap"),_=i(async()=>{A({error:null,swap:null,warnings:null}),S({selectedWallets:o,customDestination:r}).then(L=>{A(L)}).catch(L=>console.error(L))},"onRefresh");Ca(()=>{!!C.current.length&&!m.length&&_(),C.current=m},[m.length]),Ca(()=>{p&&v()},[p]),Ca(()=>{p&&d(p)},[p]),Ca(()=>{p||S({selectedWallets:o,customDestination:r}).then(L=>A(L)).catch(L=>console.error(L))},[]),_x(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let U=w.warnings?.quote??null,G=w.error,Y=[];if(c&&Y.push($e.createElement(Wx,{id:"widget-confirm-swap-db-error-alert",type:"error",variant:"alarm",title:c})),U||G){let L=`../${F.settings}`;Y.push($e.createElement(Tr,{warning:U,error:G,couldChangeSettings:!1,refetchQuote:_,skipAlerts:G?.type===4||U?.type===2,showWarningModal:N,confirmationDisabled:!g,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:async()=>{b(!1),await E()},onChangeSettings:()=>s(L)}))}return $e.createElement(ae,{header:{title:uc.t("Confirm Swap"),onWallet:()=>{let L=`../${F.wallets}`;s(L)}},footer:$e.createElement(Fx,null,$e.createElement("div",{className:Ox()},$e.createElement(Bx,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:T||f,disabled:!!w.error||!g,onClick:I},uc.t("Start Swap"))),$e.createElement(Xg,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:T||f,disabled:!g,onClick:d.bind(null,!0)},$e.createElement(Px,{size:24})))},u&&$e.createElement(_f,{open:u,onClose:()=>d(!1),onCancel:v,loading:T,onCheckBalance:x}),$e.createElement(ue,null,$e.createElement("div",{className:zx()},$e.createElement(Mx,{variant:"title",size:"small"},uc.t("You get")),$e.createElement("div",{className:Ux()},$e.createElement(Ui,{onClick:!T&&!u&&!N?_:void 0}))),$e.createElement(dc,{size:"12"}),Bm(Y.map((L,ee)=>({element:L,key:`alert-${ee}`})),$e.createElement(dc,{size:10})),Y.length>0?$e.createElement(dc,{size:10}):null,$e.createElement(Go,{quote:t,type:"swap-preview",id:"widget-confirm-swap-quote-container",expanded:!0,tagHidden:!0,error:w.error,loading:T,warning:w.warnings?.quote??null})))}i(Yg,"ConfirmSwapPage");import{i18n as oo}from"@lingui/core";import{Button as xc,CustomTokensZeroStateDarkIcon as sE,CustomTokensZeroStateIcon as lE,DeleteIcon as cE,Divider as Lr,IconButton as pE,MessageBox as uE,NotFound as dE,styled as Ic}from"@rango-dev/ui";import ye,{useState as Ec}from"react";import{useNavigate as mE}from"react-router-dom";import{CloseIcon as Hx,IconButton as Qx,SearchIcon as qx,TextField as Gx}from"@rango-dev/ui";import Pn from"react";import{styled as Zg}from"@rango-dev/ui";var Jg=Zg("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"}),Rg=Zg("div",{width:"100%","& ._text-field":{paddingLeft:"$10","& input":{paddingLeft:"$2",paddingTop:"$12",paddingBottom:"$12"}}});function At(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(Qx,{id:`${u}\u06F0icon-btn`,variant:"ghost",onClick:()=>l?.(""),size:"small"},Pn.createElement(Hx,{color:"gray",size:10})):null;return p&&(f=p),Pn.createElement(Rg,null,Pn.createElement(Gx,{prefix:Pn.createElement(Jg,null,Pn.createElement(qx,{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(At,"SearchInput");import{i18n as bc}from"@lingui/core";import{Button as Xx,CustomTokenWarning as Yx,darkTheme as uh,Divider as to,ExternalLinkIcon as Zx,Image as Jx,ListItem as Rx,NotFound as eE,PinIcon as tE,Skeleton as Vo,Typography as Wr,VirtualizedList as oE}from"@rango-dev/ui";import M,{useState as nE}from"react";import{useTranslation as rE}from"react-i18next";import{Divider as ch,ListItem as jx,Skeleton as Nr}from"@rango-dev/ui";import Nt from"react";import{css as _n,darkTheme as fc,ImageContainer as Vx,ListItemButton as Kx,styled as st,Typography as eh}from"@rango-dev/ui";var gc=_n({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),hc=_n({position:"relative",height:12,width:"30%",maxWidth:"150px"}),yc=_n({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Sc=_n({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${fc} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Cc=_n({}),kc=_n(),th=st("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Tc=st("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),ka=st("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${hc}`]:{[`& .${Sc}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Cc}`]:{bottom:"-15px"},[`& .${gc}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${yc}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),oh=st(Kx,{variants:{customToken:{true:{"&:hover":{cursor:"unset"}}}}}),wc=st("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),vc=st(eh,{}),nh=st("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${kc}`]:{$$color:"$colors$neutral600",[`.${fc} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Ar=st("div",{display:"flex",alignItems:"end",flexDirection:"column"}),NV=st("div",{display:"flex",alignItems:"center"}),rh=st("div",{position:"relative",[`& ${Vx}`]:{borderRadius:"$xm",overflow:"hidden"}}),ih=st("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),ah=st(eh,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),sh=st("a",{"& svg:hover":{color:"$colors$info"}}),lh=st("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":{[`.${fc} &`]:{color:"$foreground"}}}});function ph(t){return Nt.createElement(ka,null,Array.from(Array(t.size),e=>Nt.createElement(jx,{key:e,hasDivider:!0,start:Nt.createElement(Nr,{variant:"circular",width:35,height:35}),end:Nt.createElement(Ar,null,Nt.createElement(Nr,{variant:"text",size:"large",width:70}),Nt.createElement(ch,{size:4}),Nt.createElement(Nr,{variant:"text",size:"medium",width:50})),title:Nt.createElement("div",null,Nt.createElement(Nr,{variant:"text",size:"large",width:90}),Nt.createElement(ch,{size:4}),Nt.createElement(Nr,{variant:"text",size:"medium",width:90}))})))}i(ph,"LoadingTokenList");var iE=20,aE=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,c=e.length;return M.createElement("div",{className:hc()},o?M.createElement("div",{className:gc()},o):M.createElement(Tc,{className:yc()},M.createElement(Wr,{variant:"title",size:"xmedium"},r.symbol),M.createElement(to,{direction:"horizontal",size:4}),M.createElement(wc,{css:a},M.createElement(vc,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&M.createElement("div",{className:`${Sc()} ${!o&&Cc()}`},c>10?`${e.slice(0,5)}...${e.slice(c-6,c)}`:e," ",M.createElement(to,{size:4,direction:"horizontal"}),M.createElement(sh,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:l=>l.stopPropagation()},M.createElement(Zx,{size:12}))))},"renderDesc");function Br(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s,type:c,showWarning:l=!0}=t,p=k().fetchStatus,u=k().blockchains(),{getBalanceFor:d,fetchingWallets:f}=k(),{isTokenPinned:h}=k(),{setFromToken:g,setToToken:m}=H()(),{t:C}=rE(),y=Ge(),[S,T]=nE(null),v=i(()=>{c==="source"?g({token:S,meta:{blockchains:u}}):m({token:S,meta:{blockchains:u}})},"updateToken"),w=i(()=>{v(),y()},"handleImportToken"),A=i(x=>{if(x.customToken){let{customToken:B,...I}=x;return M.createElement(Xx,{variant:"contained",type:"primary",size:"small",className:"widget-token-list-item-import-btn",onClick:i(U=>{U.stopPropagation(),T({...I,warning:!0})},"handleClick")},M.createElement(Wr,{variant:"body",size:"xsmall",color:"background"},C("import")))}let E=mi(d(x));return s?s(x):f?M.createElement(Ar,null,M.createElement(Vo,{variant:"text",size:"large",width:70}),M.createElement(to,{size:4}),M.createElement(Vo,{variant:"text",size:"medium",width:50})):E&&M.createElement(nh,null,M.createElement(ah,{variant:"title",size:"small"},E.amount),M.createElement("div",null),E.usdValue&&M.createElement(Wr,{variant:"body",className:kc(),size:"xsmall"},`$${E.usdValue}`))},"endRenderer"),N=i(()=>M.createElement(oE,{itemContent:x=>{let E=e[x];if(E==="skeleton")return M.createElement(Rx,{hasDivider:!0,start:M.createElement(Vo,{variant:"circular",width:35,height:35}),end:M.createElement(Ar,null,M.createElement(Vo,{variant:"text",size:"large",width:70}),M.createElement(to,{size:4}),M.createElement(Vo,{variant:"text",size:"medium",width:50})),title:M.createElement("div",null,M.createElement(Vo,{variant:"text",size:"large",width:90}),M.createElement(to,{size:4}),M.createElement(Vo,{variant:"text",size:"medium",width:90}))});let B=u.find(L=>L.name===E?.blockchain);if(!B||!E)return null;let I=E.address,_=pl(B.color,"main"),U={$$color:_.main150,[`.${uh} &`]:{$$color:_.main750},backgroundColor:"$$color"},G={$$color:_.main750,[`.${uh} &`]:{$$color:_.main150},color:"$$color"},Y=i(()=>{typeof E!="string"&&!E.customToken&&n?.(E)},"handleClick");return M.createElement(lh,null,M.createElement(oh,{"tab-index":x,key:`${E.symbol}${I}`,id:`${E.symbol}${I}`,className:"widget-token-list-item-btn",hasDivider:!0,customToken:E?.customToken,onClick:Y,start:M.createElement(rh,null,M.createElement(Jx,{src:E.image===""?ni:E.image,size:30}),t.type!=="custom-token"&&E&&h(E,t.type)&&M.createElement(ih,null,M.createElement(tE,{size:12,color:"gray"}))),title:B.type==="COSMOS"||E.name||!E.name&&!I?M.createElement(Tc,null,M.createElement(Wr,{variant:"title",size:"xmedium"},E.symbol),M.createElement(to,{direction:"horizontal",size:4}),M.createElement(wc,{css:U},M.createElement(vc,{variant:"body",size:"xsmall",css:G},E.blockchain)),l&&E.warning&&M.createElement(M.Fragment,null,M.createElement(to,{direction:"horizontal",size:4}),M.createElement(Yx,{container:W()}))):void 0,description:typeof E!="string"&&B.info&&I&&B.type!=="COSMOS"?aE({address:I,token:E,customCssForTag:U,customCssForTagTitle:G,name:E.name,url:B.info.addressUrl.split("{wallet}").join(I)}):E.name||void 0,end:A(E)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList"),b=S?No(S?.blockchain,u):null;return M.createElement(M.Fragment,null,a&&M.createElement(M.Fragment,null,M.createElement(Wr,{variant:"label",size:"large"},bc.t("Select Token")),M.createElement(to,{size:4})),M.createElement(th,null,M.createElement(to,{size:4}),p==="loading"&&M.createElement(ph,{size:iE}),p==="success"&&(e.length?M.createElement(M.Fragment,null,M.createElement(mr,{token:S,address:S?.address??"",blockchain:b??void 0,onImport:w,onExitErrorModal:()=>T(null),onExitImportModal:()=>T(null)}),M.createElement(ka,{as:"ul"},N())):!!o&&M.createElement(eE,{title:bc.t("No results found"),description:bc.t("Try using different keywords")}))))}i(Br,"TokenList");var fE=Ic("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),gE=Ic("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),hE=Ic(pE,{"&:hover":{"& svg":{color:"$secondary550"}}});function dh(){let[t,e]=Ec(""),{deleteCustomToken:o}=k(),n=k().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:c}=H()(),{mode:l}=mo({}),p=mE(),[u,d]=Ec(!1),[f,h]=Ec(),g=i(S=>{let T=S.target.value;e(T)},"handleSearch"),m=l==="dark",C=n.filter(S=>ct(S.symbol,t)||ct(S.address||"",t)||ct(S.name||"",t)),y=i(()=>{if(f){let S=a?St(a):null,T=r?St(r):null,v=St(f);S===v?c({token:null}):T===v&&s({token:null}),o(f)}d(!1)},"handleDeleteCustomToken");return ye.createElement(ae,{header:{title:oo.t("Custom Tokens")}},ye.createElement(ue,null,ye.createElement(fE,null,n.length?ye.createElement(ye.Fragment,null,ye.createElement(At,{id:"widget-custom-tokens-search-token-input",value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:oo.t("Search Token"),onChange:g}),ye.createElement(Lr,{size:16}),ye.createElement(Br,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,showWarning:!1,action:S=>ye.createElement(hE,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{d(!0),h(S)}},ye.createElement(cE,{size:12,color:"gray"}))})):ye.createElement(gE,null,ye.createElement(dE,{icon:m?ye.createElement(sE,{size:200}):ye.createElement(lE,{size:200}),title:oo.t("No custom tokens"),description:oo.t("press the button to add your custom token")})),ye.createElement(Lr,{size:20}),ye.createElement(xc,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p(F.addCustomTokens)},oo.t("Add Custom Token"))),ye.createElement(R,{open:u,id:"widget-custom-tokens-delete-modal",dismissible:!0,onClose:()=>d(!1),container:W()},ye.createElement(uE,{title:oo.t("Delete Custom Token"),type:"error",description:oo.t("Are you sure you want to Delete this Token?")},ye.createElement(Lr,{size:40}),ye.createElement(Lr,{size:10}),ye.createElement(xc,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:y},oo.t("Yes, Delete it")),ye.createElement(Lr,{size:12}),ye.createElement(xc,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>d(!1)},oo.t("No, Continue"))))))}i(dh,"CustomTokensPage");import{i18n as Fe}from"@lingui/core";import{useManager as DE}from"@rango-dev/queue-manager-react";import{Button as Pc,darkTheme as $E,Divider as ko,MessageBox as FE,NotFound as OE,styled as _c,Tabs as UE,Typography as va}from"@rango-dev/ui";import{TransactionStatus as _r}from"rango-types";import oe,{useMemo as Bh,useState as Dr}from"react";import{useNavigate as zE}from"react-router-dom";import{FilterIcon as vE,Popover as bE}from"@rango-dev/ui";import Ko from"react";import{css as yE,darkTheme as Ta,IconButton as SE,styled as Mr}from"@rango-dev/ui";var Ac=Mr("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:""}}}}}),mh=Mr(SE,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${Ta} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Ta} &`]:{backgroundColor:"$neutral"},[`& ${Ac}::before`]:{backgroundColor:"$secondary100",[`.${Ta} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),fh=Mr("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),gh=Mr("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),hh=yE({display:"flex",justifyContent:"space-between",alignItems:"center"}),yh=Mr("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as Sh}from"@lingui/core";import{Button as CE,Divider as Ch,ListItemButton as kE,Radio as TE,RadioRoot as wE,Typography as kh}from"@rango-dev/ui";import ft from"react";function Th(t){let{filterBy:e,onClickItem:o}=t;return ft.createElement(gh,null,ft.createElement("div",{className:hh()},ft.createElement(kh,{size:"small",variant:"body"},Sh.t("Status")),ft.createElement(CE,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},Sh.t("Reset"))),ft.createElement(Ch,{size:10}),ft.createElement(wE,{value:e},ft.createElement(yh,null,t.list.map((n,r)=>ft.createElement(kE,{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:ft.createElement(ft.Fragment,null,ft.createElement(Ch,{direction:"horizontal",size:4}),ft.createElement(kh,{size:"medium",variant:"body"},n.title)),start:ft.createElement(TE,{value:n.id}),onClick:o})))))}i(Th,"FilterSelectorContent");function Nc(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return Ko.createElement("div",null,Ko.createElement(bE,{open:a,align:"end",onOpenChange:o,container:W(),content:Ko.createElement(Th,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},Ko.createElement(mh,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},Ko.createElement(Ac,{isSelect:!!n},Ko.createElement(vE,{size:16,color:"black"}),!!n&&Ko.createElement(fh,null)))))}i(Nc,"FilterSelector");import{i18n as IE}from"@lingui/core";import{getCurrentStep as AE}from"@rango-dev/queue-manager-rango-preset";import{Divider as Eh,GroupedVirtualizedList as NE,Skeleton as WE,SwapListItem as Ih,Typography as BE}from"@rango-dev/ui";import et,{useCallback as Ah,useEffect as LE,useRef as ME,useState as PE}from"react";function wh(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(wh,"calculateGroupsSoFar");import{css as xE,darkTheme as EE,styled as Pr}from"@rango-dev/ui";var Wc=xE(),vh=Pr("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),Bc=Pr("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${Wc}`]:{$$color:"$colors$neutral600",[`.${EE} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Lc=Pr("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),bh=Pr("div",{gap:"$10",display:"flex",flexDirection:"column"}),xh=Pr("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var _E=10;function Mc(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=PE([]),c=ME(0),{swaps:l,groupCounts:p,groups:u}=n(e),d=Ah(wh,[]),f=Ah(()=>{let h=e.length-c.current;h&&(c.current+=Math.min(h,_E),s(d(p,c.current)))},[e.length]);if(LE(()=>{r||f()},[r,f]),r){let h=[1,2];return et.createElement(et.Fragment,null,[h,h].map((m,C)=>et.createElement(Bc,{key:C},et.createElement(Lc,null,et.createElement(WE,{variant:"text",width:60,size:"small"}),et.createElement(Eh,{size:16})),et.createElement(Eh,{size:4}),et.createElement(bh,null,m.map((S,T)=>et.createElement(Ih,{isLoading:!0,key:T}))))))}return et.createElement(NE,{endReached:()=>{c.current<e.length&&f()},groupCounts:a,groupContent:h=>et.createElement(Bc,null,et.createElement(Lc,null,et.createElement(BE,{variant:"label",size:"medium",className:Wc()},u[h]))),itemContent:(h,g)=>{let m=l[h];if(!m)return null;let C=AE(m),y=m.steps[0],S=m.steps[m.steps.length-1];return!y||!S?null:et.createElement(vh,{key:m.requestId},et.createElement(Ih,{className:"widget-history-group-list-swap-item-btn",requestId:m.requestId,creationTime:m.creationTime,status:m.status,onClick:o,currentStep:C,tooltipContainer:W(),onlyShowTime:u[g]===IE.t("Today"),swapTokenData:{from:{token:{image:y.fromLogo,displayName:y.fromSymbol},blockchain:{image:y.fromBlockchainLogo||""},amount:P(m.inputAmount,6,6),realAmount:m.inputAmount},to:{token:{image:S.toLogo,displayName:S.toSymbol},blockchain:{image:S.toBlockchainLogo||""},amount:P(S.outputAmount||S.expectedOutputAmountHumanReadable||"",6,6),realAmount:S.outputAmount||S.expectedOutputAmountHumanReadable||""}}}))}})}i(Mc,"HistoryGroupedList");import{i18n as wa}from"@lingui/core";import Nh from"dayjs";var Wh=i(t=>{let e=new Map([["today",{title:wa.t("Today"),swaps:[]}],["week",{title:wa.t("This week"),swaps:[]}],["month",{title:wa.t("This month"),swaps:[]}],["year",{title:wa.t("This year"),swaps:[]}]]);function o(l,p){e.has(l)||e.set(l,{title:l,swaps:[]}),e.get(l)?.swaps.push(p)}i(o,"addYearsToOutput");let n=Nh();t.forEach(l=>{let p=Number(l.creationTime),u=Nh(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 HE=_c("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),QE=_c("div",{display:"flex",justifyContent:"center",alignItems:"center"}),qE=_c("div",{"._typography":{color:"$neutral700",[`.${$E}&`]:{color:"$neutral900"}}}),GE=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 Lh(){let t=zE(),{manager:e,state:o}=DE(),n=Tt(e).map(({swap:b})=>b),[r,a]=Dr(""),[s,c]=Dr(!1),l=!o.loadedFromPersistor,[p,u]=Dr(""),[d,f]=Dr(!1),[h,g]=Dr("all"),m=i(b=>{let x=b.target.value;a(x)},"handleSearch"),{isMultiMode:C}=rt(),y=[{id:_r.SUCCESS,title:Fe.t("Complete")},{id:_r.RUNNING,title:Fe.t("Running")},{id:_r.FAILED,title:Fe.t("Failed")}],S=[{id:"all",title:Fe.t("All")},{id:"swap",title:Fe.t("Swap")},{id:"refuel",title:Fe.t("Refuel")}],T=Bh(()=>!r&&!p&&h==="all"?n:n.filter(b=>{let{inputAmount:x,status:E,steps:B,requestId:I,mode:_}=b;return(!r||Pt(x,r)||Pt(E,r)||GE(B,r)||Pt(I,r))&&(!p||p===E)&&(h==="all"?!0:h==="swap"?!_||_==="swap":h==="refuel"?_==="refuel":!1)}),[n,r,p,h]),v=!T?.length&&!l,w=i(()=>f(!1),"onCloseModal"),A=i(async()=>{try{await e?.clearQueue(),f(!1)}catch(b){console.log(b)}},"onClear"),N=Bh(()=>!n.some(b=>b.status===_r.SUCCESS||b.status===_r.FAILED),[n]);return oe.createElement(ae,{header:{title:Fe.t("History"),suffix:oe.createElement(fo,null,oe.createElement(Pc,{id:"widget-history-clear-btn",disabled:N,variant:"ghost",size:"xsmall",onClick:()=>f(!0)},oe.createElement(va,{size:"medium",variant:"label",color:"error"},Fe.t("Clear"))))}},oe.createElement(ue,null,oe.createElement(QE,null,oe.createElement(At,{setValue:a,fullWidth:!0,variant:"contained",placeholder:Fe.t("Search Transaction"),id:"widget-history-search-transaction-input",autoFocus:!0,onChange:m,style:{height:36},value:r}),oe.createElement(ko,{size:10,direction:"horizontal"}),oe.createElement(Nc,{filterBy:p,open:s,onOpenChange:b=>c(b),onClickItem:b=>u(b),list:y})),oe.createElement(ko,{size:"16"}),C&&!l&&oe.createElement(oe.Fragment,null,oe.createElement(UE,{items:S,onChange:b=>g(b.id),value:h,type:"secondary"}),oe.createElement(ko,{size:"12"})),oe.createElement(HE,null,v&&oe.createElement(xh,null,oe.createElement(ko,{size:32}),oe.createElement(OE,{title:r?Fe.t("No results found"):Fe.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?Fe.t("Try using different keywords"):Fe.t("Your transaction history is stored locally and will appear here after you start a swap")})),!v&&oe.createElement(Mc,{list:T,onSwapClick:t,groupBy:Wh,isLoading:l}))),oe.createElement(R,{open:d,onClose:w,id:"widget-history-clear-modal",container:W()},oe.createElement(ko,{size:20}),oe.createElement(FE,{type:"warning",title:Fe.t("Clear Transaction History"),description:oe.createElement(qE,null,oe.createElement(va,{variant:"body",size:"medium"},Fe.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),oe.createElement(ko,{size:"24"}),oe.createElement(va,{variant:"body",size:"small"},Fe.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),oe.createElement(ko,{size:30}),oe.createElement(Pc,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:A},Fe.t("Yes, Clear the history")),oe.createElement(ko,{size:10}),oe.createElement(Pc,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:w},oe.createElement(va,{variant:"title",size:"medium",color:"primary"},Fe.t("No, Cancel")))))}i(Lh,"HistoryPage");import{i18n as ly}from"@lingui/core";import{Button as II,Divider as Xc,styled as AI,WarningIcon as NI}from"@rango-dev/ui";import WI from"bignumber.js";import Ce,{useEffect as cy,useState as py}from"react";import{useNavigate as BI}from"react-router-dom";import{i18n as Ph}from"@lingui/core";import{Alert as KE,Divider as Dc,NoRouteIcon as jE,Typography as XE}from"@rango-dev/ui";import jo from"react";import{styled as VE}from"@rango-dev/ui";var Mh=VE("div",{display:"flex",flexDirection:"column",alignItems:"center"});function $c(){let{fromToken:t,toToken:e}=H()();return!!t&&!!e&&qt(t,e)?jo.createElement(Mh,null,jo.createElement(Dc,{size:10}),jo.createElement(jE,{size:24,color:"gray"}),jo.createElement(Dc,{size:4}),jo.createElement(XE,{variant:"title",size:"small"},Ph.t("No Routes Found")),jo.createElement(Dc,{size:4}),jo.createElement(KE,{title:Ph.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i($c,"SameTokensWarning");import{Alert as YE,Button as ZE}from"@rango-dev/ui";import Dh from"react";import{i18n as ba}from"@lingui/core";function _h(t){let e=null;return t===yi?(e={alertType:"error",action:"reset-slippage",actionButtonTitle:ba.t("Reset"),title:ba.t("Slippage cannot be set lower than 0.01%.")},e):t>an?(e={alertType:"warning",action:"change-settings",actionButtonTitle:ba.t("Change"),title:ba.t("Caution, your slippage is high!")},e):null}i(_h,"makeAlerts");function $h(t){let{slippage:e,customSlippage:o,setSlippage:n,setCustomSlippage:r}=k(),{onChangeSettings:a}=t,c=_h(o!==null?o:e),l=i(p=>{p==="reset-slippage"?(n(hi),r(null)):p==="change-settings"&&a()},"onClickActionButton");return c?Dh.createElement(YE,{title:c.title,type:c.alertType,variant:"alarm",action:Dh.createElement(ZE,{id:"widget-slippage-warning-error-change-settings-or-reset-slippage-btn",size:"xxsmall",type:c.alertType,onClick:()=>l(c.action)},c.actionButtonTitle)}):null}i($h,"SlippageWarningsAndErrors");import{i18n as oI}from"@lingui/core";import{IconButton as nI,ReverseIcon as rI,Skeleton as iI,Tooltip as aI,Typography as $r}from"@rango-dev/ui";import gt from"react";import xa from"bignumber.js";function Oh(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(Oh,"getSlippageColor");function Uh(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(Uh,"getUsdExchangeRate");function zh(t,e){let o=new xa(t).multipliedBy(e);return o.isLessThan(.001)?"$0":`$${o.decimalPlaces(2,xa.ROUND_DOWN).toFormat(2)}`}i(zh,"formatTokenValueInUsd");import{darkTheme as eI,styled as Oc,Typography as tI}from"@rango-dev/ui";var Hh=Oc("div",{display:"flex",padding:"$4",justifyContent:"space-between",alignItems:"center"}),Qh=Oc("div",{display:"flex",alignItems:"center",gap:"$2","& .rate-text":{color:"$neutral700",[`.${eI} &`]:{color:"$neutral700"}},"& ._icon-button":{transform:"rotate(90deg)",width:"$16",height:"$16"}}),Uc=Oc(tI,{maxWidth:"$32",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});function zc(t){let{slippage:e,customSlippage:o,quoteTokensRate:n,changeQuoteTokensRate:r}=k(),{quoteError:a,quoteWarning:s,fromToken:c,toToken:l,quote:p,loading:u}=t,d=o!==null?o:e,{mode:f}=mo({}),h=cn(d),g=f==="dark",m=n==="default",C={quoteError:a,slippageError:h?.type==="error"?h.message:null},y={quoteWarning:s,slippageWarning:h?.type==="warning"?h.message:null},S=p?.swaps[0]?.from||c,T=p?.swaps[p?.swaps.length-1]?.to||l,v=m?S:T,w=m?T:S,A=Number(m?p?.outputAmount:p?.requestAmount),N=Number(m?p?.requestAmount:p?.outputAmount),b=A||v.usdPrice,x=N||w.usdPrice,{rawValue:E,displayValue:B}=Uh({toTokenUsdPrice:x,fromTokenUsdPrice:b});return gt.createElement(Hh,null,gt.createElement($r,{variant:C||y?"label":"body",size:C||y?"medium":"small",color:Oh({error:C,warning:y,isDarkTheme:g})},oI.t("Slippage:")," ",d,"%"),u?gt.createElement(iI,{height:16,width:104,variant:"rounded"}):b&&x&>.createElement(Qh,null,gt.createElement($r,{className:"rate-text",variant:"body",size:"small"},"1"),gt.createElement(Uc,{className:"rate-text",variant:"body",size:"small"},w.symbol),gt.createElement(nI,{id:"widget-home-page-change-rate-button",onClick:r},gt.createElement(rI,{size:14,color:"secondary"})),gt.createElement(aI,{container:W(),side:"top",sideOffset:4,content:gt.createElement($r,{className:"rate-text",variant:"body",size:"small"},E)},gt.createElement($r,{className:"rate-text",variant:"body",size:"small"},B)),gt.createElement(Uc,{className:"rate-text",variant:"body",size:"small"},v.symbol),v.usdPrice&>.createElement($r,{color:"neutral600",variant:"body",size:"small"},"~",zh(Number(E),v.usdPrice))))}i(zc,"SwapMetrics");import{i18n as dI}from"@lingui/core";import{Header as mI}from"@rango-dev/ui";import To,{useEffect as fI,useState as gI}from"react";import{i18n as lI}from"@lingui/core";import{Divider as Qc,FullExpandedQuote as cI,Typography as pI}from"@rango-dev/ui";import ve from"react";import{styled as Hc}from"@rango-dev/ui";var qh=Hc("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Gh=Hc("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Vh=Hc("div",{width:"146px"});import{i18n as Fr}from"@lingui/core";import{Select as sI}from"@rango-dev/ui";import Kh from"react";function Ea(t){let{updateQuotePartialState:e,sortStrategy:o}=H()(),n=[{value:"SMART",label:Fr.t("Smart Routing")},{value:"FEE",label:Fr.t("Lowest Fee")},{value:"SPEED",label:Fr.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Fr.t("Maximum Return")},{value:"PRICE",label:Fr.t("Maximum Output")}];return Kh.createElement(Vh,null,Kh.createElement(sI,{id:"widget-quotes-strategy-select",container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(Ea,"SelectStrategy");var jh=3;function Or(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:C}=k(),{findToken:y}=k(),S=c||W(),T=!!p&&p.results.length,v=C??m,w=i(b=>{if(!d||!f||!p)return null;let x={requestAmount:p.requestAmount,validationStatus:null,...b};return Cn({currentQuote:x,userSlippage:v,findToken:y})},"getQuoteWarning"),A=g?.type===0||g?.type===1,N=p?.results?Bi(h,p?.results):[];return ve.createElement(ve.Fragment,null,a&&ve.createElement(ve.Fragment,null,ve.createElement(Gh,null,ve.createElement(pI,{size:"xmedium",variant:"title"},lI.t("Sort by")),ve.createElement(Ea,{container:S})),ve.createElement(Qc,{size:"10"})),e&&Array.from({length:jh},(b,x)=>ve.createElement(ve.Fragment,{key:x},s?ve.createElement(cI,{loading:!0}):ve.createElement(Er,{tagHidden:!1,type:"list-item",expanded:!1}),x!==jh-1&&ve.createElement(Qc,{size:16}))),!e&&ve.createElement(ve.Fragment,null,T?N.map((b,x)=>{let E=w(b),B=cc(b.swaps),I=N.length-1===x;return ve.createElement(ve.Fragment,{key:b.requestId},ve.createElement(Go,{id:"widget-quotes-quote-info-container",showModalFee:r,container:S,selected:l?.requestId===b.requestId,tagHidden:!1,quote:{...b,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:B?.options||null,warning:E,fullExpandedMode:s,onClick:_=>{B||u("warning",E),u("error",B?.options||null),o(_)},type:"list-item"}),!I&&ve.createElement(Qc,{size:16}))}):A&&ve.createElement(qh,null,ve.createElement(Cr,{size:s?"large":"small",error:g,fetch:n}))))}i(Or,"Quotes");import{darkTheme as uI,styled as Xh}from"@rango-dev/ui";var Yh=Xh("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${uI} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Zh=Xh("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var hI=100;function qc(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,c]=gI(!1),l=s?"":"is-hidden",{config:p}=k(),u=p?.variant==="full-expanded",d=Bo();return fI(()=>{let f=null;return a?f=setTimeout(()=>{c(!0)},hI):(c(!1),f&&clearTimeout(f)),()=>{f&&clearTimeout(f)}},[a]),To.createElement(Yh,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${l} ${qi()} widget-expanded-quotes-container`,id:ot.EXPANDED_BOX_ID},To.createElement(mI,{title:dI.t("Routes"),suffix:To.createElement(To.Fragment,null,To.createElement(Ea,{container:d}),To.createElement(zo,{container:d,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),To.createElement(Zh,null,To.createElement(Or,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:Bo(),onClickOnQuote:n,fullExpandedMode:u})))}i(qc,"ExpandedQuotes");import{i18n as ry}from"@lingui/core";import{SwapInput as iy}from"@rango-dev/ui";import kI from"bignumber.js";import Ur from"react";import{ReverseIcon as CI}from"@rango-dev/ui";import Vc from"react";import{keyframes as yI,styled as Jh}from"@rango-dev/ui";var Gc=450,SI=yI({"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)"}}),Rh=Jh("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),ey=Jh("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${SI} ${Gc}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 Kc(){let t=H().use.switchFromAndTo();return Vc.createElement(Rh,null,Vc.createElement(ey,{id:"widget-switch-from-and-to-btn",onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Gc),t()}},Vc.createElement(CI,{size:12})))}i(Kc,"SwitchFromAndToButton");import{styled as ty}from"@rango-dev/ui";var oy=ty("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),ny=ty("div",{position:"relative"});function jc(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:C}=rt(),{connectedWallets:y,getBalanceFor:S}=k(),T=a?S(a):null,v=mi(T)?.amount??"0",w=T?new kI(T.amount).shiftedBy(-T.decimals):de,A=!!s&&Wu(y,s.name),N=!Ks(m,d,f),b=!Ks(m,d,g),x=!f||!g||!g.gt(0)?null:jt(f.toString(),g.toString());return Ur.createElement(oy,null,Ur.createElement(ny,null,Ur.createElement(iy,{label:ry.t("From"),id:"widget-swap-from",mode:"From",onInputChange:p,onInputBlur:u,balance:v,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:P(f,4,4),realUsdValue:N?void 0:f?.toString(),error:N?re().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:A,tooltipContainer:W(),onSelectMaxBalance:()=>{let E=P(w,T?.decimals),B=T?.amount?E.split(",").join(""):"";p(B)},anyWalletConnected:y.length>0}),C==="swap"&&Ur.createElement(Kc,null)),Ur.createElement(iy,{selectionType:C==="swap"?"token":"chain",sharpBottomStyle:!r&&(!!m||e),label:ry.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:P(jt(f,g),2,2),warningLevel:Xt(x??0),price:{value:P(h,6,6),usdValue:b?void 0:P(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:W()}))}i(jc,"Inputs");import{warn as TI}from"@rango-dev/logging-core";import{useCallback as wI,useEffect as vI,useRef as bI,useState as xI}from"react";function ay(){let{fetch:t,loading:e,cancelFetch:o}=ha({request:async(n,r)=>await ut().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(ay,"useFetchAllQuotes");var EI=600;function Ia({refetchQuote:t}){let{fetch:e,cancelFetch:o}=ay(),{excludeLiquiditySources:n,routing:r}=k().config,{connectedWallets:a}=k(),c=a.some(le=>le.isContractWallet),{fromToken:l,toToken:p,inputAmount:u,inputUsdValue:d,selectedQuote:f,sortStrategy:h,resetQuote:g,error:m,warning:C,setSelectedQuote:y,updateQuotePartialState:S}=H()(),{slippage:T,customSlippage:v,affiliatePercent:w,affiliateRef:A,affiliateWallets:N,fetchStatus:b}=k(),x=k().getLiquiditySources(),E=k().getDisabledLiquiditySources(),B=k().excludeLiquiditySources(),{findToken:I}=k(),{swapMode:_}=rt(),[U,G]=xI(!0),Y=bI(u),L=v??T,J=!l||!p||qt(l,p)||!Vn(u),te=i(le=>{G(le)},"resetState"),se=i(le=>{let{fromToken:Xe,toToken:He,inputAmount:Bt,liquiditySources:$,excludeLiquiditySources:z,disabledLiquiditySources:V,slippage:pe,affiliateRef:Q,affiliatePercent:X,affiliateWallets:j}=le;if(U||te(!0),!J&&Xe&&He){g();let Ie=jd({fromToken:Xe,toToken:He,inputAmount:Bt,liquiditySources:$,excludeLiquiditySources:z,disabledLiquiditySources:V,wallets:a,slippage:pe,affiliateRef:Q,affiliatePercent:X,affiliateWallets:j,contractCall:c});ln("experimental",r)&&(Ie.experimental=!0),ln("avoidNativeFee",r)&&(Ie.avoidNativeFee=!0),ln("enableCentralizedSwappers",r)&&(Ie.enableCentralizedSwappers=!0),r?.maxLength&&(Ie.maxLength=r.maxLength),_==="refuel"&&(Ie.maxLength=1),e(Ie).then(Ae=>{let Ye=Bi(h,Ae.results),Lt=Dd(f,Ye,Ae.requestAmount);G(!1),S("quotes",Ae),y(Lt),ya({diagnosisMessages:Ae.diagnosisMessages,requestId:Lt?.requestId||"",swaps:Lt?.swaps});let so=Lt&&Cn({currentQuote:Lt,userSlippage:L,findToken:I});S("warning",so)}).catch(Ae=>{let Ye=Sa(Ae);(Ye.type===0||Ye.type===1)&&g(),Ye.type!==2&&(S("error",Ye),G(!1),TI(new Error("quote error"),{tags:{...Ye,type:Re[Ye.type],requestBody:Ie}}))})}},"fetch"),je=wI(ai(le=>{se(le)},EI),[J]);return vI(()=>{if(!t){G(!1);return}if(b!=="success")return;if(J){G(!1),(f||m||C)&&g();return}if(!Vn(u)&&d?.eq(0)){te(!1),o();return}g(),te(!0);let le=se;return Y.current&&Y.current!=u&&(le=je),Y.current=u,le({inputAmount:u,fromToken:l,toToken:p,liquiditySources:x,excludeLiquiditySources:B,disabledLiquiditySources:E,slippage:L,affiliateRef:A,affiliatePercent:w,affiliateWallets:N,contractCall:c}),o},[b,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,J,x?.length,n,E.length,L,A,w,c,JSON.stringify(N)]),{fetch:()=>se({inputAmount:u,fromToken:l,toToken:p,liquiditySources:x,excludeLiquiditySources:B,disabledLiquiditySources:E,slippage:L,affiliateRef:A,affiliatePercent:w,affiliateWallets:N,contractCall:c}),loading:U}}i(Ia,"useSwapInput");function sy(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};we.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(sy,"emitPreventableEvent");var LI=AI("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),MI=300;function uy(){let t=BI(),{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]=py(!1),{isLargeScreen:m,isExtraLargeScreen:C}=wn(),{fetch:y,loading:S}=Ia({refetchQuote:a}),{config:T,fetchStatus:v,connectedWallets:w,customSlippage:A,slippage:N,setSlippage:b,setCustomSlippage:x}=k(),{isActiveTab:E}=ne(),[B,I]=py(!1),_=A!==null?A:N,{swapMode:U}=rt(),G=cn(_),L=qd({fetchMetaStatus:v,fetchingQuote:S,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:c,needsToWarnEthOnPath:!1}),ee=$u(m,C,T?.variant),J=!!n&&!!e&&!!o&&new WI(n).gt(0)&&!tm(e,o),te=J&&v==="success"&&S,se=G?.quoteValidation||c,Xe=(!ee||ee&&l?.results.length)&&(se||s),He=!!e&&!!o,Bt=He&&!!G,$=(r||s)&&!B?y:void 0,z=i(X=>{ee&&h?(g(!1),setTimeout(()=>{t(X)},MI)):t(X)},"onHandleNavigation"),V=i(X=>{r?.requestId!==X.requestId&&(I(!1),p(X))},"onClickOnQuote"),pe=i(X=>{if(X){if(gi.includes(X)){b(X),x(null);return}x(X)}},"onChangeSlippage"),Q=i(X=>{z(X==="from"?F.fromSwap:U==="swap"?F.toSwap:F.toSwap+"/"+F.blockchains)},"handleInputTokenClick");return cy(()=>{u(),f("refetchQuote",!0)},[]),cy(()=>{g(J)},[J]),Ce.createElement(LI,null,Ce.createElement(ae,{height:"auto",footer:Ce.createElement(II,{id:`widget-swap-${L.action}-btn`,type:"primary",size:"large",disabled:L.disabled||!E,prefix:L.action==="confirm-warning"&&Ce.createElement(NI,null),fullWidth:!0,onClick:()=>{L.action==="connect-wallet"?sy({type:"clickConnectWallet"},()=>z(F.wallets)):L.action==="confirm-warning"?I(!0):z(F.confirmSwap)}},L.title),header:{onWallet:()=>{z(F.wallets)},hasBackButton:!1,title:T.title||(U==="swap"?ly.t("Swap"):ly.t("Refuel")),suffix:Ce.createElement(zo,{hidden:ee?["refresh"]:void 0,onClickRefresh:$,onClickHistory:()=>z(F.swaps),onClickSettings:()=>{z(F.settings)}})}},Ce.createElement(ue,null,Ce.createElement(jc,{fetchingQuote:te,fetchMetaStatus:v,isExpandable:ee,onClickToken:Q}),Ce.createElement(Xc,{size:"2"}),ee?null:Ce.createElement(Go,{quote:r,loading:te,error:s,id:"widget-home-expandable-quote-container",tagHidden:!1,warning:se,type:"basic",onClickAllRoutes:l&&l.results.length>1?()=>{f("refetchQuote",!1),z(F.routes)}:void 0}),He&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Xc,{size:8}),Ce.createElement(zc,{quoteError:s,quoteWarning:se,fromToken:e,toToken:o,quote:r,loading:te})),Xe?Ce.createElement(Ce.Fragment,null,Ce.createElement(Tr,{warning:se,error:s,skipAlerts:!!G,couldChangeSettings:!0,refetchQuote:y,showWarningModal:B,confirmationDisabled:!E,onOpenWarningModal:()=>I(!0),onCloseWarningModal:()=>I(!1),onChangeSlippage:pe,onConfirmWarningModal:()=>{I(!1),d(!0),z(F.confirmSwap)},onChangeSettings:()=>z(F.settings)})):null,Bt&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Xc,{size:"10"}),Ce.createElement($h,{onChangeSettings:()=>z(F.settings)})),Ce.createElement($c,null))),ee?Ce.createElement(qc,{loading:te,onClickOnQuote:V,fetch:y,onClickRefresh:$,isVisible:h}):null)}i(uy,"Home");import{i18n as dy}from"@lingui/core";import{Alert as PI,Divider as _I,List as DI,ListItemButton as $I,Radio as FI,RadioRoot as OI,Typography as UI}from"@rango-dev/ui";import Ot from"react";function wo(){let{setLanguage:t,language:e,config:o}=k(),n=qu,r=o?.language||pn;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||pn),resetLanguage:()=>t(null)}}i(wo,"useLanguage");function my(){let{activeLanguage:t,changeLanguage:e,languages:o}=wo(),n=Ge(),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(UI,{variant:"title",size:"xmedium"},c),onClick:()=>{e(a.local),n()},end:Ot.createElement(FI,{value:s}),start:Ot.createElement(l,null)}});return Ot.createElement(ae,{header:{title:dy.t("Language")}},Ot.createElement(ue,null,Ot.createElement(PI,{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(OI,{value:t},Ot.createElement(DI,{type:Ot.createElement($I,{title:dy.t("language"),className:"widget-language-list-item-btn",id:"_",onClick:()=>console.log()}),items:r}))))}i(my,"LanguagePage");import{i18n as no}from"@lingui/core";import{Button as GI,Checkbox as VI,Image as KI,ListItemButton as jI,NotFound as XI,Typography as YI}from"@rango-dev/ui";import tt,{useState as ZI}from"react";import{Checkbox as QI,Skeleton as gy}from"@rango-dev/ui";import Hr from"react";import{styled as Yc}from"@rango-dev/ui";var zr=Yc("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),Zc=Yc("div",{width:80,display:"flex",justifyContent:"flex-end"}),Jc=Yc("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as zI,styled as HI}from"@rango-dev/ui";var fy=HI(zI,{height:61});var qI=30;function Rc(){return Hr.createElement(zr,null,Array.from(Array(qI),(t,e)=>Hr.createElement(fy,{hasDivider:!0,key:e,start:Hr.createElement(gy,{variant:"circular",width:35,height:35}),title:Hr.createElement(gy,{variant:"text",size:"large",width:90}),end:Hr.createElement(QI,{checked:!1})})))}i(Rc,"LoadingLiquiditySourceList");function ep({sourceType:t}){let e=k().fetchStatus,o=k().swappers(),n=k().getDisabledLiquiditySources(),[r,a]=ZI(""),s=k().toggleLiquiditySource,c=k().isInCampaignMode(),l=Si(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(y=>u.includes(y.type)),f=d.length===d.filter(y=>y.selected).length,h=i(()=>{d.forEach(y=>{f?s(y.groupTitle):y.selected||s(y.groupTitle)})},"toggleAllSources"),g=d.map(y=>{let{selected:S,groupTitle:T,logo:v,id:w,...A}=y;return{id:`widget-setting-liquidity-source-${Su(w.toLowerCase())}-item-btn`,start:tt.createElement(KI,{src:v,size:22,type:"circular"}),onClick:()=>{c||s(T)},end:tt.createElement(VI,{checked:S,disabled:c}),title:tt.createElement(YI,{variant:"title",size:"xmedium"},no.t(T)),selected:S,groupTitle:T,logo:v,...A}}),m=i(y=>{let S=y.target.value;a(S)},"handleSearch"),C=g;return r&&(C=g.filter(y=>Pt(y.groupTitle,r))),tt.createElement(ae,{header:{title:no.t(t),suffix:tt.createElement(Zc,null,tt.createElement(GI,{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")))}},tt.createElement(ue,{view:!0},tt.createElement(At,{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"&&tt.createElement(Rc,null),!C.length&&r?tt.createElement(Jc,null,tt.createElement(XI,{title:no.t("No results found"),description:no.t("Try using different keywords")})):e==="success"&&tt.createElement(zr,{disabled:c,className:"widget-liquidity-source-list"},C.map(y=>{let{groupTitle:S,...T}=y;return tt.createElement(tt.Fragment,{key:y.id},tt.createElement(jI,{style:{height:"61px"},...T,selected:!1,className:"widget-liquidity-source-list-item-btn",hasDivider:!0}))}))))}i(ep,"LiquiditySourcePage");import{i18n as JI}from"@lingui/core";import Aa from"react";import{useNavigate as RI}from"react-router-dom";function hy(){let t=RI(),e=Ge(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=H()(),{fetch:c,loading:l}=Ia({refetchQuote:n}),p=i(f=>{r(f),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${F.settings}`,d=`../${F.wallets}`;return Aa.createElement(ae,{header:{onWallet:()=>{t(d),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:JI.t("Routes"),suffix:Aa.createElement(zo,{onClickRefresh:o||s?c:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},Aa.createElement(ue,null,Aa.createElement(Or,{fetch:c,loading:l,onClickOnQuote:p})))}i(hy,"RoutesPage");import{i18n as vy}from"@lingui/core";import{Divider as by,getCategoriesCount as cA,SelectableCategoryList as pA}from"@rango-dev/ui";import ro,{useState as xy}from"react";import{useNavigate as uA}from"react-router-dom";import{i18n as tp}from"@lingui/core";import{Divider as nA,Image as rA,ListItemButton as iA,NotFound as aA,Typography as wy}from"@rango-dev/ui";import ht,{useEffect as sA,useState as lA}from"react";var yy=i((t,e,o)=>t.filter(n=>si(n.type,o)).filter(n=>ct(n.name,e)||ct(n.displayName,e)),"filterBlockchains");import{ImageContainer as eA,styled as Sy}from"@rango-dev/ui";var Cy=Sy("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Na=Sy(Al,{padding:0,margin:0,listStyle:"none",[`& ${eA}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as tA,Skeleton as ky}from"@rango-dev/ui";import Wa from"react";var oA=20;function Ty(){return Wa.createElement(Na,{id:"widget-blockchain-loading-list",as:"ul"},Array.from(Array(oA),t=>Wa.createElement(tA,{key:t,hasDivider:!0,start:Wa.createElement(ky,{variant:"circular",width:35,height:35}),title:Wa.createElement(ky,{variant:"text",size:"large",width:90})})))}i(Ty,"LoadingBlockchainList");function op(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,c]=lA(e),{fetchStatus:l}=k();sA(()=>{c([...yy(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?ht.createElement(aA,{title:tp.t("No results found"),description:tp.t("Try using different keywords")}):ht.createElement(Na,{as:"ul",key:`${r}-${o}`,id:"widget-blockchain-list"},s.map(u=>ht.createElement(iA,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:ht.createElement(rA,{src:u.logo,size:30}),title:ht.createElement(wy,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return ht.createElement(ht.Fragment,null,a&&ht.createElement(ht.Fragment,null,ht.createElement(wy,{variant:"label",size:"large"},tp.t("Select Chain")),ht.createElement(nA,{size:4})),ht.createElement(Cy,null,l==="loading"&&ht.createElement(Ty,null),l==="success"&&p()))}i(op,"BlockchainList");function Ba(t){let{type:e}=t,o=Ge(),[n,r]=xy(""),[a,s]=xy("ALL"),c=H().use.setToBlockchain(),l=H().use.setFromBlockchain(),p=H().use.setToToken(),{fetchStatus:u,findNativeToken:d}=k(),f=uA(),{swapMode:h}=rt(),g=k().blockchains({type:e}),m=cA(g),C=!t.hideCategory&&m!==1,y=i(S=>{if(e==="custom-token")f(`..?blockchain=${S.name}`,{replace:!0});else{if(e==="source")l(S);else if(h==="swap")c(S);else{let T=d(S);T&&p({token:T,meta:{blockchains:g}})}o()}},"handleBlockchainChange");return ro.createElement(ae,{header:{title:vy.t("Select Chain")}},ro.createElement(ue,{view:!0},C&&ro.createElement(ro.Fragment,null,ro.createElement(pA,{setCategory:s,category:a,blockchains:g,isLoading:u==="loading"}),ro.createElement(by,{size:24})),ro.createElement(At,{value:n,autoFocus:!0,placeholder:vy.t("Search Chain"),id:"widget-select-blockchain-search-input",color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:S=>r(S.target.value)}),ro.createElement(by,{size:16}),ro.createElement(op,{list:g,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:y})))}i(Ba,"SelectBlockchainPage");import{i18n as Pa}from"@lingui/core";import{Divider as Ly,Spinner as EA}from"@rango-dev/ui";import vo,{useEffect as IA,useState as AA}from"react";import{useNavigate as NA}from"react-router-dom";import{i18n as ip}from"@lingui/core";import{BlockchainsChip as La,Divider as Ny,Image as Wy,Skeleton as yA,Tooltip as SA,Typography as ap}from"@rango-dev/ui";import be from"react";import{useEffect as fA}from"react";var Ey=["ETH","COSMOS","OSMOSIS"];function np(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(dA),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(mA(s)),r=n.splice(a)}return{list:n,more:r}}i(np,"prepare");function dA(t,e){let o=Ey,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(dA,"sortByMostUsedBlockchains");function mA(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(mA,"generateSortByPreferredBlockchainsFor");function Iy(t,e){return!!e.list.find(o=>o.name===t)}i(Iy,"isInVisibleList");function rp(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=k();fA(()=>{if(e?.selected){let a=np(t,o,e);Iy(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=np(t,o,e);return{list:r.list,more:r.more,history:[]}}i(rp,"usePrepareBlockchainList");import{styled as gA}from"@rango-dev/ui";var Ay=gA("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var CA=6,kA=12;function sp(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,{showCompactTokenSelector:s}=ne(),c=rp(e,{limit:s?4:10,selected:n?.name}),{fetchStatus:l}=k(),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(Ny,{size:12}),be.createElement(ap,{variant:"label",size:"large"},ip.t("Select Chain"))),be.createElement(Ny,{size:12}),be.createElement(Ay,{id:"widget-blockchains-section-container"},l==="loading"&&Array.from(Array(s?CA:kA),(m,C)=>be.createElement(yA,{key:C,variant:"rounded",height:50})),l==="success"&&be.createElement(be.Fragment,null,be.createElement(La,{className:"widget-blockchains-section-all-btn",selected:!n,onClick:()=>{o==="from"?u():p()}},be.createElement(ap,{variant:"body",size:"xsmall",color:"secondary500"},ip.t("All"))),c.list.map(m=>be.createElement(SA,{key:m.name,content:m.shortName,side:"bottom",sideOffset:2,container:W()},be.createElement(La,{className:"widget-blockchains-section-item-btn",key:m.name,selected:!!n&&n.name===m.name,onClick:()=>r(m)},be.createElement(Wy,{src:m.logo,size:30})))),h?be.createElement(La,{className:"widget-blockchains-section-only-item-btn",key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},be.createElement(Wy,{src:f.logo,size:30})):null,g?be.createElement(La,{onClick:a,key:"more-blockchains",className:"widget-blockchains-section-more-items-btn"},be.createElement(ap,{variant:"body",size:"xsmall",color:"secondary500"},ip._("More +{count}",{count:c.more.length}))):null)))}i(sp,"BlockchainsSection");import{useCallback as wA,useRef as vA,useState as lp}from"react";function cp(){let t=k().blockchains(),e=vA(null),{customTokens:o}=k(),[n,r]=lp(!1),[a,s]=lp([]),[c,l]=lp(null),p=i(async(f,h)=>{l(null),r(!0),s([]);try{let g=await ut().searchCustomTokens({query:f,blockchain:h},{signal:e.current?.signal}),m=new Set(o().map(S=>Vt(S))),C=new Set(t.map(S=>S.name)),y=g.tokens.filter(S=>C.has(S.blockchain)&&!m.has(Vt(S)));s(y),r(!1)}catch(g){l(g instanceof Error?g.message:"something went wrong"),s([]),g?.name!=="CanceledError"&&r(!1)}},"fetch"),u=wA(ai((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(cp,"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 By(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(By,"prepareTokensList");function _a(t){let{type:e}=t,o=NA(),n=Ge(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:c,setFromBlockchain:l,setToBlockchain:p}=H()(),{getBalanceFor:u}=k(),{fetch:d,loading:f,tokens:h,cancel:g}=cp(),[m,C]=AA(""),y=e==="source"?r:a,S=y?.name??"",T=k().blockchains({type:e}),v=k().tokens({type:e,blockchain:S,searchFor:m,getBalanceFor:u}),w=By(v,h,m,f,y?.name),A=i(x=>{e==="source"?l(x):p(x)},"updateBlockchain"),N=i(x=>{e==="source"?s({token:x,meta:{blockchains:T}}):c({token:x,meta:{blockchains:T}})},"updateToken"),b={source:Pa.t("Source"),destination:Pa.t("Destination")};return IA(()=>(Ma(v,m,y?.name)&&d(m,y?.name??void 0),()=>{g()}),[v.length,m,y?.name]),vo.createElement(ae,{header:{title:Pa.t("Swap {type}",{type:b[e]})}},vo.createElement(ue,null,vo.createElement(sp,{blockchains:T,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o(F.blockchains),onChange:x=>{A(x)}}),vo.createElement(Ly,{size:24}),vo.createElement(At,{value:m,id:"widget-select-swap-item-search-input",autoFocus:!0,placeholder:Pa.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>C(""),onChange:x=>C(x.target.value),suffix:Ma(v,m,y?.name)&&f?vo.createElement(EA,{size:12,color:"secondary"}):void 0}),vo.createElement(Ly,{size:16}),vo.createElement(Br,{list:w,selectedBlockchain:S,searchedFor:m,type:e,onChange:x=>{N(x);let E=T.find(B=>x.blockchain===B.name);E&&A(E),n()}})))}i(_a,"SelectSwapItemsPage");import{i18n as mp}from"@lingui/core";import{Alert as oN,Button as nN,styled as rN}from"@rango-dev/ui";import Xo from"react";import{useInRouterContext as iN,useSearchParams as aN}from"react-router-dom";import{i18n as Fy}from"@lingui/core";import{Alert as MA,Divider as up,InfoIcon as PA,SlippageIcon as _A,TextField as DA,Tooltip as $A,Typography as Oy}from"@rango-dev/ui";import Ue from"react";import{Chip as WA,styled as Qr,TextField as BA}from"@rango-dev/ui";var My=Qr("div",{paddingTop:"$5",padding:"$10 $5"}),Py=Qr("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${BA}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px",paddingLeft:"$2"}}),_y=Qr("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Da=Qr("div",{maxWidth:"280px",padding:"$10"}),Dy=Qr(WA,{width:"61px",flexShrink:0});import{i18n as pp}from"@lingui/core";import{Typography as LA}from"@rango-dev/ui";import qr from"react";function $y(){return qr.createElement(Da,null,qr.createElement(LA,{variant:"label",size:"medium",color:"neutral700"},pp.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),qr.createElement("br",null),qr.createElement("br",null),qr.createElement("b",null,pp.t("Warning")),":\xA0",pp.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($y,"SlippageTooltipContent");function dp(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=k(),r=o!==null?cn(o):null,a=i(l=>{let p=l.target.value,u=parseFloat(p);if(isNaN(u))return n(null);let d=u;u>Yn&&(d=Yn),n(d)},"onSlippageValueChange"),s=i(l=>{o!==null&&n(null),e(l)},"onClickSlippageChip"),c=i(l=>{let p=l.target,u=p.value;ku(u)||(p.value=u.slice(0,-1))},"onInput");return Ue.createElement(My,null,Ue.createElement(_y,null,Ue.createElement(_A,{size:16,color:"gray"}),Ue.createElement(up,{direction:"horizontal",size:4}),Ue.createElement(Oy,{variant:"title",size:"xmedium"},Fy.t("Slippage tolerance per swap")),Ue.createElement(up,{direction:"horizontal",size:4}),Ue.createElement($A,{container:W(),side:"top",sideOffset:4,content:Ue.createElement($y,null)},Ue.createElement(PA,{color:"gray"}))),Ue.createElement(Py,null,gi.map((l,p)=>{let u=`slippage-${p}`;return Ue.createElement(Dy,{id:`widget-slippage-chip-${l.toString()}%-btn`,key:u,onClick:()=>s(l),selected:o===null&&l===t,label:`${l.toString()}%`})}),Ue.createElement(DA,{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&&Ue.createElement(Oy,{variant:"body",size:"small"},"%"),placeholder:Fy.t("Custom")})),r&&Ue.createElement(Ue.Fragment,null,Ue.createElement(up,{size:10}),Ue.createElement(MA,{id:"widget-slippage-alert",variant:"alarm",type:r.type,title:r.message})))}i(dp,"Slippage");import{i18n as wt}from"@lingui/core";import{AutoThemeIcon as Uy,BridgesIcon as FA,ChevronRightIcon as $a,DarkModeIcon as zy,Divider as Gr,ExchangeIcon as OA,InfinityIcon as UA,InfoIcon as zA,LanguageIcon as HA,LightModeIcon as Hy,List as QA,ListItem as qA,ListItemButton as GA,Skeleton as VA,styled as KA,Switch as jA,Tabs as XA,TargetIcon as YA,Tooltip as ZA,Typography as lt}from"@rango-dev/ui";import D from"react";import{useNavigate as JA}from"react-router-dom";var RA=KA("div",{width:"202px",height:"$40"}),eN=[{id:"light",icon:D.createElement(Hy,{color:"black",size:24}),tooltip:D.createElement(lt,{size:"xsmall",variant:"body"},wt.t("Light"))},{id:"dark",icon:D.createElement(zy,{color:"black",size:24}),tooltip:D.createElement(lt,{size:"xsmall",variant:"body"},wt.t("Dark"))},{id:"auto",icon:D.createElement(Uy,{color:"black",size:24}),tooltip:D.createElement(lt,{size:"xsmall",variant:"body"},wt.t("Auto"))}],tN=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return D.createElement(Uy,{...e});case"dark":return D.createElement(zy,{...e});default:return D.createElement(Hy,{...e})}},"getThemeIcon");function Qy(){let t=JA(),{theme:e}=k().config,{setTheme:o,theme:n}=k(),{activeLanguage:r,languages:a}=wo(),s=a.find(L=>L.local===r)?.label,c=k().fetchStatus,l=k().swappers(),p=k().getDisabledLiquiditySources(),{config:{features:u}}=k(),d=k().customTokens(),f=nt("theme",u),h=nt("liquiditySource",u),g=nt("language",u),m=nt("customTokens",u),C=k().infiniteApprove,y=k().toggleInfiniteApprove,S=Si(l,p),T=S.filter(L=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(L.type)),v=T.length,w=T.filter(L=>L.selected).length,A=S.filter(L=>L.type==="DEX"),N=A.length,b=A.filter(L=>L.selected).length,x=i((L,ee)=>{switch(c){case"loading":return D.createElement(VA,{variant:"text",size:"medium",width:50});case"failed":return D.createElement(lt,{variant:"body",size:"medium",color:"$error500"},wt.t("Loading failed"));default:return D.createElement(lt,{variant:"body",size:"medium"},`${L} / ${ee}`)}},"handleSwapperEndItem"),E={id:"widget-setting-bridge-item-btn",title:D.createElement(lt,{variant:"title",size:"xmedium"},wt.t("Bridges")),end:D.createElement(D.Fragment,null,x(w,v),D.createElement(Gr,{direction:"horizontal",size:8}),D.createElement($a,{color:"black"})),onClick:()=>t(F.bridges),start:D.createElement(FA,{color:"gray",size:16})},B={id:"widget-setting-exchange-item-btn",title:D.createElement(lt,{variant:"title",size:"xmedium"},wt.t("Exchanges")),end:D.createElement(D.Fragment,null,x(b,N),D.createElement(Gr,{direction:"horizontal",size:8}),D.createElement($a,{color:"black"})),start:D.createElement(OA,{color:"gray",size:16}),onClick:()=>t(F.exchanges)},I={id:"widget-setting-custom-tokens-item-btn",title:D.createElement(lt,{variant:"title",size:"xmedium"},wt.t("Custom Tokens")),end:D.createElement(D.Fragment,null,D.createElement(lt,{variant:"body",size:"medium"},`${d.length}`),D.createElement(Gr,{direction:"horizontal",size:8}),D.createElement($a,{color:"black"})),start:D.createElement(YA,{color:"gray",size:16}),onClick:()=>t(F.customTokens)},_={id:"widget-setting-language-item-btn",title:D.createElement(lt,{variant:"title",size:"xmedium"},wt.t("Language")),start:D.createElement(HA,{color:"gray",size:16}),end:D.createElement(D.Fragment,null,D.createElement(lt,{variant:"body",size:"medium"},s),D.createElement(Gr,{direction:"horizontal",size:8}),D.createElement($a,{color:"black"})),onClick:()=>t(F.languages)},U={id:"widget-setting-infinite-approval-item-btn",title:D.createElement(D.Fragment,null,D.createElement(lt,{variant:"title",size:"xmedium"},wt.t("Infinite approval")),D.createElement(Gr,{direction:"horizontal",size:4}),D.createElement(ZA,{side:"top",sideOffset:4,container:W(),content:D.createElement(Da,null,D.createElement(lt,{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(zA,{color:"gray"}))),start:D.createElement(UA,{color:"gray",size:16}),end:D.createElement(jA,{checked:C}),onClick:y},G={id:"widget-setting-theme-item-btn",type:D.createElement(qA,null),title:D.createElement(lt,{variant:"title",size:"xmedium"},wt.t("Theme")),end:D.createElement(RA,null,D.createElement(XA,{container:W(),items:eN,value:n,className:"widget-setting-theme-item-tabs-container",onChange:L=>o(L.id),type:"primary",borderRadius:"small"})),start:tN(n)},Y=h?[]:[E,B];return m||Y.push(I),g||Y.push(_),Y.push(U),!e?.singleTheme&&!f&&Y.push(G),D.createElement(QA,{type:D.createElement(GA,{className:"widget-settings-list-item-btn",hasDivider:!0,id:"_",onClick:()=>console.log()}),items:Y})}i(Qy,"SettingsLists");var sN=rN("div",{paddingLeft:"$8"});function qy(){let{isInCampaignMode:t,updateCampaignMode:e}=k(),o=t(),[,n]=aN(),r=iN(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Xo.createElement(ae,{header:{title:mp.t("Settings")}},Xo.createElement(ue,null,o&&Xo.createElement(oN,{type:"info",variant:"alarm",id:"widget-settings-campaign-mode-alert",title:mp.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(sN,null,Xo.createElement(nN,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},mp.t("Reset")))}),Xo.createElement(dp,null),Xo.createElement(Qy,null)))}i(qy,"SettingsPage");import{i18n as y0}from"@lingui/core";import{cancelSwap as S0}from"@rango-dev/queue-manager-rango-preset";import{useManager as C0}from"@rango-dev/queue-manager-react";import{Alert as k0}from"@rango-dev/ui";import Wp from"react";import{useParams as T0}from"react-router-dom";import{i18n as zt}from"@lingui/core";import{getCurrentNamespaceOfOrNull as n0,getCurrentStep as r0,getRelatedWalletOrNull as i0}from"@rango-dev/queue-manager-rango-preset";import{Button as FS,Divider as a0,QuoteCost as s0,StepDetails as l0,Typography as bp}from"@rango-dev/ui";import{useWallets as c0}from"@rango-dev/wallets-react";import OS from"bignumber.js";import{PendingSwapNetworkStatus as Fn}from"rango-types";import Te,{useEffect as xp,useRef as Ep,useState as Va}from"react";import{useNavigate as p0}from"react-router-dom";import{i18n as bo}from"@lingui/core";var lN=[bo.t("Sunday"),bo.t("Monday"),bo.t("Tuesday"),bo.t("Wednesday"),bo.t("Thursday"),bo.t("Friday"),bo.t("Saturday")];function Gy(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?bo.t("Today"):`${lN[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Gy,"timeSince");function Vy(t){return t.finishTime?Gy(parseInt(t.finishTime)):Gy(parseInt(t.creationTime))}i(Vy,"getSwapDate");import Vr from"react";import{i18n as Fa}from"@lingui/core";import{Button as Ky,Divider as fp,MessageBox as cN}from"@rango-dev/ui";import xo from"react";var jy=i(({onCancel:t,onClose:e})=>xo.createElement(xo.Fragment,null,xo.createElement(fp,{size:20}),xo.createElement(cN,{type:"error",title:Fa.t("Cancel Swap"),description:Fa.t("Are you sure you want to cancel this swap?")}),xo.createElement(fp,{size:32}),xo.createElement(Ky,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Fa.t("Yes, Cancel it")),xo.createElement(fp,{size:12}),xo.createElement(Ky,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Fa.t("No, Continue"))),"CancelContent");import{i18n as Oa}from"@lingui/core";import{Button as Xy,Divider as gp,MessageBox as pN,Typography as uN}from"@rango-dev/ui";import io from"react";var Yy=i(({onDelete:t,onClose:e})=>io.createElement(io.Fragment,null,io.createElement(gp,{size:20}),io.createElement(pN,{type:"error",title:Oa.t("Delete Transaction"),description:Oa.t("Are you sure you want to delete this swap?")}),io.createElement(gp,{size:32}),io.createElement(Xy,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Oa.t("Yes, Delete it")),io.createElement(gp,{size:12}),io.createElement(Xy,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},io.createElement(uN,{variant:"title",size:"medium",color:"primary"},Oa.t("No, Cancel")))),"DeleteContent");import{i18n as dN}from"@lingui/core";import{Button as mN,Divider as fN,MessageBox as gN}from"@rango-dev/ui";import Yo from"react";var Zy=i(t=>{let{switchNetworkModalState:e,handleSwitchNetwork:o}=t;return Yo.createElement(Yo.Fragment,null,Yo.createElement(gN,{type:e.type,title:e.title,description:e.description}),e.type==="error"&&Yo.createElement(Yo.Fragment,null,Yo.createElement(fN,{size:"30"}),Yo.createElement(mN,{id:"widget-switch-network-try-again",type:"primary",size:"large",onClick:o},dN.t("Try Again"))))},"NetworkStateContent");import{getCurrentNamespaceOfOrNull as MN,getCurrentStep as PN,getRelatedWalletOrNull as _N}from"@rango-dev/queue-manager-rango-preset";import{WalletState as DN}from"@rango-dev/ui";import{useWallets as $N}from"@rango-dev/wallets-react";import rS from"react";import{i18n as Dn}from"@lingui/core";import{Alert as eS,Button as SN,Checkbox as CN,Divider as Ha,Image as kN,MessageBox as TN,Spinner as wN,WarningIcon as vN}from"@rango-dev/ui";import{useWallets as bN}from"@rango-dev/wallets-react";import Se,{useState as xN}from"react";import{css as hN,darkTheme as yN,styled as hp}from"@rango-dev/ui";var Jy=hN({wordWrap:"break-word",display:"block"}),Ry=hp("img",{width:"100%"}),Ua=hp("div",{position:"relative"}),za=hp("span",{position:"absolute",top:0,right:0,borderRadius:"50%",width:"14px",height:"14px",display:"flex",padding:"$2",backgroundColor:"$warning300",[`.${yN} &`]:{$$color:"$warning600"}});var tS=i(t=>{let{wallet:e,namespace:o,onClose:n}=t,[r,a]=xN(null),{list:s}=vt(),c=ne.use.isActiveTab(),{state:l,connect:p}=bN(),u=s.find(w=>w.type===e.walletType),d=u?.needsNamespace?.data.find(w=>w.value===o?.namespace);if(!u)return null;let f=l(e.walletType),h=u.isHub&&o?.namespace?f.namespaces?.get(o.namespace):null,g=f.connecting||h?.connecting,m=u.isHub?h?.connected:f.connected,C=i(()=>m?Dn.t("Done"):r?Dn.t("Try again"):Dn.t("Connect"),"getButtonTitle"),y=i(()=>g?Se.createElement(wN,{color:"info"}):r||m?null:Se.createElement(CN,{checked:!0,disabled:!0}),"getNamespaceSuffix"),S=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"),T=i(async()=>{if(m){n();return}S()},"handleClickButton"),v=i(()=>{if(!m)return null;let w=u?.isHub?h?.accounts?.[0]?.split(":"):f?.accounts?.[0]?.split(":"),A=w?.[w?.length-1];return A?lo(A):null},"getAddress");return Se.createElement(Se.Fragment,null,Se.createElement(TN,{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:Se.createElement(Ua,null,Se.createElement(kN,{src:u.image,size:45}),Se.createElement(za,null,Se.createElement(vN,{color:"warning",size:10})))}),m&&!d&&Se.createElement(Se.Fragment,null,Se.createElement(Ha,{size:10}),Se.createElement(eS,{type:"success",variant:"alarm",title:Dn.t("Wallet connected successfully.")})),r&&!d&&Se.createElement(Se.Fragment,null,Se.createElement(Ha,{size:10}),Se.createElement(eS,{type:"error",title:r?.message,variant:"alarm"})),d&&Se.createElement(Se.Fragment,null,Se.createElement(Ha,{size:30}),Se.createElement(_o,{namespace:d,suffix:y(),error:r?.message,connected:m,address:v()})),Se.createElement(Ha,{size:"40"}),Se.createElement(SN,{loading:g,type:"primary",id:"widget-connect-wallet-btn",onClick:T,disabled:!c},C()))},"ConnectWalletContent");import{i18n as oS}from"@lingui/core";import{Button as EN,Divider as IN,Image as AN,MessageBox as NN,WarningIcon as WN}from"@rango-dev/ui";import{useWallets as BN}from"@rango-dev/wallets-react";import{detectInstallLink as LN}from"@rango-dev/wallets-shared";import ao from"react";var nS=i(t=>{let{walletType:e}=t,{getWalletInfo:o}=BN(),n=e?o(e):null;if(!n)return null;let r=i(()=>window.open(LN(n.installLink),"_blank"),"handleButtonClick");return ao.createElement(ao.Fragment,null,ao.createElement(NN,{type:"warning",title:oS.t("Install {wallet}",{wallet:n.name}),description:"Your wallet is not installed. Please install it to continue the swap. ",icon:ao.createElement(Ua,null,ao.createElement(AN,{src:n.img,size:45}),ao.createElement(za,null,ao.createElement(WN,{color:"warning",size:10})))}),ao.createElement(IN,{size:"40"}),ao.createElement(EN,{type:"primary",id:"widget-install-wallet-btn",onClick:r},oS.t("Install")))},"InstallWalletContent");var iS=i(t=>{let{swap:e,onClose:o}=t,{state:n}=$N(),r=PN(e),a=r?_N(e,r):null,s=a?.walletType,c=s?Kn(n(s)):null,l=r?MN(e,r):null;return s?c===DN.NOT_INSTALLED?rS.createElement(nS,{walletType:s}):rS.createElement(tS,{wallet:a,namespace:l,onClose:o}):null},"WalletStateContent");function yp(t){let{isOpen:e,state:o,switchNetworkModalState:n,onClose:r,onDelete:a,onCancel:s,swap:c,message:l,handleSwitchNetwork:p}=t;return Vr.createElement(R,{open:e,onClose:r,container:W()},o==="connectWallet"&&Vr.createElement(iS,{swap:c,message:l,onClose:r}),o==="switchNetwork"&&n&&Vr.createElement(Zy,{message:l,switchNetworkModalState:n,handleSwitchNetwork:p}),o==="delete"&&Vr.createElement(Yy,{onClose:r,onDelete:()=>{r(),a()}}),o==="cancel"&&Vr.createElement(jy,{onClose:r,onCancel:()=>{r(),s()}}))}i(yp,"SwapDetailsModal");import{i18n as Kr}from"@lingui/core";import{Button as Sp,Divider as jr,MessageBox as lS,TokenAmount as FN,Typography as cS}from"@rango-dev/ui";import ke from"react";import{Link as ON,useNavigate as UN}from"react-router-dom";var aS="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",sS="/profile";function Cp(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=UN(),{showProfileBanner:g}=ne();return ke.createElement(R,{open:e,onClose:o,id:"widget-swap-details-complete-modal",container:document.getElementById(ot.SWAP_BOX_ID)||document.body},n==="success"?ke.createElement(lS,{type:"success",title:Kr.t("Swap Successful")},ke.createElement(FN,{direction:"vertical",tooltipContainer:W(),id:"widget-swap-details-complete-modal-success-token-amount-container",type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:c},token:l,chain:p,percentageChange:u}),ke.createElement(jr,{size:12}),ke.createElement(cS,{className:Jy(),variant:"body",size:"medium",color:"neutral700",align:"center"},d)):ke.createElement(lS,{type:"error",title:Kr.t("Transaction Failed"),description:d}),ke.createElement(jr,{size:30}),n==="success"&&ke.createElement(ke.Fragment,null,g&&ke.createElement(ke.Fragment,null,ke.createElement(ON,{to:sS},ke.createElement(Ry,{src:aS,alt:"Profile Banner"})),ke.createElement(jr,{size:30})),ke.createElement(Sp,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{h("../../")}},Kr.t("Done"))),ke.createElement(jr,{size:12}),f&&ke.createElement(ke.Fragment,null,ke.createElement(Sp,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(f,"_blank")},Kr.t("Diagnosis")),ke.createElement(jr,{size:12})),ke.createElement(Sp,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},ke.createElement(cS,{variant:"title",size:"medium",color:"primary"},Kr.t("See Details"))))}i(Cp,"SwapDetailsCompleteModal");import{i18n as Ga}from"@lingui/core";import{CopyIcon as JN,DoneIcon as RN,IconButton as e0,RangoExplorerIcon as t0,Tooltip as LS,Typography as MS,useCopyToClipboard as o0}from"@rango-dev/ui";import Wt from"react";import ZN from"react";import{i18n as KN}from"@lingui/core";import{Alert as AS,IconButton as jN,LinkIcon as XN}from"@rango-dev/ui";import Eo,{Fragment as YN}from"react";import{Alert as HN,ChevronDownIcon as QN,IconButton as qN}from"@rango-dev/ui";import $n,{useState as GN}from"react";import{css as Xr,darkTheme as pS,styled as Ut,Typography as zN}from"@rango-dev/ui";var uS=Ut(ue,{overflowY:"auto","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${pS} &`]:{color:"$secondary500"}}}}}),dS=Ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),mS=Ut("div",{position:"sticky",top:0,zIndex:10,backgroundColor:"$background"}),fS=Ut("div",{padding:"$0 $20 $20 $20"}),LY=Ut("div",{display:"flex",flexDirection:"column",gap:"$10"}),gS=Ut("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),MY=Ut("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),Zo=Xr({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${pS} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),hS=Xr({padding:"$5 0"}),Qa=Xr({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),yS=Xr({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),SS=Xr({width:"100%",padding:"0 $20 $10"}),CS=Ut("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),kS=Ut("div",{display:"flex",flexDirection:"column",gap:"$5"}),qa=Ut(zN,{wordBreak:"break-word"});import{styled as kp}from"@rango-dev/ui";var TS=kp("div",{display:"flex",flexDirection:"column",gap:"$10"}),wS=kp("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),vS=kp("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function bS(t){let{message:e}=t,[o,n]=GN(!1);return $n.createElement(HN,{id:"widget-failed-swap-details-alert",type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&$n.createElement(qN,{id:"widget-swap-details-failed-btn",onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},$n.createElement(wS,{rotated:o},$n.createElement(QN,{size:12,color:"gray"}))),footer:$n.createElement(vS,{open:o},$n.createElement(qa,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(bS,"FailedAlert");import{i18n as xS}from"@lingui/core";import{Alert as Tp,Button as ES}from"@rango-dev/ui";import{PendingSwapNetworkStatus as VN}from"rango-types";import Yr from"react";function IS(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,setNetworkModal:n,message:r,showNetworkModal:a}=t;return e?Yr.createElement(Tp,{type:"warning",id:"widget-swap-details-change-network-alert",title:r.shortMessage,action:Yr.createElement(ES,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{n("switchNetwork"),o()}},xS.t("Change"))}):a===VN.WaitingForConnectingWallet?Yr.createElement(Tp,{type:"warning",title:r.shortMessage,id:"widget-swap-details-warning-alert-connect-wallet-alert",action:Yr.createElement(ES,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{n("connectWallet")}},xS.t("Connect"))}):Yr.createElement(Tp,{id:"widget-swap-details-short-alert",type:"warning",title:r.shortMessage})}i(IS,"WarningAlert");function wp(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(TS,null,s.explorerUrl?.map((f,h,g)=>{let m=h+f.url,C=h===g.length-1,y=(C&&u||p)&&!d,S=C&&s.status==="failed";return Eo.createElement(YN,{key:m},Eo.createElement(AS,{id:"widget-swap-details-tx-alert",type:C&&(y&&"loading"||S&&"error")||"success",title:f.description?`${f.description} Tx`:KN.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(XN,{size:12}))}))}),d&&Eo.createElement(AS,{id:"widget-swap-details-loading-alert",type:"loading",title:a.shortMessage}),s.status!=="failed"&&l&&Eo.createElement(IS,{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a}),s.status==="failed"&&Eo.createElement(bS,{message:a}))}i(wp,"SwapDetailsAlerts");var NS=2e3;var WS=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:P(c,6,6),realValue:c??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:yt(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:P(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:ZN.createElement(wp,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function BS(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(BS,"getStepState");function PS(t){let{requestId:e}=t,[o,n]=o0(NS);return Wt.createElement(mS,{className:Zo()},Wt.createElement(MS,{variant:"label",size:"large",color:"neutral700"},Ga.t("Request ID")),Wt.createElement("div",{className:Qa()},Wt.createElement(MS,{variant:"label",size:"small",color:"neutral700"},e),Wt.createElement(LS,{container:W(),content:o?Ga.t("Copied To Clipboard"):Ga.t("Copy Request ID"),open:o||void 0,side:"bottom",alignOffset:-16,align:"end"},Wt.createElement(e0,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:n.bind(null,e||"")},o?Wt.createElement(RN,{size:16,color:"secondary"}):Wt.createElement(JN,{size:16,color:"gray"}))),Wt.createElement(CS,{target:"_blank",href:`${nu}/swap/${e}`},Wt.createElement(LS,{container:W(),content:Ga.t("View on Rango Explorer"),side:"bottom"},Wt.createElement(t0,{size:20})))))}i(PS,"RequestIdRow");import{i18n as _S}from"@lingui/core";import{Typography as DS}from"@rango-dev/ui";import vp from"react";function $S(t){let{date:e,isFinished:o}=t;return vp.createElement("div",{className:Zo()},vp.createElement(DS,{variant:"label",size:"large",color:"neutral700"},o?_S.t("Finished at"):_S.t("Created at")),vp.createElement(DS,{variant:"label",size:"small",color:"neutral700"},e))}i($S,"SwapDateRow");var u0=3e3;function Ip(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:c}=c0(),l=k().blockchains(),p=k().swappers(),{findToken:u}=k(),d=H().use.retry(),f=p0(),h=Ep(null),[g,m]=Va(!1),[C,y]=Va(null),[S,T]=Va(null),[v,w]=Va(null),A=Ep(C),N=Ep(S),b=We.use.getNotifications(),x=We.use.removeNotification(),E=b(),B=r0(e),I=B?.networkStatus,_=i(Me=>{m(!0),y(Me)},"handleChangeModalState"),U=i(()=>{m(!1)},"handleCloseModal"),G=i(()=>{T({type:"loading",title:zt.t("Change Network"),description:`We\u2019re switching the connected network to ${J?.network}. Please check your wallet.`})},"handleShowSwitchNetworkLoading"),Y=i(()=>{T({type:"success",title:zt.t("Network Changed"),description:"The network has been successfully changed."})},"handleShowSwitchNetworkSucceeded"),L=i(Me=>{T({type:"error",title:zt.t("Network Switch Failed"),description:Me?.message||pe.detailedMessage.content})},"handleShowSwitchNetworkFailed"),ee=Jd(e),J=B?n0(e,B):null,te=B?i0(e,B):null,se=Vy(e),je=Rd(e),le=i(Me=>!!c(Me)?.mobileWallet,"checkIsMobileWallet"),Xe=!!I&&[Fn.WaitingForNetworkChange,Fn.NetworkChangeFailed].includes(I),He=!!te?.walletType&&le(te.walletType),Bt=!!te&&!!J&&a(te.walletType,J.network,J),$=!!J&&Xe&&(He||Bt),z=i(()=>{$&&(G(),s(te.walletType,[{namespace:J.namespace,network:J.network}]).then(()=>{Y()}).catch(Me=>{L(Me)}))},"handleSwitchNetwork"),V=i(()=>{_("switchNetwork"),z()},"handleSwitchNetworkClick"),pe=Zd(e,B,c),Q=WS({swap:e,switchNetworkIsAvailable:$,handleSwitchNetworkClick:V,showNetworkModal:I,setNetworkModal:_,message:pe,blockchains:l,swappers:p}),X=Q.length,[j,Ie]=[e.steps[0],e.steps[X-1]],Ae=Ie?.outputAmount||Ie?.expectedOutputAmountHumanReadable,Ye=e.steps.reduce((Me,Mt)=>Me+parseFloat(Mt.feeInUsd||""),0),Lt=e.steps.find(Me=>Me.diagnosisUrl)?.diagnosisUrl,so=P(parseFloat(Ae||"0")*(Ie?.toUsdPrice||0),4,4),Io=P(parseFloat(e.inputAmount)*(j?.fromUsdPrice||0),4,4),zn=Ae?new OS(Ae).multipliedBy(Ie.toUsdPrice||0).toString():"",Rr=new OS(e.inputAmount).multipliedBy(j?.fromUsdPrice||0).toString(),ns=jt(Io,so),rs=pe.detailedMessage.content||pe.shortMessage,SC=e.status==="success"?zt.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:P(Ae,6,6),token:Q[X-1]?.to.token.displayName,conciseAddress:lo(e.wallets[Q[X-1]?.to.chain.displayName||""]?.address||""),chain:Q[X-1]?.to.chain.displayName}}):Te.createElement(kS,null,Te.createElement(bp,{variant:"body",size:"medium",color:"neutral700",align:"center"},rs?"":zt.t("Transaction was not sent."),ee?`${zt.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:ee.outputAmount,symbol:ee.symbol,blockchain:ee.blockchain}})}`:""),rs&&Te.createElement(qa,{align:"center",variant:"body",size:"medium",color:"neutral700"},Te.createElement("b",null,"Reason:")," ",rs));return xp(()=>{E.find(Mt=>Mt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(w(e.status),x(e.requestId),U()):v&&w(null))},[e.status,e.requestId]),xp(()=>{if($){if(_("switchNetwork"),I===Fn.WaitingForNetworkChange){G();return}if(I===Fn.NetworkChangeFailed){L();return}return}if(I===Fn.WaitingForConnectingWallet){_("connectWallet");return}if(I===Fn.NetworkChanged){_("switchNetwork"),Y();return}C&&["connectWallet","switchNetwork"].includes(C)&&U()},[I]),xp(()=>{if(A.current=C,N.current=S,C==="switchNetwork"&&S?.type==="success"){let Me=setTimeout(()=>{A.current==="switchNetwork"&&N.current?.type==="success"&&U()},u0);return()=>clearTimeout(Me)}},[C,S]),Te.createElement(ae,{header:{title:zt.t("Swap Details"),onCancel:e.status==="running"?()=>_("cancel"):void 0,suffix:e.status!=="running"&&Te.createElement(fo,null,Te.createElement(FS,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>_("delete")},Te.createElement(bp,{size:"medium",variant:"label",color:"error"},zt.t("Delete"))))},footer:je&&!v&&Te.createElement(FS,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let Me=Wi(e,l,u);d(Me),setTimeout(()=>{f("../../")},0)}},zt.t("Try again"))},Te.createElement(uS,{compact:!0,ref:h},Te.createElement(PS,{requestId:o}),Te.createElement($S,{date:se,isFinished:!!e.finishTime}),Te.createElement("div",{className:yS()},Te.createElement(s0,{fee:P(String(Ye),2,2),time:Gn(ci(e.steps)),steps:X}),Te.createElement(wr,{from:{price:{value:P(e.inputAmount,6,6),usdValue:Io,realUsdValue:Rr,realValue:e.inputAmount},token:{displayName:Q[0]?.from.token.displayName||"",image:Q[0]?.from.token.image},chain:{image:Q[0]?.from.chain.image,displayName:Q[0]?.from.chain.displayName||""}},to:{price:{value:P(Ae,6,6),usdValue:so,realUsdValue:zn,realValue:Ae||""},token:{displayName:Q[X-1]?.to.token.displayName||"",image:Q[X-1]?.to.token.image},chain:{image:Q[X-1]?.to.chain.image,displayName:Q[X-1]?.to.chain.displayName||""}},percentageChange:P(ns,2,2),warningLevel:Xt(ns??0)})),Te.createElement("div",{className:SS()},Te.createElement(bp,{variant:"title",size:"small"},zt.t("Swaps steps"))),Te.createElement(a0,{size:8}),Te.createElement(fS,null,Q.map((Me,Mt)=>{let Up=Mt,Hn=e.steps[Mt]&&BS(e.steps[Mt]),CC=Hn==="error"||Hn==="in-progress"||Hn==="warning"||Hn==="completed"&&Mt===Q.length-1;return Te.createElement(l0,{className:"widget-swap-details-step-item-container",key:Up,step:Me,type:"swap-progress",ref:h,state:Hn,hasSeparator:Mt!==0,tabIndex:Up,isFocused:CC,tooltipContainer:W()})}))),Te.createElement(yp,{isOpen:g,state:C,switchNetworkModalState:S,onClose:U,onCancel:r,onDelete:n,message:pe.detailedMessage.content,swap:e,handleSwitchNetwork:V}),Te.createElement(Cp,{open:!!v,diagnosisUrl:Lt,onClose:()=>w(null),status:e.status==="success"?"success":"failed",priceValue:P(Ae,6,6),usdValue:so,realUsdValue:zn,realValue:Ae||"",percentageChange:P(ns,2,2),token:{displayName:Q[X-1]?.to.token.displayName||"",image:Q[X-1]?.to.token.image},chain:{image:Q[X-1]?.to.chain.image},description:SC}))}i(Ip,"SwapDetails");import{i18n as ja}from"@lingui/core";import{Divider as HS,NotFound as h0,Skeleton as Jr,Typography as Xa}from"@rango-dev/ui";import Ee from"react";import{i18n as d0}from"@lingui/core";import{Divider as m0,Skeleton as f0,Typography as g0}from"@rango-dev/ui";import xe from"react";import{css as Ht,styled as Ap}from"@rango-dev/ui";var US=Ap("div",{width:"100%",height:"100%",padding:"$10 $20"}),Zr=Ap("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Ka=Ap("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),a9=Ht({display:"flex",justifyContent:"space-between",alignItems:"center"}),s9=Ht({paddingTop:"$15",display:"flex"}),l9=Ht({padding:"$15 $0"}),c9=Ht({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),p9=Ht({paddingBottom:"$10"}),u9=Ht({display:"flex",justifyContent:"start",alignItems:"center"}),d9=Ht({paddingTop:"$5",display:"flex",alignItems:"center"}),m9=Ht({display:"flex",alignItems:"center"}),f9=Ht({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),zS=Ht({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Np(){return xe.createElement(US,null,xe.createElement(br,{type:"swap-preview"}),xe.createElement("div",{className:"swaps-steps"},xe.createElement(g0,{variant:"title",size:"small"},d0.t("Swaps steps"))),xe.createElement(xe.Fragment,null,xe.createElement(Zr,null,xe.createElement(Ft,{separator:!1}),xe.createElement("div",{className:zS()},xe.createElement(m0,{direction:"horizontal",size:20}),xe.createElement(f0,{height:22,variant:"rectangular"}))),xe.createElement(Ka,null),xe.createElement(Zr,null,xe.createElement(Ft,{separator:!1})),xe.createElement(Ka,null),xe.createElement(Zr,null,xe.createElement(Ft,{separator:!1})),xe.createElement(Ka,null),xe.createElement(Zr,null,xe.createElement(Ft,{separator:!1}))))}i(Np,"LoadingSwapDetails");function QS(t){let{requestId:e,showSkeleton:o}=t;return Ee.createElement(ae,{header:{title:ja.t("Swap Details"),suffix:Ee.createElement(fo,null)}},o&&Ee.createElement(dS,null,Ee.createElement("div",{className:Zo()},Ee.createElement(Xa,{variant:"label",size:"large",color:"neutral700"},`${ja.t("Request ID")}`),Ee.createElement("div",{className:Qa()},Ee.createElement(Xa,{variant:"label",size:"small",color:"neutral700"},Ee.createElement(Jr,{width:60,height:10,variant:"rounded"})),Ee.createElement(HS,{direction:"horizontal",size:4}),Ee.createElement(Jr,{width:16,height:16,variant:"rectangular"}),Ee.createElement(HS,{direction:"horizontal",size:4}),Ee.createElement(Jr,{width:16,height:16,variant:"rectangular"}))),Ee.createElement("div",{className:Zo()},Ee.createElement(Xa,{className:hS(),variant:"label",size:"large",color:"neutral700"},Ee.createElement(Jr,{width:60,height:10,variant:"rounded"})),Ee.createElement(Xa,{variant:"label",size:"small",color:"neutral700"},Ee.createElement(Jr,{width:60,height:10,variant:"rounded"}))),Ee.createElement(Np,null)),!o&&Ee.createElement(gS,null,Ee.createElement(h0,{title:ja.t("Not found"),description:ja.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(QS,"SwapDetailsPlaceholder");function qS(){let{manager:t,state:e}=C0(),o=!e.loadedFromPersistor,n=Tt(t),{requestId:r}=T0(),a=Ge(),{fetchStatus:s}=k();if(!r)return Wp.createElement(k0,{containerStyles:{margin:"20px"},type:"error",title:y0.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&&S0(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?Wp.createElement(QS,{requestId:r,showSkeleton:c}):Wp.createElement(Ip,{swap:d,requestId:r,onCancel:p,onDelete:u})}i(qS,"SwapDetailsPage");import{i18n as GS}from"@lingui/core";import{Divider as w0,getCategoriesCount as v0,SelectableCategoryList as b0,styled as KS,Typography as x0,Wallet as E0,WalletState as I0}from"@rango-dev/ui";import{useWallets as A0}from"@rango-dev/wallets-react";import Qt,{useState as VS}from"react";var N0=KS("div",{display:"flex",justifyContent:"center",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5"}),W0=KS(ue,{textAlign:"center"});function jS(){let{fetchStatus:t}=k(),[e,o]=VS("ALL"),n=k().blockchains(),{config:r}=k(),{state:a}=A0(),{checkHasDeepLink:s,getWalletLink:c}=un(),[l,p]=VS(),u=ne.use.isActiveTab(),{list:d}=vt(),f=Lu(d,n),g=v0(f)!==1,m=Mu(d,e),C=i(y=>{mu(d,r.multiWallets)||p(y)},"handleWalletItemClick");return Qt.createElement(ae,{header:{title:GS.t("Connect Wallets")}},Qt.createElement(W0,null,g&&Qt.createElement(Qt.Fragment,null,Qt.createElement(b0,{setCategory:o,category:e,blockchains:f,isLoading:t==="loading"}),Qt.createElement(w0,{size:24})),Qt.createElement(x0,{variant:"title",size:"xmedium",align:"center"},GS.t("Choose a wallet to connect.")),Qt.createElement(N0,null,m.map((y,S)=>{let T=a(y.type).namespaces,v=`wallet-${S}-${y.type}`,w=fs(y,T),A=y.state;return w&&(A=I0.PARTIALLY_CONNECTED),Qt.createElement(E0,{key:v,...y,state:A,hasDeepLink:s(y.type),link:c(y.type),container:W(),onClick:()=>C(y),isLoading:t==="loading",disabled:!u})}),Qt.createElement(sr,{id:"widget-state-full-connect-modal",wallet:l,onClose:()=>{p(void 0)}}))))}i(jS,"WalletsPage");function XS(){return pm(),el(),B0([{path:F.home,element:ze.createElement(uy,null)},{path:F.routes,element:ze.createElement(hy,null)},{path:F.fromSwap,children:[{index:!0,element:ze.createElement(_a,{type:"source"})},{path:F.blockchains,element:ze.createElement(Ba,{type:"source"})}]},{path:F.toSwap,children:[{index:!0,element:ze.createElement(_a,{type:"destination"})},{path:F.blockchains,element:ze.createElement(Ba,{type:"destination"})}]},{path:F.settings,children:[{index:!0,element:ze.createElement(qy,null)},{path:F.languages,element:ze.createElement(my,null)},{path:F.exchanges,element:ze.createElement(ep,{sourceType:"Exchanges"})},{path:F.bridges,element:ze.createElement(ep,{sourceType:"Bridges"})},{path:F.customTokens,children:[{index:!0,element:ze.createElement(dh,null)},{path:F.addCustomTokens,children:[{index:!0,element:ze.createElement(sf,null)},{path:F.blockchains,element:ze.createElement(Ba,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:F.swaps,children:[{index:!0,element:ze.createElement(Lh,null)},{path:F.swapDetails,element:ze.createElement(qS,null)}]},{path:F.wallets,element:ze.createElement(jS,null)},{path:F.confirmSwap,element:ze.createElement(Yg,null)}])}i(XS,"AppRoutes");import{useQueueManager as j0}from"@rango-dev/queue-manager-rango-preset";import{isEvmBlockchain as X0}from"rango-sdk";import{useContext as Y0,useEffect as Pp,useState as sC}from"react";import{Provider as D0}from"@rango-dev/wallets-react";import Ya,{createContext as $0,useEffect as eC,useMemo as F0,useRef as tC}from"react";import{useEffect as L0}from"react";function YS(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(YS,"hashProviders");function Bp(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=k(),a=n();return L0(()=>{o(),r()},[YS(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(Bp,"useWalletProviders");import{legacyFormatAddressWithNetwork as M0,legacyReadAccountAddress as ZS}from"@rango-dev/wallets-core/legacy";import{Events as On}from"@rango-dev/wallets-react";import{isEvmBlockchain as P0}from"rango-sdk";function JS(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=k(),{onConnectWalletHandler:c,onDisconnectWalletHandler:l}=t,p=s().filter(P0).map(m=>m.name),u=i((m,C)=>{let[y,,S,T,v]=m,w={walletType:y,network:T.network??void 0,accounts:S};c.current?c.current(w):console.warn("onConnectWallet handler hasn't been set. Are you sure?");let A=ms(y,S,p,C.supportedChainNames,v.isContractWallet);A.length&&e(A,v.namespace,T.derivationPath)},"onAccountsEvent"),d=i((m,C,y,S,T)=>{if(C===On.ACCOUNTS){let v=jn(T.supportedBlockchains);y&&u([m,C,y,S,T],{supportedChainNames:v})}C===On.PROVIDER_DISCONNECTED&&(o(m),l.current?l.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),C===On.NAMESPACE_DISCONNECTED&&n(m,y)},"handleUpdatesForHub"),f=i((m,C,y,S,T)=>{if(C===On.ACCOUNTS){let v=jn(T.supportedBlockchains),w=[],A=[];if(y?.forEach(b=>{let{network:x}=ZS(b);p.includes(x)?w.push(b):A.push(b)}),r.filter(b=>b.walletType===m).map(b=>M0(b.address,b.chain)).length>0){if(w.length>0){let b=ms(m,w,p,v,T.isContractWallet);a(m,{chains:b.map(x=>x.chain)})}A.length>0&&a(m,{chains:A.map(b=>{let{network:x}=ZS(b);return x})})}y?u([m,C,y,S,T],{supportedChainNames:v}):(o(m),l.current?l.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}},"handleUpdatesForLegacy"),h=i((m,C,y,S,T)=>{if(C===On.CONNECTED&&y){let v={walletType:m,network:S.network??void 0,accounts:S.accounts??void 0};c.current?c.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(C===On.NETWORK&&y){let v={walletType:m,network:y,accounts:S.accounts??void 0};c.current?c.current(v):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((m,C,y,S,T)=>{T.isHub?d(m,C,y,S,T):f(m,C,y,S,T),h(m,C,y,S,T)},"handler")}}i(JS,"useUpdates");import{LegacyEvents as _0}from"@rango-dev/wallets-core/legacy";function RS(t,e){let[o,n,r,a,s]=e;n!==_0.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i(RS,"propagateEvents");var Za=$0({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function O0(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=k(),a=k().blockchains(),s=k().config,c={walletConnectProjectId:s?.walletConnectProjectId,trezorManifest:s?.trezorManifest,tonConnect:s.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:l}=Bp(s.wallets,c),p=tC(),u=tC(),{handler:d}=JS({onConnectWalletHandler:p,onDisconnectWalletHandler:u});eC(()=>{n().catch(console.log)},[]),eC(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let f=ne.use.isActiveTab(),h=F0(()=>({onConnectWallet:g=>{p.current=g},onDisconnectWallet:g=>{u.current=g}}),[]);return Ya.createElement(Za.Provider,{value:h},Ya.createElement(D0,{allBlockChains:a,providers:l,onUpdateState:(g,m,C,y,S)=>{let T=[g,m,C,y,S];d(...T),t.onUpdateState&&RS(t.onUpdateState,T)},autoConnect:!!f,configs:{wallets:s.wallets}},t.children))}i(O0,"Main");function Ja(t){let{config:e,...o}=t;return Ya.createElement(Ju,{config:e},Ya.createElement(O0,{...o,config:e}))}i(Ja,"WidgetWallets");import{globalCss as U0}from"@rango-dev/ui";var oC=i(()=>U0({"@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 z0}from"@rango-dev/wallets-react";import{useEffect as H0,useRef as Q0}from"react";function nC(){let{connect:t,state:e}=z0(),o=Q0({}),{fetchStatus:n}=k(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);H0(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(nC,"useForceAutoConnect");import{isApprovalTX as q0,RouteEventType as rC,StepEventType as iC,StepExecutionEventStatus as G0,WidgetEvents as Ra}from"@rango-dev/queue-manager-rango-preset";import{useEffect as aC}from"react";function Lp(){let t=We.use.setNotification(),{connectedWallets:e,fetchBalances:o,customTokens:n}=k();aC(()=>{let r=i(a=>{let{event:s,step:c,route:l}=a;if(s.type===iC.TX_EXECUTION&&s.status===G0.TX_SENT&&!q0(c)||s.type===iC.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(C=>C.blockchain===m.blockchain&&C.address?.toLocaleLowerCase()===m.address?.toLocaleLowerCase()&&C.symbol?.toLocaleLowerCase()===m.symbol?.toLocaleLowerCase()));o(u,{selectedCustomTokens:g,shouldFetchCustomTokens:g.length>0})}}t(s,l)},"handleStepEvent");return we.on(Ra.StepEvent,r),()=>we.off(Ra.StepEvent,r)},[we,e]),aC(()=>{let r=i(a=>{let{event:s,route:c}=a;(s.type===rC.FAILED||s.type===rC.SUCCEEDED)&&t(s,c)},"handleRouteEvent");return we.on(Ra.RouteEvent,r),()=>we.off(Ra.RouteEvent,r)},[we])}i(Lp,"useSubscribeToWidgetEvents");import{useManager as V0}from"@rango-dev/queue-manager-react";import{useEffect as K0}from"react";function Mp(){let{isSynced:t,syncNotifications:e}=We(),{manager:o,state:n}=V0();K0(()=>{We.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(Tt(o))},[We.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Mp,"useSyncNotifications");function _p(){nC(),oC(),Lp(),Mp();let t=k().blockchains(),{canSwitchNetworkTo:e}=Ji(),[o,n]=sC(null),[r,a]=sC(),s=Y0(Za),c=t.filter(X0);Pp(()=>()=>lm(),[]),Pp(()=>()=>cm(),[]),j0({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:c,canSwitchNetworkTo:e}),Pp(()=>(Po.init(),We.persist.hasHydrated()||We.persist.rehydrate(),s.onConnectWallet(l=>{n(p=>{if(!p||p.walletType!==l.walletType)return l;let u={...p};return l.network&&(u.network=l.network),l.accounts&&(u.accounts=l.accounts),u})}),s.onDisconnectWallet(l=>{a(l),n(p=>l===p?.walletType?null:p)}),Po.destroy),[])}i(_p,"useBootstrap");import{styled as Z0}from"@rango-dev/ui";var lC=Z0("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Jo(){_p();let{config:t}=k(),{activeTheme:e}=mo(t?.theme||{}),{activeLanguage:o}=wo();return Dp.createElement(J0,{language:o},Dp.createElement(lC,{id:"swap-container",className:e()},Dp.createElement(XS,null)))}i(Jo,"Main");import{setSolanaSignerConfig as SW}from"@rango-dev/signer-solana";import Fp,{useEffect as Op,useMemo as CW}from"react";function cC(){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(cC,"useFetchApiConfig");import{useState as R0}from"react";var eW=i(()=>{let[t,e]=R0(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=du(a);if(s){let c=o(s);e(c)}},"handleLoadCustomFont")}},"useFontLoader"),pC=eW;import{checkWaitingForNetworkChange as tW,makeQueueDefinition as oW}from"@rango-dev/queue-manager-rango-preset";import{Provider as nW}from"@rango-dev/queue-manager-react";import{useWallets as rW}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as iW}from"@rango-dev/wallets-shared";import{isEvmBlockchain as aW}from"rango-types";import sW,{useMemo as lW}from"react";function cW(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=rW(),c=lW(()=>oW({API_KEY:t.apiKey||Gt("API_KEY"),BASE_URL:Gt("BASE_URL"),emitter:{emit:we.emit}}),[t.apiKey]),{blockchains:l,connectedWallets:p}=k(),u=l(),d={blockchains:p.map(v=>({accounts:[v],name:v.chain}))},f=i(async(v,w)=>a(v,w.network,w)?await r(v,[w]):void 0,"switchNetwork"),h=i(v=>!!s(v).mobileWallet,"isMobileWallet"),g=u.filter(v=>v.enabled).reduce((v,w)=>(v[w.name]=w,v),{}),m=u.filter(aW),C=i(v=>{let{supportedChains:w}=s(v);return jn(w)},"getSupportedChainNames"),y=e(),S={meta:{blockchains:g,evmBasedChains:m,evmNetworkChainInfo:iW(m),getSupportedChainNames:C},getSigners:o,wallets:d,providers:y,switchNetwork:f,canSwitchNetworkTo:a,state:n,isMobileWallet:h},T=ne.use.isActiveTab();return sW.createElement(nW,{queuesDefs:[c],context:S,onPersistedDataLoaded:v=>{tW(v)},isPaused:!T},t.children)}i(cW,"QueueManager");var uC=cW;import{useManager as fW}from"@rango-dev/queue-manager-react";import gW,{createContext as hW,useContext as yW}from"react";function dC(){let{findToken:t}=k(),e=k().blockchains(),o=k().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 C=e.find(y=>y.name===u)??null;n(C)}if(d!==void 0){let C=d?t(d)??null:null;r({meta:m,token:C})}if(f!==void 0){let C=e.find(y=>y.name===f)??null;a(C)}if(h!==void 0){let C=h?t(h)??null:null;s({meta:m,token:C})}g!==void 0&&c(g)},"updateQuoteInputs")}i(dC,"useUpdateQuoteInputs");import{cancelSwap as pW,getCurrentNamespaceOfOrNull as uW,getCurrentStep as dW,getRelatedWalletOrNull as mW}from"@rango-dev/queue-manager-rango-preset";var es=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return Tt(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=Wi(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&pW(o)}getCurrentStepInfo(e){let o=dW(e);return{step:o,wallet:o?mW(e,o):null,network:o?uW(e,o)?.network:null}}};var mC=hW(void 0);function $p(t){let{manager:e}=fW(),o=ne.use.isActiveTab(),n=H().use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:c}=k(),l=new es(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=k(),u=Eu(a()),d=k().blockchains(),f=k().tokens(),h=k().swappers(),g=k().fetchStatus,m=wo().resetLanguage,C=We().getNotifications(),y=We().clearNotifications,S=dC(),{fromBlockchain:T,toBlockchain:v,fromToken:w,toToken:A,inputAmount:N}=H()(),b={isActiveTab:o,setCurrentTabAsActive:Po.forceClaim,history:l,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async x=>c(x)},meta:{blockchains:d,tokens:f,swappers:h,loadingStatus:g,findToken:r},resetLanguage:m,notifications:{list:C,clearAll:y},quote:{quoteInputs:{fromBlockchain:T?.name??null,fromToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,toBlockchain:v?.name??null,toToken:A?{symbol:A.symbol,blockchain:A.blockchain,address:A.address}:null,requestAmount:N},updateQuoteInputs:S}};return gW.createElement(mC.Provider,{value:b},t.children)}i($p,"WidgetInfo");function fC(){let t=yW(mC);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(fC,"useWidget");function Un(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{fetchApiConfig:r}=cC(),{handleLoadCustomFont:a}=pC();return Op(()=>{r().catch(console.log)},[]),Op(()=>{n&&a(n)},[n]),CW(()=>{Pu({API_KEY:o?.apiKey||ri,BASE_URL:o?.apiUrl||ou})},[o.apiKey,o.apiUrl]),Op(()=>{t.config?.signers?.customSolanaRPC&&SW("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),Fp.createElement(Ja,{config:o,onUpdateState:e},Fp.createElement(uC,{apiKey:o.apiKey},Fp.createElement($p,null,t.children)))}i(Un,"WidgetProvider");function gC(t){let e=t.config?.externalWallets;return ts.createElement(Ai,null,e?ts.createElement(Jo,null):ts.createElement(Un,{config:t.config??on},ts.createElement(Jo,null)))}i(gC,"Refuel");import os from"react";function hC(t){let e=t.config?.externalWallets;return os.createElement(Ai,null,e?os.createElement(Jo,null):os.createElement(Un,{config:t.config??on},os.createElement(Jo,null)))}i(hC,"Widget");function yC(){let{on:t,off:e}=we;return{on:t,off:e}}i(yC,"useWidgetEvents");var cte={DerivationPath:rr,Namespaces:tr,Detached:nr,isOnDerivationPath:ar,isOnNamespace:ir,isOnDetached:Ao};export{Mee as EventSeverity,sn as MainEvents,Qee as Networks,Vee as PendingSwapNetworkStatus,Cs as QuoteEventTypes,gC as Refuel,Pee as RouteEventType,ls as SUPPORTED_FONTS,cte as StatefulConnect,_ee as StepEventType,Dee as StepExecutionBlockedEventStatus,$ee as StepExecutionEventStatus,bd as SwapModeContext,ot as UI_ID,Ts as UiEventTypes,ks as WalletEventTypes,zee as WalletEvents,qee as WalletTypes,hC as Widget,sn as WidgetEvents,Un as WidgetProvider,Ja as WidgetWallets,fl as customizedThemeTokens,Oee as readAccountAddress,Ro as useStatefulConnect,vt as useWalletList,Ji as useWallets,fC as useWidget,yC as useWidgetEvents,wk as widgetEventEmitter};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|