import{j as e,ak as s,a6 as w,a$ as B,bd as N,at as v,W as d}from"./vendor-mui-core-BPQ6AEW_.js";import{r as l}from"./vendor-react-CUXIiAnY.js";import{C as I}from"./vendor-utils-BgSaqjGx.js";import{p as $}from"./vendor-ux-r9bApERu.js";import{l as L,a as E,v as z}from"./index-DY2wgD65.js";import{W as A}from"./did-address-j4poFq12.js";import{a as D}from"./page-header-BkgoSN-0.js";import{S as F}from"./layout-PANci1G8.js";import{S as P}from"./step-actions-D5Cu9stE.js";import{S as m}from"./button-DqhIB3De.js";import"./vendor-hooks-PN9SWiQm.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-D8WYBDYe.js";import"./content-layout-B-2tfq3i.js";import"./use-mobile-C5RjvO7g.js";function R({onNext:n=()=>{},onPrevious:x=()=>{}}){const{locale:u,t}=l.useContext($),{blocklet:a,gas:c,tokenInfo:f,actions:h}=L(),{api:j}=E(),[y,o]=l.useState(!1),{need:p="",current:g="",owe:r=99999,deficiency:k,symbol:b="",endpoint:i}=c||{},{origin:C="/"}=i?new URL(i):{};l.useEffect(()=>{const W=setInterval(()=>{h.refreshFuel()},2e3);return()=>{clearInterval(W)}},[]);const S=()=>{o(!1)};return c?e.jsxs(T,{children:[e.jsx("div",{className:"header",children:e.jsx(D,{title:t("setup.fuel.title"),onClickBack:x})}),e.jsxs(s,{className:"qr-body",children:[e.jsxs(s,{className:"tip",sx:{mb:6},children:[t("setup.fuel.tipStart").replace("slot",""),e.jsx("span",{className:"amount",children:`${p} ${b}`}),t("setup.fuel.tipEnd")]}),e.jsx(s,{sx:{fontSize:16,fontWeight:"fontWeightBold",mb:.5},children:t("setup.fuel.addressTitle")}),e.jsxs(s,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(A,{className:"address",did:a.appDid}),e.jsx(B,{style:{lineHeight:1},target:"_blank",href:I(C,"/explorer/accounts/",a.appDid),underline:"hover",children:e.jsx(N,{className:"icon-launch"})})]}),e.jsx(s,{sx:{my:2},children:e.jsx(m,{color:"primary",onClick:()=>o(!0),disabled:!r,children:t("setup.fuel.fuelApp")})}),e.jsx(z,{popup:!0,open:y,action:"fuel",checkFn:j.get,checkTimeout:10*60*1e3,onSuccess:S,onClose:()=>o(!1),locale:u,messages:{title:t("setup.connect.title"),scan:t("setup.connect.scan"),confirm:t("setup.connect.confirm"),success:t("setup.connect.success")},extraParams:{amount:k,...f,endpoint:i}}),e.jsxs(s,{sx:{display:"flex",color:"text.secondary"},children:[e.jsxs(s,{sx:{display:"flex"},children:[e.jsxs(s,{children:[t("setup.fuel.need"),":"]}),e.jsx(s,{sx:{ml:.5,color:"primary.main",fontWeight:"fontWeightBold"},children:p})]}),e.jsxs(s,{sx:{display:"flex",ml:3},children:[e.jsxs(s,{children:[t("setup.fuel.current"),":"]}),e.jsx(s,{sx:{ml:.5,color:r>0?"error.main":"primary.main",fontWeight:"fontWeightBold"},children:g})]})]})]}),e.jsx(P,{mt:8,children:e.jsx(m,{disabled:r>0,onClick:()=>n(),children:t("setup.next")})})]}):e.jsx(s,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%"},children:e.jsx(w,{})})}R.propTypes={onNext:d.func,onPrevious:d.func};const T=v(F)`
  .qr-body {
    width: 580px;
    ${n=>n.theme.breakpoints.down("md")} {
      width: 80%;
    }
    display: flex;
    flex-direction: column;
    align-items: center;

    .tip {
      font-size: 16px;
      font-weight: bold;
    }

    .address {
      width: 100%;
      text-align: center;
    }

    .amount {
      color: ${n=>n.theme.palette.primary.main};
    }

    .icon-launch {
      font-size: 16px;
      margin-left: 6px;
      line-height: 1;
      color: ${n=>n.theme.palette.primary.main};
    }
  }
`;export{R as default};
