PageSourceSearch

https://debot.ai/assets/2.2.202/BridgePageClient-PpTt55-t.js

js debot.ai collected 2026-10-05 11:56:47 UTC 27,029 bytes, 1 lines download raw bytes

1import{r as t,ex as ge,j as e,R as ft}from"./vendor-Rj1RSOnu.js";import{b as Tt,a as St,B as vt}from"./BridgeInfo-BHqyYxRg.js";import{u as Se,ac as he,ad as ve,Z as Et,_ as Ct,a8 as bt,$ as Be,ae as Ne,aa as mt}from"./index-HNKnsEb_.js";import{i as me}from"./type-WGtdEErS.js";import{f as It}from"./fetchWithStream-BYzpM5QK.js";import{u as Bt}from"./useMobile-n5ssPt5t.js";import{u as Rt}from"./useTradeError-Beqd8_4D.js";import{u as $e}from"./vendor-react-query-B2wLbHiI.js";import{L as De}from"./link-CfaSn0FG.js";import{b as jt,a as kt}from"./navigation-BFFxuWTV.js";import{u as Lt}from"./index-ptIgEM4A.js";import{S as yt}from"./transfer-ksrMICkd.js";import{P as Ot}from"./PageContainer--7x7LbOi.js";import{P as At}from"./ProDialog-_IoxeTVr.js";import{N as wt}from"./NeedLogin-DdWI0cpn.js";import{P as Mt}from"./PrimaryButton-BZhXV7FU.js";import{u as Je}from"./useBalanceNew-DbJLdKaH.js";import{u as Wt}from"./useDebounceFn-iF3-ibGR.js";import{S as Qe}from"./wallet_icon-CVeZT4Ez.js";import{W as Re}from"./WalletAddressWidget-CsdMD0i-.js";import{n as Nt}from"./utils-DJckle50.js";import{s as Dt,g as Xt,a as Ut,i as Xe,p as Pt}from"./dexSwapBalanceUtils-Dof1JJSV.js";import{W as Ft}from"./WalletAvatarWithEmoji-cfRWUFMX.js";import{W as Gt}from"./WalletVersionBadge-2SB2MnA-.js";import{M as zt,a as c,z as Ze,d as ae,S as v,H as Yt,i as et,T as tt}from"./vendor-mui-D9GkDIbn.js";import{f as Vt,p as Ht}from"./vendor-web3-evm-GIbWFb1m.js";import{U as ot,T as Kt,b as Ue}from"./vendor-tabler-icons-BafU9BTd.js";import{u as qt}from"./useClientDevice-BVs0XmB9.js";import"./vendor-dnd-Cop8zEK3.js";import"./vendor-web3-sol-FaBCTGTu.js";import"./vendor-dt-design-BfOjlafk.js";import"./vendor-radix-gr_Omi-V.js";import"./useConfig-9zlgd27j.js";import"./Scrollbar-Dr3ZOSBJ.js";import"./usePageHeight-BJm6hDS4.js";import"./LoginButton-DW26hs0h.js";import"./AuthDialog-DmLUV6QG.js";import"./api-DGWucP16.js";import"./CustomCheckbox-BegDgS95.js";import"./CustomFormLabel-BIWpRJDP.js";import"./CustomTextField-ZXRiYFoX.js";import"./passkeyWebAuthn-DVt0ukHG.js";import"./DTLoadingButton-DZV3Bpp7.js";import"./api-D2_p68Ma.js";import"./TableBodyDataFontContext-DVv2al_H.js";import"./CustomSwapInput-Ozss2EE6.js";import"./edit-pencil-C3cGZiIt.js";import"./EtherscanTxIcon-Be6xEyg4.js";import"./vendor-emoji-CYAM8b89.js";import"./WalletIcon-Bxn68Cf3.js";import"./blockieCache-C8CJ9ktH.js";const $t=n=>t.createElement("svg",{width:92,height:60,viewBox:"0 0 92 60",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},t.createElement("circle",{cx:45,cy:31,r:29,fill:"#00A870",fillOpacity:.12}),t.createElement("circle",{cx:45,cy:31,r:20,fill:"#00A870"}),t.createElement("path",{d:"M35 30.2016L42.2 37.4016L55 24.6016",stroke:"white",strokeWidth:4}),t.createElement("path",{d:"M74 6H86",stroke:"#00A870",strokeWidth:2}),t.createElement("path",{d:"M80 12L80 0",stroke:"#00A870",strokeWidth:2}),t.createElement("path",{d:"M0 54H12",stroke:"#00A870",strokeWidth:2}),t.createElement("path",{d:"M6 60L6 48",stroke:"#00A870",strokeWidth:2}),t.createElement("path",{d:"M86 15H92",stroke:"#00A870",strokeWidth:1.2}),t.createElement("path",{d:"M89 18L89 12",stroke:"#00A870",strokeWidth:1.2})),Jt={width:600,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",backgroundColor:"var(--bg-page-popover)",backgroundImage:"none",border:"1px solid var(--border-default)",boxShadow:"none"},Qt={disablePadding:!0,sx:{backgroundColor:"var(--bg-page-popover)"}},Zt={sx:Jt},eo={display:"flex",width:"100%",height:"min(400px, calc(100vh - 64px))",minHeight:280,minWidth:0},to={width:"clamp(104px, 28vw, 150px)",flexShrink:0,overflowY:"auto",borderRight:"1px solid var(--border-muted)"},oo={minHeight:42,px:1.5,py:1,gap:1,borderRadius:0,color:"var(--text-tertiary)",backgroundColor:"var(--bg-page-popover)","&:hover":{color:"var(--text-primary)",backgroundColor:"var(--bg-page-popover-hover)"},"&.Mui-selected":{color:"var(--text-primary)",backgroundColor:"var(--bg-page-popover-component-selected)"},"&.Mui-selected:hover":{backgroundColor:"var(--bg-page-popover-component-selected)"}},no={minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},ro={minWidth:0,flex:1,overflowY:"auto"},so={height:"100%",display:"flex",alignItems:"center",justifyContent:"center",px:2,color:"var(--text-tertiary)",fontSize:14,textAlign:"center"},io={height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-tertiary)"},lo={borderRadius:0,px:1.5,py:1,width:"100%",boxSizing:"border-box",backgroundColor:"var(--bg-page-popover)","&:hover":{backgroundColor:"var(--bg-page-popover-hover)"}},co={width:"100%",minWidth:0,flexWrap:"nowrap"},ao={minWidth:0,flex:1,overflow:"hidden",flexWrap:"nowrap"},uo={minWidth:0,overflow:"hidden"},ho={ml:"0 !important",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},xo={flexShrink:0,color:"var(--text-tertiary)",fontSize:12,whiteSpace:"nowrap"},go={minWidth:0,ml:"auto",flexShrink:1,flexWrap:"nowrap",overflow:"hidden"},nt={color:"var(--text-tertiary)",fontSize:12,fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap",minWidth:0,flexShrink:1},_o={...nt,color:"var(--text-primary)"},po={minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},fo=t.memo(function({chainItem:r,label:d,selected:E,onSelect:u}){const j=t.useCallback(()=>{u(r.value)},[r.value,u]);return e.jsxs(ae,{selected:E,onClick:j,sx:oo,children:[e.jsx(r.Icon,{width:16,height:16}),e.jsx(c,{component:"span",title:d,sx:no,children:d})]})}),Pe=t.memo(function({Icon:r,value:d,symbol:E,active:u}){return e.jsxs(v,{direction:"row",alignItems:"center",gap:.5,sx:u?_o:nt,children:[e.jsx(r,{width:12,height:12}),e.jsxs(c,{component:"span",title:`${d} ${E}`,sx:po,children:[d," ",E]})]})});function Fe(n,r){return Number(Vt(Pt(n),r)).toFixed(3)}const To=t.memo(function({item:r,chainItem:d,onSelect:E}){const{t:u}=ge(),j=Xt(r),L=Ut(r),B=ve(r.chain),k=!!Et(r.wallet).remark,m=Ct(r.wallet),x=t.useCallback(()=>{E(r.wallet,r.chain)},[r.chain,r.wallet,E]);return e.jsx(ae,{onClick:x,sx:lo,children:e.jsxs(v,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1,sx:co,children:[e.jsxs(v,{direction:"row",alignItems:"center",gap:1,sx:ao,children:[e.jsx(Ft,{showChain:!0,address:r.wallet,chain:r.chain,size:20}),e.jsx(c,{sx:uo,children:e.jsx(Re,{address:r.wallet,editable:!1,sx:ho,noRemarkColor:"var(--text-primary)"})}),k&&e.jsx(c,{component:"span",title:r.wallet,sx:xo,children:m}),e.jsx(Gt,{version:r.version})]}),e.jsxs(v,{direction:"row",alignItems:"center",justifyContent:"flex-end",gap:1.5,sx:go,
1children:[e.jsx(Pe,{Icon:d.CoinIcon,value:Fe(j.balance,j.decimals),symbol:d.coin,active:Xe(j)}),d.usdc&&e.jsx(Pe,{Icon:d.UsdcIcon,value:Fe(L.balance,L.decimals),symbol:B,active:Xe(L)})]})]})})});function rt({anchorEl:n,setAnchorEl:r,setWallet:d,filterChain:E,currentChain:u,onlyV3Wallets:j=!1}){var s;const{t:L}=ge(),B=Se(a=>a.userPostsReducer.isLogin),[g,k]=t.useState(((s=he[0])==null?void 0:s.value)??"solana"),m=t.useMemo(()=>he.filter(a=>!E||a.value!==E),[E]),x=t.useMemo(()=>m.find(a=>a.value===g),[m,g]),{data:y,isFetching:H}=$e({queryKey:["unifiedBalance",g],queryFn:()=>bt({chains:[g],get_balance:!0,get_usd:!0}),enabled:B&&!!n&&!!x}),l=t.useMemo(()=>{if(!n)return[];const a=((y==null?void 0:y.list)??[]).filter(b=>b.chain===g&&(!j||me(b.version)));return Dt(a)},[n,y==null?void 0:y.list,j,g]);t.useEffect(()=>{var a;if(!n){if(u&&m.some(b=>b.value===u)){k(u);return}m.some(b=>b.value===g)||k(((a=m[0])==null?void 0:a.value)??"")}},[n,m,u,g]);const F=t.useCallback(a=>{k(a)},[]),K=t.useCallback((a,b)=>{d(a,b),r(null)},[r,d]),q=t.useCallback(()=>{r(null)},[r]);return e.jsx(zt,{open:!!n,anchorEl:n,onClose:q,PaperProps:Zt,MenuListProps:Qt,children:e.jsxs(c,{sx:eo,children:[e.jsx(c,{sx:to,children:m.map(a=>e.jsx(fo,{chainItem:a,label:a.title,selected:g===a.value,onSelect:F},a.value))}),e.jsx(c,{sx:ro,children:H&&l.length===0?e.jsx(c,{sx:io,children:e.jsx(Ze,{size:20,color:"inherit"})}):l.length===0?e.jsx(c,{sx:so,children:L("NoWalletOnChain",{chain:(x==null?void 0:x.title)??g})}):l.map(a=>x?e.jsx(To,{item:a,chainItem:x,onSelect:K},`${a.chain}_${a.wallet}`):null)})]})})}const So={fontSize:n=>n.typography.subtitle1,color:"var(--text-tertiary)"},vo={fontSize:n=>n.typography.subtitle1},Eo={color:"var(--text-tertiary)"},Co={height:"12px"},bo={borderColor:"var(--border-subtle)"},mo={display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:"32px",height:"20px"},Io={color:"var(--text-brand)",lineHeight:1},Bo={display:"inline-flex",alignItems:"center",justifyContent:"center",width:"14px",height:"14px"},Ro={fontSize:"16px",fontWeight:600},jo={minWidth:128,backgroundColor:"var(--bg-page-component)","& .MuiSelect-select":{display:"flex",alignItems:"center",gap:"8px",py:"4px",pl:"8px",pr:"28px!important"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--border-default)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--border-default)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--border-default)"},"& .MuiSvgIcon-root":{color:"var(--text-tertiary)"}},Ce={display:"flex",alignItems:"center",gap:"8px"},Ge={"&:hover":{backgroundColor:"var(--bg-dialog-hover)"},"&.Mui-selected":{backgroundColor:"var(--bg-dialog-hover)"},"&.Mui-selected:hover":{backgroundColor:"var(--bg-dialog-hover)"}},ko={PaperProps:{sx:{mt:1,border:"1px solid var(--border-default)",backgroundColor:"var(--bg-dialog)",backgroundImage:"none",boxShadow:"var(--dialog-shadow)"}},MenuListProps:{sx:{py:.5,backgroundColor:"var(--bg-dialog)"}}},Lo={mb:1.5,"& .MuiInputBase-root":{height:"unset"},"& .MuiInputBase-input":{textAlign:"right",fontSize:"16px!important",px:0},"& .MuiOutlinedInput-notchedOutline":{border:"none"}},yo={width:"100%",height:"140px",borderRadius:"12px",padding:"24px 20px",boxSizing:"border-box"},Oo={border:"1px solid var(--border-default)",backgroundColor:"var(--bg-surface)"},Ao={border:"1px solid var(--error)",backgroundColor:"var(--bg-surface)"},wo={fontSize:n=>n.typography.subtitle1},Mo={color:"var(--error)"},Wo={color:"var(--text-tertiary)"},No=ft.forwardRef(function({fromChain:r,fromWallet:d,toChain:E,excludeDestinationChain:u=!1,setFromWallet:j,onSetMax:L,isMaxLoading:B=!1,value:g,onChange:k,minBridgeValueUsd:m,baseTokenPriceUsd:x,onError:y,inputAmountUsd:H,bridgeToken:l,onBridgeTokenChange:F,tokenAddress:K,tokenSymbol:q},s){const{t:a}=ge(),[b,W]=t.useState(null),[N,T]=t.useState(null),[A,Q]=t.useState(g);t.useImperativeHandle(s,()=>({verify:()=>{_(),G()}}));const f=t.useMemo(()=>he.find(h=>h.value===r),[r]),_e=Be(r)&&!!(f!=null&&f.usdc),D=t.useMemo(()=>ve(r),[r]),{balance:X,balanceOriginal:U}=Je({address:d,chain:r,token:K}),_=t.useCallback(()=>A&&U<Number(A)?(T(a("NotEnoughBalance")),!1):(T(""),!0),[U,a,A]),G=t.useCallback(()=>_()?(T(""),!0):!1,[_]),de=t.useCallback(()=>{B||L()},[B,L]),$=t.useCallback(h=>e.jsxs(c,{style:Ce,children:[h==="usdc"?f!=null&&f.UsdcIcon?e.jsx(f.UsdcIcon,{width:24,height:24}):e.jsx(c,{width:24,height:24}):f!=null&&f.CoinIcon?e.jsx(f.CoinIcon,{width:24,height:24}):e.jsx(c,{width:24,height:24}),h==="usdc"?D:(f==null?void 0:f.coin)??"Native"]}),[f,D]),re=t.useCallback(h=>{F(h.target.value)},[F]),Z=t.useCallback(async()=>
1{if(_(),!A||!Number(A)){await k("");return}const h=Nt(A);await k(h)},[k,_,A]),{run:se}=Wt(Z,500);t.useEffect(()=>{U&&se()},[U,se]),t.useEffect(()=>{G()},[G]),t.useEffect(()=>{g&&Q(g)},[g]),t.useEffect(()=>{y(N)},[N,y]);const pe=t.useMemo(()=>e.jsxs(e.Fragment,{children:[e.jsxs(v,{direction:"row",justifyContent:"space-between",mb:3,children:[e.jsxs(v,{direction:"row",alignItems:"center",gap:1,children:[e.jsx(c,{sx:So,children:a("From")}),e.jsxs(v,{direction:"row",alignItems:"center",gap:.5,className:"cursor-pointer",onClick:h=>{W(h.currentTarget)},children:[e.jsx(Qe,{color:"var(--text-primary)"}),e.jsx(Re,{address:d,editable:!1}),e.jsx(ot,{color:"var(--text-tertiary)",size:12})]})]}),e.jsxs(v,{direction:"row",alignItems:"center",sx:vo,gap:"6px",children:[e.jsxs(c,{sx:Eo,children:[a("Balance"),":"]}),X," ",q,e.jsx(Yt,{orientation:"vertical",style:Co,sx:bo}),e.jsx(c,{className:B?"":"cursor-pointer",style:mo,sx:Io,onClick:de,children:B?e.jsx(c,{style:Bo,children:e.jsx(Ze,{size:14})}):"Max"})]})]}),e.jsxs(v,{direction:"row",alignItems:"center",justifyContent:"space-between",children:[e.jsx(v,{direction:"row",alignItems:"center",gap:1,style:Ro,children:e.jsxs(et,{size:"small",value:l,onChange:re,renderValue:$,MenuProps:ko,sx:jo,children:[e.jsx(ae,{value:"native",sx:Ge,children:e.jsxs(c,{style:Ce,children:[f!=null&&f.CoinIcon?e.jsx(f.CoinIcon,{width:24,height:24}):e.jsx(c,{width:24,height:24}),(f==null?void 0:f.coin)??"Native"]})}),_e&&e.jsx(ae,{value:"usdc",sx:Ge,children:e.jsxs(c,{style:Ce,children:[f!=null&&f.UsdcIcon?e.jsx(f.UsdcIcon,{width:24,height:24}):e.jsx(c,{width:24,height:24}),D]})})]})}),e.jsx(tt,{value:A,onChange:h=>{Q(h.target.value),se()},placeholder:"0.00",sx:Lo})]})]}),[X,se,d,de,re,B,f,l,$,D,_e,a,q,A]);return e.jsxs(e.Fragment,{children:[e.jsxs(v,{style:yo,sx:N?Ao:Oo,children:[pe,e.jsx(v,{direction:"row",justifyContent:"flex-end",sx:wo,children:N?e.jsx(c,{sx:Mo,children:N}):!!H&&e.jsxs(c,{sx:Wo,children:["≈$",H]})})]}),e.jsx(rt,{anchorEl:b,setAnchorEl:W,setWallet:j,filterChain:u?E:void 0,currentChain:r})]})}),Do={width:"100%",height:"140px",borderRadius:"12px",padding:"24px 20px",boxSizing:"border-box"},Xo={border:"1px solid var(--border-default)",backgroundColor:"var(--bg-surface)"},Uo={fontSize:n=>n.typography.subtitle1,color:"var(--text-tertiary)"},Po={fontSize:n=>n.typography.subtitle1},Fo={color:"var(--text-tertiary)"},Go={fontSize:"16px",fontWeight:600},zo={minWidth:128,backgroundColor:"var(--bg-page-component)","& .MuiSelect-select":{display:"flex",alignItems:"center",gap:"8px",py:"4px",pl:"8px",pr:"28px!important"},"& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--border-default)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--border-default)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--border-default)"},"& .MuiSvgIcon-root":{color:"var(--text-tertiary)"}},be={display:"flex",alignItems:"center",gap:"8px"},ze={"&:hover":{backgroundColor:"var(--bg-dialog-hover)"},"&.Mui-selected":{backgroundColor:"var(--bg-dialog-hover)"},"&.Mui-selected:hover":{backgroundColor:"var(--bg-dialog-hover)"}},Yo={PaperProps:{sx:{mt:1,border:"1px solid var(--border-default)",backgroundColor:"var(--bg-dialog)",backgroundImage:"none",boxShadow:"var(--dialog-shadow)"}},MenuListProps:{sx:{py:.5,backgroundColor:"var(--bg-dialog)"}}},Vo={mb:1.5,"& .MuiInputBase-root":{height:"unset"},"& .MuiInputBase-input":{textAlign:"right",fontSize:"16px!important",px:0},"& .MuiOutlinedInput-notchedOutline":{border:"none"}},Ho={color:"var(--text-tertiary)",fontSize:n=>n.typography.subtitle1};function Ko({toChain:n,toWallet:r,setToWallet:d,dstAmount:E,dst_amount_usd:u,slippage_rate:j,bridgeToken:L,onBridgeTokenChange:B,tokenAddress:g,tokenSymbol:k,dstTokenSymbol:m}){const{t:x}=ge(),[y,H]=t.useState(null),l=t.useMemo(()=>he.find(b=>b.value===n),[n]),F=Be(n)&&!!(l!=null&&l.usdc),K=t.useMemo(()=>ve(n),[n]),{balance:q}=Je({address:r,chain:n,token:g}),s=t.useCallback(b=>e.jsxs(c,{style:be,children:[b==="usdc"?l!=null&&l.UsdcIcon?e.jsx(l.UsdcIcon,{width:24,height:24}):e.jsx(c,{width:24,height:24}):l!=null&&l.CoinIcon?e.jsx(l.CoinIcon,{width:24,height:24}):e.jsx(c,{width:24,height:24}),b==="usdc"?K:(l==null?void 0:l.coin)??"Native"]}),[l,K]),a=t.useCallback(b=>{B(b.target.value)},[B]);return e.jsxs(e.Fragment,{children:[e.jsxs(v,{style:Do,sx:Xo,children:[e.jsxs(v,{direction:"row",justifyContent:"space-between",mb:3,children:[e.jsxs(v,{direction:"row",alignItems:"center",gap:1,children:[e.jsx(c,{sx:Uo,children:x("To")}),e.jsxs(v,{direction:"row",alignItems:"center",gap:.5,className:"cursor-pointer",onClick:b=>{m||H(b.currentTarget)},children:[e.jsx(Qe,{color:"var(--text-primary)"}),e.jsx(Re,{address:r,editable:!1}),!m&&e.jsx(ot,{color:"var(--text-tertiary)",size:12})]})]}),!m&&e.jsxs(v,{direction:"row",alignItems:"center",sx:Po,gap:"6px",children:[e.jsxs(c,{sx:Fo,children:[x("Balance"),":"]}),q,"  ",k]})]}),e.jsxs(v,{direction:"row",alignItems:"center",justifyContent:"space-between",children:[e.jsx(v,{direction:"row",alignItems:"center",gap:1,sx:Go,children:m?e.jsxs(e.Fragment,{children:[L==="usdc"?l!=null&&l.UsdcIcon?e.jsx(l.UsdcIcon,{width:24,height:24}):e.jsx(c,{width:24,height:24}):l!=null&&l.CoinIcon?e.jsx(l.CoinIcon,{width:24,height:24}):e.jsx(c,{width:24,height:24}),m||k]}):e.jsxs(et,{size:"small",value:L,onChange:a,renderValue:s,MenuProps:Yo,sx:zo,children:[e.jsx(ae,{value:"native",sx:ze,children:e.jsxs(c,{style:be,children:[l!=null&&l.CoinIcon?e.jsx(l.CoinIcon,{width:24,height:24}):e.jsx(c,{width:24,height:24}),(l==null?void 0:l.coin)??"Native"]})}),F&&e.jsx(ae,{value:"usdc",sx:ze,children:e.jsxs(c,{style:be,children:[l!=null&&l.UsdcIcon?e.jsx(l.UsdcIcon,{width:24,height:24}):e.jsx(c,{width:24,height:24}),K]})})]})}),e.jsx(tt,{placeholder:"0.00",value:E,inputProps:{readOnly:!0},sx:Vo})]}),!!u&&e.jsx(v,{direction:"row",justifyContent:"flex-end",children:e.jsxs(c,{sx:Ho,children:["≈$",u,"(",j,")"]})})]}),e.jsx(rt,{anchorEl:y,setAnchorEl:H,setWallet:d,currentChain:n,onlyV3Wallets:!0})]})}const qo={backgroundColor:"var(--bg-page)",px:1.5,pb:1.5},$o={display:"flex",justifyContent:"center",alignItems:"center",flex:1,height:"100%"},Jo={fontSize:"24px",lineHeight:"24px",fontWeight:500},Qo={fontSize:"14px",fontWeight:400,color:"var(--text-brand)"},Zo={height:"12px",position:"relative"},en={position:"absolute",top:"-18px",left:"50%",transform:"translateX(-50%)",width:"48px",height:"48px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",backgroundColor:"var(--bg-surface)"},tn={border:"1px solid var(--border-default)"},st={mt:3},on=[st,{opacity:.4,"&.Mui-disabled":{opacity:.4}}],nn={px:1.5,py:1,border:"1px solid var(--error)",borderRadius:1,backgroundColor:"var(--bg-page-message)",color:"var(--error)",fontSize:13,lineHeight:1.4,textAlign:"left"},Ye={flexShrink:0,marginTop:1},rn={px:1.5,py:1,border:"1px solid var(--yellow)",borderRadius:1,backgroundColor:"var(--bg-page-message)",color:"var(--yellow)",fontSize:13,lineHeight:1.5,textAlign:"left"},sn={mt:1},Ie="bsc",xe="xlayer",Ve="robinhood",He="stable",C="native";function it(n,r){return n===Ie&&r===xe}function lt(n,r){return n===xe&&r!==Ie||r===xe&&n!==Ie}function ln(n,r){return n===Ve&&r===xe||r===Ve&&n===xe}function Ke(n,r){return lt(n,r)||ln(n,r)}function ce(n,r,d,E,u){const j=u.toUpperCase()==="USDC";return it(n,r)&&(d!==C||E!==C||j)}function Ee(n){return he.find(r=>r.value===n)}function Te(n,r){const d=Ee(n);return d?r==="usdc"?d.usdc??"":d.coinAddress:""}function ne(n){var r;return Be(n)&&!!((r=Ee(n))!=null&&r.usdc)}function cn(n,r){const d=Ee(n);return r==="usdc"?(d==null?void 0:d.usdcDecimals)??6:n==="solana"?9:18}function qe(n,r){const d=Ee(n);return r==="usdc"?ve(n):(d==null?void 0:d.coin)||""}function an({isMobileUa:n}){const r=Bt(n),d=jt(),{enqueueSnackbar:E}=Lt(),{t:u}=ge(),j=t.useRef(),L=kt(),B=L.get("dst_token")||"",g=L.get("dst_token_symbol")||"",k=L.get("dst_chain")||"",m=L.get("dst_wallet")||"",x=t.useMemo(()=>B&&k&&m&&g,[B,k,m,g]),y=Se(o=>o.globalReducer.chain),H=Se(o=>o.userPostsReducer.userInfo),l=Se(o=>o.userPostsReducer.isLogin),F=Rt(),[K,q]=t.useState(!1),[s,a]=t.useState(null),b=t.useRef(null),[W,N]=t.useState(""),[T,A]=t.useState(""),[Q,f]=t.useState(""),[_e,D]=t.useState(null),[X,U]=t.useState(""),[_,G]=t.useState(""),[de,$]=t.useState(""),[re,Z]=t.useState(!1),[se,pe]=t.useState(!1),[h,ee]=t.useState("native"),[I,te]=t.useState("native"),R=t.useCallback(()=>{$(""),a(null),D(null)},[]),w=t.useCallback(()=>{E(u("BridgeXLayerBnbOnly"),{variant:"errorLite"})},[E,u]);t.useEffect(()=>{x&&(U(m),G(k))},[x,m,k]);const{data:z}=$e({queryKey:["getMyWallets",H.inviteCode],queryFn:()=>mt(),enabled:l}),je=t.useMemo(()=>{const o=new Map;return z==null||z.forEach(i=>
1{o.set(i.publicKey.toLowerCase(),i.version)}),o},[z]),fe=t.useCallback(o=>{if(!o)return!1;const i=je.get(o.toLowerCase());return i!==void 0&&!me(i)},[je]);t.useEffect(()=>{if(!(z!=null&&z.length))return;const o=z.find(i=>i.chain===y);if(o&&(N(i=>i||o.publicKey),A(i=>i||o.chain)),!x){const i=z.filter(p=>p.chain!==y&&me(p.version));if(i.length>0){const p=y==="solana"?i.find(S=>S.chain==="bsc")||i[0]:i.find(S=>S.chain==="solana")||i[0];U(S=>S||p.publicKey),G(S=>S||p.chain)}}},[y,x,z]);const O=t.useCallback(async o=>{var We;const i=(o==null?void 0:o.amount)!==void 0?o==null?void 0:o.amount:Q,p=(o==null?void 0:o.fromChain)||T,S=(o==null?void 0:o.toChain)||_,M=(o==null?void 0:o.fromWallet)||W,Y=(o==null?void 0:o.toWallet)||X,P=(o==null?void 0:o.srcToken)||h,oe=(o==null?void 0:o.dstToken)||I;if(ce(p,S,P,x?C:oe,x?g:"")){w(),$(""),a(null),D(null);return}const J=Te(p,P),_t=Te(S,oe),pt=cn(p,P),ue={src_chain:p,dst_chain:S,src_wallet:M,dst_wallet:Y,amount:i!=="max"?Ht(i,pt).toString():"max"};if(ue.src_token=J,ue.dst_token=_t,Ke(p,S)){$(""),a(null),D(null),E(u("BridgeXLayerOnly"),{variant:"errorLite"});return}if(!M||!Y||!i||!Number(i)&&i!=="max"){$(""),a(null),D(null);return}B&&(ue.dst_token=B),Z(!0);let V=null;x?V=await Tt(ue).finally(()=>{Z(!1),a(null)}):V=await St(ue).finally(()=>{Z(!1),a(null)}),V&&(i==="max"&&f(V==null?void 0:V.input_amount),$(V==null?void 0:V.dst_amount),(We=b.current)==null||We.verify(),a(V))},[Q,h,I,T,_,W,X,B,g,x,E,w,u]),ct=t.useCallback(()=>{d.back()},[d]),at=t.useCallback(()=>{const o=_,i=T,p=I,S=h,M=ce(o,i,p,S,x?g:"");N(X),A(o),U(fe(W)?"":W),G(i),ee(M?C:p),te(M?C:S),M&&w(),R()},[W,X,T,_,h,I,g,x,fe,w,R]),ke=t.useCallback(o=>{if(ce(T,_,o,x?C:I,x?g:"")){ee(C),w(),R();return}ee(o),R(),O({srcToken:o})},[I,g,T,O,x,w,R,_]),Le=t.useCallback(o=>{if(ce(T,_,h,o,x?g:"")){te(C),w(),R();return}te(o),R(),O({dstToken:o})},[g,T,O,x,w,R,h,_]);t.useEffect(()=>{if(!it(T,_))return;const o=h!==C,i=!x&&I!==C;!o&&!i||(o&&ee(C),i&&te(C),w(),R())},[I,T,x,w,R,h,_]),t.useEffect(()=>{const o=h==="usdc"&&!ne(T),i=I==="usdc"&&!ne(_);!o&&!i||(o&&ee(C),i&&te(C),R())},[I,T,R,h,_]);const ye=t.useCallback(async()=>{pe(!0);try{await O({amount:"max"})}finally{pe(!1)}},[O]),dt=t.useCallback(()=>{q(!1)},[]),Oe=lt(T,_),Ae=T===He||_===He,ut=Ke(T,_),we=t.useCallback((o,i)=>{if(i!==_){const J=h==="usdc"&&!ne(i)?C:h;A(i),N(o),J!==h&&(ee(J),R()),O({fromWallet:o,fromChain:i,srcToken:J});return}const p=T,S=fe(W)?"":W,M=I,Y=h,P=ce(i,p,M,Y,""),oe=P||M==="usdc"&&!ne(i)?C:M,le=P||Y==="usdc"&&!ne(p)?C:Y;N(o),A(i),U(S),G(p),ee(oe),te(le),P&&w(),R(),S&&O({fromWallet:o,fromChain:i,toWallet:S,toChain:p,srcToken:oe,dstToken:le})},[I,T,W,O,fe,w,R,h,_]),Me=t.useCallback((o,i)=>{if(i!==T){const J=I==="usdc"&&!ne(i)?C:I;U(o),G(i),J!==I&&(te(J),R()),O({toWallet:o,toChain:i,dstToken:J});return}const p=_,S=X,M=I,Y=h,P=ce(p,i,M,Y,""),oe=P||M==="usdc"&&!ne(p)?C:M,le=P||Y==="usdc"&&!ne(i)?C:Y;N(S),A(p),U(o),G(i),ee(oe),te(le),P&&w(),R(),O({fromWallet:S,fromChain:p,toWallet:o,toChain:i,srcToken:oe,dstToken:le})},[I,T,O,w,R,h,_,X]),ht=t.useMemo(()=>e.jsx(No,{ref:b,isMaxLoading:se,onSetMax:ye,fromChain:T,fromWallet:W,toChain:_,excludeDestinationChain:!!x,bridgeToken:h,onBridgeTokenChange:ke,tokenAddress:Te(T,h),tokenSymbol:qe(T,h),setFromWallet:we,value:Q,onChange:o=>(f(o),o||(a(null),$(""),D(null)),O({amount:o})),minBridgeValueUsd:Number((s==null?void 0:s.input_amount_usd)||0)+Number((s==null?void 0:s.estimated_bridge_fee_usd)||0),baseTokenPriceUsd:Number((s==null?void 0:s.base_token_price_usd)||1),onError:o=>{D(o)},inputAmountUsd:s==null?void 0:s.input_amount_usd}),[T,W,_,h,Q,se,x,s==null?void 0:s.estimated_bridge_fee_usd,s==null?void 0:s.base_token_price_usd,s==null?void 0:s.input_amount_usd,O,ke,ye,we]),xt=t.useMemo(()=>e.jsx(Ko,{toChain:_,toWallet:X,bridgeToken:I,onBridgeTokenChange:Le,tokenAddress:B||Te(_,I),tokenSymbol:qe(_,I),dstTokenSymbol:g,setToWallet:Me,dstAmount:de,dst_amount_usd:s==null?void 0:s.dst_amount_usd,slippage_rate:s==null?void 0:s.slippage_rate}),[_,X,I,B,g,de,s==null?void 0:s.dst_amount_usd,s==null?void 0:s.slippage_rate,Le,Me]),ie=t.useRef(null);t.useEffect(()=>{if(s!=null&&s.id){const o=()=>{ie.current=setTimeout(()=>{O({}).finally(()=>{o()})},2e4)};o()}else ie.current&&clearTimeout(ie.current),ie.current=null;return()=>{ie.current&&clearTimeout(ie.current),ie.current=null}},[Q,s==null?void 0:s.id,O]);const gt=t.useCallback(()=>{Z(!0),It("/api/dt_trading/bridge/create",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({id:s==null?void 0:s.id,chain:T})},(o,i)=>{if(o==="task_id"){Z(!1),E(e.jsx("div",{id:s==null?void 0:s.id,children:u("Trading")}),{variant:"info",persist:!0,anchorOrigin:{vertical:"top",horizontal:"center"}});let p=30;clearInterval(j.current),j.current=setInterval(()=>{p--;const S=document.getElementById((s==null?void 0:s.id)||"");S&&(S.innerText=`${u("Trading")} (${p}s)`)},1e3)}else if(o==="bridge_result"){Ne();const p=JSON.parse(i);if(p.Status==="success")q(!0);else{let S=F[p.StatusCode];p.StatusCode||(S=F[88e3]),E(e.jsxs("div",{children:[u("TradeFail"),":",S]}),{variant:"errorLite",autoHideDuration:2e4,anchorOrigin:{vertical:"top",horizontal:"center"}})}}else o==="error"&&(Z(!1),Ne(),E(u("BridgeCreateFail"),{variant:"errorLite",anchorOrigin:{vertical:"top",horizontal:"center"}}))})},[s==null?void 0:s.id,E,T,u,F]);return e.jsxs(e.Fragment,{children:[e.jsx(Ot,{needBottomPadding:!1,sx:qo,children:e.jsx(wt,{isMobile:r,style:$o,children:e.jsx(v,{direction:"row",justifyContent:"center",children:e.jsxs(c,{width:580,children:[e.jsxs(v,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1,mt:3,mb:2,sx:Jo,children:[e.jsxs(v,{direction:"row",alignItems:"center",gap:1,children:[e.jsx(Kt,{onClick:ct,className:"cursor-pointer"}),u("Bridge")]}),e.jsx(c,{component:De,href:"/operation?tab=bridge",sx:Qo,children:u("BridgeRecord")})]}),ht,e.jsx(c,{style:Zo,children:x?null:e.jsx(c,{className:"cursor-pointer",onClick:at,style:en,sx:tn,children:e.jsx(yt,{})})}),xt,e.jsx(Mt,{disabled:re||!(s!=null&&s.id)||!!_e||ut,loading:re,loadingPosition:"start",onClick:gt,fullWidth:!0,sx:re?on:st,children:u(re?"Estimating":"BridgeConfirm")}),(Ae||Oe)&&e.jsxs(v,{gap:1,sx:sn,children:[Ae&&e.jsxs(v,{direction:"row",alignItems:"flex-start",ga
1p:.75,role:"note",sx:rn,children:[e.jsx(Ue,{size:16,color:"var(--yellow)",style:Ye}),e.jsx(c,{children:u("BridgeStableLiquidityNotice")})]}),Oe&&e.jsxs(v,{direction:"row",alignItems:"flex-start",justifyContent:"center",gap:.75,role:"note",sx:nn,children:[e.jsx(Ue,{size:16,style:Ye}),e.jsx(c,{children:u("BridgeXLayerOnly")})]})]}),s&&e.jsx(vt,{data:s})]})})})}),e.jsx(At,{open:K,onClose:dt,isMobile:!1,content:e.jsxs(v,{width:256,height:168,alignItems:"center",justifyContent:"center",gap:3,children:[e.jsx($t,{}),e.jsxs(v,{direction:"row",children:[e.jsx(c,{children:u("RequestSent")})," ",e.jsx(c,{color:"var(--text-brand)",component:De,href:"/operation?tab=bridge",children:u("ViewStatus")})]})]})})]})}function lr(){const{isMobileUa:n}=qt();return e.jsx(an,{isMobileUa:n})}export{lr as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.