@ian2018cs/agenthub 0.1.34 → 0.1.35

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,8 +1,8 @@
1
- import{j as e,s as Pa,R as Ra,o as za,E as $a,m as _a,b as Aa,c as Oa,h as Fa,p as Wa,d as Ba}from"./vendor-codemirror-C_VWDoZS.js";import{b as Ua,g as Vr,a as r,d as ps,R as tt,u as Os,B as Ha,e as qa,f as xs,h as Ja}from"./vendor-react-BeVl62c0.js";import{t as Ka,c as Ga,a as Fs,F as Va}from"./vendor-utils-00TdZexr.js";import{F as Rr,X as Ue,C as Ya,L as wt,T as Ge,R as _t,S as At,a as nt,b as Et,c as cr,d as hs,P as Xt,e as Cr,f as zt,g as zr,h as Qa,i as ot,j as Ot,k as Za,l as Xa,M as dr,B as Ws,D as $t,m as Bs,n as en,o as Us,U as gs,p as tn,E as Hs,q as rn,r as sn,s as qs,t as fs,u as hr,v as gr,I as Js,w as Ft,x as fr,y as br,G as $r,Z as an,z as nn,A as on,H as Ks,J as Gs,K as _r,N as ln,O as cn,Q as mr,V as yr,W as dn,Y as mn,_ as Vs,$ as un,a0 as pn,a1 as Ar,a2 as Or,a3 as Fr,a4 as xn,a5 as hn,a6 as gn,a7 as fn,a8 as bn,a9 as yn,aa as vn,ab as jn}from"./vendor-icons-CX_nKP5H.js";import{r as wn,a as kn,b as Nn,M as Sn}from"./vendor-markdown-VwNYkg_0.js";import{h as Cn}from"./vendor-syntax-CdGaPJRS.js";import{r as En,a as Mn,b as Ln,c as In}from"./vendor-xterm-CvdiG4-n.js";import"./vendor-katex-DK8hFnhL.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const l of n)if(l.type==="childList")for(const i of l.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function a(n){const l={};return n.integrity&&(l.integrity=n.integrity),n.referrerPolicy&&(l.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?l.credentials="include":n.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(n){if(n.ep)return;n.ep=!0;const l=a(n);fetch(n.href,l)}})();var nr={},bs;function Dn(){if(bs)return nr;bs=1;var t=Ua();return nr.createRoot=t.createRoot,nr.hydrateRoot=t.hydrateRoot,nr}var Tn=Dn();const Pn=Vr(Tn);function Be(...t){return Ka(Ga(t))}function Rn(t){if(!t||typeof t!="string")return null;try{return JSON.parse(t)}catch{return null}}const Yr=r.forwardRef(({className:t,children:s,...a},o)=>e.jsx("div",{ref:o,className:Be("relative overflow-hidden",t),...a,children:e.jsx("div",{className:"h-full w-full rounded-[inherit] overflow-auto",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:s})}));Yr.displayName="ScrollArea";const zn=Fs("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),K=r.forwardRef(({className:t,variant:s,size:a,...o},n)=>e.jsx("button",{className:Be(zn({variant:s,size:a,className:t})),ref:n,...o}));K.displayName="Button";const $n=Fs("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",success:"border-transparent bg-green-500 text-white shadow hover:bg-green-500/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ye({className:t,variant:s,...a}){return e.jsx("div",{className:Be($n({variant:s}),t),...a})}const Ve=r.forwardRef(({className:t,type:s,...a},o)=>e.jsx("input",{type:s,className:Be("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",t),ref:o,...a}));Ve.displayName="Input";const dt=({className:t="w-5 h-5"})=>e.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:t}),re=(t,s={})=>{const a=localStorage.getItem("auth-token"),o={};return s.body instanceof FormData||(o["Content-Type"]="application/json"),a&&(o.Authorization=`Bearer ${a}`),fetch(t,{...s,headers:{...o,...s.headers}})},ve={auth:{status:()=>fetch("/api/auth/status"),login:(t,s)=>fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:s})}),sendCode:t=>fetch("/api/auth/send-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t})}),verifyCode:(t,s)=>fetch("/api/auth/verify-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t,code:s})}),user:()=>re("/api/auth/user"),logout:()=>re("/api/auth/logout",{method:"POST"}),limitStatus:()=>re("/api/auth/limit-status"),changePassword:(t,s)=>re("/api/auth/change-password",{method:"PATCH",body:JSON.stringify({current_password:t,new_password:s})}),feishuBindToken:()=>re("/api/auth/feishu-bind-token",{method:"POST"})},admin:{getUsers:()=>re("/api/admin/users"),createUser:(t,s)=>re("/api/admin/users",{method:"POST",body:JSON.stringify({username:t,password:s})}),updateUserStatus:(t,s)=>re(`/api/admin/users/${t}`,{method:"PATCH",body:JSON.stringify({status:s})}),deleteUser:t=>re(`/api/admin/users/${t}`,{method:"DELETE"}),getEmailDomains:()=>re("/api/admin/email-domains"),addEmailDomain:t=>re("/api/admin/email-domains",{method:"POST",body:JSON.stringify({domain:t})}),removeEmailDomain:t=>re(`/api/admin/email-domains/${t}`,{method:"DELETE"}),getUserLimits:t=>re(`/api/admin/users/${t}/limits`),updateUserLimits:(t,s)=>re(`/api/admin/users/${t}/limits`,{method:"PATCH",body:JSON.stringify(s)}),resetUserPassword:(t,s)=>re(`/api/admin/users/${t}/password`,{method:"PATCH",body:JSON.stringify({new_password:s})}),getDefaultLimits:()=>re("/api/admin/settings/default-limits"),updateDefaultLimits:t=>re("/api/admin/settings/default-limits",{method:"PUT",body:JSON.stringify(t)})},projects:()=>re("/api/projects"),sessions:(t,s=5,a=0)=>re(`/api/projects/${t}/sessions?limit=${s}&offset=${a}`),sessionMessages:(t,s,a=null,o=0)=>{const n=new URLSearchParams;a!==null&&(n.append("limit",a),n.append("offset",o));const l=n.toString(),i=`/api/projects/${t}/sessions/${s}/messages${l?`?${l}`:""}`;return re(i)},renameProject:(t,s)=>re(`/api/projects/${t}/rename`,{method:"PUT",body:JSON.stringify({displayName:s})}),deleteSession:(t,s)=>re(`/api/projects/${t}/sessions/${s}`,{method:"DELETE"}),deleteProject:(t,s=!0)=>re(`/api/projects/${t}?deleteFolder=${s}`,{method:"DELETE"}),createProject:t=>re("/api/projects/create",{method:"POST",body:JSON.stringify({path:t})}),createWorkspace:t=>re("/api/projects/create-workspace",{method:"POST",body:JSON.stringify(t)}),readFile:(t,s)=>re(`/api/projects/${t}/file?filePath=${encodeURIComponent(s)}`),saveFile:(t,s,a)=>re(`/api/projects/${t}/file`,{method:"PUT",body:JSON.stringify({filePath:s,content:a})}),getFiles:(t,s={})=>{const a=new URLSearchParams;s.dirPath&&a.set("dirPath",s.dirPath),s.depth&&a.set("depth",s.depth.toString());const o=a.toString();return re(`/api/projects/${t}/files${o?"?"+o:""}`)},uploadFiles:(t,s)=>re(`/api/projects/${t}/upload-files`,{method:"POST",body:s,headers:{}}),deleteFile:(t,s)=>re(`/api/projects/${t}/files?filePath=${encodeURIComponent(s)}`,{method:"DELETE"}),getFileContent:(t,s)=>re(`/api/projects/${t}/files/content?path=${encodeURIComponent(s)}`),transcribe:t=>re("/api/transcribe",{method:"POST",body:t,headers:{}}),settings:{getAgentPermissions:()=>re("/api/settings/agent-permissions"),saveAgentPermissions:t=>re("/api/settings/agent-permissions",{method:"PUT",body:JSON.stringify({agentPermissions:t})})},get:t=>re(`/api${t}`)},_n=/^[a-zA-Z0-9_-]+$/,An=({onClose:t,onProjectCreated:s})=>{const[a,o]=r.useState(""),[n,l]=r.useState(""),[i,d]=r.useState(!1),[h,p]=r.useState(null),g=v=>v.trim()?_n.test(v.trim())?null:"项目名称只能包含字母、数字、连字符和下划线":"项目名称为必填项",k=async()=>{p(null);const v=g(a);if(v){p(v);return}d(!0);try{const x={name:a.trim()};n.trim()&&(x.githubUrl=n.trim());const R=await ve.createWorkspace(x),z=await R.json();if(!R.ok)throw new Error(z.error||"Failed to create project");s&&s(z.project),t()}catch(x){console.error("Error creating project:",x),p(x.message||"Failed to create project")}finally{d(!1)}},y=v=>{v.key==="Enter"&&!i&&k()};return e.jsx("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[60] p-0 sm:p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-none sm:rounded-lg shadow-xl w-full h-full sm:h-auto sm:max-w-md border-0 sm:border border-gray-200 dark:border-gray-700 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Rr,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"创建新项目"})]}),e.jsx("button",{onClick:t,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",disabled:i,children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-5",children:[h&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(Ya,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:h})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["项目名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ve,{type:"text",value:a,onChange:v=>o(v.target.value),onKeyDown:y,placeholder:"my-awesome-project",className:"w-full",autoFocus:!0}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"仅允许字母、数字、连字符和下划线"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"GitHub 链接(可选)"}),e.jsx(Ve,{type:"text",value:n,onChange:v=>l(v.target.value),onKeyDown:y,placeholder:"https://github.com/user/repo",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"留空以创建空项目,或输入公共仓库链接以克隆"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(K,{variant:"outline",onClick:t,disabled:i,children:"取消"}),e.jsx(K,{onClick:k,disabled:i||!a.trim(),children:i?e.jsxs(e.Fragment,{children:[e.jsx(wt,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):"创建项目"})]})]})})},ys=(t,s)=>{const a=new Date(t),o=s;if(isNaN(a.getTime()))return"Unknown";const n=o-a,l=Math.floor(n/1e3),i=Math.floor(n/(1e3*60)),d=Math.floor(n/(1e3*60*60)),h=Math.floor(n/(1e3*60*60*24));return l<60?"Just now":i===1?"1 min ago":i<60?`${i} mins ago`:d===1?"1 hour ago":d<24?`${d} hours ago`:h===1?"1 day ago":h<7?`${h} days ago`:a.toLocaleDateString()};function vs({projects:t,selectedProject:s,selectedSession:a,onProjectSelect:o,onSessionSelect:n,onNewSession:l,onSessionDelete:i,onProjectDelete:d,isLoading:h,onRefresh:p,onShowSettings:g,isPWA:k,isMobile:y,onToggleSidebar:v}){const[x,R]=r.useState(new Set),[z,T]=r.useState(null),[C,u]=r.useState(!1),[m,j]=r.useState(""),[w,L]=r.useState({}),[F,O]=r.useState({}),[se,ce]=r.useState(new Set),[ae,oe]=r.useState(new Date),[W,I]=r.useState("name"),[_,X]=r.useState(!1),[je,ie]=r.useState(null),[Z,we]=r.useState(""),[Me,De]=r.useState({}),[Ce,Oe]=r.useState(""),[xe,Se]=r.useState(null),[Re,ze]=r.useState(()=>{try{const b=localStorage.getItem("starredProjects");return b?new Set(JSON.parse(b)):new Set}catch(b){return console.error("Error loading starred projects:",b),new Set}}),he=b=>Q=>{Q.target.closest(".overflow-y-auto")||Q.target.closest("[data-scroll-container]")||(Q.preventDefault(),Q.stopPropagation(),b())};r.useEffect(()=>{const b=setInterval(()=>{oe(new Date)},6e4);return()=>clearInterval(b)},[]),r.useEffect(()=>{O({}),ce(new Set)},[t]),r.useEffect(()=>{a&&s&&R(b=>new Set([...b,s.name]))},[a,s]),r.useEffect(()=>{if(t.length>0&&!h){const b=new Set;t.forEach(Q=>{Q.sessions&&Q.sessions.length>=0&&b.add(Q.name)}),ce(b)}},[t,h]),r.useEffect(()=>{const b=()=>{try{const ue=localStorage.getItem("claude-settings");if(ue){const J=JSON.parse(ue);I(J.projectSortOrder||"name")}}catch(ue){console.error("Error loading sort order:",ue)}};b();const Q=ue=>{ue.key==="claude-settings"&&b()};window.addEventListener("storage",Q);const B=setInterval(()=>{document.hasFocus()&&b()},1e3);return()=>{window.removeEventListener("storage",Q),clearInterval(B)}},[]);const Le=b=>{const Q=new Set;x.has(b)||Q.add(b),R(Q)},Te=(b,Q)=>{n({...b,__projectName:Q})},_e=b=>{const Q=new Set(Re);Q.has(b)?Q.delete(b):Q.add(b),ze(Q);try{localStorage.setItem("starredProjects",JSON.stringify([...Q]))}catch(B){console.error("Error saving starred projects:",B)}},We=b=>Re.has(b),D=b=>[...b.sessions||[],...F[b.name]||[]].map(B=>({...B,__provider:"claude"})).sort((B,ue)=>new Date(ue.lastActivity)-new Date(B.lastActivity)),$=b=>{const Q=D(b);return Q.length===0?new Date(0):Q.reduce((ue,J)=>{const ye=new Date(J.lastActivity);return ye>ue?ye:ue},new Date(0))},A=[...t].sort((b,Q)=>{const B=We(b.name),ue=We(Q.name);if(B&&!ue)return-1;if(!B&&ue)return 1;if(W==="date")return $(Q)-$(b);{const J=b.displayName||b.name,ye=Q.displayName||Q.name;return J.localeCompare(ye)}}),f=b=>{T(b.name),j(b.displayName)},H=()=>{T(null),j("")},de=async b=>{try{(await ve.renameProject(b,m)).ok?window.refreshProjects?window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(Q){console.error("Error renaming project:",Q)}T(null),j("")},Ee=async(b,Q,B="claude")=>{if(confirm("Are you sure you want to delete this session? This action cannot be undone."))try{console.log("[Sidebar] Deleting session:",{projectName:b,sessionId:Q,provider:B});const ue=await ve.deleteSession(b,Q);if(console.log("[Sidebar] Delete response:",{ok:ue.ok,status:ue.status}),ue.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),i?i(Q):console.warn("[Sidebar] No onSessionDelete callback provided");else{const J=await ue.text();console.error("[Sidebar] Failed to delete session:",{status:ue.status,error:J}),alert("Failed to delete session. Please try again.")}}catch(ue){console.error("[Sidebar] Error deleting session:",ue),alert("Error deleting session. Please try again.")}},Ae=async b=>{if(xe)try{const Q=await ve.deleteProject(b,!0);if(Q.ok)Se(null),d&&d(b);else{const B=await Q.json();console.error("Failed to delete project"),alert(B.error||"Failed to delete project. Please try again.")}}catch(Q){console.error("Error deleting project:",Q),alert("Error deleting project. Please try again.")}},rt=async b=>{if(!(!(b.sessionMeta?.hasMore!==!1)||w[b.name])){L(B=>({...B,[b.name]:!0}));try{const B=(b.sessions?.length||0)+(F[b.name]?.length||0),ue=await ve.sessions(b.name,5,B);if(ue.ok){const J=await ue.json();O(ye=>({...ye,[b.name]:[...ye[b.name]||[],...J.sessions]})),J.hasMore===!1&&(b.sessionMeta={...b.sessionMeta,hasMore:!1})}}catch(B){console.error("Error loading more sessions:",B)}finally{L(B=>({...B,[b.name]:!1}))}}},G=A.filter(b=>{if(!Ce.trim())return!0;const Q=Ce.toLowerCase(),B=(b.displayName||b.name).toLowerCase(),ue=b.name.toLowerCase();return B.includes(Q)||ue.includes(Q)}),ee=b=>{o(b)};return e.jsxs(e.Fragment,{children:[C&&ps.createPortal(e.jsx(An,{onClose:()=>u(!1),onProjectCreated:b=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),xe&&ps.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4",children:e.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl w-full max-w-sm p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:e.jsx(Ge,{className:"w-5 h-5 text-red-600 dark:text-red-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"删除项目"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"此操作不可撤销"})]})]}),e.jsxs("p",{className:"text-sm text-foreground",children:["确定要删除项目 ",e.jsxs("span",{className:"font-medium text-red-600 dark:text-red-400",children:['"',xe.displayName||xe.name,'"']})," 吗?"]}),e.jsx("p",{className:"text-xs text-muted-foreground bg-muted/50 rounded-lg p-3",children:"将同时删除:所有会话记录(JSONL 文件)和项目文件夹及其所有内容。"}),e.jsxs("div",{className:"flex gap-3 pt-1",children:[e.jsx("button",{className:"flex-1 px-4 py-2 rounded-lg border border-border text-sm font-medium hover:bg-accent transition-colors",onClick:()=>Se(null),children:"取消"}),e.jsx("button",{className:"flex-1 px-4 py-2 rounded-lg bg-red-600 hover:bg-red-700 text-white text-sm font-medium transition-colors",onClick:()=>Ae(xe.name),children:"确认删除"})]})]})}),document.body),e.jsxs("div",{className:"h-full flex flex-col bg-card md:select-none",style:k&&y?{paddingTop:"44px"}:{},children:[e.jsxs("div",{className:"md:p-4 md:border-b md:border-border",children:[e.jsxs("div",{className:"hidden md:flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:"/logo.svg",className:"w-8 h-8",alt:"AgentHub"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold text-foreground",children:"AgentHub"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"你的 AI 助手"})]})]}),v&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 hover:bg-accent transition-colors duration-200",onClick:v,title:"收起侧边栏",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),e.jsx("div",{className:"md:hidden p-3 border-b border-border",style:k&&y?{paddingTop:"16px"}:{},children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:"/logo.svg",className:"w-8 h-8",alt:"AgentHub"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"AgentHub"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"项目"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{className:"w-8 h-8 rounded-md bg-background border border-border flex items-center justify-center active:scale-95 transition-all duration-150",onClick:async()=>{X(!0);try{await p()}finally{X(!1)}},disabled:_,children:e.jsx(_t,{className:`w-4 h-4 text-foreground ${_?"animate-spin":""}`})}),e.jsx("button",{className:"w-8 h-8 rounded-md bg-primary text-primary-foreground flex items-center justify-center active:scale-95 transition-all duration-150",onClick:()=>u(!0),children:e.jsx(Rr,{className:"w-4 h-4"})})]})]})})]}),!h&&!y&&e.jsx("div",{className:"px-3 md:px-4 py-2 border-b border-border",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"default",size:"sm",className:"flex-1 h-8 text-xs bg-primary hover:bg-primary/90 transition-all duration-200",onClick:()=>u(!0),title:"创建新项目",children:[e.jsx(Rr,{className:"w-3.5 h-3.5 mr-1.5"}),"新建项目"]}),e.jsx(K,{variant:"outline",size:"sm",className:"h-8 w-8 px-0 hover:bg-accent transition-colors duration-200 group",onClick:async()=>{X(!0);try{await p()}finally{X(!1)}},disabled:_,title:"刷新项目和会话 (Ctrl+R)",children:e.jsx(_t,{className:`w-3.5 h-3.5 ${_?"animate-spin":""} group-hover:rotate-180 transition-transform duration-300`})})]})}),t.length>0&&!h&&e.jsx("div",{className:"px-3 md:px-4 py-2 border-b border-border",children:e.jsxs("div",{className:"relative",children:[e.jsx(At,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Ve,{type:"text",placeholder:"搜索项目...",value:Ce,onChange:b=>Oe(b.target.value),className:"pl-9 h-9 text-sm bg-muted/50 border-0 focus:bg-background focus:ring-1 focus:ring-primary/20"}),Ce&&e.jsx("button",{onClick:()=>Oe(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 hover:bg-accent rounded",children:e.jsx(Ue,{className:"w-3 h-3 text-muted-foreground"})})]})}),e.jsx(Yr,{className:"flex-1 md:px-2 md:py-3 overflow-y-auto overscroll-contain",children:e.jsx("div",{className:"md:space-y-1 pb-safe-area-inset-bottom",children:h?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:"加载项目中..."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"正在获取您的 Claude 项目和会话"})]}):t.length===0?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(nt,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:"未找到项目"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"在项目目录中运行 Claude CLI 以开始使用"})]}):G.length===0?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(At,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:"无匹配的项目"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"尝试调整搜索条件"})]}):G.map(b=>{const Q=x.has(b.name),B=s?.name===b.name,ue=We(b.name);return e.jsxs("div",{className:"md:space-y-1",children:[e.jsxs("div",{className:"group md:group",children:[e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:Be("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",B&&"bg-primary/5 border-primary/20",ue&&!B&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:()=>{Le(b.name)},onTouchEnd:he(()=>Le(b.name)),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:Be("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",Q?"bg-primary/10":"bg-muted"),children:Q?e.jsx(Et,{className:"w-4 h-4 text-primary"}):e.jsx(nt,{className:"w-4 h-4 text-muted-foreground"})}),e.jsx("div",{className:"min-w-0 flex-1",children:z===b.name?e.jsx("input",{type:"text",value:m,onChange:J=>j(J.target.value),className:"w-full px-3 py-2 text-sm border-2 border-primary/40 focus:border-primary rounded-lg bg-background text-foreground shadow-sm focus:shadow-md transition-all duration-200 focus:outline-none",placeholder:"项目名称",autoFocus:!0,autoComplete:"off",onClick:J=>J.stopPropagation(),onKeyDown:J=>{J.key==="Enter"&&de(b.name),J.key==="Escape"&&H()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-between min-w-0 flex-1",children:e.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:b.displayName})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(()=>{const J=D(b).length;return`${b.sessionMeta?.hasMore!==!1&&J>=5?`${J}+`:J} 会话`})()})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:z===b.name?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-green-500 dark:bg-green-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:J=>{J.stopPropagation(),de(b.name)},children:e.jsx(cr,{className:"w-4 h-4 text-white"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500 dark:bg-gray-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:J=>{J.stopPropagation(),H()},children:e.jsx(Ue,{className:"w-4 h-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:Be("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",ue?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:J=>{J.stopPropagation(),_e(b.name)},onTouchEnd:he(()=>_e(b.name)),title:ue?"从收藏中移除":"添加到收藏",children:e.jsx(hs,{className:Be("w-4 h-4 transition-colors",ue?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-red-500/10 dark:bg-red-900/30 flex items-center justify-center active:scale-90 border border-red-200 dark:border-red-800",onClick:J=>{J.stopPropagation(),Se({name:b.name,displayName:b.displayName})},onTouchEnd:he(()=>Se({name:b.name,displayName:b.displayName})),children:e.jsx(Ge,{className:"w-4 h-4 text-red-600 dark:text-red-400"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/10 dark:bg-primary/20 flex items-center justify-center active:scale-90 border border-primary/20 dark:border-primary/30",onClick:J=>{J.stopPropagation(),f(b)},onTouchEnd:he(()=>f(b)),children:e.jsx(Xt,{className:"w-4 h-4 text-primary"})}),e.jsx("div",{className:"w-6 h-6 rounded-md bg-muted/30 flex items-center justify-center",children:Q?e.jsx(Cr,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(zt,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),e.jsxs(K,{variant:"ghost",className:Be("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",B&&"bg-accent text-accent-foreground",ue&&!B&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:()=>{s?.name!==b.name&&ee(b),Le(b.name)},onTouchEnd:he(()=>{s?.name!==b.name&&ee(b),Le(b.name)}),children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[Q?e.jsx(Et,{className:"w-4 h-4 text-primary flex-shrink-0"}):e.jsx(nt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:z===b.name?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:m,onChange:J=>j(J.target.value),className:"w-full px-2 py-1 text-sm border border-border rounded bg-background text-foreground focus:ring-2 focus:ring-primary/20",placeholder:"项目名称",autoFocus:!0,onKeyDown:J=>{J.key==="Enter"&&de(b.name),J.key==="Escape"&&H()}}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",title:b.fullPath,children:b.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold truncate text-foreground",title:b.displayName,children:b.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[(()=>{const J=D(b).length;return b.sessionMeta?.hasMore!==!1&&J>=5?`${J}+`:J})(),b.fullPath!==b.displayName&&e.jsxs("span",{className:"ml-1 opacity-60",title:b.fullPath,children:["• ",b.fullPath.length>25?"..."+b.fullPath.slice(-22):b.fullPath]})]})]})})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:z===b.name?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-6 h-6 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-900/20 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:J=>{J.stopPropagation(),de(b.name)},children:e.jsx(cr,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 text-gray-500 hover:text-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:J=>{J.stopPropagation(),H()},children:e.jsx(Ue,{className:"w-3 h-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:Be("w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 flex items-center justify-center rounded cursor-pointer touch:opacity-100",ue?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100":"hover:bg-accent"),onClick:J=>{J.stopPropagation(),_e(b.name)},title:ue?"从收藏中移除":"添加到收藏",children:e.jsx(hs,{className:Be("w-3 h-3 transition-colors",ue?"text-yellow-600 dark:text-yellow-400 fill-current":"text-muted-foreground")})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:J=>{J.stopPropagation(),f(b)},title:"重命名项目 (F2)",children:e.jsx(Xt,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-red-50 dark:hover:bg-red-900/20 flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:J=>{J.stopPropagation(),Se({name:b.name,displayName:b.displayName})},title:"删除项目",children:e.jsx(Ge,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),Q?e.jsx(Cr,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):e.jsx(zt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),Q&&e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[se.has(b.name)?D(b).length===0&&!w[b.name]?e.jsx("div",{className:"py-2 px-3 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"还没有会话"})}):D(b).map(J=>{const ye=new Date(J.lastActivity),pe=Math.floor((ae-ye)/(1e3*60))<10,le=J.summary||"新会话",fe=J.lastActivity,ke=J.messageCount||0;return e.jsxs("div",{className:"group relative",children:[pe&&e.jsx("div",{className:"absolute left-0 top-1/2 transform -translate-y-1/2 -translate-x-1",children:e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"})}),e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:Be("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",a?.id===J.id?"bg-primary/5 border-primary/20":pe?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:()=>{ee(b),Te(J,b.name)},onTouchEnd:he(()=>{ee(b),Te(J,b.name)}),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:Be("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",a?.id===J.id?"bg-primary/10":"bg-muted/50"),children:e.jsx(dt,{className:"w-3 h-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:le}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(zr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ys(fe,ae)}),ke>0&&e.jsx(Ye,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:ke}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(dt,{className:"w-3 h-3"})})]})]}),e.jsx("button",{className:"w-5 h-5 rounded-md bg-red-50 dark:bg-red-900/20 flex items-center justify-center active:scale-95 transition-transform opacity-70 ml-1",onClick:ge=>{ge.stopPropagation(),Ee(b.name,J.id)},onTouchEnd:he(()=>Ee(b.name,J.id)),children:e.jsx(Ge,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})]})})}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx(K,{variant:"ghost",className:Be("w-full justify-start p-2 h-auto font-normal text-left hover:bg-accent/50 transition-colors duration-200",a?.id===J.id&&"bg-accent text-accent-foreground"),onClick:()=>Te(J,b.name),onTouchEnd:he(()=>Te(J,b.name)),children:e.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full",children:[e.jsx(dt,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:le}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(zr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ys(fe,ae)}),ke>0&&e.jsx(Ye,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:ke}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(dt,{className:"w-3 h-3"})})]})]})]})}),e.jsx("div",{className:"absolute right-2 top-1/2 transform -translate-y-1/2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-all duration-200",children:je===J.id?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:Z,onChange:ge=>we(ge.target.value),onKeyDown:ge=>{ge.stopPropagation(),ge.key==="Enter"?updateSessionSummary(b.name,J.id,Z):ge.key==="Escape"&&(ie(null),we(""))},onClick:ge=>ge.stopPropagation(),className:"w-32 px-2 py-1 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),e.jsx("button",{className:"w-6 h-6 bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40 rounded flex items-center justify-center",onClick:ge=>{ge.stopPropagation(),updateSessionSummary(b.name,J.id,Z)},title:"Save",children:e.jsx(cr,{className:"w-3 h-3 text-green-600 dark:text-green-400"})}),e.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:ge=>{ge.stopPropagation(),ie(null),we("")},title:"Cancel",children:e.jsx(Ue,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:ge=>{ge.stopPropagation(),ie(J.id),we(J.summary||"新会话")},title:"手动编辑会话名称",children:e.jsx(Qa,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{className:"w-6 h-6 bg-red-50 hover:bg-red-100 dark:bg-red-900/20 dark:hover:bg-red-900/40 rounded flex items-center justify-center",onClick:ge=>{ge.stopPropagation(),Ee(b.name,J.id)},title:"永久删除此会话",children:e.jsx(Ge,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]},J.id)}):Array.from({length:3}).map((J,ye)=>e.jsx("div",{className:"p-2 rounded-md",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-3 h-3 bg-muted rounded-full animate-pulse mt-0.5"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"h-3 bg-muted rounded animate-pulse",style:{width:`${60+ye*15}%`}}),e.jsx("div",{className:"h-2 bg-muted rounded animate-pulse w-1/2"})]})]})},ye)),D(b).length>0&&b.sessionMeta?.hasMore!==!1&&e.jsx(K,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>rt(b),disabled:w[b.name],children:w[b.name]?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),"加载中..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Cr,{className:"w-3 h-3"}),"显示更多会话"]})}),e.jsx("div",{className:"md:hidden px-3 pb-2",children:e.jsxs("button",{className:"w-full h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-md flex items-center justify-center gap-2 font-medium text-xs active:scale-[0.98] transition-all duration-150",onClick:()=>{ee(b),l(b)},children:[e.jsx(ot,{className:"w-3 h-3"}),"新会话"]})}),e.jsxs(K,{variant:"default",size:"sm",className:"hidden md:flex w-full justify-start gap-2 mt-1 h-8 text-xs font-medium bg-primary hover:bg-primary/90 text-primary-foreground transition-colors",onClick:()=>l(b),children:[e.jsx(ot,{className:"w-3 h-3"}),"新会话"]})]})]},b.name)})})}),e.jsxs("div",{className:"md:p-2 md:border-t md:border-border flex-shrink-0",children:[e.jsx("div",{className:"md:hidden p-4 pb-20 border-t border-border/50",children:e.jsxs("button",{className:"w-full h-14 bg-muted/50 hover:bg-muted/70 rounded-2xl flex items-center justify-start gap-4 px-4 active:scale-[0.98] transition-all duration-150",onClick:g,children:[e.jsx("div",{className:"w-10 h-10 rounded-2xl bg-background/80 flex items-center justify-center",children:e.jsx(Ot,{className:"w-5 h-5 text-muted-foreground"})}),e.jsx("span",{className:"text-lg font-medium text-foreground",children:"设置"})]})}),e.jsxs(K,{variant:"ghost",className:"hidden md:flex w-full justify-start gap-2 p-2 h-auto font-normal text-muted-foreground hover:text-foreground hover:bg-accent transition-colors duration-200",onClick:g,children:[e.jsx(Ot,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:"设置"})]})]})]})]})}const On={'code[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:"0.5em 0",overflow:"auto",borderRadius:"0.3em"},'code[class*="language-"]::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"]::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},':not(pre) > code[class*="language-"]':{padding:"0.2em 0.3em",borderRadius:"0.3em",whiteSpace:"normal"},comment:{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},prolog:{color:"hsl(220, 10%, 40%)"},cdata:{color:"hsl(220, 10%, 40%)"},doctype:{color:"hsl(220, 14%, 71%)"},punctuation:{color:"hsl(220, 14%, 71%)"},entity:{color:"hsl(220, 14%, 71%)",cursor:"help"},"attr-name":{color:"hsl(29, 54%, 61%)"},"class-name":{color:"hsl(29, 54%, 61%)"},boolean:{color:"hsl(29, 54%, 61%)"},constant:{color:"hsl(29, 54%, 61%)"},number:{color:"hsl(29, 54%, 61%)"},atrule:{color:"hsl(29, 54%, 61%)"},keyword:{color:"hsl(286, 60%, 67%)"},property:{color:"hsl(355, 65%, 65%)"},tag:{color:"hsl(355, 65%, 65%)"},symbol:{color:"hsl(355, 65%, 65%)"},deleted:{color:"hsl(355, 65%, 65%)"},important:{color:"hsl(355, 65%, 65%)"},selector:{color:"hsl(95, 38%, 62%)"},string:{color:"hsl(95, 38%, 62%)"},char:{color:"hsl(95, 38%, 62%)"},builtin:{color:"hsl(95, 38%, 62%)"},inserted:{color:"hsl(95, 38%, 62%)"},regex:{color:"hsl(95, 38%, 62%)"},"attr-value":{color:"hsl(95, 38%, 62%)"},"attr-value > .token.punctuation":{color:"hsl(95, 38%, 62%)"},variable:{color:"hsl(207, 82%, 66%)"},operator:{color:"hsl(207, 82%, 66%)"},function:{color:"hsl(207, 82%, 66%)"},url:{color:"hsl(187, 47%, 55%)"},"attr-value > .token.punctuation.attr-equals":{color:"hsl(220, 14%, 71%)"},"special-attr > .token.attr-value > .token.value.css":{color:"hsl(220, 14%, 71%)"},".language-css .token.selector":{color:"hsl(355, 65%, 65%)"},".language-css .token.property":{color:"hsl(220, 14%, 71%)"},".language-css .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.string.url":{color:"hsl(95, 38%, 62%)"},".language-css .token.important":{color:"hsl(286, 60%, 67%)"},".language-css .token.atrule .token.rule":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.operator":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation":{color:"hsl(5, 48%, 51%)"},".language-json .token.operator":{color:"hsl(220, 14%, 71%)"},".language-json .token.null.keyword":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.url":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.operator":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url-reference.url > .token.string":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.content":{color:"hsl(207, 82%, 66%)"},".language-markdown .token.url > .token.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.url-reference.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.blockquote.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.hr.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.code-snippet":{color:"hsl(95, 38%, 62%)"},".language-markdown .token.bold .token.content":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.italic .token.content":{color:"hsl(286, 60%, 67%)"},".language-markdown .token.strike .token.content":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.strike .token.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.list.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.title.important > .token.punctuation":{color:"hsl(355, 65%, 65%)"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},namespace:{Opacity:"0.8"},"token.tab:not(:empty):before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.cr:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.lf:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.space:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item":{marginRight:"0.4em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},".line-highlight.line-highlight":{background:"hsla(220, 100%, 80%, 0.04)"},".line-highlight.line-highlight:before":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},".line-highlight.line-highlight[data-end]:after":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},"pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before":{backgroundColor:"hsla(220, 100%, 80%, 0.04)"},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".command-line .command-line-prompt":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".line-numbers .line-numbers-rows > span:before":{color:"hsl(220, 14%, 45%)"},".command-line .command-line-prompt > span:before":{color:"hsl(220, 14%, 45%)"},".rainbow-braces .token.token.punctuation.brace-level-1":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-5":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-9":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-2":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-6":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-10":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-3":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-7":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-11":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-4":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-8":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-12":{color:"hsl(286, 60%, 67%)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},".prism-previewer.prism-previewer:before":{borderColor:"hsl(224, 13%, 17%)"},".prism-previewer-gradient.prism-previewer-gradient div":{borderColor:"hsl(224, 13%, 17%)",borderRadius:"0.3em"},".prism-previewer-color.prism-previewer-color:before":{borderRadius:"0.3em"},".prism-previewer-easing.prism-previewer-easing:before":{borderRadius:"0.3em"},".prism-previewer.prism-previewer:after":{borderTopColor:"hsl(224, 13%, 17%)"},".prism-previewer-flipped.prism-previewer-flipped.after":{borderBottomColor:"hsl(224, 13%, 17%)"},".prism-previewer-angle.prism-previewer-angle:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-time.prism-previewer-time:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-easing.prism-previewer-easing":{background:"hsl(219, 13%, 22%)"},".prism-previewer-angle.prism-previewer-angle circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-time.prism-previewer-time circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-easing.prism-previewer-easing circle":{stroke:"hsl(220, 14%, 71%)",fill:"transparent"},".prism-previewer-easing.prism-previewer-easing path":{stroke:"hsl(220, 14%, 71%)"},".prism-previewer-easing.prism-previewer-easing line":{stroke:"hsl(220, 14%, 71%)"}};var Er={exports:{}},Mr,js;function Fn(){if(js)return Mr;js=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Mr=t,Mr}var Lr,ws;function Wn(){if(ws)return Lr;ws=1;var t=Fn();function s(){}function a(){}return a.resetWarningCache=s,Lr=function(){function o(i,d,h,p,g,k){if(k!==t){var y=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw y.name="Invariant Violation",y}}o.isRequired=o;function n(){return o}var l={array:o,bigint:o,bool:o,func:o,number:o,object:o,string:o,symbol:o,any:o,arrayOf:n,element:o,elementType:o,instanceOf:n,node:o,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:a,resetWarningCache:s};return l.PropTypes=l,l},Lr}var ks;function Bn(){return ks||(ks=1,Er.exports=Wn()()),Er.exports}var Un=Bn();const $e=Vr(Un);function Mt(t,s,a,o){function n(l){return l instanceof a?l:new a(function(i){i(l)})}return new(a||(a=Promise))(function(l,i){function d(g){try{p(o.next(g))}catch(k){i(k)}}function h(g){try{p(o.throw(g))}catch(k){i(k)}}function p(g){g.done?l(g.value):n(g.value).then(d,h)}p((o=o.apply(t,s||[])).next())})}const Hn=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function Wt(t,s,a){const o=qn(t),{webkitRelativePath:n}=t,l=typeof s=="string"?s:typeof n=="string"&&n.length>0?n:`./${t.name}`;return typeof o.path!="string"&&Ns(o,"path",l),Ns(o,"relativePath",l),o}function qn(t){const{name:s}=t;if(s&&s.lastIndexOf(".")!==-1&&!t.type){const o=s.split(".").pop().toLowerCase(),n=Hn.get(o);n&&Object.defineProperty(t,"type",{value:n,writable:!1,configurable:!1,enumerable:!0})}return t}function Ns(t,s,a){Object.defineProperty(t,s,{value:a,writable:!1,configurable:!1,enumerable:!0})}const Jn=[".DS_Store","Thumbs.db"];function Kn(t){return Mt(this,void 0,void 0,function*(){return ur(t)&&Gn(t.dataTransfer)?Zn(t.dataTransfer,t.type):Vn(t)?Yn(t):Array.isArray(t)&&t.every(s=>"getFile"in s&&typeof s.getFile=="function")?Qn(t):[]})}function Gn(t){return ur(t)}function Vn(t){return ur(t)&&ur(t.target)}function ur(t){return typeof t=="object"&&t!==null}function Yn(t){return Wr(t.target.files).map(s=>Wt(s))}function Qn(t){return Mt(this,void 0,void 0,function*(){return(yield Promise.all(t.map(a=>a.getFile()))).map(a=>Wt(a))})}function Zn(t,s){return Mt(this,void 0,void 0,function*(){if(t.items){const a=Wr(t.items).filter(n=>n.kind==="file");if(s!=="drop")return a;const o=yield Promise.all(a.map(Xn));return Ss(Ys(o))}return Ss(Wr(t.files).map(a=>Wt(a)))})}function Ss(t){return t.filter(s=>Jn.indexOf(s.name)===-1)}function Wr(t){if(t===null)return[];const s=[];for(let a=0;a<t.length;a++){const o=t[a];s.push(o)}return s}function Xn(t){if(typeof t.webkitGetAsEntry!="function")return Cs(t);const s=t.webkitGetAsEntry();return s&&s.isDirectory?Qs(s):Cs(t,s)}function Ys(t){return t.reduce((s,a)=>[...s,...Array.isArray(a)?Ys(a):[a]],[])}function Cs(t,s){return Mt(this,void 0,void 0,function*(){var a;if(globalThis.isSecureContext&&typeof t.getAsFileSystemHandle=="function"){const l=yield t.getAsFileSystemHandle();if(l===null)throw new Error(`${t} is not a File`);if(l!==void 0){const i=yield l.getFile();return i.handle=l,Wt(i)}}const o=t.getAsFile();if(!o)throw new Error(`${t} is not a File`);return Wt(o,(a=s?.fullPath)!==null&&a!==void 0?a:void 0)})}function eo(t){return Mt(this,void 0,void 0,function*(){return t.isDirectory?Qs(t):to(t)})}function Qs(t){const s=t.createReader();return new Promise((a,o)=>{const n=[];function l(){s.readEntries(i=>Mt(this,void 0,void 0,function*(){if(i.length){const d=Promise.all(i.map(eo));n.push(d),l()}else try{const d=yield Promise.all(n);a(d)}catch(d){o(d)}}),i=>{o(i)})}l()})}function to(t){return Mt(this,void 0,void 0,function*(){return new Promise((s,a)=>{t.file(o=>{const n=Wt(o,t.fullPath);s(n)},o=>{a(o)})})})}var or={},Es;function ro(){return Es||(Es=1,or.__esModule=!0,or.default=function(t,s){if(t&&s){var a=Array.isArray(s)?s:s.split(",");if(a.length===0)return!0;var o=t.name||"",n=(t.type||"").toLowerCase(),l=n.replace(/\/.*$/,"");return a.some(function(i){var d=i.trim().toLowerCase();return d.charAt(0)==="."?o.toLowerCase().endsWith(d):d.endsWith("/*")?l===d.replace(/\/.*$/,""):n===d})}return!0}),or}var so=ro();const Ir=Vr(so);function Ms(t){return oo(t)||no(t)||Xs(t)||ao()}function ao(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import{j as e,s as Pa,R as Ra,o as za,E as $a,m as _a,b as Aa,c as Oa,h as Fa,p as Wa,d as Ba}from"./vendor-codemirror-C_VWDoZS.js";import{b as Ua,g as Vr,a as r,d as ps,R as tt,u as Os,B as Ha,e as qa,f as xs,h as Ja}from"./vendor-react-BeVl62c0.js";import{t as Ka,c as Ga,a as Fs,F as Va}from"./vendor-utils-00TdZexr.js";import{F as Rr,X as Ue,C as Ya,L as wt,T as Ge,R as _t,S as At,a as nt,b as Et,c as cr,d as hs,P as Xt,e as Cr,f as zt,g as zr,h as Qa,i as ot,j as Ot,k as Za,l as Xa,M as dr,B as Ws,D as $t,m as Bs,n as en,o as Us,U as gs,p as tn,E as Hs,q as rn,r as sn,s as qs,t as fs,u as hr,v as gr,I as Js,w as Ft,x as fr,y as br,G as $r,Z as an,z as nn,A as on,H as Ks,J as Gs,K as _r,N as ln,O as cn,Q as mr,V as yr,W as dn,Y as mn,_ as Vs,$ as un,a0 as pn,a1 as Ar,a2 as Or,a3 as Fr,a4 as xn,a5 as hn,a6 as gn,a7 as fn,a8 as bn,a9 as yn,aa as vn,ab as jn}from"./vendor-icons-CX_nKP5H.js";import{r as wn,a as kn,b as Nn,M as Sn}from"./vendor-markdown-VwNYkg_0.js";import{h as Cn}from"./vendor-syntax-CdGaPJRS.js";import{r as En,a as Mn,b as Ln,c as In}from"./vendor-xterm-CvdiG4-n.js";import"./vendor-katex-DK8hFnhL.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const l of n)if(l.type==="childList")for(const i of l.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function a(n){const l={};return n.integrity&&(l.integrity=n.integrity),n.referrerPolicy&&(l.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?l.credentials="include":n.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function o(n){if(n.ep)return;n.ep=!0;const l=a(n);fetch(n.href,l)}})();var nr={},bs;function Dn(){if(bs)return nr;bs=1;var t=Ua();return nr.createRoot=t.createRoot,nr.hydrateRoot=t.hydrateRoot,nr}var Tn=Dn();const Pn=Vr(Tn);function Be(...t){return Ka(Ga(t))}function Rn(t){if(!t||typeof t!="string")return null;try{return JSON.parse(t)}catch{return null}}const Yr=r.forwardRef(({className:t,children:s,...a},o)=>e.jsx("div",{ref:o,className:Be("relative overflow-hidden",t),...a,children:e.jsx("div",{className:"h-full w-full rounded-[inherit] overflow-auto",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:s})}));Yr.displayName="ScrollArea";const zn=Fs("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),K=r.forwardRef(({className:t,variant:s,size:a,...o},n)=>e.jsx("button",{className:Be(zn({variant:s,size:a,className:t})),ref:n,...o}));K.displayName="Button";const $n=Fs("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",success:"border-transparent bg-green-500 text-white shadow hover:bg-green-500/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ve({className:t,variant:s,...a}){return e.jsx("div",{className:Be($n({variant:s}),t),...a})}const Ye=r.forwardRef(({className:t,type:s,...a},o)=>e.jsx("input",{type:s,className:Be("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",t),ref:o,...a}));Ye.displayName="Input";const dt=({className:t="w-5 h-5"})=>e.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:t}),re=(t,s={})=>{const a=localStorage.getItem("auth-token"),o={};return s.body instanceof FormData||(o["Content-Type"]="application/json"),a&&(o.Authorization=`Bearer ${a}`),fetch(t,{...s,headers:{...o,...s.headers}})},ve={auth:{status:()=>fetch("/api/auth/status"),login:(t,s)=>fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:s})}),sendCode:t=>fetch("/api/auth/send-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t})}),verifyCode:(t,s)=>fetch("/api/auth/verify-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t,code:s})}),user:()=>re("/api/auth/user"),logout:()=>re("/api/auth/logout",{method:"POST"}),limitStatus:()=>re("/api/auth/limit-status"),changePassword:(t,s)=>re("/api/auth/change-password",{method:"PATCH",body:JSON.stringify({current_password:t,new_password:s})}),feishuBindToken:()=>re("/api/auth/feishu-bind-token",{method:"POST"})},admin:{getUsers:()=>re("/api/admin/users"),createUser:(t,s)=>re("/api/admin/users",{method:"POST",body:JSON.stringify({username:t,password:s})}),updateUserStatus:(t,s)=>re(`/api/admin/users/${t}`,{method:"PATCH",body:JSON.stringify({status:s})}),deleteUser:t=>re(`/api/admin/users/${t}`,{method:"DELETE"}),getEmailDomains:()=>re("/api/admin/email-domains"),addEmailDomain:t=>re("/api/admin/email-domains",{method:"POST",body:JSON.stringify({domain:t})}),removeEmailDomain:t=>re(`/api/admin/email-domains/${t}`,{method:"DELETE"}),getUserLimits:t=>re(`/api/admin/users/${t}/limits`),updateUserLimits:(t,s)=>re(`/api/admin/users/${t}/limits`,{method:"PATCH",body:JSON.stringify(s)}),resetUserPassword:(t,s)=>re(`/api/admin/users/${t}/password`,{method:"PATCH",body:JSON.stringify({new_password:s})}),getDefaultLimits:()=>re("/api/admin/settings/default-limits"),updateDefaultLimits:t=>re("/api/admin/settings/default-limits",{method:"PUT",body:JSON.stringify(t)})},projects:()=>re("/api/projects"),sessions:(t,s=5,a=0)=>re(`/api/projects/${t}/sessions?limit=${s}&offset=${a}`),sessionMessages:(t,s,a=null,o=0)=>{const n=new URLSearchParams;a!==null&&(n.append("limit",a),n.append("offset",o));const l=n.toString(),i=`/api/projects/${t}/sessions/${s}/messages${l?`?${l}`:""}`;return re(i)},renameProject:(t,s)=>re(`/api/projects/${t}/rename`,{method:"PUT",body:JSON.stringify({displayName:s})}),deleteSession:(t,s)=>re(`/api/projects/${t}/sessions/${s}`,{method:"DELETE"}),deleteProject:(t,s=!0)=>re(`/api/projects/${t}?deleteFolder=${s}`,{method:"DELETE"}),createProject:t=>re("/api/projects/create",{method:"POST",body:JSON.stringify({path:t})}),createWorkspace:t=>re("/api/projects/create-workspace",{method:"POST",body:JSON.stringify(t)}),readFile:(t,s)=>re(`/api/projects/${t}/file?filePath=${encodeURIComponent(s)}`),saveFile:(t,s,a)=>re(`/api/projects/${t}/file`,{method:"PUT",body:JSON.stringify({filePath:s,content:a})}),getFiles:(t,s={})=>{const a=new URLSearchParams;s.dirPath&&a.set("dirPath",s.dirPath),s.depth&&a.set("depth",s.depth.toString());const o=a.toString();return re(`/api/projects/${t}/files${o?"?"+o:""}`)},uploadFiles:(t,s)=>re(`/api/projects/${t}/upload-files`,{method:"POST",body:s,headers:{}}),deleteFile:(t,s)=>re(`/api/projects/${t}/files?filePath=${encodeURIComponent(s)}`,{method:"DELETE"}),getFileContent:(t,s)=>re(`/api/projects/${t}/files/content?path=${encodeURIComponent(s)}`),transcribe:t=>re("/api/transcribe",{method:"POST",body:t,headers:{}}),settings:{getAgentPermissions:()=>re("/api/settings/agent-permissions"),saveAgentPermissions:t=>re("/api/settings/agent-permissions",{method:"PUT",body:JSON.stringify({agentPermissions:t})})},get:t=>re(`/api${t}`)},_n=/^[a-zA-Z0-9_-]+$/,An=({onClose:t,onProjectCreated:s})=>{const[a,o]=r.useState(""),[n,l]=r.useState(""),[i,d]=r.useState(!1),[h,p]=r.useState(null),g=v=>v.trim()?_n.test(v.trim())?null:"项目名称只能包含字母、数字、连字符和下划线":"项目名称为必填项",k=async()=>{p(null);const v=g(a);if(v){p(v);return}d(!0);try{const x={name:a.trim()};n.trim()&&(x.githubUrl=n.trim());const R=await ve.createWorkspace(x),z=await R.json();if(!R.ok)throw new Error(z.error||"Failed to create project");s&&s(z.project),t()}catch(x){console.error("Error creating project:",x),p(x.message||"Failed to create project")}finally{d(!1)}},y=v=>{v.key==="Enter"&&!i&&k()};return e.jsx("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[60] p-0 sm:p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-none sm:rounded-lg shadow-xl w-full h-full sm:h-auto sm:max-w-md border-0 sm:border border-gray-200 dark:border-gray-700 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Rr,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"创建新项目"})]}),e.jsx("button",{onClick:t,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",disabled:i,children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-5",children:[h&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(Ya,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:h})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["项目名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ye,{type:"text",value:a,onChange:v=>o(v.target.value),onKeyDown:y,placeholder:"my-awesome-project",className:"w-full",autoFocus:!0}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"仅允许字母、数字、连字符和下划线"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"GitHub 链接(可选)"}),e.jsx(Ye,{type:"text",value:n,onChange:v=>l(v.target.value),onKeyDown:y,placeholder:"https://github.com/user/repo",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"留空以创建空项目,或输入公共仓库链接以克隆"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(K,{variant:"outline",onClick:t,disabled:i,children:"取消"}),e.jsx(K,{onClick:k,disabled:i||!a.trim(),children:i?e.jsxs(e.Fragment,{children:[e.jsx(wt,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):"创建项目"})]})]})})},ys=(t,s)=>{const a=new Date(t),o=s;if(isNaN(a.getTime()))return"Unknown";const n=o-a,l=Math.floor(n/1e3),i=Math.floor(n/(1e3*60)),d=Math.floor(n/(1e3*60*60)),h=Math.floor(n/(1e3*60*60*24));return l<60?"Just now":i===1?"1 min ago":i<60?`${i} mins ago`:d===1?"1 hour ago":d<24?`${d} hours ago`:h===1?"1 day ago":h<7?`${h} days ago`:a.toLocaleDateString()};function vs({projects:t,selectedProject:s,selectedSession:a,onProjectSelect:o,onSessionSelect:n,onNewSession:l,onSessionDelete:i,onProjectDelete:d,isLoading:h,onRefresh:p,onShowSettings:g,isPWA:k,isMobile:y,onToggleSidebar:v}){const[x,R]=r.useState(new Set),[z,T]=r.useState(null),[C,u]=r.useState(!1),[m,j]=r.useState(""),[w,L]=r.useState({}),[F,O]=r.useState({}),[se,ce]=r.useState(new Set),[ae,oe]=r.useState(new Date),[W,I]=r.useState("name"),[_,X]=r.useState(!1),[je,ie]=r.useState(null),[Z,we]=r.useState(""),[Me,De]=r.useState({}),[Ce,Oe]=r.useState(""),[xe,Se]=r.useState(null),[Re,ze]=r.useState(()=>{try{const b=localStorage.getItem("starredProjects");return b?new Set(JSON.parse(b)):new Set}catch(b){return console.error("Error loading starred projects:",b),new Set}}),he=b=>Q=>{Q.target.closest(".overflow-y-auto")||Q.target.closest("[data-scroll-container]")||(Q.preventDefault(),Q.stopPropagation(),b())};r.useEffect(()=>{const b=setInterval(()=>{oe(new Date)},6e4);return()=>clearInterval(b)},[]),r.useEffect(()=>{O({}),ce(new Set)},[t]),r.useEffect(()=>{a&&s&&R(b=>new Set([...b,s.name]))},[a,s]),r.useEffect(()=>{if(t.length>0&&!h){const b=new Set;t.forEach(Q=>{Q.sessions&&Q.sessions.length>=0&&b.add(Q.name)}),ce(b)}},[t,h]),r.useEffect(()=>{const b=()=>{try{const ue=localStorage.getItem("claude-settings");if(ue){const J=JSON.parse(ue);I(J.projectSortOrder||"name")}}catch(ue){console.error("Error loading sort order:",ue)}};b();const Q=ue=>{ue.key==="claude-settings"&&b()};window.addEventListener("storage",Q);const B=setInterval(()=>{document.hasFocus()&&b()},1e3);return()=>{window.removeEventListener("storage",Q),clearInterval(B)}},[]);const Le=b=>{const Q=new Set;x.has(b)||Q.add(b),R(Q)},Te=(b,Q)=>{n({...b,__projectName:Q})},_e=b=>{const Q=new Set(Re);Q.has(b)?Q.delete(b):Q.add(b),ze(Q);try{localStorage.setItem("starredProjects",JSON.stringify([...Q]))}catch(B){console.error("Error saving starred projects:",B)}},We=b=>Re.has(b),D=b=>[...b.sessions||[],...F[b.name]||[]].map(B=>({...B,__provider:"claude"})).sort((B,ue)=>new Date(ue.lastActivity)-new Date(B.lastActivity)),$=b=>{const Q=D(b);return Q.length===0?new Date(0):Q.reduce((ue,J)=>{const ye=new Date(J.lastActivity);return ye>ue?ye:ue},new Date(0))},A=[...t].sort((b,Q)=>{const B=We(b.name),ue=We(Q.name);if(B&&!ue)return-1;if(!B&&ue)return 1;if(W==="date")return $(Q)-$(b);{const J=b.displayName||b.name,ye=Q.displayName||Q.name;return J.localeCompare(ye)}}),f=b=>{T(b.name),j(b.displayName)},H=()=>{T(null),j("")},de=async b=>{try{(await ve.renameProject(b,m)).ok?window.refreshProjects?window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(Q){console.error("Error renaming project:",Q)}T(null),j("")},Ee=async(b,Q,B="claude")=>{if(confirm("Are you sure you want to delete this session? This action cannot be undone."))try{console.log("[Sidebar] Deleting session:",{projectName:b,sessionId:Q,provider:B});const ue=await ve.deleteSession(b,Q);if(console.log("[Sidebar] Delete response:",{ok:ue.ok,status:ue.status}),ue.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),i?i(Q):console.warn("[Sidebar] No onSessionDelete callback provided");else{const J=await ue.text();console.error("[Sidebar] Failed to delete session:",{status:ue.status,error:J}),alert("Failed to delete session. Please try again.")}}catch(ue){console.error("[Sidebar] Error deleting session:",ue),alert("Error deleting session. Please try again.")}},Ae=async b=>{if(xe)try{const Q=await ve.deleteProject(b,!0);if(Q.ok)Se(null),d&&d(b);else{const B=await Q.json();console.error("Failed to delete project"),alert(B.error||"Failed to delete project. Please try again.")}}catch(Q){console.error("Error deleting project:",Q),alert("Error deleting project. Please try again.")}},rt=async b=>{if(!(!(b.sessionMeta?.hasMore!==!1)||w[b.name])){L(B=>({...B,[b.name]:!0}));try{const B=(b.sessions?.length||0)+(F[b.name]?.length||0),ue=await ve.sessions(b.name,5,B);if(ue.ok){const J=await ue.json();O(ye=>({...ye,[b.name]:[...ye[b.name]||[],...J.sessions]})),J.hasMore===!1&&(b.sessionMeta={...b.sessionMeta,hasMore:!1})}}catch(B){console.error("Error loading more sessions:",B)}finally{L(B=>({...B,[b.name]:!1}))}}},G=A.filter(b=>{if(!Ce.trim())return!0;const Q=Ce.toLowerCase(),B=(b.displayName||b.name).toLowerCase(),ue=b.name.toLowerCase();return B.includes(Q)||ue.includes(Q)}),ee=b=>{o(b)};return e.jsxs(e.Fragment,{children:[C&&ps.createPortal(e.jsx(An,{onClose:()=>u(!1),onProjectCreated:b=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),xe&&ps.createPortal(e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4",children:e.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl w-full max-w-sm p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:e.jsx(Ge,{className:"w-5 h-5 text-red-600 dark:text-red-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"删除项目"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"此操作不可撤销"})]})]}),e.jsxs("p",{className:"text-sm text-foreground",children:["确定要删除项目 ",e.jsxs("span",{className:"font-medium text-red-600 dark:text-red-400",children:['"',xe.displayName||xe.name,'"']})," 吗?"]}),e.jsx("p",{className:"text-xs text-muted-foreground bg-muted/50 rounded-lg p-3",children:"将同时删除:所有会话记录(JSONL 文件)和项目文件夹及其所有内容。"}),e.jsxs("div",{className:"flex gap-3 pt-1",children:[e.jsx("button",{className:"flex-1 px-4 py-2 rounded-lg border border-border text-sm font-medium hover:bg-accent transition-colors",onClick:()=>Se(null),children:"取消"}),e.jsx("button",{className:"flex-1 px-4 py-2 rounded-lg bg-red-600 hover:bg-red-700 text-white text-sm font-medium transition-colors",onClick:()=>Ae(xe.name),children:"确认删除"})]})]})}),document.body),e.jsxs("div",{className:"h-full flex flex-col bg-card md:select-none",style:k&&y?{paddingTop:"44px"}:{},children:[e.jsxs("div",{className:"md:p-4 md:border-b md:border-border",children:[e.jsxs("div",{className:"hidden md:flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:"/logo.svg",className:"w-8 h-8",alt:"AgentHub"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold text-foreground",children:"AgentHub"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"你的 AI 助手"})]})]}),v&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 hover:bg-accent transition-colors duration-200",onClick:v,title:"收起侧边栏",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]}),e.jsx("div",{className:"md:hidden p-3 border-b border-border",style:k&&y?{paddingTop:"16px"}:{},children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:"/logo.svg",className:"w-8 h-8",alt:"AgentHub"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"AgentHub"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"项目"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{className:"w-8 h-8 rounded-md bg-background border border-border flex items-center justify-center active:scale-95 transition-all duration-150",onClick:async()=>{X(!0);try{await p()}finally{X(!1)}},disabled:_,children:e.jsx(_t,{className:`w-4 h-4 text-foreground ${_?"animate-spin":""}`})}),e.jsx("button",{className:"w-8 h-8 rounded-md bg-primary text-primary-foreground flex items-center justify-center active:scale-95 transition-all duration-150",onClick:()=>u(!0),children:e.jsx(Rr,{className:"w-4 h-4"})})]})]})})]}),!h&&!y&&e.jsx("div",{className:"px-3 md:px-4 py-2 border-b border-border",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"default",size:"sm",className:"flex-1 h-8 text-xs bg-primary hover:bg-primary/90 transition-all duration-200",onClick:()=>u(!0),title:"创建新项目",children:[e.jsx(Rr,{className:"w-3.5 h-3.5 mr-1.5"}),"新建项目"]}),e.jsx(K,{variant:"outline",size:"sm",className:"h-8 w-8 px-0 hover:bg-accent transition-colors duration-200 group",onClick:async()=>{X(!0);try{await p()}finally{X(!1)}},disabled:_,title:"刷新项目和会话 (Ctrl+R)",children:e.jsx(_t,{className:`w-3.5 h-3.5 ${_?"animate-spin":""} group-hover:rotate-180 transition-transform duration-300`})})]})}),t.length>0&&!h&&e.jsx("div",{className:"px-3 md:px-4 py-2 border-b border-border",children:e.jsxs("div",{className:"relative",children:[e.jsx(At,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Ye,{type:"text",placeholder:"搜索项目...",value:Ce,onChange:b=>Oe(b.target.value),className:"pl-9 h-9 text-sm bg-muted/50 border-0 focus:bg-background focus:ring-1 focus:ring-primary/20"}),Ce&&e.jsx("button",{onClick:()=>Oe(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 hover:bg-accent rounded",children:e.jsx(Ue,{className:"w-3 h-3 text-muted-foreground"})})]})}),e.jsx(Yr,{className:"flex-1 md:px-2 md:py-3 overflow-y-auto overscroll-contain",children:e.jsx("div",{className:"md:space-y-1 pb-safe-area-inset-bottom",children:h?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:"加载项目中..."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"正在获取您的 Claude 项目和会话"})]}):t.length===0?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(nt,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:"未找到项目"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"在项目目录中运行 Claude CLI 以开始使用"})]}):G.length===0?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(At,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:"无匹配的项目"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"尝试调整搜索条件"})]}):G.map(b=>{const Q=x.has(b.name),B=s?.name===b.name,ue=We(b.name);return e.jsxs("div",{className:"md:space-y-1",children:[e.jsxs("div",{className:"group md:group",children:[e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:Be("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",B&&"bg-primary/5 border-primary/20",ue&&!B&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:()=>{Le(b.name)},onTouchEnd:he(()=>Le(b.name)),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:Be("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",Q?"bg-primary/10":"bg-muted"),children:Q?e.jsx(Et,{className:"w-4 h-4 text-primary"}):e.jsx(nt,{className:"w-4 h-4 text-muted-foreground"})}),e.jsx("div",{className:"min-w-0 flex-1",children:z===b.name?e.jsx("input",{type:"text",value:m,onChange:J=>j(J.target.value),className:"w-full px-3 py-2 text-sm border-2 border-primary/40 focus:border-primary rounded-lg bg-background text-foreground shadow-sm focus:shadow-md transition-all duration-200 focus:outline-none",placeholder:"项目名称",autoFocus:!0,autoComplete:"off",onClick:J=>J.stopPropagation(),onKeyDown:J=>{J.key==="Enter"&&de(b.name),J.key==="Escape"&&H()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-between min-w-0 flex-1",children:e.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:b.displayName})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(()=>{const J=D(b).length;return`${b.sessionMeta?.hasMore!==!1&&J>=5?`${J}+`:J} 会话`})()})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:z===b.name?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-green-500 dark:bg-green-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:J=>{J.stopPropagation(),de(b.name)},children:e.jsx(cr,{className:"w-4 h-4 text-white"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500 dark:bg-gray-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:J=>{J.stopPropagation(),H()},children:e.jsx(Ue,{className:"w-4 h-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:Be("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",ue?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:J=>{J.stopPropagation(),_e(b.name)},onTouchEnd:he(()=>_e(b.name)),title:ue?"从收藏中移除":"添加到收藏",children:e.jsx(hs,{className:Be("w-4 h-4 transition-colors",ue?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-red-500/10 dark:bg-red-900/30 flex items-center justify-center active:scale-90 border border-red-200 dark:border-red-800",onClick:J=>{J.stopPropagation(),Se({name:b.name,displayName:b.displayName})},onTouchEnd:he(()=>Se({name:b.name,displayName:b.displayName})),children:e.jsx(Ge,{className:"w-4 h-4 text-red-600 dark:text-red-400"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/10 dark:bg-primary/20 flex items-center justify-center active:scale-90 border border-primary/20 dark:border-primary/30",onClick:J=>{J.stopPropagation(),f(b)},onTouchEnd:he(()=>f(b)),children:e.jsx(Xt,{className:"w-4 h-4 text-primary"})}),e.jsx("div",{className:"w-6 h-6 rounded-md bg-muted/30 flex items-center justify-center",children:Q?e.jsx(Cr,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(zt,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),e.jsxs(K,{variant:"ghost",className:Be("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",B&&"bg-accent text-accent-foreground",ue&&!B&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:()=>{s?.name!==b.name&&ee(b),Le(b.name)},onTouchEnd:he(()=>{s?.name!==b.name&&ee(b),Le(b.name)}),children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[Q?e.jsx(Et,{className:"w-4 h-4 text-primary flex-shrink-0"}):e.jsx(nt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:z===b.name?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:m,onChange:J=>j(J.target.value),className:"w-full px-2 py-1 text-sm border border-border rounded bg-background text-foreground focus:ring-2 focus:ring-primary/20",placeholder:"项目名称",autoFocus:!0,onKeyDown:J=>{J.key==="Enter"&&de(b.name),J.key==="Escape"&&H()}}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",title:b.fullPath,children:b.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold truncate text-foreground",title:b.displayName,children:b.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[(()=>{const J=D(b).length;return b.sessionMeta?.hasMore!==!1&&J>=5?`${J}+`:J})(),b.fullPath!==b.displayName&&e.jsxs("span",{className:"ml-1 opacity-60",title:b.fullPath,children:["• ",b.fullPath.length>25?"..."+b.fullPath.slice(-22):b.fullPath]})]})]})})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:z===b.name?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-6 h-6 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-900/20 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:J=>{J.stopPropagation(),de(b.name)},children:e.jsx(cr,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 text-gray-500 hover:text-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:J=>{J.stopPropagation(),H()},children:e.jsx(Ue,{className:"w-3 h-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:Be("w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 flex items-center justify-center rounded cursor-pointer touch:opacity-100",ue?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100":"hover:bg-accent"),onClick:J=>{J.stopPropagation(),_e(b.name)},title:ue?"从收藏中移除":"添加到收藏",children:e.jsx(hs,{className:Be("w-3 h-3 transition-colors",ue?"text-yellow-600 dark:text-yellow-400 fill-current":"text-muted-foreground")})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:J=>{J.stopPropagation(),f(b)},title:"重命名项目 (F2)",children:e.jsx(Xt,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-red-50 dark:hover:bg-red-900/20 flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:J=>{J.stopPropagation(),Se({name:b.name,displayName:b.displayName})},title:"删除项目",children:e.jsx(Ge,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),Q?e.jsx(Cr,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):e.jsx(zt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),Q&&e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[se.has(b.name)?D(b).length===0&&!w[b.name]?e.jsx("div",{className:"py-2 px-3 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"还没有会话"})}):D(b).map(J=>{const ye=new Date(J.lastActivity),pe=Math.floor((ae-ye)/(1e3*60))<10,le=J.summary||"新会话",fe=J.lastActivity,ke=J.messageCount||0;return e.jsxs("div",{className:"group relative",children:[pe&&e.jsx("div",{className:"absolute left-0 top-1/2 transform -translate-y-1/2 -translate-x-1",children:e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"})}),e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:Be("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",a?.id===J.id?"bg-primary/5 border-primary/20":pe?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:()=>{ee(b),Te(J,b.name)},onTouchEnd:he(()=>{ee(b),Te(J,b.name)}),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:Be("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",a?.id===J.id?"bg-primary/10":"bg-muted/50"),children:e.jsx(dt,{className:"w-3 h-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:le}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(zr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ys(fe,ae)}),ke>0&&e.jsx(Ve,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:ke}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(dt,{className:"w-3 h-3"})})]})]}),e.jsx("button",{className:"w-5 h-5 rounded-md bg-red-50 dark:bg-red-900/20 flex items-center justify-center active:scale-95 transition-transform opacity-70 ml-1",onClick:ge=>{ge.stopPropagation(),Ee(b.name,J.id)},onTouchEnd:he(()=>Ee(b.name,J.id)),children:e.jsx(Ge,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})]})})}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx(K,{variant:"ghost",className:Be("w-full justify-start p-2 h-auto font-normal text-left hover:bg-accent/50 transition-colors duration-200",a?.id===J.id&&"bg-accent text-accent-foreground"),onClick:()=>Te(J,b.name),onTouchEnd:he(()=>Te(J,b.name)),children:e.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full",children:[e.jsx(dt,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:le}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(zr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ys(fe,ae)}),ke>0&&e.jsx(Ve,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:ke}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(dt,{className:"w-3 h-3"})})]})]})]})}),e.jsx("div",{className:"absolute right-2 top-1/2 transform -translate-y-1/2 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-all duration-200",children:je===J.id?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:Z,onChange:ge=>we(ge.target.value),onKeyDown:ge=>{ge.stopPropagation(),ge.key==="Enter"?updateSessionSummary(b.name,J.id,Z):ge.key==="Escape"&&(ie(null),we(""))},onClick:ge=>ge.stopPropagation(),className:"w-32 px-2 py-1 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),e.jsx("button",{className:"w-6 h-6 bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40 rounded flex items-center justify-center",onClick:ge=>{ge.stopPropagation(),updateSessionSummary(b.name,J.id,Z)},title:"Save",children:e.jsx(cr,{className:"w-3 h-3 text-green-600 dark:text-green-400"})}),e.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:ge=>{ge.stopPropagation(),ie(null),we("")},title:"Cancel",children:e.jsx(Ue,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:ge=>{ge.stopPropagation(),ie(J.id),we(J.summary||"新会话")},title:"手动编辑会话名称",children:e.jsx(Qa,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{className:"w-6 h-6 bg-red-50 hover:bg-red-100 dark:bg-red-900/20 dark:hover:bg-red-900/40 rounded flex items-center justify-center",onClick:ge=>{ge.stopPropagation(),Ee(b.name,J.id)},title:"永久删除此会话",children:e.jsx(Ge,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]},J.id)}):Array.from({length:3}).map((J,ye)=>e.jsx("div",{className:"p-2 rounded-md",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-3 h-3 bg-muted rounded-full animate-pulse mt-0.5"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"h-3 bg-muted rounded animate-pulse",style:{width:`${60+ye*15}%`}}),e.jsx("div",{className:"h-2 bg-muted rounded animate-pulse w-1/2"})]})]})},ye)),D(b).length>0&&b.sessionMeta?.hasMore!==!1&&e.jsx(K,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>rt(b),disabled:w[b.name],children:w[b.name]?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),"加载中..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Cr,{className:"w-3 h-3"}),"显示更多会话"]})}),e.jsx("div",{className:"md:hidden px-3 pb-2",children:e.jsxs("button",{className:"w-full h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-md flex items-center justify-center gap-2 font-medium text-xs active:scale-[0.98] transition-all duration-150",onClick:()=>{ee(b),l(b)},children:[e.jsx(ot,{className:"w-3 h-3"}),"新会话"]})}),e.jsxs(K,{variant:"default",size:"sm",className:"hidden md:flex w-full justify-start gap-2 mt-1 h-8 text-xs font-medium bg-primary hover:bg-primary/90 text-primary-foreground transition-colors",onClick:()=>l(b),children:[e.jsx(ot,{className:"w-3 h-3"}),"新会话"]})]})]},b.name)})})}),e.jsxs("div",{className:"md:p-2 md:border-t md:border-border flex-shrink-0",children:[e.jsx("div",{className:"md:hidden p-4 pb-20 border-t border-border/50",children:e.jsxs("button",{className:"w-full h-14 bg-muted/50 hover:bg-muted/70 rounded-2xl flex items-center justify-start gap-4 px-4 active:scale-[0.98] transition-all duration-150",onClick:g,children:[e.jsx("div",{className:"w-10 h-10 rounded-2xl bg-background/80 flex items-center justify-center",children:e.jsx(Ot,{className:"w-5 h-5 text-muted-foreground"})}),e.jsx("span",{className:"text-lg font-medium text-foreground",children:"设置"})]})}),e.jsxs(K,{variant:"ghost",className:"hidden md:flex w-full justify-start gap-2 p-2 h-auto font-normal text-muted-foreground hover:text-foreground hover:bg-accent transition-colors duration-200",onClick:g,children:[e.jsx(Ot,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:"设置"})]})]})]})]})}const On={'code[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{background:"hsl(220, 13%, 18%)",color:"hsl(220, 14%, 71%)",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:'"Fira Code", "Fira Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"2",OTabSize:"2",tabSize:"2",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:"0.5em 0",overflow:"auto",borderRadius:"0.3em"},'code[class*="language-"]::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::-moz-selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"]::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'code[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},'pre[class*="language-"] *::selection':{background:"hsl(220, 13%, 28%)",color:"inherit",textShadow:"none"},':not(pre) > code[class*="language-"]':{padding:"0.2em 0.3em",borderRadius:"0.3em",whiteSpace:"normal"},comment:{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},prolog:{color:"hsl(220, 10%, 40%)"},cdata:{color:"hsl(220, 10%, 40%)"},doctype:{color:"hsl(220, 14%, 71%)"},punctuation:{color:"hsl(220, 14%, 71%)"},entity:{color:"hsl(220, 14%, 71%)",cursor:"help"},"attr-name":{color:"hsl(29, 54%, 61%)"},"class-name":{color:"hsl(29, 54%, 61%)"},boolean:{color:"hsl(29, 54%, 61%)"},constant:{color:"hsl(29, 54%, 61%)"},number:{color:"hsl(29, 54%, 61%)"},atrule:{color:"hsl(29, 54%, 61%)"},keyword:{color:"hsl(286, 60%, 67%)"},property:{color:"hsl(355, 65%, 65%)"},tag:{color:"hsl(355, 65%, 65%)"},symbol:{color:"hsl(355, 65%, 65%)"},deleted:{color:"hsl(355, 65%, 65%)"},important:{color:"hsl(355, 65%, 65%)"},selector:{color:"hsl(95, 38%, 62%)"},string:{color:"hsl(95, 38%, 62%)"},char:{color:"hsl(95, 38%, 62%)"},builtin:{color:"hsl(95, 38%, 62%)"},inserted:{color:"hsl(95, 38%, 62%)"},regex:{color:"hsl(95, 38%, 62%)"},"attr-value":{color:"hsl(95, 38%, 62%)"},"attr-value > .token.punctuation":{color:"hsl(95, 38%, 62%)"},variable:{color:"hsl(207, 82%, 66%)"},operator:{color:"hsl(207, 82%, 66%)"},function:{color:"hsl(207, 82%, 66%)"},url:{color:"hsl(187, 47%, 55%)"},"attr-value > .token.punctuation.attr-equals":{color:"hsl(220, 14%, 71%)"},"special-attr > .token.attr-value > .token.value.css":{color:"hsl(220, 14%, 71%)"},".language-css .token.selector":{color:"hsl(355, 65%, 65%)"},".language-css .token.property":{color:"hsl(220, 14%, 71%)"},".language-css .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.function":{color:"hsl(187, 47%, 55%)"},".language-css .token.url > .token.string.url":{color:"hsl(95, 38%, 62%)"},".language-css .token.important":{color:"hsl(286, 60%, 67%)"},".language-css .token.atrule .token.rule":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.operator":{color:"hsl(286, 60%, 67%)"},".language-javascript .token.template-string > .token.interpolation > .token.interpolation-punctuation.punctuation":{color:"hsl(5, 48%, 51%)"},".language-json .token.operator":{color:"hsl(220, 14%, 71%)"},".language-json .token.null.keyword":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.url":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.operator":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url-reference.url > .token.string":{color:"hsl(220, 14%, 71%)"},".language-markdown .token.url > .token.content":{color:"hsl(207, 82%, 66%)"},".language-markdown .token.url > .token.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.url-reference.url":{color:"hsl(187, 47%, 55%)"},".language-markdown .token.blockquote.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.hr.punctuation":{color:"hsl(220, 10%, 40%)",fontStyle:"italic"},".language-markdown .token.code-snippet":{color:"hsl(95, 38%, 62%)"},".language-markdown .token.bold .token.content":{color:"hsl(29, 54%, 61%)"},".language-markdown .token.italic .token.content":{color:"hsl(286, 60%, 67%)"},".language-markdown .token.strike .token.content":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.strike .token.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.list.punctuation":{color:"hsl(355, 65%, 65%)"},".language-markdown .token.title.important > .token.punctuation":{color:"hsl(355, 65%, 65%)"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},namespace:{Opacity:"0.8"},"token.tab:not(:empty):before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.cr:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.lf:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"token.space:before":{color:"hsla(220, 14%, 71%, 0.15)",textShadow:"none"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item":{marginRight:"0.4em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 9%, 55%)",padding:"0.1em 0.4em",borderRadius:"0.3em"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > button:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > a:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:hover":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},"div.code-toolbar > .toolbar.toolbar > .toolbar-item > span:focus":{background:"hsl(220, 13%, 28%)",color:"hsl(220, 14%, 71%)"},".line-highlight.line-highlight":{background:"hsla(220, 100%, 80%, 0.04)"},".line-highlight.line-highlight:before":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},".line-highlight.line-highlight[data-end]:after":{background:"hsl(220, 13%, 26%)",color:"hsl(220, 14%, 71%)",padding:"0.1em 0.6em",borderRadius:"0.3em",boxShadow:"0 2px 0 0 rgba(0, 0, 0, 0.2)"},"pre[id].linkable-line-numbers.linkable-line-numbers span.line-numbers-rows > span:hover:before":{backgroundColor:"hsla(220, 100%, 80%, 0.04)"},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".command-line .command-line-prompt":{borderRightColor:"hsla(220, 14%, 71%, 0.15)"},".line-numbers .line-numbers-rows > span:before":{color:"hsl(220, 14%, 45%)"},".command-line .command-line-prompt > span:before":{color:"hsl(220, 14%, 45%)"},".rainbow-braces .token.token.punctuation.brace-level-1":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-5":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-9":{color:"hsl(355, 65%, 65%)"},".rainbow-braces .token.token.punctuation.brace-level-2":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-6":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-10":{color:"hsl(95, 38%, 62%)"},".rainbow-braces .token.token.punctuation.brace-level-3":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-7":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-11":{color:"hsl(207, 82%, 66%)"},".rainbow-braces .token.token.punctuation.brace-level-4":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-8":{color:"hsl(286, 60%, 67%)"},".rainbow-braces .token.token.punctuation.brace-level-12":{color:"hsl(286, 60%, 67%)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)":{backgroundColor:"hsla(353, 100%, 66%, 0.15)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix)::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre > code.diff-highlight .token.token.deleted:not(.prefix) *::selection":{backgroundColor:"hsla(353, 95%, 66%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)":{backgroundColor:"hsla(137, 100%, 55%, 0.15)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::-moz-selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre.diff-highlight > code .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix)::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},"pre > code.diff-highlight .token.token.inserted:not(.prefix) *::selection":{backgroundColor:"hsla(135, 73%, 55%, 0.25)"},".prism-previewer.prism-previewer:before":{borderColor:"hsl(224, 13%, 17%)"},".prism-previewer-gradient.prism-previewer-gradient div":{borderColor:"hsl(224, 13%, 17%)",borderRadius:"0.3em"},".prism-previewer-color.prism-previewer-color:before":{borderRadius:"0.3em"},".prism-previewer-easing.prism-previewer-easing:before":{borderRadius:"0.3em"},".prism-previewer.prism-previewer:after":{borderTopColor:"hsl(224, 13%, 17%)"},".prism-previewer-flipped.prism-previewer-flipped.after":{borderBottomColor:"hsl(224, 13%, 17%)"},".prism-previewer-angle.prism-previewer-angle:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-time.prism-previewer-time:before":{background:"hsl(219, 13%, 22%)"},".prism-previewer-easing.prism-previewer-easing":{background:"hsl(219, 13%, 22%)"},".prism-previewer-angle.prism-previewer-angle circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-time.prism-previewer-time circle":{stroke:"hsl(220, 14%, 71%)",strokeOpacity:"1"},".prism-previewer-easing.prism-previewer-easing circle":{stroke:"hsl(220, 14%, 71%)",fill:"transparent"},".prism-previewer-easing.prism-previewer-easing path":{stroke:"hsl(220, 14%, 71%)"},".prism-previewer-easing.prism-previewer-easing line":{stroke:"hsl(220, 14%, 71%)"}};var Er={exports:{}},Mr,js;function Fn(){if(js)return Mr;js=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Mr=t,Mr}var Lr,ws;function Wn(){if(ws)return Lr;ws=1;var t=Fn();function s(){}function a(){}return a.resetWarningCache=s,Lr=function(){function o(i,d,h,p,g,k){if(k!==t){var y=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw y.name="Invariant Violation",y}}o.isRequired=o;function n(){return o}var l={array:o,bigint:o,bool:o,func:o,number:o,object:o,string:o,symbol:o,any:o,arrayOf:n,element:o,elementType:o,instanceOf:n,node:o,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:a,resetWarningCache:s};return l.PropTypes=l,l},Lr}var ks;function Bn(){return ks||(ks=1,Er.exports=Wn()()),Er.exports}var Un=Bn();const $e=Vr(Un);function Mt(t,s,a,o){function n(l){return l instanceof a?l:new a(function(i){i(l)})}return new(a||(a=Promise))(function(l,i){function d(g){try{p(o.next(g))}catch(k){i(k)}}function h(g){try{p(o.throw(g))}catch(k){i(k)}}function p(g){g.done?l(g.value):n(g.value).then(d,h)}p((o=o.apply(t,s||[])).next())})}const Hn=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function Wt(t,s,a){const o=qn(t),{webkitRelativePath:n}=t,l=typeof s=="string"?s:typeof n=="string"&&n.length>0?n:`./${t.name}`;return typeof o.path!="string"&&Ns(o,"path",l),Ns(o,"relativePath",l),o}function qn(t){const{name:s}=t;if(s&&s.lastIndexOf(".")!==-1&&!t.type){const o=s.split(".").pop().toLowerCase(),n=Hn.get(o);n&&Object.defineProperty(t,"type",{value:n,writable:!1,configurable:!1,enumerable:!0})}return t}function Ns(t,s,a){Object.defineProperty(t,s,{value:a,writable:!1,configurable:!1,enumerable:!0})}const Jn=[".DS_Store","Thumbs.db"];function Kn(t){return Mt(this,void 0,void 0,function*(){return ur(t)&&Gn(t.dataTransfer)?Zn(t.dataTransfer,t.type):Vn(t)?Yn(t):Array.isArray(t)&&t.every(s=>"getFile"in s&&typeof s.getFile=="function")?Qn(t):[]})}function Gn(t){return ur(t)}function Vn(t){return ur(t)&&ur(t.target)}function ur(t){return typeof t=="object"&&t!==null}function Yn(t){return Wr(t.target.files).map(s=>Wt(s))}function Qn(t){return Mt(this,void 0,void 0,function*(){return(yield Promise.all(t.map(a=>a.getFile()))).map(a=>Wt(a))})}function Zn(t,s){return Mt(this,void 0,void 0,function*(){if(t.items){const a=Wr(t.items).filter(n=>n.kind==="file");if(s!=="drop")return a;const o=yield Promise.all(a.map(Xn));return Ss(Ys(o))}return Ss(Wr(t.files).map(a=>Wt(a)))})}function Ss(t){return t.filter(s=>Jn.indexOf(s.name)===-1)}function Wr(t){if(t===null)return[];const s=[];for(let a=0;a<t.length;a++){const o=t[a];s.push(o)}return s}function Xn(t){if(typeof t.webkitGetAsEntry!="function")return Cs(t);const s=t.webkitGetAsEntry();return s&&s.isDirectory?Qs(s):Cs(t,s)}function Ys(t){return t.reduce((s,a)=>[...s,...Array.isArray(a)?Ys(a):[a]],[])}function Cs(t,s){return Mt(this,void 0,void 0,function*(){var a;if(globalThis.isSecureContext&&typeof t.getAsFileSystemHandle=="function"){const l=yield t.getAsFileSystemHandle();if(l===null)throw new Error(`${t} is not a File`);if(l!==void 0){const i=yield l.getFile();return i.handle=l,Wt(i)}}const o=t.getAsFile();if(!o)throw new Error(`${t} is not a File`);return Wt(o,(a=s?.fullPath)!==null&&a!==void 0?a:void 0)})}function eo(t){return Mt(this,void 0,void 0,function*(){return t.isDirectory?Qs(t):to(t)})}function Qs(t){const s=t.createReader();return new Promise((a,o)=>{const n=[];function l(){s.readEntries(i=>Mt(this,void 0,void 0,function*(){if(i.length){const d=Promise.all(i.map(eo));n.push(d),l()}else try{const d=yield Promise.all(n);a(d)}catch(d){o(d)}}),i=>{o(i)})}l()})}function to(t){return Mt(this,void 0,void 0,function*(){return new Promise((s,a)=>{t.file(o=>{const n=Wt(o,t.fullPath);s(n)},o=>{a(o)})})})}var or={},Es;function ro(){return Es||(Es=1,or.__esModule=!0,or.default=function(t,s){if(t&&s){var a=Array.isArray(s)?s:s.split(",");if(a.length===0)return!0;var o=t.name||"",n=(t.type||"").toLowerCase(),l=n.replace(/\/.*$/,"");return a.some(function(i){var d=i.trim().toLowerCase();return d.charAt(0)==="."?o.toLowerCase().endsWith(d):d.endsWith("/*")?l===d.replace(/\/.*$/,""):n===d})}return!0}),or}var so=ro();const Ir=Vr(so);function Ms(t){return oo(t)||no(t)||Xs(t)||ao()}function ao(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function no(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function oo(t){if(Array.isArray(t))return Br(t)}function Ls(t,s){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);s&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,o)}return a}function Is(t){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?Ls(Object(a),!0).forEach(function(o){Zs(t,o,a[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):Ls(Object(a)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(a,o))})}return t}function Zs(t,s,a){return s in t?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a,t}function er(t,s){return co(t)||lo(t,s)||Xs(t,s)||io()}function io(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Xs(t,s){if(t){if(typeof t=="string")return Br(t,s);var a=Object.prototype.toString.call(t).slice(8,-1);if(a==="Object"&&t.constructor&&(a=t.constructor.name),a==="Map"||a==="Set")return Array.from(t);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return Br(t,s)}}function Br(t,s){(s==null||s>t.length)&&(s=t.length);for(var a=0,o=new Array(s);a<s;a++)o[a]=t[a];return o}function lo(t,s){var a=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(a!=null){var o=[],n=!0,l=!1,i,d;try{for(a=a.call(t);!(n=(i=a.next()).done)&&(o.push(i.value),!(s&&o.length===s));n=!0);}catch(h){l=!0,d=h}finally{try{!n&&a.return!=null&&a.return()}finally{if(l)throw d}}return o}}function co(t){if(Array.isArray(t))return t}var mo=typeof Ir=="function"?Ir:Ir.default,uo="file-invalid-type",po="file-too-large",xo="file-too-small",ho="too-many-files",go=function(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",a=s.split(","),o=a.length>1?"one of ".concat(a.join(", ")):a[0];return{code:uo,message:"File type must be ".concat(o)}},Ds=function(s){return{code:po,message:"File is larger than ".concat(s," ").concat(s===1?"byte":"bytes")}},Ts=function(s){return{code:xo,message:"File is smaller than ".concat(s," ").concat(s===1?"byte":"bytes")}},fo={code:ho,message:"Too many files"};function ea(t,s){var a=t.type==="application/x-moz-file"||mo(t,s);return[a,a?null:go(s)]}function ta(t,s,a){if(Ct(t.size))if(Ct(s)&&Ct(a)){if(t.size>a)return[!1,Ds(a)];if(t.size<s)return[!1,Ts(s)]}else{if(Ct(s)&&t.size<s)return[!1,Ts(s)];if(Ct(a)&&t.size>a)return[!1,Ds(a)]}return[!0,null]}function Ct(t){return t!=null}function bo(t){var s=t.files,a=t.accept,o=t.minSize,n=t.maxSize,l=t.multiple,i=t.maxFiles,d=t.validator;return!l&&s.length>1||l&&i>=1&&s.length>i?!1:s.every(function(h){var p=ea(h,a),g=er(p,1),k=g[0],y=ta(h,o,n),v=er(y,1),x=v[0],R=d?d(h):null;return k&&x&&!R})}function pr(t){return typeof t.isPropagationStopped=="function"?t.isPropagationStopped():typeof t.cancelBubble<"u"?t.cancelBubble:!1}function ir(t){return t.dataTransfer?Array.prototype.some.call(t.dataTransfer.types,function(s){return s==="Files"||s==="application/x-moz-file"}):!!t.target&&!!t.target.files}function Ps(t){t.preventDefault()}function yo(t){return t.indexOf("MSIE")!==-1||t.indexOf("Trident/")!==-1}function vo(t){return t.indexOf("Edge/")!==-1}function jo(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return yo(t)||vo(t)}function ct(){for(var t=arguments.length,s=new Array(t),a=0;a<t;a++)s[a]=arguments[a];return function(o){for(var n=arguments.length,l=new Array(n>1?n-1:0),i=1;i<n;i++)l[i-1]=arguments[i];return s.some(function(d){return!pr(o)&&d&&d.apply(void 0,[o].concat(l)),pr(o)})}}function wo(){return"showOpenFilePicker"in window}function ko(t){if(Ct(t)){var s=Object.entries(t).filter(function(a){var o=er(a,2),n=o[0],l=o[1],i=!0;return ra(n)||(console.warn('Skipped "'.concat(n,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),i=!1),(!Array.isArray(l)||!l.every(sa))&&(console.warn('Skipped "'.concat(n,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(a,o){var n=er(o,2),l=n[0],i=n[1];return Is(Is({},a),{},Zs({},l,i))},{});return[{description:"Files",accept:s}]}return t}function No(t){if(Ct(t))return Object.entries(t).reduce(function(s,a){var o=er(a,2),n=o[0],l=o[1];return[].concat(Ms(s),[n],Ms(l))},[]).filter(function(s){return ra(s)||sa(s)}).join(",")}function So(t){return t instanceof DOMException&&(t.name==="AbortError"||t.code===t.ABORT_ERR)}function Co(t){return t instanceof DOMException&&(t.name==="SecurityError"||t.code===t.SECURITY_ERR)}function ra(t){return t==="audio/*"||t==="video/*"||t==="image/*"||t==="text/*"||t==="application/*"||/\w+\/[-+.\w]+/g.test(t)}function sa(t){return/^.*\.[\w]+$/.test(t)}var Eo=["children"],Mo=["open"],Lo=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],Io=["refKey","onChange","onClick"];function Do(t){return Ro(t)||Po(t)||aa(t)||To()}function To(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
4
4
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Po(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Ro(t){if(Array.isArray(t))return Ur(t)}function Dr(t,s){return _o(t)||$o(t,s)||aa(t,s)||zo()}function zo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
5
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function aa(t,s){if(t){if(typeof t=="string")return Ur(t,s);var a=Object.prototype.toString.call(t).slice(8,-1);if(a==="Object"&&t.constructor&&(a=t.constructor.name),a==="Map"||a==="Set")return Array.from(t);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return Ur(t,s)}}function Ur(t,s){(s==null||s>t.length)&&(s=t.length);for(var a=0,o=new Array(s);a<s;a++)o[a]=t[a];return o}function $o(t,s){var a=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(a!=null){var o=[],n=!0,l=!1,i,d;try{for(a=a.call(t);!(n=(i=a.next()).done)&&(o.push(i.value),!(s&&o.length===s));n=!0);}catch(h){l=!0,d=h}finally{try{!n&&a.return!=null&&a.return()}finally{if(l)throw d}}return o}}function _o(t){if(Array.isArray(t))return t}function Rs(t,s){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);s&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,o)}return a}function Fe(t){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?Rs(Object(a),!0).forEach(function(o){Hr(t,o,a[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):Rs(Object(a)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(a,o))})}return t}function Hr(t,s,a){return s in t?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a,t}function xr(t,s){if(t==null)return{};var a=Ao(t,s),o,n;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(t);for(n=0;n<l.length;n++)o=l[n],!(s.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(t,o)&&(a[o]=t[o])}return a}function Ao(t,s){if(t==null)return{};var a={},o=Object.keys(t),n,l;for(l=0;l<o.length;l++)n=o[l],!(s.indexOf(n)>=0)&&(a[n]=t[n]);return a}var Qr=r.forwardRef(function(t,s){var a=t.children,o=xr(t,Eo),n=Zr(o),l=n.open,i=xr(n,Mo);return r.useImperativeHandle(s,function(){return{open:l}},[l]),tt.createElement(r.Fragment,null,a(Fe(Fe({},i),{},{open:l})))});Qr.displayName="Dropzone";var na={disabled:!1,getFilesFromEvent:Kn,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};Qr.defaultProps=na;Qr.propTypes={children:$e.func,accept:$e.objectOf($e.arrayOf($e.string)),multiple:$e.bool,preventDropOnDocument:$e.bool,noClick:$e.bool,noKeyboard:$e.bool,noDrag:$e.bool,noDragEventsBubbling:$e.bool,minSize:$e.number,maxSize:$e.number,maxFiles:$e.number,disabled:$e.bool,getFilesFromEvent:$e.func,onFileDialogCancel:$e.func,onFileDialogOpen:$e.func,useFsAccessApi:$e.bool,autoFocus:$e.bool,onDragEnter:$e.func,onDragLeave:$e.func,onDragOver:$e.func,onDrop:$e.func,onDropAccepted:$e.func,onDropRejected:$e.func,onError:$e.func,validator:$e.func};var qr={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function Zr(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=Fe(Fe({},na),t),a=s.accept,o=s.disabled,n=s.getFilesFromEvent,l=s.maxSize,i=s.minSize,d=s.multiple,h=s.maxFiles,p=s.onDragEnter,g=s.onDragLeave,k=s.onDragOver,y=s.onDrop,v=s.onDropAccepted,x=s.onDropRejected,R=s.onFileDialogCancel,z=s.onFileDialogOpen,T=s.useFsAccessApi,C=s.autoFocus,u=s.preventDropOnDocument,m=s.noClick,j=s.noKeyboard,w=s.noDrag,L=s.noDragEventsBubbling,F=s.onError,O=s.validator,se=r.useMemo(function(){return No(a)},[a]),ce=r.useMemo(function(){return ko(a)},[a]),ae=r.useMemo(function(){return typeof z=="function"?z:zs},[z]),oe=r.useMemo(function(){return typeof R=="function"?R:zs},[R]),W=r.useRef(null),I=r.useRef(null),_=r.useReducer(Oo,qr),X=Dr(_,2),je=X[0],ie=X[1],Z=je.isFocused,we=je.isFileDialogActive,Me=r.useRef(typeof window<"u"&&window.isSecureContext&&T&&wo()),De=function(){!Me.current&&we&&setTimeout(function(){if(I.current){var ee=I.current.files;ee.length||(ie({type:"closeDialog"}),oe())}},300)};r.useEffect(function(){return window.addEventListener("focus",De,!1),function(){window.removeEventListener("focus",De,!1)}},[I,we,oe,Me]);var Ce=r.useRef([]),Oe=function(ee){W.current&&W.current.contains(ee.target)||(ee.preventDefault(),Ce.current=[])};r.useEffect(function(){return u&&(document.addEventListener("dragover",Ps,!1),document.addEventListener("drop",Oe,!1)),function(){u&&(document.removeEventListener("dragover",Ps),document.removeEventListener("drop",Oe))}},[W,u]),r.useEffect(function(){return!o&&C&&W.current&&W.current.focus(),function(){}},[W,C,o]);var xe=r.useCallback(function(G){F?F(G):console.error(G)},[F]),Se=r.useCallback(function(G){G.preventDefault(),G.persist(),de(G),Ce.current=[].concat(Do(Ce.current),[G.target]),ir(G)&&Promise.resolve(n(G)).then(function(ee){if(!(pr(G)&&!L)){var b=ee.length,Q=b>0&&bo({files:ee,accept:se,minSize:i,maxSize:l,multiple:d,maxFiles:h,validator:O}),B=b>0&&!Q;ie({isDragAccept:Q,isDragReject:B,isDragActive:!0,type:"setDraggedFiles"}),p&&p(G)}}).catch(function(ee){return xe(ee)})},[n,p,xe,L,se,i,l,d,h,O]),Re=r.useCallback(function(G){G.preventDefault(),G.persist(),de(G);var ee=ir(G);if(ee&&G.dataTransfer)try{G.dataTransfer.dropEffect="copy"}catch{}return ee&&k&&k(G),!1},[k,L]),ze=r.useCallback(function(G){G.preventDefault(),G.persist(),de(G);var ee=Ce.current.filter(function(Q){return W.current&&W.current.contains(Q)}),b=ee.indexOf(G.target);b!==-1&&ee.splice(b,1),Ce.current=ee,!(ee.length>0)&&(ie({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),ir(G)&&g&&g(G))},[W,g,L]),he=r.useCallback(function(G,ee){var b=[],Q=[];G.forEach(function(B){var ue=ea(B,se),J=Dr(ue,2),ye=J[0],V=J[1],pe=ta(B,i,l),le=Dr(pe,2),fe=le[0],ke=le[1],ge=O?O(B):null;if(ye&&fe&&!ge)b.push(B);else{var be=[V,ke];ge&&(be=be.concat(ge)),Q.push({file:B,errors:be.filter(function(He){return He})})}}),(!d&&b.length>1||d&&h>=1&&b.length>h)&&(b.forEach(function(B){Q.push({file:B,errors:[fo]})}),b.splice(0)),ie({acceptedFiles:b,fileRejections:Q,isDragReject:Q.length>0,type:"setFiles"}),y&&y(b,Q,ee),Q.length>0&&x&&x(Q,ee),b.length>0&&v&&v(b,ee)},[ie,d,se,i,l,h,y,v,x,O]),Le=r.useCallback(function(G){G.preventDefault(),G.persist(),de(G),Ce.current=[],ir(G)&&Promise.resolve(n(G)).then(function(ee){pr(G)&&!L||he(ee,G)}).catch(function(ee){return xe(ee)}),ie({type:"reset"})},[n,he,xe,L]),Te=r.useCallback(function(){if(Me.current){ie({type:"openDialog"}),ae();var G={multiple:d,types:ce};window.showOpenFilePicker(G).then(function(ee){return n(ee)}).then(function(ee){he(ee,null),ie({type:"closeDialog"})}).catch(function(ee){So(ee)?(oe(ee),ie({type:"closeDialog"})):Co(ee)?(Me.current=!1,I.current?(I.current.value=null,I.current.click()):xe(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):xe(ee)});return}I.current&&(ie({type:"openDialog"}),ae(),I.current.value=null,I.current.click())},[ie,ae,oe,T,he,xe,ce,d]),_e=r.useCallback(function(G){!W.current||!W.current.isEqualNode(G.target)||(G.key===" "||G.key==="Enter"||G.keyCode===32||G.keyCode===13)&&(G.preventDefault(),Te())},[W,Te]),We=r.useCallback(function(){ie({type:"focus"})},[]),D=r.useCallback(function(){ie({type:"blur"})},[]),$=r.useCallback(function(){m||(jo()?setTimeout(Te,0):Te())},[m,Te]),A=function(ee){return o?null:ee},f=function(ee){return j?null:A(ee)},H=function(ee){return w?null:A(ee)},de=function(ee){L&&ee.stopPropagation()},Ee=r.useMemo(function(){return function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ee=G.refKey,b=ee===void 0?"ref":ee,Q=G.role,B=G.onKeyDown,ue=G.onFocus,J=G.onBlur,ye=G.onClick,V=G.onDragEnter,pe=G.onDragOver,le=G.onDragLeave,fe=G.onDrop,ke=xr(G,Lo);return Fe(Fe(Hr({onKeyDown:f(ct(B,_e)),onFocus:f(ct(ue,We)),onBlur:f(ct(J,D)),onClick:A(ct(ye,$)),onDragEnter:H(ct(V,Se)),onDragOver:H(ct(pe,Re)),onDragLeave:H(ct(le,ze)),onDrop:H(ct(fe,Le)),role:typeof Q=="string"&&Q!==""?Q:"presentation"},b,W),!o&&!j?{tabIndex:0}:{}),ke)}},[W,_e,We,D,$,Se,Re,ze,Le,j,w,o]),Ae=r.useCallback(function(G){G.stopPropagation()},[]),rt=r.useMemo(function(){return function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ee=G.refKey,b=ee===void 0?"ref":ee,Q=G.onChange,B=G.onClick,ue=xr(G,Io),J=Hr({accept:se,multiple:d,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:A(ct(Q,Le)),onClick:A(ct(B,Ae)),tabIndex:-1},b,I);return Fe(Fe({},J),ue)}},[I,a,d,Le,o]);return Fe(Fe({},je),{},{isFocused:Z&&!o,getRootProps:Ee,getInputProps:rt,rootRef:W,inputRef:I,open:A(Te)})}function Oo(t,s){switch(s.type){case"focus":return Fe(Fe({},t),{},{isFocused:!0});case"blur":return Fe(Fe({},t),{},{isFocused:!1});case"openDialog":return Fe(Fe({},qr),{},{isFileDialogActive:!0});case"closeDialog":return Fe(Fe({},t),{},{isFileDialogActive:!1});case"setDraggedFiles":return Fe(Fe({},t),{},{isDragActive:s.isDragActive,isDragAccept:s.isDragAccept,isDragReject:s.isDragReject});case"setFiles":return Fe(Fe({},t),{},{acceptedFiles:s.acceptedFiles,fileRejections:s.fileRejections,isDragReject:s.isDragReject});case"reset":return Fe({},qr);default:return t}}function zs(){}const Tr=({todos:t,isResult:s=!1})=>{if(!t||!Array.isArray(t))return null;const a=l=>{switch(l){case"completed":return e.jsx(Xa,{className:"w-4 h-4 text-green-500 dark:text-green-400"});case"in_progress":return e.jsx(zr,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"});case"pending":default:return e.jsx(Za,{className:"w-4 h-4 text-gray-400 dark:text-gray-500"})}},o=l=>{switch(l){case"completed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 border-green-200 dark:border-green-800";case"in_progress":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-200 border-blue-200 dark:border-blue-800";case"pending":default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}},n=l=>{switch(l){case"high":return"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300 border-red-200 dark:border-red-800";case"medium":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800";case"low":default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}};return e.jsxs("div",{className:"space-y-3",children:[s&&e.jsxs("div",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:["待办事项列表 (",t.length," 项)"]}),t.map((l,i)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-sm hover:shadow-md dark:shadow-gray-900/50 transition-shadow",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:a(l.status)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsx("p",{className:`text-sm font-medium ${l.status==="completed"?"line-through text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100"}`,children:l.content}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(Ye,{variant:"outline",className:`text-xs px-2 py-0.5 ${n(l.priority)}`,children:l.priority}),e.jsx(Ye,{variant:"outline",className:`text-xs px-2 py-0.5 ${o(l.status)}`,children:l.status.replace("_"," ")})]})]})})]},l.id||`todo-${i}`))]})};function Fo({status:t,onAbort:s,isLoading:a,provider:o="claude"}){const[n,l]=r.useState(0),[i,d]=r.useState(0),[h,p]=r.useState(0);if(r.useEffect(()=>{if(!a){l(0),p(0);return}const T=Date.now(),C=30+Math.random()*20,u=setInterval(()=>{const m=Math.floor((Date.now()-T)/1e3);l(m),p(Math.floor(m*C))},1e3);return()=>clearInterval(u)},[a]),r.useEffect(()=>{if(!a)return;const T=setInterval(()=>{d(C=>(C+1)%4)},500);return()=>clearInterval(T)},[a]),!a)return null;const g=["思考中","处理中","分析中","工作中","计算中","推理中"],k=Math.floor(n/3)%g.length,y=t?.text||g[k],v=t?.tokens||h,x=t?.can_interrupt!==!1,z=["✻","✹","✸","✶"][i];return e.jsx("div",{className:"w-full mb-3 sm:mb-6 animate-in slide-in-from-bottom duration-300",children:e.jsxs("div",{className:"flex items-center justify-between max-w-4xl mx-auto bg-gray-800 dark:bg-gray-900 text-white rounded-lg shadow-lg px-2.5 py-2 sm:px-4 sm:py-3 border border-gray-700 dark:border-gray-800",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx("span",{className:Be("text-base sm:text-xl transition-all duration-500 flex-shrink-0",i%2===0?"text-blue-400 scale-110":"text-blue-300"),children:z}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsxs("span",{className:"font-medium text-xs sm:text-sm truncate",children:[y,"..."]}),e.jsxs("span",{className:"text-gray-400 text-xs sm:text-sm flex-shrink-0",children:["(",n,"s)"]}),v>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-500 hidden sm:inline",children:"·"}),e.jsxs("span",{className:"text-gray-300 text-xs sm:text-sm hidden sm:inline flex-shrink-0",children:["⚒ ",v.toLocaleString()]})]}),e.jsx("span",{className:"text-gray-500 hidden sm:inline",children:"·"}),e.jsx("span",{className:"text-gray-400 text-xs sm:text-sm hidden sm:inline",children:"按 esc 停止"})]})})]})}),x&&s&&e.jsxs("button",{onClick:s,className:"ml-2 sm:ml-3 text-xs bg-red-600 hover:bg-red-700 active:bg-red-800 text-white px-2 py-1 sm:px-3 sm:py-1.5 rounded-md transition-colors flex items-center gap-1 sm:gap-1.5 flex-shrink-0 font-medium",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{className:"hidden sm:inline",children:"停止"})]})]})})}async function Wo(t,s){const a=new FormData,o=`recording_${Date.now()}.webm`,n=new File([t],o,{type:t.type});a.append("audio",n);const l=window.localStorage.getItem("whisperMode")||"default";a.append("mode",l);try{const i=await ve.transcribe(a);if(!i.ok){const h=await i.json().catch(()=>({}));throw new Error(h.error||`Transcription error: ${i.status} ${i.statusText}`)}return(await i.json()).text||""}catch(i){throw i.name==="TypeError"&&i.message.includes("fetch")?new Error("Cannot connect to server. Please ensure the backend is running."):i}}function Bo({onTranscript:t,className:s=""}){const[a,o]=r.useState("idle"),[n,l]=r.useState(null),[i,d]=r.useState(!0),h=r.useRef(null),p=r.useRef(null),g=r.useRef([]),k=r.useRef(0);r.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){d(!1),l("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){d(!1),l("Microphone requires HTTPS. Please use a secure connection.");return}d(!0),l(null)})()},[]);const y=async()=>{try{if(console.log("Starting recording..."),l(null),g.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const u=await navigator.mediaDevices.getUserMedia({audio:!0});p.current=u;const m=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",j=new MediaRecorder(u,{mimeType:m});h.current=j,j.ondataavailable=w=>{w.data.size>0&&g.current.push(w.data)},j.onstop=async()=>{console.log("Recording stopped, creating blob...");const w=new Blob(g.current,{type:m});p.current&&(p.current.getTracks().forEach(se=>se.stop()),p.current=null),o("transcribing");const L=window.localStorage.getItem("whisperMode")||"default",F=L==="prompt"||L==="vibe"||L==="instructions"||L==="architect";let O;F&&(O=setTimeout(()=>{o("processing")},2e3));try{const se=await Wo(w);se&&t&&t(se)}catch(se){console.error("Transcription error:",se),l(se.message)}finally{O&&clearTimeout(O),o("idle")}},j.start(),o("recording"),console.log("Recording started successfully")}catch(u){console.error("Failed to start recording:",u);let m="Microphone access failed";u.name==="NotAllowedError"?m="Microphone access denied. Please allow microphone permissions.":u.name==="NotFoundError"?m="No microphone found. Please check your audio devices.":u.name==="NotSupportedError"?m="Microphone not supported by this browser.":u.name==="NotReadableError"?m="Microphone is being used by another application.":u.message.includes("HTTPS")&&(m=u.message),l(m),o("idle")}},v=()=>{console.log("Stopping recording..."),h.current&&h.current.state==="recording"?h.current.stop():(console.log("Recorder not in recording state, forcing cleanup"),p.current&&(p.current.getTracks().forEach(u=>u.stop()),p.current=null),o("idle"))},x=u=>{if(u&&(u.preventDefault(),u.stopPropagation()),!i)return;const m=Date.now();if(m-k.current<300){console.log("Ignoring rapid tap");return}k.current=m,console.log("Button clicked, current state:",a),a==="idle"?y():a==="recording"&&v()};r.useEffect(()=>()=>{p.current&&p.current.getTracks().forEach(u=>u.stop())},[]);const R=()=>{if(!i)return{icon:e.jsx(dr,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(a){case"recording":return{icon:e.jsx(dr,{className:"w-5 h-5 text-white"}),className:"bg-red-500 hover:bg-red-600 animate-pulse",disabled:!1};case"transcribing":return{icon:e.jsx(wt,{className:"w-5 h-5 animate-spin"}),className:"bg-blue-500 hover:bg-blue-600",disabled:!0};case"processing":return{icon:e.jsx(Ws,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:e.jsx(dr,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:z,className:T,disabled:C}=R();return e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",style:{backgroundColor:a==="recording"?"#ef4444":a==="transcribing"?"#3b82f6":a==="processing"?"#a855f7":"#374151"},className:`
5
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function aa(t,s){if(t){if(typeof t=="string")return Ur(t,s);var a=Object.prototype.toString.call(t).slice(8,-1);if(a==="Object"&&t.constructor&&(a=t.constructor.name),a==="Map"||a==="Set")return Array.from(t);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return Ur(t,s)}}function Ur(t,s){(s==null||s>t.length)&&(s=t.length);for(var a=0,o=new Array(s);a<s;a++)o[a]=t[a];return o}function $o(t,s){var a=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(a!=null){var o=[],n=!0,l=!1,i,d;try{for(a=a.call(t);!(n=(i=a.next()).done)&&(o.push(i.value),!(s&&o.length===s));n=!0);}catch(h){l=!0,d=h}finally{try{!n&&a.return!=null&&a.return()}finally{if(l)throw d}}return o}}function _o(t){if(Array.isArray(t))return t}function Rs(t,s){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);s&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,o)}return a}function Fe(t){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?Rs(Object(a),!0).forEach(function(o){Hr(t,o,a[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):Rs(Object(a)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(a,o))})}return t}function Hr(t,s,a){return s in t?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a,t}function xr(t,s){if(t==null)return{};var a=Ao(t,s),o,n;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(t);for(n=0;n<l.length;n++)o=l[n],!(s.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(t,o)&&(a[o]=t[o])}return a}function Ao(t,s){if(t==null)return{};var a={},o=Object.keys(t),n,l;for(l=0;l<o.length;l++)n=o[l],!(s.indexOf(n)>=0)&&(a[n]=t[n]);return a}var Qr=r.forwardRef(function(t,s){var a=t.children,o=xr(t,Eo),n=Zr(o),l=n.open,i=xr(n,Mo);return r.useImperativeHandle(s,function(){return{open:l}},[l]),tt.createElement(r.Fragment,null,a(Fe(Fe({},i),{},{open:l})))});Qr.displayName="Dropzone";var na={disabled:!1,getFilesFromEvent:Kn,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};Qr.defaultProps=na;Qr.propTypes={children:$e.func,accept:$e.objectOf($e.arrayOf($e.string)),multiple:$e.bool,preventDropOnDocument:$e.bool,noClick:$e.bool,noKeyboard:$e.bool,noDrag:$e.bool,noDragEventsBubbling:$e.bool,minSize:$e.number,maxSize:$e.number,maxFiles:$e.number,disabled:$e.bool,getFilesFromEvent:$e.func,onFileDialogCancel:$e.func,onFileDialogOpen:$e.func,useFsAccessApi:$e.bool,autoFocus:$e.bool,onDragEnter:$e.func,onDragLeave:$e.func,onDragOver:$e.func,onDrop:$e.func,onDropAccepted:$e.func,onDropRejected:$e.func,onError:$e.func,validator:$e.func};var qr={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function Zr(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=Fe(Fe({},na),t),a=s.accept,o=s.disabled,n=s.getFilesFromEvent,l=s.maxSize,i=s.minSize,d=s.multiple,h=s.maxFiles,p=s.onDragEnter,g=s.onDragLeave,k=s.onDragOver,y=s.onDrop,v=s.onDropAccepted,x=s.onDropRejected,R=s.onFileDialogCancel,z=s.onFileDialogOpen,T=s.useFsAccessApi,C=s.autoFocus,u=s.preventDropOnDocument,m=s.noClick,j=s.noKeyboard,w=s.noDrag,L=s.noDragEventsBubbling,F=s.onError,O=s.validator,se=r.useMemo(function(){return No(a)},[a]),ce=r.useMemo(function(){return ko(a)},[a]),ae=r.useMemo(function(){return typeof z=="function"?z:zs},[z]),oe=r.useMemo(function(){return typeof R=="function"?R:zs},[R]),W=r.useRef(null),I=r.useRef(null),_=r.useReducer(Oo,qr),X=Dr(_,2),je=X[0],ie=X[1],Z=je.isFocused,we=je.isFileDialogActive,Me=r.useRef(typeof window<"u"&&window.isSecureContext&&T&&wo()),De=function(){!Me.current&&we&&setTimeout(function(){if(I.current){var ee=I.current.files;ee.length||(ie({type:"closeDialog"}),oe())}},300)};r.useEffect(function(){return window.addEventListener("focus",De,!1),function(){window.removeEventListener("focus",De,!1)}},[I,we,oe,Me]);var Ce=r.useRef([]),Oe=function(ee){W.current&&W.current.contains(ee.target)||(ee.preventDefault(),Ce.current=[])};r.useEffect(function(){return u&&(document.addEventListener("dragover",Ps,!1),document.addEventListener("drop",Oe,!1)),function(){u&&(document.removeEventListener("dragover",Ps),document.removeEventListener("drop",Oe))}},[W,u]),r.useEffect(function(){return!o&&C&&W.current&&W.current.focus(),function(){}},[W,C,o]);var xe=r.useCallback(function(G){F?F(G):console.error(G)},[F]),Se=r.useCallback(function(G){G.preventDefault(),G.persist(),de(G),Ce.current=[].concat(Do(Ce.current),[G.target]),ir(G)&&Promise.resolve(n(G)).then(function(ee){if(!(pr(G)&&!L)){var b=ee.length,Q=b>0&&bo({files:ee,accept:se,minSize:i,maxSize:l,multiple:d,maxFiles:h,validator:O}),B=b>0&&!Q;ie({isDragAccept:Q,isDragReject:B,isDragActive:!0,type:"setDraggedFiles"}),p&&p(G)}}).catch(function(ee){return xe(ee)})},[n,p,xe,L,se,i,l,d,h,O]),Re=r.useCallback(function(G){G.preventDefault(),G.persist(),de(G);var ee=ir(G);if(ee&&G.dataTransfer)try{G.dataTransfer.dropEffect="copy"}catch{}return ee&&k&&k(G),!1},[k,L]),ze=r.useCallback(function(G){G.preventDefault(),G.persist(),de(G);var ee=Ce.current.filter(function(Q){return W.current&&W.current.contains(Q)}),b=ee.indexOf(G.target);b!==-1&&ee.splice(b,1),Ce.current=ee,!(ee.length>0)&&(ie({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),ir(G)&&g&&g(G))},[W,g,L]),he=r.useCallback(function(G,ee){var b=[],Q=[];G.forEach(function(B){var ue=ea(B,se),J=Dr(ue,2),ye=J[0],V=J[1],pe=ta(B,i,l),le=Dr(pe,2),fe=le[0],ke=le[1],ge=O?O(B):null;if(ye&&fe&&!ge)b.push(B);else{var be=[V,ke];ge&&(be=be.concat(ge)),Q.push({file:B,errors:be.filter(function(He){return He})})}}),(!d&&b.length>1||d&&h>=1&&b.length>h)&&(b.forEach(function(B){Q.push({file:B,errors:[fo]})}),b.splice(0)),ie({acceptedFiles:b,fileRejections:Q,isDragReject:Q.length>0,type:"setFiles"}),y&&y(b,Q,ee),Q.length>0&&x&&x(Q,ee),b.length>0&&v&&v(b,ee)},[ie,d,se,i,l,h,y,v,x,O]),Le=r.useCallback(function(G){G.preventDefault(),G.persist(),de(G),Ce.current=[],ir(G)&&Promise.resolve(n(G)).then(function(ee){pr(G)&&!L||he(ee,G)}).catch(function(ee){return xe(ee)}),ie({type:"reset"})},[n,he,xe,L]),Te=r.useCallback(function(){if(Me.current){ie({type:"openDialog"}),ae();var G={multiple:d,types:ce};window.showOpenFilePicker(G).then(function(ee){return n(ee)}).then(function(ee){he(ee,null),ie({type:"closeDialog"})}).catch(function(ee){So(ee)?(oe(ee),ie({type:"closeDialog"})):Co(ee)?(Me.current=!1,I.current?(I.current.value=null,I.current.click()):xe(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):xe(ee)});return}I.current&&(ie({type:"openDialog"}),ae(),I.current.value=null,I.current.click())},[ie,ae,oe,T,he,xe,ce,d]),_e=r.useCallback(function(G){!W.current||!W.current.isEqualNode(G.target)||(G.key===" "||G.key==="Enter"||G.keyCode===32||G.keyCode===13)&&(G.preventDefault(),Te())},[W,Te]),We=r.useCallback(function(){ie({type:"focus"})},[]),D=r.useCallback(function(){ie({type:"blur"})},[]),$=r.useCallback(function(){m||(jo()?setTimeout(Te,0):Te())},[m,Te]),A=function(ee){return o?null:ee},f=function(ee){return j?null:A(ee)},H=function(ee){return w?null:A(ee)},de=function(ee){L&&ee.stopPropagation()},Ee=r.useMemo(function(){return function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ee=G.refKey,b=ee===void 0?"ref":ee,Q=G.role,B=G.onKeyDown,ue=G.onFocus,J=G.onBlur,ye=G.onClick,V=G.onDragEnter,pe=G.onDragOver,le=G.onDragLeave,fe=G.onDrop,ke=xr(G,Lo);return Fe(Fe(Hr({onKeyDown:f(ct(B,_e)),onFocus:f(ct(ue,We)),onBlur:f(ct(J,D)),onClick:A(ct(ye,$)),onDragEnter:H(ct(V,Se)),onDragOver:H(ct(pe,Re)),onDragLeave:H(ct(le,ze)),onDrop:H(ct(fe,Le)),role:typeof Q=="string"&&Q!==""?Q:"presentation"},b,W),!o&&!j?{tabIndex:0}:{}),ke)}},[W,_e,We,D,$,Se,Re,ze,Le,j,w,o]),Ae=r.useCallback(function(G){G.stopPropagation()},[]),rt=r.useMemo(function(){return function(){var G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ee=G.refKey,b=ee===void 0?"ref":ee,Q=G.onChange,B=G.onClick,ue=xr(G,Io),J=Hr({accept:se,multiple:d,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:A(ct(Q,Le)),onClick:A(ct(B,Ae)),tabIndex:-1},b,I);return Fe(Fe({},J),ue)}},[I,a,d,Le,o]);return Fe(Fe({},je),{},{isFocused:Z&&!o,getRootProps:Ee,getInputProps:rt,rootRef:W,inputRef:I,open:A(Te)})}function Oo(t,s){switch(s.type){case"focus":return Fe(Fe({},t),{},{isFocused:!0});case"blur":return Fe(Fe({},t),{},{isFocused:!1});case"openDialog":return Fe(Fe({},qr),{},{isFileDialogActive:!0});case"closeDialog":return Fe(Fe({},t),{},{isFileDialogActive:!1});case"setDraggedFiles":return Fe(Fe({},t),{},{isDragActive:s.isDragActive,isDragAccept:s.isDragAccept,isDragReject:s.isDragReject});case"setFiles":return Fe(Fe({},t),{},{acceptedFiles:s.acceptedFiles,fileRejections:s.fileRejections,isDragReject:s.isDragReject});case"reset":return Fe({},qr);default:return t}}function zs(){}const Tr=({todos:t,isResult:s=!1})=>{if(!t||!Array.isArray(t))return null;const a=l=>{switch(l){case"completed":return e.jsx(Xa,{className:"w-4 h-4 text-green-500 dark:text-green-400"});case"in_progress":return e.jsx(zr,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"});case"pending":default:return e.jsx(Za,{className:"w-4 h-4 text-gray-400 dark:text-gray-500"})}},o=l=>{switch(l){case"completed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 border-green-200 dark:border-green-800";case"in_progress":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-200 border-blue-200 dark:border-blue-800";case"pending":default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}},n=l=>{switch(l){case"high":return"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300 border-red-200 dark:border-red-800";case"medium":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800";case"low":default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}};return e.jsxs("div",{className:"space-y-3",children:[s&&e.jsxs("div",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:["待办事项列表 (",t.length," 项)"]}),t.map((l,i)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-sm hover:shadow-md dark:shadow-gray-900/50 transition-shadow",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:a(l.status)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsx("p",{className:`text-sm font-medium ${l.status==="completed"?"line-through text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100"}`,children:l.content}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(Ve,{variant:"outline",className:`text-xs px-2 py-0.5 ${n(l.priority)}`,children:l.priority}),e.jsx(Ve,{variant:"outline",className:`text-xs px-2 py-0.5 ${o(l.status)}`,children:l.status.replace("_"," ")})]})]})})]},l.id||`todo-${i}`))]})};function Fo({status:t,onAbort:s,isLoading:a,provider:o="claude"}){const[n,l]=r.useState(0),[i,d]=r.useState(0),[h,p]=r.useState(0);if(r.useEffect(()=>{if(!a){l(0),p(0);return}const T=Date.now(),C=30+Math.random()*20,u=setInterval(()=>{const m=Math.floor((Date.now()-T)/1e3);l(m),p(Math.floor(m*C))},1e3);return()=>clearInterval(u)},[a]),r.useEffect(()=>{if(!a)return;const T=setInterval(()=>{d(C=>(C+1)%4)},500);return()=>clearInterval(T)},[a]),!a)return null;const g=["思考中","处理中","分析中","工作中","计算中","推理中"],k=Math.floor(n/3)%g.length,y=t?.text||g[k],v=t?.tokens||h,x=t?.can_interrupt!==!1,z=["✻","✹","✸","✶"][i];return e.jsx("div",{className:"w-full mb-3 sm:mb-6 animate-in slide-in-from-bottom duration-300",children:e.jsxs("div",{className:"flex items-center justify-between max-w-4xl mx-auto bg-gray-800 dark:bg-gray-900 text-white rounded-lg shadow-lg px-2.5 py-2 sm:px-4 sm:py-3 border border-gray-700 dark:border-gray-800",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx("span",{className:Be("text-base sm:text-xl transition-all duration-500 flex-shrink-0",i%2===0?"text-blue-400 scale-110":"text-blue-300"),children:z}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsxs("span",{className:"font-medium text-xs sm:text-sm truncate",children:[y,"..."]}),e.jsxs("span",{className:"text-gray-400 text-xs sm:text-sm flex-shrink-0",children:["(",n,"s)"]}),v>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-500 hidden sm:inline",children:"·"}),e.jsxs("span",{className:"text-gray-300 text-xs sm:text-sm hidden sm:inline flex-shrink-0",children:["⚒ ",v.toLocaleString()]})]}),e.jsx("span",{className:"text-gray-500 hidden sm:inline",children:"·"}),e.jsx("span",{className:"text-gray-400 text-xs sm:text-sm hidden sm:inline",children:"按 esc 停止"})]})})]})}),x&&s&&e.jsxs("button",{onClick:s,className:"ml-2 sm:ml-3 text-xs bg-red-600 hover:bg-red-700 active:bg-red-800 text-white px-2 py-1 sm:px-3 sm:py-1.5 rounded-md transition-colors flex items-center gap-1 sm:gap-1.5 flex-shrink-0 font-medium",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{className:"hidden sm:inline",children:"停止"})]})]})})}async function Wo(t,s){const a=new FormData,o=`recording_${Date.now()}.webm`,n=new File([t],o,{type:t.type});a.append("audio",n);const l=window.localStorage.getItem("whisperMode")||"default";a.append("mode",l);try{const i=await ve.transcribe(a);if(!i.ok){const h=await i.json().catch(()=>({}));throw new Error(h.error||`Transcription error: ${i.status} ${i.statusText}`)}return(await i.json()).text||""}catch(i){throw i.name==="TypeError"&&i.message.includes("fetch")?new Error("Cannot connect to server. Please ensure the backend is running."):i}}function Bo({onTranscript:t,className:s=""}){const[a,o]=r.useState("idle"),[n,l]=r.useState(null),[i,d]=r.useState(!0),h=r.useRef(null),p=r.useRef(null),g=r.useRef([]),k=r.useRef(0);r.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){d(!1),l("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){d(!1),l("Microphone requires HTTPS. Please use a secure connection.");return}d(!0),l(null)})()},[]);const y=async()=>{try{if(console.log("Starting recording..."),l(null),g.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const u=await navigator.mediaDevices.getUserMedia({audio:!0});p.current=u;const m=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",j=new MediaRecorder(u,{mimeType:m});h.current=j,j.ondataavailable=w=>{w.data.size>0&&g.current.push(w.data)},j.onstop=async()=>{console.log("Recording stopped, creating blob...");const w=new Blob(g.current,{type:m});p.current&&(p.current.getTracks().forEach(se=>se.stop()),p.current=null),o("transcribing");const L=window.localStorage.getItem("whisperMode")||"default",F=L==="prompt"||L==="vibe"||L==="instructions"||L==="architect";let O;F&&(O=setTimeout(()=>{o("processing")},2e3));try{const se=await Wo(w);se&&t&&t(se)}catch(se){console.error("Transcription error:",se),l(se.message)}finally{O&&clearTimeout(O),o("idle")}},j.start(),o("recording"),console.log("Recording started successfully")}catch(u){console.error("Failed to start recording:",u);let m="Microphone access failed";u.name==="NotAllowedError"?m="Microphone access denied. Please allow microphone permissions.":u.name==="NotFoundError"?m="No microphone found. Please check your audio devices.":u.name==="NotSupportedError"?m="Microphone not supported by this browser.":u.name==="NotReadableError"?m="Microphone is being used by another application.":u.message.includes("HTTPS")&&(m=u.message),l(m),o("idle")}},v=()=>{console.log("Stopping recording..."),h.current&&h.current.state==="recording"?h.current.stop():(console.log("Recorder not in recording state, forcing cleanup"),p.current&&(p.current.getTracks().forEach(u=>u.stop()),p.current=null),o("idle"))},x=u=>{if(u&&(u.preventDefault(),u.stopPropagation()),!i)return;const m=Date.now();if(m-k.current<300){console.log("Ignoring rapid tap");return}k.current=m,console.log("Button clicked, current state:",a),a==="idle"?y():a==="recording"&&v()};r.useEffect(()=>()=>{p.current&&p.current.getTracks().forEach(u=>u.stop())},[]);const R=()=>{if(!i)return{icon:e.jsx(dr,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(a){case"recording":return{icon:e.jsx(dr,{className:"w-5 h-5 text-white"}),className:"bg-red-500 hover:bg-red-600 animate-pulse",disabled:!1};case"transcribing":return{icon:e.jsx(wt,{className:"w-5 h-5 animate-spin"}),className:"bg-blue-500 hover:bg-blue-600",disabled:!0};case"processing":return{icon:e.jsx(Ws,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:e.jsx(dr,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:z,className:T,disabled:C}=R();return e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",style:{backgroundColor:a==="recording"?"#ef4444":a==="transcribing"?"#3b82f6":a==="processing"?"#a855f7":"#374151"},className:`
6
6
  flex items-center justify-center
7
7
  w-12 h-12 rounded-full
8
8
  text-white transition-all duration-200
@@ -122,7 +122,7 @@ ${ne}`:ne:Pe.push({type:"assistant",content:ne,timestamp:new Date,isStreaming:!0
122
122
  background-color: ${x?"#374151":"#f3f4f6"};
123
123
  }
124
124
  `}),e.jsx("div",{className:o?"w-full h-full flex flex-col":`fixed inset-0 z-40 md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${y?"md:p-0":""}`,children:e.jsxs("div",{className:o?"bg-background flex flex-col w-full h-full":`bg-background shadow-2xl flex flex-col ${"w-full h-full md:rounded-lg md:shadow-2xl"+(y?" md:w-full md:h-full md:rounded-none":" md:w-full md:max-w-6xl md:h-[80vh] md:max-h-[80vh]")}`,children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border flex-shrink-0 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0",children:e.jsx("h3",{className:"font-medium text-gray-900 dark:text-white truncate",children:t.name})}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 truncate",children:t.path})]})}),e.jsxs("div",{className:"flex items-center gap-1 md:gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:ae,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Download file",children:e.jsx($t,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsx("button",{onClick:ce,disabled:g,className:`px-3 py-2 text-white rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors min-h-[44px] md:min-h-0 ${z?"bg-green-600 hover:bg-green-700":"bg-blue-600 hover:bg-blue-700"}`,children:z?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-5 h-5 md:w-4 md:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{className:"hidden sm:inline",children:"Saved!"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Bs,{className:"w-5 h-5 md:w-4 md:h-4"}),e.jsx("span",{className:"hidden sm:inline",children:g?"Saving...":"Save"})]})}),!o&&e.jsx("button",{onClick:oe,className:"hidden md:flex p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:y?"Exit fullscreen":"Fullscreen",children:y?e.jsx(en,{className:"w-4 h-4"}):e.jsx(Us,{className:"w-4 h-4"})}),e.jsx("button",{onClick:s,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Close",children:e.jsx(Ue,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(Ra,{ref:F,value:i,onChange:d,extensions:[...se(t.name),...O,...C?[$a.lineWrapping]:[]],theme:x?za:void 0,height:"100%",style:{fontSize:`${w}px`,height:"100%"},basicSetup:{lineNumbers:m,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),e.jsxs("div",{className:"flex items-center justify-between p-3 border-t border-border bg-muted flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("span",{children:["Lines: ",i.split(`
125
- `).length]}),e.jsxs("span",{children:["Characters: ",i.length]})]}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Press Ctrl+S to save • Esc to close"})]})]})})]})}function Xo({file:t,onClose:s}){const a=`/api/projects/${t.projectName}/files/content?path=${encodeURIComponent(t.path)}`,[o,n]=r.useState(null),[l,i]=r.useState(null),[d,h]=r.useState(!0);return r.useEffect(()=>{let p;const g=new AbortController;return(async()=>{try{h(!0),i(null),n(null);const y=await re(a,{signal:g.signal});if(!y.ok)throw new Error(`Request failed with status ${y.status}`);const v=await y.blob();p=URL.createObjectURL(v),n(p)}catch(y){if(y.name==="AbortError")return;console.error("Error loading image:",y),i("无法加载图像")}finally{h(!1)}})(),()=>{g.abort(),p&&URL.revokeObjectURL(p)}},[a]),e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-4xl max-h-[90vh] w-full mx-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:t.name}),e.jsx(K,{variant:"ghost",size:"sm",onClick:s,className:"h-8 w-8 p-0",children:e.jsx(Ue,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"p-4 flex justify-center items-center bg-gray-50 dark:bg-gray-900 min-h-[400px]",children:[d&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:"加载图像中…"})}),!d&&o&&e.jsx("img",{src:o,alt:t.name,className:"max-w-full max-h-[70vh] object-contain rounded-lg shadow-md"}),!d&&!o&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("p",{children:l||"无法加载图像"}),e.jsx("p",{className:"text-sm mt-2 break-all",children:t.path})]})]}),e.jsx("div",{className:"p-4 border-t bg-gray-50 dark:bg-gray-800",children:e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:t.path})})]})})}function ei({selectedProject:t}){const[s,a]=r.useState([]),[o,n]=r.useState(!1),[l,i]=r.useState(new Set),[d,h]=r.useState(new Set),[p,g]=r.useState(new Set),[k,y]=r.useState(null),[v,x]=r.useState(null),[R,z]=r.useState("detailed"),[T,C]=r.useState(""),[u,m]=r.useState([]),[j,w]=r.useState(!1),[L,F]=r.useState(!1),[O,se]=r.useState(null),[ce,ae]=r.useState({}),[oe,W]=r.useState(null);r.useEffect(()=>{t&&(i(new Set),g(new Set),h(new Set),_())},[t]),r.useEffect(()=>{const $=localStorage.getItem("file-tree-view-mode");$&&["simple","detailed","compact"].includes($)&&z($)},[]),r.useEffect(()=>{if(!T.trim())m(s);else{const $=I(s,T.toLowerCase());m($);const A=f=>{f.forEach(H=>{H.type==="directory"&&H.children&&H.children.length>0&&(i(de=>new Set(de.add(H.path))),A(H.children))})};A($)}},[s,T]);const I=($,A)=>$.reduce((f,H)=>{const de=H.name.toLowerCase().includes(A);let Ee=[];return H.type==="directory"&&H.children&&(Ee=I(H.children,A)),(de||Ee.length>0)&&f.push({...H,children:Ee}),f},[]),_=async()=>{n(!0);try{const $=await ve.getFiles(t.name,{depth:1});if(!$.ok){const f=await $.text();console.error("❌ File fetch failed:",$.status,f),a([]);return}const A=await $.json();a(A)}catch($){console.error("❌ Error fetching files:",$),a([])}finally{n(!1)}},X=async $=>{if(!(p.has($)||d.has($))){h(A=>new Set([...A,$]));try{const A=await ve.getFiles(t.name,{dirPath:$,depth:1});if(!A.ok){console.error("Failed to load directory:",$);return}const f=await A.json();a(H=>je(H,$,f)),g(H=>new Set([...H,$]))}catch(A){console.error("Error loading directory:",A)}finally{h(A=>{const f=new Set(A);return f.delete($),f})}}},je=($,A,f)=>$.map(H=>H.path===A?{...H,children:f}:H.type==="directory"&&H.children&&H.children.length>0?{...H,children:je(H.children,A,f)}:H),ie=r.useCallback(async $=>{if(!t||$.length===0)return;F(!0),se(null);const A=new FormData;$.forEach(H=>{A.append("files",H)});const f={};$.forEach(H=>{f[H.name]=0}),ae(f);try{const H=await ve.uploadFiles(t.name,A);if(!H.ok){const Ee=await H.json();throw new Error(Ee.error||"Upload failed")}const de={};$.forEach(Ee=>{de[Ee.name]=100}),ae(de),await _(),setTimeout(()=>{w(!1),ae({})},1e3)}catch(H){console.error("Upload failed:",H),se(H.message)}finally{F(!1)}},[t]),{getRootProps:Z,getInputProps:we,isDragActive:Me,open:De}=Zr({onDrop:ie,noClick:!0,noKeyboard:!0}),Ce=async $=>{if(t)try{const A=await ve.deleteFile(t.name,$);if(!A.ok){const f=await A.json();throw new Error(f.error||"Delete failed")}await _(),W(null)}catch(A){console.error("Delete failed:",A),alert(`Failed to delete: ${A.message}`)}},Oe=async($,A)=>{const f=new Set(l);f.has($)?f.delete($):(f.add($),A&&!p.has($)&&await X($)),i(f)},xe=$=>{z($),localStorage.setItem("file-tree-view-mode",$)},Se=$=>{if(!$||$===0)return"0 B";const A=1024,f=["B","KB","MB","GB"],H=Math.floor(Math.log($)/Math.log(A));return parseFloat(($/Math.pow(A,H)).toFixed(1))+" "+f[H]},Re=$=>{if(!$)return"-";const A=new Date,f=new Date($),H=Math.floor((A-f)/1e3);return H<60?"just now":H<3600?`${Math.floor(H/60)} min ago`:H<86400?`${Math.floor(H/3600)} hours ago`:H<2592e3?`${Math.floor(H/86400)} days ago`:f.toLocaleDateString()},ze=($,A=0)=>$.map(f=>{const H=d.has(f.path),de=l.has(f.path),Ee=f.hasChildren||f.children&&f.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:Be("w-full flex items-center justify-between p-2 hover:bg-accent",f.type==="directory"||he(f.name)||Le(f.name)?"cursor-pointer":"cursor-default"),style:{paddingLeft:`${A*16+12}px`},onClick:()=>{f.type==="directory"?Oe(f.path,Ee):he(f.name)?x({name:f.name,path:f.path,projectPath:t.path,projectName:t.name}):Le(f.name)&&y({name:f.name,path:f.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[f.type==="directory"?H?e.jsx(wt,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):de?e.jsx(Et,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):Ee?e.jsx(nt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(nt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):_e(f.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:f.name}),f.type==="directory"&&Ee&&!de&&!H&&e.jsx(zt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[f.type==="file"&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity flex-shrink-0",onClick:Ae=>{Ae.stopPropagation(),Te(f)},title:"下载文件",children:e.jsx($t,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity flex-shrink-0",onClick:Ae=>{Ae.stopPropagation(),W({path:f.path,name:f.name,type:f.type})},title:`删除${f.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ge,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]})]}),f.type==="directory"&&de&&e.jsx("div",{children:H?e.jsxs("div",{className:"flex items-center gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(A+1)*16+12}px`},children:[e.jsx(wt,{className:"w-3 h-3 animate-spin"}),"加载中..."]}):f.children&&f.children.length>0?ze(f.children,A+1):e.jsx("div",{className:"p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(A+1)*16+12}px`},children:"空文件夹"})})]},f.path)}),he=$=>{const A=$.split(".").pop()?.toLowerCase();return["png","jpg","jpeg","gif","svg","webp","ico","bmp"].includes(A)},Le=$=>{const A=$.toLowerCase(),f=["dockerfile","makefile","gemfile","rakefile","procfile","vagrantfile","jenkinsfile"];if(!$.includes("."))return f.includes(A);const H=$.split(".").pop()?.toLowerCase();return new Set(["js","jsx","ts","tsx","mjs","cjs","py","pyw","pyi","java","kt","kts","scala","groovy","cpp","cxx","cc","c","h","hpp","hxx","cs","fs","fsx","go","rs","swift","php","rb","lua","pl","pm","r","dart","elm","clj","cljs","ex","exs","sh","bash","zsh","fish","ps1","bat","cmd","html","htm","xhtml","css","scss","sass","less","vue","svelte","astro","json","json5","jsonc","yaml","yml","toml","ini","cfg","conf","config","env","properties","xml","xsd","xsl","csv","tsv","graphql","gql","proto","sql","md","mdx","markdown","txt","text","rst","adoc","tex","log","lock","gitignore","gitattributes","gitmodules","editorconfig","prettierrc","eslintrc","babelrc","htaccess"]).has(H)},Te=async $=>{try{const A=await ve.getFileContent(t.name,$.path);if(!A.ok)throw new Error("Download failed");const f=await A.blob(),H=URL.createObjectURL(f),de=document.createElement("a");de.href=H,de.download=$.name,document.body.appendChild(de),de.click(),document.body.removeChild(de),URL.revokeObjectURL(H)}catch(A){console.error("Download failed:",A)}},_e=$=>{const A=$.split(".").pop()?.toLowerCase(),f=["js","jsx","ts","tsx","py","java","cpp","c","php","rb","go","rs"],H=["md","txt","doc","pdf"],de=["png","jpg","jpeg","gif","svg","webp","ico","bmp"];return f.includes(A)?e.jsx(sn,{className:"w-4 h-4 text-green-500 flex-shrink-0"}):H.includes(A)?e.jsx(qs,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):de.includes(A)?e.jsx(fs,{className:"w-4 h-4 text-purple-500 flex-shrink-0"}):e.jsx(fs,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"})},We=($,A=0)=>$.map(f=>{const H=d.has(f.path),de=l.has(f.path),Ee=f.hasChildren||f.children&&f.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:Be("grid grid-cols-12 gap-2 p-2 hover:bg-accent items-center",f.type==="directory"||he(f.name)||Le(f.name)?"cursor-pointer":"cursor-default"),style:{paddingLeft:`${A*16+12}px`},onClick:()=>{f.type==="directory"?Oe(f.path,Ee):he(f.name)?x({name:f.name,path:f.path,projectPath:t.path,projectName:t.name}):Le(f.name)&&y({name:f.name,path:f.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"col-span-4 flex items-center gap-2 min-w-0",children:[f.type==="directory"?H?e.jsx(wt,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):de?e.jsx(Et,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):Ee?e.jsx(nt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(nt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):_e(f.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:f.name}),f.type==="directory"&&Ee&&!de&&!H&&e.jsx(zt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground",children:f.type==="file"?Se(f.size):"-"}),e.jsx("div",{className:"col-span-3 text-sm text-muted-foreground",children:Re(f.modified)}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground font-mono",children:f.permissionsRwx||"-"}),e.jsxs("div",{className:"col-span-1 flex justify-end items-center gap-0.5",children:[f.type==="file"&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:Ae=>{Ae.stopPropagation(),Te(f)},title:"下载文件",children:e.jsx($t,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:Ae=>{Ae.stopPropagation(),W({path:f.path,name:f.name,type:f.type})},title:`删除${f.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ge,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]})]}),f.type==="directory"&&de&&e.jsx("div",{children:H?e.jsx("div",{className:"grid grid-cols-12 gap-2 p-2 text-sm text-muted-foreground items-center",style:{paddingLeft:`${(A+1)*16+12}px`},children:e.jsxs("div",{className:"col-span-4 flex items-center gap-2",children:[e.jsx(wt,{className:"w-3 h-3 animate-spin"}),"加载中..."]})}):f.children&&f.children.length>0?We(f.children,A+1):e.jsx("div",{className:"grid grid-cols-12 gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(A+1)*16+12}px`},children:e.jsx("div",{className:"col-span-4",children:"空文件夹"})})})]},f.path)}),D=($,A=0)=>$.map(f=>{const H=d.has(f.path),de=l.has(f.path),Ee=f.hasChildren||f.children&&f.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:Be("flex items-center justify-between p-2 hover:bg-accent",f.type==="directory"||he(f.name)||Le(f.name)?"cursor-pointer":"cursor-default"),style:{paddingLeft:`${A*16+12}px`},onClick:()=>{f.type==="directory"?Oe(f.path,Ee):he(f.name)?x({name:f.name,path:f.path,projectPath:t.path,projectName:t.name}):Le(f.name)&&y({name:f.name,path:f.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.type==="directory"?H?e.jsx(wt,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):de?e.jsx(Et,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):Ee?e.jsx(nt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(nt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):_e(f.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:f.name}),f.type==="directory"&&Ee&&!de&&!H&&e.jsx(zt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[f.type==="file"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:Se(f.size)}),e.jsx("span",{className:"font-mono",children:f.permissionsRwx})]}),f.type==="file"&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:Ae=>{Ae.stopPropagation(),Te(f)},title:"下载文件",children:e.jsx($t,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:Ae=>{Ae.stopPropagation(),W({path:f.path,name:f.name,type:f.type})},title:`删除${f.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ge,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]})]}),f.type==="directory"&&de&&e.jsx("div",{children:H?e.jsxs("div",{className:"flex items-center gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(A+1)*16+12}px`},children:[e.jsx(wt,{className:"w-3 h-3 animate-spin"}),"加载中..."]}):f.children&&f.children.length>0?D(f.children,A+1):e.jsx("div",{className:"p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(A+1)*16+12}px`},children:"空文件夹"})})]},f.path)});return o?e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsx("div",{className:"text-gray-500 dark:text-gray-400",children:"加载文件中..."})}):e.jsxs("div",{...Z(),className:Be("h-full flex flex-col bg-card relative",Me&&"ring-2 ring-primary ring-inset"),children:[e.jsx("input",{...we()}),Me&&e.jsx("div",{className:"absolute inset-0 bg-primary/10 flex items-center justify-center z-10 pointer-events-none",children:e.jsx("div",{className:"text-primary font-medium",children:"拖放文件以上传"})}),e.jsxs("div",{className:"p-4 border-b border-border space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground",children:"文件"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>w(!0),title:"上传文件",children:e.jsx(gs,{className:"w-4 h-4"})}),e.jsx(K,{variant:R==="simple"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>xe("simple"),title:"简单视图",children:e.jsx(tn,{className:"w-4 h-4"})}),e.jsx(K,{variant:R==="compact"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>xe("compact"),title:"紧凑视图",children:e.jsx(Hs,{className:"w-4 h-4"})}),e.jsx(K,{variant:R==="detailed"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>xe("detailed"),title:"详细视图",children:e.jsx(rn,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(At,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Ve,{type:"text",placeholder:"搜索文件和文件夹...",value:T,onChange:$=>C($.target.value),className:"pl-8 pr-8 h-8 text-sm"}),T&&e.jsx(K,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-accent",onClick:()=>C(""),title:"清除搜索",children:e.jsx(Ue,{className:"w-3 h-3"})})]})]}),R==="detailed"&&u.length>0&&e.jsx("div",{className:"px-4 pt-2 pb-1 border-b border-border",children:e.jsxs("div",{className:"grid grid-cols-12 gap-2 px-2 text-xs font-medium text-muted-foreground",children:[e.jsx("div",{className:"col-span-4",children:"名称"}),e.jsx("div",{className:"col-span-2",children:"大小"}),e.jsx("div",{className:"col-span-3",children:"修改时间"}),e.jsx("div",{className:"col-span-2",children:"权限"}),e.jsx("div",{className:"col-span-1"})]})}),e.jsx(Yr,{className:"flex-1 p-4",children:s.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-3",children:e.jsx(nt,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h4",{className:"font-medium text-foreground mb-1",children:"未找到文件"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"检查项目路径是否可访问"})]}):u.length===0&&T?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-3",children:e.jsx(At,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h4",{className:"font-medium text-foreground mb-1",children:"无匹配结果"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"尝试不同的搜索条件或清除搜索"})]}):e.jsxs("div",{className:R==="detailed"?"":"space-y-1",children:[R==="simple"&&ze(u),R==="compact"&&D(u),R==="detailed"&&We(u)]})}),k&&e.jsx(Gr,{file:k,onClose:()=>y(null),projectPath:k.projectPath}),v&&e.jsx(Xo,{file:v,onClose:()=>x(null)}),j&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-xl p-6 w-full max-w-md mx-4 border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"上传文件"}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{w(!1),se(null),ae({})},children:e.jsx(Ue,{className:"w-4 h-4"})})]}),e.jsxs("div",{onClick:De,className:Be("border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors","border-border hover:border-primary/50"),children:[e.jsx(gs,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-foreground",children:"将文件拖到此处或点击浏览"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"每次上传最多 20 个文件"})]}),Object.keys(ce).length>0&&e.jsx("div",{className:"mt-4 space-y-2 max-h-40 overflow-y-auto",children:Object.entries(ce).map(([$,A])=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm truncate flex-1 text-foreground",children:$}),e.jsx("div",{className:"w-20 h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${A}%`}})}),e.jsxs("span",{className:"text-xs text-muted-foreground w-10",children:[A,"%"]})]},$))}),O&&e.jsx("div",{className:"mt-4 p-3 bg-destructive/10 border border-destructive/20 rounded-lg",children:e.jsx("p",{className:"text-sm text-destructive",children:O})}),L&&e.jsx("div",{className:"mt-4 text-center text-sm text-muted-foreground",children:"上传中..."})]})}),oe&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-xl p-6 w-full max-w-sm mx-4 border border-border",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground mb-2",children:"确认删除"}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["确定要删除",oe.type==="directory"?"文件夹":"文件"," ",e.jsxs("span",{className:"font-medium text-foreground",children:['"',oe.name,'"']}),"?",oe.type==="directory"&&e.jsx("span",{className:"block mt-1 text-destructive",children:"这将删除内部的所有内容。"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>W(null),children:"取消"}),e.jsx(K,{variant:"destructive",size:"sm",onClick:()=>Ce(oe.path),children:"删除"})]})]})})]})}var es=En(),ts=Mn(),rs=Ln(),ss=In();const ti=`
125
+ `).length]}),e.jsxs("span",{children:["Characters: ",i.length]})]}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Press Ctrl+S to save • Esc to close"})]})]})})]})}function Xo({file:t,onClose:s}){const a=`/api/projects/${t.projectName}/files/content?path=${encodeURIComponent(t.path)}`,[o,n]=r.useState(null),[l,i]=r.useState(null),[d,h]=r.useState(!0);return r.useEffect(()=>{let p;const g=new AbortController;return(async()=>{try{h(!0),i(null),n(null);const y=await re(a,{signal:g.signal});if(!y.ok)throw new Error(`Request failed with status ${y.status}`);const v=await y.blob();p=URL.createObjectURL(v),n(p)}catch(y){if(y.name==="AbortError")return;console.error("Error loading image:",y),i("无法加载图像")}finally{h(!1)}})(),()=>{g.abort(),p&&URL.revokeObjectURL(p)}},[a]),e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-4xl max-h-[90vh] w-full mx-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:t.name}),e.jsx(K,{variant:"ghost",size:"sm",onClick:s,className:"h-8 w-8 p-0",children:e.jsx(Ue,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"p-4 flex justify-center items-center bg-gray-50 dark:bg-gray-900 min-h-[400px]",children:[d&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:"加载图像中…"})}),!d&&o&&e.jsx("img",{src:o,alt:t.name,className:"max-w-full max-h-[70vh] object-contain rounded-lg shadow-md"}),!d&&!o&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("p",{children:l||"无法加载图像"}),e.jsx("p",{className:"text-sm mt-2 break-all",children:t.path})]})]}),e.jsx("div",{className:"p-4 border-t bg-gray-50 dark:bg-gray-800",children:e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:t.path})})]})})}function ei({selectedProject:t}){const[s,a]=r.useState([]),[o,n]=r.useState(!1),[l,i]=r.useState(new Set),[d,h]=r.useState(new Set),[p,g]=r.useState(new Set),[k,y]=r.useState(null),[v,x]=r.useState(null),[R,z]=r.useState("detailed"),[T,C]=r.useState(""),[u,m]=r.useState([]),[j,w]=r.useState(!1),[L,F]=r.useState(!1),[O,se]=r.useState(null),[ce,ae]=r.useState({}),[oe,W]=r.useState(null);r.useEffect(()=>{t&&(i(new Set),g(new Set),h(new Set),_())},[t]),r.useEffect(()=>{const $=localStorage.getItem("file-tree-view-mode");$&&["simple","detailed","compact"].includes($)&&z($)},[]),r.useEffect(()=>{if(!T.trim())m(s);else{const $=I(s,T.toLowerCase());m($);const A=f=>{f.forEach(H=>{H.type==="directory"&&H.children&&H.children.length>0&&(i(de=>new Set(de.add(H.path))),A(H.children))})};A($)}},[s,T]);const I=($,A)=>$.reduce((f,H)=>{const de=H.name.toLowerCase().includes(A);let Ee=[];return H.type==="directory"&&H.children&&(Ee=I(H.children,A)),(de||Ee.length>0)&&f.push({...H,children:Ee}),f},[]),_=async()=>{n(!0);try{const $=await ve.getFiles(t.name,{depth:1});if(!$.ok){const f=await $.text();console.error("❌ File fetch failed:",$.status,f),a([]);return}const A=await $.json();a(A)}catch($){console.error("❌ Error fetching files:",$),a([])}finally{n(!1)}},X=async $=>{if(!(p.has($)||d.has($))){h(A=>new Set([...A,$]));try{const A=await ve.getFiles(t.name,{dirPath:$,depth:1});if(!A.ok){console.error("Failed to load directory:",$);return}const f=await A.json();a(H=>je(H,$,f)),g(H=>new Set([...H,$]))}catch(A){console.error("Error loading directory:",A)}finally{h(A=>{const f=new Set(A);return f.delete($),f})}}},je=($,A,f)=>$.map(H=>H.path===A?{...H,children:f}:H.type==="directory"&&H.children&&H.children.length>0?{...H,children:je(H.children,A,f)}:H),ie=r.useCallback(async $=>{if(!t||$.length===0)return;F(!0),se(null);const A=new FormData;$.forEach(H=>{A.append("files",H)});const f={};$.forEach(H=>{f[H.name]=0}),ae(f);try{const H=await ve.uploadFiles(t.name,A);if(!H.ok){const Ee=await H.json();throw new Error(Ee.error||"Upload failed")}const de={};$.forEach(Ee=>{de[Ee.name]=100}),ae(de),await _(),setTimeout(()=>{w(!1),ae({})},1e3)}catch(H){console.error("Upload failed:",H),se(H.message)}finally{F(!1)}},[t]),{getRootProps:Z,getInputProps:we,isDragActive:Me,open:De}=Zr({onDrop:ie,noClick:!0,noKeyboard:!0}),Ce=async $=>{if(t)try{const A=await ve.deleteFile(t.name,$);if(!A.ok){const f=await A.json();throw new Error(f.error||"Delete failed")}await _(),W(null)}catch(A){console.error("Delete failed:",A),alert(`Failed to delete: ${A.message}`)}},Oe=async($,A)=>{const f=new Set(l);f.has($)?f.delete($):(f.add($),A&&!p.has($)&&await X($)),i(f)},xe=$=>{z($),localStorage.setItem("file-tree-view-mode",$)},Se=$=>{if(!$||$===0)return"0 B";const A=1024,f=["B","KB","MB","GB"],H=Math.floor(Math.log($)/Math.log(A));return parseFloat(($/Math.pow(A,H)).toFixed(1))+" "+f[H]},Re=$=>{if(!$)return"-";const A=new Date,f=new Date($),H=Math.floor((A-f)/1e3);return H<60?"just now":H<3600?`${Math.floor(H/60)} min ago`:H<86400?`${Math.floor(H/3600)} hours ago`:H<2592e3?`${Math.floor(H/86400)} days ago`:f.toLocaleDateString()},ze=($,A=0)=>$.map(f=>{const H=d.has(f.path),de=l.has(f.path),Ee=f.hasChildren||f.children&&f.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:Be("w-full flex items-center justify-between p-2 hover:bg-accent",f.type==="directory"||he(f.name)||Le(f.name)?"cursor-pointer":"cursor-default"),style:{paddingLeft:`${A*16+12}px`},onClick:()=>{f.type==="directory"?Oe(f.path,Ee):he(f.name)?x({name:f.name,path:f.path,projectPath:t.path,projectName:t.name}):Le(f.name)&&y({name:f.name,path:f.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[f.type==="directory"?H?e.jsx(wt,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):de?e.jsx(Et,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):Ee?e.jsx(nt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(nt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):_e(f.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:f.name}),f.type==="directory"&&Ee&&!de&&!H&&e.jsx(zt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[f.type==="file"&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity flex-shrink-0",onClick:Ae=>{Ae.stopPropagation(),Te(f)},title:"下载文件",children:e.jsx($t,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity flex-shrink-0",onClick:Ae=>{Ae.stopPropagation(),W({path:f.path,name:f.name,type:f.type})},title:`删除${f.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ge,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]})]}),f.type==="directory"&&de&&e.jsx("div",{children:H?e.jsxs("div",{className:"flex items-center gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(A+1)*16+12}px`},children:[e.jsx(wt,{className:"w-3 h-3 animate-spin"}),"加载中..."]}):f.children&&f.children.length>0?ze(f.children,A+1):e.jsx("div",{className:"p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(A+1)*16+12}px`},children:"空文件夹"})})]},f.path)}),he=$=>{const A=$.split(".").pop()?.toLowerCase();return["png","jpg","jpeg","gif","svg","webp","ico","bmp"].includes(A)},Le=$=>{const A=$.toLowerCase(),f=["dockerfile","makefile","gemfile","rakefile","procfile","vagrantfile","jenkinsfile"];if(!$.includes("."))return f.includes(A);const H=$.split(".").pop()?.toLowerCase();return new Set(["js","jsx","ts","tsx","mjs","cjs","py","pyw","pyi","java","kt","kts","scala","groovy","cpp","cxx","cc","c","h","hpp","hxx","cs","fs","fsx","go","rs","swift","php","rb","lua","pl","pm","r","dart","elm","clj","cljs","ex","exs","sh","bash","zsh","fish","ps1","bat","cmd","html","htm","xhtml","css","scss","sass","less","vue","svelte","astro","json","json5","jsonc","yaml","yml","toml","ini","cfg","conf","config","env","properties","xml","xsd","xsl","csv","tsv","graphql","gql","proto","sql","md","mdx","markdown","txt","text","rst","adoc","tex","log","lock","gitignore","gitattributes","gitmodules","editorconfig","prettierrc","eslintrc","babelrc","htaccess"]).has(H)},Te=async $=>{try{const A=await ve.getFileContent(t.name,$.path);if(!A.ok)throw new Error("Download failed");const f=await A.blob(),H=URL.createObjectURL(f),de=document.createElement("a");de.href=H,de.download=$.name,document.body.appendChild(de),de.click(),document.body.removeChild(de),URL.revokeObjectURL(H)}catch(A){console.error("Download failed:",A)}},_e=$=>{const A=$.split(".").pop()?.toLowerCase(),f=["js","jsx","ts","tsx","py","java","cpp","c","php","rb","go","rs"],H=["md","txt","doc","pdf"],de=["png","jpg","jpeg","gif","svg","webp","ico","bmp"];return f.includes(A)?e.jsx(sn,{className:"w-4 h-4 text-green-500 flex-shrink-0"}):H.includes(A)?e.jsx(qs,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):de.includes(A)?e.jsx(fs,{className:"w-4 h-4 text-purple-500 flex-shrink-0"}):e.jsx(fs,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"})},We=($,A=0)=>$.map(f=>{const H=d.has(f.path),de=l.has(f.path),Ee=f.hasChildren||f.children&&f.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:Be("grid grid-cols-12 gap-2 p-2 hover:bg-accent items-center",f.type==="directory"||he(f.name)||Le(f.name)?"cursor-pointer":"cursor-default"),style:{paddingLeft:`${A*16+12}px`},onClick:()=>{f.type==="directory"?Oe(f.path,Ee):he(f.name)?x({name:f.name,path:f.path,projectPath:t.path,projectName:t.name}):Le(f.name)&&y({name:f.name,path:f.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"col-span-4 flex items-center gap-2 min-w-0",children:[f.type==="directory"?H?e.jsx(wt,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):de?e.jsx(Et,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):Ee?e.jsx(nt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(nt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):_e(f.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:f.name}),f.type==="directory"&&Ee&&!de&&!H&&e.jsx(zt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground",children:f.type==="file"?Se(f.size):"-"}),e.jsx("div",{className:"col-span-3 text-sm text-muted-foreground",children:Re(f.modified)}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground font-mono",children:f.permissionsRwx||"-"}),e.jsxs("div",{className:"col-span-1 flex justify-end items-center gap-0.5",children:[f.type==="file"&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:Ae=>{Ae.stopPropagation(),Te(f)},title:"下载文件",children:e.jsx($t,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:Ae=>{Ae.stopPropagation(),W({path:f.path,name:f.name,type:f.type})},title:`删除${f.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ge,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]})]}),f.type==="directory"&&de&&e.jsx("div",{children:H?e.jsx("div",{className:"grid grid-cols-12 gap-2 p-2 text-sm text-muted-foreground items-center",style:{paddingLeft:`${(A+1)*16+12}px`},children:e.jsxs("div",{className:"col-span-4 flex items-center gap-2",children:[e.jsx(wt,{className:"w-3 h-3 animate-spin"}),"加载中..."]})}):f.children&&f.children.length>0?We(f.children,A+1):e.jsx("div",{className:"grid grid-cols-12 gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(A+1)*16+12}px`},children:e.jsx("div",{className:"col-span-4",children:"空文件夹"})})})]},f.path)}),D=($,A=0)=>$.map(f=>{const H=d.has(f.path),de=l.has(f.path),Ee=f.hasChildren||f.children&&f.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:Be("flex items-center justify-between p-2 hover:bg-accent",f.type==="directory"||he(f.name)||Le(f.name)?"cursor-pointer":"cursor-default"),style:{paddingLeft:`${A*16+12}px`},onClick:()=>{f.type==="directory"?Oe(f.path,Ee):he(f.name)?x({name:f.name,path:f.path,projectPath:t.path,projectName:t.name}):Le(f.name)&&y({name:f.name,path:f.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.type==="directory"?H?e.jsx(wt,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):de?e.jsx(Et,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):Ee?e.jsx(nt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(nt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):_e(f.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:f.name}),f.type==="directory"&&Ee&&!de&&!H&&e.jsx(zt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[f.type==="file"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:Se(f.size)}),e.jsx("span",{className:"font-mono",children:f.permissionsRwx})]}),f.type==="file"&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:Ae=>{Ae.stopPropagation(),Te(f)},title:"下载文件",children:e.jsx($t,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-primary"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:Ae=>{Ae.stopPropagation(),W({path:f.path,name:f.name,type:f.type})},title:`删除${f.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ge,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]})]}),f.type==="directory"&&de&&e.jsx("div",{children:H?e.jsxs("div",{className:"flex items-center gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(A+1)*16+12}px`},children:[e.jsx(wt,{className:"w-3 h-3 animate-spin"}),"加载中..."]}):f.children&&f.children.length>0?D(f.children,A+1):e.jsx("div",{className:"p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(A+1)*16+12}px`},children:"空文件夹"})})]},f.path)});return o?e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsx("div",{className:"text-gray-500 dark:text-gray-400",children:"加载文件中..."})}):e.jsxs("div",{...Z(),className:Be("h-full flex flex-col bg-card relative",Me&&"ring-2 ring-primary ring-inset"),children:[e.jsx("input",{...we()}),Me&&e.jsx("div",{className:"absolute inset-0 bg-primary/10 flex items-center justify-center z-10 pointer-events-none",children:e.jsx("div",{className:"text-primary font-medium",children:"拖放文件以上传"})}),e.jsxs("div",{className:"p-4 border-b border-border space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground",children:"文件"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>w(!0),title:"上传文件",children:e.jsx(gs,{className:"w-4 h-4"})}),e.jsx(K,{variant:R==="simple"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>xe("simple"),title:"简单视图",children:e.jsx(tn,{className:"w-4 h-4"})}),e.jsx(K,{variant:R==="compact"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>xe("compact"),title:"紧凑视图",children:e.jsx(Hs,{className:"w-4 h-4"})}),e.jsx(K,{variant:R==="detailed"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>xe("detailed"),title:"详细视图",children:e.jsx(rn,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(At,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Ye,{type:"text",placeholder:"搜索文件和文件夹...",value:T,onChange:$=>C($.target.value),className:"pl-8 pr-8 h-8 text-sm"}),T&&e.jsx(K,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-6 w-6 p-0 hover:bg-accent",onClick:()=>C(""),title:"清除搜索",children:e.jsx(Ue,{className:"w-3 h-3"})})]})]}),R==="detailed"&&u.length>0&&e.jsx("div",{className:"px-4 pt-2 pb-1 border-b border-border",children:e.jsxs("div",{className:"grid grid-cols-12 gap-2 px-2 text-xs font-medium text-muted-foreground",children:[e.jsx("div",{className:"col-span-4",children:"名称"}),e.jsx("div",{className:"col-span-2",children:"大小"}),e.jsx("div",{className:"col-span-3",children:"修改时间"}),e.jsx("div",{className:"col-span-2",children:"权限"}),e.jsx("div",{className:"col-span-1"})]})}),e.jsx(Yr,{className:"flex-1 p-4",children:s.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-3",children:e.jsx(nt,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h4",{className:"font-medium text-foreground mb-1",children:"未找到文件"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"检查项目路径是否可访问"})]}):u.length===0&&T?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-3",children:e.jsx(At,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h4",{className:"font-medium text-foreground mb-1",children:"无匹配结果"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"尝试不同的搜索条件或清除搜索"})]}):e.jsxs("div",{className:R==="detailed"?"":"space-y-1",children:[R==="simple"&&ze(u),R==="compact"&&D(u),R==="detailed"&&We(u)]})}),k&&e.jsx(Gr,{file:k,onClose:()=>y(null),projectPath:k.projectPath}),v&&e.jsx(Xo,{file:v,onClose:()=>x(null)}),j&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-xl p-6 w-full max-w-md mx-4 border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"上传文件"}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{w(!1),se(null),ae({})},children:e.jsx(Ue,{className:"w-4 h-4"})})]}),e.jsxs("div",{onClick:De,className:Be("border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors","border-border hover:border-primary/50"),children:[e.jsx(gs,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-foreground",children:"将文件拖到此处或点击浏览"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"每次上传最多 20 个文件"})]}),Object.keys(ce).length>0&&e.jsx("div",{className:"mt-4 space-y-2 max-h-40 overflow-y-auto",children:Object.entries(ce).map(([$,A])=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm truncate flex-1 text-foreground",children:$}),e.jsx("div",{className:"w-20 h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${A}%`}})}),e.jsxs("span",{className:"text-xs text-muted-foreground w-10",children:[A,"%"]})]},$))}),O&&e.jsx("div",{className:"mt-4 p-3 bg-destructive/10 border border-destructive/20 rounded-lg",children:e.jsx("p",{className:"text-sm text-destructive",children:O})}),L&&e.jsx("div",{className:"mt-4 text-center text-sm text-muted-foreground",children:"上传中..."})]})}),oe&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-xl p-6 w-full max-w-sm mx-4 border border-border",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground mb-2",children:"确认删除"}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["确定要删除",oe.type==="directory"?"文件夹":"文件"," ",e.jsxs("span",{className:"font-medium text-foreground",children:['"',oe.name,'"']}),"?",oe.type==="directory"&&e.jsx("span",{className:"block mt-1 text-destructive",children:"这将删除内部的所有内容。"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>W(null),children:"取消"}),e.jsx(K,{variant:"destructive",size:"sm",onClick:()=>Ce(oe.path),children:"删除"})]})]})})]})}var es=En(),ts=Mn(),rs=Ln(),ss=In();const ti=`
126
126
  .xterm .xterm-screen {
127
127
  outline: none !important;
128
128
  }
@@ -132,17 +132,17 @@ ${ne}`:ne:Pe.push({type:"assistant",content:ne,timestamp:new Date,isStreaming:!0
132
132
  .xterm-screen:focus {
133
133
  outline: none !important;
134
134
  }
135
- `;if(typeof document<"u"){const t=document.createElement("style");t.type="text/css",t.innerText=ti,document.head.appendChild(t)}function ri({selectedProject:t,selectedSession:s,initialCommand:a,isPlainShell:o=!1,onProcessComplete:n,minimal:l=!1,autoConnect:i=!1}){const d=r.useRef(null),h=r.useRef(null),p=r.useRef(null),g=r.useRef(null),[k,y]=r.useState(!1),[v,x]=r.useState(!1),[R,z]=r.useState(!1),[T,C]=r.useState(null),[u,m]=r.useState(!1),j=r.useRef(t),w=r.useRef(s),L=r.useRef(a),F=r.useRef(o),O=r.useRef(n);r.useEffect(()=>{j.current=t,w.current=s,L.current=a,F.current=o,O.current=n});const se=r.useCallback(async()=>{if(!(u||k))try{let je;{const ie=localStorage.getItem("auth-token");if(!ie){console.error("No authentication token found for Shell WebSocket connection");return}je=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(ie)}`}g.current=new WebSocket(je),g.current.onopen=()=>{y(!0),m(!1),setTimeout(()=>{p.current&&h.current&&(p.current.fit(),g.current.send(JSON.stringify({type:"init",projectPath:j.current.fullPath||j.current.path,sessionId:F.current?null:w.current?.id,hasSession:F.current?!1:!!w.current,provider:F.current?"plain-shell":w.current?.__provider||"claude",cols:h.current.cols,rows:h.current.rows,initialCommand:L.current,isPlainShell:F.current})))},100)},g.current.onmessage=ie=>{try{const Z=JSON.parse(ie.data);if(Z.type==="output"){let we=Z.data;if(F.current&&O.current){const Me=we.replace(/\x1b\[[0-9;]*m/g,"");if(Me.includes("Process exited with code 0"))O.current(0);else if(Me.match(/Process exited with code (\d+)/)){const De=parseInt(Me.match(/Process exited with code (\d+)/)[1]);De!==0&&O.current(De)}}h.current&&h.current.write(we)}else Z.type==="url_open"&&window.open(Z.url,"_blank")}catch(Z){console.error("[Shell] Error handling WebSocket message:",Z,ie.data)}},g.current.onclose=ie=>{y(!1),m(!1),h.current&&(h.current.clear(),h.current.write("\x1B[2J\x1B[H"))},g.current.onerror=ie=>{y(!1),m(!1)}}catch{y(!1),m(!1)}},[u,k]),ce=r.useCallback(()=>{!v||k||u||(m(!0),se())},[v,k,u,se]),ae=r.useCallback(()=>{g.current&&(g.current.readyState===WebSocket.OPEN&&g.current.send(JSON.stringify({type:"terminate"})),g.current.close(),g.current=null),h.current&&(h.current.clear(),h.current.write("\x1B[2J\x1B[H")),y(!1),m(!1)},[]),oe=r.useMemo(()=>s?s.__provider==="cursor"?s.name||"Untitled Session":s.summary||"New Session":null,[s]),W=r.useMemo(()=>oe?oe.slice(0,30):null,[oe]),I=r.useMemo(()=>oe?oe.slice(0,50):null,[oe]),_=()=>{z(!0),g.current&&(g.current.readyState===WebSocket.OPEN&&g.current.send(JSON.stringify({type:"terminate"})),g.current.close(),g.current=null),h.current&&(h.current.dispose(),h.current=null,p.current=null),y(!1),x(!1),setTimeout(()=>{z(!1)},200)};return r.useEffect(()=>{const X=s?.id||null;T!==null&&T!==X&&v&&ae(),C(X)},[s?.id,v,ae]),r.useEffect(()=>{if(!d.current||!t||R||h.current)return;h.current=new es.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!1,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff",extendedAnsi:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"]}}),p.current=new ts.FitAddon;const X=new rs.WebglAddon,je=new ss.WebLinksAddon;h.current.loadAddon(p.current),h.current.loadAddon(je);try{h.current.loadAddon(X)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}h.current.open(d.current),h.current.attachCustomKeyEventHandler(Z=>(Z.ctrlKey||Z.metaKey)&&Z.key==="c"&&h.current.hasSelection()?(document.execCommand("copy"),!1):(Z.ctrlKey||Z.metaKey)&&Z.key==="v"?(navigator.clipboard.readText().then(we=>{g.current&&g.current.readyState===WebSocket.OPEN&&g.current.send(JSON.stringify({type:"input",data:we}))}).catch(()=>{}),!1):!0),setTimeout(()=>{p.current&&(p.current.fit(),h.current&&g.current&&g.current.readyState===WebSocket.OPEN&&g.current.send(JSON.stringify({type:"resize",cols:h.current.cols,rows:h.current.rows})))},100),x(!0),h.current.onData(Z=>{g.current&&g.current.readyState===WebSocket.OPEN&&g.current.send(JSON.stringify({type:"input",data:Z}))});const ie=new ResizeObserver(()=>{p.current&&h.current&&setTimeout(()=>{p.current.fit(),g.current&&g.current.readyState===WebSocket.OPEN&&g.current.send(JSON.stringify({type:"resize",cols:h.current.cols,rows:h.current.rows}))},50)});return d.current&&ie.observe(d.current),()=>{ie.disconnect(),g.current&&(g.current.readyState===WebSocket.OPEN||g.current.readyState===WebSocket.CONNECTING)&&g.current.close(),g.current=null,h.current&&(h.current.dispose(),h.current=null)}},[t?.path||t?.fullPath,R]),r.useEffect(()=>{!i||!v||u||k||ce()},[i,v,u,k,ce]),t?l?e.jsx("div",{className:"h-full w-full bg-gray-900",children:e.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}})}):e.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${k?"bg-green-500":"bg-red-500"}`}),s&&e.jsxs("span",{className:"text-xs text-blue-300",children:["(",W,"...)"]}),!s&&e.jsx("span",{className:"text-xs text-gray-400",children:"(新会话)"}),!v&&e.jsx("span",{className:"text-xs text-yellow-400",children:"(正在初始化...)"}),R&&e.jsx("span",{className:"text-xs text-blue-400",children:"(正在重启...)"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[k&&e.jsxs("button",{onClick:ae,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:"断开 Shell 连接",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{children:"断开连接"})]}),e.jsxs("button",{onClick:_,disabled:R||k,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:"重启 Shell(先断开连接)",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),e.jsx("span",{children:"重启"})]})]})]})}),e.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[e.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!v&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:e.jsx("div",{className:"text-white",children:"加载终端中..."})}),v&&!k&&!u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("button",{onClick:ce,className:"px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",title:"Connect to shell",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsx("span",{children:"在 Shell 中继续"})]}),e.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:o?`Run ${a||"command"} in ${t.displayName}`:s?`Resume session: ${I}...`:"Start a new Claude session"})]})}),u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),e.jsx("span",{className:"text-base font-medium",children:"连接到 Shell..."})]}),e.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:o?`Running ${a||"command"} in ${t.displayName}`:`Starting Claude CLI in ${t.displayName}`})]})})]})]}):e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"选择项目"}),e.jsx("p",{children:"选择一个项目以在该目录中打开交互式 Shell"})]})})}function si({project:t,session:s=null,command:a=null,isPlainShell:o=null,autoConnect:n=!0,onComplete:l=null,onClose:i=null,title:d=null,className:h="",showHeader:p=!0,compact:g=!1,minimal:k=!1}){const[y,v]=r.useState(!1),x=o!==null?o:a!==null,R=r.useCallback(z=>{v(!0),l&&l(z)},[l]);return t?e.jsxs("div",{className:`h-full w-full flex flex-col ${h}`,children:[!k&&p&&d&&e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-200",children:d}),y&&e.jsx("span",{className:"text-xs text-green-400",children:"(已完成)"})]}),i&&e.jsx("button",{onClick:i,className:"text-gray-400 hover:text-white",title:"关闭",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsx("div",{className:"flex-1 w-full min-h-0",children:e.jsx(ri,{selectedProject:t,selectedSession:s,initialCommand:a,isPlainShell:x,onProcessComplete:R,minimal:k,autoConnect:k?!0:n})})]}):e.jsx("div",{className:`h-full flex items-center justify-center ${h}`,children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"未选择项目"}),e.jsx("p",{children:"打开 Shell 需要一个项目"})]})})}function ai({selectedProject:t,minimal:s=!1,autoConnect:a=!1}){const o=r.useRef(null),n=r.useRef(null),l=r.useRef(null),i=r.useRef(null),[d,h]=r.useState(!1),[p,g]=r.useState(!1),[k,y]=r.useState(!1),[v,x]=r.useState(!1),R=r.useRef(t);r.useEffect(()=>{R.current=t});const z=r.useCallback(async()=>{if(!(v||d))try{let j;{const w=localStorage.getItem("auth-token");if(!w){console.error("No authentication token found for Codex WebSocket connection");return}j=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/codex?token=${encodeURIComponent(w)}`}i.current=new WebSocket(j),i.current.onopen=()=>{h(!0),x(!1),setTimeout(()=>{l.current&&n.current&&(l.current.fit(),i.current.send(JSON.stringify({type:"init",projectPath:R.current.fullPath||R.current.path,cols:n.current.cols,rows:n.current.rows})))},100)},i.current.onmessage=w=>{try{const L=JSON.parse(w.data);L.type==="output"?n.current&&n.current.write(L.data):L.type==="url_open"&&window.open(L.url,"_blank")}catch(L){console.error("[CodexShell] Error handling WebSocket message:",L)}},i.current.onclose=()=>{h(!1),x(!1),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H"))},i.current.onerror=()=>{h(!1),x(!1)}}catch{h(!1),x(!1)}},[v,d]),T=r.useCallback(()=>{!p||d||v||(x(!0),z())},[p,d,v,z]),C=r.useCallback(()=>{i.current&&(i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"terminate"})),i.current.close(),i.current=null),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H")),h(!1),x(!1)},[]),u=()=>{y(!0),i.current&&(i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"terminate"})),i.current.close(),i.current=null),n.current&&(n.current.dispose(),n.current=null,l.current=null),h(!1),g(!1),setTimeout(()=>y(!1),200)};return r.useEffect(()=>{if(!o.current||!t||k||n.current)return;n.current=new es.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!1,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff"}}),l.current=new ts.FitAddon;const m=new rs.WebglAddon,j=new ss.WebLinksAddon;n.current.loadAddon(l.current),n.current.loadAddon(j);try{n.current.loadAddon(m)}catch{console.warn("[CodexShell] WebGL renderer unavailable, using Canvas fallback")}n.current.open(o.current),n.current.attachCustomKeyEventHandler(L=>(L.ctrlKey||L.metaKey)&&L.key==="c"&&n.current.hasSelection()?(document.execCommand("copy"),!1):(L.ctrlKey||L.metaKey)&&L.key==="v"?(navigator.clipboard.readText().then(F=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:F}))}).catch(()=>{}),!1):!0),setTimeout(()=>{l.current&&(l.current.fit(),n.current&&i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows})))},100),g(!0),n.current.onData(L=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:L}))});const w=new ResizeObserver(()=>{l.current&&n.current&&setTimeout(()=>{l.current.fit(),i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows}))},50)});return o.current&&w.observe(o.current),()=>{w.disconnect(),i.current&&(i.current.readyState===WebSocket.OPEN||i.current.readyState===WebSocket.CONNECTING)&&i.current.close(),i.current=null,n.current&&(n.current.dispose(),n.current=null)}},[t?.path||t?.fullPath,k]),r.useEffect(()=>{!a||!p||v||d||T()},[a,p,v,d,T]),t?s?e.jsx("div",{className:"h-full w-full bg-gray-900",children:e.jsx("div",{ref:o,className:"h-full w-full focus:outline-none",style:{outline:"none"}})}):e.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${d?"bg-green-500":"bg-red-500"}`}),e.jsx("span",{className:"text-xs text-gray-300 font-medium",children:"Codex"}),!p&&e.jsx("span",{className:"text-xs text-yellow-400",children:"(正在初始化...)"}),k&&e.jsx("span",{className:"text-xs text-blue-400",children:"(正在重启...)"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[d&&e.jsxs("button",{onClick:C,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:"断开 Codex 连接",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{children:"断开连接"})]}),e.jsxs("button",{onClick:u,disabled:k||d,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:"重启 Codex(先断开连接)",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),e.jsx("span",{children:"重启"})]})]})]})}),e.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[e.jsx("div",{ref:o,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!p&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:e.jsx("div",{className:"text-white",children:"加载终端中..."})}),p&&!d&&!v&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("button",{onClick:T,className:"px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsx("span",{children:"启动 Codex"})]}),e.jsxs("p",{className:"text-gray-400 text-sm mt-3 px-2",children:["在 ",t.displayName," 中启动 Codex CLI"]})]})}),v&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),e.jsx("span",{className:"text-base font-medium",children:"连接到 Codex..."})]}),e.jsxs("p",{className:"text-gray-400 text-sm mt-3 px-2",children:["正在 ",t.displayName," 中启动 Codex CLI"]})]})})]})]}):e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"选择项目"}),e.jsx("p",{children:"选择一个项目以在该目录中打开 Codex"})]})})}function ni({project:t,autoConnect:s=!0,onClose:a=null,className:o="",showHeader:n=!0,minimal:l=!1}){return t?e.jsxs("div",{className:`h-full w-full flex flex-col ${o}`,children:[!l&&n&&a&&e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-200",children:"Codex"}),e.jsx("button",{onClick:a,className:"text-gray-400 hover:text-white",title:"关闭",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsx("div",{className:"flex-1 w-full min-h-0",children:e.jsx(ai,{selectedProject:t,minimal:l,autoConnect:l?!0:s})})]}):e.jsx("div",{className:`h-full flex items-center justify-center ${o}`,children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"未选择项目"}),e.jsx("p",{children:"打开 Codex 需要一个项目"})]})})}function oi({selectedProject:t,minimal:s=!1,autoConnect:a=!1}){const o=r.useRef(null),n=r.useRef(null),l=r.useRef(null),i=r.useRef(null),[d,h]=r.useState(!1),[p,g]=r.useState(!1),[k,y]=r.useState(!1),[v,x]=r.useState(!1),R=r.useRef(t);r.useEffect(()=>{R.current=t});const z=r.useCallback(async()=>{if(!(v||d))try{let j;{const w=localStorage.getItem("auth-token");if(!w){console.error("No authentication token found for Gemini WebSocket connection");return}j=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/gemini?token=${encodeURIComponent(w)}`}i.current=new WebSocket(j),i.current.onopen=()=>{h(!0),x(!1),setTimeout(()=>{l.current&&n.current&&(l.current.fit(),i.current.send(JSON.stringify({type:"init",projectPath:R.current.fullPath||R.current.path,cols:n.current.cols,rows:n.current.rows})))},100)},i.current.onmessage=w=>{try{const L=JSON.parse(w.data);L.type==="output"?n.current&&n.current.write(L.data):L.type==="url_open"&&window.open(L.url,"_blank")}catch(L){console.error("[GeminiShell] Error handling WebSocket message:",L)}},i.current.onclose=()=>{h(!1),x(!1),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H"))},i.current.onerror=()=>{h(!1),x(!1)}}catch{h(!1),x(!1)}},[v,d]),T=r.useCallback(()=>{!p||d||v||(x(!0),z())},[p,d,v,z]),C=r.useCallback(()=>{i.current&&(i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"terminate"})),i.current.close(),i.current=null),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H")),h(!1),x(!1)},[]),u=()=>{y(!0),i.current&&(i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"terminate"})),i.current.close(),i.current=null),n.current&&(n.current.dispose(),n.current=null,l.current=null),h(!1),g(!1),setTimeout(()=>y(!1),200)};return r.useEffect(()=>{if(!o.current||!t||k||n.current)return;n.current=new es.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!1,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff"}}),l.current=new ts.FitAddon;const m=new rs.WebglAddon,j=new ss.WebLinksAddon;n.current.loadAddon(l.current),n.current.loadAddon(j);try{n.current.loadAddon(m)}catch{console.warn("[GeminiShell] WebGL renderer unavailable, using Canvas fallback")}n.current.open(o.current),n.current.attachCustomKeyEventHandler(L=>(L.ctrlKey||L.metaKey)&&L.key==="c"&&n.current.hasSelection()?(document.execCommand("copy"),!1):(L.ctrlKey||L.metaKey)&&L.key==="v"?(navigator.clipboard.readText().then(F=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:F}))}).catch(()=>{}),!1):!0),setTimeout(()=>{l.current&&(l.current.fit(),n.current&&i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows})))},100),g(!0),n.current.onData(L=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:L}))});const w=new ResizeObserver(()=>{l.current&&n.current&&setTimeout(()=>{l.current.fit(),i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows}))},50)});return o.current&&w.observe(o.current),()=>{w.disconnect(),i.current&&(i.current.readyState===WebSocket.OPEN||i.current.readyState===WebSocket.CONNECTING)&&i.current.close(),i.current=null,n.current&&(n.current.dispose(),n.current=null)}},[t?.path||t?.fullPath,k]),r.useEffect(()=>{!a||!p||v||d||T()},[a,p,v,d,T]),t?s?e.jsx("div",{className:"h-full w-full bg-gray-900",children:e.jsx("div",{ref:o,className:"h-full w-full focus:outline-none",style:{outline:"none"}})}):e.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${d?"bg-green-500":"bg-red-500"}`}),e.jsx("span",{className:"text-xs text-gray-300 font-medium",children:"Gemini"}),!p&&e.jsx("span",{className:"text-xs text-yellow-400",children:"(正在初始化...)"}),k&&e.jsx("span",{className:"text-xs text-blue-400",children:"(正在重启...)"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[d&&e.jsxs("button",{onClick:C,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:"断开 Gemini 连接",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{children:"断开连接"})]}),e.jsxs("button",{onClick:u,disabled:k||d,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:"重启 Gemini(先断开连接)",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),e.jsx("span",{children:"重启"})]})]})]})}),e.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[e.jsx("div",{ref:o,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!p&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:e.jsx("div",{className:"text-white",children:"加载终端中..."})}),p&&!d&&!v&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("button",{onClick:T,className:"px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsx("span",{children:"启动 Gemini"})]}),e.jsxs("p",{className:"text-gray-400 text-sm mt-3 px-2",children:["在 ",t.displayName," 中启动 Gemini CLI"]})]})}),v&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),e.jsx("span",{className:"text-base font-medium",children:"连接到 Gemini..."})]}),e.jsxs("p",{className:"text-gray-400 text-sm mt-3 px-2",children:["正在 ",t.displayName," 中启动 Gemini CLI"]})]})})]})]}):e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"选择项目"}),e.jsx("p",{children:"选择一个项目以在该目录中打开 Gemini"})]})})}function ii({project:t,autoConnect:s=!0,onClose:a=null,className:o="",showHeader:n=!0,minimal:l=!1}){return t?e.jsxs("div",{className:`h-full w-full flex flex-col ${o}`,children:[!l&&n&&a&&e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-200",children:"Gemini"}),e.jsx("button",{onClick:a,className:"text-gray-400 hover:text-white",title:"关闭",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsx("div",{className:"flex-1 w-full min-h-0",children:e.jsx(oi,{selectedProject:t,minimal:l,autoConnect:l?!0:s})})]}):e.jsx("div",{className:`h-full flex items-center justify-center ${o}`,children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"未选择项目"}),e.jsx("p",{children:"打开 Gemini 需要一个项目"})]})})}class li extends tt.Component{constructor(s){super(s),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(s){return{hasError:!0}}componentDidCatch(s,a){console.error("ErrorBoundary caught an error:",s,a),this.setState({error:s,errorInfo:a})}render(){return this.state.hasError?e.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 max-w-md",children:[e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),e.jsx("h3",{className:"ml-3 text-sm font-medium text-red-800",children:"出现问题"})]}),e.jsxs("div",{className:"text-sm text-red-700",children:[e.jsx("p",{className:"mb-2",children:"加载聊天界面时出现错误。"}),this.props.showDetails&&this.state.error&&e.jsxs("details",{className:"mt-4",children:[e.jsx("summary",{className:"cursor-pointer text-xs font-mono",children:"错误详情"}),e.jsxs("pre",{className:"mt-2 text-xs bg-red-100 p-2 rounded overflow-auto max-h-40",children:[this.state.error.toString(),this.state.errorInfo&&this.state.errorInfo.componentStack]})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:()=>{this.setState({hasError:!1,error:null,errorInfo:null}),this.props.onRetry&&this.props.onRetry()},className:"bg-red-600 text-white px-4 py-2 rounded text-sm hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500",children:"重试"})})]})}):this.props.children}}const Zt=({children:t,content:s,position:a="top",className:o="",delay:n=500})=>{const[l,i]=r.useState(!1),[d,h]=r.useState(null),p=()=>{const v=setTimeout(()=>{i(!0)},n);h(v)},g=()=>{d&&(clearTimeout(d),h(null)),i(!1)},k=()=>{switch(a){case"top":return"bottom-full left-1/2 transform -translate-x-1/2 mb-2";case"bottom":return"top-full left-1/2 transform -translate-x-1/2 mt-2";case"left":return"right-full top-1/2 transform -translate-y-1/2 mr-2";case"right":return"left-full top-1/2 transform -translate-y-1/2 ml-2";default:return"bottom-full left-1/2 transform -translate-x-1/2 mb-2"}},y=()=>{switch(a){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}};return s?e.jsxs("div",{className:"relative inline-block",onMouseEnter:p,onMouseLeave:g,children:[t,l&&e.jsxs("div",{className:Be("absolute z-50 px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-nowrap pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",k(),o),children:[s,e.jsx("div",{className:Be("absolute w-0 h-0 border-4 border-transparent",y())})]})]}):t};function ci({selectedProject:t,selectedSession:s,activeTab:a,setActiveTab:o,ws:n,sendMessage:l,messages:i,isMobile:d,isPWA:h,onMenuClick:p,isLoading:g,onInputFocusChange:k,onSessionActive:y,onSessionInactive:v,onSessionProcessing:x,onSessionNotProcessing:R,processingSessions:z,onReplaceTemporarySession:T,onNavigateToSession:C,onShowSettings:u,autoExpandTools:m,showRawParameters:j,showThinking:w,autoScrollToBottom:L,sendByCtrlEnter:F,externalMessageUpdate:O,limitStatus:se,onLimitBlocked:ce,checkLimitStatus:ae}){const[oe,W]=r.useState(null),[I,_]=r.useState(600),[X,je]=r.useState(!1),[ie,Z]=r.useState(!1),we=r.useRef(null);r.useEffect(()=>{a==="shell"&&ae&&ae()},[a,ae]);const Me=(xe,Se=null)=>{const Re={name:xe.split("/").pop(),path:xe,projectName:t?.name,diffInfo:Se};W(Re)},De=()=>{W(null),Z(!1)},Ce=()=>{Z(!ie)},Oe=xe=>{d||(je(!0),xe.preventDefault())};return r.useEffect(()=>{const xe=Re=>{if(!X)return;const ze=we.current?.parentElement;if(!ze)return;const he=ze.getBoundingClientRect(),Le=he.right-Re.clientX,Te=300,_e=he.width*.8;Le>=Te&&Le<=_e&&_(Le)},Se=()=>{je(!1)};return X&&(document.addEventListener("mousemove",xe),document.addEventListener("mouseup",Se),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",xe),document.removeEventListener("mouseup",Se),document.body.style.cursor="",document.body.style.userSelect=""}},[X]),g?e.jsxs("div",{className:"h-full flex flex-col",children:[d&&e.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:e.jsx("button",{onClick:p,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 pwa-menu-button",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:e.jsx("div",{className:"w-full h-full rounded-full border-4 border-gray-200 border-t-blue-500",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"正在加载 AgentHub"}),e.jsx("p",{children:"正在设置您的工作区..."})]})})]}):t?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between relative",children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0 flex-1",children:[d&&e.jsx("button",{onClick:p,onTouchStart:xe=>{xe.preventDefault(),p()},className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 touch-manipulation active:scale-95 pwa-menu-button flex-shrink-0",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),e.jsxs("div",{className:"min-w-0 flex items-center gap-2 flex-1 overflow-x-auto scrollbar-hide",children:[a==="chat"&&s&&e.jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:e.jsx(dt,{className:"w-4 h-4"})}),e.jsx("div",{className:"min-w-0 flex-1",children:a==="chat"&&s?e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white whitespace-nowrap overflow-x-auto scrollbar-hide",children:s.summary||"新会话"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.displayName})]}):a==="chat"&&!s?e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:"新会话"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.displayName})]}):e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:a==="files"?"项目文件":"项目"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.displayName})]})})]})]}),e.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:e.jsxs("div",{className:"relative flex bg-gray-100 dark:bg-gray-800 rounded-lg p-1",children:[e.jsx(Zt,{content:"Chat",position:"bottom",children:e.jsx("button",{onClick:()=>o("chat"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md ${a==="chat"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[e.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Chat"})]})})}),e.jsx(Zt,{content:"Files",position:"bottom",children:e.jsx("button",{onClick:()=>o("files"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${a==="files"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[e.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Files"})]})})}),e.jsx(Zt,{content:se&&!se.allowed?"使用已达上限":"Claude Code",position:"bottom",children:e.jsx("button",{onClick:()=>{if(se&&!se.allowed){ce?.(se.reason);return}o("shell")},className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${se&&!se.allowed?"opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-500":a==="shell"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[e.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z",fill:"#D97757",fillRule:"nonzero"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Claude Code"})]})})}),e.jsx(Zt,{content:"Codex",position:"bottom",children:e.jsx("button",{onClick:()=>o("codex"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${a==="codex"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[e.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.797.797 0 00-.856 0l-5.97 3.473zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.433.433 0 01.476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737v6.898zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33L12 15.128zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482 4.482 0 014.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.432.432 0 01-.476 0zm-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71c.286.167.571.167.856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523zm5.899 2.83a5.947 5.947 0 005.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947-.642 0-1.26.095-1.88.31A5.962 5.962 0 0010.205 0a5.947 5.947 0 00-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 004.162 1.713z"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Codex"})]})})}),e.jsx(Zt,{content:"Gemini CLI",position:"bottom",children:e.jsx("button",{onClick:()=>o("gemini"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${a==="gemini"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[e.jsxs("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"#3186FF"}),e.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#gemini-tab-fill-0)"}),e.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#gemini-tab-fill-1)"}),e.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#gemini-tab-fill-2)"}),e.jsxs("defs",{children:[e.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"gemini-tab-fill-0",x1:"7",x2:"11",y1:"15.5",y2:"12",children:[e.jsx("stop",{stopColor:"#08B962"}),e.jsx("stop",{offset:"1",stopColor:"#08B962",stopOpacity:"0"})]}),e.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"gemini-tab-fill-1",x1:"8",x2:"11.5",y1:"5.5",y2:"11",children:[e.jsx("stop",{stopColor:"#F94543"}),e.jsx("stop",{offset:"1",stopColor:"#F94543",stopOpacity:"0"})]}),e.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"gemini-tab-fill-2",x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",children:[e.jsx("stop",{stopColor:"#FABC12"}),e.jsx("stop",{offset:".46",stopColor:"#FABC12",stopOpacity:"0"})]})]})]}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Gemini CLI"})]})})})]})})]})}),e.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[e.jsxs("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${oe?"mr-0":""} ${ie?"hidden":""}`,children:[e.jsx("div",{className:`h-full ${a==="chat"?"block":"hidden"}`,children:e.jsx(li,{showDetails:!0,children:e.jsx(Zo,{selectedProject:t,selectedSession:s,ws:n,sendMessage:l,messages:i,onFileOpen:Me,onInputFocusChange:k,onSessionActive:y,onSessionInactive:v,onSessionProcessing:x,onSessionNotProcessing:R,processingSessions:z,onReplaceTemporarySession:T,onNavigateToSession:C,onShowSettings:u,autoExpandTools:m,showRawParameters:j,showThinking:w,autoScrollToBottom:L,sendByCtrlEnter:F,externalMessageUpdate:O,limitStatus:se,onLimitExceeded:ce,checkLimitStatus:ae})})}),a==="files"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(ei,{selectedProject:t})}),a==="shell"&&e.jsxs("div",{className:"h-full w-full overflow-hidden relative",children:[e.jsx(si,{project:t,session:s,showHeader:!1}),se&&!se.allowed&&e.jsx("div",{className:"absolute inset-0 bg-black/60 z-50 flex items-center justify-center",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-xl p-6 mx-4 max-w-md text-center",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-4 bg-red-100 dark:bg-red-900/30 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-red-600 dark:text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:se.reason==="total_limit_exceeded"?"使用上限已达到":"今日使用上限已达到"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:se.reason==="total_limit_exceeded"?"您已达到使用上限,请联系管理员提升额度。":"您已达到今日使用上限,请明日再来或联系管理员提升额度。"}),e.jsx("button",{onClick:()=>o("chat"),className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",children:"返回 Chat"})]})})]}),a==="codex"&&e.jsx("div",{className:"h-full w-full overflow-hidden relative",children:e.jsx(ni,{project:t,showHeader:!1})}),a==="gemini"&&e.jsx("div",{className:"h-full w-full overflow-hidden relative",children:e.jsx(ii,{project:t,showHeader:!1})}),e.jsx("div",{className:`h-full overflow-hidden ${a==="preview"?"block":"hidden"}`})]}),oe&&!d&&e.jsxs(e.Fragment,{children:[!ie&&e.jsx("div",{ref:we,onMouseDown:Oe,className:"flex-shrink-0 w-1 bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 dark:hover:bg-blue-600 cursor-col-resize transition-colors relative group",title:"Drag to resize",children:e.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-blue-500 dark:bg-blue-600 opacity-0 group-hover:opacity-100 transition-opacity"})}),e.jsx("div",{className:`flex-shrink-0 border-l border-gray-200 dark:border-gray-700 h-full overflow-hidden ${ie?"flex-1":""}`,style:ie?{}:{width:`${I}px`},children:e.jsx(Gr,{file:oe,onClose:De,projectPath:t?.path,isSidebar:!0,isExpanded:ie,onToggleExpand:Ce})})]})]}),oe&&d&&e.jsx(Gr,{file:oe,onClose:De,projectPath:t?.path,isSidebar:!1})]}):e.jsxs("div",{className:"h-full flex flex-col",children:[d&&e.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:e.jsx("button",{onClick:p,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 pwa-menu-button",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 max-w-md mx-auto px-6",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-6 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})})}),e.jsx("h2",{className:"text-2xl font-semibold mb-3 text-gray-900 dark:text-white",children:"选择您的项目"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:"从侧边栏选择一个项目,开始与 Claude 进行编码。每个项目包含您的聊天会话和文件历史。"}),e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:e.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:["💡 ",e.jsx("strong",{children:"提示:"})," ",d?"点击上方菜单按钮访问项目":"点击侧边栏中的文件夹图标创建新项目"]})})]})})]})}const di=tt.memo(ci);function mi({activeTab:t,setActiveTab:s,isInputFocused:a}){const o=[{id:"chat",icon:hr,onClick:()=>s("chat")},{id:"shell",icon:gr,onClick:()=>s("shell")},{id:"files",icon:nt,onClick:()=>s("files")}];return e.jsx("div",{className:`fixed bottom-0 left-0 right-0 bg-background border-t border-border z-50 ios-bottom-safe transform transition-transform duration-300 ease-in-out shadow-lg ${a?"translate-y-full":"translate-y-0"}`,children:e.jsx("div",{className:"flex items-center justify-around py-1",children:o.map(n=>{const l=n.icon,i=t===n.id;return e.jsxs("button",{onClick:n.onClick,onTouchStart:d=>{d.preventDefault(),n.onClick()},className:`flex items-center justify-center p-2 rounded-lg min-h-[40px] min-w-[40px] relative touch-manipulation ${i?"text-blue-600 dark:text-blue-400":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,"aria-label":n.id,children:[e.jsx(l,{className:"w-5 h-5"}),i&&e.jsx("div",{className:"absolute top-0 left-1/2 transform -translate-x-1/2 w-6 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-full"})]},n.id)})})})}const ia=r.createContext(),as=()=>{const t=r.useContext(ia);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t},ui=({children:t})=>{const[s,a]=r.useState(()=>{const l=localStorage.getItem("theme");return l?l==="dark":window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1});r.useEffect(()=>{if(s){document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark");const l=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');l&&l.setAttribute("content","black-translucent");const i=document.querySelector('meta[name="theme-color"]');i&&i.setAttribute("content","#0c1117")}else{document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light");const l=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');l&&l.setAttribute("content","default");const i=document.querySelector('meta[name="theme-color"]');i&&i.setAttribute("content","#ffffff")}},[s]),r.useEffect(()=>{if(!window.matchMedia)return;const l=window.matchMedia("(prefers-color-scheme: dark)"),i=d=>{localStorage.getItem("theme")||a(d.matches)};return l.addEventListener("change",i),()=>l.removeEventListener("change",i)},[]);const n={isDarkMode:s,toggleDarkMode:()=>{a(l=>!l)}};return e.jsx(ia.Provider,{value:n,children:t})},la=r.createContext({user:null,token:null,login:()=>{},sendCode:()=>{},verifyCode:()=>{},logout:()=>{},isLoading:!0,needsSetup:!1,smtpConfigured:!1,error:null,isAdmin:!1,limitStatus:{allowed:!0},checkLimitStatus:()=>{},setLimitStatus:()=>{}}),Bt=()=>{const t=r.useContext(la);if(!t)throw new Error("useAuth must be used within an AuthProvider");return t};async function Pr(){try{const t=await ve.settings.getAgentPermissions();if(t.ok){const s=await t.json();s.agentPermissions&&localStorage.setItem("claude-settings",JSON.stringify(s.agentPermissions))}}catch{}}const pi=({children:t})=>{const[s,a]=r.useState(null),[o,n]=r.useState(localStorage.getItem("auth-token")),[l,i]=r.useState(!0),[d,h]=r.useState(!1),[p,g]=r.useState(!1),[k,y]=r.useState(null),[v,x]=r.useState({allowed:!0});r.useEffect(()=>{R()},[]);const R=async()=>{try{i(!0),y(null);const L=await(await ve.auth.status()).json();if(g(L.smtpConfigured||!1),L.needsSetup){h(!0),i(!1);return}if(o)try{const F=await ve.auth.user();if(F.ok){const O=await F.json();a(O.user),h(!1),await Pr()}else localStorage.removeItem("auth-token"),n(null),a(null)}catch(F){console.error("Token verification failed:",F),localStorage.removeItem("auth-token"),n(null),a(null)}}catch(w){console.error("[AuthContext] Auth status check failed:",w),y("Failed to check authentication status")}finally{i(!1)}},z=async w=>{try{y(null);const L=await ve.auth.sendCode(w),F=await L.json();return L.ok?{success:!0,type:F.type}:{success:!1,error:F.error||"发送验证码失败",waitSeconds:F.waitSeconds}}catch(L){return console.error("Send code error:",L),{success:!1,error:"网络错误,请稍后再试"}}},T=async(w,L)=>{try{y(null);const F=await ve.auth.verifyCode(w,L),O=await F.json();return F.ok?(n(O.token),a(O.user),h(!1),localStorage.setItem("auth-token",O.token),await Pr(),{success:!0}):(y(O.error||"验证失败"),{success:!1,error:O.error||"验证失败"})}catch(F){return console.error("Verify code error:",F),{success:!1,error:"网络错误,请稍后再试"}}},C=async(w,L)=>{try{y(null);const F=await ve.auth.login(w,L),O=await F.json();return F.ok?(n(O.token),a(O.user),localStorage.setItem("auth-token",O.token),await Pr(),{success:!0}):(y(O.error||"登录失败"),{success:!1,error:O.error||"登录失败"})}catch(F){console.error("Login error:",F);const O="网络错误,请稍后再试";return y(O),{success:!1,error:O}}},u=()=>{n(null),a(null),x({allowed:!0}),localStorage.removeItem("auth-token"),o&&ve.auth.logout().catch(w=>{console.error("Logout endpoint error:",w)})},m=async()=>{if(!s)return{allowed:!0};try{const w=await ve.auth.limitStatus();if(w.ok){const L=await w.json();return x(L),L}}catch(w){console.error("Error checking limit status:",w)}return{allowed:!0}};r.useEffect(()=>{s&&!l&&m()},[s,l]);const j={user:s,token:o,login:C,sendCode:z,verifyCode:T,logout:u,isLoading:l,needsSetup:d,smtpConfigured:p,error:k,isAdmin:s?.role==="admin",limitStatus:v,checkLimitStatus:m,setLimitStatus:x};return e.jsx(la.Provider,{value:j,children:t})},xi=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],hi=["Shell(ls)","Shell(mkdir)","Shell(cd)","Shell(cat)","Shell(echo)","Shell(git status)","Shell(git diff)","Shell(git log)","Shell(npm install)","Shell(npm run)","Shell(python)","Shell(node)"];function gi({skipPermissions:t,setSkipPermissions:s,allowedTools:a,setAllowedTools:o,disallowedTools:n,setDisallowedTools:l,newAllowedTool:i,setNewAllowedTool:d,newDisallowedTool:h,setNewDisallowedTool:p}){const g=x=>{x&&!a.includes(x)&&(o([...a,x]),d(""))},k=x=>{o(a.filter(R=>R!==x))},y=x=>{x&&!n.includes(x)&&(l([...n,x]),p(""))},v=x=>{l(n.filter(R=>R!==x))};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-sky-50 dark:bg-sky-900/20 border border-sky-200 dark:border-sky-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Js,{className:"w-5 h-5 text-sky-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-sky-800 dark:text-sky-200",children:[e.jsx("span",{className:"font-medium",children:"提示:"}),"此权限设置仅对 ",e.jsx("span",{className:"font-medium",children:"Chat(聊天)"})," 中的 Claude Agent 生效,对 ",e.jsx("span",{className:"font-medium",children:"Shell(终端)"})," 无效。Shell 是直接的系统终端,不受此权限控制。"]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ft,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"权限设置"})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>s(x.target.checked),className:"w-4 h-4 text-blue-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-blue-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:"跳过权限提示(请谨慎使用)"}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"等同于 --dangerously-skip-permissions 标志"})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fr,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"允许的工具"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自动允许而不提示权限的工具"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ve,{value:i,onChange:x=>d(x.target.value),placeholder:'e.g., "Bash(git log:*)" or "Write"',onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),g(i))},className:"flex-1 h-10"}),e.jsxs(K,{onClick:()=>g(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(ot,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:"添加"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"快速添加常用工具:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:xi.map(x=>e.jsx(K,{variant:"outline",size:"sm",onClick:()=>g(x),disabled:a.includes(x),className:"text-xs h-8",children:x},x))})]}),e.jsxs("div",{className:"space-y-2",children:[a.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:x}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k(x),className:"text-green-600 hover:text-green-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]},x)),a.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"未配置允许的工具"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ft,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"阻止的工具"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自动阻止而不提示权限的工具"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ve,{value:h,onChange:x=>p(x.target.value),placeholder:'e.g., "Bash(rm:*)"',onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),y(h))},className:"flex-1 h-10"}),e.jsxs(K,{onClick:()=>y(h),disabled:!h,size:"sm",className:"h-10 px-4",children:[e.jsx(ot,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:"添加"})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:x}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>v(x),className:"text-red-600 hover:text-red-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]},x)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"未配置阻止的工具"})]})]}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:"工具模式示例:"}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git log:*)"'})," - 允许所有 git log 命令"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git diff:*)"'})," - 允许所有 git diff 命令"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," - 允许所有 Write 工具使用"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," - 阻止所有 rm 命令(危险)"]})]})]})]})}function fi({skipPermissions:t,setSkipPermissions:s,allowedCommands:a,setAllowedCommands:o,disallowedCommands:n,setDisallowedCommands:l,newAllowedCommand:i,setNewAllowedCommand:d,newDisallowedCommand:h,setNewDisallowedCommand:p}){const g=x=>{x&&!a.includes(x)&&(o([...a,x]),d(""))},k=x=>{o(a.filter(R=>R!==x))},y=x=>{x&&!n.includes(x)&&(l([...n,x]),p(""))},v=x=>{l(n.filter(R=>R!==x))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ft,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"权限设置"})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>s(x.target.checked),className:"w-4 h-4 text-purple-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-purple-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:"跳过权限提示(请谨慎使用)"}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"等同于 Cursor CLI 中的 -f 标志"})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fr,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"允许的 Shell 命令"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自动允许而不提示的 Shell 命令"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ve,{value:i,onChange:x=>d(x.target.value),placeholder:'e.g., "Shell(ls)" or "Shell(git status)"',onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),g(i))},className:"flex-1 h-10"}),e.jsxs(K,{onClick:()=>g(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(ot,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:"添加"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"快速添加常用命令:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:hi.map(x=>e.jsx(K,{variant:"outline",size:"sm",onClick:()=>g(x),disabled:a.includes(x),className:"text-xs h-8",children:x},x))})]}),e.jsxs("div",{className:"space-y-2",children:[a.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:x}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k(x),className:"text-green-600 hover:text-green-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]},x)),a.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"未配置允许的命令"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ft,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"阻止的 Shell 命令"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自动阻止的 Shell 命令"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ve,{value:h,onChange:x=>p(x.target.value),placeholder:'e.g., "Shell(rm -rf)" or "Shell(sudo)"',onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),y(h))},className:"flex-1 h-10"}),e.jsxs(K,{onClick:()=>y(h),disabled:!h,size:"sm",className:"h-10 px-4",children:[e.jsx(ot,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:"添加"})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:x}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>v(x),className:"text-red-600 hover:text-red-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]},x)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"未配置阻止的命令"})]})]}),e.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:"Shell 命令示例:"}),e.jsxs("ul",{className:"text-sm text-purple-800 dark:text-purple-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(ls)"'})," - 允许 ls 命令"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(git status)"'})," - 允许 git status"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(npm install)"'})," - 允许 npm install"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(rm -rf)"'})," - 阻止递归删除"]})]})]})]})}function bi({permissionMode:t,setPermissionMode:s}){return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fr,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"权限模式"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"控制 Codex 如何处理文件修改和命令执行"}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="default"?"bg-gray-100 dark:bg-gray-800 border-gray-400 dark:border-gray-500":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>s("default"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="default",onChange:()=>s("default"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"默认"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"仅受信任的命令(ls、cat、grep、git status 等)会自动运行。其他命令将被跳过。可以写入工作区。"})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="acceptEdits"?"bg-green-50 dark:bg-green-900/20 border-green-400 dark:border-green-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>s("acceptEdits"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="acceptEdits",onChange:()=>s("acceptEdits"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:"接受编辑"}),e.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:"所有命令在工作区内自动运行。沙盒执行的完全自动模式。"})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/20 border-orange-400 dark:border-orange-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>s("bypassPermissions"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="bypassPermissions",onChange:()=>s("bypassPermissions"),className:"mt-1 w-4 h-4 text-orange-600"}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-orange-900 dark:text-orange-100 flex items-center gap-2",children:["跳过权限",e.jsx(Ft,{className:"w-4 h-4"})]}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"无限制的完全系统访问。所有命令自动运行,具有完全的磁盘和网络访问权限。请谨慎使用。"})]})]})}),e.jsxs("details",{className:"text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"技术详情"}),e.jsxs("div",{className:"mt-2 p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg text-xs text-muted-foreground space-y-2",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Default:"})," sandboxMode=workspace-write, approvalPolicy=untrusted. Trusted commands: cat, cd, grep, head, ls, pwd, tail, git status/log/diff/show, find (without -exec), etc."]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Accept Edits:"})," sandboxMode=workspace-write, approvalPolicy=never. All commands auto-execute within project directory."]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Bypass Permissions:"})," sandboxMode=danger-full-access, approvalPolicy=never. Full system access, use only in trusted environments."]}),e.jsx("p",{className:"text-xs opacity-75",children:"您可以在聊天界面中使用模式按钮为每个会话覆盖此设置。"})]})]})]})})}function yi({agent:t,...s}){return t==="claude"?e.jsx(gi,{...s}):t==="cursor"?e.jsx(fi,{...s}):t==="codex"?e.jsx(bi,{...s}):null}const vi=t=>{switch(t){case"stdio":return e.jsx(gr,{className:"w-4 h-4"});case"sse":return e.jsx(an,{className:"w-4 h-4"});case"http":return e.jsx($r,{className:"w-4 h-4"});default:return e.jsx(br,{className:"w-4 h-4"})}};function ji({servers:t,onAdd:s,onEdit:a,onDelete:o,onTest:n,onDiscoverTools:l,testResults:i,serverTools:d,toolsLoading:h}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(br,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP 服务器"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol 服务器为 Claude 提供额外的工具和数据源"}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(K,{onClick:s,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(ot,{className:"w-4 h-4 mr-2"}),"添加 MCP 服务器"]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(p=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[vi(p.type),e.jsx("span",{className:"font-medium text-foreground",children:p.name}),e.jsx(Ye,{variant:"outline",className:"text-xs",children:p.type}),e.jsx(Ye,{variant:"outline",className:"text-xs",children:p.scope==="local"?"local":p.scope==="user"?"user":p.scope})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[p.type==="stdio"&&p.config?.command&&e.jsxs("div",{children:["命令:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:p.config.command})]}),(p.type==="sse"||p.type==="http")&&p.config?.url&&e.jsxs("div",{children:["URL:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:p.config.url})]}),p.config?.args&&p.config.args.length>0&&e.jsxs("div",{children:["参数:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:p.config.args.join(" ")})]})]}),i?.[p.id]&&e.jsx("div",{className:`mt-2 p-2 rounded text-xs ${i[p.id].success?"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200":"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200"}`,children:e.jsx("div",{className:"font-medium",children:i[p.id].message})}),d?.[p.id]&&d[p.id].tools?.length>0&&e.jsxs("div",{className:"mt-2 p-2 rounded text-xs bg-blue-50 dark:bg-blue-900/20 text-blue-800 dark:text-blue-200",children:[e.jsxs("div",{className:"font-medium",children:["工具(",d[p.id].tools.length,"):"]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[d[p.id].tools.slice(0,5).map((g,k)=>e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:g.name},k)),d[p.id].tools.length>5&&e.jsxs("span",{className:"text-xs opacity-75",children:["+",d[p.id].tools.length-5," 更多"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(K,{onClick:()=>a(p),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"编辑服务器",children:e.jsx(Xt,{className:"w-4 h-4"})}),e.jsx(K,{onClick:()=>o(p.id,p.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"删除服务器",children:e.jsx(Ge,{className:"w-4 h-4"})})]})]})},p.id)),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"未配置 MCP 服务器"})]})]})}function wi({servers:t,onAdd:s,onEdit:a,onDelete:o}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(br,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP 服务器"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol 服务器为 Cursor 提供额外的工具和数据源"}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(K,{onClick:s,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(ot,{className:"w-4 h-4 mr-2"}),"添加 MCP 服务器"]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(n=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(gr,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:n.name}),e.jsx(Ye,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:n.config?.command&&e.jsxs("div",{children:["命令:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:n.config.command})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(K,{onClick:()=>a(n),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",children:e.jsx(Xt,{className:"w-4 h-4"})}),e.jsx(K,{onClick:()=>o(n.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",children:e.jsx(Ge,{className:"w-4 h-4"})})]})]})},n.name||n.id)),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"未配置 MCP 服务器"})]})]})}function ki({servers:t,onAdd:s,onEdit:a,onDelete:o}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(br,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP 服务器"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol 服务器为 Codex 提供额外的工具和数据源"}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(K,{onClick:s,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[e.jsx(ot,{className:"w-4 h-4 mr-2"}),"添加 MCP 服务器"]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(n=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(gr,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:n.name}),e.jsx(Ye,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[n.config?.command&&e.jsxs("div",{children:["命令:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:n.config.command})]}),n.config?.args&&n.config.args.length>0&&e.jsxs("div",{children:["参数:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:n.config.args.join(" ")})]}),n.config?.env&&Object.keys(n.config.env).length>0&&e.jsxs("div",{children:["环境变量:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:Object.entries(n.config.env).map(([l,i])=>`${l}=${i}`).join(", ")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(K,{onClick:()=>a(n),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"编辑服务器",children:e.jsx(Xt,{className:"w-4 h-4"})}),e.jsx(K,{onClick:()=>o(n.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"删除服务器",children:e.jsx(Ge,{className:"w-4 h-4"})})]})]})},n.name)),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"未配置 MCP 服务器"})]}),e.jsxs("div",{className:"bg-gray-100 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:"关于 Codex MCP"}),e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Codex 支持基于 stdio 的 MCP 服务器。您可以添加扩展 Codex 功能的服务器,提供额外的工具和资源。"})]})]})}function Ni({agent:t,...s}){return t==="claude"?e.jsx(ji,{...s}):t==="cursor"?e.jsx(wi,{...s}):t==="codex"?e.jsx(ki,{...s}):null}const Si=[{key:"ANTHROPIC_DEFAULT_OPUS_MODEL",label:"Opus 模型",placeholder:"例如: claude-opus-4-6",description:"覆盖 opus 别名使用的模型,Plan Mode 激活时也用于 opusplan"},{key:"ANTHROPIC_DEFAULT_SONNET_MODEL",label:"Sonnet 模型",placeholder:"例如: claude-sonnet-4-5-20250929",description:"覆盖 sonnet 别名使用的模型,Plan Mode 未激活时也用于 opusplan"},{key:"ANTHROPIC_DEFAULT_HAIKU_MODEL",label:"Haiku 模型",placeholder:"例如: claude-haiku-4-5-20251001",description:"覆盖 haiku 别名使用的模型,也用于后台功能"},{key:"CLAUDE_CODE_SUBAGENT_MODEL",label:"Subagent 模型",placeholder:"例如: claude-haiku-4-5-20251001",description:"覆盖子代理(subagents)使用的模型"}],Ci=r.forwardRef(function({onStatusChange:s},a){const[o,n]=r.useState({}),[l,i]=r.useState({}),[d,h]=r.useState(!0),[p,g]=r.useState(!1),[k,y]=r.useState(null),[v,x]=r.useState(null),R=JSON.stringify(o)!==JSON.stringify(l);r.useEffect(()=>{s?.({saving:p,hasChanges:R})},[p,R,s]),r.useEffect(()=>{z()},[]),r.useEffect(()=>{if(k){const u=setTimeout(()=>y(null),3e3);return()=>clearTimeout(u)}},[k]);const z=async()=>{try{h(!0),x(null);const u=await re("/api/settings/models");if(u.ok){const m=await u.json();n(m.models||{}),i(m.models||{})}else{const m=await u.json();x(m.error||"加载模型配置失败")}}catch(u){x(u.message)}finally{h(!1)}},T=async()=>{try{g(!0),y(null);const u=await re("/api/settings/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:o})});if(u.ok)return y("success"),i({...o}),!0;{const m=await u.json();return y("error"),x(m.error||"保存失败"),!1}}catch(u){return y("error"),x(u.message),!1}finally{g(!1)}},C=()=>{n({...l}),y(null)};return r.useImperativeHandle(a,()=>({save:T,reset:C,get hasChanges(){return R},get saving(){return p}}),[R,p,o,l]),d?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-500"}),e.jsx("span",{className:"ml-3 text-sm text-muted-foreground",children:"加载模型配置..."})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-3",children:[e.jsx(Js,{className:"w-4 h-4 text-blue-500 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-blue-700 dark:text-blue-300",children:[e.jsx("p",{children:"自定义模型 ID 来覆盖 Claude Code 使用的默认模型。留空表示使用默认模型。"}),e.jsx("p",{className:"mt-1 text-blue-600 dark:text-blue-400",children:"非 Claude 模型将按 Sonnet 定价计费,但统计中会记录实际模型 ID。"})]})]}),v&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3 text-sm text-red-600 dark:text-red-400",children:v}),k==="success"&&e.jsx("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3 text-sm text-green-600 dark:text-green-400",children:"模型配置已保存"}),Si.map(u=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"font-medium text-sm text-foreground",children:u.label}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:u.description})]}),e.jsx("input",{type:"text",value:o[u.key]||"",onChange:m=>n(j=>({...j,[u.key]:m.target.value})),placeholder:u.placeholder,className:"w-full text-sm bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 px-3 py-2"}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:u.key})]})},u.key))]})});function Ei({onNavigateToUsage:t}){const[s,a]=r.useState([]),[o,n]=r.useState({}),[l,i]=r.useState(!0),[d,h]=r.useState(null),[p,g]=r.useState(!1),[k,y]=r.useState(""),[v,x]=r.useState(""),[R,z]=r.useState(""),[T,C]=r.useState(!1),[u,m]=r.useState(null),[j,w]=r.useState({total_limit_usd:"",daily_limit_usd:""}),[L,F]=r.useState(""),[O,se]=r.useState(!1),[ce,ae]=r.useState(null),[oe,W]=r.useState(""),[I,_]=r.useState(""),[X,je]=r.useState(""),[ie,Z]=r.useState(!1),we=async()=>{try{const D=await re("/api/admin/users");if(D.ok){const $=await D.json();a($.users)}}catch(D){console.error("Error fetching users:",D)}finally{i(!1)}},Me=async()=>{try{const D=await re("/api/admin/usage/summary");if(D.ok){const $=await D.json(),A={};for(const f of $.users)A[f.user_uuid]={total_cost:f.total_cost||0,total_requests:f.total_requests||0,last_active:f.last_active};n(A)}}catch(D){console.error("Error fetching usage data:",D)}};r.useEffect(()=>{we(),Me()},[]);const De=D=>!D||D===0?"$0.00":D<.01?`$${D.toFixed(4)}`:`$${D.toFixed(2)}`,Ce=async(D,$)=>{const A=$==="active"?"disabled":"active";h(D);try{(await re(`/api/admin/users/${D}`,{method:"PATCH",body:JSON.stringify({status:A})})).ok&&a(s.map(H=>H.id===D?{...H,status:A}:H))}catch(f){console.error("Error updating user status:",f)}finally{h(null)}},Oe=async(D,$)=>{if(confirm(`确定要删除用户 "${$}"?这将删除其所有数据。`)){h(D);try{(await re(`/api/admin/users/${D}`,{method:"DELETE"})).ok&&a(s.filter(f=>f.id!==D))}catch(A){console.error("Error deleting user:",A)}finally{h(null)}}},xe=async D=>{if(D.preventDefault(),z(""),!k||!v){z("用户名和密码不能为空");return}if(k.length<3){z("用户名至少3个字符");return}if(v.length<6){z("密码至少6个字符");return}C(!0);try{const $=await ve.admin.createUser(k,v),A=await $.json();$.ok?(await we(),g(!1),y(""),x("")):z(A.error||"创建用户失败")}catch($){console.error("Error creating user:",$),z("网络错误,请稍后再试")}finally{C(!1)}},Se=()=>{g(!1),y(""),x(""),z("")},Re=D=>{m(D),w({total_limit_usd:D.total_limit_usd!==null&&D.total_limit_usd!==void 0?String(D.total_limit_usd):"",daily_limit_usd:D.daily_limit_usd!==null&&D.daily_limit_usd!==void 0?String(D.daily_limit_usd):""}),F("")},ze=()=>{m(null),w({total_limit_usd:"",daily_limit_usd:""}),F("")},he=async D=>{D.preventDefault(),F("");const $=j.total_limit_usd.trim()===""?null:parseFloat(j.total_limit_usd),A=j.daily_limit_usd.trim()===""?null:parseFloat(j.daily_limit_usd);if($!==null&&(isNaN($)||$<0)){F("总额度限制必须是正数或留空");return}if(A!==null&&(isNaN(A)||A<0)){F("每日额度限制必须是正数或留空");return}se(!0);try{const f=await ve.admin.updateUserLimits(u.id,{total_limit_usd:$,daily_limit_usd:A}),H=await f.json();f.ok?(a(s.map(de=>de.id===u.id?{...de,total_limit_usd:$,daily_limit_usd:A}:de)),ze()):F(H.error||"更新限制失败")}catch(f){console.error("Error updating limits:",f),F("网络错误,请稍后再试")}finally{se(!1)}},Le=D=>D==null?"无限制":`$${D.toFixed(2)}`,Te=D=>{ae(D),W(""),_(""),je("")},_e=()=>{ae(null),W(""),_(""),je("")},We=async D=>{if(D.preventDefault(),je(""),!oe){je("请输入新密码");return}if(oe.length<6){je("密码至少需要6个字符");return}if(oe!==I){je("两次输入的密码不一致");return}Z(!0);try{const $=await ve.admin.resetUserPassword(ce.id,oe),A=await $.json();$.ok?_e():je(A.error||"重置密码失败")}catch($){console.error("Error resetting password:",$),je("网络错误,请稍后再试")}finally{Z(!1)}};return l?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"正在加载用户..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"用户管理"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"default",size:"sm",onClick:()=>g(!0),className:"flex items-center gap-2",children:[e.jsx(nn,{className:"w-4 h-4"}),"创建用户"]}),t&&e.jsxs(K,{variant:"outline",size:"sm",onClick:t,className:"flex items-center gap-2",children:[e.jsx(on,{className:"w-4 h-4"}),"使用量统计"]})]})]}),e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[700px]",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-muted-foreground",children:"用户"}),e.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium text-muted-foreground w-16",children:"角色"}),e.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium text-muted-foreground w-16",children:"状态"}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium text-muted-foreground w-20",children:"费用"}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium text-muted-foreground w-28",children:"额度限制"}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-muted-foreground w-24",children:"创建时间"}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium text-muted-foreground w-20",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:s.map(D=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-900/30",children:[e.jsx("td",{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[D.role==="admin"?e.jsx(fr,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):e.jsx(Ks,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-foreground text-sm truncate",children:D.username||D.email}),D.email&&D.username&&e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:D.email})]})]})}),e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx("span",{className:`inline-block px-1.5 py-0.5 text-xs rounded whitespace-nowrap ${D.role==="admin"?"bg-blue-500/20 text-blue-400":"bg-gray-500/20 text-gray-400"}`,children:D.role==="admin"?"管理员":"用户"})}),e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${D.status==="active"?"bg-green-500":"bg-red-500"}`,title:D.status==="active"?"活跃":"已禁用"})}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsx("span",{className:"font-mono text-xs text-foreground whitespace-nowrap",children:De(o[D.uuid]?.total_cost)})}),e.jsx("td",{className:"px-3 py-2 text-right",children:D.role!=="admin"?e.jsx("button",{onClick:()=>Re(D),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline font-mono whitespace-nowrap",title:"点击编辑额度限制",children:D.total_limit_usd!==null||D.daily_limit_usd!==null?e.jsxs("span",{className:"flex flex-col items-end text-[11px] leading-tight",children:[e.jsxs("span",{children:["总:",Le(D.total_limit_usd)]}),e.jsxs("span",{children:["日:",Le(D.daily_limit_usd)]})]}):e.jsxs("span",{className:"flex items-center gap-1 justify-end",children:[e.jsx(Gs,{className:"w-3 h-3"}),"限额"]})}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"-"})}),e.jsx("td",{className:"px-3 py-2 text-xs text-muted-foreground whitespace-nowrap",children:new Date(D.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("div",{className:"flex items-center justify-end gap-1",children:D.role!=="admin"&&e.jsxs(e.Fragment,{children:[D.username&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>Te(D),disabled:d===D.id,title:"重置密码",children:e.jsx(_r,{className:"w-4 h-4 text-blue-500"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>Ce(D.id,D.status),disabled:d===D.id,title:D.status==="active"?"禁用用户":"启用用户",children:D.status==="active"?e.jsx(ln,{className:"w-4 h-4 text-orange-500"}):e.jsx(cn,{className:"w-4 h-4 text-green-500"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>Oe(D.id,D.username||D.email),disabled:d===D.id,title:"删除用户",children:e.jsx(Ge,{className:"w-4 h-4 text-red-500"})})]})})})]},D.id))})]})}),p&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg w-full max-w-md p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h4",{className:"text-lg font-semibold text-foreground",children:"创建用户"}),e.jsx("button",{onClick:Se,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:xe,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"newUsername",className:"block text-sm font-medium text-foreground mb-1",children:"用户名"}),e.jsx("input",{type:"text",id:"newUsername",value:k,onChange:D=>y(D.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入用户名",disabled:T})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"newPassword",className:"block text-sm font-medium text-foreground mb-1",children:"密码"}),e.jsx("input",{type:"password",id:"newPassword",value:v,onChange:D=>x(D.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入密码",disabled:T})]}),R&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:R})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:Se,disabled:T,children:"取消"}),e.jsx(K,{type:"submit",disabled:T,children:T?"创建中...":"创建"})]})]})]})}),u&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg w-full max-w-md p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h4",{className:"text-lg font-semibold text-foreground",children:["设置额度限制 - ",u.username||u.email]}),e.jsx("button",{onClick:ze,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:he,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"totalLimit",className:"block text-sm font-medium text-foreground mb-1",children:"总额度上限 (USD)"}),e.jsx("input",{type:"number",id:"totalLimit",step:"0.01",min:"0",value:j.total_limit_usd,onChange:D=>w($=>({...$,total_limit_usd:D.target.value})),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"留空表示不限制",disabled:O}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"用户累计使用金额达到此限制后,将无法继续使用"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"dailyLimit",className:"block text-sm font-medium text-foreground mb-1",children:"每日额度上限 (USD)"}),e.jsx("input",{type:"number",id:"dailyLimit",step:"0.01",min:"0",value:j.daily_limit_usd,onChange:D=>w($=>({...$,daily_limit_usd:D.target.value})),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"留空表示不限制",disabled:O}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"用户每日使用金额达到此限制后,需等待次日重置"})]}),o[u.uuid]&&e.jsx("div",{className:"p-3 bg-gray-100 dark:bg-gray-800 rounded-md",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["当前已使用:",e.jsx("span",{className:"font-mono text-foreground",children:De(o[u.uuid]?.total_cost)})]})}),L&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:L})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:ze,disabled:O,children:"取消"}),e.jsx(K,{type:"submit",disabled:O,children:O?"保存中...":"保存"})]})]})]})}),ce&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg w-full max-w-md p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h4",{className:"text-lg font-semibold text-foreground",children:["重置密码 - ",ce.username]}),e.jsx("button",{onClick:_e,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:We,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"resetNewPassword",className:"block text-sm font-medium text-foreground mb-1",children:"新密码"}),e.jsx("input",{type:"password",id:"resetNewPassword",value:oe,onChange:D=>W(D.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入新密码(至少6个字符)",disabled:ie})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"resetConfirmPassword",className:"block text-sm font-medium text-foreground mb-1",children:"确认新密码"}),e.jsx("input",{type:"password",id:"resetConfirmPassword",value:I,onChange:D=>_(D.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请再次输入新密码",disabled:ie})]}),X&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:X})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:_e,disabled:ie,children:"取消"}),e.jsx(K,{type:"submit",disabled:ie,children:ie?"重置中...":"重置密码"})]})]})]})})]})}function Mi(){const[t,s]=r.useState([]),[a,o]=r.useState(!0),[n,l]=r.useState(null),[i,d]=r.useState(!1),[h,p]=r.useState(""),[g,k]=r.useState(""),[y,v]=r.useState(!1),x=async()=>{try{const C=await ve.admin.getEmailDomains();if(C.ok){const u=await C.json();s(u.domains)}}catch(C){console.error("Error fetching email domains:",C)}finally{o(!1)}};r.useEffect(()=>{x()},[]);const R=async C=>{if(C.preventDefault(),k(""),!h){k("域名不能为空");return}if(!/^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(h)){k("域名格式无效,例如: example.com");return}v(!0);try{const m=await ve.admin.addEmailDomain(h.toLowerCase()),j=await m.json();m.ok?(await x(),d(!1),p("")):k(j.error||"添加域名失败")}catch(m){console.error("Error adding domain:",m),k("网络错误,请稍后再试")}finally{v(!1)}},z=async(C,u)=>{if(confirm(`确定要删除域名 "${u}"?删除后该域名的邮箱将无法注册。`)){l(C);try{(await ve.admin.removeEmailDomain(C)).ok&&s(t.filter(j=>j.id!==C))}catch(m){console.error("Error removing domain:",m)}finally{l(null)}}},T=()=>{d(!1),p(""),k("")};return a?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"正在加载..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"邮箱域名白名单"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t.length===0?"未设置白名单,所有邮箱域名均可注册":"只有白名单内的域名邮箱可以注册"})]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>d(!0),className:"flex items-center gap-2",children:[e.jsx(ot,{className:"w-4 h-4"}),"添加域名"]})]}),t.length>0?e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-sm font-medium text-muted-foreground",children:"域名"}),e.jsx("th",{className:"px-4 py-3 text-left text-sm font-medium text-muted-foreground",children:"添加时间"}),e.jsx("th",{className:"px-4 py-3 text-right text-sm font-medium text-muted-foreground",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:t.map(C=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-900/30",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"font-medium text-foreground",children:C.domain})]})}),e.jsx("td",{className:"px-4 py-3 text-sm text-muted-foreground",children:new Date(C.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>z(C.id,C.domain),disabled:n===C.id,title:"删除域名",children:e.jsx(Ge,{className:"w-4 h-4 text-red-500"})})})})]},C.id))})]})}):e.jsxs("div",{className:"border border-dashed border-gray-300 dark:border-gray-600 rounded-lg p-8 text-center",children:[e.jsx(mr,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"暂无域名白名单,所有邮箱域名均可注册"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"添加域名后,只有白名单内的域名邮箱可以注册"})]}),i&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg w-full max-w-md p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h4",{className:"text-lg font-semibold text-foreground",children:"添加域名"}),e.jsx("button",{onClick:T,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:R,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"newDomain",className:"block text-sm font-medium text-foreground mb-1",children:"邮箱域名"}),e.jsx("input",{type:"text",id:"newDomain",value:h,onChange:C=>p(C.target.value.toLowerCase()),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"例如: example.com",disabled:y}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"输入域名后,该域名下的所有邮箱(如 user@example.com)都可以注册"})]}),g&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:g})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:T,disabled:y,children:"取消"}),e.jsx(K,{type:"submit",disabled:y,children:y?"添加中...":"添加"})]})]})]})})]})}function Li(){const[t,s]=r.useState(""),[a,o]=r.useState(!0),[n,l]=r.useState(!1),[i,d]=r.useState(null);r.useEffect(()=>{h()},[]);const h=async()=>{try{const g=await ve.admin.getDefaultLimits();if(g.ok){const k=await g.json();s(k.default_total_limit_usd!==null?String(k.default_total_limit_usd):"")}}catch(g){console.error("Error fetching default limits:",g)}finally{o(!1)}},p=async g=>{g.preventDefault(),l(!0),d(null);const k=t.trim()===""?null:parseFloat(t);if(k!==null&&(isNaN(k)||k<0)){d("error"),l(!1);return}try{(await ve.admin.updateDefaultLimits({default_total_limit_usd:k})).ok?(d("success"),setTimeout(()=>d(null),2e3)):d("error")}catch(y){console.error("Error updating default limits:",y),d("error")}finally{l(!1)}};return a?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"正在加载..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"新用户默认额度"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"新注册用户将自动应用此总额度限制,留空表示不限制。管理员账户不受此限制。"})]}),e.jsxs("form",{onSubmit:p,className:"flex items-end gap-3",children:[e.jsxs("div",{className:"flex-1 max-w-xs",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-1",children:"默认总额度上限 (USD)"}),e.jsx("input",{type:"number",step:"0.01",min:"0",value:t,onChange:g=>s(g.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"留空表示不限制",disabled:n})]}),e.jsxs(K,{type:"submit",variant:"default",size:"sm",disabled:n,className:"flex items-center gap-2",children:[e.jsx(Bs,{className:"w-4 h-4"}),n?"保存中...":"保存"]}),i==="success"&&e.jsx("span",{className:"text-sm text-green-600",children:"已保存"}),i==="error"&&e.jsx("span",{className:"text-sm text-red-600",children:"请输入有效的正数"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"此设置仅影响新注册的用户,不会修改已有用户的额度。"})]})}function Ii({onBack:t}){const[s,a]=r.useState("week"),[o,n]=r.useState(null),[l,i]=r.useState(!0),[d,h]=r.useState(!1),p=async()=>{try{const T=await re(`/api/admin/usage/dashboard?period=${s}`);if(T.ok){const C=await T.json();n(C)}}catch(T){console.error("Error fetching dashboard data:",T)}finally{i(!1),h(!1)}};r.useEffect(()=>{i(!0),p()},[s]);const g=async()=>{try{h(!0),await re("/api/admin/usage/scan",{method:"POST"}),await p()}catch(T){console.error("Error triggering scan:",T),h(!1)}},k=T=>!T||T===0?"$0.00":T<.01?`$${T.toFixed(4)}`:`$${T.toFixed(2)}`,y=T=>T?T>=1e6?`${(T/1e6).toFixed(1)}M`:T>=1e3?`${(T/1e3).toFixed(1)}K`:T.toString():"0";if(l)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"text-muted-foreground",children:"加载仪表板中..."})});const{totals:v,dailyTrend:x,modelDistribution:R,topUsers:z}=o||{};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[t&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:t,children:[e.jsx(yr,{className:"w-4 h-4 mr-2"}),"返回"]}),e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"使用情况仪表板"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:["week","month"].map(T=>e.jsx("button",{onClick:()=>a(T),className:`px-4 py-2 text-sm font-medium transition-colors ${s===T?"bg-primary text-primary-foreground":"bg-background text-foreground hover:bg-muted"}`,children:T==="week"?"周":"月"},T))}),e.jsx(K,{variant:"outline",size:"sm",onClick:g,disabled:d,title:"扫描新的使用数据",children:e.jsx(_t,{className:`w-4 h-4 ${d?"animate-spin":""}`})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-green-100 dark:bg-green-900/30 rounded-lg",children:e.jsx(Gs,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"总成本"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:k(v?.totalCost)})]})]})}),e.jsx("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-blue-100 dark:bg-blue-900/30 rounded-lg",children:e.jsx(dn,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"活跃用户"}),e.jsxs("p",{className:"text-2xl font-bold text-foreground",children:[v?.activeUsers||0," / ",v?.totalUsers||0]})]})]})}),e.jsx("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-purple-100 dark:bg-purple-900/30 rounded-lg",children:e.jsx(hr,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"总请求数"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:y(v?.totalRequests)})]})]})}),e.jsx("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-orange-100 dark:bg-orange-900/30 rounded-lg",children:e.jsx(mn,{className:"w-5 h-5 text-orange-600 dark:text-orange-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"会话数"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:y(v?.totalSessions)})]})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"每日成本趋势"}),x&&x.length>0?e.jsx("div",{className:"space-y-2",children:x.map(T=>{const C=Math.max(...x.map(m=>m.cost||0),.01),u=(T.cost||0)/C*100;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground w-20 shrink-0",children:new Date(T.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}),e.jsx("div",{className:"flex-1 h-6 bg-gray-100 dark:bg-gray-800 rounded overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-600 rounded",style:{width:`${u}%`}})}),e.jsx("span",{className:"text-sm font-mono text-foreground w-16 text-right",children:k(T.cost)})]},T.date)})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"无可用的使用数据"})]}),e.jsxs("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"模型成本"}),R&&R.length>0?e.jsx("div",{className:"space-y-3",children:R.map(T=>{const C=R.reduce((L,F)=>L+(F.cost||0),0)||1,u=(T.cost||0)/C*100,m=(T.normalized_model||T.model||"").toLowerCase(),w=(L=>L.includes("codex")?"bg-orange-500":L.includes("opus")?"bg-purple-500":L.includes("sonnet")?"bg-blue-500":L.includes("haiku")?"bg-green-500":"bg-gray-500")(m);return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Ye,{variant:"secondary",className:"truncate max-w-[200px]",title:T.model,children:T.model}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[y(T.requests)," 请求"]})]}),e.jsx("span",{className:"text-sm font-mono text-foreground whitespace-nowrap ml-2",children:k(T.cost)})]}),e.jsx("div",{className:"h-2 bg-gray-100 dark:bg-gray-800 rounded overflow-hidden",children:e.jsx("div",{className:`h-full ${w} rounded`,style:{width:`${u}%`}})})]},T.model)})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"无可用的使用数据"})]})]}),e.jsxs("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"用户成本"}),z&&z.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[e.jsx("th",{className:"text-left py-2 text-sm font-medium text-muted-foreground",children:"排名"}),e.jsx("th",{className:"text-left py-2 text-sm font-medium text-muted-foreground",children:"用户名"}),e.jsx("th",{className:"text-right py-2 text-sm font-medium text-muted-foreground",children:"请求数"}),e.jsx("th",{className:"text-right py-2 text-sm font-medium text-muted-foreground",children:"成本"})]})}),e.jsx("tbody",{children:z.map((T,C)=>e.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-800 last:border-0",children:[e.jsxs("td",{className:"py-2 text-sm text-muted-foreground",children:["#",C+1]}),e.jsx("td",{className:"py-2 text-sm font-medium text-foreground",children:T.username}),e.jsx("td",{className:"py-2 text-sm text-right text-muted-foreground",children:y(T.total_requests)}),e.jsx("td",{className:"py-2 text-sm text-right font-mono text-foreground",children:k(T.total_cost)})]},T.user_uuid))})]})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"无可用的使用数据"})]})]})}function Di({onClose:t,onInstalled:s,onOpenRepoManager:a}){const[o,n]=r.useState([]),[l,i]=r.useState([]),[d,h]=r.useState(!0),[p,g]=r.useState(null),[k,y]=r.useState(""),[v,x]=r.useState("all"),[R,z]=r.useState(null);r.useEffect(()=>{T()},[]);const T=async(m=!1)=>{try{h(!0),g(null),m&&await re("/api/skills/repos/refresh",{method:"POST"});const[j,w]=await Promise.all([re("/api/skills/available"),re("/api/skills/repos")]);if(j.ok){const L=await j.json();n(L.skills||[])}if(w.ok){const L=await w.json();i(L.repos||[])}}catch(j){g(j.message)}finally{h(!1)}},C=async m=>{try{z(m.name);const j=await re(`/api/skills/install/${m.name}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({skillPath:m.path})});if(j.ok)T(),s?.();else{const w=await j.json();alert(w.error||"Failed to install skill")}}catch(j){alert(j.message)}finally{z(null)}},u=o.filter(m=>{if(k){const j=k.toLowerCase();if(!m.name.toLowerCase().includes(j)&&!m.title?.toLowerCase().includes(j)&&!m.description?.toLowerCase().includes(j))return!1}return!(v!=="all"&&m.repository!==v)});return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-background rounded-xl shadow-xl w-full max-w-4xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Skills 管理"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>T(!0),disabled:d,children:[e.jsx(_t,{className:`w-4 h-4 ${d?"animate-spin":""}`}),e.jsx("span",{className:"ml-1 hidden sm:inline",children:"刷新"})]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:a,children:[e.jsx(Ot,{className:"w-4 h-4"}),e.jsx("span",{className:"ml-1 hidden sm:inline",children:"仓库管理"})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:t,children:e.jsx(Ue,{className:"w-5 h-5"})})]})]}),e.jsx("div",{className:"px-4 pt-4 pb-2",children:e.jsx("h3",{className:"text-amber-500 font-medium",children:"发现技能"})}),e.jsxs("div",{className:"px-4 pb-4 flex flex-wrap gap-3",children:[e.jsx("div",{className:"flex-1 min-w-[200px]",children:e.jsxs("div",{className:"relative",children:[e.jsx(At,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Ve,{type:"text",placeholder:"搜索技能名称或描述...",value:k,onChange:m=>y(m.target.value),className:"pl-10"})]})}),e.jsxs("select",{value:v,onChange:m=>x(m.target.value),className:"px-3 py-2 rounded-md border border-border bg-background text-foreground text-sm min-w-[120px]",children:[e.jsx("option",{value:"all",children:"全部"}),l.map(m=>e.jsxs("option",{value:`${m.owner}/${m.repo}`,children:[m.owner,"/",m.repo]},`${m.owner}/${m.repo}`))]})]}),e.jsxs("div",{className:"flex-1 overflow-auto px-4 pb-4",children:[p&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 text-red-800 dark:text-red-200 text-sm mb-4",children:p}),d?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):u.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:o.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"没有可用的技能"}),e.jsx("p",{className:"text-xs mt-2",children:"请先添加技能仓库"}),e.jsxs(K,{variant:"outline",size:"sm",className:"mt-4",onClick:a,children:[e.jsx(Ot,{className:"w-4 h-4 mr-2"}),"管理仓库"]})]}):e.jsx("p",{children:"没有找到匹配的技能"})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:u.map(m=>e.jsx("div",{className:"border border-border rounded-lg p-4 hover:border-amber-500/50 transition-colors",children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h4",{className:"font-medium text-foreground",children:m.title||m.name}),e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["skills/",m.name]}),e.jsx(Ye,{variant:"outline",className:"text-xs ml-2",children:m.repository})]})]}),m.description&&e.jsx("p",{className:"text-sm text-muted-foreground flex-1 line-clamp-3 mb-3",children:m.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-auto pt-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>window.open(`https://github.com/${m.repository}`,"_blank"),children:[e.jsx(Vs,{className:"w-4 h-4 mr-1"}),"查看"]}),m.installed?e.jsx(K,{size:"sm",disabled:!0,variant:"outline",className:"ml-auto",children:"已安装"}):e.jsxs(K,{size:"sm",className:"bg-amber-600 hover:bg-amber-700 text-white ml-auto",onClick:()=>C(m),disabled:R===m.name,children:[e.jsx($t,{className:"w-4 h-4 mr-1"}),R===m.name?"安装中...":"安装"]})]})]})},`${m.repository}-${m.name}`))})]})]})})}function Ti({onClose:t,onChanged:s}){const[a,o]=r.useState([]),[n,l]=r.useState(!0),[i,d]=r.useState(null),[h,p]=r.useState(""),[g,k]=r.useState("main"),[y,v]=r.useState(!1),[x,R]=r.useState(null);r.useEffect(()=>{z()},[]);const z=async()=>{try{l(!0),d(null);const u=await re("/api/skills/repos");if(u.ok){const m=await u.json();o(m.repos||[])}else{const m=await u.json();d(m.error||"Failed to fetch repos")}}catch(u){d(u.message)}finally{l(!1)}},T=async u=>{if(u.preventDefault(),!h.trim()){d("请输入仓库 URL");return}try{v(!0),d(null);const m=await re("/api/skills/repos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:h.trim(),branch:g.trim()||"main"})});if(m.ok)p(""),k("main"),z(),s?.();else{const j=await m.json();d(j.error||"Failed to add repo")}}catch(m){d(m.message)}finally{v(!1)}},C=async(u,m)=>{if(confirm(`确定要移除仓库 "${u}/${m}" 吗?`))try{R(`${u}/${m}`);const j=await re(`/api/skills/repos/${u}/${m}`,{method:"DELETE"});if(j.ok)z(),s?.();else{const w=await j.json();alert(w.error||"Failed to remove repo")}}catch(j){alert(j.message)}finally{R(null)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-background rounded-xl shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 border-b border-border",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:t,children:e.jsx(yr,{className:"w-5 h-5"})}),e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"管理技能仓库"})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-6",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 space-y-4",children:[e.jsx("h3",{className:"font-medium text-foreground",children:"添加技能仓库"}),e.jsxs("form",{onSubmit:T,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-muted-foreground mb-1",children:"仓库 URL"}),e.jsx(Ve,{type:"text",placeholder:"owner/name 或 https://github.com/owner/name",value:h,onChange:u=>p(u.target.value),disabled:y})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-muted-foreground mb-1",children:"分支"}),e.jsx(Ve,{type:"text",placeholder:"main",value:g,onChange:u=>k(u.target.value),disabled:y})]}),e.jsxs(K,{type:"submit",disabled:y||!h.trim(),className:"bg-amber-600 hover:bg-amber-700 text-white",children:[e.jsx(ot,{className:"w-4 h-4 mr-2"}),y?"添加中...":"添加仓库"]})]})]}),i&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 text-red-800 dark:text-red-200 text-sm",children:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"font-medium text-foreground",children:"已添加的仓库"}),n?e.jsx("div",{className:"text-center py-4 text-muted-foreground",children:"加载中..."}):a.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(un,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"还没有添加任何仓库"})]}):a.map(u=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:"font-medium text-foreground",children:[u.owner,"/",u.repo]})}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pn,{className:"w-3 h-3"}),"分支: main"]}),e.jsxs(Ye,{variant:"outline",className:"text-xs",children:["识别到 ",u.skillCount," 个技能"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>window.open(u.url,"_blank"),children:e.jsx(Vs,{className:"w-4 h-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>C(u.owner,u.repo),disabled:x===`${u.owner}/${u.repo}`,className:"text-red-500 hover:text-red-600",children:e.jsx(Ge,{className:"w-4 h-4"})})]})]})},`${u.owner}/${u.repo}`))]})]})]})})}function Pi(){const[t,s]=r.useState([]),[a,o]=r.useState(!0),[n,l]=r.useState(null),[i,d]=r.useState(!1),[h,p]=r.useState(!1),[g,k]=r.useState(!1),y=r.useRef(null);r.useEffect(()=>{v()},[]);const v=async()=>{try{o(!0),l(null);const C=await re("/api/skills");if(C.ok){const u=await C.json();s(u.skills||[])}else{const u=await C.json();l(u.error||"Failed to fetch skills")}}catch(C){l(C.message)}finally{o(!1)}},x=async C=>{if(confirm(`确定要删除技能 "${C}" 吗?`))try{const u=await re(`/api/skills/${C}`,{method:"DELETE"});if(u.ok)v();else{const m=await u.json();alert(m.error||"Failed to delete skill")}}catch(u){alert(u.message)}},R=()=>{y.current?.click()},z=async C=>{const u=C.target.files?.[0];if(u)try{k(!0);const m=new FormData;m.append("skillZip",u);const j=await re("/api/skills/import",{method:"POST",body:m});if(j.ok)v();else{const w=await j.json();alert(w.error||"Failed to import skill")}}catch(m){alert(m.message)}finally{k(!1),y.current&&(y.current.value="")}},T=(C,u)=>{switch(C){case"repo":return e.jsx(Ye,{variant:"outline",className:"text-xs bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300",children:u||"仓库"});case"imported":return e.jsx(Ye,{variant:"outline",className:"text-xs bg-purple-50 dark:bg-purple-900/20 text-purple-700 dark:text-purple-300",children:"导入"});default:return e.jsx(Ye,{variant:"outline",className:"text-xs",children:"本地"})}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ar,{className:"w-5 h-5 text-amber-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Skills 管理"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Skills 是 Claude Code 的扩展能力,可以通过 SKILLS.md 文件定义自定义指令和工作流程"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["已安装:Claude: ",e.jsx("span",{className:"font-medium text-foreground",children:t.length})," 个技能"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("input",{ref:y,type:"file",accept:".zip",className:"hidden",onChange:z}),e.jsxs(K,{onClick:R,variant:"outline",size:"sm",disabled:g,children:[e.jsx($t,{className:"w-4 h-4 mr-2"}),g?"导入中...":"导入已有"]}),e.jsxs(K,{onClick:()=>d(!0),className:"bg-amber-600 hover:bg-amber-700 text-white",size:"sm",children:[e.jsx(At,{className:"w-4 h-4 mr-2"}),"发现技能"]})]})]}),n&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 text-red-800 dark:text-red-200 text-sm",children:n}),e.jsx("div",{className:"space-y-2",children:a?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):t.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ar,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"还没有安装任何技能"}),e.jsx("p",{className:"text-xs mt-2",children:'点击"发现技能"从仓库安装,或"导入已有"上传本地技能'})]}):t.map(C=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsx("span",{className:"font-medium text-foreground",children:C.title||C.name}),T(C.source,C.repository)]}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:C.description})]}),e.jsx("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>x(C.name),className:"text-red-500 hover:text-red-600",title:"删除技能",children:e.jsx(Ge,{className:"w-4 h-4"})})})]})},C.name))}),i&&e.jsx(Di,{onClose:()=>d(!1),onInstalled:v,onOpenRepoManager:()=>{d(!1),p(!0)}}),h&&e.jsx(Ti,{onClose:()=>p(!1),onChanged:()=>{}})]})}function Ri({isOpen:t,onClose:s,projects:a=[],initialTab:o="agents"}){const n=Os(),{isDarkMode:l,toggleDarkMode:i}=as(),{user:d,logout:h}=Bt(),p=d?.role==="admin",[g,k]=r.useState([]),[y,v]=r.useState([]),[x,R]=r.useState(""),[z,T]=r.useState(""),[C,u]=r.useState(!1),[m,j]=r.useState(!1),[w,L]=r.useState(null),[F,O]=r.useState("name"),[se,ce]=r.useState([]),[ae,oe]=r.useState(!1),[W,I]=r.useState(null),[_,X]=r.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[je,ie]=r.useState(!1),[Z,we]=r.useState({}),[Me,De]=r.useState({}),[Ce,Oe]=r.useState({}),[xe,Se]=r.useState(o),[Re,ze]=r.useState(""),[he,Le]=r.useState("permissions"),[Te,_e]=r.useState(!1),We=r.useRef(null),[D,$]=r.useState({saving:!1,hasChanges:!1}),A=r.useCallback(E=>$(E),[]),[f,H]=r.useState(""),[de,Ee]=r.useState(""),[Ae,rt]=r.useState(""),[G,ee]=r.useState(""),[b,Q]=r.useState(""),[B,ue]=r.useState(!1),[J,ye]=r.useState(""),[V,pe]=r.useState(!1),[le,fe]=r.useState(""),[ke,ge]=r.useState(!1),[be,He]=r.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[mt,st]=r.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[ut,kt]=r.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[ft,vr]=r.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[Qe,jr]=r.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),bt=async()=>{try{const E=await re("/api/mcp/config/read");if(E.ok){const Ie=await E.json();if(Ie.success&&Ie.servers){ce(Ie.servers);return}}const U=await re("/api/mcp/cli/list");if(U.ok){const Ie=await U.json();if(Ie.success&&Ie.servers){const Xe=Ie.servers.map(et=>({id:et.name,name:et.name,type:et.type,scope:"user",config:{command:et.command||"",args:et.args||[],env:et.env||{},url:et.url||"",headers:et.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));ce(Xe);return}}const te=await re("/api/mcp/servers?scope=user");if(te.ok){const Ie=await te.json();ce(Ie.servers||[])}else console.error("Failed to fetch MCP servers")}catch(E){console.error("Error fetching MCP servers:",E)}},Ut=async E=>{try{W&&await Ht(W.id,"user");const U=await re("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:E.name,type:E.type,scope:E.scope,projectPath:E.projectPath,command:E.config?.command,args:E.config?.args||[],url:E.config?.url,headers:E.config?.headers||{},env:E.config?.env||{}})});if(U.ok){const te=await U.json();if(te.success)return await bt(),!0;throw new Error(te.error||"Failed to save server via Claude CLI")}else{const te=await U.json();throw new Error(te.error||"Failed to save server")}}catch(U){throw console.error("Error saving MCP server:",U),U}},Ht=async(E,U="user")=>{try{const te=await re(`/api/mcp/cli/remove/${E}?scope=${U}`,{method:"DELETE"});if(te.ok){const Ie=await te.json();if(Ie.success)return await bt(),!0;throw new Error(Ie.error||"Failed to delete server via Claude CLI")}else{const Ie=await te.json();throw new Error(Ie.error||"Failed to delete server")}}catch(te){throw console.error("Error deleting MCP server:",te),te}},Lt=async(E,U="user")=>{try{const te=await re(`/api/mcp/servers/${E}/test?scope=${U}`,{method:"POST"});if(te.ok)return(await te.json()).testResult;{const Ie=await te.json();throw new Error(Ie.error||"Failed to test server")}}catch(te){throw console.error("Error testing MCP server:",te),te}},tr=async(E,U="user")=>{try{const te=await re(`/api/mcp/servers/${E}/tools?scope=${U}`,{method:"POST"});if(te.ok)return(await te.json()).toolsResult;{const Ie=await te.json();throw new Error(Ie.error||"Failed to discover tools")}}catch(te){throw console.error("Error discovering MCP tools:",te),te}};r.useEffect(()=>{t&&(It(),Se(o),_e(!1))},[t,o]),r.useEffect(()=>{localStorage.setItem("codeEditorTheme",be),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[be]),r.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",mt.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[mt]),r.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",ut.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ut]),r.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",ft.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ft]),r.useEffect(()=>{localStorage.setItem("codeEditorFontSize",Qe),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Qe]);const It=async()=>{try{let E=null;try{const U=await ve.settings.getAgentPermissions();U.ok&&(E=(await U.json()).agentPermissions)}catch{}if(E)k(E.allowedTools||[]),v(E.disallowedTools||[]),u(E.skipPermissions||!1),O(E.projectSortOrder||"name"),localStorage.setItem("claude-settings",JSON.stringify(E));else{const U=localStorage.getItem("claude-settings");if(U){const te=JSON.parse(U);k(te.allowedTools||[]),v(te.disallowedTools||[]),u(te.skipPermissions||!1),O(te.projectSortOrder||"name")}else k([]),v([]),u(!1),O("name")}await bt()}catch(E){console.error("Error loading tool settings:",E),k([]),v([]),u(!1),O("name")}},wr=async()=>{j(!0),L(null);try{const E={allowedTools:g,disallowedTools:y,skipPermissions:C,projectSortOrder:F,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(E));try{await ve.settings.saveAgentPermissions(E)}catch(U){console.warn("Failed to sync agent permissions to server:",U)}L("success"),setTimeout(()=>{s()},1e3)}catch(E){console.error("Error saving tool settings:",E),L("error")}finally{j(!1)}},at=async E=>{if(E.preventDefault(),ee(""),Q(""),!f){ee("请输入当前密码");return}if(!de){ee("请输入新密码");return}if(de.length<6){ee("新密码至少需要6个字符");return}if(de!==Ae){ee("两次输入的新密码不一致");return}ue(!0);try{const U=await ve.auth.changePassword(f,de),te=await U.json();U.ok?(Q("密码修改成功"),H(""),Ee(""),rt("")):ee(te.error||"修改密码失败")}catch(U){console.error("Error changing password:",U),ee("网络错误,请稍后再试")}finally{ue(!1)}},qt=d?.username&&!d.username.includes("@"),Nt=async()=>{pe(!0),fe(""),ye(""),ge(!1);try{const E=await ve.auth.feishuBindToken(),U=await E.json();E.ok&&U.token?ye(U.token):fe(U.error||"生成失败,请重试")}catch{fe("网络错误,请稍后再试")}finally{pe(!1)}},Jt=()=>{if(!J)return;const E=`/auth ${J}`;if(navigator.clipboard&&window.isSecureContext)navigator.clipboard.writeText(E).then(()=>{ge(!0),setTimeout(()=>ge(!1),2e3)});else{const U=document.createElement("textarea");U.value=E,U.style.position="fixed",U.style.opacity="0",document.body.appendChild(U),U.focus(),U.select();try{document.execCommand("copy"),ge(!0),setTimeout(()=>ge(!1),2e3)}finally{document.body.removeChild(U)}}},it=()=>{X({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),I(null),oe(!1),ze("")},Ze=(E=null)=>{E?(I(E),X({name:E.name,type:E.type,scope:E.scope,projectPath:E.projectPath||"",config:{...E.config},raw:E.raw,importMode:"form",jsonInput:""})):it(),oe(!0)},Je=async E=>{E.preventDefault(),ie(!0);try{if(_.importMode==="json"){const U=await re("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:_.name,jsonConfig:_.jsonInput,scope:_.scope,projectPath:_.projectPath})});if(U.ok){const te=await U.json();if(te.success)await bt(),it(),L("success");else throw new Error(te.error||"Failed to add server via JSON")}else{const te=await U.json();throw new Error(te.error||"Failed to add server")}}else await Ut(_),it(),L("success")}catch(U){alert(`Error: ${U.message}`),L("error")}finally{ie(!1)}},Kt=async(E,U)=>{if(confirm("确定要删除此 MCP 服务器吗?"))try{await Ht(E,U),L("success")}catch(te){alert(`Error: ${te.message}`),L("error")}},pt=async(E,U)=>{try{we({...Z,[E]:{loading:!0}});const te=await Lt(E,U);we({...Z,[E]:te})}catch(te){we({...Z,[E]:{success:!1,message:te.message,details:[]}})}},Dt=async(E,U)=>{try{Oe({...Ce,[E]:!0});const te=await tr(E,U);De({...Me,[E]:te})}catch{De({...Me,[E]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{Oe({...Ce,[E]:!1})}},lt=(E,U)=>{X(te=>({...te,config:{...te.config,[E]:U}}))};return t?e.jsx("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:e.jsxs("div",{className:"bg-background border border-border md:rounded-lg shadow-xl w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-600"}),e.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:"设置"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:s,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsx("div",{className:"border-b border-border",children:e.jsxs("div",{className:"flex px-4 md:px-6",children:[e.jsx("button",{onClick:()=>Se("agents"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Agent"}),e.jsx("button",{onClick:()=>Se("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"外观"}),p&&e.jsx("button",{onClick:()=>Se("users"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="users"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"用户"}),e.jsx("button",{onClick:()=>Se("account"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="account"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"账户"})]})}),e.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[xe==="appearance"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:xe==="appearance"&&e.jsxs("div",{className:"space-y-6 md:space-y-8",children:[e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"深色模式"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"切换浅色和深色主题"})]}),e.jsxs("button",{onClick:i,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":l,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${l?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:l?e.jsx(Or,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Fr,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"项目排序"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"侧边栏中项目的排序方式"})]}),e.jsxs("select",{value:F,onChange:E=>O(E.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-32",children:[e.jsx("option",{value:"name",children:"按字母顺序"}),e.jsx("option",{value:"date",children:"按最近活动"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"代码编辑器"}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"编辑器主题"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"代码编辑器的默认主题"})]}),e.jsxs("button",{onClick:()=>He(be==="dark"?"light":"dark"),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":be==="dark","aria-label":"Toggle editor theme",children:[e.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),e.jsx("span",{className:`${be==="dark"?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:be==="dark"?e.jsx(Or,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Fr,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"自动换行"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"在编辑器中默认启用自动换行"})]}),e.jsxs("button",{onClick:()=>st(!mt),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":mt,"aria-label":"Toggle word wrap",children:[e.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),e.jsx("span",{className:`${mt?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"显示小地图"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"在差异视图中显示小地图以便于导航"})]}),e.jsxs("button",{onClick:()=>kt(!ut),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":ut,"aria-label":"Toggle minimap",children:[e.jsx("span",{className:"sr-only",children:"Toggle minimap"}),e.jsx("span",{className:`${ut?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"显示行号"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"在编辑器中显示行号"})]}),e.jsxs("button",{onClick:()=>vr(!ft),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":ft,"aria-label":"Toggle line numbers",children:[e.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),e.jsx("span",{className:`${ft?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"字体大小"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"编辑器字体大小(像素)"})]}),e.jsxs("select",{value:Qe,onChange:E=>jr(E.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-24",children:[e.jsx("option",{value:"10",children:"10px"}),e.jsx("option",{value:"11",children:"11px"}),e.jsx("option",{value:"12",children:"12px"}),e.jsx("option",{value:"13",children:"13px"}),e.jsx("option",{value:"14",children:"14px"}),e.jsx("option",{value:"15",children:"15px"}),e.jsx("option",{value:"16",children:"16px"}),e.jsx("option",{value:"18",children:"18px"}),e.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),xe==="agents"&&e.jsx("div",{className:"flex flex-col h-full min-h-[400px] md:min-h-[500px]",children:e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex px-2 md:px-4 overflow-x-auto",children:[e.jsx("button",{onClick:()=>Le("permissions"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${he==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"权限"}),e.jsx("button",{onClick:()=>Le("mcp"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${he==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"MCP 服务器"}),e.jsx("button",{onClick:()=>Le("skills"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${he==="skills"?"border-amber-600 text-amber-600 dark:text-amber-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"技能"}),e.jsx("button",{onClick:()=>Le("models"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${he==="models"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"模型"})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4",children:[he==="permissions"&&e.jsx(yi,{agent:"claude",skipPermissions:C,setSkipPermissions:u,allowedTools:g,setAllowedTools:k,disallowedTools:y,setDisallowedTools:v,newAllowedTool:x,setNewAllowedTool:R,newDisallowedTool:z,setNewDisallowedTool:T}),he==="mcp"&&e.jsx(Ni,{agent:"claude",servers:se,onAdd:()=>Ze(),onEdit:E=>Ze(E),onDelete:(E,U)=>Kt(E,U),onTest:(E,U)=>pt(E,U),onDiscoverTools:(E,U)=>Dt(E,U),testResults:Z,serverTools:Me,toolsLoading:Ce}),he==="skills"&&e.jsx(Pi,{}),he==="models"&&e.jsx(Ci,{ref:We,onStatusChange:A})]})]})}),xe==="users"&&p&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:Te?e.jsx(Ii,{onBack:()=>_e(!1)}):e.jsxs(e.Fragment,{children:[e.jsx(Ei,{onNavigateToUsage:()=>_e(!0)}),e.jsx(Li,{}),e.jsx(Mi,{})]})}),xe==="account"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"账户"}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-primary/10 rounded-full flex items-center justify-center",children:e.jsx("span",{className:"text-lg font-semibold text-primary",children:d?.username?.charAt(0).toUpperCase()})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:d?.username}),e.jsx("div",{className:"text-sm text-muted-foreground",children:d?.role==="admin"?"管理员":"用户"})]})]})}),qt&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(_r,{className:"w-5 h-5 text-blue-600"}),e.jsx("div",{className:"font-medium text-foreground",children:"修改密码"})]}),e.jsxs("form",{onSubmit:at,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"currentPassword",className:"block text-sm font-medium text-foreground mb-1",children:"当前密码"}),e.jsx("input",{type:"password",id:"currentPassword",value:f,onChange:E=>H(E.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入当前密码",disabled:B})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"newPassword",className:"block text-sm font-medium text-foreground mb-1",children:"新密码"}),e.jsx("input",{type:"password",id:"newPassword",value:de,onChange:E=>Ee(E.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入新密码(至少6个字符)",disabled:B})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirmNewPassword",className:"block text-sm font-medium text-foreground mb-1",children:"确认新密码"}),e.jsx("input",{type:"password",id:"confirmNewPassword",value:Ae,onChange:E=>rt(E.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请再次输入新密码",disabled:B})]}),G&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:G})}),b&&e.jsx("div",{className:"p-3 bg-green-100 dark:bg-green-900/20 border border-green-300 dark:border-green-800 rounded-md",children:e.jsx("p",{className:"text-sm text-green-700 dark:text-green-400",children:b})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{type:"submit",disabled:B,className:"bg-blue-600 hover:bg-blue-700",children:B?"修改中...":"修改密码"})})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("img",{src:"/feishu-logo.svg",alt:"飞书",className:"h-4"}),e.jsx("div",{className:"font-medium text-foreground",children:"飞书账号绑定"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-3",children:["生成绑定 Token,在飞书中向机器人发送 ",e.jsx("code",{className:"bg-gray-200 dark:bg-gray-700 px-1 rounded text-xs",children:"/auth <token>"})," 即可完成绑定,Token 有效期 24 小时。"]}),J?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background border border-border rounded-md",children:[e.jsxs("code",{className:"flex-1 text-xs text-foreground font-mono break-all select-all",children:["/auth ",J]}),e.jsx("button",{onClick:Jt,className:"shrink-0 p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-800 text-muted-foreground hover:text-foreground transition-colors",title:"复制命令",children:ke?e.jsx(cr,{className:"w-4 h-4 text-green-500"}):e.jsx(xn,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"复制上方命令,在飞书私聊机器人中发送"}),e.jsxs("button",{onClick:Nt,disabled:V,className:"flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-50",children:[e.jsx(_t,{className:"w-3 h-3"}),"重新生成"]})]})]}):e.jsxs("div",{className:"space-y-2",children:[le&&e.jsx("p",{className:"text-sm text-red-500",children:le}),e.jsxs(K,{onClick:Nt,disabled:V,variant:"outline",className:"gap-2",children:[V?e.jsx(_t,{className:"w-4 h-4 animate-spin"}):e.jsx(_r,{className:"w-4 h-4"}),V?"生成中...":"生成绑定 Token"]})]})]}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"退出登录"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"结束当前会话"})]}),e.jsxs(K,{variant:"outline",className:"gap-2 text-red-600 dark:text-red-400 border-red-200 dark:border-red-800 hover:bg-red-50 dark:hover:bg-red-900/20",onClick:()=>{confirm("确定要退出登录吗?")&&(s(),n("/"),h())},children:[e.jsx(hn,{className:"w-4 h-4"}),"退出"]})]})})]})}),ae&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:e.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:W?"编辑 MCP 服务器":"添加 MCP 服务器"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:it,children:e.jsx(Ue,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:Je,className:"p-4 space-y-4",children:[!W&&e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("button",{type:"button",onClick:()=>X(E=>({...E,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${_.importMode==="form"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:"表单输入"}),e.jsx("button",{type:"button",onClick:()=>X(E=>({...E,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${_.importMode==="json"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:"JSON 导入"})]}),_.importMode==="form"&&W&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"作用域"}),e.jsxs("div",{className:"flex items-center gap-2",children:[_.scope==="user"?e.jsx($r,{className:"w-4 h-4"}):e.jsx(Et,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:_.scope==="user"?"用户(全局)":"项目(本地)"}),_.scope==="local"&&_.projectPath&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",_.projectPath]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"编辑现有服务器时无法更改作用域"})]}),_.importMode==="form"&&!W&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"作用域 *"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>X(E=>({...E,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${_.scope==="user"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx($r,{className:"w-4 h-4"}),e.jsx("span",{children:"用户(全局)"})]})}),e.jsx("button",{type:"button",onClick:()=>X(E=>({...E,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${_.scope==="local"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(Et,{className:"w-4 h-4"}),e.jsx("span",{children:"项目(本地)"})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:_.scope==="user"?"用户作用域:在您机器上的所有项目中可用":"本地作用域:仅在选定的项目中可用"})]}),_.scope==="local"&&!W&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"项目 *"}),e.jsxs("select",{value:_.projectPath,onChange:E=>X(U=>({...U,projectPath:E.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",required:_.scope==="local",children:[e.jsx("option",{value:"",children:"选择项目..."}),a.map(E=>e.jsx("option",{value:E.path||E.fullPath,children:E.displayName||E.name},E.name))]}),_.projectPath&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Path: ",_.projectPath]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:_.importMode==="json"?"md:col-span-2":"",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"服务器名称 *"}),e.jsx(Ve,{value:_.name,onChange:E=>{X(U=>({...U,name:E.target.value}))},placeholder:"my-server",required:!0})]}),_.importMode==="form"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"传输类型 *"}),e.jsxs("select",{value:_.type,onChange:E=>{X(U=>({...U,type:E.target.value}))},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",children:[e.jsx("option",{value:"stdio",children:"stdio"}),e.jsx("option",{value:"sse",children:"SSE"}),e.jsx("option",{value:"http",children:"HTTP"})]})]})]}),W&&_.raw&&_.importMode==="form"&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsxs("h4",{className:"text-sm font-medium text-foreground mb-2",children:["配置详情 (from ",W.scope==="global"?"~/.claude.json":"project config",")"]}),e.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(_.raw,null,2)})]}),_.importMode==="json"&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"JSON 配置 *"}),e.jsx("textarea",{value:_.jsonInput,onChange:E=>{X(U=>({...U,jsonInput:E.target.value}));try{if(E.target.value.trim()){const U=JSON.parse(E.target.value);U.type?U.type==="stdio"&&!U.command?ze("stdio 类型需要 command 字段"):(U.type==="http"||U.type==="sse")&&!U.url?ze(`${U.type} 类型需要 url 字段`):ze(""):ze("缺少必填字段:type")}}catch{E.target.value.trim()?ze("无效的 JSON 格式"):ze("")}},className:`w-full px-3 py-2 border ${Re?"border-red-500":"border-gray-300 dark:border-gray-600"} bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 font-mono text-sm`,rows:"8",placeholder:`{
135
+ `;if(typeof document<"u"){const t=document.createElement("style");t.type="text/css",t.innerText=ti,document.head.appendChild(t)}function ri({selectedProject:t,selectedSession:s,initialCommand:a,isPlainShell:o=!1,onProcessComplete:n,minimal:l=!1,autoConnect:i=!1}){const d=r.useRef(null),h=r.useRef(null),p=r.useRef(null),g=r.useRef(null),[k,y]=r.useState(!1),[v,x]=r.useState(!1),[R,z]=r.useState(!1),[T,C]=r.useState(null),[u,m]=r.useState(!1),j=r.useRef(t),w=r.useRef(s),L=r.useRef(a),F=r.useRef(o),O=r.useRef(n);r.useEffect(()=>{j.current=t,w.current=s,L.current=a,F.current=o,O.current=n});const se=r.useCallback(async()=>{if(!(u||k))try{let je;{const ie=localStorage.getItem("auth-token");if(!ie){console.error("No authentication token found for Shell WebSocket connection");return}je=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(ie)}`}g.current=new WebSocket(je),g.current.onopen=()=>{y(!0),m(!1),setTimeout(()=>{p.current&&h.current&&(p.current.fit(),g.current.send(JSON.stringify({type:"init",projectPath:j.current.fullPath||j.current.path,sessionId:F.current?null:w.current?.id,hasSession:F.current?!1:!!w.current,provider:F.current?"plain-shell":w.current?.__provider||"claude",cols:h.current.cols,rows:h.current.rows,initialCommand:L.current,isPlainShell:F.current})))},100)},g.current.onmessage=ie=>{try{const Z=JSON.parse(ie.data);if(Z.type==="output"){let we=Z.data;if(F.current&&O.current){const Me=we.replace(/\x1b\[[0-9;]*m/g,"");if(Me.includes("Process exited with code 0"))O.current(0);else if(Me.match(/Process exited with code (\d+)/)){const De=parseInt(Me.match(/Process exited with code (\d+)/)[1]);De!==0&&O.current(De)}}h.current&&h.current.write(we)}else Z.type==="url_open"&&window.open(Z.url,"_blank")}catch(Z){console.error("[Shell] Error handling WebSocket message:",Z,ie.data)}},g.current.onclose=ie=>{y(!1),m(!1),h.current&&(h.current.clear(),h.current.write("\x1B[2J\x1B[H"))},g.current.onerror=ie=>{y(!1),m(!1)}}catch{y(!1),m(!1)}},[u,k]),ce=r.useCallback(()=>{!v||k||u||(m(!0),se())},[v,k,u,se]),ae=r.useCallback(()=>{g.current&&(g.current.readyState===WebSocket.OPEN&&g.current.send(JSON.stringify({type:"terminate"})),g.current.close(),g.current=null),h.current&&(h.current.clear(),h.current.write("\x1B[2J\x1B[H")),y(!1),m(!1)},[]),oe=r.useMemo(()=>s?s.__provider==="cursor"?s.name||"Untitled Session":s.summary||"New Session":null,[s]),W=r.useMemo(()=>oe?oe.slice(0,30):null,[oe]),I=r.useMemo(()=>oe?oe.slice(0,50):null,[oe]),_=()=>{z(!0),g.current&&(g.current.readyState===WebSocket.OPEN&&g.current.send(JSON.stringify({type:"terminate"})),g.current.close(),g.current=null),h.current&&(h.current.dispose(),h.current=null,p.current=null),y(!1),x(!1),setTimeout(()=>{z(!1)},200)};return r.useEffect(()=>{const X=s?.id||null;T!==null&&T!==X&&v&&ae(),C(X)},[s?.id,v,ae]),r.useEffect(()=>{if(!d.current||!t||R||h.current)return;h.current=new es.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!1,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff",extendedAnsi:["#000000","#800000","#008000","#808000","#000080","#800080","#008080","#c0c0c0","#808080","#ff0000","#00ff00","#ffff00","#0000ff","#ff00ff","#00ffff","#ffffff"]}}),p.current=new ts.FitAddon;const X=new rs.WebglAddon,je=new ss.WebLinksAddon;h.current.loadAddon(p.current),h.current.loadAddon(je);try{h.current.loadAddon(X)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}h.current.open(d.current),h.current.attachCustomKeyEventHandler(Z=>(Z.ctrlKey||Z.metaKey)&&Z.key==="c"&&h.current.hasSelection()?(document.execCommand("copy"),!1):(Z.ctrlKey||Z.metaKey)&&Z.key==="v"?(navigator.clipboard.readText().then(we=>{g.current&&g.current.readyState===WebSocket.OPEN&&g.current.send(JSON.stringify({type:"input",data:we}))}).catch(()=>{}),!1):!0),setTimeout(()=>{p.current&&(p.current.fit(),h.current&&g.current&&g.current.readyState===WebSocket.OPEN&&g.current.send(JSON.stringify({type:"resize",cols:h.current.cols,rows:h.current.rows})))},100),x(!0),h.current.onData(Z=>{g.current&&g.current.readyState===WebSocket.OPEN&&g.current.send(JSON.stringify({type:"input",data:Z}))});const ie=new ResizeObserver(()=>{p.current&&h.current&&setTimeout(()=>{p.current.fit(),g.current&&g.current.readyState===WebSocket.OPEN&&g.current.send(JSON.stringify({type:"resize",cols:h.current.cols,rows:h.current.rows}))},50)});return d.current&&ie.observe(d.current),()=>{ie.disconnect(),g.current&&(g.current.readyState===WebSocket.OPEN||g.current.readyState===WebSocket.CONNECTING)&&g.current.close(),g.current=null,h.current&&(h.current.dispose(),h.current=null)}},[t?.path||t?.fullPath,R]),r.useEffect(()=>{!i||!v||u||k||ce()},[i,v,u,k,ce]),t?l?e.jsx("div",{className:"h-full w-full bg-gray-900",children:e.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}})}):e.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${k?"bg-green-500":"bg-red-500"}`}),s&&e.jsxs("span",{className:"text-xs text-blue-300",children:["(",W,"...)"]}),!s&&e.jsx("span",{className:"text-xs text-gray-400",children:"(新会话)"}),!v&&e.jsx("span",{className:"text-xs text-yellow-400",children:"(正在初始化...)"}),R&&e.jsx("span",{className:"text-xs text-blue-400",children:"(正在重启...)"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[k&&e.jsxs("button",{onClick:ae,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:"断开 Shell 连接",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{children:"断开连接"})]}),e.jsxs("button",{onClick:_,disabled:R||k,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:"重启 Shell(先断开连接)",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),e.jsx("span",{children:"重启"})]})]})]})}),e.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[e.jsx("div",{ref:d,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!v&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:e.jsx("div",{className:"text-white",children:"加载终端中..."})}),v&&!k&&!u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("button",{onClick:ce,className:"px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",title:"Connect to shell",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsx("span",{children:"在 Shell 中继续"})]}),e.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:o?`Run ${a||"command"} in ${t.displayName}`:s?`Resume session: ${I}...`:"Start a new Claude session"})]})}),u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),e.jsx("span",{className:"text-base font-medium",children:"连接到 Shell..."})]}),e.jsx("p",{className:"text-gray-400 text-sm mt-3 px-2",children:o?`Running ${a||"command"} in ${t.displayName}`:`Starting Claude CLI in ${t.displayName}`})]})})]})]}):e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"选择项目"}),e.jsx("p",{children:"选择一个项目以在该目录中打开交互式 Shell"})]})})}function si({project:t,session:s=null,command:a=null,isPlainShell:o=null,autoConnect:n=!0,onComplete:l=null,onClose:i=null,title:d=null,className:h="",showHeader:p=!0,compact:g=!1,minimal:k=!1}){const[y,v]=r.useState(!1),x=o!==null?o:a!==null,R=r.useCallback(z=>{v(!0),l&&l(z)},[l]);return t?e.jsxs("div",{className:`h-full w-full flex flex-col ${h}`,children:[!k&&p&&d&&e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-200",children:d}),y&&e.jsx("span",{className:"text-xs text-green-400",children:"(已完成)"})]}),i&&e.jsx("button",{onClick:i,className:"text-gray-400 hover:text-white",title:"关闭",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsx("div",{className:"flex-1 w-full min-h-0",children:e.jsx(ri,{selectedProject:t,selectedSession:s,initialCommand:a,isPlainShell:x,onProcessComplete:R,minimal:k,autoConnect:k?!0:n})})]}):e.jsx("div",{className:`h-full flex items-center justify-center ${h}`,children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"未选择项目"}),e.jsx("p",{children:"打开 Shell 需要一个项目"})]})})}function ai({selectedProject:t,minimal:s=!1,autoConnect:a=!1}){const o=r.useRef(null),n=r.useRef(null),l=r.useRef(null),i=r.useRef(null),[d,h]=r.useState(!1),[p,g]=r.useState(!1),[k,y]=r.useState(!1),[v,x]=r.useState(!1),R=r.useRef(t);r.useEffect(()=>{R.current=t});const z=r.useCallback(async()=>{if(!(v||d))try{let j;{const w=localStorage.getItem("auth-token");if(!w){console.error("No authentication token found for Codex WebSocket connection");return}j=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/codex?token=${encodeURIComponent(w)}`}i.current=new WebSocket(j),i.current.onopen=()=>{h(!0),x(!1),setTimeout(()=>{l.current&&n.current&&(l.current.fit(),i.current.send(JSON.stringify({type:"init",projectPath:R.current.fullPath||R.current.path,cols:n.current.cols,rows:n.current.rows})))},100)},i.current.onmessage=w=>{try{const L=JSON.parse(w.data);L.type==="output"?n.current&&n.current.write(L.data):L.type==="url_open"&&window.open(L.url,"_blank")}catch(L){console.error("[CodexShell] Error handling WebSocket message:",L)}},i.current.onclose=()=>{h(!1),x(!1),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H"))},i.current.onerror=()=>{h(!1),x(!1)}}catch{h(!1),x(!1)}},[v,d]),T=r.useCallback(()=>{!p||d||v||(x(!0),z())},[p,d,v,z]),C=r.useCallback(()=>{i.current&&(i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"terminate"})),i.current.close(),i.current=null),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H")),h(!1),x(!1)},[]),u=()=>{y(!0),i.current&&(i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"terminate"})),i.current.close(),i.current=null),n.current&&(n.current.dispose(),n.current=null,l.current=null),h(!1),g(!1),setTimeout(()=>y(!1),200)};return r.useEffect(()=>{if(!o.current||!t||k||n.current)return;n.current=new es.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!1,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff"}}),l.current=new ts.FitAddon;const m=new rs.WebglAddon,j=new ss.WebLinksAddon;n.current.loadAddon(l.current),n.current.loadAddon(j);try{n.current.loadAddon(m)}catch{console.warn("[CodexShell] WebGL renderer unavailable, using Canvas fallback")}n.current.open(o.current),n.current.attachCustomKeyEventHandler(L=>(L.ctrlKey||L.metaKey)&&L.key==="c"&&n.current.hasSelection()?(document.execCommand("copy"),!1):(L.ctrlKey||L.metaKey)&&L.key==="v"?(navigator.clipboard.readText().then(F=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:F}))}).catch(()=>{}),!1):!0),setTimeout(()=>{l.current&&(l.current.fit(),n.current&&i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows})))},100),g(!0),n.current.onData(L=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:L}))});const w=new ResizeObserver(()=>{l.current&&n.current&&setTimeout(()=>{l.current.fit(),i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows}))},50)});return o.current&&w.observe(o.current),()=>{w.disconnect(),i.current&&(i.current.readyState===WebSocket.OPEN||i.current.readyState===WebSocket.CONNECTING)&&i.current.close(),i.current=null,n.current&&(n.current.dispose(),n.current=null)}},[t?.path||t?.fullPath,k]),r.useEffect(()=>{!a||!p||v||d||T()},[a,p,v,d,T]),t?s?e.jsx("div",{className:"h-full w-full bg-gray-900",children:e.jsx("div",{ref:o,className:"h-full w-full focus:outline-none",style:{outline:"none"}})}):e.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${d?"bg-green-500":"bg-red-500"}`}),e.jsx("span",{className:"text-xs text-gray-300 font-medium",children:"Codex"}),!p&&e.jsx("span",{className:"text-xs text-yellow-400",children:"(正在初始化...)"}),k&&e.jsx("span",{className:"text-xs text-blue-400",children:"(正在重启...)"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[d&&e.jsxs("button",{onClick:C,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:"断开 Codex 连接",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{children:"断开连接"})]}),e.jsxs("button",{onClick:u,disabled:k||d,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:"重启 Codex(先断开连接)",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),e.jsx("span",{children:"重启"})]})]})]})}),e.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[e.jsx("div",{ref:o,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!p&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:e.jsx("div",{className:"text-white",children:"加载终端中..."})}),p&&!d&&!v&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("button",{onClick:T,className:"px-6 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsx("span",{children:"启动 Codex"})]}),e.jsxs("p",{className:"text-gray-400 text-sm mt-3 px-2",children:["在 ",t.displayName," 中启动 Codex CLI"]})]})}),v&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),e.jsx("span",{className:"text-base font-medium",children:"连接到 Codex..."})]}),e.jsxs("p",{className:"text-gray-400 text-sm mt-3 px-2",children:["正在 ",t.displayName," 中启动 Codex CLI"]})]})})]})]}):e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"选择项目"}),e.jsx("p",{children:"选择一个项目以在该目录中打开 Codex"})]})})}function ni({project:t,autoConnect:s=!0,onClose:a=null,className:o="",showHeader:n=!0,minimal:l=!1}){return t?e.jsxs("div",{className:`h-full w-full flex flex-col ${o}`,children:[!l&&n&&a&&e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-200",children:"Codex"}),e.jsx("button",{onClick:a,className:"text-gray-400 hover:text-white",title:"关闭",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsx("div",{className:"flex-1 w-full min-h-0",children:e.jsx(ai,{selectedProject:t,minimal:l,autoConnect:l?!0:s})})]}):e.jsx("div",{className:`h-full flex items-center justify-center ${o}`,children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"未选择项目"}),e.jsx("p",{children:"打开 Codex 需要一个项目"})]})})}function oi({selectedProject:t,minimal:s=!1,autoConnect:a=!1}){const o=r.useRef(null),n=r.useRef(null),l=r.useRef(null),i=r.useRef(null),[d,h]=r.useState(!1),[p,g]=r.useState(!1),[k,y]=r.useState(!1),[v,x]=r.useState(!1),R=r.useRef(t);r.useEffect(()=>{R.current=t});const z=r.useCallback(async()=>{if(!(v||d))try{let j;{const w=localStorage.getItem("auth-token");if(!w){console.error("No authentication token found for Gemini WebSocket connection");return}j=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/gemini?token=${encodeURIComponent(w)}`}i.current=new WebSocket(j),i.current.onopen=()=>{h(!0),x(!1),setTimeout(()=>{l.current&&n.current&&(l.current.fit(),i.current.send(JSON.stringify({type:"init",projectPath:R.current.fullPath||R.current.path,cols:n.current.cols,rows:n.current.rows})))},100)},i.current.onmessage=w=>{try{const L=JSON.parse(w.data);L.type==="output"?n.current&&n.current.write(L.data):L.type==="url_open"&&window.open(L.url,"_blank")}catch(L){console.error("[GeminiShell] Error handling WebSocket message:",L)}},i.current.onclose=()=>{h(!1),x(!1),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H"))},i.current.onerror=()=>{h(!1),x(!1)}}catch{h(!1),x(!1)}},[v,d]),T=r.useCallback(()=>{!p||d||v||(x(!0),z())},[p,d,v,z]),C=r.useCallback(()=>{i.current&&(i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"terminate"})),i.current.close(),i.current=null),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H")),h(!1),x(!1)},[]),u=()=>{y(!0),i.current&&(i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"terminate"})),i.current.close(),i.current=null),n.current&&(n.current.dispose(),n.current=null,l.current=null),h(!1),g(!1),setTimeout(()=>y(!1),200)};return r.useEffect(()=>{if(!o.current||!t||k||n.current)return;n.current=new es.Terminal({cursorBlink:!0,fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',allowProposedApi:!0,allowTransparency:!1,convertEol:!0,scrollback:1e4,tabStopWidth:4,windowsMode:!1,macOptionIsMeta:!0,macOptionClickForcesSelection:!1,theme:{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#ffffff",cursorAccent:"#1e1e1e",selection:"#264f78",selectionForeground:"#ffffff",black:"#000000",red:"#cd3131",green:"#0dbc79",yellow:"#e5e510",blue:"#2472c8",magenta:"#bc3fbc",cyan:"#11a8cd",white:"#e5e5e5",brightBlack:"#666666",brightRed:"#f14c4c",brightGreen:"#23d18b",brightYellow:"#f5f543",brightBlue:"#3b8eea",brightMagenta:"#d670d6",brightCyan:"#29b8db",brightWhite:"#ffffff"}}),l.current=new ts.FitAddon;const m=new rs.WebglAddon,j=new ss.WebLinksAddon;n.current.loadAddon(l.current),n.current.loadAddon(j);try{n.current.loadAddon(m)}catch{console.warn("[GeminiShell] WebGL renderer unavailable, using Canvas fallback")}n.current.open(o.current),n.current.attachCustomKeyEventHandler(L=>(L.ctrlKey||L.metaKey)&&L.key==="c"&&n.current.hasSelection()?(document.execCommand("copy"),!1):(L.ctrlKey||L.metaKey)&&L.key==="v"?(navigator.clipboard.readText().then(F=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:F}))}).catch(()=>{}),!1):!0),setTimeout(()=>{l.current&&(l.current.fit(),n.current&&i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows})))},100),g(!0),n.current.onData(L=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:L}))});const w=new ResizeObserver(()=>{l.current&&n.current&&setTimeout(()=>{l.current.fit(),i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"resize",cols:n.current.cols,rows:n.current.rows}))},50)});return o.current&&w.observe(o.current),()=>{w.disconnect(),i.current&&(i.current.readyState===WebSocket.OPEN||i.current.readyState===WebSocket.CONNECTING)&&i.current.close(),i.current=null,n.current&&(n.current.dispose(),n.current=null)}},[t?.path||t?.fullPath,k]),r.useEffect(()=>{!a||!p||v||d||T()},[a,p,v,d,T]),t?s?e.jsx("div",{className:"h-full w-full bg-gray-900",children:e.jsx("div",{ref:o,className:"h-full w-full focus:outline-none",style:{outline:"none"}})}):e.jsxs("div",{className:"h-full flex flex-col bg-gray-900 w-full",children:[e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${d?"bg-green-500":"bg-red-500"}`}),e.jsx("span",{className:"text-xs text-gray-300 font-medium",children:"Gemini"}),!p&&e.jsx("span",{className:"text-xs text-yellow-400",children:"(正在初始化...)"}),k&&e.jsx("span",{className:"text-xs text-blue-400",children:"(正在重启...)"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[d&&e.jsxs("button",{onClick:C,className:"px-3 py-1 text-xs bg-red-600 text-white rounded hover:bg-red-700 flex items-center space-x-1",title:"断开 Gemini 连接",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{children:"断开连接"})]}),e.jsxs("button",{onClick:u,disabled:k||d,className:"text-xs text-gray-400 hover:text-white disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1",title:"重启 Gemini(先断开连接)",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),e.jsx("span",{children:"重启"})]})]})]})}),e.jsxs("div",{className:"flex-1 p-2 overflow-hidden relative",children:[e.jsx("div",{ref:o,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!p&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90",children:e.jsx("div",{className:"text-white",children:"加载终端中..."})}),p&&!d&&!v&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("button",{onClick:T,className:"px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors flex items-center justify-center space-x-2 text-base font-medium w-full sm:w-auto",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsx("span",{children:"启动 Gemini"})]}),e.jsxs("p",{className:"text-gray-400 text-sm mt-3 px-2",children:["在 ",t.displayName," 中启动 Gemini CLI"]})]})}),v&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-900 bg-opacity-90 p-4",children:e.jsxs("div",{className:"text-center max-w-sm w-full",children:[e.jsxs("div",{className:"flex items-center justify-center space-x-3 text-yellow-400",children:[e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-yellow-400 border-t-transparent"}),e.jsx("span",{className:"text-base font-medium",children:"连接到 Gemini..."})]}),e.jsxs("p",{className:"text-gray-400 text-sm mt-3 px-2",children:["正在 ",t.displayName," 中启动 Gemini CLI"]})]})})]})]}):e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"选择项目"}),e.jsx("p",{children:"选择一个项目以在该目录中打开 Gemini"})]})})}function ii({project:t,autoConnect:s=!0,onClose:a=null,className:o="",showHeader:n=!0,minimal:l=!1}){return t?e.jsxs("div",{className:`h-full w-full flex flex-col ${o}`,children:[!l&&n&&a&&e.jsx("div",{className:"flex-shrink-0 bg-gray-800 border-b border-gray-700 px-4 py-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-200",children:"Gemini"}),e.jsx("button",{onClick:a,className:"text-gray-400 hover:text-white",title:"关闭",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),e.jsx("div",{className:"flex-1 w-full min-h-0",children:e.jsx(oi,{selectedProject:t,minimal:l,autoConnect:l?!0:s})})]}):e.jsx("div",{className:`h-full flex items-center justify-center ${o}`,children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"未选择项目"}),e.jsx("p",{children:"打开 Gemini 需要一个项目"})]})})}class li extends tt.Component{constructor(s){super(s),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(s){return{hasError:!0}}componentDidCatch(s,a){console.error("ErrorBoundary caught an error:",s,a),this.setState({error:s,errorInfo:a})}render(){return this.state.hasError?e.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 max-w-md",children:[e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),e.jsx("h3",{className:"ml-3 text-sm font-medium text-red-800",children:"出现问题"})]}),e.jsxs("div",{className:"text-sm text-red-700",children:[e.jsx("p",{className:"mb-2",children:"加载聊天界面时出现错误。"}),this.props.showDetails&&this.state.error&&e.jsxs("details",{className:"mt-4",children:[e.jsx("summary",{className:"cursor-pointer text-xs font-mono",children:"错误详情"}),e.jsxs("pre",{className:"mt-2 text-xs bg-red-100 p-2 rounded overflow-auto max-h-40",children:[this.state.error.toString(),this.state.errorInfo&&this.state.errorInfo.componentStack]})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:()=>{this.setState({hasError:!1,error:null,errorInfo:null}),this.props.onRetry&&this.props.onRetry()},className:"bg-red-600 text-white px-4 py-2 rounded text-sm hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500",children:"重试"})})]})}):this.props.children}}const Zt=({children:t,content:s,position:a="top",className:o="",delay:n=500})=>{const[l,i]=r.useState(!1),[d,h]=r.useState(null),p=()=>{const v=setTimeout(()=>{i(!0)},n);h(v)},g=()=>{d&&(clearTimeout(d),h(null)),i(!1)},k=()=>{switch(a){case"top":return"bottom-full left-1/2 transform -translate-x-1/2 mb-2";case"bottom":return"top-full left-1/2 transform -translate-x-1/2 mt-2";case"left":return"right-full top-1/2 transform -translate-y-1/2 mr-2";case"right":return"left-full top-1/2 transform -translate-y-1/2 ml-2";default:return"bottom-full left-1/2 transform -translate-x-1/2 mb-2"}},y=()=>{switch(a){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}};return s?e.jsxs("div",{className:"relative inline-block",onMouseEnter:p,onMouseLeave:g,children:[t,l&&e.jsxs("div",{className:Be("absolute z-50 px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-nowrap pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",k(),o),children:[s,e.jsx("div",{className:Be("absolute w-0 h-0 border-4 border-transparent",y())})]})]}):t};function ci({selectedProject:t,selectedSession:s,activeTab:a,setActiveTab:o,ws:n,sendMessage:l,messages:i,isMobile:d,isPWA:h,onMenuClick:p,isLoading:g,onInputFocusChange:k,onSessionActive:y,onSessionInactive:v,onSessionProcessing:x,onSessionNotProcessing:R,processingSessions:z,onReplaceTemporarySession:T,onNavigateToSession:C,onShowSettings:u,autoExpandTools:m,showRawParameters:j,showThinking:w,autoScrollToBottom:L,sendByCtrlEnter:F,externalMessageUpdate:O,limitStatus:se,onLimitBlocked:ce,checkLimitStatus:ae}){const[oe,W]=r.useState(null),[I,_]=r.useState(600),[X,je]=r.useState(!1),[ie,Z]=r.useState(!1),we=r.useRef(null);r.useEffect(()=>{a==="shell"&&ae&&ae()},[a,ae]);const Me=(xe,Se=null)=>{const Re={name:xe.split("/").pop(),path:xe,projectName:t?.name,diffInfo:Se};W(Re)},De=()=>{W(null),Z(!1)},Ce=()=>{Z(!ie)},Oe=xe=>{d||(je(!0),xe.preventDefault())};return r.useEffect(()=>{const xe=Re=>{if(!X)return;const ze=we.current?.parentElement;if(!ze)return;const he=ze.getBoundingClientRect(),Le=he.right-Re.clientX,Te=300,_e=he.width*.8;Le>=Te&&Le<=_e&&_(Le)},Se=()=>{je(!1)};return X&&(document.addEventListener("mousemove",xe),document.addEventListener("mouseup",Se),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",xe),document.removeEventListener("mouseup",Se),document.body.style.cursor="",document.body.style.userSelect=""}},[X]),g?e.jsxs("div",{className:"h-full flex flex-col",children:[d&&e.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:e.jsx("button",{onClick:p,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 pwa-menu-button",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-4",children:e.jsx("div",{className:"w-full h-full rounded-full border-4 border-gray-200 border-t-blue-500",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"正在加载 AgentHub"}),e.jsx("p",{children:"正在设置您的工作区..."})]})})]}):t?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between relative",children:[e.jsxs("div",{className:"flex items-center space-x-2 min-w-0 flex-1",children:[d&&e.jsx("button",{onClick:p,onTouchStart:xe=>{xe.preventDefault(),p()},className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 touch-manipulation active:scale-95 pwa-menu-button flex-shrink-0",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),e.jsxs("div",{className:"min-w-0 flex items-center gap-2 flex-1 overflow-x-auto scrollbar-hide",children:[a==="chat"&&s&&e.jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:e.jsx(dt,{className:"w-4 h-4"})}),e.jsx("div",{className:"min-w-0 flex-1",children:a==="chat"&&s?e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white whitespace-nowrap overflow-x-auto scrollbar-hide",children:s.summary||"新会话"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.displayName})]}):a==="chat"&&!s?e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:"新会话"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.displayName})]}):e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:a==="files"?"项目文件":"项目"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.displayName})]})})]})]}),e.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:e.jsxs("div",{className:"relative flex bg-gray-100 dark:bg-gray-800 rounded-lg p-1",children:[e.jsx(Zt,{content:"Chat",position:"bottom",children:e.jsx("button",{onClick:()=>o("chat"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md ${a==="chat"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[e.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Chat"})]})})}),e.jsx(Zt,{content:"Files",position:"bottom",children:e.jsx("button",{onClick:()=>o("files"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${a==="files"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[e.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Files"})]})})}),e.jsx(Zt,{content:se&&!se.allowed?"使用已达上限":"Claude Code",position:"bottom",children:e.jsx("button",{onClick:()=>{if(se&&!se.allowed){ce?.(se.reason);return}o("shell")},className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${se&&!se.allowed?"opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-500":a==="shell"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[e.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z",fill:"#D97757",fillRule:"nonzero"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Claude Code"})]})})}),e.jsx(Zt,{content:"Codex",position:"bottom",children:e.jsx("button",{onClick:()=>o("codex"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${a==="codex"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[e.jsx("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",fill:"currentColor",fillRule:"evenodd",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.797.797 0 00-.856 0l-5.97 3.473zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.433.433 0 01.476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737v6.898zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33L12 15.128zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482 4.482 0 014.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.432.432 0 01-.476 0zm-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71c.286.167.571.167.856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523zm5.899 2.83a5.947 5.947 0 005.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947-.642 0-1.26.095-1.88.31A5.962 5.962 0 0010.205 0a5.947 5.947 0 00-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 004.162 1.713z"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Codex"})]})})}),e.jsx(Zt,{content:"Gemini CLI",position:"bottom",children:e.jsx("button",{onClick:()=>o("gemini"),className:`relative px-2 sm:px-3 py-1.5 text-xs sm:text-sm font-medium rounded-md transition-all duration-200 ${a==="gemini"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("span",{className:"flex items-center gap-1 sm:gap-1.5",children:[e.jsxs("svg",{className:"w-3 sm:w-3.5 h-3 sm:h-3.5",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"#3186FF"}),e.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#gemini-tab-fill-0)"}),e.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#gemini-tab-fill-1)"}),e.jsx("path",{d:"M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z",fill:"url(#gemini-tab-fill-2)"}),e.jsxs("defs",{children:[e.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"gemini-tab-fill-0",x1:"7",x2:"11",y1:"15.5",y2:"12",children:[e.jsx("stop",{stopColor:"#08B962"}),e.jsx("stop",{offset:"1",stopColor:"#08B962",stopOpacity:"0"})]}),e.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"gemini-tab-fill-1",x1:"8",x2:"11.5",y1:"5.5",y2:"11",children:[e.jsx("stop",{stopColor:"#F94543"}),e.jsx("stop",{offset:"1",stopColor:"#F94543",stopOpacity:"0"})]}),e.jsxs("linearGradient",{gradientUnits:"userSpaceOnUse",id:"gemini-tab-fill-2",x1:"3.5",x2:"17.5",y1:"13.5",y2:"12",children:[e.jsx("stop",{stopColor:"#FABC12"}),e.jsx("stop",{offset:".46",stopColor:"#FABC12",stopOpacity:"0"})]})]})]}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Gemini CLI"})]})})})]})})]})}),e.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[e.jsxs("div",{className:`flex-1 flex flex-col min-h-0 overflow-hidden ${oe?"mr-0":""} ${ie?"hidden":""}`,children:[e.jsx("div",{className:`h-full ${a==="chat"?"block":"hidden"}`,children:e.jsx(li,{showDetails:!0,children:e.jsx(Zo,{selectedProject:t,selectedSession:s,ws:n,sendMessage:l,messages:i,onFileOpen:Me,onInputFocusChange:k,onSessionActive:y,onSessionInactive:v,onSessionProcessing:x,onSessionNotProcessing:R,processingSessions:z,onReplaceTemporarySession:T,onNavigateToSession:C,onShowSettings:u,autoExpandTools:m,showRawParameters:j,showThinking:w,autoScrollToBottom:L,sendByCtrlEnter:F,externalMessageUpdate:O,limitStatus:se,onLimitExceeded:ce,checkLimitStatus:ae})})}),a==="files"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(ei,{selectedProject:t})}),a==="shell"&&e.jsxs("div",{className:"h-full w-full overflow-hidden relative",children:[e.jsx(si,{project:t,session:s,showHeader:!1}),se&&!se.allowed&&e.jsx("div",{className:"absolute inset-0 bg-black/60 z-50 flex items-center justify-center",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-xl p-6 mx-4 max-w-md text-center",children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-4 bg-red-100 dark:bg-red-900/30 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-red-600 dark:text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:se.reason==="total_limit_exceeded"?"使用上限已达到":"今日使用上限已达到"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:se.reason==="total_limit_exceeded"?"您已达到使用上限,请联系管理员提升额度。":"您已达到今日使用上限,请明日再来或联系管理员提升额度。"}),e.jsx("button",{onClick:()=>o("chat"),className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors",children:"返回 Chat"})]})})]}),a==="codex"&&e.jsx("div",{className:"h-full w-full overflow-hidden relative",children:e.jsx(ni,{project:t,showHeader:!1})}),a==="gemini"&&e.jsx("div",{className:"h-full w-full overflow-hidden relative",children:e.jsx(ii,{project:t,showHeader:!1})}),e.jsx("div",{className:`h-full overflow-hidden ${a==="preview"?"block":"hidden"}`})]}),oe&&!d&&e.jsxs(e.Fragment,{children:[!ie&&e.jsx("div",{ref:we,onMouseDown:Oe,className:"flex-shrink-0 w-1 bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 dark:hover:bg-blue-600 cursor-col-resize transition-colors relative group",title:"Drag to resize",children:e.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-blue-500 dark:bg-blue-600 opacity-0 group-hover:opacity-100 transition-opacity"})}),e.jsx("div",{className:`flex-shrink-0 border-l border-gray-200 dark:border-gray-700 h-full overflow-hidden ${ie?"flex-1":""}`,style:ie?{}:{width:`${I}px`},children:e.jsx(Gr,{file:oe,onClose:De,projectPath:t?.path,isSidebar:!0,isExpanded:ie,onToggleExpand:Ce})})]})]}),oe&&d&&e.jsx(Gr,{file:oe,onClose:De,projectPath:t?.path,isSidebar:!1})]}):e.jsxs("div",{className:"h-full flex flex-col",children:[d&&e.jsx("div",{className:"bg-background border-b border-border p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:e.jsx("button",{onClick:p,className:"p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 pwa-menu-button",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}),e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 max-w-md mx-auto px-6",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-6 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-5l-2-2H5a2 2 0 00-2 2z"})})}),e.jsx("h2",{className:"text-2xl font-semibold mb-3 text-gray-900 dark:text-white",children:"选择您的项目"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-6 leading-relaxed",children:"从侧边栏选择一个项目,开始与 Claude 进行编码。每个项目包含您的聊天会话和文件历史。"}),e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:e.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:["💡 ",e.jsx("strong",{children:"提示:"})," ",d?"点击上方菜单按钮访问项目":"点击侧边栏中的文件夹图标创建新项目"]})})]})})]})}const di=tt.memo(ci);function mi({activeTab:t,setActiveTab:s,isInputFocused:a}){const o=[{id:"chat",icon:hr,onClick:()=>s("chat")},{id:"shell",icon:gr,onClick:()=>s("shell")},{id:"files",icon:nt,onClick:()=>s("files")}];return e.jsx("div",{className:`fixed bottom-0 left-0 right-0 bg-background border-t border-border z-50 ios-bottom-safe transform transition-transform duration-300 ease-in-out shadow-lg ${a?"translate-y-full":"translate-y-0"}`,children:e.jsx("div",{className:"flex items-center justify-around py-1",children:o.map(n=>{const l=n.icon,i=t===n.id;return e.jsxs("button",{onClick:n.onClick,onTouchStart:d=>{d.preventDefault(),n.onClick()},className:`flex items-center justify-center p-2 rounded-lg min-h-[40px] min-w-[40px] relative touch-manipulation ${i?"text-blue-600 dark:text-blue-400":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,"aria-label":n.id,children:[e.jsx(l,{className:"w-5 h-5"}),i&&e.jsx("div",{className:"absolute top-0 left-1/2 transform -translate-x-1/2 w-6 h-0.5 bg-blue-600 dark:bg-blue-400 rounded-full"})]},n.id)})})})}const ia=r.createContext(),as=()=>{const t=r.useContext(ia);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t},ui=({children:t})=>{const[s,a]=r.useState(()=>{const l=localStorage.getItem("theme");return l?l==="dark":window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1});r.useEffect(()=>{if(s){document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark");const l=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');l&&l.setAttribute("content","black-translucent");const i=document.querySelector('meta[name="theme-color"]');i&&i.setAttribute("content","#0c1117")}else{document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light");const l=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');l&&l.setAttribute("content","default");const i=document.querySelector('meta[name="theme-color"]');i&&i.setAttribute("content","#ffffff")}},[s]),r.useEffect(()=>{if(!window.matchMedia)return;const l=window.matchMedia("(prefers-color-scheme: dark)"),i=d=>{localStorage.getItem("theme")||a(d.matches)};return l.addEventListener("change",i),()=>l.removeEventListener("change",i)},[]);const n={isDarkMode:s,toggleDarkMode:()=>{a(l=>!l)}};return e.jsx(ia.Provider,{value:n,children:t})},la=r.createContext({user:null,token:null,login:()=>{},sendCode:()=>{},verifyCode:()=>{},logout:()=>{},isLoading:!0,needsSetup:!1,smtpConfigured:!1,error:null,isAdmin:!1,limitStatus:{allowed:!0},checkLimitStatus:()=>{},setLimitStatus:()=>{}}),Bt=()=>{const t=r.useContext(la);if(!t)throw new Error("useAuth must be used within an AuthProvider");return t};async function Pr(){try{const t=await ve.settings.getAgentPermissions();if(t.ok){const s=await t.json();s.agentPermissions&&localStorage.setItem("claude-settings",JSON.stringify(s.agentPermissions))}}catch{}}const pi=({children:t})=>{const[s,a]=r.useState(null),[o,n]=r.useState(localStorage.getItem("auth-token")),[l,i]=r.useState(!0),[d,h]=r.useState(!1),[p,g]=r.useState(!1),[k,y]=r.useState(null),[v,x]=r.useState({allowed:!0});r.useEffect(()=>{R()},[]);const R=async()=>{try{i(!0),y(null);const L=await(await ve.auth.status()).json();if(g(L.smtpConfigured||!1),L.needsSetup){h(!0),i(!1);return}if(o)try{const F=await ve.auth.user();if(F.ok){const O=await F.json();a(O.user),h(!1),await Pr()}else localStorage.removeItem("auth-token"),n(null),a(null)}catch(F){console.error("Token verification failed:",F),localStorage.removeItem("auth-token"),n(null),a(null)}}catch(w){console.error("[AuthContext] Auth status check failed:",w),y("Failed to check authentication status")}finally{i(!1)}},z=async w=>{try{y(null);const L=await ve.auth.sendCode(w),F=await L.json();return L.ok?{success:!0,type:F.type}:{success:!1,error:F.error||"发送验证码失败",waitSeconds:F.waitSeconds}}catch(L){return console.error("Send code error:",L),{success:!1,error:"网络错误,请稍后再试"}}},T=async(w,L)=>{try{y(null);const F=await ve.auth.verifyCode(w,L),O=await F.json();return F.ok?(n(O.token),a(O.user),h(!1),localStorage.setItem("auth-token",O.token),await Pr(),{success:!0}):(y(O.error||"验证失败"),{success:!1,error:O.error||"验证失败"})}catch(F){return console.error("Verify code error:",F),{success:!1,error:"网络错误,请稍后再试"}}},C=async(w,L)=>{try{y(null);const F=await ve.auth.login(w,L),O=await F.json();return F.ok?(n(O.token),a(O.user),localStorage.setItem("auth-token",O.token),await Pr(),{success:!0}):(y(O.error||"登录失败"),{success:!1,error:O.error||"登录失败"})}catch(F){console.error("Login error:",F);const O="网络错误,请稍后再试";return y(O),{success:!1,error:O}}},u=()=>{n(null),a(null),x({allowed:!0}),localStorage.removeItem("auth-token"),o&&ve.auth.logout().catch(w=>{console.error("Logout endpoint error:",w)})},m=async()=>{if(!s)return{allowed:!0};try{const w=await ve.auth.limitStatus();if(w.ok){const L=await w.json();return x(L),L}}catch(w){console.error("Error checking limit status:",w)}return{allowed:!0}};r.useEffect(()=>{s&&!l&&m()},[s,l]);const j={user:s,token:o,login:C,sendCode:z,verifyCode:T,logout:u,isLoading:l,needsSetup:d,smtpConfigured:p,error:k,isAdmin:s?.role==="admin",limitStatus:v,checkLimitStatus:m,setLimitStatus:x};return e.jsx(la.Provider,{value:j,children:t})},xi=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],hi=["Shell(ls)","Shell(mkdir)","Shell(cd)","Shell(cat)","Shell(echo)","Shell(git status)","Shell(git diff)","Shell(git log)","Shell(npm install)","Shell(npm run)","Shell(python)","Shell(node)"];function gi({skipPermissions:t,setSkipPermissions:s,allowedTools:a,setAllowedTools:o,disallowedTools:n,setDisallowedTools:l,newAllowedTool:i,setNewAllowedTool:d,newDisallowedTool:h,setNewDisallowedTool:p}){const g=x=>{x&&!a.includes(x)&&(o([...a,x]),d(""))},k=x=>{o(a.filter(R=>R!==x))},y=x=>{x&&!n.includes(x)&&(l([...n,x]),p(""))},v=x=>{l(n.filter(R=>R!==x))};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-sky-50 dark:bg-sky-900/20 border border-sky-200 dark:border-sky-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Js,{className:"w-5 h-5 text-sky-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-sky-800 dark:text-sky-200",children:[e.jsx("span",{className:"font-medium",children:"提示:"}),"此权限设置仅对 ",e.jsx("span",{className:"font-medium",children:"Chat(聊天)"})," 中的 Claude Agent 生效,对 ",e.jsx("span",{className:"font-medium",children:"Shell(终端)"})," 无效。Shell 是直接的系统终端,不受此权限控制。"]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ft,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"权限设置"})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>s(x.target.checked),className:"w-4 h-4 text-blue-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-blue-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:"跳过权限提示(请谨慎使用)"}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"等同于 --dangerously-skip-permissions 标志"})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fr,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"允许的工具"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自动允许而不提示权限的工具"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ye,{value:i,onChange:x=>d(x.target.value),placeholder:'e.g., "Bash(git log:*)" or "Write"',onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),g(i))},className:"flex-1 h-10"}),e.jsxs(K,{onClick:()=>g(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(ot,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:"添加"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"快速添加常用工具:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:xi.map(x=>e.jsx(K,{variant:"outline",size:"sm",onClick:()=>g(x),disabled:a.includes(x),className:"text-xs h-8",children:x},x))})]}),e.jsxs("div",{className:"space-y-2",children:[a.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:x}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k(x),className:"text-green-600 hover:text-green-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]},x)),a.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"未配置允许的工具"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ft,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"阻止的工具"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自动阻止而不提示权限的工具"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ye,{value:h,onChange:x=>p(x.target.value),placeholder:'e.g., "Bash(rm:*)"',onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),y(h))},className:"flex-1 h-10"}),e.jsxs(K,{onClick:()=>y(h),disabled:!h,size:"sm",className:"h-10 px-4",children:[e.jsx(ot,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:"添加"})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:x}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>v(x),className:"text-red-600 hover:text-red-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]},x)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"未配置阻止的工具"})]})]}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:"工具模式示例:"}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git log:*)"'})," - 允许所有 git log 命令"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git diff:*)"'})," - 允许所有 git diff 命令"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," - 允许所有 Write 工具使用"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," - 阻止所有 rm 命令(危险)"]})]})]})]})}function fi({skipPermissions:t,setSkipPermissions:s,allowedCommands:a,setAllowedCommands:o,disallowedCommands:n,setDisallowedCommands:l,newAllowedCommand:i,setNewAllowedCommand:d,newDisallowedCommand:h,setNewDisallowedCommand:p}){const g=x=>{x&&!a.includes(x)&&(o([...a,x]),d(""))},k=x=>{o(a.filter(R=>R!==x))},y=x=>{x&&!n.includes(x)&&(l([...n,x]),p(""))},v=x=>{l(n.filter(R=>R!==x))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ft,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"权限设置"})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>s(x.target.checked),className:"w-4 h-4 text-purple-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-purple-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:"跳过权限提示(请谨慎使用)"}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"等同于 Cursor CLI 中的 -f 标志"})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fr,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"允许的 Shell 命令"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自动允许而不提示的 Shell 命令"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ye,{value:i,onChange:x=>d(x.target.value),placeholder:'e.g., "Shell(ls)" or "Shell(git status)"',onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),g(i))},className:"flex-1 h-10"}),e.jsxs(K,{onClick:()=>g(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(ot,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:"添加"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"快速添加常用命令:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:hi.map(x=>e.jsx(K,{variant:"outline",size:"sm",onClick:()=>g(x),disabled:a.includes(x),className:"text-xs h-8",children:x},x))})]}),e.jsxs("div",{className:"space-y-2",children:[a.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:x}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>k(x),className:"text-green-600 hover:text-green-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]},x)),a.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"未配置允许的命令"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ft,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"阻止的 Shell 命令"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"自动阻止的 Shell 命令"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ye,{value:h,onChange:x=>p(x.target.value),placeholder:'e.g., "Shell(rm -rf)" or "Shell(sudo)"',onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),y(h))},className:"flex-1 h-10"}),e.jsxs(K,{onClick:()=>y(h),disabled:!h,size:"sm",className:"h-10 px-4",children:[e.jsx(ot,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:"添加"})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:x}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>v(x),className:"text-red-600 hover:text-red-700",children:e.jsx(Ue,{className:"w-4 h-4"})})]},x)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:"未配置阻止的命令"})]})]}),e.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:"Shell 命令示例:"}),e.jsxs("ul",{className:"text-sm text-purple-800 dark:text-purple-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(ls)"'})," - 允许 ls 命令"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(git status)"'})," - 允许 git status"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(npm install)"'})," - 允许 npm install"]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(rm -rf)"'})," - 阻止递归删除"]})]})]})]})}function bi({permissionMode:t,setPermissionMode:s}){return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fr,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"权限模式"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"控制 Codex 如何处理文件修改和命令执行"}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="default"?"bg-gray-100 dark:bg-gray-800 border-gray-400 dark:border-gray-500":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>s("default"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="default",onChange:()=>s("default"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"默认"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"仅受信任的命令(ls、cat、grep、git status 等)会自动运行。其他命令将被跳过。可以写入工作区。"})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="acceptEdits"?"bg-green-50 dark:bg-green-900/20 border-green-400 dark:border-green-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>s("acceptEdits"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="acceptEdits",onChange:()=>s("acceptEdits"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:"接受编辑"}),e.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:"所有命令在工作区内自动运行。沙盒执行的完全自动模式。"})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/20 border-orange-400 dark:border-orange-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>s("bypassPermissions"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="bypassPermissions",onChange:()=>s("bypassPermissions"),className:"mt-1 w-4 h-4 text-orange-600"}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-orange-900 dark:text-orange-100 flex items-center gap-2",children:["跳过权限",e.jsx(Ft,{className:"w-4 h-4"})]}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:"无限制的完全系统访问。所有命令自动运行,具有完全的磁盘和网络访问权限。请谨慎使用。"})]})]})}),e.jsxs("details",{className:"text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"技术详情"}),e.jsxs("div",{className:"mt-2 p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg text-xs text-muted-foreground space-y-2",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Default:"})," sandboxMode=workspace-write, approvalPolicy=untrusted. Trusted commands: cat, cd, grep, head, ls, pwd, tail, git status/log/diff/show, find (without -exec), etc."]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Accept Edits:"})," sandboxMode=workspace-write, approvalPolicy=never. All commands auto-execute within project directory."]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Bypass Permissions:"})," sandboxMode=danger-full-access, approvalPolicy=never. Full system access, use only in trusted environments."]}),e.jsx("p",{className:"text-xs opacity-75",children:"您可以在聊天界面中使用模式按钮为每个会话覆盖此设置。"})]})]})]})})}function yi({agent:t,...s}){return t==="claude"?e.jsx(gi,{...s}):t==="cursor"?e.jsx(fi,{...s}):t==="codex"?e.jsx(bi,{...s}):null}const vi=t=>{switch(t){case"stdio":return e.jsx(gr,{className:"w-4 h-4"});case"sse":return e.jsx(an,{className:"w-4 h-4"});case"http":return e.jsx($r,{className:"w-4 h-4"});default:return e.jsx(br,{className:"w-4 h-4"})}};function ji({servers:t,onAdd:s,onEdit:a,onDelete:o,onTest:n,onDiscoverTools:l,testResults:i,serverTools:d,toolsLoading:h}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(br,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP 服务器"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol 服务器为 Claude 提供额外的工具和数据源"}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(K,{onClick:s,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(ot,{className:"w-4 h-4 mr-2"}),"添加 MCP 服务器"]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(p=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[vi(p.type),e.jsx("span",{className:"font-medium text-foreground",children:p.name}),e.jsx(Ve,{variant:"outline",className:"text-xs",children:p.type}),e.jsx(Ve,{variant:"outline",className:"text-xs",children:p.scope==="local"?"local":p.scope==="user"?"user":p.scope})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[p.type==="stdio"&&p.config?.command&&e.jsxs("div",{children:["命令:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:p.config.command})]}),(p.type==="sse"||p.type==="http")&&p.config?.url&&e.jsxs("div",{children:["URL:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:p.config.url})]}),p.config?.args&&p.config.args.length>0&&e.jsxs("div",{children:["参数:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:p.config.args.join(" ")})]})]}),i?.[p.id]&&e.jsx("div",{className:`mt-2 p-2 rounded text-xs ${i[p.id].success?"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200":"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200"}`,children:e.jsx("div",{className:"font-medium",children:i[p.id].message})}),d?.[p.id]&&d[p.id].tools?.length>0&&e.jsxs("div",{className:"mt-2 p-2 rounded text-xs bg-blue-50 dark:bg-blue-900/20 text-blue-800 dark:text-blue-200",children:[e.jsxs("div",{className:"font-medium",children:["工具(",d[p.id].tools.length,"):"]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[d[p.id].tools.slice(0,5).map((g,k)=>e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:g.name},k)),d[p.id].tools.length>5&&e.jsxs("span",{className:"text-xs opacity-75",children:["+",d[p.id].tools.length-5," 更多"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(K,{onClick:()=>a(p),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"编辑服务器",children:e.jsx(Xt,{className:"w-4 h-4"})}),e.jsx(K,{onClick:()=>o(p.id,p.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"删除服务器",children:e.jsx(Ge,{className:"w-4 h-4"})})]})]})},p.id)),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"未配置 MCP 服务器"})]})]})}function wi({servers:t,onAdd:s,onEdit:a,onDelete:o}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(br,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP 服务器"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol 服务器为 Cursor 提供额外的工具和数据源"}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(K,{onClick:s,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(ot,{className:"w-4 h-4 mr-2"}),"添加 MCP 服务器"]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(n=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(gr,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:n.name}),e.jsx(Ve,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:n.config?.command&&e.jsxs("div",{children:["命令:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:n.config.command})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(K,{onClick:()=>a(n),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",children:e.jsx(Xt,{className:"w-4 h-4"})}),e.jsx(K,{onClick:()=>o(n.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",children:e.jsx(Ge,{className:"w-4 h-4"})})]})]})},n.name||n.id)),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"未配置 MCP 服务器"})]})]})}function ki({servers:t,onAdd:s,onEdit:a,onDelete:o}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(br,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"MCP 服务器"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Model Context Protocol 服务器为 Codex 提供额外的工具和数据源"}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(K,{onClick:s,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[e.jsx(ot,{className:"w-4 h-4 mr-2"}),"添加 MCP 服务器"]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(n=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(gr,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:n.name}),e.jsx(Ve,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[n.config?.command&&e.jsxs("div",{children:["命令:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:n.config.command})]}),n.config?.args&&n.config.args.length>0&&e.jsxs("div",{children:["参数:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:n.config.args.join(" ")})]}),n.config?.env&&Object.keys(n.config.env).length>0&&e.jsxs("div",{children:["环境变量:",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:Object.entries(n.config.env).map(([l,i])=>`${l}=${i}`).join(", ")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(K,{onClick:()=>a(n),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"编辑服务器",children:e.jsx(Xt,{className:"w-4 h-4"})}),e.jsx(K,{onClick:()=>o(n.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"删除服务器",children:e.jsx(Ge,{className:"w-4 h-4"})})]})]})},n.name)),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"未配置 MCP 服务器"})]}),e.jsxs("div",{className:"bg-gray-100 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:"关于 Codex MCP"}),e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Codex 支持基于 stdio 的 MCP 服务器。您可以添加扩展 Codex 功能的服务器,提供额外的工具和资源。"})]})]})}function Ni({agent:t,...s}){return t==="claude"?e.jsx(ji,{...s}):t==="cursor"?e.jsx(wi,{...s}):t==="codex"?e.jsx(ki,{...s}):null}const Si=[{key:"ANTHROPIC_DEFAULT_OPUS_MODEL",label:"Opus 模型",placeholder:"例如: claude-opus-4-6",description:"覆盖 opus 别名使用的模型,Plan Mode 激活时也用于 opusplan"},{key:"ANTHROPIC_DEFAULT_SONNET_MODEL",label:"Sonnet 模型",placeholder:"例如: claude-sonnet-4-5-20250929",description:"覆盖 sonnet 别名使用的模型,Plan Mode 未激活时也用于 opusplan"},{key:"ANTHROPIC_DEFAULT_HAIKU_MODEL",label:"Haiku 模型",placeholder:"例如: claude-haiku-4-5-20251001",description:"覆盖 haiku 别名使用的模型,也用于后台功能"},{key:"CLAUDE_CODE_SUBAGENT_MODEL",label:"Subagent 模型",placeholder:"例如: claude-haiku-4-5-20251001",description:"覆盖子代理(subagents)使用的模型"}],Ci=r.forwardRef(function({onStatusChange:s},a){const[o,n]=r.useState({}),[l,i]=r.useState({}),[d,h]=r.useState(!0),[p,g]=r.useState(!1),[k,y]=r.useState(null),[v,x]=r.useState(null),R=JSON.stringify(o)!==JSON.stringify(l);r.useEffect(()=>{s?.({saving:p,hasChanges:R})},[p,R,s]),r.useEffect(()=>{z()},[]),r.useEffect(()=>{if(k){const u=setTimeout(()=>y(null),3e3);return()=>clearTimeout(u)}},[k]);const z=async()=>{try{h(!0),x(null);const u=await re("/api/settings/models");if(u.ok){const m=await u.json();n(m.models||{}),i(m.models||{})}else{const m=await u.json();x(m.error||"加载模型配置失败")}}catch(u){x(u.message)}finally{h(!1)}},T=async()=>{try{g(!0),y(null);const u=await re("/api/settings/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:o})});if(u.ok)return y("success"),i({...o}),!0;{const m=await u.json();return y("error"),x(m.error||"保存失败"),!1}}catch(u){return y("error"),x(u.message),!1}finally{g(!1)}},C=()=>{n({...l}),y(null)};return r.useImperativeHandle(a,()=>({save:T,reset:C,get hasChanges(){return R},get saving(){return p}}),[R,p,o,l]),d?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-500"}),e.jsx("span",{className:"ml-3 text-sm text-muted-foreground",children:"加载模型配置..."})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-3",children:[e.jsx(Js,{className:"w-4 h-4 text-blue-500 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-blue-700 dark:text-blue-300",children:[e.jsx("p",{children:"自定义模型 ID 来覆盖 Claude Code 使用的默认模型。留空表示使用默认模型。"}),e.jsx("p",{className:"mt-1 text-blue-600 dark:text-blue-400",children:"非 Claude 模型将按 Sonnet 定价计费,但统计中会记录实际模型 ID。"})]})]}),v&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3 text-sm text-red-600 dark:text-red-400",children:v}),k==="success"&&e.jsx("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3 text-sm text-green-600 dark:text-green-400",children:"模型配置已保存"}),Si.map(u=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"font-medium text-sm text-foreground",children:u.label}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:u.description})]}),e.jsx("input",{type:"text",value:o[u.key]||"",onChange:m=>n(j=>({...j,[u.key]:m.target.value})),placeholder:u.placeholder,className:"w-full text-sm bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 px-3 py-2"}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:u.key})]})},u.key))]})});function Ei({onNavigateToUsage:t}){const[s,a]=r.useState([]),[o,n]=r.useState({}),[l,i]=r.useState(!0),[d,h]=r.useState(null),[p,g]=r.useState(!1),[k,y]=r.useState(""),[v,x]=r.useState(""),[R,z]=r.useState(""),[T,C]=r.useState(!1),[u,m]=r.useState(null),[j,w]=r.useState({total_limit_usd:"",daily_limit_usd:""}),[L,F]=r.useState(""),[O,se]=r.useState(!1),[ce,ae]=r.useState(null),[oe,W]=r.useState(""),[I,_]=r.useState(""),[X,je]=r.useState(""),[ie,Z]=r.useState(!1),we=async()=>{try{const D=await re("/api/admin/users");if(D.ok){const $=await D.json();a($.users)}}catch(D){console.error("Error fetching users:",D)}finally{i(!1)}},Me=async()=>{try{const D=await re("/api/admin/usage/summary");if(D.ok){const $=await D.json(),A={};for(const f of $.users)A[f.user_uuid]={total_cost:f.total_cost||0,total_requests:f.total_requests||0,last_active:f.last_active};n(A)}}catch(D){console.error("Error fetching usage data:",D)}};r.useEffect(()=>{we(),Me()},[]);const De=D=>!D||D===0?"$0.00":D<.01?`$${D.toFixed(4)}`:`$${D.toFixed(2)}`,Ce=async(D,$)=>{const A=$==="active"?"disabled":"active";h(D);try{(await re(`/api/admin/users/${D}`,{method:"PATCH",body:JSON.stringify({status:A})})).ok&&a(s.map(H=>H.id===D?{...H,status:A}:H))}catch(f){console.error("Error updating user status:",f)}finally{h(null)}},Oe=async(D,$)=>{if(confirm(`确定要删除用户 "${$}"?这将删除其所有数据。`)){h(D);try{(await re(`/api/admin/users/${D}`,{method:"DELETE"})).ok&&a(s.filter(f=>f.id!==D))}catch(A){console.error("Error deleting user:",A)}finally{h(null)}}},xe=async D=>{if(D.preventDefault(),z(""),!k||!v){z("用户名和密码不能为空");return}if(k.length<3){z("用户名至少3个字符");return}if(v.length<6){z("密码至少6个字符");return}C(!0);try{const $=await ve.admin.createUser(k,v),A=await $.json();$.ok?(await we(),g(!1),y(""),x("")):z(A.error||"创建用户失败")}catch($){console.error("Error creating user:",$),z("网络错误,请稍后再试")}finally{C(!1)}},Se=()=>{g(!1),y(""),x(""),z("")},Re=D=>{m(D),w({total_limit_usd:D.total_limit_usd!==null&&D.total_limit_usd!==void 0?String(D.total_limit_usd):"",daily_limit_usd:D.daily_limit_usd!==null&&D.daily_limit_usd!==void 0?String(D.daily_limit_usd):""}),F("")},ze=()=>{m(null),w({total_limit_usd:"",daily_limit_usd:""}),F("")},he=async D=>{D.preventDefault(),F("");const $=j.total_limit_usd.trim()===""?null:parseFloat(j.total_limit_usd),A=j.daily_limit_usd.trim()===""?null:parseFloat(j.daily_limit_usd);if($!==null&&(isNaN($)||$<0)){F("总额度限制必须是正数或留空");return}if(A!==null&&(isNaN(A)||A<0)){F("每日额度限制必须是正数或留空");return}se(!0);try{const f=await ve.admin.updateUserLimits(u.id,{total_limit_usd:$,daily_limit_usd:A}),H=await f.json();f.ok?(a(s.map(de=>de.id===u.id?{...de,total_limit_usd:$,daily_limit_usd:A}:de)),ze()):F(H.error||"更新限制失败")}catch(f){console.error("Error updating limits:",f),F("网络错误,请稍后再试")}finally{se(!1)}},Le=D=>D==null?"无限制":`$${D.toFixed(2)}`,Te=D=>{ae(D),W(""),_(""),je("")},_e=()=>{ae(null),W(""),_(""),je("")},We=async D=>{if(D.preventDefault(),je(""),!oe){je("请输入新密码");return}if(oe.length<6){je("密码至少需要6个字符");return}if(oe!==I){je("两次输入的密码不一致");return}Z(!0);try{const $=await ve.admin.resetUserPassword(ce.id,oe),A=await $.json();$.ok?_e():je(A.error||"重置密码失败")}catch($){console.error("Error resetting password:",$),je("网络错误,请稍后再试")}finally{Z(!1)}};return l?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"正在加载用户..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"用户管理"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"default",size:"sm",onClick:()=>g(!0),className:"flex items-center gap-2",children:[e.jsx(nn,{className:"w-4 h-4"}),"创建用户"]}),t&&e.jsxs(K,{variant:"outline",size:"sm",onClick:t,className:"flex items-center gap-2",children:[e.jsx(on,{className:"w-4 h-4"}),"使用量统计"]})]})]}),e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[700px]",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-muted-foreground",children:"用户"}),e.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium text-muted-foreground w-16",children:"角色"}),e.jsx("th",{className:"px-3 py-2 text-center text-xs font-medium text-muted-foreground w-16",children:"状态"}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium text-muted-foreground w-20",children:"费用"}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium text-muted-foreground w-28",children:"额度限制"}),e.jsx("th",{className:"px-3 py-2 text-left text-xs font-medium text-muted-foreground w-24",children:"创建时间"}),e.jsx("th",{className:"px-3 py-2 text-right text-xs font-medium text-muted-foreground w-20",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:s.map(D=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-900/30",children:[e.jsx("td",{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[D.role==="admin"?e.jsx(fr,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):e.jsx(Ks,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-foreground text-sm truncate",children:D.username||D.email}),D.email&&D.username&&e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:D.email})]})]})}),e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx("span",{className:`inline-block px-1.5 py-0.5 text-xs rounded whitespace-nowrap ${D.role==="admin"?"bg-blue-500/20 text-blue-400":"bg-gray-500/20 text-gray-400"}`,children:D.role==="admin"?"管理员":"用户"})}),e.jsx("td",{className:"px-3 py-2 text-center",children:e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${D.status==="active"?"bg-green-500":"bg-red-500"}`,title:D.status==="active"?"活跃":"已禁用"})}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsx("span",{className:"font-mono text-xs text-foreground whitespace-nowrap",children:De(o[D.uuid]?.total_cost)})}),e.jsx("td",{className:"px-3 py-2 text-right",children:D.role!=="admin"?e.jsx("button",{onClick:()=>Re(D),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline font-mono whitespace-nowrap",title:"点击编辑额度限制",children:D.total_limit_usd!==null||D.daily_limit_usd!==null?e.jsxs("span",{className:"flex flex-col items-end text-[11px] leading-tight",children:[e.jsxs("span",{children:["总:",Le(D.total_limit_usd)]}),e.jsxs("span",{children:["日:",Le(D.daily_limit_usd)]})]}):e.jsxs("span",{className:"flex items-center gap-1 justify-end",children:[e.jsx(Gs,{className:"w-3 h-3"}),"限额"]})}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"-"})}),e.jsx("td",{className:"px-3 py-2 text-xs text-muted-foreground whitespace-nowrap",children:new Date(D.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("div",{className:"flex items-center justify-end gap-1",children:D.role!=="admin"&&e.jsxs(e.Fragment,{children:[D.username&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>Te(D),disabled:d===D.id,title:"重置密码",children:e.jsx(_r,{className:"w-4 h-4 text-blue-500"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>Ce(D.id,D.status),disabled:d===D.id,title:D.status==="active"?"禁用用户":"启用用户",children:D.status==="active"?e.jsx(ln,{className:"w-4 h-4 text-orange-500"}):e.jsx(cn,{className:"w-4 h-4 text-green-500"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>Oe(D.id,D.username||D.email),disabled:d===D.id,title:"删除用户",children:e.jsx(Ge,{className:"w-4 h-4 text-red-500"})})]})})})]},D.id))})]})}),p&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg w-full max-w-md p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h4",{className:"text-lg font-semibold text-foreground",children:"创建用户"}),e.jsx("button",{onClick:Se,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:xe,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"newUsername",className:"block text-sm font-medium text-foreground mb-1",children:"用户名"}),e.jsx("input",{type:"text",id:"newUsername",value:k,onChange:D=>y(D.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入用户名",disabled:T})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"newPassword",className:"block text-sm font-medium text-foreground mb-1",children:"密码"}),e.jsx("input",{type:"password",id:"newPassword",value:v,onChange:D=>x(D.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入密码",disabled:T})]}),R&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:R})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:Se,disabled:T,children:"取消"}),e.jsx(K,{type:"submit",disabled:T,children:T?"创建中...":"创建"})]})]})]})}),u&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg w-full max-w-md p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h4",{className:"text-lg font-semibold text-foreground",children:["设置额度限制 - ",u.username||u.email]}),e.jsx("button",{onClick:ze,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:he,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"totalLimit",className:"block text-sm font-medium text-foreground mb-1",children:"总额度上限 (USD)"}),e.jsx("input",{type:"number",id:"totalLimit",step:"0.01",min:"0",value:j.total_limit_usd,onChange:D=>w($=>({...$,total_limit_usd:D.target.value})),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"留空表示不限制",disabled:O}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"用户累计使用金额达到此限制后,将无法继续使用"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"dailyLimit",className:"block text-sm font-medium text-foreground mb-1",children:"每日额度上限 (USD)"}),e.jsx("input",{type:"number",id:"dailyLimit",step:"0.01",min:"0",value:j.daily_limit_usd,onChange:D=>w($=>({...$,daily_limit_usd:D.target.value})),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"留空表示不限制",disabled:O}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"用户每日使用金额达到此限制后,需等待次日重置"})]}),o[u.uuid]&&e.jsx("div",{className:"p-3 bg-gray-100 dark:bg-gray-800 rounded-md",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["当前已使用:",e.jsx("span",{className:"font-mono text-foreground",children:De(o[u.uuid]?.total_cost)})]})}),L&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:L})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:ze,disabled:O,children:"取消"}),e.jsx(K,{type:"submit",disabled:O,children:O?"保存中...":"保存"})]})]})]})}),ce&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg w-full max-w-md p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h4",{className:"text-lg font-semibold text-foreground",children:["重置密码 - ",ce.username]}),e.jsx("button",{onClick:_e,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:We,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"resetNewPassword",className:"block text-sm font-medium text-foreground mb-1",children:"新密码"}),e.jsx("input",{type:"password",id:"resetNewPassword",value:oe,onChange:D=>W(D.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入新密码(至少6个字符)",disabled:ie})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"resetConfirmPassword",className:"block text-sm font-medium text-foreground mb-1",children:"确认新密码"}),e.jsx("input",{type:"password",id:"resetConfirmPassword",value:I,onChange:D=>_(D.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请再次输入新密码",disabled:ie})]}),X&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:X})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:_e,disabled:ie,children:"取消"}),e.jsx(K,{type:"submit",disabled:ie,children:ie?"重置中...":"重置密码"})]})]})]})})]})}function Mi(){const[t,s]=r.useState([]),[a,o]=r.useState(!0),[n,l]=r.useState(null),[i,d]=r.useState(!1),[h,p]=r.useState(""),[g,k]=r.useState(""),[y,v]=r.useState(!1),x=async()=>{try{const C=await ve.admin.getEmailDomains();if(C.ok){const u=await C.json();s(u.domains)}}catch(C){console.error("Error fetching email domains:",C)}finally{o(!1)}};r.useEffect(()=>{x()},[]);const R=async C=>{if(C.preventDefault(),k(""),!h){k("域名不能为空");return}if(!/^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(h)){k("域名格式无效,例如: example.com");return}v(!0);try{const m=await ve.admin.addEmailDomain(h.toLowerCase()),j=await m.json();m.ok?(await x(),d(!1),p("")):k(j.error||"添加域名失败")}catch(m){console.error("Error adding domain:",m),k("网络错误,请稍后再试")}finally{v(!1)}},z=async(C,u)=>{if(confirm(`确定要删除域名 "${u}"?删除后该域名的邮箱将无法注册。`)){l(C);try{(await ve.admin.removeEmailDomain(C)).ok&&s(t.filter(j=>j.id!==C))}catch(m){console.error("Error removing domain:",m)}finally{l(null)}}},T=()=>{d(!1),p(""),k("")};return a?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"正在加载..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"邮箱域名白名单"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t.length===0?"未设置白名单,所有邮箱域名均可注册":"只有白名单内的域名邮箱可以注册"})]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>d(!0),className:"flex items-center gap-2",children:[e.jsx(ot,{className:"w-4 h-4"}),"添加域名"]})]}),t.length>0?e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-900/50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-sm font-medium text-muted-foreground",children:"域名"}),e.jsx("th",{className:"px-4 py-3 text-left text-sm font-medium text-muted-foreground",children:"添加时间"}),e.jsx("th",{className:"px-4 py-3 text-right text-sm font-medium text-muted-foreground",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:t.map(C=>e.jsxs("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-900/30",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"font-medium text-foreground",children:C.domain})]})}),e.jsx("td",{className:"px-4 py-3 text-sm text-muted-foreground",children:new Date(C.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>z(C.id,C.domain),disabled:n===C.id,title:"删除域名",children:e.jsx(Ge,{className:"w-4 h-4 text-red-500"})})})})]},C.id))})]})}):e.jsxs("div",{className:"border border-dashed border-gray-300 dark:border-gray-600 rounded-lg p-8 text-center",children:[e.jsx(mr,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"暂无域名白名单,所有邮箱域名均可注册"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"添加域名后,只有白名单内的域名邮箱可以注册"})]}),i&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg w-full max-w-md p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h4",{className:"text-lg font-semibold text-foreground",children:"添加域名"}),e.jsx("button",{onClick:T,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:R,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"newDomain",className:"block text-sm font-medium text-foreground mb-1",children:"邮箱域名"}),e.jsx("input",{type:"text",id:"newDomain",value:h,onChange:C=>p(C.target.value.toLowerCase()),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"例如: example.com",disabled:y}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"输入域名后,该域名下的所有邮箱(如 user@example.com)都可以注册"})]}),g&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:g})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:T,disabled:y,children:"取消"}),e.jsx(K,{type:"submit",disabled:y,children:y?"添加中...":"添加"})]})]})]})})]})}function Li(){const[t,s]=r.useState(""),[a,o]=r.useState(!0),[n,l]=r.useState(!1),[i,d]=r.useState(null);r.useEffect(()=>{h()},[]);const h=async()=>{try{const g=await ve.admin.getDefaultLimits();if(g.ok){const k=await g.json();s(k.default_total_limit_usd!==null?String(k.default_total_limit_usd):"")}}catch(g){console.error("Error fetching default limits:",g)}finally{o(!1)}},p=async g=>{g.preventDefault(),l(!0),d(null);const k=t.trim()===""?null:parseFloat(t);if(k!==null&&(isNaN(k)||k<0)){d("error"),l(!1);return}try{(await ve.admin.updateDefaultLimits({default_total_limit_usd:k})).ok?(d("success"),setTimeout(()=>d(null),2e3)):d("error")}catch(y){console.error("Error updating default limits:",y),d("error")}finally{l(!1)}};return a?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"正在加载..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"新用户默认额度"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"新注册用户将自动应用此总额度限制,留空表示不限制。管理员账户不受此限制。"})]}),e.jsxs("form",{onSubmit:p,className:"flex items-end gap-3",children:[e.jsxs("div",{className:"flex-1 max-w-xs",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-1",children:"默认总额度上限 (USD)"}),e.jsx("input",{type:"number",step:"0.01",min:"0",value:t,onChange:g=>s(g.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"留空表示不限制",disabled:n})]}),e.jsxs(K,{type:"submit",variant:"default",size:"sm",disabled:n,className:"flex items-center gap-2",children:[e.jsx(Bs,{className:"w-4 h-4"}),n?"保存中...":"保存"]}),i==="success"&&e.jsx("span",{className:"text-sm text-green-600",children:"已保存"}),i==="error"&&e.jsx("span",{className:"text-sm text-red-600",children:"请输入有效的正数"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"此设置仅影响新注册的用户,不会修改已有用户的额度。"})]})}function Ii({onBack:t}){const[s,a]=r.useState("week"),[o,n]=r.useState(null),[l,i]=r.useState(!0),[d,h]=r.useState(!1),p=async()=>{try{const T=await re(`/api/admin/usage/dashboard?period=${s}`);if(T.ok){const C=await T.json();n(C)}}catch(T){console.error("Error fetching dashboard data:",T)}finally{i(!1),h(!1)}};r.useEffect(()=>{i(!0),p()},[s]);const g=async()=>{try{h(!0),await re("/api/admin/usage/scan",{method:"POST"}),await p()}catch(T){console.error("Error triggering scan:",T),h(!1)}},k=T=>!T||T===0?"$0.00":T<.01?`$${T.toFixed(4)}`:`$${T.toFixed(2)}`,y=T=>T?T>=1e6?`${(T/1e6).toFixed(1)}M`:T>=1e3?`${(T/1e3).toFixed(1)}K`:T.toString():"0";if(l)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"text-muted-foreground",children:"加载仪表板中..."})});const{totals:v,dailyTrend:x,modelDistribution:R,topUsers:z}=o||{};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[t&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:t,children:[e.jsx(yr,{className:"w-4 h-4 mr-2"}),"返回"]}),e.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"使用情况仪表板"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:["week","month"].map(T=>e.jsx("button",{onClick:()=>a(T),className:`px-4 py-2 text-sm font-medium transition-colors ${s===T?"bg-primary text-primary-foreground":"bg-background text-foreground hover:bg-muted"}`,children:T==="week"?"周":"月"},T))}),e.jsx(K,{variant:"outline",size:"sm",onClick:g,disabled:d,title:"扫描新的使用数据",children:e.jsx(_t,{className:`w-4 h-4 ${d?"animate-spin":""}`})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-green-100 dark:bg-green-900/30 rounded-lg",children:e.jsx(Gs,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"总成本"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:k(v?.totalCost)})]})]})}),e.jsx("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-blue-100 dark:bg-blue-900/30 rounded-lg",children:e.jsx(dn,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"活跃用户"}),e.jsxs("p",{className:"text-2xl font-bold text-foreground",children:[v?.activeUsers||0," / ",v?.totalUsers||0]})]})]})}),e.jsx("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-purple-100 dark:bg-purple-900/30 rounded-lg",children:e.jsx(hr,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"总请求数"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:y(v?.totalRequests)})]})]})}),e.jsx("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-orange-100 dark:bg-orange-900/30 rounded-lg",children:e.jsx(mn,{className:"w-5 h-5 text-orange-600 dark:text-orange-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"会话数"}),e.jsx("p",{className:"text-2xl font-bold text-foreground",children:y(v?.totalSessions)})]})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"每日成本趋势"}),x&&x.length>0?e.jsx("div",{className:"space-y-2",children:x.map(T=>{const C=Math.max(...x.map(m=>m.cost||0),.01),u=(T.cost||0)/C*100;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground w-20 shrink-0",children:new Date(T.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}),e.jsx("div",{className:"flex-1 h-6 bg-gray-100 dark:bg-gray-800 rounded overflow-hidden",children:e.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-600 rounded",style:{width:`${u}%`}})}),e.jsx("span",{className:"text-sm font-mono text-foreground w-16 text-right",children:k(T.cost)})]},T.date)})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"无可用的使用数据"})]}),e.jsxs("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"模型成本"}),R&&R.length>0?e.jsx("div",{className:"space-y-3",children:R.map(T=>{const C=R.reduce((L,F)=>L+(F.cost||0),0)||1,u=(T.cost||0)/C*100,m=(T.normalized_model||T.model||"").toLowerCase(),w=(L=>L.includes("codex")?"bg-orange-500":L.includes("opus")?"bg-purple-500":L.includes("sonnet")?"bg-blue-500":L.includes("haiku")?"bg-green-500":"bg-gray-500")(m);return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(Ve,{variant:"secondary",className:"truncate max-w-[200px]",title:T.model,children:T.model}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[y(T.requests)," 请求"]})]}),e.jsx("span",{className:"text-sm font-mono text-foreground whitespace-nowrap ml-2",children:k(T.cost)})]}),e.jsx("div",{className:"h-2 bg-gray-100 dark:bg-gray-800 rounded overflow-hidden",children:e.jsx("div",{className:`h-full ${w} rounded`,style:{width:`${u}%`}})})]},T.model)})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"无可用的使用数据"})]})]}),e.jsxs("div",{className:"bg-card border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"用户成本"}),z&&z.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[e.jsx("th",{className:"text-left py-2 text-sm font-medium text-muted-foreground",children:"排名"}),e.jsx("th",{className:"text-left py-2 text-sm font-medium text-muted-foreground",children:"用户名"}),e.jsx("th",{className:"text-right py-2 text-sm font-medium text-muted-foreground",children:"请求数"}),e.jsx("th",{className:"text-right py-2 text-sm font-medium text-muted-foreground",children:"成本"})]})}),e.jsx("tbody",{children:z.map((T,C)=>e.jsxs("tr",{className:"border-b border-gray-100 dark:border-gray-800 last:border-0",children:[e.jsxs("td",{className:"py-2 text-sm text-muted-foreground",children:["#",C+1]}),e.jsx("td",{className:"py-2 text-sm font-medium text-foreground",children:T.username}),e.jsx("td",{className:"py-2 text-sm text-right text-muted-foreground",children:y(T.total_requests)}),e.jsx("td",{className:"py-2 text-sm text-right font-mono text-foreground",children:k(T.total_cost)})]},T.user_uuid))})]})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"无可用的使用数据"})]})]})}function Di({onClose:t,onInstalled:s,onOpenRepoManager:a}){const[o,n]=r.useState([]),[l,i]=r.useState([]),[d,h]=r.useState(!0),[p,g]=r.useState(null),[k,y]=r.useState(""),[v,x]=r.useState("all"),[R,z]=r.useState(null);r.useEffect(()=>{T()},[]);const T=async(m=!1)=>{try{h(!0),g(null),m&&await re("/api/skills/repos/refresh",{method:"POST"});const[j,w]=await Promise.all([re("/api/skills/available"),re("/api/skills/repos")]);if(j.ok){const L=await j.json();n(L.skills||[])}if(w.ok){const L=await w.json();i(L.repos||[])}}catch(j){g(j.message)}finally{h(!1)}},C=async m=>{try{z(m.name);const j=await re(`/api/skills/install/${m.name}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({skillPath:m.path})});if(j.ok)T(),s?.();else{const w=await j.json();alert(w.error||"Failed to install skill")}}catch(j){alert(j.message)}finally{z(null)}},u=o.filter(m=>{if(k){const j=k.toLowerCase();if(!m.name.toLowerCase().includes(j)&&!m.title?.toLowerCase().includes(j)&&!m.description?.toLowerCase().includes(j))return!1}return!(v!=="all"&&m.repository!==v)});return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-background rounded-xl shadow-xl w-full max-w-4xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Skills 管理"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>T(!0),disabled:d,children:[e.jsx(_t,{className:`w-4 h-4 ${d?"animate-spin":""}`}),e.jsx("span",{className:"ml-1 hidden sm:inline",children:"刷新"})]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:a,children:[e.jsx(Ot,{className:"w-4 h-4"}),e.jsx("span",{className:"ml-1 hidden sm:inline",children:"仓库管理"})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:t,children:e.jsx(Ue,{className:"w-5 h-5"})})]})]}),e.jsx("div",{className:"px-4 pt-4 pb-2",children:e.jsx("h3",{className:"text-amber-500 font-medium",children:"发现技能"})}),e.jsxs("div",{className:"px-4 pb-4 flex flex-wrap gap-3",children:[e.jsx("div",{className:"flex-1 min-w-[200px]",children:e.jsxs("div",{className:"relative",children:[e.jsx(At,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Ye,{type:"text",placeholder:"搜索技能名称或描述...",value:k,onChange:m=>y(m.target.value),className:"pl-10"})]})}),e.jsxs("select",{value:v,onChange:m=>x(m.target.value),className:"px-3 py-2 rounded-md border border-border bg-background text-foreground text-sm min-w-[120px]",children:[e.jsx("option",{value:"all",children:"全部"}),l.map(m=>e.jsxs("option",{value:`${m.owner}/${m.repo}`,children:[m.owner,"/",m.repo]},`${m.owner}/${m.repo}`))]})]}),e.jsxs("div",{className:"flex-1 overflow-auto px-4 pb-4",children:[p&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 text-red-800 dark:text-red-200 text-sm mb-4",children:p}),d?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):u.length===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:o.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"没有可用的技能"}),e.jsx("p",{className:"text-xs mt-2",children:"请先添加技能仓库"}),e.jsxs(K,{variant:"outline",size:"sm",className:"mt-4",onClick:a,children:[e.jsx(Ot,{className:"w-4 h-4 mr-2"}),"管理仓库"]})]}):e.jsx("p",{children:"没有找到匹配的技能"})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:u.map(m=>e.jsx("div",{className:"border border-border rounded-lg p-4 hover:border-amber-500/50 transition-colors",children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("h4",{className:"font-medium text-foreground",children:m.title||m.name}),e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["skills/",m.name]}),e.jsx(Ve,{variant:"outline",className:"text-xs ml-2",children:m.repository})]})]}),m.description&&e.jsx("p",{className:"text-sm text-muted-foreground flex-1 line-clamp-3 mb-3",children:m.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-auto pt-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>window.open(`https://github.com/${m.repository}`,"_blank"),children:[e.jsx(Vs,{className:"w-4 h-4 mr-1"}),"查看"]}),m.installed?e.jsx(K,{size:"sm",disabled:!0,variant:"outline",className:"ml-auto",children:"已安装"}):e.jsxs(K,{size:"sm",className:"bg-amber-600 hover:bg-amber-700 text-white ml-auto",onClick:()=>C(m),disabled:R===m.name,children:[e.jsx($t,{className:"w-4 h-4 mr-1"}),R===m.name?"安装中...":"安装"]})]})]})},`${m.repository}-${m.name}`))})]})]})})}function Ti({onClose:t,onChanged:s}){const[a,o]=r.useState([]),[n,l]=r.useState(!0),[i,d]=r.useState(null),[h,p]=r.useState(""),[g,k]=r.useState("main"),[y,v]=r.useState(!1),[x,R]=r.useState(null);r.useEffect(()=>{z()},[]);const z=async()=>{try{l(!0),d(null);const u=await re("/api/skills/repos");if(u.ok){const m=await u.json();o(m.repos||[])}else{const m=await u.json();d(m.error||"Failed to fetch repos")}}catch(u){d(u.message)}finally{l(!1)}},T=async u=>{if(u.preventDefault(),!h.trim()){d("请输入仓库 URL");return}try{v(!0),d(null);const m=await re("/api/skills/repos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:h.trim(),branch:g.trim()||"main"})});if(m.ok)p(""),k("main"),z(),s?.();else{const j=await m.json();d(j.error||"Failed to add repo")}}catch(m){d(m.message)}finally{v(!1)}},C=async(u,m)=>{if(confirm(`确定要移除仓库 "${u}/${m}" 吗?`))try{R(`${u}/${m}`);const j=await re(`/api/skills/repos/${u}/${m}`,{method:"DELETE"});if(j.ok)z(),s?.();else{const w=await j.json();alert(w.error||"Failed to remove repo")}}catch(j){alert(j.message)}finally{R(null)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-background rounded-xl shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 border-b border-border",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:t,children:e.jsx(yr,{className:"w-5 h-5"})}),e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"管理技能仓库"})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-6",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 space-y-4",children:[e.jsx("h3",{className:"font-medium text-foreground",children:"添加技能仓库"}),e.jsxs("form",{onSubmit:T,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-muted-foreground mb-1",children:"仓库 URL"}),e.jsx(Ye,{type:"text",placeholder:"owner/name 或 https://github.com/owner/name",value:h,onChange:u=>p(u.target.value),disabled:y})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-muted-foreground mb-1",children:"分支"}),e.jsx(Ye,{type:"text",placeholder:"main",value:g,onChange:u=>k(u.target.value),disabled:y})]}),e.jsxs(K,{type:"submit",disabled:y||!h.trim(),className:"bg-amber-600 hover:bg-amber-700 text-white",children:[e.jsx(ot,{className:"w-4 h-4 mr-2"}),y?"添加中...":"添加仓库"]})]})]}),i&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 text-red-800 dark:text-red-200 text-sm",children:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"font-medium text-foreground",children:"已添加的仓库"}),n?e.jsx("div",{className:"text-center py-4 text-muted-foreground",children:"加载中..."}):a.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(un,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"还没有添加任何仓库"})]}):a.map(u=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-foreground",children:[u.owner,"/",u.repo]}),u.isSystem&&e.jsx(Ve,{variant:"outline",className:"text-xs bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-300",children:"内置"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pn,{className:"w-3 h-3"}),"分支: main"]}),e.jsxs(Ve,{variant:"outline",className:"text-xs",children:["识别到 ",u.skillCount," 个技能"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[!u.isSystem&&u.url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>window.open(u.url,"_blank"),children:e.jsx(Vs,{className:"w-4 h-4"})}),!u.isSystem&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>C(u.owner,u.repo),disabled:x===`${u.owner}/${u.repo}`,className:"text-red-500 hover:text-red-600",children:e.jsx(Ge,{className:"w-4 h-4"})})]})]})},`${u.owner}/${u.repo}`))]})]})]})})}function Pi(){const[t,s]=r.useState([]),[a,o]=r.useState(!0),[n,l]=r.useState(null),[i,d]=r.useState(!1),[h,p]=r.useState(!1),[g,k]=r.useState(!1),y=r.useRef(null);r.useEffect(()=>{v()},[]);const v=async()=>{try{o(!0),l(null);const C=await re("/api/skills");if(C.ok){const u=await C.json();s(u.skills||[])}else{const u=await C.json();l(u.error||"Failed to fetch skills")}}catch(C){l(C.message)}finally{o(!1)}},x=async C=>{if(confirm(`确定要删除技能 "${C}" 吗?`))try{const u=await re(`/api/skills/${C}`,{method:"DELETE"});if(u.ok)v();else{const m=await u.json();alert(m.error||"Failed to delete skill")}}catch(u){alert(u.message)}},R=()=>{y.current?.click()},z=async C=>{const u=C.target.files?.[0];if(u)try{k(!0);const m=new FormData;m.append("skillZip",u);const j=await re("/api/skills/import",{method:"POST",body:m});if(j.ok)v();else{const w=await j.json();alert(w.error||"Failed to import skill")}}catch(m){alert(m.message)}finally{k(!1),y.current&&(y.current.value="")}},T=(C,u)=>{switch(C){case"repo":return e.jsx(Ve,{variant:"outline",className:"text-xs bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300",children:u||"仓库"});case"imported":return e.jsx(Ve,{variant:"outline",className:"text-xs bg-purple-50 dark:bg-purple-900/20 text-purple-700 dark:text-purple-300",children:"导入"});default:return e.jsx(Ve,{variant:"outline",className:"text-xs",children:"本地"})}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ar,{className:"w-5 h-5 text-amber-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:"Skills 管理"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Skills 是 Claude Code 的扩展能力,可以通过 SKILLS.md 文件定义自定义指令和工作流程"}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["已安装:Claude: ",e.jsx("span",{className:"font-medium text-foreground",children:t.length})," 个技能"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("input",{ref:y,type:"file",accept:".zip",className:"hidden",onChange:z}),e.jsxs(K,{onClick:R,variant:"outline",size:"sm",disabled:g,children:[e.jsx($t,{className:"w-4 h-4 mr-2"}),g?"导入中...":"导入已有"]}),e.jsxs(K,{onClick:()=>d(!0),className:"bg-amber-600 hover:bg-amber-700 text-white",size:"sm",children:[e.jsx(At,{className:"w-4 h-4 mr-2"}),"发现技能"]})]})]}),n&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 text-red-800 dark:text-red-200 text-sm",children:n}),e.jsx("div",{className:"space-y-2",children:a?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):t.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ar,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"还没有安装任何技能"}),e.jsx("p",{className:"text-xs mt-2",children:'点击"发现技能"从仓库安装,或"导入已有"上传本地技能'})]}):t.map(C=>e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsx("span",{className:"font-medium text-foreground",children:C.title||C.name}),T(C.source,C.repository)]}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:C.description})]}),e.jsx("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>x(C.name),className:"text-red-500 hover:text-red-600",title:"删除技能",children:e.jsx(Ge,{className:"w-4 h-4"})})})]})},C.name))}),i&&e.jsx(Di,{onClose:()=>d(!1),onInstalled:v,onOpenRepoManager:()=>{d(!1),p(!0)}}),h&&e.jsx(Ti,{onClose:()=>p(!1),onChanged:()=>{}})]})}function Ri({isOpen:t,onClose:s,projects:a=[],initialTab:o="agents"}){const n=Os(),{isDarkMode:l,toggleDarkMode:i}=as(),{user:d,logout:h}=Bt(),p=d?.role==="admin",[g,k]=r.useState([]),[y,v]=r.useState([]),[x,R]=r.useState(""),[z,T]=r.useState(""),[C,u]=r.useState(!1),[m,j]=r.useState(!1),[w,L]=r.useState(null),[F,O]=r.useState("name"),[se,ce]=r.useState([]),[ae,oe]=r.useState(!1),[W,I]=r.useState(null),[_,X]=r.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[je,ie]=r.useState(!1),[Z,we]=r.useState({}),[Me,De]=r.useState({}),[Ce,Oe]=r.useState({}),[xe,Se]=r.useState(o),[Re,ze]=r.useState(""),[he,Le]=r.useState("permissions"),[Te,_e]=r.useState(!1),We=r.useRef(null),[D,$]=r.useState({saving:!1,hasChanges:!1}),A=r.useCallback(E=>$(E),[]),[f,H]=r.useState(""),[de,Ee]=r.useState(""),[Ae,rt]=r.useState(""),[G,ee]=r.useState(""),[b,Q]=r.useState(""),[B,ue]=r.useState(!1),[J,ye]=r.useState(""),[V,pe]=r.useState(!1),[le,fe]=r.useState(""),[ke,ge]=r.useState(!1),[be,He]=r.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[mt,st]=r.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[ut,kt]=r.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[ft,vr]=r.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[Qe,jr]=r.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),bt=async()=>{try{const E=await re("/api/mcp/config/read");if(E.ok){const Ie=await E.json();if(Ie.success&&Ie.servers){ce(Ie.servers);return}}const U=await re("/api/mcp/cli/list");if(U.ok){const Ie=await U.json();if(Ie.success&&Ie.servers){const Xe=Ie.servers.map(et=>({id:et.name,name:et.name,type:et.type,scope:"user",config:{command:et.command||"",args:et.args||[],env:et.env||{},url:et.url||"",headers:et.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));ce(Xe);return}}const te=await re("/api/mcp/servers?scope=user");if(te.ok){const Ie=await te.json();ce(Ie.servers||[])}else console.error("Failed to fetch MCP servers")}catch(E){console.error("Error fetching MCP servers:",E)}},Ut=async E=>{try{W&&await Ht(W.id,"user");const U=await re("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:E.name,type:E.type,scope:E.scope,projectPath:E.projectPath,command:E.config?.command,args:E.config?.args||[],url:E.config?.url,headers:E.config?.headers||{},env:E.config?.env||{}})});if(U.ok){const te=await U.json();if(te.success)return await bt(),!0;throw new Error(te.error||"Failed to save server via Claude CLI")}else{const te=await U.json();throw new Error(te.error||"Failed to save server")}}catch(U){throw console.error("Error saving MCP server:",U),U}},Ht=async(E,U="user")=>{try{const te=await re(`/api/mcp/cli/remove/${E}?scope=${U}`,{method:"DELETE"});if(te.ok){const Ie=await te.json();if(Ie.success)return await bt(),!0;throw new Error(Ie.error||"Failed to delete server via Claude CLI")}else{const Ie=await te.json();throw new Error(Ie.error||"Failed to delete server")}}catch(te){throw console.error("Error deleting MCP server:",te),te}},Lt=async(E,U="user")=>{try{const te=await re(`/api/mcp/servers/${E}/test?scope=${U}`,{method:"POST"});if(te.ok)return(await te.json()).testResult;{const Ie=await te.json();throw new Error(Ie.error||"Failed to test server")}}catch(te){throw console.error("Error testing MCP server:",te),te}},tr=async(E,U="user")=>{try{const te=await re(`/api/mcp/servers/${E}/tools?scope=${U}`,{method:"POST"});if(te.ok)return(await te.json()).toolsResult;{const Ie=await te.json();throw new Error(Ie.error||"Failed to discover tools")}}catch(te){throw console.error("Error discovering MCP tools:",te),te}};r.useEffect(()=>{t&&(It(),Se(o),_e(!1))},[t,o]),r.useEffect(()=>{localStorage.setItem("codeEditorTheme",be),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[be]),r.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",mt.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[mt]),r.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",ut.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ut]),r.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",ft.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ft]),r.useEffect(()=>{localStorage.setItem("codeEditorFontSize",Qe),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Qe]);const It=async()=>{try{let E=null;try{const U=await ve.settings.getAgentPermissions();U.ok&&(E=(await U.json()).agentPermissions)}catch{}if(E)k(E.allowedTools||[]),v(E.disallowedTools||[]),u(E.skipPermissions||!1),O(E.projectSortOrder||"name"),localStorage.setItem("claude-settings",JSON.stringify(E));else{const U=localStorage.getItem("claude-settings");if(U){const te=JSON.parse(U);k(te.allowedTools||[]),v(te.disallowedTools||[]),u(te.skipPermissions||!1),O(te.projectSortOrder||"name")}else k([]),v([]),u(!1),O("name")}await bt()}catch(E){console.error("Error loading tool settings:",E),k([]),v([]),u(!1),O("name")}},wr=async()=>{j(!0),L(null);try{const E={allowedTools:g,disallowedTools:y,skipPermissions:C,projectSortOrder:F,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(E));try{await ve.settings.saveAgentPermissions(E)}catch(U){console.warn("Failed to sync agent permissions to server:",U)}L("success"),setTimeout(()=>{s()},1e3)}catch(E){console.error("Error saving tool settings:",E),L("error")}finally{j(!1)}},at=async E=>{if(E.preventDefault(),ee(""),Q(""),!f){ee("请输入当前密码");return}if(!de){ee("请输入新密码");return}if(de.length<6){ee("新密码至少需要6个字符");return}if(de!==Ae){ee("两次输入的新密码不一致");return}ue(!0);try{const U=await ve.auth.changePassword(f,de),te=await U.json();U.ok?(Q("密码修改成功"),H(""),Ee(""),rt("")):ee(te.error||"修改密码失败")}catch(U){console.error("Error changing password:",U),ee("网络错误,请稍后再试")}finally{ue(!1)}},qt=d?.username&&!d.username.includes("@"),Nt=async()=>{pe(!0),fe(""),ye(""),ge(!1);try{const E=await ve.auth.feishuBindToken(),U=await E.json();E.ok&&U.token?ye(U.token):fe(U.error||"生成失败,请重试")}catch{fe("网络错误,请稍后再试")}finally{pe(!1)}},Jt=()=>{if(!J)return;const E=`/auth ${J}`;if(navigator.clipboard&&window.isSecureContext)navigator.clipboard.writeText(E).then(()=>{ge(!0),setTimeout(()=>ge(!1),2e3)});else{const U=document.createElement("textarea");U.value=E,U.style.position="fixed",U.style.opacity="0",document.body.appendChild(U),U.focus(),U.select();try{document.execCommand("copy"),ge(!0),setTimeout(()=>ge(!1),2e3)}finally{document.body.removeChild(U)}}},it=()=>{X({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),I(null),oe(!1),ze("")},Ze=(E=null)=>{E?(I(E),X({name:E.name,type:E.type,scope:E.scope,projectPath:E.projectPath||"",config:{...E.config},raw:E.raw,importMode:"form",jsonInput:""})):it(),oe(!0)},Je=async E=>{E.preventDefault(),ie(!0);try{if(_.importMode==="json"){const U=await re("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:_.name,jsonConfig:_.jsonInput,scope:_.scope,projectPath:_.projectPath})});if(U.ok){const te=await U.json();if(te.success)await bt(),it(),L("success");else throw new Error(te.error||"Failed to add server via JSON")}else{const te=await U.json();throw new Error(te.error||"Failed to add server")}}else await Ut(_),it(),L("success")}catch(U){alert(`Error: ${U.message}`),L("error")}finally{ie(!1)}},Kt=async(E,U)=>{if(confirm("确定要删除此 MCP 服务器吗?"))try{await Ht(E,U),L("success")}catch(te){alert(`Error: ${te.message}`),L("error")}},pt=async(E,U)=>{try{we({...Z,[E]:{loading:!0}});const te=await Lt(E,U);we({...Z,[E]:te})}catch(te){we({...Z,[E]:{success:!1,message:te.message,details:[]}})}},Dt=async(E,U)=>{try{Oe({...Ce,[E]:!0});const te=await tr(E,U);De({...Me,[E]:te})}catch{De({...Me,[E]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{Oe({...Ce,[E]:!1})}},lt=(E,U)=>{X(te=>({...te,config:{...te.config,[E]:U}}))};return t?e.jsx("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:e.jsxs("div",{className:"bg-background border border-border md:rounded-lg shadow-xl w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ot,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-600"}),e.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:"设置"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:s,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:e.jsx(Ue,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsx("div",{className:"border-b border-border",children:e.jsxs("div",{className:"flex px-4 md:px-6",children:[e.jsx("button",{onClick:()=>Se("agents"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"Agent"}),e.jsx("button",{onClick:()=>Se("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"外观"}),p&&e.jsx("button",{onClick:()=>Se("users"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="users"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"用户"}),e.jsx("button",{onClick:()=>Se("account"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${xe==="account"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"账户"})]})}),e.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[xe==="appearance"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:xe==="appearance"&&e.jsxs("div",{className:"space-y-6 md:space-y-8",children:[e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"深色模式"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"切换浅色和深色主题"})]}),e.jsxs("button",{onClick:i,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":l,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${l?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:l?e.jsx(Or,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Fr,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"项目排序"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"侧边栏中项目的排序方式"})]}),e.jsxs("select",{value:F,onChange:E=>O(E.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-32",children:[e.jsx("option",{value:"name",children:"按字母顺序"}),e.jsx("option",{value:"date",children:"按最近活动"})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"代码编辑器"}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"编辑器主题"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"代码编辑器的默认主题"})]}),e.jsxs("button",{onClick:()=>He(be==="dark"?"light":"dark"),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":be==="dark","aria-label":"Toggle editor theme",children:[e.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),e.jsx("span",{className:`${be==="dark"?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:be==="dark"?e.jsx(Or,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(Fr,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"自动换行"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"在编辑器中默认启用自动换行"})]}),e.jsxs("button",{onClick:()=>st(!mt),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":mt,"aria-label":"Toggle word wrap",children:[e.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),e.jsx("span",{className:`${mt?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"显示小地图"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"在差异视图中显示小地图以便于导航"})]}),e.jsxs("button",{onClick:()=>kt(!ut),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":ut,"aria-label":"Toggle minimap",children:[e.jsx("span",{className:"sr-only",children:"Toggle minimap"}),e.jsx("span",{className:`${ut?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"显示行号"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"在编辑器中显示行号"})]}),e.jsxs("button",{onClick:()=>vr(!ft),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":ft,"aria-label":"Toggle line numbers",children:[e.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),e.jsx("span",{className:`${ft?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"字体大小"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"编辑器字体大小(像素)"})]}),e.jsxs("select",{value:Qe,onChange:E=>jr(E.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-24",children:[e.jsx("option",{value:"10",children:"10px"}),e.jsx("option",{value:"11",children:"11px"}),e.jsx("option",{value:"12",children:"12px"}),e.jsx("option",{value:"13",children:"13px"}),e.jsx("option",{value:"14",children:"14px"}),e.jsx("option",{value:"15",children:"15px"}),e.jsx("option",{value:"16",children:"16px"}),e.jsx("option",{value:"18",children:"18px"}),e.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),xe==="agents"&&e.jsx("div",{className:"flex flex-col h-full min-h-[400px] md:min-h-[500px]",children:e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex px-2 md:px-4 overflow-x-auto",children:[e.jsx("button",{onClick:()=>Le("permissions"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${he==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"权限"}),e.jsx("button",{onClick:()=>Le("mcp"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${he==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"MCP 服务器"}),e.jsx("button",{onClick:()=>Le("skills"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${he==="skills"?"border-amber-600 text-amber-600 dark:text-amber-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"技能"}),e.jsx("button",{onClick:()=>Le("models"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${he==="models"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"模型"})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4",children:[he==="permissions"&&e.jsx(yi,{agent:"claude",skipPermissions:C,setSkipPermissions:u,allowedTools:g,setAllowedTools:k,disallowedTools:y,setDisallowedTools:v,newAllowedTool:x,setNewAllowedTool:R,newDisallowedTool:z,setNewDisallowedTool:T}),he==="mcp"&&e.jsx(Ni,{agent:"claude",servers:se,onAdd:()=>Ze(),onEdit:E=>Ze(E),onDelete:(E,U)=>Kt(E,U),onTest:(E,U)=>pt(E,U),onDiscoverTools:(E,U)=>Dt(E,U),testResults:Z,serverTools:Me,toolsLoading:Ce}),he==="skills"&&e.jsx(Pi,{}),he==="models"&&e.jsx(Ci,{ref:We,onStatusChange:A})]})]})}),xe==="users"&&p&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:Te?e.jsx(Ii,{onBack:()=>_e(!1)}):e.jsxs(e.Fragment,{children:[e.jsx(Ei,{onNavigateToUsage:()=>_e(!0)}),e.jsx(Li,{}),e.jsx(Mi,{})]})}),xe==="account"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"账户"}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-primary/10 rounded-full flex items-center justify-center",children:e.jsx("span",{className:"text-lg font-semibold text-primary",children:d?.username?.charAt(0).toUpperCase()})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:d?.username}),e.jsx("div",{className:"text-sm text-muted-foreground",children:d?.role==="admin"?"管理员":"用户"})]})]})}),qt&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(_r,{className:"w-5 h-5 text-blue-600"}),e.jsx("div",{className:"font-medium text-foreground",children:"修改密码"})]}),e.jsxs("form",{onSubmit:at,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"currentPassword",className:"block text-sm font-medium text-foreground mb-1",children:"当前密码"}),e.jsx("input",{type:"password",id:"currentPassword",value:f,onChange:E=>H(E.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入当前密码",disabled:B})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"newPassword",className:"block text-sm font-medium text-foreground mb-1",children:"新密码"}),e.jsx("input",{type:"password",id:"newPassword",value:de,onChange:E=>Ee(E.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入新密码(至少6个字符)",disabled:B})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirmNewPassword",className:"block text-sm font-medium text-foreground mb-1",children:"确认新密码"}),e.jsx("input",{type:"password",id:"confirmNewPassword",value:Ae,onChange:E=>rt(E.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请再次输入新密码",disabled:B})]}),G&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:G})}),b&&e.jsx("div",{className:"p-3 bg-green-100 dark:bg-green-900/20 border border-green-300 dark:border-green-800 rounded-md",children:e.jsx("p",{className:"text-sm text-green-700 dark:text-green-400",children:b})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(K,{type:"submit",disabled:B,className:"bg-blue-600 hover:bg-blue-700",children:B?"修改中...":"修改密码"})})]})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("img",{src:"/feishu-logo.svg",alt:"飞书",className:"h-4"}),e.jsx("div",{className:"font-medium text-foreground",children:"飞书账号绑定"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-3",children:["生成绑定 Token,在飞书中向机器人发送 ",e.jsx("code",{className:"bg-gray-200 dark:bg-gray-700 px-1 rounded text-xs",children:"/auth <token>"})," 即可完成绑定,Token 有效期 24 小时。"]}),J?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background border border-border rounded-md",children:[e.jsxs("code",{className:"flex-1 text-xs text-foreground font-mono break-all select-all",children:["/auth ",J]}),e.jsx("button",{onClick:Jt,className:"shrink-0 p-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-800 text-muted-foreground hover:text-foreground transition-colors",title:"复制命令",children:ke?e.jsx(cr,{className:"w-4 h-4 text-green-500"}):e.jsx(xn,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"复制上方命令,在飞书私聊机器人中发送"}),e.jsxs("button",{onClick:Nt,disabled:V,className:"flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-50",children:[e.jsx(_t,{className:"w-3 h-3"}),"重新生成"]})]})]}):e.jsxs("div",{className:"space-y-2",children:[le&&e.jsx("p",{className:"text-sm text-red-500",children:le}),e.jsxs(K,{onClick:Nt,disabled:V,variant:"outline",className:"gap-2",children:[V?e.jsx(_t,{className:"w-4 h-4 animate-spin"}):e.jsx(_r,{className:"w-4 h-4"}),V?"生成中...":"生成绑定 Token"]})]})]}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"退出登录"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"结束当前会话"})]}),e.jsxs(K,{variant:"outline",className:"gap-2 text-red-600 dark:text-red-400 border-red-200 dark:border-red-800 hover:bg-red-50 dark:hover:bg-red-900/20",onClick:()=>{confirm("确定要退出登录吗?")&&(s(),n("/"),h())},children:[e.jsx(hn,{className:"w-4 h-4"}),"退出"]})]})})]})}),ae&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:e.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:W?"编辑 MCP 服务器":"添加 MCP 服务器"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:it,children:e.jsx(Ue,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:Je,className:"p-4 space-y-4",children:[!W&&e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("button",{type:"button",onClick:()=>X(E=>({...E,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${_.importMode==="form"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:"表单输入"}),e.jsx("button",{type:"button",onClick:()=>X(E=>({...E,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${_.importMode==="json"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:"JSON 导入"})]}),_.importMode==="form"&&W&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"作用域"}),e.jsxs("div",{className:"flex items-center gap-2",children:[_.scope==="user"?e.jsx($r,{className:"w-4 h-4"}):e.jsx(Et,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:_.scope==="user"?"用户(全局)":"项目(本地)"}),_.scope==="local"&&_.projectPath&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",_.projectPath]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"编辑现有服务器时无法更改作用域"})]}),_.importMode==="form"&&!W&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"作用域 *"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>X(E=>({...E,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${_.scope==="user"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx($r,{className:"w-4 h-4"}),e.jsx("span",{children:"用户(全局)"})]})}),e.jsx("button",{type:"button",onClick:()=>X(E=>({...E,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${_.scope==="local"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(Et,{className:"w-4 h-4"}),e.jsx("span",{children:"项目(本地)"})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:_.scope==="user"?"用户作用域:在您机器上的所有项目中可用":"本地作用域:仅在选定的项目中可用"})]}),_.scope==="local"&&!W&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"项目 *"}),e.jsxs("select",{value:_.projectPath,onChange:E=>X(U=>({...U,projectPath:E.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",required:_.scope==="local",children:[e.jsx("option",{value:"",children:"选择项目..."}),a.map(E=>e.jsx("option",{value:E.path||E.fullPath,children:E.displayName||E.name},E.name))]}),_.projectPath&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Path: ",_.projectPath]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:_.importMode==="json"?"md:col-span-2":"",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"服务器名称 *"}),e.jsx(Ye,{value:_.name,onChange:E=>{X(U=>({...U,name:E.target.value}))},placeholder:"my-server",required:!0})]}),_.importMode==="form"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"传输类型 *"}),e.jsxs("select",{value:_.type,onChange:E=>{X(U=>({...U,type:E.target.value}))},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",children:[e.jsx("option",{value:"stdio",children:"stdio"}),e.jsx("option",{value:"sse",children:"SSE"}),e.jsx("option",{value:"http",children:"HTTP"})]})]})]}),W&&_.raw&&_.importMode==="form"&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsxs("h4",{className:"text-sm font-medium text-foreground mb-2",children:["配置详情 (from ",W.scope==="global"?"~/.claude.json":"project config",")"]}),e.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(_.raw,null,2)})]}),_.importMode==="json"&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"JSON 配置 *"}),e.jsx("textarea",{value:_.jsonInput,onChange:E=>{X(U=>({...U,jsonInput:E.target.value}));try{if(E.target.value.trim()){const U=JSON.parse(E.target.value);U.type?U.type==="stdio"&&!U.command?ze("stdio 类型需要 command 字段"):(U.type==="http"||U.type==="sse")&&!U.url?ze(`${U.type} 类型需要 url 字段`):ze(""):ze("缺少必填字段:type")}}catch{E.target.value.trim()?ze("无效的 JSON 格式"):ze("")}},className:`w-full px-3 py-2 border ${Re?"border-red-500":"border-gray-300 dark:border-gray-600"} bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 font-mono text-sm`,rows:"8",placeholder:`{
136
136
  "type": "stdio",
137
137
  "command": "/path/to/server",
138
138
  "args": ["--api-key", "abc123"],
139
139
  "env": {
140
140
  "CACHE_DIR": "/tmp"
141
141
  }
142
- }`,required:!0}),Re&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:Re}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["以 JSON 格式粘贴您的 MCP 服务器配置。示例格式:",e.jsx("br",{}),"• stdio: ",'{"type":"stdio","command":"npx","args":["@upstash/context7-mcp"]}',e.jsx("br",{}),"• http/sse: ",'{"type":"http","url":"https://api.example.com/mcp"}']})]})}),_.importMode==="form"&&_.type==="stdio"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"命令 *"}),e.jsx(Ve,{value:_.config.command,onChange:E=>lt("command",E.target.value),placeholder:"/path/to/mcp-server",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"参数(每行一个)"}),e.jsx("textarea",{value:Array.isArray(_.config.args)?_.config.args.join(`
142
+ }`,required:!0}),Re&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:Re}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["以 JSON 格式粘贴您的 MCP 服务器配置。示例格式:",e.jsx("br",{}),"• stdio: ",'{"type":"stdio","command":"npx","args":["@upstash/context7-mcp"]}',e.jsx("br",{}),"• http/sse: ",'{"type":"http","url":"https://api.example.com/mcp"}']})]})}),_.importMode==="form"&&_.type==="stdio"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"命令 *"}),e.jsx(Ye,{value:_.config.command,onChange:E=>lt("command",E.target.value),placeholder:"/path/to/mcp-server",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"参数(每行一个)"}),e.jsx("textarea",{value:Array.isArray(_.config.args)?_.config.args.join(`
143
143
  `):"",onChange:E=>lt("args",E.target.value.split(`
144
144
  `).filter(U=>U.trim())),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",rows:"3",placeholder:`--api-key
145
- abc123`})]})]}),_.importMode==="form"&&(_.type==="sse"||_.type==="http")&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"URL *"}),e.jsx(Ve,{value:_.config.url,onChange:E=>lt("url",E.target.value),placeholder:"https://api.example.com/mcp",type:"url",required:!0})]}),_.importMode==="form"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"环境变量(KEY=value,每行一个)"}),e.jsx("textarea",{value:Object.entries(_.config.env||{}).map(([E,U])=>`${E}=${U}`).join(`
145
+ abc123`})]})]}),_.importMode==="form"&&(_.type==="sse"||_.type==="http")&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"URL *"}),e.jsx(Ye,{value:_.config.url,onChange:E=>lt("url",E.target.value),placeholder:"https://api.example.com/mcp",type:"url",required:!0})]}),_.importMode==="form"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"环境变量(KEY=value,每行一个)"}),e.jsx("textarea",{value:Object.entries(_.config.env||{}).map(([E,U])=>`${E}=${U}`).join(`
146
146
  `),onChange:E=>{const U={};E.target.value.split(`
147
147
  `).forEach(te=>{const[Ie,...Xe]=te.split("=");Ie&&Ie.trim()&&(U[Ie.trim()]=Xe.join("=").trim())}),lt("env",U)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",rows:"3",placeholder:`API_KEY=your-key
148
148
  DEBUG=true`})]}),_.importMode==="form"&&(_.type==="sse"||_.type==="http")&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"请求头(KEY=value,每行一个)"}),e.jsx("textarea",{value:Object.entries(_.config.headers||{}).map(([E,U])=>`${E}=${U}`).join(`