@rango-dev/widget-embedded 0.58.1-next.5 → 0.58.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/constants/index.d.ts +0 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/store/quote.d.ts.map +1 -1
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/env.d.ts +12 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/sanitizers.d.ts +15 -0
- package/dist/utils/sanitizers.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +10 -10
- package/src/constants/index.ts +0 -1
- package/src/containers/WidgetProvider/WidgetProvider.tsx +3 -2
- package/src/store/quote.ts +2 -1
- package/src/utils/configs.ts +2 -3
- package/src/utils/env.ts +28 -0
- package/src/utils/numbers.ts +4 -0
- package/src/utils/sanitizers.test.ts +43 -0
- package/src/utils/sanitizers.ts +26 -0
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var xC=Object.defineProperty;var i=(t,e)=>xC(t,"name",{value:e,configurable:!0});import{EventSeverity as Iee,RouteEventType as Aee,StepEventType as Nee,StepExecutionBlockedEventStatus as Bee,StepExecutionEventStatus as Wee}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Lee}from"@rango-dev/wallets-core/legacy";import{useWallets as Yi,Events as _ee}from"@rango-dev/wallets-react";import{Networks as $ee,WalletTypes as Fee}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as Uee}from"rango-types";import{Divider as Gk}from"@rango-dev/ui";import po,{useEffect as Vk,useRef as Kk,useState as kd}from"react";import{WalletState as bC}from"@rango-dev/ui";import{useWallets as EC}from"@rango-dev/wallets-react";import{useReducer as IC}from"react";function Op(t){return!!t.derivationPath}i(Op,"isStateOnDerivationPathStep");function Up(t){return!!t.namespace}i(Up,"isStateOnNamespace");var Jr={status:"init",namespace:null,derivationPath:null,selectedNamespaces:null};function zp(t,e){switch(e.type){case"needsNamespace":return{...t,status:"namespace",namespace:e.payload,derivationPath:null};case"needsDerivationPath":return{...t,status:"derivationPath",derivationPath:e.payload};case"detached":return{...t,status:"detached",namespace:{targetWallet:e.payload.targetWallet},selectedNamespaces:e.payload.selectedNamespaces};case"reset":return Jr;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:Jr;default:throw new Error("Action hasn't been defined.")}}i(zp,"reducer");function en(){let{state:t,disconnect:e,connect:o}=EC(),[n,r]=IC(zp,Jr),a=i(async(d,f,h)=>{r({type:"reset"});try{let g=f?.map(m=>({...m,network:void 0}));return await o(d.type,g),{status:"connected"}}catch(g){let m=g?.message?`Error: ${g.message}`:"An unknown error happened during connecting wallet.";if(h?.disconnectOnError)try{await u(d)}catch{console.warn("An error happened during disconnecting wallet after error on connecting.")}throw new Error(m,{cause:g})}},"runConnect"),s=i(async(d,f)=>{let h=d.state===bC.DISCONNECTED,g=f?.forceConnectToNamespaces;if(h){let m=!!d.isHub,y=m?d.properties?.find(C=>C.name==="namespaces")?.value:d.needsNamespace,S=m?d.properties?.find(C=>C.name==="derivationPath")?.value:d.needsDerivationPath;if(g){let C=g.find(k=>!y?.data?.map(x=>x.value).includes(k));if(C)throw new Error(`One of the forced namespaces is not available in the wallet. Forced namespace: ${C}`);if(g.length>1&&S)throw new Error("Derivation path is not supported when multiple namespaces are selected.");return g.length===1&&g[0]&&S?(r({type:"needsDerivationPath",payload:{providerType:d.type,providerImage:d.image,namespace:g[0]}}),{status:"derivation-path"}):await a(d,g.map(k=>({namespace:k})),{...f,disconnectOnError:!0})}if(!y?.data?.length)return await a(d,void 0,f);if(y?.data.length&&y.data.length>1)return r({type:"needsNamespace",payload:{targetWallet:d,defaultSelectedChains:f?.defaultSelectedChains}}),{status:"namespace"};if(y?.data.length===1&&y.data[0]){if(S){let C=y.data[0];return r({type:"needsDerivationPath",payload:{providerType:d.type,providerImage:d.image,namespace:C.value}}),{status:"derivation-path"}}return await a(d,y?.data?.map(C=>({namespace:C.value})),f)}}if(d.isHub&&!f?.forceConnectToNamespaces){let m=d.properties?.find(y=>y.name==="namespaces")?.value;if(m?.data.length&&m.data.length>1)return r({type:"detached",payload:{targetWallet:d,selectedNamespaces:null}}),{status:"Detached"}}return f?.disconnectIfConnected?(await u(d),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),c=i(async(d,f)=>{let h=!!d.isHub,g=h?d.properties?.find(k=>k.name==="namespaces")?.value:d.needsNamespace,m=h?d.properties?.find(k=>k.name==="derivationPath")?.value:d.needsDerivationPath,y=g?.selection==="single",S=f[0];if(!S)throw new Error("To confirm a namespace, you should select at least one namespace.");if(y&&m)return r({type:"needsDerivationPath",payload:{providerType:d.type,providerImage:d.image,namespace:S}}),{status:"derivation-path"};if(!Up(n))throw new Error("Something went wrong on handling namespace. Please retry.");let C=f.map(k=>({namespace:k}));return r({type:"detached",payload:{targetWallet:d,selectedNamespaces:C??null}}),{status:"Detached"}},"handleNamespace"),l=i(async(d,f,h)=>{if(!f)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!Op(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let m=[{namespace:n.derivationPath.namespace,derivationPath:f}],S=!!d.isHub?d.properties?.find(x=>x.name==="namespaces")?.value:d.needsNamespace,C=!!S?.data&&S.data.length>1,k=!!h?.forceConnectToNamespaces;return C&&!k?(r({type:"detached",payload:{targetWallet:d,selectedNamespaces:m??null,derivationPath:f}}),{status:"Detached"}):await a(d,m)},"handleDerivationPath"),p=i(()=>n,"getState"),u=i(async d=>{let f=t(d.type);return f.connected||f.connecting?(await e(d.type),Ao(p)?(r({type:"needsNamespace",payload:{targetWallet:d}}),{status:"namespace"}):{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:c,handleDerivationPath:l,getState:p,resetState:d=>{r(d==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(en,"useStatefulConnect");import{WalletState as Es}from"@rango-dev/ui";import{useWallets as FT}from"@rango-dev/wallets-react";import{detectMobileScreens as OT,KEPLR_COMPATIBLE_WALLETS as UT,WalletTypes as Jn}from"@rango-dev/wallets-shared";import{useCallback as zT,useEffect as HT}from"react";import LT,{createContext as PT,useContext as _T,useEffect as DT,useRef as $T}from"react";import{create as WT}from"zustand";import{persist as MT}from"zustand/middleware";import{allProviders as AC}from"@rango-dev/provider-all";var ns=class{static{i(this,"CacheService")}#e=new Map;get(e){return this.#e.get(e)}set(e,o){this.#e.set(e,o)}remove(e){this.#e.delete(e)}clear(){this.#e.clear()}},tn=new ns;import{defineVersions as Qp,pickVersion as qp,Provider as rs}from"@rango-dev/wallets-core";function Gp({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=is(a);return s instanceof rs?s.id===n:s.config.type===n});r?o.push(r):console.warn(`Couldn't find ${n} provider. Please make sure you are passing the correct name.`)}else n instanceof rs?o.push(Qp().version("1.0.0",n).build()):o.push(Qp().version("0.0.0",n).build())}),o}return t}i(Gp,"matchAndGenerateProviders");function is(t){try{return qp(t,"1.0.0")[1]}catch{return qp(t,"0.0.0")[1]}}i(is,"pickProviderVersionWithFallbackToLegacy");function Vp(t){return t.map(o=>is(o)).map(o=>o instanceof rs?o.id:o.config.type)}i(Vp,"configWalletsToWalletName");function Rr(t,e){return e.find(o=>o.name===t)?.displayName}i(Rr,"getBlockchainDisplayNameFor");function yt(t,e){return e.find(o=>o.name===t)?.shortName}i(yt,"getBlockchainShortNameFor");function Kp(t,e){return e.find(o=>o.name===t)?.logo}i(Kp,"getBlockchainImage");function Qn(t,e){return e.find(o=>o.id===t)?.title}i(Qn,"getSwapperDisplayName");function No(t,e){return e.find(o=>o.name===t)??null}i(No,"findBlockchain");function as(t,e){if(!e||!t)return!1;for(let o of e.feeAssets)if(t?.blockchain===o?.blockchain&&t?.symbol===o?.symbol&&t?.address===o?.address)return!0;return!1}i(as,"isTokenNative");function St(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(St,"createTokenHash");function on(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(on,"isValidTokenAddress");function qn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(c=>{c.forEach(l=>{typeof l!="string"&&(l=St(l));let p=o.tokensMapByTokenHash.get(l);p&&(n[l]=p)})},"addTokens");if(Array.isArray(r))return r.length>0?(a(r),Object.values(n)):Array.from(o.tokensMapByTokenHash.values());if(!r)return Array.from(o.tokensMapByTokenHash.values());let s;if(e.blockchains?.length)s=e.blockchains;else{s=Object.keys(r);let c=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(l=>{let p=o.tokensMapByBlockchainName[l];!c.has(l)&&p&&a(p)})}return s.forEach(c=>{let l=r[c];if(!l&&o.tokensMapByBlockchainName?.[c]){a(o.tokensMapByBlockchainName[c]);return}l&&(l.isExcluded&&o.tokensMapByBlockchainName[c]?(a(o.tokensMapByBlockchainName[c]),l.tokens.forEach(p=>{let u=St(p);delete n[u]})):a(l.tokens))}),Object.values(n)}i(qn,"matchTokensFromConfigWithMeta");function ei(t){let{config:e}=t,o=e.from?.blockchains||[],n=e.to?.blockchains||[];if(!o.length||!n.length)return[];let r=[...o,...n],a=new Set(r);return Array.from(a)}i(ei,"getSupportedBlockchainsFromConfig");function Xp(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(Xp,"makeProvidersOptionsFromConfig");var nn={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"},tonConnect:{manifestUrl:"https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/manifests/tonconnect-manifest.json"}},NC={clientUrl:void 0},BC={liquiditySources:void 0};function jp(t){let e=Xp(t),o={walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t.wallets,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0,tonConnect:e?.tonConnect?.manifestUrl?{manifestUrl:e?.tonConnect.manifestUrl}:void 0};return AC(o).map(a=>a())}i(jp,"generateProviders");var Yp=i((t,e,o)=>{let n=jp({...nn,...t});return{config:{...nn,...t},iframe:NC,campaignMode:BC,allProviders:n,getLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?a.liquiditySources:r.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:r,campaignMode:a}=o();return a.liquiditySources?.length?[]:r},excludeLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?!1:!!r.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:r}=o();return!!r.liquiditySources?.length},updateConfig:r=>{let a=o().config,{_tokensMapByTokenHash:s,_tokensMapByBlockchainName:c}=o(),l=qn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:c,tokensMapByTokenHash:s}}),p=qn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:c,tokensMapByTokenHash:s}});tn.set("supportedSourceTokens",l),tn.set("supportedDestinationTokens",p),e({config:{...a,...r}})},updateCampaignMode:(r,a)=>{let s=o().campaignMode;e({campaignMode:{...s,[r]:a}})},updateIframe:(r,a)=>{let s=o().iframe;e({iframe:{...s,[r]:a}})},buildAndSetProviders:()=>{let{config:r}=o(),a=jp(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=Xp(a);return Gp({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as Zp}from"rango-types";var Jp=[Zp.EVM,Zp.SOLANA],ti="https://raw.githubusercontent.com/rango-exchange/assets/refs/heads/main/common/unknown-image.png";import{RangoClient as VC}from"rango-sdk";import{UI_ID as WC}from"@rango-dev/ui";var oi="c6381a79-2817-4602-83bf-6a641a409e32",Rp="https://api.rango.exchange",eu="https://explorer.rango.exchange",Re={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...WC};import{BlockchainCategories as FC,WalletState as lt}from"@rango-dev/ui";import{legacyReadAccountAddress as OC}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as UC,getCosmosExperimentalChainInfo as zC,isEvmAddress as HC,KEPLR_COMPATIBLE_WALLETS as PW,Networks as wu}from"@rango-dev/wallets-shared";import an from"bignumber.js";import{isCosmosBlockchain as QC}from"rango-types";import MC from"bignumber.js";var pe=new MC(0);import{WalletTypes as LC}from"@rango-dev/wallets-shared";var Bo="~",tu=[LC.LEAP];import{BlockchainCategories as ls,WalletState as $C}from"@rango-dev/ui";import{TransactionType as ni}from"rango-sdk";var ou="Roboto",ss=[{name:"Roboto",value:"Roboto",url:""},{name:"Times New Roman",value:"Times New Roman",url:"https://fonts.cdnfonts.com/css/times-new-roman"},{name:"Arial",value:"Arial",url:""},{name:"Open Sans",value:"Open Sans",url:"https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"},{name:"Noto Sans",value:"Noto Sans",url:"https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Montserrat",value:"Montserrat",url:"https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Poppins",value:"Poppins",url:"https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"},{name:"Roboto Condensed",value:"Roboto Condensed",url:"https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Roboto Mono",value:"Roboto Mono",url:"https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap"},{name:"Oswald",value:"Oswald",url:"https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap"},{name:"Raleway",value:"Raleway",url:"https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Sedan",value:"Sedan",url:"https://fonts.googleapis.com/css2?family=Sedan:ital@0;1&display=swap"},{name:"Inter",value:"Inter",url:"https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap"},{name:"Rubik",value:"Rubik",url:"https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap"},{name:"Lora",value:"Lora",url:"https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&display=swap"},{name:"Barlow Condensed",value:"Barlow Condensed",url:"https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"}];function rn(t){return Array.from(new Set(t))}i(rn,"removeDuplicateFrom");function ri(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(ri,"debounce");function st(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(st,"containsText");function iu(t,e){return t.toLowerCase()===e.toLowerCase()}i(iu,"exactText");function au(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(au,"startWithText");var B=i(()=>document.getElementById(Re.SWAP_BOX_ID),"getContainer"),Wo=i(()=>document.getElementById(Re.EXPANDED_BOX_ID),"getExpanded");function su(t,e,o){let n=!!e&&iu(e,t),r=!!o&&iu(o,t);return n!==r?n?-1:1:0}i(su,"compareExactMatchText");function cs(t,e,o){let n=!!e&&st(e,t),r=!!o&&st(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(cs,"compareContainsText");function ps(t,e,o){let n=!!e&&au(e,t),r=!!o&&au(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ps,"compareStartWithText");function lu(t,e,o){if(!o)return 0;let n=su(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=su(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=ps(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=cs(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ps(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=cs(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=ps(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=cs(o,t.address,e.address);if(r!==0)return r}return 0}i(lu,"compareWithSearchFor");var ii=i((t,e)=>{switch(e){case ls.ALL:return!0;case ls.UTXO:return t===ni.TRANSFER;case ls.OTHER:return t!==ni.TRANSFER&&t!==ni.COSMOS&&t!==ni.EVM;default:return t===e}},"isBlockchainTypeInCategory"),cu=i(t=>ss.find(o=>o.value===t)?.url,"getFontUrlByName");function pu(t,e){let o=!!t.find(n=>n.state===$C.CONNECTED);return e===!1&&o}i(pu,"isSingleWalletActive");function uu(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(uu,"memoizedResult");function du(t,e){let o=new Set;return e.forEach(n=>{o.add(n.blockchain)}),t.filter(n=>o.has(n.name))}i(du,"filterBlockchainsWithAtLeastOneToken");import{BigNumber as Tu}from"bignumber.js";function mu(t){return t.replace(/^0+(?=\d)/g,"")}i(mu,"removeLeadingZeros");function fu(t){return t.replace(/^\.(\d+)/,"0.$1")}i(fu,"ensureLeadingZeroForDecimal");function gu(t){return t.replace(/\B(?=(\d{3})+(?!\d))/g,",")}i(gu,"formatThousandsWithCommas");function hu(t){return t.replace(/\s+/g,"-")}i(hu,"replaceSpacesWithDash");function yu(t){return t.replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"")}i(yu,"stripTrailingZeros");function ai(t){return/^0+(?:\.0+)?$/.test(t)}i(ai,"isZeroValue");function Su(t,e=2){let o=`^(?:0|[1-9]\\d*)(?:\\.\\d{1,${e}})?$`;return new RegExp(o).test(t)}i(Su,"isValidCurrencyFormat");function Cu(t){return/\d+$/.test(t)}i(Cu,"isColorKeyOverridden");var Gn=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),_=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Tu(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Tu(n.toFixed(s,r)).eq(n)){a=s;break}if(n.gte(1e4))return n.toFormat(0,r);if(n.gte(1e3)||n.gte(100))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,1))),r);if(n.gte(1))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,2))),r);if(n.gte(.01))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,4))),r);for(let s=e||4;s<17;s++)if(n.gte(Math.pow(10,-s)))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,s))),r);return n.isEqualTo(0)?"0":n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,8))),r)},"numberToString");var si=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var Pt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),Vn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function ku(t){return ai(t)?"0":yu(t)}i(ku,"sanitizeInputAmount");function Kn(t,e){return GC(t,e)?lt.PARTIALLY_CONNECTED:e.connected?lt.CONNECTED:e.connecting?lt.CONNECTING:e.installed?lt.DISCONNECTED:lt.NOT_INSTALLED}i(Kn,"getWalletConnectionStatus");function vu(t,e,o,n){return o.filter(r=>!tu.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:c,network:l}=t(r);return s&&(!c||!!n&&l!==n)?!1:n?!!a.find(u=>u.name===n):!0}).map(r=>{let{name:a,img:s,installLink:c,showOnMobile:l,needsNamespace:p,supportedChains:u,needsDerivationPath:d,properties:f,isHub:h}=e(r),g=rn(u.map(y=>y.type)),m=Kn(e(r),t(r));return{title:a,image:s,link:UC(c),state:m,type:r,showOnMobile:l,needsNamespace:p,blockchainTypes:g,needsDerivationPath:d,properties:f,isHub:h}})}i(vu,"mapWalletTypesToWalletInfo");function jn(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(jn,"walletAndSupportedChainsNames");function ds(t,e,o,n,r){let a=[];function s(l,p,u){if(!!!a.find(f=>f.chain===l)){let f={address:p,chain:l,walletType:t,isContractWallet:u??!1};a.push(f)}}i(s,"addAccount");let c=n||[];return e.forEach(l=>{let{address:p,network:u}=OC(l),d=c.length>0,f=c.includes(u),h=u===wu.Unknown;if(d&&!f&&!h)return;let m=u===wu.Unknown&&HC(p);if(h&&!m)return;o.includes(u)||m?r?s(u,p.toLowerCase(),r):c.filter(C=>o.includes(C)).forEach(C=>{s(C,p.toLowerCase())}):s(u,p)}),a}i(ds,"prepareAccountsForWalletStore");function Mo(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,c=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:l}=r;l.forEach((p,u)=>{let d=p.from.blockchain,f=p.to.blockchain,h=a===o.swaps.length-1,g=u===l.length-1;(!h&&!g||h&&c!==d||e==="all")&&n.add(d),e==="all"&&n.add(f)})}e==="all"&&n.add(c)}),Array.from(n)}i(Mo,"getQuoteChains");function Xn(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(Xn,"isAccountAndWalletMatched");var xu=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?us(n.usdValue,n.decimals):pe.toFixed();return o.plus(r)},new an(pe));return qC(e.toString())},"calculateWalletUsdValue");function qC(t){let e=t.toString().split(".");return e[0]&&(e[0]=gu(e[0])),e.join(".")}i(qC,"numberWithThousandSeparator");var pi=i((t,e)=>{let o=zC(Object.entries(t).map(([,n])=>n).filter(QC));return o&&!!o[e]?.experimental},"isExperimentalChain");function us(t,e){return new an(t).shiftedBy(-e).toFixed()}i(us,"representAmountInNumber");function ui(t){if(!t)return null;let e=us(t.amount,t.decimals),o=t.usdValue?us(t.usdValue,t.decimals):null,n=_(e,8,8),r=o?_(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(ui,"formatBalance");function bu(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new an(t.usdValue).shiftedBy(-t.decimals):pe,n=e&&e.usdValue?new an(e.usdValue).shiftedBy(-e.decimals):pe;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new an(t.amount).shiftedBy(-t.decimals):pe,n=e&&e.amount?new an(e.amount).shiftedBy(-e.decimals):pe;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(bu,"compareTokenBalance");function qt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(qt,"areTokensEqual");function Eu(t){return t.sort((e,o)=>+(o.state===lt.CONNECTED)-+(e.state===lt.CONNECTED)||+(o.state===lt.PARTIALLY_CONNECTED)-+(e.state===lt.PARTIALLY_CONNECTED)||+(o.state===lt.DISCONNECTED||o.state===lt.CONNECTING)-+(e.state===lt.DISCONNECTED||e.state===lt.CONNECTING))}i(Eu,"sortWalletsBasedOnConnectionState");function lo(t,e=8,o=3){if(t.length<2*e+o)return t;let n=t.slice(0,e),r=t.slice(-e);return`${n}${".".repeat(o)}${r}`}i(lo,"getConciseAddress");function Iu({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Iu,"getAddress");var Au=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Nu(t){return t.map(e=>e.state).join("-")}i(Nu,"hashWalletsState");function Bu(t,e){let o=new Set;return t.forEach(r=>{r.blockchainTypes.forEach(a=>{o.add(a)})}),e.filter(r=>o.has(r.type))}i(Bu,"filterBlockchainsByWalletTypes");function Wu(t,e){return e===FC.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(ii(n,e))return!0;return!1})}i(Wu,"filterWalletsByCategory");function GC(t,e){if(!t.isHub||!t.needsNamespace||!e.connected)return!1;let n=t.needsNamespace.data.filter(r=>!r.unsupported);return t.needsNamespace.selection==="multiple"&&n.some(r=>!e.namespaces?.get(r.value)?.connected)}i(GC,"checkIsWalletPartiallyConnected");var ms={API_KEY:oi};function Gt(t){return ms[t]||""}i(Gt,"getConfig");function Mu(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ms=e,ms}i(Mu,"initConfig");var Lu=20,Pu=25,fs="theme-widget",gs=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>qt(n,t));else if(!Array.isArray(e)){let n=e[t.blockchain];if(n){o=!!n.tokens.some(a=>qt(a,t));let r=n.isExcluded;return!r&&!o||r&&o}}}return o},"isTokenExcludedInConfig"),hs=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),_u=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var di,ct=i(()=>di||(di=new VC(Gt("API_KEY"),Gt("BASE_URL")),di),"httpService");import{i18n as $u}from"@lingui/core";var mi=[.5,1,3],fi=1,sn=5,Yn=30,gi=0;var Xe=(a=>(a[a.NO_RESULT=0]="NO_RESULT",a[a.REQUEST_FAILED=1]="REQUEST_FAILED",a[a.REQUEST_CANCELED=2]="REQUEST_CANCELED",a[a.BRIDGE_LIMIT=3]="BRIDGE_LIMIT",a[a.INSUFFICIENT_SLIPPAGE=4]="INSUFFICIENT_SLIPPAGE",a))(Xe||{});import{WidgetEvents as Du}from"@rango-dev/queue-manager-rango-preset";var ys=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ys||{}),Ss=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(Ss||{}),Cs=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(Cs||{}),ln=(a=>(a[a.RouteEvent=Du.RouteEvent]="RouteEvent",a[a.StepEvent=Du.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(ln||{});function hi(t,e){let o=t.map(a=>a.swapperGroup),n=[];return rn(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(c=>c.swapperGroup===a);if(s){let c=!0;o&&(c=o.some(l=>l===s.swapperGroup)),c&&s.types.map(l=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:l,selected:!e.includes(s.swapperGroup)})})}}),n}i(hi,"getUniqueSwappersGroups");function Fu(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Fu,"sortLiquiditySourcesByGroupTitle");function et(t,e){return e?.[t]==="hidden"}i(et,"isFeatureHidden");function cn(t,e){return e?.[t]==="enabled"}i(cn,"isRoutingEnabled");var Ou=i((t,e,o)=>et("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");function pn(t){return t==gi?{type:"error",message:$u.t("Slippage must be greater than or equal to 0.01")}:t>sn&&t<=Yn?{type:"warning",message:$u.t("Your transaction is at risk of being frontrun due to high slippage tolerance."),quoteValidation:{type:3,slippage:t.toString()}}:null}i(pn,"getSlippageValidation");var Uu=i((t,e)=>({_blockchainsMapByName:new Map,_tokensMapByTokenHash:new Map,_tokensMapByBlockchainName:{},_popularTokens:[],_swappers:[],fetchStatus:"loading",blockchains:o=>{let n=e()._blockchainsMapByName,r=Array.from(n?.values()||[]);if(!o||!o?.type)return r;let a=e().config;if(o.type==="custom-token"){let l=ei({config:a}),p=r;return l.length>0&&(p=p.filter(u=>l.includes(u.name))),p.filter(u=>Jp.includes(u.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(l=>!(s.length>0&&!s.includes(l.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),c=Array.from(n.values()),l=e()._blockchainsMapByName;if(!o||!o.type)return c;let p=o.type==="source"?"from":"to",u=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",d=tn.get(u);d?.length||(d=qn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),tn.set(u,d)),d=Ou(d,s,a.features);let f=e().blockchains({type:o.type});return d.filter(g=>o.blockchain&&g.blockchain!==o.blockchain||!f.some(m=>m.name===g.blockchain)?!1:o.searchFor?!!(st(g.symbol,o.searchFor)||st(g.address||"",o.searchFor)||st(g.name||"",o.searchFor)):!0).sort((g,m)=>{let y=e().isTokenPinned(g,o.type),S=e().isTokenPinned(m,o.type);if(y!==S)return y?-1:1;if(o.getBalanceFor){let I=o.getBalanceFor(g),A=o.getBalanceFor(m),b=bu(I,A);if(b!==0)return b}let C=l.get(g.blockchain),k=l.get(m.blockchain),x=as(g,C),w=as(m,k);if(x!==w)return x?-1:1;if(g.isPopular!==m.isPopular)return g.isPopular?-1:1;if(o.searchFor){let I=lu(g,m,o.searchFor);if(I)return I}return g.isSecondaryCoin!==m.isSecondaryCoin?g.isSecondaryCoin?1:-1:C&&k?C.sort-k.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=St(o),s=n.get(a);return s||(s=r.find(c=>St(c)===a)),s},findNativeToken:o=>{let n=o.feeAssets[0];return e().findToken({blockchain:o.name,address:n.address,symbol:n.symbol})},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>qt(s,o)),swappers:()=>{let{config:o,campaignMode:n}=e(),r=n.liquiditySources?.length?n.liquiditySources:null,a=r??o.liquiditySources,s=r?!1:o.excludeLiquiditySources;return e()._swappers.filter(p=>{let u=a?.includes(p.swapperGroup);return s||!a||a.length===0?!u:u}).sort(Fu)},fetch:async()=>{try{let{routing:o}=e().config,n=cn("enableCentralizedSwappers",o),r=await ct().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,c={},l=r.popularTokens,p=r.swappers.filter(d=>d.enabled);r.blockchains.sort((d,f)=>d.sort-f.sort).forEach(d=>{d.enabled&&a.set(d.name,d)}),r.tokens.forEach(d=>{let f=St(d);c[d.blockchain]||(c[d.blockchain]=[]),s.set(f,d),c[d.blockchain]?.push(f)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:c,_popularTokens:l,_swappers:p})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as KC,Catalonia as jC,Chinese as zu,Denmark as XC,English as YC,Finland as ZC,French as JC,German as RC,Greece as eT,Hungary as tT,India as oT,Indonesian as nT,Italian as rT,Japanese as iT,Korea as aT,Lithuania as sT,Malay as lT,Netherlands as cT,Pakistan as pT,Philippines as uT,Poland as dT,Portuguese as mT,Russian as fT,SaudiArabia as gT,Serbia as hT,Slovakia as yT,SouthAfrica as ST,Spanish as CT,Swahili as TT,Swedish as kT,Thai as wT,Turkish as vT,Ukrainian as xT,Vietnamese as bT}from"@rango-dev/ui";var Hu=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:ST},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:gT},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:KC},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:jC},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:zu},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:zu},{title:"Danish",label:"Dansk",local:"da",SVGFlag:XC},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:cT},{title:"English",label:"English",local:"en",SVGFlag:YC},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:uT},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:ZC},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:JC},{title:"German",label:"Deutsch",local:"de",SVGFlag:RC},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:eT},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:oT},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:tT},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:nT},{title:"Italian",label:"Italiana",local:"it",SVGFlag:rT},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:iT},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:aT},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:sT},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:lT},{title:"Polish",label:"Polski",local:"pl",SVGFlag:dT},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:mT},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:fT},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:hT},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:yT},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:CT},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:TT},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:kT},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:wT},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:vT},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:xT},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:pT},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:bT}],un="en";var Qu=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:fi,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],quoteTokensRate:"default",changeQuoteTokensRate:()=>t(o=>({quoteTokensRate:o.quoteTokensRate==="default"?"reversed":"default"})),addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,c)=>{let l=s===o,p=c<=9;return l&&p}))return;let a=n.filter(s=>!(s===o));t(()=>({preferredBlockchains:[o,...a]}))},setSlippage:o=>t(()=>({slippage:o})),setCustomSlippage:o=>t(()=>({customSlippage:o})),setAffiliateRef:o=>t(()=>({affiliateRef:o})),setAffiliatePercent:o=>t(()=>({affiliatePercent:o})),setAffiliateWallets:o=>t(()=>({affiliateWallets:o})),toggleAllLiquiditySources:(o,n)=>t(r=>{if(n)return{disabledLiquiditySources:[]};let a=rn(o.map(s=>s.swapperGroup));return a.length===r.disabledLiquiditySources.length?{disabledLiquiditySources:[]}:{disabledLiquiditySources:a}}),toggleInfiniteApprove:()=>t(o=>({infiniteApprove:!o.infiniteApprove})),toggleLiquiditySource:o=>t(n=>n.disabledLiquiditySources.includes(o)?{disabledLiquiditySources:n.disabledLiquiditySources.filter(r=>r!=o)}:{disabledLiquiditySources:n.disabledLiquiditySources.concat(o)}),setTheme:o=>t(()=>({theme:o})),setLanguage:o=>t(()=>({language:o})),updateSettings:o=>{let{features:n,theme:r}=o,a=et("theme",n),s=et("language",n),c=et("liquiditySource",n),l=r?.singleTheme,p=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...l&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||un},...c&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||un}})},setCustomToken:o=>{e().fetchCustomTokensBalances({tokens:[o],connectedWallets:e().connectedWallets}),t(n=>({_customTokens:[o,...n._customTokens]}))},deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=ei({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import bs from"bignumber.js";import ET from"mitt";var ve=ET(),IT={on:ve.on,off:ve.off};var qu=i(t=>(e,o,n)=>t(i((...a)=>{let[s,...c]=a;e(l=>({...typeof s=="function"?s(l):s,lastUpdatedAt:+new Date}),...c)},"modifedSet"),o,n),"keepLastUpdated");import Gu from"bignumber.js";function Vt(t){return`${t.blockchain}${Bo}${t.address}${Bo}${t.symbol}`}i(Vt,"createAssetKey");function Vu(t,e){return`${Vt(e)}${Bo}${t}`}i(Vu,"createBalanceKey");function Zn(t){let[e,o,n]=t.split(Bo);return!e||!o||!n?null:{address:o==="null"?null:o,blockchain:e,symbol:n}}i(Zn,"extractAssetFromBalanceKey");function ks(t,e,o){return e.balances?.forEach(n=>{let r=n.price??t.findToken(n.asset)?.usdPrice;t._aggregatedBalances[Vt(n.asset)]?.forEach(s=>{o[s]&&(o[s]={...o[s],usdValue:r?new Gu(r??pe).multipliedBy(o[s].amount).toString():""})})}),o}i(ks,"computeNextBalancesWithNewPrices");function ws(t,e){let o={};return t.balances?.forEach(n=>{let r=Vu(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,c=n.price??e().findToken(n.asset)?.usdPrice,l=c?new Gu(c??pe).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:l};o[r]=p}),o}i(ws,"createBalanceStateForNewAccount");function vs(t,e){for(let o in e){let n=Zn(o);if(n){let r=Vt(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}}return t}i(vs,"updateAggregatedBalanceStateForNewAccount");function AT(t,e){let o=Zn(e);if(!o)return t;let n=Vt(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(AT,"removeBalanceFromAggregatedBalance");function xs(t,e,o){let n=t.connectedWallets.filter(l=>l.walletType===e);t.connectedWallets.forEach(l=>{l.walletType!==e&&(n=n.filter(p=>!(p.chain===l.chain&&p.address===l.address)))}),o?.chains&&o.chains.length>0&&(n=n.filter(l=>o.chains?.includes(l.chain))),o?.namespaces&&o.namespaces.length>0&&(n=n.filter(l=>l.namespace?o.namespaces?.includes(l.namespace):!1));let r={},a=t._aggregatedBalances,s=t._balances;return Object.keys(s).forEach(l=>{let p=Zn(l);if(!p)return;!!n.find(d=>Vu(d.address,{address:p.address,blockchain:d.chain,symbol:p.symbol})===l)?a=AT(a,l):s[l]&&(r[l]=s[l])}),{_balances:r,_aggregatedBalances:a}}i(xs,"computeNextStateAfterWalletBalanceRemoval");function NT(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(NT,"matchWalletDetailsWithConnectedWallet");var BT=uu(),Ku=qu((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,lastUpdatedAt:+new Date,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>o.find(a=>Xn(a,r))?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>o.find(s=>Xn(s,a))?{...a,loading:!1,error:!1,explorerUrl:NT(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>o.find(a=>Xn(a,r))?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n,r)=>{let a=e().connectedWallets,s=o.filter(c=>!a.some(l=>Xn(c,l)));if(s.length>0){let c=s.map(l=>{let p=!a.some(u=>u.chain===l.chain&&u.selected&&u.walletType!==l.walletType);return{address:l.address,chain:l.chain,isContractWallet:l.isContractWallet,explorerUrl:null,walletType:l.walletType,selected:p,namespace:n,derivationPath:r,loading:!1,error:!1}});t(l=>({connectedWallets:[...l.connectedWallets.filter(u=>!c.some(d=>d.walletType===u.walletType&&d.chain===u.chain)),...c]}))}},fetchCustomTokensBalances:async o=>{let{tokens:n,connectedWallets:r}=o,a=n.reduce((l,p)=>((l[p.blockchain]||=[]).push(p),l),{}),s=new Set,c=r.reduce((l,p)=>{let u=`${p.address}-${p.chain}`;return s.has(u)||(s.add(u),a[p.chain]&&(l[p.address]||(l[p.address]=[]),l[p.address]?.push(...a[p.chain]||[]))),l},{});Object.entries(c).forEach(async([l,p])=>{try{let{balances:u}=await ct().getMultipleTokenBalance({assets:p.map(({symbol:d,address:f,blockchain:h})=>({symbol:d,address:f,blockchain:h})),walletAddress:l});if(u){let d=e()._balances,f=e()._aggregatedBalances;u.forEach(h=>{if(parseFloat(h.amount.amount)===0)return;let g={blockChain:h.asset.blockchain,balances:[h],address:l},m={_aggregatedBalances:e()._aggregatedBalances,findToken:e().findToken};ks(m,g,d);let y=ws(g,e);f=vs(f,y),d={...d,...y}}),t(h=>({_balances:{...h._balances,...d},_aggregatedBalances:f}))}}catch(u){console.error(u)}})},setWalletsAsSelected:o=>{let n=e().connectedWallets.map(r=>{let a=!!o.find(c=>c.chain===r.chain&&c.walletType!==r.walletType&&r.selected),s=!!o.find(c=>c.chain===r.chain&&c.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r});t({connectedWallets:n})},newWalletConnected:async(o,n,r)=>{let a=o[0];a&&(ve.emit("walletEvent",{type:"connect",payload:{walletType:a.walletType,accounts:o}}),e().addConnectedWallet(o,n,r),e().fetchBalances(o))},removeBalancesForWallet:(o,n)=>{let r={_balances:e()._balances,_aggregatedBalances:e()._aggregatedBalances,connectedWallets:e().connectedWallets},{_balances:a,_aggregatedBalances:s}=xs(r,o,n);t({_balances:a,_aggregatedBalances:s})},disconnectNamespaces:(o,n)=>{if(e().connectedWallets.find(a=>a.walletType===o)){e().removeBalancesForWallet(o,{namespaces:n}),e()._changeSelectedWalletIfNeededOnRemove(o,{namespaces:n});let a=e().connectedWallets.filter(s=>s.namespace?!(s.walletType===o&&n.includes(s.namespace)):!0);t({connectedWallets:a})}},disconnectWallet:o=>{let n=e().connectedWallets.find(r=>r.walletType===o);if(ve.emit("walletEvent",{type:"disconnect",payload:{walletType:o}}),n){e().removeBalancesForWallet(o),e()._changeSelectedWalletIfNeededOnRemove(o);let r=e().connectedWallets.filter(a=>a.walletType!==o);t({connectedWallets:r})}},_changeSelectedWalletIfNeededOnRemove:(o,n)=>{let r=e().connectedWallets;n?.namespaces&&n.namespaces.length>0&&(r=r.filter(s=>!!s.namespace&&n.namespaces?.includes(s.namespace)));let a=r.filter(s=>s.selected&&s.walletType===o).map(s=>s.chain);if(a.length>0){let s=e().connectedWallets.map(c=>a.includes(c.chain)?(a=a.filter(l=>l!==c.chain),{...c,selected:!0}):c);t({connectedWallets:s})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let{shouldFetchCustomTokens:r=!0,selectedCustomTokens:a}=n||{};await e().fetchMainTokensBalances(o),r&&e().fetchCustomTokensBalances({tokens:a??e().customTokens(),connectedWallets:o})},fetchMainTokensBalances:async(o,n)=>{if(o.length===0||!o[0])return;let r=o[0].walletType;e().setConnectedWalletAsRefetching(o);let a=o.map(l=>({address:l.address,blockchain:l.chain})),s;try{s=await ct().getWalletsDetails(a)}catch(l){e().setConnectedWalletHasError(o),console.error(`Request for fetching balances failed. cause: ${l}`);return}let c=s.wallets;if(c){let l=e()._balances,p=e()._aggregatedBalances;c.forEach(d=>{if(d.failed)return;let f={_balances:l,_aggregatedBalances:p,connectedWallets:e().connectedWallets,findToken:e().findToken};ks(f,d,l);let{_balances:h,_aggregatedBalances:g}=xs(f,r,{chains:[d.blockChain]});if(p=g,l=h,!e().connectedWallets.find(y=>y.walletType===r&&y.address===d.address&&y.chain===d.blockChain))return;let m=ws(d,e);p=vs(p,m),l={...l,...m}}),t(d=>({_balances:{...d._balances,...l},_aggregatedBalances:p})),e().setConnectedWalletRetrievedData(o,c);let{retryOnFailedBalances:u=!0}=n||{};if(u){let d=c.filter(f=>f.failed).map(f=>({chain:f.blockChain,walletType:r,address:f.address}));d.length>0&&await e().fetchMainTokensBalances(d,{retryOnFailedBalances:!1})}}else e().setConnectedWalletHasError(o),console.error("We couldn't fetch your account balances. Seem there is no information on blockchain for them yet.")},getBalances:()=>e()._balances,getBalanceFor:o=>{let n=e().getBalances(),r=Vt(o),a=e()._aggregatedBalances[r]||[];if(a.length===0||!a[0])return null;let s=a[0];if(a.length===1&&n[s])return n[s];let c=n[a[0]];if(!c)return null;let l=c;return a.forEach(p=>{let u=n[p];if(!u)return;let d=new bs(u.amount),f=new bs(l.amount);d.isGreaterThan(f)&&(l=u)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,c)=>{let l=n[c],[,,,p]=c.split(Bo);return l&&p===o&&(s[c]=l),s},{})},getConnectedWalletsDetails:()=>BT(()=>e().connectedWallets.map(n=>{let r=e().getBalancesForWalletAddress(n.address),a=Object.keys(r);return{...n,balances:a.reduce((s,c)=>{let l=r[c],p=Zn(c);if(p&&p.blockchain===n.chain&&l){let u=e().findToken(p),d=l?.amount?new bs(l.amount).shiftedBy(-l.decimals):pe;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:l.amount,decimal:l.decimals,amount:d.toString(),isSupported:!!u,logo:u?.image||null,usdPrice:u?.usdPrice||null})}return s},[])}}),e().lastUpdatedAt)}));function ju(t){return WT()(MT((...e)=>({...Ku(...e),...Uu(...e),...Qu(...e),...Yp(t,...e)}),{name:"user-settings",skipHydration:!0,partialize:e=>({_customTokens:e._customTokens,theme:e.theme,language:e.language,affiliatePercent:e.affiliatePercent,affiliateRef:e.affiliateRef,affiliateWallets:e.affiliateWallets,slippage:e.slippage,customSlippage:e.customSlippage,infiniteApprove:e.infiniteApprove,preferredBlockchains:e.preferredBlockchains,disabledLiquiditySources:e.disabledLiquiditySources,quoteTokensRate:e.quoteTokensRate}),version:1,migrate:(e,o)=>{let n=e;return o===0&&(n._customTokens=n._customTokens.map(r=>({...r,warning:!0}))),n}}))}i(ju,"createAppStore");var Xu=PT(null);function T(){let t=_T(Xu);if(DT(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(T,"useAppStore");function Yu(t){let e=$T();return e.current||(e.current=ju(t.config)),LT.createElement(Xu.Provider,{value:e.current},t.children)}i(Yu,"AppStoreProvider");function bt(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=T(),{state:r,getWalletInfo:a}=FT(),s=T().blockchains(),{handleDisconnect:c}=en(),l=Vp(n()),p=vu(r,a,l,e);p=OT()?p.filter(m=>m.showOnMobile!==!1&&r(m.type).installed):p;let u=Eu(p),d=i(m=>!o.find(y=>y.walletType===m&&y.chain===e),"isExperimentalChainNotAdded"),f=zT(()=>{let m=p?.filter(y=>y.state===Es.CONNECTING)||[];for(let y of m)c(y)},[Nu(p)]);HT(()=>()=>{f()},[]);let h=i(m=>{let y=m.find(C=>C.type===Jn.DEFAULT);return!y||y.state===Es.NOT_INSTALLED?!1:m.filter(C=>C.state!=Es.NOT_INSTALLED&&![Jn.DEFAULT,Jn.WALLET_CONNECT_2,Jn.LEDGER].includes(C.type)&&a(C.type).supportedChains.filter(k=>k.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),g=i((m,y,S)=>pi(S,y)&&d(m)&&!UT.includes(m)||m==Jn.DEFAULT&&!h(p),"shouldExcludeWallet");return{list:u.filter(m=>!g(m.type,e??"",s)),terminateConnectingWallets:f}}i(bt,"useWalletList");import{Modal as VT}from"@rango-dev/ui";import KT from"react";import{create as GT}from"zustand";var Zu="rango-widget";var Rn=class{constructor(e){this.state="not-initiated";this.events={};this.init=()=>{this.initEvents(),this.tryClaim()};this.forceClaim=()=>{if(!this.isClaimed()){let e={name:"force-claim",candidateId:this.tabId};this.channel.postMessage(e),setTimeout(()=>{this.isClaimed()||this.claim()},300)}};this.isClaimed=()=>this.state==="claimed";this.destroy=()=>{this.channel.removeEventListener("message",this.handleMessageEvent),document.removeEventListener("visibilitychange",this.handleVisibilityChange),document.removeEventListener("resume",this.handleResume)};this.handleMessageEvent=e=>{let o=e.data.name;switch(o){case"ping":this.claimedByCurrentTab(e.data.pingAt);break;case"pong":this.alreadyClaimedByAnotherTab();break;case"force-claim":this.forceRelease(e.data.candidateId);break;case"force-release":this.tabId===e.data.candidateId&&this.claim();break;default:throw new Error(`${o} is not supported.`)}};this.handleVisibilityChange=async()=>{document.visibilityState==="visible"&&await this.tryClaim()};this.handleResume=async()=>{this.isClaimed()&&(await this.tryClaim(),this.isClaimed()||this.events.onRelease?.())};this.channel=new BroadcastChannel(Zu),this.tabId=Math.trunc(Math.random()*1e5),this.events=e}static{i(this,"TabManager")}initEvents(){this.channel.addEventListener("message",this.handleMessageEvent),document.addEventListener("visibilitychange",this.handleVisibilityChange),document.addEventListener("resume",this.handleResume)}claimedByCurrentTab(e){let o=this.lastTryClaim&&this.lastTryClaim<e;if(this.isClaimed()||o){let n={name:"pong"};this.channel.postMessage(n);return}}alreadyClaimedByAnotherTab(){this.resetLastCheck()}async tryClaim(){return this.setLastCheck(),new Promise(e=>{setTimeout(()=>{this.check(),e()},300)})}check(){this.state==="not-initiated"&&this.events.onInit?.(),this.lastTryClaim?(this.claim(),this.resetLastCheck()):this.state="not-claimed"}claim(){this.state="claimed",this.events.onClaim?.()}setLastCheck(){this.lastTryClaim=Date.now();let e={name:"ping",pingAt:this.lastTryClaim};this.channel.postMessage(e)}resetLastCheck(){this.lastTryClaim=void 0}forceRelease(e){if(this.isClaimed()){this.state="not-claimed",this.events.onRelease?.();let o={name:"force-release",candidateId:e};this.channel.postMessage(o)}}};var qT=i(t=>{let e=t;e.use={};for(let o of Object.keys(e.getState()))e.use[o]=()=>e(n=>n[o]);return e},"createSelectors"),co=qT;var ne=co(GT()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",showProfileBanner:!1,fetchingApiConfig:!1,showCompactTokenSelector:!1,activateCurrentTab:(o,n)=>{let{showActivateTabModal:r}=e();!r&&n?t({showActivateTabModal:!0}):(r||!n)&&o()},setShowActivateTabModal:o=>{t({showActivateTabModal:o})},setWatermark:o=>{t({watermark:o})},setShowProfileBanner:o=>{t({showProfileBanner:o})},setShowCompactTokenSelector:o=>{t({showCompactTokenSelector:o})}}))),Po=new Rn({onInit:()=>ne.setState({tabManagerInitiated:!0}),onClaim:()=>ne.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>ne.setState({isActiveTab:!1})});function ee(t){let{watermark:e}=ne();return KT.createElement(VT,{hasWatermark:e==="FULL",...t},t.children)}i(ee,"WatermarkedModal");import{i18n as fn}from"@lingui/core";import{Alert as sk,Button as lk,Divider as gn,Image as ck,MessageBox as pk,RadioRoot as uk,WalletImageContainer as dk}from"@rango-dev/ui";import le,{useEffect as mk,useMemo as fk,useState as gk}from"react";import{i18n as ZT}from"@lingui/core";import{Typography as id}from"@rango-dev/ui";import dn from"react";function yi(t,e){return t.find(o=>o.name===e)?.logo}i(yi,"getBlockchainLogo");import{darkTheme as jT,Image as XT,styled as Kt,Typography as YT}from"@rango-dev/ui";var Si=Kt("li",{backgroundColor:"$neutral200",padding:"$16",borderRadius:"$sm",variants:{clickable:{true:{cursor:"pointer"}},hasError:{true:{background:"$error100",[`.${jT} &`]:{backgroundColor:"$error700"}}},unsupported:{true:{cursor:"not-allowed",paddingTop:"$8",paddingBottom:"$8"}}}}),Ci=Kt("div",{display:"flex",gap:"$8",alignItems:"center"}),Ru=Kt("div",{flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between",height:"$40",variants:{showSupportedChains:{true:{justifyContent:"space-between"},false:{justifyContent:"center"}}}}),ed=Kt("div",{flex:"1",display:"flex",alignItems:"center",gap:"$4",opacity:"0.5"}),td=Kt("div",{display:"flex",gap:"$6",alignItems:"center"}),od=Kt("div",{paddingLeft:"48px"}),nd=Kt("div",{display:"flex",gap:"$2",cursor:"pointer",alignItems:"center",width:"fit-content"}),rd=Kt(YT,{maxWidth:"100px"}),Ti=Kt(XT,{variants:{disabled:{true:{opacity:"0.5"}}}});function ki(t){let{namespace:e}=t,o=T().blockchains();return dn.createElement(Si,{unsupported:!0},dn.createElement(Ci,null,dn.createElement(Ti,{src:yi(o,e.id),size:40,disabled:!0}),dn.createElement(ed,null,dn.createElement(id,{variant:"label",size:"large"},e.label),dn.createElement(id,{variant:"body",size:"xsmall"},ZT.t("(Currently not supported)")))))}i(ki,"NamespaceUnsupportedItem");import{Checkbox as rk,Radio as ik}from"@rango-dev/ui";import Bs from"react";import{i18n as Ns}from"@lingui/core";import{ChevronDownIcon as RT,ChevronUpIcon as ek,Divider as tk,Typography as er}from"@rango-dev/ui";import Ae,{useEffect as ok,useState as nk}from"react";import{Image as sd,Tooltip as ld,Typography as JT}from"@rango-dev/ui";import _t from"react";import{styled as ad}from"@rango-dev/ui";var Is=ad("div",{display:"flex",alignItems:"center",padding:0,margin:0}),wi=ad("div",{marginLeft:"-5px",listStyleType:"none",backgroundColor:"$background",borderRadius:"$lg",minWidth:"15px",height:"15px",variants:{firstItem:{true:{marginLeft:0}}},display:"flex",alignItems:"center",justifyContent:"center"});var As=3;function cd(t){let{chains:e}=t;return _t.createElement(Is,{id:"widget-supported-chains-container"},e.slice(0,As).map((o,n)=>_t.createElement(ld,{key:o.name,container:B(),side:"bottom",align:"start",content:o.name,sideOffset:4},_t.createElement(wi,{firstItem:n===0},_t.createElement(sd,{src:o.logo,size:15})))),e.length>As&&_t.createElement(ld,{container:B(),side:"bottom",align:"start",sideOffset:4,content:_t.createElement(Is,null,e.map((o,n)=>_t.createElement(wi,{key:o.name,firstItem:n===0},_t.createElement(sd,{src:o.logo,size:15}))))},_t.createElement(wi,null,_t.createElement(JT,{variant:"body",size:"xsmall"},"+",e.length-As))))}i(cd,"SupportedChainsList");function _o(t){let{namespace:e,error:o,suffix:n,connected:r,address:a,onClick:s}=t,[c,l]=nk(!1),p=T().blockchains();ok(()=>l(!1),[o]);let u=e.getSupportedChains(p),d=!o&&!r&&u.length>1;return Ae.createElement(Si,{hasError:!!o,clickable:!!s,onClick:s},Ae.createElement(Ci,null,Ae.createElement(Ti,{src:yi(p,e.id),size:40}),Ae.createElement(Ru,{showSupportedChains:d||r||!!o},Ae.createElement(td,null,Ae.createElement(er,{variant:"label",size:"large"},e.label),r&&Ae.createElement(er,{variant:"body",size:"small",color:"success500"},Ns.t("Connected")),!!o&&Ae.createElement(er,{variant:"body",size:"small",color:"error500"},Ns.t("Connection failed"))),d&&Ae.createElement(cd,{chains:u}),r&&Ae.createElement(rd,{variant:"body",size:"small",color:"neutral700"},a),o&&Ae.createElement(nd,{onClick:()=>l(f=>!f)},Ae.createElement(er,{variant:"body",size:"small",color:"neutral700",style:{textDecoration:"underline",userSelect:"none",textDecorationSkipInk:"none"}},Ns.t("See why")),c?Ae.createElement(ek,{size:12,color:"gray"}):Ae.createElement(RT,{size:12,color:"gray"}))),n),!!o&&c&&Ae.createElement(Ae.Fragment,null,Ae.createElement(tk,{size:4}),Ae.createElement(od,null,Ae.createElement(er,{variant:"body",size:"small",color:"neutral700"},o))))}i(_o,"NamespaceItem");function pd(t){let{onClick:e,type:o,namespace:n}=t;return Bs.createElement(_o,{namespace:n,onClick:e,suffix:o==="radio"?Bs.createElement(ik,{value:n.value}):Bs.createElement(rk,{checked:t.value})})}i(pd,"NamespaceListItem");import{Button as ak,styled as ud}from"@rango-dev/ui";var vi=ud("ul",{padding:0,paddingBottom:"$20",margin:0}),mn=ud(ak,{minHeight:"$40"});function tr(t){let{targetWallet:e}=t.value,o=e.properties?.find(m=>m.name==="namespaces"),n=e.isHub,r=e.isHub?o?.value.selection==="single":e.needsNamespace?.selection==="single",a=n?o?.value:e.needsNamespace,s=e.image,c=T().blockchains(),[l,p]=gk([]),u=fk(()=>a?.data.filter(m=>!m.unsupported),[e?.type]),d=i(m=>{p(r?[m]:y=>y.includes(m)?y.filter(S=>S!==m):y.concat(m))},"onSelect"),f=u?.length===l.length,h=i(()=>{if(r)throw new Error("onSelectAll should not be called on single selection mode.");f?p([]):u&&p(u.map(m=>m.value))},"onSelectAll"),g=i(m=>r?le.createElement(uk,{value:l?.[0]},m):le.createElement(le.Fragment,null,m),"wrapRadioRoot");return mk(()=>{if(!r&&u)if(t.value.defaultSelectedChains?.length){let m=u.filter(y=>y.getSupportedChains(c).some(S=>t.value.defaultSelectedChains?.includes(S.name)));p(m.map(y=>y.value))}else p(u.map(m=>m.value))},[]),le.createElement(le.Fragment,null,le.createElement(pk,{type:"info",title:fn.t("Connect {wallet}",{wallet:e.title}),description:fn.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect."),icon:le.createElement(dk,null,le.createElement(ck,{src:s,size:45}))}),r?le.createElement(le.Fragment,null,le.createElement(gn,{size:20,className:"_initial_namespace_list_header_alert_top_divider"}),le.createElement(sk,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:fn.t("This wallet can only connect to one chain at a time. ")}),le.createElement(gn,{size:30,className:"_initial_namespace_list_header_alert_bottom_divider"})):le.createElement(le.Fragment,null,le.createElement(gn,{size:30,className:"_initial_namespace_list_header_button_top_divider"}),le.createElement(lk,{style:{marginLeft:"auto"},id:"widget-name-space-select-all-btn",size:"xsmall",variant:"ghost",type:"primary",onClick:h},f?fn.t("Deselect all"):fn.t("Select all")),le.createElement(gn,{size:10,className:"_initial_namespace_list_header_button_bottom_divider"})),le.createElement(vi,null,g(le.createElement(le.Fragment,null,a?.data.map((m,y,S)=>le.createElement(le.Fragment,{key:m.id},m.unsupported?le.createElement(ki,{namespace:m}):le.createElement(pd,{value:l.includes(m.value),namespace:m,type:r?"radio":"checkbox",onClick:()=>d(m.value)}),y!==S.length-1&&le.createElement(gn,{size:10})))))),le.createElement(gn,{size:20}),le.createElement(mn,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!l.length,onClick:()=>t.onConfirm(l)},fn.t("Connect")))}i(tr,"Namespaces");import{i18n as or}from"@lingui/core";import{Alert as wk,Button as vk,Divider as hn,Image as xk,MessageBox as bk,WalletImageContainer as Ek}from"@rango-dev/ui";import{useWallets as Ik}from"@rango-dev/wallets-react";import de from"react";import{styled as hk}from"@rango-dev/ui";var dd=hk("div",{display:"flex",justifyContent:"end"});import{i18n as Ws}from"@lingui/core";import{Button as yk,Spinner as Sk}from"@rango-dev/ui";import Ms,{useLayoutEffect as Ck,useRef as Tk,useState as kk}from"react";function md(t){let{namespace:e,initialConnect:o,disabled:n,state:r,handleConnect:a,handleDisconnect:s}=t,[c,l]=kk(null),p=Tk(!1);Ck(()=>{o&&!p.current&&u()},[]);let u=i(async g=>{try{p.current=!0,await a(g)}catch(m){l(m)}finally{p.current=!1}},"handleConnectNamespace"),d=i(async()=>{l(null),r.connected?await s():u({shouldAskForDerivationPath:!0})},"handleButtonClick"),f=i(()=>{let g=r.accounts?.[0]?.split(":"),m=g?.[g.length-1];return!r.connected||!m?null:lo(m)},"getConnectedAddress"),h=i(()=>r.connected?Ws.t("Disconnect"):c?Ws.t("Try again"):Ws.t("Connect"),"getButtonText");return Ms.createElement(_o,{namespace:e,connected:r.connected,error:c?.message,address:f(),suffix:r.connecting?Ms.createElement(Sk,{color:"info"}):Ms.createElement(yk,{id:"widget-name-space-connect-btn",variant:"ghost",type:r.connected?"error":"primary",size:"xsmall",onClick:async()=>d(),disabled:n},h())})}i(md,"NamespaceDetachedItem");function nr(t){let{value:e,selectedNamespaces:o,onConfirm:n,confirmText:r=or.t("Done"),onDisconnectWallet:a,navigateToDerivationPath:s}=t,{targetWallet:c}=e,{connect:l,disconnect:p,state:u}=Ik(),d=c.type,f=u(d),h=c.properties?.find(x=>x.name==="namespaces"),g=c.properties?.find(x=>x.name==="derivationPath"),m=h?.value.selection==="single",y=i(async(x,w)=>{m&&await p(d),g&&w?.shouldAskForDerivationPath?s(x):await l(d,[{namespace:x,network:"",derivationPath:w?.derivationPath??void 0}])},"handleConnectNamespace"),S=i(async x=>{await p(d,[x])},"handleDisconnectNamespace"),C=i(()=>m?de.createElement(de.Fragment,null,de.createElement(hn,{size:20,className:"_detached_namespace_list_header_alert_top_divider"}),de.createElement(wk,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:or.t("This wallet can only connect to one chain at a time.")}),de.createElement(hn,{size:30,className:"_detached_namespace_list_header_alert_bottom_divider"})):de.createElement(de.Fragment,null,de.createElement(hn,{size:30,className:"_detached_namespace_list_header_button_top_divider"}),de.createElement(dd,null,de.createElement(vk,{id:"widget-detached-disconnect-wallet-btn",variant:"ghost",type:"error",size:"xsmall",disabled:f.connecting||!f.connected,onClick:a},or.t("Disconnect wallet"))),de.createElement(hn,{size:16,className:"_detached_namespace_list_header_button_bottom_divider"})),"renderNamespaceListHeader"),k=i(x=>{if(x.unsupported)return de.createElement(ki,{namespace:x});let w=o?.find(b=>b.namespace===x.value),I=f.namespaces?.get(x.value);if(!I)throw new Error(`State for ${x.value} was not found!`);let A=m&&f.connecting;return de.createElement(md,{namespace:x,initialConnect:!!w,disabled:A,state:I,handleConnect:async b=>y(x.value,{derivationPath:w?.derivationPath,shouldAskForDerivationPath:b?.shouldAskForDerivationPath}),handleDisconnect:async()=>S(x.value)})},"renderNamespaceItem");return de.createElement(de.Fragment,null,de.createElement(bk,{type:"info",title:or.t("Connect {wallet}",{wallet:c.type}),description:or.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect or disconnect."),icon:de.createElement(Ek,null,de.createElement(xk,{src:c.image,size:45}))}),C(),de.createElement(vi,{id:"widget-detached-namespace-list"},c.needsNamespace?.data.map((x,w,I)=>de.createElement(de.Fragment,{key:x.id},k(x),w!==I.length-1&&de.createElement(hn,{size:10})))),de.createElement(hn,{size:20}),de.createElement(mn,{id:"widget-name-space-confirm-btn",type:"primary",onClick:n},r))}i(nr,"Detached");import{i18n as yn}from"@lingui/core";import{Divider as Wk,Image as Mk,MessageBox as Lk,Select as Pk,TextField as _k}from"@rango-dev/ui";import Et,{useEffect as Dk,useState as gd}from"react";import{namespaces as Ak}from"@rango-dev/wallets-shared";var xi={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Ls(t){let e=t?Ak[t]?.derivationPaths:null;return e?[...e,xi]:[]}i(Ls,"getDerivationPaths");import{Button as Nk,styled as Ps,Typography as Bk}from"@rango-dev/ui";var fd=Ps("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),_s=Ps(Bk,{paddingLeft:"$10"}),Ds={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"},a_=Ps(Nk,{minHeight:"$40"});var hd="0";function rr(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=gd(null),[c,l]=gd(hd),p=a===xi.id,u=Ls(o),d=i(({value:h})=>{let g=u?.find(m=>m.id===h);g&&(a===xi.id&&Number.isNaN(Number(c))&&l(hd),s(g.id))},"handleDerivationPathItemClick"),f=i(()=>{let h=u.find(g=>g.id===a);if(h)e(h.generateDerivationPath(c));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return Dk(()=>{s(Ls(o)[0]?.id||null)},[o]),Et.createElement(Et.Fragment,null,Et.createElement(Lk,{type:"info",title:yn.t("Select Derivation Path"),description:yn.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Et.createElement(Mk,{src:n,size:45})}),Et.createElement(fd,{className:"_derivation_path_inputs_container"},Et.createElement(_s,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},yn.t("Choose Derivation Path Template")),Et.createElement(Pk,{id:"widget-derivation-path-template-select",value:a||"",options:u.map(h=>({value:h.id,label:h.label})),variant:"filled",handleItemClick:d,styles:{trigger:Ds}}),Et.createElement(Wk,{size:20}),Et.createElement(_s,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},p?yn.t("Enter Path"):yn.t("Enter Index")),Et.createElement(_k,{id:"widget-derivation-path-template-input",type:p?"text":"number",variant:"contained",value:c,onChange:h=>l(h.target.value),style:Ds})),Et.createElement(mn,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:f,disabled:!u||!a||!c},yn.t("Confirm")))}i(rr,"DerivationPath");import{i18n as Sn}from"@lingui/core";import{Image as Ok,MessageBox as Fs,WalletImageContainer as Uk,WalletState as zk}from"@rango-dev/ui";import{useWallets as Hk}from"@rango-dev/wallets-react";import Do from"react";import{keyframes as $k,styled as $s}from"@rango-dev/ui";var y_=$s("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),yd=$s("div",{position:"relative"}),Fk=$k({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Sd=$s("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${Fk} 1s linear infinite`,top:0,bottom:0,right:0,left:0});function Os(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a,getWalletInfo:s}=Hk();return Kn(s(n),a(n))===zk.CONNECTED?Do.createElement(Fs,{type:"success",title:Sn.t("Wallet Connected"),description:Sn.t("Your wallet is connected, you can use it to swap.")}):o?Do.createElement(Fs,{type:"error",title:Sn.t("Failed to Connect"),description:o||Sn.t("Your wallet is not connected. Please try again.")}):Do.createElement(Fs,{type:"loading",title:Sn.t("Connecting to your wallet"),description:Sn.t("Click connect in your wallet popup."),icon:Do.createElement(yd,null,Do.createElement(Uk,null,Do.createElement(Ok,{src:r,size:45})),Do.createElement(Sd,null))})}i(Os,"ConnectStatus");import{i18n as Us}from"@lingui/core";import{Button as Qk,Divider as Cd,MessageBox as qk}from"@rango-dev/ui";import bi from"react";function zs(t){let{displayName:e,onConfirm:o,id:n}=t;return bi.createElement(qk,{id:n,title:Us.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:Us.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},bi.createElement(Cd,{size:18}),bi.createElement(Cd,{size:32}),bi.createElement(Qk,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},Us.t("Confirm")))}i(zs,"ExperimentalChain");function Td(t,e){return t().status==="init"&&!!e}i(Td,"isOnStatus");function ir(t){return t().status==="namespace"}i(ir,"isOnNamespace");function ar(t){return t().status==="derivationPath"}i(ar,"isOnDerivationPath");function Ao(t){return t().status==="detached"}i(Ao,"isOnDetached");var jk=3e3,Xk=300;function sr(t){let e=Kk(),[o,n]=kd(!1),[r,a]=kd(),s=i(w=>{a(w.message)},"catchErrorOnHandle"),{terminateConnectingWallets:c}=bt(),{handleConnect:l,handleDerivationPath:p,handleNamespace:u,getState:d,resetState:f,handleDisconnect:h}=en(),g=i(w=>{u(t.wallet,w).then(k).catch(s)},"handleConfirmNamespaces"),m=i(()=>{S()},"handleDetachedConfirm"),y=i(w=>{if(!w)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");p(t.wallet,w).then(k).catch(s)},"handleDerivationPathConfirm"),S=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),f(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),k=i((w,I)=>{let A=w.status==="connected",b=["disconnected","disconnected-unhandled"].includes(w.status);A?(t.onConnect?.(),I||(e.current=setTimeout(S,jk))):b&&S()},"afterConnected"),x=i(w=>{t.wallet?.needsDerivationPath&&u(t.wallet,[w])},"handleNavigateToDerivationPath");return Vk(()=>{if(t.wallet){C();let w=!1,I=!0;i(()=>{setTimeout(()=>{I=!1,w||n(!0)},Xk)},"beforeConnecting")(),l(t.wallet,{disconnectIfConnected:!0,defaultSelectedChains:t.options?.defaultSelectedChains}).then(b=>{["namespace","Detached","derivation-path"].includes(b.status)||(w=!0),k(b,I)}).catch(s)}},[t.wallet]),po.createElement(ee,{id:t.id,open:o,onClose:S,onExit:()=>{C(),c(),t.onClose&&t.onClose()},container:B()},Td(d,t.wallet)&&po.createElement(po.Fragment,null,po.createElement(Os,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),po.createElement(Gk,{direction:"vertical",size:32})),ir(d)&&po.createElement(tr,{onConfirm:g,value:d().namespace}),ar(d)&&po.createElement(rr,{onConfirm:y,value:d().derivationPath}),Ao(d)&&po.createElement(nr,{onConfirm:m,onDisconnectWallet:()=>void h(d().namespace.targetWallet),value:d().namespace,selectedNamespaces:d().selectedNamespaces,navigateToDerivationPath:x}))}i(sr,"StatefulConnectModal");import es from"react";import Yk,{Fragment as Zk}from"react";import{MemoryRouter as Jk,useInRouterContext as Rk}from"react-router";function Ei({children:t}){let o=Rk()?Zk:Jk;return Yk.createElement(o,null,t)}i(Ei,"AppRouter");import{I18nManager as eB}from"@rango-dev/ui";import Pp from"react";import Ue from"react";import{useRoutes as M0}from"react-router-dom";var $={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as Tn,useRef as Li}from"react";import ot from"bignumber.js";import{create as em}from"zustand";import{subscribeWithSelector as tm}from"zustand/middleware";import{createContext as ew,useContext as tw}from"react";var wd=ew({swapMode:"swap",isMultiMode:!1});function tt(){let{swapMode:t,isMultiMode:e}=tw(wd);return{swapMode:t,isMultiMode:e}}i(tt,"useSwapMode");import{i18n as Tt}from"@lingui/core";import{getRelatedWalletOrNull as rw,RouteEventType as PD}from"@rango-dev/queue-manager-rango-preset";import He from"bignumber.js";import{PendingSwapNetworkStatus as cr}from"rango-types";import{i18n as ze}from"@lingui/core";var re=i(()=>({genericServerError:ze.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:ze.t("Please reset your liquidity sources."),description:ze.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:ze.t("No Routes Found."),description:ze.t("Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination.")},bridgeLimitErrors:{increaseAmount:ze.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:ze.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:ze.t("High Price Impact"),title:ze.t("Price impact is too high!"),description:ze.t("The price impact is significantly higher than the allowed amount."),confirmMessage:ze.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:ze.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:ze.t("USD Price Unknown"),title:ze.t("USD Price Unknown, Cannot calculate Price Impact."),description:ze.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:ze.t("Confirm USD Price Unknown")}}),"errorMessages");function vd(t){return t.type===0?t.diagnosisMessage??re().noResultError.title:t.type===1?t.diagnosisMessage??re().genericServerError:""}i(vd,"getQuoteErrorMessage");import{i18n as Ii}from"@lingui/core";var $o=i(()=>({connectWallet:Ii.t("Connect Wallet"),swap:Ii.t("Swap"),swapAnyway:Ii.t("Swap anyway"),ethWarning:Ii.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function Hs(t,e){return{"Network Fee":e("Network Fee"),"Swapper Fee":e("Protocol Fee"),"Affiliate Fee":e("Affiliate Fee"),"Outbound network fee":e("Outbound Fee"),"Rango Fee":e("Rango Fee")}[t]}i(Hs,"getFeeLabel");var Qs=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],xd=100,bd=30,Ed=15,Id=60;var Ad=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Nd=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as nw}from"@rango-dev/queue-manager-rango-preset";import TD from"bignumber.js";function Wd(t,e){if(e===null)return null;let o=e?.find(n=>n.blockchain===t.chain)?.wallets.find(n=>n.address?.toLowerCase()===t.address.toLowerCase());return o?o.requiredAssets:null}i(Wd,"getRequiredBalanceOfWallet");function Xt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Xt,"getPriceImpactLevel");function Ai(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=nw(t.steps);if(!r||!n)return{fromBlockchain:null,fromToken:void 0,toBlockchain:null,toToken:void 0,inputAmount:""};let s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},c=No(a?a.toBlockchain:n.fromBlockchain,e),l=No(r.toBlockchain,e),p=o(a?{blockchain:c?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:c?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),u=o(s),d=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:c,fromToken:p,toBlockchain:l,toToken:u,inputAmount:d}}i(Ai,"createRetryQuote");function Cn(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=lr(o),s=Ct(o);if(o&&a&&s){let p=jt(a.toString(),s.toString());if(!!p&&Dd(a,p)){let d=Bi(o?.swaps,n),f=Xt(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:d,warningLevel:f}}}if(e&&Od(e,o))return{type:4,usdValueChange:_(Ct(o)?.minus(Ct(e)??0).toString()??"0",null,2),percentageChange:_(jt(Ct(e)??"1",Ct(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let c=Wi(o.swaps),l=r>sn;if(Fd(t.userSlippage.toString(),c)){if(l&&parseFloat(c??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:$d(o,r),minRequiredSlippage:c};return null}i(Cn,"generateQuoteWarnings");function Md(t){return![4].includes(t.type)}i(Md,"isQuoteWarningConfirmationRequired");function jt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:qs(t.toString(),e.toString());return n&&n<0?n:null}i(jt,"getPriceImpact");var Ld=i(t=>{let e=new Set,o=[];return t.forEach(n=>{e.has(n.from.chain.displayName)||(e.add(n.from.chain.displayName),o.push(n.from.chain)),e.has(n.to.chain.displayName)||(e.add(n.to.chain.displayName),o.push(n.to.chain))}),o},"getUniqueBlockchains"),Ni=i((t,e)=>e.sort((o,n)=>{let r=i(p=>p.scores?.find(u=>u.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let c=o.requestId.toLowerCase(),l=n.requestId.toLowerCase();return c.localeCompare(l)}),"sortQuotesBy"),Pd=i((t,e,o)=>{let n=e[0];if(!e.length||!n)return null;if(!t)return{requestAmount:o,validationStatus:null,...n};let r=new Set(t.swaps.map(s=>s.swapperId)),a=e.find(s=>{let c=new Set(s.swaps.map(l=>l.swapperId));return Array.from(r).every(l=>c.has(l))});return{requestAmount:o,validationStatus:null,...a||n}},"getDefaultQuote"),_d=i(t=>{let e=i((o,n)=>{let r=Qs.indexOf(o.value),a=Qs.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function Dd(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Ad.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new He(r)))}i(Dd,"hasHighValueLoss");function Ud(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new He(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new He(e.fromAmountMaxValue):null;return e.fromAmountRestrictionType==="EXCLUSIVE"?o?.gte(e.fromAmount)||n?.lte(e.fromAmount):o?.gt(e.fromAmount)||n?.lt(e.fromAmount)}).length>0}i(Ud,"hasLimitError");function zd(t){let e=(t||[]).filter(c=>{let l=c.fromAmountMinValue?new He(c.fromAmountMinValue):null,p=c.fromAmountMaxValue?new He(c.fromAmountMaxValue):null;return c.fromAmountRestrictionType==="EXCLUSIVE"?l?.gte(c.fromAmount)||p?.lte(c.fromAmount):l?.gt(c.fromAmount)||p?.lt(c.fromAmount)})[0];if(!e)return{swap:void 0,fromAmountRangeError:"",recommendation:""};let o=e.fromAmountMinValue?new He(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new He(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=Tt.t({id:"Required: >= {min} {symbol}",values:{min:_(o,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=Tt.t({id:"Required: > {min} {symbol}",values:{min:_(o,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=Tt.t({id:"Required: <= {max} {symbol}",values:{max:_(n,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=Tt.t({id:"Required: < {max} {symbol}",values:{max:_(n,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(zd,"getLimitErrorMessage");function Hd(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:c,needsToWarnEthOnPath:l}=t;return e!=="success"?{title:$o().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||c||!r||r==="0"?{title:$o().swap,action:"confirm-swap",disabled:!0}:s?{title:$o().swapAnyway,action:"confirm-warning",disabled:!1}:l?{title:$o().ethWarning,action:"confirm-warning",disabled:!1}:{title:$o().swap,action:"confirm-swap",disabled:!1}:{title:$o().connectWallet,action:"connect-wallet",disabled:!1}}i(Hd,"getSwapButtonState");function Gs(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(pe))&&e&&e!=="0"&&n!==0)}i(Gs,"canComputePriceImpact");function Vs(t,e){let o=pe;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(!r||r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new He(r.amount).multipliedBy(a||0))}return o}i(Vs,"getUsdFeeOfStep");function Bi(t,e){return t.reduce((o,n)=>o.plus(Vs(n,e)),pe)}i(Bi,"getTotalFeeInUsd");function Ks(t){let e=pe,o=new He(t.price||0);return e=e.plus(new He(t.amount).multipliedBy(o)),e}i(Ks,"getUsdFee");function Qd(t){return t.reduce((e,o)=>e.plus(Ks(o)),pe)}i(Qd,"getTotalFeesInUsd");function qd(t){return t.reduce((e,o)=>{for(let n of o.fee){let r=n.name,a=n.expenseType!=="DECREASE_FROM_OUTPUT"?e.payable:e.nonePayable;a[r]=[...a[r]||[],n]}return e},{payable:{},nonePayable:{}})}i(qd,"getFeesGroup");function Gd(t){let e=new Map;return t.forEach((o,n)=>{o.recommendedSlippage?.error&&e.set(n,o.recommendedSlippage.slippage)}),e.size>0?Object.fromEntries(e):null}i(Gd,"checkSlippageErrors");function $d(t,e){let o=new Map;return t?.swaps.forEach((n,r)=>{n.recommendedSlippage?.slippage&&parseFloat(n.recommendedSlippage.slippage)>e&&o.set(r,n.recommendedSlippage.slippage)}),o.size>0?Object.fromEntries(o):null}i($d,"checkSlippageWarnings");function Wi(t){return t.map(o=>o.recommendedSlippage)?.map(o=>o?.slippage||"0")?.filter(o=>parseFloat(o)>0)?.sort((o,n)=>parseFloat(n)-parseFloat(o))?.find(()=>!0)||null}i(Wi,"getMinRequiredSlippage");function Fd(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(Fd,"hasProperSlippage");function Vd(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:c,excludeLiquiditySources:l,slippage:p,affiliateRef:u,affiliatePercent:d,affiliateWallets:f,destination:h,contractCall:g}=t,m=a?.reduce((C,k)=>(C[k.chain]=k.address,C),{}),y=[];return r?.forEach(C=>{y.push({blockchain:C.chain,addresses:[C.address]})}),{amount:n.toString(),affiliateRef:u??void 0,affiliatePercent:d??void 0,affiliateWallets:f??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:y,selectedWallets:m??{},slippage:p.toString(),contractCall:g,...h&&{destination:h},...l&&{swapperGroups:s.concat(c??[]),swappersGroupsExclude:!0},...!l&&{swapperGroups:c?.filter(C=>!s.includes(C)),swappersGroupsExclude:!1}}}i(Vd,"createQuoteRequestBody");function Kd(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType,derivationPath:n.derivationPath},o),{})}i(Kd,"getWalletsForNewSwap");function lr(t){let e=t.requestAmount,o=t.swaps[0]?.from.usdPrice;if(!(!e||!o))return new He(e).multipliedBy(o)}i(lr,"getUsdInputFrom");function Ct(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1]?.to.usdPrice;if(!(!e||!o))return new He(e).multipliedBy(o)}i(Ct,"getUsdOutputFrom");function qs(t,e){return new He(e).div(new He(t)).minus(1).multipliedBy(xd).toNumber()}i(qs,"getPercentageChange");function Od(t,e){let o=lr(t),n=Ct(t),r=Ct(e);if(!o||!n||!r)return!1;let a=qs(n.toString(),r.toString());return Nd.some(({threshold:s,minInput:c})=>a<=s&&o.isGreaterThanOrEqualTo(c))}i(Od,"isOutputAmountChangedExcessively");function jd(t,e,o){let n=t.validationStatus,r=Mo({filter:"required",quote:t});return e.sort((s,c)=>r.indexOf(s.chain)-r.indexOf(c.chain)).flatMap(s=>Wd(s,n)||[]).filter(s=>!s.ok).map(s=>{let c=s.asset.symbol,l=_(new He(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=_(new He(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=Tt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=Tt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=Tt.t(" for input and network fee")),Tt.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:p,symbol:c,reason:u,currentAmount:l,blockchain:yt(s.asset.blockchain,o)}})})}i(jd,"generateBalanceWarnings");function pr(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==cr.NetworkChanged}i(pr,"isNetworkStatusInWarningState");function Xd(t,e,o){let n="bellow button or",r=t.extraMessage,a=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(n)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(n,"")),pr(e)){r=t.networkStatusExtraMessage||"",a=t.networkStatusExtraMessageDetail||"";let p=(e?rw(t,e):null)?.walletType,u=p?o?.(p)?.name:null;switch(e?.networkStatus){case cr.WaitingForConnectingWallet:r=u?Tt.t("Connect {wallet}",{wallet:u}):r;break;case cr.WaitingForQueue:r=r||Tt.t("Waiting for other running tasks to be finished");break;case cr.WaitingForNetworkChange:r=r||Tt.t("Waiting for changing wallet network");break;case cr.NetworkChangeFailed:r=r||Tt.t("The network switch could not be completed. Please try again, or switch the network manually in your wallet.");break;default:r=r||"";break}}a=a||"",r=r||"";let c=r?.indexOf("code")!==-1&&r?.indexOf("reason")!==-1;return{shortMessage:r,detailedMessage:{content:a,long:c}}}i(Xd,"getSwapMessages");function Yd(t){let e=null;if(t.status==="failed"){let o=t.steps.slice().reverse().filter(n=>n.status==="success")[0];o&&(e={blockchain:o.toBlockchain,symbol:o.toSymbol,outputAmount:o.outputAmount,address:o.toSymbolAddress})}return e}i(Yd,"getLastConvertedTokenInFailedSwap");function Zd(t){return t.status==="failed"}i(Zd,"shouldRetrySwap");function Jd(t,e,o,n,r,a){if(!n||t)return!0;let s=Mo({filter:"all",quote:n}),c=Mo({filter:"required",quote:n}),l=s.every(d=>r.some(f=>f.chain===d)),p=c.every(d=>r.some(f=>f.chain===d)),u=o&&a?on(a,o):!1;return!e&&!l||e&&!o||e&&!!o&&(!u||!p)}i(Jd,"isConfirmSwapDisabled");function Rd(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(Rd,"isTokensIdentical");var Mi=i((t,e)=>t?.usdPrice?new ot(e||pe).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),om=i(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new ot(0),outputUsdValue:new ot(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=pe,a=o.inputUsdValue;return Vn(o.inputAmount)?(e&&(n=e?.outputAmount?new ot(e?.outputAmount):null,a=lr(e)??pe,r=Ct(e)??pe),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new ot(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new ot(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new ot(0)}})},setFromToken:e=>t(o=>({fromToken:e.token,...e.token&&{fromBlockchain:e.meta.blockchains.find(n=>n.name===e.token.blockchain)??null},...!!o.inputAmount&&{inputUsdValue:Mi(e.token,o.inputAmount)}})),setToBlockchain:e=>{t(o=>o.toBlockchain?.name===e?.name?{}:{toBlockchain:e,...o.toToken&&{selectedQuote:null,toToken:null,outputAmount:null,outputUsdValue:new ot(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),sanitizeInputAmount:e=>{let o=ku(e);t(()=>({inputAmount:o}))},setInputAmount:e=>{let o=e;ai(e)||(o=mu(o),o=fu(o)),t(n=>({inputAmount:o,...!o&&{outputAmount:null,outputUsdValue:new ot(0),selectedQuote:null},...!!n.fromToken&&{inputUsdValue:Mi(n.fromToken,o)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:Mi(n??null,s),outputUsdValue:new ot(0),toBlockchain:r,toToken:a,selectedQuote:null})},switchFromAndTo:()=>t(e=>({fromBlockchain:e.toBlockchain,fromToken:e.toToken,toBlockchain:e.fromBlockchain,toToken:e.fromToken,inputAmount:e.outputAmount?.toString()||"",inputUsdValue:e.toToken?Mi(e.toToken,e.outputAmount?.toString()||""):new ot(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new ot(0),inputUsdValue:new ot(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new ot(0),selectedQuote:null})),setQuoteWalletConfirmed:e=>t({quoteWalletsConfirmed:e}),setSelectedWallets:e=>t({selectedWallets:e}),setCustomDestination:e=>t({customDestination:e}),resetQuoteWallets:()=>t({quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null}),setQuoteWarningsConfirmed:e=>t({quoteWarningsConfirmed:e})}),"initializer"),nm=em()(tm(om)),rm=em()(tm(om)),iw=co(nm),aw=co(rm);function H(){let{swapMode:t}=tt();return co(t==="refuel"?rm:nm)}i(H,"useQuoteStore");var im=i((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&ve.emit("quoteEvent",{type:"quoteInputUpdate",payload:{fromBlockchain:t.fromBlockchain?.name,toBlockchain:t.toBlockchain?.name,fromToken:t.fromToken?{symbol:t.fromToken.symbol,name:t.fromToken.name,address:t.fromToken.address}:void 0,toToken:t.toToken?{symbol:t.toToken.symbol,name:t.toToken.name,address:t.toToken.address}:void 0,requestAmount:t.inputAmount}}),t.selectedQuote?.requestId!==e.selectedQuote?.requestId&&ve.emit("quoteEvent",{type:"quoteOutputUpdate",payload:t.selectedQuote?{requestAmount:t.selectedQuote.requestAmount,swaps:t.selectedQuote.swaps,outputAmount:t.selectedQuote.outputAmount,resultType:t.selectedQuote.resultType,tags:t.selectedQuote.tags}:null})},"subscribeCallback"),am=iw.subscribe(im),sm=aw.subscribe(im);function lm(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:c,fromBlockchain:l,toBlockchain:p}=H()(),u=T().config,d=T().fetchStatus,f=T().blockchains(),{findToken:h}=T(),{setAffiliateRef:g,setAffiliatePercent:m,setAffiliateWallets:y}=T(),S=u?.from?.tokens,C=u?.from?.blockchains,k=u?.to?.tokens,x=u?.to?.blockchains,w=Li(void 0),I=Li(void 0),A=Li(void 0),b=Li(void 0);Tn(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),Tn(()=>{if(d==="success"){r();let E=f.find(M=>M.name===u?.from?.blockchain),v=u?.from?.token,N=v&&h(v);(E||!E&&A.current)&&n(E??null),N?a({token:N,meta:{blockchains:f}}):!N&&w.current&&a({token:null}),A.current=u?.from?.blockchain,w.current=u?.from?.token}},[u?.from?.token?.symbol,u?.from?.token?.address,u?.from?.token?.blockchain,u?.from?.blockchain,d]),Tn(()=>{gs(s,S)&&a({token:null}),hs(l,C)&&n(null)},[S,C]),Tn(()=>{gs(c,k)&&a({token:null}),hs(p,x)&&o(null)},[k,x]),Tn(()=>{if(d==="success"){r();let E=f.find(M=>M.name===u?.to?.blockchain),v=u?.to?.token,N=v&&h(v);(E||!E&&b.current)&&o(E??null),N?e({token:N,meta:{blockchains:f}}):!N&&I.current&&e({token:null}),b.current=u?.to?.blockchain,I.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,d]),Tn(()=>{g(u?.affiliate?.ref??null),m(u?.affiliate?.percent??null),y(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(lm,"useSyncStoresWithConfig");import{useEffect as Ys,useRef as sw}from"react";import{useInRouterContext as lw,useLocation as cw,useSearchParams as pw}from"react-router-dom";function js(t,e){let o=t.split("--");return o[0]?{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}:null}i(js,"convertTokenSearchParamToAsset");function Xs(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Xs,"tokenToSearchParam");function Js(){let t=cw(),[e,o]=pw(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:c,setFromBlockchain:l,setToBlockchain:p,setFromToken:u,setToToken:d,setInputAmount:f}=H()(),h=T().fetchStatus,g=T().blockchains(),m=lw(),{updateIframe:y,updateCampaignMode:S}=T(),C=T().isInCampaignMode(),k=sw(),{findToken:x}=T(),w=i(()=>{let A={};for(let[W,J]of e.entries())(W.startsWith("utm_")||W.startsWith("privy_"))&&(A[W]=J);let b=e.get("fromAmount"),E=e.get("fromBlockchain"),v=e.get("fromToken"),N=e.get("toBlockchain"),M=e.get("toToken"),P=e.get("autoConnect"),U=e.get("clientUrl"),Q=e.get("liquiditySources"),Z=e.get("blockchain");return{fromAmount:b,fromBlockchain:E,fromToken:v,toBlockchain:N,toToken:M,autoConnect:P,clientUrl:U,liquiditySources:Q,extraQueryParams:A,blockchain:Z}},"getUrlSearchParams"),I=i(A=>{for(let b in A)A[b]||delete A[b];o(A,{replace:!0})},"updateUrlSearchParams");Ys(()=>{let{autoConnect:A,clientUrl:b,extraQueryParams:E,blockchain:v}=w();m&&h==="success"&&I({fromBlockchain:n?.name,fromToken:Xs(a),toBlockchain:r?.name,toToken:Xs(s),fromAmount:c,autoConnect:A??void 0,clientUrl:b??void 0,blockchain:v??void 0,liquiditySources:C?k.current:void 0,...E})},[t.pathname,c,n,a,r,s,C,h]),Ys(()=>{if(!m)return;let A=w();if(!k.current&&A.liquiditySources&&(k.current=A.liquiditySources),A.fromAmount&&f(A.fromAmount),h==="success"){let b=g.find(U=>U.name===A.fromBlockchain),E=A.fromToken&&b&&js(A.fromToken,b),v=E?x(E):void 0,N=g.find(U=>U.name===A.toBlockchain),M=A.toToken&&N&&js(A.toToken,N),P=M?x(M):void 0;b&&(l(b),v&&u({token:v,meta:{blockchains:g}})),N&&(p(N),P&&d({token:P,meta:{blockchains:g}}))}},[h]),Ys(()=>{let{clientUrl:A,liquiditySources:b}=w();y("clientUrl",A||void 0),S("liquiditySources",b?.split(",")??void 0)},[])}i(Js,"useSyncUrlAndStore");import{i18n as vn}from"@lingui/core";import{Alert as Wv,Button as Mv,darkTheme as Lv,Divider as Al,DoneIcon as Pv,styled as _v,TextField as Dv,Typography as $v}from"@rango-dev/ui";import qe,{useState as Fv}from"react";import{useNavigate as Ov,useSearchParams as Uv}from"react-router-dom";import{ChevronRightIcon as uw,Divider as mm,Image as dw,Typography as fm}from"@rango-dev/ui";import It from"react";import{darkTheme as cm,styled as Rs}from"@rango-dev/ui";var pm=Rs("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${cm} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${cm} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),um=Rs("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),dm=Rs("div",{display:"flex"});function el(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return It.createElement(um,null,It.createElement(fm,{size:"large",variant:"label"},n),It.createElement(mm,{size:10}),It.createElement(pm,{onClick:s?void 0:e,disabled:s,id:"widget-blockchain-selector-container"},It.createElement(dm,null,r&&It.createElement(It.Fragment,null,It.createElement(dw,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),It.createElement(mm,{size:4,direction:"horizontal"})),It.createElement(fm,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),It.createElement(uw,{size:12,color:"black"})))}i(el,"BlockchainSelectorButton");import{i18n as rl}from"@lingui/core";import{Button as Tw,Divider as Tm,MessageBox as kw}from"@rango-dev/ui";import uo,{useEffect as km,useState as il}from"react";import{i18n as Pi}from"@lingui/core";import{Divider as Fo,ExternalLinkIcon as gw,Image as hw,InfoIcon as yw,Tooltip as Sw,Typography as dr}from"@rango-dev/ui";import me from"react";var gm="https://blog.rango.exchange/understanding-the-risks-of-using-custom-token-contract-addresses-96022308eca4";function hm(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(hm,"generateExplorerLink");import{Button as mw,darkTheme as kn,styled as ur,Typography as fw}from"@rango-dev/ui";var tl=ur("a",{textDecoration:"none",color:"$colors$neutral700",[`.${kn} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${kn} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${kn} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${kn} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),ym=ur("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${kn} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${kn} &`]:{color:"$colors$neutral900"}}}),ol=ur(mw,{minHeight:"$40"}),Sm=ur(fw,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"96px"}),Cm=ur("div",{display:"flex",justifyContent:"center",alignItems:"center"});var Cw=9;function nl(t){let{open:e,onClose:o,token:n,onExit:r,onSubmitClick:a,blockchain:s}=t,c=hm(n.address,s),l=i(()=>window.open(gm,"_blank"),"onClickLearnMore");return me.createElement(ee,{open:e,id:"widget-custom-token-watermarked-modal",dismissible:!0,onClose:o,onExit:r,container:B()},me.createElement(ym,null,me.createElement(hw,{src:n.image===""?ti:n.image,size:45,type:"circular"}),me.createElement(Fo,{size:4}),me.createElement(Cm,null,me.createElement(Sm,{variant:"title",size:"medium"},n.symbol),n.symbol.length>Cw&&me.createElement(Sw,{content:n.symbol,container:B()},me.createElement(yw,{size:12,color:"gray"}))),me.createElement(dr,{variant:"body",size:"small",className:"_blockchain-name"},s.displayName),me.createElement(Fo,{size:4}),me.createElement(dr,{variant:"body",size:"medium"},c?me.createElement(tl,{hasHover:!0,href:c,target:"_blank",rel:"nofollow noreferrer"},n.address,me.createElement(gw,{size:12,color:"gray"})):me.createElement(tl,null,n.address)),me.createElement(Fo,{size:4}),n.coinSource&&me.createElement(dr,{className:"_coin-source",variant:"body",size:"xsmall"},Pi.t("via")," ",me.createElement(dr,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),me.createElement(Fo,{size:"32"}),me.createElement(dr,{size:"medium",variant:"body",className:"_custom-token-description"},Pi.t("This token is not part of our verified token list. please verify its source and make sure to understand all associated risks before proceeding."))),me.createElement(Fo,{size:40}),me.createElement(Fo,{size:10}),me.createElement(ol,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:a},Pi.t("Import Anyway")),me.createElement(Fo,{size:10}),me.createElement(ol,{id:"widget-custom-token-modal-learn-more-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:l},Pi.t("Learn More")))}i(nl,"CustomTokenModal");function mr(t){let{token:e,blockchain:o,error:n,address:r,fetchCustomToken:a,onCloseErrorModal:s,onImport:c,onExitErrorModal:l,onExitImportModal:p}=t,{setCustomToken:u}=T(),[d,f]=il(!1),[h,g]=il(!1),[m,y]=il(!1),S=i(()=>{o&&a?.({blockchain:o.name,tokenAddress:r})},"getCustomToken"),C=i(()=>{n?.type!=="network-error"&&s?.(),f(!1)},"closeErrorModal"),k=i(()=>{y(!0),C()},"handleErrorModalButtonClick"),x=i(()=>{m&&n?.type==="network-error"&&(y(!1),S()),l()},"handleExit"),w=i(()=>{e&&(u(e),c())},"handleSubmit");return km(()=>{n&&f(!0)},[n]),km(()=>{o&&e&&g(!0)},[o,e]),uo.createElement(uo.Fragment,null,uo.createElement(ee,{open:d,dismissible:!0,id:"widget-add-custom-token-modal",onClose:C,onExit:x,container:B()},uo.createElement(kw,{title:n?.title??"",type:"error",description:n?.message||rl.t("Failed Network, Please retry.")},uo.createElement(Tm,{size:40}),uo.createElement(Tm,{size:10}),uo.createElement(Tw,{id:`widget-add-custom-token-${n?.type==="network-error"?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:k},n?.type==="network-error"?rl.t("Retry"):rl.t("Add another custom token")))),o&&e&&uo.createElement(nl,{blockchain:o,token:e,onSubmitClick:w,onClose:()=>g(!1),open:h,onExit:p}))}i(mr,"ImportCustomToken");import{useManager as bv}from"@rango-dev/queue-manager-react";import{BottomLogo as Ev,Divider as tf,Header as Iv}from"@rango-dev/ui";import Be,{useEffect as qi,useLayoutEffect as Av,useRef as of,useState as nf}from"react";import{useRef as ww}from"react";function _i(){return window.self!==window.top}i(_i,"isAppLoadedIntoIframe");function al(){let t=ww(null),{iframe:e}=T(),o=_i()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(c=>{for(let l of c)n({type:"widget_height",data:{height:l.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(al,"useIframe");import{useNavigate as vw}from"react-router-dom";function Qe(){let t=vw();return()=>t(-1)}i(Qe,"useNavigateBack");import{createTheme as ml,darkTheme as Dw,lightTheme as $w}from"@rango-dev/ui";import{useEffect as Fw,useState as Ow}from"react";import{theme as Pw,darkColors as _w}from"@rango-dev/ui";import ul from"react";var Di=16,$i=255,wm=.11;function xw(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(xw,"expandShortHexColor");function bw(t,e){return t.padStart(e,"0")}i(bw,"pad");function sl(t){let e=Math.min(Math.max(Math.round(t),0),$i);return bw(e.toString(Di),2)}i(sl,"intToHex");function Ew(t){return`#${sl(t.red)}${sl(t.green)}${sl(t.blue)}`}i(Ew,"rgbToHex");function Iw(t){let e=parseInt(t.slice(1,3),Di),o=parseInt(t.slice(3,5),Di),n=parseInt(t.slice(5,7),Di);return{red:e,green:o,blue:n}}i(Iw,"hexToRGB");function Aw(t,e){let o=1-wm*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(Aw,"generateShade");function Nw(t,e){let o=wm*e;return{red:t.red+($i-t.red)*o,green:t.green+($i-t.green)*o,blue:t.blue+($i-t.blue)*o}}i(Nw,"generateTint");function Bw(t){return vm(t,Aw)}i(Bw,"calculateShades");function Ww(t){return vm(t,Nw)}i(Ww,"calculateTints");function vm(t,e){let o=Iw(t),n=[];for(let r=1;r<9;r++)n.push(Ew(e(o,r)));return n}i(vm,"calculateColors");function ll(t,e,o){let a=Ww(t).reverse().concat(t),s=Bw(t),c=a.concat(s),l={},p=c.length;for(let u=0;u<p;u++){let d=100+(o?p-1-u:u)*50,f=c[u];f&&(l[`${e}${d}`]=f)}return l}i(ll,"createTintsAndShades");function cl(t,e,o){let n={...t};for(let r in e){let a=e[r],s=r==="neutral"&&!!o?.reverseNeutralRange;if(!["background","foreground"].includes(r)&&!Cu(r)){let l=xw(a);Object.assign(n,ll(l,r,s))}}return{...n,...e}}i(cl,"expandToGenerateThemeColors");var xm=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),Mw=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=xm(o%52)+e;return xm(o%52)+e},"toAlphabeticName"),Lw=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),pl=i(t=>Mw(Lw(5381,JSON.stringify(t))>>>0),"toHash");function dl(t){let e=Pw.colors,o={...e,..._w},n,r;if(t?.light){let s={colors:cl(e,t.light)};n={id:`${fs}-light-${pl(s)}`,tokens:s}}if(t?.dark){let s={colors:cl(o,t.dark,{reverseNeutralRange:!0})};r={id:`${fs}-dark-${pl(s)}`,tokens:s}}return{light:n,dark:r}}i(dl,"customizedThemeTokens");function bm(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>ul.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(ul.cloneElement(a,{key:s})),r<t.length-1){let c=`divider-${r}`;o.push(ul.cloneElement(e,{key:c}))}}),o}i(bm,"joinList");function Em(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Em,"doesWindowPreferDarkColorScheme");function mo(t){let{colors:e,fontFamily:o=ou,borderRadius:n=Lu,secondaryBorderRadius:r=Pu}=t,[a,s]=Ow(Em()?"dark":"light"),{theme:c}=T(),{dark:l,light:p}=dl(e),u=ml({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),d=[u.className,$w.className],f=[u.className,Dw.className];if(p){let g=ml(p.id,p.tokens);d.push(g.className)}if(l){let g=ml(l.id,l.tokens);f.push(g.className)}return Fw(()=>{let g=i(m=>{m.matches?s("dark"):s("light")},"switchThemeListener");return Em()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",g),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",g)}},[]),{activeTheme:i(()=>{let g=d.join(" "),m=f.join(" ");return c==="auto"?a==="dark"?m:g:c==="dark"?m:g},"getActiveTheme"),mode:c==="auto"?a:c}}i(mo,"useTheme");var kt=i(t=>{let e=[];return t?.getAll().forEach((o,n)=>{let r=o.list.getStorage();r?.swapDetails&&e.push({id:n,swap:r?.swapDetails})}),e.sort((o,n)=>Number(n.swap.creationTime)-Number(o.swap.creationTime))},"getPendingSwaps");import{i18n as Im}from"@lingui/core";import{Alert as Uw,Button as zw}from"@rango-dev/ui";import Am from"react";function fl(t){return Am.createElement(Uw,{action:Am.createElement(zw,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Im.t("Activate this tab")),type:"warning",variant:"alarm",title:Im.t("Another tab is open and handles transactions.")})}i(fl,"ActivateTabAlert");import{i18n as gl}from"@lingui/core";import{Button as Hw,Divider as Qw,MessageBox as qw}from"@rango-dev/ui";import Fi from"react";function hl(t){let{open:e,onClose:o,onConfirm:n}=t;return Fi.createElement(ee,{open:e,dismissible:!0,onClose:o,id:"widget-active-tab-modal",container:B()},Fi.createElement(qw,{title:gl.t("Activate current tab"),type:"warning",description:gl.t("Currently, some transactions are running and being handled by other browser tab. If you activate this tab, all transactions that are already in the transaction sign step will expire.")},Fi.createElement(Qw,{size:20}),Fi.createElement(Hw,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},gl.t("Confirm"))))}i(hl,"ActivateTabModal");import{ChevronLeftIcon as Kw}from"@rango-dev/ui";import Dm from"react";import{css as Gw,darkTheme as Nm,IconButton as Vw,styled as Oo}from"@rango-dev/ui";var Dt=Oo(Vw,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${Nm} &`]:{backgroundColor:"$neutral"}}}),Bm=Oo("div",{position:"absolute",background:"$secondary500",[`.${Nm} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),fo=Oo("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),Wm=Oo("div",{position:"absolute",width:"14px",height:"14px",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"7px",top:"$0",right:"$0",variants:{isSever:{true:{backgroundColor:"$error500"},false:{backgroundColor:"$secondary500"}}}}),Mm=Oo("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Lm=Oo("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),Pm=Gw({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),_m=Oo("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});function yl(t){return Dm.createElement(Dt,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Dm.createElement(Kw,{color:"black",size:16}))}i(yl,"BackButton");import{i18n as jw}from"@lingui/core";import{Button as Xw,Typography as Yw}from"@rango-dev/ui";import Sl from"react";function Cl(t){return Sl.createElement(fo,null,Sl.createElement(Xw,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},Sl.createElement(Yw,{variant:"label",size:"medium",color:"error500"},jw.t("Cancel"))))}i(Cl,"CancelButton");import{i18n as Zw}from"@lingui/core";import{Image as Jw,Tooltip as Rw,WalletIcon as ev,WalletState as $m}from"@rango-dev/ui";import Uo from"react";function Tl(t){let{list:e}=bt(),o=e.filter(r=>r.state===$m.CONNECTED||r.state===$m.PARTIALLY_CONNECTED),n=o.length?Uo.createElement("div",{className:Pm()},o.map(r=>Uo.createElement(_m,{key:r.title},Uo.createElement(Jw,{src:r.image,size:14})))):Zw.t("Connect Wallet");return Uo.createElement(Rw,{container:t.container,side:"bottom",content:n},Uo.createElement(Dt,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&Uo.createElement(Bm,null),Uo.createElement(ev,{size:18,color:"black"})))}i(Tl,"WalletButton");import{i18n as Ui}from"@lingui/core";import{NotificationsIcon as hv,Popover as yv,SettingsIcon as Sv,Tooltip as zi,TransactionIcon as Cv}from"@rango-dev/ui";import Le from"react";import{Notifications as rv}from"@rango-dev/ui";import iv from"react";import{useNavigate as av}from"react-router-dom";import{create as tv}from"zustand";import{persist as ov,subscribeWithSelector as nv}from"zustand/middleware";var Ne=co(tv()(ov(nv((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1];if(!r||!a)return;let s={event:o,creationTime:Date.now(),requestId:n.requestId,route:{creationTime:parseInt(n.creationTime),from:{blockchain:r.fromBlockchain,address:r.fromSymbolAddress,symbol:r.fromSymbol},to:{blockchain:a.toBlockchain,address:a.toSymbolAddress,symbol:a.toSymbol}}},c=e().notifications.filter(l=>l.requestId!==n.requestId);t(()=>({notifications:[...c,s]}))},removeNotification:o=>{t(n=>({notifications:n.notifications.filter(r=>r.requestId!==o)}))},getNotifications:()=>{let{isSynced:o,notifications:n}=e();return o?n.sort((r,a)=>r.route.creationTime&&!a.route.creationTime?-1:!r.route.creationTime&&a.route.creationTime?1:!r.route.creationTime&&!a.route.creationTime?a.creationTime-r.creationTime:a.route.creationTime-r.route.creationTime):[]},syncNotifications:o=>{let{isSynced:n,notifications:r}=e();if(!n){let a=[];r.forEach(s=>{o.some(l=>l.swap.requestId===s.requestId)&&a.push(s)}),t({isSynced:!0,notifications:a})}},clearNotifications:()=>t({notifications:[]})})),{name:"notification",skipHydration:!0,partialize:({isSynced:t,...e})=>e,version:1,migrate:(t,e)=>{if(e===0){let o=t.notifications;t.notifications=o.filter(n=>!n.read).map(({read:n,...r})=>r)}return t}})));function kl(){let t=av(),{getNotifications:e,clearNotifications:o}=Ne(),n=e(),r=T().blockchains(),{findToken:a}=T();return iv.createElement(rv,{id:"widget-notifications-container",list:n,getBlockchainImage:c=>Kp(c,r),getTokenImage:c=>a(c)?.image,onClickItem:i(c=>{t(`${$.swaps}/${c}`)},"onClickItem"),onClearAll:o})}i(kl,"NotificationContent");import{useManager as sv}from"@rango-dev/queue-manager-react";import{InProgressIcon as lv}from"@rango-dev/ui";import Fm from"react";var cv=i(()=>{let{manager:t}=sv();return kt(t).map(({swap:o})=>o).find(o=>o.status==="running")?Fm.createElement(Lm,{id:"widget-header-history-badge-container"},Fm.createElement(lv,{color:"info",size:6})):null},"InProgressTransactionBadge"),Om=cv;import{EventSeverity as pv}from"@rango-dev/queue-manager-rango-preset";import{Typography as uv}from"@rango-dev/ui";import Um from"react";function zm(){let{getNotifications:t}=Ne(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===pv.WARNING);return o?Um.createElement(Wm,{isSever:n},Um.createElement(uv,{variant:"body",size:"xsmall",color:"$background",id:"widget-header-notifications-badge-container"},o)):null}i(zm,"NotificationsBadge");import{RefreshProgressButton as dv}from"@rango-dev/ui";import wl,{useEffect as mv,useState as Hm}from"react";var fv=1e3,Qm=60,gv=100;function Oi({onClick:t}){let[e,o]=Hm(0),[n,r]=Hm(!1),a=i(l=>{document.hidden&&l&&s(l)},"handleVisibilityChange");mv(()=>{let l;return t?l=window.setInterval(()=>{o(p=>p+1),e===Qm&&c()},fv):s(l),document.addEventListener("visibilitychange",()=>a(l)),()=>{document.removeEventListener("visibilitychange",()=>a(l)),l&&clearInterval(l)}},[e,t]);let s=i(l=>{l&&clearInterval(l),o(0)},"clearTimeout"),c=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return wl.createElement(Dt,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:c,disabled:!t},wl.createElement(Mm,{onTransitionEnd:()=>r(!1),isRefetched:n},wl.createElement(dv,{size:22,color:t?"black":"gray",progress:e/Qm*gv})))}i(Oi,"RefreshButton");function zo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=T(),c=et("notification",s)||r.includes("notifications");return Le.createElement(Le.Fragment,null,!r.includes("refresh")&&Le.createElement(zi,{container:a||B(),side:"top",content:Ui.t("Refresh")},Le.createElement(Oi,{onClick:e})),!c&&Le.createElement(yv,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:B(),content:Le.createElement(kl,null)},Le.createElement("div",null,Le.createElement(zi,{container:B(),side:"top",content:Ui.t("Notifications")},Le.createElement(Dt,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Le.createElement(hv,{size:18,color:"black"}),Le.createElement(zm,null))))),!r.includes("settings")&&Le.createElement(zi,{container:B(),side:"top",content:Ui.t("Settings")},Le.createElement(Dt,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Le.createElement(Sv,{size:18,color:"black"}))),!r.includes("history")&&Le.createElement(zi,{container:B(),side:"top",content:Ui.t("History")},Le.createElement(Dt,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Le.createElement(Cv,{size:18,color:"black"}),Le.createElement(Om,null))))}i(zo,"HeaderButtons");import{i18n as vl}from"@lingui/core";import{Divider as Gm,MessageBox as wv,RefreshIcon as vv}from"@rango-dev/ui";import wn from"react";import{Button as Tv,styled as kv}from"@rango-dev/ui";var qm=kv(Tv,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function xl(t){let{open:e,onClose:o}=t;return wn.createElement(ee,{open:e,dismissible:!0,onClose:o,id:"widget-refresh-modal",container:B()},wn.createElement(wv,{title:vl.t("Something went wrong"),type:"error",description:vl.t("Something went wrong. Please refresh the app.")},wn.createElement(Gm,{size:30}),wn.createElement(qm,{variant:"outlined",id:"widget-refresh-modal-refresh-btn",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},wn.createElement(vv,{size:20,color:"primary"}),wn.createElement(Gm,{size:4,direction:"horizontal"}),vl.t("Refresh"))))}i(xl,"RefreshModal");var Vm="700px",Km="425px",jm="550px",Xm="640px",Ym="800px";function bl(t){let e=t.target;if(e){let o=e.scrollTop,n=B();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(bl,"onScrollContentAttachStatusToContainer");import{css as xv,styled as Hi}from"@rango-dev/ui";var Qi=xv({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Zm=Hi("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",maxHeight:Vm,variants:{height:{auto:{height:"auto"},fixed:{height:"100%",minHeight:Km,[`@media screen and (min-height: ${Ym})`]:{minHeight:jm}}},showBanner:{true:{overflow:"visible"}}}}),Jm=Hi("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),Rm=Hi("div",{padding:"0 $20 $10","& .footer__alert":{paddingTop:"$10"},"& .footer__logo":{opacity:0,transition:"opacity 1s ease-in-out","&.logo__show":{opacity:1},"&.logo__hidden":{visibility:"hidden"}}}),ef=Hi("div",{width:"100%",position:"absolute",bottom:"-$10",transform:"translateY(100%)",overflow:"hidden"});function se(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=al(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:c,connectedWallets:l,config:{__UNSTABLE_OR_INTERNAL__:p}}=T(),[u,d]=nf(!1),{config:{features:f,theme:h}}=T(),{watermark:g}=ne(),m=g==="FULL",{activeTheme:y}=mo(h||{}),[S,C]=nf(!1),k=et("connectWalletButton",f),{isActiveTab:x,tabManagerInitiated:w,showActivateTabModal:I,setShowActivateTabModal:A,activateCurrentTab:b,setShowCompactTokenSelector:E}=ne(),v=Qe(),{manager:N}=bv(),P=kt(N).map(({swap:X})=>X).some(X=>X.status==="running"),U=i(()=>b(Po.forceClaim,P),"onActivateTab"),Q=i(()=>{r.onWallet?.()},"onConnectWallet"),Z=typeof r.hasBackButton>"u"||r.hasBackButton,W=of(null),J=of(null);return qi(()=>{let X=(p?.swapBoxBanner?.routes?.length??0)===0,ae=!!p?.swapBoxBanner?.routes?.some(Se=>location.pathname.endsWith(Se));C(!!p?.swapBoxBanner&&(X||ae))},[p?.swapBoxBanner?.routes?.toString(),location.pathname]),qi(()=>(_i()&&J.current&&e(J.current),()=>{o()}),[]),qi(()=>(W.current?.addEventListener("scroll",bl),()=>{W.current?.removeEventListener("scroll",bl)}),[]),qi(()=>{d(c==="failed")},[c]),Av(()=>{if(!J.current)return;let X=new ResizeObserver(ae=>{for(let Se of ae)Se.contentRect&&E(Se.contentRect.height<parseInt(Xm))});return X.observe(J.current),()=>X.disconnect()},[]),Be.createElement(Zm,{height:s,id:Re.SWAP_BOX_ID,className:`${y()} ${Qi()}`,ref:J,showBanner:S},Be.createElement(Iv,{prefix:Z?Be.createElement(yl,{onClick:()=>{v(),r.onBack?.()}}):null,title:r.title,suffix:Be.createElement(Be.Fragment,null,r.suffix,r.onWallet&&!k&&Be.createElement(Tl,{container:B(),onClick:Q,isConnected:!!l?.length}),r.onCancel&&Be.createElement(Cl,{onClick:r.onCancel}))}),Be.createElement(Jm,{ref:W},n),Be.createElement(hl,{open:I,onClose:()=>A(!1),onConfirm:U}),Be.createElement(Rm,null,Be.createElement("div",{className:"footer__content"},w&&!x&&Be.createElement("div",{className:"footer__alert"},Be.createElement(fl,{onActivateTab:U}),Be.createElement(tf,{size:10})),a),Be.createElement(tf,{size:12}),Be.createElement("div",{className:`footer__logo ${m?"logo__show":"logo__hidden"}`},Be.createElement(Ev,null))),S&&Be.createElement(ef,null,p?.swapBoxBanner?.element),Be.createElement(xl,{open:u,onClose:()=>d(!1)}))}i(se,"Layout");import{styled as Nv}from"@rango-dev/ui";var rf="$20 $20 $10 $20",El=Nv("div",{padding:rf,overflowY:"auto",flexGrow:1});import{styled as Bv}from"@rango-dev/ui";var ce=Bv("div",{display:"flex",flexDirection:"column",padding:"20px 20px 10px",flexGrow:1,variants:{view:{true:{flexGrow:1,overflow:"hidden"}},compact:{true:{padding:0}}}});import{i18n as go}from"@lingui/core";import{useState as Il}from"react";function af(){let[t,e]=Il(!1),[o,n]=Il(null),[r,a]=Il(null),{findToken:s}=T(),c=T().customTokens(),l=i(()=>{a(null),e(!1),n(null)},"resetState");function p(d,f){switch(d){case"duplicated":return{type:d,title:go.t("Duplicate Token"),message:go.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{type:d,title:go.t("Token Already Exists"),message:go.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{type:d,title:go.t("Token Not Found"),message:go.t({id:"Sorry, no token was found on {blockchain} chain with the provided address. please make sure you have entered the right token address.",values:{blockchain:f}})};case"network-error":return{type:d,title:go.t("Network error"),message:go.t("An error occurred while retrieving token data.")}}}return i(p,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:d,tokenAddress:f})=>{e(!0);try{if(c.some(S=>S.address?.toLowerCase()===f.toLowerCase())){let S=p("duplicated");n(S);return}let g=await ct().getCustomToken({blockchain:d,address:f});if(!g||!g.token||g.error){let S=p("not-found",d);n(S);return}let m=g.token;if(s({blockchain:m.blockchain,address:m.address,symbol:m.symbol})){let S=p("token-exist");n(S);return}return a({...m,warning:!0})}catch(h){if(h.code==="ERR_BAD_REQUEST"){let g=p("not-found",d);n(g);return}n(p("network-error"));return}finally{e(!1)}},"fetchCustomToken"),token:r,loading:t,error:o,resetState:l}}i(af,"useFetchCustomToken");var zv=_v("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $12",backgroundColor:"$neutral300","& input":{padding:"0"},[`.${Lv} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}});function sf(){let t=Ov(),[e]=Uv(),o=Qe(),n=T().blockchains(),r=e.get("blockchain")||"",a=No(r,n),[s,c]=Fv(""),{fetchCustomToken:l,token:p,loading:u,error:d,resetState:f}=af(),h=!!a&&on(a,s),g=!a||!s||!h,m=i(()=>{a&&l({blockchain:r,tokenAddress:s})},"getCustomToken");return qe.createElement(se,{header:{title:vn.t("Add Custom Token")}},qe.createElement(ce,null,qe.createElement(zv,null,qe.createElement("div",null,qe.createElement(el,{onClick:()=>t($.blockchains,{replace:!0}),hasLogo:!!a?.logo,value:a?{name:a.displayName,logo:a.logo}:void 0,title:vn.t("Select chain"),placeholder:vn.t("Select chain")}),qe.createElement(Al,{size:"24"}),qe.createElement($v,{size:"large",variant:"label"},vn.t("Enter Address")),qe.createElement(Al,{size:10}),qe.createElement(Dv,{fullWidth:!0,id:"widget-add-custom-token-token-address-input",disabled:!a,variant:"contained",placeholder:vn.t("Enter token address"),size:"large",value:s,suffix:!!s&&h&&qe.createElement(Pv,{color:"success",size:12}),onChange:y=>c(y.target.value)}),!h&&!!s&&qe.createElement(qe.Fragment,null,qe.createElement(Al,{size:4}),qe.createElement(Wv,{id:"widget-add-custom-token-invalid-address-alert",type:"error",variant:"alarm",title:"Invalid Address"}))),qe.createElement(Mv,{id:"widget-add-custom-token-import-btn",disabled:g,type:"primary",variant:"contained",loading:u,size:"large",onClick:m},vn.t("Import"))),qe.createElement(mr,{token:p,blockchain:a??void 0,address:s,error:d??void 0,fetchCustomToken:l,onCloseErrorModal:()=>{d?.type!=="network-error"&&c("")},onImport:o,onExitErrorModal:f,onExitImportModal:f})))}i(sf,"AddCustomTokenPage");import{i18n as cc}from"@lingui/core";import{useManager as Wb}from"@rango-dev/queue-manager-react";import{Alert as Mb,Button as Lb,css as uc,Divider as pc,IconButton as Rg,styled as Pb,Typography as _b,WalletIcon as Db}from"@rango-dev/ui";import De,{useEffect as Sa,useLayoutEffect as $b,useRef as Fb,useState as br}from"react";import{useNavigate as Ob}from"react-router-dom";import{i18n as Ho}from"@lingui/core";import{Alert as mx,BalanceErrors as fx,Button as Lf,ChevronLeftIcon as gx,Divider as Dl,MessageBox as hx,Typography as $l}from"@rango-dev/ui";import ie,{useCallback as yx,useEffect as Pf,useMemo as Sx,useState as In}from"react";import{useNavigate as Cx}from"react-router-dom";import{i18n as Ml}from"@lingui/core";import{Alert as Vv,ChevronDownIcon as Kv,CloseIcon as jv,Divider as ff,IconButton as gf,PasteIcon as Xv,Typography as Yv,WalletIcon as Zv}from"@rango-dev/ui";import Pe,{useEffect as Jv,useRef as Rv}from"react";import ji,{useRef as qv}from"react";import*as xn from"@radix-ui/react-collapsible";import{keyframes as lf,styled as Gi}from"@rango-dev/ui";var Nl=300,Hv=lf({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Qv=lf({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),cf=Gi(xn.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),Bl=Gi(xn.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Vi=Gi(xn.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Hv} ${Nl}ms ease-out`},false:{animation:`${Qv} ${Nl}ms ease-out`}}}}),Ki=Gi("div",{transition:`all ${Nl}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Xi(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:c}=t,l=qv(null);return ji.createElement(cf,{ref:l,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},c==="top"&&ji.createElement(Bl,{className:"collapsible_trigger",onClick:a},s),ji.createElement(Vi,{className:"collapsible_content",open:e},r),c==="bottom"&&ji.createElement(Bl,{className:"collapsible_trigger",onClick:a},s))}i(Xi,"CustomCollapsible");import{darkTheme as pf,styled as Wl,TextField as Gv}from"@rango-dev/ui";var uf=Wl("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"},"& input":{padding:"$15"}}),df=Wl(Gv,{backgroundColor:"$neutral100"}),mf=Wl("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${pf} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${pf} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function hf(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=H()(),{config:s}=T(),c=T().blockchains(),l=Rr(e.name,c),p=Rv(null),u=s?.defaultCustomDestinations?.[e.name],d=navigator?.userAgent.includes("Firefox"),h=n&&!!r&&e&&!on(e,r),g=i(()=>{a("")},"handleClear"),m=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let C=await navigator.clipboard.readText();a(C),p?.current?.focus()}},"handlePaste"),y=i(()=>r?Pe.createElement(gf,{id:"widget-custom-destination-close-icon-btn",onClick:g,variant:"ghost"},Pe.createElement(jv,{size:12,color:"gray"})):d?null:Pe.createElement(gf,{id:"widget-custom-destination-paste-icon-btn",onClick:m,variant:"ghost"},Pe.createElement(Xv,{size:16})),"renderSuffix");return Jv(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),Pe.createElement(uf,null,Pe.createElement(Xi,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Pe.createElement(mf,{id:"widget-custom-destination-collapsible-btn"},Pe.createElement("div",{className:"button__content"},Pe.createElement(Zv,{size:18,color:"info"}),Pe.createElement(ff,{size:4,direction:"horizontal"}),Pe.createElement(Yv,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Ml.t("Send to a different address"))),Pe.createElement(Ki,{orientation:n?"up":"down"},Pe.createElement(Kv,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Pe.createElement(df,{id:"widget-custom-destination-blockchain-address-input",ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Ml.t("Enter {blockchainName} address",{blockchainName:l}),value:r||"",suffix:y(),onChange:S=>{let C=S.target.value;a(C)}})),h&&Pe.createElement(Pe.Fragment,null,Pe.createElement(ff,{size:4}),Pe.createElement(Vv,{variant:"alarm",type:"error",title:Ml.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(hf,"CustomDestination");import{css as ex,IconButton as tx,SelectableWalletButton as ox,styled as ho}from"@rango-dev/ui";var yf=ho("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),Sf=ho("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Cf=ho(ox,{justifyContent:"center"}),Tf=ho("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),kf=ho(tx,{position:"absolute",left:"$20"}),wf=ho("div",{paddingTop:"$20"}),vf=ex({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),xf=ho("div",{display:"flex"}),bf=ho("div",{overflow:"visible",width:"100%"});import{i18n as Pl}from"@lingui/core";import{warn as sx}from"@rango-dev/logging-core";import{Divider as lx,makeInfo as cx,SelectableWallet as px,Typography as Wf,WalletState as En}from"@rango-dev/ui";import nt,{useEffect as Mf,useState as gr}from"react";import{Image as ix,MessageBox as ax}from"@rango-dev/ui";import fr from"react";import{keyframes as nx,styled as Ll}from"@rango-dev/ui";var Ef=Ll("div",{position:"relative"}),rx=nx({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),If=Ll("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${rx} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Af=Ll("div",{"& img":{borderRadius:"50%"}});import{i18n as bn}from"@lingui/core";function Nf(t,e){switch(t){case"in-progress":return{type:"loading",title:bn.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:bn.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:bn.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:bn.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:bn.t("Request Rejected"),description:bn.t({id:"You've rejected adding {blockchainDisplayName} chain to your wallet.",values:{blockchainDisplayName:e}})};default:throw new Error(`Showing information about an experimentation chain status needs to be defined first. status: ${t}`)}}i(Nf,"generateMessageByStatus");function Bf(t){let{status:e,displayName:o,image:n}=t,r=Nf(e,o),a=e=="in-progress";return fr.createElement(ax,{type:r.type,title:r.title,description:r.description,icon:a?fr.createElement(Ef,null,fr.createElement(Af,null,fr.createElement(ix,{src:n,size:45})),fr.createElement(If,null)):void 0})}i(Bf,"ExperimentalChainStatus");var ux=7,dx=3e3;function _l(t){let{chain:e,quoteChains:o,isSelected:n,selectWallet:r,limit:a,onShowMore:s}=t,c=ne.use.isActiveTab(),{blockchains:l,connectedWallets:p}=T(),[u,d]=gr(),[f,h]=gr(null),[g,m]=gr(!1),[y,S]=gr(null),{suggestAndConnect:C}=Yi(),{list:k}=bt({chain:e}),[x,w]=gr(k),I=k.length,A=a&&I-a>0,b=i(async v=>{m(!1),S("in-progress");try{let N=k.find(Q=>Q.type===Q.type),M=N?.isHub?N.properties?.find(Q=>Q.name==="namespaces")?.value:N?.needsNamespace,P=l(),U=M?.data.find(Q=>Q.getSupportedChains(P).some(Z=>Z.name===v.chain));if(!U)throw new Error("Requested chain is not supported");await C(v.walletType,{namespace:U.value,network:v.chain}),S("completed")}catch{S("rejected")}},"addExperimentalChain");Mf(()=>{w(v=>{let N=k.findIndex(M=>n(M.type,e));return A&&N>1?[k[N]].concat(k.filter((M,P)=>P!==N)):v.map(M=>k.find(P=>P.type===M.type)??M)})},[JSON.stringify(k)]);let E=document.getElementById(Re.SWAP_BOX_ID);return Mf(()=>{let v=null;return(y==="completed"||y==="rejected")&&(v=setTimeout(()=>S(null),dx)),()=>{v&&clearTimeout(v)}},[y]),nt.createElement(nt.Fragment,null,x.slice(0,a).map(v=>{let N=Iu({connectedWallets:p,walletType:v.type,chain:e}),M=v.state===En.CONNECTED||v.state===En.PARTIALLY_CONNECTED,P=N?lo(N,ux):"",U=M&&!!v.needsNamespace&&!P,Q=pi(l(),e),Z=!p.find(ue=>ue.walletType===v.type&&ue.chain===e),W=Q&&Z&&v.state===En.CONNECTED,J=i(async()=>{v.state===En.DISCONNECTED||U&&!W?d(v):W?(h({walletType:v.type,chain:e,address:N??""}),m(!0)):r({walletType:v.type,chain:e,address:N??""})},"onSelectableWalletClick"),X=cx(v.state),ae=i(()=>W?Pl.t({id:"Add {chain} chain",values:{chain:e}}):U?Pl.t("Chain not connected"):P||X.description,"getWalletDescription"),Se=i(()=>v.state===En.CONNECTED||v.state===En.PARTIALLY_CONNECTED?U?"neutral600":"neutral700":X.color,"getWalletDescriptionColor"),at=f?.chain?Rr(f.chain,l()):void 0;return nt.createElement(nt.Fragment,{key:`${v.title}_${at}`},!!f&&nt.createElement(ee,{id:"widget-wallets-list-watermarked-modal",open:!!f&&g,container:E,onClose:()=>{h(null)}},nt.createElement(zs,{id:"widget-wallets-list-experimental-chain-container",displayName:at,onConfirm:()=>{b(f)}})),y&&nt.createElement(ee,{id:"widget-wallets-list-experimental-chain-watermarked-modal",open:!!y,onClose:S.bind(null,null),container:E},nt.createElement(Bf,{status:y,displayName:at,image:v.image}),nt.createElement(lx,{direction:"vertical",size:32})),nt.createElement(px,{key:v.type,id:"widget-wallets-list-selectable-wallet-btn",description:ae(),descriptionColor:Se(),onClick:J,selected:n(v.type,e),disabled:!c,...v}))}),nt.createElement(sr,{id:"widget-wallets-list-stateful-connect-modal",wallet:u,options:{defaultSelectedChains:o||[e]},onClose:()=>{d(void 0)},onConnect:()=>{t.onConnect&&(u?.type?t.onConnect(u.type):sx(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),A&&nt.createElement(Cf,{selected:!1,onClick:s,id:"widget-wallets-list-show-more-wallets-btn"},nt.createElement(Wf,{variant:"label",size:"medium"},Pl.t("Show more wallets"),nt.createElement(Wf,{variant:"label",size:"medium",color:"$primary"},"\xA0+",I-(a??0)))))}i(_l,"WalletList");var Tx=2;function _f(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=Cx(),c=T().blockchains(),{selectedQuote:l,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:d,customDestination:f,setCustomDestination:h}=H()(),{config:g,connectedWallets:m,setWalletsAsSelected:y}=T(),[S,C]=In(""),[k,x]=In([]),[w,I]=In(""),[A,b]=In(!!f),E=Sx(()=>Mo({filter:"all",quote:l}),[l]),v=Mo({filter:"required",quote:l}),N=c.find(O=>O.name===l?.swaps[l?.swaps.length-1]?.to.blockchain),M=i(O=>v.includes(O),"isWalletRequiredFor"),P=yx(()=>m.filter(O=>O.selected&&E.includes(O.chain)),[m,E]),[U,Q]=In(P()),[Z,W]=In([]),J=i((O,z)=>W(Y=>Y.concat({blockchain:O,walletType:z})),"addNextSelectedWallets"),X=k.length>0,ae=i((O,z)=>!!U.find(Y=>Y.walletType===O&&Y.chain===z&&Y.selected&&(M(z)||!M(z)&&!f)),"isSelected"),Se=i((O,z,Y)=>{let te=!1;return O.map(j=>{if(j.chain===z){let G=j.selected;return!te&&Y?(te=!0,G=!0):Y||(G=!1),{...j,selected:G}}return j})},"updateSelectableWallets"),at=i(O=>{b(O),O?M(N?.name??"")||Q(z=>Se(z,N?.name||"",!1)):(h(""),Q(z=>Se(z,N?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),ue=i(O=>{if(S&&C(""),ae(O.walletType,O.chain))return;let Y=m.find(te=>te.walletType===O.walletType&&te.chain===O.chain);Y&&(n(),O.chain===N?.name&&A&&!M(N.name)&&(b(!1),h(null)),Q(te=>te.filter(j=>j.chain!==O.chain).concat({...Y,selected:!0})))},"onChange"),gt=i(()=>{let O=U.filter(z=>z.selected);y(O),p(O),d(!0),o()},"onConfirmBalance"),vt=i(async()=>{x([]),I("");let O=await r?.({selectedWallets:U.filter(Y=>Y.selected),customDestination:f}),z=O.warnings;z?.balance?.messages&&x(z.balance.messages),O.error&&I(vd(O.error)),!O.error&&!z?.balance?.messages.length?gt():x(z?.balance?.messages??[])},"onConfirmWallets");Pf(()=>{Q(O=>{let z=[];return O.forEach(Y=>{!m.some(j=>j.chain===Y.chain&&j.walletType===Y.walletType&&j.address===Y.address)||z.push(Y)}),z=z.concat(m.filter(Y=>!!!z.find(j=>j.chain===Y.chain)&&Y.selected&&E.includes(Y.chain))),z})},[m,E]),Pf(()=>{let O=[];Z.length>0&&(Z.forEach(z=>{let Y=m.find(te=>te.chain===z.blockchain&&te.walletType===z.walletType);Y?ue(Y):O.push(z)}),W(O))},[m,Z]);let xt=document.getElementById(Re.SWAP_BOX_ID);return ie.createElement(ee,{id:"widget-confirm-wallets-modal",open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!S,container:xt,...!S&&{styles:{container:{height:"100%"}},footer:ie.createElement(xf,null,ie.createElement(Lf,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:Jd(a,A,f,l,U,N),onClick:vt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},Ho.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:ie.createElement(Tf,null,ie.createElement(kf,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:C.bind(null,"")},ie.createElement(gx,{size:16})),ie.createElement($l,{variant:"headline",size:"small"},Ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:yt(S,c)}})))},anchor:"center"},ie.createElement(ee,{id:'"widget-confirm-wallets-insufficient-account-balance-modal',open:X,onClose:x.bind(null,[]),container:xt},ie.createElement(hx,{title:Ho.t("Insufficient account balance"),type:"error",description:ie.createElement(fx,{messages:k??[]})},ie.createElement(Lf,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:gt},Ho.t("Proceed anyway")))),S&&ie.createElement(wf,null,ie.createElement("div",{className:vf()},ie.createElement(_l,{chain:S,quoteChains:E,isSelected:ae,selectWallet:ue,onShowMore:()=>C(S),onConnect:O=>{J(S,O)}}))),!S&&ie.createElement(ie.Fragment,null,w&&ie.createElement(ie.Fragment,null,ie.createElement(mx,{id:"widget-confirm-wallet-modal-error-alert",variant:"alarm",type:"error",title:Ho.t(w)}),ie.createElement(Dl,{size:12})),ie.createElement(bf,null,E.map((O,z)=>{let Y=c.find(Ve=>Ve.name===O),te=`wallet-${z}`,j=z===E.length-1,G=j&&N&&g?.customDestination!==!1;return ie.createElement("div",{key:te},ie.createElement(yf,null,ie.createElement($l,{variant:"title",size:"xmedium"},Ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:Y?.shortName}})),ie.createElement($l,{variant:"label",color:"$neutral700",size:"medium"},Ho.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:Y?.shortName}}))),ie.createElement(Dl,{size:24}),ie.createElement(Sf,null,ie.createElement(_l,{chain:O,quoteChains:E,isSelected:ae,selectWallet:ue,limit:Tx,onShowMore:()=>C(Y?.name??""),onConnect:Ve=>{J(O,Ve)}})),!j&&ie.createElement(Dl,{size:32}),G&&ie.createElement(hf,{blockchain:N,open:A,handleOpenChange:at}))}))))}i(_f,"ConfirmWalletsModal");import{i18n as Vx}from"@lingui/core";import{Alert as Kx,Button as jx,Divider as tg,InfoIcon as Xx}from"@rango-dev/ui";import Fe from"react";import{Alert as vx,Button as xx,Divider as Ul,NoRouteIcon as bx,RefreshIcon as Ex,Typography as Hf}from"@rango-dev/ui";import pt from"react";import{i18n as Df}from"@lingui/core";var kx=24,wx=60;function $f(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:re().genericServerError,action:{onClick:n,title:Df.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:re().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Df.t("Reset")}},description:re().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:re().noResultError.description}}i($f,"makeInfo");var Fl=(o=>(o[o.small=kx]="small",o[o.large=wx]="large",o))(Fl||{}),Ol=(o=>(o.small="small",o.large="medium",o))(Ol||{});import{styled as Zi}from"@rango-dev/ui";var Ff=Zi("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Of=Zi("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Uf=Zi("div",{variants:{size:{small:{width:"100%"},large:{}}}}),zf=Zi("div",{padding:"$6 $0"});function hr(t){let{fetch:e,error:o,size:n="small",skipAlerts:r}=t,a=T().getDisabledLiquiditySources(),s=T().toggleAllLiquiditySources,c=T().swappers(),l=$f(o,a,()=>s(c,!0),e);return r&&(l.alert=null),pt.createElement(Ff,{id:"widget-no-result-container"},pt.createElement(bx,{size:Fl[n],color:"gray"}),pt.createElement(Ul,{size:4}),pt.createElement(Hf,{variant:"title",size:Ol[n]},re().noResultError.title),n==="large"&&pt.createElement(Ul,{size:4}),!!l.description&&pt.createElement(Of,{size:n},pt.createElement(Hf,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),pt.createElement(Ul,{size:n==="large"?"24":"4"}),!!l.alert&&pt.createElement(Uf,{size:n},pt.createElement(vx,{id:"widget-no-result-alert",type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&pt.createElement(xx,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:pt.createElement(zf,null,pt.createElement(Ex,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(hr,"NoResult");import{i18n as yr}from"@lingui/core";import{Button as Px,Divider as _x,MessageBox as Dx,Typography as $x,WarningIcon as Fx}from"@rango-dev/ui";import Yt from"react";import{InfoIcon as Bx,Tooltip as Wx,Typography as Mx}from"@rango-dev/ui";import An from"react";import{Button as Ix,darkTheme as Ax,styled as Qo,Typography as Nx}from"@rango-dev/ui";var Qf=Qo("div",{width:"100%"}),zl=Qo("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),qf=Qo("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${Ax} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Gf=Qo("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$2"}),Vf=Qo(Nx,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"250px"}),Kf=Qo("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"}),jf=Qo(Ix,{"& ._text":{gap:"$5",display:"flex",alignItems:"center",justifyContent:"center"}});var Lx=35;function Xf(t){let{title:e,value:o,valueColor:n}=t,r=B();return An.createElement(qf,null,An.createElement(Mx,{size:"medium",variant:"label",className:"_title"},e),An.createElement(Gf,null,An.createElement(Vf,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`),o.length>Lx&&An.createElement(Wx,{content:o,container:r},An.createElement(Bx,{size:12,color:"gray"}))))}i(Xf,"QuoteErrorsModalItem");function Yf(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",c=[{title:yr.t("Swapping"),value:_(r.inputUsdValue)},{title:yr.t("Gas cost"),value:_(r.totalFee,2,2)},{title:yr.t("Receiving"),value:_(r.outputUsdValue)},{title:yr.t("Price impact"),value:_(r.priceImpact,2,2),valueColor:`${s}500`}];return Yt.createElement(ee,{id:"widget-high-value-loss-warning-modal",footer:Yt.createElement(Px,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Yt.createElement(Fx,null),fullWidth:!0,disabled:a,onClick:n},re().highValueLossError.confirmMessage),open:e,onClose:o,container:B()},Yt.createElement(Dx,{type:s,title:re().highValueLossError.impactTitle,description:re().highValueLossError.description}),Yt.createElement(zl,null,Yt.createElement(_x,{size:"4"}),Yt.createElement($x,{size:"small",variant:"title"},yr.t("Details")),Yt.createElement(zl,null,c.map((l,p)=>Yt.createElement(Xf,{key:p,...l})))))}i(Yf,"HighValueLossWarningModal");import{i18n as Nn}from"@lingui/core";function Zf(t,e){let o={alertType:"warning",title:"",action:null,actionButtonTitle:null};if(e)return o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=Nn.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-slippage",o.actionButtonTitle=Nn.t("Increase")),o;if(t){switch(t.type){case 0:{Xt(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=re().highValueLossError.title;break}case 4:{o.title=Nn.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=re().unknownPriceError.title;break}case 2:{o.title=Nn.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-slippage",o.actionButtonTitle=Nn.t("Increase");break}case 3:{o.title=Nn.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(Zf,"makeAlerts");function Jf(t,e){return e?.type===4?Number(e.minRequiredSlippage):t?.type===2?Number(t.minRequiredSlippage):null}i(Jf,"getRequiredSlippage");import{i18n as Bn}from"@lingui/core";import{Button as Ox,Divider as Hl,MessageBox as Ux,WarningIcon as zx}from"@rango-dev/ui";import Co from"react";import{useNavigate as Hx}from"react-router-dom";function Rf(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=Hx();return Co.createElement(ee,{id:"widget-slippage-warning-modal",anchor:"bottom",open:e,container:B(),onClose:o},Co.createElement(Ux,{type:"warning",title:r.type===3?Bn.t("High slippage"):Bn.t("Low slippage"),description:r.type===3?Bn.t("Caution, your slippage is high. Your trade may be front run."):Bn.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:r.minRequiredSlippage}})},Co.createElement(Hl,{size:18}),Co.createElement(Hl,{size:32}),Co.createElement(jf,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:a,onClick:n},Co.createElement(zx,{color:"white",size:16}),Bn.t("Swap anyway")),Co.createElement(Hl,{size:10}),Co.createElement(Ox,{id:"widget-slippage-warning-modal-change-slippage-btn",size:"large",type:"primary",variant:"outlined",fullWidth:!0,disabled:a,onClick:()=>s("../"+$.settings)},Bn.t("Change Slippage"))))}i(Rf,"SlippageWarningModal");import{Button as Qx,MessageBox as qx,WarningIcon as Gx}from"@rango-dev/ui";import Ji from"react";function eg(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return Ji.createElement(ee,{id:"widget-unknown-price-warning-modal",footer:Ji.createElement(Qx,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Ji.createElement(Gx,null),fullWidth:!0,disabled:r,onClick:n},re().unknownPriceError.confirmMessage),open:e,onClose:o,container:B()},Ji.createElement(qx,{type:"warning",title:re().unknownPriceError.impactTitle,description:re().unknownPriceError.description}))}i(eg,"UnknownPriceWarningModal");function Sr(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,skipAlerts:s,refetchQuote:c,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:d,onChangeSlippage:f}=t,h={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},g=o?.type===0||o?.type===1,m=Zf(e,o?.type===3||o?.type===4?o:null);m&&!n&&(m.action=null);let y=!!m&&!s,S=i(C=>{if(C==="change-slippage"){let k=o?.type===3||o?.type===4?o:null,x=Jf(e,k);f?.(x)}else C==="change-settings"&&d()},"onclickActionButton");return Fe.createElement(Fe.Fragment,null,g&&Fe.createElement(Fe.Fragment,null,Fe.createElement(tg,{size:10}),Fe.createElement(hr,{skipAlerts:s,error:o,fetch:c})),y&&Fe.createElement(Qf,null,Fe.createElement(tg,{size:10}),Fe.createElement(Kx,{id:"widget-quote-warning-and-errors-alert",title:m.title,type:m.alertType,variant:"alarm",...m.action==="show-info"&&{action:Fe.createElement(Kf,{onClick:l},Fe.createElement(Xx,{size:12,color:"gray"}))},...(m.action==="change-settings"||m.action==="change-slippage")&&{action:Fe.createElement(jx,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:m.alertType,onClick:()=>S(m.action)},m.actionButtonTitle||Vx.t("Change"))}})),e&&Fe.createElement(Fe.Fragment,null,e.type===0&&Fe.createElement(Yf,{...h,warning:e}),(e.type===3||e.type===2)&&Fe.createElement(Rf,{...h,warning:e}),e.type===1&&Fe.createElement(eg,{...h,warning:e})))}i(Sr,"QuoteWarningsAndErrors");import xb from"bignumber.js";import fa from"react";import{i18n as qo}from"@lingui/core";import{Alert as db,CampaignQuoteTag as mb,Divider as Mn,FullExpandedQuote as fb,InfoIcon as Rl,NumericTooltip as ec,QuoteTag as gb,StepDetails as hb,TokenAmount as yb,Typography as Ln,useIsTruncated as tc}from"@rango-dev/ui";import oc from"bignumber.js";import F,{useRef as ua,useState as Sb}from"react";import{styled as Ql}from"@rango-dev/ui";var ql=Ql("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),og=Ql("div",{paddingBottom:"$15","& .from-amount-text":{wordBreak:"break-word"},variants:{dense:{true:{paddingBottom:0}}}}),ng=Ql("div",{width:"100%",display:"flex"});import*as Ri from"@radix-ui/react-collapsible";import{Button as Yx,css as ea,darkTheme as _e,Image as rg,styled as Ge,Typography as Gl}from"@rango-dev/ui";var Zx=300,ig=Ge(Ri.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${_e} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${_e} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${_e} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),ag=ea({padding:"$10 $15"}),sg=Ge(Yx,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${_e} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${_e} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${_e} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),lg=Ge("div",{borderRadius:"$xm",display:"flex",flexDirection:"column",alignItems:"start",justifyContent:"space-between",color:"$foreground",boxSizing:"border-box",position:"relative",variants:{selected:{true:{},false:{$$color:"$colors$neutral200",[`.${_e} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${_e} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${_e} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${_e} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${_e} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${_e} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${_e} &`]:{backgroundColor:"$neutral400"}}}}]}),cg=ea({width:"100%",padding:"$15 $15 $10 $15"}),pg=ea({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Wn=ea({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),ug=Ge(Ri.Trigger,{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",height:"$36",padding:"$10 $15",boxSizing:"border-box",cursor:"pointer",border:"none",outline:"none",backgroundColor:"transparent",variants:{error:{true:{[`& ${rg}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${rg}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${_e} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${_e} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${_e} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),dg=Ge("div",{width:"18px",height:"18px",borderRadius:"100%",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",img:{borderRadius:"100%"},variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),mg=Ge(Vi,{width:"100%",background:"inherit"}),Vl=Ge("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${Zx}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),bQ=Ge("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),fg=Ge("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${_e} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),gg=Ge("div",{display:"flex",flexDirection:"row",alignItems:"center",gap:"$2",flex:"1 1 auto",minWidth:0}),Kl=Ge(Gl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"$30"}),jl=Ge(Gl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,flex:"0 1 auto"}),Xl=Ge("div",{width:"18px",height:"18px",borderRadius:"100%",backgroundColor:"$background",cursor:"default",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),hg=Ge("div",{display:"flex"}),ta=Ge("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${_e} &`]:{borderTopColor:"$neutral800"}}),yg=Ge(Gl,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",minWidth:0,flexShrink:3});import{i18n as $t}from"@lingui/core";import{ChevronDownIcon as Rx,CloseIcon as eb,Divider as ra,IconButton as tb,NumericTooltip as ob,QuoteCost as nb,Typography as At}from"@rango-dev/ui";import R,{useState as kg}from"react";import{css as Jx,styled as oa}from"@rango-dev/ui";var na=oa("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Yl=oa("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),Sg=oa("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),Cg=oa("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),Tg=Jx({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var rb=i(t=>t.fee.isZero()?null:R.createElement(na,null,R.createElement(At,{variant:"label",size:"medium",color:"neutral600"},t.label),R.createElement(At,{variant:"label",size:"medium"},"$",_(t.fee,4,4))),"NonPayableFee");function Zl(t){let[e,o]=kg(!1),[n,r]=kg(!1),{steps:a,quote:s,fee:c,time:l,feeWarning:p,timeWarning:u,showModalFee:d,fullExpandedMode:f=!1}=t,h=s?.swaps??[],g=f?Wo():B(),m=qd(h),y=_(c,2,2);return R.createElement(R.Fragment,null,R.createElement(nb,{onClickFee:d?S=>{S.stopPropagation(),o(!e)}:void 0,fee:y,feeWarning:p,timeWarning:u,time:l,steps:a,tooltipGas:d?$t.t("View more info"):void 0,tooltipContainer:g}),R.createElement(ee,{id:"widget-quote-cost-explanation-modal",container:g,open:e,anchor:f?"center":"bottom",styles:{container:{maxWidth:f?"484px":"unset"}},header:R.createElement(Cg,{style:{textAlign:f?"left":"center"}},R.createElement(At,{variant:"title",size:"medium"},$t.t("Gas & Fee Explanation")),R.createElement(tb,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},R.createElement(eb,{color:"gray",size:14}))),onClose:()=>{o(!1)}},R.createElement(Sg,null,R.createElement(At,{variant:"title",size:"small"},$t.t("Details")),R.createElement(ra,{size:10}),Object.entries(m.payable).flatMap(([S,C])=>C.map((k,x)=>{let w=`payable-fee-${x}`,I=Ks(k);return R.createElement(na,{key:w},R.createElement(At,{variant:"label",size:"medium",color:"neutral600"},Hs(S,$t.t)),R.createElement(ob,{content:k.amount,container:g},R.createElement(At,{variant:"label",size:"medium"},_(k.amount,2,2),k.asset.symbol," ($",_(I,4,4),")")))})),R.createElement(na,{className:"total_payable_fee"},R.createElement(At,{variant:"label",size:"medium"},$t.t("Total Payable Fee")),R.createElement(At,{variant:"label",size:"medium"},"$",_(c,4,4))),R.createElement(Yl,null),!!Object.keys(m.nonePayable).length&&R.createElement(Xi,{triggerAnchor:"bottom",onClickTrigger:()=>r(S=>!S),trigger:R.createElement("div",{className:Tg()},R.createElement(At,{size:"small",variant:"body",color:"neutral700"},n?$t.t("Hide non-payable fees"):$t.t("Show non-payable fees")),R.createElement(ra,{size:4,direction:"horizontal"}),R.createElement(Ki,{orientation:n?"up":"down"},R.createElement(Rx,{size:12,color:"gray"}))),open:n},R.createElement(At,{size:"small",variant:"title"},$t.t("Description")),R.createElement(ra,{size:4}),R.createElement(At,{size:"small",variant:"body",color:"neutral700"},$t.t(`The following fees are considered in the transaction output and
|
|
2
|
-
you won\u2019t need to pay extra gas for them.`)),R.createElement(ra,{size:10}),Object.entries(m.nonePayable).map(([S,C],k)=>{let x=Qd(C),w=Hs(S,$t.t),I=`non-payable-fee-${k}`;return R.createElement(rb,{key:I,fee:x,label:w})}),R.createElement(Yl,null)))))}i(Zl,"QuoteCostDetails");import{i18n as xg}from"@lingui/core";import{TokenAmount as bg}from"@rango-dev/ui";import ia from"react";import{css as ib,styled as ab}from"@rango-dev/ui";var wg=ab("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),vg=ib({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function Cr(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return ia.createElement(wg,null,ia.createElement(bg,{direction:"horizontal",label:xg.t("Swap input"),id:"widget-quote-summary-swap-input",type:"input",tooltipContainer:B(),price:{value:e.price.value,usdValue:e.price.usdValue,realValue:e.price.realValue,realUsdValue:e.price.realUsdValue},token:{displayName:e.token.displayName,image:e.token.image},chain:{image:e.chain.image}}),ia.createElement("div",{className:vg()}),ia.createElement(bg,{id:"widget-quote-summary-estimated-input",direction:"horizontal",tooltipContainer:B(),label:xg.t("Estimated output"),type:"output",price:{value:o.price.value,usdValue:o.price.usdValue,realValue:o.price.realValue,realUsdValue:o.price.realUsdValue},token:{displayName:o.token.displayName,image:o.token.image},chain:{image:o.chain.image},percentageChange:n,warningLevel:r}))}i(Cr,"QuoteSummary");import{i18n as Bg}from"@lingui/core";import{ChevronDownIcon as cb,ChevronRightIcon as pb,Divider as Jl,Image as ub,Tooltip as pa,Typography as sa}from"@rango-dev/ui";import q from"react";import{useLayoutEffect as sb,useState as Tr}from"react";var Eg=480,Ig=768,Ag=1024,Ng=1200,lb=i(()=>{let[t,e]=Tr(!1),[o,n]=Tr(!1),[r,a]=Tr(!1),[s,c]=Tr(!1),[l,p]=Tr(!1),u=i(()=>{e(window.innerWidth<=Eg),n(window.innerWidth>Eg&&window.innerWidth<=Ig),a(window.innerWidth>Ig&&window.innerWidth<=Ag),c(window.innerWidth>Ag&&window.innerWidth<=Ng),p(window.innerWidth>Ng)},"handleResize");return sb(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:l}},"useScreenDetect"),aa=lb;var la=4,ca=6,kr=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,c=s||B();return q.createElement(pa,{container:c,side:"bottom",sideOffset:4,open:r,content:e},q.createElement(dg,{className:n,state:a},q.createElement(ub,{src:o,size:16})))},"ImageComponent");function Wg(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:c}=t,l=c||B(),p=r.length,u=Ld(r),{isTablet:d,isMobile:f}=aa();return q.createElement(ug,{className:"widget-quote-trigger-btn",listItem:s==="list-item",ref:h=>e.current=h,selected:o,onClick:h=>{h.stopPropagation(),n(g=>!g)}},q.createElement("div",{className:Wn()},q.createElement(sa,{variant:"body",size:"xsmall"},Bg.t("Via:")),q.createElement(Jl,{direction:"horizontal",size:4}),r.map((h,g)=>{let m=`item-${g}`,y=q.createElement(Vl,null,q.createElement(pb,{size:12,color:"black"}));return f||d?q.createElement(q.Fragment,{key:m},q.createElement(kr,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&q.createElement(q.Fragment,null,y)):q.createElement(q.Fragment,{key:m},p<=la||p>la&&g<la-1?q.createElement(q.Fragment,null,q.createElement(kr,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&q.createElement(q.Fragment,null,y)):g===la-1&&q.createElement(pa,{container:l,side:"bottom",align:"end",sideOffset:4,content:q.createElement("div",{className:Wn()},y,r.map((S,C)=>{let k=`image-${C}`;return C>=g&&q.createElement(q.Fragment,{key:k},q.createElement(kr,{content:S.swapper.displayName,src:S.swapper.image??"",state:S.state,open:!1}),C!==p-1&&q.createElement(q.Fragment,null,y))}))},q.createElement(Xl,{state:r.find((S,C)=>C>=g&&(S.state==="error"||S.state==="warning"))?.state},q.createElement(sa,{size:"xsmall",variant:"body"},"+",p-g))))})),q.createElement("div",{className:Wn()},q.createElement("div",{className:"blockchains_section"},q.createElement("div",{className:Wn()},q.createElement(sa,{variant:"body",size:"xsmall"},Bg.t("Chains:")),q.createElement(Jl,{direction:"horizontal",size:4}),u.map((h,g)=>q.createElement(q.Fragment,{key:h.displayName},u.length<=ca||u.length>ca&&g<ca-1?q.createElement(pa,{container:l,side:"bottom",content:h.displayName,sideOffset:4},q.createElement(kr,{content:"",src:h.image??"",open:!1,className:g!==0?"blockchainImage":""})):g===ca-1&&q.createElement(pa,{container:l,side:"bottom",align:"end",sideOffset:4,content:q.createElement("div",{className:Wn()},u.map((m,y)=>y>=g&&q.createElement(kr,{key:m.displayName,content:"",src:m.image??"",open:!1,className:y>g?"blockchainImage":"",container:c})))},q.createElement(Xl,{className:"blockchainImage"},q.createElement(sa,{size:"xsmall",variant:"body"},"+",u.length-g))))),q.createElement(Jl,{direction:"horizontal",size:32}))),q.createElement(Vl,{orientation:a?"up":"down"},q.createElement(cb,{size:12,color:"black"}))))}i(Wg,"QuoteTrigger");function nc(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:c=!1,tagHidden:l=!0,showModalFee:p=!0,onClickAllRoutes:u,fullExpandedMode:d=!1,container:f}=t,h=T().blockchains(),{findToken:g}=T(),m=T().swappers(),{customSlippage:y,slippage:S}=T(),C=y||S,[k,x]=Sb(t.expanded),w=ua(null),I=_(n.value,6,6),A=n.usdValue?_(n.usdValue,4,4):"",{config:{__UNSTABLE_OR_INTERNAL__:b}}=T(),E=jt(o.usdValue,n.usdValue??null),v=_(E,2,2),N=Xt(E??0),M=i((G,Ve)=>G.map((V,Ce)=>{let Je,ht=r?.type===3&&r.swap.swapperId===V.swapperId,so=r?.type===4&&!!r.recommendedSlippages?.[Ce],zn=a?.type===2&&!!a.recommendedSlippages?.[Ce],Io=ht||so,Zr=zn;Io?Je="error":Zr&&(Je="warning");let Ro=Io?qo.t("Slippage Error"):qo.t("Slippage Warning");return ht&&(Ro=qo.t("Bridge Limit Error")),{swapper:{displayName:Qn(V.swapperId,m)??"",image:V.swapperLogo},from:{token:{displayName:V.from.symbol,image:V.from.logo},chain:{displayName:yt(V.from.blockchain,h)??"",image:V.from.blockchainLogo},price:{value:Ce===0&&!Ve?_(o.value,6,6):_(V.fromAmount,6,6),usdValue:_((V.from.usdPrice??0)*parseFloat(V.fromAmount),4,4),realValue:Ce===0?o.value:V.fromAmount,realUsdValue:new oc(V.from.usdPrice??0).multipliedBy(V.fromAmount).toString()}},to:{token:{displayName:V.to.symbol,image:V.to.logo},chain:{displayName:yt(V.to.blockchain,h)||"",image:V.to.blockchainLogo},price:{value:_(V.toAmount,6,6),usdValue:_((V.to.usdPrice??0)*parseFloat(V.toAmount),4,4),realValue:V.toAmount,realUsdValue:new oc(V.to.usdPrice??0).multipliedBy(V.toAmount).toString()}},state:Je,alerts:Io||Zr?F.createElement(og,{dense:d},F.createElement(db,{variant:"alarm",type:Io?"error":"warning",title:Ro,id:"widget-quote-footer-step-alarm-alert",footer:F.createElement(ng,null,ht&&F.createElement("div",null,F.createElement(Ln,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Mn,{direction:"vertical",size:2}),F.createElement(Ln,{size:"xsmall",variant:"body",className:"from-amount-text",color:"neutral900"},qo.t({id:"Yours: {amount} {symbol}",values:{amount:_(V.fromAmount,6,6),symbol:V?.from.symbol}}))),(so||zn)&&!ht&&F.createElement("div",null,F.createElement(Ln,{size:"xsmall",variant:"body",color:"neutral900"},qo.t({id:"Minimum suggested slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.[Ce]},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.[Ce]}}})),F.createElement(Mn,{direction:"vertical",size:2}),F.createElement(Ln,{size:"xsmall",variant:"body",color:"neutral900"},qo.t({id:"Yours: {userSlippage}",values:{userSlippage:C}}))))})):void 0,time:Gn(V.estimatedTimeInSeconds),fee:_(Vs(V,g),2,2),internalSwaps:V.internalSwaps?M(V.internalSwaps):void 0}}),"getQuoteSteps"),P=M(e?.swaps??[]),U=P.length,Q=f||B(),Z=_d(t.quote.tags||[]),W=!!u,J=si(e?.swaps),X=Gn(J),ae=Bi(e?.swaps??[],g),Se=_(ae,2,2),at=ae.gte(new oc(bd)),ue=J/Id>=Ed,gt=ua(null),vt=tc(o.value,gt),xt=ua(null),O=tc(n.value,xt),z=ua(null),Y=tc(A,z),te=P[U-1],j=P[0];return!j||!te?null:d?F.createElement(fb,{selected:c,fee:Se,time:X,tooltipContainer:Wo(),steps:P,tags:Z,campaignTag:b?.campaignTag,id:"widget-quote-full-expanded-quote-container",quoteCost:F.createElement(Zl,{quote:e,fullExpandedMode:!0,time:X,fee:ae,feeWarning:at,timeWarning:ue,showModalFee:p,steps:U}),percentageChange:v,warningLevel:N,outputPrice:{value:I,usdValue:A,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(lg,{id:"widget-quote-summary-container",selected:c,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:cg()},!l&&Z.length?F.createElement(F.Fragment,null,F.createElement(hg,null,Z.map((G,Ve)=>{let V=`${G.value}_${Ve}`;return F.createElement(F.Fragment,{key:V},G.value=="CAMPAIGN"&&b?.campaignTag?F.createElement(mb,{routeTag:G,...b.campaignTag}):F.createElement(gb,{label:G.label,value:G.value}),F.createElement(Mn,{size:4,direction:"horizontal"}))})),F.createElement(ta,null),!W&&F.createElement(Mn,{size:4})):null,F.createElement("div",{id:"portal-root",className:pg()},F.createElement(Zl,{quote:e,time:X,fee:ae,feeWarning:at,timeWarning:ue,showModalFee:p,steps:U}),W&&F.createElement(sg,{onClick:G=>{G.stopPropagation(),u()},id:"widget-quote-all-routes-btn",size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Ln,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},qo.t("See All Routes")))),s==="basic"&&F.createElement(gg,null,F.createElement(jl,{ref:gt,size:"small",variant:"body"},o.value),vt&&F.createElement(ec,{content:o.value,container:Q,open:o.value?void 0:!1},F.createElement(Rl,{size:12,color:"gray"})),F.createElement(Kl,{size:"small",variant:"body"},P[0]?.from.token.displayName),F.createElement(Ln,{size:"small",variant:"body"},"="),F.createElement(jl,{ref:xt,size:"small",variant:"body"},n.value),O&&F.createElement(ec,{content:n.value,container:Q,open:n.value?void 0:!1},F.createElement(Rl,{size:12,color:"gray"})),F.createElement(Kl,{size:"small",variant:"body"},te?.to.token.displayName),F.createElement(Mn,{size:2,direction:"horizontal"}),F.createElement(yg,{ref:z,color:"$neutral600",size:"xsmall",variant:"body"},`($${A})`),Y&&F.createElement(ec,{content:n.usdValue,container:Q},F.createElement(Rl,{size:12,color:"gray"}))),s==="list-item"&&F.createElement(yb,{id:"widget-quote-token-amount-container",tooltipContainer:Q,type:"output",direction:"vertical",price:{value:I,usdValue:A,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:te.to.token.displayName,image:te.to.token.image},chain:{image:te.to.chain.image},percentageChange:v,warningLevel:N}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(Cr,{from:j.from,to:te.to,percentageChange:v,warningLevel:N}),F.createElement(Mn,{size:4}))),F.createElement(ig,{selected:c,listItem:s==="list-item",open:k,className:"quote_container",onOpenChange:x},F.createElement(Wg,{type:s,quoteRef:w,selected:c,setExpanded:x,container:Q,expanded:k,steps:P}),F.createElement(mg,{open:k},F.createElement(fg,null),F.createElement("div",{className:ag()},P.map((G,Ve)=>{let V=`item-${Ve}`;return F.createElement(hb,{type:"quote-details",className:"widget-quote-step-details-container",key:V,tooltipContainer:Q,step:G,hasSeparator:Ve!==P.length-1,state:G.state})})))))}i(nc,"Quote");import{Divider as wb,Skeleton as vb}from"@rango-dev/ui";import eo from"react";import{darkTheme as Cb,styled as da}from"@rango-dev/ui";var Mg=da("div",{$$color:"$colors$neutral100",[`.${Cb} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Lg=da("div",{paddingTop:"$2"}),Pg=da("div",{paddingLeft:"$8"}),_g=da("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Gg,Divider as Nt,Skeleton as ut}from"@rango-dev/ui";import K from"react";import{css as Tb,styled as Rt}from"@rango-dev/ui";var rc=Rt("div",{display:"flex"}),Dg=Rt("div",{padding:"$10 $0 $20"}),$g=Rt("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Fg=Rt("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Og=Rt("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Ug=Rt("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),zg=Rt("div",{width:"65%",display:"flex",justifyContent:"start"}),Hg=Rt("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Qg=Rt("div",{padding:"$15 $0 $15 $0"}),qg=Tb({display:"flex",justifyContent:"space-between",alignItems:"center"});function wr(t){let{type:e,tagHidden:o=!0}=t,n=K.createElement(Og,null,K.createElement(zg,null,K.createElement(Gg,{loading:!0,size:"medium"}),K.createElement(Nt,{size:8,direction:"horizontal"}),K.createElement(Hg,null,K.createElement(ut,{height:10,width:60,variant:"rounded"}),K.createElement(Nt,{size:4}),K.createElement(ut,{height:15,variant:"rounded"}))),K.createElement(ut,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return K.createElement("div",null,!o&&K.createElement(K.Fragment,null,K.createElement(rc,null,K.createElement(ut,{width:65,height:20,variant:"rounded"}),K.createElement(Nt,{size:4,direction:"horizontal"}),K.createElement(ut,{width:65,height:20,variant:"rounded"}),K.createElement(Nt,{size:4,direction:"horizontal"}),K.createElement(ut,{width:65,height:20,variant:"rounded"})),K.createElement(ta,null),!r&&K.createElement(Nt,{size:4})),K.createElement("div",{className:qg()},K.createElement(rc,null,K.createElement(ut,{width:60,height:10,variant:"rounded"}),K.createElement(Nt,{size:4,direction:"horizontal"}),K.createElement(ut,{width:60,height:10,variant:"rounded"}),K.createElement(Nt,{size:4,direction:"horizontal"}),K.createElement(ut,{width:60,height:10,variant:"rounded"})),r&&K.createElement(ut,{width:85,height:24,variant:"rounded"})),e==="basic"&&K.createElement(Dg,null,K.createElement(ut,{height:15,width:148,variant:"rounded"})),e==="list-item"&&K.createElement($g,null,K.createElement(Fg,null,K.createElement(Gg,{loading:!0,size:"medium"}),K.createElement(Nt,{direction:"horizontal",size:4}),K.createElement(ut,{height:15,width:150,variant:"rounded"})),K.createElement(Nt,{size:10}),K.createElement(ut,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&K.createElement(K.Fragment,null,K.createElement(Nt,{size:4}),K.createElement(Qg,null,n,K.createElement(Ug,null),n),K.createElement(Nt,{size:12})))}i(wr,"QuoteSummarySkeleton");import{ChainToken as Yg,Divider as ac,NextIcon as kb,Skeleton as ma}from"@rango-dev/ui";import We from"react";import{styled as vr}from"@rango-dev/ui";var Vg=vr("div",{display:"flex",alignItems:"start"}),Kg=vr("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),ic=vr("div",{display:"flex",alignItems:"center",flexGrow:1}),jg=vr("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Xg=vr("div",{display:"flex",alignItems:"center"});function Ft(t){let{separator:e=!0}=t;return We.createElement(We.Fragment,null,We.createElement(Xg,null,We.createElement(ma,{height:22,width:22,variant:"circular"}),We.createElement(ac,{direction:"horizontal",size:8}),We.createElement(ma,{height:15,width:148,variant:"rounded"})),We.createElement(Vg,null,We.createElement(_g,{hideSeparator:!e}),We.createElement(Kg,{extraSpace:e},We.createElement(ic,null,We.createElement(Yg,{size:"small",loading:!0}),We.createElement(ac,{direction:"horizontal",size:8}),We.createElement(ma,{height:12,variant:"rounded"})),We.createElement(jg,null,We.createElement(kb,{color:"gray",size:16})),We.createElement(ic,null,We.createElement(Yg,{size:"small",loading:!0}),We.createElement(ac,{direction:"horizontal",size:8}),We.createElement(ma,{height:12,variant:"rounded"})))))}i(Ft,"StepSkeleton");function xr(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return eo.createElement(Mg,{expanded:o,rounded:e!=="basic"},eo.createElement(wr,{type:e,tagHidden:n}),eo.createElement(Lg,null,eo.createElement(vb,{height:15,variant:"rounded"})),o&&eo.createElement(Pg,null,eo.createElement(wb,{size:24}),eo.createElement(Ft,null),eo.createElement(Ft,null),eo.createElement(Ft,{separator:!1})))}i(xr,"QuoteSkeleton");function Go(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:c,onClick:l,showModalFee:p,selected:u,id:d,onClickAllRoutes:f,fullExpandedMode:h=!1,container:g}=t,{inputAmount:m,inputUsdValue:y}=H()(),S=e?.outputAmount?new xb(e?.outputAmount):null,C=e?Ct(e):null,x=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?fa.createElement(ql,null,fa.createElement(xr,{tagHidden:c,type:o,expanded:s})):x?fa.createElement(ql,{onClick:()=>l?.(e),id:d},fa.createElement(nc,{quote:e,error:r,container:g,showModalFee:p,warning:a,tagHidden:c,selected:u,type:o,expanded:s,onClickAllRoutes:f,fullExpandedMode:h,input:{value:m,usdValue:y?.toString()??""},output:{value:S?.toString()??"",usdValue:C?.toString()??""}})):null}i(Go,"QuoteInfo");import{warn as Ab}from"@rango-dev/logging-core";import{calculatePendingSwap as Nb}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Bb}from"react";import{useRef as bb,useState as Eb}from"react";var Ib=2e3;function ga({request:t}){let[e,o]=Eb(!1),n=bb(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async c=>(await new Promise(l=>setTimeout(l,Ib)),await s(c,!1)),"retryFetch"),s=i(async(c,l=!1)=>{r(),n.current=new AbortController,o(!0);try{let p=await t(c,{signal:n.current.signal});return n.current=null,p}catch(p){if(l)return await a(c);throw p}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(ga,"useFetch");function Zg(){let{fetch:t,loading:e,cancelFetch:o}=ga({request:async(n,r)=>await ct().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Zg,"useFetchConfirmQuote");function ha(t){if(!t.swaps)throw new Error(re().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=sc(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(ha,"throwErrorIfResponseIsNotValid");function sc(t){if(Ud(t)){let{swap:n,fromAmountRangeError:r,recommendation:a}=zd(t);return n?{message:"bridge limit error",options:{type:3,swap:n,recommendation:a,fromAmountRangeError:r}}:null}let o=Gd(t);if(o){let n=Wi(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(sc,"getQuoteError");function Jg(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,c={quote:null,balance:null},l=Cn({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});l&&(c.quote=l);let p=jd(e,r,n.blockchains);return p.length===0||(c.balance={messages:p}),c}i(Jg,"generateWarnings");function ya(t){return t?.code==="ERR_CANCELED"?{type:2}:t.cause?t.cause:t?.code==="ERR_BAD_REQUEST"?{type:0,diagnosisMessage:t.response.data.error}:{type:1,diagnosisMessage:t.message}}i(ya,"handleQuoteErrors");function lc(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:c}=H()(),{slippage:l,customSlippage:p}=T(),u=T().getDisabledLiquiditySources(),d=T().blockchains(),f=T().tokens(),{findToken:h}=T(),{swapMode:g}=tt(),m=p||l,{fetch:y,cancelFetch:S,loading:C}=Zg();return Bb(()=>S,[]),{loading:C,fetch:i(async x=>{let w=x.selectedWallets,I=x?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=w.reduce((E,v)=>(E[v.chain]=v.address,E),{}),b={requestId:a?.requestId||"",selectedWallets:A,destination:I||void 0};try{return await y(b,!0).then(E=>{let{result:v}=E;if(!v)throw new Error(E.error??"Error fetching updated quote");ha({diagnosisMessages:v.diagnosisMessages,requestId:v.requestId,swaps:v.result?.swaps});let N={outputAmount:v.result?.outputAmount,requestId:v.requestId,resultType:v.result?.resultType,swaps:v.result?.swaps||[],validationStatus:v.validationStatus,requestAmount:v.requestAmount};r(N);let M={slippage:m.toString(),disabledSwappersGroups:u},P=Jg({previousQuote:a??void 0,currentQuote:N,meta:{blockchains:d},selectedWallets:w,userSlippage:m,inputUsdValue:n,findToken:h});c();let U=!!P.balance,Q=Nb({inputAmount:o.toString(),bestRoute:v,wallets:Kd(w),settings:M,validateBalanceOrFee:!U,meta:{blockchains:d,tokens:f},swapMode:g});return{quote:N,swap:Q,error:null,warnings:P}})}catch(E){let v=ya(E);return v.type!==2&&Ab(new Error("confirm swap error"),{tags:{...v,type:Xe[v.type],initialQuote:a,requestBody:b}}),{swap:null,error:v,warnings:null}}},"fetch"),cancelFetch:S}}i(lc,"useConfirmSwap");var Ub=Pb("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Rg}`]:{width:"$48",height:"$48"}}),zb=uc({flexGrow:1,paddingRight:"$10"}),Hb=uc({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Qb=uc({display:"flex",justifyContent:"space-between",alignItems:"center"});function eh(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=H()(),s=Ob(),[c,l]=br(""),p=!n,[u,d]=br(!1),[f,h]=br(!1),{isActiveTab:g}=ne(),m=T().getDisabledLiquiditySources(),y=Fb(m),{manager:S}=Wb(),{fetch:C,loading:k,cancelFetch:x}=lc(),[w,I]=br({swap:null,error:null,warnings:null}),[A,b]=br(!1),E=i(async({selectedWallets:W,customDestination:J})=>{let X=await C?.({selectedWallets:W,customDestination:J});return I(X),X},"onConfirmSwap"),v=i(async()=>{if(w.swap&&n)try{await S?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let W=`../${$.swaps}/${w.swap.requestId}`;s(W,{replace:!0}),setTimeout(()=>{e("")},0)}catch(W){l("Error: "+W?.message)}},"addNewSwap"),N=i(async()=>{h(!0),await v(),h(!1)},"onConfirm"),M=i(async()=>{w.warnings?.quote&&Md(w.warnings.quote)&&!a?b(!0):await N()},"onStartConfirmSwap"),P=i(async()=>{I({error:null,swap:null,warnings:null}),C({selectedWallets:o,customDestination:r}).then(W=>{I(W)}).catch(W=>console.error(W))},"onRefresh");Sa(()=>{!!y.current.length&&!m.length&&P(),y.current=m},[m.length]),Sa(()=>{p&&x()},[p]),Sa(()=>{p&&d(p)},[p]),Sa(()=>{p||C({selectedWallets:o,customDestination:r}).then(W=>I(W)).catch(W=>console.error(W))},[]),$b(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let U=w.warnings?.quote??null,Q=w.error,Z=[];if(c&&Z.push(De.createElement(Mb,{id:"widget-confirm-swap-db-error-alert",type:"error",variant:"alarm",title:c})),U||Q){let W=`../${$.settings}`;Z.push(De.createElement(Sr,{warning:U,error:Q,couldChangeSettings:!1,refetchQuote:P,skipAlerts:Q?.type===4||U?.type===2,showWarningModal:A,confirmationDisabled:!g,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:async()=>{b(!1),await v()},onChangeSettings:()=>s(W)}))}return De.createElement(se,{header:{title:cc.t("Confirm Swap"),onWallet:()=>{let W=`../${$.wallets}`;s(W)}},footer:De.createElement(Ub,null,De.createElement("div",{className:zb()},De.createElement(Lb,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:k||f,disabled:!!w.error||!g,onClick:M},cc.t("Start Swap"))),De.createElement(Rg,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:k||f,disabled:!g,onClick:d.bind(null,!0)},De.createElement(Db,{size:24})))},u&&De.createElement(_f,{open:u,onClose:()=>d(!1),onCancel:x,loading:k,onCheckBalance:E}),De.createElement(ce,null,De.createElement("div",{className:Qb()},De.createElement(_b,{variant:"title",size:"small"},cc.t("You get")),De.createElement("div",{className:Hb()},De.createElement(Oi,{onClick:!k&&!u&&!A?P:void 0}))),De.createElement(pc,{size:"12"}),bm(Z.map((W,J)=>({element:W,key:`alert-${J}`})),De.createElement(pc,{size:10})),Z.length>0?De.createElement(pc,{size:10}):null,De.createElement(Go,{quote:t,type:"swap-preview",id:"widget-confirm-swap-quote-container",expanded:!0,tagHidden:!0,error:w.error,loading:k,warning:w.warnings?.quote??null})))}i(eh,"ConfirmSwapPage");import{i18n as oo}from"@lingui/core";import{Button as vc,CustomTokensZeroStateDarkIcon as cE,CustomTokensZeroStateIcon as pE,DeleteIcon as uE,Divider as Br,IconButton as dE,MessageBox as mE,NotFound as fE,styled as bc}from"@rango-dev/ui";import he,{useState as xc}from"react";import{useNavigate as gE}from"react-router-dom";import{CloseIcon as qb,IconButton as Gb,SearchIcon as Vb,TextField as Kb}from"@rango-dev/ui";import Pn from"react";import{styled as th}from"@rango-dev/ui";var oh=th("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"}),nh=th("div",{width:"100%","& ._text-field":{paddingLeft:"$10","& input":{paddingLeft:"$2",paddingTop:"$12",paddingBottom:"$12"}}});function Bt(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:c,setValue:l,suffix:p,id:u,...d}=t,f=s.length?Pn.createElement(Gb,{id:`${u}\u06F0icon-btn`,variant:"ghost",onClick:()=>l?.(""),size:"small"},Pn.createElement(qb,{color:"gray",size:10})):null;return p&&(f=p),Pn.createElement(nh,null,Pn.createElement(Kb,{prefix:Pn.createElement(oh,null,Pn.createElement(Vb,{color:"black"})),id:u,suffix:f,fullWidth:o,color:n,variant:e,style:{borderRadius:25,alignItems:"center",...c},size:r,value:s,onChange:a,...d}))}i(Bt,"SearchInput");import{i18n as wc}from"@lingui/core";import{Button as Zb,CustomTokenWarning as Jb,darkTheme as gh,Divider as to,ExternalLinkIcon as Rb,Image as eE,ListItem as tE,NotFound as oE,PinIcon as nE,Skeleton as Vo,Typography as Ar,VirtualizedList as rE}from"@rango-dev/ui";import L,{useState as iE}from"react";import{useTranslation as aE}from"react-i18next";import{Divider as mh,ListItem as Yb,Skeleton as Ir}from"@rango-dev/ui";import Wt from"react";import{css as _n,darkTheme as dc,ImageContainer as jb,ListItemButton as Xb,styled as rt,Typography as rh}from"@rango-dev/ui";var mc=_n({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),fc=_n({position:"relative",height:12,width:"30%",maxWidth:"150px"}),gc=_n({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),hc=_n({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${dc} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),yc=_n({}),Sc=_n(),ih=rt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Cc=rt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Ca=rt("ul",{flexGrow:1,height:"100%",padding:0,margin:0,display:"flex",flexDirection:"column",listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${fc}`]:{[`& .${hc}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${yc}`]:{bottom:"-15px"},[`& .${mc}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${gc}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),ah=rt(Xb,{variants:{customToken:{true:{"&:hover":{cursor:"unset"}}}}}),Tc=rt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),kc=rt(rh,{}),sh=rt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Sc}`]:{$$color:"$colors$neutral600",[`.${dc} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Er=rt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),vV=rt("div",{display:"flex",alignItems:"center"}),lh=rt("div",{position:"relative",[`& ${jb}`]:{borderRadius:"$xm",overflow:"hidden"}}),ch=rt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),ph=rt(rh,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),uh=rt("a",{"& svg:hover":{color:"$colors$info"}}),dh=rt("div",{paddingRight:"$5","& .widget-token-list-item-btn":{width:"100%",overflow:"hidden",height:"60px"},"& .widget-token-list-item-import-btn":{height:"$20",padding:"0 $10","& ._text":{display:"flex",justifyContent:"center",alignItems:"center"},"& ._typography":{[`.${dc} &`]:{color:"$foreground"}}}});function fh(t){return Wt.createElement(Ca,null,Array.from(Array(t.size),e=>Wt.createElement(Yb,{key:e,hasDivider:!0,start:Wt.createElement(Ir,{variant:"circular",width:35,height:35}),end:Wt.createElement(Er,null,Wt.createElement(Ir,{variant:"text",size:"large",width:70}),Wt.createElement(mh,{size:4}),Wt.createElement(Ir,{variant:"text",size:"medium",width:50})),title:Wt.createElement("div",null,Wt.createElement(Ir,{variant:"text",size:"large",width:90}),Wt.createElement(mh,{size:4}),Wt.createElement(Ir,{variant:"text",size:"medium",width:90}))})))}i(fh,"LoadingTokenList");var sE=20,lE=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,c=e.length;return L.createElement("div",{className:fc()},o?L.createElement("div",{className:mc()},o):L.createElement(Cc,{className:gc()},L.createElement(Ar,{variant:"title",size:"xmedium"},r.symbol),L.createElement(to,{direction:"horizontal",size:4}),L.createElement(Tc,{css:a},L.createElement(kc,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&L.createElement("div",{className:`${hc()} ${!o&&yc()}`},c>10?`${e.slice(0,5)}...${e.slice(c-6,c)}`:e," ",L.createElement(to,{size:4,direction:"horizontal"}),L.createElement(uh,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:l=>l.stopPropagation()},L.createElement(Rb,{size:12}))))},"renderDesc");function Nr(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s,type:c,showWarning:l=!0}=t,p=T().fetchStatus,u=T().blockchains(),{getBalanceFor:d,fetchingWallets:f}=T(),{isTokenPinned:h}=T(),{setFromToken:g,setToToken:m}=H()(),{t:y}=aE(),S=Qe(),[C,k]=iE(null),x=i(()=>{c==="source"?g({token:C,meta:{blockchains:u}}):m({token:C,meta:{blockchains:u}})},"updateToken"),w=i(()=>{x(),S()},"handleImportToken"),I=i(E=>{if(E.customToken){let{customToken:N,...M}=E;return L.createElement(Zb,{variant:"contained",type:"primary",size:"small",className:"widget-token-list-item-import-btn",onClick:i(U=>{U.stopPropagation(),k({...M,warning:!0})},"handleClick")},L.createElement(Ar,{variant:"body",size:"xsmall",color:"background"},y("import")))}let v=ui(d(E));return s?s(E):f?L.createElement(Er,null,L.createElement(Vo,{variant:"text",size:"large",width:70}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:50})):v&&L.createElement(sh,null,L.createElement(ph,{variant:"title",size:"small"},v.amount),L.createElement("div",null),v.usdValue&&L.createElement(Ar,{variant:"body",className:Sc(),size:"xsmall"},`$${v.usdValue}`))},"endRenderer"),A=i(()=>L.createElement(rE,{style:{flexGrow:1,minHeight:0},itemContent:E=>{let v=e[E];if(v==="skeleton")return L.createElement(tE,{hasDivider:!0,start:L.createElement(Vo,{variant:"circular",width:35,height:35}),end:L.createElement(Er,null,L.createElement(Vo,{variant:"text",size:"large",width:70}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:50})),title:L.createElement("div",null,L.createElement(Vo,{variant:"text",size:"large",width:90}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:90}))});let N=u.find(W=>W.name===v?.blockchain);if(!N||!v)return null;let M=v.address,P=ll(N.color,"main"),U={$$color:P.main150,[`.${gh} &`]:{$$color:P.main750},backgroundColor:"$$color"},Q={$$color:P.main750,[`.${gh} &`]:{$$color:P.main150},color:"$$color"},Z=i(()=>{typeof v!="string"&&!v.customToken&&n?.(v)},"handleClick");return L.createElement(dh,null,L.createElement(ah,{"tab-index":E,key:`${v.symbol}${M}`,id:`${v.symbol}${M}`,className:"widget-token-list-item-btn",hasDivider:!0,customToken:v?.customToken,onClick:Z,start:L.createElement(lh,null,L.createElement(eE,{src:v.image===""?ti:v.image,size:30}),t.type!=="custom-token"&&v&&h(v,t.type)&&L.createElement(ch,null,L.createElement(nE,{size:12,color:"gray"}))),title:N.type==="COSMOS"||v.name||!v.name&&!M?L.createElement(Cc,null,L.createElement(Ar,{variant:"title",size:"xmedium"},v.symbol),L.createElement(to,{direction:"horizontal",size:4}),L.createElement(Tc,{css:U},L.createElement(kc,{variant:"body",size:"xsmall",css:Q},v.blockchain)),l&&v.warning&&L.createElement(L.Fragment,null,L.createElement(to,{direction:"horizontal",size:4}),L.createElement(Jb,{container:B()}))):void 0,description:typeof v!="string"&&N.info&&M&&N.type!=="COSMOS"?lE({address:M,token:v,customCssForTag:U,customCssForTagTitle:Q,name:v.name,url:N.info.addressUrl.split("{wallet}").join(M)}):v.name||void 0,end:I(v)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList"),b=C?No(C?.blockchain,u):null;return L.createElement(L.Fragment,null,a&&L.createElement(L.Fragment,null,L.createElement(Ar,{variant:"label",size:"large"},wc.t("Select Token")),L.createElement(to,{size:4})),L.createElement(ih,null,L.createElement(to,{size:4}),p==="loading"&&L.createElement(fh,{size:sE}),p==="success"&&(e.length?L.createElement(L.Fragment,null,L.createElement(mr,{token:C,address:C?.address??"",blockchain:b??void 0,onImport:w,onExitErrorModal:()=>k(null),onExitImportModal:()=>k(null)}),L.createElement(Ca,{as:"ul"},A())):!!o&&L.createElement(oE,{title:wc.t("No results found"),description:wc.t("Try using different keywords")}))))}i(Nr,"TokenList");var hE=bc("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),yE=bc("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),SE=bc(dE,{"&:hover":{"& svg":{color:"$secondary550"}}});function hh(){let[t,e]=xc(""),{deleteCustomToken:o}=T(),n=T().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:c}=H()(),{mode:l}=mo({}),p=gE(),[u,d]=xc(!1),[f,h]=xc(),g=i(C=>{let k=C.target.value;e(k)},"handleSearch"),m=l==="dark",y=n.filter(C=>st(C.symbol,t)||st(C.address||"",t)||st(C.name||"",t)),S=i(()=>{if(f){let C=a?St(a):null,k=r?St(r):null,x=St(f);C===x?c({token:null}):k===x&&s({token:null}),o(f)}d(!1)},"handleDeleteCustomToken");return he.createElement(se,{header:{title:oo.t("Custom Tokens")}},he.createElement(ce,null,he.createElement(hE,null,n.length?he.createElement(he.Fragment,null,he.createElement(Bt,{id:"widget-custom-tokens-search-token-input",value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:oo.t("Search Token"),onChange:g}),he.createElement(Br,{size:16}),he.createElement(Nr,{list:y,type:"custom-token",searchedFor:t,showTitle:!1,showWarning:!1,action:C=>he.createElement(SE,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{d(!0),h(C)}},he.createElement(uE,{size:12,color:"gray"}))})):he.createElement(yE,null,he.createElement(fE,{icon:m?he.createElement(cE,{size:200}):he.createElement(pE,{size:200}),title:oo.t("No custom tokens"),description:oo.t("press the button to add your custom token")})),he.createElement(Br,{size:20}),he.createElement(vc,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p($.addCustomTokens)},oo.t("Add Custom Token"))),he.createElement(ee,{open:u,id:"widget-custom-tokens-delete-modal",dismissible:!0,onClose:()=>d(!1),container:B()},he.createElement(mE,{title:oo.t("Delete Custom Token"),type:"error",description:oo.t("Are you sure you want to Delete this Token?")},he.createElement(Br,{size:40}),he.createElement(Br,{size:10}),he.createElement(vc,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},oo.t("Yes, Delete it")),he.createElement(Br,{size:12}),he.createElement(vc,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>d(!1)},oo.t("No, Continue"))))))}i(hh,"CustomTokensPage");import{i18n as $e}from"@lingui/core";import{useManager as FE}from"@rango-dev/queue-manager-react";import{Button as Mc,darkTheme as OE,Divider as To,MessageBox as UE,NotFound as zE,styled as Lc,Tabs as HE,Typography as wa}from"@rango-dev/ui";import{TransactionStatus as Lr}from"rango-types";import oe,{useMemo as _h,useState as Pr}from"react";import{useNavigate as QE}from"react-router-dom";import{FilterIcon as bE,Popover as EE}from"@rango-dev/ui";import Ko from"react";import{css as CE,darkTheme as Ta,IconButton as TE,styled as Wr}from"@rango-dev/ui";var Ec=Wr("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${Ta} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),yh=Wr(TE,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${Ta} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Ta} &`]:{backgroundColor:"$neutral"},[`& ${Ec}::before`]:{backgroundColor:"$secondary100",[`.${Ta} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),Sh=Wr("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),Ch=Wr("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),Th=CE({display:"flex",justifyContent:"space-between",alignItems:"center"}),kh=Wr("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as wh}from"@lingui/core";import{Button as kE,Divider as vh,ListItemButton as wE,Radio as vE,RadioRoot as xE,Typography as xh}from"@rango-dev/ui";import dt from"react";function bh(t){let{filterBy:e,onClickItem:o}=t;return dt.createElement(Ch,null,dt.createElement("div",{className:Th()},dt.createElement(xh,{size:"small",variant:"body"},wh.t("Status")),dt.createElement(kE,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},wh.t("Reset"))),dt.createElement(vh,{size:10}),dt.createElement(xE,{value:e},dt.createElement(kh,null,t.list.map((n,r)=>dt.createElement(wE,{key:n.id,className:"widget-filter-selector-list-item-btn",style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:dt.createElement(dt.Fragment,null,dt.createElement(vh,{direction:"horizontal",size:4}),dt.createElement(xh,{size:"medium",variant:"body"},n.title)),start:dt.createElement(vE,{value:n.id}),onClick:o})))))}i(bh,"FilterSelectorContent");function Ic(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return Ko.createElement("div",null,Ko.createElement(EE,{open:a,align:"end",onOpenChange:o,container:B(),content:Ko.createElement(bh,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},Ko.createElement(yh,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},Ko.createElement(Ec,{isSelect:!!n},Ko.createElement(bE,{size:16,color:"black"}),!!n&&Ko.createElement(Sh,null)))))}i(Ic,"FilterSelector");import{i18n as NE}from"@lingui/core";import{getCurrentStep as BE}from"@rango-dev/queue-manager-rango-preset";import{Divider as Bh,GroupedVirtualizedList as WE,Skeleton as ME,SwapListItem as Wh,Typography as LE}from"@rango-dev/ui";import Ye,{useCallback as Mh,useEffect as PE,useRef as _E,useState as DE}from"react";function Eh(t,e){let o=[],n=0;do{let r=t[n];r&&(o.push(Math.min(r,e)),e-=r),n++}while(e>0&&n<=t.length);return o}i(Eh,"calculateGroupsSoFar");import{css as IE,darkTheme as AE,styled as Mr}from"@rango-dev/ui";var Ac=IE(),Ih=Mr("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),Nc=Mr("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${Ac}`]:{$$color:"$colors$neutral600",[`.${AE} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Bc=Mr("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),Ah=Mr("div",{gap:"$10",display:"flex",flexDirection:"column"}),Nh=Mr("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var $E=10;function Wc(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=DE([]),c=_E(0),{swaps:l,groupCounts:p,groups:u}=n(e),d=Mh(Eh,[]),f=Mh(()=>{let h=e.length-c.current;h&&(c.current+=Math.min(h,$E),s(d(p,c.current)))},[e.length]);if(PE(()=>{r||f()},[r,f]),r){let h=[1,2];return Ye.createElement(Ye.Fragment,null,[h,h].map((m,y)=>Ye.createElement(Nc,{key:y},Ye.createElement(Bc,null,Ye.createElement(ME,{variant:"text",width:60,size:"small"}),Ye.createElement(Bh,{size:16})),Ye.createElement(Bh,{size:4}),Ye.createElement(Ah,null,m.map((C,k)=>Ye.createElement(Wh,{isLoading:!0,key:k}))))))}return Ye.createElement(WE,{style:{flexGrow:1,minHeight:0},endReached:()=>{c.current<e.length&&f()},groupCounts:a,groupContent:h=>Ye.createElement(Nc,null,Ye.createElement(Bc,null,Ye.createElement(LE,{variant:"label",size:"medium",className:Ac()},u[h]))),itemContent:(h,g)=>{let m=l[h];if(!m)return null;let y=BE(m),S=m.steps[0],C=m.steps[m.steps.length-1];return!S||!C?null:Ye.createElement(Ih,{key:m.requestId},Ye.createElement(Wh,{className:"widget-history-group-list-swap-item-btn",requestId:m.requestId,creationTime:m.creationTime,status:m.status,onClick:o,currentStep:y,tooltipContainer:B(),onlyShowTime:u[g]===NE.t("Today"),swapTokenData:{from:{token:{image:S.fromLogo,displayName:S.fromSymbol},blockchain:{image:S.fromBlockchainLogo||""},amount:_(m.inputAmount,6,6),realAmount:m.inputAmount},to:{token:{image:C.toLogo,displayName:C.toSymbol},blockchain:{image:C.toBlockchainLogo||""},amount:_(C.outputAmount||C.expectedOutputAmountHumanReadable||"",6,6),realAmount:C.outputAmount||C.expectedOutputAmountHumanReadable||""}}}))}})}i(Wc,"HistoryGroupedList");import{i18n as ka}from"@lingui/core";import Lh from"dayjs";var Ph=i(t=>{let e=new Map([["today",{title:ka.t("Today"),swaps:[]}],["week",{title:ka.t("This week"),swaps:[]}],["month",{title:ka.t("This month"),swaps:[]}],["year",{title:ka.t("This year"),swaps:[]}]]);function o(l,p){e.has(l)||e.set(l,{title:l,swaps:[]}),e.get(l)?.swaps.push(p)}i(o,"addYearsToOutput");let n=Lh();t.forEach(l=>{let p=Number(l.creationTime),u=Lh(p);if(n.isSame(u,"day"))e.get("today")?.swaps.push(l);else if(n.isSame(u,"week"))e.get("week")?.swaps.push(l);else if(n.isSame(u,"month"))e.get("month")?.swaps.push(l);else if(n.isSame(u,"year"))e.get("year")?.swaps.push(l);else{let d=new Date(p).getFullYear().toString();o(d,l)}});let r=Array.from(e.values()).filter(l=>l.swaps.length>0),a=r.flatMap(l=>l.swaps),s=r.map(l=>l.swaps.length),c=r.map(l=>l.title);return{swaps:a,groupCounts:s,groups:c}},"groupSwapsByDate");var qE=Lc("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%",minHeight:0,flexGrow:1}),GE=Lc("div",{display:"flex",justifyContent:"center",alignItems:"center"}),VE=Lc("div",{"._typography":{color:"$neutral700",[`.${OE}&`]:{color:"$neutral900"}}}),KE=i((t,e)=>t?.length?t.filter(o=>Pt(o.fromBlockchain,e)||Pt(o.toBlockchain,e)||Pt(o.toSymbol,e)||Pt(o.fromSymbol,e)).length:!1,"isStepContainsText");function Dh(){let t=QE(),{manager:e,state:o}=FE(),n=kt(e).map(({swap:b})=>b),[r,a]=Pr(""),[s,c]=Pr(!1),l=!o.loadedFromPersistor,[p,u]=Pr(""),[d,f]=Pr(!1),[h,g]=Pr("all"),m=i(b=>{let E=b.target.value;a(E)},"handleSearch"),{isMultiMode:y}=tt(),S=[{id:Lr.SUCCESS,title:$e.t("Complete")},{id:Lr.RUNNING,title:$e.t("Running")},{id:Lr.FAILED,title:$e.t("Failed")}],C=[{id:"all",title:$e.t("All")},{id:"swap",title:$e.t("Swap")},{id:"refuel",title:$e.t("Refuel")}],k=_h(()=>!r&&!p&&h==="all"?n:n.filter(b=>{let{inputAmount:E,status:v,steps:N,requestId:M,mode:P}=b;return(!r||Pt(E,r)||Pt(v,r)||KE(N,r)||Pt(M,r))&&(!p||p===v)&&(h==="all"?!0:h==="swap"?!P||P==="swap":h==="refuel"?P==="refuel":!1)}),[n,r,p,h]),x=!k?.length&&!l,w=i(()=>f(!1),"onCloseModal"),I=i(async()=>{try{await e?.clearQueue(),f(!1)}catch(b){console.log(b)}},"onClear"),A=_h(()=>!n.some(b=>b.status===Lr.SUCCESS||b.status===Lr.FAILED),[n]);return oe.createElement(se,{header:{title:$e.t("History"),suffix:oe.createElement(fo,null,oe.createElement(Mc,{id:"widget-history-clear-btn",disabled:A,variant:"ghost",size:"xsmall",onClick:()=>f(!0)},oe.createElement(wa,{size:"medium",variant:"label",color:"error"},$e.t("Clear"))))}},oe.createElement(ce,null,oe.createElement(GE,null,oe.createElement(Bt,{setValue:a,fullWidth:!0,variant:"contained",placeholder:$e.t("Search Transaction"),id:"widget-history-search-transaction-input",autoFocus:!0,onChange:m,style:{height:36},value:r}),oe.createElement(To,{size:10,direction:"horizontal"}),oe.createElement(Ic,{filterBy:p,open:s,onOpenChange:b=>c(b),onClickItem:b=>u(b),list:S})),oe.createElement(To,{size:"16"}),y&&!l&&oe.createElement(oe.Fragment,null,oe.createElement(HE,{items:C,onChange:b=>g(b.id),value:h,type:"secondary"}),oe.createElement(To,{size:"12"})),oe.createElement(qE,null,x&&oe.createElement(Nh,null,oe.createElement(To,{size:32}),oe.createElement(zE,{title:r?$e.t("No results found"):$e.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?$e.t("Try using different keywords"):$e.t("Your transaction history is stored locally and will appear here after you start a swap")})),!x&&oe.createElement(Wc,{list:k,onSwapClick:t,groupBy:Ph,isLoading:l}))),oe.createElement(ee,{open:d,onClose:w,id:"widget-history-clear-modal",container:B()},oe.createElement(To,{size:20}),oe.createElement(UE,{type:"warning",title:$e.t("Clear Transaction History"),description:oe.createElement(VE,null,oe.createElement(wa,{variant:"body",size:"medium"},$e.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),oe.createElement(To,{size:"24"}),oe.createElement(wa,{variant:"body",size:"small"},$e.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),oe.createElement(To,{size:30}),oe.createElement(Mc,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:I},$e.t("Yes, Clear the history")),oe.createElement(To,{size:10}),oe.createElement(Mc,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:w},oe.createElement(wa,{variant:"title",size:"medium",color:"primary"},$e.t("No, Cancel")))))}i(Dh,"HistoryPage");import{i18n as dy}from"@lingui/core";import{Button as NI,Divider as Kc,styled as BI,WarningIcon as WI}from"@rango-dev/ui";import MI from"bignumber.js";import Te,{useEffect as my,useState as fy}from"react";import{useNavigate as LI}from"react-router-dom";import{i18n as Fh}from"@lingui/core";import{Alert as XE,Divider as Pc,NoRouteIcon as YE,Typography as ZE}from"@rango-dev/ui";import jo from"react";import{styled as jE}from"@rango-dev/ui";var $h=jE("div",{display:"flex",flexDirection:"column",alignItems:"center"});function _c(){let{fromToken:t,toToken:e}=H()();return!!t&&!!e&&qt(t,e)?jo.createElement($h,null,jo.createElement(Pc,{size:10}),jo.createElement(YE,{size:24,color:"gray"}),jo.createElement(Pc,{size:4}),jo.createElement(ZE,{variant:"title",size:"small"},Fh.t("No Routes Found")),jo.createElement(Pc,{size:4}),jo.createElement(XE,{title:Fh.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(_c,"SameTokensWarning");import{Alert as JE,Button as RE}from"@rango-dev/ui";import Uh from"react";import{i18n as va}from"@lingui/core";function Oh(t){let e=null;return t===gi?(e={alertType:"error",action:"reset-slippage",actionButtonTitle:va.t("Reset"),title:va.t("Slippage cannot be set lower than 0.01%.")},e):t>sn?(e={alertType:"warning",action:"change-settings",actionButtonTitle:va.t("Change"),title:va.t("Caution, your slippage is high!")},e):null}i(Oh,"makeAlerts");function zh(t){let{slippage:e,customSlippage:o,setSlippage:n,setCustomSlippage:r}=T(),{onChangeSettings:a}=t,c=Oh(o!==null?o:e),l=i(p=>{p==="reset-slippage"?(n(fi),r(null)):p==="change-settings"&&a()},"onClickActionButton");return c?Uh.createElement(JE,{title:c.title,type:c.alertType,variant:"alarm",action:Uh.createElement(RE,{id:"widget-slippage-warning-error-change-settings-or-reset-slippage-btn",size:"xxsmall",type:c.alertType,onClick:()=>l(c.action)},c.actionButtonTitle)}):null}i(zh,"SlippageWarningsAndErrors");import{i18n as rI}from"@lingui/core";import{IconButton as iI,ReverseIcon as aI,Skeleton as sI,Tooltip as lI,Typography as _r}from"@rango-dev/ui";import mt from"react";import xa from"bignumber.js";function Qh(t){let{error:e,isDarkTheme:o,warning:n}=t,{quoteError:r,slippageError:a}=e,{quoteWarning:s,slippageWarning:c}=n,l=!!a||r?.type===4,p=!!c||s?.type===2;return l?"$error500":p?"$warning500":o?"$neutral600":"$neutral700"}i(Qh,"getSlippageColor");function qh(t){let{toTokenUsdPrice:e,fromTokenUsdPrice:o}=t;if(!e||!o)return{rawValue:"0",displayValue:"0"};let n=new xa(e),r=new xa(o),a=n.dividedBy(r),s;return a.isLessThan(1)?s=a.toFixed(14).replace(/\.?0+$/,""):a.toFixed(0).length>10?s=a.toFixed(0).slice(0,10):s=a.toFixed(2),{displayValue:s,rawValue:a.toFixed()}}i(qh,"getUsdExchangeRate");function Gh(t,e){let o=new xa(t).multipliedBy(e);return o.isLessThan(.001)?"$0":`$${o.decimalPlaces(2,xa.ROUND_DOWN).toFormat(2)}`}i(Gh,"formatTokenValueInUsd");import{darkTheme as oI,styled as $c,Typography as nI}from"@rango-dev/ui";var Vh=$c("div",{display:"flex",padding:"$4",justifyContent:"space-between",alignItems:"center"}),Kh=$c("div",{display:"flex",alignItems:"center",gap:"$2","& .rate-text":{color:"$neutral700",[`.${oI} &`]:{color:"$neutral700"}},"& ._icon-button":{transform:"rotate(90deg)",width:"$16",height:"$16"}}),Fc=$c(nI,{maxWidth:"$32",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});function Oc(t){let{slippage:e,customSlippage:o,quoteTokensRate:n,changeQuoteTokensRate:r}=T(),{quoteError:a,quoteWarning:s,fromToken:c,toToken:l,quote:p,loading:u}=t,d=o!==null?o:e,{mode:f}=mo({}),h=pn(d),g=f==="dark",m=n==="default",y={quoteError:a,slippageError:h?.type==="error"?h.message:null},S={quoteWarning:s,slippageWarning:h?.type==="warning"?h.message:null},C=p?.swaps[0]?.from||c,k=p?.swaps[p?.swaps.length-1]?.to||l,x=m?C:k,w=m?k:C,I=Number(m?p?.outputAmount:p?.requestAmount),A=Number(m?p?.requestAmount:p?.outputAmount),b=I||x.usdPrice,E=A||w.usdPrice,{rawValue:v,displayValue:N}=qh({toTokenUsdPrice:E,fromTokenUsdPrice:b});return mt.createElement(Vh,null,mt.createElement(_r,{variant:y||S?"label":"body",size:y||S?"medium":"small",color:Qh({error:y,warning:S,isDarkTheme:g})},rI.t("Slippage:")," ",d,"%"),u?mt.createElement(sI,{height:16,width:104,variant:"rounded"}):b&&E&&mt.createElement(Kh,null,mt.createElement(_r,{className:"rate-text",variant:"body",size:"small"},"1"),mt.createElement(Fc,{className:"rate-text",variant:"body",size:"small"},w.symbol),mt.createElement(iI,{id:"widget-home-page-change-rate-button",onClick:r},mt.createElement(aI,{size:14,color:"secondary"})),mt.createElement(lI,{container:B(),side:"top",sideOffset:4,content:mt.createElement(_r,{className:"rate-text",variant:"body",size:"small"},v)},mt.createElement(_r,{className:"rate-text",variant:"body",size:"small"},N)),mt.createElement(Fc,{className:"rate-text",variant:"body",size:"small"},x.symbol),x.usdPrice&&mt.createElement(_r,{color:"neutral600",variant:"body",size:"small"},"~",Gh(Number(v),x.usdPrice))))}i(Oc,"SwapMetrics");import{i18n as fI}from"@lingui/core";import{Header as gI}from"@rango-dev/ui";import ko,{useEffect as hI,useState as yI}from"react";import{i18n as pI}from"@lingui/core";import{Divider as zc,FullExpandedQuote as uI,Typography as dI}from"@rango-dev/ui";import xe from"react";import{styled as Uc}from"@rango-dev/ui";var jh=Uc("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Xh=Uc("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Yh=Uc("div",{width:"146px"});import{i18n as Dr}from"@lingui/core";import{Select as cI}from"@rango-dev/ui";import Zh from"react";function ba(t){let{updateQuotePartialState:e,sortStrategy:o}=H()(),n=[{value:"SMART",label:Dr.t("Smart Routing")},{value:"FEE",label:Dr.t("Lowest Fee")},{value:"SPEED",label:Dr.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Dr.t("Maximum Return")},{value:"PRICE",label:Dr.t("Maximum Output")}];return Zh.createElement(Yh,null,Zh.createElement(cI,{id:"widget-quotes-strategy-select",container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(ba,"SelectStrategy");var Jh=3;function $r(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:c}=t,{selectedQuote:l,quotes:p,updateQuotePartialState:u,fromToken:d,toToken:f,sortStrategy:h,error:g}=H()(),{slippage:m,customSlippage:y}=T(),{findToken:S}=T(),C=c||B(),k=!!p&&p.results.length,x=y??m,{config:{__UNSTABLE_OR_INTERNAL__:w}}=T(),I=i(E=>{if(!d||!f||!p)return null;let v={requestAmount:p.requestAmount,validationStatus:null,...E};return Cn({currentQuote:v,userSlippage:x,findToken:S})},"getQuoteWarning"),A=g?.type===0||g?.type===1,b=p?.results?Ni(h,p?.results):[];return xe.createElement(xe.Fragment,null,a&&xe.createElement(xe.Fragment,null,xe.createElement(Xh,null,xe.createElement(dI,{size:"xmedium",variant:"title"},pI.t("Sort by")),xe.createElement(ba,{container:C})),xe.createElement(zc,{size:"10"})),e&&Array.from({length:Jh},(E,v)=>xe.createElement(xe.Fragment,{key:v},s?xe.createElement(uI,{campaignTag:w?.campaignTag,loading:!0}):xe.createElement(xr,{tagHidden:!1,type:"list-item",expanded:!1}),v!==Jh-1&&xe.createElement(zc,{size:16}))),!e&&xe.createElement(xe.Fragment,null,k?b.map((E,v)=>{let N=I(E),M=sc(E.swaps),P=b.length-1===v;return xe.createElement(xe.Fragment,{key:E.requestId},xe.createElement(Go,{id:"widget-quotes-quote-info-container",showModalFee:r,container:C,selected:l?.requestId===E.requestId,tagHidden:!1,quote:{...E,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:M?.options||null,warning:N,fullExpandedMode:s,onClick:U=>{M||u("warning",N),u("error",M?.options||null),o(U)},type:"list-item"}),!P&&xe.createElement(zc,{size:16}))}):A&&xe.createElement(jh,null,xe.createElement(hr,{size:s?"large":"small",error:g,fetch:n}))))}i($r,"Quotes");import{darkTheme as mI,styled as Rh}from"@rango-dev/ui";var ey=Rh("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${mI} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),ty=Rh("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var SI=100;function Hc(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,c]=yI(!1),l=s?"":"is-hidden",{config:p}=T(),u=p?.variant==="full-expanded",d=Wo();return hI(()=>{let f=null;return a?f=setTimeout(()=>{c(!0)},SI):(c(!1),f&&clearTimeout(f)),()=>{f&&clearTimeout(f)}},[a]),ko.createElement(ey,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${l} ${Qi()} widget-expanded-quotes-container`,id:Re.EXPANDED_BOX_ID},ko.createElement(gI,{title:fI.t("Routes"),suffix:ko.createElement(ko.Fragment,null,ko.createElement(ba,{container:d}),ko.createElement(zo,{container:d,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),ko.createElement(ty,null,ko.createElement($r,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:Wo(),onClickOnQuote:n,fullExpandedMode:u})))}i(Hc,"ExpandedQuotes");import{i18n as ly}from"@lingui/core";import{SwapInput as cy}from"@rango-dev/ui";import wI from"bignumber.js";import Fr from"react";import{ReverseIcon as kI}from"@rango-dev/ui";import qc from"react";import{keyframes as CI,styled as oy}from"@rango-dev/ui";var Qc=450,TI=CI({"0%":{transform:"rotateX(0deg) rotateY(0deg) rotateZ(0deg)"},"33%":{transform:"rotateX(0deg) rotateZ(78deg) rotateY(66deg)"},"66%":{transform:"rotateX(0deg) rotateZ(163deg) rotateY(66deg)"},"100%":{transform:"rotateX(0deg) rotateZ(180deg) rotateY(0deg)"}}),ny=oy("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),ry=oy("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${TI} ${Qc}ms ease-in-out forwards`}},"&:hover":{color:"$secondary500",transform:"translateY(1px) scale(1.04)",boxShadow:"1px 1px 1px 1px rgba(0, 0, 0, 0.05)"}});function Gc(){let t=H().use.switchFromAndTo();return qc.createElement(ny,null,qc.createElement(ry,{id:"widget-switch-from-and-to-btn",onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Qc),t()}},qc.createElement(kI,{size:12})))}i(Gc,"SwitchFromAndToButton");import{styled as iy}from"@rango-dev/ui";var ay=iy("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),sy=iy("div",{position:"relative"});function Vc(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:c,toBlockchain:l,setInputAmount:p,sanitizeInputAmount:u,inputAmount:d,inputUsdValue:f,outputAmount:h,outputUsdValue:g,selectedQuote:m}=H()(),{swapMode:y}=tt(),{connectedWallets:S,getBalanceFor:C}=T(),k=a?C(a):null,x=ui(k)?.amount??"0",w=k?new wI(k.amount).shiftedBy(-k.decimals):pe,I=!!s&&Au(S,s.name),A=!Gs(m,d,f),b=!Gs(m,d,g),E=!f||!g||!g.gt(0)?null:jt(f.toString(),g.toString());return Fr.createElement(ay,null,Fr.createElement(sy,null,Fr.createElement(cy,{label:ly.t("From"),id:"widget-swap-from",mode:"From",onInputChange:p,onInputBlur:u,balance:x,chain:{displayName:s?.displayName||"",image:s?.logo},token:{displayName:a?.symbol||"",image:a?.image,securityWarning:!!a?.warning},onClickToken:()=>n("from"),price:{value:d,usdValue:A?void 0:_(f,4,4),realUsdValue:A?void 0:f?.toString(),error:A?re().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:I,tooltipContainer:B(),onSelectMaxBalance:()=>{let v=w.isGreaterThan(pe)?w.toFixed():"";p(v)},anyWalletConnected:S.length>0}),y==="swap"&&Fr.createElement(Gc,null)),Fr.createElement(cy,{selectionType:y==="swap"?"token":"chain",sharpBottomStyle:!r&&(!!m||e),label:ly.t("To"),mode:"To",id:"widget-swap-to-input",fetchingQuote:e,chain:{displayName:l?.displayName||"",image:l?.logo},token:{displayName:c?.symbol||"",image:c?.image,securityWarning:!!c?.warning},percentageChange:_(jt(f,g),2,2),warningLevel:Xt(E??0),price:{value:_(h,6,6),usdValue:b?void 0:_(g,4,4),realValue:h?.toString(),realUsdValue:b?void 0:g?.toString(),error:b?re().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:B()}))}i(Vc,"Inputs");import{warn as vI}from"@rango-dev/logging-core";import{useCallback as xI,useEffect as bI,useRef as EI,useState as II}from"react";function py(){let{fetch:t,loading:e,cancelFetch:o}=ga({request:async(n,r)=>await ct().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(py,"useFetchAllQuotes");var AI=600;function Ea({refetchQuote:t}){let{fetch:e,cancelFetch:o}=py(),{excludeLiquiditySources:n,routing:r}=T().config,{connectedWallets:a}=T(),c=a.some(ue=>ue.isContractWallet),{fromToken:l,toToken:p,inputAmount:u,inputUsdValue:d,selectedQuote:f,sortStrategy:h,resetQuote:g,error:m,warning:y,setSelectedQuote:S,updateQuotePartialState:C}=H()(),{slippage:k,customSlippage:x,affiliatePercent:w,affiliateRef:I,affiliateWallets:A,fetchStatus:b}=T(),E=T().getLiquiditySources(),v=T().getDisabledLiquiditySources(),N=T().excludeLiquiditySources(),{findToken:M}=T(),{swapMode:P}=tt(),[U,Q]=II(!0),Z=EI(u),W=x??k,X=!l||!p||qt(l,p)||!Vn(u),ae=i(ue=>{Q(ue)},"resetState"),Se=i(ue=>{let{fromToken:gt,toToken:vt,inputAmount:xt,liquiditySources:O,excludeLiquiditySources:z,disabledLiquiditySources:Y,slippage:te,affiliateRef:j,affiliatePercent:G,affiliateWallets:Ve}=ue;if(U||ae(!0),!X&>&&vt){g();let V=Vd({fromToken:gt,toToken:vt,inputAmount:xt,liquiditySources:O,excludeLiquiditySources:z,disabledLiquiditySources:Y,wallets:a,slippage:te,affiliateRef:j,affiliatePercent:G,affiliateWallets:Ve,contractCall:c});cn("experimental",r)&&(V.experimental=!0),cn("avoidNativeFee",r)&&(V.avoidNativeFee=!0),cn("enableCentralizedSwappers",r)&&(V.enableCentralizedSwappers=!0),r?.maxLength&&(V.maxLength=r.maxLength),P==="refuel"&&(V.maxLength=1),e(V).then(Ce=>{let Je=Ni(h,Ce.results),ht=Pd(f,Je,Ce.requestAmount);Q(!1),C("quotes",Ce),S(ht),ha({diagnosisMessages:Ce.diagnosisMessages,requestId:ht?.requestId||"",swaps:ht?.swaps});let so=ht&&Cn({currentQuote:ht,userSlippage:W,findToken:M});C("warning",so)}).catch(Ce=>{let Je=ya(Ce);(Je.type===0||Je.type===1)&&g(),Je.type!==2&&(C("error",Je),Q(!1),vI(new Error("quote error"),{tags:{...Je,type:Xe[Je.type],requestBody:V}}))})}},"fetch"),at=xI(ri(ue=>{Se(ue)},AI),[X]);return bI(()=>{if(!t){Q(!1);return}if(b!=="success")return;if(X){Q(!1),(f||m||y)&&g();return}if(!Vn(u)&&d?.eq(0)){ae(!1),o();return}g(),ae(!0);let ue=Se;return Z.current&&Z.current!=u&&(ue=at),Z.current=u,ue({inputAmount:u,fromToken:l,toToken:p,liquiditySources:E,excludeLiquiditySources:N,disabledLiquiditySources:v,slippage:W,affiliateRef:I,affiliatePercent:w,affiliateWallets:A,contractCall:c}),o},[b,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,X,E?.length,n,v.length,W,I,w,c,JSON.stringify(A)]),{fetch:()=>Se({inputAmount:u,fromToken:l,toToken:p,liquiditySources:E,excludeLiquiditySources:N,disabledLiquiditySources:v,slippage:W,affiliateRef:I,affiliatePercent:w,affiliateWallets:A,contractCall:c}),loading:U}}i(Ea,"useSwapInput");function uy(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};ve.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(uy,"emitPreventableEvent");var PI=BI("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),_I=300;function gy(){let t=LI(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:c,quotes:l,setSelectedQuote:p,resetQuoteWallets:u,setQuoteWarningsConfirmed:d,updateQuotePartialState:f}=H()(),[h,g]=fy(!1),{isLargeScreen:m,isExtraLargeScreen:y}=aa(),{fetch:S,loading:C}=Ea({refetchQuote:a}),{config:k,fetchStatus:x,connectedWallets:w,customSlippage:I,slippage:A,setSlippage:b,setCustomSlippage:E}=T(),{isActiveTab:v}=ne(),[N,M]=fy(!1),P=I!==null?I:A,{swapMode:U}=tt(),Q=pn(P),W=Hd({fetchMetaStatus:x,fetchingQuote:C,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:c,needsToWarnEthOnPath:!1}),J=_u(m,y,k?.variant),X=!!n&&!!e&&!!o&&new MI(n).gt(0)&&!Rd(e,o),ae=X&&x==="success"&&C,Se=Q?.quoteValidation||c,gt=(!J||J&&l?.results.length)&&(Se||s),vt=!!e&&!!o,xt=vt&&!!Q,O=(r||s)&&!N?S:void 0,z=i(G=>{J&&h?(g(!1),setTimeout(()=>{t(G)},_I)):t(G)},"onHandleNavigation"),Y=i(G=>{r?.requestId!==G.requestId&&(M(!1),p(G))},"onClickOnQuote"),te=i(G=>{if(G){if(mi.includes(G)){b(G),E(null);return}E(G)}},"onChangeSlippage"),j=i(G=>{z(G==="from"?$.fromSwap:U==="swap"?$.toSwap:$.toSwap+"/"+$.blockchains)},"handleInputTokenClick");return my(()=>{u(),f("refetchQuote",!0)},[]),my(()=>{g(X)},[X]),Te.createElement(PI,null,Te.createElement(se,{height:"auto",footer:Te.createElement(NI,{id:`widget-swap-${W.action}-btn`,type:"primary",size:"large",disabled:W.disabled||!v,prefix:W.action==="confirm-warning"&&Te.createElement(WI,null),fullWidth:!0,onClick:()=>{W.action==="connect-wallet"?uy({type:"clickConnectWallet"},()=>z($.wallets)):W.action==="confirm-warning"?M(!0):z($.confirmSwap)}},W.title),header:{onWallet:()=>{z($.wallets)},hasBackButton:!1,title:k.title||(U==="swap"?dy.t("Swap"):dy.t("Refuel")),suffix:Te.createElement(zo,{hidden:J?["refresh"]:void 0,onClickRefresh:O,onClickHistory:()=>z($.swaps),onClickSettings:()=>{z($.settings)}})}},Te.createElement(ce,null,Te.createElement(Vc,{fetchingQuote:ae,fetchMetaStatus:x,isExpandable:J,onClickToken:j}),Te.createElement(Kc,{size:"2"}),J?null:Te.createElement(Go,{quote:r,loading:ae,error:s,id:"widget-home-expandable-quote-container",tagHidden:!1,warning:Se,type:"basic",onClickAllRoutes:l&&l.results.length>1?()=>{f("refetchQuote",!1),z($.routes)}:void 0}),vt&&Te.createElement(Te.Fragment,null,Te.createElement(Kc,{size:8}),Te.createElement(Oc,{quoteError:s,quoteWarning:Se,fromToken:e,toToken:o,quote:r,loading:ae})),gt?Te.createElement(Te.Fragment,null,Te.createElement(Sr,{warning:Se,error:s,skipAlerts:!!Q,couldChangeSettings:!0,refetchQuote:S,showWarningModal:N,confirmationDisabled:!v,onOpenWarningModal:()=>M(!0),onCloseWarningModal:()=>M(!1),onChangeSlippage:te,onConfirmWarningModal:()=>{M(!1),d(!0),z($.confirmSwap)},onChangeSettings:()=>z($.settings)})):null,xt&&Te.createElement(Te.Fragment,null,Te.createElement(Kc,{size:"10"}),Te.createElement(zh,{onChangeSettings:()=>z($.settings)})),Te.createElement(_c,null))),J?Te.createElement(Hc,{loading:ae,onClickOnQuote:Y,fetch:S,onClickRefresh:O,isVisible:h}):null)}i(gy,"Home");import{i18n as hy}from"@lingui/core";import{Alert as DI,Divider as $I,List as FI,ListItemButton as OI,Radio as UI,RadioRoot as zI,Typography as HI}from"@rango-dev/ui";import Ot from"react";function wo(){let{setLanguage:t,language:e,config:o}=T(),n=Hu,r=o?.language||un;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||un),resetLanguage:()=>t(null)}}i(wo,"useLanguage");function yy(){let{activeLanguage:t,changeLanguage:e,languages:o}=wo(),n=Qe(),r=o.map(a=>{let{local:s,label:c,SVGFlag:l}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Ot.createElement(HI,{variant:"title",size:"xmedium"},c),onClick:()=>{e(a.local),n()},end:Ot.createElement(UI,{value:s}),start:Ot.createElement(l,null)}});return Ot.createElement(se,{header:{title:hy.t("Language")}},Ot.createElement(ce,null,Ot.createElement(DI,{type:"warning",id:"widget-language-machine-translation-alarm-alert",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Ot.createElement($I,{size:"8"}),Ot.createElement(zI,{value:t},Ot.createElement(FI,{type:Ot.createElement(OI,{title:hy.t("language"),className:"widget-language-list-item-btn",id:"_",onClick:()=>console.log()}),items:r}))))}i(yy,"LanguagePage");import{i18n as no}from"@lingui/core";import{Button as KI,Checkbox as jI,Image as XI,ListItemButton as YI,NotFound as ZI,Typography as JI}from"@rango-dev/ui";import Ze,{useState as RI}from"react";import{Checkbox as GI,Skeleton as Cy}from"@rango-dev/ui";import Ur from"react";import{styled as jc}from"@rango-dev/ui";var Or=jc("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),Xc=jc("div",{width:80,display:"flex",justifyContent:"flex-end"}),Yc=jc("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as QI,styled as qI}from"@rango-dev/ui";var Sy=qI(QI,{height:61});var VI=30;function Zc(){return Ur.createElement(Or,null,Array.from(Array(VI),(t,e)=>Ur.createElement(Sy,{hasDivider:!0,key:e,start:Ur.createElement(Cy,{variant:"circular",width:35,height:35}),title:Ur.createElement(Cy,{variant:"text",size:"large",width:90}),end:Ur.createElement(GI,{checked:!1})})))}i(Zc,"LoadingLiquiditySourceList");function Jc({sourceType:t}){let e=T().fetchStatus,o=T().swappers(),n=T().getDisabledLiquiditySources(),[r,a]=RI(""),s=T().toggleLiquiditySource,c=T().isInCampaignMode(),l=hi(o,n),p={Exchanges:no.t("Exchanges"),Bridges:no.t("Bridges")},u=[];t==="Exchanges"&&u.push("DEX"),t==="Bridges"&&u.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let d=l.filter(S=>u.includes(S.type)),f=d.length===d.filter(S=>S.selected).length,h=i(()=>{d.forEach(S=>{f?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),g=d.map(S=>{let{selected:C,groupTitle:k,logo:x,id:w,...I}=S;return{id:`widget-setting-liquidity-source-${hu(w.toLowerCase())}-item-btn`,start:Ze.createElement(XI,{src:x,size:22,type:"circular"}),onClick:()=>{c||s(k)},end:Ze.createElement(jI,{checked:C,disabled:c}),title:Ze.createElement(JI,{variant:"title",size:"xmedium"},no.t(k)),selected:C,groupTitle:k,logo:x,...I}}),m=i(S=>{let C=S.target.value;a(C)},"handleSearch"),y=g;return r&&(y=g.filter(S=>Pt(S.groupTitle,r))),Ze.createElement(se,{header:{title:no.t(t),suffix:Ze.createElement(Xc,null,Ze.createElement(KI,{id:`widget-liquidity-source-${f?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:h},f?no.t("Deselect all"):no.t("Select all")))}},Ze.createElement(ce,{view:!0},Ze.createElement(Bt,{value:r,setValue:a,id:"widget-liquidity-source-search-input",fullWidth:!0,color:"light",variant:"contained",placeholder:no.t("Search {sourceType}",{sourceType:p[t]}),onChange:m}),e==="loading"&&Ze.createElement(Zc,null),!y.length&&r?Ze.createElement(Yc,null,Ze.createElement(ZI,{title:no.t("No results found"),description:no.t("Try using different keywords")})):e==="success"&&Ze.createElement(Or,{disabled:c,className:"widget-liquidity-source-list"},y.map(S=>{let{groupTitle:C,...k}=S;return Ze.createElement(Ze.Fragment,{key:S.id},Ze.createElement(YI,{style:{height:"61px"},...k,selected:!1,className:"widget-liquidity-source-list-item-btn",hasDivider:!0}))}))))}i(Jc,"LiquiditySourcePage");import{i18n as eA}from"@lingui/core";import Ia from"react";import{useNavigate as tA}from"react-router-dom";function Ty(){let t=tA(),e=Qe(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=H()(),{fetch:c,loading:l}=Ea({refetchQuote:n}),p=i(f=>{r(f),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${$.settings}`,d=`../${$.wallets}`;return Ia.createElement(se,{header:{onWallet:()=>{t(d),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:eA.t("Routes"),suffix:Ia.createElement(zo,{onClickRefresh:o||s?c:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},Ia.createElement(ce,null,Ia.createElement($r,{fetch:c,loading:l,onClickOnQuote:p})))}i(Ty,"RoutesPage");import{i18n as Iy}from"@lingui/core";import{Divider as Ay,getCategoriesCount as uA,SelectableCategoryList as dA}from"@rango-dev/ui";import ro,{useMemo as mA,useState as Ny}from"react";import{useNavigate as fA}from"react-router-dom";import{i18n as Rc}from"@lingui/core";import{Divider as iA,Image as aA,ListItemButton as sA,NotFound as lA,Typography as Ey}from"@rango-dev/ui";import ft,{useEffect as cA,useState as pA}from"react";var ky=i((t,e,o)=>t.filter(n=>ii(n.type,o)).filter(n=>st(n.name,e)||st(n.displayName,e)),"filterBlockchains");import{ImageContainer as oA,styled as wy}from"@rango-dev/ui";var vy=wy("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Aa=wy(El,{padding:0,margin:0,listStyle:"none",[`& ${oA}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as nA,Skeleton as xy}from"@rango-dev/ui";import Na from"react";var rA=20;function by(){return Na.createElement(Aa,{id:"widget-blockchain-loading-list",as:"ul"},Array.from(Array(rA),t=>Na.createElement(nA,{key:t,hasDivider:!0,start:Na.createElement(xy,{variant:"circular",width:35,height:35}),title:Na.createElement(xy,{variant:"text",size:"large",width:90})})))}i(by,"LoadingBlockchainList");function ep(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,c]=pA(e),{fetchStatus:l}=T();cA(()=>{c([...ky(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?ft.createElement(lA,{title:Rc.t("No results found"),description:Rc.t("Try using different keywords")}):ft.createElement(Aa,{as:"ul",key:`${r}-${o}`,id:"widget-blockchain-list"},s.map(u=>ft.createElement(sA,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:ft.createElement(aA,{src:u.logo,size:30}),title:ft.createElement(Ey,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return ft.createElement(ft.Fragment,null,a&&ft.createElement(ft.Fragment,null,ft.createElement(Ey,{variant:"label",size:"large"},Rc.t("Select Chain")),ft.createElement(iA,{size:4})),ft.createElement(vy,null,l==="loading"&&ft.createElement(by,null),l==="success"&&p()))}i(ep,"BlockchainList");function Ba(t){let{type:e}=t,o=Qe(),[n,r]=Ny(""),[a,s]=Ny("ALL"),c=H().use.setToBlockchain(),l=H().use.setFromBlockchain(),p=H().use.setToToken(),{fetchStatus:u,findNativeToken:d}=T(),f=fA(),{swapMode:h}=tt(),g=T().blockchains({type:e}),m=T().tokens(),y=mA(()=>du(g,m),[g.length,m.length]),S=uA(y),C=!t.hideCategory&&S!==1,k=i(x=>{if(e==="custom-token")f(`..?blockchain=${x.name}`,{replace:!0});else{if(e==="source")l(x);else if(h==="swap")c(x);else{let w=d(x);w&&p({token:w,meta:{blockchains:g}})}o()}},"handleBlockchainChange");return ro.createElement(se,{header:{title:Iy.t("Select Chain")}},ro.createElement(ce,{view:!0},C&&ro.createElement(ro.Fragment,null,ro.createElement(dA,{setCategory:s,category:a,blockchains:y,isLoading:u==="loading"}),ro.createElement(Ay,{size:24})),ro.createElement(Bt,{value:n,autoFocus:!0,placeholder:Iy.t("Search Chain"),id:"widget-select-blockchain-search-input",color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:x=>r(x.target.value)}),ro.createElement(Ay,{size:16}),ro.createElement(ep,{list:y,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:k})))}i(Ba,"SelectBlockchainPage");import{i18n as La}from"@lingui/core";import{Divider as Dy,Spinner as NA}from"@rango-dev/ui";import vo,{useEffect as BA,useState as WA}from"react";import{useNavigate as MA}from"react-router-dom";import{i18n as np}from"@lingui/core";import{BlockchainsChip as Wa,Divider as Ly,Image as Py,Skeleton as TA,Tooltip as kA,Typography as rp}from"@rango-dev/ui";import be from"react";import{useEffect as yA}from"react";var By=["ETH","COSMOS","OSMOSIS"];function tp(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(gA),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let c=o.limit-e.length;for(let l=0;l<=c;l++){let p=n[l];s=s.filter(u=>p?.name!==u)}}n.sort(hA(s)),r=n.splice(a)}return{list:n,more:r}}i(tp,"prepare");function gA(t,e){let o=By,n=o.findIndex(c=>c===t.name),r=o.findIndex(c=>c===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(gA,"sortByMostUsedBlockchains");function hA(t){return i(function(o,n){let r=t.findIndex(l=>l===o.name),a=t.findIndex(l=>l===n.name),s=r>-1,c=a>-1;return s&&c?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(hA,"generateSortByPreferredBlockchainsFor");function Wy(t,e){return!!e.list.find(o=>o.name===t)}i(Wy,"isInVisibleList");function op(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=T();yA(()=>{if(e?.selected){let a=tp(t,o,e);Wy(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=tp(t,o,e);return{list:r.list,more:r.more,history:[]}}i(op,"usePrepareBlockchainList");import{styled as SA}from"@rango-dev/ui";var My=SA("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var wA=6,vA=12;function ip(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,{showCompactTokenSelector:s}=ne(),c=op(e,{limit:s?4:10,selected:n?.name}),{fetchStatus:l}=T(),p=H().use.resetToBlockchain(),u=H().use.resetFromBlockchain(),d=c.more.length>0,f=c.more[0],h=c.more.length===1&&f,g=!h&&d;return be.createElement(be.Fragment,null,!s&&be.createElement(be.Fragment,null,be.createElement(Ly,{size:12}),be.createElement(rp,{variant:"label",size:"large"},np.t("Select Chain"))),be.createElement(Ly,{size:12}),be.createElement(My,{id:"widget-blockchains-section-container"},l==="loading"&&Array.from(Array(s?wA:vA),(m,y)=>be.createElement(TA,{key:y,variant:"rounded",height:50})),l==="success"&&be.createElement(be.Fragment,null,be.createElement(Wa,{className:"widget-blockchains-section-all-btn",selected:!n,onClick:()=>{o==="from"?u():p()}},be.createElement(rp,{variant:"body",size:"xsmall",color:"secondary500"},np.t("All"))),c.list.map(m=>be.createElement(kA,{key:m.name,content:m.shortName,side:"bottom",sideOffset:2,container:B()},be.createElement(Wa,{className:"widget-blockchains-section-item-btn",key:m.name,selected:!!n&&n.name===m.name,onClick:()=>r(m)},be.createElement(Py,{src:m.logo,size:30})))),h?be.createElement(Wa,{className:"widget-blockchains-section-only-item-btn",key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},be.createElement(Py,{src:f.logo,size:30})):null,g?be.createElement(Wa,{onClick:a,key:"more-blockchains",className:"widget-blockchains-section-more-items-btn"},be.createElement(rp,{variant:"body",size:"xsmall",color:"secondary500"},np._("More +{count}",{count:c.more.length}))):null)))}i(ip,"BlockchainsSection");import{useCallback as bA,useRef as EA,useState as ap}from"react";function sp(){let t=T().blockchains(),e=EA(null),{customTokens:o}=T(),[n,r]=ap(!1),[a,s]=ap([]),[c,l]=ap(null),p=i(async(f,h)=>{l(null),r(!0),s([]);try{let g=await ct().searchCustomTokens({query:f,blockchain:h},{signal:e.current?.signal}),m=new Set(o().map(C=>Vt(C))),y=new Set(t.map(C=>C.name)),S=g.tokens.filter(C=>y.has(C.blockchain)&&!m.has(Vt(C)));s(S),r(!1)}catch(g){l(g instanceof Error?g.message:"something went wrong"),s([]),g?.name!=="CanceledError"&&r(!1)}},"fetch"),u=bA(ri((f,h)=>{e.current?.signal.aborted||p(f,h)},600),[t.length]);return{fetch:(f,h)=>{e.current=new AbortController,s([]),r(!0),u(f,h)},cancel:i(()=>{e.current?.abort()},"cancel"),loading:n,tokens:a,error:c}}i(sp,"useSearchCustomTokens");function Ma(t,e,o){return o&&t.length===1&&t[0]?.address===e?!1:t.length<20&&e.trim().length>=3}i(Ma,"shouldSearchForCustomTokens");function _y(t,e,o,n,r){let a=[...t];return Ma(t,o,r)&&(a=n?[...a,"skeleton","skeleton","skeleton"]:[...a,...e.map(s=>({...s,customToken:!0,warning:!0}))]),a}i(_y,"prepareTokensList");function Pa(t){let{type:e}=t,o=MA(),n=Qe(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:c,setFromBlockchain:l,setToBlockchain:p}=H()(),{getBalanceFor:u}=T(),{fetch:d,loading:f,tokens:h,cancel:g}=sp(),[m,y]=WA(""),S=e==="source"?r:a,C=S?.name??"",k=T().blockchains({type:e}),x=T().tokens({type:e,blockchain:C,searchFor:m,getBalanceFor:u}),w=_y(x,h,m,f,S?.name),I=i(E=>{e==="source"?l(E):p(E)},"updateBlockchain"),A=i(E=>{e==="source"?s({token:E,meta:{blockchains:k}}):c({token:E,meta:{blockchains:k}})},"updateToken"),b={source:La.t("Source"),destination:La.t("Destination")};return BA(()=>(Ma(x,m,S?.name)&&d(m,S?.name??void 0),()=>{g()}),[x.length,m,S?.name]),vo.createElement(se,{header:{title:La.t("Swap {type}",{type:b[e]})}},vo.createElement(ce,null,vo.createElement(ip,{blockchains:k,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o($.blockchains),onChange:E=>{I(E)}}),vo.createElement(Dy,{size:24}),vo.createElement(Bt,{value:m,id:"widget-select-swap-item-search-input",autoFocus:!0,placeholder:La.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>y(""),onChange:E=>y(E.target.value),suffix:Ma(x,m,S?.name)&&f?vo.createElement(NA,{size:12,color:"secondary"}):void 0}),vo.createElement(Dy,{size:16}),vo.createElement(Nr,{list:w,selectedBlockchain:C,searchedFor:m,type:e,onChange:E=>{A(E);let v=k.find(N=>E.blockchain===N.name);v&&I(v),n()}})))}i(Pa,"SelectSwapItemsPage");import{i18n as up}from"@lingui/core";import{Alert as iN,Button as aN,styled as sN}from"@rango-dev/ui";import Xo from"react";import{useInRouterContext as lN,useSearchParams as cN}from"react-router-dom";import{i18n as Hy}from"@lingui/core";import{Alert as DA,Divider as cp,InfoIcon as $A,SlippageIcon as FA,TextField as OA,Tooltip as UA,Typography as Qy}from"@rango-dev/ui";import Oe from"react";import{Chip as LA,styled as zr,TextField as PA}from"@rango-dev/ui";var $y=zr("div",{paddingTop:"$5",padding:"$10 $5"}),Fy=zr("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${PA}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px",paddingLeft:"$2"}}),Oy=zr("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),_a=zr("div",{maxWidth:"280px",padding:"$10"}),Uy=zr(LA,{width:"61px",flexShrink:0});import{i18n as lp}from"@lingui/core";import{Typography as _A}from"@rango-dev/ui";import Hr from"react";function zy(){return Hr.createElement(_a,null,Hr.createElement(_A,{variant:"label",size:"medium",color:"neutral700"},lp.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Hr.createElement("br",null),Hr.createElement("br",null),Hr.createElement("b",null,lp.t("Warning")),":\xA0",lp.t("This setting is applied to each step (e.g. 1Inch, Thorchain, etc.), meaning only that specific step will be reverted, not the entire route.")))}i(zy,"SlippageTooltipContent");function pp(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=T(),r=o!==null?pn(o):null,a=i(l=>{let p=l.target.value,u=parseFloat(p);if(isNaN(u))return n(null);let d=u;u>Yn&&(d=Yn),n(d)},"onSlippageValueChange"),s=i(l=>{o!==null&&n(null),e(l)},"onClickSlippageChip"),c=i(l=>{let p=l.target,u=p.value;Su(u)||(p.value=u.slice(0,-1))},"onInput");return Oe.createElement($y,null,Oe.createElement(Oy,null,Oe.createElement(FA,{size:16,color:"gray"}),Oe.createElement(cp,{direction:"horizontal",size:4}),Oe.createElement(Qy,{variant:"title",size:"xmedium"},Hy.t("Slippage tolerance per swap")),Oe.createElement(cp,{direction:"horizontal",size:4}),Oe.createElement(UA,{container:B(),side:"top",sideOffset:4,content:Oe.createElement(zy,null)},Oe.createElement($A,{color:"gray"}))),Oe.createElement(Fy,null,mi.map((l,p)=>{let u=`slippage-${p}`;return Oe.createElement(Uy,{id:`widget-slippage-chip-${l.toString()}%-btn`,key:u,onClick:()=>s(l),selected:o===null&&l===t,label:`${l.toString()}%`})}),Oe.createElement(OA,{type:"number",min:"0.01",max:"30",step:"0.01",status:r?.type||(o?"success":"default"),id:"widget-slippage-chip-text-input",onInput:c,fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:a,suffix:o&&Oe.createElement(Qy,{variant:"body",size:"small"},"%"),placeholder:Hy.t("Custom")})),r&&Oe.createElement(Oe.Fragment,null,Oe.createElement(cp,{size:10}),Oe.createElement(DA,{id:"widget-slippage-alert",variant:"alarm",type:r.type,title:r.message})))}i(pp,"Slippage");import{i18n as wt}from"@lingui/core";import{AutoThemeIcon as qy,BridgesIcon as zA,ChevronRightIcon as Da,DarkModeIcon as Gy,Divider as Qr,ExchangeIcon as HA,InfinityIcon as QA,InfoIcon as qA,LanguageIcon as GA,LightModeIcon as Vy,List as VA,ListItem as KA,ListItemButton as jA,Skeleton as XA,styled as YA,Switch as ZA,Tabs as JA,TargetIcon as RA,Tooltip as eN,Typography as it}from"@rango-dev/ui";import D from"react";import{useNavigate as tN}from"react-router-dom";var oN=YA("div",{width:"202px",height:"$40"}),nN=[{id:"light",icon:D.createElement(Vy,{color:"black",size:24}),tooltip:D.createElement(it,{size:"xsmall",variant:"body"},wt.t("Light"))},{id:"dark",icon:D.createElement(Gy,{color:"black",size:24}),tooltip:D.createElement(it,{size:"xsmall",variant:"body"},wt.t("Dark"))},{id:"auto",icon:D.createElement(qy,{color:"black",size:24}),tooltip:D.createElement(it,{size:"xsmall",variant:"body"},wt.t("Auto"))}],rN=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return D.createElement(qy,{...e});case"dark":return D.createElement(Gy,{...e});default:return D.createElement(Vy,{...e})}},"getThemeIcon");function Ky(){let t=tN(),{theme:e}=T().config,{setTheme:o,theme:n}=T(),{activeLanguage:r,languages:a}=wo(),s=a.find(W=>W.local===r)?.label,c=T().fetchStatus,l=T().swappers(),p=T().getDisabledLiquiditySources(),{config:{features:u}}=T(),d=T().customTokens(),f=et("theme",u),h=et("liquiditySource",u),g=et("language",u),m=et("customTokens",u),y=T().infiniteApprove,S=T().toggleInfiniteApprove,C=hi(l,p),k=C.filter(W=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(W.type)),x=k.length,w=k.filter(W=>W.selected).length,I=C.filter(W=>W.type==="DEX"),A=I.length,b=I.filter(W=>W.selected).length,E=i((W,J)=>{switch(c){case"loading":return D.createElement(XA,{variant:"text",size:"medium",width:50});case"failed":return D.createElement(it,{variant:"body",size:"medium",color:"$error500"},wt.t("Loading failed"));default:return D.createElement(it,{variant:"body",size:"medium"},`${W} / ${J}`)}},"handleSwapperEndItem"),v={id:"widget-setting-bridge-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Bridges")),end:D.createElement(D.Fragment,null,E(w,x),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(Da,{color:"black"})),onClick:()=>t($.bridges),start:D.createElement(zA,{color:"gray",size:16})},N={id:"widget-setting-exchange-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Exchanges")),end:D.createElement(D.Fragment,null,E(b,A),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(Da,{color:"black"})),start:D.createElement(HA,{color:"gray",size:16}),onClick:()=>t($.exchanges)},M={id:"widget-setting-custom-tokens-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Custom Tokens")),end:D.createElement(D.Fragment,null,D.createElement(it,{variant:"body",size:"medium"},`${d.length}`),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(Da,{color:"black"})),start:D.createElement(RA,{color:"gray",size:16}),onClick:()=>t($.customTokens)},P={id:"widget-setting-language-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Language")),start:D.createElement(GA,{color:"gray",size:16}),end:D.createElement(D.Fragment,null,D.createElement(it,{variant:"body",size:"medium"},s),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(Da,{color:"black"})),onClick:()=>t($.languages)},U={id:"widget-setting-infinite-approval-item-btn",title:D.createElement(D.Fragment,null,D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Infinite approval")),D.createElement(Qr,{direction:"horizontal",size:4}),D.createElement(eN,{side:"top",sideOffset:4,container:B(),content:D.createElement(_a,null,D.createElement(it,{variant:"label",size:"medium",color:"neutral700"},D.createElement("b",null,wt.t("Warning")),":\xA0",wt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},D.createElement(qA,{color:"gray"}))),start:D.createElement(QA,{color:"gray",size:16}),end:D.createElement(ZA,{checked:y}),onClick:S},Q={id:"widget-setting-theme-item-btn",type:D.createElement(KA,null),title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Theme")),end:D.createElement(oN,null,D.createElement(JA,{container:B(),items:nN,value:n,className:"widget-setting-theme-item-tabs-container",onChange:W=>o(W.id),type:"primary",borderRadius:"small"})),start:rN(n)},Z=h?[]:[v,N];return m||Z.push(M),g||Z.push(P),Z.push(U),!e?.singleTheme&&!f&&Z.push(Q),D.createElement(VA,{type:D.createElement(jA,{className:"widget-settings-list-item-btn",hasDivider:!0,id:"_",onClick:()=>console.log()}),items:Z})}i(Ky,"SettingsLists");var pN=sN("div",{paddingLeft:"$8"});function jy(){let{isInCampaignMode:t,updateCampaignMode:e}=T(),o=t(),[,n]=cN(),r=lN(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Xo.createElement(se,{header:{title:up.t("Settings")}},Xo.createElement(ce,null,o&&Xo.createElement(iN,{type:"info",variant:"alarm",id:"widget-settings-campaign-mode-alert",title:up.t("Currently, you're in campaign mode with restrictions on liquidity sources. Would you like to switch out of this mode and make use of all available liquidity sources?"),action:Xo.createElement(pN,null,Xo.createElement(aN,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},up.t("Reset")))}),Xo.createElement(pp,null),Xo.createElement(Ky,null)))}i(jy,"SettingsPage");import{i18n as T0}from"@lingui/core";import{cancelSwap as k0}from"@rango-dev/queue-manager-rango-preset";import{useManager as w0}from"@rango-dev/queue-manager-react";import{Alert as v0}from"@rango-dev/ui";import Ap from"react";import{useParams as x0}from"react-router-dom";import{i18n as zt}from"@lingui/core";import{getCurrentNamespaceOfOrNull as a0,getCurrentStep as s0,getRelatedWalletOrNull as l0}from"@rango-dev/queue-manager-rango-preset";import{Button as HS,Divider as c0,QuoteCost as p0,StepDetails as u0,Typography as wp}from"@rango-dev/ui";import{useWallets as d0}from"@rango-dev/wallets-react";import QS from"bignumber.js";import{PendingSwapNetworkStatus as Fn}from"rango-types";import we,{useEffect as vp,useRef as xp,useState as Ga}from"react";import{useNavigate as m0}from"react-router-dom";import{i18n as xo}from"@lingui/core";var uN=[xo.t("Sunday"),xo.t("Monday"),xo.t("Tuesday"),xo.t("Wednesday"),xo.t("Thursday"),xo.t("Friday"),xo.t("Saturday")];function Xy(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?xo.t("Today"):`${uN[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Xy,"timeSince");function Yy(t){return t.finishTime?Xy(parseInt(t.finishTime)):Xy(parseInt(t.creationTime))}i(Yy,"getSwapDate");import qr from"react";import{i18n as $a}from"@lingui/core";import{Button as Zy,Divider as dp,MessageBox as dN}from"@rango-dev/ui";import bo from"react";var Jy=i(({onCancel:t,onClose:e})=>bo.createElement(bo.Fragment,null,bo.createElement(dp,{size:20}),bo.createElement(dN,{type:"error",title:$a.t("Cancel Swap"),description:$a.t("Are you sure you want to cancel this swap?")}),bo.createElement(dp,{size:32}),bo.createElement(Zy,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},$a.t("Yes, Cancel it")),bo.createElement(dp,{size:12}),bo.createElement(Zy,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},$a.t("No, Continue"))),"CancelContent");import{i18n as Fa}from"@lingui/core";import{Button as Ry,Divider as mp,MessageBox as mN,Typography as fN}from"@rango-dev/ui";import io from"react";var eS=i(({onDelete:t,onClose:e})=>io.createElement(io.Fragment,null,io.createElement(mp,{size:20}),io.createElement(mN,{type:"error",title:Fa.t("Delete Transaction"),description:Fa.t("Are you sure you want to delete this swap?")}),io.createElement(mp,{size:32}),io.createElement(Ry,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},Fa.t("Yes, Delete it")),io.createElement(mp,{size:12}),io.createElement(Ry,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},io.createElement(fN,{variant:"title",size:"medium",color:"primary"},Fa.t("No, Cancel")))),"DeleteContent");import{i18n as gN}from"@lingui/core";import{Button as hN,Divider as yN,MessageBox as SN}from"@rango-dev/ui";import Yo from"react";var tS=i(t=>{let{switchNetworkModalState:e,handleSwitchNetwork:o}=t;return Yo.createElement(Yo.Fragment,null,Yo.createElement(SN,{type:e.type,title:e.title,description:e.description}),e.type==="error"&&Yo.createElement(Yo.Fragment,null,Yo.createElement(yN,{size:"30"}),Yo.createElement(hN,{id:"widget-switch-network-try-again",type:"primary",size:"large",onClick:o},gN.t("Try Again"))))},"NetworkStateContent");import{getCurrentNamespaceOfOrNull as DN,getCurrentStep as $N,getRelatedWalletOrNull as FN}from"@rango-dev/queue-manager-rango-preset";import{WalletState as ON}from"@rango-dev/ui";import{useWallets as UN}from"@rango-dev/wallets-react";import lS from"react";import{i18n as Dn}from"@lingui/core";import{Alert as rS,Button as kN,Checkbox as wN,Divider as za,Image as vN,MessageBox as xN,Spinner as bN,WarningIcon as EN}from"@rango-dev/ui";import{useWallets as IN}from"@rango-dev/wallets-react";import ye,{useState as AN}from"react";import{css as CN,darkTheme as TN,styled as fp}from"@rango-dev/ui";var oS=CN({wordWrap:"break-word",display:"block"}),nS=fp("img",{width:"100%"}),Oa=fp("div",{position:"relative"}),Ua=fp("span",{position:"absolute",top:0,right:0,borderRadius:"50%",width:"14px",height:"14px",display:"flex",padding:"$2",backgroundColor:"$warning300",[`.${TN} &`]:{$$color:"$warning600"}});var iS=i(t=>{let{wallet:e,namespace:o,onClose:n}=t,[r,a]=AN(null),{list:s}=bt(),c=ne.use.isActiveTab(),{state:l,connect:p}=IN(),u=s.find(w=>w.type===e.walletType),d=u?.needsNamespace?.data.find(w=>w.value===o?.namespace);if(!u)return null;let f=l(e.walletType),h=u.isHub&&o?.namespace?f.namespaces?.get(o.namespace):null,g=f.connecting||h?.connecting,m=u.isHub?h?.connected:f.connected,y=i(()=>m?Dn.t("Done"):r?Dn.t("Try again"):Dn.t("Connect"),"getButtonTitle"),S=i(()=>g?ye.createElement(bN,{color:"info"}):r||m?null:ye.createElement(wN,{checked:!0,disabled:!0}),"getNamespaceSuffix"),C=i(async()=>{try{a(null),await p(u.type,o?.namespace?[{namespace:o?.namespace,network:void 0,derivationPath:e.derivationPath}]:void 0)}catch(w){a(w)}},"handleConnect"),k=i(async()=>{if(m){n();return}C()},"handleClickButton"),x=i(()=>{if(!m)return null;let w=u?.isHub?h?.accounts?.[0]?.split(":"):f?.accounts?.[0]?.split(":"),I=w?.[w?.length-1];return I?lo(I):null},"getAddress");return ye.createElement(ye.Fragment,null,ye.createElement(xN,{type:"warning",title:Dn.t("Connect {wallet}",{wallet:u.title}),description:Dn.t("The connection of your wallet or some networks has been disconnected. Connect to continue the swap"),icon:ye.createElement(Oa,null,ye.createElement(vN,{src:u.image,size:45}),ye.createElement(Ua,null,ye.createElement(EN,{color:"warning",size:10})))}),m&&!d&&ye.createElement(ye.Fragment,null,ye.createElement(za,{size:10}),ye.createElement(rS,{type:"success",variant:"alarm",title:Dn.t("Wallet connected successfully.")})),r&&!d&&ye.createElement(ye.Fragment,null,ye.createElement(za,{size:10}),ye.createElement(rS,{type:"error",title:r?.message,variant:"alarm"})),d&&ye.createElement(ye.Fragment,null,ye.createElement(za,{size:30}),ye.createElement(_o,{namespace:d,suffix:S(),error:r?.message,connected:m,address:x()})),ye.createElement(za,{size:"40"}),ye.createElement(kN,{loading:g,type:"primary",id:"widget-connect-wallet-btn",onClick:k,disabled:!c},y()))},"ConnectWalletContent");import{i18n as aS}from"@lingui/core";import{Button as NN,Divider as BN,Image as WN,MessageBox as MN,WarningIcon as LN}from"@rango-dev/ui";import{useWallets as PN}from"@rango-dev/wallets-react";import{detectInstallLink as _N}from"@rango-dev/wallets-shared";import ao from"react";var sS=i(t=>{let{walletType:e}=t,{getWalletInfo:o}=PN(),n=e?o(e):null;if(!n)return null;let r=i(()=>window.open(_N(n.installLink),"_blank"),"handleButtonClick");return ao.createElement(ao.Fragment,null,ao.createElement(MN,{type:"warning",title:aS.t("Install {wallet}",{wallet:n.name}),description:"Your wallet is not installed. Please install it to continue the swap. ",icon:ao.createElement(Oa,null,ao.createElement(WN,{src:n.img,size:45}),ao.createElement(Ua,null,ao.createElement(LN,{color:"warning",size:10})))}),ao.createElement(BN,{size:"40"}),ao.createElement(NN,{type:"primary",id:"widget-install-wallet-btn",onClick:r},aS.t("Install")))},"InstallWalletContent");var cS=i(t=>{let{swap:e,onClose:o}=t,{state:n,getWalletInfo:r}=UN(),a=$N(e),s=a?FN(e,a):null,c=s?.walletType,l=c?Kn(r(c),n(c)):null,p=a?DN(e,a):null;return c?l===ON.NOT_INSTALLED?lS.createElement(sS,{walletType:c}):lS.createElement(iS,{wallet:s,namespace:p,onClose:o}):null},"WalletStateContent");function gp(t){let{isOpen:e,state:o,switchNetworkModalState:n,onClose:r,onDelete:a,onCancel:s,swap:c,message:l,handleSwitchNetwork:p}=t;return qr.createElement(ee,{open:e,onClose:r,container:B()},o==="connectWallet"&&qr.createElement(cS,{swap:c,message:l,onClose:r}),o==="switchNetwork"&&n&&qr.createElement(tS,{message:l,switchNetworkModalState:n,handleSwitchNetwork:p}),o==="delete"&&qr.createElement(eS,{onClose:r,onDelete:()=>{r(),a()}}),o==="cancel"&&qr.createElement(Jy,{onClose:r,onCancel:()=>{r(),s()}}))}i(gp,"SwapDetailsModal");import{i18n as Gr}from"@lingui/core";import{Button as hp,Divider as Vr,MessageBox as dS,TokenAmount as zN,Typography as mS}from"@rango-dev/ui";import ke from"react";import{Link as HN,useNavigate as QN}from"react-router-dom";var pS="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",uS="/profile";function yp(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:c,token:l,chain:p,percentageChange:u,description:d,diagnosisUrl:f}=t,h=QN(),{showProfileBanner:g}=ne();return ke.createElement(ee,{open:e,onClose:o,id:"widget-swap-details-complete-modal",container:document.getElementById(Re.SWAP_BOX_ID)||document.body},n==="success"?ke.createElement(dS,{type:"success",title:Gr.t("Swap Successful")},ke.createElement(zN,{direction:"vertical",tooltipContainer:B(),id:"widget-swap-details-complete-modal-success-token-amount-container",type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:c},token:l,chain:p,percentageChange:u}),ke.createElement(Vr,{size:12}),ke.createElement(mS,{className:oS(),variant:"body",size:"medium",color:"neutral700",align:"center"},d)):ke.createElement(dS,{type:"error",title:Gr.t("Transaction Failed"),description:d}),ke.createElement(Vr,{size:30}),n==="success"&&ke.createElement(ke.Fragment,null,g&&ke.createElement(ke.Fragment,null,ke.createElement(HN,{to:uS},ke.createElement(nS,{src:pS,alt:"Profile Banner"})),ke.createElement(Vr,{size:30})),ke.createElement(hp,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{h("../../")}},Gr.t("Done"))),ke.createElement(Vr,{size:12}),f&&ke.createElement(ke.Fragment,null,ke.createElement(hp,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(f,"_blank")},Gr.t("Diagnosis")),ke.createElement(Vr,{size:12})),ke.createElement(hp,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},ke.createElement(mS,{variant:"title",size:"medium",color:"primary"},Gr.t("See Details"))))}i(yp,"SwapDetailsCompleteModal");import{i18n as qa}from"@lingui/core";import{CopyIcon as t0,DoneIcon as o0,IconButton as n0,RangoExplorerIcon as r0,Tooltip as DS,Typography as $S,useCopyToClipboard as i0}from"@rango-dev/ui";import Mt from"react";import e0 from"react";import{i18n as YN}from"@lingui/core";import{Alert as MS,IconButton as ZN,LinkIcon as JN}from"@rango-dev/ui";import Eo,{Fragment as RN}from"react";import{Alert as GN,ChevronDownIcon as VN,IconButton as KN}from"@rango-dev/ui";import $n,{useState as jN}from"react";import{css as Kr,darkTheme as fS,styled as Ut,Typography as qN}from"@rango-dev/ui";var gS=Ut(ce,{overflowY:"auto","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${fS} &`]:{color:"$secondary500"}}}}}),hS=Ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),yS=Ut("div",{position:"sticky",top:0,zIndex:10,backgroundColor:"$background"}),SS=Ut("div",{padding:"$0 $20 $20 $20"}),IY=Ut("div",{display:"flex",flexDirection:"column",gap:"$10"}),CS=Ut("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),AY=Ut("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),Zo=Kr({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${fS} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),TS=Kr({padding:"$5 0"}),Ha=Kr({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),kS=Kr({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),wS=Kr({width:"100%",padding:"0 $20 $10"}),vS=Ut("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),xS=Ut("div",{display:"flex",flexDirection:"column",gap:"$5"}),Qa=Ut(qN,{wordBreak:"break-word"});import{styled as Sp}from"@rango-dev/ui";var bS=Sp("div",{display:"flex",flexDirection:"column",gap:"$10"}),ES=Sp("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),IS=Sp("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function AS(t){let{message:e}=t,[o,n]=jN(!1);return $n.createElement(GN,{id:"widget-failed-swap-details-alert",type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&$n.createElement(KN,{id:"widget-swap-details-failed-btn",onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},$n.createElement(ES,{rotated:o},$n.createElement(VN,{size:12,color:"gray"}))),footer:$n.createElement(IS,{open:o},$n.createElement(Qa,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(AS,"FailedAlert");import{i18n as NS}from"@lingui/core";import{Alert as Cp,Button as BS}from"@rango-dev/ui";import{PendingSwapNetworkStatus as XN}from"rango-types";import jr from"react";function WS(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,setNetworkModal:n,message:r,showNetworkModal:a}=t;return e?jr.createElement(Cp,{type:"warning",id:"widget-swap-details-change-network-alert",title:r.shortMessage,action:jr.createElement(BS,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{n("switchNetwork"),o()}},NS.t("Change"))}):a===XN.WaitingForConnectingWallet?jr.createElement(Cp,{type:"warning",title:r.shortMessage,id:"widget-swap-details-warning-alert-connect-wallet-alert",action:jr.createElement(BS,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{n("connectWallet")}},NS.t("Connect"))}):jr.createElement(Cp,{id:"widget-swap-details-short-alert",type:"warning",title:r.shortMessage})}i(WS,"WarningAlert");function Tp(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a,step:s,hasAlreadyProceededToSign:c}=t,l=pr(s),p=s.status==="waitingForApproval"&&!l,u=s.status==="running"&&!l,d=u&&!c||p&&!s.explorerUrl?.length;return Eo.createElement(bS,null,s.explorerUrl?.map((f,h,g)=>{let m=h+f.url,y=h===g.length-1,S=(y&&u||p)&&!d,C=y&&s.status==="failed";return Eo.createElement(RN,{key:m},Eo.createElement(MS,{id:"widget-swap-details-tx-alert",type:y&&(S&&"loading"||C&&"error")||"success",title:f.description?`${f.description} Tx`:YN.t("View transaction"),action:f.url&&Eo.createElement(ZN,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(f.url,"_blank")},Eo.createElement(JN,{size:12}))}))}),d&&Eo.createElement(MS,{id:"widget-swap-details-loading-alert",type:"loading",title:a.shortMessage}),s.status!=="failed"&&l&&Eo.createElement(WS,{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a}),s.status==="failed"&&Eo.createElement(AS,{message:a}))}i(Tp,"SwapDetailsAlerts");var LS=2e3;var PS=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let c=s===0?t.inputAmount:t.steps[s-1]?.outputAmount||t.steps[s-1]?.expectedOutputAmountHumanReadable;return{from:{token:{displayName:a.fromSymbol,image:a.fromLogo??""},chain:{displayName:yt(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:_(c,6,6),realValue:c??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:yt(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:_(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:Qn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(l=>({from:{chain:{displayName:yt(l.fromBlockchain,e)??"",image:l.fromBlockchainLogo??""}},to:{chain:{displayName:yt(l.toBlockchain,e)??"",image:l.toBlockchainLogo??""}},swapper:{displayName:Qn(l.swapperId,o)??"",image:l.swapperLogo??"",type:l.swapperType}})):[],alerts:e0.createElement(Tp,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function _S(t){if(pr(t)&&t.status!=="failed"&&t.status!=="success")return"warning";switch(t.status){case"created":return"default";case"approved":case"waitingForApproval":case"running":return"in-progress";case"failed":return"error";case"success":return"completed"}}i(_S,"getStepState");function FS(t){let{requestId:e}=t,[o,n]=i0(LS);return Mt.createElement(yS,{className:Zo()},Mt.createElement($S,{variant:"label",size:"large",color:"neutral700"},qa.t("Request ID")),Mt.createElement("div",{className:Ha()},Mt.createElement($S,{variant:"label",size:"small",color:"neutral700"},e),Mt.createElement(DS,{container:B(),content:o?qa.t("Copied To Clipboard"):qa.t("Copy Request ID"),open:o||void 0,side:"bottom",alignOffset:-16,align:"end"},Mt.createElement(n0,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:n.bind(null,e||"")},o?Mt.createElement(o0,{size:16,color:"secondary"}):Mt.createElement(t0,{size:16,color:"gray"}))),Mt.createElement(vS,{target:"_blank",href:`${eu}/swap/${e}`},Mt.createElement(DS,{container:B(),content:qa.t("View on Rango Explorer"),side:"bottom"},Mt.createElement(r0,{size:20})))))}i(FS,"RequestIdRow");import{i18n as OS}from"@lingui/core";import{Typography as US}from"@rango-dev/ui";import kp from"react";function zS(t){let{date:e,isFinished:o}=t;return kp.createElement("div",{className:Zo()},kp.createElement(US,{variant:"label",size:"large",color:"neutral700"},o?OS.t("Finished at"):OS.t("Created at")),kp.createElement(US,{variant:"label",size:"small",color:"neutral700"},e))}i(zS,"SwapDateRow");var f0=3e3;function bp(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:c}=d0(),l=T().blockchains(),p=T().swappers(),{findToken:u}=T(),d=H().use.retry(),f=m0(),h=xp(null),[g,m]=Ga(!1),[y,S]=Ga(null),[C,k]=Ga(null),[x,w]=Ga(null),I=xp(y),A=xp(C),b=Ne.use.getNotifications(),E=Ne.use.removeNotification(),v=b(),N=s0(e),M=N?.networkStatus,P=i(Me=>{m(!0),S(Me)},"handleChangeModalState"),U=i(()=>{m(!1)},"handleCloseModal"),Q=i(()=>{k({type:"loading",title:zt.t("Change Network"),description:`We\u2019re switching the connected network to ${X?.network}. Please check your wallet.`})},"handleShowSwitchNetworkLoading"),Z=i(()=>{k({type:"success",title:zt.t("Network Changed"),description:"The network has been successfully changed."})},"handleShowSwitchNetworkSucceeded"),W=i(Me=>{k({type:"error",title:zt.t("Network Switch Failed"),description:Me?.message||te.detailedMessage.content})},"handleShowSwitchNetworkFailed"),J=Yd(e),X=N?a0(e,N):null,ae=N?l0(e,N):null,Se=Yy(e),at=Zd(e),ue=i(Me=>!!c(Me)?.mobileWallet,"checkIsMobileWallet"),gt=!!M&&[Fn.WaitingForNetworkChange,Fn.NetworkChangeFailed].includes(M),vt=!!ae?.walletType&&ue(ae.walletType),xt=!!ae&&!!X&&a(ae.walletType,X.network,X),O=!!X&>&&(vt||xt),z=i(()=>{O&&(Q(),s(ae.walletType,[{namespace:X.namespace,network:X.network}]).then(()=>{Z()}).catch(Me=>{W(Me)}))},"handleSwitchNetwork"),Y=i(()=>{P("switchNetwork"),z()},"handleSwitchNetworkClick"),te=Xd(e,N,c),j=PS({swap:e,switchNetworkIsAvailable:O,handleSwitchNetworkClick:Y,showNetworkModal:M,setNetworkModal:P,message:te,blockchains:l,swappers:p}),G=j.length,[Ve,V]=[e.steps[0],e.steps[G-1]],Ce=V?.outputAmount||V?.expectedOutputAmountHumanReadable,Je=e.steps.reduce((Me,Lt)=>Me+parseFloat(Lt.feeInUsd||""),0),ht=e.steps.find(Me=>Me.diagnosisUrl)?.diagnosisUrl,so=_(parseFloat(Ce||"0")*(V?.toUsdPrice||0),4,4),zn=_(parseFloat(e.inputAmount)*(Ve?.fromUsdPrice||0),4,4),Io=Ce?new QS(Ce).multipliedBy(V.toUsdPrice||0).toString():"",Zr=new QS(e.inputAmount).multipliedBy(Ve?.fromUsdPrice||0).toString(),Ro=jt(zn,so),os=te.detailedMessage.content||te.shortMessage,wC=e.status==="success"?zt.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:_(Ce,6,6),token:j[G-1]?.to.token.displayName,conciseAddress:lo(e.wallets[j[G-1]?.to.chain.displayName||""]?.address||""),chain:j[G-1]?.to.chain.displayName}}):we.createElement(xS,null,we.createElement(wp,{variant:"body",size:"medium",color:"neutral700",align:"center"},os?"":zt.t("Transaction was not sent."),J?`${zt.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:J.outputAmount,symbol:J.symbol,blockchain:J.blockchain}})}`:""),os&&we.createElement(Qa,{align:"center",variant:"body",size:"medium",color:"neutral700"},we.createElement("b",null,"Reason:")," ",os));return vp(()=>{v.find(Lt=>Lt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(w(e.status),E(e.requestId),U()):x&&w(null))},[e.status,e.requestId]),vp(()=>{if(O){if(P("switchNetwork"),M===Fn.WaitingForNetworkChange){Q();return}if(M===Fn.NetworkChangeFailed){W();return}return}if(M===Fn.WaitingForConnectingWallet){P("connectWallet");return}if(M===Fn.NetworkChanged){P("switchNetwork"),Z();return}y&&["connectWallet","switchNetwork"].includes(y)&&U()},[M]),vp(()=>{if(I.current=y,A.current=C,y==="switchNetwork"&&C?.type==="success"){let Me=setTimeout(()=>{I.current==="switchNetwork"&&A.current?.type==="success"&&U()},f0);return()=>clearTimeout(Me)}},[y,C]),we.createElement(se,{header:{title:zt.t("Swap Details"),onCancel:e.status==="running"?()=>P("cancel"):void 0,suffix:e.status!=="running"&&we.createElement(fo,null,we.createElement(HS,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>P("delete")},we.createElement(wp,{size:"medium",variant:"label",color:"error"},zt.t("Delete"))))},footer:at&&!x&&we.createElement(HS,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let Me=Ai(e,l,u);d(Me),setTimeout(()=>{f("../../")},0)}},zt.t("Try again"))},we.createElement(gS,{compact:!0,ref:h},we.createElement(FS,{requestId:o}),we.createElement(zS,{date:Se,isFinished:!!e.finishTime}),we.createElement("div",{className:kS()},we.createElement(p0,{fee:_(String(Je),2,2),time:Gn(si(e.steps)),steps:G}),we.createElement(Cr,{from:{price:{value:_(e.inputAmount,6,6),usdValue:zn,realUsdValue:Zr,realValue:e.inputAmount},token:{displayName:j[0]?.from.token.displayName||"",image:j[0]?.from.token.image},chain:{image:j[0]?.from.chain.image,displayName:j[0]?.from.chain.displayName||""}},to:{price:{value:_(Ce,6,6),usdValue:so,realUsdValue:Io,realValue:Ce||""},token:{displayName:j[G-1]?.to.token.displayName||"",image:j[G-1]?.to.token.image},chain:{image:j[G-1]?.to.chain.image,displayName:j[G-1]?.to.chain.displayName||""}},percentageChange:_(Ro,2,2),warningLevel:Xt(Ro??0)})),we.createElement("div",{className:wS()},we.createElement(wp,{variant:"title",size:"small"},zt.t("Swaps steps"))),we.createElement(c0,{size:8}),we.createElement(SS,null,j.map((Me,Lt)=>{let Fp=Lt,Hn=e.steps[Lt]&&_S(e.steps[Lt]),vC=Hn==="error"||Hn==="in-progress"||Hn==="warning"||Hn==="completed"&&Lt===j.length-1;return we.createElement(u0,{className:"widget-swap-details-step-item-container",key:Fp,step:Me,type:"swap-progress",ref:h,state:Hn,hasSeparator:Lt!==0,tabIndex:Fp,isFocused:vC,tooltipContainer:B()})}))),we.createElement(gp,{isOpen:g,state:y,switchNetworkModalState:C,onClose:U,onCancel:r,onDelete:n,message:te.detailedMessage.content,swap:e,handleSwitchNetwork:Y}),we.createElement(yp,{open:!!x,diagnosisUrl:ht,onClose:()=>w(null),status:e.status==="success"?"success":"failed",priceValue:_(Ce,6,6),usdValue:so,realUsdValue:Io,realValue:Ce||"",percentageChange:_(Ro,2,2),token:{displayName:j[G-1]?.to.token.displayName||"",image:j[G-1]?.to.token.image},chain:{image:j[G-1]?.to.chain.image},description:wC}))}i(bp,"SwapDetails");import{i18n as Ka}from"@lingui/core";import{Divider as VS,NotFound as C0,Skeleton as Yr,Typography as ja}from"@rango-dev/ui";import Ie from"react";import{i18n as g0}from"@lingui/core";import{Divider as h0,Skeleton as y0,Typography as S0}from"@rango-dev/ui";import Ee from"react";import{css as Ht,styled as Ep}from"@rango-dev/ui";var qS=Ep("div",{width:"100%",height:"100%",padding:"$10 $20"}),Xr=Ep("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Va=Ep("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),t9=Ht({display:"flex",justifyContent:"space-between",alignItems:"center"}),o9=Ht({paddingTop:"$15",display:"flex"}),n9=Ht({padding:"$15 $0"}),r9=Ht({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),i9=Ht({paddingBottom:"$10"}),a9=Ht({display:"flex",justifyContent:"start",alignItems:"center"}),s9=Ht({paddingTop:"$5",display:"flex",alignItems:"center"}),l9=Ht({display:"flex",alignItems:"center"}),c9=Ht({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),GS=Ht({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Ip(){return Ee.createElement(qS,null,Ee.createElement(wr,{type:"swap-preview"}),Ee.createElement("div",{className:"swaps-steps"},Ee.createElement(S0,{variant:"title",size:"small"},g0.t("Swaps steps"))),Ee.createElement(Ee.Fragment,null,Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1}),Ee.createElement("div",{className:GS()},Ee.createElement(h0,{direction:"horizontal",size:20}),Ee.createElement(y0,{height:22,variant:"rectangular"}))),Ee.createElement(Va,null),Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1})),Ee.createElement(Va,null),Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1})),Ee.createElement(Va,null),Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1}))))}i(Ip,"LoadingSwapDetails");function KS(t){let{requestId:e,showSkeleton:o}=t;return Ie.createElement(se,{header:{title:Ka.t("Swap Details"),suffix:Ie.createElement(fo,null)}},o&&Ie.createElement(hS,null,Ie.createElement("div",{className:Zo()},Ie.createElement(ja,{variant:"label",size:"large",color:"neutral700"},`${Ka.t("Request ID")}`),Ie.createElement("div",{className:Ha()},Ie.createElement(ja,{variant:"label",size:"small",color:"neutral700"},Ie.createElement(Yr,{width:60,height:10,variant:"rounded"})),Ie.createElement(VS,{direction:"horizontal",size:4}),Ie.createElement(Yr,{width:16,height:16,variant:"rectangular"}),Ie.createElement(VS,{direction:"horizontal",size:4}),Ie.createElement(Yr,{width:16,height:16,variant:"rectangular"}))),Ie.createElement("div",{className:Zo()},Ie.createElement(ja,{className:TS(),variant:"label",size:"large",color:"neutral700"},Ie.createElement(Yr,{width:60,height:10,variant:"rounded"})),Ie.createElement(ja,{variant:"label",size:"small",color:"neutral700"},Ie.createElement(Yr,{width:60,height:10,variant:"rounded"}))),Ie.createElement(Ip,null)),!o&&Ie.createElement(CS,null,Ie.createElement(C0,{title:Ka.t("Not found"),description:Ka.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(KS,"SwapDetailsPlaceholder");function jS(){let{manager:t,state:e}=w0(),o=!e.loadedFromPersistor,n=kt(t),{requestId:r}=x0(),a=Qe(),{fetchStatus:s}=T();if(!r)return Ap.createElement(v0,{containerStyles:{margin:"20px"},type:"error",title:T0.t("The request ID is necessary to display the swap details.")});let c=o||s==="loading",l=r?n.find(({swap:f})=>f.requestId===r):void 0,p=i(()=>{if(l?.id){let f=t?.get(l.id);f&&k0(f)}},"onCancel"),u=i(async()=>{if(l?.id)try{t?.deleteQueue(l.id),a()}catch(f){console.log(f)}},"onDelete"),d=l?.swap;return!d||c?Ap.createElement(KS,{requestId:r,showSkeleton:c}):Ap.createElement(bp,{swap:d,requestId:r,onCancel:p,onDelete:u})}i(jS,"SwapDetailsPage");import{i18n as XS}from"@lingui/core";import{Divider as b0,getCategoriesCount as E0,SelectableCategoryList as I0,styled as ZS,Typography as A0,Wallet as N0}from"@rango-dev/ui";import Qt,{useState as YS}from"react";var B0=ZS("div",{display:"flex",justifyContent:"center",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5"}),W0=ZS(ce,{textAlign:"center"});function JS(){let{fetchStatus:t}=T(),[e,o]=YS("ALL"),n=T().blockchains(),{config:r}=T(),[a,s]=YS(),c=ne.use.isActiveTab(),{list:l}=bt(),p=Bu(l,n),d=E0(p)!==1,f=Wu(l,e),h=i(g=>{pu(l,r.multiWallets)||s(g)},"handleWalletItemClick");return Qt.createElement(se,{header:{title:XS.t("Connect Wallets")}},Qt.createElement(W0,null,d&&Qt.createElement(Qt.Fragment,null,Qt.createElement(I0,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Qt.createElement(b0,{size:24})),Qt.createElement(A0,{variant:"title",size:"xmedium",align:"center"},XS.t("Choose a wallet to connect.")),Qt.createElement(B0,null,f.map((g,m)=>{let y=`wallet-${m}-${g.type}`;return Qt.createElement(N0,{key:y,...g,state:g.state,container:B(),onClick:()=>h(g),isLoading:t==="loading",disabled:!c})}),Qt.createElement(sr,{id:"widget-state-full-connect-modal",wallet:a,onClose:()=>{s(void 0)}}))))}i(JS,"WalletsPage");function RS(){return lm(),Js(),M0([{path:$.home,element:Ue.createElement(gy,null)},{path:$.routes,element:Ue.createElement(Ty,null)},{path:$.fromSwap,children:[{index:!0,element:Ue.createElement(Pa,{type:"source"})},{path:$.blockchains,element:Ue.createElement(Ba,{type:"source"})}]},{path:$.toSwap,children:[{index:!0,element:Ue.createElement(Pa,{type:"destination"})},{path:$.blockchains,element:Ue.createElement(Ba,{type:"destination"})}]},{path:$.settings,children:[{index:!0,element:Ue.createElement(jy,null)},{path:$.languages,element:Ue.createElement(yy,null)},{path:$.exchanges,element:Ue.createElement(Jc,{sourceType:"Exchanges"})},{path:$.bridges,element:Ue.createElement(Jc,{sourceType:"Bridges"})},{path:$.customTokens,children:[{index:!0,element:Ue.createElement(hh,null)},{path:$.addCustomTokens,children:[{index:!0,element:Ue.createElement(sf,null)},{path:$.blockchains,element:Ue.createElement(Ba,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:Ue.createElement(Dh,null)},{path:$.swapDetails,element:Ue.createElement(jS,null)}]},{path:$.wallets,element:Ue.createElement(JS,null)},{path:$.confirmSwap,element:Ue.createElement(eh,null)}])}i(RS,"AppRoutes");import{useQueueManager as Y0}from"@rango-dev/queue-manager-rango-preset";import{isEvmBlockchain as Z0}from"rango-sdk";import{useContext as J0,useEffect as Mp,useState as uC}from"react";import{Provider as F0}from"@rango-dev/wallets-react";import Xa,{createContext as O0,useEffect as rC,useMemo as U0,useRef as iC}from"react";import{useEffect as P0}from"react";import{Provider as L0}from"@rango-dev/wallets-core";function eC(t){return t.map(e=>typeof e=="string"?e:e instanceof L0?e.id:e.config.type).join("-")}i(eC,"hashProviders");function Np(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=T(),a=n();return P0(()=>{o(),r()},[eC(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(Np,"useWalletProviders");import{legacyFormatAddressWithNetwork as _0,legacyReadAccountAddress as tC}from"@rango-dev/wallets-core/legacy";import{Events as On}from"@rango-dev/wallets-react";import{isEvmBlockchain as D0}from"rango-sdk";function oC(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=T(),{onConnectWalletHandler:c,onDisconnectWalletHandler:l}=t,p=s().filter(D0).map(m=>m.name),u=i((m,y)=>{let[S,,C,k,x]=m,w={walletType:S,network:k.network??void 0,accounts:C};c.current?c.current(w):console.warn("onConnectWallet handler hasn't been set. Are you sure?");let I=ds(S,C,p,y.supportedChainNames,x.isContractWallet);I.length&&e(I,x.namespace,k.derivationPath)},"onAccountsEvent"),d=i((m,y,S,C,k)=>{if(y===On.ACCOUNTS){let x=jn(k.supportedBlockchains);S&&u([m,y,S,C,k],{supportedChainNames:x})}y===On.PROVIDER_DISCONNECTED&&(o(m),l.current?l.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),y===On.NAMESPACE_DISCONNECTED&&n(m,S)},"handleUpdatesForHub"),f=i((m,y,S,C,k)=>{if(y===On.ACCOUNTS){let x=jn(k.supportedBlockchains),w=[],I=[];if(S?.forEach(b=>{let{network:E}=tC(b);p.includes(E)?w.push(b):I.push(b)}),r.filter(b=>b.walletType===m).map(b=>_0(b.address,b.chain)).length>0){if(w.length>0){let b=ds(m,w,p,x,k.isContractWallet);a(m,{chains:b.map(E=>E.chain)})}I.length>0&&a(m,{chains:I.map(b=>{let{network:E}=tC(b);return E})})}S?u([m,y,S,C,k],{supportedChainNames:x}):(o(m),l.current?l.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}},"handleUpdatesForLegacy"),h=i((m,y,S,C,k)=>{if(y===On.CONNECTED&&S){let x={walletType:m,network:C.network??void 0,accounts:C.accounts??void 0};c.current?c.current(x):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(y===On.NETWORK&&S){let x={walletType:m,network:S,accounts:C.accounts??void 0};c.current?c.current(x):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((m,y,S,C,k)=>{k.isHub?d(m,y,S,C,k):f(m,y,S,C,k),h(m,y,S,C,k)},"handler")}}i(oC,"useUpdates");import{LegacyEvents as $0}from"@rango-dev/wallets-core/legacy";function nC(t,e){let[o,n,r,a,s]=e;n!==$0.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i(nC,"propagateEvents");var Ya=O0({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function z0(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=T(),a=T().blockchains(),s=T().config,c={walletConnectProjectId:s?.walletConnectProjectId,trezorManifest:s?.trezorManifest,tonConnect:s.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:l}=Np(s.wallets,c),p=iC(),u=iC(),{handler:d}=oC({onConnectWalletHandler:p,onDisconnectWalletHandler:u});rC(()=>{n().catch(console.log)},[]),rC(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let f=ne.use.isActiveTab(),h=U0(()=>({onConnectWallet:g=>{p.current=g},onDisconnectWallet:g=>{u.current=g}}),[]);return Xa.createElement(Ya.Provider,{value:h},Xa.createElement(F0,{allBlockChains:a,providers:l,onUpdateState:(g,m,y,S,C)=>{let k=[g,m,y,S,C];d(...k),t.onUpdateState&&nC(t.onUpdateState,k)},autoConnect:!!f,configs:{wallets:s.wallets}},t.children))}i(z0,"Main");function Za(t){let{config:e,...o}=t;return Xa.createElement(Yu,{config:e},Xa.createElement(z0,{...o,config:e}))}i(Za,"WidgetWallets");import{globalCss as H0}from"@rango-dev/ui";var aC=i(()=>H0({"@import":"url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap')"})(),"globalFont");import{useWallets as Q0}from"@rango-dev/wallets-react";import{useEffect as q0,useRef as G0}from"react";function sC(){let{connect:t,state:e}=Q0(),o=G0({}),{fetchStatus:n}=T(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);q0(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(sC,"useForceAutoConnect");import{isApprovalTX as V0,RouteEventType as lC,StepEventType as cC,StepExecutionEventStatus as K0,WidgetEvents as Ja}from"@rango-dev/queue-manager-rango-preset";import{useEffect as pC}from"react";function Bp(){let t=Ne.use.setNotification(),{connectedWallets:e,fetchBalances:o,customTokens:n}=T();pC(()=>{let r=i(a=>{let{event:s,step:c,route:l}=a;if(s.type===cC.TX_EXECUTION&&s.status===K0.TX_SENT&&!V0(c)||s.type===cC.SUCCEEDED){let u=[],d=l.wallets[c?.fromBlockchain];if(d){let f=e.find(h=>h.address?.toLocaleLowerCase()===d.address?.toLocaleLowerCase()&&h.walletType===d.walletType&&h.chain===c?.fromBlockchain);f&&u.push(f)}if(c?.fromBlockchain!==c?.toBlockchain){let f=l.wallets[c?.toBlockchain];if(f){let h=e.find(g=>g.address?.toLocaleLowerCase()===f.address?.toLocaleLowerCase()&&g.walletType===f.walletType&&g.chain===c?.toBlockchain);h&&u.push(h)}}if(u.length>0){let f=n(),g=[{blockchain:c.fromBlockchain,address:c.fromSymbolAddress,symbol:c.fromSymbol},{blockchain:c.toBlockchain,address:c.toSymbolAddress,symbol:c.toSymbol}].filter(m=>f.some(y=>y.blockchain===m.blockchain&&y.address?.toLocaleLowerCase()===m.address?.toLocaleLowerCase()&&y.symbol?.toLocaleLowerCase()===m.symbol?.toLocaleLowerCase()));o(u,{selectedCustomTokens:g,shouldFetchCustomTokens:g.length>0})}}t(s,l)},"handleStepEvent");return ve.on(Ja.StepEvent,r),()=>ve.off(Ja.StepEvent,r)},[ve,e]),pC(()=>{let r=i(a=>{let{event:s,route:c}=a;(s.type===lC.FAILED||s.type===lC.SUCCEEDED)&&t(s,c)},"handleRouteEvent");return ve.on(Ja.RouteEvent,r),()=>ve.off(Ja.RouteEvent,r)},[ve])}i(Bp,"useSubscribeToWidgetEvents");import{useManager as j0}from"@rango-dev/queue-manager-react";import{useEffect as X0}from"react";function Wp(){let{isSynced:t,syncNotifications:e}=Ne(),{manager:o,state:n}=j0();X0(()=>{Ne.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(kt(o))},[Ne.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Wp,"useSyncNotifications");function Lp(){sC(),aC(),Bp(),Wp();let t=T().blockchains(),{canSwitchNetworkTo:e}=Yi(),[o,n]=uC(null),[r,a]=uC(),s=J0(Ya),c=t.filter(Z0);Mp(()=>()=>am(),[]),Mp(()=>()=>sm(),[]),Y0({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:c,canSwitchNetworkTo:e}),Mp(()=>(Po.init(),Ne.persist.hasHydrated()||Ne.persist.rehydrate(),s.onConnectWallet(l=>{n(p=>{if(!p||p.walletType!==l.walletType)return l;let u={...p};return l.network&&(u.network=l.network),l.accounts&&(u.accounts=l.accounts),u})}),s.onDisconnectWallet(l=>{a(l),n(p=>l===p?.walletType?null:p)}),Po.destroy),[])}i(Lp,"useBootstrap");import{styled as R0}from"@rango-dev/ui";var dC=R0("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left",height:"100%","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Jo(){Lp();let{config:t}=T(),{activeTheme:e}=mo(t?.theme||{}),{activeLanguage:o}=wo();return Pp.createElement(eB,{language:o},Pp.createElement(dC,{id:"swap-container",className:e()},Pp.createElement(RS,null)))}i(Jo,"Main");import{setSolanaSignerConfig as TB}from"@rango-dev/signer-solana";import Dp,{useEffect as $p,useMemo as kB}from"react";function mC(){let{setWatermark:t,setShowProfileBanner:e}=ne();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Gt("BASE_URL")}/meta/dapp/config?apiKey=${Gt("API_KEY")}`);if(!n.ok)throw new Error(`Request failed with status: ${n.status} `);let r=await n.json();t(r.config.watermark),e(r.config.banners.profile)},"fetchApiConfig")}}i(mC,"useFetchApiConfig");import{useState as tB}from"react";var oB=i(()=>{let[t,e]=tB(null),o=i(a=>{let s=document.createElement("link");return s.href=a,s.rel="stylesheet",document.head.appendChild(s),s},"loadFont"),n=i(()=>{t&&(document.head.removeChild(t),e(null))},"unloadFont");return{handleLoadCustomFont:i(a=>{n();let s=cu(a);if(s){let c=o(s);e(c)}},"handleLoadCustomFont")}},"useFontLoader"),fC=oB;import{checkWaitingForNetworkChange as nB,makeQueueDefinition as rB}from"@rango-dev/queue-manager-rango-preset";import{Provider as iB}from"@rango-dev/queue-manager-react";import{useWallets as aB}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as sB}from"@rango-dev/wallets-shared";import{isEvmBlockchain as lB}from"rango-types";import cB,{useMemo as pB}from"react";function uB(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s,hubProvider:c}=aB(),l=pB(()=>rB({API_KEY:t.apiKey||Gt("API_KEY"),BASE_URL:Gt("BASE_URL"),emitter:{emit:ve.emit}}),[t.apiKey]),{blockchains:p,connectedWallets:u}=T(),d=p(),f={blockchains:u.map(w=>({accounts:[w],name:w.chain}))},h=i(async(w,I)=>a(w,I.network,I)?await r(w,[I]):void 0,"switchNetwork"),g=i(w=>!!s(w).mobileWallet,"isMobileWallet"),m=d.filter(w=>w.enabled).reduce((w,I)=>(w[I.name]=I,w),{}),y=d.filter(lB),S=i(w=>{let{supportedChains:I}=s(w);return jn(I)},"getSupportedChainNames"),C=e(),k={meta:{blockchains:m,evmBasedChains:y,evmNetworkChainInfo:sB(y),getSupportedChainNames:S},getSigners:o,wallets:f,providers:C,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:g,hubProvider:c},x=ne.use.isActiveTab();return cB.createElement(iB,{queuesDefs:[l],context:k,onPersistedDataLoaded:w=>{nB(w)},isPaused:!x},t.children)}i(uB,"QueueManager");var gC=uB;import{useManager as hB}from"@rango-dev/queue-manager-react";import yB,{createContext as SB,useContext as CB}from"react";function hC(){let{findToken:t}=T(),e=T().blockchains(),o=T().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:c}=H()();return i(p=>{let{fromBlockchain:u,fromToken:d,toBlockchain:f,toToken:h,requestAmount:g}=p,m={blockchains:e,tokens:o};if(u!==void 0){let y=e.find(S=>S.name===u)??null;n(y)}if(d!==void 0){let y=d?t(d)??null:null;r({meta:m,token:y})}if(f!==void 0){let y=e.find(S=>S.name===f)??null;a(y)}if(h!==void 0){let y=h?t(h)??null:null;s({meta:m,token:y})}g!==void 0&&c(g)},"updateQuoteInputs")}i(hC,"useUpdateQuoteInputs");import{cancelSwap as dB,getCurrentNamespaceOfOrNull as mB,getCurrentStep as fB,getRelatedWalletOrNull as gB}from"@rango-dev/queue-manager-rango-preset";var Ra=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return kt(this.manager)}getCurrentStep(e){return this.getCurrentStepInfo(e).step}getCurrentStepWallet(e){return this.getCurrentStepInfo(e).wallet}getCurrentStepNetwork(e){return this.getCurrentStepInfo(e).network}retry(e,o){let n=Ai(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&dB(o)}getCurrentStepInfo(e){let o=fB(e);return{step:o,wallet:o?gB(e,o):null,network:o?mB(e,o)?.network:null}}};var yC=SB(void 0);function _p(t){let{manager:e}=hB(),o=ne.use.isActiveTab(),n=H().use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:c}=T(),l=new Ra(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=T(),u=xu(a()),d=T().blockchains(),f=T().tokens(),h=T().swappers(),g=T().fetchStatus,m=wo().resetLanguage,y=Ne().getNotifications(),S=Ne().clearNotifications,C=hC(),{fromBlockchain:k,toBlockchain:x,fromToken:w,toToken:I,inputAmount:A}=H()(),b={isActiveTab:o,setCurrentTabAsActive:Po.forceClaim,history:l,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async E=>c(E)},meta:{blockchains:d,tokens:f,swappers:h,loadingStatus:g,findToken:r},resetLanguage:m,notifications:{list:y,clearAll:S},quote:{quoteInputs:{fromBlockchain:k?.name??null,fromToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,toBlockchain:x?.name??null,toToken:I?{symbol:I.symbol,blockchain:I.blockchain,address:I.address}:null,requestAmount:A},updateQuoteInputs:C}};return yB.createElement(yC.Provider,{value:b},t.children)}i(_p,"WidgetInfo");function SC(){let t=CB(yC);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(SC,"useWidget");function Un(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{fetchApiConfig:r}=mC(),{handleLoadCustomFont:a}=fC();return $p(()=>{r().catch(console.log)},[]),$p(()=>{n&&a(n)},[n]),kB(()=>{Mu({API_KEY:o?.apiKey||oi,BASE_URL:o?.apiUrl||Rp})},[o.apiKey,o.apiUrl]),$p(()=>{t.config?.signers?.customSolanaRPC&&TB("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),Dp.createElement(Za,{config:o,onUpdateState:e},Dp.createElement(gC,{apiKey:o.apiKey},Dp.createElement(_p,null,t.children)))}i(Un,"WidgetProvider");function CC(t){let e=t.config?.externalWallets;return es.createElement(Ei,null,e?es.createElement(Jo,null):es.createElement(Un,{config:t.config??nn},es.createElement(Jo,null)))}i(CC,"Refuel");import ts from"react";function TC(t){let e=t.config?.externalWallets;return ts.createElement(Ei,null,e?ts.createElement(Jo,null):ts.createElement(Un,{config:t.config??nn},ts.createElement(Jo,null)))}i(TC,"Widget");function kC(){let{on:t,off:e}=ve;return{on:t,off:e}}i(kC,"useWidgetEvents");var rte={DerivationPath:rr,Namespaces:tr,Detached:nr,isOnDerivationPath:ar,isOnNamespace:ir,isOnDetached:Ao};export{Iee as EventSeverity,ln as MainEvents,$ee as Networks,Uee as PendingSwapNetworkStatus,ys as QuoteEventTypes,CC as Refuel,Aee as RouteEventType,ss as SUPPORTED_FONTS,rte as StatefulConnect,Nee as StepEventType,Bee as StepExecutionBlockedEventStatus,Wee as StepExecutionEventStatus,wd as SwapModeContext,Re as UI_ID,Cs as UiEventTypes,Ss as WalletEventTypes,_ee as WalletEvents,Fee as WalletTypes,TC as Widget,ln as WidgetEvents,Un as WidgetProvider,Za as WidgetWallets,dl as customizedThemeTokens,is as pickProviderVersionWithFallbackToLegacy,Lee as readAccountAddress,en as useStatefulConnect,bt as useWalletList,Yi as useWallets,SC as useWidget,kC as useWidgetEvents,IT as widgetEventEmitter};
|
|
1
|
+
var IC=Object.defineProperty;var i=(t,e)=>IC(t,"name",{value:e,configurable:!0});import{EventSeverity as Lee,RouteEventType as Pee,StepEventType as _ee,StepExecutionBlockedEventStatus as Dee,StepExecutionEventStatus as $ee}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Oee}from"@rango-dev/wallets-core/legacy";import{useWallets as Xi,Events as zee}from"@rango-dev/wallets-react";import{Networks as Qee,WalletTypes as qee}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as Vee}from"rango-types";import{Divider as jk}from"@rango-dev/ui";import po,{useEffect as Xk,useRef as Yk,useState as xd}from"react";import{WalletState as AC}from"@rango-dev/ui";import{useWallets as NC}from"@rango-dev/wallets-react";import{useReducer as BC}from"react";function Fp(t){return!!t.derivationPath}i(Fp,"isStateOnDerivationPathStep");function Op(t){return!!t.namespace}i(Op,"isStateOnNamespace");var Jr={status:"init",namespace:null,derivationPath:null,selectedNamespaces:null};function Up(t,e){switch(e.type){case"needsNamespace":return{...t,status:"namespace",namespace:e.payload,derivationPath:null};case"needsDerivationPath":return{...t,status:"derivationPath",derivationPath:e.payload};case"detached":return{...t,status:"detached",namespace:{targetWallet:e.payload.targetWallet},selectedNamespaces:e.payload.selectedNamespaces};case"reset":return Jr;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:Jr;default:throw new Error("Action hasn't been defined.")}}i(Up,"reducer");function en(){let{state:t,disconnect:e,connect:o}=NC(),[n,r]=BC(Up,Jr),a=i(async(d,f,h)=>{r({type:"reset"});try{let g=f?.map(m=>({...m,network:void 0}));return await o(d.type,g),{status:"connected"}}catch(g){let m=g?.message?`Error: ${g.message}`:"An unknown error happened during connecting wallet.";if(h?.disconnectOnError)try{await u(d)}catch{console.warn("An error happened during disconnecting wallet after error on connecting.")}throw new Error(m,{cause:g})}},"runConnect"),s=i(async(d,f)=>{let h=d.state===AC.DISCONNECTED,g=f?.forceConnectToNamespaces;if(h){let m=!!d.isHub,y=m?d.properties?.find(C=>C.name==="namespaces")?.value:d.needsNamespace,S=m?d.properties?.find(C=>C.name==="derivationPath")?.value:d.needsDerivationPath;if(g){let C=g.find(k=>!y?.data?.map(x=>x.value).includes(k));if(C)throw new Error(`One of the forced namespaces is not available in the wallet. Forced namespace: ${C}`);if(g.length>1&&S)throw new Error("Derivation path is not supported when multiple namespaces are selected.");return g.length===1&&g[0]&&S?(r({type:"needsDerivationPath",payload:{providerType:d.type,providerImage:d.image,namespace:g[0]}}),{status:"derivation-path"}):await a(d,g.map(k=>({namespace:k})),{...f,disconnectOnError:!0})}if(!y?.data?.length)return await a(d,void 0,f);if(y?.data.length&&y.data.length>1)return r({type:"needsNamespace",payload:{targetWallet:d,defaultSelectedChains:f?.defaultSelectedChains}}),{status:"namespace"};if(y?.data.length===1&&y.data[0]){if(S){let C=y.data[0];return r({type:"needsDerivationPath",payload:{providerType:d.type,providerImage:d.image,namespace:C.value}}),{status:"derivation-path"}}return await a(d,y?.data?.map(C=>({namespace:C.value})),f)}}if(d.isHub&&!f?.forceConnectToNamespaces){let m=d.properties?.find(y=>y.name==="namespaces")?.value;if(m?.data.length&&m.data.length>1)return r({type:"detached",payload:{targetWallet:d,selectedNamespaces:null}}),{status:"Detached"}}return f?.disconnectIfConnected?(await u(d),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),c=i(async(d,f)=>{let h=!!d.isHub,g=h?d.properties?.find(k=>k.name==="namespaces")?.value:d.needsNamespace,m=h?d.properties?.find(k=>k.name==="derivationPath")?.value:d.needsDerivationPath,y=g?.selection==="single",S=f[0];if(!S)throw new Error("To confirm a namespace, you should select at least one namespace.");if(y&&m)return r({type:"needsDerivationPath",payload:{providerType:d.type,providerImage:d.image,namespace:S}}),{status:"derivation-path"};if(!Op(n))throw new Error("Something went wrong on handling namespace. Please retry.");let C=f.map(k=>({namespace:k}));return r({type:"detached",payload:{targetWallet:d,selectedNamespaces:C??null}}),{status:"Detached"}},"handleNamespace"),l=i(async(d,f,h)=>{if(!f)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!Fp(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let m=[{namespace:n.derivationPath.namespace,derivationPath:f}],S=!!d.isHub?d.properties?.find(x=>x.name==="namespaces")?.value:d.needsNamespace,C=!!S?.data&&S.data.length>1,k=!!h?.forceConnectToNamespaces;return C&&!k?(r({type:"detached",payload:{targetWallet:d,selectedNamespaces:m??null,derivationPath:f}}),{status:"Detached"}):await a(d,m)},"handleDerivationPath"),p=i(()=>n,"getState"),u=i(async d=>{let f=t(d.type);return f.connected||f.connecting?(await e(d.type),Ao(p)?(r({type:"needsNamespace",payload:{targetWallet:d}}),{status:"namespace"}):{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:c,handleDerivationPath:l,getState:p,resetState:d=>{r(d==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(en,"useStatefulConnect");import{WalletState as bs}from"@rango-dev/ui";import{useWallets as zT}from"@rango-dev/wallets-react";import{detectMobileScreens as HT,KEPLR_COMPATIBLE_WALLETS as QT,WalletTypes as Jn}from"@rango-dev/wallets-shared";import{useCallback as qT,useEffect as GT}from"react";import DT,{createContext as $T,useContext as FT,useEffect as OT,useRef as UT}from"react";import{create as PT}from"zustand";import{persist as _T}from"zustand/middleware";import{allProviders as WC}from"@rango-dev/provider-all";var os=class{static{i(this,"CacheService")}#e=new Map;get(e){return this.#e.get(e)}set(e,o){this.#e.set(e,o)}remove(e){this.#e.delete(e)}clear(){this.#e.clear()}},tn=new os;import{defineVersions as Hp,pickVersion as Qp,Provider as ns}from"@rango-dev/wallets-core";function qp({allProviders:t,configWallets:e}){if(e){let o=[];return e.forEach(n=>{if(typeof n=="string"){let r=t.find(a=>{let s=rs(a);return s instanceof ns?s.id===n:s.config.type===n});r?o.push(r):console.warn(`Couldn't find ${n} provider. Please make sure you are passing the correct name.`)}else n instanceof ns?o.push(Hp().version("1.0.0",n).build()):o.push(Hp().version("0.0.0",n).build())}),o}return t}i(qp,"matchAndGenerateProviders");function rs(t){try{return Qp(t,"1.0.0")[1]}catch{return Qp(t,"0.0.0")[1]}}i(rs,"pickProviderVersionWithFallbackToLegacy");function Gp(t){return t.map(o=>rs(o)).map(o=>o instanceof ns?o.id:o.config.type)}i(Gp,"configWalletsToWalletName");function Rr(t,e){return e.find(o=>o.name===t)?.displayName}i(Rr,"getBlockchainDisplayNameFor");function yt(t,e){return e.find(o=>o.name===t)?.shortName}i(yt,"getBlockchainShortNameFor");function Vp(t,e){return e.find(o=>o.name===t)?.logo}i(Vp,"getBlockchainImage");function Qn(t,e){return e.find(o=>o.id===t)?.title}i(Qn,"getSwapperDisplayName");function No(t,e){return e.find(o=>o.name===t)??null}i(No,"findBlockchain");function is(t,e){if(!e||!t)return!1;for(let o of e.feeAssets)if(t?.blockchain===o?.blockchain&&t?.symbol===o?.symbol&&t?.address===o?.address)return!0;return!1}i(is,"isTokenNative");function St(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(St,"createTokenHash");function on(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(on,"isValidTokenAddress");function qn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(c=>{c.forEach(l=>{typeof l!="string"&&(l=St(l));let p=o.tokensMapByTokenHash.get(l);p&&(n[l]=p)})},"addTokens");if(Array.isArray(r))return r.length>0?(a(r),Object.values(n)):Array.from(o.tokensMapByTokenHash.values());if(!r)return Array.from(o.tokensMapByTokenHash.values());let s;if(e.blockchains?.length)s=e.blockchains;else{s=Object.keys(r);let c=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(l=>{let p=o.tokensMapByBlockchainName[l];!c.has(l)&&p&&a(p)})}return s.forEach(c=>{let l=r[c];if(!l&&o.tokensMapByBlockchainName?.[c]){a(o.tokensMapByBlockchainName[c]);return}l&&(l.isExcluded&&o.tokensMapByBlockchainName[c]?(a(o.tokensMapByBlockchainName[c]),l.tokens.forEach(p=>{let u=St(p);delete n[u]})):a(l.tokens))}),Object.values(n)}i(qn,"matchTokensFromConfigWithMeta");function ei(t){let{config:e}=t,o=e.from?.blockchains||[],n=e.to?.blockchains||[];if(!o.length||!n.length)return[];let r=[...o,...n],a=new Set(r);return Array.from(a)}i(ei,"getSupportedBlockchainsFromConfig");function jp(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink}}i(jp,"makeProvidersOptionsFromConfig");var nn={apiKey:"",title:void 0,multiWallets:!0,excludeLiquiditySources:!0,customDestination:!0,variant:"default",trezorManifest:{appUrl:"https://widget.rango.exchange/",email:"hi+trezorwidget@rango.exchange"},tonConnect:{manifestUrl:"https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/manifests/tonconnect-manifest.json"}},MC={clientUrl:void 0},LC={liquiditySources:void 0};function Kp(t){let e=jp(t),o={walletconnect2:{WC_PROJECT_ID:e?.walletConnectProjectId||"",DISABLE_MODAL_AND_OPEN_LINK:e?.walletConnectListedDesktopWalletLink},selectedProviders:t.wallets,trezor:e?.trezorManifest?{manifest:e.trezorManifest}:void 0,tonConnect:e?.tonConnect?.manifestUrl?{manifestUrl:e?.tonConnect.manifestUrl}:void 0};return WC(o).map(a=>a())}i(Kp,"generateProviders");var Xp=i((t,e,o)=>{let n=Kp({...nn,...t});return{config:{...nn,...t},iframe:MC,campaignMode:LC,allProviders:n,getLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?a.liquiditySources:r.liquiditySources??[]},getDisabledLiquiditySources:()=>{let{disabledLiquiditySources:r,campaignMode:a}=o();return a.liquiditySources?.length?[]:r},excludeLiquiditySources:()=>{let{config:r,campaignMode:a}=o();return a.liquiditySources?.length?!1:!!r.excludeLiquiditySources},isInCampaignMode:()=>{let{campaignMode:r}=o();return!!r.liquiditySources?.length},updateConfig:r=>{let a=o().config,{_tokensMapByTokenHash:s,_tokensMapByBlockchainName:c}=o(),l=qn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:c,tokensMapByTokenHash:s}}),p=qn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:c,tokensMapByTokenHash:s}});tn.set("supportedSourceTokens",l),tn.set("supportedDestinationTokens",p),e({config:{...a,...r}})},updateCampaignMode:(r,a)=>{let s=o().campaignMode;e({campaignMode:{...s,[r]:a}})},updateIframe:(r,a)=>{let s=o().iframe;e({iframe:{...s,[r]:a}})},buildAndSetProviders:()=>{let{config:r}=o(),a=Kp(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=jp(a);return qp({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as Yp}from"rango-types";var Zp=[Yp.EVM,Yp.SOLANA],ti="https://raw.githubusercontent.com/rango-exchange/assets/refs/heads/main/common/unknown-image.png";import{RangoClient as XC}from"rango-sdk";function Jp(){return process.env.REACT_APP_RANGO_API_KEY}i(Jp,"getApiKeyFromEnv");function Rp(){let t=Jp();if(t)return t;throw new Error("Ensure you have set REACT_APP_RANGO_API_KEY in your env variables.")}i(Rp,"getApiKeyFromEnvOrThrow");function eu(){return Jp()||"NOT_SET"}i(eu,"getApiKeyFromEnvOrNotSet");import{BlockchainCategories as zC,WalletState as lt}from"@rango-dev/ui";import{legacyReadAccountAddress as HC}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as QC,getCosmosExperimentalChainInfo as qC,isEvmAddress as GC,KEPLR_COMPATIBLE_WALLETS as OW,Networks as bu}from"@rango-dev/wallets-shared";import an from"bignumber.js";import{isCosmosBlockchain as VC}from"rango-types";import PC from"bignumber.js";var pe=new PC(0);import{WalletTypes as _C}from"@rango-dev/wallets-shared";var Bo="~",tu=[_C.LEAP];import{BlockchainCategories as ss,WalletState as UC}from"@rango-dev/ui";import{TransactionType as oi}from"rango-sdk";import{UI_ID as DC}from"@rango-dev/ui";var ou="https://api.rango.exchange",nu="https://explorer.rango.exchange",Re={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...DC};var ru="Roboto",as=[{name:"Roboto",value:"Roboto",url:""},{name:"Times New Roman",value:"Times New Roman",url:"https://fonts.cdnfonts.com/css/times-new-roman"},{name:"Arial",value:"Arial",url:""},{name:"Open Sans",value:"Open Sans",url:"https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap"},{name:"Noto Sans",value:"Noto Sans",url:"https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Montserrat",value:"Montserrat",url:"https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Poppins",value:"Poppins",url:"https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"},{name:"Roboto Condensed",value:"Roboto Condensed",url:"https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Roboto Mono",value:"Roboto Mono",url:"https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap"},{name:"Oswald",value:"Oswald",url:"https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap"},{name:"Raleway",value:"Raleway",url:"https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap"},{name:"Sedan",value:"Sedan",url:"https://fonts.googleapis.com/css2?family=Sedan:ital@0;1&display=swap"},{name:"Inter",value:"Inter",url:"https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap"},{name:"Rubik",value:"Rubik",url:"https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap"},{name:"Lora",value:"Lora",url:"https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&display=swap"},{name:"Barlow Condensed",value:"Barlow Condensed",url:"https://fonts.googleapis.com/css2?family=Barlow+Condensed:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"}];function rn(t){return Array.from(new Set(t))}i(rn,"removeDuplicateFrom");function ni(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(ni,"debounce");function st(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(st,"containsText");function su(t,e){return t.toLowerCase()===e.toLowerCase()}i(su,"exactText");function lu(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(lu,"startWithText");var B=i(()=>document.getElementById(Re.SWAP_BOX_ID),"getContainer"),Wo=i(()=>document.getElementById(Re.EXPANDED_BOX_ID),"getExpanded");function cu(t,e,o){let n=!!e&&su(e,t),r=!!o&&su(o,t);return n!==r?n?-1:1:0}i(cu,"compareExactMatchText");function ls(t,e,o){let n=!!e&&st(e,t),r=!!o&&st(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(ls,"compareContainsText");function cs(t,e,o){let n=!!e&&lu(e,t),r=!!o&&lu(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(cs,"compareStartWithText");function pu(t,e,o){if(!o)return 0;let n=cu(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=cu(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=cs(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=ls(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=cs(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=ls(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=cs(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=ls(o,t.address,e.address);if(r!==0)return r}return 0}i(pu,"compareWithSearchFor");var ri=i((t,e)=>{switch(e){case ss.ALL:return!0;case ss.UTXO:return t===oi.TRANSFER;case ss.OTHER:return t!==oi.TRANSFER&&t!==oi.COSMOS&&t!==oi.EVM;default:return t===e}},"isBlockchainTypeInCategory"),uu=i(t=>as.find(o=>o.value===t)?.url,"getFontUrlByName");function du(t,e){let o=!!t.find(n=>n.state===UC.CONNECTED);return e===!1&&o}i(du,"isSingleWalletActive");function mu(){let t,e;return(o,n)=>((!e||!t||t!==n)&&(t=n,e=o()),e)}i(mu,"memoizedResult");function fu(t,e){let o=new Set;return e.forEach(n=>{o.add(n.blockchain)}),t.filter(n=>o.has(n.name))}i(fu,"filterBlockchainsWithAtLeastOneToken");import{BigNumber as vu}from"bignumber.js";function gu(t){return t.replace(/^0+(?=\d)/g,"")}i(gu,"removeLeadingZeros");function hu(t){return t.replace(/^\.(\d+)/,"0.$1")}i(hu,"ensureLeadingZeroForDecimal");function yu(t){return t.replace(/\B(?=(\d{3})+(?!\d))/g,",")}i(yu,"formatThousandsWithCommas");function Su(t){return t.replace(/\s+/g,"-")}i(Su,"replaceSpacesWithDash");function Cu(t){return t.replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"")}i(Cu,"stripTrailingZeros");function Tu(t){return t=t.replace(/[^\d.]/g,"").replace(/\./g,(e,o,n)=>n.indexOf(".")===o?".":""),t}i(Tu,"parseNumericValue");function ii(t){return/^0+(?:\.0+)?$/.test(t)}i(ii,"isZeroValue");function ku(t,e=2){let o=`^(?:0|[1-9]\\d*)(?:\\.\\d{1,${e}})?$`;return new RegExp(o).test(t)}i(ku,"isValidCurrencyFormat");function wu(t){return/\d+$/.test(t)}i(wu,"isColorKeyOverridden");var Gn=i(t=>{let e=Math.floor(t%60/15)*15,o=parseInt((t/60).toString());return o>=60?`${Math.floor(o/5)*5}:00`:`${o.toString().padStart(2,"0")}:${e.toString().padStart(2,"0")}`},"roundedSecondsToString"),_=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new vu(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new vu(n.toFixed(s,r)).eq(n)){a=s;break}if(n.gte(1e4))return n.toFormat(0,r);if(n.gte(1e3)||n.gte(100))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,1))),r);if(n.gte(1))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,2))),r);if(n.gte(.01))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,4))),r);for(let s=e||4;s<17;s++)if(n.gte(Math.pow(10,-s)))return n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,s))),r);return n.isEqualTo(0)?"0":n.toFormat(Math.min(a,Math.min(o||100,Math.max(e||0,8))),r)},"numberToString");var ai=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var Pt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),Vn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function xu(t){return ii(t)?"0":t.endsWith(".")?t.slice(0,-1):Cu(t)}i(xu,"sanitizeInputAmount");function Kn(t,e){return jC(t,e)?lt.PARTIALLY_CONNECTED:e.connected?lt.CONNECTED:e.connecting?lt.CONNECTING:e.installed?lt.DISCONNECTED:lt.NOT_INSTALLED}i(Kn,"getWalletConnectionStatus");function Eu(t,e,o,n){return o.filter(r=>!tu.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:c,network:l}=t(r);return s&&(!c||!!n&&l!==n)?!1:n?!!a.find(u=>u.name===n):!0}).map(r=>{let{name:a,img:s,installLink:c,showOnMobile:l,needsNamespace:p,supportedChains:u,needsDerivationPath:d,properties:f,isHub:h}=e(r),g=rn(u.map(y=>y.type)),m=Kn(e(r),t(r));return{title:a,image:s,link:QC(c),state:m,type:r,showOnMobile:l,needsNamespace:p,blockchainTypes:g,needsDerivationPath:d,properties:f,isHub:h}})}i(Eu,"mapWalletTypesToWalletInfo");function jn(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(jn,"walletAndSupportedChainsNames");function us(t,e,o,n,r){let a=[];function s(l,p,u){if(!!!a.find(f=>f.chain===l)){let f={address:p,chain:l,walletType:t,isContractWallet:u??!1};a.push(f)}}i(s,"addAccount");let c=n||[];return e.forEach(l=>{let{address:p,network:u}=HC(l),d=c.length>0,f=c.includes(u),h=u===bu.Unknown;if(d&&!f&&!h)return;let m=u===bu.Unknown&&GC(p);if(h&&!m)return;o.includes(u)||m?r?s(u,p.toLowerCase(),r):c.filter(C=>o.includes(C)).forEach(C=>{s(C,p.toLowerCase())}):s(u,p)}),a}i(us,"prepareAccountsForWalletStore");function Mo(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,c=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:l}=r;l.forEach((p,u)=>{let d=p.from.blockchain,f=p.to.blockchain,h=a===o.swaps.length-1,g=u===l.length-1;(!h&&!g||h&&c!==d||e==="all")&&n.add(d),e==="all"&&n.add(f)})}e==="all"&&n.add(c)}),Array.from(n)}i(Mo,"getQuoteChains");function Xn(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(Xn,"isAccountAndWalletMatched");var Iu=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=n.usdValue?ps(n.usdValue,n.decimals):pe.toFixed();return o.plus(r)},new an(pe));return KC(e.toString())},"calculateWalletUsdValue");function KC(t){let e=t.toString().split(".");return e[0]&&(e[0]=yu(e[0])),e.join(".")}i(KC,"numberWithThousandSeparator");var ci=i((t,e)=>{let o=qC(Object.entries(t).map(([,n])=>n).filter(VC));return o&&!!o[e]?.experimental},"isExperimentalChain");function ps(t,e){return new an(t).shiftedBy(-e).toFixed()}i(ps,"representAmountInNumber");function pi(t){if(!t)return null;let e=ps(t.amount,t.decimals),o=t.usdValue?ps(t.usdValue,t.decimals):null,n=_(e,8,8),r=o?_(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(pi,"formatBalance");function Au(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new an(t.usdValue).shiftedBy(-t.decimals):pe,n=e&&e.usdValue?new an(e.usdValue).shiftedBy(-e.decimals):pe;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new an(t.amount).shiftedBy(-t.decimals):pe,n=e&&e.amount?new an(e.amount).shiftedBy(-e.decimals):pe;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Au,"compareTokenBalance");function qt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(qt,"areTokensEqual");function Nu(t){return t.sort((e,o)=>+(o.state===lt.CONNECTED)-+(e.state===lt.CONNECTED)||+(o.state===lt.PARTIALLY_CONNECTED)-+(e.state===lt.PARTIALLY_CONNECTED)||+(o.state===lt.DISCONNECTED||o.state===lt.CONNECTING)-+(e.state===lt.DISCONNECTED||e.state===lt.CONNECTING))}i(Nu,"sortWalletsBasedOnConnectionState");function lo(t,e=8,o=3){if(t.length<2*e+o)return t;let n=t.slice(0,e),r=t.slice(-e);return`${n}${".".repeat(o)}${r}`}i(lo,"getConciseAddress");function Bu({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Bu,"getAddress");var Wu=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Mu(t){return t.map(e=>e.state).join("-")}i(Mu,"hashWalletsState");function Lu(t,e){let o=new Set;return t.forEach(r=>{r.blockchainTypes.forEach(a=>{o.add(a)})}),e.filter(r=>o.has(r.type))}i(Lu,"filterBlockchainsByWalletTypes");function Pu(t,e){return e===zC.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(ri(n,e))return!0;return!1})}i(Pu,"filterWalletsByCategory");function jC(t,e){if(!t.isHub||!t.needsNamespace||!e.connected)return!1;let n=t.needsNamespace.data.filter(r=>!r.unsupported);return t.needsNamespace.selection==="multiple"&&n.some(r=>!e.namespaces?.get(r.value)?.connected)}i(jC,"checkIsWalletPartiallyConnected");var ds={API_KEY:eu()};function Gt(t){return ds[t]||""}i(Gt,"getConfig");function _u(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ds=e,ds}i(_u,"initConfig");var Du=20,$u=25,ms="theme-widget",fs=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>qt(n,t));else if(!Array.isArray(e)){let n=e[t.blockchain];if(n){o=!!n.tokens.some(a=>qt(a,t));let r=n.isExcluded;return!r&&!o||r&&o}}}return o},"isTokenExcludedInConfig"),gs=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Fu=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var ui,ct=i(()=>ui||(ui=new XC(Gt("API_KEY"),Gt("BASE_URL")),ui),"httpService");import{i18n as Uu}from"@lingui/core";var di=[.5,1,3],mi=1,sn=5,Yn=30,fi=0;var Xe=(a=>(a[a.NO_RESULT=0]="NO_RESULT",a[a.REQUEST_FAILED=1]="REQUEST_FAILED",a[a.REQUEST_CANCELED=2]="REQUEST_CANCELED",a[a.BRIDGE_LIMIT=3]="BRIDGE_LIMIT",a[a.INSUFFICIENT_SLIPPAGE=4]="INSUFFICIENT_SLIPPAGE",a))(Xe||{});import{WidgetEvents as Ou}from"@rango-dev/queue-manager-rango-preset";var hs=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(hs||{}),ys=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(ys||{}),Ss=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(Ss||{}),ln=(a=>(a[a.RouteEvent=Ou.RouteEvent]="RouteEvent",a[a.StepEvent=Ou.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(ln||{});function gi(t,e){let o=t.map(a=>a.swapperGroup),n=[];return rn(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(c=>c.swapperGroup===a);if(s){let c=!0;o&&(c=o.some(l=>l===s.swapperGroup)),c&&s.types.map(l=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:l,selected:!e.includes(s.swapperGroup)})})}}),n}i(gi,"getUniqueSwappersGroups");function zu(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(zu,"sortLiquiditySourcesByGroupTitle");function et(t,e){return e?.[t]==="hidden"}i(et,"isFeatureHidden");function cn(t,e){return e?.[t]==="enabled"}i(cn,"isRoutingEnabled");var Hu=i((t,e,o)=>et("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");function pn(t){return t==fi?{type:"error",message:Uu.t("Slippage must be greater than or equal to 0.01")}:t>sn&&t<=Yn?{type:"warning",message:Uu.t("Your transaction is at risk of being frontrun due to high slippage tolerance."),quoteValidation:{type:3,slippage:t.toString()}}:null}i(pn,"getSlippageValidation");var Qu=i((t,e)=>({_blockchainsMapByName:new Map,_tokensMapByTokenHash:new Map,_tokensMapByBlockchainName:{},_popularTokens:[],_swappers:[],fetchStatus:"loading",blockchains:o=>{let n=e()._blockchainsMapByName,r=Array.from(n?.values()||[]);if(!o||!o?.type)return r;let a=e().config;if(o.type==="custom-token"){let l=ei({config:a}),p=r;return l.length>0&&(p=p.filter(u=>l.includes(u.name))),p.filter(u=>Zp.includes(u.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(l=>!(s.length>0&&!s.includes(l.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),c=Array.from(n.values()),l=e()._blockchainsMapByName;if(!o||!o.type)return c;let p=o.type==="source"?"from":"to",u=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",d=tn.get(u);d?.length||(d=qn({type:o.type,config:{blockchains:a[p]?.blockchains,tokens:a[p]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),tn.set(u,d)),d=Hu(d,s,a.features);let f=e().blockchains({type:o.type});return d.filter(g=>o.blockchain&&g.blockchain!==o.blockchain||!f.some(m=>m.name===g.blockchain)?!1:o.searchFor?!!(st(g.symbol,o.searchFor)||st(g.address||"",o.searchFor)||st(g.name||"",o.searchFor)):!0).sort((g,m)=>{let y=e().isTokenPinned(g,o.type),S=e().isTokenPinned(m,o.type);if(y!==S)return y?-1:1;if(o.getBalanceFor){let I=o.getBalanceFor(g),A=o.getBalanceFor(m),b=Au(I,A);if(b!==0)return b}let C=l.get(g.blockchain),k=l.get(m.blockchain),x=is(g,C),w=is(m,k);if(x!==w)return x?-1:1;if(g.isPopular!==m.isPopular)return g.isPopular?-1:1;if(o.searchFor){let I=pu(g,m,o.searchFor);if(I)return I}return g.isSecondaryCoin!==m.isSecondaryCoin?g.isSecondaryCoin?1:-1:C&&k?C.sort-k.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=St(o),s=n.get(a);return s||(s=r.find(c=>St(c)===a)),s},findNativeToken:o=>{let n=o.feeAssets[0];return e().findToken({blockchain:o.name,address:n.address,symbol:n.symbol})},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>qt(s,o)),swappers:()=>{let{config:o,campaignMode:n}=e(),r=n.liquiditySources?.length?n.liquiditySources:null,a=r??o.liquiditySources,s=r?!1:o.excludeLiquiditySources;return e()._swappers.filter(p=>{let u=a?.includes(p.swapperGroup);return s||!a||a.length===0?!u:u}).sort(zu)},fetch:async()=>{try{let{routing:o}=e().config,n=cn("enableCentralizedSwappers",o),r=await ct().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,c={},l=r.popularTokens,p=r.swappers.filter(d=>d.enabled);r.blockchains.sort((d,f)=>d.sort-f.sort).forEach(d=>{d.enabled&&a.set(d.name,d)}),r.tokens.forEach(d=>{let f=St(d);c[d.blockchain]||(c[d.blockchain]=[]),s.set(f,d),c[d.blockchain]?.push(f)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:c,_popularTokens:l,_swappers:p})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as YC,Catalonia as ZC,Chinese as qu,Denmark as JC,English as RC,Finland as eT,French as tT,German as oT,Greece as nT,Hungary as rT,India as iT,Indonesian as aT,Italian as sT,Japanese as lT,Korea as cT,Lithuania as pT,Malay as uT,Netherlands as dT,Pakistan as mT,Philippines as fT,Poland as gT,Portuguese as hT,Russian as yT,SaudiArabia as ST,Serbia as CT,Slovakia as TT,SouthAfrica as kT,Spanish as wT,Swahili as vT,Swedish as xT,Thai as bT,Turkish as ET,Ukrainian as IT,Vietnamese as AT}from"@rango-dev/ui";var Gu=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:kT},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:ST},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:YC},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:ZC},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:qu},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:qu},{title:"Danish",label:"Dansk",local:"da",SVGFlag:JC},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:dT},{title:"English",label:"English",local:"en",SVGFlag:RC},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:fT},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:eT},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:tT},{title:"German",label:"Deutsch",local:"de",SVGFlag:oT},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:nT},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:iT},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:rT},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:aT},{title:"Italian",label:"Italiana",local:"it",SVGFlag:sT},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:lT},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:cT},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:pT},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:uT},{title:"Polish",label:"Polski",local:"pl",SVGFlag:gT},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:hT},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:yT},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:CT},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:TT},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:wT},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:vT},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:xT},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:bT},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:ET},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:IT},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:mT},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:AT}],un="en";var Vu=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:mi,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],quoteTokensRate:"default",changeQuoteTokensRate:()=>t(o=>({quoteTokensRate:o.quoteTokensRate==="default"?"reversed":"default"})),addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,c)=>{let l=s===o,p=c<=9;return l&&p}))return;let a=n.filter(s=>!(s===o));t(()=>({preferredBlockchains:[o,...a]}))},setSlippage:o=>t(()=>({slippage:o})),setCustomSlippage:o=>t(()=>({customSlippage:o})),setAffiliateRef:o=>t(()=>({affiliateRef:o})),setAffiliatePercent:o=>t(()=>({affiliatePercent:o})),setAffiliateWallets:o=>t(()=>({affiliateWallets:o})),toggleAllLiquiditySources:(o,n)=>t(r=>{if(n)return{disabledLiquiditySources:[]};let a=rn(o.map(s=>s.swapperGroup));return a.length===r.disabledLiquiditySources.length?{disabledLiquiditySources:[]}:{disabledLiquiditySources:a}}),toggleInfiniteApprove:()=>t(o=>({infiniteApprove:!o.infiniteApprove})),toggleLiquiditySource:o=>t(n=>n.disabledLiquiditySources.includes(o)?{disabledLiquiditySources:n.disabledLiquiditySources.filter(r=>r!=o)}:{disabledLiquiditySources:n.disabledLiquiditySources.concat(o)}),setTheme:o=>t(()=>({theme:o})),setLanguage:o=>t(()=>({language:o})),updateSettings:o=>{let{features:n,theme:r}=o,a=et("theme",n),s=et("language",n),c=et("liquiditySource",n),l=r?.singleTheme,p=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...l&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||un},...c&&{disabledLiquiditySources:o.liquiditySources||[]},...p&&{language:o.language||un}})},setCustomToken:o=>{e().fetchCustomTokensBalances({tokens:[o],connectedWallets:e().connectedWallets}),t(n=>({_customTokens:[o,...n._customTokens]}))},deleteCustomToken:o=>t(n=>({_customTokens:n._customTokens.filter(r=>r.address!==o.address)})),customTokens:()=>{let o=e().config,n=e()._customTokens,r=ei({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import xs from"bignumber.js";import NT from"mitt";var ve=NT(),BT={on:ve.on,off:ve.off};var Ku=i(t=>(e,o,n)=>t(i((...a)=>{let[s,...c]=a;e(l=>({...typeof s=="function"?s(l):s,lastUpdatedAt:+new Date}),...c)},"modifedSet"),o,n),"keepLastUpdated");import ju from"bignumber.js";function Vt(t){return`${t.blockchain}${Bo}${t.address}${Bo}${t.symbol}`}i(Vt,"createAssetKey");function Xu(t,e){return`${Vt(e)}${Bo}${t}`}i(Xu,"createBalanceKey");function Zn(t){let[e,o,n]=t.split(Bo);return!e||!o||!n?null:{address:o==="null"?null:o,blockchain:e,symbol:n}}i(Zn,"extractAssetFromBalanceKey");function Ts(t,e,o){return e.balances?.forEach(n=>{let r=n.price??t.findToken(n.asset)?.usdPrice;t._aggregatedBalances[Vt(n.asset)]?.forEach(s=>{o[s]&&(o[s]={...o[s],usdValue:r?new ju(r??pe).multipliedBy(o[s].amount).toString():""})})}),o}i(Ts,"computeNextBalancesWithNewPrices");function ks(t,e){let o={};return t.balances?.forEach(n=>{let r=Xu(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,c=n.price??e().findToken(n.asset)?.usdPrice,l=c?new ju(c??pe).multipliedBy(a).toString():"",p={amount:a,decimals:s,usdValue:l};o[r]=p}),o}i(ks,"createBalanceStateForNewAccount");function ws(t,e){for(let o in e){let n=Zn(o);if(n){let r=Vt(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}}return t}i(ws,"updateAggregatedBalanceStateForNewAccount");function WT(t,e){let o=Zn(e);if(!o)return t;let n=Vt(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(WT,"removeBalanceFromAggregatedBalance");function vs(t,e,o){let n=t.connectedWallets.filter(l=>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=>Xu(d.address,{address:p.address,blockchain:d.chain,symbol:p.symbol})===l)?a=WT(a,l):s[l]&&(r[l]=s[l])}),{_balances:r,_aggregatedBalances:a}}i(vs,"computeNextStateAfterWalletBalanceRemoval");function MT(t,e){return e.find(o=>t.address===o.address&&t.chain===o.blockChain)}i(MT,"matchWalletDetailsWithConnectedWallet");var LT=mu(),Yu=Ku((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,lastUpdatedAt:+new Date,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>o.find(a=>Xn(a,r))?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:(o,n)=>{t(r=>({fetchingWallets:!1,connectedWallets:r.connectedWallets.map(a=>o.find(s=>Xn(s,a))?{...a,loading:!1,error:!1,explorerUrl:MT(a,n)?.explorerUrl||a.explorerUrl}:a)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>o.find(a=>Xn(a,r))?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:(o,n,r)=>{let a=e().connectedWallets,s=o.filter(c=>!a.some(l=>Xn(c,l)));if(s.length>0){let c=s.map(l=>{let p=!a.some(u=>u.chain===l.chain&&u.selected&&u.walletType!==l.walletType);return{address:l.address,chain:l.chain,isContractWallet:l.isContractWallet,explorerUrl:null,walletType:l.walletType,selected:p,namespace:n,derivationPath:r,loading:!1,error:!1}});t(l=>({connectedWallets:[...l.connectedWallets.filter(u=>!c.some(d=>d.walletType===u.walletType&&d.chain===u.chain)),...c]}))}},fetchCustomTokensBalances:async o=>{let{tokens:n,connectedWallets:r}=o,a=n.reduce((l,p)=>((l[p.blockchain]||=[]).push(p),l),{}),s=new Set,c=r.reduce((l,p)=>{let u=`${p.address}-${p.chain}`;return s.has(u)||(s.add(u),a[p.chain]&&(l[p.address]||(l[p.address]=[]),l[p.address]?.push(...a[p.chain]||[]))),l},{});Object.entries(c).forEach(async([l,p])=>{try{let{balances:u}=await ct().getMultipleTokenBalance({assets:p.map(({symbol:d,address:f,blockchain:h})=>({symbol:d,address:f,blockchain:h})),walletAddress:l});if(u){let d=e()._balances,f=e()._aggregatedBalances;u.forEach(h=>{if(parseFloat(h.amount.amount)===0)return;let g={blockChain:h.asset.blockchain,balances:[h],address:l},m={_aggregatedBalances:e()._aggregatedBalances,findToken:e().findToken};Ts(m,g,d);let y=ks(g,e);f=ws(f,y),d={...d,...y}}),t(h=>({_balances:{...h._balances,...d},_aggregatedBalances:f}))}}catch(u){console.error(u)}})},setWalletsAsSelected:o=>{let n=e().connectedWallets.map(r=>{let a=!!o.find(c=>c.chain===r.chain&&c.walletType!==r.walletType&&r.selected),s=!!o.find(c=>c.chain===r.chain&&c.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r});t({connectedWallets:n})},newWalletConnected:async(o,n,r)=>{let a=o[0];a&&(ve.emit("walletEvent",{type:"connect",payload:{walletType:a.walletType,accounts:o}}),e().addConnectedWallet(o,n,r),e().fetchBalances(o))},removeBalancesForWallet:(o,n)=>{let r={_balances:e()._balances,_aggregatedBalances:e()._aggregatedBalances,connectedWallets:e().connectedWallets},{_balances:a,_aggregatedBalances:s}=vs(r,o,n);t({_balances:a,_aggregatedBalances:s})},disconnectNamespaces:(o,n)=>{if(e().connectedWallets.find(a=>a.walletType===o)){e().removeBalancesForWallet(o,{namespaces:n}),e()._changeSelectedWalletIfNeededOnRemove(o,{namespaces:n});let a=e().connectedWallets.filter(s=>s.namespace?!(s.walletType===o&&n.includes(s.namespace)):!0);t({connectedWallets:a})}},disconnectWallet:o=>{let n=e().connectedWallets.find(r=>r.walletType===o);if(ve.emit("walletEvent",{type:"disconnect",payload:{walletType:o}}),n){e().removeBalancesForWallet(o),e()._changeSelectedWalletIfNeededOnRemove(o);let r=e().connectedWallets.filter(a=>a.walletType!==o);t({connectedWallets:r})}},_changeSelectedWalletIfNeededOnRemove:(o,n)=>{let r=e().connectedWallets;n?.namespaces&&n.namespaces.length>0&&(r=r.filter(s=>!!s.namespace&&n.namespaces?.includes(s.namespace)));let a=r.filter(s=>s.selected&&s.walletType===o).map(s=>s.chain);if(a.length>0){let s=e().connectedWallets.map(c=>a.includes(c.chain)?(a=a.filter(l=>l!==c.chain),{...c,selected:!0}):c);t({connectedWallets:s})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let{shouldFetchCustomTokens:r=!0,selectedCustomTokens:a}=n||{};await e().fetchMainTokensBalances(o),r&&e().fetchCustomTokensBalances({tokens:a??e().customTokens(),connectedWallets:o})},fetchMainTokensBalances:async(o,n)=>{if(o.length===0||!o[0])return;let r=o[0].walletType;e().setConnectedWalletAsRefetching(o);let a=o.map(l=>({address:l.address,blockchain:l.chain})),s;try{s=await ct().getWalletsDetails(a)}catch(l){e().setConnectedWalletHasError(o),console.error(`Request for fetching balances failed. cause: ${l}`);return}let c=s.wallets;if(c){let l=e()._balances,p=e()._aggregatedBalances;c.forEach(d=>{if(d.failed)return;let f={_balances:l,_aggregatedBalances:p,connectedWallets:e().connectedWallets,findToken:e().findToken};Ts(f,d,l);let{_balances:h,_aggregatedBalances:g}=vs(f,r,{chains:[d.blockChain]});if(p=g,l=h,!e().connectedWallets.find(y=>y.walletType===r&&y.address===d.address&&y.chain===d.blockChain))return;let m=ks(d,e);p=ws(p,m),l={...l,...m}}),t(d=>({_balances:{...d._balances,...l},_aggregatedBalances:p})),e().setConnectedWalletRetrievedData(o,c);let{retryOnFailedBalances:u=!0}=n||{};if(u){let d=c.filter(f=>f.failed).map(f=>({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 xs(u.amount),f=new xs(l.amount);d.isGreaterThan(f)&&(l=u)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,c)=>{let l=n[c],[,,,p]=c.split(Bo);return l&&p===o&&(s[c]=l),s},{})},getConnectedWalletsDetails:()=>LT(()=>e().connectedWallets.map(n=>{let r=e().getBalancesForWalletAddress(n.address),a=Object.keys(r);return{...n,balances:a.reduce((s,c)=>{let l=r[c],p=Zn(c);if(p&&p.blockchain===n.chain&&l){let u=e().findToken(p),d=l?.amount?new xs(l.amount).shiftedBy(-l.decimals):pe;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:l.amount,decimal:l.decimals,amount:d.toString(),isSupported:!!u,logo:u?.image||null,usdPrice:u?.usdPrice||null})}return s},[])}}),e().lastUpdatedAt)}));function Zu(t){return PT()(_T((...e)=>({...Yu(...e),...Qu(...e),...Vu(...e),...Xp(t,...e)}),{name:"user-settings",skipHydration:!0,partialize:e=>({_customTokens:e._customTokens,theme:e.theme,language:e.language,affiliatePercent:e.affiliatePercent,affiliateRef:e.affiliateRef,affiliateWallets:e.affiliateWallets,slippage:e.slippage,customSlippage:e.customSlippage,infiniteApprove:e.infiniteApprove,preferredBlockchains:e.preferredBlockchains,disabledLiquiditySources:e.disabledLiquiditySources,quoteTokensRate:e.quoteTokensRate}),version:1,migrate:(e,o)=>{let n=e;return o===0&&(n._customTokens=n._customTokens.map(r=>({...r,warning:!0}))),n}}))}i(Zu,"createAppStore");var Ju=$T(null);function T(){let t=FT(Ju);if(OT(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(T,"useAppStore");function Ru(t){let e=UT();return e.current||(e.current=Zu(t.config)),DT.createElement(Ju.Provider,{value:e.current},t.children)}i(Ru,"AppStoreProvider");function bt(t){let{chain:e}=t||{},{connectedWallets:o,getAvailableProviders:n}=T(),{state:r,getWalletInfo:a}=zT(),s=T().blockchains(),{handleDisconnect:c}=en(),l=Gp(n()),p=Eu(r,a,l,e);p=HT()?p.filter(m=>m.showOnMobile!==!1&&r(m.type).installed):p;let u=Nu(p),d=i(m=>!o.find(y=>y.walletType===m&&y.chain===e),"isExperimentalChainNotAdded"),f=qT(()=>{let m=p?.filter(y=>y.state===bs.CONNECTING)||[];for(let y of m)c(y)},[Mu(p)]);GT(()=>()=>{f()},[]);let h=i(m=>{let y=m.find(C=>C.type===Jn.DEFAULT);return!y||y.state===bs.NOT_INSTALLED?!1:m.filter(C=>C.state!=bs.NOT_INSTALLED&&![Jn.DEFAULT,Jn.WALLET_CONNECT_2,Jn.LEDGER].includes(C.type)&&a(C.type).supportedChains.filter(k=>k.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),g=i((m,y,S)=>ci(S,y)&&d(m)&&!QT.includes(m)||m==Jn.DEFAULT&&!h(p),"shouldExcludeWallet");return{list:u.filter(m=>!g(m.type,e??"",s)),terminateConnectingWallets:f}}i(bt,"useWalletList");import{Modal as XT}from"@rango-dev/ui";import YT from"react";import{create as jT}from"zustand";var ed="rango-widget";var Rn=class{constructor(e){this.state="not-initiated";this.events={};this.init=()=>{this.initEvents(),this.tryClaim()};this.forceClaim=()=>{if(!this.isClaimed()){let e={name:"force-claim",candidateId:this.tabId};this.channel.postMessage(e),setTimeout(()=>{this.isClaimed()||this.claim()},300)}};this.isClaimed=()=>this.state==="claimed";this.destroy=()=>{this.channel.removeEventListener("message",this.handleMessageEvent),document.removeEventListener("visibilitychange",this.handleVisibilityChange),document.removeEventListener("resume",this.handleResume)};this.handleMessageEvent=e=>{let o=e.data.name;switch(o){case"ping":this.claimedByCurrentTab(e.data.pingAt);break;case"pong":this.alreadyClaimedByAnotherTab();break;case"force-claim":this.forceRelease(e.data.candidateId);break;case"force-release":this.tabId===e.data.candidateId&&this.claim();break;default:throw new Error(`${o} is not supported.`)}};this.handleVisibilityChange=async()=>{document.visibilityState==="visible"&&await this.tryClaim()};this.handleResume=async()=>{this.isClaimed()&&(await this.tryClaim(),this.isClaimed()||this.events.onRelease?.())};this.channel=new BroadcastChannel(ed),this.tabId=Math.trunc(Math.random()*1e5),this.events=e}static{i(this,"TabManager")}initEvents(){this.channel.addEventListener("message",this.handleMessageEvent),document.addEventListener("visibilitychange",this.handleVisibilityChange),document.addEventListener("resume",this.handleResume)}claimedByCurrentTab(e){let o=this.lastTryClaim&&this.lastTryClaim<e;if(this.isClaimed()||o){let n={name:"pong"};this.channel.postMessage(n);return}}alreadyClaimedByAnotherTab(){this.resetLastCheck()}async tryClaim(){return this.setLastCheck(),new Promise(e=>{setTimeout(()=>{this.check(),e()},300)})}check(){this.state==="not-initiated"&&this.events.onInit?.(),this.lastTryClaim?(this.claim(),this.resetLastCheck()):this.state="not-claimed"}claim(){this.state="claimed",this.events.onClaim?.()}setLastCheck(){this.lastTryClaim=Date.now();let e={name:"ping",pingAt:this.lastTryClaim};this.channel.postMessage(e)}resetLastCheck(){this.lastTryClaim=void 0}forceRelease(e){if(this.isClaimed()){this.state="not-claimed",this.events.onRelease?.();let o={name:"force-release",candidateId:e};this.channel.postMessage(o)}}};var KT=i(t=>{let e=t;e.use={};for(let o of Object.keys(e.getState()))e.use[o]=()=>e(n=>n[o]);return e},"createSelectors"),co=KT;var ne=co(jT()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",showProfileBanner:!1,fetchingApiConfig:!1,showCompactTokenSelector:!1,activateCurrentTab:(o,n)=>{let{showActivateTabModal:r}=e();!r&&n?t({showActivateTabModal:!0}):(r||!n)&&o()},setShowActivateTabModal:o=>{t({showActivateTabModal:o})},setWatermark:o=>{t({watermark:o})},setShowProfileBanner:o=>{t({showProfileBanner:o})},setShowCompactTokenSelector:o=>{t({showCompactTokenSelector:o})}}))),Po=new Rn({onInit:()=>ne.setState({tabManagerInitiated:!0}),onClaim:()=>ne.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>ne.setState({isActiveTab:!1})});function ee(t){let{watermark:e}=ne();return YT.createElement(XT,{hasWatermark:e==="FULL",...t},t.children)}i(ee,"WatermarkedModal");import{i18n as fn}from"@lingui/core";import{Alert as pk,Button as uk,Divider as gn,Image as dk,MessageBox as mk,RadioRoot as fk,WalletImageContainer as gk}from"@rango-dev/ui";import le,{useEffect as hk,useMemo as yk,useState as Sk}from"react";import{i18n as ek}from"@lingui/core";import{Typography as ld}from"@rango-dev/ui";import dn from"react";function hi(t,e){return t.find(o=>o.name===e)?.logo}i(hi,"getBlockchainLogo");import{darkTheme as ZT,Image as JT,styled as Kt,Typography as RT}from"@rango-dev/ui";var yi=Kt("li",{backgroundColor:"$neutral200",padding:"$16",borderRadius:"$sm",variants:{clickable:{true:{cursor:"pointer"}},hasError:{true:{background:"$error100",[`.${ZT} &`]:{backgroundColor:"$error700"}}},unsupported:{true:{cursor:"not-allowed",paddingTop:"$8",paddingBottom:"$8"}}}}),Si=Kt("div",{display:"flex",gap:"$8",alignItems:"center"}),od=Kt("div",{flex:"1",display:"flex",flexDirection:"column",justifyContent:"space-between",height:"$40",variants:{showSupportedChains:{true:{justifyContent:"space-between"},false:{justifyContent:"center"}}}}),nd=Kt("div",{flex:"1",display:"flex",alignItems:"center",gap:"$4",opacity:"0.5"}),rd=Kt("div",{display:"flex",gap:"$6",alignItems:"center"}),id=Kt("div",{paddingLeft:"48px"}),ad=Kt("div",{display:"flex",gap:"$2",cursor:"pointer",alignItems:"center",width:"fit-content"}),sd=Kt(RT,{maxWidth:"100px"}),Ci=Kt(JT,{variants:{disabled:{true:{opacity:"0.5"}}}});function Ti(t){let{namespace:e}=t,o=T().blockchains();return dn.createElement(yi,{unsupported:!0},dn.createElement(Si,null,dn.createElement(Ci,{src:hi(o,e.id),size:40,disabled:!0}),dn.createElement(nd,null,dn.createElement(ld,{variant:"label",size:"large"},e.label),dn.createElement(ld,{variant:"body",size:"xsmall"},ek.t("(Currently not supported)")))))}i(Ti,"NamespaceUnsupportedItem");import{Checkbox as sk,Radio as lk}from"@rango-dev/ui";import Ns from"react";import{i18n as As}from"@lingui/core";import{ChevronDownIcon as ok,ChevronUpIcon as nk,Divider as rk,Typography as er}from"@rango-dev/ui";import Ae,{useEffect as ik,useState as ak}from"react";import{Image as pd,Tooltip as ud,Typography as tk}from"@rango-dev/ui";import _t from"react";import{styled as cd}from"@rango-dev/ui";var Es=cd("div",{display:"flex",alignItems:"center",padding:0,margin:0}),ki=cd("div",{marginLeft:"-5px",listStyleType:"none",backgroundColor:"$background",borderRadius:"$lg",minWidth:"15px",height:"15px",variants:{firstItem:{true:{marginLeft:0}}},display:"flex",alignItems:"center",justifyContent:"center"});var Is=3;function dd(t){let{chains:e}=t;return _t.createElement(Es,{id:"widget-supported-chains-container"},e.slice(0,Is).map((o,n)=>_t.createElement(ud,{key:o.name,container:B(),side:"bottom",align:"start",content:o.name,sideOffset:4},_t.createElement(ki,{firstItem:n===0},_t.createElement(pd,{src:o.logo,size:15})))),e.length>Is&&_t.createElement(ud,{container:B(),side:"bottom",align:"start",sideOffset:4,content:_t.createElement(Es,null,e.map((o,n)=>_t.createElement(ki,{key:o.name,firstItem:n===0},_t.createElement(pd,{src:o.logo,size:15}))))},_t.createElement(ki,null,_t.createElement(tk,{variant:"body",size:"xsmall"},"+",e.length-Is))))}i(dd,"SupportedChainsList");function _o(t){let{namespace:e,error:o,suffix:n,connected:r,address:a,onClick:s}=t,[c,l]=ak(!1),p=T().blockchains();ik(()=>l(!1),[o]);let u=e.getSupportedChains(p),d=!o&&!r&&u.length>1;return Ae.createElement(yi,{hasError:!!o,clickable:!!s,onClick:s},Ae.createElement(Si,null,Ae.createElement(Ci,{src:hi(p,e.id),size:40}),Ae.createElement(od,{showSupportedChains:d||r||!!o},Ae.createElement(rd,null,Ae.createElement(er,{variant:"label",size:"large"},e.label),r&&Ae.createElement(er,{variant:"body",size:"small",color:"success500"},As.t("Connected")),!!o&&Ae.createElement(er,{variant:"body",size:"small",color:"error500"},As.t("Connection failed"))),d&&Ae.createElement(dd,{chains:u}),r&&Ae.createElement(sd,{variant:"body",size:"small",color:"neutral700"},a),o&&Ae.createElement(ad,{onClick:()=>l(f=>!f)},Ae.createElement(er,{variant:"body",size:"small",color:"neutral700",style:{textDecoration:"underline",userSelect:"none",textDecorationSkipInk:"none"}},As.t("See why")),c?Ae.createElement(nk,{size:12,color:"gray"}):Ae.createElement(ok,{size:12,color:"gray"}))),n),!!o&&c&&Ae.createElement(Ae.Fragment,null,Ae.createElement(rk,{size:4}),Ae.createElement(id,null,Ae.createElement(er,{variant:"body",size:"small",color:"neutral700"},o))))}i(_o,"NamespaceItem");function md(t){let{onClick:e,type:o,namespace:n}=t;return Ns.createElement(_o,{namespace:n,onClick:e,suffix:o==="radio"?Ns.createElement(lk,{value:n.value}):Ns.createElement(sk,{checked:t.value})})}i(md,"NamespaceListItem");import{Button as ck,styled as fd}from"@rango-dev/ui";var wi=fd("ul",{padding:0,paddingBottom:"$20",margin:0}),mn=fd(ck,{minHeight:"$40"});function tr(t){let{targetWallet:e}=t.value,o=e.properties?.find(m=>m.name==="namespaces"),n=e.isHub,r=e.isHub?o?.value.selection==="single":e.needsNamespace?.selection==="single",a=n?o?.value:e.needsNamespace,s=e.image,c=T().blockchains(),[l,p]=Sk([]),u=yk(()=>a?.data.filter(m=>!m.unsupported),[e?.type]),d=i(m=>{p(r?[m]:y=>y.includes(m)?y.filter(S=>S!==m):y.concat(m))},"onSelect"),f=u?.length===l.length,h=i(()=>{if(r)throw new Error("onSelectAll should not be called on single selection mode.");f?p([]):u&&p(u.map(m=>m.value))},"onSelectAll"),g=i(m=>r?le.createElement(fk,{value:l?.[0]},m):le.createElement(le.Fragment,null,m),"wrapRadioRoot");return hk(()=>{if(!r&&u)if(t.value.defaultSelectedChains?.length){let m=u.filter(y=>y.getSupportedChains(c).some(S=>t.value.defaultSelectedChains?.includes(S.name)));p(m.map(y=>y.value))}else p(u.map(m=>m.value))},[]),le.createElement(le.Fragment,null,le.createElement(mk,{type:"info",title:fn.t("Connect {wallet}",{wallet:e.title}),description:fn.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect."),icon:le.createElement(gk,null,le.createElement(dk,{src:s,size:45}))}),r?le.createElement(le.Fragment,null,le.createElement(gn,{size:20,className:"_initial_namespace_list_header_alert_top_divider"}),le.createElement(pk,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:fn.t("This wallet can only connect to one chain at a time. ")}),le.createElement(gn,{size:30,className:"_initial_namespace_list_header_alert_bottom_divider"})):le.createElement(le.Fragment,null,le.createElement(gn,{size:30,className:"_initial_namespace_list_header_button_top_divider"}),le.createElement(uk,{style:{marginLeft:"auto"},id:"widget-name-space-select-all-btn",size:"xsmall",variant:"ghost",type:"primary",onClick:h},f?fn.t("Deselect all"):fn.t("Select all")),le.createElement(gn,{size:10,className:"_initial_namespace_list_header_button_bottom_divider"})),le.createElement(wi,null,g(le.createElement(le.Fragment,null,a?.data.map((m,y,S)=>le.createElement(le.Fragment,{key:m.id},m.unsupported?le.createElement(Ti,{namespace:m}):le.createElement(md,{value:l.includes(m.value),namespace:m,type:r?"radio":"checkbox",onClick:()=>d(m.value)}),y!==S.length-1&&le.createElement(gn,{size:10})))))),le.createElement(gn,{size:20}),le.createElement(mn,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!l.length,onClick:()=>t.onConfirm(l)},fn.t("Connect")))}i(tr,"Namespaces");import{i18n as or}from"@lingui/core";import{Alert as bk,Button as Ek,Divider as hn,Image as Ik,MessageBox as Ak,WalletImageContainer as Nk}from"@rango-dev/ui";import{useWallets as Bk}from"@rango-dev/wallets-react";import de from"react";import{styled as Ck}from"@rango-dev/ui";var gd=Ck("div",{display:"flex",justifyContent:"end"});import{i18n as Bs}from"@lingui/core";import{Button as Tk,Spinner as kk}from"@rango-dev/ui";import Ws,{useLayoutEffect as wk,useRef as vk,useState as xk}from"react";function hd(t){let{namespace:e,initialConnect:o,disabled:n,state:r,handleConnect:a,handleDisconnect:s}=t,[c,l]=xk(null),p=vk(!1);wk(()=>{o&&!p.current&&u()},[]);let u=i(async g=>{try{p.current=!0,await a(g)}catch(m){l(m)}finally{p.current=!1}},"handleConnectNamespace"),d=i(async()=>{l(null),r.connected?await s():u({shouldAskForDerivationPath:!0})},"handleButtonClick"),f=i(()=>{let g=r.accounts?.[0]?.split(":"),m=g?.[g.length-1];return!r.connected||!m?null:lo(m)},"getConnectedAddress"),h=i(()=>r.connected?Bs.t("Disconnect"):c?Bs.t("Try again"):Bs.t("Connect"),"getButtonText");return Ws.createElement(_o,{namespace:e,connected:r.connected,error:c?.message,address:f(),suffix:r.connecting?Ws.createElement(kk,{color:"info"}):Ws.createElement(Tk,{id:"widget-name-space-connect-btn",variant:"ghost",type:r.connected?"error":"primary",size:"xsmall",onClick:async()=>d(),disabled:n},h())})}i(hd,"NamespaceDetachedItem");function nr(t){let{value:e,selectedNamespaces:o,onConfirm:n,confirmText:r=or.t("Done"),onDisconnectWallet:a,navigateToDerivationPath:s}=t,{targetWallet:c}=e,{connect:l,disconnect:p,state:u}=Bk(),d=c.type,f=u(d),h=c.properties?.find(x=>x.name==="namespaces"),g=c.properties?.find(x=>x.name==="derivationPath"),m=h?.value.selection==="single",y=i(async(x,w)=>{m&&await p(d),g&&w?.shouldAskForDerivationPath?s(x):await l(d,[{namespace:x,network:"",derivationPath:w?.derivationPath??void 0}])},"handleConnectNamespace"),S=i(async x=>{await p(d,[x])},"handleDisconnectNamespace"),C=i(()=>m?de.createElement(de.Fragment,null,de.createElement(hn,{size:20,className:"_detached_namespace_list_header_alert_top_divider"}),de.createElement(bk,{id:"widget-wallet-stateful-connect-alert",variant:"alarm",type:"info",title:or.t("This wallet can only connect to one chain at a time.")}),de.createElement(hn,{size:30,className:"_detached_namespace_list_header_alert_bottom_divider"})):de.createElement(de.Fragment,null,de.createElement(hn,{size:30,className:"_detached_namespace_list_header_button_top_divider"}),de.createElement(gd,null,de.createElement(Ek,{id:"widget-detached-disconnect-wallet-btn",variant:"ghost",type:"error",size:"xsmall",disabled:f.connecting||!f.connected,onClick:a},or.t("Disconnect wallet"))),de.createElement(hn,{size:16,className:"_detached_namespace_list_header_button_bottom_divider"})),"renderNamespaceListHeader"),k=i(x=>{if(x.unsupported)return de.createElement(Ti,{namespace:x});let w=o?.find(b=>b.namespace===x.value),I=f.namespaces?.get(x.value);if(!I)throw new Error(`State for ${x.value} was not found!`);let A=m&&f.connecting;return de.createElement(hd,{namespace:x,initialConnect:!!w,disabled:A,state:I,handleConnect:async b=>y(x.value,{derivationPath:w?.derivationPath,shouldAskForDerivationPath:b?.shouldAskForDerivationPath}),handleDisconnect:async()=>S(x.value)})},"renderNamespaceItem");return de.createElement(de.Fragment,null,de.createElement(Ak,{type:"info",title:or.t("Connect {wallet}",{wallet:c.type}),description:or.t("This wallet supports multiple chains. Choose which chains you\u2019d like to connect or disconnect."),icon:de.createElement(Nk,null,de.createElement(Ik,{src:c.image,size:45}))}),C(),de.createElement(wi,{id:"widget-detached-namespace-list"},c.needsNamespace?.data.map((x,w,I)=>de.createElement(de.Fragment,{key:x.id},k(x),w!==I.length-1&&de.createElement(hn,{size:10})))),de.createElement(hn,{size:20}),de.createElement(mn,{id:"widget-name-space-confirm-btn",type:"primary",onClick:n},r))}i(nr,"Detached");import{i18n as yn}from"@lingui/core";import{Divider as Pk,Image as _k,MessageBox as Dk,Select as $k,TextField as Fk}from"@rango-dev/ui";import Et,{useEffect as Ok,useState as Sd}from"react";import{namespaces as Wk}from"@rango-dev/wallets-shared";var vi={id:"custom",label:"Custom",generateDerivationPath:t=>t};function Ms(t){let e=t?Wk[t]?.derivationPaths:null;return e?[...e,vi]:[]}i(Ms,"getDerivationPaths");import{Button as Mk,styled as Ls,Typography as Lk}from"@rango-dev/ui";var yd=Ls("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Ps=Ls(Lk,{paddingLeft:"$10"}),_s={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"},u_=Ls(Mk,{minHeight:"$40"});var Cd="0";function rr(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=Sd(null),[c,l]=Sd(Cd),p=a===vi.id,u=Ms(o),d=i(({value:h})=>{let g=u?.find(m=>m.id===h);g&&(a===vi.id&&Number.isNaN(Number(c))&&l(Cd),s(g.id))},"handleDerivationPathItemClick"),f=i(()=>{let h=u.find(g=>g.id===a);if(h)e(h.generateDerivationPath(c));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return Ok(()=>{s(Ms(o)[0]?.id||null)},[o]),Et.createElement(Et.Fragment,null,Et.createElement(Dk,{type:"info",title:yn.t("Select Derivation Path"),description:yn.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Et.createElement(_k,{src:n,size:45})}),Et.createElement(yd,{className:"_derivation_path_inputs_container"},Et.createElement(Ps,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},yn.t("Choose Derivation Path Template")),Et.createElement($k,{id:"widget-derivation-path-template-select",value:a||"",options:u.map(h=>({value:h.id,label:h.label})),variant:"filled",handleItemClick:d,styles:{trigger:_s}}),Et.createElement(Pk,{size:20}),Et.createElement(Ps,{variant:"body",size:"xsmall",color:"$neutral600",className:"_derivation_path_input_label"},p?yn.t("Enter Path"):yn.t("Enter Index")),Et.createElement(Fk,{id:"widget-derivation-path-template-input",type:p?"text":"number",variant:"contained",value:c,onChange:h=>l(h.target.value),style:_s})),Et.createElement(mn,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:f,disabled:!u||!a||!c},yn.t("Confirm")))}i(rr,"DerivationPath");import{i18n as Sn}from"@lingui/core";import{Image as Hk,MessageBox as $s,WalletImageContainer as Qk,WalletState as qk}from"@rango-dev/ui";import{useWallets as Gk}from"@rango-dev/wallets-react";import Do from"react";import{keyframes as Uk,styled as Ds}from"@rango-dev/ui";var w_=Ds("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Td=Ds("div",{position:"relative"}),zk=Uk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),kd=Ds("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${zk} 1s linear infinite`,top:0,bottom:0,right:0,left:0});function Fs(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a,getWalletInfo:s}=Gk();return Kn(s(n),a(n))===qk.CONNECTED?Do.createElement($s,{type:"success",title:Sn.t("Wallet Connected"),description:Sn.t("Your wallet is connected, you can use it to swap.")}):o?Do.createElement($s,{type:"error",title:Sn.t("Failed to Connect"),description:o||Sn.t("Your wallet is not connected. Please try again.")}):Do.createElement($s,{type:"loading",title:Sn.t("Connecting to your wallet"),description:Sn.t("Click connect in your wallet popup."),icon:Do.createElement(Td,null,Do.createElement(Qk,null,Do.createElement(Hk,{src:r,size:45})),Do.createElement(kd,null))})}i(Fs,"ConnectStatus");import{i18n as Os}from"@lingui/core";import{Button as Vk,Divider as wd,MessageBox as Kk}from"@rango-dev/ui";import xi from"react";function Us(t){let{displayName:e,onConfirm:o,id:n}=t;return xi.createElement(Kk,{id:n,title:Os.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:Os.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},xi.createElement(wd,{size:18}),xi.createElement(wd,{size:32}),xi.createElement(Vk,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},Os.t("Confirm")))}i(Us,"ExperimentalChain");function vd(t,e){return t().status==="init"&&!!e}i(vd,"isOnStatus");function ir(t){return t().status==="namespace"}i(ir,"isOnNamespace");function ar(t){return t().status==="derivationPath"}i(ar,"isOnDerivationPath");function Ao(t){return t().status==="detached"}i(Ao,"isOnDetached");var Zk=3e3,Jk=300;function sr(t){let e=Yk(),[o,n]=xd(!1),[r,a]=xd(),s=i(w=>{a(w.message)},"catchErrorOnHandle"),{terminateConnectingWallets:c}=bt(),{handleConnect:l,handleDerivationPath:p,handleNamespace:u,getState:d,resetState:f,handleDisconnect:h}=en(),g=i(w=>{u(t.wallet,w).then(k).catch(s)},"handleConfirmNamespaces"),m=i(()=>{S()},"handleDetachedConfirm"),y=i(w=>{if(!w)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");p(t.wallet,w).then(k).catch(s)},"handleDerivationPathConfirm"),S=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),f(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState"),k=i((w,I)=>{let A=w.status==="connected",b=["disconnected","disconnected-unhandled"].includes(w.status);A?(t.onConnect?.(),I||(e.current=setTimeout(S,Zk))):b&&S()},"afterConnected"),x=i(w=>{t.wallet?.needsDerivationPath&&u(t.wallet,[w])},"handleNavigateToDerivationPath");return Xk(()=>{if(t.wallet){C();let w=!1,I=!0;i(()=>{setTimeout(()=>{I=!1,w||n(!0)},Jk)},"beforeConnecting")(),l(t.wallet,{disconnectIfConnected:!0,defaultSelectedChains:t.options?.defaultSelectedChains}).then(b=>{["namespace","Detached","derivation-path"].includes(b.status)||(w=!0),k(b,I)}).catch(s)}},[t.wallet]),po.createElement(ee,{id:t.id,open:o,onClose:S,onExit:()=>{C(),c(),t.onClose&&t.onClose()},container:B()},vd(d,t.wallet)&&po.createElement(po.Fragment,null,po.createElement(Fs,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),po.createElement(jk,{direction:"vertical",size:32})),ir(d)&&po.createElement(tr,{onConfirm:g,value:d().namespace}),ar(d)&&po.createElement(rr,{onConfirm:y,value:d().derivationPath}),Ao(d)&&po.createElement(nr,{onConfirm:m,onDisconnectWallet:()=>void h(d().namespace.targetWallet),value:d().namespace,selectedNamespaces:d().selectedNamespaces,navigateToDerivationPath:x}))}i(sr,"StatefulConnectModal");import Ra from"react";import Rk,{Fragment as ew}from"react";import{MemoryRouter as tw,useInRouterContext as ow}from"react-router";function bi({children:t}){let o=ow()?ew:tw;return Rk.createElement(o,null,t)}i(bi,"AppRouter");import{I18nManager as nB}from"@rango-dev/ui";import Lp from"react";import Ue from"react";import{useRoutes as _0}from"react-router-dom";var $={home:"/",fromSwap:"from-swap",toSwap:"to-swap",blockchains:"blockchains",settings:"settings",customTokens:"custom-tokens",addCustomTokens:"add-custom-tokens",liquiditySources:"liquidity-sources",bridges:"bridges",exchanges:"exchanges",languages:"languages",swaps:"swaps",wallets:"wallets",confirmSwap:"confirm-swap",swapDetails:":requestId",routes:"routes"};import{useEffect as Tn,useRef as Mi}from"react";import ot from"bignumber.js";import{create as nm}from"zustand";import{subscribeWithSelector as rm}from"zustand/middleware";import{createContext as nw,useContext as rw}from"react";var bd=nw({swapMode:"swap",isMultiMode:!1});function tt(){let{swapMode:t,isMultiMode:e}=rw(bd);return{swapMode:t,isMultiMode:e}}i(tt,"useSwapMode");import{i18n as Tt}from"@lingui/core";import{getRelatedWalletOrNull as sw,RouteEventType as OD}from"@rango-dev/queue-manager-rango-preset";import He from"bignumber.js";import{PendingSwapNetworkStatus as cr}from"rango-types";import{i18n as ze}from"@lingui/core";var re=i(()=>({genericServerError:ze.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:ze.t("Please reset your liquidity sources."),description:ze.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:ze.t("No Routes Found."),description:ze.t("Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination.")},bridgeLimitErrors:{increaseAmount:ze.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:ze.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:ze.t("High Price Impact"),title:ze.t("Price impact is too high!"),description:ze.t("The price impact is significantly higher than the allowed amount."),confirmMessage:ze.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:ze.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:ze.t("USD Price Unknown"),title:ze.t("USD Price Unknown, Cannot calculate Price Impact."),description:ze.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:ze.t("Confirm USD Price Unknown")}}),"errorMessages");function Ed(t){return t.type===0?t.diagnosisMessage??re().noResultError.title:t.type===1?t.diagnosisMessage??re().genericServerError:""}i(Ed,"getQuoteErrorMessage");import{i18n as Ei}from"@lingui/core";var $o=i(()=>({connectWallet:Ei.t("Connect Wallet"),swap:Ei.t("Swap"),swapAnyway:Ei.t("Swap anyway"),ethWarning:Ei.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function zs(t,e){return{"Network Fee":e("Network Fee"),"Swapper Fee":e("Protocol Fee"),"Affiliate Fee":e("Affiliate Fee"),"Outbound network fee":e("Outbound Fee"),"Rango Fee":e("Rango Fee")}[t]}i(zs,"getFeeLabel");var Hs=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Id=100,Ad=30,Nd=15,Bd=60;var Wd=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],Md=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as aw}from"@rango-dev/queue-manager-rango-preset";import bD from"bignumber.js";function Pd(t,e){if(e===null)return null;let o=e?.find(n=>n.blockchain===t.chain)?.wallets.find(n=>n.address?.toLowerCase()===t.address.toLowerCase());return o?o.requiredAssets:null}i(Pd,"getRequiredBalanceOfWallet");function Xt(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(Xt,"getPriceImpactLevel");function Ii(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=aw(t.steps);if(!r||!n)return{fromBlockchain:null,fromToken:void 0,toBlockchain:null,toToken:void 0,inputAmount:""};let s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},c=No(a?a.toBlockchain:n.fromBlockchain,e),l=No(r.toBlockchain,e),p=o(a?{blockchain:c?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:c?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),u=o(s),d=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:c,fromToken:p,toBlockchain:l,toToken:u,inputAmount:d}}i(Ii,"createRetryQuote");function Cn(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=lr(o),s=Ct(o);if(o&&a&&s){let p=jt(a.toString(),s.toString());if(!!p&&Od(a,p)){let d=Ni(o?.swaps,n),f=Xt(p);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:p,totalFee:d,warningLevel:f}}}if(e&&Hd(e,o))return{type:4,usdValueChange:_(Ct(o)?.minus(Ct(e)??0).toString()??"0",null,2),percentageChange:_(jt(Ct(e)??"1",Ct(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let c=Bi(o.swaps),l=r>sn;if(zd(t.userSlippage.toString(),c)){if(l&&parseFloat(c??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:Ud(o,r),minRequiredSlippage:c};return null}i(Cn,"generateQuoteWarnings");function _d(t){return![4].includes(t.type)}i(_d,"isQuoteWarningConfirmationRequired");function jt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Qs(t.toString(),e.toString());return n&&n<0?n:null}i(jt,"getPriceImpact");var Dd=i(t=>{let e=new Set,o=[];return t.forEach(n=>{e.has(n.from.chain.displayName)||(e.add(n.from.chain.displayName),o.push(n.from.chain)),e.has(n.to.chain.displayName)||(e.add(n.to.chain.displayName),o.push(n.to.chain))}),o},"getUniqueBlockchains"),Ai=i((t,e)=>e.sort((o,n)=>{let r=i(p=>p.scores?.find(u=>u.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let c=o.requestId.toLowerCase(),l=n.requestId.toLowerCase();return c.localeCompare(l)}),"sortQuotesBy"),$d=i((t,e,o)=>{let n=e[0];if(!e.length||!n)return null;if(!t)return{requestAmount:o,validationStatus:null,...n};let r=new Set(t.swaps.map(s=>s.swapperId)),a=e.find(s=>{let c=new Set(s.swaps.map(l=>l.swapperId));return Array.from(r).every(l=>c.has(l))});return{requestAmount:o,validationStatus:null,...a||n}},"getDefaultQuote"),Fd=i(t=>{let e=i((o,n)=>{let r=Hs.indexOf(o.value),a=Hs.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function Od(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Wd.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new He(r)))}i(Od,"hasHighValueLoss");function Qd(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new He(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new He(e.fromAmountMaxValue):null;return e.fromAmountRestrictionType==="EXCLUSIVE"?o?.gte(e.fromAmount)||n?.lte(e.fromAmount):o?.gt(e.fromAmount)||n?.lt(e.fromAmount)}).length>0}i(Qd,"hasLimitError");function qd(t){let e=(t||[]).filter(c=>{let l=c.fromAmountMinValue?new He(c.fromAmountMinValue):null,p=c.fromAmountMaxValue?new He(c.fromAmountMaxValue):null;return c.fromAmountRestrictionType==="EXCLUSIVE"?l?.gte(c.fromAmount)||p?.lte(c.fromAmount):l?.gt(c.fromAmount)||p?.lt(c.fromAmount)})[0];if(!e)return{swap:void 0,fromAmountRangeError:"",recommendation:""};let o=e.fromAmountMinValue?new He(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new He(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=Tt.t({id:"Required: >= {min} {symbol}",values:{min:_(o,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=Tt.t({id:"Required: > {min} {symbol}",values:{min:_(o,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=Tt.t({id:"Required: <= {max} {symbol}",values:{max:_(n,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=Tt.t({id:"Required: < {max} {symbol}",values:{max:_(n,6,6),symbol:e.from.symbol}}),s=re().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(qd,"getLimitErrorMessage");function Gd(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:c,needsToWarnEthOnPath:l}=t;return e!=="success"?{title:$o().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||c||!r||r==="0"?{title:$o().swap,action:"confirm-swap",disabled:!0}:s?{title:$o().swapAnyway,action:"confirm-warning",disabled:!1}:l?{title:$o().ethWarning,action:"confirm-warning",disabled:!1}:{title:$o().swap,action:"confirm-swap",disabled:!1}:{title:$o().connectWallet,action:"connect-wallet",disabled:!1}}i(Gd,"getSwapButtonState");function qs(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(pe))&&e&&e!=="0"&&n!==0)}i(qs,"canComputePriceImpact");function Gs(t,e){let o=pe;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(!r||r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new He(r.amount).multipliedBy(a||0))}return o}i(Gs,"getUsdFeeOfStep");function Ni(t,e){return t.reduce((o,n)=>o.plus(Gs(n,e)),pe)}i(Ni,"getTotalFeeInUsd");function Vs(t){let e=pe,o=new He(t.price||0);return e=e.plus(new He(t.amount).multipliedBy(o)),e}i(Vs,"getUsdFee");function Vd(t){return t.reduce((e,o)=>e.plus(Vs(o)),pe)}i(Vd,"getTotalFeesInUsd");function Kd(t){return t.reduce((e,o)=>{for(let n of o.fee){let r=n.name,a=n.expenseType!=="DECREASE_FROM_OUTPUT"?e.payable:e.nonePayable;a[r]=[...a[r]||[],n]}return e},{payable:{},nonePayable:{}})}i(Kd,"getFeesGroup");function jd(t){let e=new Map;return t.forEach((o,n)=>{o.recommendedSlippage?.error&&e.set(n,o.recommendedSlippage.slippage)}),e.size>0?Object.fromEntries(e):null}i(jd,"checkSlippageErrors");function Ud(t,e){let o=new Map;return t?.swaps.forEach((n,r)=>{n.recommendedSlippage?.slippage&&parseFloat(n.recommendedSlippage.slippage)>e&&o.set(r,n.recommendedSlippage.slippage)}),o.size>0?Object.fromEntries(o):null}i(Ud,"checkSlippageWarnings");function Bi(t){return t.map(o=>o.recommendedSlippage)?.map(o=>o?.slippage||"0")?.filter(o=>parseFloat(o)>0)?.sort((o,n)=>parseFloat(n)-parseFloat(o))?.find(()=>!0)||null}i(Bi,"getMinRequiredSlippage");function zd(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(zd,"hasProperSlippage");function Xd(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:c,excludeLiquiditySources:l,slippage:p,affiliateRef:u,affiliatePercent:d,affiliateWallets:f,destination:h,contractCall:g}=t,m=a?.reduce((C,k)=>(C[k.chain]=k.address,C),{}),y=[];return r?.forEach(C=>{y.push({blockchain:C.chain,addresses:[C.address]})}),{amount:n.toString(),affiliateRef:u??void 0,affiliatePercent:d??void 0,affiliateWallets:f??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:y,selectedWallets:m??{},slippage:p.toString(),contractCall:g,...h&&{destination:h},...l&&{swapperGroups:s.concat(c??[]),swappersGroupsExclude:!0},...!l&&{swapperGroups:c?.filter(C=>!s.includes(C)),swappersGroupsExclude:!1}}}i(Xd,"createQuoteRequestBody");function Yd(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType,derivationPath:n.derivationPath},o),{})}i(Yd,"getWalletsForNewSwap");function lr(t){let e=t.requestAmount,o=t.swaps[0]?.from.usdPrice;if(!(!e||!o))return new He(e).multipliedBy(o)}i(lr,"getUsdInputFrom");function Ct(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1]?.to.usdPrice;if(!(!e||!o))return new He(e).multipliedBy(o)}i(Ct,"getUsdOutputFrom");function Qs(t,e){return new He(e).div(new He(t)).minus(1).multipliedBy(Id).toNumber()}i(Qs,"getPercentageChange");function Hd(t,e){let o=lr(t),n=Ct(t),r=Ct(e);if(!o||!n||!r)return!1;let a=Qs(n.toString(),r.toString());return Md.some(({threshold:s,minInput:c})=>a<=s&&o.isGreaterThanOrEqualTo(c))}i(Hd,"isOutputAmountChangedExcessively");function Zd(t,e,o){let n=t.validationStatus,r=Mo({filter:"required",quote:t});return e.sort((s,c)=>r.indexOf(s.chain)-r.indexOf(c.chain)).flatMap(s=>Pd(s,n)||[]).filter(s=>!s.ok).map(s=>{let c=s.asset.symbol,l=_(new He(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),p=_(new He(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),u="";return s.reason==="FEE"&&(u=Tt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(u=Tt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(u=Tt.t(" for input and network fee")),Tt.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:p,symbol:c,reason:u,currentAmount:l,blockchain:yt(s.asset.blockchain,o)}})})}i(Zd,"generateBalanceWarnings");function pr(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==cr.NetworkChanged}i(pr,"isNetworkStatusInWarningState");function Jd(t,e,o){let n="bellow button or",r=t.extraMessage,a=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(n)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(n,"")),pr(e)){r=t.networkStatusExtraMessage||"",a=t.networkStatusExtraMessageDetail||"";let p=(e?sw(t,e):null)?.walletType,u=p?o?.(p)?.name:null;switch(e?.networkStatus){case cr.WaitingForConnectingWallet:r=u?Tt.t("Connect {wallet}",{wallet:u}):r;break;case cr.WaitingForQueue:r=r||Tt.t("Waiting for other running tasks to be finished");break;case cr.WaitingForNetworkChange:r=r||Tt.t("Waiting for changing wallet network");break;case cr.NetworkChangeFailed:r=r||Tt.t("The network switch could not be completed. Please try again, or switch the network manually in your wallet.");break;default:r=r||"";break}}a=a||"",r=r||"";let c=r?.indexOf("code")!==-1&&r?.indexOf("reason")!==-1;return{shortMessage:r,detailedMessage:{content:a,long:c}}}i(Jd,"getSwapMessages");function Rd(t){let e=null;if(t.status==="failed"){let o=t.steps.slice().reverse().filter(n=>n.status==="success")[0];o&&(e={blockchain:o.toBlockchain,symbol:o.toSymbol,outputAmount:o.outputAmount,address:o.toSymbolAddress})}return e}i(Rd,"getLastConvertedTokenInFailedSwap");function em(t){return t.status==="failed"}i(em,"shouldRetrySwap");function tm(t,e,o,n,r,a){if(!n||t)return!0;let s=Mo({filter:"all",quote:n}),c=Mo({filter:"required",quote:n}),l=s.every(d=>r.some(f=>f.chain===d)),p=c.every(d=>r.some(f=>f.chain===d)),u=o&&a?on(a,o):!1;return!e&&!l||e&&!o||e&&!!o&&(!u||!p)}i(tm,"isConfirmSwapDisabled");function om(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(om,"isTokensIdentical");var Wi=i((t,e)=>t?.usdPrice?new ot(e||pe).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),im=i(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new ot(0),outputUsdValue:new ot(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=pe,a=o.inputUsdValue;return Vn(o.inputAmount)?(e&&(n=e?.outputAmount?new ot(e?.outputAmount):null,a=lr(e)??pe,r=Ct(e)??pe),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new ot(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new ot(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new ot(0)}})},setFromToken:e=>t(o=>({fromToken:e.token,...e.token&&{fromBlockchain:e.meta.blockchains.find(n=>n.name===e.token.blockchain)??null},...!!o.inputAmount&&{inputUsdValue:Wi(e.token,o.inputAmount)}})),setToBlockchain:e=>{t(o=>o.toBlockchain?.name===e?.name?{}:{toBlockchain:e,...o.toToken&&{selectedQuote:null,toToken:null,outputAmount:null,outputUsdValue:new ot(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),sanitizeInputAmount:e=>{let o=xu(e);t(()=>({inputAmount:o}))},setInputAmount:e=>{let o=Tu(e);ii(e)||(o=gu(o),o=hu(o)),t(n=>({inputAmount:o,...!o&&{outputAmount:null,outputUsdValue:new ot(0),selectedQuote:null},...!!n.fromToken&&{inputUsdValue:Wi(n.fromToken,o)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:Wi(n??null,s),outputUsdValue:new ot(0),toBlockchain:r,toToken:a,selectedQuote:null})},switchFromAndTo:()=>t(e=>({fromBlockchain:e.toBlockchain,fromToken:e.toToken,toBlockchain:e.fromBlockchain,toToken:e.fromToken,inputAmount:e.outputAmount?.toString()||"",inputUsdValue:e.toToken?Wi(e.toToken,e.outputAmount?.toString()||""):new ot(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new ot(0),inputUsdValue:new ot(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new ot(0),selectedQuote:null})),setQuoteWalletConfirmed:e=>t({quoteWalletsConfirmed:e}),setSelectedWallets:e=>t({selectedWallets:e}),setCustomDestination:e=>t({customDestination:e}),resetQuoteWallets:()=>t({quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null}),setQuoteWarningsConfirmed:e=>t({quoteWarningsConfirmed:e})}),"initializer"),am=nm()(rm(im)),sm=nm()(rm(im)),lw=co(am),cw=co(sm);function H(){let{swapMode:t}=tt();return co(t==="refuel"?sm:am)}i(H,"useQuoteStore");var lm=i((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&ve.emit("quoteEvent",{type:"quoteInputUpdate",payload:{fromBlockchain:t.fromBlockchain?.name,toBlockchain:t.toBlockchain?.name,fromToken:t.fromToken?{symbol:t.fromToken.symbol,name:t.fromToken.name,address:t.fromToken.address}:void 0,toToken:t.toToken?{symbol:t.toToken.symbol,name:t.toToken.name,address:t.toToken.address}:void 0,requestAmount:t.inputAmount}}),t.selectedQuote?.requestId!==e.selectedQuote?.requestId&&ve.emit("quoteEvent",{type:"quoteOutputUpdate",payload:t.selectedQuote?{requestAmount:t.selectedQuote.requestAmount,swaps:t.selectedQuote.swaps,outputAmount:t.selectedQuote.outputAmount,resultType:t.selectedQuote.resultType,tags:t.selectedQuote.tags}:null})},"subscribeCallback"),cm=lw.subscribe(lm),pm=cw.subscribe(lm);function um(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:c,fromBlockchain:l,toBlockchain:p}=H()(),u=T().config,d=T().fetchStatus,f=T().blockchains(),{findToken:h}=T(),{setAffiliateRef:g,setAffiliatePercent:m,setAffiliateWallets:y}=T(),S=u?.from?.tokens,C=u?.from?.blockchains,k=u?.to?.tokens,x=u?.to?.blockchains,w=Mi(void 0),I=Mi(void 0),A=Mi(void 0),b=Mi(void 0);Tn(()=>{typeof u.amount<"u"&&t(u.amount.toString())},[u?.amount]),Tn(()=>{if(d==="success"){r();let E=f.find(M=>M.name===u?.from?.blockchain),v=u?.from?.token,N=v&&h(v);(E||!E&&A.current)&&n(E??null),N?a({token:N,meta:{blockchains:f}}):!N&&w.current&&a({token:null}),A.current=u?.from?.blockchain,w.current=u?.from?.token}},[u?.from?.token?.symbol,u?.from?.token?.address,u?.from?.token?.blockchain,u?.from?.blockchain,d]),Tn(()=>{fs(s,S)&&a({token:null}),gs(l,C)&&n(null)},[S,C]),Tn(()=>{fs(c,k)&&a({token:null}),gs(p,x)&&o(null)},[k,x]),Tn(()=>{if(d==="success"){r();let E=f.find(M=>M.name===u?.to?.blockchain),v=u?.to?.token,N=v&&h(v);(E||!E&&b.current)&&o(E??null),N?e({token:N,meta:{blockchains:f}}):!N&&I.current&&e({token:null}),b.current=u?.to?.blockchain,I.current=u?.to?.token}},[u?.to?.token?.symbol,u?.to?.token?.address,u?.to?.token?.blockchain,u?.to?.blockchain,d]),Tn(()=>{g(u?.affiliate?.ref??null),m(u?.affiliate?.percent??null),y(u?.affiliate?.wallets??null)},[u?.affiliate?.ref,u?.affiliate?.percent,u?.affiliate?.wallets])}i(um,"useSyncStoresWithConfig");import{useEffect as Xs,useRef as pw}from"react";import{useInRouterContext as uw,useLocation as dw,useSearchParams as mw}from"react-router-dom";function Ks(t,e){let o=t.split("--");return o[0]?{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}:null}i(Ks,"convertTokenSearchParamToAsset");function js(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(js,"tokenToSearchParam");function Zs(){let t=dw(),[e,o]=mw(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:c,setFromBlockchain:l,setToBlockchain:p,setFromToken:u,setToToken:d,setInputAmount:f}=H()(),h=T().fetchStatus,g=T().blockchains(),m=uw(),{updateIframe:y,updateCampaignMode:S}=T(),C=T().isInCampaignMode(),k=pw(),{findToken:x}=T(),w=i(()=>{let A={};for(let[W,J]of e.entries())(W.startsWith("utm_")||W.startsWith("privy_"))&&(A[W]=J);let b=e.get("fromAmount"),E=e.get("fromBlockchain"),v=e.get("fromToken"),N=e.get("toBlockchain"),M=e.get("toToken"),P=e.get("autoConnect"),U=e.get("clientUrl"),Q=e.get("liquiditySources"),Z=e.get("blockchain");return{fromAmount:b,fromBlockchain:E,fromToken:v,toBlockchain:N,toToken:M,autoConnect:P,clientUrl:U,liquiditySources:Q,extraQueryParams:A,blockchain:Z}},"getUrlSearchParams"),I=i(A=>{for(let b in A)A[b]||delete A[b];o(A,{replace:!0})},"updateUrlSearchParams");Xs(()=>{let{autoConnect:A,clientUrl:b,extraQueryParams:E,blockchain:v}=w();m&&h==="success"&&I({fromBlockchain:n?.name,fromToken:js(a),toBlockchain:r?.name,toToken:js(s),fromAmount:c,autoConnect:A??void 0,clientUrl:b??void 0,blockchain:v??void 0,liquiditySources:C?k.current:void 0,...E})},[t.pathname,c,n,a,r,s,C,h]),Xs(()=>{if(!m)return;let A=w();if(!k.current&&A.liquiditySources&&(k.current=A.liquiditySources),A.fromAmount&&f(A.fromAmount),h==="success"){let b=g.find(U=>U.name===A.fromBlockchain),E=A.fromToken&&b&&Ks(A.fromToken,b),v=E?x(E):void 0,N=g.find(U=>U.name===A.toBlockchain),M=A.toToken&&N&&Ks(A.toToken,N),P=M?x(M):void 0;b&&(l(b),v&&u({token:v,meta:{blockchains:g}})),N&&(p(N),P&&d({token:P,meta:{blockchains:g}}))}},[h]),Xs(()=>{let{clientUrl:A,liquiditySources:b}=w();y("clientUrl",A||void 0),S("liquiditySources",b?.split(",")??void 0)},[])}i(Zs,"useSyncUrlAndStore");import{i18n as vn}from"@lingui/core";import{Alert as Pv,Button as _v,darkTheme as Dv,Divider as Il,DoneIcon as $v,styled as Fv,TextField as Ov,Typography as Uv}from"@rango-dev/ui";import qe,{useState as zv}from"react";import{useNavigate as Hv,useSearchParams as Qv}from"react-router-dom";import{ChevronRightIcon as fw,Divider as hm,Image as gw,Typography as ym}from"@rango-dev/ui";import It from"react";import{darkTheme as dm,styled as Js}from"@rango-dev/ui";var mm=Js("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${dm} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${dm} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),fm=Js("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),gm=Js("div",{display:"flex"});function Rs(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return It.createElement(fm,null,It.createElement(ym,{size:"large",variant:"label"},n),It.createElement(hm,{size:10}),It.createElement(mm,{onClick:s?void 0:e,disabled:s,id:"widget-blockchain-selector-container"},It.createElement(gm,null,r&&It.createElement(It.Fragment,null,It.createElement(gw,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),It.createElement(hm,{size:4,direction:"horizontal"})),It.createElement(ym,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),It.createElement(fw,{size:12,color:"black"})))}i(Rs,"BlockchainSelectorButton");import{i18n as nl}from"@lingui/core";import{Button as vw,Divider as vm,MessageBox as xw}from"@rango-dev/ui";import uo,{useEffect as xm,useState as rl}from"react";import{i18n as Li}from"@lingui/core";import{Divider as Fo,ExternalLinkIcon as Sw,Image as Cw,InfoIcon as Tw,Tooltip as kw,Typography as dr}from"@rango-dev/ui";import me from"react";var Sm="https://blog.rango.exchange/understanding-the-risks-of-using-custom-token-contract-addresses-96022308eca4";function Cm(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(Cm,"generateExplorerLink");import{Button as hw,darkTheme as kn,styled as ur,Typography as yw}from"@rango-dev/ui";var el=ur("a",{textDecoration:"none",color:"$colors$neutral700",[`.${kn} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${kn} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${kn} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${kn} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),Tm=ur("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${kn} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${kn} &`]:{color:"$colors$neutral900"}}}),tl=ur(hw,{minHeight:"$40"}),km=ur(yw,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"96px"}),wm=ur("div",{display:"flex",justifyContent:"center",alignItems:"center"});var ww=9;function ol(t){let{open:e,onClose:o,token:n,onExit:r,onSubmitClick:a,blockchain:s}=t,c=Cm(n.address,s),l=i(()=>window.open(Sm,"_blank"),"onClickLearnMore");return me.createElement(ee,{open:e,id:"widget-custom-token-watermarked-modal",dismissible:!0,onClose:o,onExit:r,container:B()},me.createElement(Tm,null,me.createElement(Cw,{src:n.image===""?ti:n.image,size:45,type:"circular"}),me.createElement(Fo,{size:4}),me.createElement(wm,null,me.createElement(km,{variant:"title",size:"medium"},n.symbol),n.symbol.length>ww&&me.createElement(kw,{content:n.symbol,container:B()},me.createElement(Tw,{size:12,color:"gray"}))),me.createElement(dr,{variant:"body",size:"small",className:"_blockchain-name"},s.displayName),me.createElement(Fo,{size:4}),me.createElement(dr,{variant:"body",size:"medium"},c?me.createElement(el,{hasHover:!0,href:c,target:"_blank",rel:"nofollow noreferrer"},n.address,me.createElement(Sw,{size:12,color:"gray"})):me.createElement(el,null,n.address)),me.createElement(Fo,{size:4}),n.coinSource&&me.createElement(dr,{className:"_coin-source",variant:"body",size:"xsmall"},Li.t("via")," ",me.createElement(dr,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),me.createElement(Fo,{size:"32"}),me.createElement(dr,{size:"medium",variant:"body",className:"_custom-token-description"},Li.t("This token is not part of our verified token list. please verify its source and make sure to understand all associated risks before proceeding."))),me.createElement(Fo,{size:40}),me.createElement(Fo,{size:10}),me.createElement(tl,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:a},Li.t("Import Anyway")),me.createElement(Fo,{size:10}),me.createElement(tl,{id:"widget-custom-token-modal-learn-more-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:l},Li.t("Learn More")))}i(ol,"CustomTokenModal");function mr(t){let{token:e,blockchain:o,error:n,address:r,fetchCustomToken:a,onCloseErrorModal:s,onImport:c,onExitErrorModal:l,onExitImportModal:p}=t,{setCustomToken:u}=T(),[d,f]=rl(!1),[h,g]=rl(!1),[m,y]=rl(!1),S=i(()=>{o&&a?.({blockchain:o.name,tokenAddress:r})},"getCustomToken"),C=i(()=>{n?.type!=="network-error"&&s?.(),f(!1)},"closeErrorModal"),k=i(()=>{y(!0),C()},"handleErrorModalButtonClick"),x=i(()=>{m&&n?.type==="network-error"&&(y(!1),S()),l()},"handleExit"),w=i(()=>{e&&(u(e),c())},"handleSubmit");return xm(()=>{n&&f(!0)},[n]),xm(()=>{o&&e&&g(!0)},[o,e]),uo.createElement(uo.Fragment,null,uo.createElement(ee,{open:d,dismissible:!0,id:"widget-add-custom-token-modal",onClose:C,onExit:x,container:B()},uo.createElement(xw,{title:n?.title??"",type:"error",description:n?.message||nl.t("Failed Network, Please retry.")},uo.createElement(vm,{size:40}),uo.createElement(vm,{size:10}),uo.createElement(vw,{id:`widget-add-custom-token-${n?.type==="network-error"?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:k},n?.type==="network-error"?nl.t("Retry"):nl.t("Add another custom token")))),o&&e&&uo.createElement(ol,{blockchain:o,token:e,onSubmitClick:w,onClose:()=>g(!1),open:h,onExit:p}))}i(mr,"ImportCustomToken");import{useManager as Av}from"@rango-dev/queue-manager-react";import{BottomLogo as Nv,Divider as rf,Header as Bv}from"@rango-dev/ui";import Be,{useEffect as Qi,useLayoutEffect as Wv,useRef as af,useState as sf}from"react";import{useRef as bw}from"react";function Pi(){return window.self!==window.top}i(Pi,"isAppLoadedIntoIframe");function il(){let t=bw(null),{iframe:e}=T(),o=Pi()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(c=>{for(let l of c)n({type:"widget_height",data:{height:l.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(il,"useIframe");import{useNavigate as Ew}from"react-router-dom";function Qe(){let t=Ew();return()=>t(-1)}i(Qe,"useNavigateBack");import{createTheme as dl,darkTheme as Ow,lightTheme as Uw}from"@rango-dev/ui";import{useEffect as zw,useState as Hw}from"react";import{theme as $w,darkColors as Fw}from"@rango-dev/ui";import pl from"react";var _i=16,Di=255,bm=.11;function Iw(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(Iw,"expandShortHexColor");function Aw(t,e){return t.padStart(e,"0")}i(Aw,"pad");function al(t){let e=Math.min(Math.max(Math.round(t),0),Di);return Aw(e.toString(_i),2)}i(al,"intToHex");function Nw(t){return`#${al(t.red)}${al(t.green)}${al(t.blue)}`}i(Nw,"rgbToHex");function Bw(t){let e=parseInt(t.slice(1,3),_i),o=parseInt(t.slice(3,5),_i),n=parseInt(t.slice(5,7),_i);return{red:e,green:o,blue:n}}i(Bw,"hexToRGB");function Ww(t,e){let o=1-bm*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(Ww,"generateShade");function Mw(t,e){let o=bm*e;return{red:t.red+(Di-t.red)*o,green:t.green+(Di-t.green)*o,blue:t.blue+(Di-t.blue)*o}}i(Mw,"generateTint");function Lw(t){return Em(t,Ww)}i(Lw,"calculateShades");function Pw(t){return Em(t,Mw)}i(Pw,"calculateTints");function Em(t,e){let o=Bw(t),n=[];for(let r=1;r<9;r++)n.push(Nw(e(o,r)));return n}i(Em,"calculateColors");function sl(t,e,o){let a=Pw(t).reverse().concat(t),s=Lw(t),c=a.concat(s),l={},p=c.length;for(let u=0;u<p;u++){let d=100+(o?p-1-u:u)*50,f=c[u];f&&(l[`${e}${d}`]=f)}return l}i(sl,"createTintsAndShades");function ll(t,e,o){let n={...t};for(let r in e){let a=e[r],s=r==="neutral"&&!!o?.reverseNeutralRange;if(!["background","foreground"].includes(r)&&!wu(r)){let l=Iw(a);Object.assign(n,sl(l,r,s))}}return{...n,...e}}i(ll,"expandToGenerateThemeColors");var Im=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),_w=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=Im(o%52)+e;return Im(o%52)+e},"toAlphabeticName"),Dw=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),cl=i(t=>_w(Dw(5381,JSON.stringify(t))>>>0),"toHash");function ul(t){let e=$w.colors,o={...e,...Fw},n,r;if(t?.light){let s={colors:ll(e,t.light)};n={id:`${ms}-light-${cl(s)}`,tokens:s}}if(t?.dark){let s={colors:ll(o,t.dark,{reverseNeutralRange:!0})};r={id:`${ms}-dark-${cl(s)}`,tokens:s}}return{light:n,dark:r}}i(ul,"customizedThemeTokens");function Am(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>pl.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(pl.cloneElement(a,{key:s})),r<t.length-1){let c=`divider-${r}`;o.push(pl.cloneElement(e,{key:c}))}}),o}i(Am,"joinList");function Nm(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Nm,"doesWindowPreferDarkColorScheme");function mo(t){let{colors:e,fontFamily:o=ru,borderRadius:n=Du,secondaryBorderRadius:r=$u}=t,[a,s]=Hw(Nm()?"dark":"light"),{theme:c}=T(),{dark:l,light:p}=ul(e),u=dl({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),d=[u.className,Uw.className],f=[u.className,Ow.className];if(p){let g=dl(p.id,p.tokens);d.push(g.className)}if(l){let g=dl(l.id,l.tokens);f.push(g.className)}return zw(()=>{let g=i(m=>{m.matches?s("dark"):s("light")},"switchThemeListener");return Nm()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",g),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",g)}},[]),{activeTheme:i(()=>{let g=d.join(" "),m=f.join(" ");return c==="auto"?a==="dark"?m:g:c==="dark"?m:g},"getActiveTheme"),mode:c==="auto"?a:c}}i(mo,"useTheme");var kt=i(t=>{let e=[];return t?.getAll().forEach((o,n)=>{let r=o.list.getStorage();r?.swapDetails&&e.push({id:n,swap:r?.swapDetails})}),e.sort((o,n)=>Number(n.swap.creationTime)-Number(o.swap.creationTime))},"getPendingSwaps");import{i18n as Bm}from"@lingui/core";import{Alert as Qw,Button as qw}from"@rango-dev/ui";import Wm from"react";function ml(t){return Wm.createElement(Qw,{action:Wm.createElement(qw,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Bm.t("Activate this tab")),type:"warning",variant:"alarm",title:Bm.t("Another tab is open and handles transactions.")})}i(ml,"ActivateTabAlert");import{i18n as fl}from"@lingui/core";import{Button as Gw,Divider as Vw,MessageBox as Kw}from"@rango-dev/ui";import $i from"react";function gl(t){let{open:e,onClose:o,onConfirm:n}=t;return $i.createElement(ee,{open:e,dismissible:!0,onClose:o,id:"widget-active-tab-modal",container:B()},$i.createElement(Kw,{title:fl.t("Activate current tab"),type:"warning",description:fl.t("Currently, some transactions are running and being handled by other browser tab. If you activate this tab, all transactions that are already in the transaction sign step will expire.")},$i.createElement(Vw,{size:20}),$i.createElement(Gw,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},fl.t("Confirm"))))}i(gl,"ActivateTabModal");import{ChevronLeftIcon as Yw}from"@rango-dev/ui";import Om from"react";import{css as jw,darkTheme as Mm,IconButton as Xw,styled as Oo}from"@rango-dev/ui";var Dt=Oo(Xw,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${Mm} &`]:{backgroundColor:"$neutral"}}}),Lm=Oo("div",{position:"absolute",background:"$secondary500",[`.${Mm} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),fo=Oo("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),Pm=Oo("div",{position:"absolute",width:"14px",height:"14px",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"7px",top:"$0",right:"$0",variants:{isSever:{true:{backgroundColor:"$error500"},false:{backgroundColor:"$secondary500"}}}}),_m=Oo("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),Dm=Oo("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),$m=jw({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Fm=Oo("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});function hl(t){return Om.createElement(Dt,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Om.createElement(Yw,{color:"black",size:16}))}i(hl,"BackButton");import{i18n as Zw}from"@lingui/core";import{Button as Jw,Typography as Rw}from"@rango-dev/ui";import yl from"react";function Sl(t){return yl.createElement(fo,null,yl.createElement(Jw,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},yl.createElement(Rw,{variant:"label",size:"medium",color:"error500"},Zw.t("Cancel"))))}i(Sl,"CancelButton");import{i18n as ev}from"@lingui/core";import{Image as tv,Tooltip as ov,WalletIcon as nv,WalletState as Um}from"@rango-dev/ui";import Uo from"react";function Cl(t){let{list:e}=bt(),o=e.filter(r=>r.state===Um.CONNECTED||r.state===Um.PARTIALLY_CONNECTED),n=o.length?Uo.createElement("div",{className:$m()},o.map(r=>Uo.createElement(Fm,{key:r.title},Uo.createElement(tv,{src:r.image,size:14})))):ev.t("Connect Wallet");return Uo.createElement(ov,{container:t.container,side:"bottom",content:n},Uo.createElement(Dt,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&Uo.createElement(Lm,null),Uo.createElement(nv,{size:18,color:"black"})))}i(Cl,"WalletButton");import{i18n as Oi}from"@lingui/core";import{NotificationsIcon as Cv,Popover as Tv,SettingsIcon as kv,Tooltip as Ui,TransactionIcon as wv}from"@rango-dev/ui";import Le from"react";import{Notifications as sv}from"@rango-dev/ui";import lv from"react";import{useNavigate as cv}from"react-router-dom";import{create as rv}from"zustand";import{persist as iv,subscribeWithSelector as av}from"zustand/middleware";var Ne=co(rv()(iv(av((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1];if(!r||!a)return;let s={event:o,creationTime:Date.now(),requestId:n.requestId,route:{creationTime:parseInt(n.creationTime),from:{blockchain:r.fromBlockchain,address:r.fromSymbolAddress,symbol:r.fromSymbol},to:{blockchain:a.toBlockchain,address:a.toSymbolAddress,symbol:a.toSymbol}}},c=e().notifications.filter(l=>l.requestId!==n.requestId);t(()=>({notifications:[...c,s]}))},removeNotification:o=>{t(n=>({notifications:n.notifications.filter(r=>r.requestId!==o)}))},getNotifications:()=>{let{isSynced:o,notifications:n}=e();return o?n.sort((r,a)=>r.route.creationTime&&!a.route.creationTime?-1:!r.route.creationTime&&a.route.creationTime?1:!r.route.creationTime&&!a.route.creationTime?a.creationTime-r.creationTime:a.route.creationTime-r.route.creationTime):[]},syncNotifications:o=>{let{isSynced:n,notifications:r}=e();if(!n){let a=[];r.forEach(s=>{o.some(l=>l.swap.requestId===s.requestId)&&a.push(s)}),t({isSynced:!0,notifications:a})}},clearNotifications:()=>t({notifications:[]})})),{name:"notification",skipHydration:!0,partialize:({isSynced:t,...e})=>e,version:1,migrate:(t,e)=>{if(e===0){let o=t.notifications;t.notifications=o.filter(n=>!n.read).map(({read:n,...r})=>r)}return t}})));function Tl(){let t=cv(),{getNotifications:e,clearNotifications:o}=Ne(),n=e(),r=T().blockchains(),{findToken:a}=T();return lv.createElement(sv,{id:"widget-notifications-container",list:n,getBlockchainImage:c=>Vp(c,r),getTokenImage:c=>a(c)?.image,onClickItem:i(c=>{t(`${$.swaps}/${c}`)},"onClickItem"),onClearAll:o})}i(Tl,"NotificationContent");import{useManager as pv}from"@rango-dev/queue-manager-react";import{InProgressIcon as uv}from"@rango-dev/ui";import zm from"react";var dv=i(()=>{let{manager:t}=pv();return kt(t).map(({swap:o})=>o).find(o=>o.status==="running")?zm.createElement(Dm,{id:"widget-header-history-badge-container"},zm.createElement(uv,{color:"info",size:6})):null},"InProgressTransactionBadge"),Hm=dv;import{EventSeverity as mv}from"@rango-dev/queue-manager-rango-preset";import{Typography as fv}from"@rango-dev/ui";import Qm from"react";function qm(){let{getNotifications:t}=Ne(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===mv.WARNING);return o?Qm.createElement(Pm,{isSever:n},Qm.createElement(fv,{variant:"body",size:"xsmall",color:"$background",id:"widget-header-notifications-badge-container"},o)):null}i(qm,"NotificationsBadge");import{RefreshProgressButton as gv}from"@rango-dev/ui";import kl,{useEffect as hv,useState as Gm}from"react";var yv=1e3,Vm=60,Sv=100;function Fi({onClick:t}){let[e,o]=Gm(0),[n,r]=Gm(!1),a=i(l=>{document.hidden&&l&&s(l)},"handleVisibilityChange");hv(()=>{let l;return t?l=window.setInterval(()=>{o(p=>p+1),e===Vm&&c()},yv):s(l),document.addEventListener("visibilitychange",()=>a(l)),()=>{document.removeEventListener("visibilitychange",()=>a(l)),l&&clearInterval(l)}},[e,t]);let s=i(l=>{l&&clearInterval(l),o(0)},"clearTimeout"),c=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return kl.createElement(Dt,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:c,disabled:!t},kl.createElement(_m,{onTransitionEnd:()=>r(!1),isRefetched:n},kl.createElement(gv,{size:22,color:t?"black":"gray",progress:e/Vm*Sv})))}i(Fi,"RefreshButton");function zo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=T(),c=et("notification",s)||r.includes("notifications");return Le.createElement(Le.Fragment,null,!r.includes("refresh")&&Le.createElement(Ui,{container:a||B(),side:"top",content:Oi.t("Refresh")},Le.createElement(Fi,{onClick:e})),!c&&Le.createElement(Tv,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:B(),content:Le.createElement(Tl,null)},Le.createElement("div",null,Le.createElement(Ui,{container:B(),side:"top",content:Oi.t("Notifications")},Le.createElement(Dt,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},Le.createElement(Cv,{size:18,color:"black"}),Le.createElement(qm,null))))),!r.includes("settings")&&Le.createElement(Ui,{container:B(),side:"top",content:Oi.t("Settings")},Le.createElement(Dt,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},Le.createElement(kv,{size:18,color:"black"}))),!r.includes("history")&&Le.createElement(Ui,{container:B(),side:"top",content:Oi.t("History")},Le.createElement(Dt,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},Le.createElement(wv,{size:18,color:"black"}),Le.createElement(Hm,null))))}i(zo,"HeaderButtons");import{i18n as wl}from"@lingui/core";import{Divider as jm,MessageBox as bv,RefreshIcon as Ev}from"@rango-dev/ui";import wn from"react";import{Button as vv,styled as xv}from"@rango-dev/ui";var Km=xv(vv,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function vl(t){let{open:e,onClose:o}=t;return wn.createElement(ee,{open:e,dismissible:!0,onClose:o,id:"widget-refresh-modal",container:B()},wn.createElement(bv,{title:wl.t("Something went wrong"),type:"error",description:wl.t("Something went wrong. Please refresh the app.")},wn.createElement(jm,{size:30}),wn.createElement(Km,{variant:"outlined",id:"widget-refresh-modal-refresh-btn",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},wn.createElement(Ev,{size:20,color:"primary"}),wn.createElement(jm,{size:4,direction:"horizontal"}),wl.t("Refresh"))))}i(vl,"RefreshModal");var Xm="700px",Ym="425px",Zm="550px",Jm="640px",Rm="800px";function xl(t){let e=t.target;if(e){let o=e.scrollTop,n=B();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(xl,"onScrollContentAttachStatusToContainer");import{css as Iv,styled as zi}from"@rango-dev/ui";var Hi=Iv({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),ef=zi("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",maxHeight:Xm,variants:{height:{auto:{height:"auto"},fixed:{height:"100%",minHeight:Ym,[`@media screen and (min-height: ${Rm})`]:{minHeight:Zm}}},showBanner:{true:{overflow:"visible"}}}}),tf=zi("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),of=zi("div",{padding:"0 $20 $10","& .footer__alert":{paddingTop:"$10"},"& .footer__logo":{opacity:0,transition:"opacity 1s ease-in-out","&.logo__show":{opacity:1},"&.logo__hidden":{visibility:"hidden"}}}),nf=zi("div",{width:"100%",position:"absolute",bottom:"-$10",transform:"translateY(100%)",overflow:"hidden"});function se(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=il(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:c,connectedWallets:l,config:{__UNSTABLE_OR_INTERNAL__:p}}=T(),[u,d]=sf(!1),{config:{features:f,theme:h}}=T(),{watermark:g}=ne(),m=g==="FULL",{activeTheme:y}=mo(h||{}),[S,C]=sf(!1),k=et("connectWalletButton",f),{isActiveTab:x,tabManagerInitiated:w,showActivateTabModal:I,setShowActivateTabModal:A,activateCurrentTab:b,setShowCompactTokenSelector:E}=ne(),v=Qe(),{manager:N}=Av(),P=kt(N).map(({swap:X})=>X).some(X=>X.status==="running"),U=i(()=>b(Po.forceClaim,P),"onActivateTab"),Q=i(()=>{r.onWallet?.()},"onConnectWallet"),Z=typeof r.hasBackButton>"u"||r.hasBackButton,W=af(null),J=af(null);return Qi(()=>{let X=(p?.swapBoxBanner?.routes?.length??0)===0,ae=!!p?.swapBoxBanner?.routes?.some(Se=>location.pathname.endsWith(Se));C(!!p?.swapBoxBanner&&(X||ae))},[p?.swapBoxBanner?.routes?.toString(),location.pathname]),Qi(()=>(Pi()&&J.current&&e(J.current),()=>{o()}),[]),Qi(()=>(W.current?.addEventListener("scroll",xl),()=>{W.current?.removeEventListener("scroll",xl)}),[]),Qi(()=>{d(c==="failed")},[c]),Wv(()=>{if(!J.current)return;let X=new ResizeObserver(ae=>{for(let Se of ae)Se.contentRect&&E(Se.contentRect.height<parseInt(Jm))});return X.observe(J.current),()=>X.disconnect()},[]),Be.createElement(ef,{height:s,id:Re.SWAP_BOX_ID,className:`${y()} ${Hi()}`,ref:J,showBanner:S},Be.createElement(Bv,{prefix:Z?Be.createElement(hl,{onClick:()=>{v(),r.onBack?.()}}):null,title:r.title,suffix:Be.createElement(Be.Fragment,null,r.suffix,r.onWallet&&!k&&Be.createElement(Cl,{container:B(),onClick:Q,isConnected:!!l?.length}),r.onCancel&&Be.createElement(Sl,{onClick:r.onCancel}))}),Be.createElement(tf,{ref:W},n),Be.createElement(gl,{open:I,onClose:()=>A(!1),onConfirm:U}),Be.createElement(of,null,Be.createElement("div",{className:"footer__content"},w&&!x&&Be.createElement("div",{className:"footer__alert"},Be.createElement(ml,{onActivateTab:U}),Be.createElement(rf,{size:10})),a),Be.createElement(rf,{size:12}),Be.createElement("div",{className:`footer__logo ${m?"logo__show":"logo__hidden"}`},Be.createElement(Nv,null))),S&&Be.createElement(nf,null,p?.swapBoxBanner?.element),Be.createElement(vl,{open:u,onClose:()=>d(!1)}))}i(se,"Layout");import{styled as Mv}from"@rango-dev/ui";var lf="$20 $20 $10 $20",bl=Mv("div",{padding:lf,overflowY:"auto",flexGrow:1});import{styled as Lv}from"@rango-dev/ui";var ce=Lv("div",{display:"flex",flexDirection:"column",padding:"20px 20px 10px",flexGrow:1,variants:{view:{true:{flexGrow:1,overflow:"hidden"}},compact:{true:{padding:0}}}});import{i18n as go}from"@lingui/core";import{useState as El}from"react";function cf(){let[t,e]=El(!1),[o,n]=El(null),[r,a]=El(null),{findToken:s}=T(),c=T().customTokens(),l=i(()=>{a(null),e(!1),n(null)},"resetState");function p(d,f){switch(d){case"duplicated":return{type:d,title:go.t("Duplicate Token"),message:go.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{type:d,title:go.t("Token Already Exists"),message:go.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{type:d,title:go.t("Token Not Found"),message:go.t({id:"Sorry, no token was found on {blockchain} chain with the provided address. please make sure you have entered the right token address.",values:{blockchain:f}})};case"network-error":return{type:d,title:go.t("Network error"),message:go.t("An error occurred while retrieving token data.")}}}return i(p,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:d,tokenAddress:f})=>{e(!0);try{if(c.some(S=>S.address?.toLowerCase()===f.toLowerCase())){let S=p("duplicated");n(S);return}let g=await ct().getCustomToken({blockchain:d,address:f});if(!g||!g.token||g.error){let S=p("not-found",d);n(S);return}let m=g.token;if(s({blockchain:m.blockchain,address:m.address,symbol:m.symbol})){let S=p("token-exist");n(S);return}return a({...m,warning:!0})}catch(h){if(h.code==="ERR_BAD_REQUEST"){let g=p("not-found",d);n(g);return}n(p("network-error"));return}finally{e(!1)}},"fetchCustomToken"),token:r,loading:t,error:o,resetState:l}}i(cf,"useFetchCustomToken");var qv=Fv("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $12",backgroundColor:"$neutral300","& input":{padding:"0"},[`.${Dv} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}});function pf(){let t=Hv(),[e]=Qv(),o=Qe(),n=T().blockchains(),r=e.get("blockchain")||"",a=No(r,n),[s,c]=zv(""),{fetchCustomToken:l,token:p,loading:u,error:d,resetState:f}=cf(),h=!!a&&on(a,s),g=!a||!s||!h,m=i(()=>{a&&l({blockchain:r,tokenAddress:s})},"getCustomToken");return qe.createElement(se,{header:{title:vn.t("Add Custom Token")}},qe.createElement(ce,null,qe.createElement(qv,null,qe.createElement("div",null,qe.createElement(Rs,{onClick:()=>t($.blockchains,{replace:!0}),hasLogo:!!a?.logo,value:a?{name:a.displayName,logo:a.logo}:void 0,title:vn.t("Select chain"),placeholder:vn.t("Select chain")}),qe.createElement(Il,{size:"24"}),qe.createElement(Uv,{size:"large",variant:"label"},vn.t("Enter Address")),qe.createElement(Il,{size:10}),qe.createElement(Ov,{fullWidth:!0,id:"widget-add-custom-token-token-address-input",disabled:!a,variant:"contained",placeholder:vn.t("Enter token address"),size:"large",value:s,suffix:!!s&&h&&qe.createElement($v,{color:"success",size:12}),onChange:y=>c(y.target.value)}),!h&&!!s&&qe.createElement(qe.Fragment,null,qe.createElement(Il,{size:4}),qe.createElement(Pv,{id:"widget-add-custom-token-invalid-address-alert",type:"error",variant:"alarm",title:"Invalid Address"}))),qe.createElement(_v,{id:"widget-add-custom-token-import-btn",disabled:g,type:"primary",variant:"contained",loading:u,size:"large",onClick:m},vn.t("Import"))),qe.createElement(mr,{token:p,blockchain:a??void 0,address:s,error:d??void 0,fetchCustomToken:l,onCloseErrorModal:()=>{d?.type!=="network-error"&&c("")},onImport:o,onExitErrorModal:f,onExitImportModal:f})))}i(pf,"AddCustomTokenPage");import{i18n as lc}from"@lingui/core";import{useManager as Pb}from"@rango-dev/queue-manager-react";import{Alert as _b,Button as Db,css as pc,Divider as cc,IconButton as oh,styled as $b,Typography as Fb,WalletIcon as Ob}from"@rango-dev/ui";import De,{useEffect as ya,useLayoutEffect as Ub,useRef as zb,useState as br}from"react";import{useNavigate as Hb}from"react-router-dom";import{i18n as Ho}from"@lingui/core";import{Alert as hx,BalanceErrors as yx,Button as Df,ChevronLeftIcon as Sx,Divider as _l,MessageBox as Cx,Typography as Dl}from"@rango-dev/ui";import ie,{useCallback as Tx,useEffect as $f,useMemo as kx,useState as In}from"react";import{useNavigate as wx}from"react-router-dom";import{i18n as Wl}from"@lingui/core";import{Alert as Xv,ChevronDownIcon as Yv,CloseIcon as Zv,Divider as yf,IconButton as Sf,PasteIcon as Jv,Typography as Rv,WalletIcon as ex}from"@rango-dev/ui";import Pe,{useEffect as tx,useRef as ox}from"react";import Ki,{useRef as Kv}from"react";import*as xn from"@radix-ui/react-collapsible";import{keyframes as uf,styled as qi}from"@rango-dev/ui";var Al=300,Gv=uf({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Vv=uf({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),df=qi(xn.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),Nl=qi(xn.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Gi=qi(xn.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Gv} ${Al}ms ease-out`},false:{animation:`${Vv} ${Al}ms ease-out`}}}}),Vi=qi("div",{transition:`all ${Al}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function ji(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:c}=t,l=Kv(null);return Ki.createElement(df,{ref:l,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},c==="top"&&Ki.createElement(Nl,{className:"collapsible_trigger",onClick:a},s),Ki.createElement(Gi,{className:"collapsible_content",open:e},r),c==="bottom"&&Ki.createElement(Nl,{className:"collapsible_trigger",onClick:a},s))}i(ji,"CustomCollapsible");import{darkTheme as mf,styled as Bl,TextField as jv}from"@rango-dev/ui";var ff=Bl("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"},"& input":{padding:"$15"}}),gf=Bl(jv,{backgroundColor:"$neutral100"}),hf=Bl("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${mf} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${mf} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function Cf(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=H()(),{config:s}=T(),c=T().blockchains(),l=Rr(e.name,c),p=ox(null),u=s?.defaultCustomDestinations?.[e.name],d=navigator?.userAgent.includes("Firefox"),h=n&&!!r&&e&&!on(e,r),g=i(()=>{a("")},"handleClear"),m=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let C=await navigator.clipboard.readText();a(C),p?.current?.focus()}},"handlePaste"),y=i(()=>r?Pe.createElement(Sf,{id:"widget-custom-destination-close-icon-btn",onClick:g,variant:"ghost"},Pe.createElement(Zv,{size:12,color:"gray"})):d?null:Pe.createElement(Sf,{id:"widget-custom-destination-paste-icon-btn",onClick:m,variant:"ghost"},Pe.createElement(Jv,{size:16})),"renderSuffix");return tx(()=>{!!u&&r===null&&(a(u),o(!0))},[u]),Pe.createElement(ff,null,Pe.createElement(ji,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Pe.createElement(hf,{id:"widget-custom-destination-collapsible-btn"},Pe.createElement("div",{className:"button__content"},Pe.createElement(ex,{size:18,color:"info"}),Pe.createElement(yf,{size:4,direction:"horizontal"}),Pe.createElement(Rv,{variant:"label",size:"medium",color:n?"$neutral600":void 0},Wl.t("Send to a different address"))),Pe.createElement(Vi,{orientation:n?"up":"down"},Pe.createElement(Yv,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Pe.createElement(gf,{id:"widget-custom-destination-blockchain-address-input",ref:p,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:Wl.t("Enter {blockchainName} address",{blockchainName:l}),value:r||"",suffix:y(),onChange:S=>{let C=S.target.value;a(C)}})),h&&Pe.createElement(Pe.Fragment,null,Pe.createElement(yf,{size:4}),Pe.createElement(Xv,{variant:"alarm",type:"error",title:Wl.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(Cf,"CustomDestination");import{css as nx,IconButton as rx,SelectableWalletButton as ix,styled as ho}from"@rango-dev/ui";var Tf=ho("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),kf=ho("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),wf=ho(ix,{justifyContent:"center"}),vf=ho("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),xf=ho(rx,{position:"absolute",left:"$20"}),bf=ho("div",{paddingTop:"$20"}),Ef=nx({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),If=ho("div",{display:"flex"}),Af=ho("div",{overflow:"visible",width:"100%"});import{i18n as Ll}from"@lingui/core";import{warn as px}from"@rango-dev/logging-core";import{Divider as ux,makeInfo as dx,SelectableWallet as mx,Typography as Pf,WalletState as En}from"@rango-dev/ui";import nt,{useEffect as _f,useState as gr}from"react";import{Image as lx,MessageBox as cx}from"@rango-dev/ui";import fr from"react";import{keyframes as ax,styled as Ml}from"@rango-dev/ui";var Nf=Ml("div",{position:"relative"}),sx=ax({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Bf=Ml("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${sx} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),Wf=Ml("div",{"& img":{borderRadius:"50%"}});import{i18n as bn}from"@lingui/core";function Mf(t,e){switch(t){case"in-progress":return{type:"loading",title:bn.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:bn.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:bn.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:bn.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:bn.t("Request Rejected"),description:bn.t({id:"You've rejected adding {blockchainDisplayName} chain to your wallet.",values:{blockchainDisplayName:e}})};default:throw new Error(`Showing information about an experimentation chain status needs to be defined first. status: ${t}`)}}i(Mf,"generateMessageByStatus");function Lf(t){let{status:e,displayName:o,image:n}=t,r=Mf(e,o),a=e=="in-progress";return fr.createElement(cx,{type:r.type,title:r.title,description:r.description,icon:a?fr.createElement(Nf,null,fr.createElement(Wf,null,fr.createElement(lx,{src:n,size:45})),fr.createElement(Bf,null)):void 0})}i(Lf,"ExperimentalChainStatus");var fx=7,gx=3e3;function Pl(t){let{chain:e,quoteChains:o,isSelected:n,selectWallet:r,limit:a,onShowMore:s}=t,c=ne.use.isActiveTab(),{blockchains:l,connectedWallets:p}=T(),[u,d]=gr(),[f,h]=gr(null),[g,m]=gr(!1),[y,S]=gr(null),{suggestAndConnect:C}=Xi(),{list:k}=bt({chain:e}),[x,w]=gr(k),I=k.length,A=a&&I-a>0,b=i(async v=>{m(!1),S("in-progress");try{let N=k.find(Q=>Q.type===Q.type),M=N?.isHub?N.properties?.find(Q=>Q.name==="namespaces")?.value:N?.needsNamespace,P=l(),U=M?.data.find(Q=>Q.getSupportedChains(P).some(Z=>Z.name===v.chain));if(!U)throw new Error("Requested chain is not supported");await C(v.walletType,{namespace:U.value,network:v.chain}),S("completed")}catch{S("rejected")}},"addExperimentalChain");_f(()=>{w(v=>{let N=k.findIndex(M=>n(M.type,e));return A&&N>1?[k[N]].concat(k.filter((M,P)=>P!==N)):v.map(M=>k.find(P=>P.type===M.type)??M)})},[JSON.stringify(k)]);let E=document.getElementById(Re.SWAP_BOX_ID);return _f(()=>{let v=null;return(y==="completed"||y==="rejected")&&(v=setTimeout(()=>S(null),gx)),()=>{v&&clearTimeout(v)}},[y]),nt.createElement(nt.Fragment,null,x.slice(0,a).map(v=>{let N=Bu({connectedWallets:p,walletType:v.type,chain:e}),M=v.state===En.CONNECTED||v.state===En.PARTIALLY_CONNECTED,P=N?lo(N,fx):"",U=M&&!!v.needsNamespace&&!P,Q=ci(l(),e),Z=!p.find(ue=>ue.walletType===v.type&&ue.chain===e),W=Q&&Z&&v.state===En.CONNECTED,J=i(async()=>{v.state===En.DISCONNECTED||U&&!W?d(v):W?(h({walletType:v.type,chain:e,address:N??""}),m(!0)):r({walletType:v.type,chain:e,address:N??""})},"onSelectableWalletClick"),X=dx(v.state),ae=i(()=>W?Ll.t({id:"Add {chain} chain",values:{chain:e}}):U?Ll.t("Chain not connected"):P||X.description,"getWalletDescription"),Se=i(()=>v.state===En.CONNECTED||v.state===En.PARTIALLY_CONNECTED?U?"neutral600":"neutral700":X.color,"getWalletDescriptionColor"),at=f?.chain?Rr(f.chain,l()):void 0;return nt.createElement(nt.Fragment,{key:`${v.title}_${at}`},!!f&&nt.createElement(ee,{id:"widget-wallets-list-watermarked-modal",open:!!f&&g,container:E,onClose:()=>{h(null)}},nt.createElement(Us,{id:"widget-wallets-list-experimental-chain-container",displayName:at,onConfirm:()=>{b(f)}})),y&&nt.createElement(ee,{id:"widget-wallets-list-experimental-chain-watermarked-modal",open:!!y,onClose:S.bind(null,null),container:E},nt.createElement(Lf,{status:y,displayName:at,image:v.image}),nt.createElement(ux,{direction:"vertical",size:32})),nt.createElement(mx,{key:v.type,id:"widget-wallets-list-selectable-wallet-btn",description:ae(),descriptionColor:Se(),onClick:J,selected:n(v.type,e),disabled:!c,...v}))}),nt.createElement(sr,{id:"widget-wallets-list-stateful-connect-modal",wallet:u,options:{defaultSelectedChains:o||[e]},onClose:()=>{d(void 0)},onConnect:()=>{t.onConnect&&(u?.type?t.onConnect(u.type):px(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),A&&nt.createElement(wf,{selected:!1,onClick:s,id:"widget-wallets-list-show-more-wallets-btn"},nt.createElement(Pf,{variant:"label",size:"medium"},Ll.t("Show more wallets"),nt.createElement(Pf,{variant:"label",size:"medium",color:"$primary"},"\xA0+",I-(a??0)))))}i(Pl,"WalletList");var vx=2;function Ff(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=wx(),c=T().blockchains(),{selectedQuote:l,setSelectedWallets:p,quoteWalletsConfirmed:u,setQuoteWalletConfirmed:d,customDestination:f,setCustomDestination:h}=H()(),{config:g,connectedWallets:m,setWalletsAsSelected:y}=T(),[S,C]=In(""),[k,x]=In([]),[w,I]=In(""),[A,b]=In(!!f),E=kx(()=>Mo({filter:"all",quote:l}),[l]),v=Mo({filter:"required",quote:l}),N=c.find(O=>O.name===l?.swaps[l?.swaps.length-1]?.to.blockchain),M=i(O=>v.includes(O),"isWalletRequiredFor"),P=Tx(()=>m.filter(O=>O.selected&&E.includes(O.chain)),[m,E]),[U,Q]=In(P()),[Z,W]=In([]),J=i((O,z)=>W(Y=>Y.concat({blockchain:O,walletType:z})),"addNextSelectedWallets"),X=k.length>0,ae=i((O,z)=>!!U.find(Y=>Y.walletType===O&&Y.chain===z&&Y.selected&&(M(z)||!M(z)&&!f)),"isSelected"),Se=i((O,z,Y)=>{let te=!1;return O.map(j=>{if(j.chain===z){let G=j.selected;return!te&&Y?(te=!0,G=!0):Y||(G=!1),{...j,selected:G}}return j})},"updateSelectableWallets"),at=i(O=>{b(O),O?M(N?.name??"")||Q(z=>Se(z,N?.name||"",!1)):(h(""),Q(z=>Se(z,N?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),ue=i(O=>{if(S&&C(""),ae(O.walletType,O.chain))return;let Y=m.find(te=>te.walletType===O.walletType&&te.chain===O.chain);Y&&(n(),O.chain===N?.name&&A&&!M(N.name)&&(b(!1),h(null)),Q(te=>te.filter(j=>j.chain!==O.chain).concat({...Y,selected:!0})))},"onChange"),gt=i(()=>{let O=U.filter(z=>z.selected);y(O),p(O),d(!0),o()},"onConfirmBalance"),vt=i(async()=>{x([]),I("");let O=await r?.({selectedWallets:U.filter(Y=>Y.selected),customDestination:f}),z=O.warnings;z?.balance?.messages&&x(z.balance.messages),O.error&&I(Ed(O.error)),!O.error&&!z?.balance?.messages.length?gt():x(z?.balance?.messages??[])},"onConfirmWallets");$f(()=>{Q(O=>{let z=[];return O.forEach(Y=>{!m.some(j=>j.chain===Y.chain&&j.walletType===Y.walletType&&j.address===Y.address)||z.push(Y)}),z=z.concat(m.filter(Y=>!!!z.find(j=>j.chain===Y.chain)&&Y.selected&&E.includes(Y.chain))),z})},[m,E]),$f(()=>{let O=[];Z.length>0&&(Z.forEach(z=>{let Y=m.find(te=>te.chain===z.blockchain&&te.walletType===z.walletType);Y?ue(Y):O.push(z)}),W(O))},[m,Z]);let xt=document.getElementById(Re.SWAP_BOX_ID);return ie.createElement(ee,{id:"widget-confirm-wallets-modal",open:e,onClose:()=>{u||s("../",{replace:!0}),o()},dismissible:!S,container:xt,...!S&&{styles:{container:{height:"100%"}},footer:ie.createElement(If,null,ie.createElement(Df,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:tm(a,A,f,l,U,N),onClick:vt,variant:"contained",type:"primary",fullWidth:!0,size:"large"},Ho.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:ie.createElement(vf,null,ie.createElement(xf,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:C.bind(null,"")},ie.createElement(Sx,{size:16})),ie.createElement(Dl,{variant:"headline",size:"small"},Ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:yt(S,c)}})))},anchor:"center"},ie.createElement(ee,{id:'"widget-confirm-wallets-insufficient-account-balance-modal',open:X,onClose:x.bind(null,[]),container:xt},ie.createElement(Cx,{title:Ho.t("Insufficient account balance"),type:"error",description:ie.createElement(yx,{messages:k??[]})},ie.createElement(Df,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:gt},Ho.t("Proceed anyway")))),S&&ie.createElement(bf,null,ie.createElement("div",{className:Ef()},ie.createElement(Pl,{chain:S,quoteChains:E,isSelected:ae,selectWallet:ue,onShowMore:()=>C(S),onConnect:O=>{J(S,O)}}))),!S&&ie.createElement(ie.Fragment,null,w&&ie.createElement(ie.Fragment,null,ie.createElement(hx,{id:"widget-confirm-wallet-modal-error-alert",variant:"alarm",type:"error",title:Ho.t(w)}),ie.createElement(_l,{size:12})),ie.createElement(Af,null,E.map((O,z)=>{let Y=c.find(Ve=>Ve.name===O),te=`wallet-${z}`,j=z===E.length-1,G=j&&N&&g?.customDestination!==!1;return ie.createElement("div",{key:te},ie.createElement(Tf,null,ie.createElement(Dl,{variant:"title",size:"xmedium"},Ho.t({id:"Your {blockchainName} wallets",values:{blockchainName:Y?.shortName}})),ie.createElement(Dl,{variant:"label",color:"$neutral700",size:"medium"},Ho.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:Y?.shortName}}))),ie.createElement(_l,{size:24}),ie.createElement(kf,null,ie.createElement(Pl,{chain:O,quoteChains:E,isSelected:ae,selectWallet:ue,limit:vx,onShowMore:()=>C(Y?.name??""),onConnect:Ve=>{J(O,Ve)}})),!j&&ie.createElement(_l,{size:32}),G&&ie.createElement(Cf,{blockchain:N,open:A,handleOpenChange:at}))}))))}i(Ff,"ConfirmWalletsModal");import{i18n as Xx}from"@lingui/core";import{Alert as Yx,Button as Zx,Divider as rg,InfoIcon as Jx}from"@rango-dev/ui";import Fe from"react";import{Alert as Ex,Button as Ix,Divider as Ol,NoRouteIcon as Ax,RefreshIcon as Nx,Typography as Gf}from"@rango-dev/ui";import pt from"react";import{i18n as Of}from"@lingui/core";var xx=24,bx=60;function Uf(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:re().genericServerError,action:{onClick:n,title:Of.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:re().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:Of.t("Reset")}},description:re().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:re().noResultError.description}}i(Uf,"makeInfo");var $l=(o=>(o[o.small=xx]="small",o[o.large=bx]="large",o))($l||{}),Fl=(o=>(o.small="small",o.large="medium",o))(Fl||{});import{styled as Yi}from"@rango-dev/ui";var zf=Yi("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Hf=Yi("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Qf=Yi("div",{variants:{size:{small:{width:"100%"},large:{}}}}),qf=Yi("div",{padding:"$6 $0"});function hr(t){let{fetch:e,error:o,size:n="small",skipAlerts:r}=t,a=T().getDisabledLiquiditySources(),s=T().toggleAllLiquiditySources,c=T().swappers(),l=Uf(o,a,()=>s(c,!0),e);return r&&(l.alert=null),pt.createElement(zf,{id:"widget-no-result-container"},pt.createElement(Ax,{size:$l[n],color:"gray"}),pt.createElement(Ol,{size:4}),pt.createElement(Gf,{variant:"title",size:Fl[n]},re().noResultError.title),n==="large"&&pt.createElement(Ol,{size:4}),!!l.description&&pt.createElement(Hf,{size:n},pt.createElement(Gf,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),pt.createElement(Ol,{size:n==="large"?"24":"4"}),!!l.alert&&pt.createElement(Qf,{size:n},pt.createElement(Ex,{id:"widget-no-result-alert",type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&pt.createElement(Ix,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:pt.createElement(qf,null,pt.createElement(Nx,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(hr,"NoResult");import{i18n as yr}from"@lingui/core";import{Button as $x,Divider as Fx,MessageBox as Ox,Typography as Ux,WarningIcon as zx}from"@rango-dev/ui";import Yt from"react";import{InfoIcon as Lx,Tooltip as Px,Typography as _x}from"@rango-dev/ui";import An from"react";import{Button as Bx,darkTheme as Wx,styled as Qo,Typography as Mx}from"@rango-dev/ui";var Vf=Qo("div",{width:"100%"}),Ul=Qo("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Kf=Qo("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${Wx} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),jf=Qo("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$2"}),Xf=Qo(Mx,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"250px"}),Yf=Qo("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"}),Zf=Qo(Bx,{"& ._text":{gap:"$5",display:"flex",alignItems:"center",justifyContent:"center"}});var Dx=35;function Jf(t){let{title:e,value:o,valueColor:n}=t,r=B();return An.createElement(Kf,null,An.createElement(_x,{size:"medium",variant:"label",className:"_title"},e),An.createElement(jf,null,An.createElement(Xf,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`),o.length>Dx&&An.createElement(Px,{content:o,container:r},An.createElement(Lx,{size:12,color:"gray"}))))}i(Jf,"QuoteErrorsModalItem");function Rf(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",c=[{title:yr.t("Swapping"),value:_(r.inputUsdValue)},{title:yr.t("Gas cost"),value:_(r.totalFee,2,2)},{title:yr.t("Receiving"),value:_(r.outputUsdValue)},{title:yr.t("Price impact"),value:_(r.priceImpact,2,2),valueColor:`${s}500`}];return Yt.createElement(ee,{id:"widget-high-value-loss-warning-modal",footer:Yt.createElement($x,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Yt.createElement(zx,null),fullWidth:!0,disabled:a,onClick:n},re().highValueLossError.confirmMessage),open:e,onClose:o,container:B()},Yt.createElement(Ox,{type:s,title:re().highValueLossError.impactTitle,description:re().highValueLossError.description}),Yt.createElement(Ul,null,Yt.createElement(Fx,{size:"4"}),Yt.createElement(Ux,{size:"small",variant:"title"},yr.t("Details")),Yt.createElement(Ul,null,c.map((l,p)=>Yt.createElement(Jf,{key:p,...l})))))}i(Rf,"HighValueLossWarningModal");import{i18n as Nn}from"@lingui/core";function eg(t,e){let o={alertType:"warning",title:"",action:null,actionButtonTitle:null};if(e)return o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=Nn.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-slippage",o.actionButtonTitle=Nn.t("Increase")),o;if(t){switch(t.type){case 0:{Xt(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=re().highValueLossError.title;break}case 4:{o.title=Nn.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=re().unknownPriceError.title;break}case 2:{o.title=Nn.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-slippage",o.actionButtonTitle=Nn.t("Increase");break}case 3:{o.title=Nn.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(eg,"makeAlerts");function tg(t,e){return e?.type===4?Number(e.minRequiredSlippage):t?.type===2?Number(t.minRequiredSlippage):null}i(tg,"getRequiredSlippage");import{i18n as Bn}from"@lingui/core";import{Button as Hx,Divider as zl,MessageBox as Qx,WarningIcon as qx}from"@rango-dev/ui";import Co from"react";import{useNavigate as Gx}from"react-router-dom";function og(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=Gx();return Co.createElement(ee,{id:"widget-slippage-warning-modal",anchor:"bottom",open:e,container:B(),onClose:o},Co.createElement(Qx,{type:"warning",title:r.type===3?Bn.t("High slippage"):Bn.t("Low slippage"),description:r.type===3?Bn.t("Caution, your slippage is high. Your trade may be front run."):Bn.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:r.minRequiredSlippage}})},Co.createElement(zl,{size:18}),Co.createElement(zl,{size:32}),Co.createElement(Zf,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:a,onClick:n},Co.createElement(qx,{color:"white",size:16}),Bn.t("Swap anyway")),Co.createElement(zl,{size:10}),Co.createElement(Hx,{id:"widget-slippage-warning-modal-change-slippage-btn",size:"large",type:"primary",variant:"outlined",fullWidth:!0,disabled:a,onClick:()=>s("../"+$.settings)},Bn.t("Change Slippage"))))}i(og,"SlippageWarningModal");import{Button as Vx,MessageBox as Kx,WarningIcon as jx}from"@rango-dev/ui";import Zi from"react";function ng(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return Zi.createElement(ee,{id:"widget-unknown-price-warning-modal",footer:Zi.createElement(Vx,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Zi.createElement(jx,null),fullWidth:!0,disabled:r,onClick:n},re().unknownPriceError.confirmMessage),open:e,onClose:o,container:B()},Zi.createElement(Kx,{type:"warning",title:re().unknownPriceError.impactTitle,description:re().unknownPriceError.description}))}i(ng,"UnknownPriceWarningModal");function Sr(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,skipAlerts:s,refetchQuote:c,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:d,onChangeSlippage:f}=t,h={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},g=o?.type===0||o?.type===1,m=eg(e,o?.type===3||o?.type===4?o:null);m&&!n&&(m.action=null);let y=!!m&&!s,S=i(C=>{if(C==="change-slippage"){let k=o?.type===3||o?.type===4?o:null,x=tg(e,k);f?.(x)}else C==="change-settings"&&d()},"onclickActionButton");return Fe.createElement(Fe.Fragment,null,g&&Fe.createElement(Fe.Fragment,null,Fe.createElement(rg,{size:10}),Fe.createElement(hr,{skipAlerts:s,error:o,fetch:c})),y&&Fe.createElement(Vf,null,Fe.createElement(rg,{size:10}),Fe.createElement(Yx,{id:"widget-quote-warning-and-errors-alert",title:m.title,type:m.alertType,variant:"alarm",...m.action==="show-info"&&{action:Fe.createElement(Yf,{onClick:l},Fe.createElement(Jx,{size:12,color:"gray"}))},...(m.action==="change-settings"||m.action==="change-slippage")&&{action:Fe.createElement(Zx,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:m.alertType,onClick:()=>S(m.action)},m.actionButtonTitle||Xx.t("Change"))}})),e&&Fe.createElement(Fe.Fragment,null,e.type===0&&Fe.createElement(Rf,{...h,warning:e}),(e.type===3||e.type===2)&&Fe.createElement(og,{...h,warning:e}),e.type===1&&Fe.createElement(ng,{...h,warning:e})))}i(Sr,"QuoteWarningsAndErrors");import Ib from"bignumber.js";import ma from"react";import{i18n as qo}from"@lingui/core";import{Alert as gb,CampaignQuoteTag as hb,Divider as Mn,FullExpandedQuote as yb,InfoIcon as Jl,NumericTooltip as Rl,QuoteTag as Sb,StepDetails as Cb,TokenAmount as Tb,Typography as Ln,useIsTruncated as ec}from"@rango-dev/ui";import tc from"bignumber.js";import F,{useRef as pa,useState as kb}from"react";import{styled as Hl}from"@rango-dev/ui";var Ql=Hl("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),ig=Hl("div",{paddingBottom:"$15","& .from-amount-text":{wordBreak:"break-word"},variants:{dense:{true:{paddingBottom:0}}}}),ag=Hl("div",{width:"100%",display:"flex"});import*as Ji from"@radix-ui/react-collapsible";import{Button as Rx,css as Ri,darkTheme as _e,Image as sg,styled as Ge,Typography as ql}from"@rango-dev/ui";var eb=300,lg=Ge(Ji.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${_e} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${_e} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${_e} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),cg=Ri({padding:"$10 $15"}),pg=Ge(Rx,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${_e} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${_e} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${_e} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),ug=Ge("div",{borderRadius:"$xm",display:"flex",flexDirection:"column",alignItems:"start",justifyContent:"space-between",color:"$foreground",boxSizing:"border-box",position:"relative",variants:{selected:{true:{},false:{$$color:"$colors$neutral200",[`.${_e} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${_e} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${_e} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${_e} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${_e} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${_e} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${_e} &`]:{backgroundColor:"$neutral400"}}}}]}),dg=Ri({width:"100%",padding:"$15 $15 $10 $15"}),mg=Ri({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Wn=Ri({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),fg=Ge(Ji.Trigger,{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",height:"$36",padding:"$10 $15",boxSizing:"border-box",cursor:"pointer",border:"none",outline:"none",backgroundColor:"transparent",variants:{error:{true:{[`& ${sg}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${sg}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${_e} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${_e} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${_e} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),gg=Ge("div",{width:"18px",height:"18px",borderRadius:"100%",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",img:{borderRadius:"100%"},variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),hg=Ge(Gi,{width:"100%",background:"inherit"}),Gl=Ge("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${eb}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),BQ=Ge("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),yg=Ge("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${_e} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),Sg=Ge("div",{display:"flex",flexDirection:"row",alignItems:"center",gap:"$2",flex:"1 1 auto",minWidth:0}),Vl=Ge(ql,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"$30"}),Kl=Ge(ql,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,flex:"0 1 auto"}),jl=Ge("div",{width:"18px",height:"18px",borderRadius:"100%",backgroundColor:"$background",cursor:"default",display:"flex",justifyContent:"center",alignItems:"center",border:"1.5px transparent solid",variants:{state:{error:{borderColor:"$error500"},warning:{borderColor:"$warning500"}}}}),Cg=Ge("div",{display:"flex"}),ea=Ge("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${_e} &`]:{borderTopColor:"$neutral800"}}),Tg=Ge(ql,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"0 1 auto",minWidth:0,flexShrink:3});import{i18n as $t}from"@lingui/core";import{ChevronDownIcon as ob,CloseIcon as nb,Divider as na,IconButton as rb,NumericTooltip as ib,QuoteCost as ab,Typography as At}from"@rango-dev/ui";import R,{useState as xg}from"react";import{css as tb,styled as ta}from"@rango-dev/ui";var oa=ta("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Xl=ta("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),kg=ta("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),wg=ta("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),vg=tb({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var sb=i(t=>t.fee.isZero()?null:R.createElement(oa,null,R.createElement(At,{variant:"label",size:"medium",color:"neutral600"},t.label),R.createElement(At,{variant:"label",size:"medium"},"$",_(t.fee,4,4))),"NonPayableFee");function Yl(t){let[e,o]=xg(!1),[n,r]=xg(!1),{steps:a,quote:s,fee:c,time:l,feeWarning:p,timeWarning:u,showModalFee:d,fullExpandedMode:f=!1}=t,h=s?.swaps??[],g=f?Wo():B(),m=Kd(h),y=_(c,2,2);return R.createElement(R.Fragment,null,R.createElement(ab,{onClickFee:d?S=>{S.stopPropagation(),o(!e)}:void 0,fee:y,feeWarning:p,timeWarning:u,time:l,steps:a,tooltipGas:d?$t.t("View more info"):void 0,tooltipContainer:g}),R.createElement(ee,{id:"widget-quote-cost-explanation-modal",container:g,open:e,anchor:f?"center":"bottom",styles:{container:{maxWidth:f?"484px":"unset"}},header:R.createElement(wg,{style:{textAlign:f?"left":"center"}},R.createElement(At,{variant:"title",size:"medium"},$t.t("Gas & Fee Explanation")),R.createElement(rb,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},R.createElement(nb,{color:"gray",size:14}))),onClose:()=>{o(!1)}},R.createElement(kg,null,R.createElement(At,{variant:"title",size:"small"},$t.t("Details")),R.createElement(na,{size:10}),Object.entries(m.payable).flatMap(([S,C])=>C.map((k,x)=>{let w=`payable-fee-${x}`,I=Vs(k);return R.createElement(oa,{key:w},R.createElement(At,{variant:"label",size:"medium",color:"neutral600"},zs(S,$t.t)),R.createElement(ib,{content:k.amount,container:g},R.createElement(At,{variant:"label",size:"medium"},_(k.amount,2,2),k.asset.symbol," ($",_(I,4,4),")")))})),R.createElement(oa,{className:"total_payable_fee"},R.createElement(At,{variant:"label",size:"medium"},$t.t("Total Payable Fee")),R.createElement(At,{variant:"label",size:"medium"},"$",_(c,4,4))),R.createElement(Xl,null),!!Object.keys(m.nonePayable).length&&R.createElement(ji,{triggerAnchor:"bottom",onClickTrigger:()=>r(S=>!S),trigger:R.createElement("div",{className:vg()},R.createElement(At,{size:"small",variant:"body",color:"neutral700"},n?$t.t("Hide non-payable fees"):$t.t("Show non-payable fees")),R.createElement(na,{size:4,direction:"horizontal"}),R.createElement(Vi,{orientation:n?"up":"down"},R.createElement(ob,{size:12,color:"gray"}))),open:n},R.createElement(At,{size:"small",variant:"title"},$t.t("Description")),R.createElement(na,{size:4}),R.createElement(At,{size:"small",variant:"body",color:"neutral700"},$t.t(`The following fees are considered in the transaction output and
|
|
2
|
+
you won\u2019t need to pay extra gas for them.`)),R.createElement(na,{size:10}),Object.entries(m.nonePayable).map(([S,C],k)=>{let x=Vd(C),w=zs(S,$t.t),I=`non-payable-fee-${k}`;return R.createElement(sb,{key:I,fee:x,label:w})}),R.createElement(Xl,null)))))}i(Yl,"QuoteCostDetails");import{i18n as Ig}from"@lingui/core";import{TokenAmount as Ag}from"@rango-dev/ui";import ra from"react";import{css as lb,styled as cb}from"@rango-dev/ui";var bg=cb("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),Eg=lb({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function Cr(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return ra.createElement(bg,null,ra.createElement(Ag,{direction:"horizontal",label:Ig.t("Swap input"),id:"widget-quote-summary-swap-input",type:"input",tooltipContainer:B(),price:{value:e.price.value,usdValue:e.price.usdValue,realValue:e.price.realValue,realUsdValue:e.price.realUsdValue},token:{displayName:e.token.displayName,image:e.token.image},chain:{image:e.chain.image}}),ra.createElement("div",{className:Eg()}),ra.createElement(Ag,{id:"widget-quote-summary-estimated-input",direction:"horizontal",tooltipContainer:B(),label:Ig.t("Estimated output"),type:"output",price:{value:o.price.value,usdValue:o.price.usdValue,realValue:o.price.realValue,realUsdValue:o.price.realUsdValue},token:{displayName:o.token.displayName,image:o.token.image},chain:{image:o.chain.image},percentageChange:n,warningLevel:r}))}i(Cr,"QuoteSummary");import{i18n as Lg}from"@lingui/core";import{ChevronDownIcon as db,ChevronRightIcon as mb,Divider as Zl,Image as fb,Tooltip as ca,Typography as aa}from"@rango-dev/ui";import q from"react";import{useLayoutEffect as pb,useState as Tr}from"react";var Ng=480,Bg=768,Wg=1024,Mg=1200,ub=i(()=>{let[t,e]=Tr(!1),[o,n]=Tr(!1),[r,a]=Tr(!1),[s,c]=Tr(!1),[l,p]=Tr(!1),u=i(()=>{e(window.innerWidth<=Ng),n(window.innerWidth>Ng&&window.innerWidth<=Bg),a(window.innerWidth>Bg&&window.innerWidth<=Wg),c(window.innerWidth>Wg&&window.innerWidth<=Mg),p(window.innerWidth>Mg)},"handleResize");return pb(()=>(u(),window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:l}},"useScreenDetect"),ia=ub;var sa=4,la=6,kr=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,c=s||B();return q.createElement(ca,{container:c,side:"bottom",sideOffset:4,open:r,content:e},q.createElement(gg,{className:n,state:a},q.createElement(fb,{src:o,size:16})))},"ImageComponent");function Pg(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:c}=t,l=c||B(),p=r.length,u=Dd(r),{isTablet:d,isMobile:f}=ia();return q.createElement(fg,{className:"widget-quote-trigger-btn",listItem:s==="list-item",ref:h=>e.current=h,selected:o,onClick:h=>{h.stopPropagation(),n(g=>!g)}},q.createElement("div",{className:Wn()},q.createElement(aa,{variant:"body",size:"xsmall"},Lg.t("Via:")),q.createElement(Zl,{direction:"horizontal",size:4}),r.map((h,g)=>{let m=`item-${g}`,y=q.createElement(Gl,null,q.createElement(mb,{size:12,color:"black"}));return f||d?q.createElement(q.Fragment,{key:m},q.createElement(kr,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&q.createElement(q.Fragment,null,y)):q.createElement(q.Fragment,{key:m},p<=sa||p>sa&&g<sa-1?q.createElement(q.Fragment,null,q.createElement(kr,{content:h.swapper.displayName,src:h.swapper.image??"",state:h.state,container:c}),g!==p-1&&q.createElement(q.Fragment,null,y)):g===sa-1&&q.createElement(ca,{container:l,side:"bottom",align:"end",sideOffset:4,content:q.createElement("div",{className:Wn()},y,r.map((S,C)=>{let k=`image-${C}`;return C>=g&&q.createElement(q.Fragment,{key:k},q.createElement(kr,{content:S.swapper.displayName,src:S.swapper.image??"",state:S.state,open:!1}),C!==p-1&&q.createElement(q.Fragment,null,y))}))},q.createElement(jl,{state:r.find((S,C)=>C>=g&&(S.state==="error"||S.state==="warning"))?.state},q.createElement(aa,{size:"xsmall",variant:"body"},"+",p-g))))})),q.createElement("div",{className:Wn()},q.createElement("div",{className:"blockchains_section"},q.createElement("div",{className:Wn()},q.createElement(aa,{variant:"body",size:"xsmall"},Lg.t("Chains:")),q.createElement(Zl,{direction:"horizontal",size:4}),u.map((h,g)=>q.createElement(q.Fragment,{key:h.displayName},u.length<=la||u.length>la&&g<la-1?q.createElement(ca,{container:l,side:"bottom",content:h.displayName,sideOffset:4},q.createElement(kr,{content:"",src:h.image??"",open:!1,className:g!==0?"blockchainImage":""})):g===la-1&&q.createElement(ca,{container:l,side:"bottom",align:"end",sideOffset:4,content:q.createElement("div",{className:Wn()},u.map((m,y)=>y>=g&&q.createElement(kr,{key:m.displayName,content:"",src:m.image??"",open:!1,className:y>g?"blockchainImage":"",container:c})))},q.createElement(jl,{className:"blockchainImage"},q.createElement(aa,{size:"xsmall",variant:"body"},"+",u.length-g))))),q.createElement(Zl,{direction:"horizontal",size:32}))),q.createElement(Gl,{orientation:a?"up":"down"},q.createElement(db,{size:12,color:"black"}))))}i(Pg,"QuoteTrigger");function oc(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:c=!1,tagHidden:l=!0,showModalFee:p=!0,onClickAllRoutes:u,fullExpandedMode:d=!1,container:f}=t,h=T().blockchains(),{findToken:g}=T(),m=T().swappers(),{customSlippage:y,slippage:S}=T(),C=y||S,[k,x]=kb(t.expanded),w=pa(null),I=_(n.value,6,6),A=n.usdValue?_(n.usdValue,4,4):"",{config:{__UNSTABLE_OR_INTERNAL__:b}}=T(),E=jt(o.usdValue,n.usdValue??null),v=_(E,2,2),N=Xt(E??0),M=i((G,Ve)=>G.map((V,Ce)=>{let Je,ht=r?.type===3&&r.swap.swapperId===V.swapperId,so=r?.type===4&&!!r.recommendedSlippages?.[Ce],zn=a?.type===2&&!!a.recommendedSlippages?.[Ce],Io=ht||so,Zr=zn;Io?Je="error":Zr&&(Je="warning");let Ro=Io?qo.t("Slippage Error"):qo.t("Slippage Warning");return ht&&(Ro=qo.t("Bridge Limit Error")),{swapper:{displayName:Qn(V.swapperId,m)??"",image:V.swapperLogo},from:{token:{displayName:V.from.symbol,image:V.from.logo},chain:{displayName:yt(V.from.blockchain,h)??"",image:V.from.blockchainLogo},price:{value:Ce===0&&!Ve?_(o.value,6,6):_(V.fromAmount,6,6),usdValue:_((V.from.usdPrice??0)*parseFloat(V.fromAmount),4,4),realValue:Ce===0?o.value:V.fromAmount,realUsdValue:new tc(V.from.usdPrice??0).multipliedBy(V.fromAmount).toString()}},to:{token:{displayName:V.to.symbol,image:V.to.logo},chain:{displayName:yt(V.to.blockchain,h)||"",image:V.to.blockchainLogo},price:{value:_(V.toAmount,6,6),usdValue:_((V.to.usdPrice??0)*parseFloat(V.toAmount),4,4),realValue:V.toAmount,realUsdValue:new tc(V.to.usdPrice??0).multipliedBy(V.toAmount).toString()}},state:Je,alerts:Io||Zr?F.createElement(ig,{dense:d},F.createElement(gb,{variant:"alarm",type:Io?"error":"warning",title:Ro,id:"widget-quote-footer-step-alarm-alert",footer:F.createElement(ag,null,ht&&F.createElement("div",null,F.createElement(Ln,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(Mn,{direction:"vertical",size:2}),F.createElement(Ln,{size:"xsmall",variant:"body",className:"from-amount-text",color:"neutral900"},qo.t({id:"Yours: {amount} {symbol}",values:{amount:_(V.fromAmount,6,6),symbol:V?.from.symbol}}))),(so||zn)&&!ht&&F.createElement("div",null,F.createElement(Ln,{size:"xsmall",variant:"body",color:"neutral900"},qo.t({id:"Minimum suggested slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.[Ce]},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.[Ce]}}})),F.createElement(Mn,{direction:"vertical",size:2}),F.createElement(Ln,{size:"xsmall",variant:"body",color:"neutral900"},qo.t({id:"Yours: {userSlippage}",values:{userSlippage:C}}))))})):void 0,time:Gn(V.estimatedTimeInSeconds),fee:_(Gs(V,g),2,2),internalSwaps:V.internalSwaps?M(V.internalSwaps):void 0}}),"getQuoteSteps"),P=M(e?.swaps??[]),U=P.length,Q=f||B(),Z=Fd(t.quote.tags||[]),W=!!u,J=ai(e?.swaps),X=Gn(J),ae=Ni(e?.swaps??[],g),Se=_(ae,2,2),at=ae.gte(new tc(Ad)),ue=J/Bd>=Nd,gt=pa(null),vt=ec(o.value,gt),xt=pa(null),O=ec(n.value,xt),z=pa(null),Y=ec(A,z),te=P[U-1],j=P[0];return!j||!te?null:d?F.createElement(yb,{selected:c,fee:Se,time:X,tooltipContainer:Wo(),steps:P,tags:Z,campaignTag:b?.campaignTag,id:"widget-quote-full-expanded-quote-container",quoteCost:F.createElement(Yl,{quote:e,fullExpandedMode:!0,time:X,fee:ae,feeWarning:at,timeWarning:ue,showModalFee:p,steps:U}),percentageChange:v,warningLevel:N,outputPrice:{value:I,usdValue:A,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(ug,{id:"widget-quote-summary-container",selected:c,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:dg()},!l&&Z.length?F.createElement(F.Fragment,null,F.createElement(Cg,null,Z.map((G,Ve)=>{let V=`${G.value}_${Ve}`;return F.createElement(F.Fragment,{key:V},G.value=="CAMPAIGN"&&b?.campaignTag?F.createElement(hb,{routeTag:G,...b.campaignTag}):F.createElement(Sb,{label:G.label,value:G.value}),F.createElement(Mn,{size:4,direction:"horizontal"}))})),F.createElement(ea,null),!W&&F.createElement(Mn,{size:4})):null,F.createElement("div",{id:"portal-root",className:mg()},F.createElement(Yl,{quote:e,time:X,fee:ae,feeWarning:at,timeWarning:ue,showModalFee:p,steps:U}),W&&F.createElement(pg,{onClick:G=>{G.stopPropagation(),u()},id:"widget-quote-all-routes-btn",size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Ln,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},qo.t("See All Routes")))),s==="basic"&&F.createElement(Sg,null,F.createElement(Kl,{ref:gt,size:"small",variant:"body"},o.value),vt&&F.createElement(Rl,{content:o.value,container:Q,open:o.value?void 0:!1},F.createElement(Jl,{size:12,color:"gray"})),F.createElement(Vl,{size:"small",variant:"body"},P[0]?.from.token.displayName),F.createElement(Ln,{size:"small",variant:"body"},"="),F.createElement(Kl,{ref:xt,size:"small",variant:"body"},n.value),O&&F.createElement(Rl,{content:n.value,container:Q,open:n.value?void 0:!1},F.createElement(Jl,{size:12,color:"gray"})),F.createElement(Vl,{size:"small",variant:"body"},te?.to.token.displayName),F.createElement(Mn,{size:2,direction:"horizontal"}),F.createElement(Tg,{ref:z,color:"$neutral600",size:"xsmall",variant:"body"},`($${A})`),Y&&F.createElement(Rl,{content:n.usdValue,container:Q},F.createElement(Jl,{size:12,color:"gray"}))),s==="list-item"&&F.createElement(Tb,{id:"widget-quote-token-amount-container",tooltipContainer:Q,type:"output",direction:"vertical",price:{value:I,usdValue:A,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:te.to.token.displayName,image:te.to.token.image},chain:{image:te.to.chain.image},percentageChange:v,warningLevel:N}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(Cr,{from:j.from,to:te.to,percentageChange:v,warningLevel:N}),F.createElement(Mn,{size:4}))),F.createElement(lg,{selected:c,listItem:s==="list-item",open:k,className:"quote_container",onOpenChange:x},F.createElement(Pg,{type:s,quoteRef:w,selected:c,setExpanded:x,container:Q,expanded:k,steps:P}),F.createElement(hg,{open:k},F.createElement(yg,null),F.createElement("div",{className:cg()},P.map((G,Ve)=>{let V=`item-${Ve}`;return F.createElement(Cb,{type:"quote-details",className:"widget-quote-step-details-container",key:V,tooltipContainer:Q,step:G,hasSeparator:Ve!==P.length-1,state:G.state})})))))}i(oc,"Quote");import{Divider as bb,Skeleton as Eb}from"@rango-dev/ui";import eo from"react";import{darkTheme as wb,styled as ua}from"@rango-dev/ui";var _g=ua("div",{$$color:"$colors$neutral100",[`.${wb} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),Dg=ua("div",{paddingTop:"$2"}),$g=ua("div",{paddingLeft:"$8"}),Fg=ua("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as jg,Divider as Nt,Skeleton as ut}from"@rango-dev/ui";import K from"react";import{css as vb,styled as Rt}from"@rango-dev/ui";var nc=Rt("div",{display:"flex"}),Og=Rt("div",{padding:"$10 $0 $20"}),Ug=Rt("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),zg=Rt("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Hg=Rt("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Qg=Rt("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),qg=Rt("div",{width:"65%",display:"flex",justifyContent:"start"}),Gg=Rt("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Vg=Rt("div",{padding:"$15 $0 $15 $0"}),Kg=vb({display:"flex",justifyContent:"space-between",alignItems:"center"});function wr(t){let{type:e,tagHidden:o=!0}=t,n=K.createElement(Hg,null,K.createElement(qg,null,K.createElement(jg,{loading:!0,size:"medium"}),K.createElement(Nt,{size:8,direction:"horizontal"}),K.createElement(Gg,null,K.createElement(ut,{height:10,width:60,variant:"rounded"}),K.createElement(Nt,{size:4}),K.createElement(ut,{height:15,variant:"rounded"}))),K.createElement(ut,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return K.createElement("div",null,!o&&K.createElement(K.Fragment,null,K.createElement(nc,null,K.createElement(ut,{width:65,height:20,variant:"rounded"}),K.createElement(Nt,{size:4,direction:"horizontal"}),K.createElement(ut,{width:65,height:20,variant:"rounded"}),K.createElement(Nt,{size:4,direction:"horizontal"}),K.createElement(ut,{width:65,height:20,variant:"rounded"})),K.createElement(ea,null),!r&&K.createElement(Nt,{size:4})),K.createElement("div",{className:Kg()},K.createElement(nc,null,K.createElement(ut,{width:60,height:10,variant:"rounded"}),K.createElement(Nt,{size:4,direction:"horizontal"}),K.createElement(ut,{width:60,height:10,variant:"rounded"}),K.createElement(Nt,{size:4,direction:"horizontal"}),K.createElement(ut,{width:60,height:10,variant:"rounded"})),r&&K.createElement(ut,{width:85,height:24,variant:"rounded"})),e==="basic"&&K.createElement(Og,null,K.createElement(ut,{height:15,width:148,variant:"rounded"})),e==="list-item"&&K.createElement(Ug,null,K.createElement(zg,null,K.createElement(jg,{loading:!0,size:"medium"}),K.createElement(Nt,{direction:"horizontal",size:4}),K.createElement(ut,{height:15,width:150,variant:"rounded"})),K.createElement(Nt,{size:10}),K.createElement(ut,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&K.createElement(K.Fragment,null,K.createElement(Nt,{size:4}),K.createElement(Vg,null,n,K.createElement(Qg,null),n),K.createElement(Nt,{size:12})))}i(wr,"QuoteSummarySkeleton");import{ChainToken as Rg,Divider as ic,NextIcon as xb,Skeleton as da}from"@rango-dev/ui";import We from"react";import{styled as vr}from"@rango-dev/ui";var Xg=vr("div",{display:"flex",alignItems:"start"}),Yg=vr("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),rc=vr("div",{display:"flex",alignItems:"center",flexGrow:1}),Zg=vr("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Jg=vr("div",{display:"flex",alignItems:"center"});function Ft(t){let{separator:e=!0}=t;return We.createElement(We.Fragment,null,We.createElement(Jg,null,We.createElement(da,{height:22,width:22,variant:"circular"}),We.createElement(ic,{direction:"horizontal",size:8}),We.createElement(da,{height:15,width:148,variant:"rounded"})),We.createElement(Xg,null,We.createElement(Fg,{hideSeparator:!e}),We.createElement(Yg,{extraSpace:e},We.createElement(rc,null,We.createElement(Rg,{size:"small",loading:!0}),We.createElement(ic,{direction:"horizontal",size:8}),We.createElement(da,{height:12,variant:"rounded"})),We.createElement(Zg,null,We.createElement(xb,{color:"gray",size:16})),We.createElement(rc,null,We.createElement(Rg,{size:"small",loading:!0}),We.createElement(ic,{direction:"horizontal",size:8}),We.createElement(da,{height:12,variant:"rounded"})))))}i(Ft,"StepSkeleton");function xr(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return eo.createElement(_g,{expanded:o,rounded:e!=="basic"},eo.createElement(wr,{type:e,tagHidden:n}),eo.createElement(Dg,null,eo.createElement(Eb,{height:15,variant:"rounded"})),o&&eo.createElement($g,null,eo.createElement(bb,{size:24}),eo.createElement(Ft,null),eo.createElement(Ft,null),eo.createElement(Ft,{separator:!1})))}i(xr,"QuoteSkeleton");function Go(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:c,onClick:l,showModalFee:p,selected:u,id:d,onClickAllRoutes:f,fullExpandedMode:h=!1,container:g}=t,{inputAmount:m,inputUsdValue:y}=H()(),S=e?.outputAmount?new Ib(e?.outputAmount):null,C=e?Ct(e):null,x=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?ma.createElement(Ql,null,ma.createElement(xr,{tagHidden:c,type:o,expanded:s})):x?ma.createElement(Ql,{onClick:()=>l?.(e),id:d},ma.createElement(oc,{quote:e,error:r,container:g,showModalFee:p,warning:a,tagHidden:c,selected:u,type:o,expanded:s,onClickAllRoutes:f,fullExpandedMode:h,input:{value:m,usdValue:y?.toString()??""},output:{value:S?.toString()??"",usdValue:C?.toString()??""}})):null}i(Go,"QuoteInfo");import{warn as Wb}from"@rango-dev/logging-core";import{calculatePendingSwap as Mb}from"@rango-dev/queue-manager-rango-preset";import{useEffect as Lb}from"react";import{useRef as Ab,useState as Nb}from"react";var Bb=2e3;function fa({request:t}){let[e,o]=Nb(!1),n=Ab(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async c=>(await new Promise(l=>setTimeout(l,Bb)),await s(c,!1)),"retryFetch"),s=i(async(c,l=!1)=>{r(),n.current=new AbortController,o(!0);try{let p=await t(c,{signal:n.current.signal});return n.current=null,p}catch(p){if(l)return await a(c);throw p}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(fa,"useFetch");function eh(){let{fetch:t,loading:e,cancelFetch:o}=fa({request:async(n,r)=>await ct().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(eh,"useFetchConfirmQuote");function ga(t){if(!t.swaps)throw new Error(re().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=ac(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(ga,"throwErrorIfResponseIsNotValid");function ac(t){if(Qd(t)){let{swap:n,fromAmountRangeError:r,recommendation:a}=qd(t);return n?{message:"bridge limit error",options:{type:3,swap:n,recommendation:a,fromAmountRangeError:r}}:null}let o=jd(t);if(o){let n=Bi(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(ac,"getQuoteError");function th(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,c={quote:null,balance:null},l=Cn({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});l&&(c.quote=l);let p=Zd(e,r,n.blockchains);return p.length===0||(c.balance={messages:p}),c}i(th,"generateWarnings");function ha(t){return t?.code==="ERR_CANCELED"?{type:2}:t.cause?t.cause:t?.code==="ERR_BAD_REQUEST"?{type:0,diagnosisMessage:t.response.data.error}:{type:1,diagnosisMessage:t.message}}i(ha,"handleQuoteErrors");function sc(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:c}=H()(),{slippage:l,customSlippage:p}=T(),u=T().getDisabledLiquiditySources(),d=T().blockchains(),f=T().tokens(),{findToken:h}=T(),{swapMode:g}=tt(),m=p||l,{fetch:y,cancelFetch:S,loading:C}=eh();return Lb(()=>S,[]),{loading:C,fetch:i(async x=>{let w=x.selectedWallets,I=x?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=w.reduce((E,v)=>(E[v.chain]=v.address,E),{}),b={requestId:a?.requestId||"",selectedWallets:A,destination:I||void 0};try{return await y(b,!0).then(E=>{let{result:v}=E;if(!v)throw new Error(E.error??"Error fetching updated quote");ga({diagnosisMessages:v.diagnosisMessages,requestId:v.requestId,swaps:v.result?.swaps});let N={outputAmount:v.result?.outputAmount,requestId:v.requestId,resultType:v.result?.resultType,swaps:v.result?.swaps||[],validationStatus:v.validationStatus,requestAmount:v.requestAmount};r(N);let M={slippage:m.toString(),disabledSwappersGroups:u},P=th({previousQuote:a??void 0,currentQuote:N,meta:{blockchains:d},selectedWallets:w,userSlippage:m,inputUsdValue:n,findToken:h});c();let U=!!P.balance,Q=Mb({inputAmount:o.toString(),bestRoute:v,wallets:Yd(w),settings:M,validateBalanceOrFee:!U,meta:{blockchains:d,tokens:f},swapMode:g});return{quote:N,swap:Q,error:null,warnings:P}})}catch(E){let v=ha(E);return v.type!==2&&Wb(new Error("confirm swap error"),{tags:{...v,type:Xe[v.type],initialQuote:a,requestBody:b}}),{swap:null,error:v,warnings:null}}},"fetch"),cancelFetch:S}}i(sc,"useConfirmSwap");var Qb=$b("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${oh}`]:{width:"$48",height:"$48"}}),qb=pc({flexGrow:1,paddingRight:"$10"}),Gb=pc({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),Vb=pc({display:"flex",justifyContent:"space-between",alignItems:"center"});function nh(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=H()(),s=Hb(),[c,l]=br(""),p=!n,[u,d]=br(!1),[f,h]=br(!1),{isActiveTab:g}=ne(),m=T().getDisabledLiquiditySources(),y=zb(m),{manager:S}=Pb(),{fetch:C,loading:k,cancelFetch:x}=sc(),[w,I]=br({swap:null,error:null,warnings:null}),[A,b]=br(!1),E=i(async({selectedWallets:W,customDestination:J})=>{let X=await C?.({selectedWallets:W,customDestination:J});return I(X),X},"onConfirmSwap"),v=i(async()=>{if(w.swap&&n)try{await S?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let W=`../${$.swaps}/${w.swap.requestId}`;s(W,{replace:!0}),setTimeout(()=>{e("")},0)}catch(W){l("Error: "+W?.message)}},"addNewSwap"),N=i(async()=>{h(!0),await v(),h(!1)},"onConfirm"),M=i(async()=>{w.warnings?.quote&&_d(w.warnings.quote)&&!a?b(!0):await N()},"onStartConfirmSwap"),P=i(async()=>{I({error:null,swap:null,warnings:null}),C({selectedWallets:o,customDestination:r}).then(W=>{I(W)}).catch(W=>console.error(W))},"onRefresh");ya(()=>{!!y.current.length&&!m.length&&P(),y.current=m},[m.length]),ya(()=>{p&&x()},[p]),ya(()=>{p&&d(p)},[p]),ya(()=>{p||C({selectedWallets:o,customDestination:r}).then(W=>I(W)).catch(W=>console.error(W))},[]),Ub(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let U=w.warnings?.quote??null,Q=w.error,Z=[];if(c&&Z.push(De.createElement(_b,{id:"widget-confirm-swap-db-error-alert",type:"error",variant:"alarm",title:c})),U||Q){let W=`../${$.settings}`;Z.push(De.createElement(Sr,{warning:U,error:Q,couldChangeSettings:!1,refetchQuote:P,skipAlerts:Q?.type===4||U?.type===2,showWarningModal:A,confirmationDisabled:!g,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:async()=>{b(!1),await v()},onChangeSettings:()=>s(W)}))}return De.createElement(se,{header:{title:lc.t("Confirm Swap"),onWallet:()=>{let W=`../${$.wallets}`;s(W)}},footer:De.createElement(Qb,null,De.createElement("div",{className:qb()},De.createElement(Db,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:k||f,disabled:!!w.error||!g,onClick:M},lc.t("Start Swap"))),De.createElement(oh,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:k||f,disabled:!g,onClick:d.bind(null,!0)},De.createElement(Ob,{size:24})))},u&&De.createElement(Ff,{open:u,onClose:()=>d(!1),onCancel:x,loading:k,onCheckBalance:E}),De.createElement(ce,null,De.createElement("div",{className:Vb()},De.createElement(Fb,{variant:"title",size:"small"},lc.t("You get")),De.createElement("div",{className:Gb()},De.createElement(Fi,{onClick:!k&&!u&&!A?P:void 0}))),De.createElement(cc,{size:"12"}),Am(Z.map((W,J)=>({element:W,key:`alert-${J}`})),De.createElement(cc,{size:10})),Z.length>0?De.createElement(cc,{size:10}):null,De.createElement(Go,{quote:t,type:"swap-preview",id:"widget-confirm-swap-quote-container",expanded:!0,tagHidden:!0,error:w.error,loading:k,warning:w.warnings?.quote??null})))}i(nh,"ConfirmSwapPage");import{i18n as oo}from"@lingui/core";import{Button as wc,CustomTokensZeroStateDarkIcon as dE,CustomTokensZeroStateIcon as mE,DeleteIcon as fE,Divider as Br,IconButton as gE,MessageBox as hE,NotFound as yE,styled as xc}from"@rango-dev/ui";import he,{useState as vc}from"react";import{useNavigate as SE}from"react-router-dom";import{CloseIcon as Kb,IconButton as jb,SearchIcon as Xb,TextField as Yb}from"@rango-dev/ui";import Pn from"react";import{styled as rh}from"@rango-dev/ui";var ih=rh("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"}),ah=rh("div",{width:"100%","& ._text-field":{paddingLeft:"$10","& input":{paddingLeft:"$2",paddingTop:"$12",paddingBottom:"$12"}}});function Bt(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:c,setValue:l,suffix:p,id:u,...d}=t,f=s.length?Pn.createElement(jb,{id:`${u}\u06F0icon-btn`,variant:"ghost",onClick:()=>l?.(""),size:"small"},Pn.createElement(Kb,{color:"gray",size:10})):null;return p&&(f=p),Pn.createElement(ah,null,Pn.createElement(Yb,{prefix:Pn.createElement(ih,null,Pn.createElement(Xb,{color:"black"})),id:u,suffix:f,fullWidth:o,color:n,variant:e,style:{borderRadius:25,alignItems:"center",...c},size:r,value:s,onChange:a,...d}))}i(Bt,"SearchInput");import{i18n as kc}from"@lingui/core";import{Button as eE,CustomTokenWarning as tE,darkTheme as Sh,Divider as to,ExternalLinkIcon as oE,Image as nE,ListItem as rE,NotFound as iE,PinIcon as aE,Skeleton as Vo,Typography as Ar,VirtualizedList as sE}from"@rango-dev/ui";import L,{useState as lE}from"react";import{useTranslation as cE}from"react-i18next";import{Divider as hh,ListItem as Rb,Skeleton as Ir}from"@rango-dev/ui";import Wt from"react";import{css as _n,darkTheme as uc,ImageContainer as Zb,ListItemButton as Jb,styled as rt,Typography as sh}from"@rango-dev/ui";var dc=_n({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),mc=_n({position:"relative",height:12,width:"30%",maxWidth:"150px"}),fc=_n({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),gc=_n({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${uc} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),hc=_n({}),yc=_n(),lh=rt("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Sc=rt("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),Sa=rt("ul",{flexGrow:1,height:"100%",padding:0,margin:0,display:"flex",flexDirection:"column",listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${mc}`]:{[`& .${gc}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${hc}`]:{bottom:"-15px"},[`& .${dc}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${fc}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),ch=rt(Jb,{variants:{customToken:{true:{"&:hover":{cursor:"unset"}}}}}),Cc=rt("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),Tc=rt(sh,{}),ph=rt("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${yc}`]:{$$color:"$colors$neutral600",[`.${uc} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Er=rt("div",{display:"flex",alignItems:"end",flexDirection:"column"}),AV=rt("div",{display:"flex",alignItems:"center"}),uh=rt("div",{position:"relative",[`& ${Zb}`]:{borderRadius:"$xm",overflow:"hidden"}}),dh=rt("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),mh=rt(sh,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),fh=rt("a",{"& svg:hover":{color:"$colors$info"}}),gh=rt("div",{paddingRight:"$5","& .widget-token-list-item-btn":{width:"100%",overflow:"hidden",height:"60px"},"& .widget-token-list-item-import-btn":{height:"$20",padding:"0 $10","& ._text":{display:"flex",justifyContent:"center",alignItems:"center"},"& ._typography":{[`.${uc} &`]:{color:"$foreground"}}}});function yh(t){return Wt.createElement(Sa,null,Array.from(Array(t.size),e=>Wt.createElement(Rb,{key:e,hasDivider:!0,start:Wt.createElement(Ir,{variant:"circular",width:35,height:35}),end:Wt.createElement(Er,null,Wt.createElement(Ir,{variant:"text",size:"large",width:70}),Wt.createElement(hh,{size:4}),Wt.createElement(Ir,{variant:"text",size:"medium",width:50})),title:Wt.createElement("div",null,Wt.createElement(Ir,{variant:"text",size:"large",width:90}),Wt.createElement(hh,{size:4}),Wt.createElement(Ir,{variant:"text",size:"medium",width:90}))})))}i(yh,"LoadingTokenList");var pE=20,uE=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,c=e.length;return L.createElement("div",{className:mc()},o?L.createElement("div",{className:dc()},o):L.createElement(Sc,{className:fc()},L.createElement(Ar,{variant:"title",size:"xmedium"},r.symbol),L.createElement(to,{direction:"horizontal",size:4}),L.createElement(Cc,{css:a},L.createElement(Tc,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&L.createElement("div",{className:`${gc()} ${!o&&hc()}`},c>10?`${e.slice(0,5)}...${e.slice(c-6,c)}`:e," ",L.createElement(to,{size:4,direction:"horizontal"}),L.createElement(fh,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:l=>l.stopPropagation()},L.createElement(oE,{size:12}))))},"renderDesc");function Nr(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s,type:c,showWarning:l=!0}=t,p=T().fetchStatus,u=T().blockchains(),{getBalanceFor:d,fetchingWallets:f}=T(),{isTokenPinned:h}=T(),{setFromToken:g,setToToken:m}=H()(),{t:y}=cE(),S=Qe(),[C,k]=lE(null),x=i(()=>{c==="source"?g({token:C,meta:{blockchains:u}}):m({token:C,meta:{blockchains:u}})},"updateToken"),w=i(()=>{x(),S()},"handleImportToken"),I=i(E=>{if(E.customToken){let{customToken:N,...M}=E;return L.createElement(eE,{variant:"contained",type:"primary",size:"small",className:"widget-token-list-item-import-btn",onClick:i(U=>{U.stopPropagation(),k({...M,warning:!0})},"handleClick")},L.createElement(Ar,{variant:"body",size:"xsmall",color:"background"},y("import")))}let v=pi(d(E));return s?s(E):f?L.createElement(Er,null,L.createElement(Vo,{variant:"text",size:"large",width:70}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:50})):v&&L.createElement(ph,null,L.createElement(mh,{variant:"title",size:"small"},v.amount),L.createElement("div",null),v.usdValue&&L.createElement(Ar,{variant:"body",className:yc(),size:"xsmall"},`$${v.usdValue}`))},"endRenderer"),A=i(()=>L.createElement(sE,{style:{flexGrow:1,minHeight:0},itemContent:E=>{let v=e[E];if(v==="skeleton")return L.createElement(rE,{hasDivider:!0,start:L.createElement(Vo,{variant:"circular",width:35,height:35}),end:L.createElement(Er,null,L.createElement(Vo,{variant:"text",size:"large",width:70}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:50})),title:L.createElement("div",null,L.createElement(Vo,{variant:"text",size:"large",width:90}),L.createElement(to,{size:4}),L.createElement(Vo,{variant:"text",size:"medium",width:90}))});let N=u.find(W=>W.name===v?.blockchain);if(!N||!v)return null;let M=v.address,P=sl(N.color,"main"),U={$$color:P.main150,[`.${Sh} &`]:{$$color:P.main750},backgroundColor:"$$color"},Q={$$color:P.main750,[`.${Sh} &`]:{$$color:P.main150},color:"$$color"},Z=i(()=>{typeof v!="string"&&!v.customToken&&n?.(v)},"handleClick");return L.createElement(gh,null,L.createElement(ch,{"tab-index":E,key:`${v.symbol}${M}`,id:`${v.symbol}${M}`,className:"widget-token-list-item-btn",hasDivider:!0,customToken:v?.customToken,onClick:Z,start:L.createElement(uh,null,L.createElement(nE,{src:v.image===""?ti:v.image,size:30}),t.type!=="custom-token"&&v&&h(v,t.type)&&L.createElement(dh,null,L.createElement(aE,{size:12,color:"gray"}))),title:N.type==="COSMOS"||v.name||!v.name&&!M?L.createElement(Sc,null,L.createElement(Ar,{variant:"title",size:"xmedium"},v.symbol),L.createElement(to,{direction:"horizontal",size:4}),L.createElement(Cc,{css:U},L.createElement(Tc,{variant:"body",size:"xsmall",css:Q},v.blockchain)),l&&v.warning&&L.createElement(L.Fragment,null,L.createElement(to,{direction:"horizontal",size:4}),L.createElement(tE,{container:B()}))):void 0,description:typeof v!="string"&&N.info&&M&&N.type!=="COSMOS"?uE({address:M,token:v,customCssForTag:U,customCssForTagTitle:Q,name:v.name,url:N.info.addressUrl.split("{wallet}").join(M)}):v.name||void 0,end:I(v)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList"),b=C?No(C?.blockchain,u):null;return L.createElement(L.Fragment,null,a&&L.createElement(L.Fragment,null,L.createElement(Ar,{variant:"label",size:"large"},kc.t("Select Token")),L.createElement(to,{size:4})),L.createElement(lh,null,L.createElement(to,{size:4}),p==="loading"&&L.createElement(yh,{size:pE}),p==="success"&&(e.length?L.createElement(L.Fragment,null,L.createElement(mr,{token:C,address:C?.address??"",blockchain:b??void 0,onImport:w,onExitErrorModal:()=>k(null),onExitImportModal:()=>k(null)}),L.createElement(Sa,{as:"ul"},A())):!!o&&L.createElement(iE,{title:kc.t("No results found"),description:kc.t("Try using different keywords")}))))}i(Nr,"TokenList");var CE=xc("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),TE=xc("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),kE=xc(gE,{"&:hover":{"& svg":{color:"$secondary550"}}});function Ch(){let[t,e]=vc(""),{deleteCustomToken:o}=T(),n=T().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:c}=H()(),{mode:l}=mo({}),p=SE(),[u,d]=vc(!1),[f,h]=vc(),g=i(C=>{let k=C.target.value;e(k)},"handleSearch"),m=l==="dark",y=n.filter(C=>st(C.symbol,t)||st(C.address||"",t)||st(C.name||"",t)),S=i(()=>{if(f){let C=a?St(a):null,k=r?St(r):null,x=St(f);C===x?c({token:null}):k===x&&s({token:null}),o(f)}d(!1)},"handleDeleteCustomToken");return he.createElement(se,{header:{title:oo.t("Custom Tokens")}},he.createElement(ce,null,he.createElement(CE,null,n.length?he.createElement(he.Fragment,null,he.createElement(Bt,{id:"widget-custom-tokens-search-token-input",value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:oo.t("Search Token"),onChange:g}),he.createElement(Br,{size:16}),he.createElement(Nr,{list:y,type:"custom-token",searchedFor:t,showTitle:!1,showWarning:!1,action:C=>he.createElement(kE,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{d(!0),h(C)}},he.createElement(fE,{size:12,color:"gray"}))})):he.createElement(TE,null,he.createElement(yE,{icon:m?he.createElement(dE,{size:200}):he.createElement(mE,{size:200}),title:oo.t("No custom tokens"),description:oo.t("press the button to add your custom token")})),he.createElement(Br,{size:20}),he.createElement(wc,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>p($.addCustomTokens)},oo.t("Add Custom Token"))),he.createElement(ee,{open:u,id:"widget-custom-tokens-delete-modal",dismissible:!0,onClose:()=>d(!1),container:B()},he.createElement(hE,{title:oo.t("Delete Custom Token"),type:"error",description:oo.t("Are you sure you want to Delete this Token?")},he.createElement(Br,{size:40}),he.createElement(Br,{size:10}),he.createElement(wc,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},oo.t("Yes, Delete it")),he.createElement(Br,{size:12}),he.createElement(wc,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>d(!1)},oo.t("No, Continue"))))))}i(Ch,"CustomTokensPage");import{i18n as $e}from"@lingui/core";import{useManager as zE}from"@rango-dev/queue-manager-react";import{Button as Wc,darkTheme as HE,Divider as To,MessageBox as QE,NotFound as qE,styled as Mc,Tabs as GE,Typography as ka}from"@rango-dev/ui";import{TransactionStatus as Lr}from"rango-types";import oe,{useMemo as Fh,useState as Pr}from"react";import{useNavigate as VE}from"react-router-dom";import{FilterIcon as AE,Popover as NE}from"@rango-dev/ui";import Ko from"react";import{css as wE,darkTheme as Ca,IconButton as vE,styled as Wr}from"@rango-dev/ui";var bc=Wr("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${Ca} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),Th=Wr(vE,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${Ca} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${Ca} &`]:{backgroundColor:"$neutral"},[`& ${bc}::before`]:{backgroundColor:"$secondary100",[`.${Ca} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),kh=Wr("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),wh=Wr("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),vh=wE({display:"flex",justifyContent:"space-between",alignItems:"center"}),xh=Wr("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as bh}from"@lingui/core";import{Button as xE,Divider as Eh,ListItemButton as bE,Radio as EE,RadioRoot as IE,Typography as Ih}from"@rango-dev/ui";import dt from"react";function Ah(t){let{filterBy:e,onClickItem:o}=t;return dt.createElement(wh,null,dt.createElement("div",{className:vh()},dt.createElement(Ih,{size:"small",variant:"body"},bh.t("Status")),dt.createElement(xE,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},bh.t("Reset"))),dt.createElement(Eh,{size:10}),dt.createElement(IE,{value:e},dt.createElement(xh,null,t.list.map((n,r)=>dt.createElement(bE,{key:n.id,className:"widget-filter-selector-list-item-btn",style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:dt.createElement(dt.Fragment,null,dt.createElement(Eh,{direction:"horizontal",size:4}),dt.createElement(Ih,{size:"medium",variant:"body"},n.title)),start:dt.createElement(EE,{value:n.id}),onClick:o})))))}i(Ah,"FilterSelectorContent");function Ec(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return Ko.createElement("div",null,Ko.createElement(NE,{open:a,align:"end",onOpenChange:o,container:B(),content:Ko.createElement(Ah,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},Ko.createElement(Th,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},Ko.createElement(bc,{isSelect:!!n},Ko.createElement(AE,{size:16,color:"black"}),!!n&&Ko.createElement(kh,null)))))}i(Ec,"FilterSelector");import{i18n as ME}from"@lingui/core";import{getCurrentStep as LE}from"@rango-dev/queue-manager-rango-preset";import{Divider as Lh,GroupedVirtualizedList as PE,Skeleton as _E,SwapListItem as Ph,Typography as DE}from"@rango-dev/ui";import Ye,{useCallback as _h,useEffect as $E,useRef as FE,useState as OE}from"react";function Nh(t,e){let o=[],n=0;do{let r=t[n];r&&(o.push(Math.min(r,e)),e-=r),n++}while(e>0&&n<=t.length);return o}i(Nh,"calculateGroupsSoFar");import{css as BE,darkTheme as WE,styled as Mr}from"@rango-dev/ui";var Ic=BE(),Bh=Mr("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),Ac=Mr("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${Ic}`]:{$$color:"$colors$neutral600",[`.${WE} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Nc=Mr("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),Wh=Mr("div",{gap:"$10",display:"flex",flexDirection:"column"}),Mh=Mr("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var UE=10;function Bc(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=OE([]),c=FE(0),{swaps:l,groupCounts:p,groups:u}=n(e),d=_h(Nh,[]),f=_h(()=>{let h=e.length-c.current;h&&(c.current+=Math.min(h,UE),s(d(p,c.current)))},[e.length]);if($E(()=>{r||f()},[r,f]),r){let h=[1,2];return Ye.createElement(Ye.Fragment,null,[h,h].map((m,y)=>Ye.createElement(Ac,{key:y},Ye.createElement(Nc,null,Ye.createElement(_E,{variant:"text",width:60,size:"small"}),Ye.createElement(Lh,{size:16})),Ye.createElement(Lh,{size:4}),Ye.createElement(Wh,null,m.map((C,k)=>Ye.createElement(Ph,{isLoading:!0,key:k}))))))}return Ye.createElement(PE,{style:{flexGrow:1,minHeight:0},endReached:()=>{c.current<e.length&&f()},groupCounts:a,groupContent:h=>Ye.createElement(Ac,null,Ye.createElement(Nc,null,Ye.createElement(DE,{variant:"label",size:"medium",className:Ic()},u[h]))),itemContent:(h,g)=>{let m=l[h];if(!m)return null;let y=LE(m),S=m.steps[0],C=m.steps[m.steps.length-1];return!S||!C?null:Ye.createElement(Bh,{key:m.requestId},Ye.createElement(Ph,{className:"widget-history-group-list-swap-item-btn",requestId:m.requestId,creationTime:m.creationTime,status:m.status,onClick:o,currentStep:y,tooltipContainer:B(),onlyShowTime:u[g]===ME.t("Today"),swapTokenData:{from:{token:{image:S.fromLogo,displayName:S.fromSymbol},blockchain:{image:S.fromBlockchainLogo||""},amount:_(m.inputAmount,6,6),realAmount:m.inputAmount},to:{token:{image:C.toLogo,displayName:C.toSymbol},blockchain:{image:C.toBlockchainLogo||""},amount:_(C.outputAmount||C.expectedOutputAmountHumanReadable||"",6,6),realAmount:C.outputAmount||C.expectedOutputAmountHumanReadable||""}}}))}})}i(Bc,"HistoryGroupedList");import{i18n as Ta}from"@lingui/core";import Dh from"dayjs";var $h=i(t=>{let e=new Map([["today",{title:Ta.t("Today"),swaps:[]}],["week",{title:Ta.t("This week"),swaps:[]}],["month",{title:Ta.t("This month"),swaps:[]}],["year",{title:Ta.t("This year"),swaps:[]}]]);function o(l,p){e.has(l)||e.set(l,{title:l,swaps:[]}),e.get(l)?.swaps.push(p)}i(o,"addYearsToOutput");let n=Dh();t.forEach(l=>{let p=Number(l.creationTime),u=Dh(p);if(n.isSame(u,"day"))e.get("today")?.swaps.push(l);else if(n.isSame(u,"week"))e.get("week")?.swaps.push(l);else if(n.isSame(u,"month"))e.get("month")?.swaps.push(l);else if(n.isSame(u,"year"))e.get("year")?.swaps.push(l);else{let d=new Date(p).getFullYear().toString();o(d,l)}});let r=Array.from(e.values()).filter(l=>l.swaps.length>0),a=r.flatMap(l=>l.swaps),s=r.map(l=>l.swaps.length),c=r.map(l=>l.title);return{swaps:a,groupCounts:s,groups:c}},"groupSwapsByDate");var KE=Mc("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%",minHeight:0,flexGrow:1}),jE=Mc("div",{display:"flex",justifyContent:"center",alignItems:"center"}),XE=Mc("div",{"._typography":{color:"$neutral700",[`.${HE}&`]:{color:"$neutral900"}}}),YE=i((t,e)=>t?.length?t.filter(o=>Pt(o.fromBlockchain,e)||Pt(o.toBlockchain,e)||Pt(o.toSymbol,e)||Pt(o.fromSymbol,e)).length:!1,"isStepContainsText");function Oh(){let t=VE(),{manager:e,state:o}=zE(),n=kt(e).map(({swap:b})=>b),[r,a]=Pr(""),[s,c]=Pr(!1),l=!o.loadedFromPersistor,[p,u]=Pr(""),[d,f]=Pr(!1),[h,g]=Pr("all"),m=i(b=>{let E=b.target.value;a(E)},"handleSearch"),{isMultiMode:y}=tt(),S=[{id:Lr.SUCCESS,title:$e.t("Complete")},{id:Lr.RUNNING,title:$e.t("Running")},{id:Lr.FAILED,title:$e.t("Failed")}],C=[{id:"all",title:$e.t("All")},{id:"swap",title:$e.t("Swap")},{id:"refuel",title:$e.t("Refuel")}],k=Fh(()=>!r&&!p&&h==="all"?n:n.filter(b=>{let{inputAmount:E,status:v,steps:N,requestId:M,mode:P}=b;return(!r||Pt(E,r)||Pt(v,r)||YE(N,r)||Pt(M,r))&&(!p||p===v)&&(h==="all"?!0:h==="swap"?!P||P==="swap":h==="refuel"?P==="refuel":!1)}),[n,r,p,h]),x=!k?.length&&!l,w=i(()=>f(!1),"onCloseModal"),I=i(async()=>{try{await e?.clearQueue(),f(!1)}catch(b){console.log(b)}},"onClear"),A=Fh(()=>!n.some(b=>b.status===Lr.SUCCESS||b.status===Lr.FAILED),[n]);return oe.createElement(se,{header:{title:$e.t("History"),suffix:oe.createElement(fo,null,oe.createElement(Wc,{id:"widget-history-clear-btn",disabled:A,variant:"ghost",size:"xsmall",onClick:()=>f(!0)},oe.createElement(ka,{size:"medium",variant:"label",color:"error"},$e.t("Clear"))))}},oe.createElement(ce,null,oe.createElement(jE,null,oe.createElement(Bt,{setValue:a,fullWidth:!0,variant:"contained",placeholder:$e.t("Search Transaction"),id:"widget-history-search-transaction-input",autoFocus:!0,onChange:m,style:{height:36},value:r}),oe.createElement(To,{size:10,direction:"horizontal"}),oe.createElement(Ec,{filterBy:p,open:s,onOpenChange:b=>c(b),onClickItem:b=>u(b),list:S})),oe.createElement(To,{size:"16"}),y&&!l&&oe.createElement(oe.Fragment,null,oe.createElement(GE,{items:C,onChange:b=>g(b.id),value:h,type:"secondary"}),oe.createElement(To,{size:"12"})),oe.createElement(KE,null,x&&oe.createElement(Mh,null,oe.createElement(To,{size:32}),oe.createElement(qE,{title:r?$e.t("No results found"):$e.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?$e.t("Try using different keywords"):$e.t("Your transaction history is stored locally and will appear here after you start a swap")})),!x&&oe.createElement(Bc,{list:k,onSwapClick:t,groupBy:$h,isLoading:l}))),oe.createElement(ee,{open:d,onClose:w,id:"widget-history-clear-modal",container:B()},oe.createElement(To,{size:20}),oe.createElement(QE,{type:"warning",title:$e.t("Clear Transaction History"),description:oe.createElement(XE,null,oe.createElement(ka,{variant:"body",size:"medium"},$e.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),oe.createElement(To,{size:"24"}),oe.createElement(ka,{variant:"body",size:"small"},$e.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),oe.createElement(To,{size:30}),oe.createElement(Wc,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:I},$e.t("Yes, Clear the history")),oe.createElement(To,{size:10}),oe.createElement(Wc,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:w},oe.createElement(ka,{variant:"title",size:"medium",color:"primary"},$e.t("No, Cancel")))))}i(Oh,"HistoryPage");import{i18n as gy}from"@lingui/core";import{Button as MI,Divider as Vc,styled as LI,WarningIcon as PI}from"@rango-dev/ui";import _I from"bignumber.js";import Te,{useEffect as hy,useState as yy}from"react";import{useNavigate as DI}from"react-router-dom";import{i18n as zh}from"@lingui/core";import{Alert as JE,Divider as Lc,NoRouteIcon as RE,Typography as eI}from"@rango-dev/ui";import jo from"react";import{styled as ZE}from"@rango-dev/ui";var Uh=ZE("div",{display:"flex",flexDirection:"column",alignItems:"center"});function Pc(){let{fromToken:t,toToken:e}=H()();return!!t&&!!e&&qt(t,e)?jo.createElement(Uh,null,jo.createElement(Lc,{size:10}),jo.createElement(RE,{size:24,color:"gray"}),jo.createElement(Lc,{size:4}),jo.createElement(eI,{variant:"title",size:"small"},zh.t("No Routes Found")),jo.createElement(Lc,{size:4}),jo.createElement(JE,{title:zh.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(Pc,"SameTokensWarning");import{Alert as tI,Button as oI}from"@rango-dev/ui";import Qh from"react";import{i18n as wa}from"@lingui/core";function Hh(t){let e=null;return t===fi?(e={alertType:"error",action:"reset-slippage",actionButtonTitle:wa.t("Reset"),title:wa.t("Slippage cannot be set lower than 0.01%.")},e):t>sn?(e={alertType:"warning",action:"change-settings",actionButtonTitle:wa.t("Change"),title:wa.t("Caution, your slippage is high!")},e):null}i(Hh,"makeAlerts");function qh(t){let{slippage:e,customSlippage:o,setSlippage:n,setCustomSlippage:r}=T(),{onChangeSettings:a}=t,c=Hh(o!==null?o:e),l=i(p=>{p==="reset-slippage"?(n(mi),r(null)):p==="change-settings"&&a()},"onClickActionButton");return c?Qh.createElement(tI,{title:c.title,type:c.alertType,variant:"alarm",action:Qh.createElement(oI,{id:"widget-slippage-warning-error-change-settings-or-reset-slippage-btn",size:"xxsmall",type:c.alertType,onClick:()=>l(c.action)},c.actionButtonTitle)}):null}i(qh,"SlippageWarningsAndErrors");import{i18n as sI}from"@lingui/core";import{IconButton as lI,ReverseIcon as cI,Skeleton as pI,Tooltip as uI,Typography as _r}from"@rango-dev/ui";import mt from"react";import va from"bignumber.js";function Vh(t){let{error:e,isDarkTheme:o,warning:n}=t,{quoteError:r,slippageError:a}=e,{quoteWarning:s,slippageWarning:c}=n,l=!!a||r?.type===4,p=!!c||s?.type===2;return l?"$error500":p?"$warning500":o?"$neutral600":"$neutral700"}i(Vh,"getSlippageColor");function Kh(t){let{toTokenUsdPrice:e,fromTokenUsdPrice:o}=t;if(!e||!o)return{rawValue:"0",displayValue:"0"};let n=new va(e),r=new va(o),a=n.dividedBy(r),s;return a.isLessThan(1)?s=a.toFixed(14).replace(/\.?0+$/,""):a.toFixed(0).length>10?s=a.toFixed(0).slice(0,10):s=a.toFixed(2),{displayValue:s,rawValue:a.toFixed()}}i(Kh,"getUsdExchangeRate");function jh(t,e){let o=new va(t).multipliedBy(e);return o.isLessThan(.001)?"$0":`$${o.decimalPlaces(2,va.ROUND_DOWN).toFormat(2)}`}i(jh,"formatTokenValueInUsd");import{darkTheme as iI,styled as Dc,Typography as aI}from"@rango-dev/ui";var Xh=Dc("div",{display:"flex",padding:"$4",justifyContent:"space-between",alignItems:"center"}),Yh=Dc("div",{display:"flex",alignItems:"center",gap:"$2","& .rate-text":{color:"$neutral700",[`.${iI} &`]:{color:"$neutral700"}},"& ._icon-button":{transform:"rotate(90deg)",width:"$16",height:"$16"}}),$c=Dc(aI,{maxWidth:"$32",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"});function Fc(t){let{slippage:e,customSlippage:o,quoteTokensRate:n,changeQuoteTokensRate:r}=T(),{quoteError:a,quoteWarning:s,fromToken:c,toToken:l,quote:p,loading:u}=t,d=o!==null?o:e,{mode:f}=mo({}),h=pn(d),g=f==="dark",m=n==="default",y={quoteError:a,slippageError:h?.type==="error"?h.message:null},S={quoteWarning:s,slippageWarning:h?.type==="warning"?h.message:null},C=p?.swaps[0]?.from||c,k=p?.swaps[p?.swaps.length-1]?.to||l,x=m?C:k,w=m?k:C,I=Number(m?p?.outputAmount:p?.requestAmount),A=Number(m?p?.requestAmount:p?.outputAmount),b=I||x.usdPrice,E=A||w.usdPrice,{rawValue:v,displayValue:N}=Kh({toTokenUsdPrice:E,fromTokenUsdPrice:b});return mt.createElement(Xh,null,mt.createElement(_r,{variant:y||S?"label":"body",size:y||S?"medium":"small",color:Vh({error:y,warning:S,isDarkTheme:g})},sI.t("Slippage:")," ",d,"%"),u?mt.createElement(pI,{height:16,width:104,variant:"rounded"}):b&&E&&mt.createElement(Yh,null,mt.createElement(_r,{className:"rate-text",variant:"body",size:"small"},"1"),mt.createElement($c,{className:"rate-text",variant:"body",size:"small"},w.symbol),mt.createElement(lI,{id:"widget-home-page-change-rate-button",onClick:r},mt.createElement(cI,{size:14,color:"secondary"})),mt.createElement(uI,{container:B(),side:"top",sideOffset:4,content:mt.createElement(_r,{className:"rate-text",variant:"body",size:"small"},v)},mt.createElement(_r,{className:"rate-text",variant:"body",size:"small"},N)),mt.createElement($c,{className:"rate-text",variant:"body",size:"small"},x.symbol),x.usdPrice&&mt.createElement(_r,{color:"neutral600",variant:"body",size:"small"},"~",jh(Number(v),x.usdPrice))))}i(Fc,"SwapMetrics");import{i18n as yI}from"@lingui/core";import{Header as SI}from"@rango-dev/ui";import ko,{useEffect as CI,useState as TI}from"react";import{i18n as mI}from"@lingui/core";import{Divider as Uc,FullExpandedQuote as fI,Typography as gI}from"@rango-dev/ui";import xe from"react";import{styled as Oc}from"@rango-dev/ui";var Zh=Oc("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Jh=Oc("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Rh=Oc("div",{width:"146px"});import{i18n as Dr}from"@lingui/core";import{Select as dI}from"@rango-dev/ui";import ey from"react";function xa(t){let{updateQuotePartialState:e,sortStrategy:o}=H()(),n=[{value:"SMART",label:Dr.t("Smart Routing")},{value:"FEE",label:Dr.t("Lowest Fee")},{value:"SPEED",label:Dr.t("Fastest Transfer")},{value:"NET_OUTPUT",label:Dr.t("Maximum Return")},{value:"PRICE",label:Dr.t("Maximum Output")}];return ey.createElement(Rh,null,ey.createElement(dI,{id:"widget-quotes-strategy-select",container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(xa,"SelectStrategy");var ty=3;function $r(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:c}=t,{selectedQuote:l,quotes:p,updateQuotePartialState:u,fromToken:d,toToken:f,sortStrategy:h,error:g}=H()(),{slippage:m,customSlippage:y}=T(),{findToken:S}=T(),C=c||B(),k=!!p&&p.results.length,x=y??m,{config:{__UNSTABLE_OR_INTERNAL__:w}}=T(),I=i(E=>{if(!d||!f||!p)return null;let v={requestAmount:p.requestAmount,validationStatus:null,...E};return Cn({currentQuote:v,userSlippage:x,findToken:S})},"getQuoteWarning"),A=g?.type===0||g?.type===1,b=p?.results?Ai(h,p?.results):[];return xe.createElement(xe.Fragment,null,a&&xe.createElement(xe.Fragment,null,xe.createElement(Jh,null,xe.createElement(gI,{size:"xmedium",variant:"title"},mI.t("Sort by")),xe.createElement(xa,{container:C})),xe.createElement(Uc,{size:"10"})),e&&Array.from({length:ty},(E,v)=>xe.createElement(xe.Fragment,{key:v},s?xe.createElement(fI,{campaignTag:w?.campaignTag,loading:!0}):xe.createElement(xr,{tagHidden:!1,type:"list-item",expanded:!1}),v!==ty-1&&xe.createElement(Uc,{size:16}))),!e&&xe.createElement(xe.Fragment,null,k?b.map((E,v)=>{let N=I(E),M=ac(E.swaps),P=b.length-1===v;return xe.createElement(xe.Fragment,{key:E.requestId},xe.createElement(Go,{id:"widget-quotes-quote-info-container",showModalFee:r,container:C,selected:l?.requestId===E.requestId,tagHidden:!1,quote:{...E,requestAmount:p.requestAmount,validationStatus:null},loading:e,error:M?.options||null,warning:N,fullExpandedMode:s,onClick:U=>{M||u("warning",N),u("error",M?.options||null),o(U)},type:"list-item"}),!P&&xe.createElement(Uc,{size:16}))}):A&&xe.createElement(Zh,null,xe.createElement(hr,{size:s?"large":"small",error:g,fetch:n}))))}i($r,"Quotes");import{darkTheme as hI,styled as oy}from"@rango-dev/ui";var ny=oy("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${hI} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),ry=oy("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var kI=100;function zc(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,c]=TI(!1),l=s?"":"is-hidden",{config:p}=T(),u=p?.variant==="full-expanded",d=Wo();return CI(()=>{let f=null;return a?f=setTimeout(()=>{c(!0)},kI):(c(!1),f&&clearTimeout(f)),()=>{f&&clearTimeout(f)}},[a]),ko.createElement(ny,{expandMode:p?.variant==="full-expanded"?"full":"default",className:`${l} ${Hi()} widget-expanded-quotes-container`,id:Re.EXPANDED_BOX_ID},ko.createElement(SI,{title:yI.t("Routes"),suffix:ko.createElement(ko.Fragment,null,ko.createElement(xa,{container:d}),ko.createElement(zo,{container:d,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),ko.createElement(ry,null,ko.createElement($r,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:Wo(),onClickOnQuote:n,fullExpandedMode:u})))}i(zc,"ExpandedQuotes");import{i18n as uy}from"@lingui/core";import{SwapInput as dy}from"@rango-dev/ui";import bI from"bignumber.js";import Fr from"react";import{ReverseIcon as xI}from"@rango-dev/ui";import Qc from"react";import{keyframes as wI,styled as iy}from"@rango-dev/ui";var Hc=450,vI=wI({"0%":{transform:"rotateX(0deg) rotateY(0deg) rotateZ(0deg)"},"33%":{transform:"rotateX(0deg) rotateZ(78deg) rotateY(66deg)"},"66%":{transform:"rotateX(0deg) rotateZ(163deg) rotateY(66deg)"},"100%":{transform:"rotateX(0deg) rotateZ(180deg) rotateY(0deg)"}}),ay=iy("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),sy=iy("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${vI} ${Hc}ms ease-in-out forwards`}},"&:hover":{color:"$secondary500",transform:"translateY(1px) scale(1.04)",boxShadow:"1px 1px 1px 1px rgba(0, 0, 0, 0.05)"}});function qc(){let t=H().use.switchFromAndTo();return Qc.createElement(ay,null,Qc.createElement(sy,{id:"widget-switch-from-and-to-btn",onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},Hc),t()}},Qc.createElement(xI,{size:12})))}i(qc,"SwitchFromAndToButton");import{styled as ly}from"@rango-dev/ui";var cy=ly("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),py=ly("div",{position:"relative"});function Gc(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:c,toBlockchain:l,setInputAmount:p,sanitizeInputAmount:u,inputAmount:d,inputUsdValue:f,outputAmount:h,outputUsdValue:g,selectedQuote:m}=H()(),{swapMode:y}=tt(),{connectedWallets:S,getBalanceFor:C}=T(),k=a?C(a):null,x=pi(k)?.amount??"0",w=k?new bI(k.amount).shiftedBy(-k.decimals):pe,I=!!s&&Wu(S,s.name),A=!qs(m,d,f),b=!qs(m,d,g),E=!f||!g||!g.gt(0)?null:jt(f.toString(),g.toString());return Fr.createElement(cy,null,Fr.createElement(py,null,Fr.createElement(dy,{label:uy.t("From"),id:"widget-swap-from",mode:"From",onInputChange:p,onInputBlur:u,balance:x,chain:{displayName:s?.displayName||"",image:s?.logo},token:{displayName:a?.symbol||"",image:a?.image,securityWarning:!!a?.warning},onClickToken:()=>n("from"),price:{value:d,usdValue:A?void 0:_(f,4,4),realUsdValue:A?void 0:f?.toString(),error:A?re().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:I,tooltipContainer:B(),onSelectMaxBalance:()=>{let v=w.isGreaterThan(pe)?w.toFixed():"";p(v)},anyWalletConnected:S.length>0}),y==="swap"&&Fr.createElement(qc,null)),Fr.createElement(dy,{selectionType:y==="swap"?"token":"chain",sharpBottomStyle:!r&&(!!m||e),label:uy.t("To"),mode:"To",id:"widget-swap-to-input",fetchingQuote:e,chain:{displayName:l?.displayName||"",image:l?.logo},token:{displayName:c?.symbol||"",image:c?.image,securityWarning:!!c?.warning},percentageChange:_(jt(f,g),2,2),warningLevel:Xt(E??0),price:{value:_(h,6,6),usdValue:b?void 0:_(g,4,4),realValue:h?.toString(),realUsdValue:b?void 0:g?.toString(),error:b?re().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:B()}))}i(Gc,"Inputs");import{warn as EI}from"@rango-dev/logging-core";import{useCallback as II,useEffect as AI,useRef as NI,useState as BI}from"react";function my(){let{fetch:t,loading:e,cancelFetch:o}=fa({request:async(n,r)=>await ct().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(my,"useFetchAllQuotes");var WI=600;function ba({refetchQuote:t}){let{fetch:e,cancelFetch:o}=my(),{excludeLiquiditySources:n,routing:r}=T().config,{connectedWallets:a}=T(),c=a.some(ue=>ue.isContractWallet),{fromToken:l,toToken:p,inputAmount:u,inputUsdValue:d,selectedQuote:f,sortStrategy:h,resetQuote:g,error:m,warning:y,setSelectedQuote:S,updateQuotePartialState:C}=H()(),{slippage:k,customSlippage:x,affiliatePercent:w,affiliateRef:I,affiliateWallets:A,fetchStatus:b}=T(),E=T().getLiquiditySources(),v=T().getDisabledLiquiditySources(),N=T().excludeLiquiditySources(),{findToken:M}=T(),{swapMode:P}=tt(),[U,Q]=BI(!0),Z=NI(u),W=x??k,X=!l||!p||qt(l,p)||!Vn(u),ae=i(ue=>{Q(ue)},"resetState"),Se=i(ue=>{let{fromToken:gt,toToken:vt,inputAmount:xt,liquiditySources:O,excludeLiquiditySources:z,disabledLiquiditySources:Y,slippage:te,affiliateRef:j,affiliatePercent:G,affiliateWallets:Ve}=ue;if(U||ae(!0),!X&>&&vt){g();let V=Xd({fromToken:gt,toToken:vt,inputAmount:xt,liquiditySources:O,excludeLiquiditySources:z,disabledLiquiditySources:Y,wallets:a,slippage:te,affiliateRef:j,affiliatePercent:G,affiliateWallets:Ve,contractCall:c});cn("experimental",r)&&(V.experimental=!0),cn("avoidNativeFee",r)&&(V.avoidNativeFee=!0),cn("enableCentralizedSwappers",r)&&(V.enableCentralizedSwappers=!0),r?.maxLength&&(V.maxLength=r.maxLength),P==="refuel"&&(V.maxLength=1),e(V).then(Ce=>{let Je=Ai(h,Ce.results),ht=$d(f,Je,Ce.requestAmount);Q(!1),C("quotes",Ce),S(ht),ga({diagnosisMessages:Ce.diagnosisMessages,requestId:ht?.requestId||"",swaps:ht?.swaps});let so=ht&&Cn({currentQuote:ht,userSlippage:W,findToken:M});C("warning",so)}).catch(Ce=>{let Je=ha(Ce);(Je.type===0||Je.type===1)&&g(),Je.type!==2&&(C("error",Je),Q(!1),EI(new Error("quote error"),{tags:{...Je,type:Xe[Je.type],requestBody:V}}))})}},"fetch"),at=II(ni(ue=>{Se(ue)},WI),[X]);return AI(()=>{if(!t){Q(!1);return}if(b!=="success")return;if(X){Q(!1),(f||m||y)&&g();return}if(!Vn(u)&&d?.eq(0)){ae(!1),o();return}g(),ae(!0);let ue=Se;return Z.current&&Z.current!=u&&(ue=at),Z.current=u,ue({inputAmount:u,fromToken:l,toToken:p,liquiditySources:E,excludeLiquiditySources:N,disabledLiquiditySources:v,slippage:W,affiliateRef:I,affiliatePercent:w,affiliateWallets:A,contractCall:c}),o},[b,u,l?.symbol,l?.address,l?.blockchain,p?.symbol,p?.address,p?.blockchain,X,E?.length,n,v.length,W,I,w,c,JSON.stringify(A)]),{fetch:()=>Se({inputAmount:u,fromToken:l,toToken:p,liquiditySources:E,excludeLiquiditySources:N,disabledLiquiditySources:v,slippage:W,affiliateRef:I,affiliatePercent:w,affiliateWallets:A,contractCall:c}),loading:U}}i(ba,"useSwapInput");function fy(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};ve.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(fy,"emitPreventableEvent");var $I=LI("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),FI=300;function Sy(){let t=DI(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:c,quotes:l,setSelectedQuote:p,resetQuoteWallets:u,setQuoteWarningsConfirmed:d,updateQuotePartialState:f}=H()(),[h,g]=yy(!1),{isLargeScreen:m,isExtraLargeScreen:y}=ia(),{fetch:S,loading:C}=ba({refetchQuote:a}),{config:k,fetchStatus:x,connectedWallets:w,customSlippage:I,slippage:A,setSlippage:b,setCustomSlippage:E}=T(),{isActiveTab:v}=ne(),[N,M]=yy(!1),P=I!==null?I:A,{swapMode:U}=tt(),Q=pn(P),W=Gd({fetchMetaStatus:x,fetchingQuote:C,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:c,needsToWarnEthOnPath:!1}),J=Fu(m,y,k?.variant),X=!!n&&!!e&&!!o&&new _I(n).gt(0)&&!om(e,o),ae=X&&x==="success"&&C,Se=Q?.quoteValidation||c,gt=(!J||J&&l?.results.length)&&(Se||s),vt=!!e&&!!o,xt=vt&&!!Q,O=(r||s)&&!N?S:void 0,z=i(G=>{J&&h?(g(!1),setTimeout(()=>{t(G)},FI)):t(G)},"onHandleNavigation"),Y=i(G=>{r?.requestId!==G.requestId&&(M(!1),p(G))},"onClickOnQuote"),te=i(G=>{if(G){if(di.includes(G)){b(G),E(null);return}E(G)}},"onChangeSlippage"),j=i(G=>{z(G==="from"?$.fromSwap:U==="swap"?$.toSwap:$.toSwap+"/"+$.blockchains)},"handleInputTokenClick");return hy(()=>{u(),f("refetchQuote",!0)},[]),hy(()=>{g(X)},[X]),Te.createElement($I,null,Te.createElement(se,{height:"auto",footer:Te.createElement(MI,{id:`widget-swap-${W.action}-btn`,type:"primary",size:"large",disabled:W.disabled||!v,prefix:W.action==="confirm-warning"&&Te.createElement(PI,null),fullWidth:!0,onClick:()=>{W.action==="connect-wallet"?fy({type:"clickConnectWallet"},()=>z($.wallets)):W.action==="confirm-warning"?M(!0):z($.confirmSwap)}},W.title),header:{onWallet:()=>{z($.wallets)},hasBackButton:!1,title:k.title||(U==="swap"?gy.t("Swap"):gy.t("Refuel")),suffix:Te.createElement(zo,{hidden:J?["refresh"]:void 0,onClickRefresh:O,onClickHistory:()=>z($.swaps),onClickSettings:()=>{z($.settings)}})}},Te.createElement(ce,null,Te.createElement(Gc,{fetchingQuote:ae,fetchMetaStatus:x,isExpandable:J,onClickToken:j}),Te.createElement(Vc,{size:"2"}),J?null:Te.createElement(Go,{quote:r,loading:ae,error:s,id:"widget-home-expandable-quote-container",tagHidden:!1,warning:Se,type:"basic",onClickAllRoutes:l&&l.results.length>1?()=>{f("refetchQuote",!1),z($.routes)}:void 0}),vt&&Te.createElement(Te.Fragment,null,Te.createElement(Vc,{size:8}),Te.createElement(Fc,{quoteError:s,quoteWarning:Se,fromToken:e,toToken:o,quote:r,loading:ae})),gt?Te.createElement(Te.Fragment,null,Te.createElement(Sr,{warning:Se,error:s,skipAlerts:!!Q,couldChangeSettings:!0,refetchQuote:S,showWarningModal:N,confirmationDisabled:!v,onOpenWarningModal:()=>M(!0),onCloseWarningModal:()=>M(!1),onChangeSlippage:te,onConfirmWarningModal:()=>{M(!1),d(!0),z($.confirmSwap)},onChangeSettings:()=>z($.settings)})):null,xt&&Te.createElement(Te.Fragment,null,Te.createElement(Vc,{size:"10"}),Te.createElement(qh,{onChangeSettings:()=>z($.settings)})),Te.createElement(Pc,null))),J?Te.createElement(zc,{loading:ae,onClickOnQuote:Y,fetch:S,onClickRefresh:O,isVisible:h}):null)}i(Sy,"Home");import{i18n as Cy}from"@lingui/core";import{Alert as OI,Divider as UI,List as zI,ListItemButton as HI,Radio as QI,RadioRoot as qI,Typography as GI}from"@rango-dev/ui";import Ot from"react";function wo(){let{setLanguage:t,language:e,config:o}=T(),n=Gu,r=o?.language||un;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||un),resetLanguage:()=>t(null)}}i(wo,"useLanguage");function Ty(){let{activeLanguage:t,changeLanguage:e,languages:o}=wo(),n=Qe(),r=o.map(a=>{let{local:s,label:c,SVGFlag:l}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Ot.createElement(GI,{variant:"title",size:"xmedium"},c),onClick:()=>{e(a.local),n()},end:Ot.createElement(QI,{value:s}),start:Ot.createElement(l,null)}});return Ot.createElement(se,{header:{title:Cy.t("Language")}},Ot.createElement(ce,null,Ot.createElement(OI,{type:"warning",id:"widget-language-machine-translation-alarm-alert",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Ot.createElement(UI,{size:"8"}),Ot.createElement(qI,{value:t},Ot.createElement(zI,{type:Ot.createElement(HI,{title:Cy.t("language"),className:"widget-language-list-item-btn",id:"_",onClick:()=>console.log()}),items:r}))))}i(Ty,"LanguagePage");import{i18n as no}from"@lingui/core";import{Button as YI,Checkbox as ZI,Image as JI,ListItemButton as RI,NotFound as eA,Typography as tA}from"@rango-dev/ui";import Ze,{useState as oA}from"react";import{Checkbox as jI,Skeleton as wy}from"@rango-dev/ui";import Ur from"react";import{styled as Kc}from"@rango-dev/ui";var Or=Kc("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),jc=Kc("div",{width:80,display:"flex",justifyContent:"flex-end"}),Xc=Kc("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as VI,styled as KI}from"@rango-dev/ui";var ky=KI(VI,{height:61});var XI=30;function Yc(){return Ur.createElement(Or,null,Array.from(Array(XI),(t,e)=>Ur.createElement(ky,{hasDivider:!0,key:e,start:Ur.createElement(wy,{variant:"circular",width:35,height:35}),title:Ur.createElement(wy,{variant:"text",size:"large",width:90}),end:Ur.createElement(jI,{checked:!1})})))}i(Yc,"LoadingLiquiditySourceList");function Zc({sourceType:t}){let e=T().fetchStatus,o=T().swappers(),n=T().getDisabledLiquiditySources(),[r,a]=oA(""),s=T().toggleLiquiditySource,c=T().isInCampaignMode(),l=gi(o,n),p={Exchanges:no.t("Exchanges"),Bridges:no.t("Bridges")},u=[];t==="Exchanges"&&u.push("DEX"),t==="Bridges"&&u.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let d=l.filter(S=>u.includes(S.type)),f=d.length===d.filter(S=>S.selected).length,h=i(()=>{d.forEach(S=>{f?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),g=d.map(S=>{let{selected:C,groupTitle:k,logo:x,id:w,...I}=S;return{id:`widget-setting-liquidity-source-${Su(w.toLowerCase())}-item-btn`,start:Ze.createElement(JI,{src:x,size:22,type:"circular"}),onClick:()=>{c||s(k)},end:Ze.createElement(ZI,{checked:C,disabled:c}),title:Ze.createElement(tA,{variant:"title",size:"xmedium"},no.t(k)),selected:C,groupTitle:k,logo:x,...I}}),m=i(S=>{let C=S.target.value;a(C)},"handleSearch"),y=g;return r&&(y=g.filter(S=>Pt(S.groupTitle,r))),Ze.createElement(se,{header:{title:no.t(t),suffix:Ze.createElement(jc,null,Ze.createElement(YI,{id:`widget-liquidity-source-${f?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:h},f?no.t("Deselect all"):no.t("Select all")))}},Ze.createElement(ce,{view:!0},Ze.createElement(Bt,{value:r,setValue:a,id:"widget-liquidity-source-search-input",fullWidth:!0,color:"light",variant:"contained",placeholder:no.t("Search {sourceType}",{sourceType:p[t]}),onChange:m}),e==="loading"&&Ze.createElement(Yc,null),!y.length&&r?Ze.createElement(Xc,null,Ze.createElement(eA,{title:no.t("No results found"),description:no.t("Try using different keywords")})):e==="success"&&Ze.createElement(Or,{disabled:c,className:"widget-liquidity-source-list"},y.map(S=>{let{groupTitle:C,...k}=S;return Ze.createElement(Ze.Fragment,{key:S.id},Ze.createElement(RI,{style:{height:"61px"},...k,selected:!1,className:"widget-liquidity-source-list-item-btn",hasDivider:!0}))}))))}i(Zc,"LiquiditySourcePage");import{i18n as nA}from"@lingui/core";import Ea from"react";import{useNavigate as rA}from"react-router-dom";function vy(){let t=rA(),e=Qe(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=H()(),{fetch:c,loading:l}=ba({refetchQuote:n}),p=i(f=>{r(f),a("refetchQuote",!1),e()},"onClickOnQuote"),u=`../${$.settings}`,d=`../${$.wallets}`;return Ea.createElement(se,{header:{onWallet:()=>{t(d),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:nA.t("Routes"),suffix:Ea.createElement(zo,{onClickRefresh:o||s?c:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(u),a("refetchQuote",!0)}})}},Ea.createElement(ce,null,Ea.createElement($r,{fetch:c,loading:l,onClickOnQuote:p})))}i(vy,"RoutesPage");import{i18n as By}from"@lingui/core";import{Divider as Wy,getCategoriesCount as fA,SelectableCategoryList as gA}from"@rango-dev/ui";import ro,{useMemo as hA,useState as My}from"react";import{useNavigate as yA}from"react-router-dom";import{i18n as Jc}from"@lingui/core";import{Divider as lA,Image as cA,ListItemButton as pA,NotFound as uA,Typography as Ny}from"@rango-dev/ui";import ft,{useEffect as dA,useState as mA}from"react";var xy=i((t,e,o)=>t.filter(n=>ri(n.type,o)).filter(n=>st(n.name,e)||st(n.displayName,e)),"filterBlockchains");import{ImageContainer as iA,styled as by}from"@rango-dev/ui";var Ey=by("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Ia=by(bl,{padding:0,margin:0,listStyle:"none",[`& ${iA}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as aA,Skeleton as Iy}from"@rango-dev/ui";import Aa from"react";var sA=20;function Ay(){return Aa.createElement(Ia,{id:"widget-blockchain-loading-list",as:"ul"},Array.from(Array(sA),t=>Aa.createElement(aA,{key:t,hasDivider:!0,start:Aa.createElement(Iy,{variant:"circular",width:35,height:35}),title:Aa.createElement(Iy,{variant:"text",size:"large",width:90})})))}i(Ay,"LoadingBlockchainList");function Rc(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,c]=mA(e),{fetchStatus:l}=T();dA(()=>{c([...xy(e,o,r)])},[e,o,r]);let p=i(()=>!s.length&&o?ft.createElement(uA,{title:Jc.t("No results found"),description:Jc.t("Try using different keywords")}):ft.createElement(Ia,{as:"ul",key:`${r}-${o}`,id:"widget-blockchain-list"},s.map(u=>ft.createElement(pA,{key:`${u.name}-${u.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(u),start:ft.createElement(cA,{src:u.logo,size:30}),title:ft.createElement(Ny,{variant:"title",size:"medium"},u.displayName),id:u.name}))),"renderList");return ft.createElement(ft.Fragment,null,a&&ft.createElement(ft.Fragment,null,ft.createElement(Ny,{variant:"label",size:"large"},Jc.t("Select Chain")),ft.createElement(lA,{size:4})),ft.createElement(Ey,null,l==="loading"&&ft.createElement(Ay,null),l==="success"&&p()))}i(Rc,"BlockchainList");function Na(t){let{type:e}=t,o=Qe(),[n,r]=My(""),[a,s]=My("ALL"),c=H().use.setToBlockchain(),l=H().use.setFromBlockchain(),p=H().use.setToToken(),{fetchStatus:u,findNativeToken:d}=T(),f=yA(),{swapMode:h}=tt(),g=T().blockchains({type:e}),m=T().tokens(),y=hA(()=>fu(g,m),[g.length,m.length]),S=fA(y),C=!t.hideCategory&&S!==1,k=i(x=>{if(e==="custom-token")f(`..?blockchain=${x.name}`,{replace:!0});else{if(e==="source")l(x);else if(h==="swap")c(x);else{let w=d(x);w&&p({token:w,meta:{blockchains:g}})}o()}},"handleBlockchainChange");return ro.createElement(se,{header:{title:By.t("Select Chain")}},ro.createElement(ce,{view:!0},C&&ro.createElement(ro.Fragment,null,ro.createElement(gA,{setCategory:s,category:a,blockchains:y,isLoading:u==="loading"}),ro.createElement(Wy,{size:24})),ro.createElement(Bt,{value:n,autoFocus:!0,placeholder:By.t("Search Chain"),id:"widget-select-blockchain-search-input",color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:x=>r(x.target.value)}),ro.createElement(Wy,{size:16}),ro.createElement(Rc,{list:y,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:k})))}i(Na,"SelectBlockchainPage");import{i18n as Ma}from"@lingui/core";import{Divider as Oy,Spinner as MA}from"@rango-dev/ui";import vo,{useEffect as LA,useState as PA}from"react";import{useNavigate as _A}from"react-router-dom";import{i18n as op}from"@lingui/core";import{BlockchainsChip as Ba,Divider as Dy,Image as $y,Skeleton as vA,Tooltip as xA,Typography as np}from"@rango-dev/ui";import be from"react";import{useEffect as TA}from"react";var Ly=["ETH","COSMOS","OSMOSIS"];function ep(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(SA),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let c=o.limit-e.length;for(let l=0;l<=c;l++){let p=n[l];s=s.filter(u=>p?.name!==u)}}n.sort(CA(s)),r=n.splice(a)}return{list:n,more:r}}i(ep,"prepare");function SA(t,e){let o=Ly,n=o.findIndex(c=>c===t.name),r=o.findIndex(c=>c===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(SA,"sortByMostUsedBlockchains");function CA(t){return i(function(o,n){let r=t.findIndex(l=>l===o.name),a=t.findIndex(l=>l===n.name),s=r>-1,c=a>-1;return s&&c?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(CA,"generateSortByPreferredBlockchainsFor");function Py(t,e){return!!e.list.find(o=>o.name===t)}i(Py,"isInVisibleList");function tp(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=T();TA(()=>{if(e?.selected){let a=ep(t,o,e);Py(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=ep(t,o,e);return{list:r.list,more:r.more,history:[]}}i(tp,"usePrepareBlockchainList");import{styled as kA}from"@rango-dev/ui";var _y=kA("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var bA=6,EA=12;function rp(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,{showCompactTokenSelector:s}=ne(),c=tp(e,{limit:s?4:10,selected:n?.name}),{fetchStatus:l}=T(),p=H().use.resetToBlockchain(),u=H().use.resetFromBlockchain(),d=c.more.length>0,f=c.more[0],h=c.more.length===1&&f,g=!h&&d;return be.createElement(be.Fragment,null,!s&&be.createElement(be.Fragment,null,be.createElement(Dy,{size:12}),be.createElement(np,{variant:"label",size:"large"},op.t("Select Chain"))),be.createElement(Dy,{size:12}),be.createElement(_y,{id:"widget-blockchains-section-container"},l==="loading"&&Array.from(Array(s?bA:EA),(m,y)=>be.createElement(vA,{key:y,variant:"rounded",height:50})),l==="success"&&be.createElement(be.Fragment,null,be.createElement(Ba,{className:"widget-blockchains-section-all-btn",selected:!n,onClick:()=>{o==="from"?u():p()}},be.createElement(np,{variant:"body",size:"xsmall",color:"secondary500"},op.t("All"))),c.list.map(m=>be.createElement(xA,{key:m.name,content:m.shortName,side:"bottom",sideOffset:2,container:B()},be.createElement(Ba,{className:"widget-blockchains-section-item-btn",key:m.name,selected:!!n&&n.name===m.name,onClick:()=>r(m)},be.createElement($y,{src:m.logo,size:30})))),h?be.createElement(Ba,{className:"widget-blockchains-section-only-item-btn",key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},be.createElement($y,{src:f.logo,size:30})):null,g?be.createElement(Ba,{onClick:a,key:"more-blockchains",className:"widget-blockchains-section-more-items-btn"},be.createElement(np,{variant:"body",size:"xsmall",color:"secondary500"},op._("More +{count}",{count:c.more.length}))):null)))}i(rp,"BlockchainsSection");import{useCallback as AA,useRef as NA,useState as ip}from"react";function ap(){let t=T().blockchains(),e=NA(null),{customTokens:o}=T(),[n,r]=ip(!1),[a,s]=ip([]),[c,l]=ip(null),p=i(async(f,h)=>{l(null),r(!0),s([]);try{let g=await ct().searchCustomTokens({query:f,blockchain:h},{signal:e.current?.signal}),m=new Set(o().map(C=>Vt(C))),y=new Set(t.map(C=>C.name)),S=g.tokens.filter(C=>y.has(C.blockchain)&&!m.has(Vt(C)));s(S),r(!1)}catch(g){l(g instanceof Error?g.message:"something went wrong"),s([]),g?.name!=="CanceledError"&&r(!1)}},"fetch"),u=AA(ni((f,h)=>{e.current?.signal.aborted||p(f,h)},600),[t.length]);return{fetch:(f,h)=>{e.current=new AbortController,s([]),r(!0),u(f,h)},cancel:i(()=>{e.current?.abort()},"cancel"),loading:n,tokens:a,error:c}}i(ap,"useSearchCustomTokens");function Wa(t,e,o){return o&&t.length===1&&t[0]?.address===e?!1:t.length<20&&e.trim().length>=3}i(Wa,"shouldSearchForCustomTokens");function Fy(t,e,o,n,r){let a=[...t];return Wa(t,o,r)&&(a=n?[...a,"skeleton","skeleton","skeleton"]:[...a,...e.map(s=>({...s,customToken:!0,warning:!0}))]),a}i(Fy,"prepareTokensList");function La(t){let{type:e}=t,o=_A(),n=Qe(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:c,setFromBlockchain:l,setToBlockchain:p}=H()(),{getBalanceFor:u}=T(),{fetch:d,loading:f,tokens:h,cancel:g}=ap(),[m,y]=PA(""),S=e==="source"?r:a,C=S?.name??"",k=T().blockchains({type:e}),x=T().tokens({type:e,blockchain:C,searchFor:m,getBalanceFor:u}),w=Fy(x,h,m,f,S?.name),I=i(E=>{e==="source"?l(E):p(E)},"updateBlockchain"),A=i(E=>{e==="source"?s({token:E,meta:{blockchains:k}}):c({token:E,meta:{blockchains:k}})},"updateToken"),b={source:Ma.t("Source"),destination:Ma.t("Destination")};return LA(()=>(Wa(x,m,S?.name)&&d(m,S?.name??void 0),()=>{g()}),[x.length,m,S?.name]),vo.createElement(se,{header:{title:Ma.t("Swap {type}",{type:b[e]})}},vo.createElement(ce,null,vo.createElement(rp,{blockchains:k,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o($.blockchains),onChange:E=>{I(E)}}),vo.createElement(Oy,{size:24}),vo.createElement(Bt,{value:m,id:"widget-select-swap-item-search-input",autoFocus:!0,placeholder:Ma.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>y(""),onChange:E=>y(E.target.value),suffix:Wa(x,m,S?.name)&&f?vo.createElement(MA,{size:12,color:"secondary"}):void 0}),vo.createElement(Oy,{size:16}),vo.createElement(Nr,{list:w,selectedBlockchain:C,searchedFor:m,type:e,onChange:E=>{A(E);let v=k.find(N=>E.blockchain===N.name);v&&I(v),n()}})))}i(La,"SelectSwapItemsPage");import{i18n as pp}from"@lingui/core";import{Alert as lN,Button as cN,styled as pN}from"@rango-dev/ui";import Xo from"react";import{useInRouterContext as uN,useSearchParams as dN}from"react-router-dom";import{i18n as Gy}from"@lingui/core";import{Alert as OA,Divider as lp,InfoIcon as UA,SlippageIcon as zA,TextField as HA,Tooltip as QA,Typography as Vy}from"@rango-dev/ui";import Oe from"react";import{Chip as DA,styled as zr,TextField as $A}from"@rango-dev/ui";var Uy=zr("div",{paddingTop:"$5",padding:"$10 $5"}),zy=zr("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${$A}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px",paddingLeft:"$2"}}),Hy=zr("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Pa=zr("div",{maxWidth:"280px",padding:"$10"}),Qy=zr(DA,{width:"61px",flexShrink:0});import{i18n as sp}from"@lingui/core";import{Typography as FA}from"@rango-dev/ui";import Hr from"react";function qy(){return Hr.createElement(Pa,null,Hr.createElement(FA,{variant:"label",size:"medium",color:"neutral700"},sp.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Hr.createElement("br",null),Hr.createElement("br",null),Hr.createElement("b",null,sp.t("Warning")),":\xA0",sp.t("This setting is applied to each step (e.g. 1Inch, Thorchain, etc.), meaning only that specific step will be reverted, not the entire route.")))}i(qy,"SlippageTooltipContent");function cp(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=T(),r=o!==null?pn(o):null,a=i(l=>{let p=l.target.value,u=parseFloat(p);if(isNaN(u))return n(null);let d=u;u>Yn&&(d=Yn),n(d)},"onSlippageValueChange"),s=i(l=>{o!==null&&n(null),e(l)},"onClickSlippageChip"),c=i(l=>{let p=l.target,u=p.value;ku(u)||(p.value=u.slice(0,-1))},"onInput");return Oe.createElement(Uy,null,Oe.createElement(Hy,null,Oe.createElement(zA,{size:16,color:"gray"}),Oe.createElement(lp,{direction:"horizontal",size:4}),Oe.createElement(Vy,{variant:"title",size:"xmedium"},Gy.t("Slippage tolerance per swap")),Oe.createElement(lp,{direction:"horizontal",size:4}),Oe.createElement(QA,{container:B(),side:"top",sideOffset:4,content:Oe.createElement(qy,null)},Oe.createElement(UA,{color:"gray"}))),Oe.createElement(zy,null,di.map((l,p)=>{let u=`slippage-${p}`;return Oe.createElement(Qy,{id:`widget-slippage-chip-${l.toString()}%-btn`,key:u,onClick:()=>s(l),selected:o===null&&l===t,label:`${l.toString()}%`})}),Oe.createElement(HA,{type:"number",min:"0.01",max:"30",step:"0.01",status:r?.type||(o?"success":"default"),id:"widget-slippage-chip-text-input",onInput:c,fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:a,suffix:o&&Oe.createElement(Vy,{variant:"body",size:"small"},"%"),placeholder:Gy.t("Custom")})),r&&Oe.createElement(Oe.Fragment,null,Oe.createElement(lp,{size:10}),Oe.createElement(OA,{id:"widget-slippage-alert",variant:"alarm",type:r.type,title:r.message})))}i(cp,"Slippage");import{i18n as wt}from"@lingui/core";import{AutoThemeIcon as Ky,BridgesIcon as qA,ChevronRightIcon as _a,DarkModeIcon as jy,Divider as Qr,ExchangeIcon as GA,InfinityIcon as VA,InfoIcon as KA,LanguageIcon as jA,LightModeIcon as Xy,List as XA,ListItem as YA,ListItemButton as ZA,Skeleton as JA,styled as RA,Switch as eN,Tabs as tN,TargetIcon as oN,Tooltip as nN,Typography as it}from"@rango-dev/ui";import D from"react";import{useNavigate as rN}from"react-router-dom";var iN=RA("div",{width:"202px",height:"$40"}),aN=[{id:"light",icon:D.createElement(Xy,{color:"black",size:24}),tooltip:D.createElement(it,{size:"xsmall",variant:"body"},wt.t("Light"))},{id:"dark",icon:D.createElement(jy,{color:"black",size:24}),tooltip:D.createElement(it,{size:"xsmall",variant:"body"},wt.t("Dark"))},{id:"auto",icon:D.createElement(Ky,{color:"black",size:24}),tooltip:D.createElement(it,{size:"xsmall",variant:"body"},wt.t("Auto"))}],sN=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return D.createElement(Ky,{...e});case"dark":return D.createElement(jy,{...e});default:return D.createElement(Xy,{...e})}},"getThemeIcon");function Yy(){let t=rN(),{theme:e}=T().config,{setTheme:o,theme:n}=T(),{activeLanguage:r,languages:a}=wo(),s=a.find(W=>W.local===r)?.label,c=T().fetchStatus,l=T().swappers(),p=T().getDisabledLiquiditySources(),{config:{features:u}}=T(),d=T().customTokens(),f=et("theme",u),h=et("liquiditySource",u),g=et("language",u),m=et("customTokens",u),y=T().infiniteApprove,S=T().toggleInfiniteApprove,C=gi(l,p),k=C.filter(W=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(W.type)),x=k.length,w=k.filter(W=>W.selected).length,I=C.filter(W=>W.type==="DEX"),A=I.length,b=I.filter(W=>W.selected).length,E=i((W,J)=>{switch(c){case"loading":return D.createElement(JA,{variant:"text",size:"medium",width:50});case"failed":return D.createElement(it,{variant:"body",size:"medium",color:"$error500"},wt.t("Loading failed"));default:return D.createElement(it,{variant:"body",size:"medium"},`${W} / ${J}`)}},"handleSwapperEndItem"),v={id:"widget-setting-bridge-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Bridges")),end:D.createElement(D.Fragment,null,E(w,x),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(_a,{color:"black"})),onClick:()=>t($.bridges),start:D.createElement(qA,{color:"gray",size:16})},N={id:"widget-setting-exchange-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Exchanges")),end:D.createElement(D.Fragment,null,E(b,A),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(_a,{color:"black"})),start:D.createElement(GA,{color:"gray",size:16}),onClick:()=>t($.exchanges)},M={id:"widget-setting-custom-tokens-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Custom Tokens")),end:D.createElement(D.Fragment,null,D.createElement(it,{variant:"body",size:"medium"},`${d.length}`),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(_a,{color:"black"})),start:D.createElement(oN,{color:"gray",size:16}),onClick:()=>t($.customTokens)},P={id:"widget-setting-language-item-btn",title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Language")),start:D.createElement(jA,{color:"gray",size:16}),end:D.createElement(D.Fragment,null,D.createElement(it,{variant:"body",size:"medium"},s),D.createElement(Qr,{direction:"horizontal",size:8}),D.createElement(_a,{color:"black"})),onClick:()=>t($.languages)},U={id:"widget-setting-infinite-approval-item-btn",title:D.createElement(D.Fragment,null,D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Infinite approval")),D.createElement(Qr,{direction:"horizontal",size:4}),D.createElement(nN,{side:"top",sideOffset:4,container:B(),content:D.createElement(Pa,null,D.createElement(it,{variant:"label",size:"medium",color:"neutral700"},D.createElement("b",null,wt.t("Warning")),":\xA0",wt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},D.createElement(KA,{color:"gray"}))),start:D.createElement(VA,{color:"gray",size:16}),end:D.createElement(eN,{checked:y}),onClick:S},Q={id:"widget-setting-theme-item-btn",type:D.createElement(YA,null),title:D.createElement(it,{variant:"title",size:"xmedium"},wt.t("Theme")),end:D.createElement(iN,null,D.createElement(tN,{container:B(),items:aN,value:n,className:"widget-setting-theme-item-tabs-container",onChange:W=>o(W.id),type:"primary",borderRadius:"small"})),start:sN(n)},Z=h?[]:[v,N];return m||Z.push(M),g||Z.push(P),Z.push(U),!e?.singleTheme&&!f&&Z.push(Q),D.createElement(XA,{type:D.createElement(ZA,{className:"widget-settings-list-item-btn",hasDivider:!0,id:"_",onClick:()=>console.log()}),items:Z})}i(Yy,"SettingsLists");var mN=pN("div",{paddingLeft:"$8"});function Zy(){let{isInCampaignMode:t,updateCampaignMode:e}=T(),o=t(),[,n]=dN(),r=uN(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return Xo.createElement(se,{header:{title:pp.t("Settings")}},Xo.createElement(ce,null,o&&Xo.createElement(lN,{type:"info",variant:"alarm",id:"widget-settings-campaign-mode-alert",title:pp.t("Currently, you're in campaign mode with restrictions on liquidity sources. Would you like to switch out of this mode and make use of all available liquidity sources?"),action:Xo.createElement(mN,null,Xo.createElement(cN,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},pp.t("Reset")))}),Xo.createElement(cp,null),Xo.createElement(Yy,null)))}i(Zy,"SettingsPage");import{i18n as v0}from"@lingui/core";import{cancelSwap as x0}from"@rango-dev/queue-manager-rango-preset";import{useManager as b0}from"@rango-dev/queue-manager-react";import{Alert as E0}from"@rango-dev/ui";import Ip from"react";import{useParams as I0}from"react-router-dom";import{i18n as zt}from"@lingui/core";import{getCurrentNamespaceOfOrNull as c0,getCurrentStep as p0,getRelatedWalletOrNull as u0}from"@rango-dev/queue-manager-rango-preset";import{Button as GS,Divider as d0,QuoteCost as m0,StepDetails as f0,Typography as kp}from"@rango-dev/ui";import{useWallets as g0}from"@rango-dev/wallets-react";import VS from"bignumber.js";import{PendingSwapNetworkStatus as Fn}from"rango-types";import we,{useEffect as wp,useRef as vp,useState as qa}from"react";import{useNavigate as h0}from"react-router-dom";import{i18n as xo}from"@lingui/core";var fN=[xo.t("Sunday"),xo.t("Monday"),xo.t("Tuesday"),xo.t("Wednesday"),xo.t("Thursday"),xo.t("Friday"),xo.t("Saturday")];function Jy(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?xo.t("Today"):`${fN[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Jy,"timeSince");function Ry(t){return t.finishTime?Jy(parseInt(t.finishTime)):Jy(parseInt(t.creationTime))}i(Ry,"getSwapDate");import qr from"react";import{i18n as Da}from"@lingui/core";import{Button as eS,Divider as up,MessageBox as gN}from"@rango-dev/ui";import bo from"react";var tS=i(({onCancel:t,onClose:e})=>bo.createElement(bo.Fragment,null,bo.createElement(up,{size:20}),bo.createElement(gN,{type:"error",title:Da.t("Cancel Swap"),description:Da.t("Are you sure you want to cancel this swap?")}),bo.createElement(up,{size:32}),bo.createElement(eS,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Da.t("Yes, Cancel it")),bo.createElement(up,{size:12}),bo.createElement(eS,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Da.t("No, Continue"))),"CancelContent");import{i18n as $a}from"@lingui/core";import{Button as oS,Divider as dp,MessageBox as hN,Typography as yN}from"@rango-dev/ui";import io from"react";var nS=i(({onDelete:t,onClose:e})=>io.createElement(io.Fragment,null,io.createElement(dp,{size:20}),io.createElement(hN,{type:"error",title:$a.t("Delete Transaction"),description:$a.t("Are you sure you want to delete this swap?")}),io.createElement(dp,{size:32}),io.createElement(oS,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},$a.t("Yes, Delete it")),io.createElement(dp,{size:12}),io.createElement(oS,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},io.createElement(yN,{variant:"title",size:"medium",color:"primary"},$a.t("No, Cancel")))),"DeleteContent");import{i18n as SN}from"@lingui/core";import{Button as CN,Divider as TN,MessageBox as kN}from"@rango-dev/ui";import Yo from"react";var rS=i(t=>{let{switchNetworkModalState:e,handleSwitchNetwork:o}=t;return Yo.createElement(Yo.Fragment,null,Yo.createElement(kN,{type:e.type,title:e.title,description:e.description}),e.type==="error"&&Yo.createElement(Yo.Fragment,null,Yo.createElement(TN,{size:"30"}),Yo.createElement(CN,{id:"widget-switch-network-try-again",type:"primary",size:"large",onClick:o},SN.t("Try Again"))))},"NetworkStateContent");import{getCurrentNamespaceOfOrNull as ON,getCurrentStep as UN,getRelatedWalletOrNull as zN}from"@rango-dev/queue-manager-rango-preset";import{WalletState as HN}from"@rango-dev/ui";import{useWallets as QN}from"@rango-dev/wallets-react";import uS from"react";import{i18n as Dn}from"@lingui/core";import{Alert as sS,Button as xN,Checkbox as bN,Divider as Ua,Image as EN,MessageBox as IN,Spinner as AN,WarningIcon as NN}from"@rango-dev/ui";import{useWallets as BN}from"@rango-dev/wallets-react";import ye,{useState as WN}from"react";import{css as wN,darkTheme as vN,styled as mp}from"@rango-dev/ui";var iS=wN({wordWrap:"break-word",display:"block"}),aS=mp("img",{width:"100%"}),Fa=mp("div",{position:"relative"}),Oa=mp("span",{position:"absolute",top:0,right:0,borderRadius:"50%",width:"14px",height:"14px",display:"flex",padding:"$2",backgroundColor:"$warning300",[`.${vN} &`]:{$$color:"$warning600"}});var lS=i(t=>{let{wallet:e,namespace:o,onClose:n}=t,[r,a]=WN(null),{list:s}=bt(),c=ne.use.isActiveTab(),{state:l,connect:p}=BN(),u=s.find(w=>w.type===e.walletType),d=u?.needsNamespace?.data.find(w=>w.value===o?.namespace);if(!u)return null;let f=l(e.walletType),h=u.isHub&&o?.namespace?f.namespaces?.get(o.namespace):null,g=f.connecting||h?.connecting,m=u.isHub?h?.connected:f.connected,y=i(()=>m?Dn.t("Done"):r?Dn.t("Try again"):Dn.t("Connect"),"getButtonTitle"),S=i(()=>g?ye.createElement(AN,{color:"info"}):r||m?null:ye.createElement(bN,{checked:!0,disabled:!0}),"getNamespaceSuffix"),C=i(async()=>{try{a(null),await p(u.type,o?.namespace?[{namespace:o?.namespace,network:void 0,derivationPath:e.derivationPath}]:void 0)}catch(w){a(w)}},"handleConnect"),k=i(async()=>{if(m){n();return}C()},"handleClickButton"),x=i(()=>{if(!m)return null;let w=u?.isHub?h?.accounts?.[0]?.split(":"):f?.accounts?.[0]?.split(":"),I=w?.[w?.length-1];return I?lo(I):null},"getAddress");return ye.createElement(ye.Fragment,null,ye.createElement(IN,{type:"warning",title:Dn.t("Connect {wallet}",{wallet:u.title}),description:Dn.t("The connection of your wallet or some networks has been disconnected. Connect to continue the swap"),icon:ye.createElement(Fa,null,ye.createElement(EN,{src:u.image,size:45}),ye.createElement(Oa,null,ye.createElement(NN,{color:"warning",size:10})))}),m&&!d&&ye.createElement(ye.Fragment,null,ye.createElement(Ua,{size:10}),ye.createElement(sS,{type:"success",variant:"alarm",title:Dn.t("Wallet connected successfully.")})),r&&!d&&ye.createElement(ye.Fragment,null,ye.createElement(Ua,{size:10}),ye.createElement(sS,{type:"error",title:r?.message,variant:"alarm"})),d&&ye.createElement(ye.Fragment,null,ye.createElement(Ua,{size:30}),ye.createElement(_o,{namespace:d,suffix:S(),error:r?.message,connected:m,address:x()})),ye.createElement(Ua,{size:"40"}),ye.createElement(xN,{loading:g,type:"primary",id:"widget-connect-wallet-btn",onClick:k,disabled:!c},y()))},"ConnectWalletContent");import{i18n as cS}from"@lingui/core";import{Button as MN,Divider as LN,Image as PN,MessageBox as _N,WarningIcon as DN}from"@rango-dev/ui";import{useWallets as $N}from"@rango-dev/wallets-react";import{detectInstallLink as FN}from"@rango-dev/wallets-shared";import ao from"react";var pS=i(t=>{let{walletType:e}=t,{getWalletInfo:o}=$N(),n=e?o(e):null;if(!n)return null;let r=i(()=>window.open(FN(n.installLink),"_blank"),"handleButtonClick");return ao.createElement(ao.Fragment,null,ao.createElement(_N,{type:"warning",title:cS.t("Install {wallet}",{wallet:n.name}),description:"Your wallet is not installed. Please install it to continue the swap. ",icon:ao.createElement(Fa,null,ao.createElement(PN,{src:n.img,size:45}),ao.createElement(Oa,null,ao.createElement(DN,{color:"warning",size:10})))}),ao.createElement(LN,{size:"40"}),ao.createElement(MN,{type:"primary",id:"widget-install-wallet-btn",onClick:r},cS.t("Install")))},"InstallWalletContent");var dS=i(t=>{let{swap:e,onClose:o}=t,{state:n,getWalletInfo:r}=QN(),a=UN(e),s=a?zN(e,a):null,c=s?.walletType,l=c?Kn(r(c),n(c)):null,p=a?ON(e,a):null;return c?l===HN.NOT_INSTALLED?uS.createElement(pS,{walletType:c}):uS.createElement(lS,{wallet:s,namespace:p,onClose:o}):null},"WalletStateContent");function fp(t){let{isOpen:e,state:o,switchNetworkModalState:n,onClose:r,onDelete:a,onCancel:s,swap:c,message:l,handleSwitchNetwork:p}=t;return qr.createElement(ee,{open:e,onClose:r,container:B()},o==="connectWallet"&&qr.createElement(dS,{swap:c,message:l,onClose:r}),o==="switchNetwork"&&n&&qr.createElement(rS,{message:l,switchNetworkModalState:n,handleSwitchNetwork:p}),o==="delete"&&qr.createElement(nS,{onClose:r,onDelete:()=>{r(),a()}}),o==="cancel"&&qr.createElement(tS,{onClose:r,onCancel:()=>{r(),s()}}))}i(fp,"SwapDetailsModal");import{i18n as Gr}from"@lingui/core";import{Button as gp,Divider as Vr,MessageBox as gS,TokenAmount as qN,Typography as hS}from"@rango-dev/ui";import ke from"react";import{Link as GN,useNavigate as VN}from"react-router-dom";var mS="https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.jpg",fS="/profile";function hp(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:c,token:l,chain:p,percentageChange:u,description:d,diagnosisUrl:f}=t,h=VN(),{showProfileBanner:g}=ne();return ke.createElement(ee,{open:e,onClose:o,id:"widget-swap-details-complete-modal",container:document.getElementById(Re.SWAP_BOX_ID)||document.body},n==="success"?ke.createElement(gS,{type:"success",title:Gr.t("Swap Successful")},ke.createElement(qN,{direction:"vertical",tooltipContainer:B(),id:"widget-swap-details-complete-modal-success-token-amount-container",type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:c},token:l,chain:p,percentageChange:u}),ke.createElement(Vr,{size:12}),ke.createElement(hS,{className:iS(),variant:"body",size:"medium",color:"neutral700",align:"center"},d)):ke.createElement(gS,{type:"error",title:Gr.t("Transaction Failed"),description:d}),ke.createElement(Vr,{size:30}),n==="success"&&ke.createElement(ke.Fragment,null,g&&ke.createElement(ke.Fragment,null,ke.createElement(GN,{to:fS},ke.createElement(aS,{src:mS,alt:"Profile Banner"})),ke.createElement(Vr,{size:30})),ke.createElement(gp,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{h("../../")}},Gr.t("Done"))),ke.createElement(Vr,{size:12}),f&&ke.createElement(ke.Fragment,null,ke.createElement(gp,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(f,"_blank")},Gr.t("Diagnosis")),ke.createElement(Vr,{size:12})),ke.createElement(gp,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},ke.createElement(hS,{variant:"title",size:"medium",color:"primary"},Gr.t("See Details"))))}i(hp,"SwapDetailsCompleteModal");import{i18n as Qa}from"@lingui/core";import{CopyIcon as r0,DoneIcon as i0,IconButton as a0,RangoExplorerIcon as s0,Tooltip as OS,Typography as US,useCopyToClipboard as l0}from"@rango-dev/ui";import Mt from"react";import n0 from"react";import{i18n as RN}from"@lingui/core";import{Alert as _S,IconButton as e0,LinkIcon as t0}from"@rango-dev/ui";import Eo,{Fragment as o0}from"react";import{Alert as jN,ChevronDownIcon as XN,IconButton as YN}from"@rango-dev/ui";import $n,{useState as ZN}from"react";import{css as Kr,darkTheme as yS,styled as Ut,Typography as KN}from"@rango-dev/ui";var SS=Ut(ce,{overflowY:"auto","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${yS} &`]:{color:"$secondary500"}}}}}),CS=Ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),TS=Ut("div",{position:"sticky",top:0,zIndex:10,backgroundColor:"$background"}),kS=Ut("div",{padding:"$0 $20 $20 $20"}),MY=Ut("div",{display:"flex",flexDirection:"column",gap:"$10"}),wS=Ut("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),LY=Ut("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),Zo=Kr({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${yS} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),vS=Kr({padding:"$5 0"}),za=Kr({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),xS=Kr({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),bS=Kr({width:"100%",padding:"0 $20 $10"}),ES=Ut("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),IS=Ut("div",{display:"flex",flexDirection:"column",gap:"$5"}),Ha=Ut(KN,{wordBreak:"break-word"});import{styled as yp}from"@rango-dev/ui";var AS=yp("div",{display:"flex",flexDirection:"column",gap:"$10"}),NS=yp("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),BS=yp("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function WS(t){let{message:e}=t,[o,n]=ZN(!1);return $n.createElement(jN,{id:"widget-failed-swap-details-alert",type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&$n.createElement(YN,{id:"widget-swap-details-failed-btn",onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},$n.createElement(NS,{rotated:o},$n.createElement(XN,{size:12,color:"gray"}))),footer:$n.createElement(BS,{open:o},$n.createElement(Ha,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(WS,"FailedAlert");import{i18n as MS}from"@lingui/core";import{Alert as Sp,Button as LS}from"@rango-dev/ui";import{PendingSwapNetworkStatus as JN}from"rango-types";import jr from"react";function PS(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,setNetworkModal:n,message:r,showNetworkModal:a}=t;return e?jr.createElement(Sp,{type:"warning",id:"widget-swap-details-change-network-alert",title:r.shortMessage,action:jr.createElement(LS,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{n("switchNetwork"),o()}},MS.t("Change"))}):a===JN.WaitingForConnectingWallet?jr.createElement(Sp,{type:"warning",title:r.shortMessage,id:"widget-swap-details-warning-alert-connect-wallet-alert",action:jr.createElement(LS,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{n("connectWallet")}},MS.t("Connect"))}):jr.createElement(Sp,{id:"widget-swap-details-short-alert",type:"warning",title:r.shortMessage})}i(PS,"WarningAlert");function Cp(t){let{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a,step:s,hasAlreadyProceededToSign:c}=t,l=pr(s),p=s.status==="waitingForApproval"&&!l,u=s.status==="running"&&!l,d=u&&!c||p&&!s.explorerUrl?.length;return Eo.createElement(AS,null,s.explorerUrl?.map((f,h,g)=>{let m=h+f.url,y=h===g.length-1,S=(y&&u||p)&&!d,C=y&&s.status==="failed";return Eo.createElement(o0,{key:m},Eo.createElement(_S,{id:"widget-swap-details-tx-alert",type:y&&(S&&"loading"||C&&"error")||"success",title:f.description?`${f.description} Tx`:RN.t("View transaction"),action:f.url&&Eo.createElement(e0,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(f.url,"_blank")},Eo.createElement(t0,{size:12}))}))}),d&&Eo.createElement(_S,{id:"widget-swap-details-loading-alert",type:"loading",title:a.shortMessage}),s.status!=="failed"&&l&&Eo.createElement(PS,{switchNetworkIsAvailable:e,handleSwitchNetworkClick:o,showNetworkModal:n,setNetworkModal:r,message:a}),s.status==="failed"&&Eo.createElement(WS,{message:a}))}i(Cp,"SwapDetailsAlerts");var DS=2e3;var $S=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let c=s===0?t.inputAmount:t.steps[s-1]?.outputAmount||t.steps[s-1]?.expectedOutputAmountHumanReadable;return{from:{token:{displayName:a.fromSymbol,image:a.fromLogo??""},chain:{displayName:yt(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:_(c,6,6),realValue:c??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:yt(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:_(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:Qn(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(l=>({from:{chain:{displayName:yt(l.fromBlockchain,e)??"",image:l.fromBlockchainLogo??""}},to:{chain:{displayName:yt(l.toBlockchain,e)??"",image:l.toBlockchainLogo??""}},swapper:{displayName:Qn(l.swapperId,o)??"",image:l.swapperLogo??"",type:l.swapperType}})):[],alerts:n0.createElement(Cp,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function FS(t){if(pr(t)&&t.status!=="failed"&&t.status!=="success")return"warning";switch(t.status){case"created":return"default";case"approved":case"waitingForApproval":case"running":return"in-progress";case"failed":return"error";case"success":return"completed"}}i(FS,"getStepState");function zS(t){let{requestId:e}=t,[o,n]=l0(DS);return Mt.createElement(TS,{className:Zo()},Mt.createElement(US,{variant:"label",size:"large",color:"neutral700"},Qa.t("Request ID")),Mt.createElement("div",{className:za()},Mt.createElement(US,{variant:"label",size:"small",color:"neutral700"},e),Mt.createElement(OS,{container:B(),content:o?Qa.t("Copied To Clipboard"):Qa.t("Copy Request ID"),open:o||void 0,side:"bottom",alignOffset:-16,align:"end"},Mt.createElement(a0,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:n.bind(null,e||"")},o?Mt.createElement(i0,{size:16,color:"secondary"}):Mt.createElement(r0,{size:16,color:"gray"}))),Mt.createElement(ES,{target:"_blank",href:`${nu}/swap/${e}`},Mt.createElement(OS,{container:B(),content:Qa.t("View on Rango Explorer"),side:"bottom"},Mt.createElement(s0,{size:20})))))}i(zS,"RequestIdRow");import{i18n as HS}from"@lingui/core";import{Typography as QS}from"@rango-dev/ui";import Tp from"react";function qS(t){let{date:e,isFinished:o}=t;return Tp.createElement("div",{className:Zo()},Tp.createElement(QS,{variant:"label",size:"large",color:"neutral700"},o?HS.t("Finished at"):HS.t("Created at")),Tp.createElement(QS,{variant:"label",size:"small",color:"neutral700"},e))}i(qS,"SwapDateRow");var y0=3e3;function xp(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:c}=g0(),l=T().blockchains(),p=T().swappers(),{findToken:u}=T(),d=H().use.retry(),f=h0(),h=vp(null),[g,m]=qa(!1),[y,S]=qa(null),[C,k]=qa(null),[x,w]=qa(null),I=vp(y),A=vp(C),b=Ne.use.getNotifications(),E=Ne.use.removeNotification(),v=b(),N=p0(e),M=N?.networkStatus,P=i(Me=>{m(!0),S(Me)},"handleChangeModalState"),U=i(()=>{m(!1)},"handleCloseModal"),Q=i(()=>{k({type:"loading",title:zt.t("Change Network"),description:`We\u2019re switching the connected network to ${X?.network}. Please check your wallet.`})},"handleShowSwitchNetworkLoading"),Z=i(()=>{k({type:"success",title:zt.t("Network Changed"),description:"The network has been successfully changed."})},"handleShowSwitchNetworkSucceeded"),W=i(Me=>{k({type:"error",title:zt.t("Network Switch Failed"),description:Me?.message||te.detailedMessage.content})},"handleShowSwitchNetworkFailed"),J=Rd(e),X=N?c0(e,N):null,ae=N?u0(e,N):null,Se=Ry(e),at=em(e),ue=i(Me=>!!c(Me)?.mobileWallet,"checkIsMobileWallet"),gt=!!M&&[Fn.WaitingForNetworkChange,Fn.NetworkChangeFailed].includes(M),vt=!!ae?.walletType&&ue(ae.walletType),xt=!!ae&&!!X&&a(ae.walletType,X.network,X),O=!!X&>&&(vt||xt),z=i(()=>{O&&(Q(),s(ae.walletType,[{namespace:X.namespace,network:X.network}]).then(()=>{Z()}).catch(Me=>{W(Me)}))},"handleSwitchNetwork"),Y=i(()=>{P("switchNetwork"),z()},"handleSwitchNetworkClick"),te=Jd(e,N,c),j=$S({swap:e,switchNetworkIsAvailable:O,handleSwitchNetworkClick:Y,showNetworkModal:M,setNetworkModal:P,message:te,blockchains:l,swappers:p}),G=j.length,[Ve,V]=[e.steps[0],e.steps[G-1]],Ce=V?.outputAmount||V?.expectedOutputAmountHumanReadable,Je=e.steps.reduce((Me,Lt)=>Me+parseFloat(Lt.feeInUsd||""),0),ht=e.steps.find(Me=>Me.diagnosisUrl)?.diagnosisUrl,so=_(parseFloat(Ce||"0")*(V?.toUsdPrice||0),4,4),zn=_(parseFloat(e.inputAmount)*(Ve?.fromUsdPrice||0),4,4),Io=Ce?new VS(Ce).multipliedBy(V.toUsdPrice||0).toString():"",Zr=new VS(e.inputAmount).multipliedBy(Ve?.fromUsdPrice||0).toString(),Ro=jt(zn,so),ts=te.detailedMessage.content||te.shortMessage,bC=e.status==="success"?zt.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:_(Ce,6,6),token:j[G-1]?.to.token.displayName,conciseAddress:lo(e.wallets[j[G-1]?.to.chain.displayName||""]?.address||""),chain:j[G-1]?.to.chain.displayName}}):we.createElement(IS,null,we.createElement(kp,{variant:"body",size:"medium",color:"neutral700",align:"center"},ts?"":zt.t("Transaction was not sent."),J?`${zt.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:J.outputAmount,symbol:J.symbol,blockchain:J.blockchain}})}`:""),ts&&we.createElement(Ha,{align:"center",variant:"body",size:"medium",color:"neutral700"},we.createElement("b",null,"Reason:")," ",ts));return wp(()=>{v.find(Lt=>Lt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(w(e.status),E(e.requestId),U()):x&&w(null))},[e.status,e.requestId]),wp(()=>{if(O){if(P("switchNetwork"),M===Fn.WaitingForNetworkChange){Q();return}if(M===Fn.NetworkChangeFailed){W();return}return}if(M===Fn.WaitingForConnectingWallet){P("connectWallet");return}if(M===Fn.NetworkChanged){P("switchNetwork"),Z();return}y&&["connectWallet","switchNetwork"].includes(y)&&U()},[M]),wp(()=>{if(I.current=y,A.current=C,y==="switchNetwork"&&C?.type==="success"){let Me=setTimeout(()=>{I.current==="switchNetwork"&&A.current?.type==="success"&&U()},y0);return()=>clearTimeout(Me)}},[y,C]),we.createElement(se,{header:{title:zt.t("Swap Details"),onCancel:e.status==="running"?()=>P("cancel"):void 0,suffix:e.status!=="running"&&we.createElement(fo,null,we.createElement(GS,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>P("delete")},we.createElement(kp,{size:"medium",variant:"label",color:"error"},zt.t("Delete"))))},footer:at&&!x&&we.createElement(GS,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let Me=Ii(e,l,u);d(Me),setTimeout(()=>{f("../../")},0)}},zt.t("Try again"))},we.createElement(SS,{compact:!0,ref:h},we.createElement(zS,{requestId:o}),we.createElement(qS,{date:Se,isFinished:!!e.finishTime}),we.createElement("div",{className:xS()},we.createElement(m0,{fee:_(String(Je),2,2),time:Gn(ai(e.steps)),steps:G}),we.createElement(Cr,{from:{price:{value:_(e.inputAmount,6,6),usdValue:zn,realUsdValue:Zr,realValue:e.inputAmount},token:{displayName:j[0]?.from.token.displayName||"",image:j[0]?.from.token.image},chain:{image:j[0]?.from.chain.image,displayName:j[0]?.from.chain.displayName||""}},to:{price:{value:_(Ce,6,6),usdValue:so,realUsdValue:Io,realValue:Ce||""},token:{displayName:j[G-1]?.to.token.displayName||"",image:j[G-1]?.to.token.image},chain:{image:j[G-1]?.to.chain.image,displayName:j[G-1]?.to.chain.displayName||""}},percentageChange:_(Ro,2,2),warningLevel:Xt(Ro??0)})),we.createElement("div",{className:bS()},we.createElement(kp,{variant:"title",size:"small"},zt.t("Swaps steps"))),we.createElement(d0,{size:8}),we.createElement(kS,null,j.map((Me,Lt)=>{let $p=Lt,Hn=e.steps[Lt]&&FS(e.steps[Lt]),EC=Hn==="error"||Hn==="in-progress"||Hn==="warning"||Hn==="completed"&&Lt===j.length-1;return we.createElement(f0,{className:"widget-swap-details-step-item-container",key:$p,step:Me,type:"swap-progress",ref:h,state:Hn,hasSeparator:Lt!==0,tabIndex:$p,isFocused:EC,tooltipContainer:B()})}))),we.createElement(fp,{isOpen:g,state:y,switchNetworkModalState:C,onClose:U,onCancel:r,onDelete:n,message:te.detailedMessage.content,swap:e,handleSwitchNetwork:Y}),we.createElement(hp,{open:!!x,diagnosisUrl:ht,onClose:()=>w(null),status:e.status==="success"?"success":"failed",priceValue:_(Ce,6,6),usdValue:so,realUsdValue:Io,realValue:Ce||"",percentageChange:_(Ro,2,2),token:{displayName:j[G-1]?.to.token.displayName||"",image:j[G-1]?.to.token.image},chain:{image:j[G-1]?.to.chain.image},description:bC}))}i(xp,"SwapDetails");import{i18n as Va}from"@lingui/core";import{Divider as XS,NotFound as w0,Skeleton as Yr,Typography as Ka}from"@rango-dev/ui";import Ie from"react";import{i18n as S0}from"@lingui/core";import{Divider as C0,Skeleton as T0,Typography as k0}from"@rango-dev/ui";import Ee from"react";import{css as Ht,styled as bp}from"@rango-dev/ui";var KS=bp("div",{width:"100%",height:"100%",padding:"$10 $20"}),Xr=bp("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Ga=bp("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),a9=Ht({display:"flex",justifyContent:"space-between",alignItems:"center"}),s9=Ht({paddingTop:"$15",display:"flex"}),l9=Ht({padding:"$15 $0"}),c9=Ht({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),p9=Ht({paddingBottom:"$10"}),u9=Ht({display:"flex",justifyContent:"start",alignItems:"center"}),d9=Ht({paddingTop:"$5",display:"flex",alignItems:"center"}),m9=Ht({display:"flex",alignItems:"center"}),f9=Ht({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),jS=Ht({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Ep(){return Ee.createElement(KS,null,Ee.createElement(wr,{type:"swap-preview"}),Ee.createElement("div",{className:"swaps-steps"},Ee.createElement(k0,{variant:"title",size:"small"},S0.t("Swaps steps"))),Ee.createElement(Ee.Fragment,null,Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1}),Ee.createElement("div",{className:jS()},Ee.createElement(C0,{direction:"horizontal",size:20}),Ee.createElement(T0,{height:22,variant:"rectangular"}))),Ee.createElement(Ga,null),Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1})),Ee.createElement(Ga,null),Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1})),Ee.createElement(Ga,null),Ee.createElement(Xr,null,Ee.createElement(Ft,{separator:!1}))))}i(Ep,"LoadingSwapDetails");function YS(t){let{requestId:e,showSkeleton:o}=t;return Ie.createElement(se,{header:{title:Va.t("Swap Details"),suffix:Ie.createElement(fo,null)}},o&&Ie.createElement(CS,null,Ie.createElement("div",{className:Zo()},Ie.createElement(Ka,{variant:"label",size:"large",color:"neutral700"},`${Va.t("Request ID")}`),Ie.createElement("div",{className:za()},Ie.createElement(Ka,{variant:"label",size:"small",color:"neutral700"},Ie.createElement(Yr,{width:60,height:10,variant:"rounded"})),Ie.createElement(XS,{direction:"horizontal",size:4}),Ie.createElement(Yr,{width:16,height:16,variant:"rectangular"}),Ie.createElement(XS,{direction:"horizontal",size:4}),Ie.createElement(Yr,{width:16,height:16,variant:"rectangular"}))),Ie.createElement("div",{className:Zo()},Ie.createElement(Ka,{className:vS(),variant:"label",size:"large",color:"neutral700"},Ie.createElement(Yr,{width:60,height:10,variant:"rounded"})),Ie.createElement(Ka,{variant:"label",size:"small",color:"neutral700"},Ie.createElement(Yr,{width:60,height:10,variant:"rounded"}))),Ie.createElement(Ep,null)),!o&&Ie.createElement(wS,null,Ie.createElement(w0,{title:Va.t("Not found"),description:Va.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(YS,"SwapDetailsPlaceholder");function ZS(){let{manager:t,state:e}=b0(),o=!e.loadedFromPersistor,n=kt(t),{requestId:r}=I0(),a=Qe(),{fetchStatus:s}=T();if(!r)return Ip.createElement(E0,{containerStyles:{margin:"20px"},type:"error",title:v0.t("The request ID is necessary to display the swap details.")});let c=o||s==="loading",l=r?n.find(({swap:f})=>f.requestId===r):void 0,p=i(()=>{if(l?.id){let f=t?.get(l.id);f&&x0(f)}},"onCancel"),u=i(async()=>{if(l?.id)try{t?.deleteQueue(l.id),a()}catch(f){console.log(f)}},"onDelete"),d=l?.swap;return!d||c?Ip.createElement(YS,{requestId:r,showSkeleton:c}):Ip.createElement(xp,{swap:d,requestId:r,onCancel:p,onDelete:u})}i(ZS,"SwapDetailsPage");import{i18n as JS}from"@lingui/core";import{Divider as A0,getCategoriesCount as N0,SelectableCategoryList as B0,styled as eC,Typography as W0,Wallet as M0}from"@rango-dev/ui";import Qt,{useState as RS}from"react";var L0=eC("div",{display:"flex",justifyContent:"center",alignItems:"center",columnGap:"$5",rowGap:"$10",flexWrap:"wrap",paddingTop:"$5"}),P0=eC(ce,{textAlign:"center"});function tC(){let{fetchStatus:t}=T(),[e,o]=RS("ALL"),n=T().blockchains(),{config:r}=T(),[a,s]=RS(),c=ne.use.isActiveTab(),{list:l}=bt(),p=Lu(l,n),d=N0(p)!==1,f=Pu(l,e),h=i(g=>{du(l,r.multiWallets)||s(g)},"handleWalletItemClick");return Qt.createElement(se,{header:{title:JS.t("Connect Wallets")}},Qt.createElement(P0,null,d&&Qt.createElement(Qt.Fragment,null,Qt.createElement(B0,{setCategory:o,category:e,blockchains:p,isLoading:t==="loading"}),Qt.createElement(A0,{size:24})),Qt.createElement(W0,{variant:"title",size:"xmedium",align:"center"},JS.t("Choose a wallet to connect.")),Qt.createElement(L0,null,f.map((g,m)=>{let y=`wallet-${m}-${g.type}`;return Qt.createElement(M0,{key:y,...g,state:g.state,container:B(),onClick:()=>h(g),isLoading:t==="loading",disabled:!c})}),Qt.createElement(sr,{id:"widget-state-full-connect-modal",wallet:a,onClose:()=>{s(void 0)}}))))}i(tC,"WalletsPage");function oC(){return um(),Zs(),_0([{path:$.home,element:Ue.createElement(Sy,null)},{path:$.routes,element:Ue.createElement(vy,null)},{path:$.fromSwap,children:[{index:!0,element:Ue.createElement(La,{type:"source"})},{path:$.blockchains,element:Ue.createElement(Na,{type:"source"})}]},{path:$.toSwap,children:[{index:!0,element:Ue.createElement(La,{type:"destination"})},{path:$.blockchains,element:Ue.createElement(Na,{type:"destination"})}]},{path:$.settings,children:[{index:!0,element:Ue.createElement(Zy,null)},{path:$.languages,element:Ue.createElement(Ty,null)},{path:$.exchanges,element:Ue.createElement(Zc,{sourceType:"Exchanges"})},{path:$.bridges,element:Ue.createElement(Zc,{sourceType:"Bridges"})},{path:$.customTokens,children:[{index:!0,element:Ue.createElement(Ch,null)},{path:$.addCustomTokens,children:[{index:!0,element:Ue.createElement(pf,null)},{path:$.blockchains,element:Ue.createElement(Na,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:Ue.createElement(Oh,null)},{path:$.swapDetails,element:Ue.createElement(ZS,null)}]},{path:$.wallets,element:Ue.createElement(tC,null)},{path:$.confirmSwap,element:Ue.createElement(nh,null)}])}i(oC,"AppRoutes");import{useQueueManager as R0}from"@rango-dev/queue-manager-rango-preset";import{isEvmBlockchain as eB}from"rango-sdk";import{useContext as tB,useEffect as Wp,useState as fC}from"react";import{Provider as z0}from"@rango-dev/wallets-react";import ja,{createContext as H0,useEffect as sC,useMemo as Q0,useRef as lC}from"react";import{useEffect as $0}from"react";import{Provider as D0}from"@rango-dev/wallets-core";function nC(t){return t.map(e=>typeof e=="string"?e:e instanceof D0?e.id:e.config.type).join("-")}i(nC,"hashProviders");function Ap(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=T(),a=n();return $0(()=>{o(),r()},[nC(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(Ap,"useWalletProviders");import{legacyFormatAddressWithNetwork as F0,legacyReadAccountAddress as rC}from"@rango-dev/wallets-core/legacy";import{Events as On}from"@rango-dev/wallets-react";import{isEvmBlockchain as O0}from"rango-sdk";function iC(t){let{newWalletConnected:e,disconnectWallet:o,disconnectNamespaces:n,connectedWallets:r,removeBalancesForWallet:a,blockchains:s}=T(),{onConnectWalletHandler:c,onDisconnectWalletHandler:l}=t,p=s().filter(O0).map(m=>m.name),u=i((m,y)=>{let[S,,C,k,x]=m,w={walletType:S,network:k.network??void 0,accounts:C};c.current?c.current(w):console.warn("onConnectWallet handler hasn't been set. Are you sure?");let I=us(S,C,p,y.supportedChainNames,x.isContractWallet);I.length&&e(I,x.namespace,k.derivationPath)},"onAccountsEvent"),d=i((m,y,S,C,k)=>{if(y===On.ACCOUNTS){let x=jn(k.supportedBlockchains);S&&u([m,y,S,C,k],{supportedChainNames:x})}y===On.PROVIDER_DISCONNECTED&&(o(m),l.current?l.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")),y===On.NAMESPACE_DISCONNECTED&&n(m,S)},"handleUpdatesForHub"),f=i((m,y,S,C,k)=>{if(y===On.ACCOUNTS){let x=jn(k.supportedBlockchains),w=[],I=[];if(S?.forEach(b=>{let{network:E}=rC(b);p.includes(E)?w.push(b):I.push(b)}),r.filter(b=>b.walletType===m).map(b=>F0(b.address,b.chain)).length>0){if(w.length>0){let b=us(m,w,p,x,k.isContractWallet);a(m,{chains:b.map(E=>E.chain)})}I.length>0&&a(m,{chains:I.map(b=>{let{network:E}=rC(b);return E})})}S?u([m,y,S,C,k],{supportedChainNames:x}):(o(m),l.current?l.current(m):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?"))}},"handleUpdatesForLegacy"),h=i((m,y,S,C,k)=>{if(y===On.CONNECTED&&S){let x={walletType:m,network:C.network??void 0,accounts:C.accounts??void 0};c.current?c.current(x):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(y===On.NETWORK&&S){let x={walletType:m,network:S,accounts:C.accounts??void 0};c.current?c.current(x):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}},"handleUpdatesForBoth");return{handler:i((m,y,S,C,k)=>{k.isHub?d(m,y,S,C,k):f(m,y,S,C,k),h(m,y,S,C,k)},"handler")}}i(iC,"useUpdates");import{LegacyEvents as U0}from"@rango-dev/wallets-core/legacy";function aC(t,e){let[o,n,r,a,s]=e;n!==U0.PROVIDER_DISCONNECTED&&t(o,n,r,a,s)}i(aC,"propagateEvents");var Xa=H0({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function q0(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r}=T(),a=T().blockchains(),s=T().config,c={walletConnectProjectId:s?.walletConnectProjectId,trezorManifest:s?.trezorManifest,tonConnect:s.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink},{providers:l}=Ap(s.wallets,c),p=lC(),u=lC(),{handler:d}=iC({onConnectWalletHandler:p,onDisconnectWalletHandler:u});sC(()=>{n().catch(console.log)},[]),sC(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:s,dappConfig:t.config})},[t.config,r]);let f=ne.use.isActiveTab(),h=Q0(()=>({onConnectWallet:g=>{p.current=g},onDisconnectWallet:g=>{u.current=g}}),[]);return ja.createElement(Xa.Provider,{value:h},ja.createElement(z0,{allBlockChains:a,providers:l,onUpdateState:(g,m,y,S,C)=>{let k=[g,m,y,S,C];d(...k),t.onUpdateState&&aC(t.onUpdateState,k)},autoConnect:!!f,configs:{wallets:s.wallets}},t.children))}i(q0,"Main");function Ya(t){let{config:e,...o}=t;return ja.createElement(Ru,{config:e},ja.createElement(q0,{...o,config:e}))}i(Ya,"WidgetWallets");import{globalCss as G0}from"@rango-dev/ui";var cC=i(()=>G0({"@import":"url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap')"})(),"globalFont");import{useWallets as V0}from"@rango-dev/wallets-react";import{useEffect as K0,useRef as j0}from"react";function pC(){let{connect:t,state:e}=V0(),o=j0({}),{fetchStatus:n}=T(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);K0(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(pC,"useForceAutoConnect");import{isApprovalTX as X0,RouteEventType as uC,StepEventType as dC,StepExecutionEventStatus as Y0,WidgetEvents as Za}from"@rango-dev/queue-manager-rango-preset";import{useEffect as mC}from"react";function Np(){let t=Ne.use.setNotification(),{connectedWallets:e,fetchBalances:o,customTokens:n}=T();mC(()=>{let r=i(a=>{let{event:s,step:c,route:l}=a;if(s.type===dC.TX_EXECUTION&&s.status===Y0.TX_SENT&&!X0(c)||s.type===dC.SUCCEEDED){let u=[],d=l.wallets[c?.fromBlockchain];if(d){let f=e.find(h=>h.address?.toLocaleLowerCase()===d.address?.toLocaleLowerCase()&&h.walletType===d.walletType&&h.chain===c?.fromBlockchain);f&&u.push(f)}if(c?.fromBlockchain!==c?.toBlockchain){let f=l.wallets[c?.toBlockchain];if(f){let h=e.find(g=>g.address?.toLocaleLowerCase()===f.address?.toLocaleLowerCase()&&g.walletType===f.walletType&&g.chain===c?.toBlockchain);h&&u.push(h)}}if(u.length>0){let f=n(),g=[{blockchain:c.fromBlockchain,address:c.fromSymbolAddress,symbol:c.fromSymbol},{blockchain:c.toBlockchain,address:c.toSymbolAddress,symbol:c.toSymbol}].filter(m=>f.some(y=>y.blockchain===m.blockchain&&y.address?.toLocaleLowerCase()===m.address?.toLocaleLowerCase()&&y.symbol?.toLocaleLowerCase()===m.symbol?.toLocaleLowerCase()));o(u,{selectedCustomTokens:g,shouldFetchCustomTokens:g.length>0})}}t(s,l)},"handleStepEvent");return ve.on(Za.StepEvent,r),()=>ve.off(Za.StepEvent,r)},[ve,e]),mC(()=>{let r=i(a=>{let{event:s,route:c}=a;(s.type===uC.FAILED||s.type===uC.SUCCEEDED)&&t(s,c)},"handleRouteEvent");return ve.on(Za.RouteEvent,r),()=>ve.off(Za.RouteEvent,r)},[ve])}i(Np,"useSubscribeToWidgetEvents");import{useManager as Z0}from"@rango-dev/queue-manager-react";import{useEffect as J0}from"react";function Bp(){let{isSynced:t,syncNotifications:e}=Ne(),{manager:o,state:n}=Z0();J0(()=>{Ne.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(kt(o))},[Ne.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Bp,"useSyncNotifications");function Mp(){pC(),cC(),Np(),Bp();let t=T().blockchains(),{canSwitchNetworkTo:e}=Xi(),[o,n]=fC(null),[r,a]=fC(),s=tB(Xa),c=t.filter(eB);Wp(()=>()=>cm(),[]),Wp(()=>()=>pm(),[]),R0({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:c,canSwitchNetworkTo:e}),Wp(()=>(Po.init(),Ne.persist.hasHydrated()||Ne.persist.rehydrate(),s.onConnectWallet(l=>{n(p=>{if(!p||p.walletType!==l.walletType)return l;let u={...p};return l.network&&(u.network=l.network),l.accounts&&(u.accounts=l.accounts),u})}),s.onDisconnectWallet(l=>{a(l),n(p=>l===p?.walletType?null:p)}),Po.destroy),[])}i(Mp,"useBootstrap");import{styled as oB}from"@rango-dev/ui";var gC=oB("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left",height:"100%","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Jo(){Mp();let{config:t}=T(),{activeTheme:e}=mo(t?.theme||{}),{activeLanguage:o}=wo();return Lp.createElement(nB,{language:o},Lp.createElement(gC,{id:"swap-container",className:e()},Lp.createElement(oC,null)))}i(Jo,"Main");import{setSolanaSignerConfig as vB}from"@rango-dev/signer-solana";import _p,{useEffect as Dp,useMemo as xB}from"react";function hC(){let{setWatermark:t,setShowProfileBanner:e}=ne();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Gt("BASE_URL")}/meta/dapp/config?apiKey=${Gt("API_KEY")}`);if(!n.ok)throw new Error(`Request failed with status: ${n.status} `);let r=await n.json();t(r.config.watermark),e(r.config.banners.profile)},"fetchApiConfig")}}i(hC,"useFetchApiConfig");import{useState as rB}from"react";var iB=i(()=>{let[t,e]=rB(null),o=i(a=>{let s=document.createElement("link");return s.href=a,s.rel="stylesheet",document.head.appendChild(s),s},"loadFont"),n=i(()=>{t&&(document.head.removeChild(t),e(null))},"unloadFont");return{handleLoadCustomFont:i(a=>{n();let s=uu(a);if(s){let c=o(s);e(c)}},"handleLoadCustomFont")}},"useFontLoader"),yC=iB;import{checkWaitingForNetworkChange as aB,makeQueueDefinition as sB}from"@rango-dev/queue-manager-rango-preset";import{Provider as lB}from"@rango-dev/queue-manager-react";import{useWallets as cB}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as pB}from"@rango-dev/wallets-shared";import{isEvmBlockchain as uB}from"rango-types";import dB,{useMemo as mB}from"react";function fB(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s,hubProvider:c}=cB(),l=mB(()=>sB({API_KEY:t.apiKey||Gt("API_KEY"),BASE_URL:Gt("BASE_URL"),emitter:{emit:ve.emit}}),[t.apiKey]),{blockchains:p,connectedWallets:u}=T(),d=p(),f={blockchains:u.map(w=>({accounts:[w],name:w.chain}))},h=i(async(w,I)=>a(w,I.network,I)?await r(w,[I]):void 0,"switchNetwork"),g=i(w=>!!s(w).mobileWallet,"isMobileWallet"),m=d.filter(w=>w.enabled).reduce((w,I)=>(w[I.name]=I,w),{}),y=d.filter(uB),S=i(w=>{let{supportedChains:I}=s(w);return jn(I)},"getSupportedChainNames"),C=e(),k={meta:{blockchains:m,evmBasedChains:y,evmNetworkChainInfo:pB(y),getSupportedChainNames:S},getSigners:o,wallets:f,providers:C,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:g,hubProvider:c},x=ne.use.isActiveTab();return dB.createElement(lB,{queuesDefs:[l],context:k,onPersistedDataLoaded:w=>{aB(w)},isPaused:!x},t.children)}i(fB,"QueueManager");var SC=fB;import{useManager as CB}from"@rango-dev/queue-manager-react";import TB,{createContext as kB,useContext as wB}from"react";function CC(){let{findToken:t}=T(),e=T().blockchains(),o=T().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:c}=H()();return i(p=>{let{fromBlockchain:u,fromToken:d,toBlockchain:f,toToken:h,requestAmount:g}=p,m={blockchains:e,tokens:o};if(u!==void 0){let y=e.find(S=>S.name===u)??null;n(y)}if(d!==void 0){let y=d?t(d)??null:null;r({meta:m,token:y})}if(f!==void 0){let y=e.find(S=>S.name===f)??null;a(y)}if(h!==void 0){let y=h?t(h)??null:null;s({meta:m,token:y})}g!==void 0&&c(g)},"updateQuoteInputs")}i(CC,"useUpdateQuoteInputs");import{cancelSwap as gB,getCurrentNamespaceOfOrNull as hB,getCurrentStep as yB,getRelatedWalletOrNull as SB}from"@rango-dev/queue-manager-rango-preset";var Ja=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return kt(this.manager)}getCurrentStep(e){return this.getCurrentStepInfo(e).step}getCurrentStepWallet(e){return this.getCurrentStepInfo(e).wallet}getCurrentStepNetwork(e){return this.getCurrentStepInfo(e).network}retry(e,o){let n=Ii(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&gB(o)}getCurrentStepInfo(e){let o=yB(e);return{step:o,wallet:o?SB(e,o):null,network:o?hB(e,o)?.network:null}}};var TC=kB(void 0);function Pp(t){let{manager:e}=CB(),o=ne.use.isActiveTab(),n=H().use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:c}=T(),l=new Ja(e,{retrySwap:n,findToken:r}),{fetchingWallets:p}=T(),u=Iu(a()),d=T().blockchains(),f=T().tokens(),h=T().swappers(),g=T().fetchStatus,m=wo().resetLanguage,y=Ne().getNotifications(),S=Ne().clearNotifications,C=CC(),{fromBlockchain:k,toBlockchain:x,fromToken:w,toToken:I,inputAmount:A}=H()(),b={isActiveTab:o,setCurrentTabAsActive:Po.forceClaim,history:l,wallets:{isLoading:p,details:s(),totalBalance:u,refetch:async E=>c(E)},meta:{blockchains:d,tokens:f,swappers:h,loadingStatus:g,findToken:r},resetLanguage:m,notifications:{list:y,clearAll:S},quote:{quoteInputs:{fromBlockchain:k?.name??null,fromToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,toBlockchain:x?.name??null,toToken:I?{symbol:I.symbol,blockchain:I.blockchain,address:I.address}:null,requestAmount:A},updateQuoteInputs:C}};return TB.createElement(TC.Provider,{value:b},t.children)}i(Pp,"WidgetInfo");function kC(){let t=wB(TC);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(kC,"useWidget");function Un(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{fetchApiConfig:r}=hC(),{handleLoadCustomFont:a}=yC();return Dp(()=>{r().catch(console.log)},[]),Dp(()=>{n&&a(n)},[n]),xB(()=>{_u({API_KEY:o?.apiKey||Rp(),BASE_URL:o?.apiUrl||ou})},[o.apiKey,o.apiUrl]),Dp(()=>{t.config?.signers?.customSolanaRPC&&vB("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),_p.createElement(Ya,{config:o,onUpdateState:e},_p.createElement(SC,{apiKey:o.apiKey},_p.createElement(Pp,null,t.children)))}i(Un,"WidgetProvider");function wC(t){let e=t.config?.externalWallets;return Ra.createElement(bi,null,e?Ra.createElement(Jo,null):Ra.createElement(Un,{config:t.config??nn},Ra.createElement(Jo,null)))}i(wC,"Refuel");import es from"react";function vC(t){let e=t.config?.externalWallets;return es.createElement(bi,null,e?es.createElement(Jo,null):es.createElement(Un,{config:t.config??nn},es.createElement(Jo,null)))}i(vC,"Widget");function xC(){let{on:t,off:e}=ve;return{on:t,off:e}}i(xC,"useWidgetEvents");var pte={DerivationPath:rr,Namespaces:tr,Detached:nr,isOnDerivationPath:ar,isOnNamespace:ir,isOnDetached:Ao};export{Lee as EventSeverity,ln as MainEvents,Qee as Networks,Vee as PendingSwapNetworkStatus,hs as QuoteEventTypes,wC as Refuel,Pee as RouteEventType,as as SUPPORTED_FONTS,pte as StatefulConnect,_ee as StepEventType,Dee as StepExecutionBlockedEventStatus,$ee as StepExecutionEventStatus,bd as SwapModeContext,Re as UI_ID,Ss as UiEventTypes,ys as WalletEventTypes,zee as WalletEvents,qee as WalletTypes,vC as Widget,ln as WidgetEvents,Un as WidgetProvider,Ya as WidgetWallets,ul as customizedThemeTokens,rs as pickProviderVersionWithFallbackToLegacy,Oee as readAccountAddress,en as useStatefulConnect,bt as useWalletList,Xi as useWallets,kC as useWidget,xC as useWidgetEvents,BT as widgetEventEmitter};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|