import{r as i}from"./vendor-react-DX7tU9aY.js";import{aa as k,a7 as I,br as E,bU as L}from"./vendor-ux-PO0jFgJf.js";import{r as y}from"./vendor-hooks-Ca2cSNuD.js";import{j as e,al as s,a7 as S,b4 as w,b3 as M,z as P,y as W,bN as _,M as z,T as B,bb as D,I as N,cC as A,R as K,X as F}from"./vendor-mui-core-CDEc-eG6.js";import{W as U,X as C,b2 as V}from"./index-CgSpL7jz.js";import{y as q}from"./vendor-utils-_C9URqjS.js";import{a as X}from"./api-Bo6lutcq.js";import{T as G}from"./table-tips-CRXYL7Hz.js";import{b as H}from"./team-Bso_Sjaa.js";import{u as O}from"./session-BEf_KK-i.js";import"./vendor-arcblock-BVQTtbN-.js";import"./use-mobile-CnCzXOEv.js";import"./purify.es-HRjpPm7y.js";import"./wallet-hidden-topbar-CZaZNW94.js";import"./theme-mode-toggle-WRMGhjzA.js";import"./use-mobile-DKWj9MJD.js";import"./index-BLYrVxV3.js";import"./isURL-CpQHQuaa.js";import"./isIP-BBY240SU.js";import"./use-blocklet-logo-nVOJALp0.js";import"./use-app-logo-DcBQK--f.js";function T({endpoint:l}){const[t,n]=i.useState("mcp-link"),x=C(),{api:h}=C(),{teamDid:d}=H(),{t:c,locale:p}=k(),{session:r}=O(),{data:u,run:o,loading:b}=y(()=>{const f={owner:V.ADMIN}[r?.user?.role]||r?.user?.role;return h.createAccessKey({input:{teamDid:d,passport:f,authType:"simple",remark:"Generated by MCP Servers"}})},{manual:!0}),{imgPrefix:a}=x,j=i.useMemo(()=>[{icon:e.jsx(s,{sx:{width:20,height:20},children:"🔗"}),value:"mcp-link",label:"MCP Link"},{icon:e.jsx(s,{component:"img",src:`${a}/mcp/claude.webp`,alt:"Claude",sx:{width:20,height:20}}),value:"claude",label:"Claude"},{icon:e.jsx(s,{component:"img",src:`${a}/mcp/cursor.png`,alt:"Cursor",sx:{width:20,height:20}}),value:"cursor",label:"Cursor"},{icon:e.jsx(s,{component:"img",src:`${a}/mcp/cline.png`,alt:"Cline",sx:{width:20,height:20}}),value:"cline",label:"Cline"},{icon:e.jsx(s,{component:"img",src:`${a}/mcp/roocline.png`,alt:"Roo Cline",sx:{width:20,height:20}}),value:"roo-cline",label:"Roo Cline"},{icon:e.jsx(s,{component:"img",src:`${a}/mcp/windsurf.png`,alt:"Windsurf",sx:{width:20,height:20}}),value:"windsurf",label:"Windsurf"},{icon:e.jsx(s,{component:"img",src:`${a}/mcp/witsy.png`,alt:"Witsy",sx:{width:20,height:20}}),value:"witsy",label:"Witsy"}],[a]),v=j.find(m=>m.value===t),g=i.useMemo(()=>u?.data?.accessKeySecret,[u]),R=i.useMemo(()=>!g&&t!=="mcp-link",[g,t]),$=m=>{const f=`npx @blocklet/install-mcp@latest i ${l} --client ${m} --streamableHTTP --oauth2Bearer ${g}`;switch(m){case"cursor":case"claude":case"cline":case"roo-cline":case"windsurf":case"witsy":return f;default:return l}};return e.jsxs(s,{className:"mcp-servers-container",children:[e.jsx(E,{tabs:j,current:t,onChange:n,scrollButtons:"auto",iconPosition:"start"}),e.jsxs(s,{children:[e.jsxs(s,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(B,{component:"span",variant:"h6",sx:{fontWeight:"bold",my:2},children:t==="mcp-link"?v?.label:`${v?.label} ${c("installCommand")}`}),t!=="mcp-link"&&e.jsx(D,{href:`https://www.arcblock.io/docs/blocklet-developer/${p}/mcp-${t}`,target:"_blank",rel:"noopener noreferrer",children:e.jsx(N,{size:"small",children:e.jsx(A,{fontSize:"small"})})})]}),e.jsxs(s,{className:"mcp-servers-codeblock",sx:{position:"relative","& pre":{borderRadius:1},"& .codeblock__inner":{overflow:"auto !important",borderRadius:1}},children:[e.jsx(L,{code:$(t),language:"shell",style:{margin:0},showDefaultText:!1}),R&&e.jsx(s,{sx:{position:"absolute",top:0,right:0,left:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"action.active",backdropFilter:"blur(3px)",WebkitBackdropFilter:"blur(3px)",zIndex:1},children:b?e.jsx(S,{}):e.jsx(K,{variant:"contained",color:"primary",onClick:o,size:"small",children:`${c("common.generate")} ${c("command")}`})})]})]})]})}T.propTypes={endpoint:F.string.isRequired};function ge(){const[l,t]=i.useState(null),{t:n,locale:x}=k(),h=q(U,"/mcp/servers"),{data:d,loading:c,error:p}=y(()=>Promise.all([X.get(h)])),r=i.useMemo(()=>d?.[0]?.data?.servers||[],[d]);i.useEffect(()=>{r?.length&&t(r.find(o=>o.did===window?.blocklet?.did)||r[0])},[r]);const u=o=>{const b=o.target.value;t(r.find(a=>a.did===b))};return c?e.jsx(s,{children:e.jsx(S,{})}):p?e.jsx(w,{color:"error",children:p?.message}):r?.length?e.jsxs(M,{sx:{gap:2,maxWidth:1200},children:[e.jsx(G,{title:n("mcp.listTitle"),tooltipTitle:n("mcp.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${x}/mcp-server`}),e.jsxs(P,{fullWidth:!0,children:[e.jsx(W,{id:"server-select-label",children:n("mcp.available")}),e.jsx(_,{labelId:"server-select-label",value:l?.did||"",label:n("mcp.available"),onChange:u,children:r.map(o=>e.jsx(z,{value:o.did,children:e.jsxs(s,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(I,{variant:"rounded",shape:"square",did:o.did,src:o.logo,size:20}),e.jsx(s,{sx:{fontSize:14},children:o.name})]})},o.did))})]}),l&&e.jsx(T,{endpoint:l.endpoint})]}):e.jsx(w,{color:"warning",children:n("mcp.noServer")})}export{ge as default};
