import{j as o,al as i,aT as g,X as u}from"./vendor-mui-core-CDEc-eG6.js";import{v as k,n as C,au as b,m as B}from"./index-CgSpL7jz.js";import{D as E,a as I,b as w}from"./domain-action-card-BXg1GQv4.js";import{bj as T}from"./vendor-ux-PO0jFgJf.js";import{a as A}from"./page-header-CEL5h6do.js";import{r,j as W}from"./vendor-react-DX7tU9aY.js";import{u as L}from"./useSetState-CUbypYGT.js";import{S as x}from"./button-BdkIS-Qs.js";import{S as $}from"./layout-DkUZePxy.js";import{S as z}from"./step-actions-Ezqn_AMv.js";import"./vendor-arcblock-BVQTtbN-.js";import"./vendor-hooks-Ca2cSNuD.js";import"./vendor-utils-_C9URqjS.js";import"./permission-C2bdzuoM.js";import"./session-BEf_KK-i.js";import"./useAsyncRetry-DOQg_SXs.js";import"./useAsync-10WR8h3k.js";import"./confirm-DhDNorbd.js";import"./index-DBs9Ljax.js";import"./actions-C6EeERSU.js";import"./delete-confirm-C0N4quT9.js";import"./click-to-copy-BmatCVrP.js";import"./use-mobile-DKWj9MJD.js";import"./useAsync-DQXF8Gyy.js";import"./index-BEbBg3NW.js";import"./util-Cz5-V-1E.js";import"./engine-BmJsBu5Z.js";import"./content-layout-D49-hpq6.js";import"./use-mobile-DUKvJoqs.js";function h({onNext:a=()=>{},onPrevious:f=()=>{}}){const{t:n}=r.useContext(T),[D,d]=r.useState(!1),{blocklet:e}=k(),[p,S]=r.useState(""),j=((e?.site||{}).domainAliases||[]).map(t=>C.replaceSlotToIp(t.value,p)),[s,m]=L({domain:"",invalidDNSDomain:null,type:"",addDomainState:{text:""}}),c=e.environments?.find(t=>t.key==="BLOCKLET_APP_PK")?.value,y=j.find(t=>b.isDidDomain(t)),[l,P]=W();return r.useEffect(()=>{B.get(`/dns-resolve?hostname=${window.location.hostname}`).then(({data:t})=>{S(t.address||"")}).catch(t=>{console.error(t.message)})},[]),o.jsxs(H,{children:[o.jsx(i,{className:"header",children:o.jsx(A,{title:n("setup.domain.title"),subTitle:n("setup.domain.subTitle"),onClickBack:f})}),o.jsxs(i,{className:"form form-container",sx:{display:"flex",flexDirection:"column",gap:3,overflowY:"auto"},children:[o.jsxs(i,{children:[o.jsx(i,{sx:{color:"text.primary",fontWeight:"fontWeightBold",fontSize:"1.125rem"},children:o.jsx(i,{sx:{display:"inline"},children:`${n("setup.domain.buyOrConnect")} (${n("common.optional")})`})}),o.jsx(i,{sx:{mt:1},children:o.jsx(I,{blocklet:e,bugDidDomainProps:{appPk:c,appId:e.appPid,siteId:e.site.id,teamDid:e.meta.did,inBlockletSetup:!0},connectDomainProps:{autoFocus:!1,appPk:c,appId:e.appPid,siteId:e.site.id,teamDid:e.meta.did,cnameDomain:y,currentIp:p,inBlockletSetup:!0,shouldCheckDomain:!0,onInputDomain:t=>{m({domain:t.domain,type:t.type}),d(t.error)},onStateChange:t=>m({addDomainState:t}),onSuccess:t=>{const v={domain:t.domain,type:t.type,nftDid:t.nftDid,chainHost:t.chainHost};l.set("redirect",t.domain),P(l,{replace:!0}),m(v),a()},onError:d}})})]}),o.jsx(i,{children:o.jsx(w,{inSetup:!0,showAllDomains:!0,systemTips:o.jsx(i,{sx:{color:"text.primary",fontWeight:"fontWeightBold",fontSize:"1.125rem",mb:1},children:o.jsx(i,{sx:{display:"inline"},children:n("setup.domain.skipDescription")})})})})]}),o.jsx(z,{mt:8,disabled:!!s.addDomainState.text,blocklet:e,onStartNow:()=>a("complete"),children:s.domain?o.jsx(x,{variant:"contained",loading:!!s.addDomainState.text,disabled:D||!!s.addDomainState.text||!s.domain,onClick:()=>a(),children:s.addDomainState.text||n("setup.continue")}):o.jsx(x,{variant:"contained",disabled:!!s.addDomainState.text,onClick:()=>a(),children:n("setup.continue")})})]})}function ht(a){return o.jsx(E,{children:o.jsx(h,{...a})})}h.propTypes={onNext:u.func,onPrevious:u.func};const H=g($)`
  height: 100%;
  overflow-y: hidden;

  .form {
    width: 100%;
    height: 100%;
  }
`;export{ht as default};
