@versot/vaguspi 0.1.3 → 0.1.4

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.
@@ -1,4 +1,4 @@
1
- var Ze=Object.defineProperty;var Xe=(r,o,t)=>o in r?Ze(r,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[o]=t;var Z=(r,o,t)=>Xe(r,typeof o!="symbol"?o+"":o,t);import{r as c,j as e}from"./vendor-CkEpMl6t.js";const Qe={color:{primary:"#4f8cff",bg:"#0f1117",sidebarBg:"#12141a",sidebarHover:"#1b1f2b",surface:"#161922",fg:"#e6e8ee",muted:"#8b90a0",border:"#2a2e3a",success:"#3fb950",warning:"#d29922",error:"#f85149",accent:"#79c0ff"},spacing:{xs:4,sm:8,md:16,lg:24,xl:32},radius:{sm:4,md:8,lg:12},font:{mono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",sans:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"}},qe={color:{primary:"#2563eb",bg:"#ffffff",sidebarBg:"#f6f7f9",sidebarHover:"#eceef1",surface:"#f3f4f6",fg:"#1f2937",muted:"#6b7280",border:"#e5e7eb",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",accent:"#3b82f6"},spacing:{xs:4,sm:8,md:16,lg:24,xl:32},radius:{sm:4,md:8,lg:12},font:{mono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",sans:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"}},Fe=Qe,eo={bg:"#ffffff",header:"#f6f8fa",border:"#d0d7de",text:"#24292f",keyword:"#cf222e",fn:"#8250df",type:"#953800",prop:"#0550ae",str:"#0a3069"},oo={bg:"#0d1117",header:"#161b22",border:"#30363d",text:"#c9d1d9",keyword:"#ff7b72",fn:"#d2a8ff",type:"#ffa657",prop:"#79c0ff",str:"#a5d6ff"};function ro(r){return r==="GitHub Light"?eo:oo}function no(r,o){const t=[],n=/("(?:[^"\\]|\\.)*")|([a-zA-Z_$][\w$]*)(?=\s*:\s*[A-Z][A-Za-z0-9]*)|\b(const|let|var|function|return|import|export|from|new|type|interface|extends|async|await)\b|([a-zA-Z_$][\w$]*)(?=\s*:)|#[0-9a-fA-F]{3,8}\b|\b(?:true|false|null|undefined)\b|\b\d+(?:\.\d+)?\b/g;let i=0,a;for(;(a=n.exec(r))!==null;){a.index>i&&t.push({text:r.slice(i,a.index)});const[,s,d,f,p,m,g,k]=a;s!==void 0?t.push({text:s,color:o.str}):d!==void 0?t.push({text:d,color:o.fn}):f!==void 0?t.push({text:f,color:o.keyword}):p!==void 0?t.push({text:p,color:o.prop}):m!==void 0?t.push({text:m,color:o.str}):g!==void 0?t.push({text:g,color:o.keyword}):k!==void 0&&t.push({text:k,color:o.prop}),i=n.lastIndex}return i<r.length&&t.push({text:r.slice(i)}),t}class Zo{constructor(o,t={}){Z(this,"transport");Z(this,"nextId",0);Z(this,"pending",new Map);Z(this,"eventListeners",new Set);Z(this,"requestTimeoutMs");Z(this,"unsubscribe");Z(this,"closed",!1);this.transport=o,this.requestTimeoutMs=t.requestTimeoutMs??3e5,this.unsubscribe=o.onFrame(n=>this.handleFrame(n))}request(o,t){if(this.closed)return Promise.reject(new Error("client is closed"));const n=this.nextId++,i=String(n);return new Promise((a,s)=>{const d=setTimeout(()=>{this.pending.delete(i),s(new Error(`request timed out: ${o}`))},this.requestTimeoutMs);this.pending.set(i,{resolve:a,reject:s,timer:d}),this.transport.send({type:"request",payload:{jsonrpc:"2.0",id:n,method:o,params:t}})})}notify(o,t){this.closed||this.transport.send({type:"request",payload:{jsonrpc:"2.0",id:null,method:o,params:t}})}onEvent(o){return this.eventListeners.add(o),()=>this.eventListeners.delete(o)}close(){if(!this.closed){this.closed=!0,this.unsubscribe();for(const[,o]of this.pending)clearTimeout(o.timer),o.reject(new Error("client closed"));this.pending.clear(),this.transport.close()}}handleFrame(o){if(o.type==="event"){for(const i of this.eventListeners)i(o.payload.event);return}if(o.type!=="response")return;const t=String(o.payload.id),n=this.pending.get(t);n&&(this.pending.delete(t),clearTimeout(n.timer),this.settle(n,o.payload))}settle(o,t){if(t.error){const n=new Error(`${t.error.message} (code ${t.error.code})`);t.error.data!==void 0&&(n.data=t.error.data),o.reject(n);return}o.resolve(t.result)}}const Pe="vagus.theme.v2",we=c.createContext(void 0);function to(){var r,o;return typeof window<"u"&&((o=(r=window.matchMedia)==null?void 0:r.call(window,"(prefers-color-scheme: dark)"))==null?void 0:o.matches)===!0}function io(){const r=localStorage.getItem(Pe);return r==="light"||r==="dark"||r==="system"?r:"light"}function Xo({children:r}){const[o,t]=c.useState(io),[n,i]=c.useState(to),a=o==="system"?n?"dark":"light":o;c.useEffect(()=>{localStorage.setItem(Pe,o),document.documentElement.setAttribute("data-theme",a)},[o,a]),c.useEffect(()=>{if(o!=="system")return;const d=window.matchMedia("(prefers-color-scheme: dark)"),f=p=>i(p.matches);return d.addEventListener("change",f),()=>d.removeEventListener("change",f)},[o]);const s=c.useMemo(()=>({theme:a,preference:o,tokens:a==="light"?qe:Fe,setPreference:t,toggleTheme:()=>t(d=>d==="light"?"dark":"light")}),[a,o]);return e.jsx(we.Provider,{value:s,children:r})}function _(){const r=c.useContext(we);return r||{theme:"dark",preference:"dark",tokens:Fe,setPreference:()=>{},toggleTheme:()=>{}}}function re(){const r=c.useContext(we);return r?r.tokens:Fe}const Oe="vagus.appearance.v1",ee={uiFontSize:14,showLineNumbers:!0,wrapLongLines:!0,codeFontSize:12},He=c.createContext(void 0);function so(){try{const r=localStorage.getItem(Oe);if(r===null)return ee;const o=JSON.parse(r);return{uiFontSize:typeof o.uiFontSize=="number"?o.uiFontSize:ee.uiFontSize,showLineNumbers:typeof o.showLineNumbers=="boolean"?o.showLineNumbers:ee.showLineNumbers,wrapLongLines:typeof o.wrapLongLines=="boolean"?o.wrapLongLines:ee.wrapLongLines,codeFontSize:typeof o.codeFontSize=="number"?o.codeFontSize:ee.codeFontSize}}catch{return ee}}function Qo({children:r}){const[o,t]=c.useState(so);c.useEffect(()=>{localStorage.setItem(Oe,JSON.stringify(o))},[o]);const n=c.useMemo(()=>({...o,update:i=>t(a=>({...a,...i}))}),[o]);return e.jsx(He.Provider,{value:n,children:r})}function lo(){const r=c.useContext(He);return r||{...ee,update:()=>{}}}function ao({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 uo({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 Me({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 co({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 po({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 go({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 xo({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 Ke({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 fo({providers:r,selectedId:o,adding:t,onSelect:n,onAdd:i,t:a}){const{theme:s}=_();return e.jsxs("div",{style:{width:220,flexShrink:0,borderRight:`1px solid ${a.color.border}`,padding:10,background:s==="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:i,title:"添加供应商",onMouseEnter:d=>d.currentTarget.style.color=a.color.fg,onMouseLeave:d=>d.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(Ke,{size:14})})]}),r.length===0&&!t&&e.jsx("div",{style:{fontSize:12,color:a.color.muted,padding:"8px 10px"},children:"暂无供应商"}),r.map(d=>{const f=o===d.id&&!t,p=d.enabled!==!1;return e.jsxs("div",{onClick:()=>n(d.id),onMouseEnter:m=>{f||(m.currentTarget.style.background=a.color.surface)},onMouseLeave:m=>{f||(m.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:f?a.color.border:"transparent"},children:[e.jsx(uo,{size:14}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.id}),e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:p?"#10B981":a.color.muted,flexShrink:0}})]},d.id)})]})}const Ae=[{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 ho(r){return r>=1e6?`${(r/1e6).toFixed(1)}M`:r>=1e3?`${Math.round(r/1e3)}K`:String(r)}function _e({value:r,onChange:o,t}){var d;const[n,i]=c.useState(!1),a=he(),s=((d=Ae.find(f=>f.value===r))==null?void 0:d.label)??r;return e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{type:"button",onClick:()=>i(f=>!f),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,background:a,border:`1px solid ${t.color.border}`,borderRadius:8,padding:"8px 12px",fontSize:13,color:t.color.fg,cursor:"pointer"},children:[e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s}),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"})})]}),n&&e.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:50,background:a,border:`1px solid ${t.color.border}`,borderRadius:10,padding:4,boxShadow:"0 8px 24px rgba(0,0,0,0.25)"},children:Ae.map(f=>{const p=f.value===r;return e.jsxs("button",{type:"button",onClick:()=>{o(f.value),i(!1)},style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",border:"none",background:p?t.color.border:"transparent",color:t.color.fg,borderRadius:7,padding:"7px 10px",fontSize:12.5,cursor:"pointer",textAlign:"left"},children:[e.jsx("span",{children:f.label}),p&&e.jsx("span",{style:{color:t.color.primary},children:"✓"})]},f.value)})})]})}function X({label:r,children:o}){const t=re();return e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,color:t.color.muted,marginBottom:6},children:r}),o]})}function ke({title:r,description:o,children:t}){const{theme:n}=_(),i=re(),a=n==="light"?"#ffffff":i.color.surface;return e.jsxs("div",{style:{marginBottom:30},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:i.color.fg,marginBottom:4},children:r}),o!==void 0&&e.jsx("div",{style:{fontSize:12,color:i.color.muted,marginBottom:10,lineHeight:1.5},children:o}),e.jsx("div",{style:{background:a,border:`1px solid ${i.color.border}`,borderRadius:12,overflow:"hidden"},children:t})]})}function he(){const{theme:r}=_(),o=re();return r==="light"?"#ffffff":o.color.surface}function ue({label:r,hint:o,control:t,t:n,last:i=!1}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:24,padding:"13px 18px",borderBottom:i?"none":`1px solid ${n.color.border}`},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{fontSize:13,color:n.color.fg},children:r}),o!==void 0&&e.jsx("div",{style:{fontSize:11.5,color:n.color.muted,marginTop:3,lineHeight:1.5},children:o})]}),e.jsx("div",{style:{flexShrink:0},children:t})]})}function mo({options:r,value:o,onChange:t,t:n}){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:r.map(i=>{const a=i.value===o;return e.jsx("button",{onClick:()=>t(i.value),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",whiteSpace:"nowrap"},children:i.label},i.value)})})}function ze({checked:r,onChange:o,t}){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?t.color.accent:t.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 Te({value:r,onChange:o,min:t=10,max:n=20,t:i}){const[a,s]=c.useState(String(r));c.useEffect(()=>{s(String(r))},[r]);const d=p=>{const m=p.trim();if(m===""){s(String(r));return}const g=Number(m);Number.isFinite(g)?o(Math.min(n,Math.max(t,Math.round(g)))):s(String(r))},f={width:26,height:30,border:"none",background:"transparent",color:i.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 ${i.color.border}`,borderRadius:8,overflow:"hidden",background:i.color.bg},children:[e.jsx("button",{onClick:()=>o(Math.max(t,r-1)),style:f,"aria-label":"减小字号",children:"−"}),e.jsx("input",{type:"text",inputMode:"numeric",value:a,onChange:p=>s(p.target.value.replace(/[^\d]/g,"")),onBlur:()=>d(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:i.color.fg,fontSize:12.5}}),e.jsx("button",{onClick:()=>o(Math.min(n,r+1)),style:f,"aria-label":"增大字号",children:"+"}),e.jsx("span",{style:{paddingRight:10,fontSize:12,color:i.color.muted},children:"px"})]})}function bo({form:r,setForm:o,onAdd:t,canAdd:n,inputStyle:i,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(X,{label:"名称",children:e.jsx("input",{style:i,placeholder:"如:openai",value:r.id,onChange:s=>o({...r,id:s.target.value})})}),e.jsx(X,{label:"Base URL",children:e.jsx("input",{style:i,placeholder:"https://api.example.com/v1",value:r.baseUrl,onChange:s=>o({...r,baseUrl:s.target.value})})}),e.jsx(X,{label:"API Key",children:e.jsx("input",{style:i,type:"password",placeholder:"输入 API Key(可选)",value:r.apiKey,onChange:s=>o({...r,apiKey:s.target.value})})}),e.jsx(X,{label:"API 格式",children:e.jsx(_e,{value:r.api,onChange:s=>o({...r,api:s}),t:a})}),e.jsx("button",{onClick:t,disabled:!n,onMouseEnter:s=>{n&&(s.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:s=>{s.currentTarget.style.filter="none"},style:{width:"100%",background:n?a.color.primary:a.color.border,color:n?"#fff":a.color.muted,border:"none",borderRadius:10,padding:"11px 16px",fontSize:13.5,fontWeight:500,cursor:n?"pointer":"default",transition:"filter 0.15s"},children:"添加供应商"})]})}function Ue(r,o){return r==="light"?"#ffffff":o.color.surface}function yo({open:r,form:o,setForm:t,onAdd:n,onClose:i,inputStyle:a,t:s,onProbe:d,provider:f}){const{theme:p}=_(),[m,g]=c.useState("idle"),k=c.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:i,children:e.jsxs("div",{style:{background:Ue(p,s),border:`1px solid ${s.color.border}`,borderRadius:14,padding:22,width:400,maxWidth:"90vw",boxShadow:"0 12px 40px rgba(0,0,0,0.35)"},onClick:C=>C.stopPropagation(),children:[e.jsx("div",{style:{fontSize:15,fontWeight:600,color:s.color.fg},children:"添加模型"}),e.jsx("div",{style:{fontSize:12,color:s.color.muted,margin:"4px 0 18px"},children:"配置模型的标识与参数,保存后可在聊天中选用。"}),e.jsx(X,{label:"模型 ID",children:e.jsx("input",{style:a,autoFocus:!0,placeholder:"如 gpt-4o(自动探测兼容配置)",value:o.id,onChange:C=>{const D=C.target.value;if(t(F=>({...F,id:D})),k.current!==void 0&&window.clearTimeout(k.current),d&&f&&D.trim()!==""){const F=D.trim();g("probing"),k.current=window.setTimeout(()=>{k.current=void 0,d({baseUrl:f.baseUrl,api:f.api,apiKey:f.apiKey,model:F}).then(h=>{h.ok&&h.compat?(t(j=>{var S;return j.id.trim()===F?{...j,compat:h.compat??void 0,reasoning:h.reasoning,vision:((S=h.input)==null?void 0:S.includes("image"))??j.vision}:j}),g("ok")):g("fail")}).catch(()=>g("fail"))},600)}else g("idle")},onKeyDown:C=>{C.key==="Enter"&&o.id.trim()!==""&&m!=="probing"&&n()}})}),(()=>{if(o.id.trim()!==""){if(m==="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(m==="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(m==="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:s.color.muted,marginBottom:4},children:"上下文窗口 (tokens)"}),e.jsx("input",{style:a,type:"number",min:0,placeholder:"2000000",value:o.contextWindow,onChange:C=>t({...o,contextWindow:C.target.value})})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11.5,fontWeight:500,color:s.color.muted,marginBottom:4},children:"最大输出 (tokens)"}),e.jsx("input",{style:a,type:"number",min:0,placeholder:"131072",value:o.maxTokens,onChange:C=>t({...o,maxTokens:C.target.value})})]})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,marginTop:14,cursor:"pointer",fontSize:12.5,color:s.color.fg,userSelect:"none"},children:[e.jsx("input",{type:"checkbox",checked:o.vision,onChange:C=>t({...o,vision:C.target.checked}),style:{width:15,height:15,accentColor:s.color.primary,cursor:"pointer"}}),e.jsx("span",{children:"支持图片理解"}),e.jsx("span",{style:{color:s.color.muted,fontSize:11},children:"(决定聊天中能否添加图片附件)"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:20},children:[e.jsx("button",{onClick:i,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,disabled:o.id.trim()===""||m==="probing",onMouseEnter:C=>{o.id.trim()!==""&&m!=="probing"&&(C.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:C=>{C.currentTarget.style.filter="none"},style:{background:s.color.primary,color:"#fff",border:"none",borderRadius:8,padding:"7px 18px",fontSize:12.5,fontWeight:500,cursor:o.id.trim()===""||m==="probing"?"not-allowed":"pointer",transition:"filter 0.15s",opacity:o.id.trim()===""||m==="probing"?.5:1},children:m==="probing"?"正在探测…":"添加"})]})]})}):null}function jo({confirmDeleteId:r,providers:o,onConfirm:t,onClose:n,t:i}){var s;const{theme:a}=_();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:n,children:e.jsxs("div",{style:{background:Ue(a,i),border:`1px solid ${i.color.border}`,borderRadius:14,padding:22,width:340,maxWidth:"90vw",boxShadow:"0 12px 40px rgba(0,0,0,0.35)"},onClick:d=>d.stopPropagation(),children:[e.jsx("div",{style:{fontSize:15,fontWeight:600,color:i.color.fg},children:"删除供应商"}),e.jsxs("div",{style:{fontSize:12.5,color:i.color.muted,margin:"10px 0 22px",lineHeight:1.7},children:["确定删除供应商 ",e.jsxs("span",{style:{color:i.color.fg,fontWeight:500},children:["“",((s=o.find(d=>d.id===r))==null?void 0:s.id)??r,"”"]})," 吗?其下模型将一并移除,此操作不可撤销。"]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx("button",{onClick:n,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(r),n()},onMouseEnter:d=>d.currentTarget.style.filter="brightness(1.15)",onMouseLeave:d=>d.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 vo({provider:r,detail:o,setDetail:t,showKey:n,setShowKey:i,testingId:a,testResult:s,editingModelId:d,modelForm:f,setModelForm:p,addModelOpen:m,addModelForm:g,setAddModelForm:k,confirmDeleteId:C,providers:D,onToggleEnabled:F,onDelete:h,onConfirmDelete:j,onTest:S,onAddModel:z,onRemoveModel:W,onStartEdit:E,onSaveEdit:I,onCancelEdit:O,onCancelDelete:l,onOpenAddModel:v,onCloseAddModel:B,inputStyle:A,t:x,onProbe:R}){const{theme:N}=_(),T=r,Y=N==="light"?"#ffffff":x.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:{...A,flex:1,minWidth:120,fontWeight:600,fontSize:14},value:o.id,onChange:b=>t({...o,id:b.target.value}),"aria-label":"供应商名称"}),e.jsxs("div",{style:{display:"inline-flex",background:x.color.bg,border:`1px solid ${x.color.border}`,borderRadius:99,padding:2,gap:2,flexShrink:0},children:[e.jsx("button",{onClick:F,onMouseEnter:b=>{T.enabled!==!1&&(b.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:b=>{b.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":x.color.muted,transition:"filter 0.15s"},children:"已启用"}),e.jsx("button",{onClick:F,onMouseEnter:b=>{T.enabled===!1&&(b.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:b=>{b.currentTarget.style.filter="none"},style:{border:"none",borderRadius:99,padding:"4px 12px",fontSize:12,cursor:"pointer",background:T.enabled===!1?x.color.fg:"transparent",color:T.enabled===!1?x.color.bg:x.color.muted,transition:"filter 0.15s"},children:"禁用"})]}),e.jsx("button",{onClick:h,title:"删除供应商",onMouseEnter:b=>{b.currentTarget.style.borderColor="#E5484D",b.currentTarget.style.color="#E5484D"},onMouseLeave:b=>{b.currentTarget.style.borderColor=x.color.border,b.currentTarget.style.color=x.color.muted},style:{background:"transparent",border:`1px solid ${x.color.border}`,color:x.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(Me,{})})]}),e.jsx(X,{label:"Base URL",children:e.jsx("input",{style:A,placeholder:"https://api.example.com/v1",value:o.baseUrl,onChange:b=>t({...o,baseUrl:b.target.value})})}),e.jsx(X,{label:"API 格式",children:e.jsx(_e,{value:o.api,onChange:b=>t({...o,api:b}),t:x})}),e.jsx(X,{label:"API Key",children:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{style:{...A,flex:1},type:n?"text":"password",placeholder:"留空保持不变",value:o.apiKey,onChange:b=>t({...o,apiKey:b.target.value})}),e.jsx("button",{onClick:()=>i(!n),title:n?"隐藏":"显示",onMouseEnter:b=>b.currentTarget.style.color=x.color.fg,onMouseLeave:b=>b.currentTarget.style.color=x.color.muted,style:{background:"transparent",border:`1px solid ${x.color.border}`,color:x.color.muted,borderRadius:8,width:34,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0,transition:"all 0.15s"},children:n?e.jsx(go,{}):e.jsx(po,{})})]})}),e.jsx("div",{style:{fontSize:13,fontWeight:600,color:x.color.fg,marginBottom:8},children:"模型列表"}),T.models.length===0&&e.jsx("div",{style:{fontSize:12,color:x.color.muted,marginBottom:10},children:"暂无模型 — 添加一个以在聊天中可用。"}),T.models.map(b=>e.jsxs("div",{children:[e.jsxs("div",{onMouseEnter:L=>L.currentTarget.style.background=x.color.border,onMouseLeave:L=>L.currentTarget.style.background=Y,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",borderRadius:8,background:Y,marginBottom:6,fontSize:13,transition:"background 0.15s"},children:[e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.name??b.id}),b.contextWindow!==void 0&&e.jsx("span",{style:{fontSize:11,color:x.color.fg,background:x.color.bg,border:`1px solid ${x.color.border}`,borderRadius:99,padding:"2px 8px",flexShrink:0},children:ho(b.contextWindow)}),a===b.id?e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",style:{color:x.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":`测试 ${b.id}`,onClick:()=>S(b.id),onMouseEnter:L=>L.currentTarget.style.color=x.color.fg,onMouseLeave:L=>L.currentTarget.style.color=x.color.muted,style:{color:x.color.muted,cursor:"pointer",display:"flex",padding:2,transition:"color 0.15s"},children:e.jsx(xo,{size:13})}),e.jsx("span",{role:"button","aria-label":`编辑 ${b.id}`,onClick:()=>E(b),onMouseEnter:L=>L.currentTarget.style.color=x.color.fg,onMouseLeave:L=>L.currentTarget.style.color=x.color.muted,style:{color:x.color.muted,cursor:"pointer",display:"flex",padding:2,transition:"color 0.15s"},children:e.jsx(co,{size:13})}),e.jsx("span",{role:"button","aria-label":`删除模型 ${b.id}`,onClick:()=>W(b.id),onMouseEnter:L=>L.currentTarget.style.color=x.color.fg,onMouseLeave:L=>L.currentTarget.style.color=x.color.muted,style:{color:x.color.muted,cursor:"pointer",display:"flex",padding:2,transition:"color 0.15s"},children:e.jsx(Me,{size:13})})]}),(s==null?void 0:s.modelId)===b.id&&e.jsx("div",{style:{marginBottom:8},children:s.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:s.status===0?"无法连接":s.reason==="auth"?"认证失败":s.reason==="model"?"模型不存在":`连接失败 (HTTP ${s.status})`})}),d===b.id&&e.jsxs("div",{style:{background:x.color.bg,border:`1px solid ${x.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:x.color.muted,marginBottom:4},children:"上下文窗口 (tokens)"}),e.jsx("input",{style:A,type:"number",min:0,placeholder:"128000",value:f.contextWindow,onChange:L=>p({...f,contextWindow:L.target.value})})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11.5,fontWeight:500,color:x.color.muted,marginBottom:4},children:"最大输出 (tokens)"}),e.jsx("input",{style:A,type:"number",min:0,placeholder:"8192",value:f.maxTokens,onChange:L=>p({...f,maxTokens:L.target.value})})]})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,marginTop:12,cursor:"pointer",fontSize:12.5,color:x.color.fg,userSelect:"none"},children:[e.jsx("input",{type:"checkbox",checked:f.vision,onChange:L=>p({...f,vision:L.target.checked}),style:{width:15,height:15,accentColor:x.color.primary,cursor:"pointer"}}),e.jsx("span",{children:"支持图片理解"}),e.jsx("span",{style:{color:x.color.muted,fontSize:11},children:"(聊天中能否添加图片附件)"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:10},children:[e.jsx("button",{onClick:O,style:{background:"transparent",border:`1px solid ${x.color.border}`,color:x.color.muted,borderRadius:7,padding:"5px 14px",fontSize:12,cursor:"pointer"},children:"取消"}),e.jsx("button",{onClick:I,style:{background:x.color.primary,color:"#fff",border:"none",borderRadius:7,padding:"5px 14px",fontSize:12,fontWeight:500,cursor:"pointer"},children:"保存"})]})]})]},b.id)),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:12},children:e.jsxs("button",{onClick:v,onMouseEnter:b=>{b.currentTarget.style.borderColor=x.color.fg,b.currentTarget.style.color=x.color.fg},onMouseLeave:b=>{b.currentTarget.style.borderColor=x.color.border,b.currentTarget.style.color=x.color.muted},style:{background:"transparent",border:`1px dashed ${x.color.border}`,color:x.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(Ke,{size:13})," 添加模型"]})}),e.jsx(yo,{open:m,form:g,setForm:k,onAdd:z,onClose:B,inputStyle:A,t:x,onProbe:R,provider:r}),e.jsx(jo,{confirmDeleteId:C,providers:D,onConfirm:j,onClose:l,t:x})]})}function ko({providers:r,inputStyle:o,t,onSave:n,onRefresh:i,onTest:a,onProbe:s}){const[d,f]=c.useState(null),[p,m]=c.useState(!1),[g,k]=c.useState({id:"",baseUrl:"",api:"openai-completions",apiKey:""}),[C,D]=c.useState(!1),[F,h]=c.useState({id:"",baseUrl:"",apiKey:"",api:"openai-completions"}),[j,S]=c.useState(!1),[z,W]=c.useState({id:"",contextWindow:"2000000",maxTokens:"131072",vision:!1}),[E,I]=c.useState(null),[O,l]=c.useState(null),[v,B]=c.useState(null),[A,x]=c.useState({contextWindow:"",maxTokens:"",vision:!0}),[R,N]=c.useState(void 0),T=d!==null&&!p?r.find(y=>y.id===d)??null:null,Y=y=>{const M=r.find(P=>P.id===y);if(!M)return;f(y),m(!1),B(null),N(void 0);const H={id:M.id,baseUrl:M.baseUrl,api:M.api,apiKey:M.apiKey??""};U.current=JSON.stringify(H),k(H)},b=()=>{m(!0),f(null),B(null),h({id:"",baseUrl:"",apiKey:"",api:"openai-completions"})},L=()=>{const y=F.id.trim(),M=F.baseUrl.trim();if(!y||!M)return;n([...r,{id:y,baseUrl:M,api:F.api,apiKey:F.apiKey.trim()||void 0,models:[]}]);const H={id:y,baseUrl:M,api:F.api,apiKey:F.apiKey};U.current=JSON.stringify(H),m(!1),f(y),k(H)},Q=y=>{n(r.filter(M=>M.id!==y)),d===y&&(f(null),U.current="",k({id:"",baseUrl:"",api:"openai-completions",apiKey:""}))};c.useEffect(()=>{if(!p&&d===null&&r.length>0){const y=r[0];y!==void 0&&Y(y.id)}},[p,r.length,d]);const U=c.useRef("");c.useEffect(()=>{if(d===null||!r.find(P=>P.id===d))return;const M=JSON.stringify(g);if(M===U.current)return;const H=window.setTimeout(()=>{(async()=>{const P=g.id.trim(),je=g.baseUrl.trim();P&&(U.current=M,await n(r.map(te=>te.id===d?{...te,id:P,baseUrl:je||te.baseUrl,api:g.api,apiKey:g.apiKey.trim()!==""?g.apiKey.trim():te.apiKey}:te)),P!==d&&f(P))})()},700);return()=>window.clearTimeout(H)},[g,d]);const ce=()=>{T&&n(r.map(y=>y.id===T.id?{...y,enabled:y.enabled===!1}:y))},ae=async y=>{if(!T)return;l(y),N(void 0);const M=await a({baseUrl:g.baseUrl.trim()||T.baseUrl,api:g.api||T.api,apiKey:g.apiKey.trim()||T.apiKey,model:y});N({modelId:y,...M}),l(null)},me=()=>{if(!T)return;const y=z.id.trim();if(!y)return;const M=z.compat,H=z.reasoning;n(r.map(P=>P.id===T.id?{...P,models:[...P.models,{id:y,contextWindow:z.contextWindow!==""?Number(z.contextWindow):void 0,maxTokens:z.maxTokens!==""?Number(z.maxTokens):void 0,input:z.vision?["text","image"]:["text"],...H!==void 0?{reasoning:H}:{},...M?{compat:M}:{}}]}:P)),S(!1)},ne=y=>{T&&(n(r.map(M=>M.id===T.id?{...M,models:M.models.filter(H=>H.id!==y)}:M)),v===y&&B(null))},be=y=>{var M;B(y.id),x({contextWindow:y.contextWindow!==void 0?String(y.contextWindow):"",maxTokens:y.maxTokens!==void 0?String(y.maxTokens):"",vision:((M=y.input)==null?void 0:M.includes("image"))??!0})},ye=()=>{!T||v===null||(n(r.map(y=>y.id===T.id?{...y,models:y.models.map(M=>M.id===v?{...M,contextWindow:A.contextWindow!==""?Number(A.contextWindow):void 0,maxTokens:A.maxTokens!==""?Number(A.maxTokens):void 0,input:A.vision?["text","image"]:["text"]}:M)}:y)),B(null))},pe=F.id.trim()!==""&&F.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:t.color.fg},children:"模型设置"}),e.jsx("div",{style:{fontSize:13,color:t.color.muted,margin:"4px 0 0"},children:"管理自定义模型供应商,配置后可在聊天时选择使用。"})]}),e.jsx("button",{onClick:i,title:"刷新配置",style:{background:"transparent",border:`1px solid ${t.color.border}`,color:t.color.muted,borderRadius:8,width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0},children:e.jsx(ao,{})})]}),e.jsxs("div",{style:{display:"flex",border:`1px solid ${t.color.border}`,borderRadius:14,overflow:"hidden",background:t.color.bg},children:[e.jsx(fo,{providers:r,selectedId:d,adding:p,onSelect:Y,onAdd:b,t}),e.jsx("div",{style:{flex:1,padding:"22px 24px",minWidth:0},children:!p&&T!==null?e.jsx(vo,{provider:T,detail:g,setDetail:k,showKey:C,setShowKey:D,testingId:O,testResult:R,editingModelId:v,modelForm:A,setModelForm:x,addModelOpen:j,addModelForm:z,setAddModelForm:W,confirmDeleteId:E,providers:r,onToggleEnabled:ce,onDelete:()=>I(d),onConfirmDelete:y=>Q(y),onTest:ae,onAddModel:me,onRemoveModel:ne,onStartEdit:be,onSaveEdit:ye,onCancelEdit:()=>B(null),onCancelDelete:()=>I(null),onOpenAddModel:()=>{W({id:"",contextWindow:"2000000",maxTokens:"131072",vision:!1}),S(!0)},onCloseAddModel:()=>S(!1),inputStyle:o,t,onProbe:s}):e.jsx(bo,{form:F,setForm:h,onAdd:L,canAdd:pe,inputStyle:o,t})})]})]})}const So=["const themePreview: ThemeConfig = {",' surface: "sidebar",',' accent: "#339CFF",'," contrast: 45,","};"];function Le({title:r,themeName:o,dark:t,active:n,showLineNumbers:i,codeFontSize:a,t:s}){const d=ro(o),f=n?"当前生效":t?"深色":"浅色";return e.jsxs("div",{style:{flex:"1 1 300px",background:d.bg,border:`1px solid ${d.border}`,borderRadius:12,overflow:"hidden",boxShadow:n?`0 0 0 1.5px ${s.color.accent}`:"none"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:d.header,borderBottom:`1px solid ${d.border}`},children:[e.jsx("span",{style:{fontSize:12,color:d.text,opacity:.85},children:r}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:11,color:d.text,opacity:.6},children:o}),e.jsx("span",{style:{fontSize:11,fontWeight:500,color:n?"#fff":d.text,background:n?s.color.accent:"transparent",border:n?"none":`1px solid ${d.border}`,borderRadius:99,padding:"2px 10px"},children:f})]})]}),e.jsx("div",{style:{padding:"12px 0 14px",fontSize:a,lineHeight:1.65,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",color:d.text},children:So.map((p,m)=>e.jsxs("div",{style:{display:"flex",paddingLeft:16,paddingRight:16},children:[i&&e.jsx("span",{style:{width:26,flexShrink:0,textAlign:"right",marginRight:14,color:d.text,opacity:.35,userSelect:"none"},children:m+1}),e.jsx("span",{style:{whiteSpace:"pre"},children:no(p,d).map((g,k)=>g.color!==void 0?e.jsx("span",{style:{color:g.color},children:g.text},k):g.text)})]},m))})]})}function Fo({draft:r,onChange:o,t}){const{theme:n,preference:i,setPreference:a}=_();return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:22,fontWeight:600,color:t.color.fg},children:"外观"}),e.jsxs("div",{style:{marginTop:24},children:[e.jsxs(ke,{title:"界面设置",description:"设置应用主题和界面文字大小。",children:[e.jsx(ue,{label:"界面主题",hint:"选择浅色、深色或跟随系统主题。",control:e.jsx(mo,{options:[{value:"light",label:"浅色"},{value:"dark",label:"深色"},{value:"system",label:"跟随系统"}],value:i,onChange:a,t}),t}),e.jsx(ue,{label:"界面字号",hint:"调整应用界面的文字大小,图标和布局尺寸不受影响。",last:!0,control:e.jsx(Te,{value:r.uiFontSize,onChange:s=>o({uiFontSize:s}),t}),t})]}),e.jsxs(ke,{title:"代码设置",description:"设置代码内容的主题、字号和显示方式,不受界面字号影响。",children:[e.jsx(ue,{label:"显示行号",hint:"在代码内容和差异视图中显示行号。",control:e.jsx(ze,{checked:r.showLineNumbers,onChange:s=>o({showLineNumbers:s}),t}),t}),e.jsx(ue,{label:"长行自动换行",hint:"代码内容过长时自动换行。",control:e.jsx(ze,{checked:r.wrapLongLines,onChange:s=>o({wrapLongLines:s}),t}),t}),e.jsx(ue,{label:"代码字号",hint:"调整代码块、文件预览和差异视图的默认字号。",last:!0,control:e.jsx(Te,{value:r.codeFontSize,onChange:s=>o({codeFontSize:s}),min:10,max:24,t}),t})]}),e.jsx(ke,{title:"代码预览",description:"同时预览浅色与深色代码主题,当前界面使用的主题会标记为“当前生效”。",children:e.jsxs("div",{style:{display:"flex",gap:14,flexWrap:"wrap",padding:18},children:[e.jsx(Le,{title:"浅色预览",themeName:"GitHub Light",dark:!1,active:n==="light",showLineNumbers:r.showLineNumbers,codeFontSize:r.codeFontSize,t}),e.jsx(Le,{title:"深色预览",themeName:"GitHub Dark",dark:!0,active:n==="dark",showLineNumbers:r.showLineNumbers,codeFontSize:r.codeFontSize,t})]})})]})]})}const oe=864e5,Ie=["#6366F1","#22D3EE","#FBBF24","#F472B6","#34D399","#A78BFA","#F87171","#60A5FA"],wo=["#ebedf0","#9be9a8","#40c463","#30a14e","#216e39"],Co=["#272b33","#0e4429","#006d32","#26a641","#39d353"];function le(r){return r>=1e9?`${(r/1e9).toFixed(2)}G`:r>=1e6?`${(r/1e6).toFixed(1)}M`:r>=1e3?`${(r/1e3).toFixed(1)}K`:String(Math.round(r))}function Je(r){return r>=1e3?`$${(r/1e3).toFixed(2)}K`:r>=100?`$${r.toFixed(1)}`:`$${r.toFixed(2)}`}function We(r){return`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}function Bo(r){const o=[...new Set(r.map(s=>Math.floor(s.ts/oe)))].toSorted((s,d)=>s-d);let t=0,n=0;for(let s=0;s<o.length;s++)n=s===0||o[s]===(o[s-1]??0)+1?n+1:1,n>t&&(t=n);const i=Math.floor(Date.now()/oe);let a=0;for(let s=o.length-1;s>=0&&o[s]===i-a;s--)a++;return{current:a,longest:t}}function Eo(r){const o=new Map;for(const t of r)for(const[n,i]of Object.entries(t.byModel))o.set(n,(o.get(n)??0)+i);return[...o.entries()].map(([t,n])=>({model:t,tokens:n})).toSorted((t,n)=>n.tokens-t.tokens)}function se({label:r,value:o,sub:t,accent:n}){const i=re(),a=he();return e.jsxs("div",{style:{background:a,border:`1px solid ${i.color.border}`,borderRadius:14,padding:"18px 20px",display:"flex",flexDirection:"column",gap:6},children:[e.jsx("div",{style:{fontSize:12,color:i.color.muted,fontWeight:500},children:r}),e.jsx("div",{style:{fontSize:26,fontWeight:700,color:n??i.color.fg,letterSpacing:"-0.02em",fontVariantNumeric:"tabular-nums"},children:o}),t!==void 0&&e.jsx("div",{style:{fontSize:11.5,color:i.color.muted},children:t})]})}function Do({daily:r}){const o=re(),{theme:t}=_(),[n,i]=c.useState(null),a=t==="light"?wo:Co,s=new Date;s.setHours(0,0,0,0);const d=s.getTime(),f=d-52*7*oe,p=new Map,m=new Map,g=Math.max(...r.map(l=>l.tokens),0),k=g>0?Math.log2(g):1;for(const l of r){const v=We(new Date(l.ts)),B=l.tokens===0?0:Math.max(1,Math.min(4,Math.round(Math.log2(l.tokens)/k*4)));p.set(v,B),m.set(v,l.tokens)}const C=new Date(f),D=new Date(C);D.setDate(D.getDate()-(C.getDay()+6)%7);const F=D.getTime(),h=[];for(let l=0;F+l*7*oe<d+oe;l++)h.push(F+l*7*oe);const j=13,S=3,z=20,W=h.length*(j+S),E=7*(j+S)+z,I=["","Mon","","Wed","","Fri",""],O=[];{let l=-1,v=0;for(let B=0;B<h.length;B++){const A=h[B];if(A===void 0)continue;const x=new Date(A),R=x.getFullYear()*100+x.getMonth();if(R!==l){if(l!==-1){const N=B*(j+S)-v;O.push({x:v+N/2,label:`${l%100+1}月`})}l=R,v=B*(j+S)}}if(l!==-1){const B=h.length*(j+S)-v;O.push({x:v+B/2,label:`${l%100+1}月`})}}return e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-start",position:"relative"},children:[e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:S,paddingTop:14},children:I.map((l,v)=>e.jsx("div",{style:{height:j,lineHeight:`${j}px`,fontSize:9,color:o.color.muted,textAlign:"right",paddingRight:4},children:l},v))}),e.jsx("div",{style:{flex:1,minWidth:0},children:e.jsxs("svg",{viewBox:`0 0 ${W} ${E}`,width:"100%",preserveAspectRatio:"xMinYMin meet",style:{display:"block"},children:[h.map((l,v)=>Array.from({length:7},(B,A)=>{const x=new Date(new Date(l).getTime()+A*oe),R=We(x),N=x.getTime()>d,T=N?0:p.get(R)??0,Y=a[T]??a[0],b=v*(j+S),L=A*(j+S),Q=N?0:m.get(R)??0;return e.jsx("rect",{x:b,y:L,width:j,height:j,rx:2.5,fill:Y,onMouseMove:U=>{N||i({x:U.clientX,y:U.clientY,date:R,tokens:Q})},onMouseLeave:()=>i(null)},R)})),O.map((l,v)=>e.jsx("text",{x:l.x,y:7*(j+S)+z-4,fontSize:9,fill:o.color.muted,textAnchor:"middle",children:l.label},`${l.label}-${v}`))]})}),n!==null&&e.jsxs("div",{style:{position:"fixed",left:n.x+12,top:n.y+12,zIndex:200,pointerEvents:"none",background:o.color.surface,border:`1px solid ${o.color.border}`,borderRadius:8,padding:"8px 10px",fontSize:12,boxShadow:"0 4px 16px rgba(0,0,0,0.2)",color:o.color.fg,minWidth:110},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:4},children:n.date}),e.jsx("div",{style:{color:o.color.muted},children:n.tokens>0?`${le(n.tokens)} tokens`:"无活跃"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,alignSelf:"flex-end",fontSize:10,color:o.color.muted},children:[e.jsx("span",{children:"较少"}),a.map(l=>e.jsx("span",{style:{width:10,height:10,borderRadius:2,background:l,display:"inline-block"}},l)),e.jsx("span",{children:"较多"})]})]})}function $e({title:r,rows:o,total:t,mode:n}){const i=re(),a=he(),s=o.slice(0,6),d=o.slice(6).reduce((p,m)=>p+m.value,0),f=d>0?[...s,{model:"其他",value:d}]:s;return e.jsxs("div",{style:{background:a,border:`1px solid ${i.color.border}`,borderRadius:14,padding:20},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:i.color.fg,marginBottom:16},children:r}),f.length===0?e.jsx("div",{style:{fontSize:12,color:i.color.muted,padding:"8px 0"},children:"暂无数据。"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:13},children:f.map((p,m)=>{const g=t>0?p.value/t*100:0,k=Ie[m%Ie.length],C=p.model==="其他",[D,F]=C?[void 0,"其他"]:p.model.split("/");return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:9,height:9,borderRadius:3,background:k,flexShrink:0}}),e.jsxs("span",{style:{flex:1,fontSize:13,color:i.color.fg,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[D!==void 0&&e.jsxs("span",{style:{color:i.color.muted},children:[D,"/"]}),F]}),e.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:i.color.fg,fontVariantNumeric:"tabular-nums"},children:n==="cost"?Je(p.value):le(p.value)}),e.jsxs("span",{style:{width:44,fontSize:11,color:i.color.muted,textAlign:"right"},children:[g.toFixed(1),"%"]})]}),e.jsx("div",{style:{height:5,borderRadius:3,background:i.color.border,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${Math.max(1,g)}%`,background:k,borderRadius:3}})})]},p.model)})})]})}function Mo({stats:r,t:o}){const t=he(),n=c.useMemo(()=>(r==null?void 0:r.daily)??[],[r]),i=n.reduce((E,I)=>E+I.tokens,0),a=(r==null?void 0:r.totalCost)??0,s=(r==null?void 0:r.sessionCount)??n.reduce((E,I)=>E+I.sessions,0),d=(r==null?void 0:r.messageCount)??n.reduce((E,I)=>E+I.messages,0),f=n.length,p=(r==null?void 0:r.peakTokens)??0,m=(r==null?void 0:r.maxDurationMs)??0,g=c.useMemo(()=>Bo(n),[n]),k=c.useMemo(()=>Eo(n),[n]),C=n.length>0?n[0]:void 0,D=n.length>0?n[n.length-1]:void 0,F=C!==void 0?new Date(C.ts):null,h=D!==void 0?new Date(D.ts):null,j=f>0?i/f:0,S=m>0?(m/36e5).toFixed(1):"—",z=c.useMemo(()=>((r==null?void 0:r.perModel)??[]).map(E=>({model:E.model,value:E.cost})).toSorted((E,I)=>I.value-E.value),[r]),W=z.reduce((E,I)=>E+I.value,0);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:22},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:12},children:e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[e.jsx("span",{style:{fontSize:20,fontWeight:600,color:o.color.fg},children:"使用统计"}),e.jsx("span",{style:{fontSize:13,color:o.color.muted,borderBottom:`2px solid ${o.color.primary}`,paddingBottom:2},children:"应用用量"})]})}),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(auto-fit, minmax(160px, 1fr))",gap:14},children:[e.jsx(se,{label:"Tokens 总用量",value:le(i),sub:"input + output(不含缓存复读)"}),e.jsx(se,{label:"总花费",value:Je(a),accent:"#F472B6",sub:j>0?`日均 ${le(j)} tokens`:void 0}),e.jsx(se,{label:"峰值单会话",value:le(p),sub:S!=="—"?`最长会话 ${S} 小时`:"暂无"}),e.jsx(se,{label:"会话数",value:String(s)}),e.jsx(se,{label:"消息数",value:String(d)}),e.jsx(se,{label:"活跃天数",value:String(f),sub:F!==null?`自 ${F.getFullYear()}年${F.getMonth()+1}月起`:"暂无数据"})]}),e.jsxs("div",{style:{background:t,border:`1px solid ${o.color.border}`,borderRadius:14,padding:22},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:18},children:[e.jsx("div",{style:{fontSize:15,fontWeight:600,color:o.color.fg},children:"活跃热力图"}),e.jsx("div",{style:{fontSize:12,color:o.color.muted},children:i>0?`累计 ${le(i)} tokens · 当前连击 ${g.current} 天`:"暂无活跃数据"})]}),n.length===0?e.jsx("div",{style:{fontSize:12,color:o.color.muted,padding:"8px 0"},children:"暂无活跃数据。"}):e.jsx(Do,{daily:n})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(340px, 1fr))",gap:16},children:[e.jsx($e,{title:"模型用量(Token 占比)",rows:k.map(E=>({model:E.model,value:E.tokens})),total:i,mode:"tokens"}),e.jsx($e,{title:"模型花费(USD 占比)",rows:z,total:W,mode:"cost"})]}),e.jsxs("div",{style:{display:"flex",gap:28,fontSize:12,color:o.color.muted,paddingTop:4,flexWrap:"wrap"},children:[e.jsxs("span",{children:["最长连击 ",e.jsx("b",{style:{color:o.color.fg},children:g.longest})," 天"]}),e.jsxs("span",{children:["最近活跃 ",e.jsx("b",{style:{color:o.color.fg},children:h!==null?`${h.getMonth()+1}月${h.getDate()}日`:"—"})]}),F!==null&&e.jsxs("span",{children:["起始于 ",e.jsxs("b",{style:{color:o.color.fg},children:[F.getFullYear(),"年",F.getMonth()+1,"月",F.getDate(),"日"]})]})]})]})]})}const Ao=`
1
+ var Ze=Object.defineProperty;var Xe=(r,o,t)=>o in r?Ze(r,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[o]=t;var Z=(r,o,t)=>Xe(r,typeof o!="symbol"?o+"":o,t);import{r as c,j as e}from"./vendor-CkEpMl6t.js";const Qe={color:{primary:"#4f8cff",bg:"#0f1117",sidebarBg:"#12141a",sidebarHover:"#1b1f2b",surface:"#161922",fg:"#e6e8ee",muted:"#8b90a0",border:"#2a2e3a",success:"#3fb950",warning:"#d29922",error:"#f85149",accent:"#79c0ff"},spacing:{xs:4,sm:8,md:16,lg:24,xl:32},radius:{sm:4,md:8,lg:12},font:{mono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",sans:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"}},qe={color:{primary:"#2563eb",bg:"#ffffff",sidebarBg:"#f6f7f9",sidebarHover:"#eceef1",surface:"#f3f4f6",fg:"#1f2937",muted:"#6b7280",border:"#e5e7eb",success:"#16a34a",warning:"#ca8a04",error:"#dc2626",accent:"#3b82f6"},spacing:{xs:4,sm:8,md:16,lg:24,xl:32},radius:{sm:4,md:8,lg:12},font:{mono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",sans:"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif"}},Fe=Qe,eo={bg:"#ffffff",header:"#f6f8fa",border:"#d0d7de",text:"#24292f",keyword:"#cf222e",fn:"#8250df",type:"#953800",prop:"#0550ae",str:"#0a3069"},oo={bg:"#0d1117",header:"#161b22",border:"#30363d",text:"#c9d1d9",keyword:"#ff7b72",fn:"#d2a8ff",type:"#ffa657",prop:"#79c0ff",str:"#a5d6ff"};function ro(r){return r==="GitHub Light"?eo:oo}function no(r,o){const t=[],n=/("(?:[^"\\]|\\.)*")|([a-zA-Z_$][\w$]*)(?=\s*:\s*[A-Z][A-Za-z0-9]*)|\b(const|let|var|function|return|import|export|from|new|type|interface|extends|async|await)\b|([a-zA-Z_$][\w$]*)(?=\s*:)|(#[0-9a-fA-F]{3,8}\b)|\b(true|false|null|undefined)\b|\b(\d+(?:\.\d+)?)\b/g;let i=0,a;for(;(a=n.exec(r))!==null;){a.index>i&&t.push({text:r.slice(i,a.index)});const[,s,d,f,p,m,g,k]=a;s!==void 0?t.push({text:s,color:o.str}):d!==void 0?t.push({text:d,color:o.fn}):f!==void 0?t.push({text:f,color:o.keyword}):p!==void 0?t.push({text:p,color:o.prop}):m!==void 0?t.push({text:m,color:o.str}):g!==void 0?t.push({text:g,color:o.keyword}):k!==void 0&&t.push({text:k,color:o.prop}),i=n.lastIndex}return i<r.length&&t.push({text:r.slice(i)}),t}class Zo{constructor(o,t={}){Z(this,"transport");Z(this,"nextId",0);Z(this,"pending",new Map);Z(this,"eventListeners",new Set);Z(this,"requestTimeoutMs");Z(this,"unsubscribe");Z(this,"closed",!1);this.transport=o,this.requestTimeoutMs=t.requestTimeoutMs??3e5,this.unsubscribe=o.onFrame(n=>this.handleFrame(n))}request(o,t){if(this.closed)return Promise.reject(new Error("client is closed"));const n=this.nextId++,i=String(n);return new Promise((a,s)=>{const d=setTimeout(()=>{this.pending.delete(i),s(new Error(`request timed out: ${o}`))},this.requestTimeoutMs);this.pending.set(i,{resolve:a,reject:s,timer:d}),this.transport.send({type:"request",payload:{jsonrpc:"2.0",id:n,method:o,params:t}})})}notify(o,t){this.closed||this.transport.send({type:"request",payload:{jsonrpc:"2.0",id:null,method:o,params:t}})}onEvent(o){return this.eventListeners.add(o),()=>this.eventListeners.delete(o)}close(){if(!this.closed){this.closed=!0,this.unsubscribe();for(const[,o]of this.pending)clearTimeout(o.timer),o.reject(new Error("client closed"));this.pending.clear(),this.transport.close()}}handleFrame(o){if(o.type==="event"){for(const i of this.eventListeners)i(o.payload.event);return}if(o.type!=="response")return;const t=String(o.payload.id),n=this.pending.get(t);n&&(this.pending.delete(t),clearTimeout(n.timer),this.settle(n,o.payload))}settle(o,t){if(t.error){const n=new Error(`${t.error.message} (code ${t.error.code})`);t.error.data!==void 0&&(n.data=t.error.data),o.reject(n);return}o.resolve(t.result)}}const Pe="vagus.theme.v2",we=c.createContext(void 0);function to(){var r,o;return typeof window<"u"&&((o=(r=window.matchMedia)==null?void 0:r.call(window,"(prefers-color-scheme: dark)"))==null?void 0:o.matches)===!0}function io(){const r=localStorage.getItem(Pe);return r==="light"||r==="dark"||r==="system"?r:"light"}function Xo({children:r}){const[o,t]=c.useState(io),[n,i]=c.useState(to),a=o==="system"?n?"dark":"light":o;c.useEffect(()=>{localStorage.setItem(Pe,o),document.documentElement.setAttribute("data-theme",a)},[o,a]),c.useEffect(()=>{if(o!=="system")return;const d=window.matchMedia("(prefers-color-scheme: dark)"),f=p=>i(p.matches);return d.addEventListener("change",f),()=>d.removeEventListener("change",f)},[o]);const s=c.useMemo(()=>({theme:a,preference:o,tokens:a==="light"?qe:Fe,setPreference:t,toggleTheme:()=>t(d=>d==="light"?"dark":"light")}),[a,o]);return e.jsx(we.Provider,{value:s,children:r})}function _(){const r=c.useContext(we);return r||{theme:"dark",preference:"dark",tokens:Fe,setPreference:()=>{},toggleTheme:()=>{}}}function re(){const r=c.useContext(we);return r?r.tokens:Fe}const Oe="vagus.appearance.v1",ee={uiFontSize:14,showLineNumbers:!0,wrapLongLines:!0,codeFontSize:12},He=c.createContext(void 0);function so(){try{const r=localStorage.getItem(Oe);if(r===null)return ee;const o=JSON.parse(r);return{uiFontSize:typeof o.uiFontSize=="number"?o.uiFontSize:ee.uiFontSize,showLineNumbers:typeof o.showLineNumbers=="boolean"?o.showLineNumbers:ee.showLineNumbers,wrapLongLines:typeof o.wrapLongLines=="boolean"?o.wrapLongLines:ee.wrapLongLines,codeFontSize:typeof o.codeFontSize=="number"?o.codeFontSize:ee.codeFontSize}}catch{return ee}}function Qo({children:r}){const[o,t]=c.useState(so);c.useEffect(()=>{localStorage.setItem(Oe,JSON.stringify(o))},[o]);const n=c.useMemo(()=>({...o,update:i=>t(a=>({...a,...i}))}),[o]);return e.jsx(He.Provider,{value:n,children:r})}function lo(){const r=c.useContext(He);return r||{...ee,update:()=>{}}}function ao({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 uo({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 Me({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 co({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 po({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 go({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 xo({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 Ke({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 fo({providers:r,selectedId:o,adding:t,onSelect:n,onAdd:i,t:a}){const{theme:s}=_();return e.jsxs("div",{style:{width:220,flexShrink:0,borderRight:`1px solid ${a.color.border}`,padding:10,background:s==="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:i,title:"添加供应商",onMouseEnter:d=>d.currentTarget.style.color=a.color.fg,onMouseLeave:d=>d.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(Ke,{size:14})})]}),r.length===0&&!t&&e.jsx("div",{style:{fontSize:12,color:a.color.muted,padding:"8px 10px"},children:"暂无供应商"}),r.map(d=>{const f=o===d.id&&!t,p=d.enabled!==!1;return e.jsxs("div",{onClick:()=>n(d.id),onMouseEnter:m=>{f||(m.currentTarget.style.background=a.color.surface)},onMouseLeave:m=>{f||(m.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:f?a.color.border:"transparent"},children:[e.jsx(uo,{size:14}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.id}),e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:p?"#10B981":a.color.muted,flexShrink:0}})]},d.id)})]})}const Ae=[{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 ho(r){return r>=1e6?`${(r/1e6).toFixed(1)}M`:r>=1e3?`${Math.round(r/1e3)}K`:String(r)}function _e({value:r,onChange:o,t}){var d;const[n,i]=c.useState(!1),a=he(),s=((d=Ae.find(f=>f.value===r))==null?void 0:d.label)??r;return e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{type:"button",onClick:()=>i(f=>!f),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,background:a,border:`1px solid ${t.color.border}`,borderRadius:8,padding:"8px 12px",fontSize:13,color:t.color.fg,cursor:"pointer"},children:[e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s}),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"})})]}),n&&e.jsx("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,right:0,zIndex:50,background:a,border:`1px solid ${t.color.border}`,borderRadius:10,padding:4,boxShadow:"0 8px 24px rgba(0,0,0,0.25)"},children:Ae.map(f=>{const p=f.value===r;return e.jsxs("button",{type:"button",onClick:()=>{o(f.value),i(!1)},style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",border:"none",background:p?t.color.border:"transparent",color:t.color.fg,borderRadius:7,padding:"7px 10px",fontSize:12.5,cursor:"pointer",textAlign:"left"},children:[e.jsx("span",{children:f.label}),p&&e.jsx("span",{style:{color:t.color.primary},children:"✓"})]},f.value)})})]})}function X({label:r,children:o}){const t=re();return e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",fontSize:12,fontWeight:500,color:t.color.muted,marginBottom:6},children:r}),o]})}function ke({title:r,description:o,children:t}){const{theme:n}=_(),i=re(),a=n==="light"?"#ffffff":i.color.surface;return e.jsxs("div",{style:{marginBottom:30},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:i.color.fg,marginBottom:4},children:r}),o!==void 0&&e.jsx("div",{style:{fontSize:12,color:i.color.muted,marginBottom:10,lineHeight:1.5},children:o}),e.jsx("div",{style:{background:a,border:`1px solid ${i.color.border}`,borderRadius:12,overflow:"hidden"},children:t})]})}function he(){const{theme:r}=_(),o=re();return r==="light"?"#ffffff":o.color.surface}function ue({label:r,hint:o,control:t,t:n,last:i=!1}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:24,padding:"13px 18px",borderBottom:i?"none":`1px solid ${n.color.border}`},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{fontSize:13,color:n.color.fg},children:r}),o!==void 0&&e.jsx("div",{style:{fontSize:11.5,color:n.color.muted,marginTop:3,lineHeight:1.5},children:o})]}),e.jsx("div",{style:{flexShrink:0},children:t})]})}function mo({options:r,value:o,onChange:t,t:n}){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:r.map(i=>{const a=i.value===o;return e.jsx("button",{onClick:()=>t(i.value),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",whiteSpace:"nowrap"},children:i.label},i.value)})})}function ze({checked:r,onChange:o,t}){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?t.color.accent:t.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 Te({value:r,onChange:o,min:t=10,max:n=20,t:i}){const[a,s]=c.useState(String(r));c.useEffect(()=>{s(String(r))},[r]);const d=p=>{const m=p.trim();if(m===""){s(String(r));return}const g=Number(m);Number.isFinite(g)?o(Math.min(n,Math.max(t,Math.round(g)))):s(String(r))},f={width:26,height:30,border:"none",background:"transparent",color:i.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 ${i.color.border}`,borderRadius:8,overflow:"hidden",background:i.color.bg},children:[e.jsx("button",{onClick:()=>o(Math.max(t,r-1)),style:f,"aria-label":"减小字号",children:"−"}),e.jsx("input",{type:"text",inputMode:"numeric",value:a,onChange:p=>s(p.target.value.replace(/[^\d]/g,"")),onBlur:()=>d(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:i.color.fg,fontSize:12.5}}),e.jsx("button",{onClick:()=>o(Math.min(n,r+1)),style:f,"aria-label":"增大字号",children:"+"}),e.jsx("span",{style:{paddingRight:10,fontSize:12,color:i.color.muted},children:"px"})]})}function bo({form:r,setForm:o,onAdd:t,canAdd:n,inputStyle:i,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(X,{label:"名称",children:e.jsx("input",{style:i,placeholder:"如:openai",value:r.id,onChange:s=>o({...r,id:s.target.value})})}),e.jsx(X,{label:"Base URL",children:e.jsx("input",{style:i,placeholder:"https://api.example.com/v1",value:r.baseUrl,onChange:s=>o({...r,baseUrl:s.target.value})})}),e.jsx(X,{label:"API Key",children:e.jsx("input",{style:i,type:"password",placeholder:"输入 API Key(可选)",value:r.apiKey,onChange:s=>o({...r,apiKey:s.target.value})})}),e.jsx(X,{label:"API 格式",children:e.jsx(_e,{value:r.api,onChange:s=>o({...r,api:s}),t:a})}),e.jsx("button",{onClick:t,disabled:!n,onMouseEnter:s=>{n&&(s.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:s=>{s.currentTarget.style.filter="none"},style:{width:"100%",background:n?a.color.primary:a.color.border,color:n?"#fff":a.color.muted,border:"none",borderRadius:10,padding:"11px 16px",fontSize:13.5,fontWeight:500,cursor:n?"pointer":"default",transition:"filter 0.15s"},children:"添加供应商"})]})}function Ue(r,o){return r==="light"?"#ffffff":o.color.surface}function yo({open:r,form:o,setForm:t,onAdd:n,onClose:i,inputStyle:a,t:s,onProbe:d,provider:f}){const{theme:p}=_(),[m,g]=c.useState("idle"),k=c.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:i,children:e.jsxs("div",{style:{background:Ue(p,s),border:`1px solid ${s.color.border}`,borderRadius:14,padding:22,width:400,maxWidth:"90vw",boxShadow:"0 12px 40px rgba(0,0,0,0.35)"},onClick:C=>C.stopPropagation(),children:[e.jsx("div",{style:{fontSize:15,fontWeight:600,color:s.color.fg},children:"添加模型"}),e.jsx("div",{style:{fontSize:12,color:s.color.muted,margin:"4px 0 18px"},children:"配置模型的标识与参数,保存后可在聊天中选用。"}),e.jsx(X,{label:"模型 ID",children:e.jsx("input",{style:a,autoFocus:!0,placeholder:"如 gpt-4o(自动探测兼容配置)",value:o.id,onChange:C=>{const D=C.target.value;if(t(F=>({...F,id:D})),k.current!==void 0&&window.clearTimeout(k.current),d&&f&&D.trim()!==""){const F=D.trim();g("probing"),k.current=window.setTimeout(()=>{k.current=void 0,d({baseUrl:f.baseUrl,api:f.api,apiKey:f.apiKey,model:F}).then(h=>{h.ok&&h.compat?(t(j=>{var S;return j.id.trim()===F?{...j,compat:h.compat??void 0,reasoning:h.reasoning,vision:((S=h.input)==null?void 0:S.includes("image"))??j.vision}:j}),g("ok")):g("fail")}).catch(()=>g("fail"))},600)}else g("idle")},onKeyDown:C=>{C.key==="Enter"&&o.id.trim()!==""&&m!=="probing"&&n()}})}),(()=>{if(o.id.trim()!==""){if(m==="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(m==="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(m==="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:s.color.muted,marginBottom:4},children:"上下文窗口 (tokens)"}),e.jsx("input",{style:a,type:"number",min:0,placeholder:"2000000",value:o.contextWindow,onChange:C=>t({...o,contextWindow:C.target.value})})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11.5,fontWeight:500,color:s.color.muted,marginBottom:4},children:"最大输出 (tokens)"}),e.jsx("input",{style:a,type:"number",min:0,placeholder:"131072",value:o.maxTokens,onChange:C=>t({...o,maxTokens:C.target.value})})]})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,marginTop:14,cursor:"pointer",fontSize:12.5,color:s.color.fg,userSelect:"none"},children:[e.jsx("input",{type:"checkbox",checked:o.vision,onChange:C=>t({...o,vision:C.target.checked}),style:{width:15,height:15,accentColor:s.color.primary,cursor:"pointer"}}),e.jsx("span",{children:"支持图片理解"}),e.jsx("span",{style:{color:s.color.muted,fontSize:11},children:"(决定聊天中能否添加图片附件)"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:20},children:[e.jsx("button",{onClick:i,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,disabled:o.id.trim()===""||m==="probing",onMouseEnter:C=>{o.id.trim()!==""&&m!=="probing"&&(C.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:C=>{C.currentTarget.style.filter="none"},style:{background:s.color.primary,color:"#fff",border:"none",borderRadius:8,padding:"7px 18px",fontSize:12.5,fontWeight:500,cursor:o.id.trim()===""||m==="probing"?"not-allowed":"pointer",transition:"filter 0.15s",opacity:o.id.trim()===""||m==="probing"?.5:1},children:m==="probing"?"正在探测…":"添加"})]})]})}):null}function jo({confirmDeleteId:r,providers:o,onConfirm:t,onClose:n,t:i}){var s;const{theme:a}=_();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:n,children:e.jsxs("div",{style:{background:Ue(a,i),border:`1px solid ${i.color.border}`,borderRadius:14,padding:22,width:340,maxWidth:"90vw",boxShadow:"0 12px 40px rgba(0,0,0,0.35)"},onClick:d=>d.stopPropagation(),children:[e.jsx("div",{style:{fontSize:15,fontWeight:600,color:i.color.fg},children:"删除供应商"}),e.jsxs("div",{style:{fontSize:12.5,color:i.color.muted,margin:"10px 0 22px",lineHeight:1.7},children:["确定删除供应商 ",e.jsxs("span",{style:{color:i.color.fg,fontWeight:500},children:["“",((s=o.find(d=>d.id===r))==null?void 0:s.id)??r,"”"]})," 吗?其下模型将一并移除,此操作不可撤销。"]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx("button",{onClick:n,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(r),n()},onMouseEnter:d=>d.currentTarget.style.filter="brightness(1.15)",onMouseLeave:d=>d.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 vo({provider:r,detail:o,setDetail:t,showKey:n,setShowKey:i,testingId:a,testResult:s,editingModelId:d,modelForm:f,setModelForm:p,addModelOpen:m,addModelForm:g,setAddModelForm:k,confirmDeleteId:C,providers:D,onToggleEnabled:F,onDelete:h,onConfirmDelete:j,onTest:S,onAddModel:z,onRemoveModel:W,onStartEdit:E,onSaveEdit:I,onCancelEdit:O,onCancelDelete:l,onOpenAddModel:v,onCloseAddModel:B,inputStyle:A,t:x,onProbe:R}){const{theme:N}=_(),T=r,Y=N==="light"?"#ffffff":x.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:{...A,flex:1,minWidth:120,fontWeight:600,fontSize:14},value:o.id,onChange:b=>t({...o,id:b.target.value}),"aria-label":"供应商名称"}),e.jsxs("div",{style:{display:"inline-flex",background:x.color.bg,border:`1px solid ${x.color.border}`,borderRadius:99,padding:2,gap:2,flexShrink:0},children:[e.jsx("button",{onClick:F,onMouseEnter:b=>{T.enabled!==!1&&(b.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:b=>{b.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":x.color.muted,transition:"filter 0.15s"},children:"已启用"}),e.jsx("button",{onClick:F,onMouseEnter:b=>{T.enabled===!1&&(b.currentTarget.style.filter="brightness(1.15)")},onMouseLeave:b=>{b.currentTarget.style.filter="none"},style:{border:"none",borderRadius:99,padding:"4px 12px",fontSize:12,cursor:"pointer",background:T.enabled===!1?x.color.fg:"transparent",color:T.enabled===!1?x.color.bg:x.color.muted,transition:"filter 0.15s"},children:"禁用"})]}),e.jsx("button",{onClick:h,title:"删除供应商",onMouseEnter:b=>{b.currentTarget.style.borderColor="#E5484D",b.currentTarget.style.color="#E5484D"},onMouseLeave:b=>{b.currentTarget.style.borderColor=x.color.border,b.currentTarget.style.color=x.color.muted},style:{background:"transparent",border:`1px solid ${x.color.border}`,color:x.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(Me,{})})]}),e.jsx(X,{label:"Base URL",children:e.jsx("input",{style:A,placeholder:"https://api.example.com/v1",value:o.baseUrl,onChange:b=>t({...o,baseUrl:b.target.value})})}),e.jsx(X,{label:"API 格式",children:e.jsx(_e,{value:o.api,onChange:b=>t({...o,api:b}),t:x})}),e.jsx(X,{label:"API Key",children:e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{style:{...A,flex:1},type:n?"text":"password",placeholder:"留空保持不变",value:o.apiKey,onChange:b=>t({...o,apiKey:b.target.value})}),e.jsx("button",{onClick:()=>i(!n),title:n?"隐藏":"显示",onMouseEnter:b=>b.currentTarget.style.color=x.color.fg,onMouseLeave:b=>b.currentTarget.style.color=x.color.muted,style:{background:"transparent",border:`1px solid ${x.color.border}`,color:x.color.muted,borderRadius:8,width:34,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0,transition:"all 0.15s"},children:n?e.jsx(go,{}):e.jsx(po,{})})]})}),e.jsx("div",{style:{fontSize:13,fontWeight:600,color:x.color.fg,marginBottom:8},children:"模型列表"}),T.models.length===0&&e.jsx("div",{style:{fontSize:12,color:x.color.muted,marginBottom:10},children:"暂无模型 — 添加一个以在聊天中可用。"}),T.models.map(b=>e.jsxs("div",{children:[e.jsxs("div",{onMouseEnter:L=>L.currentTarget.style.background=x.color.border,onMouseLeave:L=>L.currentTarget.style.background=Y,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",borderRadius:8,background:Y,marginBottom:6,fontSize:13,transition:"background 0.15s"},children:[e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b.name??b.id}),b.contextWindow!==void 0&&e.jsx("span",{style:{fontSize:11,color:x.color.fg,background:x.color.bg,border:`1px solid ${x.color.border}`,borderRadius:99,padding:"2px 8px",flexShrink:0},children:ho(b.contextWindow)}),a===b.id?e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",style:{color:x.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":`测试 ${b.id}`,onClick:()=>S(b.id),onMouseEnter:L=>L.currentTarget.style.color=x.color.fg,onMouseLeave:L=>L.currentTarget.style.color=x.color.muted,style:{color:x.color.muted,cursor:"pointer",display:"flex",padding:2,transition:"color 0.15s"},children:e.jsx(xo,{size:13})}),e.jsx("span",{role:"button","aria-label":`编辑 ${b.id}`,onClick:()=>E(b),onMouseEnter:L=>L.currentTarget.style.color=x.color.fg,onMouseLeave:L=>L.currentTarget.style.color=x.color.muted,style:{color:x.color.muted,cursor:"pointer",display:"flex",padding:2,transition:"color 0.15s"},children:e.jsx(co,{size:13})}),e.jsx("span",{role:"button","aria-label":`删除模型 ${b.id}`,onClick:()=>W(b.id),onMouseEnter:L=>L.currentTarget.style.color=x.color.fg,onMouseLeave:L=>L.currentTarget.style.color=x.color.muted,style:{color:x.color.muted,cursor:"pointer",display:"flex",padding:2,transition:"color 0.15s"},children:e.jsx(Me,{size:13})})]}),(s==null?void 0:s.modelId)===b.id&&e.jsx("div",{style:{marginBottom:8},children:s.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:s.status===0?"无法连接":s.reason==="auth"?"认证失败":s.reason==="model"?"模型不存在":`连接失败 (HTTP ${s.status})`})}),d===b.id&&e.jsxs("div",{style:{background:x.color.bg,border:`1px solid ${x.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:x.color.muted,marginBottom:4},children:"上下文窗口 (tokens)"}),e.jsx("input",{style:A,type:"number",min:0,placeholder:"128000",value:f.contextWindow,onChange:L=>p({...f,contextWindow:L.target.value})})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11.5,fontWeight:500,color:x.color.muted,marginBottom:4},children:"最大输出 (tokens)"}),e.jsx("input",{style:A,type:"number",min:0,placeholder:"8192",value:f.maxTokens,onChange:L=>p({...f,maxTokens:L.target.value})})]})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,marginTop:12,cursor:"pointer",fontSize:12.5,color:x.color.fg,userSelect:"none"},children:[e.jsx("input",{type:"checkbox",checked:f.vision,onChange:L=>p({...f,vision:L.target.checked}),style:{width:15,height:15,accentColor:x.color.primary,cursor:"pointer"}}),e.jsx("span",{children:"支持图片理解"}),e.jsx("span",{style:{color:x.color.muted,fontSize:11},children:"(聊天中能否添加图片附件)"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:10},children:[e.jsx("button",{onClick:O,style:{background:"transparent",border:`1px solid ${x.color.border}`,color:x.color.muted,borderRadius:7,padding:"5px 14px",fontSize:12,cursor:"pointer"},children:"取消"}),e.jsx("button",{onClick:I,style:{background:x.color.primary,color:"#fff",border:"none",borderRadius:7,padding:"5px 14px",fontSize:12,fontWeight:500,cursor:"pointer"},children:"保存"})]})]})]},b.id)),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginTop:12},children:e.jsxs("button",{onClick:v,onMouseEnter:b=>{b.currentTarget.style.borderColor=x.color.fg,b.currentTarget.style.color=x.color.fg},onMouseLeave:b=>{b.currentTarget.style.borderColor=x.color.border,b.currentTarget.style.color=x.color.muted},style:{background:"transparent",border:`1px dashed ${x.color.border}`,color:x.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(Ke,{size:13})," 添加模型"]})}),e.jsx(yo,{open:m,form:g,setForm:k,onAdd:z,onClose:B,inputStyle:A,t:x,onProbe:R,provider:r}),e.jsx(jo,{confirmDeleteId:C,providers:D,onConfirm:j,onClose:l,t:x})]})}function ko({providers:r,inputStyle:o,t,onSave:n,onRefresh:i,onTest:a,onProbe:s}){const[d,f]=c.useState(null),[p,m]=c.useState(!1),[g,k]=c.useState({id:"",baseUrl:"",api:"openai-completions",apiKey:""}),[C,D]=c.useState(!1),[F,h]=c.useState({id:"",baseUrl:"",apiKey:"",api:"openai-completions"}),[j,S]=c.useState(!1),[z,W]=c.useState({id:"",contextWindow:"2000000",maxTokens:"131072",vision:!1}),[E,I]=c.useState(null),[O,l]=c.useState(null),[v,B]=c.useState(null),[A,x]=c.useState({contextWindow:"",maxTokens:"",vision:!0}),[R,N]=c.useState(void 0),T=d!==null&&!p?r.find(y=>y.id===d)??null:null,Y=y=>{const M=r.find(P=>P.id===y);if(!M)return;f(y),m(!1),B(null),N(void 0);const H={id:M.id,baseUrl:M.baseUrl,api:M.api,apiKey:M.apiKey??""};U.current=JSON.stringify(H),k(H)},b=()=>{m(!0),f(null),B(null),h({id:"",baseUrl:"",apiKey:"",api:"openai-completions"})},L=()=>{const y=F.id.trim(),M=F.baseUrl.trim();if(!y||!M)return;n([...r,{id:y,baseUrl:M,api:F.api,apiKey:F.apiKey.trim()||void 0,models:[]}]);const H={id:y,baseUrl:M,api:F.api,apiKey:F.apiKey};U.current=JSON.stringify(H),m(!1),f(y),k(H)},Q=y=>{n(r.filter(M=>M.id!==y)),d===y&&(f(null),U.current="",k({id:"",baseUrl:"",api:"openai-completions",apiKey:""}))};c.useEffect(()=>{if(!p&&d===null&&r.length>0){const y=r[0];y!==void 0&&Y(y.id)}},[p,r.length,d]);const U=c.useRef("");c.useEffect(()=>{if(d===null||!r.find(P=>P.id===d))return;const M=JSON.stringify(g);if(M===U.current)return;const H=window.setTimeout(()=>{(async()=>{const P=g.id.trim(),je=g.baseUrl.trim();P&&(U.current=M,await n(r.map(te=>te.id===d?{...te,id:P,baseUrl:je||te.baseUrl,api:g.api,apiKey:g.apiKey.trim()!==""?g.apiKey.trim():te.apiKey}:te)),P!==d&&f(P))})()},700);return()=>window.clearTimeout(H)},[g,d]);const ce=()=>{T&&n(r.map(y=>y.id===T.id?{...y,enabled:y.enabled===!1}:y))},ae=async y=>{if(!T)return;l(y),N(void 0);const M=await a({baseUrl:g.baseUrl.trim()||T.baseUrl,api:g.api||T.api,apiKey:g.apiKey.trim()||T.apiKey,model:y});N({modelId:y,...M}),l(null)},me=()=>{if(!T)return;const y=z.id.trim();if(!y)return;const M=z.compat,H=z.reasoning;n(r.map(P=>P.id===T.id?{...P,models:[...P.models,{id:y,contextWindow:z.contextWindow!==""?Number(z.contextWindow):void 0,maxTokens:z.maxTokens!==""?Number(z.maxTokens):void 0,input:z.vision?["text","image"]:["text"],...H!==void 0?{reasoning:H}:{},...M?{compat:M}:{}}]}:P)),S(!1)},ne=y=>{T&&(n(r.map(M=>M.id===T.id?{...M,models:M.models.filter(H=>H.id!==y)}:M)),v===y&&B(null))},be=y=>{var M;B(y.id),x({contextWindow:y.contextWindow!==void 0?String(y.contextWindow):"",maxTokens:y.maxTokens!==void 0?String(y.maxTokens):"",vision:((M=y.input)==null?void 0:M.includes("image"))??!0})},ye=()=>{!T||v===null||(n(r.map(y=>y.id===T.id?{...y,models:y.models.map(M=>M.id===v?{...M,contextWindow:A.contextWindow!==""?Number(A.contextWindow):void 0,maxTokens:A.maxTokens!==""?Number(A.maxTokens):void 0,input:A.vision?["text","image"]:["text"]}:M)}:y)),B(null))},pe=F.id.trim()!==""&&F.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:t.color.fg},children:"模型设置"}),e.jsx("div",{style:{fontSize:13,color:t.color.muted,margin:"4px 0 0"},children:"管理自定义模型供应商,配置后可在聊天时选择使用。"})]}),e.jsx("button",{onClick:i,title:"刷新配置",style:{background:"transparent",border:`1px solid ${t.color.border}`,color:t.color.muted,borderRadius:8,width:32,height:32,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0},children:e.jsx(ao,{})})]}),e.jsxs("div",{style:{display:"flex",border:`1px solid ${t.color.border}`,borderRadius:14,overflow:"hidden",background:t.color.bg},children:[e.jsx(fo,{providers:r,selectedId:d,adding:p,onSelect:Y,onAdd:b,t}),e.jsx("div",{style:{flex:1,padding:"22px 24px",minWidth:0},children:!p&&T!==null?e.jsx(vo,{provider:T,detail:g,setDetail:k,showKey:C,setShowKey:D,testingId:O,testResult:R,editingModelId:v,modelForm:A,setModelForm:x,addModelOpen:j,addModelForm:z,setAddModelForm:W,confirmDeleteId:E,providers:r,onToggleEnabled:ce,onDelete:()=>I(d),onConfirmDelete:y=>Q(y),onTest:ae,onAddModel:me,onRemoveModel:ne,onStartEdit:be,onSaveEdit:ye,onCancelEdit:()=>B(null),onCancelDelete:()=>I(null),onOpenAddModel:()=>{W({id:"",contextWindow:"2000000",maxTokens:"131072",vision:!1}),S(!0)},onCloseAddModel:()=>S(!1),inputStyle:o,t,onProbe:s}):e.jsx(bo,{form:F,setForm:h,onAdd:L,canAdd:pe,inputStyle:o,t})})]})]})}const So=["const themePreview: ThemeConfig = {",' surface: "sidebar",',' accent: "#339CFF",'," contrast: 45,","};"];function Le({title:r,themeName:o,dark:t,active:n,showLineNumbers:i,codeFontSize:a,t:s}){const d=ro(o),f=n?"当前生效":t?"深色":"浅色";return e.jsxs("div",{style:{flex:"1 1 300px",background:d.bg,border:`1px solid ${d.border}`,borderRadius:12,overflow:"hidden",boxShadow:n?`0 0 0 1.5px ${s.color.accent}`:"none"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:d.header,borderBottom:`1px solid ${d.border}`},children:[e.jsx("span",{style:{fontSize:12,color:d.text,opacity:.85},children:r}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:11,color:d.text,opacity:.6},children:o}),e.jsx("span",{style:{fontSize:11,fontWeight:500,color:n?"#fff":d.text,background:n?s.color.accent:"transparent",border:n?"none":`1px solid ${d.border}`,borderRadius:99,padding:"2px 10px"},children:f})]})]}),e.jsx("div",{style:{padding:"12px 0 14px",fontSize:a,lineHeight:1.65,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",color:d.text},children:So.map((p,m)=>e.jsxs("div",{style:{display:"flex",paddingLeft:16,paddingRight:16},children:[i&&e.jsx("span",{style:{width:26,flexShrink:0,textAlign:"right",marginRight:14,color:d.text,opacity:.35,userSelect:"none"},children:m+1}),e.jsx("span",{style:{whiteSpace:"pre"},children:no(p,d).map((g,k)=>g.color!==void 0?e.jsx("span",{style:{color:g.color},children:g.text},k):g.text)})]},m))})]})}function Fo({draft:r,onChange:o,t}){const{theme:n,preference:i,setPreference:a}=_();return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:22,fontWeight:600,color:t.color.fg},children:"外观"}),e.jsxs("div",{style:{marginTop:24},children:[e.jsxs(ke,{title:"界面设置",description:"设置应用主题和界面文字大小。",children:[e.jsx(ue,{label:"界面主题",hint:"选择浅色、深色或跟随系统主题。",control:e.jsx(mo,{options:[{value:"light",label:"浅色"},{value:"dark",label:"深色"},{value:"system",label:"跟随系统"}],value:i,onChange:a,t}),t}),e.jsx(ue,{label:"界面字号",hint:"调整应用界面的文字大小,图标和布局尺寸不受影响。",last:!0,control:e.jsx(Te,{value:r.uiFontSize,onChange:s=>o({uiFontSize:s}),t}),t})]}),e.jsxs(ke,{title:"代码设置",description:"设置代码内容的主题、字号和显示方式,不受界面字号影响。",children:[e.jsx(ue,{label:"显示行号",hint:"在代码内容和差异视图中显示行号。",control:e.jsx(ze,{checked:r.showLineNumbers,onChange:s=>o({showLineNumbers:s}),t}),t}),e.jsx(ue,{label:"长行自动换行",hint:"代码内容过长时自动换行。",control:e.jsx(ze,{checked:r.wrapLongLines,onChange:s=>o({wrapLongLines:s}),t}),t}),e.jsx(ue,{label:"代码字号",hint:"调整代码块、文件预览和差异视图的默认字号。",last:!0,control:e.jsx(Te,{value:r.codeFontSize,onChange:s=>o({codeFontSize:s}),min:10,max:24,t}),t})]}),e.jsx(ke,{title:"代码预览",description:"同时预览浅色与深色代码主题,当前界面使用的主题会标记为“当前生效”。",children:e.jsxs("div",{style:{display:"flex",gap:14,flexWrap:"wrap",padding:18},children:[e.jsx(Le,{title:"浅色预览",themeName:"GitHub Light",dark:!1,active:n==="light",showLineNumbers:r.showLineNumbers,codeFontSize:r.codeFontSize,t}),e.jsx(Le,{title:"深色预览",themeName:"GitHub Dark",dark:!0,active:n==="dark",showLineNumbers:r.showLineNumbers,codeFontSize:r.codeFontSize,t})]})})]})]})}const oe=864e5,Ie=["#6366F1","#22D3EE","#FBBF24","#F472B6","#34D399","#A78BFA","#F87171","#60A5FA"],wo=["#ebedf0","#9be9a8","#40c463","#30a14e","#216e39"],Co=["#272b33","#0e4429","#006d32","#26a641","#39d353"];function le(r){return r>=1e9?`${(r/1e9).toFixed(2)}G`:r>=1e6?`${(r/1e6).toFixed(1)}M`:r>=1e3?`${(r/1e3).toFixed(1)}K`:String(Math.round(r))}function Je(r){return r>=1e3?`$${(r/1e3).toFixed(2)}K`:r>=100?`$${r.toFixed(1)}`:`$${r.toFixed(2)}`}function We(r){return`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`}function Bo(r){const o=[...new Set(r.map(s=>Math.floor(s.ts/oe)))].toSorted((s,d)=>s-d);let t=0,n=0;for(let s=0;s<o.length;s++)n=s===0||o[s]===(o[s-1]??0)+1?n+1:1,n>t&&(t=n);const i=Math.floor(Date.now()/oe);let a=0;for(let s=o.length-1;s>=0&&o[s]===i-a;s--)a++;return{current:a,longest:t}}function Eo(r){const o=new Map;for(const t of r)for(const[n,i]of Object.entries(t.byModel))o.set(n,(o.get(n)??0)+i);return[...o.entries()].map(([t,n])=>({model:t,tokens:n})).toSorted((t,n)=>n.tokens-t.tokens)}function se({label:r,value:o,sub:t,accent:n}){const i=re(),a=he();return e.jsxs("div",{style:{background:a,border:`1px solid ${i.color.border}`,borderRadius:14,padding:"18px 20px",display:"flex",flexDirection:"column",gap:6},children:[e.jsx("div",{style:{fontSize:12,color:i.color.muted,fontWeight:500},children:r}),e.jsx("div",{style:{fontSize:26,fontWeight:700,color:n??i.color.fg,letterSpacing:"-0.02em",fontVariantNumeric:"tabular-nums"},children:o}),t!==void 0&&e.jsx("div",{style:{fontSize:11.5,color:i.color.muted},children:t})]})}function Do({daily:r}){const o=re(),{theme:t}=_(),[n,i]=c.useState(null),a=t==="light"?wo:Co,s=new Date;s.setHours(0,0,0,0);const d=s.getTime(),f=d-52*7*oe,p=new Map,m=new Map,g=Math.max(...r.map(l=>l.tokens),0),k=g>0?Math.log2(g):1;for(const l of r){const v=We(new Date(l.ts)),B=l.tokens===0?0:Math.max(1,Math.min(4,Math.round(Math.log2(l.tokens)/k*4)));p.set(v,B),m.set(v,l.tokens)}const C=new Date(f),D=new Date(C);D.setDate(D.getDate()-(C.getDay()+6)%7);const F=D.getTime(),h=[];for(let l=0;F+l*7*oe<d+oe;l++)h.push(F+l*7*oe);const j=13,S=3,z=20,W=h.length*(j+S),E=7*(j+S)+z,I=["","Mon","","Wed","","Fri",""],O=[];{let l=-1,v=0;for(let B=0;B<h.length;B++){const A=h[B];if(A===void 0)continue;const x=new Date(A),R=x.getFullYear()*100+x.getMonth();if(R!==l){if(l!==-1){const N=B*(j+S)-v;O.push({x:v+N/2,label:`${l%100+1}月`})}l=R,v=B*(j+S)}}if(l!==-1){const B=h.length*(j+S)-v;O.push({x:v+B/2,label:`${l%100+1}月`})}}return e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-start",position:"relative"},children:[e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:S,paddingTop:14},children:I.map((l,v)=>e.jsx("div",{style:{height:j,lineHeight:`${j}px`,fontSize:9,color:o.color.muted,textAlign:"right",paddingRight:4},children:l},v))}),e.jsx("div",{style:{flex:1,minWidth:0},children:e.jsxs("svg",{viewBox:`0 0 ${W} ${E}`,width:"100%",preserveAspectRatio:"xMinYMin meet",style:{display:"block"},children:[h.map((l,v)=>Array.from({length:7},(B,A)=>{const x=new Date(new Date(l).getTime()+A*oe),R=We(x),N=x.getTime()>d,T=N?0:p.get(R)??0,Y=a[T]??a[0],b=v*(j+S),L=A*(j+S),Q=N?0:m.get(R)??0;return e.jsx("rect",{x:b,y:L,width:j,height:j,rx:2.5,fill:Y,onMouseMove:U=>{N||i({x:U.clientX,y:U.clientY,date:R,tokens:Q})},onMouseLeave:()=>i(null)},R)})),O.map((l,v)=>e.jsx("text",{x:l.x,y:7*(j+S)+z-4,fontSize:9,fill:o.color.muted,textAnchor:"middle",children:l.label},`${l.label}-${v}`))]})}),n!==null&&e.jsxs("div",{style:{position:"fixed",left:n.x+12,top:n.y+12,zIndex:200,pointerEvents:"none",background:o.color.surface,border:`1px solid ${o.color.border}`,borderRadius:8,padding:"8px 10px",fontSize:12,boxShadow:"0 4px 16px rgba(0,0,0,0.2)",color:o.color.fg,minWidth:110},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:4},children:n.date}),e.jsx("div",{style:{color:o.color.muted},children:n.tokens>0?`${le(n.tokens)} tokens`:"无活跃"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,alignSelf:"flex-end",fontSize:10,color:o.color.muted},children:[e.jsx("span",{children:"较少"}),a.map(l=>e.jsx("span",{style:{width:10,height:10,borderRadius:2,background:l,display:"inline-block"}},l)),e.jsx("span",{children:"较多"})]})]})}function $e({title:r,rows:o,total:t,mode:n}){const i=re(),a=he(),s=o.slice(0,6),d=o.slice(6).reduce((p,m)=>p+m.value,0),f=d>0?[...s,{model:"其他",value:d}]:s;return e.jsxs("div",{style:{background:a,border:`1px solid ${i.color.border}`,borderRadius:14,padding:20},children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:i.color.fg,marginBottom:16},children:r}),f.length===0?e.jsx("div",{style:{fontSize:12,color:i.color.muted,padding:"8px 0"},children:"暂无数据。"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:13},children:f.map((p,m)=>{const g=t>0?p.value/t*100:0,k=Ie[m%Ie.length],C=p.model==="其他",[D,F]=C?[void 0,"其他"]:p.model.split("/");return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:9,height:9,borderRadius:3,background:k,flexShrink:0}}),e.jsxs("span",{style:{flex:1,fontSize:13,color:i.color.fg,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[D!==void 0&&e.jsxs("span",{style:{color:i.color.muted},children:[D,"/"]}),F]}),e.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:i.color.fg,fontVariantNumeric:"tabular-nums"},children:n==="cost"?Je(p.value):le(p.value)}),e.jsxs("span",{style:{width:44,fontSize:11,color:i.color.muted,textAlign:"right"},children:[g.toFixed(1),"%"]})]}),e.jsx("div",{style:{height:5,borderRadius:3,background:i.color.border,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${Math.max(1,g)}%`,background:k,borderRadius:3}})})]},p.model)})})]})}function Mo({stats:r,t:o}){const t=he(),n=c.useMemo(()=>(r==null?void 0:r.daily)??[],[r]),i=n.reduce((E,I)=>E+I.tokens,0),a=(r==null?void 0:r.totalCost)??0,s=(r==null?void 0:r.sessionCount)??n.reduce((E,I)=>E+I.sessions,0),d=(r==null?void 0:r.messageCount)??n.reduce((E,I)=>E+I.messages,0),f=n.length,p=(r==null?void 0:r.peakTokens)??0,m=(r==null?void 0:r.maxDurationMs)??0,g=c.useMemo(()=>Bo(n),[n]),k=c.useMemo(()=>Eo(n),[n]),C=n.length>0?n[0]:void 0,D=n.length>0?n[n.length-1]:void 0,F=C!==void 0?new Date(C.ts):null,h=D!==void 0?new Date(D.ts):null,j=f>0?i/f:0,S=m>0?(m/36e5).toFixed(1):"—",z=c.useMemo(()=>((r==null?void 0:r.perModel)??[]).map(E=>({model:E.model,value:E.cost})).toSorted((E,I)=>I.value-E.value),[r]),W=z.reduce((E,I)=>E+I.value,0);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:22},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:12},children:e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:10},children:[e.jsx("span",{style:{fontSize:20,fontWeight:600,color:o.color.fg},children:"使用统计"}),e.jsx("span",{style:{fontSize:13,color:o.color.muted,borderBottom:`2px solid ${o.color.primary}`,paddingBottom:2},children:"应用用量"})]})}),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(auto-fit, minmax(160px, 1fr))",gap:14},children:[e.jsx(se,{label:"Tokens 总用量",value:le(i),sub:"input + output(不含缓存复读)"}),e.jsx(se,{label:"总花费",value:Je(a),accent:"#F472B6",sub:j>0?`日均 ${le(j)} tokens`:void 0}),e.jsx(se,{label:"峰值单会话",value:le(p),sub:S!=="—"?`最长会话 ${S} 小时`:"暂无"}),e.jsx(se,{label:"会话数",value:String(s)}),e.jsx(se,{label:"消息数",value:String(d)}),e.jsx(se,{label:"活跃天数",value:String(f),sub:F!==null?`自 ${F.getFullYear()}年${F.getMonth()+1}月起`:"暂无数据"})]}),e.jsxs("div",{style:{background:t,border:`1px solid ${o.color.border}`,borderRadius:14,padding:22},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:18},children:[e.jsx("div",{style:{fontSize:15,fontWeight:600,color:o.color.fg},children:"活跃热力图"}),e.jsx("div",{style:{fontSize:12,color:o.color.muted},children:i>0?`累计 ${le(i)} tokens · 当前连击 ${g.current} 天`:"暂无活跃数据"})]}),n.length===0?e.jsx("div",{style:{fontSize:12,color:o.color.muted,padding:"8px 0"},children:"暂无活跃数据。"}):e.jsx(Do,{daily:n})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(340px, 1fr))",gap:16},children:[e.jsx($e,{title:"模型用量(Token 占比)",rows:k.map(E=>({model:E.model,value:E.tokens})),total:i,mode:"tokens"}),e.jsx($e,{title:"模型花费(USD 占比)",rows:z,total:W,mode:"cost"})]}),e.jsxs("div",{style:{display:"flex",gap:28,fontSize:12,color:o.color.muted,paddingTop:4,flexWrap:"wrap"},children:[e.jsxs("span",{children:["最长连击 ",e.jsx("b",{style:{color:o.color.fg},children:g.longest})," 天"]}),e.jsxs("span",{children:["最近活跃 ",e.jsx("b",{style:{color:o.color.fg},children:h!==null?`${h.getMonth()+1}月${h.getDate()}日`:"—"})]}),F!==null&&e.jsxs("span",{children:["起始于 ",e.jsxs("b",{style:{color:o.color.fg},children:[F.getFullYear(),"年",F.getMonth()+1,"月",F.getDate(),"日"]})]})]})]})]})}const Ao=`
2
2
  @keyframes vagus-fade-up {
3
3
  from { opacity: 0; transform: translateY(10px); }
4
4
  to { opacity: 1; transform: translateY(0); }
package/gui/index.html CHANGED
@@ -24,6 +24,11 @@
24
24
  @keyframes vagus-breath { 0%, 100% { box-shadow: 0 6px 28px rgba(99,102,241,0.08), 0 0 0 0 rgba(99,102,241,0); border-color: rgba(99,102,241,0.2); } 50% { box-shadow: 0 6px 36px rgba(99,102,241,0.18), 0 0 0 3px rgba(99,102,241,0.06); border-color: rgba(99,102,241,0.5); } }
25
25
  /* Extension-notify toast slide-up */
26
26
  @keyframes vagus-toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
27
+ /* Sidebar marquee: single-direction seamless loop; content is doubled while hovered, -50% = exactly one copy+gap */
28
+ @keyframes vagus-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
29
+ .vagus-marquee:hover { text-overflow: clip; }
30
+ /* Row hover hides the time label so the name window widens for scrolling */
31
+ .vagus-session-row:hover .vagus-row-time { display: none; }
27
32
  /* Hide the history-nav rail's own scrollbar (ticks overflow internally) */
28
33
  .vagus-nav-scroll { scrollbar-width: none; -ms-overflow-style: none; }
29
34
  .vagus-nav-scroll::-webkit-scrollbar { display: none; }
@@ -31,7 +36,7 @@
31
36
  .vagus-revert-btn { pointer-events: none; }
32
37
  div:hover > .vagus-revert-btn, .vagus-revert-btn:hover { opacity: 1 !important; pointer-events: auto; }
33
38
  </style>
34
- <script type="module" crossorigin src="/assets/index-BF1Vavki.js"></script>
39
+ <script type="module" crossorigin src="/assets/index-Dl4o9eCz.js"></script>
35
40
  <link rel="modulepreload" crossorigin href="/assets/vendor-CkEpMl6t.js">
36
41
  <body>
37
42
  <div id="root"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versot/vaguspi",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "pi-web — a web frontend for the pi coding agent. Launch the full chat UI in your browser with one command.",
5
5
  "keywords": [
6
6
  "pi",