Files
to_session/text/3.65.22_0/scripts/ui/Advanced-OLP3WL2W.js
Administrator a0720d80dc fefdwef
2025-11-12 12:54:37 +08:00

8 lines
124 KiB
JavaScript

import{a as Cs,b as Ut,c as As,d as Es}from"./chunk-CABCMWZT.js";import{a as Ts,e as Is,f as ks,h as _s,m as Rs,p as ko}from"./chunk-5BADSTNQ.js";import"./chunk-MILCEF7B.js";import{a as tr,d as er}from"./chunk-KS3GEYRJ.js";import{a as io,b as co,c as uo,d as as,e as cs,f as ho,g as Co,h as Io,i as gs}from"./chunk-EIXSS37E.js";import{a as Fn,b as so,c as Un,d as Dt,e as Xo,f as Ft,g as Mt,h as Xn,i as st,k as po,m as ss,q as ms,r as Ao,s as ds,t as hs,u as Ie}from"./chunk-FVJO2JSC.js";import{f as lo,g as os,h as it}from"./chunk-S6TZRL6J.js";import{a as _t,b as is,c as mo,f as Rt,g as Ce}from"./chunk-CZLLWOTV.js";import{b as Hn}from"./chunk-NWVG2MAV.js";import{a as xt,b as Bt,c as qt,d as es,e as Te}from"./chunk-WK2EF5FH.js";import{c as rs,d as ns,g as So,h as go,j as To,l as Zo,m as Et}from"./chunk-FWA7C7Y4.js";import"./chunk-X2NMQEET.js";import{g as us,h as ps,i as ls,q as se,r as fs,s as Ss}from"./chunk-XZLDRYXW.js";import"./chunk-QPJLI3SF.js";import{a as O}from"./chunk-4DYGZNSW.js";import"./chunk-MBUS75GY.js";import{g as fo}from"./chunk-EHIXZ23F.js";import"./chunk-6TCIDKYS.js";import{b as Kn}from"./chunk-6FDARXB6.js";import{a as jn,d as $o}from"./chunk-JWQKG6DL.js";import{a as j}from"./chunk-XU4BUYWC.js";import"./chunk-UCUZGEE5.js";import"./chunk-4NS73UGB.js";import{a as kt,b as re,c as k}from"./chunk-UJIS6BFS.js";import{b as Qn,h as Wn,l as V,m as At,n as y}from"./chunk-GRAP3YP7.js";import{N as zn,P as Jo,d as zo,i as ao,m as $n,t as ne}from"./chunk-46YG4TCM.js";import"./chunk-WYIQIGDJ.js";import{d as ro}from"./chunk-GDM6S2OD.js";import{a as Gn}from"./chunk-XQPKRCN2.js";import{a as b,b as fe,c as Vn}from"./chunk-XC6ELVTG.js";import{b as Jn,f as Zn,g as ts}from"./chunk-YFP4Y2VE.js";import{e as Yn}from"./chunk-Z3DVZYQL.js";import{a as I,c as wn,e as Nt,f as On,g as dt,h as Nn,i as Dn,j as Se,k as no,m as xn,r as Bn,s as qn,u as oe,v as ge,x as jo}from"./chunk-TVUCEIYF.js";import{$ as mt,C as _,Cb as K,D as Zt,Db as U,E as te,F as Hr,H as wt,Hc as An,I as Qo,Ic as kn,Jc as _n,Ka as Ho,L as Je,Lb as oo,Ma as Xr,Mb as w,Na as $r,O as q,Ob as ee,Oc as Rn,P as pt,Q as gt,Qc as En,Rc as bn,S as Go,T as Yr,U as lt,Uc as yn,V as Ze,Va as Yo,Vc as vn,Wa as zr,Xa as Tt,Yc as Pn,Z as Vo,_ as Z,a as He,ab as Jr,b as Ye,bb as Zr,bc as on,c as le,cb as tn,cc as rn,d as me,dc as nn,e as Ke,ec as sn,f as de,fc as an,g as Uo,gc as cn,gd as Ln,h as je,ha as to,hc as un,i as Jt,ia as Ot,ic as pn,j as Ur,ja as eo,jc as ln,k as he,ka as H,kc as mn,l as Qr,la as tt,ma as Kr,md as h,nc as dn,o as G,p as Xe,pc as hn,q as W,qc as fn,rb as en,s as Gr,sb as Ko,t as F,tb as C,tc as Sn,u as $e,uc as gn,v as Vr,vc as Tn,w as Wr,wc as Cn,xc as In,ya as Wo,z as ze,za as jr}from"./chunk-MYNBMTR4.js";import{a as R,b as Mn,c as x}from"./chunk-FY3DWHT4.js";import{G as E,R as Fr,S as zt,T as Ve,U as Mr,V as xr,W as Br,aa as We,b as Ue,ba as qr,ca as M,f as St,g as Ct,h as It,j as nt,k as Qe,l as D,m as ut,n as Ge}from"./chunk-TQQZZJXW.js";import"./chunk-OW3UQNCS.js";import"./chunk-OJSBXBLD.js";import"./chunk-AAPE6FE4.js";import"./chunk-SGNJOSQB.js";import"./chunk-6MDHMQQH.js";import"./chunk-XIFCFAQW.js";import"./chunk-SE3PRL6Z.js";import"./chunk-NQTLXTUD.js";import"./chunk-FATNH5YG.js";import"./chunk-RL2JAB2F.js";import"./chunk-OV5ZOYAY.js";import{a as Lt}from"./chunk-62FSCPM5.js";import{a as qi}from"./chunk-J5JOI62E.js";import"./chunk-SQMXULWT.js";import"./chunk-KBSRU77R.js";import{G as Dr,H as z,k as Nr}from"./chunk-GQZAGQSC.js";import"./chunk-STCDRFCQ.js";import{E as yr,H as J,J as vr,O as Me,T as Pr,U as Lr,W as wr,Z as xe,aa as Be,c as $,f as rt,ga as Bo,h as ft,i as xo,ia as qo,j as S,pa as qe,r as Er,ra as P,w as br,y as Fe}from"./chunk-GSIHKWLV.js";import{e as Or,ka as Pt}from"./chunk-RC6UR2LL.js";import"./chunk-XTEVCKH7.js";import{b as B}from"./chunk-BF2V36QE.js";import"./chunk-E735URDA.js";import"./chunk-NBTO427E.js";import"./chunk-YHVKZE66.js";import{f as v,h as n,o as p,q as l}from"./chunk-QTLWQ5AJ.js";p();l();var Mo=v(B()),Bi=v(Lt());p();l();var ys=v(B());p();l();var _o=v(B());var bs=({children:a,rootStore:t})=>{let e=Mn(t),o=(0,_o.useMemo)(()=>(t.commonStore.rootStore=t,t.accountStore.rootStore=t,t),[t]);return _o.default.createElement(e.Provider,{value:o},a)};var vs=ut(({swapRootStore:a,bridgeRootStore:t,children:e,initTab:o})=>{let{commonStore:{currentTab:r}}=a.getInstance(),s=o||r,i=a.getInstance();return s===w.BRIDGE&&(i=t.getInstance()),ys.default.createElement(bs,{rootStore:i},e)});p();l();var Eo=v(B());p();l();p();l();var Ae=v(B()),Ps=v(Lt());var Ui=()=>{let a=b.get(Yo);if(a){if(b.remove(Yo),a.startsWith(Mr))return Tt.MEME_BUY;if(a.startsWith(tt))return Tt.BRIDGE;if(a.startsWith(H))return Tt.SWAP}return b.get(zr)||Tt.SWAP},Qi=a=>({[Tt.SWAP]:H,[Tt.BRIDGE]:tt,[Tt.MEME_BUY]:xr,[Tt.MEME_SELL]:Br})[a]||H,Gi=a=>{switch(a){case eo:case H:return w.SWAP;case tt:return w.BRIDGE;default:return""}},Ls=()=>{let{pathname:a}=(0,Ps.useLocation)(),{params:t,replace:e}=se(),{autoSwitch:o,from:r}=t,[s,i]=(0,Ae.useState)(""),[c,u]=(0,Ae.useState)(!0);return(0,Ae.useEffect)(()=>{let m=Ui(),d=Qi(m);if(o===Zo.BRIDGE&&!r.tokenContractAddress&&d!==a){e({pathname:d,params:{...t,autoSwitch:void 0}});return}let f=Gi(a);f&&(async()=>{if(f===w.SWAP&&o===Zo.BRIDGE){let A=await Et.judgeTabTypeByParams(t?.from,t?.to);A===w.BRIDGE&&e({pathname:tt,params:{...t,autoSwitch:void 0}}),i(A),u(!1)}else i(f),u(!1)})().catch(()=>{})},[a,o,r]),{tabType:s,autoSwitching:c}};p();l();var or=v(B());var ws=(a,t)=>{let{accountStore:e}=x(),{params:o}=se(),{addressType:r}=o;(0,or.useEffect)(()=>{e.setAddressType(r)},[]);let s=fs();(0,or.useEffect)(()=>{async function i(){let c=new Et(a,o),{from:u,to:m,tab:d,inputAmount:f,error:T}=await c.initTokenPair(t);T||s(u,m,f,d)}a&&i().catch(()=>{})},[a])};p();l();var Os=v(B()),Ns=v(Lt());var Ds=a=>{let{fromToStore:t}=x(),{from:e,to:o}=t,{params:r,replace:s}=se(),{pathname:i}=(0,Ns.useLocation)(),c=Ss();(0,Os.useEffect)(()=>{let u=c(e,o);u&&a&&[H,tt].includes(i)&&(new Et(a).writeTabInfoToLocalStorage(u),s({params:{...u,feeConfig:r.feeConfig}}))},[e?.chainId,e?.tokenContractAddress,o?.chainId,o?.tokenContractAddress,a,i])};var Vi=a=>{let{tabType:t}=Ls();ws(t,a),Ds(t)},Fs=Vi;p();l();var xs=v(B());p();l();function Wi(a){return new Promise(t=>setTimeout(t,a))}async function ie(a,t=3,e=0){let o;for(let r=0;r<t;r++)try{return await a()}catch(s){o=s,e&&r<t-1&&await Wi(e)}throw o}function Hi(a,t,e){let o=kt();return{promise:a(t,{...e,signal:o.signal}),cancel:()=>o.abort()}}function Yi(a,t,e){if(Ot())return Hi(a,t,e);let o=new AbortController,r=o.signal;return{promise:a(t,{...e,signal:r}),cancel:()=>o.abort(),abortController:o}}function Ms(a,t){return Yi(k.get,a,t)}function Bs(){let{accountStore:a,receiveAddressStore:t}=x(),{address:e,setUserForbiddenBridge:o}=a,{receiveAddrObj:r,computedSwapHighLight:s}=t,{specifiedAddress:i}=r||{};(0,xs.useEffect)(()=>{let c=()=>{};if(e&&s){let{promise:u,cancel:m}=Ms(Rn,{params:{userWalletAddress:e,receiveWalletAddress:i}});c=m,u.then(d=>{o(d?.data.blackListTypes||Je)}).catch(()=>{o(Je)})}else o(Je);return c},[e,o,i,s])}p();l();var qs=v(B());function rr(){let{accountStore:{address:a}}=x();(0,qs.useEffect)(()=>{y.setTags({address:a})},[a])}p();l();var nr=v(B());P();var Ki=()=>{let{quoteStore:a,accountStore:t,fromToStore:e,approveStore:o,recentTransactionStore:r,tokenModalStore:s,commonStore:i}=x(),{computedAccountWalletAddresses:c}=t;(0,nr.useEffect)(()=>{let u=()=>{};return c&&(u=ds(c)),()=>{u?.()}},[c]),(0,nr.useEffect)(()=>{let u=Ao({isPri:!0,needLogin:!0,subscribeParams:[{channel:Ie.DEX_PUSH_ENGINE},{channel:Ie.WALLET_ASSET}],onListenError:()=>{let m=S(a,"quote.bestRoute"),d={token:e.from,defiPlatformId:j.getCurrentRouteDefiPlatformId(e.computedIsCrossChain,m),equalsToken:i.equalsToken,isCrossChain:e.computedIsCrossChain,refetchQuote:()=>{a.fetchQuote()}};o.onSocketError(d),r.onSocketError(),e.setNeedBalanceLoading(!1),e.getSwapTokenBalance(),s.reloadTokenList()},onListenData:(m,d)=>{if(!!m){if(d?.channel===Ie.DEX_PUSH_ENGINE){r.onSocket(m);let f=S(a,"quote.bestRoute"),T={token:e.from,defiPlatformId:j.getCurrentRouteDefiPlatformId(e.computedIsCrossChain,f),equalsToken:i.equalsToken,isCrossChain:e.computedIsCrossChain,refetchQuote:()=>{a.fetchQuote()}};o.onSocket({data:m,...T});return}d.channel===Ie.WALLET_ASSET&&(s.updateAllTokenList(m),e.updateFromBalancePush(m))}}});return()=>{u?.()}},[r.onSocket,s.updateAllTokenList,e.updateFromBalancePush,t,a,r,s,e])},Us=Ki;p();l();var sr=v(B());P();var Qs=({token:a,onListenData:t=rt,globalPrice:e})=>{(0,sr.useEffect)(()=>{!ge(a)||$o(a,e)&&t(e)},[e,a?.chainId,a?.tokenContractAddress]),(0,sr.useEffect)(()=>{if(!ge(a))return rt;if($o(a,e))return rt;let o=Ao({subscribeParams:{channel:hs.DEX_MARKET_TX_CHANNEL,chainId:a.chainId,tokenAddress:a.tokenContractAddress},onListenData:r=>{t(r?.[0]||{})},onListenError:rt});return()=>{o()}},[a?.chainId,a?.tokenContractAddress])},ji=()=>{let{fromToStore:a={},commonMarketStore:t={}}=x(),{from:e,updateFromUsdPriceFromWs:o,to:r,updateToUsdPriceFromWs:s}=a,{globalPrice:i}=t;Qs({token:e,onListenData:o,globalPrice:i}),Qs({token:r,onListenData:s,globalPrice:i})},Gs=ji;p();l();var bt=v(B()),Vs=v(Lt());Qn.setDataProxy(k);var Xi=({currency:a,currentWallet:t,walletInfo:e,keyringIdentityTypeEnum:o,addressBookList:r,walletList:s,t:i,dispatch:c,currentTab:u,onBack:m})=>{let{commonStore:d,accountStore:f,recentTransactionStore:T,reset:A}=x(),L=(0,Vs.useHistory)();(0,bt.useEffect)(()=>{M.setRuntimeContext({history:L,toLocale:i,dispatch:c,walletInfo:e,onBack:m})},[i,L,c,e,m]),(0,bt.useEffect)(()=>(t&&f.setWalletConfig(t),()=>{f.cleanWalletConfig()}),[t]),(0,bt.useEffect)(()=>(d.getUserUnit(a),d.fetchChainList({businessLine:1,currentTab:u}).catch(()=>{d.setChainListLoadError(!0)}),()=>{A()}),[]),(0,bt.useEffect)(()=>{f.setAddressBookList(r)},[r]),(0,bt.useEffect)(()=>{f.setWalletList(s)},[s]),(0,bt.useEffect)(()=>{f.setKeyringIdentityTypeEnum(o)},[o]),(0,bt.useEffect)(()=>{t.walletId?T.updatePendingOrders(t.walletId):T.setPendingOrders([])},[t.walletId,u]),Ts()},Ws=Xi;p();l();var Y=v(B()),yt=v(Lt());p();l();var Qt=v(B()),Ro=v(Lt()),ti=v(qi());p();l();var Hs=v(B());var $i=()=>{let{fromToStore:a}=x(),{visibleAddFunds:t,addFundsParams:e,closeAddFunds:o}=a;return Hs.default.createElement(Cs,{visible:t,params:e,onBack:()=>{o()}})},Ys=ut($i);p();l();var Ks=v(B());var js=()=>{let{fromToStore:a}=x(),{closeAddFunds:t}=a;(0,Ks.useEffect)(()=>{t()},[])};p();l();var Xs=v(B());function $s(){return Xs.default.createElement(Is,{iconStyle:{fontSize:24},tooltipProps:{show:!1},iconClassName:Ut.rightIcon})}p();l();var zs=v(B()),Js=v(Lt());function Zs(){let a=(0,Js.useLocation)(),t=ks(),{isTelegramMiniApp:e}=M.global,o=a.pathname;return(0,zs.useMemo)(()=>!e&&o===H&&t,[e,o,t])}var zi=[H,tt],Ji=({children:a,onBack:t})=>{let{showNavigator:e,title:o}=As(),r=(0,Ro.useLocation)(),s=(0,Ro.useHistory)(),{isTelegramMiniApp:i}=M.global,{Navigator:c}=M.components,u=r.pathname.includes(zt),m=Zs();js();let d=()=>{u&&ne({...it(),button_name:"back"}),t?t(s.goBack,zi.includes(r.pathname)):s.goBack()},f=()=>i?Ut.telegramContainer:e?Ut.extensionContainer:Ut.extensionContainerNoHeader,{recentTransactionStore:T}=x(),{dialogVisible:A,dialogOrderId:L,closeDialog:N}=T;return Qt.default.createElement("div",{className:(0,ti.default)("universe-swap background-base-primary",Ut.wrapper)},e?Qt.default.createElement(c,{asPage:!0,title:o,onBack:d,closeable:m?{children:Qt.default.createElement($s,null)}:!1}):null,Qt.default.createElement("div",{className:f()},a),Qt.default.createElement(Ys,null),Qt.default.createElement(gs,{orderId:L,visible:A,onClose:N}))},ei=ut(Ji);var Zi=(0,Y.lazy)(()=>import("./Swap-XDYVZTLI.js")),ta=(0,Y.lazy)(()=>import("./Bridge-3CIPPEV5.js")),ea=(0,Y.lazy)(()=>import("./OrderDetail-BX4MNL2H.js")),oa=(0,Y.lazy)(()=>import("./Contract-LRZMKJRK.js")),ra=(0,Y.lazy)(()=>import("./Approve-UIXR7Y5B.js")),na=(0,Y.lazy)(()=>import("./Solana-WBWJAGTU.js")),sa=(0,Y.lazy)(()=>import("./Claim-UK36JAQM.js")),ia=({onBack:a})=>{let t=(0,yt.useLocation)();return Y.default.createElement(ei,{onBack:a},Y.default.createElement(Y.Suspense,null,Y.default.createElement(yt.Switch,null,[{path:H,component:Zi,exact:!0},{path:tt,component:ta,exact:!0},{path:Fr,component:ea,exact:!0},{path:zt,component:oa,exact:!0},{path:Ve,component:ra,exact:!0},{path:We,component:na,exact:!0},{path:qr,component:sa,exact:!0}].map((o,r)=>Y.default.createElement(yt.Route,{key:r,path:o.path,component:o.component,exact:o.exact})),Y.default.createElement(yt.Redirect,{from:eo,to:{pathname:H,search:t.search},strict:!0,exact:!0}))))},oi=ia;var aa=({currency:a,currentWallet:t,keyringIdentityTypeEnum:e,addressBookList:o,walletList:r,walletInfo:s,onBack:i,t:c,dispatch:u,currentTab:m=w.SWAP})=>{Fs(s.chainId),Ws({currency:a,currentWallet:t,walletInfo:s,keyringIdentityTypeEnum:e,addressBookList:o,walletList:r,t:c,dispatch:u,currentTab:m,onBack:i}),Bs(),Us(),rr(),Gs();let{initialized:d}=ms();return d?Eo.default.createElement(oi,{onBack:i}):null},ri=(0,Eo.memo)(ut(aa));p();l();p();l();p();l();var ke=class{constructor(){this.isSwapLoading=!1;this.setSwapLoading=t=>{this.isSwapLoading=t};this.checkCancelLimitOrder=async()=>{};D(this)}};p();l();P();var _e=class{constructor(t){n(this,"checkTokenValid",async t=>{if(!ge(t))return!1;let[e,o]=await E(k.get(Pn,{params:xe(t,["chainId","tokenContractAddress"])}));return e?!1:o.data.supportMarket});this.rootStore=t,this.accountStore=t.accountStore,D(this,{},{autoBind:!0})}};var Gt=class{constructor(){Gt.instance?(this.commonStore=Gt.instance.commonStore,this.accountStore=Gt.instance.accountStore,this.checkTokenStore=Gt.instance.checkTokenStore,this.limitOrderConfirmStore=new ke(this)):(this.commonStore=new Xn(this),this.accountStore=new Un(this),this.checkTokenStore=new _e(this),this.limitOrderConfirmStore=new ke(this),Gt.instance=this)}},Vt=Gt;n(Vt,"instance",null);p();l();P();p();l();P();var ir=class{constructor(){this.approveTokenDefaultConfig={status:_.Unknown,approvedAmount:"0",tagStatus:_.Unknown};this.approveTokensConfig={};this.bridgeApproveSocketError=!1;this.getApproveTokenMapKey=(t,e)=>{let o=t.tokenContractAddress;return`${t.chainId}_${o}_${e}`};this.registerApproveToken=(t,e)=>{let o=this.getApproveTokenMapKey(t,e),r=S(this.approveTokensConfig,o);J(r)&&(this.approveTokensConfig[o]={...this.approveTokenDefaultConfig})};this.updateApproveTokenConfig=(t,e,o)=>{let r=this.getApproveTokenMapKey(t,e),s=S(this.approveTokensConfig,r),i=J(s),c=s||this.approveTokenDefaultConfig;this.approveTokensConfig={...this.approveTokensConfig,[r]:{...c,...o}},i&&y.stuff("if you want to update approve token config, you should register it first.")};this.removeApproveTokenConfig=(t,e)=>{let o=this.getApproveTokenMapKey(t,e);delete this.approveTokensConfig[o]};this.getApproveTokenConfig=(t,e)=>{let o=this.getApproveTokenMapKey(t,e);return S(this.approveTokensConfig,o,this.approveTokenDefaultConfig)};this.clearNonApprovingTokensConfig=()=>{let t=Lr(this.approveTokensConfig,e=>[_.Approving,_.CancelApproving].includes(e.status));this.approveTokensConfig={...t}};this.getApprovalStatus=(t,e)=>this.getApproveTokenConfig(t,e).status;this.isApprovalCheckRequired=(t,e,o)=>{let{isNativeToken:r}=t;return(e?!0:o==="1")&&!r&&!Zn(t.chainId)&&!ts(t.chainId)};this.validApproveAmountLessSwapAmount=(t,e)=>new I.BigNumber(t).isLessThan(e||"0");this.isValidApprovalStatus=(t,e,o)=>{let r=wn(t),s=this.validApproveAmountLessSwapAmount(t,e);return r?_.UnApproved:s&&o?_.CancelApprove:s?_.UnApproved:_.Approved};this.fetchApproveAllowance=(t,e,o)=>k.get(Sn,{params:{userWalletAddress:e,tokenContractAddress:t.tokenContractAddress,chainId:t.chainId,defiPlatformIds:o}}).then(r=>r?.data);this.getApproveUrl=t=>t?{approveDataUrl:Tn,saveApproveUrl:In}:{approveDataUrl:gn,saveApproveUrl:Cn};this.fetchApproveData=({approveDataUrl:t,params:e})=>{let{isCrossChain:o,...r}=e;return k.get(t,{params:r}).then(s=>{let{id:i,data:c,from:u,to:m,unsignedTx:d}=s?.data||{},f={data:c,from:u,to:m},T={txSource:3};return Jn(e.chainId)&&(f=JSON.parse(d),Be(T,"orderId",i)),o&&Be(f,"extParams",T),y.info(V.APPROVE_DATA,{id:i,transactionPayload:f,unsignedTx:d,cancelApproveTag:r.cancelApproveTag}),{transactionPayload:f,id:i,defiPlatformId:r.defiPlatformId}})};this.isApprovalStatusPending=(t,e)=>{let o=this.getApprovalStatus(t,e);return[_.Approving,_.CancelApproving].includes(o)};this.isCancelApproveStatus=(t,e)=>{let o=this.getApprovalStatus(t,e);return[_.CancelApprove,_.CancelApproving].includes(o)};this.isPendingNeedCheck=async t=>{this.isApprovalStatusPending(t.token,t.defiPlatformId)&&this.checkApprove(t).catch(()=>{})};this.isPendingNotCheck=async t=>{this.isApprovalStatusPending(t.token,t.defiPlatformId)||this.checkApprove({...t,needCheck:"NO_CHECK"}).catch(()=>{})};this.bridgePendingNotCheck=async t=>{(!this.isApprovalStatusPending(t.token,t.defiPlatformId)||this.bridgeApproveSocketError)&&(await this.checkApprove({...t,isCrossChain:!0,needCheck:"NO_CHECK"}),this.bridgeApproveSocketError=!1)};this.updateUnnecessaryApproveTokenStatus=(t,e)=>{e.forEach(o=>{this.registerApproveToken(t,o),this.updateApproveTokenConfig(t,o,{status:_.Approved,tagStatus:_.UnApproved})})};this.updateApproveConfigByAllowance=({allowanceData:t,token:e,defiPlatformId:o,needCheck:r})=>{if(!t||J(t)){this.updateApproveTokenConfig(e,o,{status:_.Unknown,approvedAmount:"0",tagStatus:_.Unknown});return}r==="NO_CHECK"&&this.isApprovalStatusPending(e,o)||Object.keys(t).forEach(s=>{let i=t[s];this.calcApproveState({approveInfo:i,token:e,defiPlatformId:s})})};this.checkApprove=async({token:t,userWalletAddress:e,needApprove:o,defiPlatformIds:r,defiPlatformId:s,allowanceData:i={},needCheck:c="",isLimitOrder:u=!1,isCrossChain:m=!1})=>{if(!this.isApprovalCheckRequired(t,u,o)){this.updateUnnecessaryApproveTokenStatus(t,r);return}let{tokenContractAddress:d}=t;if(d&&e){if(!m){let[,f]=await E(this.fetchApproveAllowance(t,e,r));this.updateApproveConfigByAllowance({allowanceData:f,token:t,defiPlatformId:s,needCheck:c});return}this.updateApproveConfigByAllowance({allowanceData:i,token:t,defiPlatformId:s,needCheck:c})}};this.calcApproveState=({approveInfo:t,token:e,defiPlatformId:o})=>{let{decimals:r}=e,s=Number(t.status);if([_.Approving,_.CancelApprove].includes(s))return;let i=Number(t.status)===_.Approved?t.amount:"0",c=no(i,r)||"0",u=t?.needCancelApproveToken,m=this.isValidApprovalStatus(c,e.amount||"0",u);this.registerApproveToken(e,o),this.updateApproveTokenConfig(e,o,{status:m,tagStatus:m,approvedAmount:c})};this.fetchApproveDataErrorTips=(t,e,o)=>{this.updateApproveTokenConfig(t,e,{status:_.UnApproved});let r=O(t?.tokenSymbol);go({title:o?h("swaptrade_transfer_notification_title_ccy_unrevoked",{ccy:r}):h("swaptrade_toast_approve_fail",{tokenSymbol:r})})};this.approveErrorTips=({error:t,chainId:e,transactionPayload:o,token:r,defiPlatformId:s,cancelApproveTag:i})=>{y.error(V.APPROVE_TOKEN_ERROR,{chainId:e,transactionPayload:o,error:t,token:r,defiPlatformId:s,tags:At(t)}),cs(t)||Dr.error({title:h("swaptrade_home_toast_broadcast_failed")}),this.updateApproveTokenConfig(r,s,{status:this.isCancelApprove(i)?_.CancelApprove:_.UnApproved})};this.isCancelApprove=t=>t===Zt.CANCEL_APPROVE;this.setApprove=async({token:t,userWalletAddress:e,defiPlatformId:o,isCrossChain:r=!1,cancelApproveTag:s})=>{let{chainId:i}=t;this.updateApproveTokenConfig(t,o,{status:this.isCancelApprove(s)?_.CancelApproving:_.Approving});try{let{id:c,transactionPayload:u,defiPlatformId:m}=await this.fetchApproveData({approveDataUrl:this.getApproveUrl(r).approveDataUrl,params:{isCrossChain:r,userWalletAddress:e,tokenContractAddress:t.tokenContractAddress,chainId:t.chainId,defiPlatformId:o,cancelApproveTag:s}});await this.approveToken({chainId:i,transactionPayload:u}).then(async({result:d})=>{await this.saveApprove({id:c,chainId:i,transactionHash:d,userWalletAddress:e,isCrossChain:r,cancelApproveTag:s,defiPlatformId:m})}).catch(d=>{this.approveErrorTips({error:d,chainId:i,transactionPayload:u,token:t,defiPlatformId:m,cancelApproveTag:s})})}catch{this.fetchApproveDataErrorTips(t,o,s)}};this.saveApprove=async({id:t,chainId:e,transactionHash:o,userWalletAddress:r,isCrossChain:s,cancelApproveTag:i,defiPlatformId:c,refetchQuote:u})=>{if(!o)return;let m={id:t,transactionHash:o,chainId:e,userWalletAddress:r,cancelApproveTag:i};s&&Be(m,"defiPlatformId",c),y.info(V.SAVE_APPROVE,m);let{saveApproveUrl:d}=this.getApproveUrl(s),[f]=await E(k.post(d,m));f&&y.info(V.SAVE_APPROVE_ERROR,{error:f?.message,...m}),s&&String(c)!==Z&&u?.()};this.checkCurrentPushedApproveInfo=(t,e,o,r,s)=>{let{chainId:i,fromTokenAddress:c,platformId:u,defiPlatformId:m}=t,d=r?m:u,f={chainId:Number(i),tokenContractAddress:c},T=s(e,f),A=String(o)===String(d);return{isCurrentToken:T,isSamePlatform:A,pushedToken:f,pushedPlatformId:d}};this.handleCurrentPushedApproveToken=async({dexData:t,pushedPlatformId:e,token:o,isCrossChain:r,refetchQuote:s,userWalletAddress:i,needApprove:c})=>{if(!r)await this.isPendingNeedCheck({token:o,userWalletAddress:i,defiPlatformIds:[e],defiPlatformId:e,needApprove:c});else{let u={status:t.status,amount:t.approveAmount,needCancelApproveToken:t.needCancelApproveToken};this.calcApproveState({approveInfo:u,token:o,defiPlatformId:e}),s?.()}};this.onSocket=async({data:t,token:e,defiPlatformId:o,isCrossChain:r,equalsToken:s,refetchQuote:i})=>{if(t?.type==="1"&&t?.dexData&&t.dexData.type==="approve"){let c=t.dexData,{status:u,transactionHash:m,fromTokenSymbol:d,exploreUrl:f,solanaToast:T,userWalletAddress:A}=c,L=Ot();if(T==="1"){if(L)return;let Q=u===te.CANCEL_APPROVE_SUBMITTED?"swaptrade_transfer_toast_ccy_unrevoke_submit":"swaptrade_transfer_notification_approval_submit";So({title:h(Q,{ccy:O(d)})});return}let{isCurrentToken:N,isSamePlatform:et,pushedToken:X,pushedPlatformId:ot}=this.checkCurrentPushedApproveInfo(c,e,o,r,s);if(N&&et&&await this.handleCurrentPushedApproveToken({dexData:c,pushedPlatformId:ot,token:e,isCrossChain:r,userWalletAddress:A,refetchQuote:i,needApprove:"1"}),(!N||N&&!et)&&this.removeApproveTokenConfig(X,ot),u===te.APPROVE_SUCCESS){let Q=h("swaptrade_toast_approve_success",{tokenSymbol:O(d)});!L&&So({title:Q,exploreUrl:f}),ns.emit(rs.APPROVE,{data:m,status:0,message:Q})}else if(u===te.APPROVE_FAILED&&!L){let Q=h("swaptrade_toast_approve_fail",{tokenSymbol:O(d)});go({title:Q,exploreUrl:f})}else if(u===te.CANCEL_APPROVE_SUCCESS&&!L){let Q=h("swaptrade_transfer_notification_title_ccy_revoked",{ccy:O(d)});So({title:Q,exploreUrl:f})}else if(u===te.CANCEL_APPROVE_FAILED&&!L){let Q=h("swaptrade_transfer_notification_title_ccy_unrevoked",{ccy:O(d)});go({title:Q,exploreUrl:f})}}};this.onSocketError=t=>{t.isCrossChain?this.bridgeApproveSocketError=!0:this.isPendingNeedCheck(t).catch(()=>{})}}approveToken(t){return Promise.resolve(t)}},ni=ir;var Wt=class extends ni{constructor(e){super(e);n(this,"approveInfo",{});n(this,"setApproveInfo",e=>{this.approveInfo=e});n(this,"setApprove",async(e=Zt.APPROVE)=>{let{fromToStore:o,quoteStore:r,accountStore:s}=this.rootStore,i=S(r,"quote.bestRoute"),c=j.getCurrentRouteDefiPlatformId(o.computedIsCrossChain,i),u=o.from,{chainId:m,tokenContractAddress:d}=u,f=s.getAddressByChainId(m);this.updateApproveTokenConfig(u,c,{status:this.isCancelApprove(e)?_.CancelApproving:_.Approving});try{let{id:T,transactionPayload:A}=await this.fetchApproveData({approveDataUrl:this.getApproveUrl(o.computedIsCrossChain).approveDataUrl,params:{userWalletAddress:f,tokenContractAddress:d,chainId:m,defiPlatformId:c,cancelApproveTag:e}});this.setApproveInfo({chainId:m,id:T,transactionPayload:A,token:u,defiPlatformId:c,cancelApproveTag:e}),M.history?.push({pathname:Ve})}catch{this.fetchApproveDataErrorTips(u,c,e)}});n(this,"approveCancel",()=>{let e=this.approveInfo.cancelApproveTag;this.setApproveInfo({}),M.history?.goBack?.();let{fromToStore:o,quoteStore:r}=this.rootStore,s=S(r,"quote.bestRoute"),i=j.getCurrentRouteDefiPlatformId(o.computedIsCrossChain,s),c=o.from;this.updateApproveTokenConfig(c,i,{status:this.isCancelApprove(e)?_.CancelApprove:_.UnApproved})});n(this,"approveConfirm",async({txHash:e,error:o})=>{if(o){this.approveErrorTips({error:o,...this.approveInfo}),this.approveCancel();return}let{fromToStore:r,accountStore:s,quoteStore:i}=this.rootStore,{id:c,chainId:u,cancelApproveTag:m,defiPlatformId:d}=this.approveInfo;await this.saveApprove({id:c,chainId:u,transactionHash:e,userWalletAddress:s.getAddressByChainId(u),cancelApproveTag:m,defiPlatformId:d,isCrossChain:r.computedIsCrossChain,refetchQuote:()=>{i.fetchQuote()}}),M.history?.goBack?.(),this.setApproveInfo({})});st(this),this.rootStore=e}};p();l();P();p();l();var at=()=>{let{fromToStore:a,gasDropStore:t,receiveAddressStore:e,outerStore:o,quoteStore:r,accountStore:s}=R(),{from:i,to:c}=a,{receiveAddrObj:u}=e,{computedForbiddenBridge:m,address:d}=s,f=I.BigNumber(a.computedTypedValue).toString(10),A={...{chainId:i.chainId,toChainId:c.chainId,toTokenAddress:c.tokenContractAddress,fromTokenAddress:i.tokenContractAddress,amount:f,userWalletAddress:d},...r.computedSlippage,pmm:"1",gasDropType:t?.computedGasDropSelected?1:0,forbiddenBridgeTypes:jo(m),dexIds:jo(lo?.computedIds),receiveWalletAddress:u?.specifiedAddress};return o.extendFeeConfig(A)},si=()=>{let{quoteStore:a}=R();return{...at(),sort:a.bridgeSortType}},ii=()=>{let{quoteStore:a}=R(),{quote:t}=a,e=t?.bestRoute?.bridge?.bridgeId,{slippage:o,toChainId:r,receiveWalletAddress:s,userWalletAddress:i,chainId:c,fromTokenAddress:u,toTokenAddress:m,amount:d}=at();return{slippage:o,toChainId:r,receiveWalletAddress:s,userWalletAddress:i,chainId:c,fromTokenAddress:u,toTokenAddress:m,amount:d,bridgeId:e}};p();l();function ca({selector:a}){let t=document.querySelector(a);t&&t.scrollTo({top:0,behavior:"smooth"})}var bo=ca;var ai=20,ct={CONFIRM:"confirm",UPDATE:"update",FILL_UP:"fill_up",SNAP_UPDATE:"snap_update",CANCEL:"cancel",DEFAULT:"default"},ar=class{constructor(t){n(this,"quoteData",null);n(this,"preDataForSendBtc",null);n(this,"setPreDataForSendBtc",t=>{this.preDataForSendBtc=t});n(this,"setQuoteData",t=>{this.quoteData=t});n(this,"quoteParams",()=>{let{accountStore:t,fromToStore:e,receiveAddressStore:o}=this.rootStore,s={...at(),userWalletAddress:t.address};return e.computedDiffCrossChain&&(s.receiveWalletAddress=o.receiveAddrObj?.specifiedAddress),s});n(this,"updating",!1);n(this,"updateQuoteData",async()=>{let{quoteStore:{quote:t},swapStore:e}=this.rootStore,o=this.rootStore?.quoteStore?.quote?.bestRoute?.defiPlatformId;this.updating=!0;let s={...at(),bridgeId:t?.bestRoute?.bridge?.bridgeId,...o&&{defiPlatformId:o}},i=await e.extendSignParams(s),[c,u]=await E(k.post(`${_n}`,i));if(this.updating=!1,bo({selector:"#wallet_scroll"}),c){z.error({title:c?.data?.msg||h("swaptrade_top_notif_data_failed")});return}let{callDataResult:m,quoteResult:d}=u?.data||{};if(this.rootStore.quoteStore.handleUpdateQuote({data:d}),m){let f=await this.getPreExecutionPayload(m);St(()=>{this.transactionPayload=f})}this.initCountDown(),this.startCountdown()});n(this,"updateBridgeGetIntentQuoteCallData",async()=>{let t=ii();this.updating=!0;let[e,o]=await E(k.get(yn,{params:{...t}}));if(this.updating=!1,bo({selector:"#wallet_scroll"}),e){z.error({title:e?.data?.msg||h("swaptrade_trading_mode_error_no_update")});return}let{quoteResult:r}=o?.data||{};r&&this.rootStore.quoteStore.handleUpdateQuote({data:r}),this.initCountDown(),this.startCountdown()});n(this,"updateSnapQuoteData",async()=>{let t=at(),e=this.rootStore?.quoteStore?.quote?.bestRoute?.defiPlatformId;this.updating=!0;let[o,r]=await E(k.get(En,{params:{defiPlatformId:e,...t}}));if(this.updating=!1,bo({selector:"#wallet_scroll"}),o){z.error({title:o?.data?.msg||h("swaptrade_trading_mode_error_no_update")});return}let{quoteResult:s}=r?.data||{};s&&this.rootStore.quoteStore.handleUpdateQuote({data:s}),this.initCountDown(),this.startCountdown()});n(this,"timer",null);n(this,"countdown",ai);n(this,"initCountDown",()=>{this.countdown=ai});n(this,"startCountdown",()=>{this.timer=setTimeout(()=>{let t=this.countdown;if(t===0){this.clearTimer();return}this.countdown=t-1,this.startCountdown()},1e3)});n(this,"clearTimer",()=>{this.timer&&clearTimeout(this.timer)});n(this,"initGasInfo",()=>({gasType:"normal",gasLimit:"0",gasPrice:"0",maxFeePerGas:"0",maxPriorityFeePerGas:"0",supportEip1559:!1,isNetworkFeeLoading:!0,isGasLimitLoading:!0}));n(this,"gasInfo",this.initGasInfo());n(this,"setGasInfo",t=>{this.gasInfo=t});n(this,"gasFee",0);n(this,"setGasFee",t=>{this.gasFee=t});n(this,"orderInfo",{});n(this,"transactionPayload",null);n(this,"solonaRent","");n(this,"getPreExecutionPayload",async(t,e)=>{let{swapStore:o,quoteStore:r}=this.rootStore,s=r?.quote?.bestRoute||{},{fromToken:i}=s,c=as(i,{orderData:t},o);if(e){let d=await c.jitoTransaction();return this.solonaRent=ss(d),d}let{payload:u,rent:m}=await c.preExecution();return i.chainId===Ko.SOLANA_MAINNET&&m&&(this.solonaRent=m),u});n(this,"setTransactionPayload",t=>{this.transactionPayload=t});n(this,"fetchCallData",async()=>{let{swapStore:t}=this.rootStore||{};t.setCalldataSign(null);let e=t.saveOrderParams(),o=await t.extendSignParams(e);if(!o)return!1;let r=t.isSwapSolana(o.chainId),s,i;if(r){let u=t.extendSolanaCalldata(o);[s,i]=await t.getSolanaCalldata(u)}else[s,i]=await E(k.post(kn,o));if(s){let u=s?.error_message;return z.error({title:u||h("swaptrade_top_notif_data_failed")}),!0}let c=await this.getPreExecutionPayload(i?.data||{},r);return this.transactionPayload=c,!1});n(this,"preExecutionResult",{});n(this,"setPreExecutionResult",t=>{this.preExecutionResult=t});n(this,"nativeCoin",null);n(this,"setNativeCoin",t=>{this.nativeCoin={...t}});n(this,"calcNativeCoinAmount",()=>{let{coinAmountInt:t,decimals:e}=this.nativeCoin,{from:o,computedIsFromBtcCoin:r}=this.rootStore.fromToStore;return I.BigNumber(r?o.availableBalance:no(t,e))});n(this,"calcNativeCoinAmountChange",()=>{let t;if(this.type===lt.SWAP){let{fromToStore:o}=this.rootStore;t=o.from}else{let{fromToken:o,fromTokenAmount:r}=this.rootStore.facetStore.facetOrderDetail;t={...o,amount:r}}let e=I.BigNumber(this.gasFee).isNaN()?"0":this.gasFee;return t.isNativeToken?I.BigNumber(t.amount).plus(e):I.BigNumber(e)});n(this,"gasFeeLoading",!0);n(this,"setGasFeeLoading",t=>{this.gasFeeLoading=t});n(this,"gasLimitError",null);n(this,"setGasLimitError",t=>{this.gasLimitError=t});n(this,"activityId",null);n(this,"setActivityId",t=>{this.activityId=t});n(this,"type",lt.SWAP);n(this,"setSwapType",t=>{this.type=t});n(this,"reset",()=>{this.gasInfo=this.initGasInfo(),this.setGasFeeLoading(!1),this.nativeCoin=null,this.transactionPayload=null,this.gasFee=0,this.setGasLimitError(null),this.setStarknetRegisterStatus(""),this.setVisibleStarknetRegister(!1),this.setActivityId(null),this.setSwapType(lt.SWAP),this.clearTimer(),this.solonaRent=""});n(this,"starknetRegisterStatus","");n(this,"setStarknetRegisterStatus",t=>{this.starknetRegisterStatus=t});n(this,"visibleStarknetRegister",!1);n(this,"setVisibleStarknetRegister",t=>{this.visibleStarknetRegister=t});n(this,"onSwap",()=>{ne({...it(),button_name:"confirm"}),this.rootStore.swapStore.onSwap()});n(this,"onRedeem",()=>{this.rootStore.facetStore.walletSendRedeem()});n(this,"onIntentSwap",()=>{this.rootStore.intentSwapStore.onIntentSwap()});n(this,"confirmSwapMap",{[lt.SWAP]:this.onSwap,[lt.REDEEM]:this.onRedeem,[lt.INTENT_SWAP]:this.onIntentSwap});n(this,"onConfirm",t=>{this.confirmSwapMap[t]?.()});n(this,"getBtnProps",t=>{let{fromToStore:e}=this.rootStore,{symbol:o,coinId:r,chainId:s}=this.nativeCoin||{};return{[ct.CONFIRM]:{disabled:this.computedConfirmBtnDisabled,onClick:c=>{this.onConfirm(c)},btnText:h("swaptrade_card_swap_btn_confirm_swap"),loading:this.computedIsConfirming},[ct.UPDATE]:{onClick:()=>{ne({...it(),button_name:"update"}),this.updateQuoteData().catch(rt)},btnText:h("swaptrade_confirmswap_btn_update_price")},[ct.SNAP_UPDATE]:{onClick:()=>{ne({...it(),button_name:"update"}),e.computedIsCrossChain?this.updateBridgeGetIntentQuoteCallData().catch(rt):this.updateSnapQuoteData().catch(rt)},btnText:h("swaptrade_confirmswap_btn_update_price")},[ct.FILL_UP]:{onClick:()=>{Jo({wallet_address:this.rootStore.accountStore.address,button_name:"fill_up"}),e.baseAddFunds({coinId:r,chainId:s,receiveOnly:!1})},btnText:h("swaptrade_dialog_btn_supplement",{token:o})},[ct.CANCEL]:{onClick:()=>{Jo({wallet_address:this.rootStore.accountStore.address,button_name:"cancel"});let{history:c}=M;c?.goBack()},btnText:h("swaptrade_top_btn_cancel")},default:{}}[t]});D(this),this.rootStore=t}get computedFormatTime(){return qn(this.countdown)}get computedPriceUpdate(){return this.countdown===0}get computedIsSufficientGas(){if(!this.nativeCoin)return!0;let t=this.calcNativeCoinAmount(),e=this.calcNativeCoinAmountChange();return t.gte(e)}get computedSolonaNativeTokenSufficientRent(){let{quoteStore:t}=this.rootStore,e=t?.quote?.bestRoute||{},{fromToken:o}=e||{};if(o?.chainId!==Ko.SOLANA_MAINNET||!this.nativeCoin||!this.solonaRent)return!0;let r=this.calcNativeCoinAmount(),s=this.calcNativeCoinAmountChange();return r.gte(s.plus(this.solonaRent))}get walletSendParams(){let{toLocale:t,dispatch:e}=M;return!t||!e?null:{t,dispatch:e}}get computedIsIntentSwap(){return this.rootStore?.quoteStore?.computedIsOfflineType}get compuletedGetNativeCoinLoading(){return this.nativeCoin?this.nativeCoin?.isBalanceLoading:!0}get compuletedGetNativeCoinError(){return this.nativeCoin?this.nativeCoin.isBalanceLoadError:!0}get computedConfirmBtnDisabled(){let{RegisterLocalStatusEnum:t}=M.global,{computedIsStarknetChain:e,computedIsFromBtcCoin:o,computedIsEvmChain:r}=this.rootStore.fromToStore;if(this.computedIsIntentSwap)return this.computedPriceUpdate;if(e&&this.starknetRegisterStatus!==t?.COMPLETED)return!0;let s=this.computedPriceUpdate||!this.computedIsSufficientGas||!this.computedSolonaNativeTokenSufficientRent||this.gasFeeLoading||this.gasLimitError||this.compuletedGetNativeCoinError||this.compuletedGetNativeCoinLoading||this.updating;return o||!r?s:s||this.gasInfo?.isGasLimitLoading||this.gasInfo?.gasLimitInfo?.queryGasLimitErrorUseDefault}get computedIsConfirming(){let{swapStore:t,intentSwapStore:e}=this.rootStore;return this.computedIsIntentSwap?!!e.isConfirmLoading:t.isConfirmLoading}get computedConfirmBtnProps(){return this.getBtnProps(ct.CONFIRM)}get computedCancelBtnProps(){return this.getBtnProps(ct.CANCEL)}get computedTipsBtnProps(){let t=ct.DEFAULT;return(!this.computedIsSufficientGas||!this.computedSolonaNativeTokenSufficientRent)&&!this.compuletedGetNativeCoinError&&!this.compuletedGetNativeCoinLoading?t=ct.FILL_UP:this.computedPriceUpdate&&(t=this.computedIsIntentSwap?ct.SNAP_UPDATE:ct.UPDATE),this.getBtnProps(t)}get computedMonitorGasType(){return this.gasInfo?.gasType?{network_fee_details:{gas_level:this.gasInfo?.gasType}}:{}}},yo=ar;p();l();P();p();l();var cr=class{constructor(t){n(this,"signIntentSwap",async()=>[]);n(this,"createIntentOrder",async t=>{let e={intentCode:t.offlineType,signature:t.signature,quote:t?.quote,userWalletAddress:this.rootStore?.accountStore?.address,defiPlatformId:t.defiPlatformId},[o,r]=await E(k.post(bn,{...e}));return o&&(y.error(V.INTENT_ORDER_CREATE_ERROR,{error:o}),z.error({title:o?.error_message||h("swaptrade_trading_mode_alert_order_fail")})),zo({...it(),order_id:r?.data?.orderId,wallet_type:this.rootStore?.accountStore.walletConfig?.walletType}),[o,r]});n(this,"bridgeSumbitIntentOrder",async t=>{let{slippageStore:e,quoteStore:o,receiveAddressStore:r,fromToStore:s,accountStore:i}=this.rootStore,{quote:c,computedQuoteAmount:u}=o,{from:m,to:d}=s,{computedRealSlippageValue:f}=e,T=r?.receiveAddrObj?.specifiedAddress,A=f,L=c?.bestRoute?.bridge?.bridgeId,N=i?.address,et={signature:t.signature,quote:t?.quote,defiPlatformId:t.defiPlatformId,receiveWalletAddress:T,fromChainId:m?.chainId,fromTokenAddress:m?.tokenContractAddress,fromAmount:u,toChainId:d.chainId,toTokenAddress:d.tokenContractAddress,toAmount:d.reverseReceiveAmount,walletAddress:N,bridgeId:L,minimumReceived:c?.bestRoute?.minimumReceived,slippage:A},[X,ot]=await E(k.post(vn,{...et}));return X&&(y.error(V.INTENT_ORDER_CREATE_ERROR,{error:X}),z.error({title:X?.error_message||h("swaptrade_trading_mode_alert_order_fail")})),zo({...it(),order_id:ot?.data?.orderId,wallet_type:this.rootStore?.accountStore.walletConfig?.walletType}),[X,ot]});this.rootStore=t}},ci=cr;p();l();var ui=so(["isConfirmLoading"],[]);var ur=class extends ci{constructor(e){super(e);n(this,"isConfirmLoading",!1);n(this,"setIsConfirmLoading",e=>{this.isConfirmLoading=e});n(this,"signIntentSwap",async(e,o)=>{let{signTransaction:r}=this.rootStore.sendTransactionStore,[s,i]=await r(o,e);return s&&(y.error(V.INTENT_SWAP_SIGN_ERROR,{error:s,msg:{chainId:e,unsignedTx:o},tags:At(s)}),z.error({title:h("swaptrade_trading_mode_alert_order_fail")})),[s,i]});n(this,"onIntentSwap",async()=>{let{fromToStore:e}=this.rootStore;if(e?.computedIsCrossChain){await this.onIntentBridgeOrder();return}await this.onIntentSwapOrder()});n(this,"onIntentSwapOrder",async()=>{this.setIsConfirmLoading(!0),y.keepLive();let{swapStore:e,quoteStore:o}=this.rootStore,r=S(o,"quote.bestRoute.fromToken.chainId");try{let{offlineType:s,calldata:i,defiPlatformId:c}=o?.quote.bestRoute,{quote:u,unsignedTx:m}=i||{};if(!u||!m)return;let[d,f]=await this.signIntentSwap(r,m);if(d)return;let[T,A]=await this.createIntentOrder({quote:u,offlineType:s,signature:f,defiPlatformId:c});if(T)return;e.afterTransaction(A.data?.orderId)}catch(s){y.error(V.INTENT_SWAP_PROCESS_ERROR,{error:s,tags:At(s)})}finally{this.setIsConfirmLoading(!1),y.removeKeep()}});n(this,"onIntentBridgeOrder",async()=>{this.setIsConfirmLoading(!0),y.keepLive();let{swapStore:e,quoteStore:o}=this.rootStore,r=S(o,"quote.bestRoute.fromToken.chainId");try{let{bridge:s}=o?.quote.bestRoute,{calldata:i,defiPlatformId:c}=s,{quote:u,unsignedTx:m}=i||{};if(!u||!m)return;let[d,f]=await this.signIntentSwap(r,m);if(d)return;let[T,A]=await this.bridgeSumbitIntentOrder({quote:u,signature:f,defiPlatformId:c});if(T)return;e.afterTransaction(A.data?.orderId)}catch(s){y.error(V.INTENT_SWAP_PROCESS_ERROR,{error:s,tags:At(s)})}finally{this.setIsConfirmLoading(!1),y.removeKeep()}});Qe(this,ui)}},vo=ur;p();l();P();p();l();P();p();l();P();P();var pr=class{constructor(t){n(this,"rootStore");this.rootStore=t}checkZeroValue(){let t=null,o=this.rootStore.quoteStore.quote.bestRoute,{fromTokenPrice:r,toTokenPrice:s,fromToken:i,toToken:c}=o;return!Number(r)&&!Number(s)?t=i.tokenSymbol===c.tokenSymbol?F.ALIKE_TOKEN_SYMBOL_PRICE_UNKNOWN:F.ALL_TOKEN_PRICE_UNKNOWN:Number(r)?Number(s)||(t=F.TO_TOKEN_PRICE_UNKNOWN):t=F.FROM_TOKEN_PRICE_UNKNOWN,{errorType:t,continueToNextInterceptor:!1}}checkValueDifference(){let t=null,{fromToStore:e}=this.rootStore,{computedValueDifference:o,computedIsCrossChain:r}=e;return o.showValueDiffDialog&&(t=r?F.VALUE_DIFFERENCE_TOO_MUCH_CROSS:F.VALUE_DIFFERENCE_TOO_MUCH),{errorType:t,continueToNextInterceptor:!1}}checkMinReceive(){let t=null,e=this.rootStore.quoteStore,o=this.rootStore.slippageStore;return e?null:(o?.computedMinimumReceivedIsOrange&&(t=F.MIN_RECEIVED_TOO_SMALL),{errorType:t,continueToNextInterceptor:!1})}checkRepeatOrderWithEnoughBalance(){let t=null,{swapCheckStore:e}=this.rootStore,{repeatOrder:o}=e;return o?.enoughFlag===Qo.ENOUGH&&(t=F.REPEAT_ORDER),{errorType:t,continueToNextInterceptor:!1}}async checkBlockedRepeatOrder(){let t=null,{swapCheckStore:e}=this.rootStore;await e.checkRepeatOrder();let{repeatOrder:o}=e;return o&&(o.repeatFlag===wt.BTC_REPEAT?t=F.REPEAT_ORDER_BTC:o.repeatFlag===wt.FACET_REPEAT?t=F.REPEAT_ORDER_FACET:o.enoughFlag!==Qo.ENOUGH&&(t=F.REPEAT_ORDER_NOT_ENOUGH)),{errorType:t,continueToNextInterceptor:!1}}checkFacetTokenCrossChainDetail(){let{fromToStore:t}=this.rootStore,{from:e,to:o,computedNonsupportFacetToken:r}=t;if(r||b.get($r))return null;let s=null;return e.tokenType!==o.tokenType&&(Number(e.tokenType)===Go.FACET||Number(o.tokenType)===Go.FACET)&&(s=F.FACET_SWAP_TIPS),{errorType:s,continueToNextInterceptor:!1}}checkCrossChain(){let t=null;return this.rootStore.fromToStore.computedNeedCrossChainDoubleConfirm&&!b.get(Wr)&&(t=F.CROSS_CHAIN_DOUBLE_CONFIRM),{errorType:t,continueToNextInterceptor:!1}}checkGasMoreThanReceive(){let t=null,{fromToStore:e,quoteStore:o}=this.rootStore,{computedIsCrossChain:r}=e,s=o.quote.bestRoute,{toTokenPrice:i,quoteNetWorkFeeOfMoney:c,fromSwapFeeUsd:u}=s,{BigNumber:m}=I;return(r?new m(u):new m(c)).gte(new m(i))&&(t=F.GAS_MORE_THAN_RECEIVE_VALUE),{errorType:t,continueToNextInterceptor:!1}}checkToSwapThanGasFee(){let t=null,{fromToStore:e,quoteStore:o}=this.rootStore,{computedHasToSwap:r}=e,s=Number(e.to.chainId)===1;if(r&&s){let i=S(o,"quote.bestRoute.toSwapFeeUsd"),c=S(o,"quote.bestRoute.bridge.bridgeAmountOutUsd"),u=S(o,"quote.bestRoute.bridge.toRiskLimit");I.BigNumber(i).dividedBy(c).gte(u)&&(t=F.TO_SWAP_THAN_GAS_FEE)}return{errorType:t,continueToNextInterceptor:!1}}checkVolatilitySlippage(){let t=null,o=this.rootStore.slippageStore.computedVolatilityTips?.swapInterceptorType;return o&&(t=o),{errorType:t,continueToNextInterceptor:!0}}async checkBtcBalance(){let{fromToStore:t,safeMoonStore:e}=this.rootStore,{computedIsFromBtcCoin:o,from:r,updateBtcFromBalance:s}=t;if(o){if(!await s())throw Error("btc balance update failed");let c=e.computedInputVal,u=r.availableBalance;if(I.BigNumber(c).gt(u))return{errorType:F.BTC_AVAILABLE_BALANCE_NOT_ENOUGH,continueToNextInterceptor:!1}}return null}async checkCrossChainSwap(){let{swapCheckStore:t}=this.rootStore;await t.checkCrossChainSwap();let e=t.checkSwapMoreInfo?.errorCode;return vr(e)&&e!==0?e===4&&b.get(`${$e}_${t.checkSwapMoreInfo?.contentTip?.extra?.bridgeName}_${e}`)||b.get(`${$e}_${e}`)?null:{errorType:F.CHECK_CROSS_MORE,continueToNextInterceptor:!1}:null}async checkThirdPartyProvider(){let{quoteStore:t}=this.rootStore,{computedIsOkxProvider:e}=t,o=b.get(`${$e}_${Vr}`);return!e&&!o?{errorType:F.THIRD_PARTY_PROVIDER,continueToNextInterceptor:!0}:null}async checkBridgeThirdPartyProvider(){let{quoteStore:t}=this.rootStore,{computedBridgeIsOkxProvider:e,computedIsOfflineType:o}=t;return!e&&o?{errorType:F.THIRD_PARTY_PROVIDER,continueToNextInterceptor:!0}:null}async checkDisclaimerVisible(){return Hn()?{errorType:F.DISCLAIMER_VISIBLE,continueToNextInterceptor:!0}:null}makeCheckers(){let{fromToStore:{computedIsCrossChain:t}}=this.rootStore;return t?[this.checkDisclaimerVisible,this.checkBridgeThirdPartyProvider,this.checkVolatilitySlippage,this.checkCrossChainSwap,this.checkBtcBalance,this.checkZeroValue,this.checkToSwapThanGasFee,this.checkValueDifference,this.checkMinReceive,this.checkGasMoreThanReceive]:[this.checkDisclaimerVisible,this.checkThirdPartyProvider,this.checkVolatilitySlippage,this.checkBlockedRepeatOrder,this.checkFacetTokenCrossChainDetail,this.checkZeroValue,this.checkRepeatOrderWithEnoughBalance,this.checkValueDifference,this.checkMinReceive,this.checkGasMoreThanReceive]}async check(){let t=[],e=this.makeCheckers();for(let o=0;o<e.length;o++){let r=e[o],{errorType:s,continueToNextInterceptor:i}=await r.call(this)||{};if(s&&(t.push(s),!i))return t}return t}},pi=pr;p();l();P();p();l();var ua=()=>{let{quoteStore:a}=R(),t=a.enableQuoteAggregates?S(a,"quote.bestRoute"):null;return S(t,"defiPlatformId")===Z?h("swaptrade_trade_placeholder_okxdex"):S(t,"name")},lr=({disabled:a,toUsdPrice:t})=>{let{commonStore:e,fromToStore:o,buySellStore:r,quoteStore:s}=R();if(e.portal===to.MARKET){let m=S(s,"quote.bestRoute.receiveAmount");return m?h(r.tradeMode==="buy"?"swaptrade_market_placeorder_btn_buy_amt":"swaptrade_market_placeorder_btn_sell_amt",{amt:dt(m,{needBillionMillionUnit:!0,useScientificNotation:!0}),token:Dn(o.to.tokenSymbol),price:On(e.currencyConversion(t).toString(),e.computedNowCurrencySymbol,{needPlaceholder:!0})}):r.tradeMode==="buy"?h("swaptrade_market_placeorder_btn_buy_symbol",{symbol:o.to.tokenSymbol}):h("swaptrade_market_placeorder_btn_sell_symbol",{symbol:o.from.tokenSymbol})}let u=(s.enableQuoteAggregates?S(s,"quote.bestRoute"):null)?Ur:a?G:Jt;if(o.computedIsSingleChain){let m=ua();return h(u,{provider:m})}return h(Qr)},li=()=>{let{commonStore:a,buySellStore:t}=R();return a.portal===to.MARKET?t.tradeMode==="buy"?Pt.TYPE.green:Pt.TYPE.red:null},mi=()=>{let{commonStore:a,swapBtnStore:t,swapStore:e}=R();return a.portal===to.MARKET?e.isConfirmLoading:t.swapBtnLoading};p();l();P();var di=()=>{let{accountStore:a}=R(),t=S(a,"walletConfig.isWCApp"),e=S(a,"walletConfig.isOkxConnect"),o=h("swaptrade_card_swap_modal_btn_confirming_in_your_wallet"),r=h("swaptrade_modal_confirm_swap_btn_confirming_in_app");return t||e?r:o};var Ee=class{constructor(t){n(this,"swapBtnErrorTipsDialog",null);n(this,"swapInterceptor");n(this,"isInterceptionProcessing",!1);n(this,"defaultTipsDialogInfo",()=>({type:"",visible:!1,confirmCallBack:()=>{}}));n(this,"notShowAgainCrossChainConfirm",!1);n(this,"setNotShowAgainCrossChainConfirm",t=>{this.notShowAgainCrossChainConfirm=t});n(this,"tipsDialogInfo",this.defaultTipsDialogInfo());n(this,"swapBtnLoading",!1);n(this,"showErrorTips",(t,e)=>{this.tipsDialogInfo={type:t,visible:!0,confirmCallBack:e},this.setNotShowAgainCrossChainConfirm(!1)});n(this,"closeErrorTipsDialog",()=>{this.swapBtnLoading=!1,this.tipsDialogInfo.visible=!1});n(this,"openConfirmSwapDialog",(t,e)=>{let{swapStore:o}=this,{receiveAddressStore:r}=this.rootStore;r.saveWalletAddressToStorage(e),o.setConfirmSwapVisible(!0)});n(this,"connectWallet",()=>{});n(this,"approve",()=>{});n(this,"cancelApprove",()=>{});n(this,"swap",()=>{});n(this,"clickSwapOnDapp",()=>{let{from:t,to:e,computedIsSingleChain:o}=this.fromToStore,{computedNotThirdBiz:r}=this.commonStore;ao({business_type:o?"swap":"bridge",trade_dialog:r?"no":"yes",from_token_address:t.tokenContractAddress,to_token_address:e.tokenContractAddress,swap_type:o?"discover_swap":"discover_cross_chain_swap",from_chain:t.chainName,to_chain:e.chainName}),this.rootStore.swapDappStore?.showDappPanel()});n(this,"checkDappTrade",()=>{let t=this.rootStore.swapDappStore?.checkShouldJumpToDapp;return typeof t=="function"&&t()?he:null});n(this,"checkBlackAddress",()=>{let{quoteStore:t}=this.rootStore,{quoteError:e}=t.quote;return e?.error_code===Jr?G:null});n(this,"checkShowLimitRegion",()=>this.checkDappTrade()?null:fo.computedIsLimitRegion?G:null);n(this,"isQuoting",()=>{let{fromToStore:t,quoteStore:e,slippageStore:o}=this.rootStore,{isFetchQuoting:r,bestRoute:s,quoteError:i,quoteNull:c}=e.quote,{from:u,to:m,computedTypedValue:d}=t,{tokenContractAddress:f}=u,{computedRealSlippageValue:T}=o;return c||!s&&i&&!r||!d||!m.tokenContractAddress||!f||T>50||T<0?G:null});n(this,"isHoneypot",()=>this.rootStore?.safeMoonStore?.computedHoneypot?G:null);n(this,"noAmountOrOverLimit",()=>{let{fromToStore:t}=this,{overLimit:e}=this.rootStore?.safeMoonStore?.computedSlippageTips||{},{computedTypedValue:o}=t;return Number(o)===0||e?G:null});n(this,"hasFeeConfigErrorTips",()=>this.outerStore.computedFeeConfigErrorTips?G:null);n(this,"uninitializedWalletInfo",()=>{let{accountStore:{hasInitWalletInfo:t}}=this;return t?null:G});n(this,"unConnectedWallet",()=>{let{accountStore:{isConnectedWallet:t}}=this;return t?null:le});n(this,"nonsupportChain",()=>{let{accountStore:{computedNonsupportChain:t}}=this;return t?G:null});n(this,"nonsupportFacetToken",()=>{let{fromToStore:{computedNonsupportFacetToken:t}}=this;return t?G:null});n(this,"checkReceiveAddressStatus",()=>{let{fromToStore:{computedDiffCrossChain:t}}=this,{receiveAddressStore:{checkReceiveAddressLoading:e,computedSwapHighLight:o}}=this.rootStore;return t&&!o||e?G:null});n(this,"interceptionProcessing",()=>{let{fromToStore:t}=this;return!this.isInterceptionProcessing&&t.isBalanceLoading||t.fromBalanceState===Xe.BALANCE_REQUEST_FAILED?G:null});n(this,"balanceLessThenInputAmount",()=>this.computedTooBalance?me:null);n(this,"approveStatus",()=>{let{fromToStore:t,quoteStore:e,approveStore:{getApprovalStatus:o}}=this,{from:r,computedIsCrossChain:s}=t,i=S(e,"quote.bestRoute"),c=j.getCurrentRouteDefiPlatformId(s,i),u=o(r,c);return Hr[u]||null});n(this,"isValidAmount",()=>{let{fromToStore:t}=this,{from:e,to:o}=t;return o.amount&&e.amount?Jt:null});n(this,"getBtnStatus",()=>{let t=[this.checkBlackAddress,this.checkShowLimitRegion,this.hasFeeConfigErrorTips,this.unConnectedWallet,this.nonsupportChain,this.nonsupportFacetToken,this.checkDappTrade,this.checkReceiveAddressStatus,this.noAmountOrOverLimit,this.interceptionProcessing,this.balanceLessThenInputAmount,this.isQuoting,this.approveStatus,this.isValidAmount],e;for(let o of t){let r=o();if(r){e=r;break}}return e||(e=G),e});n(this,"checkIsCurrentQuote",()=>(this.computedIsCurrentQuote||z.warn({title:h("swaptrade_mid_toast_tryagain_with_newquote")}),this.computedIsCurrentQuote));let{accountStore:e,fromToStore:o,swapStore:r,commonStore:s,quoteStore:i,approveStore:c}=t;this.rootStore=t,this.accountStore=e,this.fromToStore=o,this.swapStore=r,this.commonStore=s,this.quoteStore=i,this.approveStore=c,this.swapInterceptor=new pi(t),Object.assign(this,t)}async runSwapInterceptor(t){this.isInterceptionProcessing=!0;let[e,o]=await E(this.swapInterceptor.check());if(this.isInterceptionProcessing=!1,e){y.error(V.UPDATE_BTC_BALANCE_ERROR_BEFORE_SWAP,{error:e,tags:At(e)});return}if(o.length===0){t();return}let r=-1,s=()=>{r++;let i=r===o.length-1;this.showErrorTips(o[r],i?t:s)};s()}getBtnAllStatus({from:t,toUsdPrice:e}){return{[le]:{statusType:le,disabled:!1,toLocaleText:()=>h(le),onClick:this.connectWallet},[me]:{statusType:me,disabled:!0,toLocaleText:()=>h(me,{tokenSymbol:O(t.tokenSymbol)}),symbol:t.tokenSymbol},[Ke]:{statusType:Ke,disabled:!1,toLocaleText:()=>h(Ke,{tokenSymbol:O(t.tokenSymbol)}),onClick:()=>{this.quoteStore.setAggregateSelectStatus(1),this.approve()},icon:"okx-defi-dex-authorization",iconType:Pt.ICON_POSITION.leading},[de]:{statusType:de,loading:!0,disabled:!0,toLocaleText:()=>h(de)},[Uo]:{statusType:de,disabled:!1,toLocaleText:()=>h(Uo,{ccy:t.tokenSymbol}),onClick:this.cancelApprove,icon:"okx-defi-dex-authorization",iconType:Pt.ICON_POSITION.leading},[je]:{statusType:je,loading:!0,disabled:!0,toLocaleText:()=>h(je)},[G]:{statusType:G,disabled:!0,toLocaleText:()=>lr({disabled:!0,toUsdPrice:e})},[Jt]:{statusType:Jt,disabled:!1,loading:mi(),toLocaleText:()=>lr({disabled:!1,toUsdPrice:e}),toLoadingLocaleText:()=>di(),onClick:()=>{this.quoteStore.setAggregateSelectStatus(1),this.swap()},type:li()},[he]:{statusType:he,disabled:!1,loading:this.rootStore.swapDappStore?.swapOnDappBtnLoading,toLocaleText:()=>h(he),icon:"okds-open-link",iconType:Pt.ICON_POSITION.leading,onClick:this.clickSwapOnDapp}}}get needToCrossChainDoubleCheck(){return!0}get computedTooBalance(){let{rootStore:t,fromToStore:e,accountStore:o}=this,{isConnectedWallet:r}=o,s=e.from.balance,i=t.safeMoonStore.computedInputVal;return r?I.BigNumber(s||0).isLessThan(i):!1}get computedBtnStatus(){let{fromToStore:t}=this,{from:e,to:o}=t,r=this.getBtnStatus();return this.getBtnAllStatus({from:e,swapLoading:this.swapBtnLoading,toUsdPrice:S(o,"usdPrice")})[r]}get computedIsCurrentQuote(){let{fromToStore:t,quoteStore:e}=this,{computedIsExactIn:o,computedTypedValue:r}=t,{quote:s,getGasTokenFeeLoading:i}=e,{fromTokenAmount:c="",inputToTokenAmount:u=""}=s?.bestRoute||{},m=!!r,d=m&&o&&I.BigNumber(r).isEqualTo(c),f=m&&!o&&I.BigNumber(r).isEqualTo(u);return!i&&(d||f)}};p();l();var hi=so(["tipsDialogInfo","notShowAgainCrossChainConfirm","isInterceptionProcessing","swapBtnLoading"],["computedTooBalance","computedBtnStatus","computedIsCurrentQuote"]);p();l();var dr=()=>{let{accountStore:a}=R();zn({wallet_address:a.address,...os()})};var Ht=class extends Ee{constructor(e){super(e);n(this,"handleSwap",async()=>{let{quote:e,computedIsOfflineType:o}=this.quoteStore,{receiveAddressStore:r,swapStore:s}=this.rootStore,{from:i,cacheTokenInfo:c}=this.fromToStore;if(this.swapBtnLoading=!0,this.walletContractStore.setQuoteData(e.bestRoute),y.info(V.CLICK_WALLET_SWAP_BUTTON,{chainId:i.chainId,tokenContractAddress:ro(i.tokenContractAddress),amountNum:i.balance}),I.eq(i.balance,c.amountNum)||y.info(V.BALANCE_IS_ERROR,{chainId:i.chainId,tokenContractAddress:ro(i.tokenContractAddress),amountNum:i.balance,cacheTokenInfo:{...c,tokenContractAddress:ro(c.tokenContractAddress)}}),!o){let d=await this.walletContractStore.fetchCallData();if(this.swapBtnLoading=!1,d)return}this.swapBtnLoading=!1;let u=o?lt.INTENT_SWAP:lt.SWAP;r.saveWalletAddressToStorage(this.fromToStore?.to);let{fromToken:m}=qe.get(e,"bestRoute",{});if(s.isSwapSolana(m.chainId)){M.history?.push({pathname:We});return}M.history?.push({pathname:zt,search:`needUpdate=${Yr.on}&type=${u}`})});n(this,"swap",async()=>{let e=this.checkIsCurrentQuote();ao({wallet_address:this.accountStore.address,button_name:"confirm",...it()}),e&&(this.swapBtnLoading=!0,this.runSwapInterceptor(this.handleSwap))});n(this,"approve",async()=>{let{fromToStore:e,quoteStore:o}=this.rootStore,r=qe.get(o,"quote.bestRoute"),s=j.getCurrentRouteDefiPlatformId(e.computedIsCrossChain,r),i=e.from;this.approveStore.updateApproveTokenConfig(i,s,{status:_.Approving});let c=await M.checkMpcAccountIfNecessary();if(dr(),!c){this.approveStore.updateCurrentApproveTokenConfig({status:_.UnApproved});return}this.approveStore.setApprove()});n(this,"cancelApprove",async()=>{let{fromToStore:e,quoteStore:o}=this.rootStore,r=qe.get(o,"quote.bestRoute"),s=j.getCurrentRouteDefiPlatformId(e.computedIsCrossChain,r),i=e.from;this.approveStore.updateApproveTokenConfig(i,s,{status:_.CancelApproving});let c=await M.checkMpcAccountIfNecessary();if(dr(),!c){this.approveStore.updateApproveTokenConfig(i,s,{status:_.CancelApprove});return}this.approveStore.setApprove(Zt.CANCEL_APPROVE)});this.walletContractStore=e.walletContractStore,Qe(this,hi)}};p();l();P();P();p();l();P();P();p();l();p();l();var fi=function(){return new Promise(function(t){setTimeout(t,1)})};p();l();var ae=v(B());p();l();var pa={[w.SWAP]:"swap_used_chain_cache",[w.LIMIT_ORDER]:"limit_used_chain_cache",[w.BRIDGE]:"bridge_used_chain_cache"},Si=(a,t,e)=>{let o=pa[e],r=b.get(o)||[];if(t.sort((s,i)=>i.popularWeight-s.popularWeight),r.length===0&&(r=t.slice(0,4).map(i=>i.chainId)),a.forEach(s=>{r.includes(s)||r.unshift(s)}),r=r.filter(s=>t.find(i=>i.chainId===s)),r.length<4)for(let s=0;s<t.length&&r.length<4;s++)r.includes(t[s].chainId)||r.push(t[s].chainId);return r.length>4&&(r=r.slice(0,4)),b.set(o,r),r};p();l();var be=class{constructor(t){n(this,"id",1);n(this,"tokenSymbol","--");n(this,"tokenName","--");n(this,"decimals",6);n(this,"tokenContractAddress","");n(this,"tokenLogoUrl","");n(this,"type","");n(this,"amountNum",0);n(this,"currencyAmount",0);D(this),Object.assign(this,t),this.tokenModalStore=R().tokenModalStore}get computedPrice(){let{nowCurrencyUnit:t}=this.tokenModalStore.commonStore,{symbol:e,usdToThisRate:o}=t,r=I.BigNumber(this.currencyAmount);return r.isNaN()||r.isZero()?`${e||""}0.00`:e&&o&&!r.isNaN()&&!r.isZero()?Nt(r.multipliedBy(o).toJSON(),e):"0"}get computedIsSelect(){let{equalsToken:t}=this.tokenModalStore.commonStore,{from:e,to:o}=this.tokenModalStore.fromToStore;return this.tokenModalStore.tokenModalFromState===C.FROM?t(this,o):t(this,e)}get computedIsSelectOrigin(){let{from:t,to:e}=this.tokenModalStore.fromToStore,{equalsToken:o}=this.tokenModalStore.commonStore;return this.tokenModalStore.tokenModalFromState===C.FROM?o(this,t):o(this,e)}get computedAmountNum(){return this.amountNumBigDecimal!==""?this.amountNum:0}toJSON(){return nt(this)}get computedTokenVolume(){let{currencyConversionWithSymbol:t}=this.tokenModalStore.commonStore;return t(this.volume,{needPlaceholder:!0})}get computedTokenLiquidity(){let{currencyConversionWithSymbol:t}=this.tokenModalStore.commonStore;return t(this.liquidity,{needPlaceholder:!0})}};p();l();var ye=(a={})=>({...U,logoUrl:U.logoUrl(),chainName:h(U.localKey),...a}),Po=(a={})=>{let t=Nr();return{...K,get logoUrl(){return t===Or.dark?K.darkLogoUrl():K.logoUrl()},chainName:h(K.localKey),...a}};var gi="hide_collect_cancel_dialog",Ti="hideTokenGuide",Yt=class{constructor(t){n(this,"searchValue","");n(this,"setSearchValue",t=>{this.searchValue=t});n(this,"fromTokenList",new Map);n(this,"toTokenList",new Map);n(this,"searchTokenList",{});n(this,"currentCollectionGroupId");n(this,"setCurrentCollectionGroupId",t=>{this.currentCollectionGroupId=t});n(this,"setCurrentCollectionGroupIdAndGetList",t=>{t&&t===this.currentCollectionGroupId||(this.setCurrentCollectionGroupId(t),this[`${this.tokenModalFromState}TokenList`].set(U.chainId),this.getTokenListByChainId().then(rt).catch(rt))});n(this,"error",!1);n(this,"tokenModalVisible",!1);n(this,"tokenModalFromState",C.FROM);n(this,"setTokenModalFromState",t=>{this.tokenModalFromState=t});n(this,"loading",{[C.FROM]:{},[C.TO]:{}});n(this,"initLoading",()=>{this.loading={[C.FROM]:{},[C.TO]:{}}});n(this,"importTokenInfo",{});n(this,"setImportTokenInfo",t=>{this.importTokenInfo={...t}});n(this,"toSelectedChainId","");n(this,"fromSelectedChainId","");n(this,"setToSelectedChainId",t=>{this.toSelectedChainId=t});n(this,"setFromSelectedChainId",t=>{this.fromSelectedChainId=t});n(this,"fromSelectedChainAtSearch","");n(this,"toSelectedChainAtSearch","");n(this,"setFromSelectedChainAtSearch",t=>{this.fromSelectedChainAtSearch=t});n(this,"setToSelectedChainAtSearch",t=>{this.toSelectedChainAtSearch=t});n(this,"updateSelectedChainAtSearch",t=>{this.tokenModalFromState===C.FROM?this.setFromSelectedChainAtSearch(t):this.setToSelectedChainAtSearch(t)});n(this,"updateFromToSelectedChainIdAfterSearch",()=>{if(this.tokenModalFromState===C.FROM&&this.fromSelectedChainAtSearch!==this.fromSelectedChainId){this.setFromSelectedChainId(this.fromSelectedChainAtSearch);return}this.tokenModalFromState===C.TO&&this.toSelectedChainAtSearch!==this.toSelectedChainId&&this.setToSelectedChainId(this.toSelectedChainAtSearch)});n(this,"extendTokens",(t,e)=>t.filter(o=>this.commonStore.getChainByID($(o.chainId))).map(o=>{let r=new be(o,this);return{...o,balance:r.computedAmountNum,selected:r.computedIsSelect,selectedOrigin:e?r.computedIsSelectOrigin:!1,price:r.computedPrice,formattedVolume:r.computedTokenVolume,formattedLiquidity:r.computedTokenLiquidity}}));n(this,"extendTokenList",(t=[],e=!0)=>J(t)?t:this.extendTokens(t,e));n(this,"importUserToken",It(function*(e,o=!0){let r=e.map(c=>{let{chainId:u,tokenContractAddress:m,tokenSymbol:d,decimals:f}=c;return{chainId:u,contractAddress:m,tokenSymbol:d,precision:f}}),s={userUniqueId:this.commonStore.userUniqueId,tokenDetailList:r},i=[];try{i=(yield k.post(on,s)).data}catch(c){throw z.error(h("swaptrade_pricechart_no_connection_desc")),c}return o&&(this.searchValue="",this.changeTokenModalVisible(!1)),i}));n(this,"sortTokens",t=>wr(t,[e=>Number(e.topPlacement),e=>Number(e.currencyAmount),e=>Number(e.amountNum),e=>Number(e.isCollectToken),e=>Number(e.collectTime)],["desc","desc","desc","desc","desc"]));n(this,"orderTokenList",t=>this.computedIsCollectChain?t:this.commonStore.currentTab===w.BRIDGE?t.map(e=>({...e,tokenList:this.sortTokens(e.tokenList)})):this.sortTokens(t));n(this,"formatTokenList",(t,e)=>{let o=t;t.length>100&&e!==U.chainId&&(o=t.slice(0,100));let r=this.extendTokenList(o,!0);return this.orderTokenList(r)});n(this,"changeTokenModalVisible",t=>{this.tokenModalVisible=t});n(this,"clearCacheTokenList",()=>{});n(this,"getTokenListByChainId",async()=>{let t=this.tokenModalFromState===C.FROM,e={};if(this.clearCacheTokenList(),this.tokenModalFromState===C.FROM?e={fromChainId:this.fromSelectedChainId}:this.tokenModalFromState===C.TO&&(e={fromChainId:this.fromToStore.from.chainId,toChainId:this.toSelectedChainId}),this.tokenModalFromState===C.FROM&&Number(this.fromSelectedChainId)===K.chainId){this.getFromAllNetworksTokens();return}if(this.tokenModalFromState===C.TO&&Number(this.toSelectedChainId)===K.chainId){this.getToAllNetworksTokens(e.fromChainId);return}if(this.tokenModalFromState===C.FROM&&Number(this.fromSelectedChainId)===U.chainId){this.getFromCollectedTokens();return}if(this.tokenModalFromState===C.TO&&Number(this.toSelectedChainId)===U.chainId){this.getToCollectedTokens(e.fromChainId);return}t?this.getTokenList(C.FROM,e.fromChainId):this.getTokenList(C.TO,e.toChainId,e.fromChainId)});n(this,"setTokenList",(t,e,o)=>{let r=this.formatTokenList(e,t);this[`${o}TokenList`].set(t,r)});n(this,"cancelGetTokenListRef",null);n(this,"handleTokenList",It(function*(e,o,r,s){this.setError(!1),this.cancelGetTokenListRef&&this.cancelGetTokenListRef.abort(),this[`${e}TokenList`].get(o)||this.setLoading(e,o,!0),this.cancelGetTokenListRef=kt();try{let{data:i}=yield k.get(r,{params:s,signal:this.cancelGetTokenListRef?.signal,isolate:!0}),c=this.toLowerCaseContractAddress(i);return this.setTokenList(o,c,e),this.setLoading(e,o,!1),{data:c}}catch(i){return this.isCancel(i)?null:(this.setTokenList(o,[],e),this.setLoading(e,o,!1),this.setError(!0),i)}}).bind(this));n(this,"getCrossChainParams",(t,e,o)=>{switch(t){case w.BRIDGE:return{fromChainId:e.fromChainId??e?.chainId,userUniqueId:e.userUniqueId,accountId:e.accountId,targetChainId:e.targetChainId,targetWalletAddress:e.targetWalletAddress,walletAddress:e.walletAddress,...o,toChainId:o.toChainId===-1?"":o?.toChainId};case w.SWAP:default:return e}});n(this,"getTokenList",It(function*(e,o,r){let s={fromChainId:r,chainId:o,userUniqueId:this.commonStore.userUniqueId,accountId:this.accountStore.computedAccountId,walletAddress:this.accountStore.computedSignWalletAddress,...this.computedAdresses};this.commonStore?.computedCurrentTabIsLimit&&(s={...s,businessLine:ee.LIMIT_ORDER});let i=this.getCrossChainParams(this.commonStore.currentTab,s,{selectChainType:this.getCrossChainSelectChainType(),toChainId:this.computedCurrentToChainId,fromTokenAddress:this.fromToStore.from.tokenContractAddress||""}),c=$(o);if(this.computedIsNotSupportToChain)return this.setTokenList(c,[],e),{data:[]};let u=Mt(Ft.ALL_TOKENS,this.commonStore.currentTab);return yield this.handleTokenList(e,c,u,i)}));n(this,"getFromCollectedTokens",It(function*(){let e={userUniqueId:this.commonStore.userUniqueId,accountId:this.accountStore.computedAccountId,fromChainId:"",...this.computedCollectionGroupParams,...this.computedAdresses};this.commonStore?.computedCurrentTabIsLimit&&(e={...e,businessLine:ee.LIMIT_ORDER});let o=this.getCrossChainParams(this.commonStore.currentTab,e,{selectChainType:Dt.FROM,toChainId:this.computedCurrentToChainId,fromTokenAddress:"",...this.computedCollectionGroupParams}),r=Mt(Ft.COLLECT_LIST,this.commonStore.currentTab);return yield this.handleTokenList(C.FROM,U.chainId,r,o)}));n(this,"getToCollectedTokens",It(function*(e){let o={userUniqueId:this.commonStore.userUniqueId,accountId:this.accountStore.computedAccountId,fromChainId:e,chainId:e,...this.computedCollectionGroupParams,...this.computedAdresses};this.commonStore?.computedCurrentTabIsLimit&&(o={...o,businessLine:ee.LIMIT_ORDER});let r=this.getCrossChainParams(this.commonStore.currentTab,o,{selectChainType:Dt.TO,toChainId:"",fromTokenAddress:this.fromToStore.from.tokenContractAddress,...this.computedCollectionGroupParams}),s=Mt(Ft.COLLECT_LIST,this.commonStore.currentTab);return yield this.handleTokenList(C.TO,U.chainId,s,r)}));n(this,"getFromAllNetworksTokens",It(function*(){let e={userUniqueId:this.commonStore.userUniqueId,accountId:this.accountStore.computedAccountId,fromChainId:"",walletAddress:this.accountStore.computedSignWalletAddress,...this.computedAdresses};this.commonStore?.computedCurrentTabIsLimit&&(e={...e,businessLine:ee.LIMIT_ORDER});let o=Mt(Ft.ALL_NETWORK,this.commonStore.currentTab),r=this.getCrossChainParams(this.commonStore.currentTab,e,{selectChainType:Dt.FROM,toChainId:this.computedCurrentToChainId,fromTokenAddress:""});return yield this.handleTokenList(C.FROM,K.chainId,o,r)}));n(this,"getToAllNetworksTokens",It(function*(e){let o={userUniqueId:this.commonStore.userUniqueId,accountId:this.accountStore.computedAccountId,fromChainId:e,walletAddress:this.accountStore.computedSignWalletAddress,...this.computedAdresses};this.commonStore?.computedCurrentTabIsLimit&&(o={...o,businessLine:ee.LIMIT_ORDER});let r=Mt(Ft.ALL_NETWORK,this.commonStore.currentTab),s=this.getCrossChainParams(this.commonStore.currentTab,o,{selectChainType:Dt.TO,toChainId:"",fromTokenAddress:this.fromToStore.from.tokenContractAddress});return yield this.handleTokenList(C.TO,K.chainId,r,s)}));n(this,"cancelSearchRef",null);n(this,"needRemoveChainId",t=>[K.chainId,U.chainId].includes($(t)));n(this,"getSearchChainType",()=>{let t=ze.SINGLE;return this.computedCurrentSearchChainId===K.chainId&&(t=ze.ALL_NETWORK),this.computedCurrentSearchChainId===U.chainId&&(t=ze.COLLECT),t});n(this,"getCrossChainSelectChainType",()=>this.tokenModalFromState===C.FROM?Dt.FROM:Dt.TO);n(this,"singleSearchParams",t=>{let e=this.getSearchChainType(),o={userUniqueId:this.commonStore.userUniqueId,accountId:this.accountStore.computedAccountId,chainType:e,searchType:e,walletAddress:this.accountStore.computedSignWalletAddress,...this.computedAdresses},r={},s={};return this.tokenModalFromState===C.FROM?(r={inputContent:t,fromChainId:this.fromSelectedChainAtSearch,chainId:this.fromSelectedChainAtSearch,toChainId:this.fromSelectedChainAtSearch},this.needRemoveChainId(this.fromSelectedChainAtSearch)&&(delete r.fromChainId,delete r.toChainId,delete r.chainId)):this.tokenModalFromState===C.TO&&(s={inputContent:t,fromChainId:this.fromToStore.from.chainId,chainId:this.fromToStore.from.chainId,toChainId:this.toSelectedChainAtSearch,fromTokenAddress:this.fromToStore.from.tokenContractAddress||""},this.needRemoveChainId(this.toSelectedChainAtSearch)&&(delete s.toChainId,delete r.chainId)),{...o,...r,...s}});n(this,"getSearchTokenList",async()=>{if(this.searchValue==="")return;if(this.cancelSearchRef&&this.cancelSearchRef.abort(),this.computedIsNotSupportToChain){this.setSearchTokenList({}),this.setLoading(this.tokenModalFromState,"search",!1);return}this.cancelSearchRef=kt(),this.setLoading(this.tokenModalFromState,"search",!0),this.setError(!1);let t=qo(this.searchValue),e=this.getSearchParams(t);$n({keyword:t});let o=Mt(Ft.SEARCH,this.commonStore.currentTab),[r,s]=await E(k.get(o,{params:e,signal:this.cancelSearchRef?.signal}));if(r&&!this.isCancel(r)){this.setError(!0),this.setSearchTokenList({}),this.setLoading(this.tokenModalFromState,"search",!1);return}if(s){let{data:i}=s;if(this.commonStore.currentTab===w.BRIDGE)this.setSearchTokenList({list:i});else{let{systemList:c,thirdPartyList:u}=s.data;this.setSearchTokenList({systemList:c,thirdPartyList:u})}this.updateFromToSelectedChainIdAfterSearch(),this.setError(!1),this.setLoading(this.tokenModalFromState,"search",!1)}});n(this,"resetTokenModal",()=>{this.resetTokenData()});n(this,"resetTokenData",()=>{this.searchTokenList={},this.searchValue=""});n(this,"balancePushSort",(t,e)=>{let o=[...t],{currencyAmount:r,coinAmountOriginalDec:s}=e;for(let i=0;i<o.length;i++)if(this.commonStore.equalsToken(o[i],e)){o[i].amountNum=s,o[i].currencyAmount=r;break}return o});n(this,"updateAllTokenList",t=>{let{chainId:e}=t,o=$(e),r=this.fromTokenList.get(o);r&&this.setTokenList(o,this.balancePushSort(nt(r),t),C.FROM);let s=this.toTokenList.get(o);s&&this.setTokenList(o,this.balancePushSort(nt(s),t),C.TO)});n(this,"checkFromToLegal",(t,e)=>{let{currentTab:o}=this.commonStore,r={toToken:{...e,amount:""},isChanged:!1};if(Number(t.chainId)!==Number(e.chainId)){if(this.computedToChain?.some(f=>f.chainId===e.chainId&&!f.disabled))return r;let{dexDefaultFromToTokenShowVO:s}=this.commonStore.getChainByID(this.fromToStore.from.chainId),{fromDexMultiTokenInfoVO:i,toDexMultiTokenInfoVO:c,toCrossDexMultiTokenInfoVO:u}=s,m=o===w.BRIDGE,d;return m&&u?d=u:this.commonStore.equalsToken(t,c)?d=i:d=c,{toToken:d,isChanged:!0}}return r});n(this,"calcCurToChainIdIsInSupList",t=>{let e=!1;return nt(this.computedToChain).forEach(o=>{Number(o.chainId)===Number(t)&&!o.disabled&&(e=!0)}),e});n(this,"hideCollectCancelConfirm",b.get(gi));n(this,"showCollectOverLimitDialog",!1);n(this,"setShowCollectOverLimitDialog",t=>{this.showCollectOverLimitDialog=t});n(this,"setCommonlyUsedChain",t=>{let{from:e,to:o}=this.fromToStore,{chainList:r,currentTab:s}=this.commonStore,i=t&&t.length>0?t:[e.chainId,o.chainId];return Si(i,r,s)});n(this,"tokenPageChainList",[]);n(this,"setTokenPageChainList",t=>{this.tokenPageChainList=t});n(this,"getCurrentToChainInfo",()=>this.computedToChain.find(e=>$(e.chainId)===$(this.toSelectedChainId)));n(this,"changeTokenPageChainList",async t=>{if(this.tokenPageChainList.findIndex(o=>$(o.chainId)===$(t))===-1){let o=this.commonStore.chainList.find(s=>$(s.chainId)===$(t)),r=[...this.tokenPageChainList];r.unshift(o),r.length>4&&r.pop(),this.setTokenPageChainList(r)}this.tokenModalFromState===C.FROM?this.setFromSelectedChainId(t):this.setToSelectedChainId(t),await this.getTokenListByChainId()});n(this,"searchChainKeywords","");n(this,"setSearchChainKeywords",t=>{this.searchChainKeywords=t});n(this,"filterChains",t=>br(t,e=>{let o=Bo(qo(this.searchChainKeywords));return Bo(e.chainName).includes(o)}));n(this,"dialogIndex",Ho.TOKEN_LIST);n(this,"setDialogIndex",t=>{this.dialogIndex=t});n(this,"hideTokenGuide",!!b.get(Ti));n(this,"setHideTokenGuide",()=>{this.hideTokenGuide=!0,b.set(Ti,"1")});n(this,"importToken",async(t,e)=>{let r=(await this.importUserToken(Array.isArray(t)?t:[t]))[0]||{};e&&e(r),jn(r)&&await this.fromToStore.getTokenBalanceByAccount(this.tokenModalFromState,r),this.setImportTokenInfo({}),this.setDialogIndex(Ho.TOKEN_LIST)});n(this,"reloadTokenList",async()=>{!this.tokenModalVisible||(this.searchValue!==""?await this.getSearchTokenList():await this.getTokenListByChainId())});n(this,"selectTokenHandle",async t=>{let e=this.commonStore.getChainByID(Number(t?.chainId));if(await fi(),!e)return;let{quoteStore:o}=this.rootStore,{from:r,updateFrom:s,updateTo:i,setBalance:c,setFromBalanceRequestError:u,setToBalanceRequestError:m,to:d,computedIsExactIn:f,needCrossChainDoubleConfirm:T,setNeedCrossChainDoubleConfirm:A}=this.fromToStore,{clearReceiveAddressValue:L}=this.rootStore.receiveAddressStore;this.setCommonlyUsedChain([t?.chainId]);let N=this.tokenModalFromState===C.FROM,et=()=>{this.rootStore.fromToStore.setCacheTokenInfo({chainId:t.chainId,tokenContractAddress:t.tokenContractAddress,amountNum:t.balance},"tokenList"),u(!1),c(C.FROM,t.balance)},X=()=>{m(!1),c(C.TO,t.balance)};if(t.selected){N?X():et(),this.fromToStore.onSwitchFromTo();return}N?et():X();let ot=()=>{T||A(!0)};if(N){if(Yn(t.chainId,d.chainId)&&this.commonStore.currentTab===w.BRIDGE){let Q=new Et(this.commonStore.currentTab,{}),[vt,ht]=await Q.fetchCrossChainTokens({fromChainId:t.chainId,fromTokenAddress:t.tokenContractAddress}),{amount:Rr}=r,De={...t},pe;vt?(s({...De,amount:Rr}),pe=e?.dexDefaultFromToTokenShowVO?.toCrossDexMultiTokenInfoVO,i({...pe})):(De=ht.data.fromTokenInfo,pe=ht.data.toTokenInfo,s({...De,amount:Rr}),i(pe),ot(),this.fromToStore.getTokenBalanceByAccount("from",De)),this.fromToStore.getTokenBalanceByAccount("to",pe)}else if(!this.commonStore.equalsToken(t,r)){let{amount:Q}=r;o.setQuoteNumber(2),s({...t,riskLevel:t.riskLevel,amount:Q});let{toToken:vt,isChanged:ht}=this.checkFromToLegal(t,d);i(vt),ht&&(ot(),this.fromToStore.getTokenBalanceByAccount("to",nt(vt))),f&&this.fromToStore.advanceSetTypedValue("")}}else this.commonStore.equalsToken(t,d)||(ot(),o.setQuoteNumber(0),i({...t,amount:""}),f||this.fromToStore.advanceSetTypedValue(""));L()});n(this,"updateTokenCollectionStatus",(t,e,o)=>{let r=!o?.length,s=this.currentCollectionGroupId&&!o.includes(this.currentCollectionGroupId);this.updateTokenCollectedLocal({...e,isCollectToken:r||s})});n(this,"memeTagConfig",{});n(this,"setMemeTagConfig",t=>{this.memeTagConfig=t});n(this,"fetchMemeTagConfig",async()=>{let[,t]=await E(k.get(Ln)),e=t.data?.tagAndEmojiMap||{};return this.setMemeTagConfig(e),e});this.rootStore=t,this.commonStore=t.commonStore,this.swapStore=t.swapStore,this.accountStore=t.accountStore,this.fromToStore=t.fromToStore}get computedIsSearching(){return!!this.searchValue}get computedCollectionGroupParams(){let t={accountId:this.accountStore.computedAccountId,walletAddress:this.accountStore.computedSignWalletAddress};return this.currentCollectionGroupId?{...t,groupId:this.currentCollectionGroupId}:t}get computedAdresses(){return S(this,"accountStore.computedMultiAddresses",{})}setSearchTokenList(t){this.searchTokenList=t}setError(t){this.error=t}setLoading(t,e,o){this.loading[t][e]=o}get computedTokenList(){return this.tokenModalFromState===C.FROM?this.fromTokenList.get(this.fromSelectedChainId):this.toTokenList.get(this.toSelectedChainId)}get computedSearchTokenList(){let t={};return J(this.searchTokenList)||(t={systemList:this.extendTokenList(this.searchTokenList?.systemList,!1),thirdPartyList:this.extendTokenList(this.searchTokenList?.thirdPartyList,!1)}),t}toLowerCaseContractAddress(t){let e=[];return Array.isArray(t)&&t.forEach(o=>{e.push({...o,tokenContractAddress:this.commonStore.getTokenAddress(o)})}),e}isCancel(t){return re(t)}getSearchParams(){throw new Error("getSearchParams method must be implemented by subclass")}get computedFromChain(){let t=ye(),e=Po({});return[t,e,...nt(this.tokenPageChainList)]}get computedToChain(){let t=ye();if(oe(this.fromToStore.from.chainId)){let e=this.tokenPageChainList.filter(o=>o?.chainId===this.fromToStore.from.chainId);return[t,...e]}return[t]}get computedCurrentToChainId(){return this.toSelectedChainId||oe(this.toSelectedChainId)?this.toSelectedChainId:oe(this.fromToStore.to.chainId)?this.calcCurToChainIdIsInSupList(this.fromToStore.to.chainId)?this.fromToStore.to.chainId:this.fromToStore.from.chainId:this.computedToChain.length>1?K.chainId:en}reassignTokenInfo(t,e,o){if(this.commonStore.equalsToken(t,e)){let r=e?.isCollectToken;return ft({},e,{isCollectToken:r?0:1,collectTime:r?"":Date.now().toString(),isCustomToken:o?1:e?.isCustomToken})}return t}filterCollectToken(t){let e=!t.isCustomToken||t.balance;return!!(!this.computedIsCollectChain&&e||this.searchValue||t.isCollectToken)}updateTokenCollectedLocal(t){let e=(o=[],r=!1)=>o.map(s=>this.reassignTokenInfo(s,t,r)).filter(s=>this.filterCollectToken(s));if(this.searchValue){let{systemList:o,thirdPartyList:r}=this.searchTokenList;this.setSearchTokenList({systemList:e(o),thirdPartyList:e(r,!0)})}else this.updateTokenList(e)}updateTokenList(t){if(this.tokenModalFromState===C.FROM){let e=t(this.fromTokenList.get(this.fromSelectedChainId));this.fromTokenList.set(this.fromSelectedChainId,e)}else if(this.tokenModalFromState===C.TO){let e=t(this.toTokenList.get(this.toSelectedChainId));this.toTokenList.set(this.toSelectedChainId,e)}}get computedCurrentChainId(){return $(this.tokenModalFromState===C.FROM?this.fromSelectedChainId:this.toSelectedChainId)}get computedCurrentSearchChainId(){return $(this.tokenModalFromState===C.FROM?this.fromSelectedChainAtSearch:this.toSelectedChainAtSearch)}get computedIsCollectChain(){return this.computedCurrentChainId===U.chainId}setShowCollectCancelConfirm(t){b.set(gi,t),this.hideCollectCancelConfirm=t}get computedIsNotSupportToChain(){let t=this.getCurrentToChainInfo();return this.tokenModalFromState===C.TO&&t&&t.disabled}get computedSelectedChainId(){return this.tokenModalFromState===C.FROM?this.fromSelectedChainId||this.fromToStore.from.chainId:this.tokenModalFromState===C.TO?this.toSelectedChainId||this.fromToStore.to.chainId:""}get computedAllChainList(){let t=this.commonStore.chainList;return this.tokenModalFromState===C.FROM?{supported:t,unsupported:[]}:this.tokenModalFromState===C.TO?this.computedToChainList:{supported:[],unsupported:[]}}get computedToChainList(){let t=this.commonStore.chainList,e=Fe(nt(t),{chainId:Number(this.fromToStore.to.chainId)});return{supported:e?[e]:[],unsupported:[]}}get computedIsSearchChainStatus(){return!!this.searchChainKeywords}get computedSearchedChainList(){if(!this.computedIsSearchChainStatus)return{supported:[],unsupported:[]};let{supported:t,unsupported:e}=this.computedAllChainList;return{supported:this.filterChains(t),unsupported:this.filterChains(e)}}get computedTokenGuideVisible(){return!1}get computedIsWatchListGroupShow(){return this.searchValue?!1:this.tokenModalFromState===C.FROM&&Number(this.fromSelectedChainId)===U.chainId||this.tokenModalFromState===C.TO&&Number(this.toSelectedChainId)===U.chainId}};var Lo=class extends Yt{constructor(e){super(e);n(this,"showChainTab",!0);n(this,"clearCacheTokenList",()=>{this.fromTokenList.clear(),this.toTokenList.clear()});n(this,"extendTokenList",(e=[],o=!0)=>J(e)?e:e?.map(r=>({...r,tokenList:this.extendTokens(r.tokenList,o)})));n(this,"generateToChainMap",()=>{let e=this.commonStore.chainList,r=Fe(nt(e),{chainId:Number(this.fromToStore.from.chainId)})?.bridgeSupportChainInfoList||[];return Me([...r],"chainId")});n(this,"getCrossChainSearchType",()=>{let e=this.tokenModalFromState===C.FROM?this.fromSelectedChainAtSearch:this.toSelectedChainAtSearch;return Number(e)===U.chainId?Xo.COLLECTION:Xo.COMMON});n(this,"getToChainIdAtSearch",()=>{let e=this.toSelectedChainId;return this.tokenModalFromState===C.TO&&(e=this.toSelectedChainAtSearch),Number(e)===K.chainId?"":e});st(this)}get computedTokenGuideVisible(){let{tokenModalFromState:e,hideTokenGuide:o}=this;return e===C.TO&&!o}get computedSearchTokenList(){return this.extendTokenList(this.searchTokenList?.list,!1)}get computedToChainList(){let e=this.commonStore.chainList,o=[],r=[],s=this.generateToChainMap();return e.forEach(i=>{let c={...i};c.disabled=!s[i.chainId],c.disabled||o.push(c)}),{supported:o,unsupported:r}}updateTokenCollectedLocal(e){let o=(r=[],s=!1)=>{let i=[];return r?.forEach(c=>{let u=c?.tokenList.map(m=>this.reassignTokenInfo(m,e,s)).filter(m=>this.filterCollectToken(m));i.push({...c,tokenList:u})}),i};if(this.searchValue){let{list:r}=this.searchTokenList;this.setSearchTokenList({list:o(r)})}else this.updateTokenList(o)}get computedToChain(){let e=ye(),o=Po({});if(oe(this.fromToStore.from.chainId)){let r=this.generateToChainMap(),s=[];return nt(this.tokenPageChainList).forEach(i=>{i.chainId!==Number(this.fromToStore.from.chainId)&&s.push({...i,disabled:!r[i.chainId]})}),[e,o,...s]}return[e]}getSearchParams(e){let o={...this.computedAdresses};return this.tokenModalFromState===C.FROM&&(o={...o,fromChainId:this.fromSelectedChainAtSearch},this.needRemoveChainId(this.fromSelectedChainAtSearch)&&delete o.fromChainId),this.tokenModalFromState===C.TO&&(o={...o,fromChainId:this.fromToStore.from.chainId,toChainId:this.toSelectedChainAtSearch},this.needRemoveChainId(this.toSelectedChainAtSearch)&&delete o.toChainId),{fromChainId:o.fromChainId??o?.chainId,userUniqueId:this.commonStore.userUniqueId,accountId:this.accountStore.computedAccountId,targetChainId:o.targetChainId,targetWalletAddress:o.targetWalletAddress,walletAddress:this.accountStore.computedSignWalletAddress,inputContent:e,selectChainType:this.getCrossChainSelectChainType(),searchType:this.getCrossChainSearchType(),toChainId:this.getToChainIdAtSearch(),fromTokenAddress:this.fromToStore.from?.tokenContractAddress||""}}};p();l();P();var{BigNumber:Ci}=I,hr="safemoon_slippage",fr="safemoon_is_changed",Ii=50,Sr={NeedIncreaseSlip:0,AdviseGivenSlip:1,NotAvailableGivenSlip:2,AdviseSlip:3},Kt=class{constructor(t){n(this,"isChanged",!1);n(this,"getSafemoonIsChangedLocal",()=>!!b.get(`${fr}_${this.computedSlippageTokenPair}`));n(this,"cacheSlippage",0);D(this),this.rootStore=t,this.commonStore=t.commonStore,this.fromToStore=t.fromToStore,Ct(()=>this.computedSlippageTokenPair,()=>{this.setSafeMoonIsChanged(b.get(`${fr}_${this.computedSlippageTokenPair}`)),this.setCacheSlippage(b.get(`${hr}_${this.computedSlippageTokenPair}`))}),Ct(()=>({slippage:this.computedPairSlippage}),()=>{this.cacheSlippage>0&&this.computedPairSlippage>this.cacheSlippage&&this.setSafeMoonIsChanged(!1),this.setCacheSlippage(b.get(`${hr}_${this.computedSlippageTokenPair}`))}),Ct(()=>this.computedSlippage,e=>{this.commonStore.safemoonSlippage=e})}setSafeMoonIsChanged(t){this.isChanged=t,b.set(`${fr}_${this.computedSlippageTokenPair}`,t)}checkIsChanged(t){let e=new Ci(t),o=e.gte(this.computedPairSlippage)&&e.lte(50);o&&this.setSafeMoonIsChanged(o)}setSafeMoonPairSlippage(t){!this.isAccessSlippage(t)||(this.setCacheSlippage(t),b.set(`${hr}_${this.computedSlippageTokenPair}`,t))}isAccessSlippage(t){let e=new Ci(t);return this.computedPairSlippage>0&&e.gte(this.computedPairSlippage)&&e.lte(50)}get computedAutoSlippage(){return mo(this.rootStore)}get computedSafeMoonToken(){let{from:t,to:e}=this.fromToStore;return this.checkIsSafeMoon(t)?t:this.checkIsSafeMoon(e)?e:null}get computedHoneypot(){let{from:t,to:e}=this.fromToStore;return this.checkIsHoneypot(t)?t:this.checkIsHoneypot(e)?e:null}setCacheSlippage(t){this.cacheSlippage=t}get computedPairSlippage(){return this.computedSafeMoonToken?1.1:0}get computedSlippage(){return this.cacheSlippage>this.computedPairSlippage?this.cacheSlippage:this.computedPairSlippage}get computedOverLimit(){return this.computedSlippage>50}get computedSlippageTokenPair(){let{from:t,to:e}=this.fromToStore;return`${this.checkIsSafeMoon(t)?t.tokenContractAddress:""}_${this.checkIsSafeMoon(e)?e.tokenContractAddress:""}`}get computedSlippageTips(){let t=S(this,"rootStore.quoteStore.quote.bestRoute"),e=Number(this.computedAutoSlippage),{tokenSymbol:o}=this.computedSafeMoonToken||{};return t?.isSafeMoonToken!=="1"||t?.isHoneypot==="1"?null:e===Ii?{type:Sr.AdviseGivenSlip,safeMoonSlippage:e,equalLimit:!0,tip:h("swaptrade_card_errortip_autoadjust_to_50",{tokenSymbol:o,slippageTolerance:e}),tipEquation:h("swaptrade_card_errortip_autoadjust_to_50",{tokenSymbol:O(o),slippageTolerance:e}),inputWarning:h("swaptrade_adjustslip_modal_advise_givenslip")}:e>Ii?{type:Sr.NotAvailableGivenSlip,overLimit:!0,safeMoonSlippage:e,tip:h("wallet_swap_adjustslip_modal_slip_notsupported",{tokenSymbol:o}),tipEquation:h("wallet_swap_adjustslip_modal_slip_notsupported",{tokenSymbol:O(o)})}:{type:Sr.AdviseSlip,safeMoonSlippage:e,tip:h("swaptrade_card_errortip_autoadjust_to_less50",{slippageTolerance:e,tokenSymbol:o}),tipEquation:h("swaptrade_card_errortip_autoadjust_to_less50",{slippageTolerance:e,tokenSymbol:O(o)}),inputWarning:h("swaptrade_modal_errortip_adjust_to_suggested_range",{slippageTolerance:e})}}checkIsSafeMoon(t){return S(t,"isSafeMoonToken")===1}checkIsHoneypot(t){return S(t,"isHoneypot")===1}get computedInputVal(){let{computedSwapAmount:t}=this.fromToStore;return t[C.FROM]}get computedInputFiatVal(){let{computedFromLocalCostByUsd:t}=this.fromToStore;return t}get computedOutputVal(){let{computedSwapAmount:t}=this.fromToStore;return t[C.TO]}get computedOutputFiatVal(){let{computedToLocalCostByUsd:t}=this.fromToStore;return t}get computedOutputPopVal(){let{computedSwapAmount:t}=this.fromToStore;return Nn(t[C.TO])}};p();l();var wo=class{constructor(){n(this,"gasDropConfig",{gasDropShow:!1,gasDropSwitch:b.get(Vo)===Gr.OPEN,chainName:"",chainId:"",deduction:"",gasDrop:"",tokenLogoUrl:"",tokenSymbol:""});n(this,"setGasDropInfo",t=>{this.gasDropConfig={...this.gasDropConfig,...t}});n(this,"setGasDropSwitch",t=>{this.setGasDropInfo({gasDropSwitch:t}),b.set(Vo,`${Number(t)}`)});n(this,"resetGasDrop",()=>{this.setGasDropInfo({gasDropShow:!1})});D(this)}get computedGasDropSelected(){let{gasDropShow:t,gasDropSwitch:e}=this.gasDropConfig;return t&&e}};p();l();var gr=class{constructor(t){n(this,"isShowMev",!1);n(this,"setShowMev",t=>{this.isShowMev=t});n(this,"mevSwitchOpenStatue",Ze.AUTO_OFF);n(this,"setMevUserSwitchOpen",t=>{this.mevSwitchOpenStatue=t});n(this,"mevInfo",{});n(this,"setMevInfo",t=>{this.mevInfo=t});n(this,"walletMevControl",!1);n(this,"setWalletMevControl",t=>{this.walletMevControl=t});this.rootStore=t,this.quoteStore=this.rootStore.quoteStore,this.fromToStore=this.rootStore.fromToStore,D(this,{},{autoBind:!0})}get computedIsMevOpen(){return this.isShowMev&&(this.mevSwitchOpenStatue===Ze.AUTO_ON||this.mevSwitchOpenStatue===Ze.USER_ON)}},Oo=gr;p();l();P();var Tr=class{constructor(t){n(this,"feeConfig",{});n(this,"setFeeConfig",t=>{if(!this.isIframe)return;if(!J(t)){this.feeConfig=t,fe.set("feeConfig",t);return}let e=fe.get("feeConfig"),o=xe(e,["referrerAddress","feePercent"]);J(o)?(this.feeConfig={},fe.remove("feeConfig")):this.feeConfig=o});n(this,"widgetFeeConfig",{});n(this,"setWidgetFeeConfig",t=>{this.isWidget&&(this.widgetFeeConfig=t)});n(this,"receiveQuoteUrl",()=>this.isIframe?nn:an);n(this,"aggregatorQuoteUrl",()=>un);n(this,"saveOrderUrl",()=>this.isIframe?mn:ln);n(this,"illegalFeePercent",t=>{let{BigNumber:e}=I,o=e(t);return!!(o.isNaN()||o.gt(Xr)||o.lte(0))});n(this,"extendFeeConfig",t=>{if(this.isWidget){let o=S(this.widgetFeeConfig,[t.chainId],{});if(typeof o.referrerAddress=="string")return{...t,...o};let r=S(o,["referrerAddress",t.fromTokenAddress]),s=S(r,"account"),c=S(r,"feePercent")||o.feePercent;return s?{...t,referrerAddress:s,feePercent:c}:t}if(!this.computedHasFeeConfig)return t;let e=J(this.feeConfig)?fe.get("feeConfig"):this.feeConfig;return{...t,...e}});D(this),this.rootStore=t,this.isIframe=!Ot()&&Vn()&&!Kn,this.isWidget=!Ot()&&Wn()}get computedHasFeeConfig(){return!!this.feeConfig?.referrerAddress&&!!this.feeConfig?.feePercent&&this.isIframe}get computedFeeConfigErrorTips(){return this.computedHasFeeConfig?this.illegalFeePercent(this.feeConfig?.feePercent):!1}},No=Tr;p();l();P();p();l();P();p();l();var Ai=()=>{let{swapStore:a,intentSwapStore:t,swapDappStore:e,approveStore:o,fromToStore:r}=R(),{from:s,to:i}=r;return!(!i?.tokenContractAddress||!s?.tokenContractAddress||o.visibleApprove||a.isConfirmLoading||t.isConfirmLoading||e.computedSupportDappTradeByChain)};p();l();p();l();var ki=a=>{let{fromToStore:t,quoteStore:e}=R(),{commonDexInfo:o,pathSelectionRouterList:r,singleChainSwapInfo:s}=a,{computedIsSingleChain:i}=t,c=Number(o?.code)===pt.CROSS_CHAIN_INTERVAL,u=c?{crossMaxAmount:o?.crossMaxAmount,crossMiniAmount:o?.crossMiniAmount}:null;return e.setQuoteScope(u),{isAutoError:c||(i?!s:!r?.length)}};var la=({quoteStore:a,fromToStore:t})=>{a.setQuoteNumber(a.quoteNumber+1),a.quoteNumber===1&&a.checkQuoteScopeLtMin(a.quoteScope,t.from.amount)&&t.advanceSetTypedValue("")},ma=(a,{fromToStore:t,quoteStore:e})=>{let{commonDexInfo:o,pathSelectionRouterList:r,singleChainSwapInfo:s,swapType:i,intentCode:c,isSupportDappTrade:u,offlineType:m,traceData:d,serviceFeeInfo:f}=a,T={intentCode:c,offlineType:m,swapType:i,traceData:d},A=r?.map(N=>({...o,...N,...T,isSupportDappTrade:u}));return{bestRoute:t.computedIsSingleChain?{...o,...s,...T,serviceFeeInfo:f,intentInfo:a?.intentInfo||{},isSupportDappTrade:u}:e.pickBestRouterAccordingBridgeId(A)||{...o,...T,isSupportDappTrade:u},combineSelectionRouterList:A}},da=({bestRoute:a,combineSelectionRouterList:t,isAutoError:e},{fromToStore:o,quoteStore:r})=>{r.updateSlippageInfoFetched(a),r.setQuote({...r.quote,bestRoute:a,quoteNull:e,quoteError:null,isFetchQuoting:!1}),o.quoteUpdateFromTo(a),o.computedIsSingleChain||r.setPathSelectionRouterList(t||[])},Cr=({isAutoError:a},{approveStore:t})=>{if(!a){let{fromToStore:e,quoteStore:o,accountStore:r}=R(),{needApprove:s,defiPlatformId:i,defiPlatformIds:c,allowanceData:u}=j.getApproveInfo(e.computedIsCrossChain,o);t.isPendingNotCheck({token:e.from,needApprove:s,defiPlatformIds:c,defiPlatformId:i,allowanceData:u,userWalletAddress:r.getAddressByChainId(e.from.chainId)}).catch(()=>{})}},ve=({isAutoError:a},{quoteStore:t})=>{a&&(t.handleReverseQuoteErrorAndNull(),St(()=>{t.updateQuoteStatus(t.quoteScope?2:3)}))},ha=a=>{let{solanaPriorityFeeStore:t}=R();t&&t.setJitoData(a?.priorityFeeInfo)},_i=a=>{let{fromToStore:t,quoteStore:e,approveStore:o}=R(),{isAutoError:r}=ki(a);la({quoteStore:e,fromToStore:t});let{bestRoute:s,combineSelectionRouterList:i}=ma(a,{fromToStore:t,quoteStore:e});da({bestRoute:s,combineSelectionRouterList:i,isAutoError:r},{fromToStore:t,quoteStore:e,approveStore:o}),ha(a),Cr({isAutoError:r},{approveStore:o}),ve({isAutoError:r},{quoteStore:e})};p();l();var Pe=class{constructor(t){n(this,"allTimerAndQuoteState",{[W.DEFAULT]:{isShowLoadingCpt:!1,quoteText:()=>""},[W.QUOTING]:{isShowLoadingCpt:!0,quoteText:()=>h(He)},[W.TIMER]:{isShowLoadingCpt:!0,quoteText:()=>h(He)},[W.QUOTE_IS_HONEYPOT]:{isShowLoadingCpt:!1,quoteText:()=>h(Ye)},[W.QUOTE_NULL]:{isShowLoadingCpt:!0,quoteText:()=>h(Ye)},[W.QUOTE_NULL_AND_SECTION]:{isShowLoadingCpt:!0,quoteText:()=>h(He)},[W.QUOTE_ERROR]:{isShowLoadingCpt:!1,quoteText:()=>h(Ye)}});Object.assign(this,t)}isValidRange(t){if(typeof t!="string")return!1;let{from:e}=this.fromToStore,o=t.split("-");if(o.length!==2)return!1;let{BigNumber:r}=I;return r(e.amount).lt(o[0])||r(e.amount).gt(o[1])}getCurrentTimerQuoteState(){let{quoteNull:t,isFetchQuoting:e,quoteError:o,bestRoute:r}=this.quote,s=this.fromToStore?.computedIfQuote,i=o!==null;return s?i?this.allTimerAndQuoteState[W.QUOTE_ERROR]:this.rootStore.safeMoonStore.computedHoneypot?this.allTimerAndQuoteState[W.QUOTE_IS_HONEYPOT]:t?r?.msg&&(e||this.isValidRange(r.msg))?this.allTimerAndQuoteState[W.QUOTE_NULL_AND_SECTION]:this.allTimerAndQuoteState[W.QUOTE_NULL]:e?e?this.allTimerAndQuoteState[W.QUOTING]:this.allTimerAndQuoteState[W.DEFAULT]:this.allTimerAndQuoteState[W.TIMER]:this.allTimerAndQuoteState[W.DEFAULT]}};var{FACET_TOKEN_ERROR_ONE:Sa,FACET_TOKEN_ERROR_TWO:ga,FACET_TOKEN_ERROR_THREE:Ta}=pt,jt=class{constructor(){n(this,"dialogCloseFlag",!1);n(this,"slippageInfoFetched",!1);n(this,"setDialogCloseFlag",t=>{this.dialogCloseFlag=t});n(this,"enableQuoteAggregates",!1);n(this,"dialogShowQuotationComparison",!1);n(this,"setDialogShowQuotationComparison",t=>{this.dialogShowQuotationComparison=t});n(this,"quoteNumber",0);n(this,"setQuoteNumber",t=>{this.quoteNumber=t});n(this,"aggregateSelectId",mt);n(this,"isDialog",!1);n(this,"setIsDialog",t=>{this.isDialog=t});n(this,"initQuote",{bestRoute:null,quoteError:null,quoteNull:!1,isFetchQuoting:!1});n(this,"isPickRouterFromWallet",!1);n(this,"setIsPickRouterFromWallet",t=>{this.isPickRouterFromWallet=t});n(this,"quoteScope",null);n(this,"setQuoteScope",t=>{this.quoteScope=t});n(this,"fetchQuoteStatus",0);n(this,"quote",{...this.initQuote});n(this,"setQuote",t=>{this.quote=t});n(this,"pathSelectionRouterList",[]);n(this,"setPathSelectionRouterList",t=>{this.pathSelectionRouterList=t});n(this,"pickRouter",{});n(this,"setPickRouter",(t,e)=>{this.pickRouter=t,e&&(this.setNoCurrentPathTipInfo({bridgeName:t?.bridge?.bridgeName}),this.updateBestRoute(t))});n(this,"showChainListModel",!1);n(this,"setShowChainListModel",t=>{this.showChainListModel=t});n(this,"noCurrentPathTipInfo",{visible:!1,bridgeName:""});n(this,"setNoCurrentPathTipInfo",t=>{this.noCurrentPathTipInfo={...this.noCurrentPathTipInfo,...t}});n(this,"currentBridgeId","");n(this,"setCurrentBridgeId",t=>{this.currentBridgeId=t});n(this,"updateBestRoute",t=>{this.setQuote({...this.quote,bestRoute:t}),this.rootStore.fromToStore?.quoteUpdateFromTo(t)});n(this,"pickBestRouterAccordingBridgeId",t=>{let{smartRouterStore:{showXRouteModal:e}}=this.rootStore;if(!t||t.length===0)return null;let o=t.find(r=>r?.bridge?.bridgeId===this.currentBridgeId);return this.currentBridgeId&&!o&&(this.setCurrentBridgeId(""),!this.showChainListModel&&e!==oo.ROUTER_SELECT&&this.setNoCurrentPathTipInfo({visible:!0})),o||t?.[0]});n(this,"quoteTimer",null);n(this,"clearQuote",()=>{this.cleanQuoteTimer(),this.setQuote(this.initQuote),this.rootStore.fromToStore?.quoteUpdateFromTo(null),this.quotePending=!1;let{computedIsCrossChain:t,computedIfQuote:e}=this.fromToStore;t?(this.setBridgeQuoteSelectStatus(0),this.setBridgeFetchStatus(e?1:0)):(this.setAggregateSelectStatus(0),this.setAggregateFetchStatus(e?1:0))});n(this,"cancelRef",null);n(this,"cleanQuoteTimer",()=>{clearTimeout(this.quoteTimer),this.quoteTimer=null,this.cancelRef&&this.cancelRef.abort()});n(this,"isClearQuote",()=>{let{currentTab:t}=this.commonStore,{computedTypedValue:e,from:o,to:r,computedIsSingleChain:s,computedIsExactIn:i}=this.fromToStore;return t===w.LIMIT_ORDER||!Se(e)||!r?.tokenContractAddress||!o?.tokenContractAddress||!i&&!s});n(this,"getQuoteData",t=>{let e=at();return E(ie(()=>k.get(this.getQuoteStoreUrl(),{params:e,signal:t,isolate:!0}),gt.NUM,gt.TIMER))});n(this,"handleUpdateQuote",t=>{if(t){let{data:e}=t;_i(e)}});n(this,"fetchQuote",async({source:t}={})=>{if(!Ai())return this.quoteTimer=setTimeout(()=>{this.fetchQuote().catch(()=>{})},Wo),Promise.resolve(!1);if(t===0){let{computedIsCrossChain:r}=this.fromToStore;r?(this.setBridgeQuoteSelectStatus(0),this.setBridgeFetchStatus(1),this.setBridgeSelectId(mt)):(this.setAggregateSelectStatus(0),this.setAggregateFetchStatus(1),this.setAggregateSelectId(mt))}if(this.isClearQuote())return this.quoteScope=null,this.clearQuote(),Promise.resolve(!1);if(this.cleanQuoteTimer(),this.rootStore.outerStore.computedFeeConfigErrorTips)return this.handleQuoteError(null),Promise.resolve(!1);this.setQuote({...this.quote,isFetchQuoting:!0}),this.cancelRef=kt();let[e,o]=await this.getQuoteData(this.cancelRef.signal);return this.quotePending=!1,!re(e)&&e&&this.handleQuoteError(e),this.handleUpdateQuote(o),this.setIsPickRouterFromWallet(!1),this.commonStore.setResetFromToByTabChange(!1),!re(e)&&!this.dialogCloseFlag&&St(()=>{this.quoteTimer=setTimeout(()=>{this.fetchQuote().catch(()=>{})},Wo)}),Promise.resolve(!0)});n(this,"quotePending",!1);n(this,"debounceQuote",Er(this.fetchQuote,jr));n(this,"fetchQuoteDebounce",async({source:t}={})=>{let{computedIsCrossChain:e,computedIfQuote:o}=this.fromToStore;this.quotePending=!0,o&&e?await this.debounceQuote({source:t}):o&&!e?this.debounceQuote({source:t}):this.clearQuote()});n(this,"handleQuoteError",t=>{this.setQuote({...this.initQuote,quoteError:t}),this.handleReverseQuoteErrorAndNull()});n(this,"getGasTokenFeeLoading",!1);n(this,"getGasTokenFeeCancelRef",null);n(this,"cancelGasTokenGeeRequest",()=>{this.getGasTokenFeeCancelRef&&(this.getGasTokenFeeCancelRef.abort(),this.getGasTokenFeeCancelRef=null)});n(this,"cacheNativeGasFee","");n(this,"setCacheNativeGasFee",t=>{this.cacheNativeGasFee=t});n(this,"fetchGasTokenFee",async()=>{let{from:t}=this.rootStore.fromToStore,{computedReserveGas:e}=this.rootStore.commonStore,{decimals:o,balance:r}=t||{},s=Pr(at(),["dexIds"]);this.getGasTokenFeeCancelRef=kt();let i=this.rootStore.fromToStore?.computedIsExactIn?rn:sn;this.getGasTokenFeeLoading=!0;let c=this.getGasTokenFeeCancelRef.signal,u=e,[m,d]=await E(k.get(i,{params:{...s,amount:xn(r,o)},signal:c}));if(this.getGasTokenFeeLoading=!1,!re(m)&&m)return-1;if(!m){let{data:f}=d||{},{commonDexInfo:T}=f||{};Number(T?.code)===0&&T?.estimateReserveGasTokenFee!==""&&(u=T.estimateReserveGasTokenFee)}return this.setCacheNativeGasFee(u),u})}initQuoteStatus(){this.fetchQuoteStatus=0}updateQuoteStatus(t){this.fetchQuoteStatus=t}get computedSlippage(){let{computedIsSingleChain:t,computedDefaultAutoSlippageInfo:e}=this.fromToStore,o=this.rootStore.slippageStore,r=is({isSingleChain:t,autoSlippageInfo:e}),s=xt.AUTO,i,c;return o&&(r=o.computedRealSlippageValue,s=o.getSlippageType(),i=t?o.computedRealCustomMaxSlippage:void 0,c=t?o.computedRealCustomSlippage:void 0),!this.slippageInfoFetched&&s===xt.AUTO&&(s=xt.DEFAULT),{slippage:r,slippageType:s,customSlippage:c,maxSlippage:i}}getQuoteStoreUrl(){return this.outerStore.receiveQuoteUrl()}handleReverseQuoteErrorAndNull(){let{updateFromAmount:t,computedIsExactIn:e,updateTo:o}=this.fromToStore;e?o({amount:""}):t({amount:""})}getQuoteError(t){let{commonDexInfo:e,pathSelectionRouterList:o,singleChainSwapInfo:r}=t,{computedIsSingleChain:s}=this.fromToStore,i=Number(e?.code)===pt.CROSS_CHAIN_INTERVAL,c=i?{crossMaxAmount:e?.crossMaxAmount,crossMiniAmount:e?.crossMiniAmount}:null;return this.setQuoteScope(c),{isAutoError:i||(s?!r:!o?.length)}}updateSlippageInfoFetched(t){let{referenceSlippage:e,autoSlippage:o,autoTotalSlippage:r}=t?.autoSlippageInfo||{};(e||o||r)&&(this.slippageInfoFetched=!0)}checkQuoteScopeLtMin(t,e){if(!t||!e)return!1;let{crossMiniAmount:o}=this.quoteScope||{};return!!I.BigNumber(e).lt(I.BigNumber(o))}get computedCurrentTimerQuoteState(){return new Pe(this).getCurrentTimerQuoteState()}get computedRouterForSmartRouterStore(){return this.fromToStore?.computedIsSingleChain?this.quote?.bestRoute:this.pickRouter}get computedMediaForChangeSmartRouterData(){return Gn()?.media==="sm"||this.isDialog}get computedQuoteAmount(){let{computedIsExactIn:t}=this.fromToStore;return t?this.quote?.bestRoute?.fromTokenAmount:this.quote?.bestRoute?.payAmount}get computedQuoteIntervalIsEmpty(){return this.computedQuoteInterval.type===q.EMPTY}get computedShouldShowLimitRegionTip(){let t=!!fo.computedIsLimitRegion;return this.fromToStore?.computedIsSingleChain?t&&!this.quote?.bestRoute:t}get computedQuoteInterval(){let{fromToStore:t,approveStore:e,swapBtnStore:o,swapDappStore:r}=this.rootStore;if(this.quote?.bestRoute?.code===tn||this.quote?.bestRoute?.code===Zr||t.computedFormToTokenIsLeverageToken)return{type:q.EMPTY};let s=_s.handleQuoteErrorState({quote:this.quote,honeypotToken:S(this,"rootStore.safeMoonStore.computedHoneypot",!1),shouldShowLimitRegionTip:this.computedShouldShowLimitRegionTip})||this.accountStore.computedNonsupportChain,{from:i,computedNonsupportFacetToken:c}=this.fromToStore;if(s||c)return{type:q.EMPTY};if(r.checkShouldJumpToDapp())return{type:q.SHOULD_JUMP_DAPPS};if(this.computedNotSupportBtcAddress&&this.accountStore.isConnectedWallet)return{type:q.NOT_SUPPORT_BTC_ADDRESS_TYPE,text:this.quote.bestRoute?.errorMsg};if(this.computedIsNoOkxLiquidity)return{type:q.NOT_OKX_LIQUIDITY};let m=t.computedIsCrossChain?S(this.quote?.bestRoute,"bridge.defiPlatformId"):S(this.quote?.bestRoute,"defiPlatformId",Z);if((!this.quoteScope||!t.computedIfQuote)&&this.fetchQuoteStatus!==3&&!e.isCancelApproveStatus(i,m)&&!this.computedPriceWarn.show&&!this.quote?.bestRoute?.errorMsg)return{type:q.EMPTY};if(this.computedCrossAccuracyLimit)return{type:q.CROSS_CHAIN_ACCURACY,text:h("swaptrade_card_tooltips_adjust_pay_token_decimal",{fromToken:i.tokenSymbol,value:this.computedCrossAccuracyLimit}),equation:h("swaptrade_card_tooltips_adjust_pay_token_decimal",{fromToken:O(i.tokenSymbol),value:this.computedCrossAccuracyLimit})};if(this.computedFacetTokenTips)return{type:q.FACET_TOKEN_SWAP_ERROR,text:this.computedFacetTokenTips};let{crossMiniAmount:d,crossMaxAmount:f}=this.quoteScope||{};if(I.BigNumber(i.amount).lt(I.BigNumber(d))){let T=dt(d,{cutPriceText:!0,isFloor:!1});return{type:q.CROSS_CHAIN_MIN,text:h("swaptrade_bridge_toast_min_amout_crosschain_swap",{value:T,symbol:i.tokenSymbol}),equation:h("swaptrade_bridge_toast_min_amout_crosschain_swap",{value:T,symbol:O(i.tokenSymbol)})}}if(I.BigNumber(i.amount).gt(I.BigNumber(f))){let T=dt(f,{cutPriceText:!0});return{type:q.CROSS_CHAIN_MAX,text:h("swaptrade_bridge_toast_max_amout_crosschain_swap",{value:T,symbol:i.tokenSymbol}),equation:h("swaptrade_bridge_toast_max_amout_crosschain_swap",{value:T,symbol:O(i.tokenSymbol)})}}return this.quote?.bestRoute?.errorMsg?{type:q.CROSS_CHAIN_MORE_TIPS,text:this.quote?.bestRoute?.errorMsg}:this.computedIsNoLiquidity?{type:q.NOT_LIQUIDITY}:this.computedCrossChainIntervalOutOfRange?{type:q.NOT_LIQUIDITY}:e.isCancelApproveStatus(i,m)&&!o.computedTooBalance?{type:q.CANCEL_APPROVE_TIPS}:this.computedPriceWarn.show?{type:q.PROVIDER_PRICE_WARN}:{type:q.EMPTY}}get computedNotSupportFromBtcAddressType(){let t=this.quote?.bestRoute?.code;return Number(t)===pt.NOT_SUPPORT_FROM_BTC_ADDRESS}get computedNotSupportToBtcAddressType(){let t=this.quote?.bestRoute?.code;return Number(t)===pt.NOT_SUPPORT_TO_BTC_ADDRESS}get computedNotSupportBtcAddress(){return this.computedNotSupportFromBtcAddressType||this.computedNotSupportToBtcAddressType}get computedCrossChainIntervalOutOfRange(){let{from:t}=this.fromToStore,{crossMiniAmount:e,crossMaxAmount:o}=this.quoteScope||{};return I.BigNumber(t.amount).lte(o)&&I.BigNumber(t.amount).gte(e)}get computedIsNoLiquidity(){return this.fetchQuoteStatus===3&&this.quote.quoteNull}get computedIsNoOkxLiquidity(){let t=this.quote?.bestRoute?.defiPlatformInfoList;return this.enableQuoteAggregates&&t&&this.aggregateFetchStatus===3?!t.some(o=>o?.defiPlatformId===Z):!1}get computedCrossAccuracyLimit(){let{crossAccuracyLimit:t,code:e}=this.quote.bestRoute||{};return Number(e)===pt.CROSS_CHAIN_ACCURACY?t:""}get computedFacetTokenTips(){let{errorMsg:t,code:e}=this.quote.bestRoute||{};return[Sa,ga,Ta].includes(Number(e))&&t?t:""}get computedYouSaveVisible(){let{computedNowCurrencySymbol:t,currencyConversion:e,computedIsWalletEnv:o}=this.commonStore,{computedIsExactIn:r,computedIsCrossChain:s}=this.rootStore.fromToStore,{quoteError:i,quoteNull:c,bestRoute:u}=this.quote;if(!r||i||c||!u?.youSaveDTO||s)return{visible:!1};let{youSaveDTO:m,fromToken:d,toToken:f}=u,{topTenDexInfoList:T,youSaveMoney:A}=m,L=Number(A)>=.1&&T?.length>0&&!d.isHoneypot&&!f.isHoneypot,N=e(A).toString(),et=L?Nt(N,t,{isFloor:!1}):"",X=L?T?.[1]?.dexName:"";return o&&(!s&&this.computedTopTenDexInfoList.length>0?L=!0:L=!1),{visible:L,youSaveStr:et,dexName:X}}get computedHasYouSave(){let{computedIsCrossChain:t}=this.rootStore.fromToStore;return!!this.quote?.bestRoute?.youSaveDTO||t}get computedTopTenDexInfoList(){if(!this.rootStore.fromToStore?.computedIsExactIn||!this.computedHasYouSave)return[];let{computedNowCurrencySymbol:t,currencyConversion:e}=this.commonStore;return this.quote?.bestRoute?.youSaveDTO?.topTenDexInfoList?.map(({logoUrl:o,dexName:r,comparePercent:s,price:i,dexAmountOut:c,amountOutOfMoney:u,gasOfMoney:m,isOkxDex:d})=>{let f=e(u)?.toString(),T=e(m)?.toString();return{logoUrl:o,dexName:r,comparePercent:s,price:i,isOkxDex:d,formatPrice:dt(i),dexAmountOut:I.BigNumber(c).toString(),formatDexAmountOut:dt(c),amountOutOfMoney:f,formatAmountOutOfMoney:Nt(f,t,{needBillionMillionUnit:!1}),gasOfMoney:Nt(T,t),symbol:t||""}})??[]}get computedReferredFee(){let{bestRoute:t}=this.quote,{referredNetWorkFee:e,referredAmount:o}=t||{};if(!o||!e)return"";let{computedNowCurrencySymbol:r,currencyConversion:s}=this.commonStore,{from:i}=this.fromToStore;return h("swaptrade_modal_desc_crosschain_valuediff_variavle",{price:`${dt(o)} ${i.tokenSymbol}`,fee:`${Nt(s(e).toString(),r)}`})}get computedIsUsingCentralizedBridge(){let t=["8"],e=String(this.quote.bestRoute?.bridge?.bridgeId);return t.includes(e)}get computedIsNoQuote(){return this.quote.quoteError||this.quote.quoteNull||!this.quote.bestRoute||this.fromToStore.computedFormToTokenIsLeverageToken||this.rootStore.outerStore.computedFeeConfigErrorTips||!this.fromToStore.computedTypedValueIsValid}get computedSupportDappTradeByQuote(){return Number(this.quote?.bestRoute?.isSupportDappTrade)===1}setAggregateFetchStatus(t){return t}setAggregateSelectStatus(t){return t}setAggregateSelectId(t){return t}get computedIsOfflineType(){let{computedIsCrossChain:t}=this.rootStore.fromToStore;return t?Number(this?.quote?.bestRoute?.bridge?.bridgeType)===ls.INTENT_BRIDGE:this?.quote?.bestRoute?.offlineType===us.YES}get computedIsFreeNetworkFee(){return this?.quote?.bestRoute?.bridge?.isFreeNetworkFee===ps.FREE_NETWORK_FEE}get computedIsOkxProvider(){return!this?.quote?.bestRoute?.defiPlatformId||this?.quote?.bestRoute?.defiPlatformId===Z}get computedBridgeIsOkxProvider(){let{defiPlatformId:t}=this?.quote?.bestRoute?.bridge||{};return!t||t===Z}get computedPriceWarn(){let t=I.BigNumber(this?.quote?.bestRoute?.reducePercent),e=I.BigNumber(this?.quote?.bestRoute?.warnPercent);return{show:t&&t.isGreaterThan(e)}}get computedreducePercent(){return Bn(this?.quote?.bestRoute?.reducePercent)}};p();l();P();var Ca=a=>{let{quoteStore:t,swapStore:e}=R();!a&&t.bridgeQuoteSelectStatus!==0&&(t.setBridgeNoRouteTipStatus(e.confirmSwapVisible?2:1),t.setBridgeQuoteSelectStatus(0))},bi=a=>Number(a.commonDexInfo?.code)===pt.CROSS_CHAIN_INTERVAL,Ia=a=>!a.pathSelectionRouterList?.length,Aa=a=>bi(a)||Ia(a),ka=a=>{let{quoteStore:t}=R(),e=bi(a)?{crossMaxAmount:a.commonDexInfo?.crossMaxAmount,crossMiniAmount:a.commonDexInfo?.crossMiniAmount}:null;t.setQuoteScope(e)},_a=a=>{let{quoteStore:t}=R(),e=t.bridgeSelectId===mt?a[0]:a?.find(o=>o.bridge.bridgeId===t.bridgeSelectId);return Ca(e),e||a[0]},Ra=({data:a})=>{let{commonDexInfo:t,singleChainSwapInfo:e,swapType:o,pathSelectionRouterList:r,intentCode:s,isSupportDappTrade:i,offlineType:c,traceData:u}=a||{},m=r?.map((A,L)=>({commonDexInfo:t,...A,...A?.valueDiffInfo,isBest:L===0})),d={intentCode:s,offlineType:c,swapType:o,traceData:u},f={...e,...t,swapType:o,pathSelectionRouterList:m},T=m?.map(A=>({...t,...A,...d,isSupportDappTrade:i}));return{bestRoute:f,combineSelectionRouterList:T}},Ea=a=>{let{quoteStore:t,smartRouterStore:e}=R();if(e.showXRouteModal!==oo.XROUTER)return;let o=a.find(r=>r?.bridge?.bridgeId===t.pickRouter?.bridge?.bridgeId);o&&t.setPickRouter(o)},ba=({isAutoError:a,approveStore:t})=>{if(!a){let{fromToStore:e,accountStore:o,quoteStore:r}=R(),{needApprove:s,defiPlatformId:i,defiPlatformIds:c,allowanceData:u}=j.getApproveInfo(e.computedIsCrossChain,r),m=S(e,"from.chainId");t.bridgePendingNotCheck({token:e.from,userWalletAddress:o.getAddressByChainId(m),needApprove:s,defiPlatformIds:c,defiPlatformId:i,allowanceData:u}).catch(()=>{})}},ya=({bestRoute:a,bridgeInfo:t,isAutoError:e,originData:o,combineSelectionRouterList:r},{fromToStore:s,quoteStore:i})=>{let c=ft({},a,t);i.updateSlippageInfoFetched(c),i.setBridgeSelectId(c?.bridge?.bridgeId),i.setQuote({...i.quote,bestRoute:c,quoteNull:e,quoteError:null,isFetchQuoting:!1}),ka(o),e&&i.setBridgeFetchStatus(3),s.quoteUpdateFromTo(c),s.computedIsCrossChain&&(i.setPathSelectionRouterList(r||[]),Ea(r||[]))},yi=a=>{let{fromToStore:t,quoteStore:e,approveStore:o}=R(),{bestRoute:r,combineSelectionRouterList:s}=Ra({data:a}),i=_a(r.pathSelectionRouterList),c=Aa(a);e.setQuoteNumber(e.quoteNumber+1),ya({bestRoute:r,bridgeInfo:i,isAutoError:c,originData:a,combineSelectionRouterList:s},{fromToStore:t,quoteStore:e}),ba({isAutoError:c,approveStore:o}),ve({isAutoError:c},{quoteStore:e})};var Le=class extends jt{constructor(e){super();this.isEnableBridgeQuoteSearch=!0;this.bridgeListPending=!1;this.bridgeQuoteSelectStatus=0;this.bridgeFetchStatus=0;this.bridgeNoRouteTipStatus=0;this.compareVisible=!1;this.dialogGroupVisibleStatus=1;this.bridgeSortType=0;this.setBridgeSelectId=e=>{this.bridgeSelectId=e};this.setBridgeQuoteSelectStatus=e=>{this.bridgeQuoteSelectStatus=e};this.setBridgeFetchStatus=e=>{this.bridgeFetchStatus=e};this.setBridgeNoRouteTipStatus=e=>{this.bridgeNoRouteTipStatus=e};this.setBridgeList=e=>{this.bridgeList=e};this.setBridgeListPending=e=>{this.bridgeListPending=e};this.setBridgeSortType=e=>{this.bridgeSortType=e};this.setCompareVisible=e=>{this.compareVisible=e};this.setDialogGroupVisibleStatus=e=>{this.dialogGroupVisibleStatus=e};this.getQuoteData=e=>{let o=si();return this.bridgeFetchStatus===0&&this.setBridgeFetchStatus(1),E(ie(()=>k.get(this.getQuoteStoreUrl(),{params:o,signal:e,isolate:!0}).then(r=>(this.setBridgeFetchStatus(2),this.handleUpdateQuote(r),this.setQuoteNumber(this.quoteNumber+1),this.quotePending=!1,r)).catch(r=>{throw y.stuff(r),r}),gt.NUM,gt.TIMER))};this.handleUpdateQuote=e=>{if(e){let{data:o}=e;yi(o)}};this.updateBestRoute=e=>{let o={...this.quote.bestRoute,...e};this.setQuote({...this.quote,bestRoute:o}),this.rootStore.fromToStore?.quoteUpdateFromTo(o)};this.handleQuoteError=(e=null)=>{this.setQuote({...this.initQuote,quoteError:e}),this.handleReverseQuoteErrorAndNull(),this.setBridgeFetchStatus(4)};st(this),Object.assign(this,e),this.rootStore=e}static async getInitialProps(){let[e,o]=await E(k.get(dn));if(e)throw e;return S(o,"data",[])}get bridgeList(){return(this.initialPropsStore.initialProps.bridgeList||[]).map(o=>({...o,platformId:o.chainId,logo:o.logoUrl}))}get computedIsBridgeListLoading(){return Ge()?!this.bridgeList?.length:this.bridgeListPending}async getBridgeList(){this.setBridgeListPending(!0),await E(this.initialPropsStore.getInitialProps({key:"bridgeList",callee:Le})),this.setBridgeListPending(!1)}getQuoteStoreUrl(){return cn}},vi=io(Le);p();l();P();var wa="1",Oa="2",Pi={minValue:.01,maxValue:.5},Li={minValue:.03,maxValue:.5},Xt=class{constructor(t){n(this,"slippageSetting",{autoIsSelected:!1,inputSlippage:"",mode:Bt.DYNAMIC,level:qt.LOW,customMax:""});n(this,"configSingle",Pi);n(this,"configCross",Li);n(this,"inputCache","");n(this,"isFrozen",!1);n(this,"setFrozenInfo",({computedSafeMoonNotSupport:t,isCrossBridgeOnly:e})=>{this.isFrozen=t||e});this.rootStore=t,this.commonStore=t.commonStore,this.fromToStore=t.fromToStore,this.smartRouterStore=t.smartRouterStore,D(this,{},{autoBind:!0})}setInputCache(t){this.inputCache=t}getSafeMoonStore(){return this.rootStore.safeMoonStore}getOrderSlippageInfo(){let{autoIsSelected:t}=this.slippageSetting,e=_t(this.rootStore);return t||this.isFrozen?{maxSlippage:this.computedRealCustomMaxSlippage,autoSlippageInfo:e}:{customSlippage:this.computedRealCustomSlippage,autoSlippageInfo:e}}get isSingleChain(){return this.rootStore.fromToStore.computedIsSingleChain}get minSlippage(){return this.isSingleChain?this.configSingle.minValue:this.configCross.minValue}get maxSlippage(){return this.isSingleChain?this.configSingle.maxValue:this.configCross.maxValue}get minSlippageShow(){return I.mul(this.minSlippage,100)}get maxSlippageShow(){return I.mul(this.maxSlippage,100)}get computedSupportCustomMax(){return S(_t(this.rootStore),"supportMaxSlippage",!1)}get computedFixedSlippageLevelMap(){if(!this.isSingleChain)return null;let t=S(_t(this.rootStore),"shortcutFixSlippage",Object.values(es));return{low:Rt(t[0]),medium:Rt(t[1]),high:Rt(t[2])}}get computedDynamicSlippageLimit(){let t=S(_t(this.rootStore),"dynamicSlippageRangeMin",Te.DYNAMIC_MIN),e=S(_t(this.rootStore),"dynamicSlippageRangeMax",Te.DYNAMIC_MAX),o=S(_t(this.rootStore),"recommendSlippageRangeMin",Te.RECOMMEND_MIN),r=S(_t(this.rootStore),"recommendSlippageRangeMax",Te.RECOMMEND_MAX);return{dynamicMin:Rt(t),dynamicMax:Rt(e),recommendMin:Rt(o),recommendMax:Rt(r)}}get computedAutoSlippage(){let{computedHoneypot:t}=this.getSafeMoonStore();if(t){let e=S(this,"rootStore.quoteStore.quote.bestRoute.realSlippage",0);return I.mul(e,100)}return mo(this.rootStore)}get computedRealCustomSlippage(){let t=S(this,"slippageSetting.inputSlippage","");return t?Ce(t):""}get computedRealCustomMaxSlippage(){let t=S(this,"slippageSetting.customMax","");return t?Ce(t):""}get computedSafeMoonNotSupport(){let{computedHoneypot:t,computedSlippageTips:e}=this.getSafeMoonStore();return!!(t||e?.overLimit||e?.equalLimit)}get computedSafeMoonSlippage(){return this.getSafeMoonStore().computedSlippage}get computedSafeMoonTips(){return this.getSafeMoonStore().computedSlippageTips}get computedSafeMoonTip(){return this.getSafeMoonStore().computedSlippageTips?.tip}get computedSafeMoonPairSlippage(){return this.getSafeMoonStore().computedPairSlippage}get computedSlippageValue(){return this.getSlippageValue()}get computedRealSlippageValue(){let t=this.getSlippageValue();return Number(Ce(t))||0}isValidVolatilityTip(){if(Number(this.computedSlippageValue)>this.computedAutoSlippage)return!1;let t=this.getSafeMoonStore(),e=this.smartRouterStore;return t.computedSafeMoonToken===null&&!e?.isCrossBridgeOnly}get computedVolatilityTips(){if(!this.isValidVolatilityTip())return null;let{computedAutoSlippage:t}=this,e=this.rootStore?.quoteStore?.quote?.bestRoute||{},{priceFluctuationMonitorTime:o,priceFluctuationThreshold:r,fromPriceFluctuation:s,toPriceFluctuation:i,rateFluctuationThreshold:c,slippageFluctuationhold:u,rateFluctuation:m}=e,{from:d,to:f}=this.fromToStore,T=f?.tokenSymbol||"",A=d?.tokenSymbol||"",L=I.mul(u,100),N=I.mul(r,100),et=I.mul(c,100),X=Number(m),ot=Number(c);if(t>L){if(X<ot)return null}else if(t===L){let Q=Math.abs(s),vt=Math.abs(i),ht=Number(r);if(Q>ht&&vt>ht)return{tip:h("swaptrade_placeorder_alert_both_volatility",{payToken:A,receiveToken:T,value:N,min:o}),tipEquation:h("swaptrade_placeorder_alert_both_volatility",{payToken:O(A),receiveToken:O(T),value:N,min:o})};if(Q>ht)return{tip:h("swaptrade_placeorder_alert_pay_receive_volatility",{token:A,value:N,min:o}),tipEquation:h("swaptrade_placeorder_alert_pay_receive_volatility",{token:O(A),value:N,min:o})};if(vt>ht)return{tip:h("swaptrade_placeorder_alert_pay_receive_volatility",{token:T,value:N,min:o}),tipEquation:h("swaptrade_placeorder_alert_pay_receive_volatility",{token:O(T),value:N,min:o})};if(X>=ot)return{tip:h("swaptrade_settings_alert_both_exchange",{payToken:A,receiveToken:T,value:et,min:o}),tipEquation:h("swaptrade_settings_alert_both_exchange",{payToken:O(A),receiveToken:O(T),value:et,min:o})}}return null}getDefaultSetting(){let t={inputSlippage:"",autoIsSelected:!0,mode:Bt.DYNAMIC,level:qt.LOW,customMax:""},e=this.getSafeMoonStore();if(e.computedSafeMoonToken){let o=e.computedSlippage,r=xo(o);e.isChanged&&r&&(t.inputSlippage=r,t.autoIsSelected=!1,t.mode=Bt.FIXED,t.level=qt.CUSTOM,t.customMax="")}return t}getSlippageType(){return this.slippageSetting.autoIsSelected||this.isFrozen?xt.AUTO:xt.CUSTOM}getSlippageValue(t=this.slippageSetting){let{autoIsSelected:e,inputSlippage:o}=t;return e||this.isFrozen?this.computedAutoSlippage:o||this.computedAutoSlippage}setSlippageSetting(t){let e={...t},o=this.getSafeMoonStore(),{computedSafeMoonToken:r}=o;if(!r){this.slippageSetting=e;return}let s=this.getSlippageValue(e);if(s===this.getSlippageValue(this.slippageSetting)||o.isAccessSlippage(s)||!o.getSafemoonIsChangedLocal()){e.inputSlippage="",e.autoIsSelected=!0,e.mode=Bt.DYNAMIC,e.level=qt.LOW;let i=xo(s);o.isChanged&&i&&(e.inputSlippage=i,e.autoIsSelected=!1,e.mode=Bt.FIXED,e.level=qt.CUSTOM,e.customMax=""),o.setSafeMoonPairSlippage(s),this.slippageSetting=e}}async initSlippageConfigs(){try{let{data:t}=await k.get(An),e=t?.find(({configId:r})=>wa===r),o=t?.find(({configId:r})=>Oa===r);e&&(this.configSingle=e),o&&(this.configCross=o)}catch{this.configSingle=Pi,this.configCross=Li}}initSlippageSetting(){let t=this.getDefaultSetting(),e;t?e={...t}:e={autoIsSelected:!0,inputSlippage:"",mode:Bt.DYNAMIC,level:qt.LOW,customMax:""},this.setSlippageSetting(e)}initReactions(){Ct(()=>{let{from:t,to:e}=this.fromToStore;return{chainId:t.chainId,toChainId:e.chainId,fromTokenAddress:t.tokenContractAddress,toTokenAddress:e.tokenContractAddress}},({fromTokenAddress:t,toTokenAddress:e})=>t&&e?(this.rootStore.quoteStore.slippageInfoFetched=!1,this.initSlippageSetting()):!1,{equals:Ue.shallow}),Ct(()=>{let{computedSafeMoonPairSlippage:t}=this;return{computedSafeMoonPairSlippage:t}},()=>{this.initSlippageSetting()},{equals:Ue.shallow}),Ct(()=>{let{quote:t}=this.rootStore.quoteStore,e=S(t,"bestRoute.smartRoutingMenuVoList"),o=S(e,[0,"smartRoutingMenuType"]),r=e&&e.length===1&&o===Rs.BRIDGE,{computedSafeMoonNotSupport:s}=this;return{computedSafeMoonNotSupport:s,isCrossBridgeOnly:r}},this.setFrozenInfo,{equals:Ue.shallow})}get computedMinimumReceived(){let{quote:t,computedIsOfflineType:e}=this.rootStore.quoteStore,{receiveAmount:o,minimumReceived:r}=t?.bestRoute||{},s=this.fromToStore.to?.tokenSymbol;if(!Se(o))return"--";let i=this.inputCache?Ce(this.inputCache):this.computedRealSlippageValue,c=e?r:I.mul(o,1-(Se(i)?i:0));return I.BigNumber(c).lte(0)?"--":`${dt(c,{needBillionMillionUnit:!1})} ${s}`}get computedMinimumReceivedIsOrange(){let{quote:t}=this.rootStore.quoteStore,e=this.computedMinimumReceived,o=t?.bestRoute?.receiveAmount,r=I.BigNumber(o);return!r.isZero()&&!r.isNaN()&&I.div(I.sub(r,e),r)>=.1}};p();l();P();var Ar=class{constructor(t){n(this,"checkCrossChainParams",()=>{let{quoteStore:t,receiveAddressStore:e}=this.rootStore,{quote:o}=t,r=this.checkCommonParams(),{receiveAddrObj:s}=e,i=S(o.bestRoute,"quoteNetWorkFeeOfMoney"),c=o?.bestRoute?.bridge?.bridgeId,u=s?.specifiedAddress;return{...r,fromSwapFeeUsd:i,bridgeId:c,receiveWalletAddress:u}});n(this,"checkCommonParams",()=>{let{accountStore:t,fromToStore:e,quoteStore:o}=this.rootStore,{from:r,to:s}=e;return{fromChainId:r.chainId,fromTokenAddress:r.tokenContractAddress,amount:o?.computedQuoteAmount,toChainId:s.chainId,toTokenAddress:s.tokenContractAddress,userWalletAddress:t.address,accountId:t.computedAccountId}});n(this,"repeatOrder",null);n(this,"checkRepeatOrder",async()=>{this.repeatOrder=null;let{fromChainId:t,...e}=this.checkCommonParams(),{quoteStore:{quote:o}}=this.rootStore,r=S(o.bestRoute,"fromSwapFeeUsd"),s={...e,chainId:t,fromSwapFeeUsd:r},[i,c]=await E(k.get(hn,{params:s}));!i&&[wt.COMMON_REPEAT,wt.BTC_REPEAT,wt.FACET_REPEAT].includes(c?.data.repeatFlag)&&St(()=>{let{orderId:u,enoughFlag:m}=c?.data??{};this.repeatOrder={enoughFlag:m,repeatFlag:c?.data.repeatFlag,id:u}})});n(this,"checkSwapMoreInfo",null);n(this,"checkCrossChainSwap",async()=>{this.checkSwapMoreInfo=null;let t=this.checkCrossChainParams(),[e,o]=await E(k.post(fn,{...t}));e||St(()=>{this.checkSwapMoreInfo=o?.data})});D(this),this.rootStore=t}},Do=Ar;p();l();var $t=class{constructor(t){n(this,"swapOnDappBtnLoading",!1);n(this,"setSwapOnDappBtnLoading",t=>{this.swapOnDappBtnLoading=t});n(this,"dappPanelVisible",!1);n(this,"setDappPanelVisible",t=>{this.dappPanelVisible=t});n(this,"showDappPanel",()=>{this.setSwapOnDappBtnLoading(!0),this.setDappPanelVisible(!0)});n(this,"hideDappPanel",()=>{this.setSwapOnDappBtnLoading(!1),this.setDappPanelVisible(!1)});n(this,"getSupportDetail",(t={},e=!1)=>{let o=this.chainIsSupportMarket(t),r=this.chainIsSupportDappTrade(t),s=!!this.quoteStore?.computedSupportDappTradeByQuote,i=!o&&r,c=o&&r,u=o&&!r;return{chainSupportMarket:o,chainSupportDappTrade:r,quoteSupportDappTrade:s,balance:c||u,kline:c||u,klineJumpMarket:c||u,costValue:e&&c||u,valueDifference:u,liquidity:u,disableInput:i||c,showMax:u,showAddFund:u}});n(this,"mergeCurrencyInputProps",(t,e)=>({balanceStatus:e.balance?t.balanceStatus:Xe.BALANCE_NOT_SHOW,costValue:e.costValue?t.costValue:"",valueDifference:e.valueDifference?t.valueDifference:{},disableInput:e.disableInput,showMax:e.showMax?t.showMax:!1,showMaxIcon:e.showMax?t.showMaxIcon:!1,showAddFund:e.showAddFund?t.showAddFund:!1}));n(this,"getCurrentFromToChainConfig",()=>{let t=this.fromToStore.from.chainId,e=this.fromToStore.to.chainId,o=this.commonStore.getChainByID(t),r=this.commonStore.getChainByID(e);return[o,r]});n(this,"chainIsSupportMarket",t=>Number(t?.isSupportMarket)===1);n(this,"chainIsSupportDappTrade",t=>Number(t?.isSupportDappTrade)===1);n(this,"bridgeSupportDappTrade",t=>Number(t?.supportLinkDapp)===1);n(this,"getSupportDappTradeByToken",()=>{let t=this.quoteStore?.computedSupportDappTradeByQuote,e=lo?.computedIsSelectedAllDex;return this.fromToStore.computedIsSingleChain&&t&&e});n(this,"checkShouldJumpToDapp",()=>this.fromToStore.computedFormToTokenIsLeverageToken?!1:this.computedSupportDappTradeByChain?!0:this.getSupportDappTradeByToken());this.rootStore=t,this.commonStore=t.commonStore,this.fromToStore=t.fromToStore,this.quoteStore=t.quoteStore,D(this,{},{autoBind:!0})}get computedFromToSupportMarketAndDappTrade(){let[t,e]=this.getCurrentFromToChainConfig();return{from:{...this.getSupportDetail(t,!0)},to:{...this.getSupportDetail(e)}}}get computedFromToSupportMarket(){let[t,e]=this.getCurrentFromToChainConfig();return this.chainIsSupportMarket(t)&&this.chainIsSupportMarket(e)}get computedSupportDappTradeByChain(){let t=this.fromToStore.from.chainId,e=this.fromToStore.to.chainId,o=this.commonStore.getChainByID(t);if(this.fromToStore.computedIsSingleChain)return this.chainIsSupportDappTrade(o);let r=o?.bridgeSupportChainInfoList,s=Array.isArray(r)&&r.find(i=>Number(i.chainId)===Number(e));return this.bridgeSupportDappTrade(s)}};var ce=class extends Vt{constructor(){super();n(this,"reset",()=>{this.receiveAddressStore=new uo(this),this.outerStore=new No(this),this.fromToStore=new co(this),this.approveStore=new Wt(this),this.quoteStore=new vi(this),this.tokenModalStore=new Lo(this),this.safeMoonStore=new Kt(this),this.walletContractStore=new yo(this),this.sendTransactionStore=new po(this),this.intentSwapStore=new vo(this),this.swapCheckStore=new Do(this),this.swapStore=new ho(this),this.swapBtnStore=new Ht(this),this.mevStore=new Oo(this),this.recentTransactionStore=new To(this),this.facetStore=new Co(this),this.swapDappStore=new $t(this),this.smartRouterStore=new ko(this),this.slippageStore=new Xt(this),this.oneMoreOrderStore=new Io(this),this.gasDropStore=new wo});this.reset()}},we=ce;n(we,"instance",null),n(we,"getInstance",()=>(ce.instance||(ce.instance=new ce),ce.instance));var Oi=we;p();l();p();l();var Fo=class extends Yt{constructor(t){super(t),st(this)}getSearchParams(t){return this.singleSearchParams(t)}};p();l();P();p();l();P();var Na=a=>{let{quoteStore:t,swapStore:e}=R();!a&&t.aggregateSelectStatus!==0&&(t.setAggregateNoRouteTipStatus(e.confirmSwapVisible?2:1),t.setAggregateSelectStatus(0))},Da=a=>{let{quoteStore:t}=R(),e=t.aggregateSelectId===mt?a[0]:a.find(r=>r.defiPlatformId===t.aggregateSelectId),o=S(a.find(r=>r.defiPlatformId===Z),"dexRouterList",[]);return Na(e),ft({},e||a[0],{dexRouterList:o})},Fa=({data:a,isCompareResult:t})=>{let{commonDexInfo:e,singleChainSwapInfo:o,swapType:r,isSupportDappTrade:s,defiPlatformInfoList:i,traceData:c}=a,u=i.map((d,f)=>({...d,isBest:f===0}));return{bestRoute:{...o,...e,isSupportDappTrade:t?s:"0",swapType:r,defiPlatformInfoList:u,traceData:c}}},Ma=({bestRoute:a,aggregateInfo:t,isAutoError:e},{fromToStore:o,quoteStore:r})=>{let s=ft({},a,t);r.updateSlippageInfoFetched(s),r.setAggregateSelectId(s.defiPlatformId),r.setQuote({...r.quote,bestRoute:s,quoteNull:e,quoteError:null,isFetchQuoting:!1}),e&&r.setAggregateFetchStatus(4),o.quoteUpdateFromTo(s)},xa=a=>{let{solanaPriorityFeeStore:t}=R();t&&a?.jitoData&&t.setJitoData(a?.jitoData)},Ni=a=>{let{fromToStore:t,quoteStore:e,approveStore:o}=R(),r=e.aggregateFetchStatus===3,{bestRoute:s}=Fa({data:a,isCompareResult:r}),i=Da(s.defiPlatformInfoList),c=r&&s.defiPlatformInfoList.length===0;e.setQuoteNumber(e.quoteNumber+1),Ma({bestRoute:s,aggregateInfo:i,isAutoError:c},{fromToStore:t,quoteStore:e}),xa(a),Cr({isAutoError:c},{approveStore:o}),ve({isAutoError:c},{quoteStore:e})};var Oe=class extends jt{constructor(e){super();this.enableQuoteAggregates=!0;this.setAggregateSelectId=e=>{this.aggregateSelectId=e};this.aggregateSelectStatus=0;this.setAggregateSelectStatus=e=>{this.aggregateSelectStatus=e};this.aggregateFetchStatus=0;this.setAggregateFetchStatus=e=>{this.aggregateFetchStatus=e};this.fetchOKXQuote=({params:e,signal:o})=>{this.aggregateFetchStatus!==3&&k.get(this.outerStore.aggregatorQuoteUrl(),{params:ft({},e,{defiPlatformIds:Z}),signal:o}).then(r=>{this.aggregateFetchStatus===1&&(this.setAggregateFetchStatus(2),this.handleUpdateQuote(r),this.setQuoteNumber(this.quoteNumber+1),this.quotePending=!1)}).catch(r=>{y.stuff(r)})};this.getQuoteData=e=>{let o=at();return this.fetchOKXQuote({params:o,signal:e}),E(ie(()=>this.fetchAggregatesQuote({params:o,signal:e}),gt.NUM,gt.TIMER))};this.handleUpdateQuote=e=>{if(e){let{data:o}=e;Ni(o)}};this.updateBestRoute=e=>{let o={...this.quote.bestRoute,...e};this.setQuote({...this.quote,bestRoute:o}),this.rootStore.fromToStore?.quoteUpdateFromTo(o)};this.aggregateNoRouteTipStatus=0;this.setAggregateNoRouteTipStatus=e=>{this.aggregateNoRouteTipStatus=e};this.handleQuoteError=(e=null)=>{this.setQuote({...this.initQuote,quoteError:e}),this.handleReverseQuoteErrorAndNull(),this.setAggregateFetchStatus(5)};this.aggregatorListPending=!1;this.setAggregatorListPending=e=>{this.aggregatorListPending=e};this.fetchAggregatorList=async()=>{this.setAggregatorListPending(!0),await E(this.initialPropsStore.getInitialProps({key:"aggregatorList",callee:Oe})),this.setAggregatorListPending(!1)};this.compareVisible=!1;this.setCompareVisible=e=>{this.compareVisible=e};this.dialogGroupVisibleStatus=1;this.setDialogGroupVisibleStatus=e=>{this.dialogGroupVisibleStatus=e};st(this),Object.assign(this,e),this.rootStore=e}static async getInitialProps(){let[e,o]=await E(k.get(pn));if(e)throw e;return S(o,"data",[])}fetchAggregatesQuote({params:e,signal:o}){return k.get(this.outerStore.aggregatorQuoteUrl(),{params:e,signal:o,isolate:!0}).then(r=>(this.aggregateFetchStatus===2&&this.setAggregateSelectId(mt),this.setAggregateFetchStatus(3),r))}get aggregatorList(){return this.initialPropsStore.initialProps.aggregatorList||[]}get computedIsAggregatorListLoading(){return Ge()?!this.aggregatorList?.length:this.aggregatorListPending}},Di=io(Oe);p();l();p();l();P();var kr=a=>{if(!a)return[];let{solPrice:t,solTokenSymbol:e,solDecimals:o}=a;return er.map(r=>({type:r,fee:a[`${r}Fee`],usd:a[`${r}FeeUsd`],solPrice:t,solTokenSymbol:e,solDecimals:o}))},Fi=a=>{let t={},e=Me(kr(a),"type");return yr(er).forEach(o=>{t[o]={amount:e[o]?.fee||"",price:e[o]?.usd||""}}),t};var _r=class{constructor(t){n(this,"visible",!1);n(this,"setVisible",t=>{this.visible=t});n(this,"feeType",tr.MARKET);n(this,"setFeeType",t=>{this.feeType=t});n(this,"customFee",null);n(this,"setCustomFee",t=>{this.customFee=t});n(this,"jitoData",null);n(this,"setJitoData",t=>{this.jitoData=t});this.rootStore=t,st(this)}get computedPriorityFeeList(){return kr(this.jitoData)}get computedPriorityFeeMap(){return Fi(this.jitoData)}get computedPriorityFeeAmount(){return this.jitoData?this.feeType===tr.CUSTOM?this.customFee:this.computedPriorityFeeList.find(e=>e.type===this.feeType)?.fee:null}get computedPriorityFeeOfUsd(){if(!this.jitoData)return null;let{solPrice:t}=this.jitoData;return I.mul(this.computedPriorityFeeAmount,t,{returnString:!0})}},Mi=_r;var ue=class extends Vt{constructor(){super();n(this,"reset",()=>{this.receiveAddressStore=new uo(this),this.outerStore=new No(this),this.fromToStore=new co(this),this.approveStore=new Wt(this),this.quoteStore=new Di(this),this.tokenModalStore=new Fo(this),this.safeMoonStore=new Kt(this),this.walletContractStore=new yo(this),this.sendTransactionStore=new po(this),this.intentSwapStore=new vo(this),this.swapCheckStore=new Do(this),this.swapStore=new ho(this),this.swapBtnStore=new Ht(this),this.solanaPriorityFeeStore=new Mi(this),this.mevStore=new Oo(this),this.recentTransactionStore=new To(this),this.facetStore=new Co(this),this.swapDappStore=new $t(this),this.smartRouterStore=new ko(this),this.slippageStore=new Xt(this),this.oneMoreOrderStore=new Io(this)});this.reset()}},Ne=ue;n(Ne,"instance",null),n(Ne,"getInstance",()=>(ue.instance||(ue.instance=new ue),ue.instance));var xi=Ne;var Ba=({localeData:a,...t})=>{Es();let e=(0,Bi.useLocation)(),o;return e.pathname.includes(tt)?o=w.BRIDGE:e.pathname.includes(Kr)?o=w.LIMIT_ORDER:e.pathname===H&&(o=w.SWAP),Mo.default.createElement(Fn,{localeData:a,isDev:!0,noRemoteData:!0,customRender:r=>r},Mo.default.createElement(vs,{swapRootStore:xi,bridgeRootStore:Oi,initTab:o},Mo.default.createElement(ri,{currentTab:o,...t})))},qC=ut(Ba);export{qC as default};
window.inOKXExtension = true;
window.inMiniApp = false;
window.ASSETS_BUILD_TYPE = "publish";
//# sourceMappingURL=Advanced-OLP3WL2W.js.map