@rango-dev/widget-embedded 0.37.1-next.0 → 0.37.1-next.2
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/containers/WidgetInfo/WidgetInfo.types.d.ts +2 -2
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/dist/store/slices/wallets.d.ts +20 -0
- package/dist/store/slices/wallets.d.ts.map +1 -1
- package/dist/store/utils/wallets.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +2 -2
- package/src/containers/WidgetInfo/WidgetInfo.tsx +2 -2
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +2 -2
- package/src/store/slices/wallets.ts +89 -0
- package/src/store/utils/wallets.ts +4 -1
- package/src/utils/wallets.ts +4 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var Fh=Object.defineProperty;var i=(t,e)=>Fh(t,"name",{value:e,configurable:!0});import{EventSeverity as Vj,RouteEventType as Kj,StepEventType as jj,StepExecutionBlockedEventStatus as Xj,StepExecutionEventStatus as Yj}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Jj}from"@rango-dev/wallets-core/legacy";import{useWallets as jr,Events as e3}from"@rango-dev/wallets-react";import{Networks as o3,WalletTypes as n3}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as i3}from"rango-types";import{Divider as BS}from"@rango-dev/ui";import po,{useEffect as MS,useRef as LS,useState as Nc}from"react";import{WalletState as Oh}from"@rango-dev/ui";import{useWallets as Uh}from"@rango-dev/wallets-react";import{useReducer as zh}from"react";function tp(t){return!!t.derivationPath}i(tp,"isStateOnDerivationPathStep");function op(t){return!!t.namespace}i(op,"isStateOnNamespace");var tr={status:"init",namespace:null,derivationPath:null};function np(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"reset":return tr;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:tr;default:throw new Error("Action hasn't been defined.")}}i(np,"reducer");function Gt(){let{state:t,disconnect:e,connect:o}=Uh(),[n,r]=zh(np,tr),a=i(async(c,m,h)=>{r({type:"reset"});try{let f=m?.map(d=>({...d,network:void 0}));return await o(c,f),{status:"connected"}}catch(f){let d=f?.message?`Error: ${f.message}`:"An unknown error happened during connecting wallet.";throw new Error(d,{cause:f})}},"runConnect"),s=i(async(c,m)=>{if(c.state===Oh.DISCONNECTED){if(!!c.isHub&&c.properties?.find(T=>T.name==="detached")&&c.state!=="connected")return r({type:"needsNamespace",payload:{targetWallet:c}}),{status:"namespace"};if(!c.needsNamespace)return await a(c.type,void 0,m);let d=c.needsNamespace.data.length>1,g=c.needsDerivationPath;if(d)return r({type:"needsNamespace",payload:{targetWallet:c}}),{status:"namespace"};if(g){let C=c.needsNamespace.data[0];return r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:C.value}}),{status:"derivation-path"}}return await a(c.type,c.needsNamespace?.data.map(C=>({namespace:C.value})),m)}return m?.disconnectIfConnected?(await u(c.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(c,m)=>{let h=c.needsNamespace?.selection==="single",f=c.needsDerivationPath,d=m[0];if(!d)throw new Error("To confirm a namespace, you should select at least one namespace.");if(h&&f)return r({type:"needsDerivationPath",payload:{providerType:c.type,providerImage:c.image,namespace:d}}),{status:"derivation-path"};if(!op(n))throw new Error("Something went wrong on handling namespace. Please retry.");let g=n.namespace.targetWallet.type,C=m.map(S=>({namespace:S}));return await a(g,C)},"handleNamespace"),p=i(async c=>{if(!c)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!tp(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let m=n.derivationPath.providerType,f=[{namespace:n.derivationPath.namespace,derivationPath:c}];return await a(m,f)},"handleDerivationPath"),u=i(async c=>{let m=t(c);return m.connected||m.connecting?(await e(c),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:l,handleDerivationPath:p,getState:()=>n,resetState:c=>{r(c==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(Gt,"useStatefulConnect");import{WalletState as fa}from"@rango-dev/ui";import{useWallets as Xy}from"@rango-dev/wallets-react";import{detectMobileScreens as Yy,KEPLR_COMPATIBLE_WALLETS as Zy,WalletTypes as cn}from"@rango-dev/wallets-shared";import{useCallback as Jy,useEffect as Ry}from"react";import Hy,{createContext as Gy,useContext as Vy,useEffect as Ky,useRef as jy}from"react";import{create as Qy}from"zustand";import{persist as qy}from"zustand/middleware";import{allProviders as Qh}from"@rango-dev/provider-all";var Zi=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()}},bo=new Zi;import{defineVersions as rp,pickVersion as ip,Provider as Ji}from"@rango-dev/wallets-core";function ap({allProviders:t,configWallets:e,options:o}){if(e){let n=[];return e.forEach(r=>{if(typeof r=="string"){let a=t.find(s=>{let l=sp(s,o);return l instanceof Ji?l.id===r:l.config.type===r});a?n.push(a):console.warn(`Couldn't find ${r} provider. Please make sure you are passing the correct name.`)}else r instanceof Ji?n.push(rp().version("1.0.0",r).build()):n.push(rp().version("0.0.0",r).build())}),n}return t}i(ap,"matchAndGenerateProviders");function sp(t,e){let{experimentalWallet:o="enabled"}=e||{},n=o=="disabled"?"0.0.0":"1.0.0";try{return ip(t,n)[1]}catch{return ip(t,"0.0.0")[1]}}i(sp,"pickProviderVersionWithFallbackToLegacy");function lp(t,e){return t.map(n=>sp(n,e)).map(n=>n instanceof Ji?n.id:n.config.type)}i(lp,"configWalletsToWalletName");function or(t,e){return e.find(o=>o.name===t)?.displayName}i(or,"getBlockchainDisplayNameFor");function st(t,e){return e.find(o=>o.name===t)?.shortName}i(st,"getBlockchainShortNameFor");function pp(t,e){return e.find(o=>o.name===t)?.logo}i(pp,"getBlockchainImage");function on(t,e){return e.find(o=>o.id===t)?.title}i(on,"getSwapperDisplayName");function nn(t,e){return e.find(o=>o.name===t)??null}i(nn,"findBlockchain");function Ri(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(Ri,"isTokenNative");function lt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(lt,"createTokenHash");function Eo(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(Eo,"isValidTokenAddress");function rn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(p=>{typeof p!="string"&&(p=lt(p));let u=o.tokensMapByTokenHash.get(p);u&&(n[p]=u)})},"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 l=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(p=>{l.has(p)||a(o.tokensMapByBlockchainName[p])})}return s.forEach(l=>{let p=r[l];if(!p&&o.tokensMapByBlockchainName?.[l]){a(o.tokensMapByBlockchainName[l]);return}p&&(p.isExcluded?(a(o.tokensMapByBlockchainName[l]),p.tokens.forEach(u=>{let c=lt(u);delete n[c]})):a(p.tokens))}),Object.values(n)}i(rn,"matchTokensFromConfigWithMeta");function nr(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(nr,"getSupportedBlockchainsFromConfig");function up(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink,experimentalWallet:t.features?.experimentalWallet}}i(up,"makeProvidersOptionsFromConfig");var rr={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"},features:{experimentalWallet:"enabled"}},qh={clientUrl:void 0},Hh={liquiditySources:void 0};function cp(t){let e=up(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 Qh(o).map(a=>a())}i(cp,"generateProviders");var mp=i((t,e,o)=>{let n=cp({...rr,...t});return{config:{...rr,...t},iframe:qh,campaignMode:Hh,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:l}=o(),p=rn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}}),u=rn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}});bo.set("supportedSourceTokens",p),bo.set("supportedDestinationTokens",u),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=cp(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=up(a);return ap({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as dp}from"rango-types";var fp=[dp.EVM,dp.SOLANA];import{RangoClient as iy}from"rango-sdk";import{UI_ID as Gh}from"@rango-dev/ui";var ir="c6381a79-2817-4602-83bf-6a641a409e32",gp="https://api.rango.exchange",hp="https://explorer.rango.exchange",$e={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...Gh};import{BlockchainCategories as Jh,WalletState as xt}from"@rango-dev/ui";import{legacyReadAccountAddress as Rh}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as ey,getCosmosExperimentalChainInfo as ty,isEvmAddress as oy,KEPLR_COMPATIBLE_WALLETS as eA,Networks as Np}from"@rango-dev/wallets-shared";import ro from"bignumber.js";import{isCosmosBlockchain as ny}from"rango-types";import Vh from"bignumber.js";var ge=new Vh(0);import{WalletTypes as Kh}from"@rango-dev/wallets-shared";var yp=[Kh.LEAP];import{BlockchainCategories as ta,WalletState as Zh}from"@rango-dev/ui";import{TransactionType as ar}from"rango-sdk";var Sp="Roboto",ea=[{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 Io(t){return Array.from(new Set(t))}i(Io,"removeDuplicateFrom");function xp(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(xp,"debounce");function Je(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(Je,"containsText");function Tp(t,e){return t.toLowerCase()===e.toLowerCase()}i(Tp,"exactText");function vp(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(vp,"startWithText");var W=i(()=>document.getElementById($e.SWAP_BOX_ID),"getContainer"),no=i(()=>document.getElementById($e.EXPANDED_BOX_ID),"getExpanded");function wp(t,e,o){let n=!!e&&Tp(e,t),r=!!o&&Tp(o,t);return n!==r?n?-1:1:0}i(wp,"compareExactMatchText");function oa(t,e,o){let n=!!e&&Je(e,t),r=!!o&&Je(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(oa,"compareContainsText");function na(t,e,o){let n=!!e&&vp(e,t),r=!!o&&vp(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(na,"compareStartWithText");function bp(t,e,o){if(!o)return 0;let n=wp(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=wp(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=na(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=oa(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=na(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=oa(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=na(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=oa(o,t.address,e.address);if(r!==0)return r}return 0}i(bp,"compareWithSearchFor");var sr=i((t,e)=>{switch(e){case ta.ALL:return!0;case ta.UTXO:return t===ar.TRANSFER;case ta.OTHER:return t!==ar.TRANSFER&&t!==ar.COSMOS&&t!==ar.EVM;default:return t===e}},"isBlockchainTypeInCategory"),Ep=i(t=>ea.find(o=>o.value===t)?.url,"getFontUrlByName");function Ip(t,e){let o=!!t.find(n=>n.state===Zh.CONNECTED);return e===!1&&o}i(Ip,"isSingleWalletActive");import{BigNumber as Ap}from"bignumber.js";var an=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"),L=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Ap(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Ap(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 lr=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var wt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),sn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function ln(t){switch(!0){case t.connected:return xt.CONNECTED;case t.connecting:return xt.CONNECTING;case!t.installed:return xt.NOT_INSTALLED;default:return xt.DISCONNECTED}}i(ln,"mapStatusToWalletState");function Wp(t,e,o,n){return o.filter(r=>!yp.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:p}=t(r);return s&&(!l||!!n&&p!==n)?!1:n?!!a.find(c=>c.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:p,needsNamespace:u,supportedChains:c,needsDerivationPath:m,properties:h,isHub:f}=e(r),d=Io(c.map(C=>C.type)),g=ln(t(r));return{title:a,image:s,link:ey(l),state:g,type:r,showOnMobile:p,needsNamespace:u,blockchainTypes:d,needsDerivationPath:m,properties:h,isHub:f}})}i(Wp,"mapWalletTypesToWalletInfo");function ur(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(ur,"walletAndSupportedChainsNames");function ra(t,e,o,n,r){let a=[];function s(p,u){if(!!!a.find(m=>m.chain===p)){let m={address:u,chain:p,walletType:t};a.push(m)}}i(s,"addAccount");let l=n||[];return e.forEach(p=>{let{address:u,network:c}=Rh(p),m=l.length>0,h=l.includes(c),f=c===Np.Unknown;if(m&&!h&&!f)return;let g=c===Np.Unknown&&oy(u);if(f&&!g)return;o.includes(c)||g?r?s(c,u.toLowerCase()):l.filter(T=>o.includes(T)).forEach(T=>{s(T,u.toLowerCase())}):s(c,u)}),a}i(ra,"prepareAccountsForWalletStore");function io(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,l=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:p}=r;p.forEach((u,c)=>{let m=u.from.blockchain,h=u.to.blockchain,f=a===o.swaps.length-1,d=c===p.length-1;(!f&&!d||f&&l!==m||e==="all")&&n.add(m),e==="all"&&n.add(h)})}e==="all"&&n.add(l)}),Array.from(n)}i(io,"getQuoteWallets");function Bp(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(Bp,"isAccountAndWalletMatched");var Mp=i(t=>{let e=Object.values(t).reduce((o,n)=>n.usdValue?o.plus(n.usdValue):o,new ro(ge));return ry(e.toString())},"calculateWalletUsdValue");function ry(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(ry,"numberWithThousandSeparator");var mr=i((t,e)=>{let o=ty(Object.entries(t).map(([,n])=>n).filter(ny));return o&&o[e]?.experimental},"isExperimentalChain");function dr(t){if(!t)return null;let e=new ro(t.amount).shiftedBy(-t.decimals).toFixed(),o=t.usdValue?new ro(t.usdValue).shiftedBy(-t.decimals).toFixed():null,n=L(e,8,8),r=o?L(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(dr,"formatBalance");function Lp(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new ro(t.usdValue).shiftedBy(-t.decimals):ge,n=e&&e.usdValue?new ro(e.usdValue).shiftedBy(-e.decimals):ge;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new ro(t.amount).shiftedBy(-t.decimals):ge,n=e&&e.amount?new ro(e.amount).shiftedBy(-e.decimals):ge;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Lp,"compareTokenBalance");function Mt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Mt,"areTokensEqual");function Pp(t){return t.sort((e,o)=>+(o.state===xt.CONNECTED)-+(e.state===xt.CONNECTED)||+(o.state===xt.DISCONNECTED||o.state===xt.CONNECTING)-+(e.state===xt.DISCONNECTED||e.state===xt.CONNECTING))}i(Pp,"sortWalletsBasedOnConnectionState");function fr(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(fr,"getConciseAddress");function _p({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(_p,"getAddress");var $p=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Dp(t){return t.map(e=>e.state).join("-")}i(Dp,"hashWalletsState");function Fp(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(Fp,"filterBlockchainsByWalletTypes");function Op(t,e){return e===Jh.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(sr(n,e))return!0;return!1})}i(Op,"filterWalletsByCategory");var ia={API_KEY:ir};function Lt(t){return ia[t]||""}i(Lt,"getConfig");function Up(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ia=e,ia}i(Up,"initConfig");var zp=20,Qp=25,aa="theme-widget",sa=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Mt(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>Mt(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),la=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),qp=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var gr,bt=i(()=>gr||(gr=new iy(Lt("API_KEY"),Lt("BASE_URL")),gr),"httpService");function hr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Io(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(l=>l.swapperGroup===a);if(s){let l=!0;o&&(l=o.some(p=>p===s.swapperGroup)),l&&s.types.map(p=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:p,selected:!e.includes(s.swapperGroup)})})}}),n}i(hr,"getUniqueSwappersGroups");function Hp(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Hp,"sortLiquiditySourcesByGroupTitle");function Ve(t,e){return e?.[t]==="hidden"}i(Ve,"isFeatureHidden");function Gp(t,e){return e?.[t]==="enabled"}i(Gp,"isFeatureEnabled");function Ao(t,e){return e?.[t]==="enabled"}i(Ao,"isRoutingEnabled");var Vp=i((t,e,o)=>Ve("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var Kp=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 p=nr({config:a}),u=r;return p.length>0&&(u=u.filter(c=>p.includes(c.name))),u.filter(c=>fp.includes(c.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(p=>!(s.length>0&&!s.includes(p.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),l=Array.from(n.values()),p=e()._blockchainsMapByName;if(!o||!o.type)return l;let u=o.type==="source"?"from":"to",c=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",m=bo.get(c);m?.length||(m=rn({type:o.type,config:{blockchains:a[u]?.blockchains,tokens:a[u]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),bo.set(c,m)),m=Vp(m,s,a.features);let h=e().blockchains({type:o.type});return m.filter(d=>o.blockchain&&d.blockchain!==o.blockchain||!h.some(g=>g.name===d.blockchain)?!1:o.searchFor?!!(Je(d.symbol,o.searchFor)||Je(d.address||"",o.searchFor)||Je(d.name||"",o.searchFor)):!0).sort((d,g)=>{let C=e().isTokenPinned(d,o.type),S=e().isTokenPinned(g,o.type);if(C!==S)return C?-1:1;if(o.getBalanceFor){let A=o.getBalanceFor(d),M=o.getBalanceFor(g),x=Lp(A,M);if(x!==0)return x}let T=p.get(d.blockchain),k=p.get(g.blockchain),v=Ri(d,T),w=Ri(g,k);if(v!==w)return v?-1:1;if(d.isPopular!==g.isPopular)return d.isPopular?-1:1;if(o.searchFor){let A=bp(d,g,o.searchFor);if(A)return A}return d.isSecondaryCoin!==g.isSecondaryCoin?d.isSecondaryCoin?1:-1:T&&k?T.sort-k.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=lt(o),s=n.get(a);return s||(s=r.find(l=>lt(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>Mt(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(u=>{let c=a?.includes(u.swapperGroup);return s||!a||a.length===0?!c:c}).sort(Hp)},fetch:async()=>{try{let{routing:o}=e().config,n=Ao("enableCentralizedSwappers",o),r=await bt().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,l={},p=[],u=r.popularTokens,c=r.swappers.filter(f=>f.enabled),m=new Set;r.tokens.forEach(f=>{m.add(f.blockchain),p.push(f)}),r.blockchains.sort((f,d)=>f.sort-d.sort).forEach(f=>{f.enabled&&m.has(f.name)&&a.set(f.name,f)}),p.forEach(f=>{let d=lt(f);l[f.blockchain]||(l[f.blockchain]=[]),s.set(d,f),l[f.blockchain].push(d)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l,_popularTokens:u,_swappers:c})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as ay,Catalonia as sy,Chinese as jp,Denmark as ly,English as py,Finland as cy,French as uy,German as my,Greece as dy,Hungary as fy,India as gy,Indonesian as hy,Italian as yy,Japanese as Sy,Korea as Cy,Lithuania as ky,Malay as Ty,Netherlands as vy,Pakistan as wy,Philippines as xy,Poland as by,Portuguese as Ey,Russian as Iy,SaudiArabia as Ay,Serbia as Ny,Slovakia as Wy,SouthAfrica as By,Spanish as My,Swahili as Ly,Swedish as Py,Thai as _y,Turkish as $y,Ukrainian as Dy,Vietnamese as Fy}from"@rango-dev/ui";var Xp=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:By},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:Ay},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:ay},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:sy},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:jp},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:jp},{title:"Danish",label:"Dansk",local:"da",SVGFlag:ly},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:vy},{title:"English",label:"English",local:"en",SVGFlag:py},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:xy},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:cy},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:uy},{title:"German",label:"Deutsch",local:"de",SVGFlag:my},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:dy},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:gy},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:fy},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:hy},{title:"Italian",label:"Italiana",local:"it",SVGFlag:yy},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:Sy},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:Cy},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:ky},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:Ty},{title:"Polish",label:"Polski",local:"pl",SVGFlag:by},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:Ey},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:Iy},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:Ny},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:Wy},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:My},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:Ly},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:Py},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:_y},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:$y},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:Dy},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:wy},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:Fy}],No="en";var Yp=[.5,1,3],Zp=1,Jp=5,Rp=100,ec=0;var tc=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:Zp,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let p=s===o,u=l<=9;return p&&u}))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=Io(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=Ve("theme",n),s=Ve("language",n),l=Ve("liquiditySource",n),p=r?.singleTheme,u=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...p&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||No},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...u&&{language:o.language||No}})},setCustomToken:o=>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=nr({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import ac from"bignumber.js";import Oy from"mitt";var he=Oy(),Uy={on:he.on,off:he.off};import{WidgetEvents as oc}from"@rango-dev/queue-manager-rango-preset";var ca=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(ca||{}),ua=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(ua||{}),ma=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(ma||{}),Wo=(a=>(a[a.RouteEvent=oc.RouteEvent]="RouteEvent",a[a.StepEvent=oc.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(Wo||{});import zy from"bignumber.js";function pn(t){return`${t.blockchain}-${t.address}-${t.symbol}`}i(pn,"createAssetKey");function da(t,e){return`${pn(e)}-${t}`}i(da,"createBalanceKey");function yr(t){let[e,o,n]=t.split("-");return{address:o,blockchain:e,symbol:n}}i(yr,"extractAssetFromBalanceKey");function nc(t,e){let o={};return t.balances?.forEach(n=>{let r=da(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,l=e().findToken(n.asset)?.usdPrice,p=l?new zy(l??ge).multipliedBy(a).toString():"",u={amount:a,decimals:s,usdValue:p};o[r]=u}),o}i(nc,"createBalanceStateForNewAccount");function rc(t,e){for(let o in e){let n=yr(o),r=pn(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}return t}i(rc,"updateAggregatedBalanceStateForNewAccount");function ic(t,e){let o=yr(e),n=pn(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(ic,"removeBalanceFromAggregatedBalance");var sc=i((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!1,error:!1}:r)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:o=>{let n=e().connectedWallets,r=o.filter(a=>!n.some(s=>Bp(a,s)));if(r.length>0){let a=r.map(s=>{let l=!n.some(p=>p.chain===s.chain&&p.selected&&p.walletType!==s.walletType);return{address:s.address,chain:s.chain,explorerUrl:null,walletType:s.walletType,selected:l,loading:!1,error:!1}});t(s=>({connectedWallets:[...s.connectedWallets.filter(p=>!a.some(u=>u.walletType===p.walletType&&u.chain===p.chain)),...a]}))}},setWalletsAsSelected:o=>{let n=e().connectedWallets.map(r=>{let a=!!o.find(l=>l.chain===r.chain&&l.walletType!==r.walletType&&r.selected),s=!!o.find(l=>l.chain===r.chain&&l.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r});t({connectedWallets:n})},newWalletConnected:async o=>{he.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}}),e().addConnectedWallet(o),e().fetchBalances(o)},removeBalancesForWallet:(o,n)=>{let r=e().connectedWallets.filter(u=>u.walletType===o);e().connectedWallets.forEach(u=>{u.walletType!==o&&(r=r.filter(c=>!(c.chain===u.chain&&c.address===u.address)))}),n?.chains&&n.chains.length>0&&(r=r.filter(u=>n.chains?.includes(u.chain)));let a={},s=e()._aggregatedBalances,l=e()._balances;Object.keys(l).forEach(u=>{let c=yr(u),m=!!r.find(h=>da(h.address,{address:c.address,blockchain:h.chain,symbol:c.symbol})===u);m||(a[u]=l[u]),m&&(s=ic(s,u))}),t({_balances:a,_aggregatedBalances:s})},disconnectWallet:o=>{if(e().connectedWallets.find(r=>r.walletType===o)){he.emit("walletEvent",{type:"disconnect",payload:{walletType:o}}),e().removeBalancesForWallet(o);let r=e().connectedWallets.filter(s=>s.selected&&s.walletType===o).map(s=>s.chain),a=e().connectedWallets.filter(s=>s.walletType!==o);r.length>0&&(a=a.map(s=>r.includes(s.chain)?(r=r.filter(l=>l!==s.chain),{...s,selected:!0}):s)),t({connectedWallets:a})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let r=o[0].walletType;e().setConnectedWalletAsRefetching(r);let a=o.map(p=>({address:p.address,blockchain:p.chain})),l=(await bt().getWalletsDetails(a)).wallets;if(l){let{retryOnFailedBalances:p=!0}=n||{};if(p){let m=l.filter(h=>h.failed).map(h=>({chain:h.blockChain,walletType:r,address:h.address}));m.length>0&&e().fetchBalances(m,{retryOnFailedBalances:!1})}let u={},c=e()._aggregatedBalances;l.forEach(m=>{if(m.failed)return;let h=nc(m,e);c=rc(c,h),u={...u,...h}}),t(m=>({_balances:{...m._balances,...u},_aggregatedBalances:c})),e().setConnectedWalletRetrievedData(r)}else throw e().setConnectedWalletHasError(r),new 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=pn(o),a=e()._aggregatedBalances[r]||[];if(a.length===0)return null;if(a.length===1){let p=a[0];return n[p]}let l=n[a[0]];return a.forEach(p=>{let u=n[p],c=new ac(u.amount),m=new ac(l.amount);c.isGreaterThan(m)&&(l=u)}),l}}),"createWalletsSlice");function lc(t){return Qy()(qy((...e)=>({...sc(...e),...Kp(...e),...tc(...e),...mp(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})}))}i(lc,"createAppStore");var pc=Gy(null);function y(){let t=Vy(pc);if(Ky(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function cc(t){let e=jy();return e.current||(e.current=lc(t.config)),Hy.createElement(pc.Provider,{value:e.current},t.children)}i(cc,"AppStoreProvider");function ft(t){let{chain:e}=t||{},{config:o,connectedWallets:n,getAvailableProviders:r}=y(),{state:a,getWalletInfo:s}=Xy(),l=y().blockchains(),{handleDisconnect:p}=Gt(),u=lp(r(),{trezorManifest:o?.trezorManifest,walletConnectProjectId:o?.walletConnectProjectId,walletConnectListedDesktopWalletLink:o.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink,tonConnect:o.tonConnect}),c=Wp(a,s,u,e);c=Yy()?c.filter(C=>C.showOnMobile!==!1&&a(C.type).installed):c;let m=Pp(c),h=i(C=>!n.find(S=>S.walletType===C&&S.chain===e),"isExperimentalChainNotAdded"),f=Jy(()=>{let C=c?.filter(S=>S.state===fa.CONNECTING)||[];for(let S of C)p(S.type)},[Dp(c)]);Ry(()=>()=>{f()},[]);let d=i(C=>{let S=C.find(k=>k.type===cn.DEFAULT);return!S||S.state===fa.NOT_INSTALLED?!1:C.filter(k=>k.state!=fa.NOT_INSTALLED&&![cn.DEFAULT,cn.WALLET_CONNECT_2,cn.LEDGER].includes(k.type)&&s(k.type).supportedChains.filter(v=>v.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),g=i((C,S,T)=>mr(T,S)&&h(C)&&!Zy.includes(C)||C==cn.DEFAULT&&!d(c),"shouldExcludeWallet");return{list:m.filter(C=>!g(C.type,e??"",l)),terminateConnectingWallets:f}}i(ft,"useWalletList");import{Modal as nS}from"@rango-dev/ui";import rS from"react";import{create as oS}from"zustand";var uc="rango-widget";var un=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(uc),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 tS=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"),Bo=tS;var re=Bo(oS()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",showProfileBanner:!1,fetchingApiConfig:!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})}}))),ao=new un({onInit:()=>re.setState({tabManagerInitiated:!0}),onClaim:()=>re.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>re.setState({isActiveTab:!1})});function Z(t){let{watermark:e}=re();return rS.createElement(nS,{hasWatermark:e==="FULL",...t},t.children)}i(Z,"WatermarkedModal");import{i18n as ga}from"@lingui/core";import{Button as cS,Checkbox as uS,Divider as mS,Image as Tc,ListItemButton as dS,MessageBox as fS,Radio as gS,RadioRoot as hS}from"@rango-dev/ui";import we,{useState as yS}from"react";import{css as iS,darkTheme as dc,IconButton as aS,styled as so}from"@rango-dev/ui";var Et=so(aS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${dc} &`]:{backgroundColor:"$neutral"}}}),fc=so("div",{position:"absolute",background:"$secondary500",[`.${dc} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Vt=so("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),gc=so("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"}}}}),hc=so("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),yc=so("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),Sc=iS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Sr=so("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as sS,styled as Cr}from"@rango-dev/ui";var oN=Cr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Mo=Cr("div",{position:"relative"}),lS=sS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Lo=Cr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${lS} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),kr=Cr("div",{"& img":{borderRadius:"50%"}});function Cc(t,e){return t.find(o=>o.name===e)?.logo}i(Cc,"getBlockchainLogo");import{styled as pS}from"@rango-dev/ui";var kc=pS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function mn(t){let{targetWallet:e}=t.value,o=e.needsNamespace?.selection==="single",n=e.image,[r,a]=yS([]),s=y().blockchains(),l=i(u=>{a(o?[u]:c=>c.includes(u)?c.filter(m=>m!==u):c.concat(u))},"onSelect"),p=i(u=>o?we.createElement(hS,{value:r?.[0]},u):we.createElement(we.Fragment,null,u),"wrapRadioRoot");return we.createElement(we.Fragment,null,we.createElement(mS,{size:20}),we.createElement(fS,{type:"info",title:ga.t("Select chain types"),description:ga.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:we.createElement(Mo,null,we.createElement(Sr,null,we.createElement(Tc,{src:n,size:45})),we.createElement(Lo,null))}),we.createElement(kc,null,p(we.createElement(we.Fragment,null,e.needsNamespace?.data.map(u=>we.createElement(dS,{key:u.id,id:u.id,title:u.label,hasDivider:!0,style:{height:60},onClick:()=>l(u.value),start:we.createElement(Tc,{src:Cc(s,u.id),size:22}),end:o?we.createElement(gS,{value:u.value}):we.createElement(uS,{checked:r.includes(u.value)})}))))),we.createElement(cS,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},ga.t("Confirm")))}i(mn,"Namespaces");import{i18n as Po}from"@lingui/core";import{Button as kS,Divider as xc,Image as TS,MessageBox as vS,Select as wS,TextField as xS}from"@rango-dev/ui";import Oe,{useEffect as bS,useState as bc}from"react";import{namespaces as SS}from"@rango-dev/wallets-shared";var Tr={id:"custom",label:"Custom",generateDerivationPath:t=>t};function ha(t){let e=t?SS[t].derivationPaths:null;return e?[...e,Tr]:[]}i(ha,"getDerivationPaths");import{styled as vc,Typography as CS}from"@rango-dev/ui";var wc=vc("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),ya=vc(CS,{paddingLeft:"$10"}),Sa={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var Ec="0";function dn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=bc(null),[l,p]=bc(Ec),u=a===Tr.id,c=ha(o),m=i(({value:f})=>{let d=c?.find(g=>g.id===f);d&&(a===Tr.id&&Number.isNaN(Number(l))&&p(Ec),s(d.id))},"handleDerivationPathItemClick"),h=i(()=>{let f=c.find(d=>d.id===a);if(f)e(f.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return bS(()=>{s(ha(o)[0]?.id||null)},[o]),Oe.createElement(Oe.Fragment,null,Oe.createElement(xc,{size:20}),Oe.createElement(vS,{type:"info",title:Po.t("Select Derivation Path"),description:Po.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Oe.createElement(Mo,null,Oe.createElement(kr,null,Oe.createElement(TS,{src:n,size:45})),Oe.createElement(Lo,null))}),Oe.createElement(wc,null,Oe.createElement(ya,{variant:"body",size:"xsmall",color:"$neutral600"},Po.t("Choose Derivation Path Template")),Oe.createElement(wS,{value:a||"",options:c.map(f=>({value:f.id,label:f.label})),variant:"filled",handleItemClick:m,styles:{trigger:Sa}}),Oe.createElement(xc,{size:20}),Oe.createElement(ya,{variant:"body",size:"xsmall",color:"$neutral600"},u?Po.t("Enter Path"):Po.t("Enter Index")),Oe.createElement(xS,{type:u?"text":"number",variant:"contained",value:l,onChange:f=>p(f.target.value),style:Sa})),Oe.createElement(kS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:h,disabled:!c||!a||!l},Po.t("Confirm")))}i(dn,"DerivationPath");import{i18n as _o}from"@lingui/core";import{Image as ES,MessageBox as Ca,WalletState as IS}from"@rango-dev/ui";import{useWallets as AS}from"@rango-dev/wallets-react";import lo from"react";function ka(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=AS();return ln(a(n))===IS.CONNECTED?lo.createElement(Ca,{type:"success",title:_o.t("Wallet Connected"),description:_o.t("Your wallet is connected, you can use it to swap.")}):o?lo.createElement(Ca,{type:"error",title:_o.t("Failed to Connect"),description:o||_o.t("Your wallet is not connected. Please try again.")}):lo.createElement(Ca,{type:"loading",title:_o.t("Connecting to your wallet"),description:_o.t("Click connect in your wallet popup."),icon:lo.createElement(Mo,null,lo.createElement(kr,null,lo.createElement(ES,{src:r,size:45})),lo.createElement(Lo,null))})}i(ka,"ConnectStatus");import{i18n as Ta}from"@lingui/core";import{Button as NS,Divider as Ic,MessageBox as WS}from"@rango-dev/ui";import vr from"react";function va(t){let{displayName:e,onConfirm:o}=t;return vr.createElement(WS,{title:Ta.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:Ta.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},vr.createElement(Ic,{size:18}),vr.createElement(Ic,{size:32}),vr.createElement(NS,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},Ta.t("Confirm")))}i(va,"ExperimentalChain");function Ac(t,e){return t().status==="init"&&!!e}i(Ac,"isOnStatus");function fn(t){return t().status==="namespace"}i(fn,"isOnNamespace");function gn(t){return t().status==="derivationPath"}i(gn,"isOnDerivationPath");var PS=3e3,_S=300;function co(t){let e=LS(),[o,n]=Nc(!1),[r,a]=Nc(),s=i(S=>{a(S.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ft(),{handleConnect:p,handleDerivationPath:u,handleNamespace:c,getState:m,resetState:h}=Gt(),f=i(S=>{c(t.wallet,S).catch(s)},"handleConfirmNamespaces"),d=i(S=>{if(!S)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");u(S).catch(s)},"handleDerivationPathConfirm"),g=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),h(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState");return MS(()=>{if(t.wallet){C();let S=!1,T=!0,k=i(()=>{setTimeout(()=>{T=!1,S||n(!0)},_S)},"beforeConnecting"),v=i(w=>{let A=w.status==="connected",M=["disconnected","disconnected-unhandled"].includes(w.status);["namespace","derivation-path"].includes(w.status)||(S=!0),A&&!T?e.current=setTimeout(g,PS):M&&g(),t.onConnect&&t.onConnect(w)},"afterConnected");k(),p(t.wallet,{disconnectIfConnected:!0}).then(v).catch(s)}},[t.wallet]),po.createElement(Z,{open:o,onClose:g,onExit:()=>{C(),l(),t.onClose&&t.onClose()},container:W()},Ac(m,t.wallet)&&po.createElement(po.Fragment,null,po.createElement(ka,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),po.createElement(BS,{direction:"vertical",size:32})),fn(m)&&po.createElement(mn,{onConfirm:f,value:m().namespace}),gn(m)&&po.createElement(dn,{onConfirm:d,value:m().derivationPath}))}i(co,"StatefulConnectModal");import{legacyFormatAddressWithNetwork as DS,legacyReadAccountAddress as Bc}from"@rango-dev/wallets-core/legacy";import{Events as wr,Provider as FS}from"@rango-dev/wallets-react";import{isEvmBlockchain as OS}from"rango-sdk";import xr,{createContext as US,useEffect as Mc,useMemo as zS,useRef as Lc}from"react";import{useEffect as $S}from"react";function Wc(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Wc,"hashProviders");function wa(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=y(),a=n();return $S(()=>{o(),r()},[Wc(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(wa,"useWalletProviders");var br=US({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function QS(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r,removeBalancesForWallet:a}=y(),s=y().blockchains(),{newWalletConnected:l,disconnectWallet:p,connectedWallets:u}=y(),c=y().config,m={walletConnectProjectId:c?.walletConnectProjectId,trezorManifest:c?.trezorManifest,tonConnect:c.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink,experimentalWallet:t.config.features?.experimentalWallet},{providers:h}=wa(c.wallets,m),f=Lc(),d=Lc();Mc(()=>{n().catch(console.log)},[]),Mc(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:c,dappConfig:t.config})},[t.config,r]);let g=s.filter(OS).map(k=>k.name),C=i((k,v,w,A,M)=>{if(v===wr.ACCOUNTS){let x=ur(M.supportedBlockchains),E=[],b=[];if(w?.forEach(I=>{let{network:B}=Bc(I);g.includes(B)?E.push(I):b.push(I)}),u.filter(I=>I.walletType===k).map(I=>DS(I.address,I.chain)).length>0){if(E.length>0){let I=ra(k,E,g,x,M.isContractWallet);a(k,{chains:I.map(B=>B.chain)})}b.length>0&&a(k,{chains:b.map(I=>{let{network:B}=Bc(I);return B})})}if(w){let I=ra(k,w,g,x,M.isContractWallet);I.length&&l(I)}else p(k),d.current?d.current(k):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")}if(v===wr.ACCOUNTS&&A.connected||v===wr.ACCOUNTS&&M.isHub){let x=`${k}-${A.network}-${w}`;f.current?f.current(x):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(v===wr.NETWORK&&A.network){let x=`${k}-${A.network}`;f.current?f.current(x):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}t.onUpdateState&&t.onUpdateState(k,v,w,A,M)},"onUpdateState"),S=re.use.isActiveTab(),T=zS(()=>({onConnectWallet:k=>{f.current=k},onDisconnectWallet:k=>{d.current=k}}),[]);return xr.createElement(br.Provider,{value:T},xr.createElement(FS,{allBlockChains:s,providers:h,onUpdateState:C,autoConnect:!!S,configs:{wallets:c.wallets,isExperimentalEnabled:Gp("experimentalWallet",c.features)}},t.children))}i(QS,"Main");function Er(t){let{config:e,...o}=t;return xr.createElement(cc,{config:e},xr.createElement(QS,{...o,config:e}))}i(Er,"WidgetWallets");import Xi from"react";import qS,{Fragment as HS}from"react";import{MemoryRouter as GS,useInRouterContext as VS}from"react-router";function Pc({children:t}){let o=VS()?HS:GS;return qS.createElement(o,null,t)}i(Pc,"AppRouter");import{I18nManager as IE}from"@rango-dev/ui";import Zl from"react";import _e from"react";import{useRoutes as dE}from"react-router-dom";var D={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 Do,useRef as _r}from"react";import Ke from"bignumber.js";import{create as XS}from"zustand";import{subscribeWithSelector as YS}from"zustand/middleware";import{i18n as gt}from"@lingui/core";import{RouteEventType as pB}from"@rango-dev/queue-manager-rango-preset";import Ue from"bignumber.js";import{PendingSwapNetworkStatus as Lr}from"rango-types";import{i18n as De}from"@lingui/core";var R=i(()=>({genericServerError:De.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:De.t("Please reset your liquidity sources."),description:De.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:De.t("No Routes Found."),description:De.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:De.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:De.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:De.t("High Price Impact"),title:De.t("Price impact is too high!"),description:De.t("The price impact is significantly higher than the allowed amount."),confirmMessage:De.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:De.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:De.t("USD Price Unknown"),title:De.t("USD Price Unknown, Cannot calculate Price Impact."),description:De.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:De.t("Confirm USD Price Unknown")}}),"errorMessages");function _c(t){switch(t.type){case 0:return t.diagnosisMessage??R().noResultError.title;case 1:return R().genericServerError;default:return""}}i(_c,"getQuoteErrorMessage");import{i18n as Ir}from"@lingui/core";var uo=i(()=>({connectWallet:Ir.t("Connect Wallet"),swap:Ir.t("Swap"),swapAnyway:Ir.t("Swap anyway"),ethWarning:Ir.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function xa(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(xa,"getFeeLabel");var ba=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],$c=100,Dc=30,Fc=15,Oc=60;var Uc=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],zc=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as jS}from"@rango-dev/queue-manager-rango-preset";import XW from"bignumber.js";function qc(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(qc,"getRequiredBalanceOfWallet");function _t(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(_t,"getPriceImpactLevel");function Nr(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=jS(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=nn(a?a.toBlockchain:n.fromBlockchain,e),p=nn(r.toBlockchain,e),u=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),c=o(s),m=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:u,toBlockchain:p,toToken:c,inputAmount:m}}i(Nr,"createRetryQuote");function $o(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=hn(o),s=pt(o);if(o&&a&&s){let u=Pt(a.toString(),s.toString());if(!!u&&jc(a,u)){let m=Br(o?.swaps,n),h=_t(u);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:u,totalFee:m,warningLevel:h}}}if(e&&Zc(e,o))return{type:4,usdValueChange:L(pt(o)?.minus(pt(e)??0).toString()??"0",null,2),percentageChange:L(Pt(pt(e)??"1",pt(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let l=Mr(o.swaps),p=r>Jp;if(Yc(t.userSlippage.toString(),l)){if(p&&parseFloat(l??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:Xc(o,r),minRequiredSlippage:l};return null}i($o,"generateQuoteWarnings");function Hc(t){return![4].includes(t.type)}i(Hc,"isQuoteWarningConfirmationRequired");function Pt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Ea(t.toString(),e.toString());return n&&n<0?n:null}i(Pt,"getPriceImpact");var Gc=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"),Wr=i((t,e)=>e.sort((o,n)=>{let r=i(u=>u.scores?.find(c=>c.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let l=o.requestId.toLowerCase(),p=n.requestId.toLowerCase();return l.localeCompare(p)}),"sortQuotesBy"),Vc=i((t,e,o)=>{if(!e.length)return null;if(!t)return{requestAmount:o,validationStatus:null,...e[0]};let n=new Set(t.swaps.map(a=>a.swapperId)),r=e.find(a=>{let s=new Set(a.swaps.map(l=>l.swapperId));return Array.from(n).every(l=>s.has(l))});return{requestAmount:o,validationStatus:null,...r||e[0]}},"getDefaultQuote"),Kc=i(t=>{let e=i((o,n)=>{let r=ba.indexOf(o.value),a=ba.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function jc(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Uc.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new Ue(r)))}i(jc,"hasHighValueLoss");function Jc(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Ue(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ue(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(Jc,"hasLimitError");function Rc(t){let e=(t||[]).filter(l=>{let p=l.fromAmountMinValue?new Ue(l.fromAmountMinValue):null,u=l.fromAmountMaxValue?new Ue(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?p?.gte(l.fromAmount)||u?.lte(l.fromAmount):p?.gt(l.fromAmount)||u?.lt(l.fromAmount)})[0],o=e.fromAmountMinValue?new Ue(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ue(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=gt.t({id:"Required: >= {min} {symbol}",values:{min:L(o,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=gt.t({id:"Required: > {min} {symbol}",values:{min:L(o,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=gt.t({id:"Required: <= {max} {symbol}",values:{max:L(n,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=gt.t({id:"Required: < {max} {symbol}",values:{max:L(n,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(Rc,"getLimitErrorMessage");function eu(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:p}=t;return e!=="success"?{title:uo().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:uo().swap,action:"confirm-swap",disabled:!0}:s?{title:uo().swapAnyway,action:"confirm-warning",disabled:!1}:p?{title:uo().ethWarning,action:"confirm-warning",disabled:!1}:{title:uo().swap,action:"confirm-swap",disabled:!1}:{title:uo().connectWallet,action:"connect-wallet",disabled:!1}}i(eu,"getSwapButtonState");function Ia(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(ge))&&e&&e!=="0"&&n!==0)}i(Ia,"canComputePriceImpact");function Aa(t,e){let o=ge;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new Ue(r.amount).multipliedBy(a||0))}return o}i(Aa,"getUsdFeeOfStep");function Br(t,e){return t.reduce((o,n)=>o.plus(Aa(n,e)),ge)}i(Br,"getTotalFeeInUsd");function Na(t){let e=ge;return e=e.plus(new Ue(t.amount).multipliedBy(t.price||0)),e}i(Na,"getUsdFee");function tu(t){return t.reduce((e,o)=>e.plus(Na(o)),ge)}i(tu,"getTotalFeesInUsd");function ou(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(ou,"getFeesGroup");function nu(t){let e=new Map;return t.forEach((o,n)=>{o.recommendedSlippage?.error&&e.set(n,o.recommendedSlippage.slippage)}),e.size>0?e:null}i(nu,"checkSlippageErrors");function Xc(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?o:null}i(Xc,"checkSlippageWarnings");function Mr(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(Mr,"getMinRequiredSlippage");function Yc(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(Yc,"hasProperSlippage");function ru(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:p,slippage:u,affiliateRef:c,affiliatePercent:m,affiliateWallets:h,destination:f}=t,d=a?.reduce((S,T)=>(S[T.chain]=T.address,S),{}),g=[];return r?.forEach(S=>{g.push({blockchain:S.chain,addresses:[S.address]})}),{amount:n.toString(),affiliateRef:c??void 0,affiliatePercent:m??void 0,affiliateWallets:h??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:g,selectedWallets:d??{},slippage:u.toString(),...f&&{destination:f},...p&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!p&&{swapperGroups:l?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}i(ru,"createQuoteRequestBody");function iu(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(iu,"getWalletsForNewSwap");function hn(t){let e=t.requestAmount,o=t.swaps[0].from.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(hn,"getUsdInputFrom");function pt(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1].to.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(pt,"getUsdOutputFrom");function Ea(t,e){return new Ue(e).div(new Ue(t)).minus(1).multipliedBy($c).toNumber()}i(Ea,"getPercentageChange");function Zc(t,e){let o=hn(t),n=pt(t),r=pt(e);if(!o||!n||!r)return!1;let a=Ea(n.toString(),r.toString());return zc.some(({threshold:s,minInput:l})=>a<=s&&o.isGreaterThanOrEqualTo(l))}i(Zc,"isOutputAmountChangedExcessively");function au(t,e,o){let n=t.validationStatus,r=io({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>qc(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,p=L(new Ue(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),u=L(new Ue(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),c="";return s.reason==="FEE"&&(c=gt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(c=gt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(c=gt.t(" for input and network fee")),gt.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:u,symbol:l,reason:c,currentAmount:p,blockchain:st(s.asset.blockchain,o)}})})}i(au,"generateBalanceWarnings");function yn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Lr.NetworkChanged}i(yn,"isNetworkStatusInWarningState");function su(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),yn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Lr.WaitingForConnectingWallet:n=n||gt.t("Waiting for connecting wallet");break;case Lr.WaitingForQueue:n=n||gt.t("Waiting for other running tasks to be finished");break;case Lr.WaitingForNetworkChange:n=n||gt.t("Waiting for changing wallet network");break;default:n=n||"";break}r=r||"",n=n||"";let s=n?.indexOf("code")!==-1&&n?.indexOf("reason")!==-1;return{shortMessage:n,detailedMessage:{content:r,long:s}}}i(su,"getSwapMessages");function lu(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(lu,"getLastConvertedTokenInFailedSwap");function pu(t){return t.status==="failed"}i(pu,"shouldRetrySwap");function cu(t,e,o,n,r,a){if(!n||t)return!0;let s=io({filter:"all",quote:n}),l=io({filter:"required",quote:n}),p=s.every(m=>r.some(h=>h.chain===m)),u=l.every(m=>r.some(h=>h.chain===m)),c=o&&a?Eo(a,o):!1;return!e&&!p||e&&!o||e&&!!o&&(!c||!u)}i(cu,"isConfirmSwapDisabled");function uu(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(uu,"isTokensIdentical");var Pr=i((t,e)=>t?.usdPrice?new Ke(e||ge).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),O=Bo(XS()(YS(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Ke(0),outputUsdValue:new Ke(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=ge,a=o.inputUsdValue;return sn(o.inputAmount)?(e&&(n=e?.outputAmount?new Ke(e?.outputAmount):null,a=hn(e)??ge,r=pt(e)??ge),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Ke(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Ke(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Ke(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:Pr(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 Ke(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),setInputAmount:e=>{t(o=>({inputAmount:e,...!e&&{outputAmount:null,outputUsdValue:new Ke(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:Pr(o.fromToken,e)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:Pr(n??null,s),outputUsdValue:new Ke(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?Pr(e.toToken,e.outputAmount?.toString()||""):new Ke(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Ke(0),inputUsdValue:new Ke(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Ke(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})})))),mu=O.subscribe((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&he.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&&he.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})});function du(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:p,toBlockchain:u}=O(),c=y().config,m=y().fetchStatus,h=y().blockchains(),f=y().tokens(),{findToken:d}=y(),{setAffiliateRef:g,setAffiliatePercent:C,setAffiliateWallets:S}=y(),T=c?.from?.tokens,k=c?.from?.blockchains,v=c?.to?.tokens,w=c?.to?.blockchains,A=_r(void 0),M=_r(void 0),x=_r(void 0),E=_r(void 0);Do(()=>{typeof c.amount<"u"&&t(c.amount.toString())},[c?.amount]),Do(()=>{if(m==="success"){r();let b=h.find(B=>B.name===c?.from?.blockchain),N=c?.from?.token,I=N&&d(N);(b||!b&&x.current)&&n(b??null),I?a({token:I,meta:{blockchains:h,tokens:f}}):!I&&A.current&&a({token:null}),x.current=c?.from?.blockchain,A.current=c?.from?.token}},[c?.from?.token?.symbol,c?.from?.token?.address,c?.from?.token?.blockchain,c?.from?.blockchain,m]),Do(()=>{sa(s,T)&&a({token:null}),la(p,k)&&n(null)},[T,k]),Do(()=>{sa(l,v)&&a({token:null}),la(u,w)&&o(null)},[v,w]),Do(()=>{if(m==="success"){r();let b=h.find(B=>B.name===c?.to?.blockchain),N=c?.to?.token,I=N&&d(N);(b||!b&&E.current)&&o(b??null),I?e({token:I,meta:{blockchains:h,tokens:f}}):!I&&M.current&&e({token:null}),E.current=c?.to?.blockchain,M.current=c?.to?.token}},[c?.to?.token?.symbol,c?.to?.token?.address,c?.to?.token?.blockchain,c?.to?.blockchain,m]),Do(()=>{g(c?.affiliate?.ref??null),C(c?.affiliate?.percent??null),S(c?.affiliate?.wallets??null)},[c?.affiliate?.ref,c?.affiliate?.percent,c?.affiliate?.wallets])}i(du,"useSyncStoresWithConfig");import{useEffect as Ma,useRef as ZS}from"react";import{useInRouterContext as JS,useLocation as RS,useSearchParams as eC}from"react-router-dom";function Wa(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i(Wa,"convertTokenSearchParamToAsset");function Ba(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Ba,"tokenToSearchParam");function Pa(){let t=RS(),[e,o]=eC(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:p,setToBlockchain:u,setFromToken:c,setToToken:m,setInputAmount:h}=O(),f=y().fetchStatus,d=y().blockchains(),g=y().tokens(),C=JS(),{updateIframe:S,updateCampaignMode:T}=y(),k=y().isInCampaignMode(),v=ZS(),{findToken:w}=y(),A=i(()=>{let x={};for(let[X,se]of e.entries())X.startsWith("utm_")&&(x[X]=se);let E=e.get("fromAmount"),b=e.get("fromBlockchain"),N=e.get("fromToken"),I=e.get("toBlockchain"),B=e.get("toToken"),j=e.get("autoConnect"),te=e.get("clientUrl"),J=e.get("liquiditySources"),P=e.get("blockchain");return{fromAmount:E,fromBlockchain:b,fromToken:N,toBlockchain:I,toToken:B,autoConnect:j,clientUrl:te,liquiditySources:J,utmQueryParams:x,blockchain:P}},"getUrlSearchParams"),M=i(x=>{for(let E in x)x[E]||delete x[E];o(x,{replace:!0})},"updateUrlSearchParams");Ma(()=>{let{autoConnect:x,clientUrl:E,utmQueryParams:b,blockchain:N}=A();C&&f==="success"&&M({fromBlockchain:n?.name,fromToken:Ba(a),toBlockchain:r?.name,toToken:Ba(s),fromAmount:l,autoConnect:x??void 0,clientUrl:E??void 0,blockchain:N??void 0,liquiditySources:k?v.current:void 0,...b})},[t.pathname,l,n,a,r,s,k]),Ma(()=>{if(!C)return;let x=A();if(!v.current&&x.liquiditySources&&(v.current=x.liquiditySources),x.fromAmount&&h(x.fromAmount),f==="success"){let E=d.find(B=>B.name===x.fromBlockchain),b=x.fromToken&&E?w(Wa(x.fromToken,E)):void 0,N=d.find(B=>B.name===x.toBlockchain),I=x.toToken&&N?w(Wa(x.toToken,N)):void 0;E&&(p(E),b&&c({token:b,meta:{blockchains:d,tokens:g}})),N&&(u(N),I&&m({token:I,meta:{blockchains:d,tokens:g}}))}},[f]),Ma(()=>{let{clientUrl:x,liquiditySources:E}=A();S("clientUrl",x||void 0),T("liquiditySources",E?.split(",")??void 0)},[])}i(Pa,"useSyncUrlAndStore");import{i18n as It}from"@lingui/core";import{Alert as fk,Button as Ku,darkTheme as gk,Divider as kn,DoneIcon as hk,MessageBox as yk,styled as Sk,TextField as Ck,Typography as kk}from"@rango-dev/ui";import ye,{useEffect as Tk,useState as Qr}from"react";import{useNavigate as vk,useSearchParams as wk}from"react-router-dom";import{ChevronRightIcon as tC,Divider as Su,Image as oC,Typography as Cu}from"@rango-dev/ui";import ht from"react";import{darkTheme as fu,styled as _a}from"@rango-dev/ui";var gu=_a("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${fu} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${fu} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),hu=_a("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),yu=_a("div",{display:"flex"});function $a(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return ht.createElement(hu,null,ht.createElement(Cu,{size:"large",variant:"label"},n),ht.createElement(Su,{size:10}),ht.createElement(gu,{onClick:s?void 0:e,disabled:s},ht.createElement(yu,null,r&&ht.createElement(ht.Fragment,null,ht.createElement(oC,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),ht.createElement(Su,{size:4,direction:"horizontal"})),ht.createElement(Cu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),ht.createElement(tC,{size:12,color:"black"})))}i($a,"BlockchainSelectorButton");import{i18n as Fa}from"@lingui/core";import{Button as nC,Divider as Sn,ExternalLinkIcon as rC,Image as iC,Typography as Oo}from"@rango-dev/ui";import Ne from"react";function ku(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(ku,"generateExplorerLink");import{darkTheme as Fo,styled as Tu}from"@rango-dev/ui";var Da=Tu("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Fo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Fo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Fo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Fo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),vu=Tu("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Fo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Fo} &`]:{color:"$colors$neutral900"}}});function Oa(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=ku(n.address,a);return Ne.createElement(Z,{open:e,dismissible:!0,onClose:o,container:W()},Ne.createElement(vu,null,Ne.createElement(iC,{src:n.image,size:45,type:"circular"}),Ne.createElement(Oo,{variant:"title",size:"medium"},n.name),Ne.createElement(Oo,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),Ne.createElement(Sn,{size:4}),Ne.createElement(Oo,{variant:"body",size:"medium"},s?Ne.createElement(Da,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,Ne.createElement(rC,{size:12,color:"gray"})):Ne.createElement(Da,null,n.address)),Ne.createElement(Sn,{size:4}),n.coinSource&&Ne.createElement(Oo,{className:"_coin-source",variant:"body",size:"xsmall"},Fa.t("via")," ",Ne.createElement(Oo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),Ne.createElement(Sn,{size:"32"}),Ne.createElement(Oo,{size:"medium",variant:"body",className:"_custom-token-description"},Fa.t("This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade."))),Ne.createElement(Sn,{size:40}),Ne.createElement(Sn,{size:10}),Ne.createElement(nC,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Fa.t("Import")))}i(Oa,"CustomTokenModal");import{useManager as lk}from"@rango-dev/queue-manager-react";import{BottomLogo as pk,Divider as Qu,Header as ck}from"@rango-dev/ui";import Be,{useEffect as ss,useRef as qu,useState as uk}from"react";import{useRef as aC}from"react";function $r(){return window.self!==window.top}i($r,"isAppLoadedIntoIframe");function Ua(){let t=aC(null),{iframe:e}=y(),o=$r()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(l=>{for(let p of l)n({type:"widget_height",data:{height:p.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(Ua,"useIframe");import{useNavigate as sC}from"react-router-dom";function je(){let t=sC();return()=>t(-1)}i(je,"useNavigateBack");import{createTheme as Ka,darkTheme as TC,lightTheme as vC}from"@rango-dev/ui";import{useEffect as wC,useState as xC}from"react";import{theme as CC,darkColors as kC}from"@rango-dev/ui";import Ga from"react";function lC(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(lC,"expandShortHexColor");function pC(t){return/[0-9]+$/.test(t)}i(pC,"isOverridingColor");function cC(t,e){return t.padStart(e,"0")}i(cC,"pad");function za(t){let e=Math.min(Math.max(Math.round(t),0),255);return cC(e.toString(16),2)}i(za,"intToHex");function uC(t){return`#${za(t.red)}${za(t.green)}${za(t.blue)}`}i(uC,"rgbToHex");function mC(t){let e=parseInt(t.slice(1,3),16),o=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return{red:e,green:o,blue:n}}i(mC,"hexToRGB");function dC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(dC,"generateShade");function fC(t,e){let o=.11*e;return{red:t.red+(255-t.red)*o,green:t.green+(255-t.green)*o,blue:t.blue+(255-t.blue)*o}}i(fC,"generateTint");function gC(t){return wu(t,dC)}i(gC,"calculateShades");function hC(t){return wu(t,fC)}i(hC,"calculateTints");function wu(t,e){let o=mC(t),n=[];for(let r=1;r<9;r++)n.push(uC(e(o,r)));return n}i(wu,"calculateColors");function Qa(t,e,o){let a=hC(t).reverse().concat(t),s=gC(t),l=a.concat(s),p={},u=l.length;for(let c=0;c<u;c++){let m=100+(o?u-1-c:c)*50;p[`${e}${m}`]=l[c]}return p}i(Qa,"createTintsAndShades");function qa(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)&&!pC(r)){let p=lC(a);Object.assign(n,Qa(p,r,s))}}return{...n,...e}}i(qa,"expandToGenerateThemeColors");var xu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),yC=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=xu(o%52)+e;return xu(o%52)+e},"toAlphabeticName"),SC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Ha=i(t=>yC(SC(5381,JSON.stringify(t))>>>0),"toHash");function Va(t){let e=CC.colors,o={...e,...kC},n,r;if(t?.light){let s={colors:qa(e,t.light)};n={id:`${aa}-light-${Ha(s)}`,tokens:s}}if(t?.dark){let s={colors:qa(o,t.dark,{reverseNeutralRange:!0})};r={id:`${aa}-dark-${Ha(s)}`,tokens:s}}return{light:n,dark:r}}i(Va,"customizedThemeTokens");function bu(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>Ga.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(Ga.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(Ga.cloneElement(e,{key:l}))}}),o}i(bu,"joinList");function Eu(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Eu,"doesWindowPreferDarkColorScheme");function Uo(t){let{colors:e,fontFamily:o=Sp,borderRadius:n=zp,secondaryBorderRadius:r=Qp}=t,[a,s]=xC(Eu()?"dark":"light"),{theme:l}=y(),{dark:p,light:u}=Va(e),c=Ka({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),m=[c.className,vC.className],h=[c.className,TC.className];if(u){let d=Ka(u.id,u.tokens);m.push(d.className)}if(p){let d=Ka(p.id,p.tokens);h.push(d.className)}return wC(()=>{let d=i(g=>{g.matches?s("dark"):s("light")},"switchThemeListener");return Eu()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",d),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",d)}},[]),{activeTheme:i(()=>{let d=m.join(" "),g=h.join(" ");return l==="auto"?a==="dark"?g:d:l==="dark"?g:d},"getActiveTheme"),mode:l==="auto"?a:l}}i(Uo,"useTheme");var ct=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 Iu}from"@lingui/core";import{Alert as bC,Button as EC}from"@rango-dev/ui";import Au from"react";function ja(t){return Au.createElement(bC,{action:Au.createElement(EC,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Iu.t("Activate this tab")),type:"warning",variant:"alarm",title:Iu.t("Another tab is open and handles transactions.")})}i(ja,"ActivateTabAlert");import{i18n as Xa}from"@lingui/core";import{Button as IC,Divider as AC,MessageBox as NC}from"@rango-dev/ui";import Dr from"react";function Ya(t){let{open:e,onClose:o,onConfirm:n}=t;return Dr.createElement(Z,{open:e,dismissible:!0,onClose:o,container:W()},Dr.createElement(NC,{title:Xa.t("Activate current tab"),type:"warning",description:Xa.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.")},Dr.createElement(AC,{size:20}),Dr.createElement(IC,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},Xa.t("Confirm"))))}i(Ya,"ActivateTabModal");import{ChevronLeftIcon as WC}from"@rango-dev/ui";import Nu from"react";function Za(t){return Nu.createElement(Et,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Nu.createElement(WC,{color:"black",size:16}))}i(Za,"BackButton");import{i18n as BC}from"@lingui/core";import{Button as MC,Typography as LC}from"@rango-dev/ui";import Ja from"react";function Ra(t){return Ja.createElement(Vt,null,Ja.createElement(MC,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},Ja.createElement(LC,{variant:"label",size:"medium",color:"error500"},BC.t("Cancel"))))}i(Ra,"CancelButton");import{i18n as PC}from"@lingui/core";import{Image as _C,Tooltip as $C,WalletIcon as DC}from"@rango-dev/ui";import mo from"react";function es(t){let{list:e}=ft(),o=e.filter(r=>r.state==="connected"),n=o.length?mo.createElement("div",{className:Sc()},o.map(r=>mo.createElement(Sr,{key:r.title},mo.createElement(_C,{src:r.image,size:14})))):PC.t("Connect Wallet");return mo.createElement($C,{container:t.container,side:"bottom",content:n},mo.createElement(Et,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&mo.createElement(fc,null),mo.createElement(DC,{size:18,color:"black"})))}i(es,"WalletButton");import{i18n as Or}from"@lingui/core";import{NotificationsIcon as RC,Popover as ek,SettingsIcon as tk,Tooltip as Ur,TransactionIcon as ok}from"@rango-dev/ui";import We from"react";import{Notifications as zC}from"@rango-dev/ui";import QC from"react";import{useNavigate as qC}from"react-router-dom";import{create as FC}from"zustand";import{persist as OC,subscribeWithSelector as UC}from"zustand/middleware";var xe=Bo(FC()(OC(UC((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1],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}}},l=e().notifications.filter(p=>p.requestId!==n.requestId);t(()=>({notifications:[...l,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(p=>p.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 ts(){let t=qC(),{getNotifications:e,clearNotifications:o}=xe(),n=e(),r=y().blockchains(),{findToken:a}=y();return QC.createElement(zC,{list:n,getBlockchainImage:l=>pp(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${D.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(ts,"NotificationContent");import{useManager as HC}from"@rango-dev/queue-manager-react";import{InProgressIcon as GC}from"@rango-dev/ui";import Wu from"react";var VC=i(()=>{let{manager:t}=HC();return ct(t).map(({swap:o})=>o).find(o=>o.status==="running")?Wu.createElement(yc,null,Wu.createElement(GC,{color:"info",size:6})):null},"InProgressTransactionBadge"),Bu=VC;import{EventSeverity as KC}from"@rango-dev/queue-manager-rango-preset";import{Typography as jC}from"@rango-dev/ui";import Mu from"react";function Lu(){let{getNotifications:t}=xe(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===KC.WARNING);return o?Mu.createElement(gc,{isSever:n},Mu.createElement(jC,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(Lu,"NotificationsBadge");import{RefreshProgressButton as XC}from"@rango-dev/ui";import os,{useEffect as YC,useState as Pu}from"react";var ZC=1e3,_u=60,JC=100;function Fr({onClick:t}){let[e,o]=Pu(0),[n,r]=Pu(!1),a=i(p=>{document.hidden&&p&&s(p)},"handleVisibilityChange");YC(()=>{let p;return t?p=window.setInterval(()=>{o(u=>u+1),e===_u&&l()},ZC):s(p),document.addEventListener("visibilitychange",()=>a(p)),()=>{document.removeEventListener("visibilitychange",()=>a(p)),p&&clearInterval(p)}},[e,t]);let s=i(p=>{p&&clearInterval(p),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return os.createElement(Et,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},os.createElement(hc,{onTransitionEnd:()=>r(!1),isRefetched:n},os.createElement(XC,{size:22,color:t?"black":"gray",progress:e/_u*JC})))}i(Fr,"RefreshButton");function fo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=Ve("notification",s)||r.includes("notifications");return We.createElement(We.Fragment,null,!r.includes("refresh")&&We.createElement(Ur,{container:a||W(),side:"top",content:Or.t("Refresh")},We.createElement(Fr,{onClick:e})),!l&&We.createElement(ek,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:W(),content:We.createElement(ts,null)},We.createElement("div",null,We.createElement(Ur,{container:W(),side:"top",content:Or.t("Notifications")},We.createElement(Et,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},We.createElement(RC,{size:18,color:"black"}),We.createElement(Lu,null))))),!r.includes("settings")&&We.createElement(Ur,{container:W(),side:"top",content:Or.t("Settings")},We.createElement(Et,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},We.createElement(tk,{size:18,color:"black"}))),!r.includes("history")&&We.createElement(Ur,{container:W(),side:"top",content:Or.t("History")},We.createElement(Et,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},We.createElement(ok,{size:18,color:"black"}),We.createElement(Bu,null))))}i(fo,"HeaderButtons");import{i18n as ns}from"@lingui/core";import{Divider as Du,MessageBox as ik,RefreshIcon as ak}from"@rango-dev/ui";import zo from"react";import{Button as nk,styled as rk}from"@rango-dev/ui";var $u=rk(nk,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function rs(t){let{open:e,onClose:o}=t;return zo.createElement(Z,{open:e,dismissible:!0,onClose:o,container:W()},zo.createElement(ik,{title:ns.t("Something went wrong"),type:"error",description:ns.t("Something went wrong. Please refresh the app.")},zo.createElement(Du,{size:30}),zo.createElement($u,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},zo.createElement(ak,{size:20,color:"primary"}),zo.createElement(Du,{size:4,direction:"horizontal"}),ns.t("Refresh"))))}i(rs,"RefreshModal");function is(t){let e=t.target;if(e){let o=e.scrollTop,n=W();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(is,"onScrollContentAttachStatusToContainer");import{css as sk,styled as as}from"@rango-dev/ui";var Fu="700px",zr=sk({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Ou=as("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:Fu},fixed:{height:Fu}}}}),Uu=as("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),zu=as("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"}}});function oe(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=Ua(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l,connectedWallets:p}=y(),[u,c]=uk(!1),{config:{features:m,theme:h}}=y(),{watermark:f}=re(),d=f==="FULL",{activeTheme:g}=Uo(h||{}),C=Ve("connectWalletButton",m),{isActiveTab:S,tabManagerInitiated:T,showActivateTabModal:k,setShowActivateTabModal:v,activateCurrentTab:w}=re(),A=je(),{manager:M}=lk(),E=ct(M).map(({swap:te})=>te).some(te=>te.status==="running"),b=i(()=>w(ao.forceClaim,E),"onActivateTab"),N=i(()=>{r.onWallet?.()},"onConnectWallet"),I=typeof r.hasBackButton>"u"||r.hasBackButton,B=qu(null),j=qu(null);return ss(()=>($r()&&j.current&&e(j.current),()=>{o()}),[]),ss(()=>(B.current?.addEventListener("scroll",is),()=>{B.current?.removeEventListener("scroll",is)}),[]),ss(()=>{c(l==="failed")},[l]),Be.createElement(Ou,{height:s,id:$e.SWAP_BOX_ID,className:`${g()} ${zr()}`,ref:j},Be.createElement(ck,{prefix:I?Be.createElement(Za,{onClick:()=>{A(),r.onBack&&r.onBack()}}):null,title:r.title,suffix:Be.createElement(Be.Fragment,null,r.suffix,r.onWallet&&!C&&Be.createElement(es,{container:W(),onClick:N,isConnected:!!p?.length}),r.onCancel&&Be.createElement(Ra,{onClick:r.onCancel}))}),Be.createElement(Uu,{ref:B},n),Be.createElement(Ya,{open:k,onClose:()=>v(!1),onConfirm:b}),Be.createElement(zu,null,Be.createElement("div",{className:"footer__content"},T&&!S&&Be.createElement("div",{className:"footer__alert"},Be.createElement(ja,{onActivateTab:b}),Be.createElement(Qu,{size:10})),a),Be.createElement(Qu,{size:12}),Be.createElement("div",{className:`footer__logo ${d?"logo__show":"logo__hidden"}`},Be.createElement(pk,null))),Be.createElement(rs,{open:u,onClose:()=>c(!1)}))}i(oe,"Layout");import{styled as mk}from"@rango-dev/ui";var Hu="$20 $20 $10 $20",Cn=mk("div",{padding:Hu,overflowY:"auto",flexGrow:1});import{styled as dk}from"@rango-dev/ui";var ie=dk("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 Qo}from"@lingui/core";import{useState as Gu}from"react";function Vu(){let[t,e]=Gu(!1),[o,n]=Gu(void 0),{findToken:r}=y(),a=y().customTokens();function s(p,u){switch(p){case"duplicated":return{title:Qo.t("Duplicate Token"),message:Qo.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:Qo.t("Token Already Exists"),message:Qo.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:Qo.t("Token Not Found"),message:Qo.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:u}})}}}return i(s,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:p,tokenAddress:u})=>{e(!0);try{if(a.some(d=>d.address?.toLowerCase()===u.toLowerCase())){let d=s("duplicated");n(d);return}let m=await bt().getCustomToken({blockchain:p,address:u});if(!m||!m.token||m.error){let d=s("not-found",p);n(d);return}let h=m.token;if(r({blockchain:h.blockchain,address:h.address,symbol:h.symbol})){let d=s("token-exist");n(d);return}return h}catch(c){if(c?.code==="ERR_BAD_REQUEST"){let m=s("not-found",p);n(m);return}throw n(void 0),new Error(c.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Vu,"useFetchCustomToken");var xk=Sk("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${gk} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),bk=1e3;function ju(){let t=vk(),[e]=wk(),o=je(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=nn(a,r),[l,p]=Qr(""),[u,c]=Qr(!1),[m,h]=Qr(),{fetchCustomToken:f,loading:d,error:g}=Vu(),[C,S]=Qr(""),T=!!s&&Eo(s,l),k=!s||!l||!T,v=i(async()=>{if(s)try{let M=await f({blockchain:a,tokenAddress:l});S(""),M&&h(M)}catch(M){M.message==="Failed to fetch"&&(S(It.t("Network Error")),c(!0))}},"getCustomToken"),w=i(()=>{g&&p(""),c(!1)},"closeErrorModal"),A=i(async()=>{C&&setTimeout(async()=>{await v()},bk),w()},"handleErrorModalButtonClick");return Tk(()=>{g&&c(!0)},[g]),ye.createElement(oe,{header:{title:It.t("Add Custom Token")}},ye.createElement(ie,null,ye.createElement(xk,null,ye.createElement("div",null,ye.createElement($a,{onClick:()=>t(D.blockchains,{replace:!0}),hasLogo:!!s?.logo,value:s?{name:s.displayName,logo:s.logo}:void 0,title:It.t("Select chain"),placeholder:It.t("Select chain")}),ye.createElement(kn,{size:"24"}),ye.createElement(kk,{size:"large",variant:"label"},It.t("Enter Address")),ye.createElement(kn,{size:10}),ye.createElement(Ck,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:It.t("Enter token address"),size:"large",value:l,suffix:!!l&&T&&ye.createElement(hk,{color:"success",size:12}),onChange:M=>p(M.target.value)}),!T&&!!l&&ye.createElement(ye.Fragment,null,ye.createElement(kn,{size:4}),ye.createElement(fk,{type:"error",variant:"alarm",title:"Invalid Address"}))),ye.createElement(Ku,{id:"widget-add-custom-token-import-btn",disabled:k,type:"primary",variant:"contained",loading:d,size:"large",onClick:v},It.t("Import"))),ye.createElement(Z,{open:u,dismissible:!0,onClose:w,container:W()},ye.createElement(yk,{title:g?.title||C,type:"error",description:g?.message||It.t("Failed Network, Please retry.")},ye.createElement(kn,{size:40}),ye.createElement(kn,{size:10}),ye.createElement(Ku,{id:`widget-add-custom-token-${C?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:A},C?It.t("Retry"):It.t("Add another custom token")))),s&&m&&ye.createElement(Oa,{blockchain:s,token:m,onSubmitClick:()=>{m&&(n(m),h(void 0),o())},onClose:()=>h(void 0),open:!!s&&!!m})))}i(ju,"AddCustomTokenPage");import{i18n as Ds}from"@lingui/core";import{useManager as lv}from"@rango-dev/queue-manager-react";import{Alert as pv,Button as cv,css as Os,Divider as Fs,IconButton as Qd,styled as uv,Typography as mv,WalletIcon as dv}from"@rango-dev/ui";import Le,{useEffect as hi,useLayoutEffect as fv,useRef as gv,useState as Ln}from"react";import{useNavigate as hv}from"react-router-dom";import{i18n as go}from"@lingui/core";import{Alert as Yk,BalanceErrors as Zk,Button as vm,ChevronLeftIcon as Jk,Divider as gs,MessageBox as Rk,Typography as hs}from"@rango-dev/ui";import ee,{useCallback as eT,useEffect as wm,useMemo as tT,useState as Go}from"react";import{useNavigate as oT}from"react-router-dom";import{i18n as us}from"@lingui/core";import{Alert as Wk,ChevronDownIcon as Bk,CloseIcon as Mk,Divider as tm,IconButton as om,PasteIcon as Lk,Typography as Pk,WalletIcon as _k}from"@rango-dev/ui";import Me,{useEffect as $k,useRef as Dk}from"react";import Vr,{useRef as Ak}from"react";import*as qo from"@radix-ui/react-collapsible";import{keyframes as Xu,styled as qr}from"@rango-dev/ui";var ls=300,Ek=Xu({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Ik=Xu({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),Yu=qr(qo.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),ps=qr(qo.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Hr=qr(qo.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Ek} ${ls}ms ease-out`},false:{animation:`${Ik} ${ls}ms ease-out`}}}}),Gr=qr("div",{transition:`all ${ls}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Kr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,p=Ak(null);return Vr.createElement(Yu,{ref:p,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Vr.createElement(ps,{className:"collapsible_trigger",onClick:a},s),Vr.createElement(Hr,{className:"collapsible_content",open:e},r),l==="bottom"&&Vr.createElement(ps,{className:"collapsible_trigger",onClick:a},s))}i(Kr,"CustomCollapsible");import{darkTheme as Zu,styled as cs,TextField as Nk}from"@rango-dev/ui";var Ju=cs("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),Ru=cs(Nk,{backgroundColor:"$neutral100",padding:"$15"}),em=cs("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${Zu} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${Zu} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function nm(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=O(),{config:s}=y(),l=y().blockchains(),p=or(e.name,l),u=Dk(null),c=s?.defaultCustomDestinations?.[e.name],m=navigator?.userAgent.includes("Firefox"),f=n&&!!r&&e&&!Eo(e,r),d=i(()=>{a("")},"handleClear"),g=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let T=await navigator.clipboard.readText();a(T),u?.current?.focus()}},"handlePaste"),C=i(()=>r?Me.createElement(om,{id:"widget-custom-destination-close-icon-btn",onClick:d,variant:"ghost"},Me.createElement(Mk,{size:12,color:"gray"})):m?null:Me.createElement(om,{id:"widget-custom-destination-paste-icon-btn",onClick:g,variant:"ghost"},Me.createElement(Lk,{size:16})),"renderSuffix");return $k(()=>{!!c&&r===null&&(a(c),o(!0))},[c]),Me.createElement(Ju,null,Me.createElement(Kr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Me.createElement(em,null,Me.createElement("div",{className:"button__content"},Me.createElement(_k,{size:18,color:"info"}),Me.createElement(tm,{size:4,direction:"horizontal"}),Me.createElement(Pk,{variant:"label",size:"medium",color:n?"$neutral600":void 0},us.t("Send to a different address"))),Me.createElement(Gr,{orientation:n?"up":"down"},Me.createElement(Bk,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Me.createElement(Ru,{ref:u,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:us.t("Enter {blockchainName} address",{blockchainName:p}),value:r||"",suffix:C(),onChange:S=>{let T=S.target.value;a(T)}})),f&&Me.createElement(Me.Fragment,null,Me.createElement(tm,{size:4}),Me.createElement(Wk,{variant:"alarm",type:"error",title:us.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(nm,"CustomDestination");import{css as Fk,darkTheme as ms,IconButton as Ok,styled as $t}from"@rango-dev/ui";var rm=$t("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),im=$t("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Uk=$t("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${ms} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${ms} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${ms} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),am=$t(Uk,{alignSelf:"stretch",minHeight:"93px"}),sm=$t("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),lm=$t(Ok,{position:"absolute",left:"$20"}),pm=$t("div",{paddingTop:"$20"}),cm=Fk({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),um=$t("div",{display:"flex"}),mm=$t("div",{overflow:"visible",width:"100%"});import{i18n as Sm}from"@lingui/core";import{warn as Gk}from"@rango-dev/logging-core";import{Divider as Vk,SelectableWallet as Kk,Typography as Cm,WalletState as km}from"@rango-dev/ui";import Xe,{useEffect as Tm,useState as vn}from"react";import{Image as qk,MessageBox as Hk}from"@rango-dev/ui";import Tn from"react";import{keyframes as zk,styled as ds}from"@rango-dev/ui";var dm=ds("div",{position:"relative"}),Qk=zk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),fm=ds("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${Qk} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),gm=ds("div",{"& img":{borderRadius:"50%"}});import{i18n as Ho}from"@lingui/core";function hm(t,e){switch(t){case"in-progress":return{type:"loading",title:Ho.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Ho.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Ho.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Ho.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Ho.t("Request Rejected"),description:Ho.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(hm,"generateMessageByStatus");function ym(t){let{status:e,displayName:o,image:n}=t,r=hm(e,o),a=e=="in-progress";return Tn.createElement(Hk,{type:r.type,title:r.title,description:r.description,icon:a?Tn.createElement(dm,null,Tn.createElement(gm,null,Tn.createElement(qk,{src:n,size:45})),Tn.createElement(fm,null)):void 0})}i(ym,"ExperimentalChainStatus");var jk=7,Xk=3e3;function fs(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=re.use.isActiveTab(),{blockchains:l,connectedWallets:p}=y(),[u,c]=vn(),[m,h]=vn(null),[f,d]=vn(!1),[g,C]=vn(null),{suggestAndConnect:S}=jr(),{handleDisconnect:T}=Gt(),{list:k}=ft({chain:e}),[v,w]=vn(k),A=k.length,M=r&&A-r>0,x=i(async b=>{d(!1),C("in-progress");try{await S(b.walletType,b.chain),C("completed")}catch{C("rejected")}},"addExperimentalChain");Tm(()=>{w(b=>{let N=k.findIndex(I=>o(I.type,e));return M&&N>1?[k[N]].concat(k.filter((I,B)=>B!==N)):b.map(I=>k.find(B=>B.type===I.type)??I)})},[JSON.stringify(k)]);let E=document.getElementById($e.SWAP_BOX_ID);return Tm(()=>{let b=null;return(g==="completed"||g==="rejected")&&(b=setTimeout(()=>C(null),Xk)),()=>{b&&clearTimeout(b)}},[g]),Xe.createElement(Xe.Fragment,null,v.slice(0,r).map(b=>{let N=_p({connectedWallets:p,walletType:b.type,chain:e}),I=N?fr(N,jk):"",B=mr(l(),e),j=!p.find(se=>se.walletType===b.type&&se.chain===e),te=B&&j&&b.state===km.CONNECTED,J=te?Sm.t({id:"Add {chain} chain",values:{chain:e}}):I,P=i(async()=>{let se=b.state===km.DISCONNECTED,z=(b.isHub||!!b.needsNamespace)&&!I;se?c(b):z?(await T(b.type),c(b)):te?(h({walletType:b.type,chain:e,address:N??""}),d(!0)):n({walletType:b.type,chain:e,address:N??""})},"onSelectableWalletClick"),X=m?.chain?or(m.chain,l()):void 0;return Xe.createElement(Xe.Fragment,{key:`${b.title}_${X}`},!!m&&Xe.createElement(Z,{open:!!m&&f,container:E,onClose:()=>{h(null)}},Xe.createElement(va,{displayName:X,onConfirm:()=>{x(m)}})),g&&Xe.createElement(Z,{open:!!g,onClose:C.bind(null,null),container:E},Xe.createElement(ym,{status:g,displayName:X,image:b.image}),Xe.createElement(Vk,{direction:"vertical",size:32})),Xe.createElement(Kk,{key:b.type,description:J,onClick:P,selected:o(b.type,e),disabled:!s,...b}))}),Xe.createElement(co,{wallet:u,onClose:()=>{c(void 0)},onConnect:b=>{t.onConnect&&b.status==="connected"&&(u?.type?t.onConnect(u.type):Gk(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),M&&Xe.createElement(am,{selected:!1,onClick:a},Xe.createElement(Cm,{variant:"label",size:"medium"},Sm.t("Show more wallets"),Xe.createElement(Cm,{variant:"label",size:"medium",color:"$primary"},"\xA0+",A-(r??0)))))}i(fs,"WalletList");var nT=2;function xm(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=oT(),l=y().blockchains(),{selectedQuote:p,setSelectedWallets:u,quoteWalletsConfirmed:c,setQuoteWalletConfirmed:m,customDestination:h,setCustomDestination:f}=O(),{config:d,connectedWallets:g,setWalletsAsSelected:C}=y(),[S,T]=Go(""),[k,v]=Go([]),[w,A]=Go(""),[M,x]=Go(!!h),E=tT(()=>io({filter:"all",quote:p}),[p]),b=io({filter:"required",quote:p}),N=l.find(_=>_.name===p?.swaps[p?.swaps.length-1].to.blockchain),I=i(_=>b.includes(_),"isWalletRequiredFor"),B=eT(()=>g.filter(_=>_.selected&&E.includes(_.chain)),[g,E]),[j,te]=Go(B()),[J,P]=Go([]),X=i((_,H)=>P(V=>V.concat({blockchain:_,walletType:H})),"addNextSelectedWallets"),se=k.length>0,z=i((_,H)=>!!j.find(V=>V.walletType===_&&V.chain===H&&V.selected&&(I(H)||!I(H)&&!h)),"isSelected"),me=i((_,H,V)=>{let de=!1;return _.map(ne=>{if(ne.chain===H){let fe=ne.selected;return!de&&V?(de=!0,fe=!0):V||(fe=!1),{...ne,selected:fe}}return ne})},"updateSelectableWallets"),vt=i(_=>{x(_),_?I(N?.name??"")||te(H=>me(H,N?.name||"",!1)):(f(""),te(H=>me(H,N?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ze=i(_=>{if(S&&T(""),z(_.walletType,_.chain))return;let V=g.find(de=>de.walletType===_.walletType&&de.chain===_.chain);V&&(n(),_.chain===N?.name&&M&&!I(N.name)&&(x(!1),f(null)),te(de=>de.filter(ne=>ne.chain!==_.chain).concat({...V,selected:!0})))},"onChange"),le=i(()=>{let _=j.filter(H=>H.selected);C(_),u(_),m(!0),o()},"onConfirmBalance"),at=i(async()=>{v([]),A("");let _=await r?.({selectedWallets:j.filter(V=>V.selected),customDestination:h}),H=_.warnings;H?.balance?.messages&&v(H.balance.messages),_.error&&A(_c(_.error)),!_.error&&!H?.balance?.messages.length?le():v(H?.balance?.messages??[])},"onConfirmWallets");wm(()=>{te(_=>{let H=[];return _.forEach(V=>{!g.some(ne=>ne.chain===V.chain&&ne.walletType===V.walletType&&ne.address===V.address)||H.push(V)}),H=H.concat(g.filter(V=>!!!H.find(ne=>ne.chain===V.chain)&&V.selected&&E.includes(V.chain))),H})},[g,E]),wm(()=>{let _=[];J.length>0&&(J.forEach(H=>{let V=g.find(de=>de.chain===H.blockchain&&de.walletType===H.walletType);V?Ze(V):_.push(H)}),P(_))},[g,J]);let G=document.getElementById($e.SWAP_BOX_ID);return ee.createElement(Z,{open:e,onClose:()=>{c||s("../",{replace:!0}),o()},dismissible:!S,container:G,...!S&&{styles:{container:{height:"100%"}},footer:ee.createElement(um,null,ee.createElement(vm,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:cu(a,M,h,p,j,N),onClick:at,variant:"contained",type:"primary",fullWidth:!0,size:"large"},go.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:ee.createElement(sm,null,ee.createElement(lm,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:T.bind(null,"")},ee.createElement(Jk,{size:16})),ee.createElement(hs,{variant:"headline",size:"small"},go.t({id:"Your {blockchainName} wallets",values:{blockchainName:st(S,l)}})))},anchor:"center"},ee.createElement(Z,{open:se,onClose:v.bind(null,[]),container:G},ee.createElement(Rk,{title:go.t("Insufficient account balance"),type:"error",description:ee.createElement(Zk,{messages:k??[]})},ee.createElement(vm,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:le},go.t("Proceed anyway")))),S&&ee.createElement(pm,null,ee.createElement("div",{className:cm()},ee.createElement(fs,{chain:S,isSelected:z,selectWallet:Ze,onShowMore:()=>T(S),onConnect:_=>{X(S,_)}}))),!S&&ee.createElement(ee.Fragment,null,w&&ee.createElement(ee.Fragment,null,ee.createElement(Yk,{variant:"alarm",type:"error",title:go.t(w)}),ee.createElement(gs,{size:12})),ee.createElement(mm,null,E.map((_,H)=>{let V=l.find(Fe=>Fe.name===_),de=`wallet-${H}`,ne=H===E.length-1,fe=ne&&N&&d?.customDestination!==!1;return ee.createElement("div",{key:de},ee.createElement(rm,null,ee.createElement(hs,{variant:"title",size:"xmedium"},go.t({id:"Your {blockchainName} wallets",values:{blockchainName:V?.shortName}})),ee.createElement(hs,{variant:"label",color:"$neutral700",size:"medium"},go.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:V?.shortName}}))),ee.createElement(gs,{size:24}),ee.createElement(im,null,ee.createElement(fs,{chain:_,isSelected:z,selectWallet:Ze,limit:nT,onShowMore:()=>T(V?.name??""),onConnect:Fe=>{X(_,Fe)}})),!ne&&ee.createElement(gs,{size:32}),fe&&ee.createElement(nm,{blockchain:N,open:M,handleOpenChange:vt}))}))))}i(xm,"ConfirmWalletsModal");import{i18n as vT}from"@lingui/core";import{Alert as wT,Button as xT,InfoIcon as bT}from"@rango-dev/ui";import et from"react";import{Alert as aT,Button as sT,Divider as Cs,NoRouteIcon as lT,RefreshIcon as pT,Typography as Bm}from"@rango-dev/ui";import Re from"react";import{i18n as bm}from"@lingui/core";var rT=24,iT=60;function Em(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:R().genericServerError,action:{onClick:n,title:bm.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:R().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:bm.t("Reset")}},description:R().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:R().noResultError.description}}i(Em,"makeInfo");var ys=(o=>(o[o.small=rT]="small",o[o.large=iT]="large",o))(ys||{}),Ss=(o=>(o.small="small",o.large="medium",o))(Ss||{});import{styled as Xr}from"@rango-dev/ui";var Im=Xr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Am=Xr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Nm=Xr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),Wm=Xr("div",{padding:"$6 $0"});function wn(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Em(o,r,()=>a(s,!0),e);return Re.createElement(Im,null,Re.createElement(lT,{size:ys[n],color:"gray"}),Re.createElement(Cs,{size:4}),Re.createElement(Bm,{variant:"title",size:Ss[n]},R().noResultError.title),n==="large"&&Re.createElement(Cs,{size:4}),!!l.description&&Re.createElement(Am,{size:n},Re.createElement(Bm,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),Re.createElement(Cs,{size:n==="large"?"24":"4"}),!!l.alert&&Re.createElement(Nm,{size:n},Re.createElement(aT,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&Re.createElement(sT,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:Re.createElement(Wm,null,Re.createElement(pT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(wn,"NoResult");import{i18n as xn}from"@lingui/core";import{Button as uT,Divider as mT,MessageBox as dT,Typography as fT,WarningIcon as gT}from"@rango-dev/ui";import Dt from"react";import{Typography as _m}from"@rango-dev/ui";import Ts from"react";import{darkTheme as cT,styled as Yr}from"@rango-dev/ui";var Mm=Yr("div",{width:"100%"}),ks=Yr("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Lm=Yr("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${cT} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Pm=Yr("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function $m(t){let{title:e,value:o,valueColor:n}=t;return Ts.createElement(Lm,null,Ts.createElement(_m,{size:"medium",variant:"label",className:"_title"},e),Ts.createElement(_m,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i($m,"QuoteErrorsModalItem");function Dm(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:xn.t("Swapping"),value:L(r.inputUsdValue,4,4)},{title:xn.t("Gas cost"),value:L(r.totalFee,2,2)},{title:xn.t("Receiving"),value:L(r.outputUsdValue,4,4)},{title:xn.t("Price impact"),value:L(r.priceImpact,2,2),valueColor:`${s}500`}];return Dt.createElement(Z,{footer:Dt.createElement(uT,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Dt.createElement(gT,null),fullWidth:!0,disabled:a,onClick:n},R().highValueLossError.confirmMessage),open:e,onClose:o,container:W()},Dt.createElement(dT,{type:s,title:R().highValueLossError.impactTitle,description:R().highValueLossError.description}),Dt.createElement(ks,null,Dt.createElement(mT,{size:"4"}),Dt.createElement(fT,{size:"small",variant:"title"},xn.t("Details")),Dt.createElement(ks,null,l.map((p,u)=>Dt.createElement($m,{key:u,...p})))))}i(Dm,"HighValueLossWarningModal");import{i18n as Zr}from"@lingui/core";function Fm(t,e){let o={alertType:"warning",title:"",action:null};if(e)return o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=Zr.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-settings"),o;if(t){switch(t.type){case 0:{_t(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=R().highValueLossError.title;break}case 4:{o.title=Zr.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=R().unknownPriceError.title;break}case 2:{o.title=Zr.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-settings";break}case 3:{o.title=Zr.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(Fm,"makeAlerts");import{i18n as Vo}from"@lingui/core";import{Button as Om,Divider as Um,MessageBox as hT,Typography as yT}from"@rango-dev/ui";import ho from"react";import{useNavigate as ST}from"react-router-dom";function zm(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,p=ST(),u=e??o;return ho.createElement(Z,{anchor:"bottom",open:n,prefix:ho.createElement(Om,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>p("../"+D.settings)},ho.createElement(yT,{variant:"label",size:"medium",color:"$neutral900"},Vo.t("Change settings"))),container:W(),onClose:r},ho.createElement(hT,{type:"warning",title:s.type===3?Vo.t("High slippage"):Vo.t("Low slippage"),description:s.type===3?Vo.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:u}}):Vo.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},ho.createElement(Um,{size:18}),ho.createElement(Um,{size:32}),ho.createElement(Om,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},Vo.t("Confirm anyway"))))}i(zm,"SlippageWarningModal");import{Button as CT,MessageBox as kT,WarningIcon as TT}from"@rango-dev/ui";import Jr from"react";function Qm(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return Jr.createElement(Z,{footer:Jr.createElement(CT,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Jr.createElement(TT,null),fullWidth:!0,disabled:r,onClick:n},R().unknownPriceError.confirmMessage),open:e,onClose:o,container:W()},Jr.createElement(kT,{type:"warning",title:R().unknownPriceError.impactTitle,description:R().unknownPriceError.description}))}i(Qm,"UnknownPriceWarningModal");function bn(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:p,onConfirmWarningModal:u,onChangeSettings:c}=t,m={confirmationDisabled:a,open:r,onClose:p,onConfirm:u},h=o?.type===0||o?.type===1,f=Fm(e,o?.type===3||o?.type===4?o:null);return f&&!n&&(f.action=null),et.createElement(et.Fragment,null,h&&et.createElement(wn,{error:o,fetch:s}),!!f&&et.createElement(Mm,null,et.createElement(wT,{title:f.title,type:f.alertType,variant:"alarm",...f.action==="show-info"&&{action:et.createElement(Pm,{onClick:l},et.createElement(bT,{size:12,color:"gray"}))},...f.action==="change-settings"&&{action:et.createElement(xT,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:f.alertType,onClick:c},vT.t("Change"))}})),e&&et.createElement(et.Fragment,null,e.type===0&&et.createElement(Dm,{...m,warning:e}),(e.type===3||e.type===2)&&et.createElement(zm,{...m,warning:e}),e.type===1&&et.createElement(Qm,{...m,warning:e})))}i(bn,"QuoteWarningsAndErrors");import ov from"bignumber.js";import mi from"react";import{i18n as yo}from"@lingui/core";import{Alert as qT,Divider as jo,FullExpandedQuote as HT,InfoIcon as GT,NumericTooltip as kd,QuoteTag as VT,StepDetails as KT,TokenAmount as jT,Typography as Xo}from"@rango-dev/ui";import Ws from"bignumber.js";import F,{useRef as XT,useState as YT}from"react";import{styled as vs}from"@rango-dev/ui";var ws=vs("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),qm=vs("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),Hm=vs("div",{width:"100%",display:"flex"});import*as Rr from"@radix-ui/react-collapsible";import{Button as ET,css as En,darkTheme as be,Image as Gm,styled as ze,Typography as IT}from"@rango-dev/ui";var AT=300,Vm=ze(Rr.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${be} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${be} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${be} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),Km=En({padding:"$10 $15"}),jm=ze(ET,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${be} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${be} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${be} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),Xm=ze("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",[`.${be} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${be} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${be} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${be} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${be} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${be} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${be} &`]:{backgroundColor:"$neutral400"}}}}]}),Ym=En({width:"100%",padding:"$15 $15 $10 $15"}),Zm=En({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Ko=En({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),Jm=En({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${be} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Rm=ze(Rr.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:{[`& ${Gm}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${Gm}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${be} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${be} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${be} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),ed=ze("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"}}}}),td=ze(Hr,{width:"100%",background:"inherit"}),xs=ze("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${AT}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),LF=ze("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),od=ze("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${be} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),nd=ze("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),bs=ze(IT,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),rd=ze("div",{display:"flex",flexWrap:"wrap"}),Es=ze("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"}}}}),id=ze("div",{display:"flex"}),ei=ze("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${be} &`]:{borderTopColor:"$neutral800"}});import{i18n as At}from"@lingui/core";import{ChevronDownIcon as WT,CloseIcon as BT,Divider as ni,IconButton as MT,NumericTooltip as LT,QuoteCost as PT,Typography as yt}from"@rango-dev/ui";import Y,{useState as pd}from"react";import{css as NT,styled as ti}from"@rango-dev/ui";var oi=ti("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),Is=ti("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),ad=ti("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),sd=ti("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),ld=NT({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var _T=i(t=>t.fee.isZero()?null:Y.createElement(oi,null,Y.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),Y.createElement(yt,{variant:"label",size:"medium"},"$",L(t.fee,4,4))),"NonPayableFee");function As(t){let[e,o]=pd(!1),[n,r]=pd(!1),{steps:a,quote:s,fee:l,time:p,feeWarning:u,timeWarning:c,showModalFee:m,fullExpandedMode:h=!1}=t,f=s?.swaps??[],d=h?no():W(),g=ou(f);return Y.createElement(Y.Fragment,null,Y.createElement(PT,{onClickFee:m?C=>{C.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:u,timeWarning:c,time:p,steps:a,tooltipGas:m?At.t("View more info"):void 0,tooltipContainer:d}),Y.createElement(Z,{container:d,open:e,anchor:h?"center":"bottom",styles:{container:{maxWidth:h?"484px":"unset"}},header:Y.createElement(sd,{style:{textAlign:h?"left":"center"}},Y.createElement(yt,{variant:"title",size:"medium"},At.t("Gas & Fee Explanation")),Y.createElement(MT,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Y.createElement(BT,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Y.createElement(ad,null,Y.createElement(yt,{variant:"title",size:"small"},At.t("Details")),Y.createElement(ni,{size:10}),Object.entries(g.payable).flatMap(([C,S])=>S.map((T,k)=>{let v=`payable-fee-${k}`,w=Na(T);return Y.createElement(oi,{key:v},Y.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},xa(C,At.t)),Y.createElement(LT,{content:T.amount,container:d},Y.createElement(yt,{variant:"label",size:"medium"},L(T.amount,2,2)," ",T.asset.symbol," ($",L(w,4,4),")")))})),Y.createElement(oi,{className:"total_payable_fee"},Y.createElement(yt,{variant:"label",size:"medium"},At.t("Total Payable Fee")),Y.createElement(yt,{variant:"label",size:"medium"},"$",L(l,4,4))),Y.createElement(Is,null),Object.keys(g.nonePayable).length&&Y.createElement(Kr,{triggerAnchor:"bottom",onClickTrigger:()=>r(C=>!C),trigger:Y.createElement("div",{className:ld()},Y.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?At.t("Hide non-payable fees"):At.t("Show non-payable fees")),Y.createElement(ni,{size:4,direction:"horizontal"}),Y.createElement(Gr,{orientation:n?"up":"down"},Y.createElement(WT,{size:12,color:"gray"}))),open:n},Y.createElement(yt,{size:"small",variant:"title"},At.t("Description")),Y.createElement(ni,{size:4}),Y.createElement(yt,{size:"small",variant:"body",color:"neutral700"},At.t(`The following fees are considered in the transaction output and
|
|
2
|
-
you won\u2019t need to pay extra gas for them.`)),Y.createElement(ni,{size:10}),Object.entries(g.nonePayable).map(([C,S],T)=>{let k=tu(S),v=xa(C,At.t),w=`non-payable-fee-${T}`;return Y.createElement(_T,{key:w,fee:k,label:v})}),Y.createElement(Is,null)))))}i(As,"QuoteCostDetails");import{i18n as md}from"@lingui/core";import{TokenAmount as dd}from"@rango-dev/ui";import ri from"react";import{css as $T,styled as DT}from"@rango-dev/ui";var cd=DT("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),ud=$T({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function In(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return ri.createElement(cd,null,ri.createElement(dd,{direction:"horizontal",label:md.t("Swap input"),type:"input",tooltipContainer:W(),price:{value:e.price.value,usdValue:e.price.usdValue,realValue:e.price.realValue,realUsdValue:e.price.realUsdValue},token:{displayName:e.token.displayName,image:e.token.image},chain:{image:e.chain.image}}),ri.createElement("div",{className:ud()}),ri.createElement(dd,{direction:"horizontal",tooltipContainer:W(),label:md.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(In,"QuoteSummary");import{i18n as Sd}from"@lingui/core";import{ChevronDownIcon as UT,ChevronRightIcon as zT,Divider as Ns,Image as QT,Tooltip as pi,Typography as ai}from"@rango-dev/ui";import U from"react";import{useLayoutEffect as FT,useState as An}from"react";var fd=480,gd=768,hd=1024,yd=1200,OT=i(()=>{let[t,e]=An(!1),[o,n]=An(!1),[r,a]=An(!1),[s,l]=An(!1),[p,u]=An(!1),c=i(()=>{e(window.innerWidth<=fd),n(window.innerWidth>fd&&window.innerWidth<=gd),a(window.innerWidth>gd&&window.innerWidth<=hd),l(window.innerWidth>hd&&window.innerWidth<=yd),u(window.innerWidth>yd)},"handleResize");return FT(()=>(c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:p}},"useScreenDetect"),ii=OT;var si=4,li=6,Nn=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||W();return U.createElement(pi,{container:l,side:"bottom",sideOffset:4,open:r,content:e},U.createElement(ed,{className:n,state:a},U.createElement(QT,{src:o,size:16})))},"ImageComponent");function Cd(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,p=l||W(),u=r.length,c=Gc(r),{isTablet:m,isMobile:h}=ii();return U.createElement(Rm,{listItem:s==="list-item",ref:f=>e.current=f,selected:o,onClick:f=>{f.stopPropagation(),n(d=>!d)}},U.createElement("div",{className:Ko()},U.createElement(ai,{variant:"body",size:"xsmall"},Sd.t("Via:")),U.createElement(Ns,{direction:"horizontal",size:4}),r.map((f,d)=>{let g=`item-${d}`,C=U.createElement(xs,null,U.createElement(zT,{size:12,color:"black"}));return h||m?U.createElement(U.Fragment,{key:g},U.createElement(Nn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),d!==u-1&&U.createElement(U.Fragment,null,C)):U.createElement(U.Fragment,{key:g},u<=si||u>si&&d<si-1?U.createElement(U.Fragment,null,U.createElement(Nn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),d!==u-1&&U.createElement(U.Fragment,null,C)):d===si-1&&U.createElement(pi,{container:p,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Ko()},C,r.map((S,T)=>{let k=`image-${T}`;return T>=d&&U.createElement(U.Fragment,{key:k},U.createElement(Nn,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),T!==u-1&&U.createElement(U.Fragment,null,C))}))},U.createElement(Es,{state:r.find((S,T)=>T>=d&&(S.state==="error"||S.state==="warning"))?.state},U.createElement(ai,{size:"xsmall",variant:"body"},"+",u-d))))})),U.createElement("div",{className:Ko()},U.createElement("div",{className:"blockchains_section"},U.createElement("div",{className:Ko()},U.createElement(ai,{variant:"body",size:"xsmall"},Sd.t("Chains:")),U.createElement(Ns,{direction:"horizontal",size:4}),c.map((f,d)=>U.createElement(U.Fragment,{key:f.displayName},c.length<=li||c.length>li&&d<li-1?U.createElement(pi,{container:p,side:"bottom",content:f.displayName,sideOffset:4},U.createElement(Nn,{content:"",src:f.image,open:!1,className:d!==0?"blockchainImage":""})):d===li-1&&U.createElement(pi,{container:p,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Ko()},c.map((g,C)=>C>=d&&U.createElement(Nn,{key:g.displayName,content:"",src:g.image,open:!1,className:C>d?"blockchainImage":"",container:l})))},U.createElement(Es,{className:"blockchainImage"},U.createElement(ai,{size:"xsmall",variant:"body"},"+",c.length-d))))),U.createElement(Ns,{direction:"horizontal",size:32}))),U.createElement(xs,{orientation:a?"up":"down"},U.createElement(UT,{size:12,color:"black"}))))}i(Cd,"QuoteTrigger");function Bs(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:p=!0,showModalFee:u=!0,onClickAllRoutes:c,fullExpandedMode:m=!1,container:h}=t,f=y().blockchains(),{findToken:d}=y(),g=y().swappers(),{customSlippage:C,slippage:S}=y(),T=C||S,[k,v]=YT(t.expanded),w=XT(null),A=L(o.value,6,6),M=L(n.value,6,6),x=n.usdValue?L(n.usdValue,4,4):"",E=Pt(o.usdValue,n.usdValue??null),b=L(E,2,2),N=_t(E??0),I=i((le,at)=>le.map((G,_)=>{let H,V=r?.type===3&&r.swap.swapperId===G.swapperId,de=r?.type===4&&r.recommendedSlippages?.has(_),ne=a?.type===2&&a.recommendedSlippages?.has(_),fe=V||de,Fe=ne;fe?H="error":Fe&&(H="warning");let ve=fe?yo.t("Slippage Error"):yo.t("Slippage Warning");return V&&(ve=yo.t("Bridge Limit Error")),{swapper:{displayName:on(G.swapperId,g)??"",image:G.swapperLogo},from:{token:{displayName:G.from.symbol,image:G.from.logo},chain:{displayName:st(G.from.blockchain,f)??"",image:G.from.blockchainLogo},price:{value:_===0&&!at?L(o.value,6,6):L(G.fromAmount,6,6),usdValue:L((G.from.usdPrice??0)*parseFloat(G.fromAmount),4,4),realValue:_===0?o.value:G.fromAmount,realUsdValue:new Ws(G.from.usdPrice??0).multipliedBy(G.fromAmount).toString()}},to:{token:{displayName:G.to.symbol,image:G.to.logo},chain:{displayName:st(G.to.blockchain,f)||"",image:G.to.blockchainLogo},price:{value:L(G.toAmount,6,6),usdValue:L((G.to.usdPrice??0)*parseFloat(G.toAmount),4,4),realValue:G.toAmount,realUsdValue:new Ws(G.to.usdPrice??0).multipliedBy(G.toAmount).toString()}},state:H,alerts:fe||Fe?F.createElement(qm,{dense:m},F.createElement(qT,{variant:"alarm",type:fe?"error":"warning",title:ve,footer:F.createElement(Hm,null,V&&F.createElement("div",null,F.createElement(Xo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(jo,{direction:"vertical",size:2}),F.createElement(Xo,{size:"xsmall",variant:"body",color:"neutral900"},yo.t({id:"Yours: {amount} {symbol}",values:{amount:L(G.fromAmount,6,6),symbol:G?.from.symbol}}))),(de||ne)&&!V&&F.createElement("div",null,F.createElement(Xo,{size:"xsmall",variant:"body",color:"neutral900"},yo.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(_)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(_)}}})),F.createElement(jo,{direction:"vertical",size:2}),F.createElement(Xo,{size:"xsmall",variant:"body",color:"neutral900"},yo.t({id:"Yours: {userSlippage}",values:{userSlippage:T}}))))})):void 0,time:an(G.estimatedTimeInSeconds),fee:L(Aa(G,d),2,2),internalSwaps:G.internalSwaps?I(G.internalSwaps):void 0}}),"getQuoteSteps"),B=I(e?.swaps??[]),j=B.length,te=h||W(),J=Kc(t.quote.tags||[]),P=!!c,X=lr(e?.swaps),se=an(X),z=Br(e?.swaps??[],d),me=L(z,2,2),vt=z.gte(new Ws(Dc)),Ze=X/Oc>=Fc;return m?F.createElement(HT,{selected:l,fee:me,time:se,tooltipContainer:no(),steps:B,tags:J,quoteCost:F.createElement(As,{quote:e,fullExpandedMode:!0,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:u,steps:j}),percentageChange:b,warningLevel:N,outputPrice:{value:M,usdValue:x,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(Xm,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:Ym()},!p&&J.length?F.createElement(F.Fragment,null,F.createElement(id,null,J.map((le,at)=>{let G=`${le.value}_${at}`;return F.createElement(F.Fragment,{key:G},F.createElement(VT,{label:le.label,value:le.value}),F.createElement(jo,{size:4,direction:"horizontal"}))})),F.createElement(ei,null),!P&&F.createElement(jo,{size:4})):null,F.createElement("div",{id:"portal-root",className:Zm()},F.createElement(As,{quote:e,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:u,steps:j}),P&&F.createElement(jm,{onClick:le=>{le.stopPropagation(),c()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Xo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},yo.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:Jm()},F.createElement(nd,null,F.createElement(GT,{size:12,color:"gray"})),F.createElement(rd,null,F.createElement(bs,{size:"small",variant:"body"},`${A} ${B[0].from.token.displayName} = `),F.createElement(kd,{content:n.value,container:te,open:n.value?void 0:!1},F.createElement(bs,{size:"small",variant:"body"},"\xA0",`${M} ${B[B.length-1].to.token.displayName}`))),F.createElement(kd,{content:n.usdValue,container:te},F.createElement(jo,{size:2,direction:"horizontal"}),F.createElement(Xo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${x})`))),s==="list-item"&&F.createElement(jT,{tooltipContainer:te,type:"output",direction:"vertical",price:{value:M,usdValue:x,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:B[j-1].to.token.displayName,image:B[j-1].to.token.image},chain:{image:B[j-1].to.chain.image},percentageChange:b,warningLevel:N}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(In,{from:B[0].from,to:B[j-1].to,percentageChange:b,warningLevel:N}),F.createElement(jo,{size:4}))),F.createElement(Vm,{selected:l,listItem:s==="list-item",open:k,className:"quote_container",onOpenChange:v},F.createElement(Cd,{type:s,quoteRef:w,selected:l,setExpanded:v,container:te,expanded:k,steps:B}),F.createElement(td,{open:k},F.createElement(od,null),F.createElement("div",{className:Km()},B.map((le,at)=>{let G=`item-${at}`;return F.createElement(KT,{type:"quote-details",key:G,tooltipContainer:te,step:le,hasSeparator:at!==B.length-1,state:le.state})})))))}i(Bs,"Quote");import{Divider as ev,Skeleton as tv}from"@rango-dev/ui";import Ot from"react";import{darkTheme as ZT,styled as ci}from"@rango-dev/ui";var Td=ci("div",{$$color:"$colors$neutral100",[`.${ZT} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),vd=ci("div",{paddingTop:"$2"}),wd=ci("div",{paddingLeft:"$8"}),xd=ci("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Pd,Divider as St,Skeleton as tt}from"@rango-dev/ui";import Q from"react";import{css as JT,styled as Ft}from"@rango-dev/ui";var Ms=Ft("div",{display:"flex"}),bd=Ft("div",{padding:"$10 $0 $20"}),Ed=Ft("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Id=Ft("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Ad=Ft("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Nd=Ft("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),Wd=Ft("div",{width:"65%",display:"flex",justifyContent:"start"}),Bd=Ft("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Md=Ft("div",{padding:"$15 $0 $15 $0"}),Ld=JT({display:"flex",justifyContent:"space-between",alignItems:"center"});function Wn(t){let{type:e,tagHidden:o=!0}=t,n=Q.createElement(Ad,null,Q.createElement(Wd,null,Q.createElement(Pd,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),Q.createElement(St,{size:8,direction:"horizontal"}),Q.createElement(Bd,null,Q.createElement(tt,{height:10,width:60,variant:"rounded"}),Q.createElement(St,{size:4}),Q.createElement(tt,{height:15,variant:"rounded"}))),Q.createElement(tt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return Q.createElement("div",null,!o&&Q.createElement(Q.Fragment,null,Q.createElement(Ms,null,Q.createElement(tt,{width:65,height:20,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:65,height:20,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:65,height:20,variant:"rounded"})),Q.createElement(ei,null),!r&&Q.createElement(St,{size:4})),Q.createElement("div",{className:Ld()},Q.createElement(Ms,null,Q.createElement(tt,{width:60,height:10,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:60,height:10,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:60,height:10,variant:"rounded"})),r&&Q.createElement(tt,{width:85,height:24,variant:"rounded"})),e==="basic"&&Q.createElement(bd,null,Q.createElement(tt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&Q.createElement(Ed,null,Q.createElement(Id,null,Q.createElement(Pd,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),Q.createElement(St,{direction:"horizontal",size:4}),Q.createElement(tt,{height:15,width:150,variant:"rounded"})),Q.createElement(St,{size:10}),Q.createElement(tt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&Q.createElement(Q.Fragment,null,Q.createElement(St,{size:4}),Q.createElement(Md,null,n,Q.createElement(Nd,null),n),Q.createElement(St,{size:12})))}i(Wn,"QuoteSummarySkeleton");import{ChainToken as Od,Divider as Ps,NextIcon as RT,Skeleton as ui}from"@rango-dev/ui";import Ee from"react";import{styled as Bn}from"@rango-dev/ui";var _d=Bn("div",{display:"flex",alignItems:"start"}),$d=Bn("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Ls=Bn("div",{display:"flex",alignItems:"center",flexGrow:1}),Dd=Bn("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Fd=Bn("div",{display:"flex",alignItems:"center"});function Nt(t){let{separator:e=!0}=t;return Ee.createElement(Ee.Fragment,null,Ee.createElement(Fd,null,Ee.createElement(ui,{height:22,width:22,variant:"circular"}),Ee.createElement(Ps,{direction:"horizontal",size:8}),Ee.createElement(ui,{height:15,width:148,variant:"rounded"})),Ee.createElement(_d,null,Ee.createElement(xd,{hideSeparator:!e}),Ee.createElement($d,{extraSpace:e},Ee.createElement(Ls,null,Ee.createElement(Od,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(Ps,{direction:"horizontal",size:8}),Ee.createElement(ui,{height:12,variant:"rounded"})),Ee.createElement(Dd,null,Ee.createElement(RT,{color:"gray",size:16})),Ee.createElement(Ls,null,Ee.createElement(Od,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(Ps,{direction:"horizontal",size:8}),Ee.createElement(ui,{height:12,variant:"rounded"})))))}i(Nt,"StepSkeleton");function Mn(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ot.createElement(Td,{expanded:o,rounded:e!=="basic"},Ot.createElement(Wn,{type:e,tagHidden:n}),Ot.createElement(vd,null,Ot.createElement(tv,{height:15,variant:"rounded"})),o&&Ot.createElement(wd,null,Ot.createElement(ev,{size:24}),Ot.createElement(Nt,null),Ot.createElement(Nt,null),Ot.createElement(Nt,{separator:!1})))}i(Mn,"QuoteSkeleton");function So(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:p,showModalFee:u,selected:c,onClickAllRoutes:m,fullExpandedMode:h=!1,container:f}=t,{inputAmount:d,inputUsdValue:g}=O(),C=e?.outputAmount?new ov(e?.outputAmount):null,S=e?pt(e):null,k=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?mi.createElement(ws,null,mi.createElement(Mn,{tagHidden:l,type:o,expanded:s})):k?mi.createElement(ws,{onClick:()=>p?.(e)},mi.createElement(Bs,{quote:e,error:r,container:f,showModalFee:u,warning:a,tagHidden:l,selected:c,type:o,expanded:s,onClickAllRoutes:m,fullExpandedMode:h,input:{value:d,usdValue:g?.toString()??""},output:{value:C?.toString()??"",usdValue:S?.toString()??""}})):null}i(So,"QuoteInfo");import{calculatePendingSwap as av}from"@rango-dev/queue-manager-rango-preset";import{useEffect as sv}from"react";import{useRef as nv,useState as rv}from"react";var iv=2e3;function di({request:t}){let[e,o]=rv(!1),n=nv(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(p=>setTimeout(p,iv)),await s(l,!1)),"retryFetch"),s=i(async(l,p=!1)=>{r(),n.current=new AbortController,o(!0);try{let u=await t(l,{signal:n.current.signal});return n.current=null,u}catch(u){if(p)return await a(l);throw u}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(di,"useFetch");function Ud(){let{fetch:t,loading:e,cancelFetch:o}=di({request:async(n,r)=>await bt().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Ud,"useFetchConfirmQuote");function fi(t){if(!t.swaps)throw new Error(R().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=_s(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(fi,"throwErrorIfResponseIsNotValid");function _s(t){if(Jc(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=Rc(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=nu(t);if(o){let n=Mr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(_s,"getQuoteError");function zd(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,l={quote:null,balance:null},p=$o({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});p&&(l.quote=p);let u=au(e,r,n.blockchains);return u.length===0||(l.balance={messages:u}),l}i(zd,"generateWarnings");function gi(t){return t?.code==="ERR_CANCELED"?{swap:null,error:{type:2},warnings:null}:t.cause?{swap:null,error:t.cause,warnings:null}:t?.code==="ERR_BAD_REQUEST"?{swap:null,error:{type:0,diagnosisMessage:t.response.data.error},warnings:null}:{swap:null,error:{type:1},warnings:null}}i(gi,"handleQuoteErrors");function $s(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:l}=O(),{slippage:p,customSlippage:u}=y(),c=y().getDisabledLiquiditySources(),m=y().blockchains(),h=y().tokens(),{findToken:f}=y(),d=u||p,{fetch:g,cancelFetch:C,loading:S}=Ud();return sv(()=>C,[]),{loading:S,fetch:i(async k=>{let v=k.selectedWallets,w=k?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=v.reduce((x,E)=>(x[E.chain]=E.address,x),{}),M={requestId:a?.requestId||"",selectedWallets:A,destination:w||void 0};try{return await g(M,!0).then(x=>{let{result:E}=x;if(!E)throw new Error("Error fetching updated route");fi({diagnosisMessages:E.diagnosisMessages,requestId:E.requestId,swaps:E.result?.swaps});let b={outputAmount:E.result?.outputAmount,requestId:E.requestId,resultType:E.result?.resultType,swaps:E.result?.swaps||[],validationStatus:E.validationStatus,requestAmount:E.requestAmount};r(b);let N={slippage:d.toString(),disabledSwappersGroups:c},I=zd({previousQuote:a??void 0,currentQuote:b,meta:{blockchains:m},selectedWallets:v,userSlippage:d,inputUsdValue:n,findToken:f});l();let B=!!I.balance,j=av(o.toString(),E,iu(v),N,!B,{blockchains:m,tokens:h});return{quote:b,swap:j,error:null,warnings:I}})}catch(x){return gi(x)}},"fetch"),cancelFetch:C}}i($s,"useConfirmSwap");var yv=uv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Qd}`]:{width:"$48",height:"$48"}}),Sv=Os({flexGrow:1,paddingRight:"$10"}),Cv=Os({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),kv=Os({display:"flex",justifyContent:"space-between",alignItems:"center"});function qd(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=O(),s=hv(),[l,p]=Ln(""),u=!n,[c,m]=Ln(!1),[h,f]=Ln(!1),{isActiveTab:d}=re(),g=y().getDisabledLiquiditySources(),C=gv(g),{manager:S}=lv(),{fetch:T,loading:k,cancelFetch:v}=$s(),[w,A]=Ln({swap:null,error:null,warnings:null}),[M,x]=Ln(!1),E=i(async({selectedWallets:P,customDestination:X})=>{let se=await T?.({selectedWallets:P,customDestination:X});return A(se),se},"onConfirmSwap"),b=i(async()=>{if(w.swap&&n)try{await S?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let P=`../${D.swaps}/${w.swap.requestId}`;s(P,{replace:!0}),setTimeout(()=>{e("")},0)}catch(P){p("Error: "+P?.message)}},"addNewSwap"),N=i(async()=>{f(!0),await b(),f(!1)},"onConfirm"),I=i(async()=>{w.warnings?.quote&&Hc(w.warnings.quote)&&!a?x(!0):await N()},"onStartConfirmSwap"),B=i(async()=>{A({error:null,swap:null,warnings:null}),T({selectedWallets:o,customDestination:r}).then(P=>{A(P)}).catch(P=>console.error(P))},"onRefresh");hi(()=>{!!C.current.length&&!g.length&&B(),C.current=g},[g.length]),hi(()=>{u&&v()},[u]),hi(()=>{u&&m(u)},[u]),hi(()=>{u||T({selectedWallets:o,customDestination:r}).then(P=>A(P)).catch(P=>console.error(P))},[]),fv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let j=w.warnings?.quote??null,te=w.error,J=[];if(l&&J.push(Le.createElement(pv,{type:"error",variant:"alarm",title:l})),j||te){let P=`../${D.settings}`;J.push(Le.createElement(bn,{warning:j,error:te,couldChangeSettings:!1,refetchQuote:B,showWarningModal:M,confirmationDisabled:!d,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:async()=>{x(!1),await b()},onChangeSettings:()=>s(P)}))}return Le.createElement(oe,{header:{title:Ds.t("Confirm Swap"),onWallet:()=>{let P=`../${D.wallets}`;s(P)}},footer:Le.createElement(yv,null,Le.createElement("div",{className:Sv()},Le.createElement(cv,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:k||h,disabled:!!w.error||!d,onClick:I},Ds.t("Start Swap"))),Le.createElement(Qd,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:k||h,disabled:!d,onClick:m.bind(null,!0)},Le.createElement(dv,{size:24})))},c&&Le.createElement(xm,{open:c,onClose:()=>m(!1),onCancel:v,loading:k,onCheckBalance:E}),Le.createElement(ie,null,Le.createElement("div",{className:kv()},Le.createElement(mv,{variant:"title",size:"small"},Ds.t("You get")),Le.createElement("div",{className:Cv()},Le.createElement(Fr,{onClick:!k&&!c&&!M?B:void 0}))),Le.createElement(Fs,{size:"12"}),bu(J.map((P,X)=>({element:P,key:`alert-${X}`})),Le.createElement(Fs,{size:10})),J.length>0?Le.createElement(Fs,{size:10}):null,Le.createElement(So,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:w.error,loading:k,warning:w.warnings?.quote??null})))}i(qd,"ConfirmSwapPage");import{i18n as Ut}from"@lingui/core";import{Button as Ys,CustomTokensZeroStateDarkIcon as $v,CustomTokensZeroStateIcon as Dv,DeleteIcon as Fv,Divider as Dn,IconButton as Ov,MessageBox as Uv,NotFound as zv,styled as Js}from"@rango-dev/ui";import ue,{useState as Zs}from"react";import{useNavigate as Qv}from"react-router-dom";import{CloseIcon as vv,IconButton as wv,SearchIcon as xv,TextField as bv}from"@rango-dev/ui";import Pn from"react";import{styled as Tv}from"@rango-dev/ui";var Hd=Tv("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function Ct(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:p,...u}=t;return Pn.createElement(bv,{prefix:Pn.createElement(Hd,null,Pn.createElement(xv,{color:"black"})),suffix:!!s.length&&Pn.createElement(wv,{variant:"ghost",onClick:()=>p?.(""),size:"small"},Pn.createElement(vv,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...u})}i(Ct,"SearchInput");import{i18n as Xs}from"@lingui/core";import{darkTheme as tf,Divider as Zo,ExternalLinkIcon as Av,Image as Nv,ListItemButton as Wv,NotFound as Bv,PinIcon as Mv,Skeleton as of,Typography as Ci,VirtualizedList as Lv}from"@rango-dev/ui";import q from"react";import{Divider as Rd,ListItem as Iv,Skeleton as _n}from"@rango-dev/ui";import kt from"react";import{css as Yo,darkTheme as Gd,ImageContainer as Ev,styled as ut,Typography as Vd}from"@rango-dev/ui";var Us=Yo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),zs=Yo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),Qs=Yo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),qs=Yo({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Gd} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Hs=Yo({}),Gs=Yo(),Kd=ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Vs=ut("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),yi=ut("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${zs}`]:{[`& .${qs}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Hs}`]:{bottom:"-15px"},[`& .${Us}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${Qs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),Ks=ut("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),js=ut(Vd,{}),jd=ut("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Gs}`]:{$$color:"$colors$neutral600",[`.${Gd} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Si=ut("div",{display:"flex",alignItems:"end",flexDirection:"column"}),IU=ut("div",{display:"flex",alignItems:"center"}),Xd=ut("div",{position:"relative",[`& ${Ev}`]:{borderRadius:"$xm",overflow:"hidden"}}),Yd=ut("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),Zd=ut(Vd,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Jd=ut("a",{"& svg:hover":{color:"$colors$info"}});function ef(t){return kt.createElement(yi,null,Array.from(Array(t.size),e=>kt.createElement(Iv,{key:e,hasDivider:!0,start:kt.createElement(_n,{variant:"circular",width:35,height:35}),end:kt.createElement(Si,null,kt.createElement(_n,{variant:"text",size:"large",width:70}),kt.createElement(Rd,{size:4}),kt.createElement(_n,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement(_n,{variant:"text",size:"large",width:90}),kt.createElement(Rd,{size:4}),kt.createElement(_n,{variant:"text",size:"medium",width:90}))})))}i(ef,"LoadingTokenList");var Pv=20,_v=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return q.createElement("div",{className:zs()},o?q.createElement("div",{className:Us()},o):q.createElement(Vs,{className:Qs()},q.createElement(Ci,{variant:"title",size:"xmedium"},r.symbol),q.createElement(Zo,{direction:"horizontal",size:4}),q.createElement(Ks,{css:a},q.createElement(js,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&q.createElement("div",{className:`${qs()} ${!o&&Hs()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",q.createElement(Zo,{size:4,direction:"horizontal"}),q.createElement(Jd,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:p=>p.stopPropagation()},q.createElement(Av,{size:12}))))},"renderDesc");function $n(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,l=y().fetchStatus,p=y().blockchains(),{getBalanceFor:u,fetchingWallets:c}=y(),{isTokenPinned:m}=y(),h=i(d=>{let g=dr(u(d));return s?s(d):c?q.createElement(Si,null,q.createElement(of,{variant:"text",size:"large",width:70}),q.createElement(Zo,{size:4}),q.createElement(of,{variant:"text",size:"medium",width:50})):g&&q.createElement(jd,null,q.createElement(Zd,{variant:"title",size:"small"},g.amount),q.createElement("div",null),g.usdValue&&q.createElement(Ci,{variant:"body",className:Gs(),size:"xsmall"},`$${g.usdValue}`))},"endRenderer"),f=i(()=>q.createElement(Lv,{itemContent:d=>{let g=e[d],C=g.address||"",S=p.find(w=>w.name===g.blockchain),T=Qa(S.color,"main"),k={$$color:T.main150,[`.${tf} &`]:{$$color:T.main750},backgroundColor:"$$color"},v={$$color:T.main750,[`.${tf} &`]:{$$color:T.main150},color:"$$color"};return q.createElement("div",{style:{paddingRight:5}},q.createElement(Wv,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":d,key:`${g.symbol}${g.address}`,id:`${g.symbol}${g.address}`,className:"widget-token-list-item-btn",hasDivider:!0,onClick:()=>n&&n(e[d]),start:q.createElement(Xd,null,q.createElement(Nv,{src:g.image,size:30}),t.type!=="custom-token"&&m(g,t.type)&&q.createElement(Yd,null,q.createElement(Mv,{size:12,color:"gray"}))),title:S?.type==="COSMOS"||g.name||!g.name&&!C?q.createElement(Vs,null,q.createElement(Ci,{variant:"title",size:"xmedium"},g.symbol),q.createElement(Zo,{direction:"horizontal",size:4}),q.createElement(Ks,{css:k},q.createElement(js,{variant:"body",size:"xsmall",css:v},g.blockchain))):void 0,description:S?.info&&C&&S.type!=="COSMOS"?_v({address:C,token:e[d],customCssForTag:k,customCssForTagTitle:v,name:g.name,url:S.info.addressUrl.split("{wallet}").join(C)}):g.name||void 0,end:h(g)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList");return q.createElement(q.Fragment,null,a&&q.createElement(q.Fragment,null,q.createElement(Ci,{variant:"label",size:"large"},Xs.t("Select Token")),q.createElement(Zo,{size:4})),q.createElement(Kd,null,q.createElement(Zo,{size:4}),l==="loading"&&q.createElement(ef,{size:Pv}),l==="success"&&(e.length?q.createElement(yi,{as:"ul"},f()):!!o&&q.createElement(Bv,{title:Xs.t("No results found"),description:Xs.t("Try using different keywords")}))))}i($n,"TokenList");var qv=Js("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),Hv=Js("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),Gv=Js(Ov,{"&:hover":{"& svg":{color:"$secondary550"}}});function nf(){let[t,e]=Zs(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=O(),{mode:p}=Uo({}),u=Qv(),[c,m]=Zs(!1),[h,f]=Zs(),d=i(T=>{let k=T.target.value;e(k)},"handleSearch"),g=p==="dark",C=n.filter(T=>Je(T.symbol,t)||Je(T.address||"",t)||Je(T.name||"",t)),S=i(()=>{if(h){let T=a?lt(a):null,k=r?lt(r):null,v=lt(h);T===v?l({token:null}):k===v&&s({token:null}),o(h)}m(!1)},"handleDeleteCustomToken");return ue.createElement(oe,{header:{title:Ut.t("Custom Tokens")}},ue.createElement(ie,null,ue.createElement(qv,null,n.length?ue.createElement(ue.Fragment,null,ue.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ut.t("Search Token"),onChange:d}),ue.createElement(Dn,{size:16}),ue.createElement($n,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,action:T=>ue.createElement(Gv,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{m(!0),f(T)}},ue.createElement(Fv,{size:12,color:"gray"}))})):ue.createElement(Hv,null,ue.createElement(zv,{icon:g?ue.createElement($v,{size:200}):ue.createElement(Dv,{size:200}),title:Ut.t("No custom tokens"),description:Ut.t("press the button to add your custom token")})),ue.createElement(Dn,{size:20}),ue.createElement(Ys,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>u(D.addCustomTokens)},Ut.t("Add Custom Token"))),ue.createElement(Z,{open:c,dismissible:!0,onClose:()=>m(!1),container:W()},ue.createElement(Uv,{title:Ut.t("Delete Custom Token"),type:"error",description:Ut.t("Are you sure you want to Delete this Token?")},ue.createElement(Dn,{size:40}),ue.createElement(Dn,{size:10}),ue.createElement(Ys,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ut.t("Yes, Delete it")),ue.createElement(Dn,{size:12}),ue.createElement(Ys,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>m(!1)},Ut.t("No, Continue"))))))}i(nf,"CustomTokensPage");import{i18n as qe}from"@lingui/core";import{useManager as cw}from"@rango-dev/queue-manager-react";import{Button as il,darkTheme as uw,Divider as ko,MessageBox as mw,NotFound as dw,styled as al,Typography as vi}from"@rango-dev/ui";import{TransactionStatus as Un}from"rango-types";import ae,{useMemo as wf,useState as wi}from"react";import{useNavigate as fw}from"react-router-dom";import{FilterIcon as Jv,Popover as Rv}from"@rango-dev/ui";import Co from"react";import{css as Vv,darkTheme as ki,IconButton as Kv,styled as Fn}from"@rango-dev/ui";var Rs=Fn("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${ki} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),rf=Fn(Kv,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${ki} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${ki} &`]:{backgroundColor:"$neutral"},[`& ${Rs}::before`]:{backgroundColor:"$secondary100",[`.${ki} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),af=Fn("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),sf=Fn("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),lf=Vv({display:"flex",justifyContent:"space-between",alignItems:"center"}),pf=Fn("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as cf}from"@lingui/core";import{Button as jv,Divider as uf,ListItemButton as Xv,Radio as Yv,RadioRoot as Zv,Typography as mf}from"@rango-dev/ui";import ot from"react";function df(t){let{filterBy:e,onClickItem:o}=t;return ot.createElement(sf,null,ot.createElement("div",{className:lf()},ot.createElement(mf,{size:"small",variant:"body"},cf.t("Status")),ot.createElement(jv,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},cf.t("Reset"))),ot.createElement(uf,{size:10}),ot.createElement(Zv,{value:e},ot.createElement(pf,null,t.list.map((n,r)=>ot.createElement(Xv,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:ot.createElement(ot.Fragment,null,ot.createElement(uf,{direction:"horizontal",size:4}),ot.createElement(mf,{size:"medium",variant:"body"},n.title)),start:ot.createElement(Yv,{value:n.id}),onClick:o})))))}i(df,"FilterSelectorContent");function el(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return Co.createElement("div",null,Co.createElement(Rv,{open:a,align:"end",onOpenChange:o,container:W(),content:Co.createElement(df,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},Co.createElement(rf,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},Co.createElement(Rs,{isSelect:!!n},Co.createElement(Jv,{size:16,color:"black"}),!!n&&Co.createElement(af,null)))))}i(el,"FilterSelector");import{i18n as ow}from"@lingui/core";import{Divider as Sf,GroupedVirtualizedList as nw,Skeleton as rw,SwapListItem as Cf,Typography as iw}from"@rango-dev/ui";import Qe,{useCallback as kf,useEffect as aw,useRef as sw,useState as lw}from"react";function ff(t,e){let o=[],n=0;do{let r=t[n];o.push(Math.min(r,e)),e-=r,n++}while(e>0&&n<=t.length);return o}i(ff,"calculateGroupsSoFar");import{css as ew,darkTheme as tw,styled as On}from"@rango-dev/ui";var tl=ew(),gf=On("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),ol=On("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${tl}`]:{$$color:"$colors$neutral600",[`.${tw} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),nl=On("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),hf=On("div",{gap:"$10",display:"flex",flexDirection:"column"}),yf=On("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var pw=10;function rl(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=lw([]),l=sw(0),{swaps:p,groupCounts:u,groups:c}=n(e),m=kf(ff,[]),h=kf(()=>{let f=e.length-l.current;f&&(l.current+=Math.min(f,pw),s(m(u,l.current)))},[e.length]);if(aw(()=>{r||h()},[r,h]),r){let f=[1,2];return Qe.createElement(Qe.Fragment,null,[f,f].map((g,C)=>Qe.createElement(ol,{key:C},Qe.createElement(nl,null,Qe.createElement(rw,{variant:"text",width:60,size:"small"}),Qe.createElement(Sf,{size:16})),Qe.createElement(Sf,{size:4}),Qe.createElement(hf,null,g.map((T,k)=>Qe.createElement(Cf,{isLoading:!0,key:k}))))))}return Qe.createElement(nw,{endReached:()=>{l.current<e.length&&h()},groupCounts:a,groupContent:f=>Qe.createElement(ol,null,Qe.createElement(nl,null,Qe.createElement(iw,{variant:"label",size:"medium",className:tl()},c[f]))),itemContent:(f,d)=>{let g=p[f];if(!g)return null;let C=g.steps[0],S=g.steps[g.steps.length-1];return Qe.createElement(gf,{key:g.requestId},Qe.createElement(Cf,{requestId:g.requestId,creationTime:g.creationTime,status:g.status,onClick:o,tooltipContainer:W(),onlyShowTime:c[d]===ow.t("Today"),swapTokenData:{from:{token:{image:C.fromLogo,displayName:C.fromSymbol},blockchain:{image:C.fromBlockchainLogo||""},amount:L(g.inputAmount,6,6),realAmount:g.inputAmount},to:{token:{image:S.toLogo,displayName:S.toSymbol},blockchain:{image:S.toBlockchainLogo||""},amount:L(S.outputAmount||S.expectedOutputAmountHumanReadable||"",6,6),realAmount:S.outputAmount||S.expectedOutputAmountHumanReadable||""}}}))}})}i(rl,"HistoryGroupedList");import{i18n as Ti}from"@lingui/core";import Tf from"dayjs";var vf=i(t=>{let e=new Map([["today",{title:Ti.t("Today"),swaps:[]}],["week",{title:Ti.t("This week"),swaps:[]}],["month",{title:Ti.t("This month"),swaps:[]}],["year",{title:Ti.t("This year"),swaps:[]}]]);function o(p,u){e.has(p)||e.set(p,{title:p,swaps:[]}),e.get(p)?.swaps.push(u)}i(o,"addYearsToOutput");let n=Tf();t.forEach(p=>{let u=Number(p.creationTime),c=Tf(u);if(n.isSame(c,"day"))e.get("today")?.swaps.push(p);else if(n.isSame(c,"week"))e.get("week")?.swaps.push(p);else if(n.isSame(c,"month"))e.get("month")?.swaps.push(p);else if(n.isSame(c,"year"))e.get("year")?.swaps.push(p);else{let m=new Date(u).getFullYear().toString();o(m,p)}});let r=Array.from(e.values()).filter(p=>p.swaps.length>0),a=r.flatMap(p=>p.swaps),s=r.map(p=>p.swaps.length),l=r.map(p=>p.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var gw=al("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),hw=al("div",{display:"flex",justifyContent:"center",alignItems:"center"}),yw=al("div",{"._typography":{color:"$neutral700",[`.${uw}&`]:{color:"$neutral900"}}}),Sw=[{id:Un.SUCCESS,title:qe.t("Complete")},{id:Un.RUNNING,title:qe.t("Running")},{id:Un.FAILED,title:qe.t("Failed")}],Cw=i((t,e)=>t?.length?t.filter(o=>wt(o.fromBlockchain,e)||wt(o.toBlockchain,e)||wt(o.toSymbol,e)||wt(o.fromSymbol,e)).length:!1,"isStepContainsText");function xf(){let t=fw(),{manager:e,state:o}=cw(),n=ct(e).map(({swap:k})=>k),[r,a]=wi(""),[s,l]=wi(!1),p=!o.loadedFromPersistor,[u,c]=wi(""),[m,h]=wi(!1),f=i(k=>{let v=k.target.value;a(v)},"handleSearch"),d=wf(()=>!r&&!u?n:n.filter(k=>{let{inputAmount:v,status:w,steps:A,requestId:M}=k;return(!r||wt(v,r)||wt(w,r)||Cw(A,r)||wt(M,r))&&(!u||u===w)}),[n,r,u]),g=!d?.length&&!p,C=i(()=>h(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),h(!1)}catch(k){console.log(k)}},"onClear"),T=wf(()=>!n.some(k=>k.status===Un.SUCCESS||k.status===Un.FAILED),[n]);return ae.createElement(oe,{header:{title:qe.t("History"),suffix:ae.createElement(Vt,null,ae.createElement(il,{id:"widget-history-clear-btn",disabled:T,variant:"ghost",size:"xsmall",onClick:()=>h(!0)},ae.createElement(vi,{size:"medium",variant:"label",color:"error"},qe.t("Clear"))))}},ae.createElement(ie,null,ae.createElement(hw,null,ae.createElement(Ct,{setValue:a,fullWidth:!0,variant:"contained",placeholder:qe.t("Search Transaction"),autoFocus:!0,onChange:f,style:{height:36},value:r}),ae.createElement(ko,{size:10,direction:"horizontal"}),ae.createElement(el,{filterBy:u,open:s,onOpenChange:k=>l(k),onClickItem:k=>c(k),list:Sw})),ae.createElement(ko,{size:"16"}),ae.createElement(gw,null,g&&ae.createElement(yf,null,ae.createElement(ko,{size:32}),ae.createElement(dw,{title:r?qe.t("No results found"):qe.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?qe.t("Try using different keywords"):qe.t("Your transaction history is stored locally and will appear here after you start a swap")})),!g&&ae.createElement(rl,{list:d,onSwapClick:t,groupBy:vf,isLoading:p}))),ae.createElement(Z,{open:m,onClose:C,container:W()},ae.createElement(ko,{size:20}),ae.createElement(mw,{type:"warning",title:qe.t("Clear Transaction History"),description:ae.createElement(yw,null,ae.createElement(vi,{variant:"body",size:"medium"},qe.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ae.createElement(ko,{size:"24"}),ae.createElement(vi,{variant:"body",size:"small"},qe.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ae.createElement(ko,{size:30}),ae.createElement(il,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},qe.t("Yes, Clear the history")),ae.createElement(ko,{size:10}),ae.createElement(il,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:C},ae.createElement(vi,{variant:"title",size:"medium",color:"primary"},qe.t("No, Cancel")))))}i(xf,"HistoryPage");import{i18n as qw}from"@lingui/core";import{Button as Hw,Divider as Gf,styled as Gw,WarningIcon as Vw}from"@rango-dev/ui";import Kw from"bignumber.js";import He,{useEffect as Vf,useState as Kf}from"react";import{useNavigate as jw}from"react-router-dom";import{i18n as Ef}from"@lingui/core";import{Alert as Tw,Divider as sl,NoRouteIcon as vw,Typography as ww}from"@rango-dev/ui";import To from"react";import{styled as kw}from"@rango-dev/ui";var bf=kw("div",{display:"flex",flexDirection:"column",alignItems:"center"});function ll(){let{fromToken:t,toToken:e}=O();return!!t&&!!e&&Mt(t,e)?To.createElement(bf,null,To.createElement(sl,{size:10}),To.createElement(vw,{size:24,color:"gray"}),To.createElement(sl,{size:4}),To.createElement(ww,{variant:"title",size:"small"},Ef.t("No Routes Found")),To.createElement(sl,{size:4}),To.createElement(Tw,{title:Ef.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(ll,"SameTokensWarning");import{i18n as Nw}from"@lingui/core";import{Header as Ww}from"@rango-dev/ui";import Jt,{useEffect as Bw,useState as Mw}from"react";import{i18n as bw}from"@lingui/core";import{Divider as cl,FullExpandedQuote as Ew,Typography as Iw}from"@rango-dev/ui";import Se from"react";import{styled as pl}from"@rango-dev/ui";var If=pl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Af=pl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Nf=pl("div",{width:"146px"});import{i18n as zn}from"@lingui/core";import{Select as xw}from"@rango-dev/ui";import Wf from"react";function xi(t){let{updateQuotePartialState:e,sortStrategy:o}=O(),n=[{value:"SMART",label:zn.t("Smart Routing")},{value:"FEE",label:zn.t("Lowest Fee")},{value:"SPEED",label:zn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:zn.t("Maximum Return")},{value:"PRICE",label:zn.t("Maximum Output")}];return Wf.createElement(Nf,null,Wf.createElement(xw,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(xi,"SelectStrategy");var Bf=3;function Qn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:p,quotes:u,updateQuotePartialState:c,fromToken:m,toToken:h,sortStrategy:f,error:d}=O(),{slippage:g,customSlippage:C}=y(),{findToken:S}=y(),T=l||W(),k=!!u&&u.results.length,v=C??g,w=i(x=>{if(!m||!h||!u)return null;let E={requestAmount:u.requestAmount,validationStatus:null,...x};return $o({currentQuote:E,userSlippage:v,findToken:S})},"getQuoteWarning"),A=d?.type===0||d?.type===1,M=u?.results?Wr(f,u?.results):[];return Se.createElement(Se.Fragment,null,a&&Se.createElement(Se.Fragment,null,Se.createElement(Af,null,Se.createElement(Iw,{size:"xmedium",variant:"title"},bw.t("Sort by")),Se.createElement(xi,{container:T})),Se.createElement(cl,{size:"10"})),e&&Array.from({length:Bf},(x,E)=>Se.createElement(Se.Fragment,{key:E},s?Se.createElement(Ew,{loading:!0}):Se.createElement(Mn,{tagHidden:!1,type:"list-item",expanded:!1}),E!==Bf-1&&Se.createElement(cl,{size:16}))),!e&&Se.createElement(Se.Fragment,null,k?M.map((x,E)=>{let b=w(x),N=_s(x.swaps),I=M.length-1===E;return Se.createElement(Se.Fragment,{key:x.requestId},Se.createElement(So,{showModalFee:r,container:T,selected:p?.requestId===x.requestId,tagHidden:!1,quote:{...x,requestAmount:u.requestAmount,validationStatus:null},loading:e,error:N?.options||null,warning:b,fullExpandedMode:s,onClick:B=>{N||c("warning",b),c("error",N?.options||null),o(B)},type:"list-item"}),!I&&Se.createElement(cl,{size:16}))}):A&&Se.createElement(If,null,Se.createElement(wn,{size:s?"large":"small",error:d,fetch:n}))))}i(Qn,"Quotes");import{darkTheme as Aw,styled as Mf}from"@rango-dev/ui";var Lf=Mf("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${Aw} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Pf=Mf("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var Lw=100;function ul(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=Mw(!1),p=s?"":"is-hidden",{config:u}=y(),c=u?.variant==="full-expanded",m=no();return Bw(()=>{let h=null;return a?h=setTimeout(()=>{l(!0)},Lw):(l(!1),h&&clearTimeout(h)),()=>{h&&clearTimeout(h)}},[a]),Jt.createElement(Lf,{expandMode:u?.variant==="full-expanded"?"full":"default",className:`${p} ${zr()}`,id:$e.EXPANDED_BOX_ID},Jt.createElement(Ww,{title:Nw.t("Routes"),suffix:Jt.createElement(Jt.Fragment,null,Jt.createElement(xi,{container:m}),Jt.createElement(fo,{container:m,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Jt.createElement(Pf,null,Jt.createElement(Qn,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:no(),onClickOnQuote:n,fullExpandedMode:c})))}i(ul,"ExpandedQuotes");import{i18n as zf}from"@lingui/core";import{SwapInput as Qf}from"@rango-dev/ui";import Dw from"bignumber.js";import qn from"react";import{ReverseIcon as $w}from"@rango-dev/ui";import dl from"react";import{keyframes as Pw,styled as _f}from"@rango-dev/ui";var ml=450,_w=Pw({"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)"}}),$f=_f("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),Df=_f("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${_w} ${ml}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 fl(){let t=O.use.switchFromAndTo();return dl.createElement($f,null,dl.createElement(Df,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},ml),t()}},dl.createElement($w,{size:12})))}i(fl,"SwitchFromAndToButton");import{styled as Ff}from"@rango-dev/ui";var Of=Ff("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Uf=Ff("div",{position:"relative"});function gl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:p,setInputAmount:u,inputAmount:c,inputUsdValue:m,outputAmount:h,outputUsdValue:f,selectedQuote:d}=O(),{connectedWallets:g,getBalanceFor:C}=y(),S=a?C(a):null,T=dr(S)?.amount??"0",k=S?new Dw(S.amount).shiftedBy(-S.decimals):ge,v=!!s&&$p(g,s.name),w=!Ia(d,c,m),A=!Ia(d,c,f),M=!m||!f||!f.gt(0)?null:Pt(m.toString(),f.toString());return qn.createElement(Of,null,qn.createElement(Uf,null,qn.createElement(Qf,{label:zf.t("From"),mode:"From",onInputChange:u,balance:T,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:c,usdValue:w?void 0:L(m,4,4),realUsdValue:w?void 0:m?.toString(),error:w?R().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:W(),onSelectMaxBalance:()=>{let x=L(k,S?.decimals),E=S?.amount?x:"";u(E)},anyWalletConnected:g.length>0}),qn.createElement(fl,null)),qn.createElement(Qf,{sharpBottomStyle:!r&&(!!d||e),label:zf.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:p?.displayName||"",image:p?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:L(Pt(m,f),2,2),warningLevel:_t(M??0),price:{value:L(h,6,6),usdValue:A?void 0:L(f,4,4),realValue:h?.toString(),realUsdValue:A?void 0:f?.toString(),error:A?R().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:W()}))}i(gl,"Inputs");import{useCallback as Fw,useEffect as Ow,useRef as Uw,useState as zw}from"react";function qf(){let{fetch:t,loading:e,cancelFetch:o}=di({request:async(n,r)=>await bt().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(qf,"useFetchAllQuotes");var Qw=600;function bi({refetchQuote:t}){let{fetch:e,cancelFetch:o}=qf(),{excludeLiquiditySources:n,routing:r}=y().config,{connectedWallets:a}=y(),{fromToken:s,toToken:l,inputAmount:p,inputUsdValue:u,selectedQuote:c,sortStrategy:m,resetQuote:h,error:f,warning:d,setSelectedQuote:g,updateQuotePartialState:C}=O(),{slippage:S,customSlippage:T,affiliatePercent:k,affiliateRef:v,affiliateWallets:w,fetchStatus:A}=y(),M=y().getLiquiditySources(),x=y().getDisabledLiquiditySources(),E=y().excludeLiquiditySources(),{findToken:b}=y(),[N,I]=zw(!0),B=Uw(p),j=T??S,J=!s||!l||Mt(s,l)||!sn(p),P=i(z=>{I(z)},"resetState"),X=i(z=>{let{fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:G,slippage:_,affiliateRef:H,affiliatePercent:V,affiliateWallets:de}=z;if(N||P(!0),!J&&me&&vt){h();let ne=ru({fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:G,wallets:a,slippage:_,affiliateRef:H,affiliatePercent:V,affiliateWallets:de});Ao("experimental",r)&&(ne.experimental=!0),Ao("avoidNativeFee",r)&&(ne.avoidNativeFee=!0),Ao("enableCentralizedSwappers",r)&&(ne.enableCentralizedSwappers=!0),r?.maxLength&&(ne.maxLength=r.maxLength),e(ne).then(fe=>{let Fe=Wr(m,fe.results),ve=Vc(c,Fe,fe.requestAmount);I(!1),C("quotes",fe),g(ve),fi({diagnosisMessages:fe.diagnosisMessages,requestId:ve?.requestId||"",swaps:ve?.swaps});let dt=ve&&$o({currentQuote:ve,userSlippage:j,findToken:b});C("warning",dt)}).catch(fe=>{let{error:Fe}=gi(fe);(Fe?.type===0||Fe?.type===1)&&h(),Fe?.type!==2&&(C("error",Fe),I(!1))})}},"fetch"),se=Fw(xp(z=>{X(z)},Qw),[J]);return Ow(()=>{if(!t){I(!1);return}if(A!=="success")return;if(J){I(!1),(c||f||d)&&h();return}if(!sn(p)||u?.eq(0)){P(!1),o();return}h(),P(!0);let z=X;return B.current&&B.current!=p&&(z=se),B.current=p,z({inputAmount:p,fromToken:s,toToken:l,liquiditySources:M,excludeLiquiditySources:E,disabledLiquiditySources:x,slippage:j,affiliateRef:v,affiliatePercent:k,affiliateWallets:w}),o},[A,p,s?.symbol,s?.address,s?.blockchain,l?.symbol,l?.address,l?.blockchain,J,M?.length,n,x.length,j,v,k,JSON.stringify(w)]),{fetch:()=>X({inputAmount:p,fromToken:s,toToken:l,liquiditySources:M,excludeLiquiditySources:E,disabledLiquiditySources:x,slippage:j,affiliateRef:v,affiliatePercent:k,affiliateWallets:w}),loading:N}}i(bi,"useSwapInput");function Hf(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};he.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(Hf,"emitPreventableEvent");var Xw=Gw("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),Yw=300;function jf(){let t=jw(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:p,setSelectedQuote:u,resetQuoteWallets:c,setQuoteWarningsConfirmed:m,updateQuotePartialState:h}=O(),[f,d]=Kf(!1),{isLargeScreen:g,isExtraLargeScreen:C}=ii(),{fetch:S,loading:T}=bi({refetchQuote:a}),{config:k,fetchStatus:v,connectedWallets:w}=y(),{isActiveTab:A}=re(),[M,x]=Kf(!1),b=eu({fetchMetaStatus:v,fetchingQuote:T,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),N=qp(g,C,k?.variant),I=!!n&&!!e&&!!o&&new Kw(n).gt(0)&&!uu(e,o),B=I&&v==="success"&&T,J=(!N||N&&p?.results.length)&&(l||s);Vf(()=>{c(),h("refetchQuote",!0)},[]),Vf(()=>{d(I)},[I]);let P=(r||s)&&!M?S:void 0,X=i(z=>{N&&f?(d(!1),setTimeout(()=>{t(z)},Yw)):t(z)},"onHandleNavigation"),se=i(z=>{r?.requestId!==z.requestId&&(x(!1),u(z))},"onClickOnQuote");return He.createElement(Xw,null,He.createElement(oe,{height:"auto",footer:He.createElement(Hw,{id:`widget-swap-${b.action}-btn`,type:"primary",size:"large",disabled:b.disabled||!A,prefix:b.action==="confirm-warning"&&He.createElement(Vw,null),fullWidth:!0,onClick:()=>{b.action==="connect-wallet"?Hf({type:"clickConnectWallet"},()=>X(D.wallets)):b.action==="confirm-warning"?x(!0):X(D.confirmSwap)}},b.title),header:{onWallet:()=>{X(D.wallets)},hasBackButton:!1,title:k.title||qw.t("Swap"),suffix:He.createElement(fo,{hidden:N?["refresh"]:void 0,onClickRefresh:P,onClickHistory:()=>X(D.swaps),onClickSettings:()=>{X(D.settings)}})}},He.createElement(ie,null,He.createElement(gl,{fetchingQuote:B,fetchMetaStatus:v,isExpandable:N,onClickToken:z=>{X(z==="from"?D.fromSwap:D.toSwap)}}),He.createElement(Gf,{size:"2"}),N?null:He.createElement(So,{quote:r,loading:B,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:p&&p.results.length>1?()=>{h("refetchQuote",!1),X(D.routes)}:void 0}),J?He.createElement(He.Fragment,null,He.createElement(Gf,{size:"10"}),He.createElement(bn,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:M,confirmationDisabled:!A,onOpenWarningModal:()=>x(!0),onCloseWarningModal:()=>x(!1),onConfirmWarningModal:()=>{x(!1),m(!0),X(D.confirmSwap)},onChangeSettings:()=>X(D.settings)})):null,He.createElement(ll,null))),N?He.createElement(ul,{loading:B,onClickOnQuote:se,fetch:S,onClickRefresh:P,isVisible:f}):null)}i(jf,"Home");import{i18n as Xf}from"@lingui/core";import{Alert as Zw,Divider as Jw,List as Rw,ListItemButton as ex,Radio as tx,RadioRoot as ox,Typography as nx}from"@rango-dev/ui";import Wt from"react";function Rt(){let{setLanguage:t,language:e,config:o}=y(),n=Xp,r=o?.language||No;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||No),resetLanguage:()=>t(null)}}i(Rt,"useLanguage");function Yf(){let{activeLanguage:t,changeLanguage:e,languages:o}=Rt(),n=je(),r=o.map(a=>{let{local:s,label:l,SVGFlag:p}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Wt.createElement(nx,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Wt.createElement(tx,{value:s}),start:Wt.createElement(p,null)}});return Wt.createElement(oe,{header:{title:Xf.t("Language")}},Wt.createElement(ie,null,Wt.createElement(Zw,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Wt.createElement(Jw,{size:"8"}),Wt.createElement(ox,{value:t},Wt.createElement(Rw,{type:Wt.createElement(ex,{title:Xf.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(Yf,"LanguagePage");import{i18n as zt}from"@lingui/core";import{Button as lx,Checkbox as px,Image as cx,ListItemButton as ux,NotFound as mx,Typography as dx}from"@rango-dev/ui";import Ge,{useState as fx}from"react";import{Checkbox as ax,Skeleton as Jf}from"@rango-dev/ui";import Gn from"react";import{styled as hl}from"@rango-dev/ui";var Hn=hl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),yl=hl("div",{width:80,display:"flex",justifyContent:"flex-end"}),Sl=hl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as rx,styled as ix}from"@rango-dev/ui";var Zf=ix(rx,{height:61});var sx=30;function Cl(){return Gn.createElement(Hn,null,Array.from(Array(sx),(t,e)=>Gn.createElement(Zf,{hasDivider:!0,key:e,start:Gn.createElement(Jf,{variant:"circular",width:35,height:35}),title:Gn.createElement(Jf,{variant:"text",size:"large",width:90}),end:Gn.createElement(ax,{checked:!1})})))}i(Cl,"LoadingLiquiditySourceList");function kl({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=fx(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),p=hr(o,n),u={Exchanges:zt.t("Exchanges"),Bridges:zt.t("Bridges")},c=[];t==="Exchanges"&&c.push("DEX"),t==="Bridges"&&c.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let m=p.filter(S=>c.includes(S.type)),h=m.length===m.filter(S=>S.selected).length,f=i(()=>{m.forEach(S=>{h?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),d=m.map(S=>{let{selected:T,groupTitle:k,logo:v,id:w,...A}=S;return{id:`widget-setting-liquidity-source-${w.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:Ge.createElement(cx,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(k)},end:Ge.createElement(px,{checked:T,disabled:l}),title:Ge.createElement(dx,{variant:"title",size:"xmedium"},zt.t(k)),selected:T,groupTitle:k,logo:v,...A}}),g=i(S=>{let T=S.target.value;a(T)},"handleSearch"),C=d;return r&&(C=d.filter(S=>wt(S.groupTitle,r))),Ge.createElement(oe,{header:{title:zt.t(t),suffix:Ge.createElement(yl,null,Ge.createElement(lx,{id:`widget-liquidity-source-${h?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:f},h?zt.t("Deselect all"):zt.t("Select all")))}},Ge.createElement(ie,{view:!0},Ge.createElement(Ct,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:zt.t("Search {sourceType}",{sourceType:u[t]}),onChange:g}),e==="loading"&&Ge.createElement(Cl,null),!C.length&&r?Ge.createElement(Sl,null,Ge.createElement(mx,{title:zt.t("No results found"),description:zt.t("Try using different keywords")})):e==="success"&&Ge.createElement(Hn,{disabled:l},C.map(S=>{let{groupTitle:T,...k}=S;return Ge.createElement(Ge.Fragment,{key:S.id},Ge.createElement(ux,{style:{height:"61px"},...k,selected:!1,hasDivider:!0}))}))))}i(kl,"LiquiditySourcePage");import{i18n as gx}from"@lingui/core";import Ei from"react";import{useNavigate as hx}from"react-router-dom";function Rf(){let t=hx(),e=je(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=O(),{fetch:l,loading:p}=bi({refetchQuote:n}),u=i(h=>{r(h),a("refetchQuote",!1),e()},"onClickOnQuote"),c=`../${D.settings}`,m=`../${D.wallets}`;return Ei.createElement(oe,{header:{onWallet:()=>{t(m),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:gx.t("Routes"),suffix:Ei.createElement(fo,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(c),a("refetchQuote",!0)}})}},Ei.createElement(ie,null,Ei.createElement(Qn,{fetch:l,loading:p,onClickOnQuote:u})))}i(Rf,"RoutesPage");import{i18n as ag}from"@lingui/core";import{Divider as sg,getCategoriesCount as Ex,SelectableCategoryList as Ix}from"@rango-dev/ui";import Qt,{useState as lg}from"react";import{useNavigate as Ax}from"react-router-dom";import{i18n as Tl}from"@lingui/core";import{Divider as kx,Image as Tx,ListItemButton as vx,NotFound as wx,Typography as ig}from"@rango-dev/ui";import nt,{useEffect as xx,useState as bx}from"react";var eg=i((t,e,o)=>t.filter(n=>sr(n.type,o)).filter(n=>Je(n.name,e)||Je(n.displayName,e)),"filterBlockchains");import{ImageContainer as yx,styled as tg}from"@rango-dev/ui";var og=tg("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Ii=tg(Cn,{padding:0,margin:0,listStyle:"none",[`& ${yx}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as Sx,Skeleton as ng}from"@rango-dev/ui";import Ai from"react";var Cx=20;function rg(){return Ai.createElement(Ii,null,Array.from(Array(Cx),t=>Ai.createElement(Sx,{key:t,hasDivider:!0,start:Ai.createElement(ng,{variant:"circular",width:35,height:35}),title:Ai.createElement(ng,{variant:"text",size:"large",width:90})})))}i(rg,"LoadingBlockchainList");function vl(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=bx(e),{fetchStatus:p}=y();xx(()=>{l([...eg(e,o,r)])},[e,o,r]);let u=i(()=>!s.length&&o?nt.createElement(wx,{title:Tl.t("No results found"),description:Tl.t("Try using different keywords")}):nt.createElement(Ii,{as:"ul",key:`${r}-${o}`},s.map(c=>nt.createElement(vx,{key:`${c.name}-${c.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(c),start:nt.createElement(Tx,{src:c.logo,size:30}),title:nt.createElement(ig,{variant:"title",size:"medium"},c.displayName),id:c.name}))),"renderList");return nt.createElement(nt.Fragment,null,a&&nt.createElement(nt.Fragment,null,nt.createElement(ig,{variant:"label",size:"large"},Tl.t("Select Chain")),nt.createElement(kx,{size:4})),nt.createElement(og,null,p==="loading"&&nt.createElement(rg,null),p==="success"&&u()))}i(vl,"BlockchainList");function Ni(t){let{type:e}=t,o=je(),[n,r]=lg(""),[a,s]=lg("ALL"),l=O.use.setToBlockchain(),p=O.use.setFromBlockchain(),{fetchStatus:u}=y(),c=Ax(),m=y().blockchains({type:e}),h=Ex(m),f=!t.hideCategory&&h!==1;return Qt.createElement(oe,{header:{title:ag.t("Select Chain")}},Qt.createElement(ie,{view:!0},f&&Qt.createElement(Qt.Fragment,null,Qt.createElement(Ix,{setCategory:s,category:a,blockchains:m,isLoading:u==="loading"}),Qt.createElement(sg,{size:24})),Qt.createElement(Ct,{value:n,autoFocus:!0,placeholder:ag.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:d=>r(d.target.value)}),Qt.createElement(sg,{size:16}),Qt.createElement(vl,{list:m,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:d=>{e==="custom-token"?c(`..?blockchain=${d.name}`,{replace:!0}):(e==="source"?p(d):l(d),o())}})))}i(Ni,"SelectBlockchainPage");import{i18n as Bi}from"@lingui/core";import{Divider as fg}from"@rango-dev/ui";import vo,{useState as $x}from"react";import{useNavigate as Dx}from"react-router-dom";import{i18n as bl}from"@lingui/core";import{BlockchainsChip as Wi,Divider as mg,Image as dg,Skeleton as Lx,Tooltip as Px,Typography as El}from"@rango-dev/ui";import Pe from"react";import{useEffect as Bx}from"react";var pg=["ETH","COSMOS","OSMOSIS"];function wl(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(Nx),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let l=o.limit-e.length;for(let p=0;p<=l;p++){let u=n[p];s=s.filter(c=>u.name!==c)}}n.sort(Wx(s)),r=n.splice(a)}return{list:n,more:r}}i(wl,"prepare");function Nx(t,e){let o=pg,n=o.findIndex(l=>l===t.name),r=o.findIndex(l=>l===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(Nx,"sortByMostUsedBlockchains");function Wx(t){return i(function(o,n){let r=t.findIndex(p=>p===o.name),a=t.findIndex(p=>p===n.name),s=r>-1,l=a>-1;return s&&l?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(Wx,"generateSortByPreferredBlockchainsFor");function cg(t,e){return!!e.list.find(o=>o.name===t)}i(cg,"isInVisibleList");function xl(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();Bx(()=>{if(e?.selected){let a=wl(t,o,e);cg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=wl(t,o,e);return{list:r.list,more:r.more,history:[]}}i(xl,"usePrepareBlockchainList");import{styled as Mx}from"@rango-dev/ui";var ug=Mx("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var _x=12;function Il(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=xl(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),p=O.use.resetToBlockchain(),u=O.use.resetFromBlockchain(),c=s.more.length>0,m=s.more.length===1,h=!m&&c;return Pe.createElement(Pe.Fragment,null,Pe.createElement(mg,{size:12}),Pe.createElement(El,{variant:"label",size:"large"},bl.t("Select Chain")),Pe.createElement(mg,{size:12}),Pe.createElement(ug,null,l==="loading"&&Array.from(Array(_x),f=>Pe.createElement(Lx,{key:f,variant:"rounded",height:50})),l==="success"&&Pe.createElement(Pe.Fragment,null,Pe.createElement(Wi,{selected:!n,onClick:()=>{o==="from"?u():p()}},Pe.createElement(El,{variant:"body",size:"xsmall",color:"secondary500"},bl.t("All"))),s.list.map(f=>Pe.createElement(Px,{key:f.name,content:f.shortName,side:"bottom",sideOffset:2,container:W()},Pe.createElement(Wi,{key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},Pe.createElement(dg,{src:f.logo,size:30})))),m?Pe.createElement(Wi,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Pe.createElement(dg,{src:s.more[0].logo,size:30})):null,h?Pe.createElement(Wi,{onClick:a,key:"more-blockchains"},Pe.createElement(El,{variant:"body",size:"xsmall",color:"secondary500"},bl._("More +{count}",{count:s.more.length}))):null)))}i(Il,"BlockchainsSection");function Al(t){let{type:e}=t,o=Dx(),n=je(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:p,setToBlockchain:u}=O(),{getBalanceFor:c}=y(),[m,h]=$x(""),d=(e==="source"?r:a)?.name??"",g=y().blockchains({type:e}),C=y().tokens({type:e,blockchain:d,searchFor:m,getBalanceFor:c}),S=i(v=>{e==="source"?p(v):u(v)},"updateBlockchain"),T=i(v=>{e==="source"?s({token:v,meta:{blockchains:g,tokens:C}}):l({token:v,meta:{blockchains:g,tokens:C}})},"updateToken"),k={source:Bi.t("Source"),destination:Bi.t("Destination")};return vo.createElement(oe,{header:{title:Bi.t("Swap {type}",{type:k[e]})}},vo.createElement(ie,null,vo.createElement(Il,{blockchains:g,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o(D.blockchains),onChange:v=>{S(v)}}),vo.createElement(fg,{size:24}),vo.createElement(Ct,{value:m,autoFocus:!0,placeholder:Bi.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>h(""),onChange:v=>h(v.target.value)}),vo.createElement(fg,{size:16}),vo.createElement($n,{list:C,selectedBlockchain:d,searchedFor:m,type:e,onChange:v=>{T(v);let w=g.find(A=>v.blockchain===A.name);w&&S(w),n()}})))}i(Al,"SelectSwapItemsPage");import{i18n as Bl}from"@lingui/core";import{Alert as pb,Button as cb,styled as ub}from"@rango-dev/ui";import wo from"react";import{useInRouterContext as mb,useSearchParams as db}from"react-router-dom";import{i18n as kg}from"@lingui/core";import{Divider as Tg,InfoIcon as zx,SlippageIcon as Qx,TextField as qx,Tooltip as Hx,Typography as vg}from"@rango-dev/ui";import rt from"react";import{Chip as Fx,styled as Vn,TextField as Ox}from"@rango-dev/ui";var gg=Vn("div",{paddingTop:"$5",padding:"$10 $5"}),hg=Vn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${Ox}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),yg=Vn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Mi=Vn("div",{maxWidth:"280px",padding:"$10"}),Sg=Vn(Fx,{width:"61px",flexShrink:0});import{i18n as Nl}from"@lingui/core";import{Typography as Ux}from"@rango-dev/ui";import Kn from"react";function Cg(){return Kn.createElement(Mi,null,Kn.createElement(Ux,{variant:"label",size:"medium",color:"neutral700"},Nl.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Kn.createElement("br",null),Kn.createElement("br",null),Kn.createElement("b",null,Nl.t("Warning")),":\xA0",Nl.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(Cg,"SlippageTooltipContent");function Wl(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return rt.createElement(gg,null,rt.createElement(yg,null,rt.createElement(Qx,{size:16,color:"gray"}),rt.createElement(Tg,{direction:"horizontal",size:4}),rt.createElement(vg,{variant:"title",size:"xmedium"},kg.t("Slippage tolerance per swap")),rt.createElement(Tg,{direction:"horizontal",size:4}),rt.createElement(Hx,{container:W(),side:"top",sideOffset:4,content:rt.createElement(Cg,null)},rt.createElement(zx,{color:"gray"}))),rt.createElement(hg,null,Yp.map((r,a)=>{let s=`slippage-${a}`;return rt.createElement(Sg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),rt.createElement(qx,{type:"number",min:"0.01",max:"30",step:"0.01",fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:r=>{let a=r.target.value,s=parseFloat(a);s>=ec&&s<=Rp?n(s):n(null)},suffix:o&&rt.createElement(vg,{variant:"body",size:"small"},"%"),placeholder:kg.t("Custom")})))}i(Wl,"Slippage");import{i18n as mt}from"@lingui/core";import{AutoThemeIcon as wg,BridgesIcon as Gx,ChevronRightIcon as Li,DarkModeIcon as xg,Divider as jn,ExchangeIcon as Vx,InfinityIcon as Kx,InfoIcon as jx,LanguageIcon as Xx,LightModeIcon as bg,List as Yx,ListItem as Zx,ListItemButton as Jx,Skeleton as Rx,styled as eb,Switch as tb,Tabs as ob,TargetIcon as nb,Tooltip as rb,Typography as Ye}from"@rango-dev/ui";import $ from"react";import{useNavigate as ib}from"react-router-dom";var ab=eb("div",{width:"202px",height:"$40"}),sb=[{id:"light",icon:$.createElement(bg,{color:"black",size:24}),tooltip:$.createElement(Ye,{size:"xsmall",variant:"body"},mt.t("Light"))},{id:"dark",icon:$.createElement(xg,{color:"black",size:24}),tooltip:$.createElement(Ye,{size:"xsmall",variant:"body"},mt.t("Dark"))},{id:"auto",icon:$.createElement(wg,{color:"black",size:24}),tooltip:$.createElement(Ye,{size:"xsmall",variant:"body"},mt.t("Auto"))}],lb=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return $.createElement(wg,{...e});case"dark":return $.createElement(xg,{...e});default:return $.createElement(bg,{...e})}},"getThemeIcon");function Eg(){let t=ib(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=Rt(),s=a.find(P=>P.local===r)?.label,l=y().fetchStatus,p=y().swappers(),u=y().getDisabledLiquiditySources(),{config:{features:c}}=y(),m=y().customTokens(),h=Ve("theme",c),f=Ve("liquiditySource",c),d=Ve("language",c),g=Ve("customTokens",c),C=y().infiniteApprove,S=y().toggleInfiniteApprove,T=hr(p,u),k=T.filter(P=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(P.type)),v=k.length,w=k.filter(P=>P.selected).length,A=T.filter(P=>P.type==="DEX"),M=A.length,x=A.filter(P=>P.selected).length,E=i((P,X)=>{switch(l){case"loading":return $.createElement(Rx,{variant:"text",size:"medium",width:50});case"failed":return $.createElement(Ye,{variant:"body",size:"medium",color:"$error500"},mt.t("Loading failed"));default:return $.createElement(Ye,{variant:"body",size:"medium"},`${P} / ${X}`)}},"handleSwapperEndItem"),b={id:"widget-setting-bridge-item-btn",title:$.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Bridges")),end:$.createElement($.Fragment,null,E(w,v),$.createElement(jn,{direction:"horizontal",size:8}),$.createElement(Li,{color:"black"})),onClick:()=>t(D.bridges),start:$.createElement(Gx,{color:"gray",size:16})},N={id:"widget-setting-exchange-item-btn",title:$.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Exchanges")),end:$.createElement($.Fragment,null,E(x,M),$.createElement(jn,{direction:"horizontal",size:8}),$.createElement(Li,{color:"black"})),start:$.createElement(Vx,{color:"gray",size:16}),onClick:()=>t(D.exchanges)},I={id:"widget-setting-custom-tokens-item-btn",title:$.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Custom Tokens")),end:$.createElement($.Fragment,null,$.createElement(Ye,{variant:"body",size:"medium"},`${m.length}`),$.createElement(jn,{direction:"horizontal",size:8}),$.createElement(Li,{color:"black"})),start:$.createElement(nb,{color:"gray",size:16}),onClick:()=>t(D.customTokens)},B={id:"widget-setting-language-item-btn",title:$.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Language")),start:$.createElement(Xx,{color:"gray",size:16}),end:$.createElement($.Fragment,null,$.createElement(Ye,{variant:"body",size:"medium"},s),$.createElement(jn,{direction:"horizontal",size:8}),$.createElement(Li,{color:"black"})),onClick:()=>t(D.languages)},j={id:"widget-setting-infinite-approval-item-btn",title:$.createElement($.Fragment,null,$.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Infinite approval")),$.createElement(jn,{direction:"horizontal",size:4}),$.createElement(rb,{side:"top",sideOffset:4,container:W(),content:$.createElement(Mi,null,$.createElement(Ye,{variant:"label",size:"medium",color:"neutral700"},$.createElement("b",null,mt.t("Warning")),":\xA0",mt.t("Enabling the 'Infinite approval' mode grants unrestricted access to underlying smart contracts, allowing them to utilize the approved token amount without limitations.")))},$.createElement(jx,{color:"gray"}))),start:$.createElement(Kx,{color:"gray",size:16}),end:$.createElement(tb,{checked:C}),onClick:S},te={id:"widget-setting-theme-item-btn",type:$.createElement(Zx,null),title:$.createElement(Ye,{variant:"title",size:"xmedium"},mt.t("Theme")),end:$.createElement(ab,null,$.createElement(ob,{container:W(),items:sb,value:n,onChange:P=>o(P.id),type:"primary",borderRadius:"small"})),start:lb(n)},J=f?[]:[b,N];return g||J.push(I),d||J.push(B),J.push(j),!e?.singleTheme&&!h&&J.push(te),$.createElement(Yx,{type:$.createElement(Jx,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:J})}i(Eg,"SettingsLists");var fb=ub("div",{paddingLeft:"$8"});function Ig(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=db(),r=mb(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return wo.createElement(oe,{header:{title:Bl.t("Settings")}},wo.createElement(ie,null,o&&wo.createElement(pb,{type:"info",variant:"alarm",title:Bl.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:wo.createElement(fb,null,wo.createElement(cb,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Bl.t("Reset")))}),wo.createElement(Wl,null),wo.createElement(Eg,null)))}i(Ig,"SettingsPage");import{i18n as tE}from"@lingui/core";import{cancelSwap as oE}from"@rango-dev/queue-manager-rango-preset";import{useManager as nE}from"@rango-dev/queue-manager-react";import{Alert as rE}from"@rango-dev/ui";import Kl from"react";import{useParams as iE}from"react-router-dom";import{i18n as it}from"@lingui/core";import{getCurrentNamespaceOfOrNull as $b,getCurrentStep as Db,getRelatedWalletOrNull as Fb}from"@rango-dev/queue-manager-rango-preset";import{Button as ih,CopyIcon as Ob,Divider as Ub,DoneIcon as zb,IconButton as Qb,QuoteCost as qb,RangoExplorerIcon as Hb,StepDetails as Gb,Tooltip as ah,Typography as xo,useCopyToClipboard as Vb}from"@rango-dev/ui";import{useWallets as Kb}from"@rango-dev/wallets-react";import sh from"bignumber.js";import{PendingSwapNetworkStatus as zi}from"rango-types";import K,{useEffect as lh,useRef as jb,useState as ph}from"react";import{useNavigate as Xb}from"react-router-dom";import{i18n as eo}from"@lingui/core";var gb=[eo.t("Sunday"),eo.t("Monday"),eo.t("Tuesday"),eo.t("Wednesday"),eo.t("Thursday"),eo.t("Friday"),eo.t("Saturday")];function Ag(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?eo.t("Today"):`${gb[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Ag,"timeSince");function Ng(t){return t.finishTime?Ag(parseInt(t.finishTime)):Ag(parseInt(t.creationTime))}i(Ng,"getSwapDate");import{PendingSwapNetworkStatus as $i}from"rango-types";import Di from"react";import{i18n as Pi}from"@lingui/core";import{Button as Wg,Divider as Ml,MessageBox as hb}from"@rango-dev/ui";import to from"react";var Bg=i(({onCancel:t,onClose:e})=>to.createElement(to.Fragment,null,to.createElement(Ml,{size:20}),to.createElement(hb,{type:"error",title:Pi.t("Cancel Swap"),description:Pi.t("Are you sure you want to cancel this swap?")}),to.createElement(Ml,{size:32}),to.createElement(Wg,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Pi.t("Yes, Cancel it")),to.createElement(Ml,{size:12}),to.createElement(Wg,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Pi.t("No, Continue"))),"CancelContent");import{i18n as _i}from"@lingui/core";import{Button as Mg,Divider as Ll,MessageBox as yb,Typography as Sb}from"@rango-dev/ui";import qt from"react";var Lg=i(({onDelete:t,onClose:e})=>qt.createElement(qt.Fragment,null,qt.createElement(Ll,{size:20}),qt.createElement(yb,{type:"error",title:_i.t("Delete Transaction"),description:_i.t("Are you sure you want to delete this swap?")}),qt.createElement(Ll,{size:32}),qt.createElement(Mg,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},_i.t("Yes, Delete it")),qt.createElement(Ll,{size:12}),qt.createElement(Mg,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},qt.createElement(Sb,{variant:"title",size:"medium",color:"primary"},_i.t("No, Cancel")))),"DeleteContent");import{i18n as Pl}from"@lingui/core";import{PendingSwapNetworkStatus as _l}from"rango-types";var $l={[_l.WaitingForNetworkChange]:{type:"loading",title:Pl.t("Change Network")},[_l.WaitingForConnectingWallet]:{type:"warning",title:Pl.t("Connect Wallet")},[_l.NetworkChanged]:{type:"success",title:Pl.t("Network Changed")}};import{warn as Cb}from"@rango-dev/logging-core";import{MessageBox as kb,Wallet as Tb}from"@rango-dev/ui";import{useWallets as vb}from"@rango-dev/wallets-react";import Jo,{useState as wb}from"react";import{styled as Pg}from"@rango-dev/ui";var _g=Pg("div",{display:"flex",justifyContent:"center"}),s5=Pg("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}});var $g=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,p]=wb(),{getWalletInfo:u,state:c}=vb(),m=n?.walletType,h=m?ln(c(m)):null,f=m?u(m):null,d=a&&!!m&&!!h&&!!f,{list:g}=ft(),C=i(()=>{if(m){let S=g.find(T=>T.type===m);S?p(S):Cb(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${S}`))}},"handleWalletItemClick");return Jo.createElement(Jo.Fragment,null,Jo.createElement(kb,{type:e,title:o,description:r}),d&&Jo.createElement(_g,null,Jo.createElement(Tb,{container:W(),title:f.name,image:f.img,type:m,state:h,link:f.installLink,disabled:s,onClick:C})),Jo.createElement(co,{wallet:l,onClose:()=>{p(void 0)}}))},"WalletStateContent");function Dl(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,p=e===$i.WaitingForNetworkChange||e===$i.WaitingForConnectingWallet||e===$i.NetworkChanged;return Di.createElement(Z,{open:!!e,onClose:o,container:document.getElementById($e.SWAP_BOX_ID)||document.body},p&&Di.createElement($g,{type:$l[e].type,title:$l[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==$i.WaitingForNetworkChange}),e==="delete"&&Di.createElement(Lg,{onClose:o,onDelete:n}),e==="cancel"&&Di.createElement(Bg,{onClose:o,onCancel:r}))}i(Dl,"SwapDetailsModal");import{i18n as Xn}from"@lingui/core";import{Button as Fl,Divider as Yn,MessageBox as Dg,TokenAmount as xb,Typography as Fg}from"@rango-dev/ui";import Ce from"react";import{useNavigate as bb}from"react-router-dom";function Ol(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:p,chain:u,percentageChange:c,description:m,diagnosisUrl:h}=t,f=bb(),{showProfileBanner:d}=re();return Ce.createElement(Z,{open:e,onClose:o,container:document.getElementById($e.SWAP_BOX_ID)||document.body},n==="success"?Ce.createElement(Dg,{type:"success",title:Xn.t("Swap Successful")},Ce.createElement(xb,{direction:"vertical",tooltipContainer:W(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:p,chain:u,percentageChange:c}),Ce.createElement(Yn,{size:12}),Ce.createElement(Fg,{variant:"body",size:"medium",color:"neutral700",align:"center"},m)):Ce.createElement(Dg,{type:"error",title:Xn.t("Transaction Failed"),description:m}),Ce.createElement(Yn,{size:30}),n==="success"&&Ce.createElement(Ce.Fragment,null,d&&Ce.createElement(Ce.Fragment,null,Ce.createElement("img",{src:"https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.png",alt:"Profile Banner"}),Ce.createElement(Yn,{size:30})),Ce.createElement(Fl,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{f("../../")}},Xn.t("Done"))),Ce.createElement(Yn,{size:12}),h&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Fl,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(h,"_blank")},Xn.t("Diagnosis")),Ce.createElement(Yn,{size:12})),Ce.createElement(Fl,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},Ce.createElement(Fg,{variant:"title",size:"medium",color:"primary"},Xn.t("See Details"))))}i(Ol,"SwapDetailsCompleteModal");import _b from"react";import{i18n as Bb}from"@lingui/core";import{Alert as th,IconButton as Mb,LinkIcon as Lb}from"@rango-dev/ui";import oo,{Fragment as Pb}from"react";import{Alert as Ib,ChevronDownIcon as Ab,IconButton as Nb}from"@rango-dev/ui";import en,{useState as Wb}from"react";import{css as Zn,darkTheme as Og,styled as Ht,Typography as Eb}from"@rango-dev/ui";var Ug=Ht("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Fi=Ht("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${Og} &`]:{color:"$secondary500"}}}}}),zg=Ht(Cn,{padding:"$0 $20 $20 $20"}),G5=Ht("div",{display:"flex",flexDirection:"column",gap:"$10"}),Qg=Ht("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),V5=Ht("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),Ro=Zn({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${Og} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),qg=Zn({padding:"$5 0"}),Oi=Zn({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Hg=Zn({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),Gg=Zn({width:"100%",padding:"0 $20 $10"}),Vg=Ht("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),Kg=Ht("div",{display:"flex",flexDirection:"column",gap:"$5"}),Ui=Ht(Eb,{wordBreak:"break-word"});import{styled as Ul}from"@rango-dev/ui";var jg=Ul("div",{display:"flex",flexDirection:"column",gap:"$10"}),Xg=Ul("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),Yg=Ul("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function Zg(t){let{message:e}=t,[o,n]=Wb(!1);return en.createElement(Ib,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&en.createElement(Nb,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},en.createElement(Xg,{rotated:o},en.createElement(Ab,{size:12,color:"gray"}))),footer:en.createElement(Yg,{open:o},en.createElement(Ui,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(Zg,"FailedAlert");import{i18n as Jg}from"@lingui/core";import{Alert as zl,Button as Rg}from"@rango-dev/ui";import{PendingSwapNetworkStatus as Ql}from"rango-types";import Jn from"react";function eh(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?Jn.createElement(zl,{type:"warning",title:n.shortMessage,action:Jn.createElement(Rg,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Ql.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},Jg.t("Change"))}):r===Ql.WaitingForConnectingWallet?Jn.createElement(zl,{type:"warning",title:n.shortMessage,action:Jn.createElement(Rg,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(Ql.WaitingForConnectingWallet)}},Jg.t("Connect"))}):Jn.createElement(zl,{type:"warning",title:n.shortMessage})}i(eh,"WarningAlert");function ql(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=yn(a),p=a.status==="waitingForApproval"&&!l,u=a.status==="running"&&!l,c=u&&!s||p&&!a.explorerUrl?.length;return oo.createElement(jg,null,a.explorerUrl?.map((m,h,f)=>{let d=h+m.url,g=h===f.length-1,C=(g&&u||p)&&!c,S=g&&a.status==="failed";return oo.createElement(Pb,{key:d},oo.createElement(th,{type:g&&(C&&"loading"||S&&"error")||"success",title:m.description?`${m.description} Tx`:Bb.t("View transaction"),action:m.url&&oo.createElement(Mb,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(m.url,"_blank")},oo.createElement(Lb,{size:12}))}))}),c&&oo.createElement(th,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&oo.createElement(eh,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&oo.createElement(Zg,{message:r}))}i(ql,"SwapDetailsAlerts");var oh=2e3;var nh=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let l=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:st(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:L(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:st(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:L(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:on(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(p=>({from:{chain:{displayName:st(p.fromBlockchain,e)??"",image:p.fromBlockchainLogo??""}},to:{chain:{displayName:st(p.toBlockchain,e)??"",image:p.toBlockchainLogo??""}},swapper:{displayName:on(p.swapperId,o)??"",image:p.swapperLogo??"",type:p.swapperType}})):[],alerts:_b.createElement(ql,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function rh(t){if(yn(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(rh,"getStepState");function Hl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=Kb(),p=y().blockchains(),u=y().swappers(),{findToken:c}=y(),m=O.use.retry(),h=re.use.isActiveTab(),f=Xb(),[d,g]=Vb(oh),C=jb(null),[S,T]=ph(null),[k,v]=ph(null),w=i(()=>{r(),T(null)},"onCancel"),A=xe.use.getNotifications(),M=xe.use.removeNotification(),x=A(),E=Db(e),b=E?.networkStatus;lh(()=>{x.find(dt=>dt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),M(e.requestId)):k&&v(null))},[e.status,e.requestId]),lh(()=>{P?T(zi.WaitingForNetworkChange):b===zi.WaitingForConnectingWallet||b===zi.NetworkChanged?T(b):T(null)},[b]);let N=lu(e),I=E?$b(e,E):null,B=E?Fb(e,E):null,j=Ng(e),te=pu(e),J=i(ve=>!!l(ve)?.mobileWallet,"isMobileWallet"),P=b===zi.WaitingForNetworkChange&&!!I&&!!B?.walletType&&(J(B.walletType)||a(B.walletType,I.network)),X=P?s.bind(null,B.walletType,[{namespace:I.namespace,network:I.network}]):void 0,se=su(e,E),z=nh({swap:e,switchNetwork:X,showNetworkModal:b,setNetworkModal:T,message:se,blockchains:p,swappers:u}),me=z.length,[vt,Ze]=[e.steps[0],e.steps[me-1]],le=Ze.outputAmount||Ze.expectedOutputAmountHumanReadable,at=e.steps.reduce((ve,dt)=>ve+parseFloat(dt.feeInUsd||""),0),G=e.steps.find(ve=>ve.diagnosisUrl)?.diagnosisUrl,_=L(parseFloat(le||"0")*(Ze.toUsdPrice||0),4,4),H=L(parseFloat(e.inputAmount)*(vt.fromUsdPrice||0),4,4),V=le?new sh(le).multipliedBy(Ze.toUsdPrice||0).toString():"",de=new sh(e.inputAmount).multipliedBy(vt.fromUsdPrice||0).toString(),ne=Pt(H,_),fe=se.detailedMessage.content||se.shortMessage,Fe=e.status==="success"?it.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:L(le,6,6),token:z[me-1].to.token.displayName,conciseAddress:fr(e.wallets[z[me-1].to.chain.displayName]?.address||""),chain:z[me-1].to.chain.displayName}}):K.createElement(Kg,null,K.createElement(xo,{variant:"body",size:"medium",color:"neutral700",align:"center"},fe?"":it.t("Transaction was not sent."),N?`${it.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:N.outputAmount,symbol:N.symbol,blockchain:N.blockchain}})}`:""),fe&&K.createElement(Ui,{align:"center",variant:"body",size:"medium",color:"neutral700"},K.createElement("b",null,"Reason:")," ",fe));return K.createElement(oe,{header:{title:it.t("Swap Details"),onCancel:e.status==="running"?()=>T("cancel"):void 0,suffix:e.status!=="running"&&K.createElement(Vt,null,K.createElement(ih,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>T("delete")},K.createElement(xo,{size:"medium",variant:"label",color:"error"},it.t("Delete"))))},footer:te&&!k&&K.createElement(ih,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let ve=Nr(e,p,c);m(ve),setTimeout(()=>{f("../../")},0)}},it.t("Try again"))},K.createElement(ie,{compact:!0,view:!0},K.createElement(Fi,null,K.createElement("div",{className:Ro()},K.createElement(xo,{variant:"label",size:"large",color:"neutral700"},`${it.t("Request ID")}`),K.createElement("div",{className:Oi()},K.createElement(xo,{variant:"label",size:"small",color:"neutral700"},o),K.createElement(ah,{container:W(),content:d?it.t("Copied To Clipboard"):it.t("Copy Request ID"),open:d||void 0,side:"bottom",alignOffset:-16,align:"end"},K.createElement(Qb,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:g.bind(null,o||"")},d?K.createElement(zb,{size:16,color:"secondary"}):K.createElement(Ob,{size:16,color:"gray"}))),K.createElement(Vg,{target:"_blank",href:`${hp}/swap/${o}`},K.createElement(ah,{container:W(),content:it.t("View on Rango Explorer"),side:"bottom"},K.createElement(Hb,{size:20}))))),K.createElement("div",{className:Ro()},K.createElement(xo,{variant:"label",size:"large",color:"neutral700"},e.finishTime?it.t("Finished at"):it.t("Created at")),K.createElement(xo,{variant:"label",size:"small",color:"neutral700"},j))),K.createElement("div",{className:Hg()},K.createElement(qb,{fee:L(String(at),2,2),time:an(lr(e.steps)),steps:me}),K.createElement(In,{from:{price:{value:L(e.inputAmount,6,6),usdValue:H,realUsdValue:de,realValue:e.inputAmount},token:{displayName:z[0].from.token.displayName,image:z[0].from.token.image},chain:{image:z[0].from.chain.image,displayName:z[0].from.chain.displayName}},to:{price:{value:L(le,6,6),usdValue:_,realUsdValue:V,realValue:le||""},token:{displayName:z[me-1].to.token.displayName,image:z[me-1].to.token.image},chain:{image:z[me-1].to.chain.image,displayName:z[me-1].to.chain.displayName}},percentageChange:L(ne,2,2),warningLevel:_t(ne??0)})),K.createElement("div",{className:Gg()},K.createElement(xo,{variant:"title",size:"small"},it.t("Swaps steps"))),K.createElement(Ub,{size:8}),K.createElement(zg,{ref:C},z.map((ve,dt)=>{let ep=dt,tn=rh(e.steps[dt]),Dh=tn==="error"||tn==="in-progress"||tn==="warning"||tn==="completed"&&dt===z.length-1;return K.createElement(Gb,{key:ep,step:ve,type:"swap-progress",ref:C,state:tn,hasSeparator:dt!==0,tabIndex:ep,isFocused:Dh,tooltipContainer:W()})}))),K.createElement(Dl,{state:S,onClose:()=>T(null),onCancel:w,onDelete:n,message:se.detailedMessage.content,currentStepWallet:B,walletButtonDisabled:!h}),K.createElement(Ol,{open:!!k,diagnosisUrl:G,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:L(le,6,6),usdValue:_,realUsdValue:V,realValue:le||"",percentageChange:L(ne,2,2),token:{displayName:z[me-1].to.token.displayName,image:z[me-1].to.token.image},chain:{image:z[me-1].to.chain.image},description:Fe}))}i(Hl,"SwapDetails");import{i18n as qi}from"@lingui/core";import{Divider as mh,NotFound as eE,Skeleton as er,Typography as Hi}from"@rango-dev/ui";import ke from"react";import{i18n as Yb}from"@lingui/core";import{Divider as Zb,Skeleton as Jb,Typography as Rb}from"@rango-dev/ui";import Te from"react";import{css as Tt,styled as Gl}from"@rango-dev/ui";var ch=Gl("div",{width:"100%",height:"100%",padding:"$10 $20"}),Rn=Gl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Qi=Gl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),rK=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),iK=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),aK=Tt({paddingTop:"$15",display:"flex"}),sK=Tt({padding:"$15 $0"}),lK=Tt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),pK=Tt({paddingBottom:"$10"}),cK=Tt({display:"flex",justifyContent:"start",alignItems:"center"}),uK=Tt({paddingTop:"$5",display:"flex",alignItems:"center"}),mK=Tt({display:"flex",alignItems:"center"}),dK=Tt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),uh=Tt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Vl(){return Te.createElement(ch,null,Te.createElement(Wn,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(Rb,{variant:"title",size:"small"},Yb.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(Rn,null,Te.createElement(Nt,{separator:!1}),Te.createElement("div",{className:uh()},Te.createElement(Zb,{direction:"horizontal",size:20}),Te.createElement(Jb,{height:22,variant:"rectangular"}))),Te.createElement(Qi,null),Te.createElement(Rn,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Qi,null),Te.createElement(Rn,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Qi,null),Te.createElement(Rn,null,Te.createElement(Nt,{separator:!1}))))}i(Vl,"LoadingSwapDetails");function dh(t){let{requestId:e,showSkeleton:o}=t;return ke.createElement(oe,{header:{title:qi.t("Swap Details"),suffix:ke.createElement(Vt,null)}},o&&ke.createElement(Ug,null,ke.createElement(Fi,null,ke.createElement("div",{className:Ro()},ke.createElement(Hi,{variant:"label",size:"large",color:"neutral700"},`${qi.t("Request ID")}`),ke.createElement("div",{className:Oi()},ke.createElement(Hi,{variant:"label",size:"small",color:"neutral700"},ke.createElement(er,{width:60,height:10,variant:"rounded"})),ke.createElement(mh,{direction:"horizontal",size:4}),ke.createElement(er,{width:16,height:16,variant:"rectangular"}),ke.createElement(mh,{direction:"horizontal",size:4}),ke.createElement(er,{width:16,height:16,variant:"rectangular"}))),ke.createElement("div",{className:Ro()},ke.createElement(Hi,{className:qg(),variant:"label",size:"large",color:"neutral700"},ke.createElement(er,{width:60,height:10,variant:"rounded"})),ke.createElement(Hi,{variant:"label",size:"small",color:"neutral700"},ke.createElement(er,{width:60,height:10,variant:"rounded"})))),ke.createElement(Vl,null)),!o&&ke.createElement(Qg,null,ke.createElement(eE,{title:qi.t("Not found"),description:qi.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(dh,"SwapDetailsPlaceholder");function fh(){let{manager:t,state:e}=nE(),o=!e.loadedFromPersistor,n=ct(t),{requestId:r}=iE(),a=je(),{fetchStatus:s}=y();if(!r)return Kl.createElement(rE,{containerStyles:{margin:"20px"},type:"error",title:tE.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",p=r?n.find(({swap:h})=>h.requestId===r):void 0,u=i(()=>{if(p?.id){let h=t?.get(p.id);h&&oE(h)}},"onCancel"),c=i(async()=>{if(p?.id)try{t?.deleteQueue(p.id),a()}catch(h){console.log(h)}},"onDelete"),m=p?.swap;return!m||l?Kl.createElement(dh,{requestId:r,showSkeleton:l}):Kl.createElement(Hl,{swap:m,requestId:r,onCancel:u,onDelete:c})}i(fh,"SwapDetailsPage");import{i18n as gh}from"@lingui/core";import{Divider as aE,getCategoriesCount as sE,SelectableCategoryList as lE,styled as yh,Typography as pE,Wallet as cE}from"@rango-dev/ui";import Bt,{useState as hh}from"react";var uE=yh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),mE=yh(ie,{textAlign:"center"});function Sh(){let{fetchStatus:t}=y(),[e,o]=hh("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=hh(),l=re.use.isActiveTab(),{list:p}=ft(),u=Fp(p,n),m=sE(u)!==1,h=Op(p,e),f=i(d=>{Ip(p,r.multiWallets)||s(d)},"handleWalletItemClick");return Bt.createElement(oe,{header:{title:gh.t("Connect Wallets")}},Bt.createElement(mE,null,m&&Bt.createElement(Bt.Fragment,null,Bt.createElement(lE,{setCategory:o,category:e,blockchains:u,isLoading:t==="loading"}),Bt.createElement(aE,{size:24})),Bt.createElement(pE,{variant:"title",size:"xmedium",align:"center"},gh.t("Choose a wallet to connect.")),Bt.createElement(uE,null,h.map((d,g)=>{let C=`wallet-${g}-${d.type}`;return Bt.createElement(cE,{key:C,...d,container:W(),onClick:()=>f(d),isLoading:t==="loading",disabled:!l})}),Bt.createElement(co,{wallet:a,onClose:()=>{s(void 0)}}))))}i(Sh,"WalletsPage");function Ch(){return du(),Pa(),dE([{path:D.home,element:_e.createElement(jf,null)},{path:D.routes,element:_e.createElement(Rf,null)},{path:D.fromSwap,children:[{index:!0,element:_e.createElement(Al,{type:"source"})},{path:D.blockchains,element:_e.createElement(Ni,{type:"source"})}]},{path:D.toSwap,children:[{index:!0,element:_e.createElement(Al,{type:"destination"})},{path:D.blockchains,element:_e.createElement(Ni,{type:"destination"})}]},{path:D.settings,children:[{index:!0,element:_e.createElement(Ig,null)},{path:D.languages,element:_e.createElement(Yf,null)},{path:D.exchanges,element:_e.createElement(kl,{sourceType:"Exchanges"})},{path:D.bridges,element:_e.createElement(kl,{sourceType:"Bridges"})},{path:D.customTokens,children:[{index:!0,element:_e.createElement(nf,null)},{path:D.addCustomTokens,children:[{index:!0,element:_e.createElement(ju,null)},{path:D.blockchains,element:_e.createElement(Ni,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:D.swaps,children:[{index:!0,element:_e.createElement(xf,null)},{path:D.swapDetails,element:_e.createElement(fh,null)}]},{path:D.wallets,element:_e.createElement(Sh,null)},{path:D.confirmSwap,element:_e.createElement(qd,null)}])}i(Ch,"AppRoutes");import{useQueueManager as vE}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as wE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as xE}from"rango-sdk";import{useContext as bE,useEffect as Eh,useState as Ih}from"react";import{globalCss as fE}from"@rango-dev/ui";var kh=i(()=>fE({"@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");function Th(){let{setWatermark:t,setShowProfileBanner:e}=re();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Lt("BASE_URL")}/meta/dapp/config?apiKey=${Lt("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(Th,"useFetchApiConfig");import{useWallets as gE}from"@rango-dev/wallets-react";import{useEffect as hE,useRef as yE}from"react";function vh(){let{connect:t,state:e}=gE(),o=yE({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);hE(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(vh,"useForceAutoConnect");import{isApprovalTX as SE,RouteEventType as wh,StepEventType as xh,StepExecutionEventStatus as CE,WidgetEvents as Gi}from"@rango-dev/queue-manager-rango-preset";import{useEffect as bh}from"react";function jl(){let t=xe.use.setNotification(),{connectedWallets:e,fetchBalances:o}=y();bh(()=>{let n=i(r=>{let{event:a,step:s,route:l}=r;if(a.type===xh.TX_EXECUTION&&a.status===CE.TX_SENT&&!SE(s)||a.type===xh.SUCCEEDED){let u=e.find(m=>m.chain===s?.fromBlockchain),c=s?.fromBlockchain!==s?.toBlockchain&&e.find(m=>m.chain===s?.toBlockchain);u&&o([u]),c&&o([c])}t(a,l)},"handleStepEvent");return he.on(Gi.StepEvent,n),()=>he.off(Gi.StepEvent,n)},[he,e]),bh(()=>{let n=i(r=>{let{event:a,route:s}=r;(a.type===wh.FAILED||a.type===wh.SUCCEEDED)&&t(a,s)},"handleRouteEvent");return he.on(Gi.RouteEvent,n),()=>he.off(Gi.RouteEvent,n)},[he])}i(jl,"useSubscribeToWidgetEvents");import{useManager as kE}from"@rango-dev/queue-manager-react";import{useEffect as TE}from"react";function Xl(){let{isSynced:t,syncNotifications:e}=xe(),{manager:o,state:n}=kE();TE(()=>{xe.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(ct(o))},[xe.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Xl,"useSyncNotifications");function Yl(){vh(),kh(),jl(),Xl();let t=y().blockchains(),{canSwitchNetworkTo:e}=jr(),[o,n]=Ih(""),[r,a]=Ih(),s=bE(br),l=t.filter(xE),{fetchApiConfig:p}=Th();Eh(()=>()=>mu(),[]),vE({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),Eh(()=>(ao.init(),xe.persist.hasHydrated()||xe.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(u=>{a(u),u===wE(o)?.[0]&&n("")}),p().catch(console.log),ao.destroy),[])}i(Yl,"useBootstrap");import{styled as EE}from"@rango-dev/ui";var Ah=EE("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Vi(){Yl();let{config:t}=y(),{activeTheme:e}=Uo(t?.theme||{}),{activeLanguage:o}=Rt();return Zl.createElement(IE,{language:o},Zl.createElement(Ah,{id:"swap-container",className:e()},Zl.createElement(Ch,null)))}i(Vi,"Main");import{setSolanaSignerConfig as KE}from"@rango-dev/signer-solana";import Rl,{useEffect as Ph,useMemo as jE}from"react";import{useState as AE}from"react";var NE=i(()=>{let[t,e]=AE(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=Ep(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),Nh=NE;import{checkWaitingForNetworkChange as WE,makeQueueDefinition as BE}from"@rango-dev/queue-manager-rango-preset";import{Provider as ME}from"@rango-dev/queue-manager-react";import{useWallets as LE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as PE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as _E}from"rango-types";import $E,{useMemo as DE}from"react";function FE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=LE(),l=DE(()=>BE({API_KEY:t.apiKey||Lt("API_KEY"),BASE_URL:Lt("BASE_URL"),emitter:{emit:he.emit}}),[t.apiKey]),{blockchains:p,connectedWallets:u}=y(),c=p(),m={blockchains:u.map(v=>({accounts:[v],name:v.chain}))},h=i(async(v,w)=>a(v,w.network)?await r(v,[w]):void 0,"switchNetwork"),f=i(v=>!!s(v).mobileWallet,"isMobileWallet"),d=c.filter(v=>v.enabled).reduce((v,w)=>(v[w.name]=w,v),{}),g=c.filter(_E),C=i(v=>{let{supportedChains:w}=s(v);return ur(w)},"getSupportedChainNames"),S=e(),T={meta:{blockchains:d,evmBasedChains:g,evmNetworkChainInfo:PE(g),getSupportedChainNames:C},getSigners:o,wallets:m,providers:S,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:f},k=re.use.isActiveTab();return $E.createElement(ME,{queuesDefs:[l],context:T,onPersistedDataLoaded:v=>{WE(v)},isPaused:!k},t.children)}i(FE,"QueueManager");var Wh=FE;import{useManager as qE}from"@rango-dev/queue-manager-react";import HE,{createContext as GE,useContext as VE}from"react";function Bh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=O();return i(u=>{let{fromBlockchain:c,fromToken:m,toBlockchain:h,toToken:f,requestAmount:d}=u,g={blockchains:e,tokens:o};if(c!==void 0){let C=e.find(S=>S.name===c)??null;n(C)}if(m!==void 0){let C=m?t(m)??null:null;r({meta:g,token:C})}if(h!==void 0){let C=e.find(S=>S.name===h)??null;a(C)}if(f!==void 0){let C=f?t(f)??null:null;s({meta:g,token:C})}d!==void 0&&l(d)},"updateQuoteInputs")}i(Bh,"useUpdateQuoteInputs");import{cancelSwap as OE,getCurrentNamespaceOfOrNull as UE,getCurrentStep as zE,getRelatedWalletOrNull as QE}from"@rango-dev/queue-manager-rango-preset";var Ki=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return ct(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=Nr(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&OE(o)}getCurrentStepInfo(e){let o=zE(e);return{step:o,wallet:o?QE(e,o):null,network:o?UE(e,o)?.network:null}}};var Mh=GE(void 0);function Jl(t){let{manager:e}=qE(),o=re.use.isActiveTab(),n=O.use.retry(),{findToken:r,connectedWallets:a,getBalances:s,fetchBalances:l}=y(),p=new Ki(e,{retrySwap:n,findToken:r}),{fetchingWallets:u}=y(),c=Mp(s()),m=y().blockchains(),h=y().tokens(),f=y().swappers(),d=y().fetchStatus,g=Rt().resetLanguage,C=xe().getNotifications(),S=xe().clearNotifications,T=Bh(),{fromBlockchain:k,toBlockchain:v,fromToken:w,toToken:A,inputAmount:M}=O(),x={isActiveTab:o,setCurrentTabAsActive:ao.forceClaim,history:p,wallets:{isLoading:u,details:a,totalBalance:c,refetch:async E=>l(E)},meta:{blockchains:m,tokens:h,swappers:f,loadingStatus:d,findToken:r},resetLanguage:g,notifications:{list:C,clearAll:S},quote:{quoteInputs:{fromBlockchain:k?.name??null,fromToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,toBlockchain:v?.name??null,toToken:A?{symbol:A.symbol,blockchain:A.blockchain,address:A.address}:null,requestAmount:M},updateQuoteInputs:T}};return HE.createElement(Mh.Provider,{value:x},t.children)}i(Jl,"WidgetInfo");function Lh(){let t=VE(Mh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Lh,"useWidget");function ji(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=Nh();return Ph(()=>{n&&r(n)},[n]),jE(()=>{Up({API_KEY:o?.apiKey||ir,BASE_URL:o?.apiUrl||gp})},[o.apiKey,o.apiUrl]),Ph(()=>{t.config?.signers?.customSolanaRPC&&KE("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),Rl.createElement(Er,{config:o,onUpdateState:e},Rl.createElement(Wh,{apiKey:o.apiKey},Rl.createElement(Jl,null,t.children)))}i(ji,"WidgetProvider");function _h(t){let e=t.config?.externalWallets;return Xi.createElement(Pc,null,e?Xi.createElement(Vi,null):Xi.createElement(ji,{config:t.config??rr},Xi.createElement(Vi,null)))}i(_h,"Widget");function $h(){let{on:t,off:e}=he;return{on:t,off:e}}i($h,"useWidgetEvents");var k3={DerivationPath:dn,Namespaces:mn,isOnDerivationPath:gn,isOnNamespace:fn};export{Vj as EventSeverity,Wo as MainEvents,o3 as Networks,i3 as PendingSwapNetworkStatus,ca as QuoteEventTypes,Kj as RouteEventType,ea as SUPPORTED_FONTS,k3 as StatefulConnect,jj as StepEventType,Xj as StepExecutionBlockedEventStatus,Yj as StepExecutionEventStatus,$e as UI_ID,ma as UiEventTypes,ua as WalletEventTypes,e3 as WalletEvents,n3 as WalletTypes,_h as Widget,Wo as WidgetEvents,ji as WidgetProvider,Er as WidgetWallets,Va as customizedThemeTokens,Jj as readAccountAddress,Gt as useStatefulConnect,ft as useWalletList,jr as useWallets,Lh as useWidget,$h as useWidgetEvents,Uy as widgetEventEmitter};
|
|
1
|
+
var Fh=Object.defineProperty;var i=(t,e)=>Fh(t,"name",{value:e,configurable:!0});import{EventSeverity as Kj,RouteEventType as jj,StepEventType as Xj,StepExecutionBlockedEventStatus as Yj,StepExecutionEventStatus as Zj}from"@rango-dev/queue-manager-rango-preset";import{legacyReadAccountAddress as Rj}from"@rango-dev/wallets-core/legacy";import{useWallets as jr,Events as t3}from"@rango-dev/wallets-react";import{Networks as n3,WalletTypes as r3}from"@rango-dev/wallets-shared";import{PendingSwapNetworkStatus as a3}from"rango-types";import{Divider as BS}from"@rango-dev/ui";import co,{useEffect as MS,useRef as LS,useState as Np}from"react";import{WalletState as Oh}from"@rango-dev/ui";import{useWallets as Uh}from"@rango-dev/wallets-react";import{useReducer as zh}from"react";function oc(t){return!!t.derivationPath}i(oc,"isStateOnDerivationPathStep");function nc(t){return!!t.namespace}i(nc,"isStateOnNamespace");var nr={status:"init",namespace:null,derivationPath:null};function rc(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"reset":return nr;case"resetDerivation":return t.namespace?{...t,derivationPath:null,status:"namespace"}:nr;default:throw new Error("Action hasn't been defined.")}}i(rc,"reducer");function Gt(){let{state:t,disconnect:e,connect:o}=Uh(),[n,r]=zh(rc,nr),a=i(async(p,d,h)=>{r({type:"reset"});try{let f=d?.map(m=>({...m,network:void 0}));return await o(p,f),{status:"connected"}}catch(f){let m=f?.message?`Error: ${f.message}`:"An unknown error happened during connecting wallet.";throw new Error(m,{cause:f})}},"runConnect"),s=i(async(p,d)=>{if(p.state===Oh.DISCONNECTED){if(!!p.isHub&&p.properties?.find(T=>T.name==="detached")&&p.state!=="connected")return r({type:"needsNamespace",payload:{targetWallet:p}}),{status:"namespace"};if(!p.needsNamespace)return await a(p.type,void 0,d);let m=p.needsNamespace.data.length>1,g=p.needsDerivationPath;if(m)return r({type:"needsNamespace",payload:{targetWallet:p}}),{status:"namespace"};if(g){let C=p.needsNamespace.data[0];return r({type:"needsDerivationPath",payload:{providerType:p.type,providerImage:p.image,namespace:C.value}}),{status:"derivation-path"}}return await a(p.type,p.needsNamespace?.data.map(C=>({namespace:C.value})),d)}return d?.disconnectIfConnected?(await u(p.type),{status:"disconnected"}):{status:"disconnected-unhandled"}},"handleConnect"),l=i(async(p,d)=>{let h=p.needsNamespace?.selection==="single",f=p.needsDerivationPath,m=d[0];if(!m)throw new Error("To confirm a namespace, you should select at least one namespace.");if(h&&f)return r({type:"needsDerivationPath",payload:{providerType:p.type,providerImage:p.image,namespace:m}}),{status:"derivation-path"};if(!nc(n))throw new Error("Something went wrong on handling namespace. Please retry.");let g=n.namespace.targetWallet.type,C=d.map(S=>({namespace:S}));return await a(g,C)},"handleNamespace"),c=i(async p=>{if(!p)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");if(!oc(n))throw new Error("It seems you are filling derivation path without setting namespace before doing that. Please retry to connect.");let d=n.derivationPath.providerType,f=[{namespace:n.derivationPath.namespace,derivationPath:p}];return await a(d,f)},"handleDerivationPath"),u=i(async p=>{let d=t(p);return d.connected||d.connecting?(await e(p),{status:"disconnected"}):{status:"noop"}},"handleDisconnect");return{handleConnect:s,handleDisconnect:u,handleNamespace:l,handleDerivationPath:c,getState:()=>n,resetState:p=>{r(p==="derivation"?{type:"resetDerivation"}:{type:"reset"})}}}i(Gt,"useStatefulConnect");import{WalletState as ga}from"@rango-dev/ui";import{useWallets as Xy}from"@rango-dev/wallets-react";import{detectMobileScreens as Yy,KEPLR_COMPATIBLE_WALLETS as Zy,WalletTypes as dn}from"@rango-dev/wallets-shared";import{useCallback as Jy,useEffect as Ry}from"react";import Hy,{createContext as Gy,useContext as Vy,useEffect as Ky,useRef as jy}from"react";import{create as Qy}from"zustand";import{persist as qy}from"zustand/middleware";import{allProviders as Qh}from"@rango-dev/provider-all";var Zi=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()}},xo=new Zi;import{defineVersions as ic,pickVersion as ac,Provider as Ji}from"@rango-dev/wallets-core";function sc({allProviders:t,configWallets:e,options:o}){if(e){let n=[];return e.forEach(r=>{if(typeof r=="string"){let a=t.find(s=>{let l=lc(s,o);return l instanceof Ji?l.id===r:l.config.type===r});a?n.push(a):console.warn(`Couldn't find ${r} provider. Please make sure you are passing the correct name.`)}else r instanceof Ji?n.push(ic().version("1.0.0",r).build()):n.push(ic().version("0.0.0",r).build())}),n}return t}i(sc,"matchAndGenerateProviders");function lc(t,e){let{experimentalWallet:o="enabled"}=e||{},n=o=="disabled"?"0.0.0":"1.0.0";try{return ac(t,n)[1]}catch{return ac(t,"0.0.0")[1]}}i(lc,"pickProviderVersionWithFallbackToLegacy");function cc(t,e){return t.map(n=>lc(n,e)).map(n=>n instanceof Ji?n.id:n.config.type)}i(cc,"configWalletsToWalletName");function rr(t,e){return e.find(o=>o.name===t)?.displayName}i(rr,"getBlockchainDisplayNameFor");function st(t,e){return e.find(o=>o.name===t)?.shortName}i(st,"getBlockchainShortNameFor");function pc(t,e){return e.find(o=>o.name===t)?.logo}i(pc,"getBlockchainImage");function on(t,e){return e.find(o=>o.id===t)?.title}i(on,"getSwapperDisplayName");function nn(t,e){return e.find(o=>o.name===t)??null}i(nn,"findBlockchain");function Ri(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(Ri,"isTokenNative");function lt(t){return`${t.blockchain.toLowerCase()}-${t.symbol.toLowerCase()}-${(t.address??"").toLowerCase()}`}i(lt,"createTokenHash");function Eo(t,e){return t.addressPatterns.filter(r=>new RegExp(r).test(e)).length>0}i(Eo,"isValidTokenAddress");function rn(t){let{config:e,meta:o}=t,n={},r=e.tokens,a=i(l=>{l.forEach(c=>{typeof c!="string"&&(c=lt(c));let u=o.tokensMapByTokenHash.get(c);u&&(n[c]=u)})},"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 l=new Set(s);Object.keys(o.tokensMapByBlockchainName).forEach(c=>{l.has(c)||a(o.tokensMapByBlockchainName[c])})}return s.forEach(l=>{let c=r[l];if(!c&&o.tokensMapByBlockchainName?.[l]){a(o.tokensMapByBlockchainName[l]);return}c&&(c.isExcluded?(a(o.tokensMapByBlockchainName[l]),c.tokens.forEach(u=>{let p=lt(u);delete n[p]})):a(c.tokens))}),Object.values(n)}i(rn,"matchTokensFromConfigWithMeta");function ir(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(ir,"getSupportedBlockchainsFromConfig");function dc(t){return{walletConnectProjectId:t?.walletConnectProjectId,trezorManifest:t?.trezorManifest,tonConnect:t?.tonConnect,walletConnectListedDesktopWalletLink:t.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink,experimentalWallet:t.features?.experimentalWallet}}i(dc,"makeProvidersOptionsFromConfig");var ar={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"},features:{experimentalWallet:"enabled"}},qh={clientUrl:void 0},Hh={liquiditySources:void 0};function uc(t){let e=dc(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 Qh(o).map(a=>a())}i(uc,"generateProviders");var mc=i((t,e,o)=>{let n=uc({...ar,...t});return{config:{...ar,...t},iframe:qh,campaignMode:Hh,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:l}=o(),c=rn({type:"source",config:{blockchains:r.from?.blockchains,tokens:r.from?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}}),u=rn({type:"destination",config:{blockchains:r.to?.blockchains,tokens:r.to?.tokens},meta:{tokensMapByBlockchainName:l,tokensMapByTokenHash:s}});xo.set("supportedSourceTokens",c),xo.set("supportedDestinationTokens",u),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=uc(r);e({allProviders:a})},getAvailableProviders:()=>{let{allProviders:r,config:a}=o(),s=dc(a);return sc({allProviders:r,configWallets:a.wallets,options:s})}}},"createConfigSlice");import{TransactionType as fc}from"rango-types";var gc=[fc.EVM,fc.SOLANA];import{RangoClient as iy}from"rango-sdk";import{UI_ID as Gh}from"@rango-dev/ui";var sr="c6381a79-2817-4602-83bf-6a641a409e32",hc="https://api.rango.exchange",yc="https://explorer.rango.exchange",De={SWAP_BOX_ID:"rango-swap-box",EXPANDED_BOX_ID:"rango-expanded-box",...Gh};import{BlockchainCategories as Jh,WalletState as bt}from"@rango-dev/ui";import{legacyReadAccountAddress as Rh}from"@rango-dev/wallets-core/legacy";import{detectInstallLink as ey,getCosmosExperimentalChainInfo as ty,isEvmAddress as oy,KEPLR_COMPATIBLE_WALLETS as eA,Networks as Wc}from"@rango-dev/wallets-shared";import ro from"bignumber.js";import{isCosmosBlockchain as ny}from"rango-types";import Vh from"bignumber.js";var ue=new Vh(0);import{WalletTypes as Kh}from"@rango-dev/wallets-shared";var Sc=[Kh.LEAP];import{BlockchainCategories as ta,WalletState as Zh}from"@rango-dev/ui";import{TransactionType as lr}from"rango-sdk";var Cc="Roboto",ea=[{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 Io(t){return Array.from(new Set(t))}i(Io,"removeDuplicateFrom");function xc(t,e){let o;return n;function n(...r){o&&clearTimeout(o),o=setTimeout(()=>{o=null,t(...r)},e)}}i(xc,"debounce");function Je(t,e){return t.toLowerCase().indexOf(e.toLowerCase())>-1}i(Je,"containsText");function vc(t,e){return t.toLowerCase()===e.toLowerCase()}i(vc,"exactText");function wc(t,e){return t.toLowerCase().startsWith(e.toLowerCase())}i(wc,"startWithText");var W=i(()=>document.getElementById(De.SWAP_BOX_ID),"getContainer"),no=i(()=>document.getElementById(De.EXPANDED_BOX_ID),"getExpanded");function bc(t,e,o){let n=!!e&&vc(e,t),r=!!o&&vc(o,t);return n!==r?n?-1:1:0}i(bc,"compareExactMatchText");function oa(t,e,o){let n=!!e&&Je(e,t),r=!!o&&Je(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(oa,"compareContainsText");function na(t,e,o){let n=!!e&&wc(e,t),r=!!o&&wc(o,t);return n!==r?n?-1:1:n&&r&&e?.length!==o?.length?e?.length-o?.length:0}i(na,"compareStartWithText");function Ec(t,e,o){if(!o)return 0;let n=bc(o,t.symbol,e.symbol);if(n)return n;if(o.length>=3){let r=bc(o,t.name,e.name);if(r)return r}if(o.length>=2){let r=na(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=oa(o,t.symbol,e.symbol);if(r)return r}if(o.length>=3){let r=na(o,t.name,e.name);if(r)return r}if(o.length>=3){let r=oa(o,t.name,e.name);if(r!==0)return r}if(o.length>=4){let r=na(o,t.address,e.address);if(r)return r}if(o.length>=4){let r=oa(o,t.address,e.address);if(r!==0)return r}return 0}i(Ec,"compareWithSearchFor");var cr=i((t,e)=>{switch(e){case ta.ALL:return!0;case ta.UTXO:return t===lr.TRANSFER;case ta.OTHER:return t!==lr.TRANSFER&&t!==lr.COSMOS&&t!==lr.EVM;default:return t===e}},"isBlockchainTypeInCategory"),Ic=i(t=>ea.find(o=>o.value===t)?.url,"getFontUrlByName");function Ac(t,e){let o=!!t.find(n=>n.state===Zh.CONNECTED);return e===!1&&o}i(Ac,"isSingleWalletActive");import{BigNumber as Nc}from"bignumber.js";var an=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"),L=i((t,e=null,o=null)=>{if(t==null||t==="")return"";let n=new Nc(t),r=1,a=1e3;for(let s=0;s<60;s++)if(new Nc(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 pr=i(t=>t?.reduce((e,o)=>e+(o.estimatedTimeInSeconds??0),0)||0,"totalArrivalTime");var wt=i((t,e)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,"containsText"),sn=i(t=>!!t&&parseFloat(t)>0,"isPositiveNumber");function ln(t){switch(!0){case t.connected:return bt.CONNECTED;case t.connecting:return bt.CONNECTING;case!t.installed:return bt.NOT_INSTALLED;default:return bt.DISCONNECTED}}i(ln,"mapStatusToWalletState");function Bc(t,e,o,n){return o.filter(r=>!Sc.includes(r)).filter(r=>{let{supportedChains:a,isContractWallet:s}=e(r),{installed:l,network:c}=t(r);return s&&(!l||!!n&&c!==n)?!1:n?!!a.find(p=>p.name===n):!0}).map(r=>{let{name:a,img:s,installLink:l,showOnMobile:c,needsNamespace:u,supportedChains:p,needsDerivationPath:d,properties:h,isHub:f}=e(r),m=Io(p.map(C=>C.type)),g=ln(t(r));return{title:a,image:s,link:ey(l),state:g,type:r,showOnMobile:c,needsNamespace:u,blockchainTypes:m,needsDerivationPath:d,properties:h,isHub:f}})}i(Bc,"mapWalletTypesToWalletInfo");function mr(t){if(!t)return null;let e=[];return e=t.map(o=>o.name),e}i(mr,"walletAndSupportedChainsNames");function ra(t,e,o,n,r){let a=[];function s(c,u){if(!!!a.find(d=>d.chain===c)){let d={address:u,chain:c,walletType:t};a.push(d)}}i(s,"addAccount");let l=n||[];return e.forEach(c=>{let{address:u,network:p}=Rh(c),d=l.length>0,h=l.includes(p),f=p===Wc.Unknown;if(d&&!h&&!f)return;let g=p===Wc.Unknown&&oy(u);if(f&&!g)return;o.includes(p)||g?r?s(p,u.toLowerCase()):l.filter(T=>o.includes(T)).forEach(T=>{s(T,u.toLowerCase())}):s(p,u)}),a}i(ra,"prepareAccountsForWalletStore");function io(t){let{filter:e,quote:o}=t,n=new Set;return o?.swaps.forEach((r,a)=>{let s=r.from.blockchain,l=r.to.blockchain;if(n.add(s),r.internalSwaps){let{internalSwaps:c}=r;c.forEach((u,p)=>{let d=u.from.blockchain,h=u.to.blockchain,f=a===o.swaps.length-1,m=p===c.length-1;(!f&&!m||f&&l!==d||e==="all")&&n.add(d),e==="all"&&n.add(h)})}e==="all"&&n.add(l)}),Array.from(n)}i(io,"getQuoteWallets");function Mc(t,e){return t.address===e.address&&t.chain===e.chain&&t.walletType===e.walletType}i(Mc,"isAccountAndWalletMatched");var Lc=i(t=>{let e=Object.values(t).reduce((o,n)=>{let r=cn(n);return r?.usdValue?o.plus(r.usdValue):o},new ro(ue));return ry(e.toString())},"calculateWalletUsdValue");function ry(t){let e=t.toString().split(".");return e[0]=e[0].replace(/\B(?=(\d{3})+(?!\d))/g,","),e.join(".")}i(ry,"numberWithThousandSeparator");var fr=i((t,e)=>{let o=ty(Object.entries(t).map(([,n])=>n).filter(ny));return o&&o[e]?.experimental},"isExperimentalChain");function cn(t){if(!t)return null;let e=new ro(t.amount).shiftedBy(-t.decimals).toFixed(),o=t.usdValue?new ro(t.usdValue).shiftedBy(-t.decimals).toFixed():null,n=L(e,8,8),r=o?L(o,4,4):null;return t?{...t,amount:n,usdValue:r}:null}i(cn,"formatBalance");function Pc(t,e){if(t?.usdValue||e?.usdValue){let o=t&&t.usdValue?new ro(t.usdValue).shiftedBy(-t.decimals):ue,n=e&&e.usdValue?new ro(e.usdValue).shiftedBy(-e.decimals):ue;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}if(t?.amount||e?.amount){let o=t&&t.amount?new ro(t.amount).shiftedBy(-t.decimals):ue,n=e&&e.amount?new ro(e.amount).shiftedBy(-e.decimals):ue;return o.isEqualTo(n)?0:o.isGreaterThan(n)?-1:1}return 0}i(Pc,"compareTokenBalance");function Mt(t,e){return t?.blockchain===e?.blockchain&&t?.symbol.toLowerCase()===e?.symbol.toLowerCase()&&t?.address?.toLowerCase()===e?.address?.toLowerCase()}i(Mt,"areTokensEqual");function _c(t){return t.sort((e,o)=>+(o.state===bt.CONNECTED)-+(e.state===bt.CONNECTED)||+(o.state===bt.DISCONNECTED||o.state===bt.CONNECTING)-+(e.state===bt.DISCONNECTED||e.state===bt.CONNECTING))}i(_c,"sortWalletsBasedOnConnectionState");function gr(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(gr,"getConciseAddress");function Dc({chain:t,connectedWallets:e,walletType:o}){return e.find(n=>n.walletType===o&&n.chain===t)?.address}i(Dc,"getAddress");var $c=i((t,e)=>!!t.find(o=>o.chain===e&&o.loading),"isFetchingBalance");function Fc(t){return t.map(e=>e.state).join("-")}i(Fc,"hashWalletsState");function Oc(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(Oc,"filterBlockchainsByWalletTypes");function Uc(t,e){return e===Jh.ALL?t:t.filter(o=>{for(let n of o.blockchainTypes)if(cr(n,e))return!0;return!1})}i(Uc,"filterWalletsByCategory");var ia={API_KEY:sr};function Lt(t){return ia[t]||""}i(Lt,"getConfig");function zc(t){let e;return typeof structuredClone=="function"?e=structuredClone(t):e=JSON.parse(JSON.stringify(t)),ia=e,ia}i(zc,"initConfig");var Qc=20,qc=25,aa="theme-widget",sa=i((t,e)=>{let o=!1;if(e&&t){if(Array.isArray(e))o=!e.some(n=>Mt(n,t));else if(!Array.isArray(e)&&e[t.blockchain]){o=e[t.blockchain].tokens.some(r=>Mt(r,t));let n=e[t.blockchain].isExcluded;return!n&&!o||n&&o}}return o},"isTokenExcludedInConfig"),la=i((t,e)=>t&&e&&!e.includes(t.name),"isBlockchainExcludedInConfig"),Hc=i((t,e,o)=>o==="expanded"&&(t||e)||o==="full-expanded"&&e,"isVariantExpandable");var hr,xt=i(()=>hr||(hr=new iy(Lt("API_KEY"),Lt("BASE_URL")),hr),"httpService");function yr(t,e){let o=t.map(a=>a.swapperGroup),n=[];return Io(t.map(a=>a.swapperGroup)).map(a=>{let s=t.find(l=>l.swapperGroup===a);if(s){let l=!0;o&&(l=o.some(c=>c===s.swapperGroup)),l&&s.types.map(c=>{n.push({id:s.swapperGroup,groupTitle:s.swapperGroup,logo:s.logo,type:c,selected:!e.includes(s.swapperGroup)})})}}),n}i(yr,"getUniqueSwappersGroups");function Gc(t,e){return t.swapperGroup<e.swapperGroup?-1:t.swapperGroup>e.swapperGroup?1:0}i(Gc,"sortLiquiditySourcesByGroupTitle");function Ve(t,e){return e?.[t]==="hidden"}i(Ve,"isFeatureHidden");function Vc(t,e){return e?.[t]==="enabled"}i(Vc,"isFeatureEnabled");function Ao(t,e){return e?.[t]==="enabled"}i(Ao,"isRoutingEnabled");var Kc=i((t,e,o)=>Ve("customTokens",o)?t:t.concat(e),"addCustomTokensToSupportedTokens");var jc=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 c=ir({config:a}),u=r;return c.length>0&&(u=u.filter(p=>c.includes(p.name))),u.filter(p=>gc.includes(p.type))}let s=(o.type==="source"?a.from?.blockchains:a.to?.blockchains)??[];return r.filter(c=>!(s.length>0&&!s.includes(c.name)))},tokens:o=>{let{_tokensMapByTokenHash:n,_tokensMapByBlockchainName:r,config:a,_customTokens:s}=e(),l=Array.from(n.values()),c=e()._blockchainsMapByName;if(!o||!o.type)return l;let u=o.type==="source"?"from":"to",p=o.type==="source"?"supportedSourceTokens":"supportedDestinationTokens",d=xo.get(p);d?.length||(d=rn({type:o.type,config:{blockchains:a[u]?.blockchains,tokens:a[u]?.tokens},meta:{tokensMapByTokenHash:n,tokensMapByBlockchainName:r}}),xo.set(p,d)),d=Kc(d,s,a.features);let h=e().blockchains({type:o.type});return d.filter(m=>o.blockchain&&m.blockchain!==o.blockchain||!h.some(g=>g.name===m.blockchain)?!1:o.searchFor?!!(Je(m.symbol,o.searchFor)||Je(m.address||"",o.searchFor)||Je(m.name||"",o.searchFor)):!0).sort((m,g)=>{let C=e().isTokenPinned(m,o.type),S=e().isTokenPinned(g,o.type);if(C!==S)return C?-1:1;if(o.getBalanceFor){let A=o.getBalanceFor(m),M=o.getBalanceFor(g),b=Pc(A,M);if(b!==0)return b}let T=c.get(m.blockchain),k=c.get(g.blockchain),v=Ri(m,T),w=Ri(g,k);if(v!==w)return v?-1:1;if(m.isPopular!==g.isPopular)return m.isPopular?-1:1;if(o.searchFor){let A=Ec(m,g,o.searchFor);if(A)return A}return m.isSecondaryCoin!==g.isSecondaryCoin?m.isSecondaryCoin?1:-1:T&&k?T.sort-k.sort:0})},findToken:o=>{let n=e()._tokensMapByTokenHash,r=e().customTokens(),a=lt(o),s=n.get(a);return s||(s=r.find(l=>lt(l)===a)),s},isTokenPinned:(o,n)=>!!(n==="source"?e().config.from?.pinnedTokens:e().config.to?.pinnedTokens)?.some(s=>Mt(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(u=>{let p=a?.includes(u.swapperGroup);return s||!a||a.length===0?!p:p}).sort(Gc)},fetch:async()=>{try{let{routing:o}=e().config,n=Ao("enableCentralizedSwappers",o),r=await xt().getAllMetadata({enableCentralizedSwappers:n});t({fetchStatus:"success"});let a=new Map,s=new Map,l={},c=[],u=r.popularTokens,p=r.swappers.filter(f=>f.enabled),d=new Set;r.tokens.forEach(f=>{d.add(f.blockchain),c.push(f)}),r.blockchains.sort((f,m)=>f.sort-m.sort).forEach(f=>{f.enabled&&d.has(f.name)&&a.set(f.name,f)}),c.forEach(f=>{let m=lt(f);l[f.blockchain]||(l[f.blockchain]=[]),s.set(m,f),l[f.blockchain].push(m)}),t({_blockchainsMapByName:a,_tokensMapByTokenHash:s,_tokensMapByBlockchainName:l,_popularTokens:u,_swappers:p})}catch(o){throw t({fetchStatus:"failed"}),o}}}),"createDataSlice");import{Bengali as ay,Catalonia as sy,Chinese as Xc,Denmark as ly,English as cy,Finland as py,French as uy,German as dy,Greece as my,Hungary as fy,India as gy,Indonesian as hy,Italian as yy,Japanese as Sy,Korea as Cy,Lithuania as ky,Malay as Ty,Netherlands as vy,Pakistan as wy,Philippines as by,Poland as xy,Portuguese as Ey,Russian as Iy,SaudiArabia as Ay,Serbia as Ny,Slovakia as Wy,SouthAfrica as By,Spanish as My,Swahili as Ly,Swedish as Py,Thai as _y,Turkish as Dy,Ukrainian as $y,Vietnamese as Fy}from"@rango-dev/ui";var Yc=[{title:"Afrikaans",label:"Afrikaans",local:"af",SVGFlag:By},{title:"Arabic",label:"\u0639\u0631\u0628\u064A",local:"ar",SVGFlag:Ay},{title:"Bengali",label:"\u09AC\u09BE\u0982\u09B2\u09BE",local:"bn",SVGFlag:ay},{title:"Catalan",label:"Catal\xE0",local:"ca",SVGFlag:sy},{title:"Chinese (Simplified)",label:"\u7B80\u4F53\u4E2D\u6587",local:"zh-CN",SVGFlag:Xc},{title:"Chinese (Traditional)",label:"\u4E2D\u6587\uFF08\u7E41\u9AD4)",local:"zh-TW",SVGFlag:Xc},{title:"Danish",label:"Dansk",local:"da",SVGFlag:ly},{title:"Dutch",label:"Nederlands",local:"nl",SVGFlag:vy},{title:"English",label:"English",local:"en",SVGFlag:cy},{title:"Filipino",label:"Filipino",local:"fil",SVGFlag:by},{title:"Finnish",label:"Suomalainen",local:"fi",SVGFlag:py},{title:"French",label:"Fran\xE7ais",local:"fr",SVGFlag:uy},{title:"German",label:"Deutsch",local:"de",SVGFlag:dy},{title:"Greek",label:"\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",local:"el",SVGFlag:my},{title:"Hindi",label:"\u0939\u093F\u0902\u0926\u0940",local:"hi",SVGFlag:gy},{title:"Hungarian",label:"Magyar",local:"hu",SVGFlag:fy},{title:"Indonesian",label:"Indonesia",local:"id",SVGFlag:hy},{title:"Italian",label:"Italiana",local:"it",SVGFlag:yy},{title:"Japanese",label:"\u65E5\u672C\u8A9E",local:"ja",SVGFlag:Sy},{title:"Korean",label:"\uD55C\uAD6D\uC778",local:"ko",SVGFlag:Cy},{title:"Lithuanian",label:"Lietuvi\u0173",local:"lt",SVGFlag:ky},{title:"Malay",label:"Melayu",local:"ms",SVGFlag:Ty},{title:"Polish",label:"Polski",local:"pl",SVGFlag:xy},{title:"Portuguese",label:"Portugu\xEAs",local:"pt",SVGFlag:Ey},{title:"Russian",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439",local:"ru",SVGFlag:Iy},{title:"Serbian",label:"C\u0440\u043F\u0441\u043A\u0438",local:"sr",SVGFlag:Ny},{title:"Slovak",label:"Slovensk\xFD",local:"sk",SVGFlag:Wy},{title:"Spanish",label:"Espa\xF1ol",local:"es",SVGFlag:My},{title:"Swahili",label:"Kiswahili",local:"sw",SVGFlag:Ly},{title:"Swedish",label:"Svenska",local:"sv",SVGFlag:Py},{title:"Thai",label:"\u0E41\u0E1A\u0E1A\u0E44\u0E17\u0E22",local:"th",SVGFlag:_y},{title:"Turkish",label:"T\xFCrk\xE7e",local:"tr",SVGFlag:Dy},{title:"Ukrainian",label:"Y\u043A\u0440\u0430\u0457\u043D\u0456",local:"uk",SVGFlag:$y},{title:"Urdu",label:"\u0627\u0631\u062F\u0648",local:"ur",SVGFlag:wy},{title:"Vietnamese",label:"Ti\u1EBFng Vi\u1EC7t",local:"vi",SVGFlag:Fy}],No="en";var Zc=[.5,1,3],Jc=1,Rc=5,ep=100,tp=0;var op=i((t,e)=>({disabledLiquiditySources:[],theme:"auto",language:null,preferredBlockchains:[],slippage:Jc,customSlippage:null,infiniteApprove:!1,affiliateRef:null,affiliatePercent:null,affiliateWallets:null,_customTokens:[],addPreferredBlockchain:o=>{let n=e().preferredBlockchains;if(n.find((s,l)=>{let c=s===o,u=l<=9;return c&&u}))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=Io(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=Ve("theme",n),s=Ve("language",n),l=Ve("liquiditySource",n),c=r?.singleTheme,u=o?.__UNSTABLE_OR_INTERNAL__?.autoUpdateSettings;t({...a&&{theme:o.theme?.mode||"auto"},...c&&{theme:o.theme?.mode||"light"},...s&&{language:o.language||No},...l&&{disabledLiquiditySources:o.liquiditySources||[]},...u&&{language:o.language||No}})},setCustomToken:o=>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=ir({config:o});return r.length?n.filter(a=>r.includes(a.blockchain)):n}}),"createSettingsSlice");import fa from"bignumber.js";import Oy from"mitt";var he=Oy(),Uy={on:he.on,off:he.off};import{WidgetEvents as np}from"@rango-dev/queue-manager-rango-preset";var pa=(o=>(o.QUOTE_INPUT_UPDATE="quoteInputUpdate",o.QUOTE_OUTPUT_UPDATE="quoteOutputUpdate",o))(pa||{}),ua=(o=>(o.CONNECT="connect",o.DISCONNECT="disconnect",o))(ua||{}),da=(e=>(e.CLICK_CONNECT_WALLET="clickConnectWallet",e))(da||{}),Wo=(a=>(a[a.RouteEvent=np.RouteEvent]="RouteEvent",a[a.StepEvent=np.StepEvent]="StepEvent",a.QuoteEvent="quoteEvent",a.WalletEvent="walletEvent",a.UiEvent="uiEvent",a))(Wo||{});import zy from"bignumber.js";function pn(t){return`${t.blockchain}-${t.address}-${t.symbol}`}i(pn,"createAssetKey");function ma(t,e){return`${pn(e)}-${t}`}i(ma,"createBalanceKey");function un(t){let[e,o,n]=t.split("-");return{address:o==="null"?null:o,blockchain:e,symbol:n}}i(un,"extractAssetFromBalanceKey");function rp(t,e){let o={};return t.balances?.forEach(n=>{let r=ma(t.address,n.asset),a=n.amount.amount,s=n.amount.decimals,l=e().findToken(n.asset)?.usdPrice,c=l?new zy(l??ue).multipliedBy(a).toString():"",u={amount:a,decimals:s,usdValue:c};o[r]=u}),o}i(rp,"createBalanceStateForNewAccount");function ip(t,e){for(let o in e){let n=un(o),r=pn(n);t[r]||(t[r]=[]),t[r].includes(o)||(t[r]=[...t[r],o])}return t}i(ip,"updateAggregatedBalanceStateForNewAccount");function ap(t,e){let o=un(e),n=pn(o);return t[n]&&(t[n]=t[n].filter(r=>r!==e)),t}i(ap,"removeBalanceFromAggregatedBalance");var sp=i((t,e)=>({_balances:{},_aggregatedBalances:{},connectedWallets:[],fetchingWallets:!1,setConnectedWalletAsRefetching:o=>{t(n=>({fetchingWallets:!0,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!0,error:!1}:r)}))},setConnectedWalletRetrievedData:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!1,error:!1}:r)}))},setConnectedWalletHasError:o=>{t(n=>({fetchingWallets:!1,connectedWallets:n.connectedWallets.map(r=>r.walletType===o?{...r,loading:!1,error:!0}:r)}))},addConnectedWallet:o=>{let n=e().connectedWallets,r=o.filter(a=>!n.some(s=>Mc(a,s)));if(r.length>0){let a=r.map(s=>{let l=!n.some(c=>c.chain===s.chain&&c.selected&&c.walletType!==s.walletType);return{address:s.address,chain:s.chain,explorerUrl:null,walletType:s.walletType,selected:l,loading:!1,error:!1}});t(s=>({connectedWallets:[...s.connectedWallets.filter(c=>!a.some(u=>u.walletType===c.walletType&&u.chain===c.chain)),...a]}))}},setWalletsAsSelected:o=>{let n=e().connectedWallets.map(r=>{let a=!!o.find(l=>l.chain===r.chain&&l.walletType!==r.walletType&&r.selected),s=!!o.find(l=>l.chain===r.chain&&l.walletType===r.walletType&&!r.selected);return a?{...r,selected:!1}:s?{...r,selected:!0}:r});t({connectedWallets:n})},newWalletConnected:async o=>{he.emit("walletEvent",{type:"connect",payload:{walletType:o[0].walletType,accounts:o}}),e().addConnectedWallet(o),e().fetchBalances(o)},removeBalancesForWallet:(o,n)=>{let r=e().connectedWallets.filter(u=>u.walletType===o);e().connectedWallets.forEach(u=>{u.walletType!==o&&(r=r.filter(p=>!(p.chain===u.chain&&p.address===u.address)))}),n?.chains&&n.chains.length>0&&(r=r.filter(u=>n.chains?.includes(u.chain)));let a={},s=e()._aggregatedBalances,l=e()._balances;Object.keys(l).forEach(u=>{let p=un(u),d=!!r.find(h=>ma(h.address,{address:p.address,blockchain:h.chain,symbol:p.symbol})===u);d||(a[u]=l[u]),d&&(s=ap(s,u))}),t({_balances:a,_aggregatedBalances:s})},disconnectWallet:o=>{if(e().connectedWallets.find(r=>r.walletType===o)){he.emit("walletEvent",{type:"disconnect",payload:{walletType:o}}),e().removeBalancesForWallet(o);let r=e().connectedWallets.filter(s=>s.selected&&s.walletType===o).map(s=>s.chain),a=e().connectedWallets.filter(s=>s.walletType!==o);r.length>0&&(a=a.map(s=>r.includes(s.chain)?(r=r.filter(l=>l!==s.chain),{...s,selected:!0}):s)),t({connectedWallets:a})}},clearConnectedWallet:()=>t({connectedWallets:[]}),fetchBalances:async(o,n)=>{let r=o[0].walletType;e().setConnectedWalletAsRefetching(r);let a=o.map(c=>({address:c.address,blockchain:c.chain})),l=(await xt().getWalletsDetails(a)).wallets;if(l){let{retryOnFailedBalances:c=!0}=n||{};if(c){let d=l.filter(h=>h.failed).map(h=>({chain:h.blockChain,walletType:r,address:h.address}));d.length>0&&e().fetchBalances(d,{retryOnFailedBalances:!1})}let u={},p=e()._aggregatedBalances;l.forEach(d=>{if(d.failed)return;let h=rp(d,e);p=ip(p,h),u={...u,...h}}),t(d=>({_balances:{...d._balances,...u},_aggregatedBalances:p})),e().setConnectedWalletRetrievedData(r)}else throw e().setConnectedWalletHasError(r),new 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=pn(o),a=e()._aggregatedBalances[r]||[];if(a.length===0)return null;if(a.length===1){let c=a[0];return n[c]}let l=n[a[0]];return a.forEach(c=>{let u=n[c],p=new fa(u.amount),d=new fa(l.amount);p.isGreaterThan(d)&&(l=u)}),l},getBalancesForWalletAddress:o=>{let n=e().getBalances();return Object.keys(n).reduce((s,l)=>{let c=n[l],[,,,u]=l.split("-");return u===o&&(s[l]=c),s},{})},getConnectedWalletsDetails:()=>e().connectedWallets.map(n=>{let r=e().getBalancesForWalletAddress(n.address),a=Object.keys(r);return{...n,balances:a.reduce((s,l)=>{let c=r[l],u=un(l);if(u.blockchain===n.chain){let p=e().findToken(u);if(p){let d=c.amount?new fa(c.amount).shiftedBy(-c.decimals):ue;s.push({chain:n.chain,symbol:p.symbol,ticker:p.symbol,address:p.address,rawAmount:c.amount,decimal:c.decimals,amount:d.toString(),logo:p.image,usdPrice:p.usdPrice})}else console.debug("Looking for asset but it couldn't be found in tokens store. May not be provided in meta.'",u)}return s},[])}})}),"createWalletsSlice");function lp(t){return Qy()(qy((...e)=>({...sp(...e),...jc(...e),...op(...e),...mc(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})}))}i(lp,"createAppStore");var cp=Gy(null);function y(){let t=Vy(cp);if(Ky(()=>{t&&!t.persist.hasHydrated()&&t.persist.rehydrate()},[]),!t)throw new Error("Missing AppStoreContext.Provider in the tree");return t()}i(y,"useAppStore");function pp(t){let e=jy();return e.current||(e.current=lp(t.config)),Hy.createElement(cp.Provider,{value:e.current},t.children)}i(pp,"AppStoreProvider");function ft(t){let{chain:e}=t||{},{config:o,connectedWallets:n,getAvailableProviders:r}=y(),{state:a,getWalletInfo:s}=Xy(),l=y().blockchains(),{handleDisconnect:c}=Gt(),u=cc(r(),{trezorManifest:o?.trezorManifest,walletConnectProjectId:o?.walletConnectProjectId,walletConnectListedDesktopWalletLink:o.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink,tonConnect:o.tonConnect}),p=Bc(a,s,u,e);p=Yy()?p.filter(C=>C.showOnMobile!==!1&&a(C.type).installed):p;let d=_c(p),h=i(C=>!n.find(S=>S.walletType===C&&S.chain===e),"isExperimentalChainNotAdded"),f=Jy(()=>{let C=p?.filter(S=>S.state===ga.CONNECTING)||[];for(let S of C)c(S.type)},[Fc(p)]);Ry(()=>()=>{f()},[]);let m=i(C=>{let S=C.find(k=>k.type===dn.DEFAULT);return!S||S.state===ga.NOT_INSTALLED?!1:C.filter(k=>k.state!=ga.NOT_INSTALLED&&![dn.DEFAULT,dn.WALLET_CONNECT_2,dn.LEDGER].includes(k.type)&&s(k.type).supportedChains.filter(v=>v.type=="EVM").length>0).length==0},"shouldShowDefaultInjectedWallet"),g=i((C,S,T)=>fr(T,S)&&h(C)&&!Zy.includes(C)||C==dn.DEFAULT&&!m(p),"shouldExcludeWallet");return{list:d.filter(C=>!g(C.type,e??"",l)),terminateConnectingWallets:f}}i(ft,"useWalletList");import{Modal as nS}from"@rango-dev/ui";import rS from"react";import{create as oS}from"zustand";var up="rango-widget";var mn=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(up),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 tS=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"),Bo=tS;var re=Bo(oS()((t,e)=>({isActiveTab:!1,tabManagerInitiated:!1,showActivateTabModal:!1,watermark:"NONE",showProfileBanner:!1,fetchingApiConfig:!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})}}))),ao=new mn({onInit:()=>re.setState({tabManagerInitiated:!0}),onClaim:()=>re.setState({isActiveTab:!0,showActivateTabModal:!1}),onRelease:()=>re.setState({isActiveTab:!1})});function Z(t){let{watermark:e}=re();return rS.createElement(nS,{hasWatermark:e==="FULL",...t},t.children)}i(Z,"WatermarkedModal");import{i18n as ha}from"@lingui/core";import{Button as pS,Checkbox as uS,Divider as dS,Image as Tp,ListItemButton as mS,MessageBox as fS,Radio as gS,RadioRoot as hS}from"@rango-dev/ui";import we,{useState as yS}from"react";import{css as iS,darkTheme as mp,IconButton as aS,styled as so}from"@rango-dev/ui";var Et=so(aS,{width:"$24",position:"relative",padding:"0",overflow:"unset","&:hover":{backgroundColor:"$secondary100",[`.${mp} &`]:{backgroundColor:"$neutral"}}}),fp=so("div",{position:"absolute",background:"$secondary500",[`.${mp} &`]:{$$color:"$colors$secondary250"},width:"$6",height:"$6",borderRadius:"$lg",right:"$4",border:"1px solid $surface100"}),Vt=so("div",{display:"flex",justifyContent:"flex-end",minWidth:"$40",button:{padding:0}}),gp=so("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"}}}}),hp=so("div",{padding:"$2",variants:{isRefetched:{true:{transform:"rotate(360deg)",transition:"transform 1s ease-in-out"}}}}),yp=so("div",{position:"absolute",right:"$4",top:"$4",backgroundColor:"$background",borderRadius:"100%"}),Sp=iS({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center"}),Sr=so("div",{borderRadius:"100%",border:"1.5px transparent solid","&:not(:first-child)":{marginLeft:"-$6"},img:{borderRadius:"100%"}});import{keyframes as sS,styled as Cr}from"@rango-dev/ui";var nN=Cr("div",{borderRadius:"$lg",width:"$45",height:"$45",backgroundColor:"$success300",display:"flex",justifyContent:"center",alignItems:"center"}),Mo=Cr("div",{position:"relative"}),lS=sS({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),Lo=Cr("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${lS} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),kr=Cr("div",{"& img":{borderRadius:"50%"}});function Cp(t,e){return t.find(o=>o.name===e)?.logo}i(Cp,"getBlockchainLogo");import{styled as cS}from"@rango-dev/ui";var kp=cS("ul",{padding:0,paddingTop:"$4",paddingBottom:"$4"});function fn(t){let{targetWallet:e}=t.value,o=e.needsNamespace?.selection==="single",n=e.image,[r,a]=yS([]),s=y().blockchains(),l=i(u=>{a(o?[u]:p=>p.includes(u)?p.filter(d=>d!==u):p.concat(u))},"onSelect"),c=i(u=>o?we.createElement(hS,{value:r?.[0]},u):we.createElement(we.Fragment,null,u),"wrapRadioRoot");return we.createElement(we.Fragment,null,we.createElement(dS,{size:20}),we.createElement(fS,{type:"info",title:ha.t("Select chain types"),description:ha.t("This wallet supports multiple chains. Select which chain you'd like to connect to."),icon:we.createElement(Mo,null,we.createElement(Sr,null,we.createElement(Tp,{src:n,size:45})),we.createElement(Lo,null))}),we.createElement(kp,null,c(we.createElement(we.Fragment,null,e.needsNamespace?.data.map(u=>we.createElement(mS,{key:u.id,id:u.id,title:u.label,hasDivider:!0,style:{height:60},onClick:()=>l(u.value),start:we.createElement(Tp,{src:Cp(s,u.id),size:22}),end:o?we.createElement(gS,{value:u.value}):we.createElement(uS,{checked:r.includes(u.value)})}))))),we.createElement(pS,{id:"widget-name-space-confirm-btn",type:"primary",disabled:!r.length,onClick:()=>t.onConfirm(r)},ha.t("Confirm")))}i(fn,"Namespaces");import{i18n as Po}from"@lingui/core";import{Button as kS,Divider as bp,Image as TS,MessageBox as vS,Select as wS,TextField as bS}from"@rango-dev/ui";import Oe,{useEffect as xS,useState as xp}from"react";import{namespaces as SS}from"@rango-dev/wallets-shared";var Tr={id:"custom",label:"Custom",generateDerivationPath:t=>t};function ya(t){let e=t?SS[t].derivationPaths:null;return e?[...e,Tr]:[]}i(ya,"getDerivationPaths");import{styled as vp,Typography as CS}from"@rango-dev/ui";var wp=vp("div",{paddingTop:"$30",paddingBottom:"$30",zIndex:10}),Sa=vp(CS,{paddingLeft:"$10"}),Ca={height:"$40",backgroundColor:"$neutral200",borderRadius:"$sm"};var Ep="0";function gn(t){let{onConfirm:e}=t,{namespace:o,providerImage:n,providerType:r}=t.value,[a,s]=xp(null),[l,c]=xp(Ep),u=a===Tr.id,p=ya(o),d=i(({value:f})=>{let m=p?.find(g=>g.id===f);m&&(a===Tr.id&&Number.isNaN(Number(l))&&c(Ep),s(m.id))},"handleDerivationPathItemClick"),h=i(()=>{let f=p.find(m=>m.id===a);if(f)e(f.generateDerivationPath(l));else throw new Error("selectedDerivationPath can not be undefined")},"handleConfirm");return xS(()=>{s(ya(o)[0]?.id||null)},[o]),Oe.createElement(Oe.Fragment,null,Oe.createElement(bp,{size:20}),Oe.createElement(vS,{type:"info",title:Po.t("Select Derivation Path"),description:Po.t({id:"In order to connect to {type}, you must first select a Derivation Path",values:{type:r}}),icon:Oe.createElement(Mo,null,Oe.createElement(kr,null,Oe.createElement(TS,{src:n,size:45})),Oe.createElement(Lo,null))}),Oe.createElement(wp,null,Oe.createElement(Sa,{variant:"body",size:"xsmall",color:"$neutral600"},Po.t("Choose Derivation Path Template")),Oe.createElement(wS,{value:a||"",options:p.map(f=>({value:f.id,label:f.label})),variant:"filled",handleItemClick:d,styles:{trigger:Ca}}),Oe.createElement(bp,{size:20}),Oe.createElement(Sa,{variant:"body",size:"xsmall",color:"$neutral600"},u?Po.t("Enter Path"):Po.t("Enter Index")),Oe.createElement(bS,{type:u?"text":"number",variant:"contained",value:l,onChange:f=>c(f.target.value),style:Ca})),Oe.createElement(kS,{id:"widget-derivation-path-confirm-btn",type:"primary",onClick:h,disabled:!p||!a||!l},Po.t("Confirm")))}i(gn,"DerivationPath");import{i18n as _o}from"@lingui/core";import{Image as ES,MessageBox as ka,WalletState as IS}from"@rango-dev/ui";import{useWallets as AS}from"@rango-dev/wallets-react";import lo from"react";function Ta(t){let{wallet:e,error:o}=t,{type:n,image:r}=e,{state:a}=AS();return ln(a(n))===IS.CONNECTED?lo.createElement(ka,{type:"success",title:_o.t("Wallet Connected"),description:_o.t("Your wallet is connected, you can use it to swap.")}):o?lo.createElement(ka,{type:"error",title:_o.t("Failed to Connect"),description:o||_o.t("Your wallet is not connected. Please try again.")}):lo.createElement(ka,{type:"loading",title:_o.t("Connecting to your wallet"),description:_o.t("Click connect in your wallet popup."),icon:lo.createElement(Mo,null,lo.createElement(kr,null,lo.createElement(ES,{src:r,size:45})),lo.createElement(Lo,null))})}i(Ta,"ConnectStatus");import{i18n as va}from"@lingui/core";import{Button as NS,Divider as Ip,MessageBox as WS}from"@rango-dev/ui";import vr from"react";function wa(t){let{displayName:e,onConfirm:o}=t;return vr.createElement(WS,{title:va.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),type:"warning",description:va.t({id:"Would you like to add the {blockchainDisplayName} experimental chain to your wallet?",values:{blockchainDisplayName:e}})},vr.createElement(Ip,{size:18}),vr.createElement(Ip,{size:32}),vr.createElement(NS,{id:"widget-experimental-chain-confirm-btn",onClick:o,variant:"outlined",type:"primary",fullWidth:!0,size:"large"},va.t("Confirm")))}i(wa,"ExperimentalChain");function Ap(t,e){return t().status==="init"&&!!e}i(Ap,"isOnStatus");function hn(t){return t().status==="namespace"}i(hn,"isOnNamespace");function yn(t){return t().status==="derivationPath"}i(yn,"isOnDerivationPath");var PS=3e3,_S=300;function po(t){let e=LS(),[o,n]=Np(!1),[r,a]=Np(),s=i(S=>{a(S.message)},"catchErrorOnHandle"),{terminateConnectingWallets:l}=ft(),{handleConnect:c,handleDerivationPath:u,handleNamespace:p,getState:d,resetState:h}=Gt(),f=i(S=>{p(t.wallet,S).catch(s)},"handleConfirmNamespaces"),m=i(S=>{if(!S)throw new Error("Derivation path is empty. Please make sure you've filled the field correctly.");u(S).catch(s)},"handleDerivationPathConfirm"),g=i(()=>{n(!1)},"handleClosingModal"),C=i(()=>{a(void 0),h(),n(!1),e.current&&clearTimeout(e.current)},"resetModalState");return MS(()=>{if(t.wallet){C();let S=!1,T=!0,k=i(()=>{setTimeout(()=>{T=!1,S||n(!0)},_S)},"beforeConnecting"),v=i(w=>{let A=w.status==="connected",M=["disconnected","disconnected-unhandled"].includes(w.status);["namespace","derivation-path"].includes(w.status)||(S=!0),A&&!T?e.current=setTimeout(g,PS):M&&g(),t.onConnect&&t.onConnect(w)},"afterConnected");k(),c(t.wallet,{disconnectIfConnected:!0}).then(v).catch(s)}},[t.wallet]),co.createElement(Z,{open:o,onClose:g,onExit:()=>{C(),l(),t.onClose&&t.onClose()},container:W()},Ap(d,t.wallet)&&co.createElement(co.Fragment,null,co.createElement(Ta,{wallet:{type:t.wallet.type,image:t.wallet.image},error:r}),co.createElement(BS,{direction:"vertical",size:32})),hn(d)&&co.createElement(fn,{onConfirm:f,value:d().namespace}),yn(d)&&co.createElement(gn,{onConfirm:m,value:d().derivationPath}))}i(po,"StatefulConnectModal");import{legacyFormatAddressWithNetwork as $S,legacyReadAccountAddress as Bp}from"@rango-dev/wallets-core/legacy";import{Events as wr,Provider as FS}from"@rango-dev/wallets-react";import{isEvmBlockchain as OS}from"rango-sdk";import br,{createContext as US,useEffect as Mp,useMemo as zS,useRef as Lp}from"react";import{useEffect as DS}from"react";function Wp(t){return t.map(e=>typeof e=="string"?e:e.config.type).join("-")}i(Wp,"hashProviders");function ba(t,e){let{clearConnectedWallet:o,getAvailableProviders:n,buildAndSetProviders:r}=y(),a=n();return DS(()=>{o(),r()},[Wp(t??[]),e?.walletConnectProjectId,e?.walletConnectListedDesktopWalletLink]),{providers:a}}i(ba,"useWalletProviders");var xr=US({onConnectWallet:()=>{},onDisconnectWallet:()=>{}});function QS(t){let{updateConfig:e,updateSettings:o,fetch:n,fetchStatus:r,removeBalancesForWallet:a}=y(),s=y().blockchains(),{newWalletConnected:l,disconnectWallet:c,connectedWallets:u}=y(),p=y().config,d={walletConnectProjectId:p?.walletConnectProjectId,trezorManifest:p?.trezorManifest,tonConnect:p.tonConnect,walletConnectListedDesktopWalletLink:t.config.__UNSTABLE_OR_INTERNAL__?.walletConnectListedDesktopWalletLink,experimentalWallet:t.config.features?.experimentalWallet},{providers:h}=ba(p.wallets,d),f=Lp(),m=Lp();Mp(()=>{n().catch(console.log)},[]),Mp(()=>{t.config&&(e(t.config),o(t.config),window.__rango={config:p,dappConfig:t.config})},[t.config,r]);let g=s.filter(OS).map(k=>k.name),C=i((k,v,w,A,M)=>{if(v===wr.ACCOUNTS){let b=mr(M.supportedBlockchains),E=[],x=[];if(w?.forEach(I=>{let{network:B}=Bp(I);g.includes(B)?E.push(I):x.push(I)}),u.filter(I=>I.walletType===k).map(I=>$S(I.address,I.chain)).length>0){if(E.length>0){let I=ra(k,E,g,b,M.isContractWallet);a(k,{chains:I.map(B=>B.chain)})}x.length>0&&a(k,{chains:x.map(I=>{let{network:B}=Bp(I);return B})})}if(w){let I=ra(k,w,g,b,M.isContractWallet);I.length&&l(I)}else c(k),m.current?m.current(k):console.warn("onDisconnectWallet handler hasn't been set. Are you sure?")}if(v===wr.ACCOUNTS&&A.connected||v===wr.ACCOUNTS&&M.isHub){let b=`${k}-${A.network}-${w}`;f.current?f.current(b):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}if(v===wr.NETWORK&&A.network){let b=`${k}-${A.network}`;f.current?f.current(b):console.warn("onConnectWallet handler hasn't been set. Are you sure?")}t.onUpdateState&&t.onUpdateState(k,v,w,A,M)},"onUpdateState"),S=re.use.isActiveTab(),T=zS(()=>({onConnectWallet:k=>{f.current=k},onDisconnectWallet:k=>{m.current=k}}),[]);return br.createElement(xr.Provider,{value:T},br.createElement(FS,{allBlockChains:s,providers:h,onUpdateState:C,autoConnect:!!S,configs:{wallets:p.wallets,isExperimentalEnabled:Vc("experimentalWallet",p.features)}},t.children))}i(QS,"Main");function Er(t){let{config:e,...o}=t;return br.createElement(pp,{config:e},br.createElement(QS,{...o,config:e}))}i(Er,"WidgetWallets");import Xi from"react";import qS,{Fragment as HS}from"react";import{MemoryRouter as GS,useInRouterContext as VS}from"react-router";function Pp({children:t}){let o=VS()?HS:GS;return qS.createElement(o,null,t)}i(Pp,"AppRouter");import{I18nManager as IE}from"@rango-dev/ui";import Jl from"react";import _e from"react";import{useRoutes as mE}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 $o,useRef as _r}from"react";import Ke from"bignumber.js";import{create as XS}from"zustand";import{subscribeWithSelector as YS}from"zustand/middleware";import{i18n as gt}from"@lingui/core";import{RouteEventType as pB}from"@rango-dev/queue-manager-rango-preset";import Ue from"bignumber.js";import{PendingSwapNetworkStatus as Lr}from"rango-types";import{i18n as $e}from"@lingui/core";var R=i(()=>({genericServerError:$e.t("Failed Network, Please retry your swap."),liquiditySourcesError:{title:$e.t("Please reset your liquidity sources."),description:$e.t("You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources.")},noResultError:{title:$e.t("No Routes Found."),description:$e.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:$e.t("Bridge Limit Error: Please increase your amount."),decreaseAmount:$e.t("Bridge Limit Error: Please decrease your amount.")},highValueLossError:{impactTitle:$e.t("High Price Impact"),title:$e.t("Price impact is too high!"),description:$e.t("The price impact is significantly higher than the allowed amount."),confirmMessage:$e.t("Confirm high price impact")},quoteUpdatedWithHighValueLoss:{title:$e.t("Route updated and price impact is too high, try again later!")},unknownPriceError:{impactTitle:$e.t("USD Price Unknown"),title:$e.t("USD Price Unknown, Cannot calculate Price Impact."),description:$e.t("USD Price Unknown, Cannot calculate Price Impact. The price impact may be higher than usual. Are you sure to continue the Swap?"),confirmMessage:$e.t("Confirm USD Price Unknown")}}),"errorMessages");function _p(t){switch(t.type){case 0:return t.diagnosisMessage??R().noResultError.title;case 1:return R().genericServerError;default:return""}}i(_p,"getQuoteErrorMessage");import{i18n as Ir}from"@lingui/core";var uo=i(()=>({connectWallet:Ir.t("Connect Wallet"),swap:Ir.t("Swap"),swapAnyway:Ir.t("Swap anyway"),ethWarning:Ir.t("The route goes through Ethereum. Continue?")}),"swapButtonTitles");function xa(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(xa,"getFeeLabel");var Ea=["RECOMMENDED","CENTRALIZED","LOWEST_FEE","FASTEST","HIGH_IMPACT"],Dp=100,$p=30,Fp=15,Op=60;var Up=[{threshold:-10,minInput:400},{threshold:-5,minInput:1e3}],zp=[{threshold:-1,minInput:1e3},{threshold:-2,minInput:500}];import{getLastSuccessfulStep as jS}from"@rango-dev/queue-manager-rango-preset";import YW from"bignumber.js";function qp(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(qp,"getRequiredBalanceOfWallet");function _t(t){let e;return t<=-3&&t>-10?e="low":t<=-10&&(e="high"),e}i(_t,"getPriceImpactLevel");function Nr(t,e,o){let n=t.steps[0],r=t.steps[t.steps.length-1],a=jS(t.steps),s={blockchain:r.toBlockchain,symbol:r.toSymbol,address:r.toSymbolAddress},l=nn(a?a.toBlockchain:n.fromBlockchain,e),c=nn(r.toBlockchain,e),u=o(a?{blockchain:l?.name??"",symbol:a.toSymbol,address:a.toSymbolAddress}:{blockchain:l?.name??"",symbol:n.fromSymbol,address:n.fromSymbolAddress}),p=o(s),d=a?a.outputAmount??"":t.inputAmount;return{fromBlockchain:l,fromToken:u,toBlockchain:c,toToken:p,inputAmount:d}}i(Nr,"createRetryQuote");function Do(t){let{previousQuote:e,currentQuote:o,findToken:n,userSlippage:r}=t,a=Sn(o),s=ct(o);if(o&&a&&s){let u=Pt(a.toString(),s.toString());if(!!u&&jp(a,u)){let d=Br(o?.swaps,n),h=_t(u);return{type:0,inputUsdValue:a,outputUsdValue:s,priceImpact:u,totalFee:d,warningLevel:h}}}if(e&&Zp(e,o))return{type:4,usdValueChange:L(ct(o)?.minus(ct(e)??0).toString()??"0",null,2),percentageChange:L(Pt(ct(e)??"1",ct(o)??"1"),null,2)};if(o&&(!a||!s))return{type:1};let l=Mr(o.swaps),c=r>Rc;if(Yp(t.userSlippage.toString(),l)){if(c&&parseFloat(l??"0")<r)return{type:3,slippage:r.toString()}}else return{type:2,recommendedSlippages:Xp(o,r),minRequiredSlippage:l};return null}i(Do,"generateQuoteWarnings");function Hp(t){return![4].includes(t.type)}i(Hp,"isQuoteWarningConfirmationRequired");function Pt(t,e){let o=typeof e=="string"?parseFloat(e)<=0:!e?.gt(0),n=!t||!e||o?null:Ia(t.toString(),e.toString());return n&&n<0?n:null}i(Pt,"getPriceImpact");var Gp=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"),Wr=i((t,e)=>e.sort((o,n)=>{let r=i(u=>u.scores?.find(p=>p.preferenceType===t)?.score??0,"getScore"),a=r(o),s=r(n);if(a!==s)return s-a;let l=o.requestId.toLowerCase(),c=n.requestId.toLowerCase();return l.localeCompare(c)}),"sortQuotesBy"),Vp=i((t,e,o)=>{if(!e.length)return null;if(!t)return{requestAmount:o,validationStatus:null,...e[0]};let n=new Set(t.swaps.map(a=>a.swapperId)),r=e.find(a=>{let s=new Set(a.swaps.map(l=>l.swapperId));return Array.from(n).every(l=>s.has(l))});return{requestAmount:o,validationStatus:null,...r||e[0]}},"getDefaultQuote"),Kp=i(t=>{let e=i((o,n)=>{let r=Ea.indexOf(o.value),a=Ea.indexOf(n.value);return r!==-1&&a!==-1?r-a:r!==-1?-1:a!==-1?1:0},"customSort");return t.sort(e)},"sortTags");function jp(t,e){if(!t)return!1;let o=parseInt(e.toFixed(2)||"0");return Up.some(({threshold:n,minInput:r})=>o<=n&&t.gte(new Ue(r)))}i(jp,"hasHighValueLoss");function Jp(t){return(t||[]).filter(e=>{let o=e.fromAmountMinValue?new Ue(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ue(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(Jp,"hasLimitError");function Rp(t){let e=(t||[]).filter(l=>{let c=l.fromAmountMinValue?new Ue(l.fromAmountMinValue):null,u=l.fromAmountMaxValue?new Ue(l.fromAmountMaxValue):null;return l.fromAmountRestrictionType==="EXCLUSIVE"?c?.gte(l.fromAmount)||u?.lte(l.fromAmount):c?.gt(l.fromAmount)||u?.lt(l.fromAmount)})[0],o=e.fromAmountMinValue?new Ue(e.fromAmountMinValue):null,n=e.fromAmountMaxValue?new Ue(e.fromAmountMaxValue):null,r=e.fromAmountRestrictionType==="EXCLUSIVE",a="",s="";return!r&&o&&o.gt(e.fromAmount)?(a=gt.t({id:"Required: >= {min} {symbol}",values:{min:L(o,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.increaseAmount):r&&o&&o.gte(e.fromAmount)&&(a=gt.t({id:"Required: > {min} {symbol}",values:{min:L(o,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.increaseAmount),!r&&n&&n.lt(e.fromAmount)?(a=gt.t({id:"Required: <= {max} {symbol}",values:{max:L(n,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.decreaseAmount):r&&n&&n.lte(e.fromAmount)&&(a=gt.t({id:"Required: < {max} {symbol}",values:{max:L(n,6,6),symbol:e.from.symbol}}),s=R().bridgeLimitErrors.decreaseAmount),{swap:e,fromAmountRangeError:a,recommendation:s}}i(Rp,"getLimitErrorMessage");function eu(t){let{fetchMetaStatus:e,anyWalletConnected:o,fetchingQuote:n,inputAmount:r,quote:a,warning:s,error:l,needsToWarnEthOnPath:c}=t;return e!=="success"?{title:uo().connectWallet,action:"connect-wallet",disabled:!0}:o?n||!a||l||!r||r==="0"?{title:uo().swap,action:"confirm-swap",disabled:!0}:s?{title:uo().swapAnyway,action:"confirm-warning",disabled:!1}:c?{title:uo().ethWarning,action:"confirm-warning",disabled:!1}:{title:uo().swap,action:"confirm-swap",disabled:!1}:{title:uo().connectWallet,action:"connect-wallet",disabled:!1}}i(eu,"getSwapButtonState");function Aa(t,e,o){let n=parseFloat(e||"0");return!(t&&(!o||o.lte(ue))&&e&&e!=="0"&&n!==0)}i(Aa,"canComputePriceImpact");function Na(t,e){let o=ue;for(let n=0;n<t.fee.length;n++){let r=t.fee[n];if(r.expenseType==="DECREASE_FROM_OUTPUT")continue;let a=e(r.asset)?.usdPrice||null;o=o.plus(new Ue(r.amount).multipliedBy(a||0))}return o}i(Na,"getUsdFeeOfStep");function Br(t,e){return t.reduce((o,n)=>o.plus(Na(n,e)),ue)}i(Br,"getTotalFeeInUsd");function Wa(t){let e=ue;return e=e.plus(new Ue(t.amount).multipliedBy(t.price||0)),e}i(Wa,"getUsdFee");function tu(t){return t.reduce((e,o)=>e.plus(Wa(o)),ue)}i(tu,"getTotalFeesInUsd");function ou(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(ou,"getFeesGroup");function nu(t){let e=new Map;return t.forEach((o,n)=>{o.recommendedSlippage?.error&&e.set(n,o.recommendedSlippage.slippage)}),e.size>0?e:null}i(nu,"checkSlippageErrors");function Xp(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?o:null}i(Xp,"checkSlippageWarnings");function Mr(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(Mr,"getMinRequiredSlippage");function Yp(t,e){return e?parseFloat(t)>=parseFloat(e):!0}i(Yp,"hasProperSlippage");function ru(t){let{fromToken:e,toToken:o,inputAmount:n,wallets:r,selectedWallets:a,disabledLiquiditySources:s,liquiditySources:l,excludeLiquiditySources:c,slippage:u,affiliateRef:p,affiliatePercent:d,affiliateWallets:h,destination:f}=t,m=a?.reduce((S,T)=>(S[T.chain]=T.address,S),{}),g=[];return r?.forEach(S=>{g.push({blockchain:S.chain,addresses:[S.address]})}),{amount:n.toString(),affiliateRef:p??void 0,affiliatePercent:d??void 0,affiliateWallets:h??void 0,from:{address:e.address,blockchain:e.blockchain,symbol:e.symbol},to:{address:o.address,blockchain:o.blockchain,symbol:o.symbol},connectedWallets:g,selectedWallets:m??{},slippage:u.toString(),...f&&{destination:f},...c&&{swapperGroups:s.concat(l??[]),swappersGroupsExclude:!0},...!c&&{swapperGroups:l?.filter(S=>!s.includes(S)),swappersGroupsExclude:!1}}}i(ru,"createQuoteRequestBody");function iu(t){return t.reduce((o,n)=>(o[n.chain]={address:n.address,walletType:n.walletType},o),{})}i(iu,"getWalletsForNewSwap");function Sn(t){let e=t.requestAmount,o=t.swaps[0].from.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(Sn,"getUsdInputFrom");function ct(t){let e=t?.outputAmount||null,o=t.swaps[t.swaps.length-1].to.usdPrice;if(!(!e||!o))return new Ue(e).multipliedBy(o)}i(ct,"getUsdOutputFrom");function Ia(t,e){return new Ue(e).div(new Ue(t)).minus(1).multipliedBy(Dp).toNumber()}i(Ia,"getPercentageChange");function Zp(t,e){let o=Sn(t),n=ct(t),r=ct(e);if(!o||!n||!r)return!1;let a=Ia(n.toString(),r.toString());return zp.some(({threshold:s,minInput:l})=>a<=s&&o.isGreaterThanOrEqualTo(l))}i(Zp,"isOutputAmountChangedExcessively");function au(t,e,o){let n=t.validationStatus,r=io({filter:"required",quote:t});return e.sort((s,l)=>r.indexOf(s.chain)-r.indexOf(l.chain)).flatMap(s=>qp(s,n)||[]).filter(s=>!s.ok).map(s=>{let l=s.asset.symbol,c=L(new Ue(s.currentAmount.amount).shiftedBy(-s.currentAmount.decimals),8,8),u=L(new Ue(s.requiredAmount.amount).shiftedBy(-s.requiredAmount.decimals),8,8),p="";return s.reason==="FEE"&&(p=gt.t(" for network fee")),s.reason==="INPUT_ASSET"&&(p=gt.t(" for swap")),s.reason==="FEE_AND_INPUT_ASSET"&&(p=gt.t(" for input and network fee")),gt.t({id:"Needs \u2248 {requiredAmount} {symbol}{reason}, but you have {currentAmount} {symbol} in your {blockchain} wallet.",values:{requiredAmount:u,symbol:l,reason:p,currentAmount:c,blockchain:st(s.asset.blockchain,o)}})})}i(au,"generateBalanceWarnings");function Cn(t){return!!t&&t.networkStatus!==null&&t.networkStatus!==Lr.NetworkChanged}i(Cn,"isNetworkStatusInWarningState");function su(t,e){let o="bellow button or",n=t.extraMessage,r=t.extraMessageDetail;if(t.networkStatusExtraMessageDetail?.includes(o)&&(t.networkStatusExtraMessageDetail=t.networkStatusExtraMessageDetail.replace(o,"")),Cn(e))switch(n=t.networkStatusExtraMessage||"",r=t.networkStatusExtraMessageDetail||"",e?.networkStatus){case Lr.WaitingForConnectingWallet:n=n||gt.t("Waiting for connecting wallet");break;case Lr.WaitingForQueue:n=n||gt.t("Waiting for other running tasks to be finished");break;case Lr.WaitingForNetworkChange:n=n||gt.t("Waiting for changing wallet network");break;default:n=n||"";break}r=r||"",n=n||"";let s=n?.indexOf("code")!==-1&&n?.indexOf("reason")!==-1;return{shortMessage:n,detailedMessage:{content:r,long:s}}}i(su,"getSwapMessages");function lu(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(lu,"getLastConvertedTokenInFailedSwap");function cu(t){return t.status==="failed"}i(cu,"shouldRetrySwap");function pu(t,e,o,n,r,a){if(!n||t)return!0;let s=io({filter:"all",quote:n}),l=io({filter:"required",quote:n}),c=s.every(d=>r.some(h=>h.chain===d)),u=l.every(d=>r.some(h=>h.chain===d)),p=o&&a?Eo(a,o):!1;return!e&&!c||e&&!o||e&&!!o&&(!p||!u)}i(pu,"isConfirmSwapDisabled");function uu(t,e){return t.blockchain===e.blockchain&&t.symbol===e.symbol&&t.address===e.address}i(uu,"isTokensIdentical");var Pr=i((t,e)=>t?.usdPrice?new Ke(e||ue).multipliedBy(t?.usdPrice||0):null,"getUsdValue"),O=Bo(XS()(YS(t=>({fromBlockchain:null,fromToken:null,inputAmount:"",outputAmount:null,inputUsdValue:new Ke(0),outputUsdValue:new Ke(0),toBlockchain:null,toToken:null,refetchQuote:!0,sortStrategy:"SMART",selectedQuote:null,quotes:null,error:null,warning:null,quoteWalletsConfirmed:!1,selectedWallets:[],customDestination:null,quoteWarningsConfirmed:!1,updateQuotePartialState:(e,o)=>t(n=>({...n,[e]:o})),setSelectedQuote:e=>t(o=>{let n=null,r=ue,a=o.inputUsdValue;return sn(o.inputAmount)?(e&&(n=e?.outputAmount?new Ke(e?.outputAmount):null,a=Sn(e)??ue,r=ct(e)??ue),{selectedQuote:e,...!!e&&{outputAmount:n,outputUsdValue:r,inputUsdValue:a}}):{}}),resetAlerts:()=>t(()=>({error:null,warning:null})),resetQuote:()=>t(()=>({selectedQuote:null,outputAmount:null,outputUsdValue:new Ke(0),quotes:null,refetchQuote:!0,error:null,warning:null})),setFromBlockchain:e=>{t(o=>o.fromBlockchain?.name===e?.name?{}:{fromBlockchain:e,inputUsdValue:new Ke(0),...o.fromToken&&{selectedQuote:null,fromToken:null,outputAmount:null,outputUsdValue:new Ke(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:Pr(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 Ke(0)}})},setToToken:e=>t(()=>({toToken:e.token,...e.token&&{toBlockchain:e.meta.blockchains.find(o=>o.name===e.token.blockchain)??null}})),setInputAmount:e=>{t(o=>({inputAmount:e,...!e&&{outputAmount:null,outputUsdValue:new Ke(0),selectedQuote:null},...!!o.fromToken&&{inputUsdValue:Pr(o.fromToken,e)}}))},retry:e=>{let{fromBlockchain:o,fromToken:n,toBlockchain:r,toToken:a,inputAmount:s}=e;t({fromBlockchain:o,fromToken:n,inputAmount:s,outputAmount:null,inputUsdValue:Pr(n??null,s),outputUsdValue:new Ke(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?Pr(e.toToken,e.outputAmount?.toString()||""):new Ke(0)})),resetFromBlockchain:()=>t(()=>({fromToken:null,fromBlockchain:null,outputUsdValue:new Ke(0),inputUsdValue:new Ke(0),inputAmount:"",outputAmount:null,selectedQuote:null})),resetToBlockchain:()=>t(()=>({toToken:null,toBlockchain:null,outputAmount:null,outputUsdValue:new Ke(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})})))),du=O.subscribe((t,e)=>{(t.fromBlockchain!==e.fromBlockchain||t.fromToken!==e.fromToken||t.toBlockchain!==e.toBlockchain||t.toToken!==e.toToken||t.inputAmount!==e.inputAmount)&&he.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&&he.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})});function mu(){let{setInputAmount:t,setToToken:e,setToBlockchain:o,setFromBlockchain:n,resetQuote:r,setFromToken:a,fromToken:s,toToken:l,fromBlockchain:c,toBlockchain:u}=O(),p=y().config,d=y().fetchStatus,h=y().blockchains(),f=y().tokens(),{findToken:m}=y(),{setAffiliateRef:g,setAffiliatePercent:C,setAffiliateWallets:S}=y(),T=p?.from?.tokens,k=p?.from?.blockchains,v=p?.to?.tokens,w=p?.to?.blockchains,A=_r(void 0),M=_r(void 0),b=_r(void 0),E=_r(void 0);$o(()=>{typeof p.amount<"u"&&t(p.amount.toString())},[p?.amount]),$o(()=>{if(d==="success"){r();let x=h.find(B=>B.name===p?.from?.blockchain),N=p?.from?.token,I=N&&m(N);(x||!x&&b.current)&&n(x??null),I?a({token:I,meta:{blockchains:h,tokens:f}}):!I&&A.current&&a({token:null}),b.current=p?.from?.blockchain,A.current=p?.from?.token}},[p?.from?.token?.symbol,p?.from?.token?.address,p?.from?.token?.blockchain,p?.from?.blockchain,d]),$o(()=>{sa(s,T)&&a({token:null}),la(c,k)&&n(null)},[T,k]),$o(()=>{sa(l,v)&&a({token:null}),la(u,w)&&o(null)},[v,w]),$o(()=>{if(d==="success"){r();let x=h.find(B=>B.name===p?.to?.blockchain),N=p?.to?.token,I=N&&m(N);(x||!x&&E.current)&&o(x??null),I?e({token:I,meta:{blockchains:h,tokens:f}}):!I&&M.current&&e({token:null}),E.current=p?.to?.blockchain,M.current=p?.to?.token}},[p?.to?.token?.symbol,p?.to?.token?.address,p?.to?.token?.blockchain,p?.to?.blockchain,d]),$o(()=>{g(p?.affiliate?.ref??null),C(p?.affiliate?.percent??null),S(p?.affiliate?.wallets??null)},[p?.affiliate?.ref,p?.affiliate?.percent,p?.affiliate?.wallets])}i(mu,"useSyncStoresWithConfig");import{useEffect as La,useRef as ZS}from"react";import{useInRouterContext as JS,useLocation as RS,useSearchParams as eC}from"react-router-dom";function Ba(t,e){let o=t.split("--");return{blockchain:e.name,address:o?.[1]||null,symbol:o[0]}}i(Ba,"convertTokenSearchParamToAsset");function Ma(t){if(t)return`${t.symbol}${t.address?`--${t.address}`:""}`}i(Ma,"tokenToSearchParam");function _a(){let t=RS(),[e,o]=eC(),{fromBlockchain:n,toBlockchain:r,fromToken:a,toToken:s,inputAmount:l,setFromBlockchain:c,setToBlockchain:u,setFromToken:p,setToToken:d,setInputAmount:h}=O(),f=y().fetchStatus,m=y().blockchains(),g=y().tokens(),C=JS(),{updateIframe:S,updateCampaignMode:T}=y(),k=y().isInCampaignMode(),v=ZS(),{findToken:w}=y(),A=i(()=>{let b={};for(let[X,se]of e.entries())X.startsWith("utm_")&&(b[X]=se);let E=e.get("fromAmount"),x=e.get("fromBlockchain"),N=e.get("fromToken"),I=e.get("toBlockchain"),B=e.get("toToken"),j=e.get("autoConnect"),te=e.get("clientUrl"),J=e.get("liquiditySources"),P=e.get("blockchain");return{fromAmount:E,fromBlockchain:x,fromToken:N,toBlockchain:I,toToken:B,autoConnect:j,clientUrl:te,liquiditySources:J,utmQueryParams:b,blockchain:P}},"getUrlSearchParams"),M=i(b=>{for(let E in b)b[E]||delete b[E];o(b,{replace:!0})},"updateUrlSearchParams");La(()=>{let{autoConnect:b,clientUrl:E,utmQueryParams:x,blockchain:N}=A();C&&f==="success"&&M({fromBlockchain:n?.name,fromToken:Ma(a),toBlockchain:r?.name,toToken:Ma(s),fromAmount:l,autoConnect:b??void 0,clientUrl:E??void 0,blockchain:N??void 0,liquiditySources:k?v.current:void 0,...x})},[t.pathname,l,n,a,r,s,k]),La(()=>{if(!C)return;let b=A();if(!v.current&&b.liquiditySources&&(v.current=b.liquiditySources),b.fromAmount&&h(b.fromAmount),f==="success"){let E=m.find(B=>B.name===b.fromBlockchain),x=b.fromToken&&E?w(Ba(b.fromToken,E)):void 0,N=m.find(B=>B.name===b.toBlockchain),I=b.toToken&&N?w(Ba(b.toToken,N)):void 0;E&&(c(E),x&&p({token:x,meta:{blockchains:m,tokens:g}})),N&&(u(N),I&&d({token:I,meta:{blockchains:m,tokens:g}}))}},[f]),La(()=>{let{clientUrl:b,liquiditySources:E}=A();S("clientUrl",b||void 0),T("liquiditySources",E?.split(",")??void 0)},[])}i(_a,"useSyncUrlAndStore");import{i18n as It}from"@lingui/core";import{Alert as fk,Button as Ku,darkTheme as gk,Divider as vn,DoneIcon as hk,MessageBox as yk,styled as Sk,TextField as Ck,Typography as kk}from"@rango-dev/ui";import ye,{useEffect as Tk,useState as Qr}from"react";import{useNavigate as vk,useSearchParams as wk}from"react-router-dom";import{ChevronRightIcon as tC,Divider as Su,Image as oC,Typography as Cu}from"@rango-dev/ui";import ht from"react";import{darkTheme as fu,styled as Da}from"@rango-dev/ui";var gu=Da("div",{display:"flex",justifyContent:"space-between",width:"100%",height:"$40",padding:"$4 $10",borderRadius:"$sm",cursor:"pointer",alignItems:"center",backgroundColor:"$neutral300",[`.${fu} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${fu} &`]:{backgroundColor:"$neutral500"}},variants:{disabled:{true:{cursor:"default","&:hover":{borderColor:"$neutral300","& svg":{color:"$neutral700"}}}}}}),hu=Da("div",{display:"flex",flexDirection:"column",width:"100%",".title_typography":{textTransform:"capitalize"}}),yu=Da("div",{display:"flex"});function $a(t){let{onClick:e,value:o,title:n,hasLogo:r,placeholder:a,disabled:s}=t;return ht.createElement(hu,null,ht.createElement(Cu,{size:"large",variant:"label"},n),ht.createElement(Su,{size:10}),ht.createElement(gu,{onClick:s?void 0:e,disabled:s},ht.createElement(yu,null,r&&ht.createElement(ht.Fragment,null,ht.createElement(oC,{src:o?.logo,size:16,useAsPlaceholder:!o?.logo,type:"circular"}),ht.createElement(Su,{size:4,direction:"horizontal"})),ht.createElement(Cu,{className:"title_typography",size:"medium",variant:"label"},o?.name||a)),ht.createElement(tC,{size:12,color:"black"})))}i($a,"BlockchainSelectorButton");import{i18n as Oa}from"@lingui/core";import{Button as nC,Divider as kn,ExternalLinkIcon as rC,Image as iC,Typography as Oo}from"@rango-dev/ui";import Ne from"react";function ku(t,e){if(e.type==="COSMOS")return"";let o=e.info?.addressUrl;return!o||!t?"":o.replace("{wallet}",t)}i(ku,"generateExplorerLink");import{darkTheme as Fo,styled as Tu}from"@rango-dev/ui";var Fa=Tu("a",{textDecoration:"none",color:"$colors$neutral700",[`.${Fo} &`]:{color:"$colors$neutral900"},"& svg":{marginLeft:"$4",color:"$colors$neutral700",[`.${Fo} &`]:{color:"$colors$neutral900"}},variants:{hasHover:{true:{"&:hover":{color:"$colors$secondary550",[`.${Fo} &`]:{color:"$colors$secondary500"},"& svg":{color:"$colors$secondary550",[`.${Fo} &`]:{color:"$colors$secondary500"}}}},false:{}}}}),vu=Tu("div",{display:"flex",justifyContent:"center",flexDirection:"column",alignItems:"center",textAlign:"center","& ._blockchain-name, & ._coin-source":{color:"$colors$neutral600",[`.${Fo} &`]:{color:"$colors$neutral800"}},"& ._coin-source-name, & ._custom-token-description":{color:"$colors$neutral700",[`.${Fo} &`]:{color:"$colors$neutral900"}}});function Ua(t){let{open:e,onClose:o,token:n,onSubmitClick:r,blockchain:a}=t,s=ku(n.address,a);return Ne.createElement(Z,{open:e,dismissible:!0,onClose:o,container:W()},Ne.createElement(vu,null,Ne.createElement(iC,{src:n.image,size:45,type:"circular"}),Ne.createElement(Oo,{variant:"title",size:"medium"},n.name),Ne.createElement(Oo,{variant:"body",size:"small",className:"_blockchain-name"},a.displayName),Ne.createElement(kn,{size:4}),Ne.createElement(Oo,{variant:"body",size:"medium"},s?Ne.createElement(Fa,{hasHover:!0,href:s,target:"_blank",rel:"nofollow noreferrer"},n.address,Ne.createElement(rC,{size:12,color:"gray"})):Ne.createElement(Fa,null,n.address)),Ne.createElement(kn,{size:4}),n.coinSource&&Ne.createElement(Oo,{className:"_coin-source",variant:"body",size:"xsmall"},Oa.t("via")," ",Ne.createElement(Oo,{className:"_coin-source-name",variant:"body",size:"xsmall"},n.coinSource)),Ne.createElement(kn,{size:"32"}),Ne.createElement(Oo,{size:"medium",variant:"body",className:"_custom-token-description"},Oa.t("This token doesn't appear on the active token list(s). Make sure this is the token that you want to trade."))),Ne.createElement(kn,{size:40}),Ne.createElement(kn,{size:10}),Ne.createElement(nC,{id:"widget-custom-token-modal-import-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:r},Oa.t("Import")))}i(Ua,"CustomTokenModal");import{useManager as lk}from"@rango-dev/queue-manager-react";import{BottomLogo as ck,Divider as Qu,Header as pk}from"@rango-dev/ui";import Be,{useEffect as ls,useRef as qu,useState as uk}from"react";import{useRef as aC}from"react";function Dr(){return window.self!==window.top}i(Dr,"isAppLoadedIntoIframe");function za(){let t=aC(null),{iframe:e}=y(),o=Dr()&&e.clientUrl,n=i(s=>{o&&window.top?.postMessage(s,e.clientUrl)},"send");return{send:n,connectHeightObserver:i(s=>{t.current=new ResizeObserver(l=>{for(let c of l)n({type:"widget_height",data:{height:c.contentRect.height}})}),t.current.observe(s)},"connectHeightObserver"),disconnectHeightObserver:i(()=>{t.current&&(t.current.disconnect(),t.current=null)},"disconnectHeightObserver")}}i(za,"useIframe");import{useNavigate as sC}from"react-router-dom";function je(){let t=sC();return()=>t(-1)}i(je,"useNavigateBack");import{createTheme as ja,darkTheme as TC,lightTheme as vC}from"@rango-dev/ui";import{useEffect as wC,useState as bC}from"react";import{theme as CC,darkColors as kC}from"@rango-dev/ui";import Va from"react";function lC(t){return t.startsWith("#")&&(t=t.slice(1)),t.length===3?`#${t.split("").reduce(function(n,r){return n+r+r},"")}`:`#${t}`}i(lC,"expandShortHexColor");function cC(t){return/[0-9]+$/.test(t)}i(cC,"isOverridingColor");function pC(t,e){return t.padStart(e,"0")}i(pC,"pad");function Qa(t){let e=Math.min(Math.max(Math.round(t),0),255);return pC(e.toString(16),2)}i(Qa,"intToHex");function uC(t){return`#${Qa(t.red)}${Qa(t.green)}${Qa(t.blue)}`}i(uC,"rgbToHex");function dC(t){let e=parseInt(t.slice(1,3),16),o=parseInt(t.slice(3,5),16),n=parseInt(t.slice(5,7),16);return{red:e,green:o,blue:n}}i(dC,"hexToRGB");function mC(t,e){let o=1-.11*e;return{red:t.red*o,green:t.green*o,blue:t.blue*o}}i(mC,"generateShade");function fC(t,e){let o=.11*e;return{red:t.red+(255-t.red)*o,green:t.green+(255-t.green)*o,blue:t.blue+(255-t.blue)*o}}i(fC,"generateTint");function gC(t){return wu(t,mC)}i(gC,"calculateShades");function hC(t){return wu(t,fC)}i(hC,"calculateTints");function wu(t,e){let o=dC(t),n=[];for(let r=1;r<9;r++)n.push(uC(e(o,r)));return n}i(wu,"calculateColors");function qa(t,e,o){let a=hC(t).reverse().concat(t),s=gC(t),l=a.concat(s),c={},u=l.length;for(let p=0;p<u;p++){let d=100+(o?u-1-p:p)*50;c[`${e}${d}`]=l[p]}return c}i(qa,"createTintsAndShades");function Ha(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)&&!cC(r)){let c=lC(a);Object.assign(n,qa(c,r,s))}}return{...n,...e}}i(Ha,"expandToGenerateThemeColors");var bu=i(t=>String.fromCharCode(t+(t>25?39:97)),"toAlphabeticChar"),yC=i(t=>{let e="",o;for(o=Math.abs(t);o>52;o=o/52|0)e=bu(o%52)+e;return bu(o%52)+e},"toAlphabeticName"),SC=i((t,e)=>{let o=e.length;for(;o;)t=t*33^e.charCodeAt(--o);return t},"toPhash"),Ga=i(t=>yC(SC(5381,JSON.stringify(t))>>>0),"toHash");function Ka(t){let e=CC.colors,o={...e,...kC},n,r;if(t?.light){let s={colors:Ha(e,t.light)};n={id:`${aa}-light-${Ga(s)}`,tokens:s}}if(t?.dark){let s={colors:Ha(o,t.dark,{reverseNeutralRange:!0})};r={id:`${aa}-dark-${Ga(s)}`,tokens:s}}return{light:n,dark:r}}i(Ka,"customizedThemeTokens");function xu(t,e){if(t.length<=1)return t.map(({element:n,key:r})=>Va.cloneElement(n,{key:r}));let o=[];return t.forEach((n,r)=>{let{element:a,key:s}=n;if(o.push(Va.cloneElement(a,{key:s})),r<t.length-1){let l=`divider-${r}`;o.push(Va.cloneElement(e,{key:l}))}}),o}i(xu,"joinList");function Eu(){return window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}i(Eu,"doesWindowPreferDarkColorScheme");function Uo(t){let{colors:e,fontFamily:o=Cc,borderRadius:n=Qc,secondaryBorderRadius:r=qc}=t,[a,s]=bC(Eu()?"dark":"light"),{theme:l}=y(),{dark:c,light:u}=Ka(e),p=ja({shadows:t.shadows||{},radii:{primary:`${n}px`,secondary:`${r}px`},fonts:{widget:o}}),d=[p.className,vC.className],h=[p.className,TC.className];if(u){let m=ja(u.id,u.tokens);d.push(m.className)}if(c){let m=ja(c.id,c.tokens);h.push(m.className)}return wC(()=>{let m=i(g=>{g.matches?s("dark"):s("light")},"switchThemeListener");return Eu()&&s("dark"),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",m),()=>{window.matchMedia("(prefers-color-scheme: dark)").removeEventListener("change",m)}},[]),{activeTheme:i(()=>{let m=d.join(" "),g=h.join(" ");return l==="auto"?a==="dark"?g:m:l==="dark"?g:m},"getActiveTheme"),mode:l==="auto"?a:l}}i(Uo,"useTheme");var pt=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 Iu}from"@lingui/core";import{Alert as xC,Button as EC}from"@rango-dev/ui";import Au from"react";function Xa(t){return Au.createElement(xC,{action:Au.createElement(EC,{id:"widget-active-tab-btn",onClick:t.onActivateTab,variant:"contained",size:"xxsmall",type:"warning"},Iu.t("Activate this tab")),type:"warning",variant:"alarm",title:Iu.t("Another tab is open and handles transactions.")})}i(Xa,"ActivateTabAlert");import{i18n as Ya}from"@lingui/core";import{Button as IC,Divider as AC,MessageBox as NC}from"@rango-dev/ui";import $r from"react";function Za(t){let{open:e,onClose:o,onConfirm:n}=t;return $r.createElement(Z,{open:e,dismissible:!0,onClose:o,container:W()},$r.createElement(NC,{title:Ya.t("Activate current tab"),type:"warning",description:Ya.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.")},$r.createElement(AC,{size:20}),$r.createElement(IC,{id:"widget-modal-confirm-activate-tab-btn",variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:n},Ya.t("Confirm"))))}i(Za,"ActivateTabModal");import{ChevronLeftIcon as WC}from"@rango-dev/ui";import Nu from"react";function Ja(t){return Nu.createElement(Et,{id:"widget-header-back-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},Nu.createElement(WC,{color:"black",size:16}))}i(Ja,"BackButton");import{i18n as BC}from"@lingui/core";import{Button as MC,Typography as LC}from"@rango-dev/ui";import Ra from"react";function es(t){return Ra.createElement(Vt,null,Ra.createElement(MC,{id:"widget-header-cancel-btn",variant:"ghost",onClick:t.onClick,size:"xsmall"},Ra.createElement(LC,{variant:"label",size:"medium",color:"error500"},BC.t("Cancel"))))}i(es,"CancelButton");import{i18n as PC}from"@lingui/core";import{Image as _C,Tooltip as DC,WalletIcon as $C}from"@rango-dev/ui";import mo from"react";function ts(t){let{list:e}=ft(),o=e.filter(r=>r.state==="connected"),n=o.length?mo.createElement("div",{className:Sp()},o.map(r=>mo.createElement(Sr,{key:r.title},mo.createElement(_C,{src:r.image,size:14})))):PC.t("Connect Wallet");return mo.createElement(DC,{container:t.container,side:"bottom",content:n},mo.createElement(Et,{id:"widget-header-wallet-icon-btn",variant:"ghost",size:"small",onClick:t.onClick},t.isConnected&&mo.createElement(fp,null),mo.createElement($C,{size:18,color:"black"})))}i(ts,"WalletButton");import{i18n as Or}from"@lingui/core";import{NotificationsIcon as RC,Popover as ek,SettingsIcon as tk,Tooltip as Ur,TransactionIcon as ok}from"@rango-dev/ui";import We from"react";import{Notifications as zC}from"@rango-dev/ui";import QC from"react";import{useNavigate as qC}from"react-router-dom";import{create as FC}from"zustand";import{persist as OC,subscribeWithSelector as UC}from"zustand/middleware";var be=Bo(FC()(OC(UC((t,e)=>({isSynced:!1,notifications:[],setNotification:(o,n)=>{let r=n.steps[0],a=n.steps[n.steps.length-1],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}}},l=e().notifications.filter(c=>c.requestId!==n.requestId);t(()=>({notifications:[...l,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(c=>c.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 os(){let t=qC(),{getNotifications:e,clearNotifications:o}=be(),n=e(),r=y().blockchains(),{findToken:a}=y();return QC.createElement(zC,{list:n,getBlockchainImage:l=>pc(l,r)??"",getTokenImage:l=>a(l)?.image??"",onClickItem:i(l=>{t(`${$.swaps}/${l}`)},"onClickItem"),onClearAll:o})}i(os,"NotificationContent");import{useManager as HC}from"@rango-dev/queue-manager-react";import{InProgressIcon as GC}from"@rango-dev/ui";import Wu from"react";var VC=i(()=>{let{manager:t}=HC();return pt(t).map(({swap:o})=>o).find(o=>o.status==="running")?Wu.createElement(yp,null,Wu.createElement(GC,{color:"info",size:6})):null},"InProgressTransactionBadge"),Bu=VC;import{EventSeverity as KC}from"@rango-dev/queue-manager-rango-preset";import{Typography as jC}from"@rango-dev/ui";import Mu from"react";function Lu(){let{getNotifications:t}=be(),e=t(),o=e.length,n=!!e.find(r=>r.event.messageSeverity===KC.WARNING);return o?Mu.createElement(gp,{isSever:n},Mu.createElement(jC,{variant:"body",size:"xsmall",color:"$background"},o)):null}i(Lu,"NotificationsBadge");import{RefreshProgressButton as XC}from"@rango-dev/ui";import ns,{useEffect as YC,useState as Pu}from"react";var ZC=1e3,_u=60,JC=100;function Fr({onClick:t}){let[e,o]=Pu(0),[n,r]=Pu(!1),a=i(c=>{document.hidden&&c&&s(c)},"handleVisibilityChange");YC(()=>{let c;return t?c=window.setInterval(()=>{o(u=>u+1),e===_u&&l()},ZC):s(c),document.addEventListener("visibilitychange",()=>a(c)),()=>{document.removeEventListener("visibilitychange",()=>a(c)),c&&clearInterval(c)}},[e,t]);let s=i(c=>{c&&clearInterval(c),o(0)},"clearTimeout"),l=i(()=>{t?.(),o(0),r(!0)},"handleRefreshClick");return ns.createElement(Et,{id:"widget-header-refresh-icon-btn",variant:"ghost",size:"small",style:{paddingTop:0,paddingBottom:0},onClick:l,disabled:!t},ns.createElement(hp,{onTransitionEnd:()=>r(!1),isRefetched:n},ns.createElement(XC,{size:22,color:t?"black":"gray",progress:e/_u*JC})))}i(Fr,"RefreshButton");function fo(t){let{onClickRefresh:e,onClickHistory:o,onClickSettings:n,hidden:r=[],container:a}=t,{config:{features:s}}=y(),l=Ve("notification",s)||r.includes("notifications");return We.createElement(We.Fragment,null,!r.includes("refresh")&&We.createElement(Ur,{container:a||W(),side:"top",content:Or.t("Refresh")},We.createElement(Fr,{onClick:e})),!l&&We.createElement(ek,{align:"end",alignOffset:-88,sideOffset:15,collisionPadding:{right:20,left:20},container:W(),content:We.createElement(os,null)},We.createElement("div",null,We.createElement(Ur,{container:W(),side:"top",content:Or.t("Notifications")},We.createElement(Et,{id:"widget-header-notification-icon-btn",size:"small",variant:"ghost"},We.createElement(RC,{size:18,color:"black"}),We.createElement(Lu,null))))),!r.includes("settings")&&We.createElement(Ur,{container:W(),side:"top",content:Or.t("Settings")},We.createElement(Et,{id:"widget-header-setting-icon-btn",size:"small",variant:"ghost",onClick:n},We.createElement(tk,{size:18,color:"black"}))),!r.includes("history")&&We.createElement(Ur,{container:W(),side:"top",content:Or.t("History")},We.createElement(Et,{id:"widget-header-history-icon-btn",size:"small",variant:"ghost",onClick:o},We.createElement(ok,{size:18,color:"black"}),We.createElement(Bu,null))))}i(fo,"HeaderButtons");import{i18n as rs}from"@lingui/core";import{Divider as $u,MessageBox as ik,RefreshIcon as ak}from"@rango-dev/ui";import zo from"react";import{Button as nk,styled as rk}from"@rango-dev/ui";var Du=rk(nk,{"& span":{display:"flex",justifyContent:"center",alignItems:"center"}});function is(t){let{open:e,onClose:o}=t;return zo.createElement(Z,{open:e,dismissible:!0,onClose:o,container:W()},zo.createElement(ik,{title:rs.t("Something went wrong"),type:"error",description:rs.t("Something went wrong. Please refresh the app.")},zo.createElement($u,{size:30}),zo.createElement(Du,{variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:()=>location.reload()},zo.createElement(ak,{size:20,color:"primary"}),zo.createElement($u,{size:4,direction:"horizontal"}),rs.t("Refresh"))))}i(is,"RefreshModal");function as(t){let e=t.target;if(e){let o=e.scrollTop,n=W();o>1?n.classList.add("rng-scrolled"):n.classList.remove("rng-scrolled")}}i(as,"onScrollContentAttachStatusToContainer");import{css as sk,styled as ss}from"@rango-dev/ui";var Fu="700px",zr=sk({borderRadius:"$primary",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"$mainContainer"}),Ou=ss("div",{position:"relative",width:"100vw",minWidth:"300px",maxWidth:"390px",backgroundColor:"$background",variants:{height:{auto:{height:"auto",maxHeight:Fu},fixed:{height:Fu}}}}),Uu=ss("div",{position:"relative",overflow:"hidden",flexGrow:1,display:"flex",flexDirection:"column",padding:0,overflowY:"auto"}),zu=ss("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"}}});function oe(t){let{connectHeightObserver:e,disconnectHeightObserver:o}=za(),{children:n,header:r,footer:a,height:s="fixed"}=t,{fetchStatus:l,connectedWallets:c}=y(),[u,p]=uk(!1),{config:{features:d,theme:h}}=y(),{watermark:f}=re(),m=f==="FULL",{activeTheme:g}=Uo(h||{}),C=Ve("connectWalletButton",d),{isActiveTab:S,tabManagerInitiated:T,showActivateTabModal:k,setShowActivateTabModal:v,activateCurrentTab:w}=re(),A=je(),{manager:M}=lk(),E=pt(M).map(({swap:te})=>te).some(te=>te.status==="running"),x=i(()=>w(ao.forceClaim,E),"onActivateTab"),N=i(()=>{r.onWallet?.()},"onConnectWallet"),I=typeof r.hasBackButton>"u"||r.hasBackButton,B=qu(null),j=qu(null);return ls(()=>(Dr()&&j.current&&e(j.current),()=>{o()}),[]),ls(()=>(B.current?.addEventListener("scroll",as),()=>{B.current?.removeEventListener("scroll",as)}),[]),ls(()=>{p(l==="failed")},[l]),Be.createElement(Ou,{height:s,id:De.SWAP_BOX_ID,className:`${g()} ${zr()}`,ref:j},Be.createElement(pk,{prefix:I?Be.createElement(Ja,{onClick:()=>{A(),r.onBack&&r.onBack()}}):null,title:r.title,suffix:Be.createElement(Be.Fragment,null,r.suffix,r.onWallet&&!C&&Be.createElement(ts,{container:W(),onClick:N,isConnected:!!c?.length}),r.onCancel&&Be.createElement(es,{onClick:r.onCancel}))}),Be.createElement(Uu,{ref:B},n),Be.createElement(Za,{open:k,onClose:()=>v(!1),onConfirm:x}),Be.createElement(zu,null,Be.createElement("div",{className:"footer__content"},T&&!S&&Be.createElement("div",{className:"footer__alert"},Be.createElement(Xa,{onActivateTab:x}),Be.createElement(Qu,{size:10})),a),Be.createElement(Qu,{size:12}),Be.createElement("div",{className:`footer__logo ${m?"logo__show":"logo__hidden"}`},Be.createElement(ck,null))),Be.createElement(is,{open:u,onClose:()=>p(!1)}))}i(oe,"Layout");import{styled as dk}from"@rango-dev/ui";var Hu="$20 $20 $10 $20",Tn=dk("div",{padding:Hu,overflowY:"auto",flexGrow:1});import{styled as mk}from"@rango-dev/ui";var ie=mk("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 Qo}from"@lingui/core";import{useState as Gu}from"react";function Vu(){let[t,e]=Gu(!1),[o,n]=Gu(void 0),{findToken:r}=y(),a=y().customTokens();function s(c,u){switch(c){case"duplicated":return{title:Qo.t("Duplicate Token"),message:Qo.t("The address you entered is duplicate, please enter a new address.")};case"token-exist":return{title:Qo.t("Token Already Exists"),message:Qo.t("There's no need to add this token again because it already exists and is supported by us.")};case"not-found":return{title:Qo.t("Token Not Found"),message:Qo.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:u}})}}}return i(s,"produceErrorMessage"),{fetchCustomToken:i(async({blockchain:c,tokenAddress:u})=>{e(!0);try{if(a.some(m=>m.address?.toLowerCase()===u.toLowerCase())){let m=s("duplicated");n(m);return}let d=await xt().getCustomToken({blockchain:c,address:u});if(!d||!d.token||d.error){let m=s("not-found",c);n(m);return}let h=d.token;if(r({blockchain:h.blockchain,address:h.address,symbol:h.symbol})){let m=s("token-exist");n(m);return}return h}catch(p){if(p?.code==="ERR_BAD_REQUEST"){let d=s("not-found",c);n(d);return}throw n(void 0),new Error(p.message)}finally{e(!1)}},"fetchCustomToken"),loading:t,error:o}}i(Vu,"useFetchCustomToken");var bk=Sk("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1,"& ._text-field":{padding:"$4 $10",backgroundColor:"$neutral300",[`.${gk} &`]:{backgroundColor:"$neutral400"},borderRadius:"$sm",height:"$40"}}),xk=1e3;function ju(){let t=vk(),[e]=wk(),o=je(),{setCustomToken:n}=y(),r=y().blockchains(),a=e.get("blockchain")||"",s=nn(a,r),[l,c]=Qr(""),[u,p]=Qr(!1),[d,h]=Qr(),{fetchCustomToken:f,loading:m,error:g}=Vu(),[C,S]=Qr(""),T=!!s&&Eo(s,l),k=!s||!l||!T,v=i(async()=>{if(s)try{let M=await f({blockchain:a,tokenAddress:l});S(""),M&&h(M)}catch(M){M.message==="Failed to fetch"&&(S(It.t("Network Error")),p(!0))}},"getCustomToken"),w=i(()=>{g&&c(""),p(!1)},"closeErrorModal"),A=i(async()=>{C&&setTimeout(async()=>{await v()},xk),w()},"handleErrorModalButtonClick");return Tk(()=>{g&&p(!0)},[g]),ye.createElement(oe,{header:{title:It.t("Add Custom Token")}},ye.createElement(ie,null,ye.createElement(bk,null,ye.createElement("div",null,ye.createElement($a,{onClick:()=>t($.blockchains,{replace:!0}),hasLogo:!!s?.logo,value:s?{name:s.displayName,logo:s.logo}:void 0,title:It.t("Select chain"),placeholder:It.t("Select chain")}),ye.createElement(vn,{size:"24"}),ye.createElement(kk,{size:"large",variant:"label"},It.t("Enter Address")),ye.createElement(vn,{size:10}),ye.createElement(Ck,{fullWidth:!0,disabled:!s,variant:"contained",placeholder:It.t("Enter token address"),size:"large",value:l,suffix:!!l&&T&&ye.createElement(hk,{color:"success",size:12}),onChange:M=>c(M.target.value)}),!T&&!!l&&ye.createElement(ye.Fragment,null,ye.createElement(vn,{size:4}),ye.createElement(fk,{type:"error",variant:"alarm",title:"Invalid Address"}))),ye.createElement(Ku,{id:"widget-add-custom-token-import-btn",disabled:k,type:"primary",variant:"contained",loading:m,size:"large",onClick:v},It.t("Import"))),ye.createElement(Z,{open:u,dismissible:!0,onClose:w,container:W()},ye.createElement(yk,{title:g?.title||C,type:"error",description:g?.message||It.t("Failed Network, Please retry.")},ye.createElement(vn,{size:40}),ye.createElement(vn,{size:10}),ye.createElement(Ku,{id:`widget-add-custom-token-${C?"retry":"add-another"}-btn`,variant:"contained",size:"large",type:"primary",fullWidth:!0,onClick:A},C?It.t("Retry"):It.t("Add another custom token")))),s&&d&&ye.createElement(Ua,{blockchain:s,token:d,onSubmitClick:()=>{d&&(n(d),h(void 0),o())},onClose:()=>h(void 0),open:!!s&&!!d})))}i(ju,"AddCustomTokenPage");import{i18n as Fs}from"@lingui/core";import{useManager as lv}from"@rango-dev/queue-manager-react";import{Alert as cv,Button as pv,css as Us,Divider as Os,IconButton as Qm,styled as uv,Typography as dv,WalletIcon as mv}from"@rango-dev/ui";import Le,{useEffect as hi,useLayoutEffect as fv,useRef as gv,useState as _n}from"react";import{useNavigate as hv}from"react-router-dom";import{i18n as go}from"@lingui/core";import{Alert as Yk,BalanceErrors as Zk,Button as vd,ChevronLeftIcon as Jk,Divider as hs,MessageBox as Rk,Typography as ys}from"@rango-dev/ui";import ee,{useCallback as eT,useEffect as wd,useMemo as tT,useState as Go}from"react";import{useNavigate as oT}from"react-router-dom";import{i18n as ds}from"@lingui/core";import{Alert as Wk,ChevronDownIcon as Bk,CloseIcon as Mk,Divider as td,IconButton as od,PasteIcon as Lk,Typography as Pk,WalletIcon as _k}from"@rango-dev/ui";import Me,{useEffect as Dk,useRef as $k}from"react";import Vr,{useRef as Ak}from"react";import*as qo from"@radix-ui/react-collapsible";import{keyframes as Xu,styled as qr}from"@rango-dev/ui";var cs=300,Ek=Xu({from:{height:0},to:{height:"var(--radix-collapsible-content-height)"}}),Ik=Xu({from:{height:"var(--radix-collapsible-content-height)"},to:{height:0}}),Yu=qr(qo.Root,{borderRadius:"$sm",overflow:"hidden",variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary500",outlineStyle:"solid"}}}}),ps=qr(qo.Trigger,{padding:"$0",border:"none",outline:"none",width:"100%",backgroundColor:"transparent",fontFamily:"inherit",cursor:"pointer"}),Hr=qr(qo.Content,{overflow:"hidden",variants:{open:{true:{animation:`${Ek} ${cs}ms ease-out`},false:{animation:`${Ik} ${cs}ms ease-out`}}}}),Gr=qr("div",{transition:`all ${cs}ms ease`,display:"flex",alignItems:"center",variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}});function Kr(t){let{open:e,hasSelected:o,onOpenChange:n,children:r,onClickTrigger:a,trigger:s,triggerAnchor:l}=t,c=Ak(null);return Vr.createElement(Yu,{ref:c,className:"collapsible_root",selected:o&&e,open:e,onOpenChange:n},l==="top"&&Vr.createElement(ps,{className:"collapsible_trigger",onClick:a},s),Vr.createElement(Hr,{className:"collapsible_content",open:e},r),l==="bottom"&&Vr.createElement(ps,{className:"collapsible_trigger",onClick:a},s))}i(Kr,"CustomCollapsible");import{darkTheme as Zu,styled as us,TextField as Nk}from"@rango-dev/ui";var Ju=us("div",{padding:"$10 $0","& .button__content":{display:"flex",alignItems:"center"},"& .alarms":{paddingTop:"$5"},"& .collapsible_content":{backgroundColor:"$neutral100"},"& .collapsible_root":{backgroundColor:"$neutral100"}}),Ru=us(Nk,{backgroundColor:"$neutral100",padding:"$15"}),ed=us("div",{width:"100%",borderRadius:"$sm",display:"flex",padding:"$15",justifyContent:"space-between",alignItems:"center",$$color:"$colors$neutral100",[`.${Zu} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomRightRadius:"0",borderBottomLeftRadius:"0","&:focus-visible":{$$background:"$colors$secondary100",[`.${Zu} &`]:{$$background:"$colors$info700"},backgroundColor:"$$background",outline:0}});function nd(t){let{blockchain:e,handleOpenChange:o,open:n}=t,{customDestination:r,setCustomDestination:a}=O(),{config:s}=y(),l=y().blockchains(),c=rr(e.name,l),u=$k(null),p=s?.defaultCustomDestinations?.[e.name],d=navigator?.userAgent.includes("Firefox"),f=n&&!!r&&e&&!Eo(e,r),m=i(()=>{a("")},"handleClear"),g=i(async S=>{if(S.preventDefault(),navigator.clipboard!==void 0){let T=await navigator.clipboard.readText();a(T),u?.current?.focus()}},"handlePaste"),C=i(()=>r?Me.createElement(od,{id:"widget-custom-destination-close-icon-btn",onClick:m,variant:"ghost"},Me.createElement(Mk,{size:12,color:"gray"})):d?null:Me.createElement(od,{id:"widget-custom-destination-paste-icon-btn",onClick:g,variant:"ghost"},Me.createElement(Lk,{size:16})),"renderSuffix");return Dk(()=>{!!p&&r===null&&(a(p),o(!0))},[p]),Me.createElement(Ju,null,Me.createElement(Kr,{onOpenChange:o,hasSelected:!0,open:n,triggerAnchor:"top",trigger:Me.createElement(ed,null,Me.createElement("div",{className:"button__content"},Me.createElement(_k,{size:18,color:"info"}),Me.createElement(td,{size:4,direction:"horizontal"}),Me.createElement(Pk,{variant:"label",size:"medium",color:n?"$neutral600":void 0},ds.t("Send to a different address"))),Me.createElement(Gr,{orientation:n?"up":"down"},Me.createElement(Bk,{size:10,color:"secondary"}))),onClickTrigger:()=>o(!n)},Me.createElement(Ru,{ref:u,style:{padding:0,paddingRight:r?"8px":"5px"},autoFocus:!r,placeholder:ds.t("Enter {blockchainName} address",{blockchainName:c}),value:r||"",suffix:C(),onChange:S=>{let T=S.target.value;a(T)}})),f&&Me.createElement(Me.Fragment,null,Me.createElement(td,{size:4}),Me.createElement(Wk,{variant:"alarm",type:"error",title:ds.t({values:{destination:r},id:"Address {destination} doesn't match the blockchain address pattern."})})))}i(nd,"CustomDestination");import{css as Fk,darkTheme as ms,IconButton as Ok,styled as Dt}from"@rango-dev/ui";var rd=Dt("div",{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"}),id=Dt("div",{display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),Uk=Dt("button",{borderRadius:"$xm",padding:"$10",border:"0",display:"flex",justifyContent:"center",$$color:"$colors$neutral100",[`.${ms} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",alignItems:"center",cursor:"pointer",width:110,position:"relative","&:hover":{$$color:"$colors$secondary100",[`.${ms} &`]:{$$color:"$colors$neutral100"},backgroundColor:"$$color"},"&:focus-visible":{$$color:"$colors$secondary100",[`.${ms} &`]:{$$color:"$colors$info700"},backgroundColor:"$$color",outline:0},variants:{selected:{true:{outlineWidth:1,outlineColor:"$secondary",outlineStyle:"solid"}}}}),ad=Dt(Uk,{alignSelf:"stretch",minHeight:"93px"}),sd=Dt("div",{padding:"$20 $20 $15 $20",display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"$neutral200",position:"relative",width:"100%"}),ld=Dt(Ok,{position:"absolute",left:"$20"}),cd=Dt("div",{paddingTop:"$20"}),pd=Fk({display:"flex",justifyContent:"space-evenly",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5",height:"100%"}),ud=Dt("div",{display:"flex"}),dd=Dt("div",{overflow:"visible",width:"100%"});import{i18n as Sd}from"@lingui/core";import{warn as Gk}from"@rango-dev/logging-core";import{Divider as Vk,SelectableWallet as Kk,Typography as Cd,WalletState as kd}from"@rango-dev/ui";import Xe,{useEffect as Td,useState as bn}from"react";import{Image as qk,MessageBox as Hk}from"@rango-dev/ui";import wn from"react";import{keyframes as zk,styled as fs}from"@rango-dev/ui";var md=fs("div",{position:"relative"}),Qk=zk({"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}),fd=fs("div",{position:"absolute",border:"2px solid rgba(0, 0, 0, 0.1)",borderTop:"2px solid $info500",borderRadius:"$lg",width:"$45",height:"$45",animation:`${Qk} 1s linear infinite`,top:0,bottom:0,right:0,left:0}),gd=fs("div",{"& img":{borderRadius:"50%"}});import{i18n as Ho}from"@lingui/core";function hd(t,e){switch(t){case"in-progress":return{type:"loading",title:Ho.t({id:"Add {blockchainDisplayName} Chain",values:{blockchainDisplayName:e}}),description:Ho.t({id:"Please approve the experimental chain pop-up in your wallet.",values:{blockchainDisplayName:e}})};case"completed":return{type:"success",title:Ho.t({id:"{blockchainDisplayName} Chain Added",values:{blockchainDisplayName:e}}),description:Ho.t({id:"The {blockchainDisplayName} chain has been successfully added to your wallet.",values:{blockchainDisplayName:e}})};case"rejected":return{type:"error",title:Ho.t("Request Rejected"),description:Ho.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(hd,"generateMessageByStatus");function yd(t){let{status:e,displayName:o,image:n}=t,r=hd(e,o),a=e=="in-progress";return wn.createElement(Hk,{type:r.type,title:r.title,description:r.description,icon:a?wn.createElement(md,null,wn.createElement(gd,null,wn.createElement(qk,{src:n,size:45})),wn.createElement(fd,null)):void 0})}i(yd,"ExperimentalChainStatus");var jk=7,Xk=3e3;function gs(t){let{chain:e,isSelected:o,selectWallet:n,limit:r,onShowMore:a}=t,s=re.use.isActiveTab(),{blockchains:l,connectedWallets:c}=y(),[u,p]=bn(),[d,h]=bn(null),[f,m]=bn(!1),[g,C]=bn(null),{suggestAndConnect:S}=jr(),{handleDisconnect:T}=Gt(),{list:k}=ft({chain:e}),[v,w]=bn(k),A=k.length,M=r&&A-r>0,b=i(async x=>{m(!1),C("in-progress");try{await S(x.walletType,x.chain),C("completed")}catch{C("rejected")}},"addExperimentalChain");Td(()=>{w(x=>{let N=k.findIndex(I=>o(I.type,e));return M&&N>1?[k[N]].concat(k.filter((I,B)=>B!==N)):x.map(I=>k.find(B=>B.type===I.type)??I)})},[JSON.stringify(k)]);let E=document.getElementById(De.SWAP_BOX_ID);return Td(()=>{let x=null;return(g==="completed"||g==="rejected")&&(x=setTimeout(()=>C(null),Xk)),()=>{x&&clearTimeout(x)}},[g]),Xe.createElement(Xe.Fragment,null,v.slice(0,r).map(x=>{let N=Dc({connectedWallets:c,walletType:x.type,chain:e}),I=N?gr(N,jk):"",B=fr(l(),e),j=!c.find(se=>se.walletType===x.type&&se.chain===e),te=B&&j&&x.state===kd.CONNECTED,J=te?Sd.t({id:"Add {chain} chain",values:{chain:e}}):I,P=i(async()=>{let se=x.state===kd.DISCONNECTED,z=(x.isHub||!!x.needsNamespace)&&!I;se?p(x):z?(await T(x.type),p(x)):te?(h({walletType:x.type,chain:e,address:N??""}),m(!0)):n({walletType:x.type,chain:e,address:N??""})},"onSelectableWalletClick"),X=d?.chain?rr(d.chain,l()):void 0;return Xe.createElement(Xe.Fragment,{key:`${x.title}_${X}`},!!d&&Xe.createElement(Z,{open:!!d&&f,container:E,onClose:()=>{h(null)}},Xe.createElement(wa,{displayName:X,onConfirm:()=>{b(d)}})),g&&Xe.createElement(Z,{open:!!g,onClose:C.bind(null,null),container:E},Xe.createElement(yd,{status:g,displayName:X,image:x.image}),Xe.createElement(Vk,{direction:"vertical",size:32})),Xe.createElement(Kk,{key:x.type,description:J,onClick:P,selected:o(x.type,e),disabled:!s,...x}))}),Xe.createElement(po,{wallet:u,onClose:()=>{p(void 0)},onConnect:x=>{t.onConnect&&x.status==="connected"&&(u?.type?t.onConnect(u.type):Gk(new Error("The selected wallet hasn't been detected after the connection process finished. It usually shouldn't happen.")))}}),M&&Xe.createElement(ad,{selected:!1,onClick:a},Xe.createElement(Cd,{variant:"label",size:"medium"},Sd.t("Show more wallets"),Xe.createElement(Cd,{variant:"label",size:"medium",color:"$primary"},"\xA0+",A-(r??0)))))}i(gs,"WalletList");var nT=2;function bd(t){let{open:e,onClose:o,onCancel:n,onCheckBalance:r,loading:a}=t,s=oT(),l=y().blockchains(),{selectedQuote:c,setSelectedWallets:u,quoteWalletsConfirmed:p,setQuoteWalletConfirmed:d,customDestination:h,setCustomDestination:f}=O(),{config:m,connectedWallets:g,setWalletsAsSelected:C}=y(),[S,T]=Go(""),[k,v]=Go([]),[w,A]=Go(""),[M,b]=Go(!!h),E=tT(()=>io({filter:"all",quote:c}),[c]),x=io({filter:"required",quote:c}),N=l.find(_=>_.name===c?.swaps[c?.swaps.length-1].to.blockchain),I=i(_=>x.includes(_),"isWalletRequiredFor"),B=eT(()=>g.filter(_=>_.selected&&E.includes(_.chain)),[g,E]),[j,te]=Go(B()),[J,P]=Go([]),X=i((_,H)=>P(V=>V.concat({blockchain:_,walletType:H})),"addNextSelectedWallets"),se=k.length>0,z=i((_,H)=>!!j.find(V=>V.walletType===_&&V.chain===H&&V.selected&&(I(H)||!I(H)&&!h)),"isSelected"),me=i((_,H,V)=>{let fe=!1;return _.map(ne=>{if(ne.chain===H){let ge=ne.selected;return!fe&&V?(fe=!0,ge=!0):V||(ge=!1),{...ne,selected:ge}}return ne})},"updateSelectableWallets"),vt=i(_=>{b(_),_?I(N?.name??"")||te(H=>me(H,N?.name||"",!1)):(f(""),te(H=>me(H,N?.name||"",!0)))},"handleCustomDestinationCollapsibleOpenChange"),Ze=i(_=>{if(S&&T(""),z(_.walletType,_.chain))return;let V=g.find(fe=>fe.walletType===_.walletType&&fe.chain===_.chain);V&&(n(),_.chain===N?.name&&M&&!I(N.name)&&(b(!1),f(null)),te(fe=>fe.filter(ne=>ne.chain!==_.chain).concat({...V,selected:!0})))},"onChange"),le=i(()=>{let _=j.filter(H=>H.selected);C(_),u(_),d(!0),o()},"onConfirmBalance"),at=i(async()=>{v([]),A("");let _=await r?.({selectedWallets:j.filter(V=>V.selected),customDestination:h}),H=_.warnings;H?.balance?.messages&&v(H.balance.messages),_.error&&A(_p(_.error)),!_.error&&!H?.balance?.messages.length?le():v(H?.balance?.messages??[])},"onConfirmWallets");wd(()=>{te(_=>{let H=[];return _.forEach(V=>{!g.some(ne=>ne.chain===V.chain&&ne.walletType===V.walletType&&ne.address===V.address)||H.push(V)}),H=H.concat(g.filter(V=>!!!H.find(ne=>ne.chain===V.chain)&&V.selected&&E.includes(V.chain))),H})},[g,E]),wd(()=>{let _=[];J.length>0&&(J.forEach(H=>{let V=g.find(fe=>fe.chain===H.blockchain&&fe.walletType===H.walletType);V?Ze(V):_.push(H)}),P(_))},[g,J]);let G=document.getElementById(De.SWAP_BOX_ID);return ee.createElement(Z,{open:e,onClose:()=>{p||s("../",{replace:!0}),o()},dismissible:!S,container:G,...!S&&{styles:{container:{height:"100%"}},footer:ee.createElement(ud,null,ee.createElement(vd,{id:"widget-confirm-wallet-modal-confirm-btn",loading:a,disabled:pu(a,M,h,c,j,N),onClick:at,variant:"contained",type:"primary",fullWidth:!0,size:"large"},go.t("Confirm")))},...S&&{styles:{container:{height:"100%",padding:"$0"}},header:ee.createElement(sd,null,ee.createElement(ld,{id:"widget-confirm-wallet-modal-navigate-back-icon-btn",variant:"ghost",onClick:T.bind(null,"")},ee.createElement(Jk,{size:16})),ee.createElement(ys,{variant:"headline",size:"small"},go.t({id:"Your {blockchainName} wallets",values:{blockchainName:st(S,l)}})))},anchor:"center"},ee.createElement(Z,{open:se,onClose:v.bind(null,[]),container:G},ee.createElement(Rk,{title:go.t("Insufficient account balance"),type:"error",description:ee.createElement(Zk,{messages:k??[]})},ee.createElement(vd,{id:"widget-confirm-wallet-modal-proceed-anyway-btn",variant:"outlined",size:"large",type:"primary",fullWidth:!0,onClick:le},go.t("Proceed anyway")))),S&&ee.createElement(cd,null,ee.createElement("div",{className:pd()},ee.createElement(gs,{chain:S,isSelected:z,selectWallet:Ze,onShowMore:()=>T(S),onConnect:_=>{X(S,_)}}))),!S&&ee.createElement(ee.Fragment,null,w&&ee.createElement(ee.Fragment,null,ee.createElement(Yk,{variant:"alarm",type:"error",title:go.t(w)}),ee.createElement(hs,{size:12})),ee.createElement(dd,null,E.map((_,H)=>{let V=l.find(Fe=>Fe.name===_),fe=`wallet-${H}`,ne=H===E.length-1,ge=ne&&N&&m?.customDestination!==!1;return ee.createElement("div",{key:fe},ee.createElement(rd,null,ee.createElement(ys,{variant:"title",size:"xmedium"},go.t({id:"Your {blockchainName} wallets",values:{blockchainName:V?.shortName}})),ee.createElement(ys,{variant:"label",color:"$neutral700",size:"medium"},go.t({id:"You need to connect a {blockchainName} wallet.",values:{blockchainName:V?.shortName}}))),ee.createElement(hs,{size:24}),ee.createElement(id,null,ee.createElement(gs,{chain:_,isSelected:z,selectWallet:Ze,limit:nT,onShowMore:()=>T(V?.name??""),onConnect:Fe=>{X(_,Fe)}})),!ne&&ee.createElement(hs,{size:32}),ge&&ee.createElement(nd,{blockchain:N,open:M,handleOpenChange:vt}))}))))}i(bd,"ConfirmWalletsModal");import{i18n as vT}from"@lingui/core";import{Alert as wT,Button as bT,InfoIcon as xT}from"@rango-dev/ui";import et from"react";import{Alert as aT,Button as sT,Divider as ks,NoRouteIcon as lT,RefreshIcon as cT,Typography as Bd}from"@rango-dev/ui";import Re from"react";import{i18n as xd}from"@lingui/core";var rT=24,iT=60;function Ed(t,e,o,n){return t?.type===1?{alert:{type:"warning",text:R().genericServerError,action:{onClick:n,title:xd.t("Retry")}},description:""}:e.length?{alert:{type:"warning",text:R().liquiditySourcesError.title,action:{onClick:()=>o(!0),title:xd.t("Reset")}},description:R().liquiditySourcesError.description}:t?.type===0&&t.diagnosisMessage?{alert:{type:"error",text:t.diagnosisMessage,action:null},description:""}:{alert:null,description:R().noResultError.description}}i(Ed,"makeInfo");var Ss=(o=>(o[o.small=rT]="small",o[o.large=iT]="large",o))(Ss||{}),Cs=(o=>(o.small="small",o.large="medium",o))(Cs||{});import{styled as Xr}from"@rango-dev/ui";var Id=Xr("div",{display:"flex",flexDirection:"column",alignItems:"center"}),Ad=Xr("div",{variants:{size:{small:{},large:{maxWidth:"316px"}}}}),Nd=Xr("div",{variants:{size:{small:{width:"100%"},large:{}}}}),Wd=Xr("div",{padding:"$6 $0"});function xn(t){let{fetch:e,error:o,size:n="small"}=t,r=y().getDisabledLiquiditySources(),a=y().toggleAllLiquiditySources,s=y().swappers(),l=Ed(o,r,()=>a(s,!0),e);return Re.createElement(Id,null,Re.createElement(lT,{size:Ss[n],color:"gray"}),Re.createElement(ks,{size:4}),Re.createElement(Bd,{variant:"title",size:Cs[n]},R().noResultError.title),n==="large"&&Re.createElement(ks,{size:4}),!!l.description&&Re.createElement(Ad,{size:n},Re.createElement(Bd,{variant:"body",size:"small",align:"center",color:"neutral700"},l.description)),Re.createElement(ks,{size:n==="large"?"24":"4"}),!!l.alert&&Re.createElement(Nd,{size:n},Re.createElement(aT,{type:l.alert.type,title:l.alert.text,titleAlign:"left",action:l.alert.action&&Re.createElement(sT,{size:"xsmall",id:"widget-no-result-alert-btn",type:l.alert.type,prefix:Re.createElement(Wd,null,Re.createElement(cT,{size:8})),onClick:l.alert.action.onClick},l.alert.action.title),variant:"alarm"})))}i(xn,"NoResult");import{i18n as En}from"@lingui/core";import{Button as uT,Divider as dT,MessageBox as mT,Typography as fT,WarningIcon as gT}from"@rango-dev/ui";import $t from"react";import{Typography as _d}from"@rango-dev/ui";import vs from"react";import{darkTheme as pT,styled as Yr}from"@rango-dev/ui";var Md=Yr("div",{width:"100%"}),Ts=Yr("div",{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"$5",width:"100%"}),Ld=Yr("div",{display:"flex",padding:"$5 0",justifyContent:"space-between",alignItems:"center",width:"100%","._title":{$$color:"$colors$neutral600",[`.${pT} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Pd=Yr("div",{padding:"$2",alignSelf:"flex-start",cursor:"pointer"});function Dd(t){let{title:e,value:o,valueColor:n}=t;return vs.createElement(Ld,null,vs.createElement(_d,{size:"medium",variant:"label",className:"_title"},e),vs.createElement(_d,{size:"large",variant:"label",color:n||"foreground"},`${n?"%":"$"}${o}`))}i(Dd,"QuoteErrorsModalItem");function $d(t){let{open:e,onClose:o,onConfirm:n,warning:r,confirmationDisabled:a}=t,s=r.warningLevel==="high"?"error":"warning",l=[{title:En.t("Swapping"),value:L(r.inputUsdValue,4,4)},{title:En.t("Gas cost"),value:L(r.totalFee,2,2)},{title:En.t("Receiving"),value:L(r.outputUsdValue,4,4)},{title:En.t("Price impact"),value:L(r.priceImpact,2,2),valueColor:`${s}500`}];return $t.createElement(Z,{footer:$t.createElement(uT,{id:"widget-high-value-loss-warning-modal-confirm-btn",type:"primary",size:"large",prefix:$t.createElement(gT,null),fullWidth:!0,disabled:a,onClick:n},R().highValueLossError.confirmMessage),open:e,onClose:o,container:W()},$t.createElement(mT,{type:s,title:R().highValueLossError.impactTitle,description:R().highValueLossError.description}),$t.createElement(Ts,null,$t.createElement(dT,{size:"4"}),$t.createElement(fT,{size:"small",variant:"title"},En.t("Details")),$t.createElement(Ts,null,l.map((c,u)=>$t.createElement(Dd,{key:u,...c})))))}i($d,"HighValueLossWarningModal");import{i18n as Zr}from"@lingui/core";function Fd(t,e){let o={alertType:"warning",title:"",action:null};if(e)return o.alertType="error",e.type===3&&(o.title=e.recommendation),e.type===4&&(o.title=Zr.t({id:"You need to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:e.minRequiredSlippage}}),o.action="change-settings"),o;if(t){switch(t.type){case 0:{_t(t.priceImpact)==="high"&&(o.alertType="error"),o.action="show-info",o.title=R().highValueLossError.title;break}case 4:{o.title=Zr.t({id:"Output amount changed by {percentageChange}% (${usdValueChange}).",values:{percentageChange:t.percentageChange,usdValueChange:t.usdValueChange}});break}case 1:{o.title=R().unknownPriceError.title;break}case 2:{o.title=Zr.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:t.minRequiredSlippage}}),o.action="change-settings";break}case 3:{o.title=Zr.t("Caution, your slippage is high."),o.action="change-settings";break}default:break}return o}return null}i(Fd,"makeAlerts");import{i18n as Vo}from"@lingui/core";import{Button as Od,Divider as Ud,MessageBox as hT,Typography as yT}from"@rango-dev/ui";import ho from"react";import{useNavigate as ST}from"react-router-dom";function zd(t){let{customSlippage:e,slippage:o}=y(),{open:n,onClose:r,onConfirm:a,warning:s,confirmationDisabled:l}=t,c=ST(),u=e??o;return ho.createElement(Z,{anchor:"bottom",open:n,prefix:ho.createElement(Od,{size:"small",id:"widget-slippage-warning-modal-change-settings-btn",variant:"ghost",onClick:()=>c("../"+$.settings)},ho.createElement(yT,{variant:"label",size:"medium",color:"$neutral900"},Vo.t("Change settings"))),container:W(),onClose:r},ho.createElement(hT,{type:"warning",title:s.type===3?Vo.t("High slippage"):Vo.t("Low slippage"),description:s.type===3?Vo.t({id:" Caution, your slippage is high (={userSlippage}). Your trade may be front run.",values:{userSlippage:u}}):Vo.t({id:"We recommend you to increase slippage to at least {minRequiredSlippage} for this route.",values:{minRequiredSlippage:s.minRequiredSlippage}})},ho.createElement(Ud,{size:18}),ho.createElement(Ud,{size:32}),ho.createElement(Od,{id:"widget-slippage-warning-modal-confirm-anyway-btn",size:"large",type:"primary",variant:"contained",fullWidth:!0,disabled:l,onClick:a},Vo.t("Confirm anyway"))))}i(zd,"SlippageWarningModal");import{Button as CT,MessageBox as kT,WarningIcon as TT}from"@rango-dev/ui";import Jr from"react";function Qd(t){let{open:e,onClose:o,onConfirm:n,confirmationDisabled:r}=t;return Jr.createElement(Z,{footer:Jr.createElement(CT,{id:"widget-unknown-price-warning-modal-confirm-btn",type:"primary",size:"large",prefix:Jr.createElement(TT,null),fullWidth:!0,disabled:r,onClick:n},R().unknownPriceError.confirmMessage),open:e,onClose:o,container:W()},Jr.createElement(kT,{type:"warning",title:R().unknownPriceError.impactTitle,description:R().unknownPriceError.description}))}i(Qd,"UnknownPriceWarningModal");function In(t){let{warning:e,error:o,couldChangeSettings:n,showWarningModal:r,confirmationDisabled:a,refetchQuote:s,onOpenWarningModal:l,onCloseWarningModal:c,onConfirmWarningModal:u,onChangeSettings:p}=t,d={confirmationDisabled:a,open:r,onClose:c,onConfirm:u},h=o?.type===0||o?.type===1,f=Fd(e,o?.type===3||o?.type===4?o:null);return f&&!n&&(f.action=null),et.createElement(et.Fragment,null,h&&et.createElement(xn,{error:o,fetch:s}),!!f&&et.createElement(Md,null,et.createElement(wT,{title:f.title,type:f.alertType,variant:"alarm",...f.action==="show-info"&&{action:et.createElement(Pd,{onClick:l},et.createElement(xT,{size:12,color:"gray"}))},...f.action==="change-settings"&&{action:et.createElement(bT,{id:"widget-quote-warning-error-change-settings-btn",size:"xxsmall",type:f.alertType,onClick:p},vT.t("Change"))}})),e&&et.createElement(et.Fragment,null,e.type===0&&et.createElement($d,{...d,warning:e}),(e.type===3||e.type===2)&&et.createElement(zd,{...d,warning:e}),e.type===1&&et.createElement(Qd,{...d,warning:e})))}i(In,"QuoteWarningsAndErrors");import ov from"bignumber.js";import di from"react";import{i18n as yo}from"@lingui/core";import{Alert as qT,Divider as jo,FullExpandedQuote as HT,InfoIcon as GT,NumericTooltip as km,QuoteTag as VT,StepDetails as KT,TokenAmount as jT,Typography as Xo}from"@rango-dev/ui";import Bs from"bignumber.js";import F,{useRef as XT,useState as YT}from"react";import{styled as ws}from"@rango-dev/ui";var bs=ws("div",{width:"100%","& .position-top__skeleton":{paddingTop:"$10"}}),qd=ws("div",{paddingBottom:"$15",variants:{dense:{true:{paddingBottom:0}}}}),Hd=ws("div",{width:"100%",display:"flex"});import*as Rr from"@radix-ui/react-collapsible";import{Button as ET,css as An,darkTheme as xe,Image as Gd,styled as ze,Typography as IT}from"@rango-dev/ui";var AT=300,Vd=ze(Rr.Root,{display:"flex",flexDirection:"column",alignItems:"start",overflowX:"auto",overflowY:"hidden",width:"100%",borderRadius:"$xm",variants:{selected:{true:{},false:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${xe} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}]}),Kd=An({padding:"$10 $15"}),jd=ze(ET,{backgroundColor:"transparent",border:"1px solid $secondary550",[`.${xe} &`]:{border:"1px solid $secondary"},transition:"background-color 0.3s ease","&:hover":{backgroundColor:"$secondary550",[`.${xe} &`]:{backgroundColor:"$secondary"},".allRoutesLabel":{$$color:"$colors$background",[`.${xe} &`]:{$$color:"$colors$foreground"},color:"$$color",transition:"color 0.3s ease"}}}),Xd=ze("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",[`.${xe} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color"}},basic:{true:{borderTopRightRadius:"0",borderTopLeftRadius:"0"}},listItem:{true:{$$color:"$colors$neutral200",[`.${xe} &`]:{$$color:"$colors$neutral500"},backgroundColor:"$$color","&:hover":{"& .quote_container":{"& button":{backgroundColor:"$neutral500",[`.${xe} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral500",[`.${xe} &`]:{backgroundColor:"$neutral200"}},backgroundColor:"$neutral300",[`.${xe} &`]:{backgroundColor:"$neutral400"}},cursor:"pointer"},false:{}}},compoundVariants:[{listItem:!0,selected:!0,css:{outline:"1px solid $secondary"}},{listItem:!1,selected:!0,css:{$$color:"$colors$secondary100",[`.${xe} &`]:{$$color:"$colors$secondary550"},backgroundColor:"$$color","&:hover":{backgroundColor:"$$color"}}},{listItem:!0,selected:!1,css:{cursor:"pointer","&:hover":{backgroundColor:"$neutral300",[`.${xe} &`]:{backgroundColor:"$neutral400"}}}}]}),Yd=An({width:"100%",padding:"$15 $15 $10 $15"}),Zd=An({display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingBottom:"$10",position:"relative"}),Ko=An({display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",".blockchainImage":{marginLeft:"-$8"}}),Jd=An({display:"flex",alignItems:"center",".usd-value":{$$color:"$colors$neutral600",[`.${xe} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Rd=ze(Rr.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:{[`& ${Gd}`]:{border:"1px $warning500 solid",borderRadius:"100%"}},false:{[`& ${Gd}`]:{border:"1px transparent solid",borderRadius:"100%"}}},selected:{true:{},false:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"}},listItem:{true:{$$color:"$colors$neutral400",[`.${xe} &`]:{$$color:"$colors$neutral200"},backgroundColor:"$$color"},false:{}}},compoundVariants:[{listItem:!1,selected:!0,css:{$$color:"$colors$secondary200",[`.${xe} &`]:{$$color:"$colors$secondary800"},backgroundColor:"$$color"}}],".blockchains_section":{display:"none"},"@xs":{".blockchains_section":{display:"block"}}}),em=ze("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"}}}}),tm=ze(Hr,{width:"100%",background:"inherit"}),xs=ze("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$2",transition:`all ${AT}ms ease`,variants:{orientation:{down:{transform:"rotate(0)"},up:{transform:"rotate(180deg)"}}}}),PF=ze("div",{height:"$12",marginLeft:"$10",marginRight:"$10",borderLeft:"1px solid $foreground"}),om=ze("div",{display:"flex",justifyContent:"center",margin:"0 $15",borderTop:"1px solid",$$color:"$colors$neutral300",[`.${xe} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color"}),nm=ze("div",{width:"$16",height:"$16",justifyContent:"center",alignItems:"center",display:"flex"}),Es=ze(IT,{overflow:"hidden",textOverflow:"ellipsis",letterSpacing:.4}),rm=ze("div",{display:"flex",flexWrap:"wrap"}),Is=ze("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"}}}}),im=ze("div",{display:"flex"}),ei=ze("div",{width:"100%",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"$neutral",margin:"$5 0",[`.${xe} &`]:{borderTopColor:"$neutral800"}});import{i18n as At}from"@lingui/core";import{ChevronDownIcon as WT,CloseIcon as BT,Divider as ni,IconButton as MT,NumericTooltip as LT,QuoteCost as PT,Typography as yt}from"@rango-dev/ui";import Y,{useState as cm}from"react";import{css as NT,styled as ti}from"@rango-dev/ui";var oi=ti("div",{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"$5 0","&.total_payable_fee":{padding:"$12 0"}}),As=ti("div",{width:"100%",borderTop:"1px solid $neutral300",margin:"$10 0"}),am=ti("div",{padding:"$20 0",display:"flex",flexDirection:"column","& .collapsible_trigger":{display:"flex",alignItems:"center"}}),sm=ti("div",{padding:"$20 $20 $10",position:"relative","._icon-button":{position:"absolute",zIndex:10,top:"$16",right:"$16"}}),lm=NT({display:"flex",flexDirection:"row",alignItems:"center",padding:"$5","&:hover":{"& ._typography, & svg":{color:"$secondary"}}});var _T=i(t=>t.fee.isZero()?null:Y.createElement(oi,null,Y.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},t.label),Y.createElement(yt,{variant:"label",size:"medium"},"$",L(t.fee,4,4))),"NonPayableFee");function Ns(t){let[e,o]=cm(!1),[n,r]=cm(!1),{steps:a,quote:s,fee:l,time:c,feeWarning:u,timeWarning:p,showModalFee:d,fullExpandedMode:h=!1}=t,f=s?.swaps??[],m=h?no():W(),g=ou(f);return Y.createElement(Y.Fragment,null,Y.createElement(PT,{onClickFee:d?C=>{C.stopPropagation(),o(!e)}:void 0,fee:l,feeWarning:u,timeWarning:p,time:c,steps:a,tooltipGas:d?At.t("View more info"):void 0,tooltipContainer:m}),Y.createElement(Z,{container:m,open:e,anchor:h?"center":"bottom",styles:{container:{maxWidth:h?"484px":"unset"}},header:Y.createElement(sm,{style:{textAlign:h?"left":"center"}},Y.createElement(yt,{variant:"title",size:"medium"},At.t("Gas & Fee Explanation")),Y.createElement(MT,{id:"widget-quote-cost-details-modal-close-icon-btn",onClick:()=>o(!1),variant:"ghost"},Y.createElement(BT,{color:"gray",size:14}))),onClose:()=>{o(!1)}},Y.createElement(am,null,Y.createElement(yt,{variant:"title",size:"small"},At.t("Details")),Y.createElement(ni,{size:10}),Object.entries(g.payable).flatMap(([C,S])=>S.map((T,k)=>{let v=`payable-fee-${k}`,w=Wa(T);return Y.createElement(oi,{key:v},Y.createElement(yt,{variant:"label",size:"medium",color:"neutral600"},xa(C,At.t)),Y.createElement(LT,{content:T.amount,container:m},Y.createElement(yt,{variant:"label",size:"medium"},L(T.amount,2,2)," ",T.asset.symbol," ($",L(w,4,4),")")))})),Y.createElement(oi,{className:"total_payable_fee"},Y.createElement(yt,{variant:"label",size:"medium"},At.t("Total Payable Fee")),Y.createElement(yt,{variant:"label",size:"medium"},"$",L(l,4,4))),Y.createElement(As,null),Object.keys(g.nonePayable).length&&Y.createElement(Kr,{triggerAnchor:"bottom",onClickTrigger:()=>r(C=>!C),trigger:Y.createElement("div",{className:lm()},Y.createElement(yt,{size:"small",variant:"body",color:"neutral700"},n?At.t("Hide non-payable fees"):At.t("Show non-payable fees")),Y.createElement(ni,{size:4,direction:"horizontal"}),Y.createElement(Gr,{orientation:n?"up":"down"},Y.createElement(WT,{size:12,color:"gray"}))),open:n},Y.createElement(yt,{size:"small",variant:"title"},At.t("Description")),Y.createElement(ni,{size:4}),Y.createElement(yt,{size:"small",variant:"body",color:"neutral700"},At.t(`The following fees are considered in the transaction output and
|
|
2
|
+
you won\u2019t need to pay extra gas for them.`)),Y.createElement(ni,{size:10}),Object.entries(g.nonePayable).map(([C,S],T)=>{let k=tu(S),v=xa(C,At.t),w=`non-payable-fee-${T}`;return Y.createElement(_T,{key:w,fee:k,label:v})}),Y.createElement(As,null)))))}i(Ns,"QuoteCostDetails");import{i18n as dm}from"@lingui/core";import{TokenAmount as mm}from"@rango-dev/ui";import ri from"react";import{css as DT,styled as $T}from"@rango-dev/ui";var pm=$T("div",{position:"relative",display:"flex",flexDirection:"column",width:"100%"}),um=DT({height:"14px",marginLeft:"14px",position:"absolute",borderLeft:"1px solid $foreground",top:"42%"});function Nn(t){let{from:e,to:o,percentageChange:n,warningLevel:r}=t;return ri.createElement(pm,null,ri.createElement(mm,{direction:"horizontal",label:dm.t("Swap input"),type:"input",tooltipContainer:W(),price:{value:e.price.value,usdValue:e.price.usdValue,realValue:e.price.realValue,realUsdValue:e.price.realUsdValue},token:{displayName:e.token.displayName,image:e.token.image},chain:{image:e.chain.image}}),ri.createElement("div",{className:um()}),ri.createElement(mm,{direction:"horizontal",tooltipContainer:W(),label:dm.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(Nn,"QuoteSummary");import{i18n as Sm}from"@lingui/core";import{ChevronDownIcon as UT,ChevronRightIcon as zT,Divider as Ws,Image as QT,Tooltip as ci,Typography as ai}from"@rango-dev/ui";import U from"react";import{useLayoutEffect as FT,useState as Wn}from"react";var fm=480,gm=768,hm=1024,ym=1200,OT=i(()=>{let[t,e]=Wn(!1),[o,n]=Wn(!1),[r,a]=Wn(!1),[s,l]=Wn(!1),[c,u]=Wn(!1),p=i(()=>{e(window.innerWidth<=fm),n(window.innerWidth>fm&&window.innerWidth<=gm),a(window.innerWidth>gm&&window.innerWidth<=hm),l(window.innerWidth>hm&&window.innerWidth<=ym),u(window.innerWidth>ym)},"handleResize");return FT(()=>(p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)),[]),{isMobile:t,isTablet:o,isNotebook:r,isLargeScreen:s,isExtraLargeScreen:c}},"useScreenDetect"),ii=OT;var si=4,li=6,Bn=i(t=>{let{content:e,src:o,className:n,open:r,state:a,container:s}=t,l=s||W();return U.createElement(ci,{container:l,side:"bottom",sideOffset:4,open:r,content:e},U.createElement(em,{className:n,state:a},U.createElement(QT,{src:o,size:16})))},"ImageComponent");function Cm(t){let{quoteRef:e,selected:o,setExpanded:n,steps:r,expanded:a,type:s,container:l}=t,c=l||W(),u=r.length,p=Gp(r),{isTablet:d,isMobile:h}=ii();return U.createElement(Rd,{listItem:s==="list-item",ref:f=>e.current=f,selected:o,onClick:f=>{f.stopPropagation(),n(m=>!m)}},U.createElement("div",{className:Ko()},U.createElement(ai,{variant:"body",size:"xsmall"},Sm.t("Via:")),U.createElement(Ws,{direction:"horizontal",size:4}),r.map((f,m)=>{let g=`item-${m}`,C=U.createElement(xs,null,U.createElement(zT,{size:12,color:"black"}));return h||d?U.createElement(U.Fragment,{key:g},U.createElement(Bn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),m!==u-1&&U.createElement(U.Fragment,null,C)):U.createElement(U.Fragment,{key:g},u<=si||u>si&&m<si-1?U.createElement(U.Fragment,null,U.createElement(Bn,{content:f.swapper.displayName,src:f.swapper.image,state:f.state,container:l}),m!==u-1&&U.createElement(U.Fragment,null,C)):m===si-1&&U.createElement(ci,{container:c,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Ko()},C,r.map((S,T)=>{let k=`image-${T}`;return T>=m&&U.createElement(U.Fragment,{key:k},U.createElement(Bn,{content:S.swapper.displayName,src:S.swapper.image,state:S.state,open:!1}),T!==u-1&&U.createElement(U.Fragment,null,C))}))},U.createElement(Is,{state:r.find((S,T)=>T>=m&&(S.state==="error"||S.state==="warning"))?.state},U.createElement(ai,{size:"xsmall",variant:"body"},"+",u-m))))})),U.createElement("div",{className:Ko()},U.createElement("div",{className:"blockchains_section"},U.createElement("div",{className:Ko()},U.createElement(ai,{variant:"body",size:"xsmall"},Sm.t("Chains:")),U.createElement(Ws,{direction:"horizontal",size:4}),p.map((f,m)=>U.createElement(U.Fragment,{key:f.displayName},p.length<=li||p.length>li&&m<li-1?U.createElement(ci,{container:c,side:"bottom",content:f.displayName,sideOffset:4},U.createElement(Bn,{content:"",src:f.image,open:!1,className:m!==0?"blockchainImage":""})):m===li-1&&U.createElement(ci,{container:c,side:"bottom",align:"end",sideOffset:4,content:U.createElement("div",{className:Ko()},p.map((g,C)=>C>=m&&U.createElement(Bn,{key:g.displayName,content:"",src:g.image,open:!1,className:C>m?"blockchainImage":"",container:l})))},U.createElement(Is,{className:"blockchainImage"},U.createElement(ai,{size:"xsmall",variant:"body"},"+",p.length-m))))),U.createElement(Ws,{direction:"horizontal",size:32}))),U.createElement(xs,{orientation:a?"up":"down"},U.createElement(UT,{size:12,color:"black"}))))}i(Cm,"QuoteTrigger");function Ms(t){let{quote:e,input:o,output:n,error:r,warning:a,type:s,selected:l=!1,tagHidden:c=!0,showModalFee:u=!0,onClickAllRoutes:p,fullExpandedMode:d=!1,container:h}=t,f=y().blockchains(),{findToken:m}=y(),g=y().swappers(),{customSlippage:C,slippage:S}=y(),T=C||S,[k,v]=YT(t.expanded),w=XT(null),A=L(o.value,6,6),M=L(n.value,6,6),b=n.usdValue?L(n.usdValue,4,4):"",E=Pt(o.usdValue,n.usdValue??null),x=L(E,2,2),N=_t(E??0),I=i((le,at)=>le.map((G,_)=>{let H,V=r?.type===3&&r.swap.swapperId===G.swapperId,fe=r?.type===4&&r.recommendedSlippages?.has(_),ne=a?.type===2&&a.recommendedSlippages?.has(_),ge=V||fe,Fe=ne;ge?H="error":Fe&&(H="warning");let ve=ge?yo.t("Slippage Error"):yo.t("Slippage Warning");return V&&(ve=yo.t("Bridge Limit Error")),{swapper:{displayName:on(G.swapperId,g)??"",image:G.swapperLogo},from:{token:{displayName:G.from.symbol,image:G.from.logo},chain:{displayName:st(G.from.blockchain,f)??"",image:G.from.blockchainLogo},price:{value:_===0&&!at?L(o.value,6,6):L(G.fromAmount,6,6),usdValue:L((G.from.usdPrice??0)*parseFloat(G.fromAmount),4,4),realValue:_===0?o.value:G.fromAmount,realUsdValue:new Bs(G.from.usdPrice??0).multipliedBy(G.fromAmount).toString()}},to:{token:{displayName:G.to.symbol,image:G.to.logo},chain:{displayName:st(G.to.blockchain,f)||"",image:G.to.blockchainLogo},price:{value:L(G.toAmount,6,6),usdValue:L((G.to.usdPrice??0)*parseFloat(G.toAmount),4,4),realValue:G.toAmount,realUsdValue:new Bs(G.to.usdPrice??0).multipliedBy(G.toAmount).toString()}},state:H,alerts:ge||Fe?F.createElement(qd,{dense:d},F.createElement(qT,{variant:"alarm",type:ge?"error":"warning",title:ve,footer:F.createElement(Hd,null,V&&F.createElement("div",null,F.createElement(Xo,{size:"xsmall",variant:"body",color:"neutral900"},r.fromAmountRangeError),F.createElement(jo,{direction:"vertical",size:2}),F.createElement(Xo,{size:"xsmall",variant:"body",color:"neutral900"},yo.t({id:"Yours: {amount} {symbol}",values:{amount:L(G.fromAmount,6,6),symbol:G?.from.symbol}}))),(fe||ne)&&!V&&F.createElement("div",null,F.createElement(Xo,{size:"xsmall",variant:"body",color:"neutral900"},yo.t({id:"Minimum required slippage: {minRequiredSlippage}",values:{...r?.type===4&&{minRequiredSlippage:r.recommendedSlippages?.get(_)},...a?.type===2&&{minRequiredSlippage:a.recommendedSlippages?.get(_)}}})),F.createElement(jo,{direction:"vertical",size:2}),F.createElement(Xo,{size:"xsmall",variant:"body",color:"neutral900"},yo.t({id:"Yours: {userSlippage}",values:{userSlippage:T}}))))})):void 0,time:an(G.estimatedTimeInSeconds),fee:L(Na(G,m),2,2),internalSwaps:G.internalSwaps?I(G.internalSwaps):void 0}}),"getQuoteSteps"),B=I(e?.swaps??[]),j=B.length,te=h||W(),J=Kp(t.quote.tags||[]),P=!!p,X=pr(e?.swaps),se=an(X),z=Br(e?.swaps??[],m),me=L(z,2,2),vt=z.gte(new Bs($p)),Ze=X/Op>=Fp;return d?F.createElement(HT,{selected:l,fee:me,time:se,tooltipContainer:no(),steps:B,tags:J,quoteCost:F.createElement(Ns,{quote:e,fullExpandedMode:!0,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:u,steps:j}),percentageChange:x,warningLevel:N,outputPrice:{value:M,usdValue:b,realValue:n.value,realUsdValue:n.usdValue}}):F.createElement(Xd,{selected:l,listItem:s==="list-item",basic:s==="basic"},F.createElement("div",{className:Yd()},!c&&J.length?F.createElement(F.Fragment,null,F.createElement(im,null,J.map((le,at)=>{let G=`${le.value}_${at}`;return F.createElement(F.Fragment,{key:G},F.createElement(VT,{label:le.label,value:le.value}),F.createElement(jo,{size:4,direction:"horizontal"}))})),F.createElement(ei,null),!P&&F.createElement(jo,{size:4})):null,F.createElement("div",{id:"portal-root",className:Zd()},F.createElement(Ns,{quote:e,time:se,fee:me,feeWarning:vt,timeWarning:Ze,showModalFee:u,steps:j}),P&&F.createElement(jd,{onClick:le=>{le.stopPropagation(),p()},size:"xxsmall",type:"secondary",variant:"default",css:{paddingLeft:"$10",paddingRight:"$10",paddingTop:"$5",paddingBottom:"$5"}},F.createElement(Xo,{color:"secondary",variant:"body",size:"xsmall",className:"allRoutesLabel"},yo.t("See All Routes")))),s==="basic"&&F.createElement("div",{className:Jd()},F.createElement(nm,null,F.createElement(GT,{size:12,color:"gray"})),F.createElement(rm,null,F.createElement(Es,{size:"small",variant:"body"},`${A} ${B[0].from.token.displayName} = `),F.createElement(km,{content:n.value,container:te,open:n.value?void 0:!1},F.createElement(Es,{size:"small",variant:"body"},"\xA0",`${M} ${B[B.length-1].to.token.displayName}`))),F.createElement(km,{content:n.usdValue,container:te},F.createElement(jo,{size:2,direction:"horizontal"}),F.createElement(Xo,{color:"$neutral600",size:"xsmall",variant:"body"},`($${b})`))),s==="list-item"&&F.createElement(jT,{tooltipContainer:te,type:"output",direction:"vertical",price:{value:M,usdValue:b,realValue:n.value,realUsdValue:n.usdValue},token:{displayName:B[j-1].to.token.displayName,image:B[j-1].to.token.image},chain:{image:B[j-1].to.chain.image},percentageChange:x,warningLevel:N}),s==="swap-preview"&&F.createElement(F.Fragment,null,F.createElement(Nn,{from:B[0].from,to:B[j-1].to,percentageChange:x,warningLevel:N}),F.createElement(jo,{size:4}))),F.createElement(Vd,{selected:l,listItem:s==="list-item",open:k,className:"quote_container",onOpenChange:v},F.createElement(Cm,{type:s,quoteRef:w,selected:l,setExpanded:v,container:te,expanded:k,steps:B}),F.createElement(tm,{open:k},F.createElement(om,null),F.createElement("div",{className:Kd()},B.map((le,at)=>{let G=`item-${at}`;return F.createElement(KT,{type:"quote-details",key:G,tooltipContainer:te,step:le,hasSeparator:at!==B.length-1,state:le.state})})))))}i(Ms,"Quote");import{Divider as ev,Skeleton as tv}from"@rango-dev/ui";import Ot from"react";import{darkTheme as ZT,styled as pi}from"@rango-dev/ui";var Tm=pi("div",{$$color:"$colors$neutral100",[`.${ZT} &`]:{$$color:"$colors$neutral300"},backgroundColor:"$$color",borderBottomLeftRadius:"$xm",borderBottomRightRadius:"$xm",padding:"$15",variants:{rounded:{true:{borderRadius:"$xm"}},expanded:{true:{paddingBottom:"3px"},false:{paddingBottom:"$12"}}}}),vm=pi("div",{paddingTop:"$2"}),wm=pi("div",{paddingLeft:"$8"}),bm=pi("div",{borderLeft:"1px dashed $foreground",minHeight:" 0",margin:"0px 11.5px",alignSelf:"stretch",variants:{hideSeparator:{true:{minHeight:"unset",height:"0"}}}});import{ChainToken as Pm,Divider as St,Skeleton as tt}from"@rango-dev/ui";import Q from"react";import{css as JT,styled as Ft}from"@rango-dev/ui";var Ls=Ft("div",{display:"flex"}),xm=Ft("div",{padding:"$10 $0 $20"}),Em=Ft("div",{padding:"14px $0 $20 $0",display:"flex",flexDirection:"column"}),Im=Ft("div",{display:"flex",justifyContent:"start",alignItems:"center"}),Am=Ft("div",{display:"flex",justifyContent:"space-between",alignItems:"end"}),Nm=Ft("div",{height:"$24",marginLeft:"13px",borderLeft:"1px solid $neutral700"}),Wm=Ft("div",{width:"65%",display:"flex",justifyContent:"start"}),Bm=Ft("div",{display:"flex",flexDirection:"column",alignItems:"start",flexGrow:1,maxWidth:"148px"}),Mm=Ft("div",{padding:"$15 $0 $15 $0"}),Lm=JT({display:"flex",justifyContent:"space-between",alignItems:"center"});function Mn(t){let{type:e,tagHidden:o=!0}=t,n=Q.createElement(Am,null,Q.createElement(Wm,null,Q.createElement(Pm,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),Q.createElement(St,{size:8,direction:"horizontal"}),Q.createElement(Bm,null,Q.createElement(tt,{height:10,width:60,variant:"rounded"}),Q.createElement(St,{size:4}),Q.createElement(tt,{height:15,variant:"rounded"}))),Q.createElement(tt,{height:12,width:64,variant:"rounded"})),r=e==="basic"&&!o;return Q.createElement("div",null,!o&&Q.createElement(Q.Fragment,null,Q.createElement(Ls,null,Q.createElement(tt,{width:65,height:20,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:65,height:20,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:65,height:20,variant:"rounded"})),Q.createElement(ei,null),!r&&Q.createElement(St,{size:4})),Q.createElement("div",{className:Lm()},Q.createElement(Ls,null,Q.createElement(tt,{width:60,height:10,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:60,height:10,variant:"rounded"}),Q.createElement(St,{size:4,direction:"horizontal"}),Q.createElement(tt,{width:60,height:10,variant:"rounded"})),r&&Q.createElement(tt,{width:85,height:24,variant:"rounded"})),e==="basic"&&Q.createElement(xm,null,Q.createElement(tt,{height:15,width:148,variant:"rounded"})),e==="list-item"&&Q.createElement(Em,null,Q.createElement(Im,null,Q.createElement(Pm,{loading:!0,size:"medium",chainImage:"",tokenImage:""}),Q.createElement(St,{direction:"horizontal",size:4}),Q.createElement(tt,{height:15,width:150,variant:"rounded"})),Q.createElement(St,{size:10}),Q.createElement(tt,{height:10,width:184,variant:"rounded"})),e==="swap-preview"&&Q.createElement(Q.Fragment,null,Q.createElement(St,{size:4}),Q.createElement(Mm,null,n,Q.createElement(Nm,null),n),Q.createElement(St,{size:12})))}i(Mn,"QuoteSummarySkeleton");import{ChainToken as Om,Divider as _s,NextIcon as RT,Skeleton as ui}from"@rango-dev/ui";import Ee from"react";import{styled as Ln}from"@rango-dev/ui";var _m=Ln("div",{display:"flex",alignItems:"start"}),Dm=Ln("div",{flexGrow:1,paddingTop:"$5",paddingBottom:"$10",display:"flex",alignItems:"center",variants:{extraSpace:{true:{paddingBottom:"$40"}}}}),Ps=Ln("div",{display:"flex",alignItems:"center",flexGrow:1}),$m=Ln("div",{margin:"$0 $2",padding:"$4",display:"flex",justifyContent:"center",alignItems:"center"}),Fm=Ln("div",{display:"flex",alignItems:"center"});function Nt(t){let{separator:e=!0}=t;return Ee.createElement(Ee.Fragment,null,Ee.createElement(Fm,null,Ee.createElement(ui,{height:22,width:22,variant:"circular"}),Ee.createElement(_s,{direction:"horizontal",size:8}),Ee.createElement(ui,{height:15,width:148,variant:"rounded"})),Ee.createElement(_m,null,Ee.createElement(bm,{hideSeparator:!e}),Ee.createElement(Dm,{extraSpace:e},Ee.createElement(Ps,null,Ee.createElement(Om,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(_s,{direction:"horizontal",size:8}),Ee.createElement(ui,{height:12,variant:"rounded"})),Ee.createElement($m,null,Ee.createElement(RT,{color:"gray",size:16})),Ee.createElement(Ps,null,Ee.createElement(Om,{size:"small",loading:!0,chainImage:"",tokenImage:""}),Ee.createElement(_s,{direction:"horizontal",size:8}),Ee.createElement(ui,{height:12,variant:"rounded"})))))}i(Nt,"StepSkeleton");function Pn(t){let{type:e,expanded:o,tagHidden:n=!1}=t;return Ot.createElement(Tm,{expanded:o,rounded:e!=="basic"},Ot.createElement(Mn,{type:e,tagHidden:n}),Ot.createElement(vm,null,Ot.createElement(tv,{height:15,variant:"rounded"})),o&&Ot.createElement(wm,null,Ot.createElement(ev,{size:24}),Ot.createElement(Nt,null),Ot.createElement(Nt,null),Ot.createElement(Nt,{separator:!1})))}i(Pn,"QuoteSkeleton");function So(t){let{quote:e,type:o,loading:n,error:r,warning:a,expanded:s=!1,tagHidden:l,onClick:c,showModalFee:u,selected:p,onClickAllRoutes:d,fullExpandedMode:h=!1,container:f}=t,{inputAmount:m,inputUsdValue:g}=O(),C=e?.outputAmount?new ov(e?.outputAmount):null,S=e?ct(e):null,k=!(r&&(r.type===0||r.type===1))&&e&&!n;return n?di.createElement(bs,null,di.createElement(Pn,{tagHidden:l,type:o,expanded:s})):k?di.createElement(bs,{onClick:()=>c?.(e)},di.createElement(Ms,{quote:e,error:r,container:f,showModalFee:u,warning:a,tagHidden:l,selected:p,type:o,expanded:s,onClickAllRoutes:d,fullExpandedMode:h,input:{value:m,usdValue:g?.toString()??""},output:{value:C?.toString()??"",usdValue:S?.toString()??""}})):null}i(So,"QuoteInfo");import{calculatePendingSwap as av}from"@rango-dev/queue-manager-rango-preset";import{useEffect as sv}from"react";import{useRef as nv,useState as rv}from"react";var iv=2e3;function mi({request:t}){let[e,o]=rv(!1),n=nv(null),r=i(()=>n.current?.abort(),"cancelFetch"),a=i(async l=>(await new Promise(c=>setTimeout(c,iv)),await s(l,!1)),"retryFetch"),s=i(async(l,c=!1)=>{r(),n.current=new AbortController,o(!0);try{let u=await t(l,{signal:n.current.signal});return n.current=null,u}catch(u){if(c)return await a(l);throw u}finally{o(!1)}},"fetch");return{fetch:s,loading:e,cancelFetch:r}}i(mi,"useFetch");function Um(){let{fetch:t,loading:e,cancelFetch:o}=mi({request:async(n,r)=>await xt().confirmRoute(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(Um,"useFetchConfirmQuote");function fi(t){if(!t.swaps)throw new Error(R().noResultError.title,{cause:{type:0,diagnosisMessage:t.diagnosisMessages?.[0]}});let e=Ds(t.swaps);if(e)throw new Error(e.message,{cause:e.options})}i(fi,"throwErrorIfResponseIsNotValid");function Ds(t){if(Jp(t)){let{swap:n,recommendation:r,fromAmountRangeError:a}=Rp(t);return{message:"bridge limit error",options:{type:3,swap:n,recommendation:r,fromAmountRangeError:a}}}let o=nu(t);if(o){let n=Mr(t);return{message:"",options:{type:4,recommendedSlippages:o,minRequiredSlippage:n}}}return null}i(Ds,"getQuoteError");function zm(t){let{currentQuote:e,previousQuote:o,meta:n,selectedWallets:r,userSlippage:a,findToken:s}=t,l={quote:null,balance:null},c=Do({previousQuote:o,currentQuote:e,findToken:s,userSlippage:a});c&&(l.quote=c);let u=au(e,r,n.blockchains);return u.length===0||(l.balance={messages:u}),l}i(zm,"generateWarnings");function gi(t){return t?.code==="ERR_CANCELED"?{swap:null,error:{type:2},warnings:null}:t.cause?{swap:null,error:t.cause,warnings:null}:t?.code==="ERR_BAD_REQUEST"?{swap:null,error:{type:0,diagnosisMessage:t.response.data.error},warnings:null}:{swap:null,error:{type:1},warnings:null}}i(gi,"handleQuoteErrors");function $s(){let{fromToken:t,toToken:e,inputAmount:o,inputUsdValue:n,setSelectedQuote:r,selectedQuote:a,customDestination:s,resetAlerts:l}=O(),{slippage:c,customSlippage:u}=y(),p=y().getDisabledLiquiditySources(),d=y().blockchains(),h=y().tokens(),{findToken:f}=y(),m=u||c,{fetch:g,cancelFetch:C,loading:S}=Um();return sv(()=>C,[]),{loading:S,fetch:i(async k=>{let v=k.selectedWallets,w=k?.customDestination??s;if(!t||!e||!o)return{quote:null,swap:null,error:null,warnings:null};let A=v.reduce((b,E)=>(b[E.chain]=E.address,b),{}),M={requestId:a?.requestId||"",selectedWallets:A,destination:w||void 0};try{return await g(M,!0).then(b=>{let{result:E}=b;if(!E)throw new Error("Error fetching updated route");fi({diagnosisMessages:E.diagnosisMessages,requestId:E.requestId,swaps:E.result?.swaps});let x={outputAmount:E.result?.outputAmount,requestId:E.requestId,resultType:E.result?.resultType,swaps:E.result?.swaps||[],validationStatus:E.validationStatus,requestAmount:E.requestAmount};r(x);let N={slippage:m.toString(),disabledSwappersGroups:p},I=zm({previousQuote:a??void 0,currentQuote:x,meta:{blockchains:d},selectedWallets:v,userSlippage:m,inputUsdValue:n,findToken:f});l();let B=!!I.balance,j=av(o.toString(),E,iu(v),N,!B,{blockchains:d,tokens:h});return{quote:x,swap:j,error:null,warnings:I}})}catch(b){return gi(b)}},"fetch"),cancelFetch:C}}i($s,"useConfirmSwap");var yv=uv("div",{width:"100%",display:"flex",justifyContent:"space-between",[`& ${Qm}`]:{width:"$48",height:"$48"}}),Sv=Us({flexGrow:1,paddingRight:"$10"}),Cv=Us({width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center"}),kv=Us({display:"flex",justifyContent:"space-between",alignItems:"center"});function qm(){let{selectedQuote:t,setInputAmount:e,selectedWallets:o,quoteWalletsConfirmed:n,customDestination:r,quoteWarningsConfirmed:a}=O(),s=hv(),[l,c]=_n(""),u=!n,[p,d]=_n(!1),[h,f]=_n(!1),{isActiveTab:m}=re(),g=y().getDisabledLiquiditySources(),C=gv(g),{manager:S}=lv(),{fetch:T,loading:k,cancelFetch:v}=$s(),[w,A]=_n({swap:null,error:null,warnings:null}),[M,b]=_n(!1),E=i(async({selectedWallets:P,customDestination:X})=>{let se=await T?.({selectedWallets:P,customDestination:X});return A(se),se},"onConfirmSwap"),x=i(async()=>{if(w.swap&&n)try{await S?.create("swap",{swapDetails:w.swap},{id:w.swap.requestId});let P=`../${$.swaps}/${w.swap.requestId}`;s(P,{replace:!0}),setTimeout(()=>{e("")},0)}catch(P){c("Error: "+P?.message)}},"addNewSwap"),N=i(async()=>{f(!0),await x(),f(!1)},"onConfirm"),I=i(async()=>{w.warnings?.quote&&Hp(w.warnings.quote)&&!a?b(!0):await N()},"onStartConfirmSwap"),B=i(async()=>{A({error:null,swap:null,warnings:null}),T({selectedWallets:o,customDestination:r}).then(P=>{A(P)}).catch(P=>console.error(P))},"onRefresh");hi(()=>{!!C.current.length&&!g.length&&B(),C.current=g},[g.length]),hi(()=>{u&&v()},[u]),hi(()=>{u&&d(u)},[u]),hi(()=>{u||T({selectedWallets:o,customDestination:r}).then(P=>A(P)).catch(P=>console.error(P))},[]),fv(()=>{t?.requestId||s(`../${location.search}`)},[t?.requestId]);let j=w.warnings?.quote??null,te=w.error,J=[];if(l&&J.push(Le.createElement(cv,{type:"error",variant:"alarm",title:l})),j||te){let P=`../${$.settings}`;J.push(Le.createElement(In,{warning:j,error:te,couldChangeSettings:!1,refetchQuote:B,showWarningModal:M,confirmationDisabled:!m,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:async()=>{b(!1),await x()},onChangeSettings:()=>s(P)}))}return Le.createElement(oe,{header:{title:Fs.t("Confirm Swap"),onWallet:()=>{let P=`../${$.wallets}`;s(P)}},footer:Le.createElement(yv,null,Le.createElement("div",{className:Sv()},Le.createElement(pv,{id:"widget-confirm-swap-start-btn",variant:"contained",type:"primary",size:"large",fullWidth:!0,loading:k||h,disabled:!!w.error||!m,onClick:I},Fs.t("Start Swap"))),Le.createElement(Qm,{id:"widget-confirm-swap-wallet-icon-btn",variant:"contained",type:"primary",size:"large",loading:k||h,disabled:!m,onClick:d.bind(null,!0)},Le.createElement(mv,{size:24})))},p&&Le.createElement(bd,{open:p,onClose:()=>d(!1),onCancel:v,loading:k,onCheckBalance:E}),Le.createElement(ie,null,Le.createElement("div",{className:kv()},Le.createElement(dv,{variant:"title",size:"small"},Fs.t("You get")),Le.createElement("div",{className:Cv()},Le.createElement(Fr,{onClick:!k&&!p&&!M?B:void 0}))),Le.createElement(Os,{size:"12"}),xu(J.map((P,X)=>({element:P,key:`alert-${X}`})),Le.createElement(Os,{size:10})),J.length>0?Le.createElement(Os,{size:10}):null,Le.createElement(So,{quote:t,type:"swap-preview",expanded:!0,tagHidden:!0,error:w.error,loading:k,warning:w.warnings?.quote??null})))}i(qm,"ConfirmSwapPage");import{i18n as Ut}from"@lingui/core";import{Button as Zs,CustomTokensZeroStateDarkIcon as Dv,CustomTokensZeroStateIcon as $v,DeleteIcon as Fv,Divider as On,IconButton as Ov,MessageBox as Uv,NotFound as zv,styled as Rs}from"@rango-dev/ui";import de,{useState as Js}from"react";import{useNavigate as Qv}from"react-router-dom";import{CloseIcon as vv,IconButton as wv,SearchIcon as bv,TextField as xv}from"@rango-dev/ui";import Dn from"react";import{styled as Tv}from"@rango-dev/ui";var Hm=Tv("div",{width:"$24",height:"$24",display:"flex",alignItems:"center",justifyContent:"center"});function Ct(t){let{variant:e,fullWidth:o,color:n,size:r,onChange:a,value:s,style:l,setValue:c,...u}=t;return Dn.createElement(xv,{prefix:Dn.createElement(Hm,null,Dn.createElement(bv,{color:"black"})),suffix:!!s.length&&Dn.createElement(wv,{variant:"ghost",onClick:()=>c?.(""),size:"small"},Dn.createElement(vv,{color:"gray",size:10})),fullWidth:o,color:n,variant:e,style:{padding:10,borderRadius:25,alignItems:"center",...l},size:r,value:s,onChange:a,...u})}i(Ct,"SearchInput");import{i18n as Ys}from"@lingui/core";import{darkTheme as tf,Divider as Zo,ExternalLinkIcon as Av,Image as Nv,ListItemButton as Wv,NotFound as Bv,PinIcon as Mv,Skeleton as of,Typography as Ci,VirtualizedList as Lv}from"@rango-dev/ui";import q from"react";import{Divider as Rm,ListItem as Iv,Skeleton as $n}from"@rango-dev/ui";import kt from"react";import{css as Yo,darkTheme as Gm,ImageContainer as Ev,styled as ut,Typography as Vm}from"@rango-dev/ui";var zs=Yo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}),Qs=Yo({position:"relative",height:12,width:"30%",maxWidth:"150px"}),qs=Yo({position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",bottom:"-8px"}),Hs=Yo({transform:"translateY(12px)",visibility:"hidden",display:"flex","& a":{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"$12",lineHeight:"$16",$$color:"$colors$neutral600",[`.${Gm} &`]:{$$color:"$colors$neutral700"},color:"$$color",textDecoration:"none"}}),Gs=Yo({}),Vs=Yo(),Km=ut("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden",justifyContent:"center"}),Ks=ut("div",{display:"flex",alignItems:"center","._typography":{textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:100,overflow:"hidden"}}),yi=ut("ul",{flexGrow:1,padding:0,margin:0,listStyle:"none","& li":{alignItems:"none","&:hover":{[`& .${Qs}`]:{[`& .${Hs}`]:{position:"absolute",transform:"none",transition:"transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms",visibility:"visible"},[`& .${Gs}`]:{bottom:"-15px"},[`& .${zs}`]:{position:"absolute",transform:"translateY(-12px)",visibility:"hidden"},[`& .${qs}`]:{position:"absolute",transform:"translateY(-12px)",bottom:"-10px"}}}}}),js=ut("div",{paddingLeft:"$5",paddingRight:"$5",borderRadius:"$md",display:"flex",alignItems:"center"}),Xs=ut(Vm,{}),jm=ut("div",{textAlign:"right",width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",[`& .${Vs}`]:{$$color:"$colors$neutral600",[`.${Gm} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),Si=ut("div",{display:"flex",alignItems:"end",flexDirection:"column"}),AU=ut("div",{display:"flex",alignItems:"center"}),Xm=ut("div",{position:"relative",[`& ${Ev}`]:{borderRadius:"$xm",overflow:"hidden"}}),Ym=ut("div",{position:"absolute",backgroundColor:"$neutral100",padding:"$4",borderRadius:"50%",bottom:-6,right:-6}),Zm=ut(Vm,{width:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Jm=ut("a",{"& svg:hover":{color:"$colors$info"}});function ef(t){return kt.createElement(yi,null,Array.from(Array(t.size),e=>kt.createElement(Iv,{key:e,hasDivider:!0,start:kt.createElement($n,{variant:"circular",width:35,height:35}),end:kt.createElement(Si,null,kt.createElement($n,{variant:"text",size:"large",width:70}),kt.createElement(Rm,{size:4}),kt.createElement($n,{variant:"text",size:"medium",width:50})),title:kt.createElement("div",null,kt.createElement($n,{variant:"text",size:"large",width:90}),kt.createElement(Rm,{size:4}),kt.createElement($n,{variant:"text",size:"medium",width:90}))})))}i(ef,"LoadingTokenList");var Pv=20,_v=i(t=>{let{address:e,name:o,url:n,token:r,customCssForTag:a,customCssForTagTitle:s}=t,l=e.length;return q.createElement("div",{className:Qs()},o?q.createElement("div",{className:zs()},o):q.createElement(Ks,{className:qs()},q.createElement(Ci,{variant:"title",size:"xmedium"},r.symbol),q.createElement(Zo,{direction:"horizontal",size:4}),q.createElement(js,{css:a},q.createElement(Xs,{variant:"body",size:"xsmall",css:s},r.blockchain))),!!e&&q.createElement("div",{className:`${Hs()} ${!o&&Gs()}`},l>10?`${e.slice(0,5)}...${e.slice(l-6,l)}`:e," ",q.createElement(Zo,{size:4,direction:"horizontal"}),q.createElement(Jm,{href:n,target:"_blank",rel:"nofollow noreferrer",onClick:c=>c.stopPropagation()},q.createElement(Av,{size:12}))))},"renderDesc");function Fn(t){let{list:e,searchedFor:o="",onChange:n,selectedBlockchain:r,showTitle:a=!0,action:s}=t,l=y().fetchStatus,c=y().blockchains(),{getBalanceFor:u,fetchingWallets:p}=y(),{isTokenPinned:d}=y(),h=i(m=>{let g=cn(u(m));return s?s(m):p?q.createElement(Si,null,q.createElement(of,{variant:"text",size:"large",width:70}),q.createElement(Zo,{size:4}),q.createElement(of,{variant:"text",size:"medium",width:50})):g&&q.createElement(jm,null,q.createElement(Zm,{variant:"title",size:"small"},g.amount),q.createElement("div",null),g.usdValue&&q.createElement(Ci,{variant:"body",className:Vs(),size:"xsmall"},`$${g.usdValue}`))},"endRenderer"),f=i(()=>q.createElement(Lv,{itemContent:m=>{let g=e[m],C=g.address||"",S=c.find(w=>w.name===g.blockchain),T=qa(S.color,"main"),k={$$color:T.main150,[`.${tf} &`]:{$$color:T.main750},backgroundColor:"$$color"},v={$$color:T.main750,[`.${tf} &`]:{$$color:T.main150},color:"$$color"};return q.createElement("div",{style:{paddingRight:5}},q.createElement(Wv,{style:{width:"100%",overflow:"hidden",height:"60px"},"tab-index":m,key:`${g.symbol}${g.address}`,id:`${g.symbol}${g.address}`,className:"widget-token-list-item-btn",hasDivider:!0,onClick:()=>n&&n(e[m]),start:q.createElement(Xm,null,q.createElement(Nv,{src:g.image,size:30}),t.type!=="custom-token"&&d(g,t.type)&&q.createElement(Ym,null,q.createElement(Mv,{size:12,color:"gray"}))),title:S?.type==="COSMOS"||g.name||!g.name&&!C?q.createElement(Ks,null,q.createElement(Ci,{variant:"title",size:"xmedium"},g.symbol),q.createElement(Zo,{direction:"horizontal",size:4}),q.createElement(js,{css:k},q.createElement(Xs,{variant:"body",size:"xsmall",css:v},g.blockchain))):void 0,description:S?.info&&C&&S.type!=="COSMOS"?_v({address:C,token:e[m],customCssForTag:k,customCssForTagTitle:v,name:g.name,url:S.info.addressUrl.split("{wallet}").join(C)}):g.name||void 0,end:h(g)}))},totalCount:e.length,key:`${r}-${o}`}),"renderList");return q.createElement(q.Fragment,null,a&&q.createElement(q.Fragment,null,q.createElement(Ci,{variant:"label",size:"large"},Ys.t("Select Token")),q.createElement(Zo,{size:4})),q.createElement(Km,null,q.createElement(Zo,{size:4}),l==="loading"&&q.createElement(ef,{size:Pv}),l==="success"&&(e.length?q.createElement(yi,{as:"ul"},f()):!!o&&q.createElement(Bv,{title:Ys.t("No results found"),description:Ys.t("Try using different keywords")}))))}i(Fn,"TokenList");var qv=Rs("div",{display:"flex",justifyContent:"space-between",flexDirection:"column",flex:1}),Hv=Rs("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:"0.75"}),Gv=Rs(Ov,{"&:hover":{"& svg":{color:"$secondary550"}}});function nf(){let[t,e]=Js(""),{deleteCustomToken:o}=y(),n=y().customTokens(),{fromToken:r,toToken:a,setFromToken:s,setToToken:l}=O(),{mode:c}=Uo({}),u=Qv(),[p,d]=Js(!1),[h,f]=Js(),m=i(T=>{let k=T.target.value;e(k)},"handleSearch"),g=c==="dark",C=n.filter(T=>Je(T.symbol,t)||Je(T.address||"",t)||Je(T.name||"",t)),S=i(()=>{if(h){let T=a?lt(a):null,k=r?lt(r):null,v=lt(h);T===v?l({token:null}):k===v&&s({token:null}),o(h)}d(!1)},"handleDeleteCustomToken");return de.createElement(oe,{header:{title:Ut.t("Custom Tokens")}},de.createElement(ie,null,de.createElement(qv,null,n.length?de.createElement(de.Fragment,null,de.createElement(Ct,{value:t,setValue:e,fullWidth:!0,color:"light",variant:"contained",placeholder:Ut.t("Search Token"),onChange:m}),de.createElement(On,{size:16}),de.createElement(Fn,{list:C,type:"custom-token",searchedFor:t,showTitle:!1,action:T=>de.createElement(Gv,{id:"widget-custom-token-delete-icon-btn",variant:"ghost",onClick:()=>{d(!0),f(T)}},de.createElement(Fv,{size:12,color:"gray"}))})):de.createElement(Hv,null,de.createElement(zv,{icon:g?de.createElement(Dv,{size:200}):de.createElement($v,{size:200}),title:Ut.t("No custom tokens"),description:Ut.t("press the button to add your custom token")})),de.createElement(On,{size:20}),de.createElement(Zs,{id:"widget-custom-token-add-btn",type:"primary",variant:"contained",size:"large",onClick:()=>u($.addCustomTokens)},Ut.t("Add Custom Token"))),de.createElement(Z,{open:p,dismissible:!0,onClose:()=>d(!1),container:W()},de.createElement(Uv,{title:Ut.t("Delete Custom Token"),type:"error",description:Ut.t("Are you sure you want to Delete this Token?")},de.createElement(On,{size:40}),de.createElement(On,{size:10}),de.createElement(Zs,{fullWidth:!0,id:"widget-custom-token-delete-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},Ut.t("Yes, Delete it")),de.createElement(On,{size:12}),de.createElement(Zs,{id:"widget-custom-token-delete-modal-no-btn",fullWidth:!0,variant:"outlined",type:"primary",size:"large",onClick:()=>d(!1)},Ut.t("No, Continue"))))))}i(nf,"CustomTokensPage");import{i18n as qe}from"@lingui/core";import{useManager as pw}from"@rango-dev/queue-manager-react";import{Button as al,darkTheme as uw,Divider as ko,MessageBox as dw,NotFound as mw,styled as sl,Typography as vi}from"@rango-dev/ui";import{TransactionStatus as Qn}from"rango-types";import ae,{useMemo as wf,useState as wi}from"react";import{useNavigate as fw}from"react-router-dom";import{FilterIcon as Jv,Popover as Rv}from"@rango-dev/ui";import Co from"react";import{css as Vv,darkTheme as ki,IconButton as Kv,styled as Un}from"@rango-dev/ui";var el=Un("div",{position:"relative","&::before":{position:"absolute",right:"1px",top:"-1px",width:"$8",height:"$8",borderRadius:"100%",backgroundColor:"$neutral300",[`.${ki} &`]:{backgroundColor:"$neutral400"},padding:"$2"},variants:{isSelect:{true:{"&::before":{content:""}}}}}),rf=Un(Kv,{width:"$36",height:"$36",position:"relative",padding:"0",overflow:"unset",backgroundColor:"$neutral300",[`.${ki} &`]:{backgroundColor:"$neutral400"},"&:hover":{backgroundColor:"$secondary100",[`.${ki} &`]:{backgroundColor:"$neutral"},[`& ${el}::before`]:{backgroundColor:"$secondary100",[`.${ki} &`]:{backgroundColor:"$neutral"}}},variants:{isSelect:{true:{border:"1px solid $secondary"}}}}),af=Un("div",{position:"absolute",width:"$6",height:"$6",display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"3px",top:"$0",right:"1px",backgroundColor:"$secondary500"}),sf=Un("div",{padding:"$15",borderRadius:"$sm",width:"248px",backgroundColor:"$background",zIndex:10}),lf=Vv({display:"flex",justifyContent:"space-between",alignItems:"center"}),cf=Un("ul",{margin:0,listStyle:"none",height:"100%",padding:0,".item-start-container":{paddingRight:"0 !important"}});import{i18n as pf}from"@lingui/core";import{Button as jv,Divider as uf,ListItemButton as Xv,Radio as Yv,RadioRoot as Zv,Typography as df}from"@rango-dev/ui";import ot from"react";function mf(t){let{filterBy:e,onClickItem:o}=t;return ot.createElement(sf,null,ot.createElement("div",{className:lf()},ot.createElement(df,{size:"small",variant:"body"},pf.t("Status")),ot.createElement(jv,{id:"widget-filter-selector-reset-btn",variant:"ghost",size:"xxsmall",onClick:()=>o("")},pf.t("Reset"))),ot.createElement(uf,{size:10}),ot.createElement(Zv,{value:e},ot.createElement(cf,null,t.list.map((n,r)=>ot.createElement(Xv,{key:n.id,style:{height:"40px",width:"100%"},selected:!1,hasDivider:t.list.length-1!=r,id:n.id,title:ot.createElement(ot.Fragment,null,ot.createElement(uf,{direction:"horizontal",size:4}),ot.createElement(df,{size:"medium",variant:"body"},n.title)),start:ot.createElement(Yv,{value:n.id}),onClick:o})))))}i(mf,"FilterSelectorContent");function tl(t){let{onClickItem:e,onOpenChange:o,filterBy:n,list:r,open:a}=t;return Co.createElement("div",null,Co.createElement(Rv,{open:a,align:"end",onOpenChange:o,container:W(),content:Co.createElement(mf,{list:r,filterBy:n,onClickItem:s=>{e(s),o(!1)}})},Co.createElement(rf,{id:"widget-filter-selector-filter-icon-btn",variant:"default",isSelect:!!n,onClick:()=>o(!t.open)},Co.createElement(el,{isSelect:!!n},Co.createElement(Jv,{size:16,color:"black"}),!!n&&Co.createElement(af,null)))))}i(tl,"FilterSelector");import{i18n as ow}from"@lingui/core";import{Divider as Sf,GroupedVirtualizedList as nw,Skeleton as rw,SwapListItem as Cf,Typography as iw}from"@rango-dev/ui";import Qe,{useCallback as kf,useEffect as aw,useRef as sw,useState as lw}from"react";function ff(t,e){let o=[],n=0;do{let r=t[n];o.push(Math.min(r,e)),e-=r,n++}while(e>0&&n<=t.length);return o}i(ff,"calculateGroupsSoFar");import{css as ew,darkTheme as tw,styled as zn}from"@rango-dev/ui";var ol=ew(),gf=zn("div",{display:"flex",justifyContent:"center",alignItems:"center",padding:"$5"}),nl=zn("div",{width:"100%",display:"flex",flexDirection:"column",backgroundColor:"$background",padding:"$10 $5 0 $5",[`& .${ol}`]:{$$color:"$colors$neutral600",[`.${tw} &`]:{$$color:"$colors$neutral700"},color:"$$color"}}),rl=zn("div",{display:"flex",justifyContent:"flex-start",padding:"$2"}),hf=zn("div",{gap:"$10",display:"flex",flexDirection:"column"}),yf=zn("div",{height:"100%",display:"flex",justifyContent:"center",alignItems:"center"});var cw=10;function il(t){let{list:e,onSwapClick:o,groupBy:n,isLoading:r}=t,[a,s]=lw([]),l=sw(0),{swaps:c,groupCounts:u,groups:p}=n(e),d=kf(ff,[]),h=kf(()=>{let f=e.length-l.current;f&&(l.current+=Math.min(f,cw),s(d(u,l.current)))},[e.length]);if(aw(()=>{r||h()},[r,h]),r){let f=[1,2];return Qe.createElement(Qe.Fragment,null,[f,f].map((g,C)=>Qe.createElement(nl,{key:C},Qe.createElement(rl,null,Qe.createElement(rw,{variant:"text",width:60,size:"small"}),Qe.createElement(Sf,{size:16})),Qe.createElement(Sf,{size:4}),Qe.createElement(hf,null,g.map((T,k)=>Qe.createElement(Cf,{isLoading:!0,key:k}))))))}return Qe.createElement(nw,{endReached:()=>{l.current<e.length&&h()},groupCounts:a,groupContent:f=>Qe.createElement(nl,null,Qe.createElement(rl,null,Qe.createElement(iw,{variant:"label",size:"medium",className:ol()},p[f]))),itemContent:(f,m)=>{let g=c[f];if(!g)return null;let C=g.steps[0],S=g.steps[g.steps.length-1];return Qe.createElement(gf,{key:g.requestId},Qe.createElement(Cf,{requestId:g.requestId,creationTime:g.creationTime,status:g.status,onClick:o,tooltipContainer:W(),onlyShowTime:p[m]===ow.t("Today"),swapTokenData:{from:{token:{image:C.fromLogo,displayName:C.fromSymbol},blockchain:{image:C.fromBlockchainLogo||""},amount:L(g.inputAmount,6,6),realAmount:g.inputAmount},to:{token:{image:S.toLogo,displayName:S.toSymbol},blockchain:{image:S.toBlockchainLogo||""},amount:L(S.outputAmount||S.expectedOutputAmountHumanReadable||"",6,6),realAmount:S.outputAmount||S.expectedOutputAmountHumanReadable||""}}}))}})}i(il,"HistoryGroupedList");import{i18n as Ti}from"@lingui/core";import Tf from"dayjs";var vf=i(t=>{let e=new Map([["today",{title:Ti.t("Today"),swaps:[]}],["week",{title:Ti.t("This week"),swaps:[]}],["month",{title:Ti.t("This month"),swaps:[]}],["year",{title:Ti.t("This year"),swaps:[]}]]);function o(c,u){e.has(c)||e.set(c,{title:c,swaps:[]}),e.get(c)?.swaps.push(u)}i(o,"addYearsToOutput");let n=Tf();t.forEach(c=>{let u=Number(c.creationTime),p=Tf(u);if(n.isSame(p,"day"))e.get("today")?.swaps.push(c);else if(n.isSame(p,"week"))e.get("week")?.swaps.push(c);else if(n.isSame(p,"month"))e.get("month")?.swaps.push(c);else if(n.isSame(p,"year"))e.get("year")?.swaps.push(c);else{let d=new Date(u).getFullYear().toString();o(d,c)}});let r=Array.from(e.values()).filter(c=>c.swaps.length>0),a=r.flatMap(c=>c.swaps),s=r.map(c=>c.swaps.length),l=r.map(c=>c.title);return{swaps:a,groupCounts:s,groups:l}},"groupSwapsByDate");var gw=sl("div",{overflowY:"visible",width:"100%",display:"flex",flexDirection:"column",gap:15,height:"100%"}),hw=sl("div",{display:"flex",justifyContent:"center",alignItems:"center"}),yw=sl("div",{"._typography":{color:"$neutral700",[`.${uw}&`]:{color:"$neutral900"}}}),Sw=[{id:Qn.SUCCESS,title:qe.t("Complete")},{id:Qn.RUNNING,title:qe.t("Running")},{id:Qn.FAILED,title:qe.t("Failed")}],Cw=i((t,e)=>t?.length?t.filter(o=>wt(o.fromBlockchain,e)||wt(o.toBlockchain,e)||wt(o.toSymbol,e)||wt(o.fromSymbol,e)).length:!1,"isStepContainsText");function bf(){let t=fw(),{manager:e,state:o}=pw(),n=pt(e).map(({swap:k})=>k),[r,a]=wi(""),[s,l]=wi(!1),c=!o.loadedFromPersistor,[u,p]=wi(""),[d,h]=wi(!1),f=i(k=>{let v=k.target.value;a(v)},"handleSearch"),m=wf(()=>!r&&!u?n:n.filter(k=>{let{inputAmount:v,status:w,steps:A,requestId:M}=k;return(!r||wt(v,r)||wt(w,r)||Cw(A,r)||wt(M,r))&&(!u||u===w)}),[n,r,u]),g=!m?.length&&!c,C=i(()=>h(!1),"onCloseModal"),S=i(async()=>{try{await e?.clearQueue(),h(!1)}catch(k){console.log(k)}},"onClear"),T=wf(()=>!n.some(k=>k.status===Qn.SUCCESS||k.status===Qn.FAILED),[n]);return ae.createElement(oe,{header:{title:qe.t("History"),suffix:ae.createElement(Vt,null,ae.createElement(al,{id:"widget-history-clear-btn",disabled:T,variant:"ghost",size:"xsmall",onClick:()=>h(!0)},ae.createElement(vi,{size:"medium",variant:"label",color:"error"},qe.t("Clear"))))}},ae.createElement(ie,null,ae.createElement(hw,null,ae.createElement(Ct,{setValue:a,fullWidth:!0,variant:"contained",placeholder:qe.t("Search Transaction"),autoFocus:!0,onChange:f,style:{height:36},value:r}),ae.createElement(ko,{size:10,direction:"horizontal"}),ae.createElement(tl,{filterBy:u,open:s,onOpenChange:k=>l(k),onClickItem:k=>p(k),list:Sw})),ae.createElement(ko,{size:"16"}),ae.createElement(gw,null,g&&ae.createElement(yf,null,ae.createElement(ko,{size:32}),ae.createElement(mw,{title:r?qe.t("No results found"):qe.t("No transactions"),titleColor:r?void 0:"$info",hasIcon:!!r,description:r?qe.t("Try using different keywords"):qe.t("Your transaction history is stored locally and will appear here after you start a swap")})),!g&&ae.createElement(il,{list:m,onSwapClick:t,groupBy:vf,isLoading:c}))),ae.createElement(Z,{open:d,onClose:C,container:W()},ae.createElement(ko,{size:20}),ae.createElement(dw,{type:"warning",title:qe.t("Clear Transaction History"),description:ae.createElement(yw,null,ae.createElement(vi,{variant:"body",size:"medium"},qe.t("Proceeding will remove all successful and failed transactions from the widget. Do you want to continue?")),ae.createElement(ko,{size:"24"}),ae.createElement(vi,{variant:"body",size:"small"},qe.t("Note: This does not erase your transaction history on the chain; it only removes them here.")))}),ae.createElement(ko,{size:30}),ae.createElement(al,{id:"widget-history-clear-modal-yes-btn",variant:"contained",type:"primary",size:"large",onClick:S},qe.t("Yes, Clear the history")),ae.createElement(ko,{size:10}),ae.createElement(al,{id:"widget-history-clear-modal-no-btn",variant:"outlined",type:"primary",size:"large",onClick:C},ae.createElement(vi,{variant:"title",size:"medium",color:"primary"},qe.t("No, Cancel")))))}i(bf,"HistoryPage");import{i18n as qw}from"@lingui/core";import{Button as Hw,Divider as Gf,styled as Gw,WarningIcon as Vw}from"@rango-dev/ui";import Kw from"bignumber.js";import He,{useEffect as Vf,useState as Kf}from"react";import{useNavigate as jw}from"react-router-dom";import{i18n as Ef}from"@lingui/core";import{Alert as Tw,Divider as ll,NoRouteIcon as vw,Typography as ww}from"@rango-dev/ui";import To from"react";import{styled as kw}from"@rango-dev/ui";var xf=kw("div",{display:"flex",flexDirection:"column",alignItems:"center"});function cl(){let{fromToken:t,toToken:e}=O();return!!t&&!!e&&Mt(t,e)?To.createElement(xf,null,To.createElement(ll,{size:10}),To.createElement(vw,{size:24,color:"gray"}),To.createElement(ll,{size:4}),To.createElement(ww,{variant:"title",size:"small"},Ef.t("No Routes Found")),To.createElement(ll,{size:4}),To.createElement(Tw,{title:Ef.t("You cannot use the same token for From and To."),type:"warning",variant:"alarm"})):null}i(cl,"SameTokensWarning");import{i18n as Nw}from"@lingui/core";import{Header as Ww}from"@rango-dev/ui";import Jt,{useEffect as Bw,useState as Mw}from"react";import{i18n as xw}from"@lingui/core";import{Divider as ul,FullExpandedQuote as Ew,Typography as Iw}from"@rango-dev/ui";import Se from"react";import{styled as pl}from"@rango-dev/ui";var If=pl("div",{display:"flex",justifyContent:"center",flexDirection:"column",height:"100%"}),Af=pl("div",{display:"flex",justifyContent:"space-between",alignItems:"center"}),Nf=pl("div",{width:"146px"});import{i18n as qn}from"@lingui/core";import{Select as bw}from"@rango-dev/ui";import Wf from"react";function bi(t){let{updateQuotePartialState:e,sortStrategy:o}=O(),n=[{value:"SMART",label:qn.t("Smart Routing")},{value:"FEE",label:qn.t("Lowest Fee")},{value:"SPEED",label:qn.t("Fastest Transfer")},{value:"NET_OUTPUT",label:qn.t("Maximum Return")},{value:"PRICE",label:qn.t("Maximum Output")}];return Wf.createElement(Nf,null,Wf.createElement(bw,{container:t.container,options:n,value:o,handleItemClick:r=>{e("sortStrategy",r.value)},variant:"filled"}))}i(bi,"SelectStrategy");var Bf=3;function Hn(t){let{loading:e,onClickOnQuote:o,fetch:n,showModalFee:r,hasSort:a=!0,fullExpandedMode:s=!1,container:l}=t,{selectedQuote:c,quotes:u,updateQuotePartialState:p,fromToken:d,toToken:h,sortStrategy:f,error:m}=O(),{slippage:g,customSlippage:C}=y(),{findToken:S}=y(),T=l||W(),k=!!u&&u.results.length,v=C??g,w=i(b=>{if(!d||!h||!u)return null;let E={requestAmount:u.requestAmount,validationStatus:null,...b};return Do({currentQuote:E,userSlippage:v,findToken:S})},"getQuoteWarning"),A=m?.type===0||m?.type===1,M=u?.results?Wr(f,u?.results):[];return Se.createElement(Se.Fragment,null,a&&Se.createElement(Se.Fragment,null,Se.createElement(Af,null,Se.createElement(Iw,{size:"xmedium",variant:"title"},xw.t("Sort by")),Se.createElement(bi,{container:T})),Se.createElement(ul,{size:"10"})),e&&Array.from({length:Bf},(b,E)=>Se.createElement(Se.Fragment,{key:E},s?Se.createElement(Ew,{loading:!0}):Se.createElement(Pn,{tagHidden:!1,type:"list-item",expanded:!1}),E!==Bf-1&&Se.createElement(ul,{size:16}))),!e&&Se.createElement(Se.Fragment,null,k?M.map((b,E)=>{let x=w(b),N=Ds(b.swaps),I=M.length-1===E;return Se.createElement(Se.Fragment,{key:b.requestId},Se.createElement(So,{showModalFee:r,container:T,selected:c?.requestId===b.requestId,tagHidden:!1,quote:{...b,requestAmount:u.requestAmount,validationStatus:null},loading:e,error:N?.options||null,warning:x,fullExpandedMode:s,onClick:B=>{N||p("warning",x),p("error",N?.options||null),o(B)},type:"list-item"}),!I&&Se.createElement(ul,{size:16}))}):A&&Se.createElement(If,null,Se.createElement(xn,{size:s?"large":"small",error:m,fetch:n}))))}i(Hn,"Quotes");import{darkTheme as Aw,styled as Mf}from"@rango-dev/ui";var Lf=Mf("div",{transition:"width 0.2s, opacity 0.2s, margin-left 0.2s",height:"700px",width:"390px",position:"relative",opacity:1,marginLeft:"$16",backgroundColor:"$neutral100",[`.${Aw} &`]:{backgroundColor:"$neutral300"},variants:{expandMode:{default:{width:"390px"},full:{width:"719px"}}},"&.is-hidden":{width:0,height:0,opacity:0,marginLeft:0}}),Pf=Mf("div",{position:"relative",overflow:"hidden",padding:"$20",flexGrow:1,display:"flex",flexDirection:"column",overflowY:"auto",borderRadius:"$primary",backgroundColor:"$background"});var Lw=100;function dl(t){let{fetch:e,loading:o,onClickOnQuote:n,onClickRefresh:r,isVisible:a}=t,[s,l]=Mw(!1),c=s?"":"is-hidden",{config:u}=y(),p=u?.variant==="full-expanded",d=no();return Bw(()=>{let h=null;return a?h=setTimeout(()=>{l(!0)},Lw):(l(!1),h&&clearTimeout(h)),()=>{h&&clearTimeout(h)}},[a]),Jt.createElement(Lf,{expandMode:u?.variant==="full-expanded"?"full":"default",className:`${c} ${zr()}`,id:De.EXPANDED_BOX_ID},Jt.createElement(Ww,{title:Nw.t("Routes"),suffix:Jt.createElement(Jt.Fragment,null,Jt.createElement(bi,{container:d}),Jt.createElement(fo,{container:d,onClickRefresh:r,hidden:["history","notifications","settings"]}))}),Jt.createElement(Pf,null,Jt.createElement(Hn,{showModalFee:!0,fetch:e,hasSort:!1,loading:o,container:no(),onClickOnQuote:n,fullExpandedMode:p})))}i(dl,"ExpandedQuotes");import{i18n as zf}from"@lingui/core";import{SwapInput as Qf}from"@rango-dev/ui";import $w from"bignumber.js";import Gn from"react";import{ReverseIcon as Dw}from"@rango-dev/ui";import fl from"react";import{keyframes as Pw,styled as _f}from"@rango-dev/ui";var ml=450,_w=Pw({"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)"}}),Df=_f("div",{position:"absolute",bottom:"-12px",left:"50%",transform:"translate(-50%, 10%)",cursor:"pointer"}),$f=_f("div",{borderRadius:"$md",border:"3px solid $background",background:"$neutral100",width:"$24",height:"$24",display:"flex",justifyContent:"center",alignItems:"center",color:"$foreground","&.rotate":{"& svg":{animation:`${_w} ${ml}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 gl(){let t=O.use.switchFromAndTo();return fl.createElement(Df,null,fl.createElement($f,{onClick:e=>{let o=e.currentTarget;o.classList.add("rotate"),setTimeout(()=>{o.classList.remove("rotate")},ml),t()}},fl.createElement(Dw,{size:12})))}i(gl,"SwitchFromAndToButton");import{styled as Ff}from"@rango-dev/ui";var Of=Ff("div",{display:"flex",flexDirection:"column",gap:"$5",alignSelf:"stretch"}),Uf=Ff("div",{position:"relative"});function hl(t){let{fetchingQuote:e,fetchMetaStatus:o,onClickToken:n,isExpandable:r}=t,{fromToken:a,fromBlockchain:s,toToken:l,toBlockchain:c,setInputAmount:u,inputAmount:p,inputUsdValue:d,outputAmount:h,outputUsdValue:f,selectedQuote:m}=O(),{connectedWallets:g,getBalanceFor:C}=y(),S=a?C(a):null,T=cn(S)?.amount??"0",k=S?new $w(S.amount).shiftedBy(-S.decimals):ue,v=!!s&&$c(g,s.name),w=!Aa(m,p,d),A=!Aa(m,p,f),M=!d||!f||!f.gt(0)?null:Pt(d.toString(),f.toString());return Gn.createElement(Of,null,Gn.createElement(Uf,null,Gn.createElement(Qf,{label:zf.t("From"),mode:"From",onInputChange:u,balance:T,chain:{displayName:s?.displayName||"",image:s?.logo||""},token:{displayName:a?.symbol||"",image:a?.image||""},onClickToken:()=>n("from"),price:{value:p,usdValue:w?void 0:L(d,4,4),realUsdValue:w?void 0:d?.toString(),error:w?R().unknownPriceError.impactTitle:void 0},disabled:o==="failed",loading:o==="loading",loadingBalance:v,tooltipContainer:W(),onSelectMaxBalance:()=>{let b=L(k,S?.decimals),E=S?.amount?b:"";u(E)},anyWalletConnected:g.length>0}),Gn.createElement(gl,null)),Gn.createElement(Qf,{sharpBottomStyle:!r&&(!!m||e),label:zf.t("To"),mode:"To",fetchingQuote:e,chain:{displayName:c?.displayName||"",image:c?.logo||""},token:{displayName:l?.symbol||"",image:l?.image||""},percentageChange:L(Pt(d,f),2,2),warningLevel:_t(M??0),price:{value:L(h,6,6),usdValue:A?void 0:L(f,4,4),realValue:h?.toString(),realUsdValue:A?void 0:f?.toString(),error:A?R().unknownPriceError.impactTitle:void 0},onClickToken:()=>n("to"),disabled:o==="failed",loading:o==="loading",tooltipContainer:W()}))}i(hl,"Inputs");import{useCallback as Fw,useEffect as Ow,useRef as Uw,useState as zw}from"react";function qf(){let{fetch:t,loading:e,cancelFetch:o}=mi({request:async(n,r)=>await xt().getAllRoutes(n,r)});return{fetch:t,loading:e,cancelFetch:o}}i(qf,"useFetchAllQuotes");var Qw=600;function xi({refetchQuote:t}){let{fetch:e,cancelFetch:o}=qf(),{excludeLiquiditySources:n,routing:r}=y().config,{connectedWallets:a}=y(),{fromToken:s,toToken:l,inputAmount:c,inputUsdValue:u,selectedQuote:p,sortStrategy:d,resetQuote:h,error:f,warning:m,setSelectedQuote:g,updateQuotePartialState:C}=O(),{slippage:S,customSlippage:T,affiliatePercent:k,affiliateRef:v,affiliateWallets:w,fetchStatus:A}=y(),M=y().getLiquiditySources(),b=y().getDisabledLiquiditySources(),E=y().excludeLiquiditySources(),{findToken:x}=y(),[N,I]=zw(!0),B=Uw(c),j=T??S,J=!s||!l||Mt(s,l)||!sn(c),P=i(z=>{I(z)},"resetState"),X=i(z=>{let{fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:G,slippage:_,affiliateRef:H,affiliatePercent:V,affiliateWallets:fe}=z;if(N||P(!0),!J&&me&&vt){h();let ne=ru({fromToken:me,toToken:vt,inputAmount:Ze,liquiditySources:le,excludeLiquiditySources:at,disabledLiquiditySources:G,wallets:a,slippage:_,affiliateRef:H,affiliatePercent:V,affiliateWallets:fe});Ao("experimental",r)&&(ne.experimental=!0),Ao("avoidNativeFee",r)&&(ne.avoidNativeFee=!0),Ao("enableCentralizedSwappers",r)&&(ne.enableCentralizedSwappers=!0),r?.maxLength&&(ne.maxLength=r.maxLength),e(ne).then(ge=>{let Fe=Wr(d,ge.results),ve=Vp(p,Fe,ge.requestAmount);I(!1),C("quotes",ge),g(ve),fi({diagnosisMessages:ge.diagnosisMessages,requestId:ve?.requestId||"",swaps:ve?.swaps});let mt=ve&&Do({currentQuote:ve,userSlippage:j,findToken:x});C("warning",mt)}).catch(ge=>{let{error:Fe}=gi(ge);(Fe?.type===0||Fe?.type===1)&&h(),Fe?.type!==2&&(C("error",Fe),I(!1))})}},"fetch"),se=Fw(xc(z=>{X(z)},Qw),[J]);return Ow(()=>{if(!t){I(!1);return}if(A!=="success")return;if(J){I(!1),(p||f||m)&&h();return}if(!sn(c)||u?.eq(0)){P(!1),o();return}h(),P(!0);let z=X;return B.current&&B.current!=c&&(z=se),B.current=c,z({inputAmount:c,fromToken:s,toToken:l,liquiditySources:M,excludeLiquiditySources:E,disabledLiquiditySources:b,slippage:j,affiliateRef:v,affiliatePercent:k,affiliateWallets:w}),o},[A,c,s?.symbol,s?.address,s?.blockchain,l?.symbol,l?.address,l?.blockchain,J,M?.length,n,b.length,j,v,k,JSON.stringify(w)]),{fetch:()=>X({inputAmount:c,fromToken:s,toToken:l,liquiditySources:M,excludeLiquiditySources:E,disabledLiquiditySources:b,slippage:j,affiliateRef:v,affiliatePercent:k,affiliateWallets:w}),loading:N}}i(xi,"useSwapInput");function Hf(t,e){let o=!1,n={preventDefault(){o=!0},...t.payload===void 0&&{payload:t.payload}};he.emit("uiEvent",{type:t.type,payload:n}),o||e()}i(Hf,"emitPreventableEvent");var Xw=Gw("div",{display:"flex",alignItems:"flex-start",maxHeight:700,"& .footer__alert":{paddingTop:"0 !important"}}),Yw=300;function jf(){let t=jw(),{fromToken:e,toToken:o,inputAmount:n,selectedQuote:r,refetchQuote:a,error:s,warning:l,quotes:c,setSelectedQuote:u,resetQuoteWallets:p,setQuoteWarningsConfirmed:d,updateQuotePartialState:h}=O(),[f,m]=Kf(!1),{isLargeScreen:g,isExtraLargeScreen:C}=ii(),{fetch:S,loading:T}=xi({refetchQuote:a}),{config:k,fetchStatus:v,connectedWallets:w}=y(),{isActiveTab:A}=re(),[M,b]=Kf(!1),x=eu({fetchMetaStatus:v,fetchingQuote:T,inputAmount:n,quote:r,anyWalletConnected:w.length>0,error:s,warning:l,needsToWarnEthOnPath:!1}),N=Hc(g,C,k?.variant),I=!!n&&!!e&&!!o&&new Kw(n).gt(0)&&!uu(e,o),B=I&&v==="success"&&T,J=(!N||N&&c?.results.length)&&(l||s);Vf(()=>{p(),h("refetchQuote",!0)},[]),Vf(()=>{m(I)},[I]);let P=(r||s)&&!M?S:void 0,X=i(z=>{N&&f?(m(!1),setTimeout(()=>{t(z)},Yw)):t(z)},"onHandleNavigation"),se=i(z=>{r?.requestId!==z.requestId&&(b(!1),u(z))},"onClickOnQuote");return He.createElement(Xw,null,He.createElement(oe,{height:"auto",footer:He.createElement(Hw,{id:`widget-swap-${x.action}-btn`,type:"primary",size:"large",disabled:x.disabled||!A,prefix:x.action==="confirm-warning"&&He.createElement(Vw,null),fullWidth:!0,onClick:()=>{x.action==="connect-wallet"?Hf({type:"clickConnectWallet"},()=>X($.wallets)):x.action==="confirm-warning"?b(!0):X($.confirmSwap)}},x.title),header:{onWallet:()=>{X($.wallets)},hasBackButton:!1,title:k.title||qw.t("Swap"),suffix:He.createElement(fo,{hidden:N?["refresh"]:void 0,onClickRefresh:P,onClickHistory:()=>X($.swaps),onClickSettings:()=>{X($.settings)}})}},He.createElement(ie,null,He.createElement(hl,{fetchingQuote:B,fetchMetaStatus:v,isExpandable:N,onClickToken:z=>{X(z==="from"?$.fromSwap:$.toSwap)}}),He.createElement(Gf,{size:"2"}),N?null:He.createElement(So,{quote:r,loading:B,error:s,tagHidden:!1,warning:l,type:"basic",onClickAllRoutes:c&&c.results.length>1?()=>{h("refetchQuote",!1),X($.routes)}:void 0}),J?He.createElement(He.Fragment,null,He.createElement(Gf,{size:"10"}),He.createElement(In,{warning:l,error:s,couldChangeSettings:!0,refetchQuote:S,showWarningModal:M,confirmationDisabled:!A,onOpenWarningModal:()=>b(!0),onCloseWarningModal:()=>b(!1),onConfirmWarningModal:()=>{b(!1),d(!0),X($.confirmSwap)},onChangeSettings:()=>X($.settings)})):null,He.createElement(cl,null))),N?He.createElement(dl,{loading:B,onClickOnQuote:se,fetch:S,onClickRefresh:P,isVisible:f}):null)}i(jf,"Home");import{i18n as Xf}from"@lingui/core";import{Alert as Zw,Divider as Jw,List as Rw,ListItemButton as eb,Radio as tb,RadioRoot as ob,Typography as nb}from"@rango-dev/ui";import Wt from"react";function Rt(){let{setLanguage:t,language:e,config:o}=y(),n=Yc,r=o?.language||No;return{activeLanguage:e||r,languages:n,defaultLanguage:r,changeLanguage:a=>t(a||No),resetLanguage:()=>t(null)}}i(Rt,"useLanguage");function Yf(){let{activeLanguage:t,changeLanguage:e,languages:o}=Rt(),n=je(),r=o.map(a=>{let{local:s,label:l,SVGFlag:c}=a;return{id:`widget-setting-languages-${s}-item-btn`,value:s,title:Wt.createElement(nb,{variant:"title",size:"xmedium"},l),onClick:()=>{e(a.local),n()},end:Wt.createElement(tb,{value:s}),start:Wt.createElement(c,null)}});return Wt.createElement(oe,{header:{title:Xf.t("Language")}},Wt.createElement(ie,null,Wt.createElement(Zw,{type:"warning",variant:"alarm",title:"Warning: We are using machine translation, so the translations may be inaccurate."}),Wt.createElement(Jw,{size:"8"}),Wt.createElement(ob,{value:t},Wt.createElement(Rw,{type:Wt.createElement(eb,{title:Xf.t("language"),id:"_",onClick:()=>console.log()}),items:r}))))}i(Yf,"LanguagePage");import{i18n as zt}from"@lingui/core";import{Button as lb,Checkbox as cb,Image as pb,ListItemButton as ub,NotFound as db,Typography as mb}from"@rango-dev/ui";import Ge,{useState as fb}from"react";import{Checkbox as ab,Skeleton as Jf}from"@rango-dev/ui";import Kn from"react";import{styled as yl}from"@rango-dev/ui";var Vn=yl("ul",{padding:"$15 $5 0",margin:0,listStyle:"none",height:"100%",overflowY:"auto",variants:{disabled:{true:{pointerEvents:"none"}}}}),Sl=yl("div",{width:80,display:"flex",justifyContent:"flex-end"}),Cl=yl("div",{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%"});import{ListItem as rb,styled as ib}from"@rango-dev/ui";var Zf=ib(rb,{height:61});var sb=30;function kl(){return Kn.createElement(Vn,null,Array.from(Array(sb),(t,e)=>Kn.createElement(Zf,{hasDivider:!0,key:e,start:Kn.createElement(Jf,{variant:"circular",width:35,height:35}),title:Kn.createElement(Jf,{variant:"text",size:"large",width:90}),end:Kn.createElement(ab,{checked:!1})})))}i(kl,"LoadingLiquiditySourceList");function Tl({sourceType:t}){let e=y().fetchStatus,o=y().swappers(),n=y().getDisabledLiquiditySources(),[r,a]=fb(""),s=y().toggleLiquiditySource,l=y().isInCampaignMode(),c=yr(o,n),u={Exchanges:zt.t("Exchanges"),Bridges:zt.t("Bridges")},p=[];t==="Exchanges"&&p.push("DEX"),t==="Bridges"&&p.push("BRIDGE","AGGREGATOR","OFF_CHAIN");let d=c.filter(S=>p.includes(S.type)),h=d.length===d.filter(S=>S.selected).length,f=i(()=>{d.forEach(S=>{h?s(S.groupTitle):S.selected||s(S.groupTitle)})},"toggleAllSources"),m=d.map(S=>{let{selected:T,groupTitle:k,logo:v,id:w,...A}=S;return{id:`widget-setting-liquidity-source-${w.toLowerCase().replace(/\s+/g,"-")}-item-btn`,start:Ge.createElement(pb,{src:v,size:22,type:"circular"}),onClick:()=>{l||s(k)},end:Ge.createElement(cb,{checked:T,disabled:l}),title:Ge.createElement(mb,{variant:"title",size:"xmedium"},zt.t(k)),selected:T,groupTitle:k,logo:v,...A}}),g=i(S=>{let T=S.target.value;a(T)},"handleSearch"),C=m;return r&&(C=m.filter(S=>wt(S.groupTitle,r))),Ge.createElement(oe,{header:{title:zt.t(t),suffix:Ge.createElement(Sl,null,Ge.createElement(lb,{id:`widget-liquidity-source-${h?"deselect-all":"select-all"}-btn`,variant:"ghost",size:"xsmall",onClick:f},h?zt.t("Deselect all"):zt.t("Select all")))}},Ge.createElement(ie,{view:!0},Ge.createElement(Ct,{value:r,setValue:a,fullWidth:!0,color:"light",variant:"contained",placeholder:zt.t("Search {sourceType}",{sourceType:u[t]}),onChange:g}),e==="loading"&&Ge.createElement(kl,null),!C.length&&r?Ge.createElement(Cl,null,Ge.createElement(db,{title:zt.t("No results found"),description:zt.t("Try using different keywords")})):e==="success"&&Ge.createElement(Vn,{disabled:l},C.map(S=>{let{groupTitle:T,...k}=S;return Ge.createElement(Ge.Fragment,{key:S.id},Ge.createElement(ub,{style:{height:"61px"},...k,selected:!1,hasDivider:!0}))}))))}i(Tl,"LiquiditySourcePage");import{i18n as gb}from"@lingui/core";import Ei from"react";import{useNavigate as hb}from"react-router-dom";function Rf(){let t=hb(),e=je(),{selectedQuote:o,refetchQuote:n,setSelectedQuote:r,updateQuotePartialState:a,error:s}=O(),{fetch:l,loading:c}=xi({refetchQuote:n}),u=i(h=>{r(h),a("refetchQuote",!1),e()},"onClickOnQuote"),p=`../${$.settings}`,d=`../${$.wallets}`;return Ei.createElement(oe,{header:{onWallet:()=>{t(d),a("refetchQuote",!0)},onBack:()=>{a("refetchQuote",!1)},title:gb.t("Routes"),suffix:Ei.createElement(fo,{onClickRefresh:o||s?l:void 0,hidden:["notifications","history"],onClickSettings:()=>{t(p),a("refetchQuote",!0)}})}},Ei.createElement(ie,null,Ei.createElement(Hn,{fetch:l,loading:c,onClickOnQuote:u})))}i(Rf,"RoutesPage");import{i18n as ag}from"@lingui/core";import{Divider as sg,getCategoriesCount as Eb,SelectableCategoryList as Ib}from"@rango-dev/ui";import Qt,{useState as lg}from"react";import{useNavigate as Ab}from"react-router-dom";import{i18n as vl}from"@lingui/core";import{Divider as kb,Image as Tb,ListItemButton as vb,NotFound as wb,Typography as ig}from"@rango-dev/ui";import nt,{useEffect as bb,useState as xb}from"react";var eg=i((t,e,o)=>t.filter(n=>cr(n.type,o)).filter(n=>Je(n.name,e)||Je(n.displayName,e)),"filterBlockchains");import{ImageContainer as yb,styled as tg}from"@rango-dev/ui";var og=tg("div",{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%",justifyContent:"center"}),Ii=tg(Tn,{padding:0,margin:0,listStyle:"none",[`& ${yb}`]:{borderRadius:"$xm",overflow:"hidden"}});import{ListItem as Sb,Skeleton as ng}from"@rango-dev/ui";import Ai from"react";var Cb=20;function rg(){return Ai.createElement(Ii,null,Array.from(Array(Cb),t=>Ai.createElement(Sb,{key:t,hasDivider:!0,start:Ai.createElement(ng,{variant:"circular",width:35,height:35}),title:Ai.createElement(ng,{variant:"text",size:"large",width:90})})))}i(rg,"LoadingBlockchainList");function wl(t){let{list:e,searchedFor:o,onChange:n,blockchainCategory:r,showTitle:a=!0}=t,[s,l]=xb(e),{fetchStatus:c}=y();bb(()=>{l([...eg(e,o,r)])},[e,o,r]);let u=i(()=>!s.length&&o?nt.createElement(wb,{title:vl.t("No results found"),description:vl.t("Try using different keywords")}):nt.createElement(Ii,{as:"ul",key:`${r}-${o}`},s.map(p=>nt.createElement(vb,{key:`${p.name}-${p.chainId}`,className:"widget-blockchain-list-item-btn",hasDivider:!0,onClick:()=>n(p),start:nt.createElement(Tb,{src:p.logo,size:30}),title:nt.createElement(ig,{variant:"title",size:"medium"},p.displayName),id:p.name}))),"renderList");return nt.createElement(nt.Fragment,null,a&&nt.createElement(nt.Fragment,null,nt.createElement(ig,{variant:"label",size:"large"},vl.t("Select Chain")),nt.createElement(kb,{size:4})),nt.createElement(og,null,c==="loading"&&nt.createElement(rg,null),c==="success"&&u()))}i(wl,"BlockchainList");function Ni(t){let{type:e}=t,o=je(),[n,r]=lg(""),[a,s]=lg("ALL"),l=O.use.setToBlockchain(),c=O.use.setFromBlockchain(),{fetchStatus:u}=y(),p=Ab(),d=y().blockchains({type:e}),h=Eb(d),f=!t.hideCategory&&h!==1;return Qt.createElement(oe,{header:{title:ag.t("Select Chain")}},Qt.createElement(ie,{view:!0},f&&Qt.createElement(Qt.Fragment,null,Qt.createElement(Ib,{setCategory:s,category:a,blockchains:d,isLoading:u==="loading"}),Qt.createElement(sg,{size:24})),Qt.createElement(Ct,{value:n,autoFocus:!0,placeholder:ag.t("Search Chain"),color:"light",variant:"contained",size:"large",setValue:()=>r(""),onChange:m=>r(m.target.value)}),Qt.createElement(sg,{size:16}),Qt.createElement(wl,{list:d,showTitle:e!=="custom-token",searchedFor:n,blockchainCategory:a,onChange:m=>{e==="custom-token"?p(`..?blockchain=${m.name}`,{replace:!0}):(e==="source"?c(m):l(m),o())}})))}i(Ni,"SelectBlockchainPage");import{i18n as Bi}from"@lingui/core";import{Divider as fg}from"@rango-dev/ui";import vo,{useState as Db}from"react";import{useNavigate as $b}from"react-router-dom";import{i18n as El}from"@lingui/core";import{BlockchainsChip as Wi,Divider as dg,Image as mg,Skeleton as Lb,Tooltip as Pb,Typography as Il}from"@rango-dev/ui";import Pe from"react";import{useEffect as Bb}from"react";var cg=["ETH","COSMOS","OSMOSIS"];function bl(t,e,o){let n=JSON.parse(JSON.stringify(t)),r=[];if(n.sort(Nb),o?.limit&&t.length>o.limit){let a=o.limit,s=e;if(e.length<=o.limit){let l=o.limit-e.length;for(let c=0;c<=l;c++){let u=n[c];s=s.filter(p=>u.name!==p)}}n.sort(Wb(s)),r=n.splice(a)}return{list:n,more:r}}i(bl,"prepare");function Nb(t,e){let o=cg,n=o.findIndex(l=>l===t.name),r=o.findIndex(l=>l===e.name),a=n>-1,s=r>-1;return a&&s?n>r?1:-1:a?-1:s?1:0}i(Nb,"sortByMostUsedBlockchains");function Wb(t){return i(function(o,n){let r=t.findIndex(c=>c===o.name),a=t.findIndex(c=>c===n.name),s=r>-1,l=a>-1;return s&&l?r>a?1:-1:t.includes(o.name)?-1:t.includes(n.name)?1:0},"sortByPreferred")}i(Wb,"generateSortByPreferredBlockchainsFor");function pg(t,e){return!!e.list.find(o=>o.name===t)}i(pg,"isInVisibleList");function xl(t,e){let{preferredBlockchains:o,addPreferredBlockchain:n}=y();Bb(()=>{if(e?.selected){let a=bl(t,o,e);pg(e.selected,a)||n(e?.selected)}},[e?.selected]);let r=bl(t,o,e);return{list:r.list,more:r.more,history:[]}}i(xl,"usePrepareBlockchainList");import{styled as Mb}from"@rango-dev/ui";var ug=Mb("div",{display:"grid",gap:"$10",gridTemplateColumns:"repeat(6, minmax(0, 1fr))"});var _b=12;function Al(t){let{blockchains:e,type:o,blockchain:n,onChange:r,onMoreClick:a}=t,s=xl(e,{limit:10,selected:n?.name}),{fetchStatus:l}=y(),c=O.use.resetToBlockchain(),u=O.use.resetFromBlockchain(),p=s.more.length>0,d=s.more.length===1,h=!d&&p;return Pe.createElement(Pe.Fragment,null,Pe.createElement(dg,{size:12}),Pe.createElement(Il,{variant:"label",size:"large"},El.t("Select Chain")),Pe.createElement(dg,{size:12}),Pe.createElement(ug,null,l==="loading"&&Array.from(Array(_b),f=>Pe.createElement(Lb,{key:f,variant:"rounded",height:50})),l==="success"&&Pe.createElement(Pe.Fragment,null,Pe.createElement(Wi,{selected:!n,onClick:()=>{o==="from"?u():c()}},Pe.createElement(Il,{variant:"body",size:"xsmall",color:"secondary500"},El.t("All"))),s.list.map(f=>Pe.createElement(Pb,{key:f.name,content:f.shortName,side:"bottom",sideOffset:2,container:W()},Pe.createElement(Wi,{key:f.name,selected:!!n&&n.name===f.name,onClick:()=>r(f)},Pe.createElement(mg,{src:f.logo,size:30})))),d?Pe.createElement(Wi,{key:s.more[0].name,selected:!!n&&n.name===s.more[0].name,onClick:()=>r(s.more[0])},Pe.createElement(mg,{src:s.more[0].logo,size:30})):null,h?Pe.createElement(Wi,{onClick:a,key:"more-blockchains"},Pe.createElement(Il,{variant:"body",size:"xsmall",color:"secondary500"},El._("More +{count}",{count:s.more.length}))):null)))}i(Al,"BlockchainsSection");function Nl(t){let{type:e}=t,o=$b(),n=je(),{fromBlockchain:r,toBlockchain:a,setFromToken:s,setToToken:l,setFromBlockchain:c,setToBlockchain:u}=O(),{getBalanceFor:p}=y(),[d,h]=Db(""),m=(e==="source"?r:a)?.name??"",g=y().blockchains({type:e}),C=y().tokens({type:e,blockchain:m,searchFor:d,getBalanceFor:p}),S=i(v=>{e==="source"?c(v):u(v)},"updateBlockchain"),T=i(v=>{e==="source"?s({token:v,meta:{blockchains:g,tokens:C}}):l({token:v,meta:{blockchains:g,tokens:C}})},"updateToken"),k={source:Bi.t("Source"),destination:Bi.t("Destination")};return vo.createElement(oe,{header:{title:Bi.t("Swap {type}",{type:k[e]})}},vo.createElement(ie,null,vo.createElement(Al,{blockchains:g,type:e=="source"?"from":"to",blockchain:e==="source"?r:a,onMoreClick:()=>o($.blockchains),onChange:v=>{S(v)}}),vo.createElement(fg,{size:24}),vo.createElement(Ct,{value:d,autoFocus:!0,placeholder:Bi.t("Search Token"),color:"light",variant:"contained",size:"large",setValue:()=>h(""),onChange:v=>h(v.target.value)}),vo.createElement(fg,{size:16}),vo.createElement(Fn,{list:C,selectedBlockchain:m,searchedFor:d,type:e,onChange:v=>{T(v);let w=g.find(A=>v.blockchain===A.name);w&&S(w),n()}})))}i(Nl,"SelectSwapItemsPage");import{i18n as Ml}from"@lingui/core";import{Alert as cx,Button as px,styled as ux}from"@rango-dev/ui";import wo from"react";import{useInRouterContext as dx,useSearchParams as mx}from"react-router-dom";import{i18n as kg}from"@lingui/core";import{Divider as Tg,InfoIcon as zb,SlippageIcon as Qb,TextField as qb,Tooltip as Hb,Typography as vg}from"@rango-dev/ui";import rt from"react";import{Chip as Fb,styled as jn,TextField as Ob}from"@rango-dev/ui";var gg=jn("div",{paddingTop:"$5",padding:"$10 $5"}),hg=jn("div",{display:"flex",flexWrap:"wrap",gap:"$10",[`& ${Ob}`]:{flex:"1 1 0",maxWidth:"127px",minWidth:"85px"}}),yg=jn("div",{display:"flex",justifyContent:"start",alignItems:"center",paddingBottom:"$10"}),Mi=jn("div",{maxWidth:"280px",padding:"$10"}),Sg=jn(Fb,{width:"61px",flexShrink:0});import{i18n as Wl}from"@lingui/core";import{Typography as Ub}from"@rango-dev/ui";import Xn from"react";function Cg(){return Xn.createElement(Mi,null,Xn.createElement(Ub,{variant:"label",size:"medium",color:"neutral700"},Wl.t("Your transaction will be reverted if the price changes unfavorably by more than this percentage."),Xn.createElement("br",null),Xn.createElement("br",null),Xn.createElement("b",null,Wl.t("Warning")),":\xA0",Wl.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(Cg,"SlippageTooltipContent");function Bl(){let{slippage:t,setSlippage:e,customSlippage:o,setCustomSlippage:n}=y();return rt.createElement(gg,null,rt.createElement(yg,null,rt.createElement(Qb,{size:16,color:"gray"}),rt.createElement(Tg,{direction:"horizontal",size:4}),rt.createElement(vg,{variant:"title",size:"xmedium"},kg.t("Slippage tolerance per swap")),rt.createElement(Tg,{direction:"horizontal",size:4}),rt.createElement(Hb,{container:W(),side:"top",sideOffset:4,content:rt.createElement(Cg,null)},rt.createElement(zb,{color:"gray"}))),rt.createElement(hg,null,Zc.map((r,a)=>{let s=`slippage-${a}`;return rt.createElement(Sg,{key:s,onClick:()=>{o&&n(null),e(r)},selected:!o&&r===t,label:`${r.toString()}%`})}),rt.createElement(qb,{type:"number",min:"0.01",max:"30",step:"0.01",fullWidth:!0,variant:"contained",value:o===null?"":o,color:"dark",onChange:r=>{let a=r.target.value,s=parseFloat(a);s>=tp&&s<=ep?n(s):n(null)},suffix:o&&rt.createElement(vg,{variant:"body",size:"small"},"%"),placeholder:kg.t("Custom")})))}i(Bl,"Slippage");import{i18n as dt}from"@lingui/core";import{AutoThemeIcon as wg,BridgesIcon as Gb,ChevronRightIcon as Li,DarkModeIcon as bg,Divider as Yn,ExchangeIcon as Vb,InfinityIcon as Kb,InfoIcon as jb,LanguageIcon as Xb,LightModeIcon as xg,List as Yb,ListItem as Zb,ListItemButton as Jb,Skeleton as Rb,styled as ex,Switch as tx,Tabs as ox,TargetIcon as nx,Tooltip as rx,Typography as Ye}from"@rango-dev/ui";import D from"react";import{useNavigate as ix}from"react-router-dom";var ax=ex("div",{width:"202px",height:"$40"}),sx=[{id:"light",icon:D.createElement(xg,{color:"black",size:24}),tooltip:D.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Light"))},{id:"dark",icon:D.createElement(bg,{color:"black",size:24}),tooltip:D.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Dark"))},{id:"auto",icon:D.createElement(wg,{color:"black",size:24}),tooltip:D.createElement(Ye,{size:"xsmall",variant:"body"},dt.t("Auto"))}],lx=i(t=>{let e={color:"gray",size:16};switch(t){case"auto":return D.createElement(wg,{...e});case"dark":return D.createElement(bg,{...e});default:return D.createElement(xg,{...e})}},"getThemeIcon");function Eg(){let t=ix(),{theme:e}=y().config,{setTheme:o,theme:n}=y(),{activeLanguage:r,languages:a}=Rt(),s=a.find(P=>P.local===r)?.label,l=y().fetchStatus,c=y().swappers(),u=y().getDisabledLiquiditySources(),{config:{features:p}}=y(),d=y().customTokens(),h=Ve("theme",p),f=Ve("liquiditySource",p),m=Ve("language",p),g=Ve("customTokens",p),C=y().infiniteApprove,S=y().toggleInfiniteApprove,T=yr(c,u),k=T.filter(P=>["BRIDGE","AGGREGATOR","OFF_CHAIN"].includes(P.type)),v=k.length,w=k.filter(P=>P.selected).length,A=T.filter(P=>P.type==="DEX"),M=A.length,b=A.filter(P=>P.selected).length,E=i((P,X)=>{switch(l){case"loading":return D.createElement(Rb,{variant:"text",size:"medium",width:50});case"failed":return D.createElement(Ye,{variant:"body",size:"medium",color:"$error500"},dt.t("Loading failed"));default:return D.createElement(Ye,{variant:"body",size:"medium"},`${P} / ${X}`)}},"handleSwapperEndItem"),x={id:"widget-setting-bridge-item-btn",title:D.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Bridges")),end:D.createElement(D.Fragment,null,E(w,v),D.createElement(Yn,{direction:"horizontal",size:8}),D.createElement(Li,{color:"black"})),onClick:()=>t($.bridges),start:D.createElement(Gb,{color:"gray",size:16})},N={id:"widget-setting-exchange-item-btn",title:D.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Exchanges")),end:D.createElement(D.Fragment,null,E(b,M),D.createElement(Yn,{direction:"horizontal",size:8}),D.createElement(Li,{color:"black"})),start:D.createElement(Vb,{color:"gray",size:16}),onClick:()=>t($.exchanges)},I={id:"widget-setting-custom-tokens-item-btn",title:D.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Custom Tokens")),end:D.createElement(D.Fragment,null,D.createElement(Ye,{variant:"body",size:"medium"},`${d.length}`),D.createElement(Yn,{direction:"horizontal",size:8}),D.createElement(Li,{color:"black"})),start:D.createElement(nx,{color:"gray",size:16}),onClick:()=>t($.customTokens)},B={id:"widget-setting-language-item-btn",title:D.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Language")),start:D.createElement(Xb,{color:"gray",size:16}),end:D.createElement(D.Fragment,null,D.createElement(Ye,{variant:"body",size:"medium"},s),D.createElement(Yn,{direction:"horizontal",size:8}),D.createElement(Li,{color:"black"})),onClick:()=>t($.languages)},j={id:"widget-setting-infinite-approval-item-btn",title:D.createElement(D.Fragment,null,D.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Infinite approval")),D.createElement(Yn,{direction:"horizontal",size:4}),D.createElement(rx,{side:"top",sideOffset:4,container:W(),content:D.createElement(Mi,null,D.createElement(Ye,{variant:"label",size:"medium",color:"neutral700"},D.createElement("b",null,dt.t("Warning")),":\xA0",dt.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(jb,{color:"gray"}))),start:D.createElement(Kb,{color:"gray",size:16}),end:D.createElement(tx,{checked:C}),onClick:S},te={id:"widget-setting-theme-item-btn",type:D.createElement(Zb,null),title:D.createElement(Ye,{variant:"title",size:"xmedium"},dt.t("Theme")),end:D.createElement(ax,null,D.createElement(ox,{container:W(),items:sx,value:n,onChange:P=>o(P.id),type:"primary",borderRadius:"small"})),start:lx(n)},J=f?[]:[x,N];return g||J.push(I),m||J.push(B),J.push(j),!e?.singleTheme&&!h&&J.push(te),D.createElement(Yb,{type:D.createElement(Jb,{hasDivider:!0,id:"_",onClick:()=>console.log()}),items:J})}i(Eg,"SettingsLists");var fx=ux("div",{paddingLeft:"$8"});function Ig(){let{isInCampaignMode:t,updateCampaignMode:e}=y(),o=t(),[,n]=mx(),r=dx(),a=i(()=>{r&&o&&(n(s=>(s.delete("liquiditySources"),s),{replace:!0}),e("liquiditySources",void 0))},"onClick");return wo.createElement(oe,{header:{title:Ml.t("Settings")}},wo.createElement(ie,null,o&&wo.createElement(cx,{type:"info",variant:"alarm",title:Ml.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:wo.createElement(fx,null,wo.createElement(px,{id:"widget-setting-exit-campaign-mode-btn",type:"secondary",size:"small",onClick:a},Ml.t("Reset")))}),wo.createElement(Bl,null),wo.createElement(Eg,null)))}i(Ig,"SettingsPage");import{i18n as tE}from"@lingui/core";import{cancelSwap as oE}from"@rango-dev/queue-manager-rango-preset";import{useManager as nE}from"@rango-dev/queue-manager-react";import{Alert as rE}from"@rango-dev/ui";import jl from"react";import{useParams as iE}from"react-router-dom";import{i18n as it}from"@lingui/core";import{getCurrentNamespaceOfOrNull as Dx,getCurrentStep as $x,getRelatedWalletOrNull as Fx}from"@rango-dev/queue-manager-rango-preset";import{Button as ih,CopyIcon as Ox,Divider as Ux,DoneIcon as zx,IconButton as Qx,QuoteCost as qx,RangoExplorerIcon as Hx,StepDetails as Gx,Tooltip as ah,Typography as bo,useCopyToClipboard as Vx}from"@rango-dev/ui";import{useWallets as Kx}from"@rango-dev/wallets-react";import sh from"bignumber.js";import{PendingSwapNetworkStatus as zi}from"rango-types";import K,{useEffect as lh,useRef as jx,useState as ch}from"react";import{useNavigate as Xx}from"react-router-dom";import{i18n as eo}from"@lingui/core";var gx=[eo.t("Sunday"),eo.t("Monday"),eo.t("Tuesday"),eo.t("Wednesday"),eo.t("Thursday"),eo.t("Friday"),eo.t("Saturday")];function Ag(t){let e=new Date(t),o=e.getDate(),n=e.toLocaleString("default",{month:"long"}),r=e.getFullYear();return`${e.getDay()===new Date().getDay()?eo.t("Today"):`${gx[e.getDay()]} ${o} ${n} ${r}`}, ${new Date(t).toLocaleTimeString()}`}i(Ag,"timeSince");function Ng(t){return t.finishTime?Ag(parseInt(t.finishTime)):Ag(parseInt(t.creationTime))}i(Ng,"getSwapDate");import{PendingSwapNetworkStatus as Di}from"rango-types";import $i from"react";import{i18n as Pi}from"@lingui/core";import{Button as Wg,Divider as Ll,MessageBox as hx}from"@rango-dev/ui";import to from"react";var Bg=i(({onCancel:t,onClose:e})=>to.createElement(to.Fragment,null,to.createElement(Ll,{size:20}),to.createElement(hx,{type:"error",title:Pi.t("Cancel Swap"),description:Pi.t("Are you sure you want to cancel this swap?")}),to.createElement(Ll,{size:32}),to.createElement(Wg,{variant:"contained",id:"widget-swap-details-modal-cancel-swap-yes-btn",type:"primary",size:"large",onClick:t},Pi.t("Yes, Cancel it")),to.createElement(Ll,{size:12}),to.createElement(Wg,{id:"widget-swap-details-modal-cancel-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},Pi.t("No, Continue"))),"CancelContent");import{i18n as _i}from"@lingui/core";import{Button as Mg,Divider as Pl,MessageBox as yx,Typography as Sx}from"@rango-dev/ui";import qt from"react";var Lg=i(({onDelete:t,onClose:e})=>qt.createElement(qt.Fragment,null,qt.createElement(Pl,{size:20}),qt.createElement(yx,{type:"error",title:_i.t("Delete Transaction"),description:_i.t("Are you sure you want to delete this swap?")}),qt.createElement(Pl,{size:32}),qt.createElement(Mg,{id:"widget-swap-details-modal-delete-swap-yes-btn",variant:"contained",type:"primary",size:"large",onClick:t},_i.t("Yes, Delete it")),qt.createElement(Pl,{size:12}),qt.createElement(Mg,{id:"widget-swap-details-modal-delete-swap-no-btn",variant:"outlined",type:"primary",size:"large",onClick:e},qt.createElement(Sx,{variant:"title",size:"medium",color:"primary"},_i.t("No, Cancel")))),"DeleteContent");import{i18n as _l}from"@lingui/core";import{PendingSwapNetworkStatus as Dl}from"rango-types";var $l={[Dl.WaitingForNetworkChange]:{type:"loading",title:_l.t("Change Network")},[Dl.WaitingForConnectingWallet]:{type:"warning",title:_l.t("Connect Wallet")},[Dl.NetworkChanged]:{type:"success",title:_l.t("Network Changed")}};import{warn as Cx}from"@rango-dev/logging-core";import{MessageBox as kx,Wallet as Tx}from"@rango-dev/ui";import{useWallets as vx}from"@rango-dev/wallets-react";import Jo,{useState as wx}from"react";import{styled as Pg}from"@rango-dev/ui";var _g=Pg("div",{display:"flex",justifyContent:"center"}),l5=Pg("div",{maxWidth:280,"& ._typography":{wordWrap:"break-word",display:"block"}});var Dg=i(t=>{let{type:e,title:o,currentStepWallet:n,message:r,showWalletButton:a,walletButtonDisabled:s}=t,[l,c]=wx(),{getWalletInfo:u,state:p}=vx(),d=n?.walletType,h=d?ln(p(d)):null,f=d?u(d):null,m=a&&!!d&&!!h&&!!f,{list:g}=ft(),C=i(()=>{if(d){let S=g.find(T=>T.type===d);S?c(S):Cx(new Error(`It seems requested wallet to be connected is not available in the list. requested wallet: ${S}`))}},"handleWalletItemClick");return Jo.createElement(Jo.Fragment,null,Jo.createElement(kx,{type:e,title:o,description:r}),m&&Jo.createElement(_g,null,Jo.createElement(Tx,{container:W(),title:f.name,image:f.img,type:d,state:h,link:f.installLink,disabled:s,onClick:C})),Jo.createElement(po,{wallet:l,onClose:()=>{c(void 0)}}))},"WalletStateContent");function Fl(t){let{state:e,onClose:o,onDelete:n,onCancel:r,currentStepWallet:a,message:s,walletButtonDisabled:l}=t,c=e===Di.WaitingForNetworkChange||e===Di.WaitingForConnectingWallet||e===Di.NetworkChanged;return $i.createElement(Z,{open:!!e,onClose:o,container:document.getElementById(De.SWAP_BOX_ID)||document.body},c&&$i.createElement(Dg,{type:$l[e].type,title:$l[e].title,currentStepWallet:a,message:s,walletButtonDisabled:l,showWalletButton:e!==Di.WaitingForNetworkChange}),e==="delete"&&$i.createElement(Lg,{onClose:o,onDelete:n}),e==="cancel"&&$i.createElement(Bg,{onClose:o,onCancel:r}))}i(Fl,"SwapDetailsModal");import{i18n as Zn}from"@lingui/core";import{Button as Ol,Divider as Jn,MessageBox as $g,TokenAmount as bx,Typography as Fg}from"@rango-dev/ui";import Ce from"react";import{useNavigate as xx}from"react-router-dom";function Ul(t){let{open:e,onClose:o,status:n,priceValue:r,usdValue:a,realUsdValue:s,realValue:l,token:c,chain:u,percentageChange:p,description:d,diagnosisUrl:h}=t,f=xx(),{showProfileBanner:m}=re();return Ce.createElement(Z,{open:e,onClose:o,container:document.getElementById(De.SWAP_BOX_ID)||document.body},n==="success"?Ce.createElement($g,{type:"success",title:Zn.t("Swap Successful")},Ce.createElement(bx,{direction:"vertical",tooltipContainer:W(),type:"output",centerAlign:!0,price:{value:r,usdValue:a,realUsdValue:s,realValue:l},token:c,chain:u,percentageChange:p}),Ce.createElement(Jn,{size:12}),Ce.createElement(Fg,{variant:"body",size:"medium",color:"neutral700",align:"center"},d)):Ce.createElement($g,{type:"error",title:Zn.t("Transaction Failed"),description:d}),Ce.createElement(Jn,{size:30}),n==="success"&&Ce.createElement(Ce.Fragment,null,m&&Ce.createElement(Ce.Fragment,null,Ce.createElement("img",{src:"https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.png",alt:"Profile Banner"}),Ce.createElement(Jn,{size:30})),Ce.createElement(Ol,{id:"widget-swap-details-modal-done-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{f("../../")}},Zn.t("Done"))),Ce.createElement(Jn,{size:12}),h&&Ce.createElement(Ce.Fragment,null,Ce.createElement(Ol,{variant:"contained",id:"widget-swap-detail-modal-diagnosis-btn",type:"primary",size:"large",onClick:()=>window.open(h,"_blank")},Zn.t("Diagnosis")),Ce.createElement(Jn,{size:12})),Ce.createElement(Ol,{id:"widget-swap-details-modal-see-details-btn",variant:"outlined",type:"primary",size:"large",onClick:o},Ce.createElement(Fg,{variant:"title",size:"medium",color:"primary"},Zn.t("See Details"))))}i(Ul,"SwapDetailsCompleteModal");import _x from"react";import{i18n as Bx}from"@lingui/core";import{Alert as th,IconButton as Mx,LinkIcon as Lx}from"@rango-dev/ui";import oo,{Fragment as Px}from"react";import{Alert as Ix,ChevronDownIcon as Ax,IconButton as Nx}from"@rango-dev/ui";import en,{useState as Wx}from"react";import{css as Rn,darkTheme as Og,styled as Ht,Typography as Ex}from"@rango-dev/ui";var Ug=Ht("div",{display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"}),Fi=Ht("div",{width:"100%","& ._icon-button":{"&:hover":{"& svg":{color:"$secondary550",[`.${Og} &`]:{color:"$secondary500"}}}}}),zg=Ht(Tn,{padding:"$0 $20 $20 $20"}),V5=Ht("div",{display:"flex",flexDirection:"column",gap:"$10"}),Qg=Ht("div",{height:"450px",display:"flex",alignItems:"center",justifyContent:"center"}),K5=Ht("div",{display:"flex",justifyContent:"center",width:"100%",paddingTop:"33%",flex:1}),Ro=Rn({display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center",padding:"$10 $20",borderBottom:"1px solid",$$color:"$colors$neutral300",[`.${Og} &`]:{$$color:"$colors$neutral400"},borderColor:"$$color",color:"$neutral500"}),qg=Rn({padding:"$5 0"}),Oi=Rn({display:"flex",justifyContent:"center",alignItems:"center",height:"$24"}),Hg=Rn({display:"flex",width:"100%",padding:"$15 $20 $20",flexDirection:"column",alignItems:"start"}),Gg=Rn({width:"100%",padding:"0 $20 $10"}),Vg=Ht("a",{fontSize:"$16",fontWeight:"$400",color:"$neutral700",display:"flex",alignItems:"center",justifyContent:"center"}),Kg=Ht("div",{display:"flex",flexDirection:"column",gap:"$5"}),Ui=Ht(Ex,{wordBreak:"break-word"});import{styled as zl}from"@rango-dev/ui";var jg=zl("div",{display:"flex",flexDirection:"column",gap:"$10"}),Xg=zl("div",{transition:"transform 0.3s ease-in-out",variants:{rotated:{true:{transform:"rotate(180deg)"}}}}),Yg=zl("div",{transition:"max-height 0.3s ease-in-out",maxHeight:"0px",overflow:"hidden",variants:{open:{true:{maxHeight:"200px"}}}});function Zg(t){let{message:e}=t,[o,n]=Wx(!1);return en.createElement(Ix,{type:"error",title:e.shortMessage,containerStyles:{"& .footer":{paddingTop:"$0"}},action:e.detailedMessage.content&&en.createElement(Nx,{onClick:()=>n(r=>!r),variant:"ghost",size:"xsmall"},en.createElement(Xg,{rotated:o},en.createElement(Ax,{size:12,color:"gray"}))),footer:en.createElement(Yg,{open:o},en.createElement(Ui,{variant:"body",size:"xsmall",color:"neutral700"},e.detailedMessage.content))})}i(Zg,"FailedAlert");import{i18n as Jg}from"@lingui/core";import{Alert as Ql,Button as Rg}from"@rango-dev/ui";import{PendingSwapNetworkStatus as ql}from"rango-types";import er from"react";function eh(t){let{switchNetwork:e,setNetworkModal:o,message:n,showNetworkModal:r}=t;return e?er.createElement(Ql,{type:"warning",title:n.shortMessage,action:er.createElement(Rg,{id:"widget-swap-details-warning-alert-change-network-btn",size:"xxsmall",type:"warning",onClick:()=>{o(ql.WaitingForNetworkChange),e().catch(a=>{console.log(a)})}},Jg.t("Change"))}):r===ql.WaitingForConnectingWallet?er.createElement(Ql,{type:"warning",title:n.shortMessage,action:er.createElement(Rg,{id:"widget-swap-details-warning-alert-connect-wallet-btn",size:"xxsmall",type:"warning",onClick:()=>{o(ql.WaitingForConnectingWallet)}},Jg.t("Connect"))}):er.createElement(Ql,{type:"warning",title:n.shortMessage})}i(eh,"WarningAlert");function Hl(t){let{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r,step:a,hasAlreadyProceededToSign:s}=t,l=Cn(a),c=a.status==="waitingForApproval"&&!l,u=a.status==="running"&&!l,p=u&&!s||c&&!a.explorerUrl?.length;return oo.createElement(jg,null,a.explorerUrl?.map((d,h,f)=>{let m=h+d.url,g=h===f.length-1,C=(g&&u||c)&&!p,S=g&&a.status==="failed";return oo.createElement(Px,{key:m},oo.createElement(th,{type:g&&(C&&"loading"||S&&"error")||"success",title:d.description?`${d.description} Tx`:Bx.t("View transaction"),action:d.url&&oo.createElement(Mx,{id:"widget-swap-details-tx-link-icon-btn",variant:"ghost",size:"xsmall",onClick:()=>window.open(d.url,"_blank")},oo.createElement(Lx,{size:12}))}))}),p&&oo.createElement(th,{type:"loading",title:r.shortMessage}),a.status!=="failed"&&l&&oo.createElement(eh,{switchNetwork:e,showNetworkModal:o,setNetworkModal:n,message:r}),a.status==="failed"&&oo.createElement(Zg,{message:r}))}i(Hl,"SwapDetailsAlerts");var oh=2e3;var nh=i(({swap:t,blockchains:e,swappers:o,...n})=>{let r=t.hasAlreadyProceededToSign!==!1;return t.steps.map((a,s)=>{let l=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:st(a.fromBlockchain,e)??"",image:a.fromBlockchainLogo??""},price:{value:L(l,6,6),realValue:l??""}},to:{token:{displayName:a.toSymbol,image:a.toLogo},chain:{displayName:st(a.toBlockchain,e)??"",image:a.toBlockchainLogo??""},price:{value:L(a.outputAmount||a.expectedOutputAmountHumanReadable,6,6),realValue:a.outputAmount||a.expectedOutputAmountHumanReadable||""}},swapper:{displayName:on(a.swapperId,o)??"",image:a.swapperLogo??"",type:a.swapperType},internalSwaps:a.internalSwaps?a.internalSwaps.map(c=>({from:{chain:{displayName:st(c.fromBlockchain,e)??"",image:c.fromBlockchainLogo??""}},to:{chain:{displayName:st(c.toBlockchain,e)??"",image:c.toBlockchainLogo??""}},swapper:{displayName:on(c.swapperId,o)??"",image:c.swapperLogo??"",type:c.swapperType}})):[],alerts:_x.createElement(Hl,{step:a,hasAlreadyProceededToSign:r,...n})}})},"getSteps");function rh(t){if(Cn(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(rh,"getStepState");function Gl(t){let{swap:e,requestId:o,onDelete:n,onCancel:r}=t,{canSwitchNetworkTo:a,connect:s,getWalletInfo:l}=Kx(),c=y().blockchains(),u=y().swappers(),{findToken:p}=y(),d=O.use.retry(),h=re.use.isActiveTab(),f=Xx(),[m,g]=Vx(oh),C=jx(null),[S,T]=ch(null),[k,v]=ch(null),w=i(()=>{r(),T(null)},"onCancel"),A=be.use.getNotifications(),M=be.use.removeNotification(),b=A(),E=$x(e),x=E?.networkStatus;lh(()=>{b.find(mt=>mt.requestId===e.requestId)&&(e.status==="success"||e.status==="failed"?(v(e.status),M(e.requestId)):k&&v(null))},[e.status,e.requestId]),lh(()=>{P?T(zi.WaitingForNetworkChange):x===zi.WaitingForConnectingWallet||x===zi.NetworkChanged?T(x):T(null)},[x]);let N=lu(e),I=E?Dx(e,E):null,B=E?Fx(e,E):null,j=Ng(e),te=cu(e),J=i(ve=>!!l(ve)?.mobileWallet,"isMobileWallet"),P=x===zi.WaitingForNetworkChange&&!!I&&!!B?.walletType&&(J(B.walletType)||a(B.walletType,I.network)),X=P?s.bind(null,B.walletType,[{namespace:I.namespace,network:I.network}]):void 0,se=su(e,E),z=nh({swap:e,switchNetwork:X,showNetworkModal:x,setNetworkModal:T,message:se,blockchains:c,swappers:u}),me=z.length,[vt,Ze]=[e.steps[0],e.steps[me-1]],le=Ze.outputAmount||Ze.expectedOutputAmountHumanReadable,at=e.steps.reduce((ve,mt)=>ve+parseFloat(mt.feeInUsd||""),0),G=e.steps.find(ve=>ve.diagnosisUrl)?.diagnosisUrl,_=L(parseFloat(le||"0")*(Ze.toUsdPrice||0),4,4),H=L(parseFloat(e.inputAmount)*(vt.fromUsdPrice||0),4,4),V=le?new sh(le).multipliedBy(Ze.toUsdPrice||0).toString():"",fe=new sh(e.inputAmount).multipliedBy(vt.fromUsdPrice||0).toString(),ne=Pt(H,_),ge=se.detailedMessage.content||se.shortMessage,Fe=e.status==="success"?it.t({id:"You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.",values:{amount:L(le,6,6),token:z[me-1].to.token.displayName,conciseAddress:gr(e.wallets[z[me-1].to.chain.displayName]?.address||""),chain:z[me-1].to.chain.displayName}}):K.createElement(Kg,null,K.createElement(bo,{variant:"body",size:"medium",color:"neutral700",align:"center"},ge?"":it.t("Transaction was not sent."),N?`${it.t({id:"{amount} {symbol} on {blockchain} remains in your wallet.",values:{amount:N.outputAmount,symbol:N.symbol,blockchain:N.blockchain}})}`:""),ge&&K.createElement(Ui,{align:"center",variant:"body",size:"medium",color:"neutral700"},K.createElement("b",null,"Reason:")," ",ge));return K.createElement(oe,{header:{title:it.t("Swap Details"),onCancel:e.status==="running"?()=>T("cancel"):void 0,suffix:e.status!=="running"&&K.createElement(Vt,null,K.createElement(ih,{id:"widget-swap-details-delete-btn",variant:"ghost",type:"error",size:"xsmall",onClick:()=>T("delete")},K.createElement(bo,{size:"medium",variant:"label",color:"error"},it.t("Delete"))))},footer:te&&!k&&K.createElement(ih,{fullWidth:!0,id:"widget-swap-details-try-again-btn",variant:"contained",type:"primary",size:"large",onClick:()=>{let ve=Nr(e,c,p);d(ve),setTimeout(()=>{f("../../")},0)}},it.t("Try again"))},K.createElement(ie,{compact:!0,view:!0},K.createElement(Fi,null,K.createElement("div",{className:Ro()},K.createElement(bo,{variant:"label",size:"large",color:"neutral700"},`${it.t("Request ID")}`),K.createElement("div",{className:Oi()},K.createElement(bo,{variant:"label",size:"small",color:"neutral700"},o),K.createElement(ah,{container:W(),content:m?it.t("Copied To Clipboard"):it.t("Copy Request ID"),open:m||void 0,side:"bottom",alignOffset:-16,align:"end"},K.createElement(Qx,{id:"widget-swap-details-done-copy-icon-btn",variant:"ghost",onClick:g.bind(null,o||"")},m?K.createElement(zx,{size:16,color:"secondary"}):K.createElement(Ox,{size:16,color:"gray"}))),K.createElement(Vg,{target:"_blank",href:`${yc}/swap/${o}`},K.createElement(ah,{container:W(),content:it.t("View on Rango Explorer"),side:"bottom"},K.createElement(Hx,{size:20}))))),K.createElement("div",{className:Ro()},K.createElement(bo,{variant:"label",size:"large",color:"neutral700"},e.finishTime?it.t("Finished at"):it.t("Created at")),K.createElement(bo,{variant:"label",size:"small",color:"neutral700"},j))),K.createElement("div",{className:Hg()},K.createElement(qx,{fee:L(String(at),2,2),time:an(pr(e.steps)),steps:me}),K.createElement(Nn,{from:{price:{value:L(e.inputAmount,6,6),usdValue:H,realUsdValue:fe,realValue:e.inputAmount},token:{displayName:z[0].from.token.displayName,image:z[0].from.token.image},chain:{image:z[0].from.chain.image,displayName:z[0].from.chain.displayName}},to:{price:{value:L(le,6,6),usdValue:_,realUsdValue:V,realValue:le||""},token:{displayName:z[me-1].to.token.displayName,image:z[me-1].to.token.image},chain:{image:z[me-1].to.chain.image,displayName:z[me-1].to.chain.displayName}},percentageChange:L(ne,2,2),warningLevel:_t(ne??0)})),K.createElement("div",{className:Gg()},K.createElement(bo,{variant:"title",size:"small"},it.t("Swaps steps"))),K.createElement(Ux,{size:8}),K.createElement(zg,{ref:C},z.map((ve,mt)=>{let tc=mt,tn=rh(e.steps[mt]),$h=tn==="error"||tn==="in-progress"||tn==="warning"||tn==="completed"&&mt===z.length-1;return K.createElement(Gx,{key:tc,step:ve,type:"swap-progress",ref:C,state:tn,hasSeparator:mt!==0,tabIndex:tc,isFocused:$h,tooltipContainer:W()})}))),K.createElement(Fl,{state:S,onClose:()=>T(null),onCancel:w,onDelete:n,message:se.detailedMessage.content,currentStepWallet:B,walletButtonDisabled:!h}),K.createElement(Ul,{open:!!k,diagnosisUrl:G,onClose:()=>v(null),status:e.status==="success"?"success":"failed",priceValue:L(le,6,6),usdValue:_,realUsdValue:V,realValue:le||"",percentageChange:L(ne,2,2),token:{displayName:z[me-1].to.token.displayName,image:z[me-1].to.token.image},chain:{image:z[me-1].to.chain.image},description:Fe}))}i(Gl,"SwapDetails");import{i18n as qi}from"@lingui/core";import{Divider as dh,NotFound as eE,Skeleton as or,Typography as Hi}from"@rango-dev/ui";import ke from"react";import{i18n as Yx}from"@lingui/core";import{Divider as Zx,Skeleton as Jx,Typography as Rx}from"@rango-dev/ui";import Te from"react";import{css as Tt,styled as Vl}from"@rango-dev/ui";var ph=Vl("div",{width:"100%",height:"100%",padding:"$10 $20"}),tr=Vl("div",{backgroundColor:"$neutral100",borderRadius:"$xm",padding:"$10 $15"}),Qi=Vl("div",{width:"0px",height:"$20",borderLeft:"1px dashed $neutral700",marginLeft:"25px"}),iK=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),aK=Tt({display:"flex",justifyContent:"space-between",alignItems:"center"}),sK=Tt({paddingTop:"$15",display:"flex"}),lK=Tt({padding:"$15 $0"}),cK=Tt({width:"0px",height:"$16",borderLeft:"1px solid $neutral400",marginLeft:"13px"}),pK=Tt({paddingBottom:"$10"}),uK=Tt({display:"flex",justifyContent:"start",alignItems:"center"}),dK=Tt({paddingTop:"$5",display:"flex",alignItems:"center"}),mK=Tt({display:"flex",alignItems:"center"}),fK=Tt({padding:"$4 $6",display:"flex",justifyContent:"center",alignItems:"center"}),uh=Tt({display:"flex",paddingTop:"$10",paddingBottom:"$5"});function Kl(){return Te.createElement(ph,null,Te.createElement(Mn,{type:"swap-preview"}),Te.createElement("div",{className:"swaps-steps"},Te.createElement(Rx,{variant:"title",size:"small"},Yx.t("Swaps steps"))),Te.createElement(Te.Fragment,null,Te.createElement(tr,null,Te.createElement(Nt,{separator:!1}),Te.createElement("div",{className:uh()},Te.createElement(Zx,{direction:"horizontal",size:20}),Te.createElement(Jx,{height:22,variant:"rectangular"}))),Te.createElement(Qi,null),Te.createElement(tr,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Qi,null),Te.createElement(tr,null,Te.createElement(Nt,{separator:!1})),Te.createElement(Qi,null),Te.createElement(tr,null,Te.createElement(Nt,{separator:!1}))))}i(Kl,"LoadingSwapDetails");function mh(t){let{requestId:e,showSkeleton:o}=t;return ke.createElement(oe,{header:{title:qi.t("Swap Details"),suffix:ke.createElement(Vt,null)}},o&&ke.createElement(Ug,null,ke.createElement(Fi,null,ke.createElement("div",{className:Ro()},ke.createElement(Hi,{variant:"label",size:"large",color:"neutral700"},`${qi.t("Request ID")}`),ke.createElement("div",{className:Oi()},ke.createElement(Hi,{variant:"label",size:"small",color:"neutral700"},ke.createElement(or,{width:60,height:10,variant:"rounded"})),ke.createElement(dh,{direction:"horizontal",size:4}),ke.createElement(or,{width:16,height:16,variant:"rectangular"}),ke.createElement(dh,{direction:"horizontal",size:4}),ke.createElement(or,{width:16,height:16,variant:"rectangular"}))),ke.createElement("div",{className:Ro()},ke.createElement(Hi,{className:qg(),variant:"label",size:"large",color:"neutral700"},ke.createElement(or,{width:60,height:10,variant:"rounded"})),ke.createElement(Hi,{variant:"label",size:"small",color:"neutral700"},ke.createElement(or,{width:60,height:10,variant:"rounded"})))),ke.createElement(Kl,null)),!o&&ke.createElement(Qg,null,ke.createElement(eE,{title:qi.t("Not found"),description:qi.t({id:"Swap with request ID = {requestId} not found.",values:{requestId:e}})})))}i(mh,"SwapDetailsPlaceholder");function fh(){let{manager:t,state:e}=nE(),o=!e.loadedFromPersistor,n=pt(t),{requestId:r}=iE(),a=je(),{fetchStatus:s}=y();if(!r)return jl.createElement(rE,{containerStyles:{margin:"20px"},type:"error",title:tE.t("The request ID is necessary to display the swap details.")});let l=o||s==="loading",c=r?n.find(({swap:h})=>h.requestId===r):void 0,u=i(()=>{if(c?.id){let h=t?.get(c.id);h&&oE(h)}},"onCancel"),p=i(async()=>{if(c?.id)try{t?.deleteQueue(c.id),a()}catch(h){console.log(h)}},"onDelete"),d=c?.swap;return!d||l?jl.createElement(mh,{requestId:r,showSkeleton:l}):jl.createElement(Gl,{swap:d,requestId:r,onCancel:u,onDelete:p})}i(fh,"SwapDetailsPage");import{i18n as gh}from"@lingui/core";import{Divider as aE,getCategoriesCount as sE,SelectableCategoryList as lE,styled as yh,Typography as cE,Wallet as pE}from"@rango-dev/ui";import Bt,{useState as hh}from"react";var uE=yh("div",{display:"flex",justifyContent:"center",alignItems:"center",gap:"$10",flexWrap:"wrap",paddingTop:"$5"}),dE=yh(ie,{textAlign:"center"});function Sh(){let{fetchStatus:t}=y(),[e,o]=hh("ALL"),n=y().blockchains(),{config:r}=y(),[a,s]=hh(),l=re.use.isActiveTab(),{list:c}=ft(),u=Oc(c,n),d=sE(u)!==1,h=Uc(c,e),f=i(m=>{Ac(c,r.multiWallets)||s(m)},"handleWalletItemClick");return Bt.createElement(oe,{header:{title:gh.t("Connect Wallets")}},Bt.createElement(dE,null,d&&Bt.createElement(Bt.Fragment,null,Bt.createElement(lE,{setCategory:o,category:e,blockchains:u,isLoading:t==="loading"}),Bt.createElement(aE,{size:24})),Bt.createElement(cE,{variant:"title",size:"xmedium",align:"center"},gh.t("Choose a wallet to connect.")),Bt.createElement(uE,null,h.map((m,g)=>{let C=`wallet-${g}-${m.type}`;return Bt.createElement(pE,{key:C,...m,container:W(),onClick:()=>f(m),isLoading:t==="loading",disabled:!l})}),Bt.createElement(po,{wallet:a,onClose:()=>{s(void 0)}}))))}i(Sh,"WalletsPage");function Ch(){return mu(),_a(),mE([{path:$.home,element:_e.createElement(jf,null)},{path:$.routes,element:_e.createElement(Rf,null)},{path:$.fromSwap,children:[{index:!0,element:_e.createElement(Nl,{type:"source"})},{path:$.blockchains,element:_e.createElement(Ni,{type:"source"})}]},{path:$.toSwap,children:[{index:!0,element:_e.createElement(Nl,{type:"destination"})},{path:$.blockchains,element:_e.createElement(Ni,{type:"destination"})}]},{path:$.settings,children:[{index:!0,element:_e.createElement(Ig,null)},{path:$.languages,element:_e.createElement(Yf,null)},{path:$.exchanges,element:_e.createElement(Tl,{sourceType:"Exchanges"})},{path:$.bridges,element:_e.createElement(Tl,{sourceType:"Bridges"})},{path:$.customTokens,children:[{index:!0,element:_e.createElement(nf,null)},{path:$.addCustomTokens,children:[{index:!0,element:_e.createElement(ju,null)},{path:$.blockchains,element:_e.createElement(Ni,{hideCategory:!0,type:"custom-token"})}]}]}]},{path:$.swaps,children:[{index:!0,element:_e.createElement(bf,null)},{path:$.swapDetails,element:_e.createElement(fh,null)}]},{path:$.wallets,element:_e.createElement(Sh,null)},{path:$.confirmSwap,element:_e.createElement(qm,null)}])}i(Ch,"AppRoutes");import{useQueueManager as vE}from"@rango-dev/queue-manager-rango-preset";import{splitWalletNetwork as wE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as bE}from"rango-sdk";import{useContext as xE,useEffect as Eh,useState as Ih}from"react";import{globalCss as fE}from"@rango-dev/ui";var kh=i(()=>fE({"@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");function Th(){let{setWatermark:t,setShowProfileBanner:e}=re();return{fetchApiConfig:i(async()=>{let n=await fetch(`${Lt("BASE_URL")}/meta/dapp/config?apiKey=${Lt("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(Th,"useFetchApiConfig");import{useWallets as gE}from"@rango-dev/wallets-react";import{useEffect as hE,useRef as yE}from"react";function vh(){let{connect:t,state:e}=gE(),o=yE({}),{fetchStatus:n}=y(),r=new URLSearchParams(location.search).get("autoConnect")||"",a=e(r);hE(()=>{n==="success"&&r&&a.installed&&!a.connecting&&!a.connected&&!o.current[r]&&(o.current[r]=!0,t(r))},[a,n])}i(vh,"useForceAutoConnect");import{isApprovalTX as SE,RouteEventType as wh,StepEventType as bh,StepExecutionEventStatus as CE,WidgetEvents as Gi}from"@rango-dev/queue-manager-rango-preset";import{useEffect as xh}from"react";function Xl(){let t=be.use.setNotification(),{connectedWallets:e,fetchBalances:o}=y();xh(()=>{let n=i(r=>{let{event:a,step:s,route:l}=r;if(a.type===bh.TX_EXECUTION&&a.status===CE.TX_SENT&&!SE(s)||a.type===bh.SUCCEEDED){let u=e.find(d=>d.chain===s?.fromBlockchain),p=s?.fromBlockchain!==s?.toBlockchain&&e.find(d=>d.chain===s?.toBlockchain);u&&o([u]),p&&o([p])}t(a,l)},"handleStepEvent");return he.on(Gi.StepEvent,n),()=>he.off(Gi.StepEvent,n)},[he,e]),xh(()=>{let n=i(r=>{let{event:a,route:s}=r;(a.type===wh.FAILED||a.type===wh.SUCCEEDED)&&t(a,s)},"handleRouteEvent");return he.on(Gi.RouteEvent,n),()=>he.off(Gi.RouteEvent,n)},[he])}i(Xl,"useSubscribeToWidgetEvents");import{useManager as kE}from"@rango-dev/queue-manager-react";import{useEffect as TE}from"react";function Yl(){let{isSynced:t,syncNotifications:e}=be(),{manager:o,state:n}=kE();TE(()=>{be.persist.hasHydrated()&&n.loadedFromPersistor&&!t&&e(pt(o))},[be.persist.hasHydrated(),n.loadedFromPersistor,t])}i(Yl,"useSyncNotifications");function Zl(){vh(),kh(),Xl(),Yl();let t=y().blockchains(),{canSwitchNetworkTo:e}=jr(),[o,n]=Ih(""),[r,a]=Ih(),s=xE(xr),l=t.filter(bE),{fetchApiConfig:c}=Th();Eh(()=>()=>du(),[]),vE({lastConnectedWallet:o,clearDisconnectedWallet:()=>{a(void 0)},disconnectedWallet:r,evmChains:l,canSwitchNetworkTo:e}),Eh(()=>(ao.init(),be.persist.hasHydrated()||be.persist.rehydrate(),s.onConnectWallet(n),s.onDisconnectWallet(u=>{a(u),u===wE(o)?.[0]&&n("")}),c().catch(console.log),ao.destroy),[])}i(Zl,"useBootstrap");import{styled as EE}from"@rango-dev/ui";var Ah=EE("div",{fontFamily:"$widget",boxSizing:"border-box",textAlign:"left","& *, *::before, *::after":{boxSizing:"inherit"},"& *:focus-visible":{outlineColor:"$info500",transition:"none"},"& ul, ol, li":{listStyleType:"none"}});function Vi(){Zl();let{config:t}=y(),{activeTheme:e}=Uo(t?.theme||{}),{activeLanguage:o}=Rt();return Jl.createElement(IE,{language:o},Jl.createElement(Ah,{id:"swap-container",className:e()},Jl.createElement(Ch,null)))}i(Vi,"Main");import{setSolanaSignerConfig as KE}from"@rango-dev/signer-solana";import ec,{useEffect as Ph,useMemo as jE}from"react";import{useState as AE}from"react";var NE=i(()=>{let[t,e]=AE(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=Ic(a);if(s){let l=o(s);e(l)}},"handleLoadCustomFont")}},"useFontLoader"),Nh=NE;import{checkWaitingForNetworkChange as WE,makeQueueDefinition as BE}from"@rango-dev/queue-manager-rango-preset";import{Provider as ME}from"@rango-dev/queue-manager-react";import{useWallets as LE}from"@rango-dev/wallets-react";import{convertEvmBlockchainMetaToEvmChainInfo as PE}from"@rango-dev/wallets-shared";import{isEvmBlockchain as _E}from"rango-types";import DE,{useMemo as $E}from"react";function FE(t){let{providers:e,getSigners:o,state:n,connect:r,canSwitchNetworkTo:a,getWalletInfo:s}=LE(),l=$E(()=>BE({API_KEY:t.apiKey||Lt("API_KEY"),BASE_URL:Lt("BASE_URL"),emitter:{emit:he.emit}}),[t.apiKey]),{blockchains:c,connectedWallets:u}=y(),p=c(),d={blockchains:u.map(v=>({accounts:[v],name:v.chain}))},h=i(async(v,w)=>a(v,w.network)?await r(v,[w]):void 0,"switchNetwork"),f=i(v=>!!s(v).mobileWallet,"isMobileWallet"),m=p.filter(v=>v.enabled).reduce((v,w)=>(v[w.name]=w,v),{}),g=p.filter(_E),C=i(v=>{let{supportedChains:w}=s(v);return mr(w)},"getSupportedChainNames"),S=e(),T={meta:{blockchains:m,evmBasedChains:g,evmNetworkChainInfo:PE(g),getSupportedChainNames:C},getSigners:o,wallets:d,providers:S,switchNetwork:h,canSwitchNetworkTo:a,state:n,isMobileWallet:f},k=re.use.isActiveTab();return DE.createElement(ME,{queuesDefs:[l],context:T,onPersistedDataLoaded:v=>{WE(v)},isPaused:!k},t.children)}i(FE,"QueueManager");var Wh=FE;import{useManager as qE}from"@rango-dev/queue-manager-react";import HE,{createContext as GE,useContext as VE}from"react";function Bh(){let{findToken:t}=y(),e=y().blockchains(),o=y().tokens(),{setFromBlockchain:n,setFromToken:r,setToBlockchain:a,setToToken:s,setInputAmount:l}=O();return i(u=>{let{fromBlockchain:p,fromToken:d,toBlockchain:h,toToken:f,requestAmount:m}=u,g={blockchains:e,tokens:o};if(p!==void 0){let C=e.find(S=>S.name===p)??null;n(C)}if(d!==void 0){let C=d?t(d)??null:null;r({meta:g,token:C})}if(h!==void 0){let C=e.find(S=>S.name===h)??null;a(C)}if(f!==void 0){let C=f?t(f)??null:null;s({meta:g,token:C})}m!==void 0&&l(m)},"updateQuoteInputs")}i(Bh,"useUpdateQuoteInputs");import{cancelSwap as OE,getCurrentNamespaceOfOrNull as UE,getCurrentStep as zE,getRelatedWalletOrNull as QE}from"@rango-dev/queue-manager-rango-preset";var Ki=class{static{i(this,"WidgetHistory")}constructor(e,o){this.manager=e,this.actions=o}getAllSwaps(){return pt(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=Nr(e,o.blockchains,this.actions.findToken);return this.actions.retrySwap(n)}cancel(e){let o=this.manager?.get(e);o&&OE(o)}getCurrentStepInfo(e){let o=zE(e);return{step:o,wallet:o?QE(e,o):null,network:o?UE(e,o)?.network:null}}};var Mh=GE(void 0);function Rl(t){let{manager:e}=qE(),o=re.use.isActiveTab(),n=O.use.retry(),{findToken:r,getBalances:a,getConnectedWalletsDetails:s,fetchBalances:l}=y(),c=new Ki(e,{retrySwap:n,findToken:r}),{fetchingWallets:u}=y(),p=Lc(a()),d=y().blockchains(),h=y().tokens(),f=y().swappers(),m=y().fetchStatus,g=Rt().resetLanguage,C=be().getNotifications(),S=be().clearNotifications,T=Bh(),{fromBlockchain:k,toBlockchain:v,fromToken:w,toToken:A,inputAmount:M}=O(),b={isActiveTab:o,setCurrentTabAsActive:ao.forceClaim,history:c,wallets:{isLoading:u,details:s(),totalBalance:p,refetch:async E=>l(E)},meta:{blockchains:d,tokens:h,swappers:f,loadingStatus:m,findToken:r},resetLanguage:g,notifications:{list:C,clearAll:S},quote:{quoteInputs:{fromBlockchain:k?.name??null,fromToken:w?{symbol:w.symbol,blockchain:w.blockchain,address:w.address}:null,toBlockchain:v?.name??null,toToken:A?{symbol:A.symbol,blockchain:A.blockchain,address:A.address}:null,requestAmount:M},updateQuoteInputs:T}};return HE.createElement(Mh.Provider,{value:b},t.children)}i(Rl,"WidgetInfo");function Lh(){let t=VE(Mh);if(!t)throw new Error("useWidget can only be used within the WidgetProvider component");return t}i(Lh,"useWidget");function ji(t){let{onUpdateState:e,config:o}=t,n=t.config?.theme?.fontFamily,{handleLoadCustomFont:r}=Nh();return Ph(()=>{n&&r(n)},[n]),jE(()=>{zc({API_KEY:o?.apiKey||sr,BASE_URL:o?.apiUrl||hc})},[o.apiKey,o.apiUrl]),Ph(()=>{t.config?.signers?.customSolanaRPC&&KE("customRPC",t.config.signers.customSolanaRPC)},[t.config?.signers?.customSolanaRPC]),ec.createElement(Er,{config:o,onUpdateState:e},ec.createElement(Wh,{apiKey:o.apiKey},ec.createElement(Rl,null,t.children)))}i(ji,"WidgetProvider");function _h(t){let e=t.config?.externalWallets;return Xi.createElement(Pp,null,e?Xi.createElement(Vi,null):Xi.createElement(ji,{config:t.config??ar},Xi.createElement(Vi,null)))}i(_h,"Widget");function Dh(){let{on:t,off:e}=he;return{on:t,off:e}}i(Dh,"useWidgetEvents");var T3={DerivationPath:gn,Namespaces:fn,isOnDerivationPath:yn,isOnNamespace:hn};export{Kj as EventSeverity,Wo as MainEvents,n3 as Networks,a3 as PendingSwapNetworkStatus,pa as QuoteEventTypes,jj as RouteEventType,ea as SUPPORTED_FONTS,T3 as StatefulConnect,Xj as StepEventType,Yj as StepExecutionBlockedEventStatus,Zj as StepExecutionEventStatus,De as UI_ID,da as UiEventTypes,ua as WalletEventTypes,t3 as WalletEvents,r3 as WalletTypes,_h as Widget,Wo as WidgetEvents,ji as WidgetProvider,Er as WidgetWallets,Ka as customizedThemeTokens,Rj as readAccountAddress,Gt as useStatefulConnect,ft as useWalletList,jr as useWallets,Lh as useWidget,Dh as useWidgetEvents,Uy as widgetEventEmitter};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|