@versot/vaguspi 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,60 @@
1
+ import{j as e,u as K,a as q,r as g,h as Oe,c as Pe,b as He}from"./index-BC6qaWvB.js";import"./vendor-BtP0CW_r.js";function Ke({size:r=14}){return e.jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),e.jsx("path",{d:"M21 3v5h-5"}),e.jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),e.jsx("path",{d:"M8 21H3v-5"})]})}function Ue({size:r=14}){return e.jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),e.jsx("path",{d:"m3.3 7 8.7 5 8.7-5"}),e.jsx("path",{d:"M12 22V12"})]})}function Be({size:r=14}){return e.jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),e.jsx("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),e.jsx("line",{x1:"10",x2:"10",y1:"11",y2:"17"}),e.jsx("line",{x1:"14",x2:"14",y1:"11",y2:"17"})]})}function _e({size:r=13}){return e.jsx("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"})})}function Je({size:r=15}){return e.jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function Ve({size:r=15}){return e.jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24"}),e.jsx("path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"}),e.jsx("path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"}),e.jsx("line",{x1:"2",x2:"22",y1:"2",y2:"22"})]})}function Ye({size:r=13}){return e.jsxs("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),e.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function Ie({size:r=13}){return e.jsx("svg",{width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})}function Ge({providers:r,selectedId:o,adding:n,onSelect:t,onAdd:s,t:a}){const{theme:i}=K();return e.jsxs("div",{style:{width:220,flexShrink:0,borderRight:`1px solid ${a.color.border}`,padding:10,background:i==="light"?"#ffffff":a.color.surface},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 10px 6px"},children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:a.color.muted,letterSpacing:"0.04em"},children:"自定义供应商"}),e.jsx("button",{onClick:s,title:"添加供应商",onMouseEnter:l=>l.currentTarget.style.color=a.color.fg,onMouseLeave:l=>l.currentTarget.style.color=a.color.muted,style:{background:"transparent",border:"none",color:a.color.muted,cursor:"pointer",display:"flex",padding:2,transition:"color 0.15s"},children:e.jsx(Ie,{size:14})})]}),r.length===0&&!n&&e.jsx("div",{style:{fontSize:12,color:a.color.muted,padding:"8px 10px"},children:"暂无供应商"}),r.map(l=>{const x=o===l.id&&!n,p=l.enabled!==!1;return e.jsxs("div",{onClick:()=>t(l.id),onMouseEnter:b=>{x||(b.currentTarget.style.background=a.color.surface)},onMouseLeave:b=>{x||(b.currentTarget.style.background="transparent")},style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",borderRadius:9,fontSize:13,color:a.color.fg,cursor:"pointer",transition:"background 0.15s",background:x?a.color.border:"transparent"},children:[e.jsx(Ue,{size:14}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l.id}),e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:p?"#10B981":a.color.muted,flexShrink:0}})]},l.id)})]})}const Ee=[{value:"openai-completions",label:"OpenAI Completions (/v1/chat/completions)"},{value:"openai-responses",label:"OpenAI Responses (/v1/responses)"},{value:"anthropic-messages",label:"Anthropic Messages (/v1/messages)"},{value:"google-generative-ai",label:"Google Gemini (/v1beta/models)"}];function Xe(r){return r>=1e6?`${(r/1e6).toFixed(1)}M`:r>=1e3?`${Math.round(r/1e3)}K`:String(r)}function Le({value:r,onChange:o,t:n}){var l;const[t,s]=g.useState(!1),a=ke(),i=((l=Ee.find(x=>x.value===r))==null?void 0:l.label)??r;return e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{type:"button",onClick:()=>s(x=>!x),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,background:a,border:`1px solid ${n.color.border}`,borderRadius:8,padding:"8px 12px",fontSize:13,color:n.color.fg,cursor:"pointer"},children:[e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i}),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0},children:e.jsx("path",{d:"M6 9l6 6 6-6"})})]}),t&&e.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:50,background:a,border:`1px solid ${n.color.border}`,borderRadius:10,padding:4,boxShadow:"0 8px 24px rgba(0,0,0,0.25)"},children:Ee.map(x=>{const p=x.value===r;return e.jsxs("button",{type:"button",onClick:()=>{o(x.value),s(!1)},style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",border:"none",background:p?n.color.border:"transparent",color:n.color.fg,borderRadius:7,padding:"7px 10px",fontSize:12.5,cursor:"pointer",textAlign:"left"},children:[e.jsx("span",{children:x.label}),p&&e.jsx("span",{style:{color:n.color.primary},children:"✓"})]},x.value)})})]})}function Z({label:r,children:o}){const n=q();return e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,color:n.color.muted,marginBottom:6},children:r}),o]})}function je({title:r,description:o,children:n}){const{theme:t}=K(),s=q(),a=t==="light"?"#ffffff":s.color.surface;return e.jsxs("div",{style:{marginBottom:30},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:s.color.fg,marginBottom:4},children:r}),o!==void 0&&e.jsx("div",{style:{fontSize:12,color:s.color.muted,marginBottom:10,lineHeight:1.5},children:o}),e.jsx("div",{style:{background:a,border:`1px solid ${s.color.border}`,borderRadius:12,overflow:"hidden"},children:n})]})}function ke(){const{theme:r}=K(),o=q();return r==="light"?"#ffffff":o.color.surface}function de({label:r,hint:o,control:n,t,last:s=!1}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:24,padding:"13px 18px",borderBottom:s?"none":`1px solid ${t.color.border}`},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{fontSize:13,color:t.color.fg},children:r}),o!==void 0&&e.jsx("div",{style:{fontSize:11.5,color:t.color.muted,marginTop:3,lineHeight:1.5},children:o})]}),e.jsx("div",{style:{flexShrink:0},children:n})]})}function Ze({options:r,value:o,onChange:n,t}){return e.jsx("div",{style:{display:"inline-flex",background:t.color.bg,border:`1px solid ${t.color.border}`,borderRadius:9,padding:3,gap:2},children:r.map(s=>{const a=s.value===o;return e.jsx("button",{onClick:()=>n(s.value),style:{border:"none",background:a?t.color.surface:"transparent",color:a?t.color.fg:t.color.muted,borderRadius:6,padding:"5px 14px",fontSize:12.5,fontWeight:a?500:400,cursor:"pointer",transition:"all 0.15s",whiteSpace:"nowrap"},children:s.label},s.value)})})}function De({checked:r,onChange:o,t:n}){return e.jsx("button",{role:"switch","aria-checked":r,onClick:()=>o(!r),style:{width:34,height:20,borderRadius:99,border:"none",cursor:"pointer",flexShrink:0,background:r?n.color.accent:n.color.border,position:"relative",transition:"background 0.15s"},children:e.jsx("span",{style:{position:"absolute",top:2,left:r?16:2,width:16,height:16,borderRadius:"50%",background:"#fff",boxShadow:"0 1px 2px rgba(0,0,0,0.25)",transition:"left 0.15s"}})})}function Me({value:r,onChange:o,min:n=10,max:t=20,t:s}){const[a,i]=g.useState(String(r));g.useEffect(()=>{i(String(r))},[r]);const l=p=>{const b=p.trim();if(b===""){i(String(r));return}const d=Number(b);Number.isFinite(d)?o(Math.min(t,Math.max(n,Math.round(d)))):i(String(r))},x={width:26,height:30,border:"none",background:"transparent",color:s.color.muted,fontSize:15,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"};return e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",border:`1px solid ${s.color.border}`,borderRadius:8,overflow:"hidden",background:s.color.bg},children:[e.jsx("button",{onClick:()=>o(Math.max(n,r-1)),style:x,"aria-label":"减小字号",children:"−"}),e.jsx("input",{type:"text",inputMode:"numeric",value:a,onChange:p=>i(p.target.value.replace(/[^\d]/g,"")),onBlur:()=>l(a),onKeyDown:p=>{p.key==="Enter"&&p.currentTarget.blur()},"aria-label":"字号",style:{width:40,height:30,border:"none",outline:"none",textAlign:"center",background:"transparent",color:s.color.fg,fontSize:12.5}}),e.jsx("button",{onClick:()=>o(Math.min(t,r+1)),style:x,"aria-label":"增大字号",children:"+"}),e.jsx("span",{style:{paddingRight:10,fontSize:12,color:s.color.muted},children:"px"})]})}function Qe({form:r,setForm:o,onAdd:n,canAdd:t,inputStyle:s,t:a}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:16,fontWeight:600,color:a.color.fg},children:"添加模型供应商"}),e.jsx("div",{style:{fontSize:12,color:a.color.muted,margin:"4px 0 20px"},children:"配置一个完全自定义的 API 端点和初始模型"}),e.jsx(Z,{label:"名称",children:e.jsx("input",{style:s,placeholder:"如:openai",value:r.id,onChange:i=>o({...r,id:i.target.value})})}),e.jsx(Z,{label:"Base URL",children:e.jsx("input",{style:s,placeholder:"https://api.example.com/v1",value:r.baseUrl,onChange:i=>o({...r,baseUrl:i.target.value})})}),e.jsx(Z,{label:"API Key",children:e.jsx("input",{style:s,type:"password",placeholder:"输入 API Key(可选)",value:r.apiKey,onChange:i=>o({...r,apiKey:i.target.value})})}),e.jsx(Z,{label:"API 格式",children:e.jsx(Le,{value:r.api,onChange:i=>o({...r,api:i}),t:a})}),e.jsx("button",{onClick:n,disabled:!t,onMouseEnter:i=>{t&&(i.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:i=>{i.currentTarget.style.filter="none"},style:{width:"100%",background:t?a.color.primary:a.color.border,color:t?"#fff":a.color.muted,border:"none",borderRadius:10,padding:"11px 16px",fontSize:13.5,fontWeight:500,cursor:t?"pointer":"default",transition:"filter 0.15s"},children:"添加供应商"})]})}function Re(r,o){return r==="light"?"#ffffff":o.color.surface}function qe({open:r,form:o,setForm:n,onAdd:t,onClose:s,inputStyle:a,t:i,onProbe:l,provider:x}){const{theme:p}=K(),[b,d]=g.useState("idle"),v=g.useRef(void 0);return r?e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:s,children:e.jsxs("div",{style:{background:Re(p,i),border:`1px solid ${i.color.border}`,borderRadius:14,padding:22,width:400,maxWidth:"90vw",boxShadow:"0 12px 40px rgba(0,0,0,0.35)"},onClick:F=>F.stopPropagation(),children:[e.jsx("div",{style:{fontSize:15,fontWeight:600,color:i.color.fg},children:"添加模型"}),e.jsx("div",{style:{fontSize:12,color:i.color.muted,margin:"4px 0 18px"},children:"配置模型的标识与参数,保存后可在聊天中选用。"}),e.jsx(Z,{label:"模型 ID",children:e.jsx("input",{style:a,autoFocus:!0,placeholder:"如 gpt-4o(自动探测兼容配置)",value:o.id,onChange:F=>{const m=F.target.value;if(n(y=>({...y,id:m})),v.current!==void 0&&window.clearTimeout(v.current),l&&x&&m.trim()!==""){const y=m.trim();d("probing"),v.current=window.setTimeout(()=>{v.current=void 0,l({baseUrl:x.baseUrl,api:x.api,apiKey:x.apiKey,model:y}).then(f=>{f.ok&&f.compat?(n(w=>{var k;return w.id.trim()===y?{...w,compat:f.compat??void 0,reasoning:f.reasoning,vision:((k=f.input)==null?void 0:k.includes("image"))??w.vision}:w}),d("ok")):d("fail")}).catch(()=>d("fail"))},600)}else d("idle")},onKeyDown:F=>{F.key==="Enter"&&o.id.trim()!==""&&b!=="probing"&&t()}})}),(()=>{if(o.id.trim()!==""){if(b==="probing")return e.jsx("div",{style:{fontSize:11.5,color:"#6366f1",background:"rgba(99,102,241,0.08)",borderRadius:6,padding:"5px 10px",marginTop:-4,marginBottom:4},children:"正在自动探测模型能力…"});if(b==="ok")return e.jsx("div",{style:{fontSize:11.5,color:"#10B981",background:"rgba(16,185,129,0.1)",borderRadius:6,padding:"5px 10px",marginTop:-4,marginBottom:4},children:"✓ 自动探测完成:compat/图片/思考配置已自动填入"});if(b==="fail")return e.jsx("div",{style:{fontSize:11.5,color:"#E5484D",background:"rgba(229,72,77,0.08)",borderRadius:6,padding:"5px 10px",marginTop:-4,marginBottom:4},children:"自动探测失败 — 请检查 baseUrl / apiKey,或稍后重试"})}return null})(),e.jsxs("div",{style:{display:"flex",gap:10},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11.5,fontWeight:500,color:i.color.muted,marginBottom:4},children:"上下文窗口 (tokens)"}),e.jsx("input",{style:a,type:"number",min:0,placeholder:"2000000",value:o.contextWindow,onChange:F=>n({...o,contextWindow:F.target.value})})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11.5,fontWeight:500,color:i.color.muted,marginBottom:4},children:"最大输出 (tokens)"}),e.jsx("input",{style:a,type:"number",min:0,placeholder:"131072",value:o.maxTokens,onChange:F=>n({...o,maxTokens:F.target.value})})]})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,marginTop:14,cursor:"pointer",fontSize:12.5,color:i.color.fg,userSelect:"none"},children:[e.jsx("input",{type:"checkbox",checked:o.vision,onChange:F=>n({...o,vision:F.target.checked}),style:{width:15,height:15,accentColor:i.color.primary,cursor:"pointer"}}),e.jsx("span",{children:"支持图片理解"}),e.jsx("span",{style:{color:i.color.muted,fontSize:11},children:"(决定聊天中能否添加图片附件)"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:20},children:[e.jsx("button",{onClick:s,style:{background:"transparent",border:`1px solid ${i.color.border}`,color:i.color.muted,borderRadius:8,padding:"7px 18px",fontSize:12.5,cursor:"pointer"},children:"取消"}),e.jsx("button",{onClick:t,disabled:o.id.trim()===""||b==="probing",onMouseEnter:F=>{o.id.trim()!==""&&b!=="probing"&&(F.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:F=>{F.currentTarget.style.filter="none"},style:{background:i.color.primary,color:"#fff",border:"none",borderRadius:8,padding:"7px 18px",fontSize:12.5,fontWeight:500,cursor:o.id.trim()===""||b==="probing"?"not-allowed":"pointer",transition:"filter 0.15s",opacity:o.id.trim()===""||b==="probing"?.5:1},children:b==="probing"?"正在探测…":"添加"})]})]})}):null}function eo({confirmDeleteId:r,providers:o,onConfirm:n,onClose:t,t:s}){var i;const{theme:a}=K();return r===null?null:e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:t,children:e.jsxs("div",{style:{background:Re(a,s),border:`1px solid ${s.color.border}`,borderRadius:14,padding:22,width:340,maxWidth:"90vw",boxShadow:"0 12px 40px rgba(0,0,0,0.35)"},onClick:l=>l.stopPropagation(),children:[e.jsx("div",{style:{fontSize:15,fontWeight:600,color:s.color.fg},children:"删除供应商"}),e.jsxs("div",{style:{fontSize:12.5,color:s.color.muted,margin:"10px 0 22px",lineHeight:1.7},children:["确定删除供应商 ",e.jsxs("span",{style:{color:s.color.fg,fontWeight:500},children:["“",((i=o.find(l=>l.id===r))==null?void 0:i.id)??r,"”"]})," 吗?其下模型将一并移除,此操作不可撤销。"]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx("button",{onClick:t,style:{background:"transparent",border:`1px solid ${s.color.border}`,color:s.color.muted,borderRadius:8,padding:"7px 18px",fontSize:12.5,cursor:"pointer"},children:"取消"}),e.jsx("button",{onClick:()=>{n(r),t()},onMouseEnter:l=>l.currentTarget.style.filter="brightness(1.15)",onMouseLeave:l=>l.currentTarget.style.filter="none",style:{background:"#E5484D",color:"#fff",border:"none",borderRadius:8,padding:"7px 18px",fontSize:12.5,fontWeight:500,cursor:"pointer",transition:"filter 0.15s"},children:"确认删除"})]})]})})}function oo({provider:r,detail:o,setDetail:n,showKey:t,setShowKey:s,testingId:a,testResult:i,editingModelId:l,modelForm:x,setModelForm:p,addModelOpen:b,addModelForm:d,setAddModelForm:v,confirmDeleteId:F,providers:m,onToggleEnabled:y,onDelete:f,onConfirmDelete:w,onTest:k,onAddModel:B,onRemoveModel:I,onStartEdit:M,onSaveEdit:R,onCancelEdit:L,onCancelDelete:u,onOpenAddModel:E,onCloseAddModel:A,inputStyle:z,t:h,onProbe:U}){const{theme:H}=K(),T=r,V=H==="light"?"#ffffff":h.color.surface;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:16},children:[e.jsx("input",{style:{...z,flex:1,minWidth:120,fontWeight:600,fontSize:14},value:o.id,onChange:j=>n({...o,id:j.target.value}),"aria-label":"供应商名称"}),e.jsxs("div",{style:{display:"inline-flex",background:h.color.bg,border:`1px solid ${h.color.border}`,borderRadius:99,padding:2,gap:2,flexShrink:0},children:[e.jsx("button",{onClick:y,onMouseEnter:j=>{T.enabled!==!1&&(j.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:j=>{j.currentTarget.style.filter="none"},style:{border:"none",borderRadius:99,padding:"4px 12px",fontSize:12,cursor:"pointer",background:T.enabled!==!1?"#10B981":"transparent",color:T.enabled!==!1?"#fff":h.color.muted,transition:"filter 0.15s"},children:"已启用"}),e.jsx("button",{onClick:y,onMouseEnter:j=>{T.enabled===!1&&(j.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:j=>{j.currentTarget.style.filter="none"},style:{border:"none",borderRadius:99,padding:"4px 12px",fontSize:12,cursor:"pointer",background:T.enabled===!1?h.color.fg:"transparent",color:T.enabled===!1?h.color.bg:h.color.muted,transition:"filter 0.15s"},children:"禁用"})]}),e.jsx("button",{onClick:f,title:"删除供应商",onMouseEnter:j=>{j.currentTarget.style.borderColor="#E5484D",j.currentTarget.style.color="#E5484D"},onMouseLeave:j=>{j.currentTarget.style.borderColor=h.color.border,j.currentTarget.style.color=h.color.muted},style:{background:"transparent",border:`1px solid ${h.color.border}`,color:h.color.muted,borderRadius:8,width:30,height:30,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0,transition:"all 0.15s"},children:e.jsx(Be,{})})]}),e.jsx(Z,{label:"Base URL",children:e.jsx("input",{style:z,placeholder:"https://api.example.com/v1",value:o.baseUrl,onChange:j=>n({...o,baseUrl:j.target.value})})}),e.jsx(Z,{label:"API 格式",children:e.jsx(Le,{value:o.api,onChange:j=>n({...o,api:j}),t:h})}),e.jsx(Z,{label:"API Key",children:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{style:{...z,flex:1},type:t?"text":"password",placeholder:"留空保持不变",value:o.apiKey,onChange:j=>n({...o,apiKey:j.target.value})}),e.jsx("button",{onClick:()=>s(!t),title:t?"隐藏":"显示",onMouseEnter:j=>j.currentTarget.style.color=h.color.fg,onMouseLeave:j=>j.currentTarget.style.color=h.color.muted,style:{background:"transparent",border:`1px solid ${h.color.border}`,color:h.color.muted,borderRadius:8,width:34,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0,transition:"all 0.15s"},children:t?e.jsx(Ve,{}):e.jsx(Je,{})})]})}),e.jsx("div",{style:{fontSize:13,fontWeight:600,color:h.color.fg,marginBottom:8},children:"模型列表"}),T.models.length===0&&e.jsx("div",{style:{fontSize:12,color:h.color.muted,marginBottom:10},children:"暂无模型 — 添加一个以在聊天中可用。"}),T.models.map(j=>e.jsxs("div",{children:[e.jsxs("div",{onMouseEnter:W=>W.currentTarget.style.background=h.color.border,onMouseLeave:W=>W.currentTarget.style.background=V,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",borderRadius:8,background:V,marginBottom:6,fontSize:13,transition:"background 0.15s"},children:[e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:j.name??j.id}),j.contextWindow!==void 0&&e.jsx("span",{style:{fontSize:11,color:h.color.fg,background:h.color.bg,border:`1px solid ${h.color.border}`,borderRadius:99,padding:"2px 8px",flexShrink:0},children:Xe(j.contextWindow)}),a===j.id?e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",style:{color:h.color.primary},children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3",strokeDasharray:"40",strokeLinecap:"round",opacity:"0.35"}),e.jsx("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:e.jsx("animateTransform",{attributeName:"transform",type:"rotate",from:"0 12 12",to:"360 12 12",dur:"0.8s",repeatCount:"indefinite"})})]}):e.jsx("span",{role:"button","aria-label":`测试 ${j.id}`,onClick:()=>k(j.id),onMouseEnter:W=>W.currentTarget.style.color=h.color.fg,onMouseLeave:W=>W.currentTarget.style.color=h.color.muted,style:{color:h.color.muted,cursor:"pointer",display:"flex",padding:2,transition:"color 0.15s"},children:e.jsx(Ye,{size:13})}),e.jsx("span",{role:"button","aria-label":`编辑 ${j.id}`,onClick:()=>M(j),onMouseEnter:W=>W.currentTarget.style.color=h.color.fg,onMouseLeave:W=>W.currentTarget.style.color=h.color.muted,style:{color:h.color.muted,cursor:"pointer",display:"flex",padding:2,transition:"color 0.15s"},children:e.jsx(_e,{size:13})}),e.jsx("span",{role:"button","aria-label":`删除模型 ${j.id}`,onClick:()=>I(j.id),onMouseEnter:W=>W.currentTarget.style.color=h.color.fg,onMouseLeave:W=>W.currentTarget.style.color=h.color.muted,style:{color:h.color.muted,cursor:"pointer",display:"flex",padding:2,transition:"color 0.15s"},children:e.jsx(Be,{size:13})})]}),(i==null?void 0:i.modelId)===j.id&&e.jsx("div",{style:{marginBottom:8},children:i.ok?e.jsx("span",{style:{fontSize:12,color:"#10B981",background:"rgba(16,185,129,0.12)",borderRadius:6,padding:"3px 10px",display:"inline-block"},children:"连接成功!"}):e.jsx("span",{style:{fontSize:12,color:"#E5484D",background:"rgba(229,72,77,0.1)",borderRadius:6,padding:"3px 10px",display:"inline-block"},children:i.status===0?"无法连接":i.reason==="auth"?"认证失败":i.reason==="model"?"模型不存在":`连接失败 (HTTP ${i.status})`})}),l===j.id&&e.jsxs("div",{style:{background:h.color.bg,border:`1px solid ${h.color.border}`,borderRadius:8,padding:"10px 12px",marginBottom:8},children:[e.jsxs("div",{style:{display:"flex",gap:10},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11.5,fontWeight:500,color:h.color.muted,marginBottom:4},children:"上下文窗口 (tokens)"}),e.jsx("input",{style:z,type:"number",min:0,placeholder:"128000",value:x.contextWindow,onChange:W=>p({...x,contextWindow:W.target.value})})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11.5,fontWeight:500,color:h.color.muted,marginBottom:4},children:"最大输出 (tokens)"}),e.jsx("input",{style:z,type:"number",min:0,placeholder:"8192",value:x.maxTokens,onChange:W=>p({...x,maxTokens:W.target.value})})]})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,marginTop:12,cursor:"pointer",fontSize:12.5,color:h.color.fg,userSelect:"none"},children:[e.jsx("input",{type:"checkbox",checked:x.vision,onChange:W=>p({...x,vision:W.target.checked}),style:{width:15,height:15,accentColor:h.color.primary,cursor:"pointer"}}),e.jsx("span",{children:"支持图片理解"}),e.jsx("span",{style:{color:h.color.muted,fontSize:11},children:"(聊天中能否添加图片附件)"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:10},children:[e.jsx("button",{onClick:L,style:{background:"transparent",border:`1px solid ${h.color.border}`,color:h.color.muted,borderRadius:7,padding:"5px 14px",fontSize:12,cursor:"pointer"},children:"取消"}),e.jsx("button",{onClick:R,style:{background:h.color.primary,color:"#fff",border:"none",borderRadius:7,padding:"5px 14px",fontSize:12,fontWeight:500,cursor:"pointer"},children:"保存"})]})]})]},j.id)),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:12},children:e.jsxs("button",{onClick:E,onMouseEnter:j=>{j.currentTarget.style.borderColor=h.color.fg,j.currentTarget.style.color=h.color.fg},onMouseLeave:j=>{j.currentTarget.style.borderColor=h.color.border,j.currentTarget.style.color=h.color.muted},style:{background:"transparent",border:`1px dashed ${h.color.border}`,color:h.color.muted,borderRadius:9,padding:"8px 18px",fontSize:12.5,cursor:"pointer",display:"flex",alignItems:"center",gap:6,transition:"all 0.15s"},children:[e.jsx(Ie,{size:13})," 添加模型"]})}),e.jsx(qe,{open:b,form:d,setForm:v,onAdd:B,onClose:A,inputStyle:z,t:h,onProbe:U,provider:r}),e.jsx(eo,{confirmDeleteId:F,providers:m,onConfirm:w,onClose:u,t:h})]})}function ro({providers:r,inputStyle:o,t:n,onSave:t,onRefresh:s,onTest:a,onProbe:i}){const[l,x]=g.useState(null),[p,b]=g.useState(!1),[d,v]=g.useState({id:"",baseUrl:"",api:"openai-completions",apiKey:""}),[F,m]=g.useState(!1),[y,f]=g.useState({id:"",baseUrl:"",apiKey:"",api:"openai-completions"}),[w,k]=g.useState(!1),[B,I]=g.useState({id:"",contextWindow:"2000000",maxTokens:"131072",vision:!1}),[M,R]=g.useState(null),[L,u]=g.useState(null),[E,A]=g.useState(null),[z,h]=g.useState({contextWindow:"",maxTokens:"",vision:!0}),[U,H]=g.useState(void 0),T=l!==null&&!p?r.find(S=>S.id===l)??null:null,V=S=>{const D=r.find(N=>N.id===S);if(!D)return;x(S),b(!1),A(null),H(void 0);const O={id:D.id,baseUrl:D.baseUrl,api:D.api,apiKey:D.apiKey??""};ee.current=JSON.stringify(O),v(O)},j=()=>{b(!0),x(null),A(null),f({id:"",baseUrl:"",apiKey:"",api:"openai-completions"})},W=()=>{const S=y.id.trim(),D=y.baseUrl.trim();if(!S||!D)return;t([...r,{id:S,baseUrl:D,api:y.api,apiKey:y.apiKey.trim()||void 0,models:[]}]);const O={id:S,baseUrl:D,api:y.api,apiKey:y.apiKey};ee.current=JSON.stringify(O),b(!1),x(S),v(O)},Y=S=>{t(r.filter(D=>D.id!==S)),l===S&&(x(null),ee.current="",v({id:"",baseUrl:"",api:"openai-completions",apiKey:""}))};g.useEffect(()=>{if(!p&&l===null&&r.length>0){const S=r[0];S!==void 0&&V(S.id)}},[p,r.length,l]);const ee=g.useRef("");g.useEffect(()=>{if(l===null||!r.find(N=>N.id===l))return;const D=JSON.stringify(d);if(D===ee.current)return;const O=window.setTimeout(()=>{(async()=>{const N=d.id.trim(),me=d.baseUrl.trim();N&&(ee.current=D,await t(r.map(ne=>ne.id===l?{...ne,id:N,baseUrl:me||ne.baseUrl,api:d.api,apiKey:d.apiKey.trim()!==""?d.apiKey.trim():ne.apiKey}:ne)),N!==l&&x(N))})()},700);return()=>window.clearTimeout(O)},[d,l]);const ce=()=>{T&&t(r.map(S=>S.id===T.id?{...S,enabled:S.enabled===!1}:S))},le=async S=>{if(!T)return;u(S),H(void 0);const D=await a({baseUrl:d.baseUrl.trim()||T.baseUrl,api:d.api||T.api,apiKey:d.apiKey.trim()||T.apiKey,model:S});H({modelId:S,...D}),u(null)},he=()=>{if(!T)return;const S=B.id.trim();if(!S)return;const D=B.compat,O=B.reasoning;t(r.map(N=>N.id===T.id?{...N,models:[...N.models,{id:S,contextWindow:B.contextWindow!==""?Number(B.contextWindow):void 0,maxTokens:B.maxTokens!==""?Number(B.maxTokens):void 0,input:B.vision?["text","image"]:["text"],...O!==void 0?{reasoning:O}:{},...D?{compat:D}:{}}]}:N)),k(!1)},re=S=>{T&&(t(r.map(D=>D.id===T.id?{...D,models:D.models.filter(O=>O.id!==S)}:D)),E===S&&A(null))},fe=S=>{var D;A(S.id),h({contextWindow:S.contextWindow!==void 0?String(S.contextWindow):"",maxTokens:S.maxTokens!==void 0?String(S.maxTokens):"",vision:((D=S.input)==null?void 0:D.includes("image"))??!0})},be=()=>{!T||E===null||(t(r.map(S=>S.id===T.id?{...S,models:S.models.map(D=>D.id===E?{...D,contextWindow:z.contextWindow!==""?Number(z.contextWindow):void 0,maxTokens:z.maxTokens!==""?Number(z.maxTokens):void 0,input:z.vision?["text","image"]:["text"]}:D)}:S)),A(null))},ue=y.id.trim()!==""&&y.baseUrl.trim()!=="";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",marginBottom:20},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:22,fontWeight:600,color:n.color.fg},children:"模型设置"}),e.jsx("div",{style:{fontSize:13,color:n.color.muted,margin:"4px 0 0"},children:"管理自定义模型供应商,配置后可在聊天时选择使用。"})]}),e.jsx("button",{onClick:s,title:"刷新配置",style:{background:"transparent",border:`1px solid ${n.color.border}`,color:n.color.muted,borderRadius:8,width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0},children:e.jsx(Ke,{})})]}),e.jsxs("div",{style:{display:"flex",border:`1px solid ${n.color.border}`,borderRadius:14,overflow:"hidden",background:n.color.bg},children:[e.jsx(Ge,{providers:r,selectedId:l,adding:p,onSelect:V,onAdd:j,t:n}),e.jsx("div",{style:{flex:1,padding:"22px 24px",minWidth:0},children:!p&&T!==null?e.jsx(oo,{provider:T,detail:d,setDetail:v,showKey:F,setShowKey:m,testingId:L,testResult:U,editingModelId:E,modelForm:z,setModelForm:h,addModelOpen:w,addModelForm:B,setAddModelForm:I,confirmDeleteId:M,providers:r,onToggleEnabled:ce,onDelete:()=>R(l),onConfirmDelete:S=>Y(S),onTest:le,onAddModel:he,onRemoveModel:re,onStartEdit:fe,onSaveEdit:be,onCancelEdit:()=>A(null),onCancelDelete:()=>R(null),onOpenAddModel:()=>{I({id:"",contextWindow:"2000000",maxTokens:"131072",vision:!1}),k(!0)},onCloseAddModel:()=>k(!1),inputStyle:o,t:n,onProbe:i}):e.jsx(Qe,{form:y,setForm:f,onAdd:W,canAdd:ue,inputStyle:o,t:n})})]})]})}const no=["const themePreview: ThemeConfig = {",' surface: "sidebar",',' accent: "#339CFF",'," contrast: 45,","};"];function Ae({title:r,themeName:o,dark:n,active:t,showLineNumbers:s,codeFontSize:a,t:i}){const l=Pe(o),x=t?"当前生效":n?"深色":"浅色";return e.jsxs("div",{style:{flex:"1 1 300px",background:l.bg,border:`1px solid ${l.border}`,borderRadius:12,overflow:"hidden",boxShadow:t?`0 0 0 1.5px ${i.color.accent}`:"none"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:l.header,borderBottom:`1px solid ${l.border}`},children:[e.jsx("span",{style:{fontSize:12,color:l.text,opacity:.85},children:r}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:11,color:l.text,opacity:.6},children:o}),e.jsx("span",{style:{fontSize:11,fontWeight:500,color:t?"#fff":l.text,background:t?i.color.accent:"transparent",border:t?"none":`1px solid ${l.border}`,borderRadius:99,padding:"2px 10px"},children:x})]})]}),e.jsx("div",{style:{padding:"12px 0 14px",fontSize:a,lineHeight:1.65,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",color:l.text},children:no.map((p,b)=>e.jsxs("div",{style:{display:"flex",paddingLeft:16,paddingRight:16},children:[s&&e.jsx("span",{style:{width:26,flexShrink:0,textAlign:"right",marginRight:14,color:l.text,opacity:.35,userSelect:"none"},children:b+1}),e.jsx("span",{style:{whiteSpace:"pre"},children:Oe(p,l).map((d,v)=>d.color!==void 0?e.jsx("span",{style:{color:d.color},children:d.text},v):d.text)})]},b))})]})}function to({draft:r,onChange:o,t:n}){const{theme:t,preference:s,setPreference:a}=K();return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:22,fontWeight:600,color:n.color.fg},children:"外观"}),e.jsxs("div",{style:{marginTop:24},children:[e.jsxs(je,{title:"界面设置",description:"设置应用主题和界面文字大小。",children:[e.jsx(de,{label:"界面主题",hint:"选择浅色、深色或跟随系统主题。",control:e.jsx(Ze,{options:[{value:"light",label:"浅色"},{value:"dark",label:"深色"},{value:"system",label:"跟随系统"}],value:s,onChange:a,t:n}),t:n}),e.jsx(de,{label:"界面字号",hint:"调整应用界面的文字大小,图标和布局尺寸不受影响。",last:!0,control:e.jsx(Me,{value:r.uiFontSize,onChange:i=>o({uiFontSize:i}),t:n}),t:n})]}),e.jsxs(je,{title:"代码设置",description:"设置代码内容的主题、字号和显示方式,不受界面字号影响。",children:[e.jsx(de,{label:"显示行号",hint:"在代码内容和差异视图中显示行号。",control:e.jsx(De,{checked:r.showLineNumbers,onChange:i=>o({showLineNumbers:i}),t:n}),t:n}),e.jsx(de,{label:"长行自动换行",hint:"代码内容过长时自动换行。",control:e.jsx(De,{checked:r.wrapLongLines,onChange:i=>o({wrapLongLines:i}),t:n}),t:n}),e.jsx(de,{label:"代码字号",hint:"调整代码块、文件预览和差异视图的默认字号。",last:!0,control:e.jsx(Me,{value:r.codeFontSize,onChange:i=>o({codeFontSize:i}),min:10,max:24,t:n}),t:n})]}),e.jsx(je,{title:"代码预览",description:"同时预览浅色与深色代码主题,当前界面使用的主题会标记为“当前生效”。",children:e.jsxs("div",{style:{display:"flex",gap:14,flexWrap:"wrap",padding:18},children:[e.jsx(Ae,{title:"浅色预览",themeName:"GitHub Light",dark:!1,active:t==="light",showLineNumbers:r.showLineNumbers,codeFontSize:r.codeFontSize,t:n}),e.jsx(Ae,{title:"深色预览",themeName:"GitHub Dark",dark:!0,active:t==="dark",showLineNumbers:r.showLineNumbers,codeFontSize:r.codeFontSize,t:n})]})})]})]})}const se=864e5,X=["#6366F1","#22D3EE","#FBBF24","#F472B6","#34D399","#A78BFA","#F87171","#60A5FA"],io=["#ebedf0","#9be9a8","#40c463","#30a14e","#216e39"],so=["#21262d","#0e4429","#006d32","#26a641","#39d353"];function Q(r){return r>=1e9?`${(r/1e9).toFixed(1)}G`:r>=1e6?`${(r/1e6).toFixed(1)}M`:r>=1e3?`${(r/1e3).toFixed(1)}K`:String(Math.round(r))}function ze(r){const o=new Date(r);return`${o.getMonth()+1}月${o.getDate()}日`}function lo(r){const o=[...new Set(r.map(i=>Math.floor(i.ts/se)))].toSorted((i,l)=>i-l);let n=0,t=0;for(let i=0;i<o.length;i++)t=i===0||o[i]===(o[i-1]??0)+1?t+1:1,t>n&&(n=t);const s=Math.floor(Date.now()/se);let a=0;for(let i=o.length-1;i>=0&&o[i]===s-a;i--)a++;return{current:a,longest:n}}function ao(r){const o=new Map;for(const n of r)for(const[t,s]of Object.entries(n.byModel))o.set(t,(o.get(t)??0)+s);return[...o.entries()].map(([n,t])=>({model:n,tokens:t})).toSorted((n,t)=>t.tokens-n.tokens)}function co({value:r,onChange:o,t:n}){const t=[{v:7,label:"最近 7 天"},{v:30,label:"最近 30 天"}];return e.jsx("div",{style:{display:"inline-flex",background:n.color.bg,border:`1px solid ${n.color.border}`,borderRadius:9,padding:3,gap:2},children:t.map(s=>{const a=r===s.v;return e.jsx("button",{onClick:()=>o(s.v),style:{border:"none",background:a?n.color.surface:"transparent",color:a?n.color.fg:n.color.muted,borderRadius:6,padding:"5px 14px",fontSize:12.5,fontWeight:a?500:400,cursor:"pointer",transition:"all 0.15s"},children:s.label},s.v)})})}function ie({icon:r,label:o,value:n,sub:t}){const s=q(),a=ke();return e.jsxs("div",{style:{background:a,border:`1px solid ${s.color.border}`,borderRadius:12,padding:16,display:"flex",flexDirection:"column",gap:6},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{color:s.color.muted,display:"flex",flexShrink:0},children:r}),e.jsx("span",{style:{fontSize:11.5,color:s.color.muted},children:o})]}),e.jsx("div",{style:{fontSize:24,fontWeight:600,color:s.color.fg,letterSpacing:"-0.02em"},children:n}),t!==void 0&&e.jsx("div",{style:{fontSize:12,color:s.color.muted},children:t})]})}function uo({daily:r,range:o}){const n=q(),{theme:t}=K(),[s,a]=g.useState(null),i=t==="light"?io:so,l=new Date;l.setHours(0,0,0,0);const x=l.getTime(),p=x-o*se,b=new Map,d=new Map;for(const L of r){const u=new Date(L.ts).toISOString().slice(0,10),E=L.tokens===0?0:Math.min(4,Math.floor(Math.log2(L.tokens)/2)+1);b.set(u,E),d.set(u,L.tokens)}const v=new Date(p),F=v.getDay(),m=new Date(v);m.setDate(m.getDate()-(F+6)%7);const y=[],f=new Date(x+se),w=new Date(m);for(let L=0;w.getTime()<f.getTime();L++)y.push(w.getTime()),w.setDate(m.getDate()+7*(L+1));const k=10,B=2,I=y.length*(k+B),M=7*(k+B),R=["","Mon","","Wed","","Fri",""];return e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-start",position:"relative"},children:[e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:B,paddingTop:14},children:R.map((L,u)=>e.jsx("div",{style:{height:k,lineHeight:`${k}px`,fontSize:9,color:n.color.muted,textAlign:"right",paddingRight:4},children:L},u))}),e.jsx("svg",{width:I,height:M,style:{flexShrink:0},children:y.map((L,u)=>Array.from({length:7},(E,A)=>{const z=new Date(new Date(L).getTime()+A*se),h=z.toISOString().slice(0,10),U=b.get(h)??0,H=i[U]??i[0],T=u*(k+B),V=A*(k+B),j=d.get(h)??0,W=z.getTime()>=p&&z.getTime()<=x;return e.jsx("rect",{x:T,y:V,width:k,height:k,rx:2,fill:H,onMouseMove:Y=>a({x:Y.clientX,y:Y.clientY,date:h,tokens:j}),onMouseLeave:()=>a(null),style:{cursor:W?"pointer":"default",opacity:W?1:.35}},h)}))}),s!==null&&e.jsxs("div",{style:{position:"fixed",left:s.x+12,top:s.y+12,zIndex:200,pointerEvents:"none",background:n.color.surface,border:`1px solid ${n.color.border}`,borderRadius:8,padding:"8px 10px",fontSize:12,boxShadow:"0 4px 16px rgba(0,0,0,0.2)",color:n.color.fg,minWidth:120},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:4},children:s.date}),e.jsx("div",{style:{color:n.color.muted},children:s.tokens>0?`${Q(s.tokens)} tokens`:"无活跃"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginLeft:"auto",alignSelf:"flex-end",fontSize:10,color:n.color.muted},children:[e.jsx("span",{children:"较少"}),i.map(L=>e.jsx("span",{style:{width:10,height:10,borderRadius:2,background:L,display:"inline-block"}},L)),e.jsx("span",{children:"较多"})]})]})}function po({daily:r,range:o}){const n=q(),[t,s]=g.useState(null),a=600,i=180,l={top:10,bottom:26,left:0,right:0},x=a-l.left-l.right,p=i-l.top-l.bottom,b=Math.max(...r.map(m=>m.tokens),1),d=Math.max(4,Math.min(12,x/r.length-2)),v=[...new Set(r.flatMap(m=>Object.keys(m.byModel)))].slice(0,8),F=Math.max(1,Math.floor(r.length/6));return e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("svg",{width:"100%",viewBox:`0 0 ${a} ${i}`,style:{display:"block"},children:[[0,.25,.5,.75,1].map(m=>{const y=l.top+p*(1-m);return e.jsxs("g",{children:[e.jsx("line",{x1:l.left,y1:y,x2:a-l.right,y2:y,stroke:n.color.border,strokeWidth:.5,strokeDasharray:"3 3"}),e.jsx("text",{x:l.left+4,y:y-2,fontSize:9,fill:n.color.muted,children:Q(Math.round(b*m))})]},m)}),r.map((m,y)=>{const f=l.left+y/r.length*x+(x/r.length-d)/2;let w=0;return e.jsxs("g",{children:[v.map(k=>{const B=m.byModel[k]??0;if(B===0)return null;const I=B/b*p,M=e.jsx("rect",{x:f,y:l.top+p-w-I,width:d,height:Math.max(1,I),fill:X[v.indexOf(k)%X.length],rx:1},k);return w+=I,M}),e.jsx("rect",{x:l.left+y/r.length*x,y:l.top,width:x/r.length,height:p,fill:"transparent",onMouseMove:k=>s({x:k.clientX,y:k.clientY,day:m}),onMouseLeave:()=>s(null)})]},y)}),r.map((m,y)=>y%F===0?e.jsx("text",{x:l.left+y/r.length*x+x/r.length/2,y:i-7,fontSize:10,fill:n.color.muted,textAnchor:"middle",children:ze(m.ts)},y):null)]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 18px",marginTop:10},children:v.map((m,y)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2,background:X[y%X.length],flexShrink:0}}),e.jsx("span",{style:{fontSize:11,color:n.color.muted,whiteSpace:"nowrap"},children:m.split("/").pop()})]},m))}),t!==null&&e.jsxs("div",{style:{position:"fixed",left:t.x+12,top:t.y+12,zIndex:200,pointerEvents:"none",background:n.color.surface,border:`1px solid ${n.color.border}`,borderRadius:8,padding:"8px 10px",fontSize:12,boxShadow:"0 4px 16px rgba(0,0,0,0.2)",color:n.color.fg,minWidth:140},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:4},children:ze(t.day.ts)}),Object.entries(t.day.byModel).map(([m,y])=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2,background:X[v.indexOf(m)%X.length],flexShrink:0}}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.split("/").pop()}),e.jsx("span",{style:{fontWeight:500},children:Q(y)})]},m)),e.jsxs("div",{style:{borderTop:`1px solid ${n.color.border}`,marginTop:4,paddingTop:4,display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{style:{color:n.color.muted},children:"合计"}),e.jsx("span",{style:{fontWeight:600},children:Q(t.day.tokens)})]})]})]})}function go({segments:r,total:o}){const n=q(),[t,s]=g.useState(null),a=100,i=100,l=70,x=28,p=2*Math.PI*l;let b=0;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:12},children:[e.jsxs("svg",{width:"100%",viewBox:"0 0 200 200",style:{maxWidth:200},children:[r.map(d=>{const v=o>0?d.tokens/o:0,F=v*p,m=`${F} ${p-F}`,y=e.jsx("circle",{cx:a,cy:i,r:l,fill:"none",stroke:d.color,strokeWidth:x,strokeDasharray:m,strokeDashoffset:-b,transform:`rotate(-90 ${a} ${i})`,onMouseMove:f=>s({x:f.clientX,y:f.clientY,seg:d,pct:Math.round(v*100)}),onMouseLeave:()=>s(null),style:{cursor:"pointer"}},d.model);return b+=F,y}),e.jsx("text",{x:a,y:i-6,textAnchor:"middle",fontSize:16,fontWeight:600,fill:n.color.fg,children:Q(o)}),e.jsx("text",{x:a,y:i+10,textAnchor:"middle",fontSize:11,fill:n.color.muted,children:"tokens"})]}),t!==null&&e.jsxs("div",{style:{position:"fixed",left:t.x+12,top:t.y+12,zIndex:200,pointerEvents:"none",background:n.color.surface,border:`1px solid ${n.color.border}`,borderRadius:8,padding:"8px 10px",fontSize:12,boxShadow:"0 4px 16px rgba(0,0,0,0.2)",color:n.color.fg,minWidth:140},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:t.seg.color,flexShrink:0}}),e.jsx("span",{style:{fontWeight:600},children:t.seg.model.split("/").pop()})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12},children:[e.jsxs("span",{style:{color:n.color.muted},children:[Q(t.seg.tokens)," tokens"]}),e.jsxs("span",{style:{fontWeight:600},children:[t.pct,"%"]})]})]}),e.jsx("div",{style:{width:"100%"},children:r.map((d,v)=>{const F=o>0?Math.round(d.tokens/o*100):0;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 0",borderBottom:v<r.length-1?`1px solid ${n.color.border}`:"none"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:d.color,flexShrink:0}}),e.jsx("span",{style:{flex:1,fontSize:12.5,fontWeight:500,color:n.color.fg,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.model.split("/").pop()}),e.jsxs("span",{style:{fontSize:11.5,color:n.color.muted,textAlign:"right"},children:[Q(d.tokens)," tokens"]}),e.jsxs("span",{style:{width:40,fontSize:12,fontWeight:500,color:n.color.fg,textAlign:"right"},children:[F,"%"]})]},d.model)})})]})}function xo({stats:r,t:o}){const[n,t]=g.useState(30),s=ke(),a=Date.now()-n*se,i=g.useMemo(()=>((r==null?void 0:r.daily)??[]).filter(M=>M.ts>=a),[r,n]),l=i.reduce((M,R)=>M+R.tokens,0),x=i.reduce((M,R)=>M+R.messages,0),p=i.reduce((M,R)=>M+R.sessions,0),b=i.length,d=g.useMemo(()=>lo(i),[i]),v=g.useMemo(()=>ao(i),[i]),F=v[0],m=F!==void 0&&l>0?Math.round(F.tokens/l*100):0,y=v.slice(0,6).map((M,R)=>({...M,color:X[R%X.length]??"#6366F1"})),f=e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:e.jsx("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"})}),w=e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),k=e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z"})]}),B=e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),e.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),e.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),I=e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:e.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:24,flexWrap:"wrap",gap:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:24},children:[e.jsx("div",{style:{fontSize:22,fontWeight:600,color:o.color.fg},children:"使用统计"}),e.jsx("div",{style:{fontSize:14,fontWeight:500,color:o.color.fg,borderBottom:`2px solid ${o.color.primary}`,paddingBottom:2},children:"应用用量"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("span",{style:{fontSize:12,color:o.color.muted},children:"时间范围"}),e.jsx(co,{value:n,onChange:t,t:o})]})]}),r===null?e.jsx("div",{style:{color:o.color.muted,fontSize:13,padding:"60px 0",textAlign:"center"},children:"加载中…"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12,marginBottom:24},children:[e.jsx(ie,{icon:f,label:"Tokens 用量",value:Q(l)}),e.jsx(ie,{icon:w,label:"会话数量",value:String(p)}),e.jsx(ie,{icon:k,label:"消息数量",value:String(x)}),e.jsx(ie,{icon:B,label:"活跃天数",value:String(b)}),e.jsx(ie,{icon:B,label:"当前连续天数",value:String(d.current)}),e.jsx(ie,{icon:I,label:"最常用模型",value:(F==null?void 0:F.model.split("/").pop())??"—",sub:F!==void 0?`占比 ${m}%`:void 0})]}),e.jsxs("div",{style:{background:s,border:`1px solid ${o.color.border}`,borderRadius:12,padding:20,marginBottom:24},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:o.color.fg,marginBottom:14},children:"活跃热力图"}),i.length===0?e.jsx("div",{style:{fontSize:12,color:o.color.muted,padding:"8px 0"},children:"所选时间范围内暂无活跃数据。"}):e.jsx(uo,{daily:i,range:n})]}),e.jsxs("div",{style:{display:"flex",gap:14,marginBottom:24,flexWrap:"wrap"},children:[e.jsxs("div",{style:{flex:"2 1 500px",background:s,border:`1px solid ${o.color.border}`,borderRadius:12,padding:20},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:o.color.fg,marginBottom:14},children:"按天 Token 趋势"}),i.length===0?e.jsx("div",{style:{fontSize:12,color:o.color.muted,padding:"8px 0"},children:"暂无数据。"}):e.jsx(po,{daily:i,range:n})]}),e.jsxs("div",{style:{flex:"1 1 320px",background:s,border:`1px solid ${o.color.border}`,borderRadius:12,padding:20},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:o.color.fg,marginBottom:14},children:"模型用量"}),y.length===0?e.jsx("div",{style:{fontSize:12,color:o.color.muted,padding:"8px 0"},children:"暂无数据。"}):e.jsx(go,{segments:y,total:l})]})]})]})]})}const ho=`
2
+ @keyframes vagus-fade-up {
3
+ from { opacity: 0; transform: translateY(10px); }
4
+ to { opacity: 1; transform: translateY(0); }
5
+ }
6
+ @keyframes vagus-pop {
7
+ 0% { opacity: 0; transform: scale(0.96); }
8
+ 60% { opacity: 1; transform: scale(1.01); }
9
+ 100% { opacity: 1; transform: scale(1); }
10
+ }
11
+ @keyframes vagus-shimmer {
12
+ 0% { background-position: -400px 0; }
13
+ 100% { background-position: 400px 0; }
14
+ }
15
+ @keyframes vagus-pulse {
16
+ 0%, 100% { opacity: 1; }
17
+ 50% { opacity: 0.35; }
18
+ }
19
+ @keyframes vagus-spin {
20
+ to { transform: rotate(360deg); }
21
+ }
22
+ .vagus-mcp-input:focus { border-color: var(--vagus-focus, #4f8cff) !important; box-shadow: 0 0 0 3px var(--vagus-focus-ring, rgba(79,140,255,0.18)) !important; }
23
+ .vagus-mcp-btn-press:active { transform: scale(0.96); }
24
+ .vagus-mcp-lift { transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease; }
25
+ .vagus-mcp-lift:hover { transform: translateY(-1px); }
26
+ `;function fo(r){if(typeof r.command=="string"){const o=Array.isArray(r.args)?r.args.join(" "):"";return`${r.command}${o?" "+o:""}`}return typeof r.url=="string"?r.url:JSON.stringify(r).slice(0,80)}function bo(r){return r.type==="http"||typeof r.url=="string"?{label:"HTTP",color:"#3fb950"}:{label:"STDIO",color:"#4f8cff"}}function mo(){return e.jsx("svg",{width:"52",height:"52",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.1",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22v-5M9 8V2M15 8V2M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8h12z"})})}function yo(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"})})}function Te(){return e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})}function jo(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}function vo(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M17 3a2.83 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}function ko(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"7",rx:"2"}),e.jsx("rect",{x:"3",y:"13",width:"18",height:"7",rx:"2"}),e.jsx("path",{d:"M7 7.5h.01M7 16.5h.01M11 7.5h6M11 16.5h6"})]})}function So(){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z"}),e.jsx("path",{d:"M19 15l.9 2.1L22 18l-2.1.9L19 21l-.9-2.1L16 18l2.1-.9L19 15z"})]})}function Fo(r){const o=/("(?:[^"\\]|\\.)*"(?=\s*:))|("(?:[^"\\]|\\.)*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|(true|false|null)|([\]{}[,:])/g,n=[];let t=0,s=0,a;for(;(a=o.exec(r))!==null;){a.index>t&&n.push(r.slice(t,a.index));const[i,l,x,p,b]=a;let d="#8b90a0";l?d="#79c0ff":x?d="#7ee787":p?d="#e3b341":b&&(d="#d2a8ff"),n.push(e.jsx("span",{style:{color:d},children:i},s++)),t=a.index+i.length}return t<r.length&&n.push(r.slice(t)),n}function wo({request:r,t:o}){const{theme:n}=K(),t=n!=="light",[s,a]=g.useState([]),[i,l]=g.useState(!0),[x,p]=g.useState(null),[b,d]=g.useState(!1),[v,F]=g.useState(null),[m,y]=g.useState("form"),[f,w]=g.useState(""),[k,B]=g.useState("stdio"),[I,M]=g.useState(""),[R,L]=g.useState(""),[u,E]=g.useState("30000"),[A,z]=g.useState(""),[h,U]=g.useState(""),[H,T]=g.useState(""),[V,j]=g.useState(null),[W,Y]=g.useState(null),[ee,ce]=g.useState(!1),le=o.color.primary,he=t?`${le}33`:`${le}22`,re=t?"0 1px 2px rgba(0,0,0,0.25), 0 6px 20px rgba(0,0,0,0.18)":"0 1px 2px rgba(15,23,42,0.04), 0 6px 20px rgba(15,23,42,0.06)",fe=t?"radial-gradient(120% 180% at 85% -20%, rgba(79,140,255,0.22), transparent 55%), radial-gradient(100% 160% at 10% -30%, rgba(121,192,255,0.12), transparent 50%)":"radial-gradient(120% 180% at 85% -20%, rgba(37,99,235,0.10), transparent 55%), radial-gradient(100% 160% at 10% -30%, rgba(59,130,246,0.06), transparent 50%)",be=t?"linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.09) 37%, rgba(255,255,255,0.04) 63%)":"linear-gradient(90deg, rgba(0,0,0,0.04) 25%, rgba(0,0,0,0.09) 37%, rgba(0,0,0,0.04) 63%)",ue=g.useCallback(async()=>Promise.resolve(!0),[]);g.useEffect(()=>{ue()},[ue]);const S=g.useCallback(async()=>{l(!0);try{const c=await r("mcp.list");a(c),p(null)}catch(c){p(c instanceof Error?c.message:"加载失败")}finally{l(!1)}},[r]);g.useEffect(()=>{S()},[S]);const D=async()=>{if(p(null),m==="json"){let c;try{c=JSON.parse(H)}catch{p("JSON 格式无效");return}const C=c,P=C.mcpServers??C,_=Object.entries(P);if(_.length===0){p("未找到服务器配置");return}for(const[J,$]of _){const Ce=await r(v?"mcp.update":"mcp.add",{name:J,config:typeof $=="object"&&$!==null?$:{}});if(!Ce.ok){p(`「${J}」${Ce.error??(v?"更新失败":"添加失败")}`);return}}T("")}else{if(!f.trim()){p("请输入名称");return}if(k==="stdio"&&!I.trim()){p("请输入命令");return}if(k==="http"&&!h.trim()){p("请输入 URL");return}let c;if(A.trim())try{c=JSON.parse(A)}catch{p("环境变量 JSON 格式无效");return}const C=Number.parseInt(u,10),P=k==="stdio"?{command:I.trim(),args:R.split(/\s+/).map($=>$.trim()).filter(Boolean),...C>0?{timeout:C}:{},...c?{env:c}:{}}:{type:"http",url:h.trim(),...C>0?{timeout:C}:{}},J=await r(v?"mcp.update":"mcp.add",{name:f.trim(),config:P});if(!J.ok){p(J.error??(v?"更新失败":"添加失败"));return}w(""),M(""),L(""),U(""),z("")}d(!1),F(null),await S(),r("session.reload",{})},O=c=>{F(c),d(!0),y("form"),p(null),w(c.name);const C=c.config,P=C.type==="http"||typeof C.url=="string";B(P?"http":"stdio"),P?(U(typeof C.url=="string"?C.url:""),M(""),L("")):(M(typeof C.command=="string"?C.command:""),L(Array.isArray(C.args)?C.args.join(" "):""),U("")),E(typeof C.timeout=="number"?String(C.timeout):"30000"),z(C.env&&typeof C.env=="object"&&Object.keys(C.env).length>0?JSON.stringify(C.env,null,2):""),T(JSON.stringify({[c.name]:C},null,2))},N=()=>{d(!1),F(null),p(null)},me=async c=>{Y(c);try{const C=await r("mcp.remove",{name:c});if(!C.ok){p(C.error??"移除失败"),Y(null);return}await S(),r("session.reload",{})}catch(C){p(C instanceof Error?C.message:"移除失败")}finally{Y(null)}},Se=(()=>{if(k==="stdio"){if(!I.trim())return null;let C;if(A.trim())try{C=JSON.parse(A)}catch{return null}const P=Number.parseInt(u,10);return{command:I.trim(),args:R.split(/\s+/).map(_=>_.trim()).filter(Boolean),...P>0?{timeout:P}:{},...C?{env:C}:{}}}if(!h.trim())return null;const c=Number.parseInt(u,10);return{type:"http",url:h.trim(),...c>0?{timeout:c}:{}}})(),ae=m==="json"?H.trim()?H:null:Se===null?null:JSON.stringify({[f.trim()||"server-name"]:Se},null,2),$e=async()=>{if(ae!==null)try{await navigator.clipboard.writeText(ae),ce(!0),setTimeout(()=>ce(!1),1600)}catch{}},te={width:"100%",background:t?o.color.bg:"#ffffff",border:`1px solid ${o.color.border}`,borderRadius:10,padding:"9px 12px",fontSize:13,outline:"none",color:o.color.fg,fontFamily:"inherit",boxSizing:"border-box",transition:"border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease"},Fe={...te,fontFamily:"monospace",fontSize:12,minHeight:160,resize:"vertical",lineHeight:1.6,background:o.color.bg},oe={fontSize:12,fontWeight:600,color:o.color.fg,marginBottom:6,display:"block",letterSpacing:"0.01em"},pe={fontSize:11,color:o.color.muted,marginTop:6,lineHeight:1.5},G={marginBottom:18},we={borderRadius:10,padding:"9px 18px",fontSize:13,cursor:"pointer",fontWeight:600,background:`linear-gradient(180deg, ${o.color.primary}, ${t?"#3d74e0":"#1d4fd7"})`,color:"#fff",border:"none",display:"inline-flex",alignItems:"center",gap:7,boxShadow:t?"0 1px 0 rgba(255,255,255,0.12) inset, 0 2px 8px rgba(79,140,255,0.35)":"0 1px 0 rgba(255,255,255,0.5) inset, 0 2px 8px rgba(37,99,235,0.28)",transition:"filter 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease"},ye={borderRadius:10,padding:"9px 16px",fontSize:13,cursor:"pointer",fontWeight:500,background:t?o.color.surface:"#ffffff",color:o.color.fg,border:`1px solid ${o.color.border}`,display:"inline-flex",alignItems:"center",gap:6,transition:"background 0.15s ease, border-color 0.15s ease"},Ne={...ye,color:o.color.muted,border:"none",background:"transparent",padding:"6px 10px",borderRadius:8};return e.jsxs("div",{style:{position:"relative"},children:[e.jsx("style",{children:ho}),e.jsx("div",{style:{position:"relative",background:fe,border:`1px solid ${o.color.border}`,borderRadius:14,padding:"22px 24px",marginBottom:24,overflow:"hidden"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:11,flexShrink:0,background:`linear-gradient(135deg, ${o.color.primary}22, ${o.color.accent}11)`,border:`1px solid ${o.color.primary}30`,display:"flex",alignItems:"center",justifyContent:"center",color:o.color.primary},children:e.jsx(ko,{})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:19,fontWeight:650,color:o.color.fg,letterSpacing:"-0.01em"},children:"MCP 服务器"}),e.jsx("div",{style:{fontSize:12.5,color:o.color.muted,marginTop:3,lineHeight:1.5},children:"连接 Model Context Protocol 服务器,扩展 AI 助手的能力"})]})]})}),i&&e.jsx("div",{style:{fontSize:13,color:o.color.muted,padding:40,textAlign:"center"},children:e.jsx("span",{style:{display:"inline-block",animation:"vagus-pulse 1.4s ease-in-out infinite"},children:"加载 MCP 配置…"})}),!i&&e.jsxs(e.Fragment,{children:[!b&&e.jsxs("div",{style:{animation:"vagus-fade-up 0.35s ease both"},children:[x&&e.jsxs("div",{style:{fontSize:13,color:"#e5484d",background:t?"rgba(248,81,73,0.10)":"rgba(220,38,38,0.06)",border:`1px solid ${t?"rgba(248,81,73,0.25)":"rgba(220,38,38,0.2)"}`,borderRadius:10,padding:"9px 14px",marginBottom:16,display:"flex",alignItems:"center",gap:9,animation:"vagus-pop 0.25s ease both"},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",style:{flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 8v4M12 16h.01",stroke:"#fff",strokeWidth:"2",fill:"none"})]}),x]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:18},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:s.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:o.color.success,display:"inline-block",animation:"vagus-pulse 2.5s ease-in-out infinite"}}),e.jsxs("span",{style:{fontSize:13,color:o.color.muted},children:[s.length," 个服务器已配置"]})]})}),e.jsxs("button",{onClick:()=>d(!0),className:"vagus-mcp-btn-press",style:we,onMouseEnter:c=>{c.currentTarget.style.filter="brightness(1.1)"},onMouseLeave:c=>{c.currentTarget.style.filter="none"},children:[e.jsx(Te,{})," 新建 MCP 服务器"]})]}),i&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[0,1,2].map(c=>e.jsx("div",{style:{height:62,borderRadius:12,background:be,backgroundSize:"800px 100%",animation:"vagus-shimmer 1.6s linear infinite",border:`1px solid ${o.color.border}`}},c))}),!i&&s.length===0&&e.jsxs("div",{style:{padding:56,textAlign:"center",border:`1.5px dashed ${o.color.border}`,borderRadius:16,animation:"vagus-fade-up 0.35s ease both"},children:[e.jsx("div",{style:{color:o.color.muted,marginBottom:14,opacity:.8},children:e.jsx(mo,{})}),e.jsx("div",{style:{fontSize:15,fontWeight:600,color:o.color.fg,marginBottom:6},children:"还没有配置 MCP 服务器"}),e.jsx("div",{style:{fontSize:12.5,color:o.color.muted,lineHeight:1.6},children:"添加一台服务器,让 AI 助手获得新的能力"})]}),!i&&s.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:s.map((c,C)=>{const P=bo(c.config),_=V===c.name,J=W===c.name;return e.jsxs("div",{onMouseEnter:()=>j(c.name),onMouseLeave:()=>j(null),className:"vagus-mcp-lift",style:{display:"flex",alignItems:"center",gap:14,background:_?t?"rgba(255,255,255,0.03)":"#fbfcfe":o.color.surface,border:`1px solid ${_?o.color.primary+"55":o.color.border}`,borderRadius:13,padding:"13px 16px",boxShadow:_?re:"none",opacity:J?.45:1,transition:"opacity 0.2s ease",animation:"vagus-fade-up 0.35s ease both",animationDelay:`${Math.min(C*45,200)}ms`},children:[e.jsx("div",{style:{width:44,height:26,borderRadius:8,background:`${P.color}1c`,color:P.color,fontSize:10,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,letterSpacing:"0.06em",border:`1px solid ${P.color}30`},children:P.label}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{fontSize:13.5,fontWeight:600,color:o.color.fg,marginBottom:3,display:"flex",alignItems:"center",gap:8},children:[c.name,e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:o.color.success,display:"inline-block",animation:_?"vagus-pulse 1.8s ease-in-out infinite":"none",opacity:.9}})]}),e.jsx("div",{style:{fontSize:12,color:o.color.muted,fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:fo(c.config)})]}),e.jsxs("button",{onClick:()=>O(c),className:"vagus-mcp-btn-press",style:ye,onMouseEnter:$=>{$.currentTarget.style.borderColor=o.color.primary,$.currentTarget.style.color=o.color.primary},onMouseLeave:$=>{$.currentTarget.style.borderColor=o.color.border,$.currentTarget.style.color=o.color.fg},children:[e.jsx(vo,{})," 编辑"]}),e.jsx("button",{onClick:()=>void me(c.name),disabled:J,className:"vagus-mcp-btn-press",style:{...Ne,opacity:J?.6:1},onMouseEnter:$=>{$.currentTarget.style.color=o.color.error,$.currentTarget.style.background=t?"rgba(248,81,73,0.10)":"rgba(220,38,38,0.06)"},onMouseLeave:$=>{$.currentTarget.style.color=o.color.muted,$.currentTarget.style.background="transparent"},children:J?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:12,height:12,borderRadius:"50%",border:`2px solid ${o.color.error}40`,borderTopColor:o.color.error,animation:"vagus-spin 0.7s linear infinite",display:"inline-block"}}),"移除中…"]}):e.jsxs(e.Fragment,{children:[e.jsx(yo,{})," 移除"]})})]},c.name)})})]}),b&&e.jsxs("div",{style:{animation:"vagus-fade-up 0.3s ease both"},children:[e.jsxs("button",{onClick:N,style:{border:"none",background:"none",color:o.color.muted,fontSize:12.5,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:5,marginBottom:18,padding:"4px 8px 4px 0",transition:"color 0.15s ease"},onMouseEnter:c=>{c.currentTarget.style.color=o.color.fg},onMouseLeave:c=>{c.currentTarget.style.color=o.color.muted},children:[e.jsx(jo,{})," 返回列表"]}),e.jsx("div",{style:{fontSize:17,fontWeight:650,color:o.color.fg,marginBottom:4,letterSpacing:"-0.01em"},children:v?"编辑 MCP 服务器":"新建 MCP 服务器"}),e.jsx("div",{style:{fontSize:12.5,color:o.color.muted,marginBottom:22,lineHeight:1.5},children:v?`修改「${v.name}」的配置,保存后自动生效`:"填写配置,实时预览生成的 MCP 配置 JSON"}),e.jsxs("div",{style:{display:"flex",position:"relative",background:t?o.color.bg:"#f1f2f4",borderRadius:11,padding:4,marginBottom:22,border:`1px solid ${o.color.border}`},children:[e.jsx("div",{style:{position:"absolute",top:4,bottom:4,left:m==="form"?4:"calc(50% + 0px)",width:"calc(50% - 8px)",background:t?o.color.surface:"#ffffff",borderRadius:8,boxShadow:t?"0 1px 0 rgba(255,255,255,0.06) inset, 0 2px 8px rgba(0,0,0,0.25)":"0 1px 0 rgba(255,255,255,0.8) inset, 0 1px 4px rgba(0,0,0,0.10)",transition:"left 0.22s cubic-bezier(0.22, 1, 0.36, 1)"}}),["form","json"].map(c=>e.jsx("div",{onClick:()=>y(c),style:{flex:1,textAlign:"center",padding:"8px 0",fontSize:13,cursor:"pointer",position:"relative",zIndex:1,color:m===c?o.color.fg:o.color.muted,fontWeight:m===c?600:400,transition:"color 0.2s ease"},children:c==="form"?"表单":"JSON"},c))]}),x&&e.jsxs("div",{style:{fontSize:13,color:"#e5484d",background:t?"rgba(248,81,73,0.10)":"rgba(220,38,38,0.06)",border:`1px solid ${t?"rgba(248,81,73,0.25)":"rgba(220,38,38,0.2)"}`,borderRadius:10,padding:"9px 14px",marginBottom:16,display:"flex",alignItems:"center",gap:9,animation:"vagus-pop 0.25s ease both"},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",style:{flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 8v4M12 16h.01",stroke:"#fff",strokeWidth:"2",fill:"none"})]}),x]}),e.jsxs("div",{style:{display:"flex",gap:20,alignItems:"flex-start"},children:[e.jsxs("div",{style:{flex:1,minWidth:0,minHeight:400},children:[m==="form"&&e.jsxs("div",{style:{background:o.color.bg,border:`1px solid ${o.color.border}`,borderRadius:16,padding:"22px 24px",boxShadow:re},children:[e.jsxs("div",{style:{...G},children:[e.jsx("label",{style:oe,children:"名称"}),e.jsx("input",{className:"vagus-mcp-input",style:te,placeholder:"my-mcp-server",value:f,onChange:c=>w(c.target.value)})]}),e.jsxs("div",{style:{...G,marginBottom:20},children:[e.jsx("label",{style:oe,children:"连接方式"}),e.jsx("div",{style:{display:"flex",gap:10},children:["stdio","http"].map(c=>{const C=k===c;return e.jsx("button",{onClick:()=>B(c),className:"vagus-mcp-btn-press",style:{flex:1,padding:"10px 0",borderRadius:10,fontSize:13,cursor:"pointer",background:C?`linear-gradient(180deg, ${o.color.primary}, ${t?"#3d74e0":"#1d4fd7"})`:t?o.color.bg:"#ffffff",color:C?"#fff":o.color.fg,border:C?"none":`1px solid ${o.color.border}`,fontWeight:C?600:400,boxShadow:C?t?"0 2px 10px rgba(79,140,255,0.30)":"0 2px 10px rgba(37,99,235,0.22)":"none",transition:"all 0.18s ease"},children:c==="stdio"?"stdio(本地命令)":"http(远程)"},c)})})]}),e.jsx("div",{style:{height:1,background:o.color.border,margin:"2px 0 20px",opacity:.7}}),k==="stdio"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{...G},children:[e.jsx("label",{style:oe,children:"命令"}),e.jsx("input",{className:"vagus-mcp-input",style:{...te,fontFamily:"monospace",fontSize:12.5},placeholder:"npx",value:I,onChange:c=>M(c.target.value)})]}),e.jsxs("div",{style:{...G},children:[e.jsx("label",{style:oe,children:"参数"}),e.jsx("input",{className:"vagus-mcp-input",style:{...te,fontFamily:"monospace",fontSize:12.5},placeholder:"-y @modelcontextprotocol/server-memory",value:R,onChange:c=>L(c.target.value)}),e.jsx("div",{style:pe,children:"多个参数用空格分隔"})]})]}):e.jsxs("div",{style:{...G},children:[e.jsx("label",{style:oe,children:"URL"}),e.jsx("input",{className:"vagus-mcp-input",style:{...te,fontFamily:"monospace",fontSize:12.5},placeholder:"https://mcp.example.com",value:h,onChange:c=>U(c.target.value)})]}),e.jsx("div",{style:{height:1,background:o.color.border,margin:"2px 0 20px",opacity:.7}}),e.jsxs("div",{style:{...G},children:[e.jsx("label",{style:oe,children:"超时时间(毫秒)"}),e.jsx("input",{className:"vagus-mcp-input",style:{...te,maxWidth:220},placeholder:"30000",value:u,onChange:c=>E(c.target.value)}),e.jsx("div",{style:pe,children:"默认 30000 ms(30 秒),设为 0 表示不限制"})]}),k==="stdio"&&e.jsxs("div",{style:{...G,marginBottom:0},children:[e.jsx("label",{style:oe,children:"环境变量(可选)"}),e.jsx("textarea",{className:"vagus-mcp-input",style:{...Fe,minHeight:100},placeholder:JSON.stringify({MY_API_KEY:"your-key"},null,2),value:A,onChange:c=>z(c.target.value)}),e.jsx("div",{style:pe,children:"JSON 格式,留空则不设置"})]})]}),m==="json"&&e.jsxs("div",{style:{background:o.color.bg,border:`1px solid ${o.color.border}`,borderRadius:16,padding:"22px 24px",boxShadow:re},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:14},children:[e.jsx(So,{}),e.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:o.color.fg,letterSpacing:"0.02em"},children:"完整配置"})]}),e.jsxs("div",{style:{...G,marginBottom:0},children:[e.jsx("textarea",{className:"vagus-mcp-input",style:{...Fe,minHeight:200},placeholder:JSON.stringify({"my-mcp-server":{type:"http",url:""}},null,2),value:H,onChange:c=>T(c.target.value)}),e.jsxs("div",{style:pe,children:["支持 ","{",'"server-name": ',"{...}","}"," 或 ","{",'"mcpServers": ',"{",'"server-name": ',"{...}","}","}",",可一次添加多台"]})]})]})]}),e.jsx("div",{style:{width:340,flexShrink:0,position:"sticky",top:0},children:e.jsxs("div",{style:{background:o.color.bg,border:`1px solid ${o.color.border}`,borderRadius:16,padding:"16px 18px",boxShadow:re},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:o.color.muted,letterSpacing:"0.06em",textTransform:"uppercase"},children:"预生成配置"}),e.jsx("button",{onClick:()=>void $e(),style:{border:`1px solid ${o.color.border}`,background:"transparent",borderRadius:6,padding:"3px 8px",fontSize:10.5,color:o.color.muted,cursor:"pointer",transition:"all 0.15s ease"},onMouseEnter:c=>{c.currentTarget.style.borderColor=o.color.primary,c.currentTarget.style.color=o.color.primary},onMouseLeave:c=>{c.currentTarget.style.borderColor=o.color.border,c.currentTarget.style.color=o.color.muted},children:ee?"✓ 已复制":"复制"})]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:12,lineHeight:1.6,whiteSpace:"pre",background:t?"rgba(0,0,0,0.2)":"rgba(0,0,0,0.02)",borderRadius:8,padding:"10px 12px",boxSizing:"border-box",overflow:"visible"},children:ae===null?e.jsxs("span",{style:{color:o.color.muted,opacity:.5},children:[`{
27
+ "server-name": {
28
+ }
29
+ `,e.jsx("span",{style:{animation:"vagus-pulse 1.4s ease-in-out infinite"},children:m==="json"?" // 在此粘贴或输入 MCP 配置 JSON":" // 填写左侧表单自动生成"}),`
30
+ }`]}):e.jsxs(e.Fragment,{children:[Fo(ae),e.jsx("div",{style:{height:4}}),e.jsxs("div",{style:{fontSize:10.5,color:o.color.muted,opacity:.5,whiteSpace:"nowrap"},children:[JSON.stringify(ae).length," B"]})]})})]})})]}),e.jsxs("div",{style:{display:"flex",gap:10,marginTop:20},children:[e.jsxs("button",{onClick:()=>void D(),className:"vagus-mcp-btn-press",style:we,onMouseEnter:c=>{c.currentTarget.style.filter="brightness(1.1)"},onMouseLeave:c=>{c.currentTarget.style.filter="none"},children:[e.jsx(Te,{})," ",v?"保存":"添加"]}),e.jsx("button",{onClick:N,className:"vagus-mcp-btn-press",style:ye,children:"取消"})]})]})]}),e.jsx("style",{children:`
31
+ :root { --vagus-focus: ${le}; --vagus-focus-ring: ${he}; }
32
+ `})]})}const We={wrench:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M14.7 6.3a4.5 4.5 0 0 0-6.4 6.4L3 18v3h3l5.3-5.3a4.5 4.5 0 0 0 6.4-6.4l-3 3-2.3-2.3 3-3z"})}),box:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M3 17l9 4 9-4M3 12l9 4 9-4M3 7l9 4 9-4-9-4z"})}),puzzle:e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 7a4 4 0 1 1 3 6.9c-.8-.4-1.3-1.2-1.3-2.1V9h-2.8A2.8 2.8 0 0 1 10 6.2c0-.8.3-1.5.8-2.1A4 4 0 0 1 14 7z"}),e.jsx("path",{d:"M4 14a4 4 0 0 0 6.9 3A4 4 0 0 0 5 12.7h2.8V10A2.8 2.8 0 0 1 11.8 8c.8 0 1.5.3 2.1.8a4 4 0 0 0-3 6.9V14H7.6z"})]})},Co=e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 8v4M12 16h.01"})]});let ge;function Bo({request:r,t:o}){const{theme:n}=K(),t=n!=="light",[s,a]=g.useState(()=>ge??[]),[i,l]=g.useState(ge===void 0),[x,p]=g.useState(null),[b,d]=g.useState(null),v=g.useCallback(f=>{ge=f,a(f)},[]);g.useEffect(()=>{let f=!1;return(async()=>{try{const w=await r("skills.list");f||(v(w),p(null))}catch(w){!f&&ge===void 0&&p(w instanceof Error?w.message:"加载失败")}finally{f||l(!1)}})(),()=>{f=!0}},[v,r]);const F=g.useCallback(async f=>{d(f.name),p(null);try{const w=await r("skills.setEnabled",{name:f.name,enabled:!f.enabled});v(w)}catch(w){p(w instanceof Error?w.message:"切换失败")}finally{d(null)}},[v,r]),m=s.filter(f=>f.source==="agents").length,y={local:{label:"本地",accent:"#818cf8",icon:"wrench"},agents:{label:"共享",accent:"#34d399",icon:"box"},package:{label:"包",accent:"#f59e0b",icon:"puzzle"},project:{label:"项目",accent:"#3b82f6",icon:"layers"}};return e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:22},children:[e.jsx("h1",{style:{margin:0,fontSize:22,fontWeight:700,letterSpacing:"-0.02em",color:o.color.fg},children:"技能"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,marginTop:8,fontSize:12.5,color:o.color.muted},children:[e.jsx("span",{children:"全局可复用的技能包,按名称去重"}),!i&&s.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",style:{color:o.color.border},children:"·"}),e.jsxs("span",{children:[s.length," 个技能"]}),e.jsx("span",{"aria-hidden":"true",style:{color:o.color.border},children:"·"}),e.jsxs("span",{children:[m," 共享"]})]})]})]}),x&&e.jsxs("div",{role:"alert",style:{display:"flex",alignItems:"flex-start",gap:9,fontSize:12.5,lineHeight:1.55,color:o.color.error,background:t?"rgba(248,81,73,0.09)":"rgba(220,38,38,0.05)",border:`1px solid ${t?"rgba(248,81,73,0.24)":"rgba(220,38,38,0.18)"}`,borderRadius:11,padding:"10px 13px",marginBottom:18},children:[e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{marginTop:1,flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 8v5M12 17h.01"})]}),e.jsx("span",{children:x})]}),i&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:11,padding:"40px 0",color:o.color.muted,fontSize:13},children:[e.jsx("span",{style:{width:13,height:13,flexShrink:0,border:"2px solid currentColor",borderRightColor:"transparent",borderRadius:"50%",animation:"sk-spin 700ms linear infinite"}}),"正在读取技能…"]}),!i&&s.length===0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:200,color:o.color.muted},children:[e.jsx("div",{style:{width:42,height:42,borderRadius:12,display:"flex",alignItems:"center",justifyContent:"center",color:o.color.muted,background:t?"rgba(15,17,23,0.5)":"rgba(245,246,250,0.9)",marginBottom:12},children:We.box}),e.jsx("div",{style:{color:o.color.fg,fontSize:14,fontWeight:650},children:"暂无全局技能"}),e.jsx("div",{style:{marginTop:5,fontSize:12.5},children:"在 ~/.pi/agent/skills/ 或 ~/.agents/skills/ 添加 SKILL.md。"})]}),!i&&s.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2},children:s.map((f,w)=>{const k=y[f.source]??{label:"其他",accent:"#8b90a0",icon:"box"},B=w===s.length-1;return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr) auto",alignItems:"center",gap:13,padding:"11px 10px",borderRadius:10,borderBottom:B?"none":`1px solid ${o.color.border}`,transition:"background 140ms ease",opacity:b===f.name?.6:1},onMouseEnter:I=>{I.currentTarget.style.background=t?"rgba(129,140,248,0.07)":"rgba(99,102,241,0.05)"},onMouseLeave:I=>{I.currentTarget.style.background="transparent"},children:[e.jsx("div",{style:{width:38,height:38,borderRadius:10,flexShrink:0,background:`${k.accent}16`,color:k.accent,border:`1px solid ${k.accent}28`,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("span",{style:{transform:"scale(1.1)",display:"flex"},children:We[k.icon]??Co})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[e.jsx("h3",{style:{margin:0,fontSize:13.5,lineHeight:1.3,fontWeight:660,color:o.color.fg},children:f.name}),e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,lineHeight:1,fontWeight:650,color:k.accent,background:`${k.accent}16`,border:`1px solid ${k.accent}28`,borderRadius:999,padding:"2.5px 7px"},children:k.label})]}),f.description&&e.jsx("p",{style:{margin:"3px 0 0",fontSize:12,lineHeight:1.5,color:o.color.muted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.description}),e.jsx("div",{style:{marginTop:4,fontSize:10.5,color:o.color.muted,fontFamily:o.font.mono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.path})]}),e.jsx("button",{role:"switch","aria-checked":f.enabled,"aria-label":`${f.enabled?"禁用":"启用"}技能 ${f.name}`,disabled:b===f.name,onClick:()=>void F(f),style:{width:40,height:22,borderRadius:99,border:"none",cursor:"pointer",position:"relative",flexShrink:0,background:f.enabled?"linear-gradient(120deg, #818cf8, #8b5cf6)":o.color.border,transition:"background 150ms ease"},children:e.jsx("span",{style:{position:"absolute",top:2,left:f.enabled?20:2,width:18,height:18,borderRadius:"50%",background:"#fff",boxShadow:"0 1px 3px rgba(0,0,0,0.25)",transition:"left 150ms ease"}})})]},`${f.source}:${f.name}`)})}),e.jsx("style",{children:`
33
+ @keyframes sk-spin { to { transform: rotate(360deg); } }
34
+ @media (prefers-reduced-motion: reduce) {
35
+ [data-theme] * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
36
+ }
37
+ `})]})}function To({providers:r,usageStats:o,onClose:n,onSave:t,onRefresh:s,onTest:a,cat:i,onCatChange:l,onProbe:x,request:p,projectCwd:b}){const d=q(),v=He(),[F,m]=g.useState(()=>({uiFontSize:v.uiFontSize,showLineNumbers:v.showLineNumbers,wrapLongLines:v.wrapLongLines,codeFontSize:v.codeFontSize})),y=M=>m(R=>({...R,...M})),f=()=>{v.update(F),n()},w=M=>({display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:9,fontSize:13,cursor:"pointer",background:M?d.color.surface:"transparent",color:M?d.color.fg:d.color.muted,fontWeight:M?500:400}),k={fontSize:11,fontWeight:600,color:d.color.muted,padding:"14px 10px 6px",letterSpacing:"0.05em"},{theme:B}=K(),I={width:"100%",background:B==="light"?"#ffffff":d.color.surface,border:`1px solid ${d.color.border}`,borderRadius:8,padding:"8px 12px",fontSize:13,outline:"none",color:d.color.fg};return e.jsxs("div",{style:{flex:1,display:"flex",minHeight:0,background:d.color.bg,fontSize:14},children:[e.jsxs("aside",{style:{width:220,flexShrink:0,borderRight:`1px solid ${d.color.border}`,padding:"20px 12px",display:"flex",flexDirection:"column",gap:4,overflowY:"auto"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"0 10px 14px"},children:[e.jsx("span",{style:{fontSize:15,fontWeight:600,color:d.color.fg},children:"设置"}),e.jsx("button",{onClick:f,style:{marginLeft:"auto",border:"none",background:"none",color:d.color.muted,fontSize:12,cursor:"pointer"},children:"← 返回"})]}),e.jsx("div",{style:k,children:"基础设置"}),e.jsxs("div",{style:w(i==="appearance"),onClick:()=>l("appearance"),children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:e.jsx("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z"})}),"外观"]}),e.jsxs("div",{style:w(i==="models"),onClick:()=>l("models"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),"模型设置"]}),e.jsx("div",{style:k,children:"Agents 能力"}),e.jsxs("div",{style:w(i==="mcp"),onClick:()=>l("mcp"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M4 20h4l10-10a2.83 2.83 0 0 0-4-4L4 16v4z"}),e.jsx("path",{d:"M13.5 6.5l4 4"})]}),"MCP 服务器"]}),e.jsxs("div",{style:w(i==="skills"),onClick:()=>l("skills"),children:[e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:e.jsx("path",{d:"M14.7 6.3a4.5 4.5 0 0 0-6.4 6.4L3 18v3h3l5.3-5.3a4.5 4.5 0 0 0 6.4-6.4l-3 3-2.3-2.3 3-3z"})}),"技能"]}),e.jsx("div",{style:k,children:"数据与统计"}),e.jsxs("div",{style:w(i==="usage"),onClick:()=>l("usage"),children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:[e.jsx("path",{d:"M3 3v18h18"}),e.jsx("path",{d:"M7 14l4-4 3 3 5-6"})]}),"使用统计"]})]}),e.jsx("main",{style:{flex:1,overflowY:"auto",minWidth:0,padding:"28px 36px 60px",scrollbarGutter:"stable"},children:e.jsxs("div",{style:{maxWidth:980,margin:"0 auto"},children:[i==="usage"&&e.jsx(xo,{stats:o,t:d}),i==="models"&&e.jsx(ro,{providers:r,inputStyle:I,t:d,onSave:t,onRefresh:s,onTest:a,onProbe:x}),i==="appearance"&&e.jsx(to,{draft:F,onChange:y,t:d}),i==="mcp"&&e.jsx(wo,{request:p,t:d}),i==="skills"&&e.jsx(Bo,{request:p,t:d})]})})]})}const Eo=["npm:@foo/pi-tools","git:github.com/user/repo","/absolute/path/to/package"],ve="linear-gradient(120deg, #818cf8 0%, #a78bfa 55%, #c084fc 100%)";let xe;function Do(r){const o=[];return r.resources.extensions>0&&o.push(`${r.resources.extensions} 扩展`),r.resources.skills>0&&o.push(`${r.resources.skills} 技能`),r.resources.prompts>0&&o.push(`${r.resources.prompts} 模板`),r.resources.themes>0&&o.push(`${r.resources.themes} 主题`),o.length>0?o.join(" · "):"未声明资源"}function Wo({request:r,t:o,onClose:n}){const{theme:t}=K(),s=t!=="light",[a,i]=g.useState(()=>xe??[]),[l,x]=g.useState(xe===void 0),[p,b]=g.useState(null),[d,v]=g.useState(null),[F,m]=g.useState(""),[y,f]=g.useState(!1),[w,k]=g.useState(null),B=g.useCallback(u=>{xe=u,i(u)},[]),I=g.useCallback(async()=>{const u=await r("plugin.list");B(u),b(null)},[B,r]);g.useEffect(()=>{let u=!1;return(async()=>{try{const E=await r("plugin.list");u||(B(E),b(null))}catch(E){!u&&xe===void 0&&b(E instanceof Error?E.message:"加载失败")}finally{u||x(!1)}})(),()=>{u=!0}},[B,r]);const M=async u=>{const E=u.trim();if(!E){b("请输入包源,例如 npm:@foo/pi-tools");return}f(!0),b(null);try{const A=await r("plugin.install",{source:E});if(!A.ok){b(A.error??"安装失败");return}m(""),await I()}catch(A){b(A instanceof Error?A.message:"安装失败")}finally{f(!1)}},R=async u=>{v(u),b(null);try{const E=await r("plugin.uninstall",{source:u});if(!E.ok){b(E.error??"卸载失败");return}await I()}catch(E){b(E instanceof Error?E.message:"卸载失败")}finally{v(null)}},L=a.reduce((u,E)=>(u.extensions+=E.resources.extensions,u.skills+=E.resources.skills,u.prompts+=E.resources.prompts,u.themes+=E.resources.themes,u),{extensions:0,skills:0,prompts:0,themes:0});return e.jsxs("div",{style:{flex:1,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",background:o.color.bg,color:o.color.fg,overflow:"hidden",fontFamily:o.font.sans},children:[e.jsx("style",{children:`
38
+ .piweb-pkg * { box-sizing: border-box; }
39
+ .piweb-pkg-back:focus-visible, .piweb-pkg-action:focus-visible, .piweb-pkg-install:focus-visible {
40
+ outline: 3px solid rgba(129,140,248,0.4);
41
+ outline-offset: 2px;
42
+ }
43
+ .piweb-pkg-action:active:not(:disabled) { transform: scale(0.97); }
44
+ .piweb-pkg-action:disabled { cursor: wait !important; opacity: 0.6; }
45
+ .piweb-pkg-spinner {
46
+ width: 13px; height: 13px; flex-shrink: 0;
47
+ border: 2px solid currentColor;
48
+ border-right-color: transparent;
49
+ border-radius: 50%;
50
+ animation: piweb-pkg-spin 700ms linear infinite;
51
+ }
52
+ @keyframes piweb-pkg-spin { to { transform: rotate(360deg); } }
53
+ @media (prefers-reduced-motion: reduce) {
54
+ .piweb-pkg *, .piweb-pkg *::before, .piweb-pkg *::after {
55
+ animation-duration: 0.01ms !important;
56
+ animation-iteration-count: 1 !important;
57
+ transition-duration: 0.01ms !important;
58
+ }
59
+ }
60
+ `}),e.jsxs("header",{style:{flex:"none",display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"0 18px",height:54,borderBottom:`1px solid ${o.color.border}`,background:s?"rgba(15,17,23,0.88)":"rgba(255,255,255,0.9)",backdropFilter:"blur(12px)",position:"relative",zIndex:2},children:[e.jsx("div",{style:{position:"absolute",left:0,right:0,top:0,height:2,background:ve,opacity:.9,pointerEvents:"none"}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("button",{className:"piweb-pkg-back",onClick:n,"aria-label":"返回上一页",style:{width:40,height:40,border:`1px solid ${o.color.border}`,borderRadius:9,background:"transparent",color:o.color.muted,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",transition:"color 150ms ease, border-color 150ms ease, background 150ms ease"},onMouseEnter:u=>{u.currentTarget.style.color="#a5b4fc",u.currentTarget.style.borderColor="rgba(129,140,248,0.5)",u.currentTarget.style.background="rgba(129,140,248,0.09)"},onMouseLeave:u=>{u.currentTarget.style.color=o.color.muted,u.currentTarget.style.borderColor=o.color.border,u.currentTarget.style.background="transparent"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),e.jsx("div",{style:{fontSize:14,fontWeight:680,letterSpacing:"-0.01em",color:o.color.fg},children:"Pi 包管理"})]}),e.jsxs("div",{"aria-live":"polite",style:{display:"inline-flex",alignItems:"center",gap:7,fontSize:11.5,fontWeight:550,color:o.color.muted},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5},children:[e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})}),a.filter(u=>u.installed).length," 已安装"]}),L.extensions>0&&e.jsxs("span",{children:["· ",L.extensions," 扩展"]})]})]}),e.jsx("main",{className:"piweb-pkg-scroll",style:{flex:1,overflowY:"auto",padding:"26px 32px 60px",scrollbarGutter:"stable",background:s?"radial-gradient(1100px 380px at 50% -140px, rgba(99,102,241,0.14), transparent 72%)":"radial-gradient(1100px 380px at 50% -140px, rgba(99,102,241,0.09), transparent 72%)"},children:e.jsxs("div",{style:{width:"100%",maxWidth:980,margin:"0 auto"},children:[e.jsxs("div",{style:{marginBottom:22,textAlign:"center"},children:[e.jsx("h1",{style:{margin:0,fontSize:28,lineHeight:1.15,fontWeight:760,letterSpacing:"-0.025em",background:ve,WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent"},children:"Pi 包管理"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",flexWrap:"wrap",gap:8,marginTop:9,fontSize:12.5,color:o.color.muted},children:[e.jsx("span",{children:"与 pi CLI 完全互通 —— 这里安装的包,"}),e.jsx("code",{style:{fontFamily:o.font.mono,fontSize:11.5,color:o.color.fg,background:o.color.surface,padding:"1px 6px",borderRadius:5},children:"pi list"}),e.jsx("span",{children:"同样可见,反之亦然"})]})]}),e.jsxs("div",{style:{display:"flex",gap:9,marginBottom:22,padding:14,borderRadius:14,background:s?"rgba(129,140,248,0.06)":"rgba(99,102,241,0.05)",border:`1px solid ${s?"rgba(129,140,248,0.18)":"rgba(99,102,241,0.16)"}`},children:[e.jsx("input",{className:"piweb-pkg-install",value:F,onChange:u=>m(u.target.value),onKeyDown:u=>{u.key==="Enter"&&M(F)},placeholder:"输入包源安装,例如 npm:@foo/pi-tools","aria-label":"Pi 包源",style:{flex:1,minWidth:0,height:40,borderRadius:9,border:`1px solid ${o.color.border}`,background:s?"rgba(0,0,0,0.25)":"#ffffff",padding:"0 13px",fontSize:13,fontFamily:o.font.mono,color:o.color.fg,outline:"none"},onFocus:u=>{u.currentTarget.style.borderColor="rgba(129,140,248,0.6)"},onBlur:u=>{u.currentTarget.style.borderColor=o.color.border}}),e.jsxs("button",{className:"piweb-pkg-action",onClick:()=>void M(F),disabled:y,style:{height:40,padding:"0 20px",borderRadius:9,border:"none",background:ve,color:"#fff",fontSize:13,fontWeight:650,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:7,boxShadow:"0 4px 12px rgba(99,102,241,0.24)"},children:[y&&e.jsx("span",{className:"piweb-pkg-spinner"}),y?"安装中":"安装"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:20,fontSize:11.5,color:o.color.muted,flexWrap:"wrap"},children:[e.jsx("span",{children:"支持:"}),Eo.map(u=>e.jsx("button",{onClick:()=>m(u),style:{fontFamily:o.font.mono,fontSize:11,color:"#a5b4fc",background:"rgba(129,140,248,0.09)",border:`1px solid ${s?"rgba(129,140,248,0.22)":"rgba(99,102,241,0.18)"}`,borderRadius:999,padding:"3px 9px",cursor:"pointer"},children:u},u)),e.jsx("span",{"aria-hidden":"true",style:{color:o.color.border},children:"·"}),e.jsx("span",{children:e.jsx("a",{href:"https://pi.dev/packages",target:"_blank",rel:"noreferrer",style:{color:"#a5b4fc",textDecoration:"none"},children:"浏览 pi.dev/packages ↗"})})]}),p&&e.jsxs("div",{role:"alert",style:{display:"flex",alignItems:"flex-start",gap:9,fontSize:12.5,lineHeight:1.55,color:o.color.error,background:s?"rgba(248,81,73,0.09)":"rgba(220,38,38,0.05)",border:`1px solid ${s?"rgba(248,81,73,0.24)":"rgba(220,38,38,0.18)"}`,borderRadius:11,padding:"10px 13px",marginBottom:18},children:[e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{marginTop:1,flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M12 8v5M12 17h.01"})]}),e.jsx("span",{children:p})]}),l&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:11,padding:"40px 0",color:o.color.muted,fontSize:13},children:[e.jsx("span",{className:"piweb-pkg-spinner"}),"正在读取已安装的包…"]}),!l&&a.length===0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:220,color:o.color.muted},children:[e.jsx("div",{style:{width:42,height:42,borderRadius:12,display:"flex",alignItems:"center",justifyContent:"center",color:"#a5b4fc",background:"rgba(129,140,248,0.1)",marginBottom:12,fontSize:18},children:"📦"}),e.jsx("div",{style:{color:o.color.fg,fontSize:14,fontWeight:650},children:"还没有安装任何 pi 包"}),e.jsxs("div",{style:{marginTop:5,fontSize:12.5,textAlign:"center"},children:["在上面输入 ",e.jsx("code",{style:{fontFamily:o.font.mono,fontSize:11.5,color:o.color.fg},children:"npm:@包名"})," 安装,或到"," ",e.jsx("a",{href:"https://pi.dev/packages",target:"_blank",rel:"noreferrer",style:{color:"#a5b4fc"},children:"pi.dev/packages"})," ","浏览生态。"]})]}),!l&&a.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:a.map(u=>{const E=w===u.source,A=d===u.source;return e.jsxs("article",{className:"piweb-pkg-row",onMouseEnter:()=>k(u.source),onMouseLeave:()=>k(null),style:{display:"flex",alignItems:"center",gap:13,padding:"12px 14px",borderRadius:12,border:`1px solid ${o.color.border}`,background:E?s?"rgba(129,140,248,0.07)":"rgba(99,102,241,0.04)":"transparent",borderLeft:E?"3px solid #818cf8":"3px solid transparent",paddingLeft:E?11:14,transition:"background 140ms ease, border-left-color 140ms ease, padding-left 140ms ease",opacity:A?.6:1},children:[e.jsx("div",{style:{width:36,height:36,borderRadius:10,flexShrink:0,background:"rgba(129,140,248,0.1)",color:"#a5b4fc",border:"1px solid rgba(129,140,248,0.22)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M14 7a4 4 0 1 1 3 6.9c-.8-.4-1.3-1.2-1.3-2.1V9h-2.8A2.8 2.8 0 0 1 10 6.2c0-.8.3-1.5.8-2.1A4 4 0 0 1 14 7z"}),e.jsx("path",{d:"M4 14a4 4 0 0 0 6.9 3A4 4 0 0 0 5 12.7h2.8V10A2.8 2.8 0 0 1 11.8 8c.8 0 1.5.3 2.1.8a4 4 0 0 0-3 6.9V14H7.6z"})]})}),e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("code",{style:{fontSize:12.5,fontWeight:650,color:o.color.fg,fontFamily:o.font.mono},children:u.source}),e.jsx("span",{style:{fontSize:10,fontWeight:650,letterSpacing:"0.02em",color:u.scope==="user"?"#a5b4fc":o.color.muted,background:u.scope==="user"?"rgba(129,140,248,0.1)":"transparent",border:`1px solid ${u.scope==="user"?"rgba(129,140,248,0.25)":o.color.border}`,borderRadius:999,padding:"2px 7px"},children:u.scope==="user"?"全局":"项目"}),u.installed?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,fontWeight:650,color:"#3fb950",background:"rgba(63,185,80,0.09)",border:"1px solid rgba(63,185,80,0.16)",borderRadius:999,padding:"2.5px 7px"},children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})}),"已安装"]}):e.jsx("span",{style:{fontSize:10,fontWeight:650,color:o.color.warning,background:"rgba(210,153,34,0.09)",border:"1px solid rgba(210,153,34,0.18)",borderRadius:999,padding:"2.5px 7px"},children:"未安装"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:7,marginTop:4,fontSize:11,color:o.color.muted},children:[e.jsx("span",{children:Do(u)}),u.installedPath&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",style:{color:o.color.border},children:"·"}),e.jsx("code",{style:{fontFamily:o.font.mono,fontSize:10.5,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:300},children:u.installedPath})]})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:e.jsxs("button",{className:"piweb-pkg-action",onClick:()=>void R(u.source),disabled:A,"aria-label":`卸载 ${u.source}`,style:{minHeight:34,borderRadius:8,padding:"0 13px",fontSize:12,cursor:"pointer",fontWeight:600,border:`1px solid ${o.color.border}`,background:"transparent",color:o.color.fg,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},onMouseEnter:z=>{A||(z.currentTarget.style.borderColor=o.color.error,z.currentTarget.style.color=o.color.error,z.currentTarget.style.background=s?"rgba(248,81,73,0.06)":"rgba(220,38,38,0.04)")},onMouseLeave:z=>{z.currentTarget.style.borderColor=o.color.border,z.currentTarget.style.color=o.color.fg,z.currentTarget.style.background="transparent"},children:[A&&e.jsx("span",{className:"piweb-pkg-spinner"}),A?"卸载中":"卸载"]})})]},u.source)})}),e.jsxs("div",{style:{marginTop:26,fontSize:11.5,lineHeight:1.7,color:o.color.muted,textAlign:"center"},children:["在 pi TUI 中用 ",e.jsx("code",{style:{fontFamily:o.font.mono,fontSize:11,color:o.color.fg},children:"pi install npm:<包名>"})," 安装的包同样出现在这里。",e.jsx("br",{}),"卸载请到 TUI 使用 ",e.jsx("code",{style:{fontFamily:o.font.mono,fontSize:11,color:o.color.fg},children:"pi remove"}),',或在这里点击"卸载"。']})]})})]})}export{wo as McpView,Wo as PluginsView,To as SettingsView};