import{j as e,ak as n,ar as E,a$ as te,at as Q,W as p,am as k,cq as ne,T,c2 as L,bf as M}from"./vendor-mui-core-BPQ6AEW_.js";import{r as u,a as oe}from"./vendor-react-CUXIiAnY.js";import{U as h,V as A,n as se,z as ae,Q as ie}from"./vendor-ux-r9bApERu.js";import{d as re}from"./keyboard-arrow-down-rounded-8U0_i9QO.js";import{f as D}from"./index-BojVbZw0.js";import{p as le}from"./dashboard-ZkYlBsz9.js";import{_ as ce,ac as me,ae as de,aU as pe,ad as ue,c as _,e as he,a1 as q}from"./index-DY2wgD65.js";import{v as xe}from"./index-ySP_m_Ux.js";import{u as ge}from"./useAsyncRetry-LJm0Fhbe.js";import{C as fe}from"./vendor-utils-BgSaqjGx.js";import{u as ve}from"./team-DP9eK2IU.js";import{W as v}from"./did-address-j4poFq12.js";import{V as be}from"./status-DMr8vsBX.js";import{c as je}from"./spaces-Cgv_XshJ.js";import"./vendor-hooks-PN9SWiQm.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-D8WYBDYe.js";import"./useLocalStorage-6wbaKET6.js";import"./index-DBs9Ljax.js";import"./confirm-B8poMcDB.js";import"./get-safe-url-DqysS0i0.js";import"./session-f4MooMkP.js";import"./passport-YH_G5MTs.js";import"./create-passport-svg-CIUyZVGt.js";import"./useSetState-cWrp7qoX.js";import"./index-BIbviVFd.js";import"./over-due-invoice-payment-BfrNEMR8.js";import"./useAsync-BCC9JxQR.js";import"./isURL-C1rexYxN.js";import"./use-app-logo-D5-5iGIj.js";import"./omit-CpvduH4b.js";import"./api-uGeIZn4a.js";const ke={width:24,height:24,body:'<path fill="currentColor" d="m12 10.8l-3.9 3.9q-.275.275-.7.275t-.7-.275q-.275-.275-.275-.7t.275-.7l4.6-4.6q.3-.3.7-.3t.7.3l4.6 4.6q.275.275.275.7t-.275.7q-.275.275-.7.275t-.7-.275L12 10.8Z"/>'},ye={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 17a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2zm12 0a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2zM9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2zM6 15v-1a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v1m-6-6v3"/>'},we={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 7a4 4 0 1 0 8 0a4 4 0 1 0-8 0M3 21v-2a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v2m1-17.87a4 4 0 0 1 0 7.75M21 21v-2a4 4 0 0 0-3-3.85"/>'},Se={width:24,height:24,body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M7 12h3v4H7z"/><path d="M10 6H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h16a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1h-6"/><path d="M10 4a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1zm4 12h2m-2-4h4"/></g>'},_e={width:24,height:24,body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M19.5 7A9 9 0 0 0 12 3a8.991 8.991 0 0 0-7.484 4"/><path d="M11.5 3a16.989 16.989 0 0 0-1.826 4M12.5 3a16.989 16.989 0 0 1 1.828 4M19.5 17a9 9 0 0 1-7.5 4a8.991 8.991 0 0 1-7.484-4"/><path d="M11.5 21a16.989 16.989 0 0 1-1.826-4m2.826 4a16.989 16.989 0 0 0 1.828-4M2 10l1 4l1.5-4L6 14l1-4m10 0l1 4l1.5-4l1.5 4l1-4M9.5 10l1 4l1.5-4l1.5 4l1-4"/></g>'},O={width:24,height:24,body:'<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M3 12a9 9 0 1 0 18 0a9 9 0 0 0-18 0"/><path d="M12 7v5l3 3"/></g>'},Te={width:24,height:24,body:'<path fill="currentColor" d="M12 14q-.825 0-1.413-.588T10 12q0-.825.588-1.413T12 10q.825 0 1.413.588T14 12q0 .825-.588 1.413T12 14Zm0 7q-3.475 0-6.025-2.288T3.05 13H5.1q.35 2.6 2.313 4.3T12 19q2.925 0 4.963-2.038T19 12q0-2.925-2.038-4.963T12 5q-1.725 0-3.225.8T6.25 8H9v2H3V4h2v2.35q1.275-1.6 3.113-2.475T12 3q1.875 0 3.513.713t2.85 1.924q1.212 1.213 1.925 2.85T21 12q0 1.875-.713 3.513t-1.924 2.85q-1.213 1.212-2.85 1.925T12 21Z"/>'};function W({icon:t,value:s,name:o,url:i="",animated:l=!1,LinkComponent:d=te,loading:x=!1}){const g=()=>oe.isValidElement(t)?t:e.jsx(n,{component:h,icon:t,alt:typeof o=="string"?o:"",sx:{fontSize:30}});if(x)return e.jsxs(V,{children:[t&&e.jsx(n,{className:"metric__image",children:e.jsx(E,{variant:"circular",width:32,height:32})}),e.jsxs(n,{children:[e.jsx(E,{className:`metric__number ${l?"metric__number--animated":""}`,variant:"rounded",width:160,height:"36px",sx:{mb:1}}),e.jsx(E,{className:"metric__name",variant:"rounded",width:80,height:20})]})]});const f=e.jsxs(e.Fragment,{children:[t&&e.jsx(n,{className:"metric__image",children:g()}),e.jsxs(n,{children:[u.isValidElement(s)?e.jsx(n,{className:`metric__number ${l?"metric__number--animated":""}`,children:s}):e.jsx(n,{className:`metric__number ${l?"metric__number--animated":""}`,dangerouslySetInnerHTML:{__html:s}}),e.jsx(n,{className:"metric__name",children:o})]})]});return e.jsx(V,{children:i?e.jsx(d,{href:i,sx:{textDecoration:"none"},children:f}):f})}W.propTypes={icon:p.string.isRequired,value:p.string.isRequired,name:p.string.isRequired,url:p.string,animated:p.bool,LinkComponent:p.elementType,loading:p.bool};const V=Q(n)`
  border-left: 1px solid ${t=>t.theme.palette.divider};
  padding: 10px 0 10px 16px;
  @media (max-width: ${t=>t.theme.breakpoints.values.sm}px) {
    padding: 0 0 0 8px;
  }

  display: flex;
  justify-items: center;
  align-items: flex-start;

  a {
    display: flex;
    justify-items: center;
    align-items: flex-start;
  }

  .metric__image {
    margin-right: 8px;
    margin-top: 2px;
  }

  .metric__number {
    margin-bottom: 8px;
    font-size: ${t=>t.size==="small"?32:36}px;
    font-weight: 600;
    line-height: 36px;
    color: ${t=>t.theme.typography.color.main};

    small {
      font-size: 12px;
      line-height: 12px;
    }

    @media (max-width: ${t=>t.theme.breakpoints.values.sm}px) {
      font-size: ${t=>t.size==="small"?24:28}px;
      line-height: ${t=>t.size==="small"?24:28}px;
      margin-bottom: 2px;
    }
  }

  .metric__number--animated {
    animation-name: blink-opacity;
    animation-duration: 250ms;
    animation-timing-function: linear;
    animation-iteration-count: 1;
    background-color: transparent !important;
  }

  .metric__name {
    font-size: 14px;
    text-transform: capitalize;
    line-height: 1.2;
    font-weight: 500;
    color: ${t=>t.theme.typography.color.main};
    @media (max-width: ${t=>t.theme.breakpoints.values.sm}px) {
      font-size: 10px;
      line-height: 1;
    }
  }

  @keyframes blink-opacity {
    0% {
      opacity: 1;
    }
    50% {
      opacity: 0.3;
    }
    100% {
      opacity: 1;
    }
  }
`,b={oneSecond:1,oneMin:1*60,oneHour:1*60*60,oneDay:24*60*60},Ae=(t,s)=>{const[o,i]=u.useState(0),l=g=>g>=b.oneDay?b.oneDay:g>=b.oneHour?b.oneHour:g>=b.oneMin?b.oneMin:b.oneSecond,[d,x]=u.useState(l(t/1e3));return u.useEffect(()=>{const g=setInterval(()=>{i(o+d);const f=l(t/1e3+o+d);d!==f&&x(f)},d*1e3);return()=>clearInterval(g)},[d,o]),u.useEffect(()=>{i(0),x(l(t/1e3))},[t]),s(t+o*1e3)};p.number.isRequired,p.func;const Ie={arcblock:"ArcBlock",ethereum:"Ethereum"};function F({source:t,migrated:s}){const{t:o}=A();return t?t.startsWith("managed")?e.jsxs(n,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(T,{children:t}),e.jsx(k,{title:o(s?"blocklet.skSourceMigratedTip":"blocklet.skSourceManagedTip"),children:e.jsx(M,{sx:{fontSize:16,color:s?"text.secondary":"warning.main"}})})]}):e.jsx(T,{children:t}):null}F.propTypes={source:p.string.isRequired,migrated:p.bool.isRequired};const $e=t=>{const{t:s}=A();let o=0,i=0;t&&(o=t.length,i=t.filter(d=>he.isBlockletRunning(d)).length);let l=o;return i&&(l+=`<small>${s("common.running")} ${i}</small>`),l},Me=(t,s)=>{const{t:o}=A();return s.length?e.jsxs(n,{component:"small",children:[o("router.domainAlias.custom")," ",s.length]}):e.jsxs(n,{component:"small",sx:{display:"flex",alignItems:"center",gap:.5,color:s.length?"text.primary":"warning.main"},children:[o("router.domainAlias.noCustom"),e.jsx(k,{title:o("router.domainAlias.noCustomTip"),children:e.jsx(M,{sx:{fontSize:16}})})]})},ze=(t,s)=>{const o=t===_.BACKUPS.STATUS.PROGRESS&&q().diff(s,"hours")>=_.BACKUPS.TIMEOUT_HOURS,i=t===_.BACKUPS.STATUS.PROGRESS&&!o;return t===_.BACKUPS.STATUS.SUCCEEDED&&!o?e.jsx(n,{sx:{width:8,height:8,borderRadius:"100%",bgcolor:"success.main"}}):i?e.jsx(n,{sx:{width:8,height:8,borderRadius:"100%",bgcolor:"error.main"}}):e.jsx(n,{sx:{width:8,height:8,borderRadius:"100%",bgcolor:"warning.main"}})},Ce=(t,s)=>{const{t:o,locale:i}=A(),l=s?.createdAt;return t&&l?e.jsxs(n,{sx:{display:"flex",alignItems:"baseline",gap:.5,color:q(l).add(1,"day").isAfter(q())?"text.primary":"warning.main"},children:[D(l,i==="tw"?"zh":i),e.jsx(k,{title:o("storage.spaces.backup.lastBackupTip",{time:D(l,i==="tw"?"zh":i)}),children:e.jsx(M,{sx:{fontSize:16}})})]}):e.jsxs(n,{sx:{display:"flex",alignItems:"baseline",gap:.5,color:"warning.main",fontSize:30},children:[o("storage.spaces.backup.noBackup"),e.jsx(k,{title:o("storage.spaces.backup.noBackupTip"),children:e.jsx(M,{sx:{fontSize:16}})})]})},j={fontSize:30,color:"text.primary"};function pt(){const{t,locale:s}=A(),{info:o,inService:i,api:l}=ce(),{teamDid:d}=ve(),[x,g]=u.useState(!1),{did:f,blocklet:a}=me(),c=ge(()=>l.getBlockletBaseInfo({input:{teamDid:d}})),{appDid:z,appPid:C,migratedFrom:y=[]}=a,B=a.environments.find(r=>r.key==="BLOCKLET_APP_CHAIN_TYPE")?.value,I=r=>typeof r!="number"||Number.isNaN(r)?"0":r>=1e4?new Intl.NumberFormat(s,{notation:"compact",compactDisplay:"short"}).format(r):new Intl.NumberFormat(s).format(r),N=[z?{name:t("blocklet.appId"),value:e.jsx(v,{did:z,showQrcode:!0})}:null,C&&z!==C?{name:e.jsxs(n,{children:[t("blocklet.appPid"),e.jsx(k,{title:t("blocklet.whyNeedAppPid"),style:{cursor:"help",fontSize:16},children:e.jsx(ne,{sx:{verticalAlign:"middle",mt:"-2px",ml:"2px"}})})]}),value:e.jsx(v,{did:C,showQrcode:!0})}:null,y?.length>1?{name:t("blocklet.alsoKnownAs"),value:e.jsxs("div",{children:[(x?y.slice(1):y.slice(1,2)).map(r=>e.jsx(v,{did:r.appDid,showQrcode:!0})),y.length>2&&e.jsx(se,{sx:{pl:0,"&:hover":{backgroundColor:"transparent"}},endIcon:x?e.jsx(h,{icon:ke}):e.jsx(h,{icon:re}),onClick:()=>g(!x),children:t(x?"common.collapseAll":"blocklet.router.showAllDIDs")})]})}:null,de(a)?{name:"NFT",value:e.jsx(v,{external:!0,href:pe(a?.controller?.chainHost,a?.controller?.nftId,"asset"),did:a?.controller?.nftId,showQrcode:!0})}:null,{name:t("common.owner"),value:a.settings?.owner?e.jsx(v,{did:a.settings.owner.did,showQrcode:!0}):"-"},a.vaults?.length?{name:t("blocklet.config.vault.name"),value:e.jsxs(n,{sx:{display:"flex",alignItems:"center",gap:.5,"& > span":{width:"auto"}},children:[e.jsx(v,{did:a.vaults[a.vaults.length-1].did,showQrcode:!0}),e.jsx(be,{vaults:a.vaults,appPid:a.appPid})]})}:null,{name:t("blocklet.installedAt"),value:a.installedAt?e.jsx(ae,{value:a.installedAt,type:"all",locale:s}):"-"},{name:t("blocklet.config.walletType.name"),value:Ie[B||"arcblock"]||B},a.externalSkSource?{name:t("blocklet.skSource"),value:e.jsx(F,{source:a.externalSkSource,migrated:y.length>0})}:null].filter(Boolean);i&&N.push({name:t("common.serverDid"),value:e.jsx(v,{did:o.did,showQrcode:!0})},{name:t("common.serverVersion"),value:e.jsx(ie,{children:o.version})});const K=r=>r.map(m=>e.jsx(xe,{style:{display:"flex",alignItems:"flex-start"},valueComponent:"div",nameWidth:150,name:m.name,nameFormatter:()=>m.name,children:m.value},m.name)),G=$e(a.children),R=Number(c?.value?.appRuntimeInfo?.uptime||0),Z=Ae(R,r=>le(r,{compact:!0,verbose:!0,locale:s==="tw"?"zh":s})),$=u.useMemo(()=>a?.site?.domainAliases||[],[a?.site?.domainAliases]),X=u.useMemo(()=>$.filter(r=>ue.isCustomDomain(r.value)),[$]),Y=Me($,X),P=u.useMemo(()=>c?.value?.passport||{},[c?.value?.passport]),U=u.useMemo(()=>c?.value?.user||{},[c?.value?.user]),H=u.useMemo(()=>je(a?.environments),[a?.environments]),J=Ce(H,c?.value?.backup),w=(r,m)=>`${_.WELLKNOWN_SERVICE_PATH_PREFIX}/admin/${r}/${m}`,S=r=>{const m=o?.routing?.adminPath;return fe(m,`/blocklets/${f}/${r}`)},ee=[{name:t("common.blocklets"),value:G,icon:e.jsx(n,{component:h,icon:ye,sx:j}),url:i?w("overview","components"):S("components")},{loading:c?.loading,name:t("common.members"),value:`${I(U?.users||0)}<small>${t("common.active")} ${I(U?.approvedUsers)}</small>`,icon:e.jsx(n,{component:h,icon:we,sx:j}),url:i?w("did-connect","members"):S("members")},{loading:c?.loading,name:t("team.member.passports"),value:`${I(P?.passports||0)}<small>${t("common.active")} ${I(P?.activePassports)}</small>`,icon:e.jsx(n,{component:h,icon:Se,sx:j}),url:i?w("did-connect","passports"):S("passports")},{loading:c?.loading,name:t("common.domains"),value:e.jsxs(n,{sx:{display:"flex",alignItems:"baseline"},children:[$.length,Y]}),icon:e.jsx(n,{component:h,icon:_e,sx:j}),url:i?w("website","domains"):S("domains")},{loading:c?.loading,name:t("common.uptime"),value:R?Z:e.jsx(n,{sx:{fontSize:28,color:"text.secondary"},children:`${t("common.waiting")}...`}),icon:e.jsx(n,{component:h,icon:O,sx:j})},a.createdAt&&+new Date(a.createdAt)!=+new Date(0)?{name:t("common.created"),value:D(new Date(a.createdAt).getTime(),s==="tw"?"zh":s),icon:e.jsx(n,{component:h,icon:O,sx:j})}:null,{loading:c?.loading,name:e.jsxs(n,{sx:{display:"flex",alignItems:"baseline",gap:.5},children:[t("storage.spaces.backup.lastBackup"),c?.value?.backup&&H&&e.jsx(k,{children:ze(c?.value?.backup?.status,c?.value?.backup?.createdAt)})]}),value:J,icon:e.jsx(n,{component:h,icon:Te,sx:j}),url:i?w("did-spaces","backups"):S("didSpaces")}].filter(Boolean);return e.jsxs(Ee,{component:"div",children:[e.jsxs(n,{className:"section",children:[e.jsx(T,{className:"section__header",color:"textPrimary",children:t("common.overview")}),e.jsx(L,{className:"page-metrics",container:!0,spacing:5,children:ee.map(({icon:r,...m})=>e.jsx(L,{sx:{small:{ml:.5}},size:{xl:1.5,lg:3,md:4,sm:6,xs:6},children:e.jsx(W,{...m})},m.name))})]}),e.jsxs(n,{className:"section",children:[e.jsx(T,{className:"section__header",color:"textPrimary",children:t("common.basicInfo")}),e.jsx(n,{className:"basicInfo",children:K(N)})]})]})}const Ee=Q(T)`
  .section {
    display: flex;
    flex-direction: column;
    margin-bottom: 64px;

    .section__header {
      font-size: 1.2rem;
      font-weight: bold;
      margin-bottom: 24px;
    }
  }
`;export{pt as default};
