@ian2018cs/agenthub 0.1.20 → 0.1.21
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.
- package/dist/assets/{index-C6s2SqL8.js → index-CPhbi9pq.js} +47 -47
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/server/index.js +246 -1
- package/server/services/gemini-usage-scanner.js +249 -0
- package/server/services/pricing.js +46 -0
- package/server/services/usage-scanner.js +7 -0
- package/server/services/user-directories.js +101 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import{j as e,s as Ia,R as Ta,o as Pa,E as Ra,m as $a,b as za,c as _a,h as Aa,p as Fa,d as Oa}from"./vendor-codemirror-C_VWDoZS.js";import{b as Wa,g as Hr,a as s,d as Ba,R as Xe,u as Is,B as Ua,e as Ha,f as os,h as qa}from"./vendor-react-BeVl62c0.js";import{t as Ja,c as Ka,a as Ts,F as Va}from"./vendor-utils-00TdZexr.js";import{F as Dr,X as Oe,C as Ga,L as ft,M as Dt,R as or,S as It,a as rt,b as kt,c as wr,d as is,T as Ve,P as Ht,e as kr,f as Lt,g as Ir,h as Ya,i as st,j as Tt,k as Qa,l as Za,m as nr,B as Ps,D as qr,n as Rs,o as Xa,p as $s,U as ls,q as en,E as zs,r as tn,s as rn,t as _s,u as cs,v as mr,I as As,w as Pt,x as ur,y as pr,G as Tr,Z as sn,z as an,A as nn,H as on,J as Fs,K as Os,N as Ws,O as ln,Q as cn,V as ir,W as xr,Y as dn,_ as mn,$ as Bs,a0 as un,a1 as pn,a2 as Pr,a3 as Rr,a4 as $r,a5 as xn,a6 as hn,a7 as gn,a8 as fn,a9 as bn,aa as yn,ab as vn}from"./vendor-icons-BhAhsylI.js";import{r as jn,a as wn,b as kn,M as Nn}from"./vendor-markdown-VwNYkg_0.js";import{h as Sn}from"./vendor-syntax-CdGaPJRS.js";import{r as Cn,a as En,b as Mn,c as Ln}from"./vendor-xterm-CvdiG4-n.js";import"./vendor-katex-DK8hFnhL.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))o(n);new MutationObserver(n=>{for(const c of n)if(c.type==="childList")for(const i of c.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function a(n){const c={};return n.integrity&&(c.integrity=n.integrity),n.referrerPolicy&&(c.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?c.credentials="include":n.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function o(n){if(n.ep)return;n.ep=!0;const c=a(n);fetch(n.href,c)}})();var er={},ds;function Dn(){if(ds)return er;ds=1;var t=Wa();return er.createRoot=t.createRoot,er.hydrateRoot=t.hydrateRoot,er}var In=Dn();const Tn=Hr(In);function Fe(...t){return Ja(Ka(t))}function Pn(t){if(!t||typeof t!="string")return null;try{return JSON.parse(t)}catch{return null}}const Jr=s.forwardRef(({className:t,children:r,...a},o)=>e.jsx("div",{ref:o,className:Fe("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:r})}));Jr.displayName="ScrollArea";const Rn=Ts("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"}}),J=s.forwardRef(({className:t,variant:r,size:a,...o},n)=>e.jsx("button",{className:Fe(Rn({variant:r,size:a,className:t})),ref:n,...o}));J.displayName="Button";const $n=Ts("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 Ge({className:t,variant:r,...a}){return e.jsx("div",{className:Fe($n({variant:r}),t),...a})}const Ke=s.forwardRef(({className:t,type:r,...a},o)=>e.jsx("input",{type:r,className:Fe("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}));Ke.displayName="Input";const ot=({className:t="w-5 h-5"})=>e.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:t}),ne=(t,r={})=>{const a=localStorage.getItem("auth-token"),o={};return r.body instanceof FormData||(o["Content-Type"]="application/json"),a&&(o.Authorization=`Bearer ${a}`),fetch(t,{...r,headers:{...o,...r.headers}})},we={auth:{status:()=>fetch("/api/auth/status"),login:(t,r)=>fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:r})}),sendCode:t=>fetch("/api/auth/send-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t})}),verifyCode:(t,r)=>fetch("/api/auth/verify-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t,code:r})}),user:()=>ne("/api/auth/user"),logout:()=>ne("/api/auth/logout",{method:"POST"}),limitStatus:()=>ne("/api/auth/limit-status"),changePassword:(t,r)=>ne("/api/auth/change-password",{method:"PATCH",body:JSON.stringify({current_password:t,new_password:r})})},admin:{getUsers:()=>ne("/api/admin/users"),createUser:(t,r)=>ne("/api/admin/users",{method:"POST",body:JSON.stringify({username:t,password:r})}),updateUserStatus:(t,r)=>ne(`/api/admin/users/${t}`,{method:"PATCH",body:JSON.stringify({status:r})}),deleteUser:t=>ne(`/api/admin/users/${t}`,{method:"DELETE"}),getEmailDomains:()=>ne("/api/admin/email-domains"),addEmailDomain:t=>ne("/api/admin/email-domains",{method:"POST",body:JSON.stringify({domain:t})}),removeEmailDomain:t=>ne(`/api/admin/email-domains/${t}`,{method:"DELETE"}),getUserLimits:t=>ne(`/api/admin/users/${t}/limits`),updateUserLimits:(t,r)=>ne(`/api/admin/users/${t}/limits`,{method:"PATCH",body:JSON.stringify(r)}),resetUserPassword:(t,r)=>ne(`/api/admin/users/${t}/password`,{method:"PATCH",body:JSON.stringify({new_password:r})})},projects:()=>ne("/api/projects"),sessions:(t,r=5,a=0)=>ne(`/api/projects/${t}/sessions?limit=${r}&offset=${a}`),sessionMessages:(t,r,a=null,o=0)=>{const n=new URLSearchParams;a!==null&&(n.append("limit",a),n.append("offset",o));const c=n.toString(),i=`/api/projects/${t}/sessions/${r}/messages${c?`?${c}`:""}`;return ne(i)},renameProject:(t,r)=>ne(`/api/projects/${t}/rename`,{method:"PUT",body:JSON.stringify({displayName:r})}),deleteSession:(t,r)=>ne(`/api/projects/${t}/sessions/${r}`,{method:"DELETE"}),deleteProject:t=>ne(`/api/projects/${t}`,{method:"DELETE"}),createProject:t=>ne("/api/projects/create",{method:"POST",body:JSON.stringify({path:t})}),createWorkspace:t=>ne("/api/projects/create-workspace",{method:"POST",body:JSON.stringify(t)}),readFile:(t,r)=>ne(`/api/projects/${t}/file?filePath=${encodeURIComponent(r)}`),saveFile:(t,r,a)=>ne(`/api/projects/${t}/file`,{method:"PUT",body:JSON.stringify({filePath:r,content:a})}),getFiles:(t,r={})=>{const a=new URLSearchParams;r.dirPath&&a.set("dirPath",r.dirPath),r.depth&&a.set("depth",r.depth.toString());const o=a.toString();return ne(`/api/projects/${t}/files${o?"?"+o:""}`)},uploadFiles:(t,r)=>ne(`/api/projects/${t}/upload-files`,{method:"POST",body:r,headers:{}}),deleteFile:(t,r)=>ne(`/api/projects/${t}/files?filePath=${encodeURIComponent(r)}`,{method:"DELETE"}),transcribe:t=>ne("/api/transcribe",{method:"POST",body:t,headers:{}}),get:t=>ne(`/api${t}`)},zn=/^[a-zA-Z0-9_-]+$/,_n=({onClose:t,onProjectCreated:r})=>{const[a,o]=s.useState(""),[n,c]=s.useState(""),[i,m]=s.useState(!1),[h,p]=s.useState(null),b=j=>j.trim()?zn.test(j.trim())?null:"项目名称只能包含字母、数字、连字符和下划线":"项目名称为必填项",E=async()=>{p(null);const j=b(a);if(j){p(j);return}m(!0);try{const g={name:a.trim()};n.trim()&&(g.githubUrl=n.trim());const $=await we.createWorkspace(g),L=await $.json();if(!$.ok)throw new Error(L.error||"Failed to create project");r&&r(L.project),t()}catch(g){console.error("Error creating project:",g),p(g.message||"Failed to create project")}finally{m(!1)}},v=j=>{j.key==="Enter"&&!i&&E()};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(Dr,{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(Oe,{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(Ga,{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(Ke,{type:"text",value:a,onChange:j=>o(j.target.value),onKeyDown:v,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(Ke,{type:"text",value:n,onChange:j=>c(j.target.value),onKeyDown:v,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(J,{variant:"outline",onClick:t,disabled:i,children:"取消"}),e.jsx(J,{onClick:E,disabled:i||!a.trim(),children:i?e.jsxs(e.Fragment,{children:[e.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):"创建项目"})]})]})})},ms=(t,r)=>{const a=new Date(t),o=r;if(isNaN(a.getTime()))return"Unknown";const n=o-a,c=Math.floor(n/1e3),i=Math.floor(n/(1e3*60)),m=Math.floor(n/(1e3*60*60)),h=Math.floor(n/(1e3*60*60*24));return c<60?"Just now":i===1?"1 min ago":i<60?`${i} mins ago`:m===1?"1 hour ago":m<24?`${m} hours ago`:h===1?"1 day ago":h<7?`${h} days ago`:a.toLocaleDateString()};function us({projects:t,selectedProject:r,selectedSession:a,onProjectSelect:o,onSessionSelect:n,onNewSession:c,onSessionDelete:i,onProjectDelete:m,isLoading:h,onRefresh:p,onShowSettings:b,isPWA:E,isMobile:v,onToggleSidebar:j}){const[g,$]=s.useState(new Set),[L,I]=s.useState(null),[C,x]=s.useState(!1),[d,k]=s.useState(""),[S,A]=s.useState({}),[W,O]=s.useState({}),[Q,ie]=s.useState(new Set),[Z,se]=s.useState(new Date),[B,T]=s.useState("name"),[z,Y]=s.useState(!1),[pe,ae]=s.useState(null),[G,xe]=s.useState(""),[Ne,Ce]=s.useState({}),[je,_e]=s.useState(""),[he,Se]=s.useState(()=>{try{const u=localStorage.getItem("starredProjects");return u?new Set(JSON.parse(u)):new Set}catch(u){return console.error("Error loading starred projects:",u),new Set}}),ke=u=>_=>{_.target.closest(".overflow-y-auto")||_.target.closest("[data-scroll-container]")||(_.preventDefault(),_.stopPropagation(),u())};s.useEffect(()=>{const u=setInterval(()=>{se(new Date)},6e4);return()=>clearInterval(u)},[]),s.useEffect(()=>{O({}),ie(new Set)},[t]),s.useEffect(()=>{a&&r&&$(u=>new Set([...u,r.name]))},[a,r]),s.useEffect(()=>{if(t.length>0&&!h){const u=new Set;t.forEach(_=>{_.sessions&&_.sessions.length>=0&&u.add(_.name)}),ie(u)}},[t,h]),s.useEffect(()=>{const u=()=>{try{const te=localStorage.getItem("claude-settings");if(te){const D=JSON.parse(te);T(D.projectSortOrder||"name")}}catch(te){console.error("Error loading sort order:",te)}};u();const _=te=>{te.key==="claude-settings"&&u()};window.addEventListener("storage",_);const X=setInterval(()=>{document.hasFocus()&&u()},1e3);return()=>{window.removeEventListener("storage",_),clearInterval(X)}},[]);const Ee=u=>{const _=new Set;g.has(u)||_.add(u),$(_)},ye=(u,_)=>{n({...u,__projectName:_})},Pe=u=>{const _=new Set(he);_.has(u)?_.delete(u):_.add(u),Se(_);try{localStorage.setItem("starredProjects",JSON.stringify([..._]))}catch(X){console.error("Error saving starred projects:",X)}},Re=u=>he.has(u),Me=u=>[...u.sessions||[],...W[u.name]||[]].map(X=>({...X,__provider:"claude"})).sort((X,te)=>new Date(te.lastActivity)-new Date(X.lastActivity)),H=u=>{const _=Me(u);return _.length===0?new Date(0):_.reduce((te,D)=>{const De=new Date(D.lastActivity);return De>te?De:te},new Date(0))},f=[...t].sort((u,_)=>{const X=Re(u.name),te=Re(_.name);if(X&&!te)return-1;if(!X&&te)return 1;if(B==="date")return H(_)-H(u);{const D=u.displayName||u.name,De=_.displayName||_.name;return D.localeCompare(De)}}),y=u=>{I(u.name),k(u.displayName)},F=()=>{I(null),k("")},oe=async u=>{try{(await we.renameProject(u,d)).ok?window.refreshProjects?window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(_){console.error("Error renaming project:",_)}I(null),k("")},ue=async(u,_,X="claude")=>{if(confirm("Are you sure you want to delete this session? This action cannot be undone."))try{console.log("[Sidebar] Deleting session:",{projectName:u,sessionId:_,provider:X});const te=await we.deleteSession(u,_);if(console.log("[Sidebar] Delete response:",{ok:te.ok,status:te.status}),te.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),i?i(_):console.warn("[Sidebar] No onSessionDelete callback provided");else{const D=await te.text();console.error("[Sidebar] Failed to delete session:",{status:te.status,error:D}),alert("Failed to delete session. Please try again.")}}catch(te){console.error("[Sidebar] Error deleting session:",te),alert("Error deleting session. Please try again.")}},Le=async u=>{if(confirm("Are you sure you want to delete this empty project? This action cannot be undone."))try{const _=await we.deleteProject(u);if(_.ok)m&&m(u);else{const X=await _.json();console.error("Failed to delete project"),alert(X.error||"Failed to delete project. Please try again.")}}catch(_){console.error("Error deleting project:",_),alert("Error deleting project. Please try again.")}},He=async u=>{if(!(!(u.sessionMeta?.hasMore!==!1)||S[u.name])){A(X=>({...X,[u.name]:!0}));try{const X=(u.sessions?.length||0)+(W[u.name]?.length||0),te=await we.sessions(u.name,5,X);if(te.ok){const D=await te.json();O(De=>({...De,[u.name]:[...De[u.name]||[],...D.sessions]})),D.hasMore===!1&&(u.sessionMeta={...u.sessionMeta,hasMore:!1})}}catch(X){console.error("Error loading more sessions:",X)}finally{A(X=>({...X,[u.name]:!1}))}}},Ye=f.filter(u=>{if(!je.trim())return!0;const _=je.toLowerCase(),X=(u.displayName||u.name).toLowerCase(),te=u.name.toLowerCase();return X.includes(_)||te.includes(_)}),qe=u=>{o(u)};return e.jsxs(e.Fragment,{children:[C&&Ba.createPortal(e.jsx(_n,{onClose:()=>x(!1),onProjectCreated:u=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),e.jsxs("div",{className:"h-full flex flex-col bg-card md:select-none",style:E&&v?{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("div",{className:"w-8 h-8 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:e.jsx(Dt,{className:"w-4 h-4 text-primary-foreground"})}),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 助手"})]})]}),j&&e.jsx(J,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 hover:bg-accent transition-colors duration-200",onClick:j,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:E&&v?{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("div",{className:"w-8 h-8 bg-primary rounded-lg flex items-center justify-center",children:e.jsx(Dt,{className:"w-4 h-4 text-primary-foreground"})}),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()=>{Y(!0);try{await p()}finally{Y(!1)}},disabled:z,children:e.jsx(or,{className:`w-4 h-4 text-foreground ${z?"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:()=>x(!0),children:e.jsx(Dr,{className:"w-4 h-4"})})]})]})})]}),!h&&!v&&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(J,{variant:"default",size:"sm",className:"flex-1 h-8 text-xs bg-primary hover:bg-primary/90 transition-all duration-200",onClick:()=>x(!0),title:"创建新项目",children:[e.jsx(Dr,{className:"w-3.5 h-3.5 mr-1.5"}),"新建项目"]}),e.jsx(J,{variant:"outline",size:"sm",className:"h-8 w-8 px-0 hover:bg-accent transition-colors duration-200 group",onClick:async()=>{Y(!0);try{await p()}finally{Y(!1)}},disabled:z,title:"刷新项目和会话 (Ctrl+R)",children:e.jsx(or,{className:`w-3.5 h-3.5 ${z?"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(It,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Ke,{type:"text",placeholder:"搜索项目...",value:je,onChange:u=>_e(u.target.value),className:"pl-9 h-9 text-sm bg-muted/50 border-0 focus:bg-background focus:ring-1 focus:ring-primary/20"}),je&&e.jsx("button",{onClick:()=>_e(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 hover:bg-accent rounded",children:e.jsx(Oe,{className:"w-3 h-3 text-muted-foreground"})})]})}),e.jsx(Jr,{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(rt,{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 以开始使用"})]}):Ye.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(It,{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:"尝试调整搜索条件"})]}):Ye.map(u=>{const _=g.has(u.name),X=r?.name===u.name,te=Re(u.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:Fe("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",X&&"bg-primary/5 border-primary/20",te&&!X&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:()=>{Ee(u.name)},onTouchEnd:ke(()=>Ee(u.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:Fe("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",_?"bg-primary/10":"bg-muted"),children:_?e.jsx(kt,{className:"w-4 h-4 text-primary"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground"})}),e.jsx("div",{className:"min-w-0 flex-1",children:L===u.name?e.jsx("input",{type:"text",value:d,onChange:D=>k(D.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:D=>D.stopPropagation(),onKeyDown:D=>{D.key==="Enter"&&oe(u.name),D.key==="Escape"&&F()},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:u.displayName})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(()=>{const D=Me(u).length;return`${u.sessionMeta?.hasMore!==!1&&D>=5?`${D}+`:D} 会话`})()})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:L===u.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:D=>{D.stopPropagation(),oe(u.name)},children:e.jsx(wr,{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:D=>{D.stopPropagation(),F()},children:e.jsx(Oe,{className:"w-4 h-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:Fe("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",te?"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:D=>{D.stopPropagation(),Pe(u.name)},onTouchEnd:ke(()=>Pe(u.name)),title:te?"从收藏中移除":"添加到收藏",children:e.jsx(is,{className:Fe("w-4 h-4 transition-colors",te?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),Me(u).length===0&&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:D=>{D.stopPropagation(),Le(u.name)},onTouchEnd:ke(()=>Le(u.name)),children:e.jsx(Ve,{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:D=>{D.stopPropagation(),y(u)},onTouchEnd:ke(()=>y(u)),children:e.jsx(Ht,{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:_?e.jsx(kr,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(Lt,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),e.jsxs(J,{variant:"ghost",className:Fe("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",X&&"bg-accent text-accent-foreground",te&&!X&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:()=>{r?.name!==u.name&&qe(u),Ee(u.name)},onTouchEnd:ke(()=>{r?.name!==u.name&&qe(u),Ee(u.name)}),children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[_?e.jsx(kt,{className:"w-4 h-4 text-primary flex-shrink-0"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:L===u.name?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:d,onChange:D=>k(D.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:D=>{D.key==="Enter"&&oe(u.name),D.key==="Escape"&&F()}}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",title:u.fullPath,children:u.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold truncate text-foreground",title:u.displayName,children:u.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[(()=>{const D=Me(u).length;return u.sessionMeta?.hasMore!==!1&&D>=5?`${D}+`:D})(),u.fullPath!==u.displayName&&e.jsxs("span",{className:"ml-1 opacity-60",title:u.fullPath,children:["• ",u.fullPath.length>25?"..."+u.fullPath.slice(-22):u.fullPath]})]})]})})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:L===u.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:D=>{D.stopPropagation(),oe(u.name)},children:e.jsx(wr,{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:D=>{D.stopPropagation(),F()},children:e.jsx(Oe,{className:"w-3 h-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:Fe("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",te?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100":"hover:bg-accent"),onClick:D=>{D.stopPropagation(),Pe(u.name)},title:te?"从收藏中移除":"添加到收藏",children:e.jsx(is,{className:Fe("w-3 h-3 transition-colors",te?"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:D=>{D.stopPropagation(),y(u)},title:"重命名项目 (F2)",children:e.jsx(Ht,{className:"w-3 h-3"})}),Me(u).length===0&&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:D=>{D.stopPropagation(),Le(u.name)},title:"删除空项目 (Delete)",children:e.jsx(Ve,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),_?e.jsx(kr,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):e.jsx(Lt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),_&&e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[Q.has(u.name)?Me(u).length===0&&!S[u.name]?e.jsx("div",{className:"py-2 px-3 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"还没有会话"})}):Me(u).map(D=>{const De=new Date(D.lastActivity),Ie=Math.floor((Z-De)/(1e3*60))<10,q=D.summary||"新会话",me=D.lastActivity,re=D.messageCount||0;return e.jsxs("div",{className:"group relative",children:[Ie&&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:Fe("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",a?.id===D.id?"bg-primary/5 border-primary/20":Ie?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:()=>{qe(u),ye(D,u.name)},onTouchEnd:ke(()=>{qe(u),ye(D,u.name)}),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:Fe("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",a?.id===D.id?"bg-primary/10":"bg-muted/50"),children:e.jsx(ot,{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:q}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Ir,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(me,Z)}),re>0&&e.jsx(Ge,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:re}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(ot,{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:le=>{le.stopPropagation(),ue(u.name,D.id)},onTouchEnd:ke(()=>ue(u.name,D.id)),children:e.jsx(Ve,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})]})})}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx(J,{variant:"ghost",className:Fe("w-full justify-start p-2 h-auto font-normal text-left hover:bg-accent/50 transition-colors duration-200",a?.id===D.id&&"bg-accent text-accent-foreground"),onClick:()=>ye(D,u.name),onTouchEnd:ke(()=>ye(D,u.name)),children:e.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full",children:[e.jsx(ot,{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:q}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Ir,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ms(me,Z)}),re>0&&e.jsx(Ge,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:re}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(ot,{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:pe===D.id?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:G,onChange:le=>xe(le.target.value),onKeyDown:le=>{le.stopPropagation(),le.key==="Enter"?updateSessionSummary(u.name,D.id,G):le.key==="Escape"&&(ae(null),xe(""))},onClick:le=>le.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:le=>{le.stopPropagation(),updateSessionSummary(u.name,D.id,G)},title:"Save",children:e.jsx(wr,{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:le=>{le.stopPropagation(),ae(null),xe("")},title:"Cancel",children:e.jsx(Oe,{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:le=>{le.stopPropagation(),ae(D.id),xe(D.summary||"新会话")},title:"手动编辑会话名称",children:e.jsx(Ya,{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:le=>{le.stopPropagation(),ue(u.name,D.id)},title:"永久删除此会话",children:e.jsx(Ve,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]},D.id)}):Array.from({length:3}).map((D,De)=>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+De*15}%`}}),e.jsx("div",{className:"h-2 bg-muted rounded animate-pulse w-1/2"})]})]})},De)),Me(u).length>0&&u.sessionMeta?.hasMore!==!1&&e.jsx(J,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>He(u),disabled:S[u.name],children:S[u.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(kr,{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:()=>{qe(u),c(u)},children:[e.jsx(st,{className:"w-3 h-3"}),"新会话"]})}),e.jsxs(J,{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:()=>c(u),children:[e.jsx(st,{className:"w-3 h-3"}),"新会话"]})]})]},u.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:b,children:[e.jsx("div",{className:"w-10 h-10 rounded-2xl bg-background/80 flex items-center justify-center",children:e.jsx(Tt,{className:"w-5 h-5 text-muted-foreground"})}),e.jsx("span",{className:"text-lg font-medium text-foreground",children:"设置"})]})}),e.jsxs(J,{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:b,children:[e.jsx(Tt,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:"设置"})]})]})]})]})}const An={'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 Nr={exports:{}},Sr,ps;function Fn(){if(ps)return Sr;ps=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Sr=t,Sr}var Cr,xs;function On(){if(xs)return Cr;xs=1;var t=Fn();function r(){}function a(){}return a.resetWarningCache=r,Cr=function(){function o(i,m,h,p,b,E){if(E!==t){var v=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 v.name="Invariant Violation",v}}o.isRequired=o;function n(){return o}var c={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:r};return c.PropTypes=c,c},Cr}var hs;function Wn(){return hs||(hs=1,Nr.exports=On()()),Nr.exports}var Bn=Wn();const $e=Hr(Bn);function Nt(t,r,a,o){function n(c){return c instanceof a?c:new a(function(i){i(c)})}return new(a||(a=Promise))(function(c,i){function m(b){try{p(o.next(b))}catch(E){i(E)}}function h(b){try{p(o.throw(b))}catch(E){i(E)}}function p(b){b.done?c(b.value):n(b.value).then(m,h)}p((o=o.apply(t,r||[])).next())})}const Un=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 Rt(t,r,a){const o=Hn(t),{webkitRelativePath:n}=t,c=typeof r=="string"?r:typeof n=="string"&&n.length>0?n:`./${t.name}`;return typeof o.path!="string"&&gs(o,"path",c),gs(o,"relativePath",c),o}function Hn(t){const{name:r}=t;if(r&&r.lastIndexOf(".")!==-1&&!t.type){const o=r.split(".").pop().toLowerCase(),n=Un.get(o);n&&Object.defineProperty(t,"type",{value:n,writable:!1,configurable:!1,enumerable:!0})}return t}function gs(t,r,a){Object.defineProperty(t,r,{value:a,writable:!1,configurable:!1,enumerable:!0})}const qn=[".DS_Store","Thumbs.db"];function Jn(t){return Nt(this,void 0,void 0,function*(){return lr(t)&&Kn(t.dataTransfer)?Qn(t.dataTransfer,t.type):Vn(t)?Gn(t):Array.isArray(t)&&t.every(r=>"getFile"in r&&typeof r.getFile=="function")?Yn(t):[]})}function Kn(t){return lr(t)}function Vn(t){return lr(t)&&lr(t.target)}function lr(t){return typeof t=="object"&&t!==null}function Gn(t){return zr(t.target.files).map(r=>Rt(r))}function Yn(t){return Nt(this,void 0,void 0,function*(){return(yield Promise.all(t.map(a=>a.getFile()))).map(a=>Rt(a))})}function Qn(t,r){return Nt(this,void 0,void 0,function*(){if(t.items){const a=zr(t.items).filter(n=>n.kind==="file");if(r!=="drop")return a;const o=yield Promise.all(a.map(Zn));return fs(Us(o))}return fs(zr(t.files).map(a=>Rt(a)))})}function fs(t){return t.filter(r=>qn.indexOf(r.name)===-1)}function zr(t){if(t===null)return[];const r=[];for(let a=0;a<t.length;a++){const o=t[a];r.push(o)}return r}function Zn(t){if(typeof t.webkitGetAsEntry!="function")return bs(t);const r=t.webkitGetAsEntry();return r&&r.isDirectory?Hs(r):bs(t,r)}function Us(t){return t.reduce((r,a)=>[...r,...Array.isArray(a)?Us(a):[a]],[])}function bs(t,r){return Nt(this,void 0,void 0,function*(){var a;if(globalThis.isSecureContext&&typeof t.getAsFileSystemHandle=="function"){const c=yield t.getAsFileSystemHandle();if(c===null)throw new Error(`${t} is not a File`);if(c!==void 0){const i=yield c.getFile();return i.handle=c,Rt(i)}}const o=t.getAsFile();if(!o)throw new Error(`${t} is not a File`);return Rt(o,(a=r?.fullPath)!==null&&a!==void 0?a:void 0)})}function Xn(t){return Nt(this,void 0,void 0,function*(){return t.isDirectory?Hs(t):eo(t)})}function Hs(t){const r=t.createReader();return new Promise((a,o)=>{const n=[];function c(){r.readEntries(i=>Nt(this,void 0,void 0,function*(){if(i.length){const m=Promise.all(i.map(Xn));n.push(m),c()}else try{const m=yield Promise.all(n);a(m)}catch(m){o(m)}}),i=>{o(i)})}c()})}function eo(t){return Nt(this,void 0,void 0,function*(){return new Promise((r,a)=>{t.file(o=>{const n=Rt(o,t.fullPath);r(n)},o=>{a(o)})})})}var tr={},ys;function to(){return ys||(ys=1,tr.__esModule=!0,tr.default=function(t,r){if(t&&r){var a=Array.isArray(r)?r:r.split(",");if(a.length===0)return!0;var o=t.name||"",n=(t.type||"").toLowerCase(),c=n.replace(/\/.*$/,"");return a.some(function(i){var m=i.trim().toLowerCase();return m.charAt(0)==="."?o.toLowerCase().endsWith(m):m.endsWith("/*")?c===m.replace(/\/.*$/,""):n===m})}return!0}),tr}var ro=to();const Er=Hr(ro);function vs(t){return no(t)||ao(t)||Js(t)||so()}function so(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ao(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function no(t){if(Array.isArray(t))return _r(t)}function
|
|
3
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
4
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function To(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function
|
|
5
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Qs(t,r){if(t){if(typeof t=="string")return Ar(t,r);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 Ar(t,r)}}function Ar(t,r){(r==null||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a<r;a++)o[a]=t[a];return o}function $o(t,r){var a=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(a!=null){var o=[],n=!0,c=!1,i,m;try{for(a=a.call(t);!(n=(i=a.next()).done)&&(o.push(i.value),!(r&&o.length===r));n=!0);}catch(h){c=!0,m=h}finally{try{!n&&a.return!=null&&a.return()}finally{if(c)throw m}}return o}}function zo(t){if(Array.isArray(t))return t}function Cs(t,r){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,o)}return a}function Ae(t){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?Cs(Object(a),!0).forEach(function(o){Fr(t,o,a[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):Cs(Object(a)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(a,o))})}return t}function Fr(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function dr(t,r){if(t==null)return{};var a=_o(t,r),o,n;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(t);for(n=0;n<c.length;n++)o=c[n],!(r.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(t,o)&&(a[o]=t[o])}return a}function _o(t,r){if(t==null)return{};var a={},o=Object.keys(t),n,c;for(c=0;c<o.length;c++)n=o[c],!(r.indexOf(n)>=0)&&(a[n]=t[n]);return a}var Kr=s.forwardRef(function(t,r){var a=t.children,o=dr(t,Co),n=Vr(o),c=n.open,i=dr(n,Eo);return s.useImperativeHandle(r,function(){return{open:c}},[c]),Xe.createElement(s.Fragment,null,a(Ae(Ae({},i),{},{open:c})))});Kr.displayName="Dropzone";var Zs={disabled:!1,getFilesFromEvent:Jn,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};Kr.defaultProps=Zs;Kr.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 Or={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function Vr(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=Ae(Ae({},Zs),t),a=r.accept,o=r.disabled,n=r.getFilesFromEvent,c=r.maxSize,i=r.minSize,m=r.multiple,h=r.maxFiles,p=r.onDragEnter,b=r.onDragLeave,E=r.onDragOver,v=r.onDrop,j=r.onDropAccepted,g=r.onDropRejected,$=r.onFileDialogCancel,L=r.onFileDialogOpen,I=r.useFsAccessApi,C=r.autoFocus,x=r.preventDropOnDocument,d=r.noClick,k=r.noKeyboard,S=r.noDrag,A=r.noDragEventsBubbling,W=r.onError,O=r.validator,Q=s.useMemo(function(){return ko(a)},[a]),ie=s.useMemo(function(){return wo(a)},[a]),Z=s.useMemo(function(){return typeof L=="function"?L:Es},[L]),se=s.useMemo(function(){return typeof $=="function"?$:Es},[$]),B=s.useRef(null),T=s.useRef(null),z=s.useReducer(Ao,Or),Y=Mr(z,2),pe=Y[0],ae=Y[1],G=pe.isFocused,xe=pe.isFileDialogActive,Ne=s.useRef(typeof window<"u"&&window.isSecureContext&&I&&jo()),Ce=function(){!Ne.current&&xe&&setTimeout(function(){if(T.current){var _=T.current.files;_.length||(ae({type:"closeDialog"}),se())}},300)};s.useEffect(function(){return window.addEventListener("focus",Ce,!1),function(){window.removeEventListener("focus",Ce,!1)}},[T,xe,se,Ne]);var je=s.useRef([]),_e=function(_){B.current&&B.current.contains(_.target)||(_.preventDefault(),je.current=[])};s.useEffect(function(){return x&&(document.addEventListener("dragover",Ss,!1),document.addEventListener("drop",_e,!1)),function(){x&&(document.removeEventListener("dragover",Ss),document.removeEventListener("drop",_e))}},[B,x]),s.useEffect(function(){return!o&&C&&B.current&&B.current.focus(),function(){}},[B,C,o]);var he=s.useCallback(function(u){W?W(u):console.error(u)},[W]),Se=s.useCallback(function(u){u.preventDefault(),u.persist(),Le(u),je.current=[].concat(Do(je.current),[u.target]),rr(u)&&Promise.resolve(n(u)).then(function(_){if(!(cr(u)&&!A)){var X=_.length,te=X>0&&fo({files:_,accept:Q,minSize:i,maxSize:c,multiple:m,maxFiles:h,validator:O}),D=X>0&&!te;ae({isDragAccept:te,isDragReject:D,isDragActive:!0,type:"setDraggedFiles"}),p&&p(u)}}).catch(function(_){return he(_)})},[n,p,he,A,Q,i,c,m,h,O]),ke=s.useCallback(function(u){u.preventDefault(),u.persist(),Le(u);var _=rr(u);if(_&&u.dataTransfer)try{u.dataTransfer.dropEffect="copy"}catch{}return _&&E&&E(u),!1},[E,A]),Ee=s.useCallback(function(u){u.preventDefault(),u.persist(),Le(u);var _=je.current.filter(function(te){return B.current&&B.current.contains(te)}),X=_.indexOf(u.target);X!==-1&&_.splice(X,1),je.current=_,!(_.length>0)&&(ae({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),rr(u)&&b&&b(u))},[B,b,A]),ye=s.useCallback(function(u,_){var X=[],te=[];u.forEach(function(D){var De=Ks(D,Q),Be=Mr(De,2),Ie=Be[0],q=Be[1],me=Vs(D,i,c),re=Mr(me,2),le=re[0],ve=re[1],ze=O?O(D):null;if(Ie&&le&&!ze)X.push(D);else{var ge=[q,ve];ze&&(ge=ge.concat(ze)),te.push({file:D,errors:ge.filter(function(We){return We})})}}),(!m&&X.length>1||m&&h>=1&&X.length>h)&&(X.forEach(function(D){te.push({file:D,errors:[go]})}),X.splice(0)),ae({acceptedFiles:X,fileRejections:te,isDragReject:te.length>0,type:"setFiles"}),v&&v(X,te,_),te.length>0&&g&&g(te,_),X.length>0&&j&&j(X,_)},[ae,m,Q,i,c,h,v,j,g,O]),Pe=s.useCallback(function(u){u.preventDefault(),u.persist(),Le(u),je.current=[],rr(u)&&Promise.resolve(n(u)).then(function(_){cr(u)&&!A||ye(_,u)}).catch(function(_){return he(_)}),ae({type:"reset"})},[n,ye,he,A]),Re=s.useCallback(function(){if(Ne.current){ae({type:"openDialog"}),Z();var u={multiple:m,types:ie};window.showOpenFilePicker(u).then(function(_){return n(_)}).then(function(_){ye(_,null),ae({type:"closeDialog"})}).catch(function(_){No(_)?(se(_),ae({type:"closeDialog"})):So(_)?(Ne.current=!1,T.current?(T.current.value=null,T.current.click()):he(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."))):he(_)});return}T.current&&(ae({type:"openDialog"}),Z(),T.current.value=null,T.current.click())},[ae,Z,se,I,ye,he,ie,m]),Me=s.useCallback(function(u){!B.current||!B.current.isEqualNode(u.target)||(u.key===" "||u.key==="Enter"||u.keyCode===32||u.keyCode===13)&&(u.preventDefault(),Re())},[B,Re]),H=s.useCallback(function(){ae({type:"focus"})},[]),f=s.useCallback(function(){ae({type:"blur"})},[]),y=s.useCallback(function(){d||(vo()?setTimeout(Re,0):Re())},[d,Re]),F=function(_){return o?null:_},oe=function(_){return k?null:F(_)},ue=function(_){return S?null:F(_)},Le=function(_){A&&_.stopPropagation()},He=s.useMemo(function(){return function(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},_=u.refKey,X=_===void 0?"ref":_,te=u.role,D=u.onKeyDown,De=u.onFocus,Be=u.onBlur,Ie=u.onClick,q=u.onDragEnter,me=u.onDragOver,re=u.onDragLeave,le=u.onDrop,ve=dr(u,Mo);return Ae(Ae(Fr({onKeyDown:oe(nt(D,Me)),onFocus:oe(nt(De,H)),onBlur:oe(nt(Be,f)),onClick:F(nt(Ie,y)),onDragEnter:ue(nt(q,Se)),onDragOver:ue(nt(me,ke)),onDragLeave:ue(nt(re,Ee)),onDrop:ue(nt(le,Pe)),role:typeof te=="string"&&te!==""?te:"presentation"},X,B),!o&&!k?{tabIndex:0}:{}),ve)}},[B,Me,H,f,y,Se,ke,Ee,Pe,k,S,o]),Ye=s.useCallback(function(u){u.stopPropagation()},[]),qe=s.useMemo(function(){return function(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},_=u.refKey,X=_===void 0?"ref":_,te=u.onChange,D=u.onClick,De=dr(u,Lo),Be=Fr({accept:Q,multiple:m,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:F(nt(te,Pe)),onClick:F(nt(D,Ye)),tabIndex:-1},X,T);return Ae(Ae({},Be),De)}},[T,a,m,Pe,o]);return Ae(Ae({},pe),{},{isFocused:G&&!o,getRootProps:He,getInputProps:qe,rootRef:B,inputRef:T,open:F(Re)})}function Ao(t,r){switch(r.type){case"focus":return Ae(Ae({},t),{},{isFocused:!0});case"blur":return Ae(Ae({},t),{},{isFocused:!1});case"openDialog":return Ae(Ae({},Or),{},{isFileDialogActive:!0});case"closeDialog":return Ae(Ae({},t),{},{isFileDialogActive:!1});case"setDraggedFiles":return Ae(Ae({},t),{},{isDragActive:r.isDragActive,isDragAccept:r.isDragAccept,isDragReject:r.isDragReject});case"setFiles":return Ae(Ae({},t),{},{acceptedFiles:r.acceptedFiles,fileRejections:r.fileRejections,isDragReject:r.isDragReject});case"reset":return Ae({},Or);default:return t}}function Es(){}const Lr=({todos:t,isResult:r=!1})=>{if(!t||!Array.isArray(t))return null;const a=c=>{switch(c){case"completed":return e.jsx(Za,{className:"w-4 h-4 text-green-500 dark:text-green-400"});case"in_progress":return e.jsx(Ir,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"});case"pending":default:return e.jsx(Qa,{className:"w-4 h-4 text-gray-400 dark:text-gray-500"})}},o=c=>{switch(c){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=c=>{switch(c){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:[r&&e.jsxs("div",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:["待办事项列表 (",t.length," 项)"]}),t.map((c,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(c.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 ${c.status==="completed"?"line-through text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100"}`,children:c.content}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(Ge,{variant:"outline",className:`text-xs px-2 py-0.5 ${n(c.priority)}`,children:c.priority}),e.jsx(Ge,{variant:"outline",className:`text-xs px-2 py-0.5 ${o(c.status)}`,children:c.status.replace("_"," ")})]})]})})]},c.id||`todo-${i}`))]})};function Fo({status:t,onAbort:r,isLoading:a,provider:o="claude"}){const[n,c]=s.useState(0),[i,m]=s.useState(0),[h,p]=s.useState(0);if(s.useEffect(()=>{if(!a){c(0),p(0);return}const I=Date.now(),C=30+Math.random()*20,x=setInterval(()=>{const d=Math.floor((Date.now()-I)/1e3);c(d),p(Math.floor(d*C))},1e3);return()=>clearInterval(x)},[a]),s.useEffect(()=>{if(!a)return;const I=setInterval(()=>{m(C=>(C+1)%4)},500);return()=>clearInterval(I)},[a]),!a)return null;const b=["思考中","处理中","分析中","工作中","计算中","推理中"],E=Math.floor(n/3)%b.length,v=t?.text||b[E],j=t?.tokens||h,g=t?.can_interrupt!==!1,L=["✻","✹","✸","✶"][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:Fe("text-base sm:text-xl transition-all duration-500 flex-shrink-0",i%2===0?"text-blue-400 scale-110":"text-blue-300"),children:L}),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:[v,"..."]}),e.jsxs("span",{className:"text-gray-400 text-xs sm:text-sm flex-shrink-0",children:["(",n,"s)"]}),j>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:["⚒ ",j.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 停止"})]})})]})}),g&&r&&e.jsxs("button",{onClick:r,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 Oo(t,r){const a=new FormData,o=`recording_${Date.now()}.webm`,n=new File([t],o,{type:t.type});a.append("audio",n);const c=window.localStorage.getItem("whisperMode")||"default";a.append("mode",c);try{const i=await we.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 Wo({onTranscript:t,className:r=""}){const[a,o]=s.useState("idle"),[n,c]=s.useState(null),[i,m]=s.useState(!0),h=s.useRef(null),p=s.useRef(null),b=s.useRef([]),E=s.useRef(0);s.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){m(!1),c("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){m(!1),c("Microphone requires HTTPS. Please use a secure connection.");return}m(!0),c(null)})()},[]);const v=async()=>{try{if(console.log("Starting recording..."),c(null),b.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const x=await navigator.mediaDevices.getUserMedia({audio:!0});p.current=x;const d=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",k=new MediaRecorder(x,{mimeType:d});h.current=k,k.ondataavailable=S=>{S.data.size>0&&b.current.push(S.data)},k.onstop=async()=>{console.log("Recording stopped, creating blob...");const S=new Blob(b.current,{type:d});p.current&&(p.current.getTracks().forEach(Q=>Q.stop()),p.current=null),o("transcribing");const A=window.localStorage.getItem("whisperMode")||"default",W=A==="prompt"||A==="vibe"||A==="instructions"||A==="architect";let O;W&&(O=setTimeout(()=>{o("processing")},2e3));try{const Q=await Oo(S);Q&&t&&t(Q)}catch(Q){console.error("Transcription error:",Q),c(Q.message)}finally{O&&clearTimeout(O),o("idle")}},k.start(),o("recording"),console.log("Recording started successfully")}catch(x){console.error("Failed to start recording:",x);let d="Microphone access failed";x.name==="NotAllowedError"?d="Microphone access denied. Please allow microphone permissions.":x.name==="NotFoundError"?d="No microphone found. Please check your audio devices.":x.name==="NotSupportedError"?d="Microphone not supported by this browser.":x.name==="NotReadableError"?d="Microphone is being used by another application.":x.message.includes("HTTPS")&&(d=x.message),c(d),o("idle")}},j=()=>{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(x=>x.stop()),p.current=null),o("idle"))},g=x=>{if(x&&(x.preventDefault(),x.stopPropagation()),!i)return;const d=Date.now();if(d-E.current<300){console.log("Ignoring rapid tap");return}E.current=d,console.log("Button clicked, current state:",a),a==="idle"?v():a==="recording"&&j()};s.useEffect(()=>()=>{p.current&&p.current.getTracks().forEach(x=>x.stop())},[]);const $=()=>{if(!i)return{icon:e.jsx(nr,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(a){case"recording":return{icon:e.jsx(nr,{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(ft,{className:"w-5 h-5 animate-spin"}),className:"bg-blue-500 hover:bg-blue-600",disabled:!0};case"processing":return{icon:e.jsx(Ps,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:e.jsx(nr,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:L,className:I,disabled:C}=$();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:`
|
|
1
|
+
import{j as e,s as Da,R as Ta,o as Ra,E as Pa,m as $a,b as za,c as _a,h as Aa,p as Oa,d as Fa}from"./vendor-codemirror-C_VWDoZS.js";import{b as Wa,g as Hr,a as s,d as Ba,R as Xe,u as $s,B as Ua,e as Ha,f as ds,h as qa}from"./vendor-react-BeVl62c0.js";import{t as Ja,c as Ka,a as zs,F as Ga}from"./vendor-utils-00TdZexr.js";import{F as Ir,X as Fe,C as Va,L as ft,M as It,R as or,S as Dt,a as rt,b as kt,c as wr,d as ms,T as Ge,P as qt,e as kr,f as Lt,g as Dr,h as Ya,i as st,j as Tt,k as Qa,l as Za,m as nr,B as _s,D as qr,n as As,o as Xa,p as Os,U as us,q as en,E as Fs,r as tn,s as rn,t as Ws,u as ps,v as mr,I as Bs,w as Rt,x as ur,y as pr,G as Tr,Z as sn,z as an,A as nn,H as on,J as Us,K as Hs,N as qs,O as ln,Q as cn,V as ir,W as xr,Y as dn,_ as mn,$ as Js,a0 as un,a1 as pn,a2 as Rr,a3 as Pr,a4 as $r,a5 as xn,a6 as hn,a7 as gn,a8 as fn,a9 as bn,aa as yn,ab as vn}from"./vendor-icons-BhAhsylI.js";import{r as jn,a as wn,b as kn,M as Nn}from"./vendor-markdown-VwNYkg_0.js";import{h as Sn}from"./vendor-syntax-CdGaPJRS.js";import{r as Cn,a as En,b as Mn,c as Ln}from"./vendor-xterm-CvdiG4-n.js";import"./vendor-katex-DK8hFnhL.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.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 tr={},xs;function In(){if(xs)return tr;xs=1;var t=Wa();return tr.createRoot=t.createRoot,tr.hydrateRoot=t.hydrateRoot,tr}var Dn=In();const Tn=Hr(Dn);function Oe(...t){return Ja(Ka(t))}function Rn(t){if(!t||typeof t!="string")return null;try{return JSON.parse(t)}catch{return null}}const Jr=s.forwardRef(({className:t,children:r,...a},o)=>e.jsx("div",{ref:o,className:Oe("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:r})}));Jr.displayName="ScrollArea";const Pn=zs("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"}}),J=s.forwardRef(({className:t,variant:r,size:a,...o},n)=>e.jsx("button",{className:Oe(Pn({variant:r,size:a,className:t})),ref:n,...o}));J.displayName="Button";const $n=zs("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:r,...a}){return e.jsx("div",{className:Oe($n({variant:r}),t),...a})}const Ke=s.forwardRef(({className:t,type:r,...a},o)=>e.jsx("input",{type:r,className:Oe("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}));Ke.displayName="Input";const ot=({className:t="w-5 h-5"})=>e.jsx("img",{src:"/icons/claude-ai-icon.svg",alt:"Claude",className:t}),ne=(t,r={})=>{const a=localStorage.getItem("auth-token"),o={};return r.body instanceof FormData||(o["Content-Type"]="application/json"),a&&(o.Authorization=`Bearer ${a}`),fetch(t,{...r,headers:{...o,...r.headers}})},we={auth:{status:()=>fetch("/api/auth/status"),login:(t,r)=>fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:t,password:r})}),sendCode:t=>fetch("/api/auth/send-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t})}),verifyCode:(t,r)=>fetch("/api/auth/verify-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t,code:r})}),user:()=>ne("/api/auth/user"),logout:()=>ne("/api/auth/logout",{method:"POST"}),limitStatus:()=>ne("/api/auth/limit-status"),changePassword:(t,r)=>ne("/api/auth/change-password",{method:"PATCH",body:JSON.stringify({current_password:t,new_password:r})})},admin:{getUsers:()=>ne("/api/admin/users"),createUser:(t,r)=>ne("/api/admin/users",{method:"POST",body:JSON.stringify({username:t,password:r})}),updateUserStatus:(t,r)=>ne(`/api/admin/users/${t}`,{method:"PATCH",body:JSON.stringify({status:r})}),deleteUser:t=>ne(`/api/admin/users/${t}`,{method:"DELETE"}),getEmailDomains:()=>ne("/api/admin/email-domains"),addEmailDomain:t=>ne("/api/admin/email-domains",{method:"POST",body:JSON.stringify({domain:t})}),removeEmailDomain:t=>ne(`/api/admin/email-domains/${t}`,{method:"DELETE"}),getUserLimits:t=>ne(`/api/admin/users/${t}/limits`),updateUserLimits:(t,r)=>ne(`/api/admin/users/${t}/limits`,{method:"PATCH",body:JSON.stringify(r)}),resetUserPassword:(t,r)=>ne(`/api/admin/users/${t}/password`,{method:"PATCH",body:JSON.stringify({new_password:r})})},projects:()=>ne("/api/projects"),sessions:(t,r=5,a=0)=>ne(`/api/projects/${t}/sessions?limit=${r}&offset=${a}`),sessionMessages:(t,r,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/${r}/messages${l?`?${l}`:""}`;return ne(i)},renameProject:(t,r)=>ne(`/api/projects/${t}/rename`,{method:"PUT",body:JSON.stringify({displayName:r})}),deleteSession:(t,r)=>ne(`/api/projects/${t}/sessions/${r}`,{method:"DELETE"}),deleteProject:t=>ne(`/api/projects/${t}`,{method:"DELETE"}),createProject:t=>ne("/api/projects/create",{method:"POST",body:JSON.stringify({path:t})}),createWorkspace:t=>ne("/api/projects/create-workspace",{method:"POST",body:JSON.stringify(t)}),readFile:(t,r)=>ne(`/api/projects/${t}/file?filePath=${encodeURIComponent(r)}`),saveFile:(t,r,a)=>ne(`/api/projects/${t}/file`,{method:"PUT",body:JSON.stringify({filePath:r,content:a})}),getFiles:(t,r={})=>{const a=new URLSearchParams;r.dirPath&&a.set("dirPath",r.dirPath),r.depth&&a.set("depth",r.depth.toString());const o=a.toString();return ne(`/api/projects/${t}/files${o?"?"+o:""}`)},uploadFiles:(t,r)=>ne(`/api/projects/${t}/upload-files`,{method:"POST",body:r,headers:{}}),deleteFile:(t,r)=>ne(`/api/projects/${t}/files?filePath=${encodeURIComponent(r)}`,{method:"DELETE"}),transcribe:t=>ne("/api/transcribe",{method:"POST",body:t,headers:{}}),get:t=>ne(`/api${t}`)},zn=/^[a-zA-Z0-9_-]+$/,_n=({onClose:t,onProjectCreated:r})=>{const[a,o]=s.useState(""),[n,l]=s.useState(""),[i,d]=s.useState(!1),[x,p]=s.useState(null),b=y=>y.trim()?zn.test(y.trim())?null:"项目名称只能包含字母、数字、连字符和下划线":"项目名称为必填项",C=async()=>{p(null);const y=b(a);if(y){p(y);return}d(!0);try{const h={name:a.trim()};n.trim()&&(h.githubUrl=n.trim());const $=await we.createWorkspace(h),M=await $.json();if(!$.ok)throw new Error(M.error||"Failed to create project");r&&r(M.project),t()}catch(h){console.error("Error creating project:",h),p(h.message||"Failed to create project")}finally{d(!1)}},j=y=>{y.key==="Enter"&&!i&&C()};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(Ir,{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(Fe,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-5",children:[x&&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(Va,{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:x})})]}),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(Ke,{type:"text",value:a,onChange:y=>o(y.target.value),onKeyDown:j,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(Ke,{type:"text",value:n,onChange:y=>l(y.target.value),onKeyDown:j,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(J,{variant:"outline",onClick:t,disabled:i,children:"取消"}),e.jsx(J,{onClick:C,disabled:i||!a.trim(),children:i?e.jsxs(e.Fragment,{children:[e.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):"创建项目"})]})]})})},hs=(t,r)=>{const a=new Date(t),o=r;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)),x=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`:x===1?"1 day ago":x<7?`${x} days ago`:a.toLocaleDateString()};function gs({projects:t,selectedProject:r,selectedSession:a,onProjectSelect:o,onSessionSelect:n,onNewSession:l,onSessionDelete:i,onProjectDelete:d,isLoading:x,onRefresh:p,onShowSettings:b,isPWA:C,isMobile:j,onToggleSidebar:y}){const[h,$]=s.useState(new Set),[M,I]=s.useState(null),[E,g]=s.useState(!1),[m,k]=s.useState(""),[w,R]=s.useState({}),[W,F]=s.useState({}),[Q,ie]=s.useState(new Set),[Z,se]=s.useState(new Date),[B,T]=s.useState("name"),[_,Y]=s.useState(!1),[pe,ae]=s.useState(null),[V,xe]=s.useState(""),[Ne,Ce]=s.useState({}),[je,_e]=s.useState(""),[he,Se]=s.useState(()=>{try{const u=localStorage.getItem("starredProjects");return u?new Set(JSON.parse(u)):new Set}catch(u){return console.error("Error loading starred projects:",u),new Set}}),ke=u=>A=>{A.target.closest(".overflow-y-auto")||A.target.closest("[data-scroll-container]")||(A.preventDefault(),A.stopPropagation(),u())};s.useEffect(()=>{const u=setInterval(()=>{se(new Date)},6e4);return()=>clearInterval(u)},[]),s.useEffect(()=>{F({}),ie(new Set)},[t]),s.useEffect(()=>{a&&r&&$(u=>new Set([...u,r.name]))},[a,r]),s.useEffect(()=>{if(t.length>0&&!x){const u=new Set;t.forEach(A=>{A.sessions&&A.sessions.length>=0&&u.add(A.name)}),ie(u)}},[t,x]),s.useEffect(()=>{const u=()=>{try{const te=localStorage.getItem("claude-settings");if(te){const D=JSON.parse(te);T(D.projectSortOrder||"name")}}catch(te){console.error("Error loading sort order:",te)}};u();const A=te=>{te.key==="claude-settings"&&u()};window.addEventListener("storage",A);const X=setInterval(()=>{document.hasFocus()&&u()},1e3);return()=>{window.removeEventListener("storage",A),clearInterval(X)}},[]);const Ee=u=>{const A=new Set;h.has(u)||A.add(u),$(A)},ye=(u,A)=>{n({...u,__projectName:A})},Re=u=>{const A=new Set(he);A.has(u)?A.delete(u):A.add(u),Se(A);try{localStorage.setItem("starredProjects",JSON.stringify([...A]))}catch(X){console.error("Error saving starred projects:",X)}},Pe=u=>he.has(u),Me=u=>[...u.sessions||[],...W[u.name]||[]].map(X=>({...X,__provider:"claude"})).sort((X,te)=>new Date(te.lastActivity)-new Date(X.lastActivity)),H=u=>{const A=Me(u);return A.length===0?new Date(0):A.reduce((te,D)=>{const Ie=new Date(D.lastActivity);return Ie>te?Ie:te},new Date(0))},f=[...t].sort((u,A)=>{const X=Pe(u.name),te=Pe(A.name);if(X&&!te)return-1;if(!X&&te)return 1;if(B==="date")return H(A)-H(u);{const D=u.displayName||u.name,Ie=A.displayName||A.name;return D.localeCompare(Ie)}}),v=u=>{I(u.name),k(u.displayName)},O=()=>{I(null),k("")},oe=async u=>{try{(await we.renameProject(u,m)).ok?window.refreshProjects?window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(A){console.error("Error renaming project:",A)}I(null),k("")},ue=async(u,A,X="claude")=>{if(confirm("Are you sure you want to delete this session? This action cannot be undone."))try{console.log("[Sidebar] Deleting session:",{projectName:u,sessionId:A,provider:X});const te=await we.deleteSession(u,A);if(console.log("[Sidebar] Delete response:",{ok:te.ok,status:te.status}),te.ok)console.log("[Sidebar] Session deleted successfully, calling callback"),i?i(A):console.warn("[Sidebar] No onSessionDelete callback provided");else{const D=await te.text();console.error("[Sidebar] Failed to delete session:",{status:te.status,error:D}),alert("Failed to delete session. Please try again.")}}catch(te){console.error("[Sidebar] Error deleting session:",te),alert("Error deleting session. Please try again.")}},Le=async u=>{if(confirm("Are you sure you want to delete this empty project? This action cannot be undone."))try{const A=await we.deleteProject(u);if(A.ok)d&&d(u);else{const X=await A.json();console.error("Failed to delete project"),alert(X.error||"Failed to delete project. Please try again.")}}catch(A){console.error("Error deleting project:",A),alert("Error deleting project. Please try again.")}},He=async u=>{if(!(!(u.sessionMeta?.hasMore!==!1)||w[u.name])){R(X=>({...X,[u.name]:!0}));try{const X=(u.sessions?.length||0)+(W[u.name]?.length||0),te=await we.sessions(u.name,5,X);if(te.ok){const D=await te.json();F(Ie=>({...Ie,[u.name]:[...Ie[u.name]||[],...D.sessions]})),D.hasMore===!1&&(u.sessionMeta={...u.sessionMeta,hasMore:!1})}}catch(X){console.error("Error loading more sessions:",X)}finally{R(X=>({...X,[u.name]:!1}))}}},Ye=f.filter(u=>{if(!je.trim())return!0;const A=je.toLowerCase(),X=(u.displayName||u.name).toLowerCase(),te=u.name.toLowerCase();return X.includes(A)||te.includes(A)}),qe=u=>{o(u)};return e.jsxs(e.Fragment,{children:[E&&Ba.createPortal(e.jsx(_n,{onClose:()=>g(!1),onProjectCreated:u=>{window.refreshProjects?window.refreshProjects():window.location.reload()}}),document.body),e.jsxs("div",{className:"h-full flex flex-col bg-card md:select-none",style:C&&j?{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("div",{className:"w-8 h-8 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:e.jsx(It,{className:"w-4 h-4 text-primary-foreground"})}),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 助手"})]})]}),y&&e.jsx(J,{variant:"ghost",size:"sm",className:"h-8 w-8 px-0 hover:bg-accent transition-colors duration-200",onClick:y,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:C&&j?{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("div",{className:"w-8 h-8 bg-primary rounded-lg flex items-center justify-center",children:e.jsx(It,{className:"w-4 h-4 text-primary-foreground"})}),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()=>{Y(!0);try{await p()}finally{Y(!1)}},disabled:_,children:e.jsx(or,{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:()=>g(!0),children:e.jsx(Ir,{className:"w-4 h-4"})})]})]})})]}),!x&&!j&&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(J,{variant:"default",size:"sm",className:"flex-1 h-8 text-xs bg-primary hover:bg-primary/90 transition-all duration-200",onClick:()=>g(!0),title:"创建新项目",children:[e.jsx(Ir,{className:"w-3.5 h-3.5 mr-1.5"}),"新建项目"]}),e.jsx(J,{variant:"outline",size:"sm",className:"h-8 w-8 px-0 hover:bg-accent transition-colors duration-200 group",onClick:async()=>{Y(!0);try{await p()}finally{Y(!1)}},disabled:_,title:"刷新项目和会话 (Ctrl+R)",children:e.jsx(or,{className:`w-3.5 h-3.5 ${_?"animate-spin":""} group-hover:rotate-180 transition-transform duration-300`})})]})}),t.length>0&&!x&&e.jsx("div",{className:"px-3 md:px-4 py-2 border-b border-border",children:e.jsxs("div",{className:"relative",children:[e.jsx(Dt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Ke,{type:"text",placeholder:"搜索项目...",value:je,onChange:u=>_e(u.target.value),className:"pl-9 h-9 text-sm bg-muted/50 border-0 focus:bg-background focus:ring-1 focus:ring-primary/20"}),je&&e.jsx("button",{onClick:()=>_e(""),className:"absolute right-2 top-1/2 transform -translate-y-1/2 p-1 hover:bg-accent rounded",children:e.jsx(Fe,{className:"w-3 h-3 text-muted-foreground"})})]})}),e.jsx(Jr,{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:x?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(rt,{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 以开始使用"})]}):Ye.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(Dt,{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:"尝试调整搜索条件"})]}):Ye.map(u=>{const A=h.has(u.name),X=r?.name===u.name,te=Pe(u.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:Oe("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",X&&"bg-primary/5 border-primary/20",te&&!X&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:()=>{Ee(u.name)},onTouchEnd:ke(()=>Ee(u.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:Oe("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",A?"bg-primary/10":"bg-muted"),children:A?e.jsx(kt,{className:"w-4 h-4 text-primary"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground"})}),e.jsx("div",{className:"min-w-0 flex-1",children:M===u.name?e.jsx("input",{type:"text",value:m,onChange:D=>k(D.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:D=>D.stopPropagation(),onKeyDown:D=>{D.key==="Enter"&&oe(u.name),D.key==="Escape"&&O()},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:u.displayName})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(()=>{const D=Me(u).length;return`${u.sessionMeta?.hasMore!==!1&&D>=5?`${D}+`:D} 会话`})()})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:M===u.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:D=>{D.stopPropagation(),oe(u.name)},children:e.jsx(wr,{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:D=>{D.stopPropagation(),O()},children:e.jsx(Fe,{className:"w-4 h-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:Oe("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",te?"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:D=>{D.stopPropagation(),Re(u.name)},onTouchEnd:ke(()=>Re(u.name)),title:te?"从收藏中移除":"添加到收藏",children:e.jsx(ms,{className:Oe("w-4 h-4 transition-colors",te?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),Me(u).length===0&&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:D=>{D.stopPropagation(),Le(u.name)},onTouchEnd:ke(()=>Le(u.name)),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:D=>{D.stopPropagation(),v(u)},onTouchEnd:ke(()=>v(u)),children:e.jsx(qt,{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:A?e.jsx(kr,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(Lt,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),e.jsxs(J,{variant:"ghost",className:Oe("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",X&&"bg-accent text-accent-foreground",te&&!X&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:()=>{r?.name!==u.name&&qe(u),Ee(u.name)},onTouchEnd:ke(()=>{r?.name!==u.name&&qe(u),Ee(u.name)}),children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[A?e.jsx(kt,{className:"w-4 h-4 text-primary flex-shrink-0"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:M===u.name?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:m,onChange:D=>k(D.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:D=>{D.key==="Enter"&&oe(u.name),D.key==="Escape"&&O()}}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",title:u.fullPath,children:u.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold truncate text-foreground",title:u.displayName,children:u.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[(()=>{const D=Me(u).length;return u.sessionMeta?.hasMore!==!1&&D>=5?`${D}+`:D})(),u.fullPath!==u.displayName&&e.jsxs("span",{className:"ml-1 opacity-60",title:u.fullPath,children:["• ",u.fullPath.length>25?"..."+u.fullPath.slice(-22):u.fullPath]})]})]})})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:M===u.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:D=>{D.stopPropagation(),oe(u.name)},children:e.jsx(wr,{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:D=>{D.stopPropagation(),O()},children:e.jsx(Fe,{className:"w-3 h-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:Oe("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",te?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100":"hover:bg-accent"),onClick:D=>{D.stopPropagation(),Re(u.name)},title:te?"从收藏中移除":"添加到收藏",children:e.jsx(ms,{className:Oe("w-3 h-3 transition-colors",te?"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:D=>{D.stopPropagation(),v(u)},title:"重命名项目 (F2)",children:e.jsx(qt,{className:"w-3 h-3"})}),Me(u).length===0&&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:D=>{D.stopPropagation(),Le(u.name)},title:"删除空项目 (Delete)",children:e.jsx(Ge,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),A?e.jsx(kr,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):e.jsx(Lt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),A&&e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[Q.has(u.name)?Me(u).length===0&&!w[u.name]?e.jsx("div",{className:"py-2 px-3 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:"还没有会话"})}):Me(u).map(D=>{const Ie=new Date(D.lastActivity),De=Math.floor((Z-Ie)/(1e3*60))<10,q=D.summary||"新会话",me=D.lastActivity,re=D.messageCount||0;return e.jsxs("div",{className:"group relative",children:[De&&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:Oe("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",a?.id===D.id?"bg-primary/5 border-primary/20":De?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:()=>{qe(u),ye(D,u.name)},onTouchEnd:ke(()=>{qe(u),ye(D,u.name)}),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:Oe("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",a?.id===D.id?"bg-primary/10":"bg-muted/50"),children:e.jsx(ot,{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:q}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Dr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:hs(me,Z)}),re>0&&e.jsx(Ve,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:re}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(ot,{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:le=>{le.stopPropagation(),ue(u.name,D.id)},onTouchEnd:ke(()=>ue(u.name,D.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(J,{variant:"ghost",className:Oe("w-full justify-start p-2 h-auto font-normal text-left hover:bg-accent/50 transition-colors duration-200",a?.id===D.id&&"bg-accent text-accent-foreground"),onClick:()=>ye(D,u.name),onTouchEnd:ke(()=>ye(D,u.name)),children:e.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full",children:[e.jsx(ot,{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:q}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Dr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:hs(me,Z)}),re>0&&e.jsx(Ve,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:re}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(ot,{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:pe===D.id?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:V,onChange:le=>xe(le.target.value),onKeyDown:le=>{le.stopPropagation(),le.key==="Enter"?updateSessionSummary(u.name,D.id,V):le.key==="Escape"&&(ae(null),xe(""))},onClick:le=>le.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:le=>{le.stopPropagation(),updateSessionSummary(u.name,D.id,V)},title:"Save",children:e.jsx(wr,{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:le=>{le.stopPropagation(),ae(null),xe("")},title:"Cancel",children:e.jsx(Fe,{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:le=>{le.stopPropagation(),ae(D.id),xe(D.summary||"新会话")},title:"手动编辑会话名称",children:e.jsx(Ya,{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:le=>{le.stopPropagation(),ue(u.name,D.id)},title:"永久删除此会话",children:e.jsx(Ge,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]},D.id)}):Array.from({length:3}).map((D,Ie)=>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+Ie*15}%`}}),e.jsx("div",{className:"h-2 bg-muted rounded animate-pulse w-1/2"})]})]})},Ie)),Me(u).length>0&&u.sessionMeta?.hasMore!==!1&&e.jsx(J,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>He(u),disabled:w[u.name],children:w[u.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(kr,{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:()=>{qe(u),l(u)},children:[e.jsx(st,{className:"w-3 h-3"}),"新会话"]})}),e.jsxs(J,{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(u),children:[e.jsx(st,{className:"w-3 h-3"}),"新会话"]})]})]},u.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:b,children:[e.jsx("div",{className:"w-10 h-10 rounded-2xl bg-background/80 flex items-center justify-center",children:e.jsx(Tt,{className:"w-5 h-5 text-muted-foreground"})}),e.jsx("span",{className:"text-lg font-medium text-foreground",children:"设置"})]})}),e.jsxs(J,{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:b,children:[e.jsx(Tt,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:"设置"})]})]})]})]})}const An={'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 Nr={exports:{}},Sr,fs;function On(){if(fs)return Sr;fs=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Sr=t,Sr}var Cr,bs;function Fn(){if(bs)return Cr;bs=1;var t=On();function r(){}function a(){}return a.resetWarningCache=r,Cr=function(){function o(i,d,x,p,b,C){if(C!==t){var j=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 j.name="Invariant Violation",j}}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:r};return l.PropTypes=l,l},Cr}var ys;function Wn(){return ys||(ys=1,Nr.exports=Fn()()),Nr.exports}var Bn=Wn();const $e=Hr(Bn);function Nt(t,r,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(b){try{p(o.next(b))}catch(C){i(C)}}function x(b){try{p(o.throw(b))}catch(C){i(C)}}function p(b){b.done?l(b.value):n(b.value).then(d,x)}p((o=o.apply(t,r||[])).next())})}const Un=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 Pt(t,r,a){const o=Hn(t),{webkitRelativePath:n}=t,l=typeof r=="string"?r:typeof n=="string"&&n.length>0?n:`./${t.name}`;return typeof o.path!="string"&&vs(o,"path",l),vs(o,"relativePath",l),o}function Hn(t){const{name:r}=t;if(r&&r.lastIndexOf(".")!==-1&&!t.type){const o=r.split(".").pop().toLowerCase(),n=Un.get(o);n&&Object.defineProperty(t,"type",{value:n,writable:!1,configurable:!1,enumerable:!0})}return t}function vs(t,r,a){Object.defineProperty(t,r,{value:a,writable:!1,configurable:!1,enumerable:!0})}const qn=[".DS_Store","Thumbs.db"];function Jn(t){return Nt(this,void 0,void 0,function*(){return lr(t)&&Kn(t.dataTransfer)?Qn(t.dataTransfer,t.type):Gn(t)?Vn(t):Array.isArray(t)&&t.every(r=>"getFile"in r&&typeof r.getFile=="function")?Yn(t):[]})}function Kn(t){return lr(t)}function Gn(t){return lr(t)&&lr(t.target)}function lr(t){return typeof t=="object"&&t!==null}function Vn(t){return zr(t.target.files).map(r=>Pt(r))}function Yn(t){return Nt(this,void 0,void 0,function*(){return(yield Promise.all(t.map(a=>a.getFile()))).map(a=>Pt(a))})}function Qn(t,r){return Nt(this,void 0,void 0,function*(){if(t.items){const a=zr(t.items).filter(n=>n.kind==="file");if(r!=="drop")return a;const o=yield Promise.all(a.map(Zn));return js(Ks(o))}return js(zr(t.files).map(a=>Pt(a)))})}function js(t){return t.filter(r=>qn.indexOf(r.name)===-1)}function zr(t){if(t===null)return[];const r=[];for(let a=0;a<t.length;a++){const o=t[a];r.push(o)}return r}function Zn(t){if(typeof t.webkitGetAsEntry!="function")return ws(t);const r=t.webkitGetAsEntry();return r&&r.isDirectory?Gs(r):ws(t,r)}function Ks(t){return t.reduce((r,a)=>[...r,...Array.isArray(a)?Ks(a):[a]],[])}function ws(t,r){return Nt(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,Pt(i)}}const o=t.getAsFile();if(!o)throw new Error(`${t} is not a File`);return Pt(o,(a=r?.fullPath)!==null&&a!==void 0?a:void 0)})}function Xn(t){return Nt(this,void 0,void 0,function*(){return t.isDirectory?Gs(t):eo(t)})}function Gs(t){const r=t.createReader();return new Promise((a,o)=>{const n=[];function l(){r.readEntries(i=>Nt(this,void 0,void 0,function*(){if(i.length){const d=Promise.all(i.map(Xn));n.push(d),l()}else try{const d=yield Promise.all(n);a(d)}catch(d){o(d)}}),i=>{o(i)})}l()})}function eo(t){return Nt(this,void 0,void 0,function*(){return new Promise((r,a)=>{t.file(o=>{const n=Pt(o,t.fullPath);r(n)},o=>{a(o)})})})}var rr={},ks;function to(){return ks||(ks=1,rr.__esModule=!0,rr.default=function(t,r){if(t&&r){var a=Array.isArray(r)?r:r.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}),rr}var ro=to();const Er=Hr(ro);function Ns(t){return no(t)||ao(t)||Ys(t)||so()}function so(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ao(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function no(t){if(Array.isArray(t))return _r(t)}function Ss(t,r){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,o)}return a}function Cs(t){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?Ss(Object(a),!0).forEach(function(o){Vs(t,o,a[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):Ss(Object(a)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(a,o))})}return t}function Vs(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function Jt(t,r){return lo(t)||io(t,r)||Ys(t,r)||oo()}function oo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ys(t,r){if(t){if(typeof t=="string")return _r(t,r);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 _r(t,r)}}function _r(t,r){(r==null||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a<r;a++)o[a]=t[a];return o}function io(t,r){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),!(r&&o.length===r));n=!0);}catch(x){l=!0,d=x}finally{try{!n&&a.return!=null&&a.return()}finally{if(l)throw d}}return o}}function lo(t){if(Array.isArray(t))return t}var co=typeof Er=="function"?Er:Er.default,mo="file-invalid-type",uo="file-too-large",po="file-too-small",xo="too-many-files",ho=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",a=r.split(","),o=a.length>1?"one of ".concat(a.join(", ")):a[0];return{code:mo,message:"File type must be ".concat(o)}},Es=function(r){return{code:uo,message:"File is larger than ".concat(r," ").concat(r===1?"byte":"bytes")}},Ms=function(r){return{code:po,message:"File is smaller than ".concat(r," ").concat(r===1?"byte":"bytes")}},go={code:xo,message:"Too many files"};function Qs(t,r){var a=t.type==="application/x-moz-file"||co(t,r);return[a,a?null:ho(r)]}function Zs(t,r,a){if(wt(t.size))if(wt(r)&&wt(a)){if(t.size>a)return[!1,Es(a)];if(t.size<r)return[!1,Ms(r)]}else{if(wt(r)&&t.size<r)return[!1,Ms(r)];if(wt(a)&&t.size>a)return[!1,Es(a)]}return[!0,null]}function wt(t){return t!=null}function fo(t){var r=t.files,a=t.accept,o=t.minSize,n=t.maxSize,l=t.multiple,i=t.maxFiles,d=t.validator;return!l&&r.length>1||l&&i>=1&&r.length>i?!1:r.every(function(x){var p=Qs(x,a),b=Jt(p,1),C=b[0],j=Zs(x,o,n),y=Jt(j,1),h=y[0],$=d?d(x):null;return C&&h&&!$})}function cr(t){return typeof t.isPropagationStopped=="function"?t.isPropagationStopped():typeof t.cancelBubble<"u"?t.cancelBubble:!1}function sr(t){return t.dataTransfer?Array.prototype.some.call(t.dataTransfer.types,function(r){return r==="Files"||r==="application/x-moz-file"}):!!t.target&&!!t.target.files}function Ls(t){t.preventDefault()}function bo(t){return t.indexOf("MSIE")!==-1||t.indexOf("Trident/")!==-1}function yo(t){return t.indexOf("Edge/")!==-1}function vo(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return bo(t)||yo(t)}function nt(){for(var t=arguments.length,r=new Array(t),a=0;a<t;a++)r[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 r.some(function(d){return!cr(o)&&d&&d.apply(void 0,[o].concat(l)),cr(o)})}}function jo(){return"showOpenFilePicker"in window}function wo(t){if(wt(t)){var r=Object.entries(t).filter(function(a){var o=Jt(a,2),n=o[0],l=o[1],i=!0;return Xs(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(ea))&&(console.warn('Skipped "'.concat(n,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(a,o){var n=Jt(o,2),l=n[0],i=n[1];return Cs(Cs({},a),{},Vs({},l,i))},{});return[{description:"Files",accept:r}]}return t}function ko(t){if(wt(t))return Object.entries(t).reduce(function(r,a){var o=Jt(a,2),n=o[0],l=o[1];return[].concat(Ns(r),[n],Ns(l))},[]).filter(function(r){return Xs(r)||ea(r)}).join(",")}function No(t){return t instanceof DOMException&&(t.name==="AbortError"||t.code===t.ABORT_ERR)}function So(t){return t instanceof DOMException&&(t.name==="SecurityError"||t.code===t.SECURITY_ERR)}function Xs(t){return t==="audio/*"||t==="video/*"||t==="image/*"||t==="text/*"||t==="application/*"||/\w+\/[-+.\w]+/g.test(t)}function ea(t){return/^.*\.[\w]+$/.test(t)}var Co=["children"],Eo=["open"],Mo=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],Lo=["refKey","onChange","onClick"];function Io(t){return Ro(t)||To(t)||ta(t)||Do()}function Do(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function To(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Ro(t){if(Array.isArray(t))return Ar(t)}function Mr(t,r){return zo(t)||$o(t,r)||ta(t,r)||Po()}function Po(){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 ta(t,r){if(t){if(typeof t=="string")return Ar(t,r);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 Ar(t,r)}}function Ar(t,r){(r==null||r>t.length)&&(r=t.length);for(var a=0,o=new Array(r);a<r;a++)o[a]=t[a];return o}function $o(t,r){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),!(r&&o.length===r));n=!0);}catch(x){l=!0,d=x}finally{try{!n&&a.return!=null&&a.return()}finally{if(l)throw d}}return o}}function zo(t){if(Array.isArray(t))return t}function Is(t,r){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r&&(o=o.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),a.push.apply(a,o)}return a}function Ae(t){for(var r=1;r<arguments.length;r++){var a=arguments[r]!=null?arguments[r]:{};r%2?Is(Object(a),!0).forEach(function(o){Or(t,o,a[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):Is(Object(a)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(a,o))})}return t}function Or(t,r,a){return r in t?Object.defineProperty(t,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[r]=a,t}function dr(t,r){if(t==null)return{};var a=_o(t,r),o,n;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(t);for(n=0;n<l.length;n++)o=l[n],!(r.indexOf(o)>=0)&&Object.prototype.propertyIsEnumerable.call(t,o)&&(a[o]=t[o])}return a}function _o(t,r){if(t==null)return{};var a={},o=Object.keys(t),n,l;for(l=0;l<o.length;l++)n=o[l],!(r.indexOf(n)>=0)&&(a[n]=t[n]);return a}var Kr=s.forwardRef(function(t,r){var a=t.children,o=dr(t,Co),n=Gr(o),l=n.open,i=dr(n,Eo);return s.useImperativeHandle(r,function(){return{open:l}},[l]),Xe.createElement(s.Fragment,null,a(Ae(Ae({},i),{},{open:l})))});Kr.displayName="Dropzone";var ra={disabled:!1,getFilesFromEvent:Jn,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};Kr.defaultProps=ra;Kr.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 Fr={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function Gr(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=Ae(Ae({},ra),t),a=r.accept,o=r.disabled,n=r.getFilesFromEvent,l=r.maxSize,i=r.minSize,d=r.multiple,x=r.maxFiles,p=r.onDragEnter,b=r.onDragLeave,C=r.onDragOver,j=r.onDrop,y=r.onDropAccepted,h=r.onDropRejected,$=r.onFileDialogCancel,M=r.onFileDialogOpen,I=r.useFsAccessApi,E=r.autoFocus,g=r.preventDropOnDocument,m=r.noClick,k=r.noKeyboard,w=r.noDrag,R=r.noDragEventsBubbling,W=r.onError,F=r.validator,Q=s.useMemo(function(){return ko(a)},[a]),ie=s.useMemo(function(){return wo(a)},[a]),Z=s.useMemo(function(){return typeof M=="function"?M:Ds},[M]),se=s.useMemo(function(){return typeof $=="function"?$:Ds},[$]),B=s.useRef(null),T=s.useRef(null),_=s.useReducer(Ao,Fr),Y=Mr(_,2),pe=Y[0],ae=Y[1],V=pe.isFocused,xe=pe.isFileDialogActive,Ne=s.useRef(typeof window<"u"&&window.isSecureContext&&I&&jo()),Ce=function(){!Ne.current&&xe&&setTimeout(function(){if(T.current){var A=T.current.files;A.length||(ae({type:"closeDialog"}),se())}},300)};s.useEffect(function(){return window.addEventListener("focus",Ce,!1),function(){window.removeEventListener("focus",Ce,!1)}},[T,xe,se,Ne]);var je=s.useRef([]),_e=function(A){B.current&&B.current.contains(A.target)||(A.preventDefault(),je.current=[])};s.useEffect(function(){return g&&(document.addEventListener("dragover",Ls,!1),document.addEventListener("drop",_e,!1)),function(){g&&(document.removeEventListener("dragover",Ls),document.removeEventListener("drop",_e))}},[B,g]),s.useEffect(function(){return!o&&E&&B.current&&B.current.focus(),function(){}},[B,E,o]);var he=s.useCallback(function(u){W?W(u):console.error(u)},[W]),Se=s.useCallback(function(u){u.preventDefault(),u.persist(),Le(u),je.current=[].concat(Io(je.current),[u.target]),sr(u)&&Promise.resolve(n(u)).then(function(A){if(!(cr(u)&&!R)){var X=A.length,te=X>0&&fo({files:A,accept:Q,minSize:i,maxSize:l,multiple:d,maxFiles:x,validator:F}),D=X>0&&!te;ae({isDragAccept:te,isDragReject:D,isDragActive:!0,type:"setDraggedFiles"}),p&&p(u)}}).catch(function(A){return he(A)})},[n,p,he,R,Q,i,l,d,x,F]),ke=s.useCallback(function(u){u.preventDefault(),u.persist(),Le(u);var A=sr(u);if(A&&u.dataTransfer)try{u.dataTransfer.dropEffect="copy"}catch{}return A&&C&&C(u),!1},[C,R]),Ee=s.useCallback(function(u){u.preventDefault(),u.persist(),Le(u);var A=je.current.filter(function(te){return B.current&&B.current.contains(te)}),X=A.indexOf(u.target);X!==-1&&A.splice(X,1),je.current=A,!(A.length>0)&&(ae({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),sr(u)&&b&&b(u))},[B,b,R]),ye=s.useCallback(function(u,A){var X=[],te=[];u.forEach(function(D){var Ie=Qs(D,Q),Be=Mr(Ie,2),De=Be[0],q=Be[1],me=Zs(D,i,l),re=Mr(me,2),le=re[0],ve=re[1],ze=F?F(D):null;if(De&&le&&!ze)X.push(D);else{var ge=[q,ve];ze&&(ge=ge.concat(ze)),te.push({file:D,errors:ge.filter(function(We){return We})})}}),(!d&&X.length>1||d&&x>=1&&X.length>x)&&(X.forEach(function(D){te.push({file:D,errors:[go]})}),X.splice(0)),ae({acceptedFiles:X,fileRejections:te,isDragReject:te.length>0,type:"setFiles"}),j&&j(X,te,A),te.length>0&&h&&h(te,A),X.length>0&&y&&y(X,A)},[ae,d,Q,i,l,x,j,y,h,F]),Re=s.useCallback(function(u){u.preventDefault(),u.persist(),Le(u),je.current=[],sr(u)&&Promise.resolve(n(u)).then(function(A){cr(u)&&!R||ye(A,u)}).catch(function(A){return he(A)}),ae({type:"reset"})},[n,ye,he,R]),Pe=s.useCallback(function(){if(Ne.current){ae({type:"openDialog"}),Z();var u={multiple:d,types:ie};window.showOpenFilePicker(u).then(function(A){return n(A)}).then(function(A){ye(A,null),ae({type:"closeDialog"})}).catch(function(A){No(A)?(se(A),ae({type:"closeDialog"})):So(A)?(Ne.current=!1,T.current?(T.current.value=null,T.current.click()):he(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."))):he(A)});return}T.current&&(ae({type:"openDialog"}),Z(),T.current.value=null,T.current.click())},[ae,Z,se,I,ye,he,ie,d]),Me=s.useCallback(function(u){!B.current||!B.current.isEqualNode(u.target)||(u.key===" "||u.key==="Enter"||u.keyCode===32||u.keyCode===13)&&(u.preventDefault(),Pe())},[B,Pe]),H=s.useCallback(function(){ae({type:"focus"})},[]),f=s.useCallback(function(){ae({type:"blur"})},[]),v=s.useCallback(function(){m||(vo()?setTimeout(Pe,0):Pe())},[m,Pe]),O=function(A){return o?null:A},oe=function(A){return k?null:O(A)},ue=function(A){return w?null:O(A)},Le=function(A){R&&A.stopPropagation()},He=s.useMemo(function(){return function(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},A=u.refKey,X=A===void 0?"ref":A,te=u.role,D=u.onKeyDown,Ie=u.onFocus,Be=u.onBlur,De=u.onClick,q=u.onDragEnter,me=u.onDragOver,re=u.onDragLeave,le=u.onDrop,ve=dr(u,Mo);return Ae(Ae(Or({onKeyDown:oe(nt(D,Me)),onFocus:oe(nt(Ie,H)),onBlur:oe(nt(Be,f)),onClick:O(nt(De,v)),onDragEnter:ue(nt(q,Se)),onDragOver:ue(nt(me,ke)),onDragLeave:ue(nt(re,Ee)),onDrop:ue(nt(le,Re)),role:typeof te=="string"&&te!==""?te:"presentation"},X,B),!o&&!k?{tabIndex:0}:{}),ve)}},[B,Me,H,f,v,Se,ke,Ee,Re,k,w,o]),Ye=s.useCallback(function(u){u.stopPropagation()},[]),qe=s.useMemo(function(){return function(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},A=u.refKey,X=A===void 0?"ref":A,te=u.onChange,D=u.onClick,Ie=dr(u,Lo),Be=Or({accept:Q,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:O(nt(te,Re)),onClick:O(nt(D,Ye)),tabIndex:-1},X,T);return Ae(Ae({},Be),Ie)}},[T,a,d,Re,o]);return Ae(Ae({},pe),{},{isFocused:V&&!o,getRootProps:He,getInputProps:qe,rootRef:B,inputRef:T,open:O(Pe)})}function Ao(t,r){switch(r.type){case"focus":return Ae(Ae({},t),{},{isFocused:!0});case"blur":return Ae(Ae({},t),{},{isFocused:!1});case"openDialog":return Ae(Ae({},Fr),{},{isFileDialogActive:!0});case"closeDialog":return Ae(Ae({},t),{},{isFileDialogActive:!1});case"setDraggedFiles":return Ae(Ae({},t),{},{isDragActive:r.isDragActive,isDragAccept:r.isDragAccept,isDragReject:r.isDragReject});case"setFiles":return Ae(Ae({},t),{},{acceptedFiles:r.acceptedFiles,fileRejections:r.fileRejections,isDragReject:r.isDragReject});case"reset":return Ae({},Fr);default:return t}}function Ds(){}const Lr=({todos:t,isResult:r=!1})=>{if(!t||!Array.isArray(t))return null;const a=l=>{switch(l){case"completed":return e.jsx(Za,{className:"w-4 h-4 text-green-500 dark:text-green-400"});case"in_progress":return e.jsx(Dr,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"});case"pending":default:return e.jsx(Qa,{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:[r&&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 Oo({status:t,onAbort:r,isLoading:a,provider:o="claude"}){const[n,l]=s.useState(0),[i,d]=s.useState(0),[x,p]=s.useState(0);if(s.useEffect(()=>{if(!a){l(0),p(0);return}const I=Date.now(),E=30+Math.random()*20,g=setInterval(()=>{const m=Math.floor((Date.now()-I)/1e3);l(m),p(Math.floor(m*E))},1e3);return()=>clearInterval(g)},[a]),s.useEffect(()=>{if(!a)return;const I=setInterval(()=>{d(E=>(E+1)%4)},500);return()=>clearInterval(I)},[a]),!a)return null;const b=["思考中","处理中","分析中","工作中","计算中","推理中"],C=Math.floor(n/3)%b.length,j=t?.text||b[C],y=t?.tokens||x,h=t?.can_interrupt!==!1,M=["✻","✹","✸","✶"][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:Oe("text-base sm:text-xl transition-all duration-500 flex-shrink-0",i%2===0?"text-blue-400 scale-110":"text-blue-300"),children:M}),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:[j,"..."]}),e.jsxs("span",{className:"text-gray-400 text-xs sm:text-sm flex-shrink-0",children:["(",n,"s)"]}),y>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:["⚒ ",y.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 停止"})]})})]})}),h&&r&&e.jsxs("button",{onClick:r,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 Fo(t,r){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 we.transcribe(a);if(!i.ok){const x=await i.json().catch(()=>({}));throw new Error(x.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 Wo({onTranscript:t,className:r=""}){const[a,o]=s.useState("idle"),[n,l]=s.useState(null),[i,d]=s.useState(!0),x=s.useRef(null),p=s.useRef(null),b=s.useRef([]),C=s.useRef(0);s.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 j=async()=>{try{if(console.log("Starting recording..."),l(null),b.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const g=await navigator.mediaDevices.getUserMedia({audio:!0});p.current=g;const m=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",k=new MediaRecorder(g,{mimeType:m});x.current=k,k.ondataavailable=w=>{w.data.size>0&&b.current.push(w.data)},k.onstop=async()=>{console.log("Recording stopped, creating blob...");const w=new Blob(b.current,{type:m});p.current&&(p.current.getTracks().forEach(Q=>Q.stop()),p.current=null),o("transcribing");const R=window.localStorage.getItem("whisperMode")||"default",W=R==="prompt"||R==="vibe"||R==="instructions"||R==="architect";let F;W&&(F=setTimeout(()=>{o("processing")},2e3));try{const Q=await Fo(w);Q&&t&&t(Q)}catch(Q){console.error("Transcription error:",Q),l(Q.message)}finally{F&&clearTimeout(F),o("idle")}},k.start(),o("recording"),console.log("Recording started successfully")}catch(g){console.error("Failed to start recording:",g);let m="Microphone access failed";g.name==="NotAllowedError"?m="Microphone access denied. Please allow microphone permissions.":g.name==="NotFoundError"?m="No microphone found. Please check your audio devices.":g.name==="NotSupportedError"?m="Microphone not supported by this browser.":g.name==="NotReadableError"?m="Microphone is being used by another application.":g.message.includes("HTTPS")&&(m=g.message),l(m),o("idle")}},y=()=>{console.log("Stopping recording..."),x.current&&x.current.state==="recording"?x.current.stop():(console.log("Recorder not in recording state, forcing cleanup"),p.current&&(p.current.getTracks().forEach(g=>g.stop()),p.current=null),o("idle"))},h=g=>{if(g&&(g.preventDefault(),g.stopPropagation()),!i)return;const m=Date.now();if(m-C.current<300){console.log("Ignoring rapid tap");return}C.current=m,console.log("Button clicked, current state:",a),a==="idle"?j():a==="recording"&&y()};s.useEffect(()=>()=>{p.current&&p.current.getTracks().forEach(g=>g.stop())},[]);const $=()=>{if(!i)return{icon:e.jsx(nr,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(a){case"recording":return{icon:e.jsx(nr,{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(ft,{className:"w-5 h-5 animate-spin"}),className:"bg-blue-500 hover:bg-blue-600",disabled:!0};case"processing":return{icon:e.jsx(_s,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:e.jsx(nr,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:M,className:I,disabled:E}=$();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
|
|
9
9
|
focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500
|
|
10
10
|
dark:ring-offset-gray-800
|
|
11
11
|
touch-action-manipulation
|
|
12
|
-
${
|
|
12
|
+
${E?"cursor-not-allowed opacity-75":"cursor-pointer"}
|
|
13
13
|
${a==="recording"?"animate-pulse":""}
|
|
14
14
|
hover:opacity-90
|
|
15
15
|
${r}
|
|
16
|
-
`,onClick:
|
|
16
|
+
`,onClick:h,disabled:E,children:M}),n&&e.jsx("div",{className:`absolute top-full mt-2 left-1/2 transform -translate-x-1/2
|
|
17
17
|
bg-red-500 text-white text-xs px-2 py-1 rounded whitespace-nowrap z-10
|
|
18
|
-
animate-fade-in`,children:n}),a==="recording"&&e.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-red-500 animate-ping pointer-events-none"}),a==="processing"&&e.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-purple-500 animate-ping pointer-events-none"})]})}const Bo=({commands:t=[],selectedIndex:r=-1,onSelect:a,onClose:o,position:n={top:0,left:0},isOpen:
|
|
18
|
+
animate-fade-in`,children:n}),a==="recording"&&e.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-red-500 animate-ping pointer-events-none"}),a==="processing"&&e.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-purple-500 animate-ping pointer-events-none"})]})}const Bo=({commands:t=[],selectedIndex:r=-1,onSelect:a,onClose:o,position:n={top:0,left:0},isOpen:l=!1,frequentCommands:i=[]})=>{const d=s.useRef(null),x=s.useRef(null),b=(()=>{const E=window.innerWidth<640,g=window.innerHeight;return E?{position:"fixed",bottom:`${n.bottom||90}px`,left:"16px",right:"16px",width:"auto",maxWidth:"calc(100vw - 32px)",maxHeight:"min(50vh, 300px)"}:{position:"fixed",top:`${Math.max(16,Math.min(n.top,g-316))}px`,left:`${n.left}px`,width:"min(400px, calc(100vw - 32px))",maxWidth:"calc(100vw - 32px)",maxHeight:"300px"}})();if(s.useEffect(()=>{const E=g=>{d.current&&!d.current.contains(g.target)&&l&&o()};if(l)return document.addEventListener("mousedown",E),()=>{document.removeEventListener("mousedown",E)}},[l,o]),s.useEffect(()=>{if(x.current&&d.current){const E=d.current.getBoundingClientRect(),g=x.current.getBoundingClientRect();g.bottom>E.bottom?x.current.scrollIntoView({block:"nearest",behavior:"smooth"}):g.top<E.top&&x.current.scrollIntoView({block:"nearest",behavior:"smooth"})}},[r]),!l)return null;if(t.length===0)return e.jsx("div",{ref:d,className:"command-menu command-menu-empty",style:{...b,maxHeight:"300px",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"20px",opacity:1,transform:"translateY(0)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out",textAlign:"center"},children:"暂无可用命令"});const C=i.length>0,j=t.reduce((E,g)=>{const m=g.namespace||g.type||"other";return E[m]||(E[m]=[]),E[m].push(g),E},{});C&&(j.frequent=i);const h=(C?["frequent","builtin","project","user","other"]:["builtin","project","user","other"]).filter(E=>j[E]),$={frequent:"⭐ 常用命令",builtin:"内置命令",project:"项目命令",user:"用户命令",other:"其他命令"};let M=0;const I=[];return h.forEach(E=>{j[E].forEach(g=>{I.push({...g,globalIndex:M++,namespace:E})})}),e.jsxs("div",{ref:d,role:"listbox","aria-label":"Available commands",className:"command-menu",style:{...b,maxHeight:"300px",overflowY:"auto",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"8px",opacity:l?1:0,transform:l?"translateY(0)":"translateY(-10px)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out"},children:[h.map(E=>e.jsxs("div",{className:"command-group",children:[h.length>1&&e.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"#6b7280",padding:"8px 12px 4px",letterSpacing:"0.05em"},children:$[E]||E}),j[E].map(g=>{const m=I.find(w=>w.name===g.name&&w.namespace===E),k=m&&m.globalIndex===r;return e.jsxs("div",{ref:k?x:null,role:"option","aria-selected":k,className:"command-item",onMouseEnter:()=>a&&a(g,m.globalIndex,!0),onClick:()=>a&&a(g,m.globalIndex,!1),style:{display:"flex",alignItems:"flex-start",padding:"10px 12px",borderRadius:"6px",cursor:"pointer",backgroundColor:k?"#eff6ff":"transparent",transition:"background-color 100ms ease-in-out",marginBottom:"2px"},onMouseDown:w=>w.preventDefault(),children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:g.description?"4px":0},children:[e.jsxs("span",{style:{fontSize:"16px",flexShrink:0},children:[E==="builtin"&&"⚡",E==="project"&&"📁",E==="user"&&"👤",E==="other"&&"📝"]}),e.jsx("span",{style:{fontWeight:600,fontSize:"14px",color:"#111827",fontFamily:"monospace"},children:g.name}),g.metadata?.type&&e.jsx("span",{className:"command-metadata-badge",style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",backgroundColor:"#f3f4f6",color:"#6b7280",fontWeight:500},children:g.metadata.type})]}),g.description&&e.jsx("div",{style:{fontSize:"13px",color:"#6b7280",marginLeft:"24px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:g.description})]}),k&&e.jsx("span",{style:{marginLeft:"8px",color:"#3b82f6",fontSize:"12px",fontWeight:600},children:"↵"})]},`${E}-${g.name}`)})]},E)),e.jsx("style",{children:`
|
|
19
19
|
.command-menu {
|
|
20
20
|
background-color: white;
|
|
21
21
|
border: 1px solid #e5e7eb;
|
|
@@ -49,59 +49,59 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
49
49
|
color: #9ca3af !important;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
`})]})},
|
|
53
|
-
`).replace(/\\t/g," ").replace(/\\r/g,"\r"),n=n.replace(new RegExp(`${a}(\\d+)${o}`,"g"),(c,i)=>r[parseInt(i)]),n}const Et=({children:t,className:r})=>{const a=Uo(String(t??"")),o=s.useMemo(()=>[jn,wn],[]),n=s.useMemo(()=>[kn],[]);return e.jsx("div",{className:r,children:e.jsx(Nn,{remarkPlugins:o,rehypePlugins:n,components:Jo,children:a})})};function Wr(t){try{return typeof t!="string"?t:t.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(r,a)=>{let o=parseInt(a,10);if(!Number.isFinite(o))return r;o<1e12&&(o*=1e3);const n=new Date(o),c=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(n),i=-n.getTimezoneOffset(),m=i>=0?"+":"-",h=Math.abs(i),p=Math.floor(h/60),b=h%60,E=`GMT${m}${p}${b?":"+String(b).padStart(2,"0"):""}`,g=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,C=>C.toUpperCase()),$=g?`${E} (${g})`:E,L=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],I=`${n.getDate()} ${L[n.getMonth()]} ${n.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${c} ${$}** - ${I}`})}catch{return t}}const Je={setItem:(t,r)=>{try{if(t.startsWith("chat_messages_")&&typeof r=="string")try{const a=JSON.parse(r);if(Array.isArray(a)&&a.length>50){console.warn(`Truncating chat history for ${t} from ${a.length} to 50 messages`);const o=a.slice(-50);r=JSON.stringify(o)}}catch(a){console.warn("Could not parse chat messages for truncation:",a)}localStorage.setItem(t,r)}catch(a){if(a.name==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old data");const o=Object.keys(localStorage),n=o.filter(i=>i.startsWith("chat_messages_")).sort();n.length>3&&n.slice(0,n.length-3).forEach(i=>{localStorage.removeItem(i),console.log(`Removed old chat data: ${i}`)}),o.filter(i=>i.startsWith("draft_input_")).forEach(i=>{localStorage.removeItem(i)});try{localStorage.setItem(t,r)}catch(i){if(console.error("Failed to save to localStorage even after cleanup:",i),t.startsWith("chat_messages_")&&typeof r=="string")try{const m=JSON.parse(r);if(Array.isArray(m)&&m.length>10){const h=m.slice(-10);localStorage.setItem(t,JSON.stringify(h)),console.warn("Saved only last 10 messages due to quota constraints")}}catch(m){console.error("Final save attempt failed:",m)}}}else console.error("localStorage error:",a)}},getItem:t=>{try{return localStorage.getItem(t)}catch(r){return console.error("localStorage getItem error:",r),null}},removeItem:t=>{try{localStorage.removeItem(t)}catch(r){console.error("localStorage removeItem error:",r)}}},Xs="claude-settings";function Gr(){const t=Je.getItem(Xs);if(!t)return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"};try{const r=JSON.parse(t);return{...r,allowedTools:Array.isArray(r.allowedTools)?r.allowedTools:[],disallowedTools:Array.isArray(r.disallowedTools)?r.disallowedTools:[],skipPermissions:!!r.skipPermissions,projectSortOrder:r.projectSortOrder||"name"}}catch{return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"}}}function Br(t,r){if(!t)return null;if(t!=="Bash")return t;const a=Pn(r),o=typeof a?.command=="string"?a.command.trim():"";if(!o)return t;const n=o.split(/\s+/);return n.length===0?t:n[0]==="git"&&n[1]?`Bash(${n[0]} ${n[1]}:*)`:`Bash(${n[0]}:*)`}function Ls(t){if(t==null)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Ho(t,r){if(r!=="claude"||!t?.toolResult?.isError)return null;const a=t?.toolName,o=Br(a,t.toolInput);if(!o)return null;const c=Gr().allowedTools.includes(o);return{toolName:a,entry:o,isAllowed:c}}function qo(t){if(!t)return{success:!1};const r=Gr(),a=r.allowedTools.includes(t),o=a?r.allowedTools:[...r.allowedTools,t],n=r.disallowedTools.filter(i=>i!==t),c={...r,allowedTools:o,disallowedTools:n,lastUpdated:new Date().toISOString()};return Je.setItem(Xs,JSON.stringify(c)),{success:!0,alreadyAllowed:a,updatedSettings:c}}const Jo={code:({node:t,inline:r,className:a,children:o,...n})=>{const[c,i]=Xe.useState(!1),m=Array.isArray(o)?o.join(""):String(o??""),h=/[\r\n]/.test(m);if(r||t&&t.type==="inlineCode"||!h)return e.jsx("code",{className:`font-mono text-[0.9em] px-1.5 py-0.5 rounded-md bg-gray-100 text-gray-900 border border-gray-200 dark:bg-gray-800/60 dark:text-gray-100 dark:border-gray-700 whitespace-pre-wrap break-words ${a||""}`,...n,children:o});const E=/language-(\w+)/.exec(a||""),v=E?E[1]:"text",j=m,g=()=>{const $=()=>{i(!0),setTimeout(()=>i(!1),1500)};try{if(navigator&&navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(j).then($).catch(()=>{const L=document.createElement("textarea");L.value=j,L.style.position="fixed",L.style.opacity="0",document.body.appendChild(L),L.select();try{document.execCommand("copy")}catch{}document.body.removeChild(L),$()});else{const L=document.createElement("textarea");L.value=j,L.style.position="fixed",L.style.opacity="0",document.body.appendChild(L),L.select();try{document.execCommand("copy")}catch{}document.body.removeChild(L),$()}}catch{}};return e.jsxs("div",{className:"relative group my-2",children:[v&&v!=="text"&&e.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:v}),e.jsx("button",{type:"button",onClick:g,className:"absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 focus:opacity-100 active:opacity-100 transition-opacity text-xs px-2 py-1 rounded-md bg-gray-700/80 hover:bg-gray-700 text-white border border-gray-600",title:c?"已复制":"复制代码","aria-label":c?"已复制":"复制代码",children:c?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),"已复制"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),"复制"]})}),e.jsx(Sn,{language:v,style:An,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:v&&v!=="text"?"2rem 1rem 1rem 1rem":"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:m})]})},blockquote:({children:t})=>e.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:t}),a:({href:t,children:r})=>e.jsx("a",{href:t,className:"text-blue-600 dark:text-blue-400 hover:underline",target:"_blank",rel:"noopener noreferrer",children:r}),p:({children:t})=>e.jsx("div",{className:"mb-2 last:mb-0",children:t}),table:({children:t})=>e.jsx("div",{className:"overflow-x-auto my-2",children:e.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:t})}),thead:({children:t})=>e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:t}),th:({children:t})=>e.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold border border-gray-200 dark:border-gray-700",children:t}),td:({children:t})=>e.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:t})};function Ko({request:t,onSubmit:r,onSkip:a}){const o=t.input?.questions||[],[n,c]=Xe.useState(()=>Object.fromEntries(o.map(p=>[p.question,[]]))),i=(p,b,E)=>{c(v=>{const j=v[p]||[];return E?{...v,[p]:j.includes(b)?j.filter(g=>g!==b):[...j,b]}:{...v,[p]:[b]}})},m=o.every(p=>(n[p.question]||[]).length>0),h=()=>{const p={};o.forEach(b=>{p[b.question]=(n[b.question]||[]).join(", ")}),r(p)};return e.jsxs("div",{className:"rounded-lg border border-blue-200 dark:border-blue-800 bg-blue-50 dark:bg-blue-900/20 p-3 shadow-sm",children:[e.jsx("div",{className:"text-sm font-semibold text-blue-900 dark:text-blue-100 mb-3",children:"Claude 需要您的回答"}),o.map((p,b)=>e.jsxs("div",{className:b<o.length-1?"mb-4":"mb-0",children:[e.jsxs("div",{className:"text-sm font-medium text-blue-800 dark:text-blue-200 mb-2",children:[p.question,p.multiSelect&&e.jsx("span",{className:"ml-2 text-xs font-normal opacity-60",children:"(可多选)"})]}),e.jsx("div",{className:"space-y-1",children:p.options.map((E,v)=>{const j=(n[p.question]||[]).includes(E.label);return e.jsxs("button",{type:"button",onClick:()=>i(p.question,E.label,p.multiSelect),className:`w-full text-left px-3 py-2 rounded-md text-xs border transition-colors ${j?"bg-blue-600 text-white border-blue-600":"bg-white dark:bg-gray-800 border-blue-200 dark:border-blue-700 text-blue-800 dark:text-blue-200 hover:bg-blue-50 dark:hover:bg-blue-900/30"}`,children:[e.jsx("span",{className:"font-medium",children:E.label}),E.description&&e.jsxs("span",{className:"ml-1 opacity-70",children:[" — ",E.description]})]},v)})})]},b)),e.jsxs("div",{className:"mt-3 flex gap-2",children:[e.jsx("button",{type:"button",onClick:h,disabled:!m,className:"inline-flex items-center gap-2 rounded-md bg-blue-600 text-white text-xs font-medium px-3 py-1.5 hover:bg-blue-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:"提交答案"}),e.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border border-gray-300 text-gray-600 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800/30 transition-colors",children:"跳过"})]})]})}const Vo=s.memo(({message:t,index:r,prevMessage:a,createDiff:o,onFileOpen:n,onShowSettings:c,onGrantToolPermission:i,autoExpandTools:m,showRawParameters:h,showThinking:p,selectedProject:b,provider:E})=>{const v=a&&a.type===t.type&&(a.type==="assistant"||a.type==="user"||a.type==="tool"||a.type==="error"),j=Xe.useRef(null),[g,$]=Xe.useState(!1),L=Ho(t,E),[I,C]=Xe.useState("idle");return Xe.useEffect(()=>{C("idle")},[L?.entry,t.toolId]),Xe.useEffect(()=>{if(!m||!j.current||!t.isToolUse)return;const x=new IntersectionObserver(d=>{d.forEach(k=>{k.isIntersecting&&!g&&($(!0),j.current.querySelectorAll("details").forEach(A=>{A.open=!0}))})},{threshold:.1});return x.observe(j.current),()=>{j.current&&x.unobserve(j.current)}},[m,g,t.isToolUse]),e.jsx("div",{ref:j,className:`chat-message ${t.type} ${v?"grouped":""} ${t.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:t.type==="user"?e.jsxs("div",{className:"flex items-end space-x-0 sm:space-x-3 w-full sm:w-auto sm:max-w-[85%] md:max-w-md lg:max-w-lg xl:max-w-xl",children:[e.jsxs("div",{className:"bg-blue-600 text-white rounded-2xl rounded-br-md px-3 sm:px-4 py-2 shadow-sm flex-1 sm:flex-initial",children:[e.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:t.content}),t.images&&t.images.length>0&&e.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:t.images.map((x,d)=>e.jsx("img",{src:x.data,alt:x.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(x.data,"_blank")},d))}),e.jsx("div",{className:"text-xs text-blue-100 mt-1 text-right",children:new Date(t.timestamp).toLocaleTimeString()})]}),!v&&e.jsx("div",{className:"hidden sm:flex w-8 h-8 bg-blue-600 rounded-full items-center justify-center text-white text-sm flex-shrink-0",children:"U"})]}):e.jsxs("div",{className:"w-full",children:[!v&&e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[t.type==="error"?e.jsx("div",{className:"w-8 h-8 bg-red-600 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"!"}):t.type==="tool"?e.jsx("div",{className:"w-8 h-8 bg-gray-600 dark:bg-gray-700 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"🔧"}):e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1",children:e.jsx(ot,{className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t.type==="error"?"错误":t.type==="tool"?"工具":"Claude"})]}),e.jsxs("div",{className:"w-full",children:[t.isToolUse&&!["Read","TodoWrite","TodoRead"].includes(t.toolName)?["Grep","Glob"].includes(t.toolName)?e.jsx(e.Fragment,{children:e.jsx("div",{className:"group relative bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-blue-400 dark:border-blue-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 flex-1 min-w-0",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),e.jsx("span",{className:"font-medium flex-shrink-0",children:t.toolName}),e.jsx("span",{className:"text-gray-400 dark:text-gray-500 flex-shrink-0",children:"•"}),t.toolInput&&(()=>{try{const d=JSON.parse(t.toolInput);return e.jsxs("span",{className:"font-mono truncate flex-1 min-w-0",children:[d.pattern&&e.jsxs("span",{children:["pattern: ",e.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:d.pattern})]}),d.path&&e.jsxs("span",{className:"ml-2",children:["in: ",d.path]})]})}catch{return null}})()]}),t.toolResult&&e.jsxs("a",{href:`#tool-result-${t.toolId}`,className:"flex-shrink-0 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium transition-colors flex items-center gap-1",children:[e.jsx("span",{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:"M19 9l-7 7-7-7"})})]})]})})}):e.jsxs("div",{className:"group relative bg-gradient-to-br from-blue-50/50 to-indigo-50/50 dark:from-blue-950/20 dark:to-indigo-950/20 border border-blue-100/30 dark:border-blue-800/30 rounded-lg p-3 mb-2",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-500/3 to-indigo-500/3 dark:from-blue-400/3 dark:to-indigo-400/3 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300"}),e.jsxs("div",{className:"relative flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative w-8 h-8 bg-gradient-to-br from-blue-500 to-indigo-600 dark:from-blue-400 dark:to-indigo-500 rounded-lg flex items-center justify-center shadow-lg shadow-blue-500/20 dark:shadow-blue-400/20",children:[e.jsxs("svg",{className:"w-4 h-4 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),e.jsx("div",{className:"absolute inset-0 rounded-lg bg-blue-500 dark:bg-blue-400 animate-pulse opacity-20"})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-semibold text-gray-900 dark:text-white text-sm",children:t.toolName}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:t.toolId})]})]}),c&&e.jsx("button",{onClick:d=>{d.stopPropagation(),c()},className:"p-2 rounded-lg hover:bg-white/60 dark:hover:bg-gray-800/60 transition-all duration-200 group/btn backdrop-blur-sm",title:"工具设置",children:e.jsxs("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-400 group-hover/btn:text-blue-600 dark:group-hover/btn:text-blue-400 transition-colors",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]}),t.toolInput&&t.toolName==="Edit"&&(()=>{try{const d=JSON.parse(t.toolInput);if(d.file_path&&d.old_string&&d.new_string)return e.jsxs("details",{className:"relative mt-3 group/details",open:m,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2.5 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform duration-200 group-open/details:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),e.jsx("span",{className:"flex items-center gap-2",children:e.jsx("span",{children:"查看编辑差异"})}),e.jsx("button",{onClick:async k=>{if(k.preventDefault(),k.stopPropagation(),!!n)try{const S=await we.readFile(b?.name,d.file_path),A=await S.json();if(!S.ok||A.error){console.error("Failed to fetch file:",A.error),n(d.file_path);return}const W=A.content||"",O=W.replace(d.new_string,d.old_string);n(d.file_path,{old_string:O,new_string:W})}catch(S){console.error("Error preparing diff:",S),n(d.file_path)}},className:"px-2.5 py-1 rounded-md bg-white/60 dark:bg-gray-800/60 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30 font-mono text-xs font-medium transition-all duration-200 shadow-sm",children:d.file_path.split("/").pop()})]}),e.jsxs("div",{className:"mt-3 pl-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-900/50 border border-gray-200/60 dark:border-gray-700/60 rounded-lg overflow-hidden shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 bg-gradient-to-r from-gray-50 to-gray-100/50 dark:from-gray-800/80 dark:to-gray-800/40 border-b border-gray-200/60 dark:border-gray-700/60 backdrop-blur-sm",children:[e.jsx("button",{onClick:async()=>{if(n)try{const k=await we.readFile(b?.name,d.file_path),S=await k.json();if(!k.ok||S.error){console.error("Failed to fetch file:",S.error),n(d.file_path);return}const A=S.content||"",W=A.replace(d.new_string,d.old_string);n(d.file_path,{old_string:W,new_string:A})}catch(k){console.error("Error preparing diff:",k),n(d.file_path)}},className:"text-xs font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 truncate cursor-pointer font-medium transition-colors",children:d.file_path}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-medium px-2 py-0.5 bg-gray-100 dark:bg-gray-700/50 rounded",children:"Diff"})]}),e.jsx("div",{className:"text-xs font-mono",children:o(d.old_string,d.new_string).map((k,S)=>e.jsxs("div",{className:"flex",children:[e.jsx("span",{className:`w-8 text-center border-r ${k.type==="removed"?"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 border-red-200 dark:border-red-800":"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400 border-green-200 dark:border-green-800"}`,children:k.type==="removed"?"-":"+"}),e.jsx("span",{className:`px-2 py-0.5 flex-1 whitespace-pre-wrap ${k.type==="removed"?"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200":"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200"}`,children:k.content})]},S))})]}),h&&e.jsxs("details",{className:"relative mt-3 pl-6 group/raw",open:m,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-xs font-medium text-gray-600 dark:text-gray-400 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-3 h-3 transition-transform duration-200 group-open/raw:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看原始参数"]}),e.jsx("pre",{className:"mt-2 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/60 dark:border-gray-700/60 p-3 rounded-lg whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono",children:t.toolInput})]})]})]})}catch{}return e.jsxs("details",{className:"relative mt-3 group/params",open:m,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2.5 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform duration-200 group-open/params:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看输入参数"]}),e.jsx("pre",{className:"mt-3 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/60 dark:border-gray-700/60 p-3 rounded-lg whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono",children:t.toolInput})]})})(),t.toolInput&&t.toolName!=="Edit"&&(()=>{if(t.toolName==="Write")try{let d;if(typeof t.toolInput=="string"?d=JSON.parse(t.toolInput):d=t.toolInput,d.file_path&&d.content!==void 0)return e.jsxs("details",{className:"relative mt-3 group/details",open:m,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2.5 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform duration-200 group-open/details:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg leading-none",children:"📄"}),e.jsx("span",{children:"创建新文件:"})]}),e.jsx("button",{onClick:async k=>{if(k.preventDefault(),k.stopPropagation(),!!n)try{const S=await we.readFile(b?.name,d.file_path),A=await S.json(),W=S.ok&&!A.error?A.content||"":d.content||"";n(d.file_path,{old_string:"",new_string:W})}catch(S){console.error("Error preparing diff:",S),n(d.file_path,{old_string:"",new_string:d.content||""})}},className:"px-2.5 py-1 rounded-md bg-white/60 dark:bg-gray-800/60 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30 font-mono text-xs font-medium transition-all duration-200 shadow-sm",children:d.file_path.split("/").pop()})]}),e.jsxs("div",{className:"mt-3 pl-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-900/50 border border-gray-200/60 dark:border-gray-700/60 rounded-lg overflow-hidden shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 bg-gradient-to-r from-gray-50 to-gray-100/50 dark:from-gray-800/80 dark:to-gray-800/40 border-b border-gray-200/60 dark:border-gray-700/60 backdrop-blur-sm",children:[e.jsx("button",{onClick:async()=>{if(n)try{const k=await we.readFile(b?.name,d.file_path),S=await k.json(),A=k.ok&&!S.error?S.content||"":d.content||"";n(d.file_path,{old_string:"",new_string:A})}catch(k){console.error("Error preparing diff:",k),n(d.file_path,{old_string:"",new_string:d.content||""})}},className:"text-xs font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 truncate cursor-pointer font-medium transition-colors",children:d.file_path}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-medium px-2 py-0.5 bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 rounded",children:"新文件"})]}),e.jsx("div",{className:"text-xs font-mono",children:o("",d.content).map((k,S)=>e.jsxs("div",{className:"flex",children:[e.jsx("span",{className:`w-8 text-center border-r ${k.type==="removed"?"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 border-red-200 dark:border-red-800":"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400 border-green-200 dark:border-green-800"}`,children:k.type==="removed"?"-":"+"}),e.jsx("span",{className:`px-2 py-0.5 flex-1 whitespace-pre-wrap ${k.type==="removed"?"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200":"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200"}`,children:k.content})]},S))})]}),h&&e.jsxs("details",{className:"relative mt-3 pl-6 group/raw",open:m,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-xs font-medium text-gray-600 dark:text-gray-400 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-3 h-3 transition-transform duration-200 group-open/raw:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看原始参数"]}),e.jsx("pre",{className:"mt-2 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/60 dark:border-gray-700/60 p-3 rounded-lg whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono",children:t.toolInput})]})]})]})}catch{}if(t.toolName==="TodoWrite")try{const d=JSON.parse(t.toolInput);if(d.todos&&Array.isArray(d.todos))return e.jsxs("details",{className:"relative mt-3 group/todo",open:m,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2.5 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform duration-200 group-open/todo:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg leading-none",children:"✓"}),e.jsx("span",{children:"更新待办列表"})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx(Lr,{todos:d.todos}),h&&e.jsxs("details",{className:"relative mt-3 group/raw",open:m,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-xs font-medium text-gray-600 dark:text-gray-400 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-3 h-3 transition-transform duration-200 group-open/raw:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看原始参数"]}),e.jsx("pre",{className:"mt-2 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/60 dark:border-gray-700/60 p-3 rounded-lg overflow-x-auto text-gray-700 dark:text-gray-300 font-mono",children:t.toolInput})]})]})]})}catch{}if(t.toolName==="Bash")try{const d=JSON.parse(t.toolInput);return e.jsxs("div",{className:"my-2",children:[e.jsxs("div",{className:"bg-gray-900 dark:bg-gray-950 rounded-md px-3 py-2 font-mono text-sm",children:[e.jsx("span",{className:"text-green-400",children:"$"}),e.jsx("span",{className:"text-gray-100 ml-2",children:d.command})]}),d.description&&e.jsx("div",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400 italic ml-1",children:d.description})]})}catch{}if(t.toolName==="Read")try{const d=JSON.parse(t.toolInput);if(d.file_path){const k=d.file_path.split("/").pop();return e.jsxs("div",{className:"mt-2 text-sm text-blue-700 dark:text-blue-300",children:["Read"," ",e.jsx("button",{onClick:()=>n&&n(d.file_path),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline font-mono",children:k})]})}}catch{}if(t.toolName==="exit_plan_mode")try{const d=JSON.parse(t.toolInput);if(d.plan){const k=d.plan.replace(/\\n/g,`
|
|
54
|
-
`);return e.jsxs("details",{className:"mt-2",open:
|
|
55
|
-
`);return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("span",{className:"font-medium",children:"实现计划"})}),e.jsx(Et,{className:"prose prose-sm max-w-none dark:prose-invert",children:
|
|
56
|
-
`),
|
|
57
|
-
`),ie=W.slice(
|
|
58
|
-
`).filter(S=>S.trim()),d=x.find(S=>S.includes("?"))||x[0]||"",k=[];return x.forEach(S=>{const A=S.match(/[❯\s]*(\d+)\.\s+(.+)/);if(A){const W=S.includes("❯");k.push({number:A[1],text:A[2].trim(),isSelected:W})}}),e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200 mb-4",children:d}),e.jsx("div",{className:"space-y-2 mb-4",children:k.map(S=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${S.isSelected?"bg-amber-600 dark:bg-amber-700 text-white border-amber-600 dark:border-amber-700 shadow-md":"bg-white dark:bg-gray-800 text-amber-900 dark:text-amber-100 border-amber-300 dark:border-amber-700"} cursor-not-allowed opacity-75`,disabled:!0,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold ${S.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:S.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:S.text}),S.isSelected&&e.jsx("span",{className:"text-lg",children:"❯"})]})},S.number))}),e.jsxs("div",{className:"bg-amber-100 dark:bg-amber-800/30 rounded-lg p-3",children:[e.jsx("p",{className:"text-amber-900 dark:text-amber-100 text-sm font-medium mb-1",children:"⏳ 等待您在 CLI 中的响应"}),e.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:"请在运行 Claude 的终端中选择一个选项。"})]})]})})()]})]})}):t.isToolUse&&t.toolName==="Read"?(()=>{try{const x=JSON.parse(t.toolInput);if(x.file_path){const d=x.file_path.split("/").pop();return e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),e.jsx("span",{className:"font-medium",children:"Read"}),e.jsx("button",{onClick:()=>n&&n(x.file_path),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-mono transition-colors",children:d})]})})}}catch{return e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),e.jsx("span",{className:"font-medium",children:"读取文件"})]})})}})():t.isToolUse&&t.toolName==="TodoWrite"?(()=>{try{const x=JSON.parse(t.toolInput);if(x.todos&&Array.isArray(x.todos))return e.jsxs("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 mb-2",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),e.jsx("span",{className:"font-medium",children:"更新待办列表"})]}),e.jsx(Lr,{todos:x.todos})]})}catch{return e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),e.jsx("span",{className:"font-medium",children:"更新待办列表"})]})})}})():t.isToolUse&&t.toolName==="TodoRead"?e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),e.jsx("span",{className:"font-medium",children:"读取待办列表"})]})}):t.isThinking?e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"cursor-pointer text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 font-medium flex items-center gap-2",children:[e.jsx("svg",{className:"w-3 h-3 transition-transform group-open:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsx("span",{children:"💭 思考中..."})]}),e.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 text-sm",children:e.jsx(Et,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:t.content})})]})}):e.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[p&&t.reasoning&&e.jsxs("details",{className:"mb-3",children:[e.jsx("summary",{className:"cursor-pointer text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 font-medium",children:"💭 思考中..."}),e.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 italic text-gray-600 dark:text-gray-400 text-sm",children:e.jsx("div",{className:"whitespace-pre-wrap",children:t.reasoning})})]}),(()=>{const x=Wr(String(t.content||"")),d=x.trim();if((d.startsWith("{")||d.startsWith("["))&&(d.endsWith("}")||d.endsWith("]")))try{const k=JSON.parse(d),S=JSON.stringify(k,null,2);return e.jsxs("div",{className:"my-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",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:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),e.jsx("span",{className:"font-medium",children:"JSON 响应"})]}),e.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsx("pre",{className:"p-4 overflow-x-auto",children:e.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:S})})})]})}catch{}return t.type==="assistant"?e.jsx(Et,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:x}):e.jsx("div",{className:"whitespace-pre-wrap",children:x})})()]}),e.jsx("div",{className:`text-xs text-gray-500 dark:text-gray-400 mt-1 ${v?"opacity-0 group-hover:opacity-100":""}`,children:new Date(t.timestamp).toLocaleTimeString()})]})]})})}),Go=({file:t,onRemove:r,uploadProgress:a,error:o})=>{const[n,c]=s.useState(null);return s.useEffect(()=>{const i=URL.createObjectURL(t);return c(i),()=>URL.revokeObjectURL(i)},[t]),e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:n,alt:t.name,className:"w-20 h-20 object-cover rounded"}),a!==void 0&&a<100&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsxs("div",{className:"text-white text-xs",children:[a,"%"]})}),o&&e.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-white",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("button",{onClick:r,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 opacity-0 group-hover:opacity-100",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"})})})]})};function Yo({selectedProject:t,selectedSession:r,ws:a,sendMessage:o,messages:n,onFileOpen:c,onInputFocusChange:i,onSessionActive:m,onSessionInactive:h,onSessionProcessing:p,onSessionNotProcessing:b,processingSessions:E,onReplaceTemporarySession:v,onNavigateToSession:j,onShowSettings:g,autoExpandTools:$,showRawParameters:L,showThinking:I,autoScrollToBottom:C,sendByCtrlEnter:x,externalMessageUpdate:d,onTaskClick:k,limitStatus:S,onLimitExceeded:A,checkLimitStatus:W}){const[O,Q]=s.useState(()=>typeof window<"u"&&t&&Je.getItem(`draft_input_${t.name}`)||""),[ie,Z]=s.useState(()=>{if(typeof window<"u"&&t){const l=Je.getItem(`chat_messages_${t.name}`);return l?JSON.parse(l):[]}return[]}),[se,B]=s.useState(!1),[T,z]=s.useState(r?.id||null),[Y,pe]=s.useState(!1),[ae,G]=s.useState([]),[xe,Ne]=s.useState(!1),[Ce,je]=s.useState(!1),[_e,he]=s.useState(0),[Se,ke]=s.useState(!1),[Ee,ye]=s.useState(0),Pe=20,Re=s.useCallback(l=>{ve.current=l,he(l)},[]),[Me,H]=s.useState(!1),[f,y]=s.useState("default"),[F,oe]=s.useState([]),[ue,Le]=s.useState([]),[He,Ye]=s.useState(new Map),[qe,u]=s.useState(new Map),[_,X]=s.useState(!1),te=s.useRef(null),D=s.useRef(null),De=s.useRef(null),Be=s.useRef(null),Ie=s.useRef(null),q=s.useRef(!1),me=s.useRef(!1),re=s.useRef(!1),le=s.useRef(null),ve=s.useRef(0),ze=s.useRef(""),ge=s.useRef(null),We=s.useRef(null),[zt,et]=s.useState(""),[_t,bt]=s.useState(!1),[Jt,yt]=s.useState([]),[tt,hr]=s.useState([]),[At,Ft]=s.useState(-1),[Kt,at]=s.useState(0),[R,V]=s.useState(-1),[de,fe]=s.useState(!1),[it,Qe]=s.useState(!1),gr=s.useRef({height:0,top:0}),[Vt,lt]=s.useState(!1),[Ze,fr]=s.useState([]),[vt,Gt]=s.useState([]),[Yt,ct]=s.useState(""),[ia,pt]=s.useState(!1),[Qr,St]=s.useState(null),[br,dt]=s.useState(-1),[Zr,xt]=s.useState(-1),[Ot,la]=s.useState(100),[ca,ht]=s.useState(null),[gt,Xr]=s.useState(()=>localStorage.getItem("claude-model")||Ms.DEFAULT),mt="claude";s.useEffect(()=>{if(r?.id){const l=localStorage.getItem(`permissionMode-${r.id}`);y(l||"default")}},[r?.id]),s.useEffect(()=>{oe(l=>l.filter(w=>!w.sessionId||w.sessionId===r?.id))},[r?.id]),s.useEffect(()=>{(async()=>{if(t)try{const w=await ne("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:t.path})});if(!w.ok)throw new Error("Failed to fetch commands");const M=await w.json(),N=[...(M.builtIn||[]).map(ce=>({...ce,type:"built-in"})),...(M.custom||[]).map(ce=>({...ce,type:"custom"}))];fr(N);const P=`command_history_${t.name}`,K=Je.getItem(P);if(K)try{const ce=JSON.parse(K),U=N.sort((ee,be)=>{const Te=ce[ee.name]||0;return(ce[be.name]||0)-Te});fr(U)}catch(ce){console.error("Error parsing command history:",ce)}}catch(w){console.error("Error fetching slash commands:",w),fr([])}})()},[t]);const yr=s.useMemo(()=>Ze.length?new Va(Ze,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[Ze]);s.useEffect(()=>{if(!Yt){Gt(Ze);return}if(!yr){Gt([]);return}const l=yr.search(Yt);Gt(l.map(w=>w.item))},[Yt,Ze,yr]);const da=s.useMemo(()=>{if(!t||Ze.length===0)return[];const l=`command_history_${t.name}`,w=Je.getItem(l);if(!w)return[];try{const M=JSON.parse(w);return Ze.map(P=>({...P,usageCount:M[P.name]||0})).filter(P=>P.usageCount>0).sort((P,K)=>K.usageCount-P.usageCount).slice(0,5)}catch(M){return console.error("Error parsing command history:",M),[]}},[t,Ze]),ma=s.useCallback((l,w,M)=>{if(!l||!t)return;if(M){dt(w);return}const N=`command_history_${t.name}`,P=Je.getItem(N);let K={};try{K=P?JSON.parse(P):{}}catch(ce){console.error("Error parsing command history:",ce)}K[l.name]=(K[l.name]||0)+1,Je.setItem(N,JSON.stringify(K)),Qt(l)},[t]),ua=s.useCallback(l=>{const{action:w,data:M}=l;switch(w){case"help":Z(N=>[...N,{type:"assistant",content:M.content,timestamp:Date.now()}]);break;case"model":{const N=M.available.claude,P=M.message?.includes("Switching to model:")?M.message.replace("Switching to model: ","").trim():null;P&&N.includes(P)?(Xr(P),localStorage.setItem("claude-model",P),Z(K=>[...K,{type:"assistant",content:`已切换到模型: **${P}**`,timestamp:Date.now()}])):Z(P?K=>[...K,{type:"assistant",content:`无效的模型: ${P}
|
|
52
|
+
`})]})},Ts={OPTIONS:[{value:"sonnet",label:"Sonnet"},{value:"opus",label:"Opus"},{value:"haiku",label:"Haiku"}],DEFAULT:"sonnet"};function Ct(t){return t&&t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function Uo(t){if(!t||typeof t!="string")return t;try{return t.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return t}}function ar(t){if(!t||typeof t!="string")return t;const r=[],a="__MATH_BLOCK_",o="__";let n=t.replace(/\$\$([\s\S]*?)\$\$|\$([^\$\n]+?)\$/g,l=>{const i=r.length;return r.push(l),`${a}${i}${o}`});return n=n.replace(/\\n/g,`
|
|
53
|
+
`).replace(/\\t/g," ").replace(/\\r/g,"\r"),n=n.replace(new RegExp(`${a}(\\d+)${o}`,"g"),(l,i)=>r[parseInt(i)]),n}const Et=({children:t,className:r})=>{const a=Uo(String(t??"")),o=s.useMemo(()=>[jn,wn],[]),n=s.useMemo(()=>[kn],[]);return e.jsx("div",{className:r,children:e.jsx(Nn,{remarkPlugins:o,rehypePlugins:n,components:Jo,children:a})})};function Wr(t){try{return typeof t!="string"?t:t.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(r,a)=>{let o=parseInt(a,10);if(!Number.isFinite(o))return r;o<1e12&&(o*=1e3);const n=new Date(o),l=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(n),i=-n.getTimezoneOffset(),d=i>=0?"+":"-",x=Math.abs(i),p=Math.floor(x/60),b=x%60,C=`GMT${d}${p}${b?":"+String(b).padStart(2,"0"):""}`,h=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,E=>E.toUpperCase()),$=h?`${C} (${h})`:C,M=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],I=`${n.getDate()} ${M[n.getMonth()]} ${n.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${l} ${$}** - ${I}`})}catch{return t}}const Je={setItem:(t,r)=>{try{if(t.startsWith("chat_messages_")&&typeof r=="string")try{const a=JSON.parse(r);if(Array.isArray(a)&&a.length>50){console.warn(`Truncating chat history for ${t} from ${a.length} to 50 messages`);const o=a.slice(-50);r=JSON.stringify(o)}}catch(a){console.warn("Could not parse chat messages for truncation:",a)}localStorage.setItem(t,r)}catch(a){if(a.name==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old data");const o=Object.keys(localStorage),n=o.filter(i=>i.startsWith("chat_messages_")).sort();n.length>3&&n.slice(0,n.length-3).forEach(i=>{localStorage.removeItem(i),console.log(`Removed old chat data: ${i}`)}),o.filter(i=>i.startsWith("draft_input_")).forEach(i=>{localStorage.removeItem(i)});try{localStorage.setItem(t,r)}catch(i){if(console.error("Failed to save to localStorage even after cleanup:",i),t.startsWith("chat_messages_")&&typeof r=="string")try{const d=JSON.parse(r);if(Array.isArray(d)&&d.length>10){const x=d.slice(-10);localStorage.setItem(t,JSON.stringify(x)),console.warn("Saved only last 10 messages due to quota constraints")}}catch(d){console.error("Final save attempt failed:",d)}}}else console.error("localStorage error:",a)}},getItem:t=>{try{return localStorage.getItem(t)}catch(r){return console.error("localStorage getItem error:",r),null}},removeItem:t=>{try{localStorage.removeItem(t)}catch(r){console.error("localStorage removeItem error:",r)}}},sa="claude-settings";function Vr(){const t=Je.getItem(sa);if(!t)return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"};try{const r=JSON.parse(t);return{...r,allowedTools:Array.isArray(r.allowedTools)?r.allowedTools:[],disallowedTools:Array.isArray(r.disallowedTools)?r.disallowedTools:[],skipPermissions:!!r.skipPermissions,projectSortOrder:r.projectSortOrder||"name"}}catch{return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"}}}function Br(t,r){if(!t)return null;if(t!=="Bash")return t;const a=Rn(r),o=typeof a?.command=="string"?a.command.trim():"";if(!o)return t;const n=o.split(/\s+/);return n.length===0?t:n[0]==="git"&&n[1]?`Bash(${n[0]} ${n[1]}:*)`:`Bash(${n[0]}:*)`}function Rs(t){if(t==null)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Ho(t,r){if(r!=="claude"||!t?.toolResult?.isError)return null;const a=t?.toolName,o=Br(a,t.toolInput);if(!o)return null;const l=Vr().allowedTools.includes(o);return{toolName:a,entry:o,isAllowed:l}}function qo(t){if(!t)return{success:!1};const r=Vr(),a=r.allowedTools.includes(t),o=a?r.allowedTools:[...r.allowedTools,t],n=r.disallowedTools.filter(i=>i!==t),l={...r,allowedTools:o,disallowedTools:n,lastUpdated:new Date().toISOString()};return Je.setItem(sa,JSON.stringify(l)),{success:!0,alreadyAllowed:a,updatedSettings:l}}const Jo={code:({node:t,inline:r,className:a,children:o,...n})=>{const[l,i]=Xe.useState(!1),d=Array.isArray(o)?o.join(""):String(o??""),x=/[\r\n]/.test(d);if(r||t&&t.type==="inlineCode"||!x)return e.jsx("code",{className:`font-mono text-[0.9em] px-1.5 py-0.5 rounded-md bg-gray-100 text-gray-900 border border-gray-200 dark:bg-gray-800/60 dark:text-gray-100 dark:border-gray-700 whitespace-pre-wrap break-words ${a||""}`,...n,children:o});const C=/language-(\w+)/.exec(a||""),j=C?C[1]:"text",y=d,h=()=>{const $=()=>{i(!0),setTimeout(()=>i(!1),1500)};try{if(navigator&&navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(y).then($).catch(()=>{const M=document.createElement("textarea");M.value=y,M.style.position="fixed",M.style.opacity="0",document.body.appendChild(M),M.select();try{document.execCommand("copy")}catch{}document.body.removeChild(M),$()});else{const M=document.createElement("textarea");M.value=y,M.style.position="fixed",M.style.opacity="0",document.body.appendChild(M),M.select();try{document.execCommand("copy")}catch{}document.body.removeChild(M),$()}}catch{}};return e.jsxs("div",{className:"relative group my-2",children:[j&&j!=="text"&&e.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:j}),e.jsx("button",{type:"button",onClick:h,className:"absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 focus:opacity-100 active:opacity-100 transition-opacity text-xs px-2 py-1 rounded-md bg-gray-700/80 hover:bg-gray-700 text-white border border-gray-600",title:l?"已复制":"复制代码","aria-label":l?"已复制":"复制代码",children:l?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),"已复制"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),"复制"]})}),e.jsx(Sn,{language:j,style:An,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:j&&j!=="text"?"2rem 1rem 1rem 1rem":"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:d})]})},blockquote:({children:t})=>e.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:t}),a:({href:t,children:r})=>e.jsx("a",{href:t,className:"text-blue-600 dark:text-blue-400 hover:underline",target:"_blank",rel:"noopener noreferrer",children:r}),p:({children:t})=>e.jsx("div",{className:"mb-2 last:mb-0",children:t}),table:({children:t})=>e.jsx("div",{className:"overflow-x-auto my-2",children:e.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:t})}),thead:({children:t})=>e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:t}),th:({children:t})=>e.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold border border-gray-200 dark:border-gray-700",children:t}),td:({children:t})=>e.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:t})};function Ko({request:t,onSubmit:r,onSkip:a}){const o=t.input?.questions||[],[n,l]=Xe.useState(()=>Object.fromEntries(o.map(p=>[p.question,[]]))),i=(p,b,C)=>{l(j=>{const y=j[p]||[];return C?{...j,[p]:y.includes(b)?y.filter(h=>h!==b):[...y,b]}:{...j,[p]:[b]}})},d=o.every(p=>(n[p.question]||[]).length>0),x=()=>{const p={};o.forEach(b=>{p[b.question]=(n[b.question]||[]).join(", ")}),r(p)};return e.jsxs("div",{className:"rounded-lg border border-blue-200 dark:border-blue-800 bg-blue-50 dark:bg-blue-900/20 p-3 shadow-sm",children:[e.jsx("div",{className:"text-sm font-semibold text-blue-900 dark:text-blue-100 mb-3",children:"Claude 需要您的回答"}),o.map((p,b)=>e.jsxs("div",{className:b<o.length-1?"mb-4":"mb-0",children:[e.jsxs("div",{className:"text-sm font-medium text-blue-800 dark:text-blue-200 mb-2",children:[p.question,p.multiSelect&&e.jsx("span",{className:"ml-2 text-xs font-normal opacity-60",children:"(可多选)"})]}),e.jsx("div",{className:"space-y-1",children:p.options.map((C,j)=>{const y=(n[p.question]||[]).includes(C.label);return e.jsxs("button",{type:"button",onClick:()=>i(p.question,C.label,p.multiSelect),className:`w-full text-left px-3 py-2 rounded-md text-xs border transition-colors ${y?"bg-blue-600 text-white border-blue-600":"bg-white dark:bg-gray-800 border-blue-200 dark:border-blue-700 text-blue-800 dark:text-blue-200 hover:bg-blue-50 dark:hover:bg-blue-900/30"}`,children:[e.jsx("span",{className:"font-medium",children:C.label}),C.description&&e.jsxs("span",{className:"ml-1 opacity-70",children:[" — ",C.description]})]},j)})})]},b)),e.jsxs("div",{className:"mt-3 flex gap-2",children:[e.jsx("button",{type:"button",onClick:x,disabled:!d,className:"inline-flex items-center gap-2 rounded-md bg-blue-600 text-white text-xs font-medium px-3 py-1.5 hover:bg-blue-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:"提交答案"}),e.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border border-gray-300 text-gray-600 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800/30 transition-colors",children:"跳过"})]})]})}const Go=s.memo(({message:t,index:r,prevMessage:a,createDiff:o,onFileOpen:n,onShowSettings:l,onGrantToolPermission:i,autoExpandTools:d,showRawParameters:x,showThinking:p,selectedProject:b,provider:C})=>{const j=a&&a.type===t.type&&(a.type==="assistant"||a.type==="user"||a.type==="tool"||a.type==="error"),y=Xe.useRef(null),[h,$]=Xe.useState(!1),M=Ho(t,C),[I,E]=Xe.useState("idle");return Xe.useEffect(()=>{E("idle")},[M?.entry,t.toolId]),Xe.useEffect(()=>{if(!d||!y.current||!t.isToolUse)return;const g=new IntersectionObserver(m=>{m.forEach(k=>{k.isIntersecting&&!h&&($(!0),y.current.querySelectorAll("details").forEach(R=>{R.open=!0}))})},{threshold:.1});return g.observe(y.current),()=>{y.current&&g.unobserve(y.current)}},[d,h,t.isToolUse]),e.jsx("div",{ref:y,className:`chat-message ${t.type} ${j?"grouped":""} ${t.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:t.type==="user"?e.jsxs("div",{className:"flex items-end space-x-0 sm:space-x-3 w-full sm:w-auto sm:max-w-[85%] md:max-w-md lg:max-w-lg xl:max-w-xl",children:[e.jsxs("div",{className:"bg-blue-600 text-white rounded-2xl rounded-br-md px-3 sm:px-4 py-2 shadow-sm flex-1 sm:flex-initial",children:[e.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:t.content}),t.images&&t.images.length>0&&e.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:t.images.map((g,m)=>e.jsx("img",{src:g.data,alt:g.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(g.data,"_blank")},m))}),e.jsx("div",{className:"text-xs text-blue-100 mt-1 text-right",children:new Date(t.timestamp).toLocaleTimeString()})]}),!j&&e.jsx("div",{className:"hidden sm:flex w-8 h-8 bg-blue-600 rounded-full items-center justify-center text-white text-sm flex-shrink-0",children:"U"})]}):e.jsxs("div",{className:"w-full",children:[!j&&e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[t.type==="error"?e.jsx("div",{className:"w-8 h-8 bg-red-600 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"!"}):t.type==="tool"?e.jsx("div",{className:"w-8 h-8 bg-gray-600 dark:bg-gray-700 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"🔧"}):e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1",children:e.jsx(ot,{className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t.type==="error"?"错误":t.type==="tool"?"工具":"Claude"})]}),e.jsxs("div",{className:"w-full",children:[t.isToolUse&&!["Read","TodoWrite","TodoRead"].includes(t.toolName)?["Grep","Glob"].includes(t.toolName)?e.jsx(e.Fragment,{children:e.jsx("div",{className:"group relative bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-blue-400 dark:border-blue-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 flex-1 min-w-0",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),e.jsx("span",{className:"font-medium flex-shrink-0",children:t.toolName}),e.jsx("span",{className:"text-gray-400 dark:text-gray-500 flex-shrink-0",children:"•"}),t.toolInput&&(()=>{try{const m=JSON.parse(t.toolInput);return e.jsxs("span",{className:"font-mono truncate flex-1 min-w-0",children:[m.pattern&&e.jsxs("span",{children:["pattern: ",e.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:m.pattern})]}),m.path&&e.jsxs("span",{className:"ml-2",children:["in: ",m.path]})]})}catch{return null}})()]}),t.toolResult&&e.jsxs("a",{href:`#tool-result-${t.toolId}`,className:"flex-shrink-0 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium transition-colors flex items-center gap-1",children:[e.jsx("span",{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:"M19 9l-7 7-7-7"})})]})]})})}):e.jsxs("div",{className:"group relative bg-gradient-to-br from-blue-50/50 to-indigo-50/50 dark:from-blue-950/20 dark:to-indigo-950/20 border border-blue-100/30 dark:border-blue-800/30 rounded-lg p-3 mb-2",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-500/3 to-indigo-500/3 dark:from-blue-400/3 dark:to-indigo-400/3 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-300"}),e.jsxs("div",{className:"relative flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative w-8 h-8 bg-gradient-to-br from-blue-500 to-indigo-600 dark:from-blue-400 dark:to-indigo-500 rounded-lg flex items-center justify-center shadow-lg shadow-blue-500/20 dark:shadow-blue-400/20",children:[e.jsxs("svg",{className:"w-4 h-4 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),e.jsx("div",{className:"absolute inset-0 rounded-lg bg-blue-500 dark:bg-blue-400 animate-pulse opacity-20"})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-semibold text-gray-900 dark:text-white text-sm",children:t.toolName}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:t.toolId})]})]}),l&&e.jsx("button",{onClick:m=>{m.stopPropagation(),l()},className:"p-2 rounded-lg hover:bg-white/60 dark:hover:bg-gray-800/60 transition-all duration-200 group/btn backdrop-blur-sm",title:"工具设置",children:e.jsxs("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-400 group-hover/btn:text-blue-600 dark:group-hover/btn:text-blue-400 transition-colors",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]}),t.toolInput&&t.toolName==="Edit"&&(()=>{try{const m=JSON.parse(t.toolInput);if(m.file_path&&m.old_string&&m.new_string)return e.jsxs("details",{className:"relative mt-3 group/details",open:d,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2.5 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform duration-200 group-open/details:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),e.jsx("span",{className:"flex items-center gap-2",children:e.jsx("span",{children:"查看编辑差异"})}),e.jsx("button",{onClick:async k=>{if(k.preventDefault(),k.stopPropagation(),!!n)try{const w=await we.readFile(b?.name,m.file_path),R=await w.json();if(!w.ok||R.error){console.error("Failed to fetch file:",R.error),n(m.file_path);return}const W=R.content||"",F=W.replace(m.new_string,m.old_string);n(m.file_path,{old_string:F,new_string:W})}catch(w){console.error("Error preparing diff:",w),n(m.file_path)}},className:"px-2.5 py-1 rounded-md bg-white/60 dark:bg-gray-800/60 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30 font-mono text-xs font-medium transition-all duration-200 shadow-sm",children:m.file_path.split("/").pop()})]}),e.jsxs("div",{className:"mt-3 pl-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-900/50 border border-gray-200/60 dark:border-gray-700/60 rounded-lg overflow-hidden shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 bg-gradient-to-r from-gray-50 to-gray-100/50 dark:from-gray-800/80 dark:to-gray-800/40 border-b border-gray-200/60 dark:border-gray-700/60 backdrop-blur-sm",children:[e.jsx("button",{onClick:async()=>{if(n)try{const k=await we.readFile(b?.name,m.file_path),w=await k.json();if(!k.ok||w.error){console.error("Failed to fetch file:",w.error),n(m.file_path);return}const R=w.content||"",W=R.replace(m.new_string,m.old_string);n(m.file_path,{old_string:W,new_string:R})}catch(k){console.error("Error preparing diff:",k),n(m.file_path)}},className:"text-xs font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 truncate cursor-pointer font-medium transition-colors",children:m.file_path}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-medium px-2 py-0.5 bg-gray-100 dark:bg-gray-700/50 rounded",children:"Diff"})]}),e.jsx("div",{className:"text-xs font-mono",children:o(m.old_string,m.new_string).map((k,w)=>e.jsxs("div",{className:"flex",children:[e.jsx("span",{className:`w-8 text-center border-r ${k.type==="removed"?"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 border-red-200 dark:border-red-800":"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400 border-green-200 dark:border-green-800"}`,children:k.type==="removed"?"-":"+"}),e.jsx("span",{className:`px-2 py-0.5 flex-1 whitespace-pre-wrap ${k.type==="removed"?"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200":"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200"}`,children:k.content})]},w))})]}),x&&e.jsxs("details",{className:"relative mt-3 pl-6 group/raw",open:d,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-xs font-medium text-gray-600 dark:text-gray-400 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-3 h-3 transition-transform duration-200 group-open/raw:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看原始参数"]}),e.jsx("pre",{className:"mt-2 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/60 dark:border-gray-700/60 p-3 rounded-lg whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono",children:t.toolInput})]})]})]})}catch{}return e.jsxs("details",{className:"relative mt-3 group/params",open:d,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2.5 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform duration-200 group-open/params:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看输入参数"]}),e.jsx("pre",{className:"mt-3 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/60 dark:border-gray-700/60 p-3 rounded-lg whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono",children:t.toolInput})]})})(),t.toolInput&&t.toolName!=="Edit"&&(()=>{if(t.toolName==="Write")try{let m;if(typeof t.toolInput=="string"?m=JSON.parse(t.toolInput):m=t.toolInput,m.file_path&&m.content!==void 0)return e.jsxs("details",{className:"relative mt-3 group/details",open:d,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2.5 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform duration-200 group-open/details:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg leading-none",children:"📄"}),e.jsx("span",{children:"创建新文件:"})]}),e.jsx("button",{onClick:async k=>{if(k.preventDefault(),k.stopPropagation(),!!n)try{const w=await we.readFile(b?.name,m.file_path),R=await w.json(),W=w.ok&&!R.error?R.content||"":m.content||"";n(m.file_path,{old_string:"",new_string:W})}catch(w){console.error("Error preparing diff:",w),n(m.file_path,{old_string:"",new_string:m.content||""})}},className:"px-2.5 py-1 rounded-md bg-white/60 dark:bg-gray-800/60 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/30 font-mono text-xs font-medium transition-all duration-200 shadow-sm",children:m.file_path.split("/").pop()})]}),e.jsxs("div",{className:"mt-3 pl-6",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-900/50 border border-gray-200/60 dark:border-gray-700/60 rounded-lg overflow-hidden shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 bg-gradient-to-r from-gray-50 to-gray-100/50 dark:from-gray-800/80 dark:to-gray-800/40 border-b border-gray-200/60 dark:border-gray-700/60 backdrop-blur-sm",children:[e.jsx("button",{onClick:async()=>{if(n)try{const k=await we.readFile(b?.name,m.file_path),w=await k.json(),R=k.ok&&!w.error?w.content||"":m.content||"";n(m.file_path,{old_string:"",new_string:R})}catch(k){console.error("Error preparing diff:",k),n(m.file_path,{old_string:"",new_string:m.content||""})}},className:"text-xs font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 truncate cursor-pointer font-medium transition-colors",children:m.file_path}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-medium px-2 py-0.5 bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 rounded",children:"新文件"})]}),e.jsx("div",{className:"text-xs font-mono",children:o("",m.content).map((k,w)=>e.jsxs("div",{className:"flex",children:[e.jsx("span",{className:`w-8 text-center border-r ${k.type==="removed"?"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 border-red-200 dark:border-red-800":"bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400 border-green-200 dark:border-green-800"}`,children:k.type==="removed"?"-":"+"}),e.jsx("span",{className:`px-2 py-0.5 flex-1 whitespace-pre-wrap ${k.type==="removed"?"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200":"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200"}`,children:k.content})]},w))})]}),x&&e.jsxs("details",{className:"relative mt-3 pl-6 group/raw",open:d,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-xs font-medium text-gray-600 dark:text-gray-400 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-3 h-3 transition-transform duration-200 group-open/raw:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看原始参数"]}),e.jsx("pre",{className:"mt-2 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/60 dark:border-gray-700/60 p-3 rounded-lg whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono",children:t.toolInput})]})]})]})}catch{}if(t.toolName==="TodoWrite")try{const m=JSON.parse(t.toolInput);if(m.todos&&Array.isArray(m.todos))return e.jsxs("details",{className:"relative mt-3 group/todo",open:d,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2.5 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform duration-200 group-open/todo:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg leading-none",children:"✓"}),e.jsx("span",{children:"更新待办列表"})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx(Lr,{todos:m.todos}),x&&e.jsxs("details",{className:"relative mt-3 group/raw",open:d,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-xs font-medium text-gray-600 dark:text-gray-400 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-3 h-3 transition-transform duration-200 group-open/raw:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看原始参数"]}),e.jsx("pre",{className:"mt-2 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/60 dark:border-gray-700/60 p-3 rounded-lg overflow-x-auto text-gray-700 dark:text-gray-300 font-mono",children:t.toolInput})]})]})]})}catch{}if(t.toolName==="Bash")try{const m=JSON.parse(t.toolInput);return e.jsxs("div",{className:"my-2",children:[e.jsxs("div",{className:"bg-gray-900 dark:bg-gray-950 rounded-md px-3 py-2 font-mono text-sm",children:[e.jsx("span",{className:"text-green-400",children:"$"}),e.jsx("span",{className:"text-gray-100 ml-2",children:m.command})]}),m.description&&e.jsx("div",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400 italic ml-1",children:m.description})]})}catch{}if(t.toolName==="Read")try{const m=JSON.parse(t.toolInput);if(m.file_path){const k=m.file_path.split("/").pop();return e.jsxs("div",{className:"mt-2 text-sm text-blue-700 dark:text-blue-300",children:["Read"," ",e.jsx("button",{onClick:()=>n&&n(m.file_path),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline font-mono",children:k})]})}}catch{}if(t.toolName==="exit_plan_mode")try{const m=JSON.parse(t.toolInput);if(m.plan){const k=m.plan.replace(/\\n/g,`
|
|
54
|
+
`);return e.jsxs("details",{className:"mt-2",open:d,children:[e.jsxs("summary",{className:"text-sm text-blue-700 dark:text-blue-300 cursor-pointer hover:text-blue-800 dark:hover:text-blue-200 flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform details-chevron",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"📋 查看实现计划"]}),e.jsx(Et,{className:"mt-3 prose prose-sm max-w-none dark:prose-invert",children:k})]})}}catch{}return e.jsxs("details",{className:"relative mt-3 group/params",open:d,children:[e.jsxs("summary",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200 p-2.5 rounded-lg hover:bg-white/50 dark:hover:bg-gray-800/50",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform duration-200 group-open/params:rotate-180",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看输入参数"]}),e.jsx("pre",{className:"mt-3 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/60 dark:border-gray-700/60 p-3 rounded-lg whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono",children:t.toolInput})]})})(),t.toolResult&&(!t.toolResult.isError&&(t.toolName==="Edit"||t.toolName==="Write"||t.toolName==="ApplyPatch"||t.toolName==="Bash")?null:e.jsxs("div",{id:`tool-result-${t.toolId}`,className:`relative mt-4 p-4 rounded-lg border backdrop-blur-sm scroll-mt-4 ${t.toolResult.isError?"bg-gradient-to-br from-red-50 to-rose-50 dark:from-red-950/20 dark:to-rose-950/20 border-red-200/60 dark:border-red-800/60":"bg-gradient-to-br from-green-50 to-emerald-50 dark:from-green-950/20 dark:to-emerald-950/20 border-green-200/60 dark:border-green-800/60"}`,children:[e.jsx("div",{className:`absolute inset-0 rounded-lg opacity-50 ${t.toolResult.isError?"bg-gradient-to-br from-red-500/5 to-rose-500/5 dark:from-red-400/5 dark:to-rose-400/5":"bg-gradient-to-br from-green-500/5 to-emerald-500/5 dark:from-green-400/5 dark:to-emerald-400/5"}`}),e.jsxs("div",{className:"relative flex items-center gap-2.5 mb-3",children:[e.jsx("div",{className:`w-6 h-6 rounded-lg flex items-center justify-center shadow-md ${t.toolResult.isError?"bg-gradient-to-br from-red-500 to-rose-600 dark:from-red-400 dark:to-rose-500 shadow-red-500/20":"bg-gradient-to-br from-green-500 to-emerald-600 dark:from-green-400 dark:to-emerald-500 shadow-green-500/20"}`,children:e.jsx("svg",{className:"w-3.5 h-3.5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.toolResult.isError?e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M6 18L18 6M6 6l12 12"}):e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.5,d:"M5 13l4 4L19 7"})})}),e.jsx("span",{className:`text-sm font-semibold ${t.toolResult.isError?"text-red-800 dark:text-red-200":"text-green-800 dark:text-green-200"}`,children:t.toolResult.isError?"工具错误":"工具结果"})]}),e.jsxs("div",{className:`relative text-sm ${t.toolResult.isError?"text-red-900 dark:text-red-100":"text-green-900 dark:text-green-100"}`,children:[(()=>{const k=String(t.toolResult.content||"");if((t.toolName==="TodoWrite"||t.toolName==="TodoRead")&&(k.includes("Todos have been modified successfully")||k.includes("Todo list")||k.startsWith("[")&&k.includes('"content"')&&k.includes('"status"')))try{let W=null;if(k.startsWith("["))W=JSON.parse(k);else if(k.includes("Todos have been modified successfully"))return e.jsx("div",{children:e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx("span",{className:"font-medium",children:"待办列表已更新成功"})})});if(W&&Array.isArray(W))return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("span",{className:"font-medium",children:"当前待办列表"})}),e.jsx(Lr,{todos:W,isResult:!0})]})}catch{}if(t.toolName==="exit_plan_mode")try{const W=JSON.parse(k);if(W.plan){const F=W.plan.replace(/\\n/g,`
|
|
55
|
+
`);return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsx("span",{className:"font-medium",children:"实现计划"})}),e.jsx(Et,{className:"prose prose-sm max-w-none dark:prose-invert",children:F})]})}}catch{}if((t.toolName==="Grep"||t.toolName==="Glob")&&t.toolResult?.toolUseResult){const W=t.toolResult.toolUseResult;if(W.filenames&&Array.isArray(W.filenames)&&W.filenames.length>0)return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-3",children:e.jsxs("span",{className:"font-medium",children:["找到 ",W.numFiles||W.filenames.length," 个文件"]})}),e.jsx("div",{className:"space-y-1 max-h-96 overflow-y-auto",children:W.filenames.map((F,Q)=>{const ie=F.split("/").pop(),Z=F.substring(0,F.lastIndexOf("/"));return e.jsxs("div",{onClick:()=>{n&&n(F)},className:"group flex items-center gap-2 px-2 py-1.5 rounded hover:bg-green-100/50 dark:hover:bg-green-800/20 cursor-pointer transition-colors",children:[e.jsx("svg",{className:"w-4 h-4 text-green-600 dark:text-green-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-mono text-sm font-medium text-green-800 dark:text-green-200 truncate group-hover:text-green-900 dark:group-hover:text-green-100",children:ie}),e.jsx("div",{className:"font-mono text-xs text-green-600/70 dark:text-green-400/70 truncate",children:Z})]}),e.jsx("svg",{className:"w-4 h-4 text-green-600 dark:text-green-400 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})]},Q)})})]})}if(k.includes("Do you want to proceed?")&&t.toolName==="Bash"){const W=k.split(`
|
|
56
|
+
`),F=W.findIndex(_=>_.includes("Do you want to proceed?")),Q=W.slice(0,F).join(`
|
|
57
|
+
`),ie=W.slice(F),Z=ie.find(_=>_.includes("Do you want to proceed?"))||"",se=[];ie.forEach(_=>{const Y=_.match(/^\s*(\d+)\.\s+(.+)$/);Y&&se.push({number:Y[1],text:Y[2].trim()})});const B=k.match(/>\s*(\d+)/),T=B?B[1]:null;return e.jsxs("div",{className:"space-y-3",children:[Q&&e.jsx("div",{className:"bg-gray-900 dark:bg-gray-950 text-gray-100 rounded-lg p-3 font-mono text-xs overflow-x-auto",children:e.jsx("pre",{className:"whitespace-pre-wrap break-words",children:Q})}),e.jsx("div",{className:"bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-amber-500 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-amber-900 dark:text-amber-100 text-base mb-2",children:"交互式提示"}),e.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200 mb-4",children:Z}),e.jsx("div",{className:"space-y-2 mb-4",children:se.map(_=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${T===_.number?"bg-amber-600 dark:bg-amber-700 text-white border-amber-600 dark:border-amber-700 shadow-md":"bg-white dark:bg-gray-800 text-amber-900 dark:text-amber-100 border-amber-300 dark:border-amber-700 hover:border-amber-400 dark:hover:border-amber-600 hover:shadow-sm"} ${T?"cursor-default":"cursor-not-allowed opacity-75"}`,disabled:!0,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold ${T===_.number?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:_.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:_.text}),T===_.number&&e.jsx("svg",{className:"w-5 h-5 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})]})},_.number))}),T&&e.jsxs("div",{className:"bg-amber-100 dark:bg-amber-800/30 rounded-lg p-3",children:[e.jsxs("p",{className:"text-amber-900 dark:text-amber-100 text-sm font-medium mb-1",children:["✓ Claude 选择了选项 ",T]}),e.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:"在 CLI 中,您可以使用方向键或输入数字来交互式地选择此选项。"})]})]})]})})]})}const w=k.match(/The file (.+?) has been updated\./);if(w)return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx("span",{className:"font-medium",children:"文件更新成功"})}),e.jsx("button",{onClick:()=>{n&&n(w[1])},className:"text-xs font-mono bg-green-100 dark:bg-green-800/30 px-2 py-1 rounded text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline cursor-pointer",children:w[1]})]});const R=k.match(/(?:The file|File) (.+?) has been (?:created|written)(?: successfully)?\.?/);return R?e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx("span",{className:"font-medium",children:"文件创建成功"})}),e.jsx("button",{onClick:()=>{n&&n(R[1])},className:"text-xs font-mono bg-green-100 dark:bg-green-800/30 px-2 py-1 rounded text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline cursor-pointer",children:R[1]})]}):t.toolName==="Write"&&!t.toolResult.isError?e.jsxs("div",{className:"text-green-700 dark:text-green-300",children:[e.jsxs("div",{className:"flex items-center gap-2",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:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("span",{className:"font-medium",children:"文件写入成功"})]}),e.jsx("p",{className:"text-xs mt-1 text-green-600 dark:text-green-400",children:"文件内容显示在上方的差异视图中"})]}):k.includes("cat -n")&&k.includes("→")?e.jsxs("details",{open:d,children:[e.jsxs("summary",{className:"text-sm text-green-700 dark:text-green-300 cursor-pointer hover:text-green-800 dark:hover:text-green-200 mb-2 flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform details-chevron",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看文件内容"]}),e.jsx("div",{className:"mt-2 bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsx("div",{className:"text-xs font-mono p-3 whitespace-pre-wrap break-words overflow-hidden",children:k})})]}):k.length>300?e.jsxs("details",{open:d,children:[e.jsxs("summary",{className:"text-sm text-green-700 dark:text-green-300 cursor-pointer hover:text-green-800 dark:hover:text-green-200 mb-2 flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 transition-transform details-chevron",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),"查看完整输出 (",k.length," 字符)"]}),e.jsx(Et,{className:"mt-2 prose prose-sm max-w-none prose-green dark:prose-invert",children:k})]}):e.jsx(Et,{className:"prose prose-sm max-w-none prose-green dark:prose-invert",children:k})})(),M&&e.jsxs("div",{className:"mt-4 border-t border-red-200/60 dark:border-red-800/60 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{if(!i)return;i(M)?.success?E("granted"):E("error")},disabled:M.isAllowed||I==="granted",className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${M.isAllowed||I==="granted"?"bg-green-100 dark:bg-green-900/30 border-green-300/70 dark:border-green-800/60 text-green-800 dark:text-green-200 cursor-default":"bg-white/80 dark:bg-gray-900/40 border-red-300/70 dark:border-red-800/60 text-red-700 dark:text-red-200 hover:bg-white dark:hover:bg-gray-900/70"}`,children:M.isAllowed||I==="granted"?"权限已添加":`授予权限 ${M.toolName}`}),l&&e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),l()},className:"text-xs text-red-700 dark:text-red-200 underline hover:text-red-800 dark:hover:text-red-100",children:"打开设置"})]}),e.jsxs("div",{className:"mt-2 text-xs text-red-700/90 dark:text-red-200/80",children:["添加 ",e.jsx("span",{className:"font-mono",children:M.entry})," 到允许的工具列表。"]}),I==="error"&&e.jsx("div",{className:"mt-2 text-xs text-red-700 dark:text-red-200",children:"无法更新权限。请重试。"}),(M.isAllowed||I==="granted")&&e.jsx("div",{className:"mt-2 text-xs text-green-700 dark:text-green-200",children:"权限已保存。请重试请求以使用该工具。"})]})]})]}))]}):t.isInteractivePrompt?e.jsx("div",{className:"bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-amber-500 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-amber-900 dark:text-amber-100 text-base mb-3",children:"交互式提示"}),(()=>{const g=t.content.split(`
|
|
58
|
+
`).filter(w=>w.trim()),m=g.find(w=>w.includes("?"))||g[0]||"",k=[];return g.forEach(w=>{const R=w.match(/[❯\s]*(\d+)\.\s+(.+)/);if(R){const W=w.includes("❯");k.push({number:R[1],text:R[2].trim(),isSelected:W})}}),e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200 mb-4",children:m}),e.jsx("div",{className:"space-y-2 mb-4",children:k.map(w=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${w.isSelected?"bg-amber-600 dark:bg-amber-700 text-white border-amber-600 dark:border-amber-700 shadow-md":"bg-white dark:bg-gray-800 text-amber-900 dark:text-amber-100 border-amber-300 dark:border-amber-700"} cursor-not-allowed opacity-75`,disabled:!0,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold ${w.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:w.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:w.text}),w.isSelected&&e.jsx("span",{className:"text-lg",children:"❯"})]})},w.number))}),e.jsxs("div",{className:"bg-amber-100 dark:bg-amber-800/30 rounded-lg p-3",children:[e.jsx("p",{className:"text-amber-900 dark:text-amber-100 text-sm font-medium mb-1",children:"⏳ 等待您在 CLI 中的响应"}),e.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:"请在运行 Claude 的终端中选择一个选项。"})]})]})})()]})]})}):t.isToolUse&&t.toolName==="Read"?(()=>{try{const g=JSON.parse(t.toolInput);if(g.file_path){const m=g.file_path.split("/").pop();return e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),e.jsx("span",{className:"font-medium",children:"Read"}),e.jsx("button",{onClick:()=>n&&n(g.file_path),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-mono transition-colors",children:m})]})})}}catch{return e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),e.jsx("span",{className:"font-medium",children:"读取文件"})]})})}})():t.isToolUse&&t.toolName==="TodoWrite"?(()=>{try{const g=JSON.parse(t.toolInput);if(g.todos&&Array.isArray(g.todos))return e.jsxs("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400 mb-2",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),e.jsx("span",{className:"font-medium",children:"更新待办列表"})]}),e.jsx(Lr,{todos:g.todos})]})}catch{return e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})}),e.jsx("span",{className:"font-medium",children:"更新待办列表"})]})})}})():t.isToolUse&&t.toolName==="TodoRead"?e.jsx("div",{className:"bg-gray-50/50 dark:bg-gray-800/30 border-l-2 border-gray-400 dark:border-gray-500 pl-3 py-2 my-2",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),e.jsx("span",{className:"font-medium",children:"读取待办列表"})]})}):t.isThinking?e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"cursor-pointer text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 font-medium flex items-center gap-2",children:[e.jsx("svg",{className:"w-3 h-3 transition-transform group-open:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsx("span",{children:"💭 思考中..."})]}),e.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 text-sm",children:e.jsx(Et,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:t.content})})]})}):e.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[p&&t.reasoning&&e.jsxs("details",{className:"mb-3",children:[e.jsx("summary",{className:"cursor-pointer text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 font-medium",children:"💭 思考中..."}),e.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 italic text-gray-600 dark:text-gray-400 text-sm",children:e.jsx("div",{className:"whitespace-pre-wrap",children:t.reasoning})})]}),(()=>{const g=Wr(String(t.content||"")),m=g.trim();if((m.startsWith("{")||m.startsWith("["))&&(m.endsWith("}")||m.endsWith("]")))try{const k=JSON.parse(m),w=JSON.stringify(k,null,2);return e.jsxs("div",{className:"my-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",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:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),e.jsx("span",{className:"font-medium",children:"JSON 响应"})]}),e.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsx("pre",{className:"p-4 overflow-x-auto",children:e.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:w})})})]})}catch{}return t.type==="assistant"?e.jsx(Et,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:g}):e.jsx("div",{className:"whitespace-pre-wrap",children:g})})()]}),e.jsx("div",{className:`text-xs text-gray-500 dark:text-gray-400 mt-1 ${j?"opacity-0 group-hover:opacity-100":""}`,children:new Date(t.timestamp).toLocaleTimeString()})]})]})})}),Vo=({file:t,onRemove:r,uploadProgress:a,error:o})=>{const[n,l]=s.useState(null);return s.useEffect(()=>{const i=URL.createObjectURL(t);return l(i),()=>URL.revokeObjectURL(i)},[t]),e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:n,alt:t.name,className:"w-20 h-20 object-cover rounded"}),a!==void 0&&a<100&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsxs("div",{className:"text-white text-xs",children:[a,"%"]})}),o&&e.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-white",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("button",{onClick:r,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 opacity-0 group-hover:opacity-100",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"})})})]})};function Yo({selectedProject:t,selectedSession:r,ws:a,sendMessage:o,messages:n,onFileOpen:l,onInputFocusChange:i,onSessionActive:d,onSessionInactive:x,onSessionProcessing:p,onSessionNotProcessing:b,processingSessions:C,onReplaceTemporarySession:j,onNavigateToSession:y,onShowSettings:h,autoExpandTools:$,showRawParameters:M,showThinking:I,autoScrollToBottom:E,sendByCtrlEnter:g,externalMessageUpdate:m,onTaskClick:k,limitStatus:w,onLimitExceeded:R,checkLimitStatus:W}){const[F,Q]=s.useState(()=>typeof window<"u"&&t&&Je.getItem(`draft_input_${t.name}`)||""),[ie,Z]=s.useState(()=>{if(typeof window<"u"&&t){const c=Je.getItem(`chat_messages_${t.name}`);return c?JSON.parse(c):[]}return[]}),[se,B]=s.useState(!1),[T,_]=s.useState(r?.id||null),[Y,pe]=s.useState(!1),[ae,V]=s.useState([]),[xe,Ne]=s.useState(!1),[Ce,je]=s.useState(!1),[_e,he]=s.useState(0),[Se,ke]=s.useState(!1),[Ee,ye]=s.useState(0),Re=20,Pe=s.useCallback(c=>{ve.current=c,he(c)},[]),[Me,H]=s.useState(!1),[f,v]=s.useState("default"),[O,oe]=s.useState([]),[ue,Le]=s.useState([]),[He,Ye]=s.useState(new Map),[qe,u]=s.useState(new Map),[A,X]=s.useState(!1),te=s.useRef(null),D=s.useRef(null),Ie=s.useRef(null),Be=s.useRef(null),De=s.useRef(null),q=s.useRef(!1),me=s.useRef(!1),re=s.useRef(!1),le=s.useRef(null),ve=s.useRef(0),ze=s.useRef(""),ge=s.useRef(null),We=s.useRef(null),[zt,et]=s.useState(""),[_t,bt]=s.useState(!1),[Kt,yt]=s.useState([]),[tt,hr]=s.useState([]),[At,Ot]=s.useState(-1),[Gt,at]=s.useState(0),[z,G]=s.useState(-1),[de,fe]=s.useState(!1),[it,Qe]=s.useState(!1),gr=s.useRef({height:0,top:0}),[Vt,lt]=s.useState(!1),[Ze,fr]=s.useState([]),[vt,Yt]=s.useState([]),[Qt,ct]=s.useState(""),[ia,pt]=s.useState(!1),[ts,St]=s.useState(null),[br,dt]=s.useState(-1),[rs,xt]=s.useState(-1),[Ft,la]=s.useState(100),[ca,ht]=s.useState(null),[gt,ss]=s.useState(()=>localStorage.getItem("claude-model")||Ts.DEFAULT),mt="claude";s.useEffect(()=>{if(r?.id){const c=localStorage.getItem(`permissionMode-${r.id}`);v(c||"default")}},[r?.id]),s.useEffect(()=>{oe(c=>c.filter(N=>!N.sessionId||N.sessionId===r?.id))},[r?.id]),s.useEffect(()=>{(async()=>{if(t)try{const N=await ne("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:t.path})});if(!N.ok)throw new Error("Failed to fetch commands");const L=await N.json(),S=[...(L.builtIn||[]).map(ce=>({...ce,type:"built-in"})),...(L.custom||[]).map(ce=>({...ce,type:"custom"}))];fr(S);const P=`command_history_${t.name}`,K=Je.getItem(P);if(K)try{const ce=JSON.parse(K),U=S.sort((ee,be)=>{const Te=ce[ee.name]||0;return(ce[be.name]||0)-Te});fr(U)}catch(ce){console.error("Error parsing command history:",ce)}}catch(N){console.error("Error fetching slash commands:",N),fr([])}})()},[t]);const yr=s.useMemo(()=>Ze.length?new Ga(Ze,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[Ze]);s.useEffect(()=>{if(!Qt){Yt(Ze);return}if(!yr){Yt([]);return}const c=yr.search(Qt);Yt(c.map(N=>N.item))},[Qt,Ze,yr]);const da=s.useMemo(()=>{if(!t||Ze.length===0)return[];const c=`command_history_${t.name}`,N=Je.getItem(c);if(!N)return[];try{const L=JSON.parse(N);return Ze.map(P=>({...P,usageCount:L[P.name]||0})).filter(P=>P.usageCount>0).sort((P,K)=>K.usageCount-P.usageCount).slice(0,5)}catch(L){return console.error("Error parsing command history:",L),[]}},[t,Ze]),ma=s.useCallback((c,N,L)=>{if(!c||!t)return;if(L){dt(N);return}const S=`command_history_${t.name}`,P=Je.getItem(S);let K={};try{K=P?JSON.parse(P):{}}catch(ce){console.error("Error parsing command history:",ce)}K[c.name]=(K[c.name]||0)+1,Je.setItem(S,JSON.stringify(K)),Zt(c)},[t]),ua=s.useCallback(c=>{const{action:N,data:L}=c;switch(N){case"help":Z(S=>[...S,{type:"assistant",content:L.content,timestamp:Date.now()}]);break;case"model":{const S=L.available.claude,P=L.message?.includes("Switching to model:")?L.message.replace("Switching to model: ","").trim():null;P&&S.includes(P)?(ss(P),localStorage.setItem("claude-model",P),Z(K=>[...K,{type:"assistant",content:`已切换到模型: **${P}**`,timestamp:Date.now()}])):Z(P?K=>[...K,{type:"assistant",content:`无效的模型: ${P}
|
|
59
59
|
|
|
60
|
-
**可用模型**: ${
|
|
60
|
+
**可用模型**: ${S.join(", ")}`,timestamp:Date.now()}]:K=>[...K,{type:"assistant",content:`**当前模型**: ${gt}
|
|
61
61
|
|
|
62
|
-
**可用模型**: ${
|
|
62
|
+
**可用模型**: ${S.join(", ")}
|
|
63
63
|
|
|
64
|
-
使用 \`/model <模型名>\` 切换模型,例如 \`/model opus\``,timestamp:Date.now()}]);break}case"cost":{let
|
|
64
|
+
使用 \`/model <模型名>\` 切换模型,例如 \`/model opus\``,timestamp:Date.now()}]);break}case"cost":{let S;L.usage?S=`**Token 使用量**: ${L.usage.used.toLocaleString()} / ${L.usage.total.toLocaleString()} (${L.usage.percentage}%)
|
|
65
65
|
|
|
66
|
-
**剩余**: ${
|
|
66
|
+
**剩余**: ${L.usage.remaining.toLocaleString()} tokens`:S=L.message||"无可用的 Token 使用数据。",Z(P=>[...P,{type:"assistant",content:S,timestamp:Date.now()}]);break}case"memory":L.error?Z(S=>[...S,{type:"assistant",content:`⚠️ ${L.message}`,timestamp:Date.now()}]):(Z(S=>[...S,{type:"assistant",content:`📝 ${L.message}
|
|
67
67
|
|
|
68
|
-
Path: \`${
|
|
69
|
-
`),N
|
|
70
|
-
`),P=[];let K=0,ce=0;for(;K<
|
|
71
|
-
`)}else typeof
|
|
68
|
+
Path: \`${L.path}\``,timestamp:Date.now()}]),L.exists&&l&&l(L.path));break;case"config":h&&h();break;default:console.warn("Unknown built-in command action:",N)}},[l,h,gt]),vr=s.useRef(null),pa=s.useCallback(async(c,N)=>{const{content:L,hasBashCommands:S,hasFileIncludes:P}=c;if(S&&!window.confirm("此命令包含将被执行的 bash 命令。是否继续?")){Z(ce=>[...ce,{type:"assistant",content:"❌ 命令执行已取消",timestamp:Date.now()}]);return}Q(L),setTimeout(()=>{if(vr.current){const K={preventDefault:()=>{}};vr.current(K)}},50)},[]),Zt=s.useCallback(async c=>{if(!(!c||!t))try{const N=F.match(new RegExp(`${c.name}\\s*(.*)`)),L=N&&N[1]?N[1].trim().split(/\s+/):[],S={projectPath:t.path,projectName:t.name,sessionId:T,provider:mt,model:gt,tokenUsage:ts},P=await ne("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:c.name,commandPath:c.path,args:L,context:S})});if(!P.ok)throw new Error("Failed to execute command");const K=await P.json();K.type==="builtin"?ua(K):K.type==="custom"&&await pa(K,L),Q(""),lt(!1),xt(-1),ct(""),dt(-1)}catch(N){console.error("Error executing command:",N),Z(L=>[...L,{type:"assistant",content:`Error executing command: ${N.message}`,timestamp:Date.now()}])}},[F,t,T,mt,gt,ts]),xa=s.useMemo(()=>{const c=new Map;return(N,L)=>{const S=`${N.length}-${L.length}-${N.slice(0,50)}`;if(c.has(S))return c.get(S);const P=ha(N,L);if(c.set(S,P),c.size>100){const K=c.keys().next().value;c.delete(K)}return P}},[]),Wt=s.useCallback(async(c,N,L=!1,S="claude")=>{if(!c||!N)return[];const P=!L;P?Ne(!0):je(!0);try{const K=L?ve.current:0,ce=await we.sessionMessages(c,N,Re,K,S);if(!ce.ok)throw new Error("Failed to load session messages");const U=await ce.json();if(P&&U.tokenUsage&&St(U.tokenUsage),U.hasMore!==void 0)return ke(U.hasMore),ye(U.total),Pe(K+(U.messages?.length||0)),U.messages||[];{const ee=U.messages||[];return ke(!1),ye(ee.length),ee}}catch(K){return console.error("Error loading session messages:",K),[]}finally{P?Ne(!1):je(!1)}},[Pe]),ha=(c,N)=>{const L=c.split(`
|
|
69
|
+
`),S=N.split(`
|
|
70
|
+
`),P=[];let K=0,ce=0;for(;K<L.length||ce<S.length;){const U=L[K],ee=S[ce];K>=L.length?(P.push({type:"added",content:ee,lineNum:ce+1}),ce++):ce>=S.length?(P.push({type:"removed",content:U,lineNum:K+1}),K++):U===ee?(K++,ce++):(P.push({type:"removed",content:U,lineNum:K+1}),P.push({type:"added",content:ee,lineNum:ce+1}),K++,ce++)}return P},ga=c=>{const N=[],L=new Map;for(const S of c)if(S.message?.role==="user"&&Array.isArray(S.message?.content))for(const P of S.message.content)P.type==="tool_result"&&L.set(P.tool_use_id,{content:P.content,isError:P.is_error,timestamp:new Date(S.timestamp||Date.now()),toolUseResult:S.toolUseResult||null});for(const S of c)if(!S.isMeta){if(S.message?.role==="user"&&S.message?.content){let P="",K="user";if(Array.isArray(S.message.content)){const ee=[];for(const be of S.message.content)be.type==="text"&&ee.push(Ct(be.text));P=ee.join(`
|
|
71
|
+
`)}else typeof S.message.content=="string"?P=Ct(S.message.content):P=Ct(String(S.message.content));const ce=P.match(/<command-name>(\/[^<]+)<\/command-name>/);ce&&(P=ce[1]),!P||P.startsWith("<command-args>")||P.startsWith("<local-command-stdout>")||P.startsWith("<system-reminder>")||P.startsWith("Caveat:")||P.startsWith("This session is being continued from a previous")||P.startsWith("[Request interrupted")||(P=ar(P),N.push({type:K,content:P,timestamp:S.timestamp||new Date().toISOString()}))}else if(S.type==="thinking"&&S.message?.content)N.push({type:"assistant",content:ar(S.message.content),timestamp:S.timestamp||new Date().toISOString(),isThinking:!0});else if(S.type==="tool_use"&&S.toolName)N.push({type:"assistant",content:"",timestamp:S.timestamp||new Date().toISOString(),isToolUse:!0,toolName:S.toolName,toolInput:S.toolInput||"",toolCallId:S.toolCallId});else if(S.type==="tool_result"){for(let P=N.length-1;P>=0;P--)if(N[P].isToolUse&&!N[P].toolResult&&(!S.toolCallId||N[P].toolCallId===S.toolCallId)){N[P].toolResult={content:S.output||"",isError:!1};break}}else if(S.message?.role==="assistant"&&S.message?.content){if(Array.isArray(S.message.content)){for(const P of S.message.content)if(P.type==="text"){let K=P.text;typeof K=="string"&&(K=ar(K)),N.push({type:"assistant",content:K,timestamp:S.timestamp||new Date().toISOString()})}else if(P.type==="tool_use"){const K=L.get(P.id);N.push({type:"assistant",content:"",timestamp:S.timestamp||new Date().toISOString(),isToolUse:!0,toolName:P.name,toolInput:JSON.stringify(P.input),toolResult:K?{content:typeof K.content=="string"?K.content:JSON.stringify(K.content),isError:K.isError,toolUseResult:K.toolUseResult}:null,toolError:K?.isError||!1,toolResultTimestamp:K?.timestamp||new Date})}}else if(typeof S.message.content=="string"){let P=S.message.content;P=ar(P),N.push({type:"assistant",content:P,timestamp:S.timestamp||new Date().toISOString()})}}}return N},as=s.useMemo(()=>ga(ae),[ae]),ut=s.useCallback(()=>{De.current&&(De.current.scrollTop=De.current.scrollHeight)},[]),Xt=s.useCallback(()=>{if(!De.current)return!1;const{scrollTop:c,scrollHeight:N,clientHeight:L}=De.current;return N-c-L<50},[]),ns=s.useCallback(async c=>{if(!c||me.current||Ce||!Se||!r||!t)return!1;me.current=!0;const N=c.scrollHeight,L=c.scrollTop;try{const S=await Wt(t.name,r.id,!0,"claude");return S.length>0?(le.current={height:N,top:L},V(P=>[...S,...P]),!0):!1}finally{me.current=!1}},[Se,Ce,r,t,Wt]),Bt=s.useCallback(async()=>{if(De.current){const c=De.current,N=Xt();Qe(!N),c.scrollTop<100?re.current||await ns(c)&&(re.current=!0):re.current=!1}},[Xt,ns]);s.useLayoutEffect(()=>{if(!le.current||!De.current)return;const{height:c,top:N}=le.current,L=De.current,P=L.scrollHeight-c;L.scrollTop=N+Math.max(P,0),le.current=null,setTimeout(()=>{De.current&&De.current.scrollTop>=100&&(re.current=!1)},300)},[ie.length]),s.useEffect(()=>{(async()=>{if(r&&t){const N=localStorage.getItem("selected-provider")||"claude";if(q.current=!0,T!==null&&T!==r.id?(Pe(0),ke(!1),ye(0),St(null),B(!1),a&&o&&o({type:"check-session-status",sessionId:r.id,provider:N})):T===null&&(Pe(0),ke(!1),ye(0),a&&o&&o({type:"check-session-status",sessionId:r.id,provider:N})),_(r.id),Me)H(!1);else{const S=await Wt(t.name,r.id,!1,"claude");V(S)}}else!Me&&!se&&(Z([]),V([])),_(null),Pe(0),ke(!1),ye(0);setTimeout(()=>{q.current=!1},250)})()},[r,t,ut,Me]),s.useEffect(()=>{m>0&&r&&t&&(async()=>{try{const N=await Wt(t.name,r.id,!1,"claude");V(N),E&&Xt()&&setTimeout(()=>ut(),200)}catch(N){console.error("Error reloading messages from external update:",N)}})()},[m,r,t,Wt,Xt,E,ut]),s.useEffect(()=>{ae.length>0&&!se&&Z(as)},[as,ae,se]),s.useEffect(()=>{i&&i(Y)},[Y,i]),s.useEffect(()=>{t&&F!==""?Je.setItem(`draft_input_${t.name}`,F):t&&F===""&&Je.removeItem(`draft_input_${t.name}`)},[F,t]),s.useEffect(()=>{t&&ie.length>0&&Je.setItem(`chat_messages_${t.name}`,JSON.stringify(ie))},[ie,t]),s.useEffect(()=>{if(t){const c=Je.getItem(`draft_input_${t.name}`)||"";c!==F&&Q(c)}},[t?.name]),s.useEffect(()=>{T&&se&&p&&p(T)},[se,T,p]),s.useEffect(()=>{T&&C&&C.has(T)&&!se&&(B(!0),fe(!0))},[T,C]),s.useEffect(()=>{if(n.length>0){const c=n[n.length-1];if(!["projects_updated","session-created","claude-complete"].includes(c.type)&&c.sessionId&&T&&c.sessionId!==T){console.log("⏭️ Skipping message for different session:",c.sessionId,"current:",T);return}switch(c.type){case"session-created":c.sessionId&&!T&&(sessionStorage.setItem("pendingSessionId",c.sessionId),H(!0),j&&j(c.sessionId),oe(U=>U.map(ee=>ee.sessionId?ee:{...ee,sessionId:c.sessionId})));break;case"token-budget":c.data&&St(c.data);break;case"claude-response":const S=c.data.message||c.data;if(S&&typeof S=="object"&&S.type){if(S.type==="content_block_delta"&&S.delta?.text){const U=Ct(S.delta.text);ze.current+=U,ge.current||(ge.current=setTimeout(()=>{const ee=ze.current;ze.current="",ge.current=null,ee&&Z(be=>{const Te=[...be],Ue=Te[Te.length-1];return Ue&&Ue.type==="assistant"&&!Ue.isToolUse&&Ue.isStreaming?Ue.content=(Ue.content||"")+ee:Te.push({type:"assistant",content:ee,timestamp:new Date,isStreaming:!0}),Te})},100));return}if(S.type==="content_block_stop"){ge.current&&(clearTimeout(ge.current),ge.current=null);const U=ze.current;ze.current="",U&&Z(ee=>{const be=[...ee],Te=be[be.length-1];return Te&&Te.type==="assistant"&&!Te.isToolUse&&Te.isStreaming?Te.content=(Te.content||"")+U:be.push({type:"assistant",content:U,timestamp:new Date,isStreaming:!0}),be}),Z(ee=>{const be=[...ee],Te=be[be.length-1];return Te&&Te.type==="assistant"&&Te.isStreaming&&(Te.isStreaming=!1),be});return}}if(c.data.type==="system"&&c.data.subtype==="init"&&c.data.session_id&&T&&c.data.session_id!==T){console.log("🔄 Claude CLI session duplication detected:",{originalSession:T,newSession:c.data.session_id}),H(!0),y&&y(c.data.session_id);return}if(c.data.type==="system"&&c.data.subtype==="init"&&c.data.session_id&&!T){console.log("🔄 New session init detected:",{newSession:c.data.session_id}),H(!0),y&&y(c.data.session_id);return}if(c.data.type==="system"&&c.data.subtype==="init"&&c.data.session_id&&T&&c.data.session_id===T){console.log("🔄 System init message for current session, ignoring");return}if(Array.isArray(S.content)){for(const U of S.content)if(U.type==="tool_use"){const ee=U.input?JSON.stringify(U.input,null,2):"";Z(be=>[...be,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:U.name,toolInput:ee,toolId:U.id,toolResult:null}])}else if(U.type==="text"&&U.text?.trim()){let ee=Ct(U.text);ee=Wr(ee),Z(be=>[...be,{type:"assistant",content:ee,timestamp:new Date}])}}else if(typeof S.content=="string"&&S.content.trim()){let U=Ct(S.content);U=Wr(U),Z(ee=>[...ee,{type:"assistant",content:U,timestamp:new Date}])}if(S.role==="user"&&Array.isArray(S.content))for(const U of S.content)U.type==="tool_result"&&Z(ee=>ee.map(be=>be.isToolUse&&be.toolId===U.tool_use_id?{...be,toolResult:{content:U.content,isError:U.is_error,timestamp:new Date}}:be));break;case"claude-output":{const U=String(c.data||"");U.trim()&&(ze.current+=ze.current?`
|
|
72
72
|
${U}`:U,ge.current||(ge.current=setTimeout(()=>{const ee=ze.current;ze.current="",ge.current=null,ee&&Z(be=>{const Te=[...be],Ue=Te[Te.length-1];return Ue&&Ue.type==="assistant"&&!Ue.isToolUse&&Ue.isStreaming?Ue.content=Ue.content?`${Ue.content}
|
|
73
|
-
${ee}`:ee:Te.push({type:"assistant",content:ee,timestamp:new Date,isStreaming:!0}),Te})},100)))}break;case"claude-interactive-prompt":Z(U=>[...U,{type:"assistant",content:l.data,timestamp:new Date,isInteractivePrompt:!0}]);break;case"claude-permission-request":{if(!l.requestId)break;oe(U=>U.some(ee=>ee.requestId===l.requestId)?U:[...U,{requestId:l.requestId,toolName:l.toolName||"UnknownTool",input:l.input,context:l.context,sessionId:l.sessionId||null,receivedAt:new Date}]),B(!0),fe(!0),ht({text:"等待权限",tokens:0,can_interrupt:!0});break}case"claude-permission-cancelled":{if(!l.requestId)break;oe(U=>U.filter(ee=>ee.requestId!==l.requestId));break}case"claude-error":Z(U=>[...U,{type:"error",content:`错误: ${l.error}`,timestamp:new Date}]),B(!1),fe(!1),ht(null),oe([]),T&&(h&&h(T),b&&b(T));break;case"claude-complete":const P=l.sessionId||T||sessionStorage.getItem("pendingSessionId");(P===T||!T)&&(B(!1),fe(!1),ht(null)),P&&(h&&h(P),b&&b(P));const K=sessionStorage.getItem("pendingSessionId");K&&!T&&l.exitCode===0&&(z(K),sessionStorage.removeItem("pendingSessionId"),console.log("✅ New session complete, ID set to:",K)),t&&l.exitCode===0&&Je.removeItem(`chat_messages_${t.name}`),oe([]);break;case"session-aborted":{const U=l.sessionId||T;U===T&&(B(!1),fe(!1),ht(null)),U&&(h&&h(U),b&&b(U)),oe([]),Z(ee=>[...ee,{type:"assistant",content:"会话已被用户中断。",timestamp:new Date}]);break}case"session-status":{const U=l.sessionId;(U===T||r&&U===r.id)&&l.isProcessing&&(B(!0),fe(!0),p&&p(U));break}case"claude-status":const ce=l.data;if(ce){let U={text:"处理中...",tokens:0,can_interrupt:!0};ce.message?U.text=ce.message:ce.status?U.text=ce.status:typeof ce=="string"&&(U.text=ce),ce.tokens?U.tokens=ce.tokens:ce.token_count&&(U.tokens=ce.token_count),ce.can_interrupt!==void 0&&(U.can_interrupt=ce.can_interrupt),ht(U),B(!0),fe(U.can_interrupt)}break}}},[n]),s.useEffect(()=>{t&&fa()},[t]);const fa=async()=>{try{const l=await we.getFiles(t.name);if(l.ok){const w=await l.json(),M=rs(w);yt(M)}}catch(l){console.error("Error fetching files:",l)}},rs=(l,w="")=>{let M=[];for(const N of l){const P=w?`${w}/${N.name}`:N.name;N.type==="directory"&&N.children?M=M.concat(rs(N.children,P)):N.type==="file"&&M.push({name:N.name,path:P,relativePath:N.path})}return M};s.useEffect(()=>{const l=O.slice(0,Kt),w=l.lastIndexOf("@");if(w!==-1){const M=l.slice(w+1);if(M.includes(" "))bt(!1),V(-1);else{V(w),bt(!0);const N=Jt.filter(P=>P.name.toLowerCase().includes(M.toLowerCase())||P.path.toLowerCase().includes(M.toLowerCase())).slice(0,10);hr(N),Ft(-1)}}else bt(!1),V(-1)},[O,Kt,Jt]),s.useEffect(()=>{const l=setTimeout(()=>{et(O)},150);return()=>clearTimeout(l)},[O]);const ss=s.useMemo(()=>ie.length<=Ot?ie:ie.slice(-Ot),[ie,Ot]);s.useEffect(()=>{if(!C&&Ie.current){const l=Ie.current;gr.current={height:l.scrollHeight,top:l.scrollTop}}}),s.useEffect(()=>{if(Ie.current&&ie.length>0)if(C)it||setTimeout(()=>ut(),50);else{const l=Ie.current,w=gr.current.height,M=gr.current.top,P=l.scrollHeight-w;P>0&&M>0&&(l.scrollTop=M+P)}},[ie.length,it,ut,C]),s.useEffect(()=>{Ie.current&&ie.length>0&&!q.current&&(Qe(!1),setTimeout(()=>{ut()},200))},[r?.id,t?.name]),s.useEffect(()=>{const l=Ie.current;if(l)return l.addEventListener("scroll",Bt),()=>l.removeEventListener("scroll",Bt)},[Bt]),s.useEffect(()=>{if(D.current){D.current.style.height="auto",D.current.style.height=D.current.scrollHeight+"px";const l=parseInt(window.getComputedStyle(D.current).lineHeight),w=D.current.scrollHeight>l*2;pt(w)}},[]),s.useEffect(()=>{D.current&&!O.trim()&&(D.current.style.height="auto",pt(!1))},[O]),s.useEffect(()=>{if(!t||!r?.id||r.id.startsWith("new-session-")){St(null);return}(async()=>{try{const w=`/api/projects/${t.name}/sessions/${r.id}/token-usage`,M=await ne(w);if(M.ok){const N=await M.json();St(N)}else St(null)}catch(w){console.error("Failed to fetch initial token usage:",w)}})()},[r?.id,r?.__provider,t?.path]);const ba=s.useCallback(l=>{l.trim()&&Q(w=>{const M=w.trim()?`${w} ${l}`:l;return setTimeout(()=>{if(D.current){D.current.style.height="auto",D.current.style.height=D.current.scrollHeight+"px";const N=parseInt(window.getComputedStyle(D.current).lineHeight),P=D.current.scrollHeight>N*2;pt(P)}},0),M})},[]),ya=s.useCallback(()=>{la(l=>l+100)},[]),Xt=s.useCallback(l=>{const w=l.filter(M=>{try{if(!M||typeof M!="object")return console.warn("Invalid file object:",M),!1;if(!M.type||!M.type.startsWith("image/"))return!1;if(!M.size||M.size>5242880){const N=M.name||"Unknown file";return u(P=>{const K=new Map(P);return K.set(N,"文件太大(最大 5MB)"),K}),!1}return!0}catch(N){return console.error("Error validating file:",N,M),!1}});w.length>0&&Le(M=>[...M,...w].slice(0,5))},[]),va=s.useCallback(async l=>{const w=l.target.files;if(!(!w||w.length===0||!t)){X(!0);try{const M=new FormData;Array.from(w).forEach(K=>{M.append("files",K)});const N=await we.uploadFiles(t.name,M);if(!N.ok){const K=await N.json();throw new Error(K.error||"上传失败")}const P=await N.json();if(P.files&&P.files.length>0){const K=P.files.map(U=>`@${U.name}`).join(" "),ce=O?`${O} ${K} `:`${K} `;Q(ce),D.current&&D.current.focus()}}catch(M){console.error("File upload failed:",M)}finally{X(!1),De.current&&(De.current.value="")}}},[t,O]),ja=s.useCallback(async l=>{const w=Array.from(l.clipboardData.items);for(const M of w)if(M.type.startsWith("image/")){const N=M.getAsFile();N&&Xt([N])}if(w.length===0&&l.clipboardData.files.length>0){const N=Array.from(l.clipboardData.files).filter(P=>P.type.startsWith("image/"));N.length>0&&Xt(N)}},[Xt]),{getRootProps:wa,getInputProps:ka,isDragActive:Na,open:Sa}=Vr({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:Xt,noClick:!0,noKeyboard:!0}),jt=s.useCallback(async l=>{if(l.preventDefault(),!O.trim()||se||!t)return;const w=O.trim();if(w.startsWith("/")){const ee=w.indexOf(" "),be=ee!==-1?w.slice(0,ee):w,Te=Ze.find(Ue=>Ue.name===be&&Ue.namespace==="builtin");if(Te){Qt(Te);return}}if(W){const ee=await W();if(ee&&!ee.allowed){A?.(ee.reason);return}}let M=[];if(ue.length>0){const ee=new FormData;ue.forEach(be=>{ee.append("images",be)});try{const be=await ne(`/api/projects/${t.name}/upload-images`,{method:"POST",headers:{},body:ee});if(!be.ok)throw new Error("图片上传失败");M=(await be.json()).images}catch(be){console.error("Image upload failed:",be),Z(Te=>[...Te,{type:"error",content:`图片上传失败: ${be.message}`,timestamp:new Date}]);return}}const N={type:"user",content:O,images:M,timestamp:new Date};Z(ee=>[...ee,N]),B(!0),fe(!0),ht({text:"处理中",tokens:0,can_interrupt:!0}),Qe(!1),setTimeout(()=>ut(),100);const K=T||r?.id||`new-session-${Date.now()}`;m&&m(K);const U=(()=>{try{const ee=Je.getItem("claude-settings");if(ee)return JSON.parse(ee)}catch(ee){console.error("Error loading tools settings:",ee)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})();o({type:"claude-command",command:O,options:{projectPath:t.path,cwd:t.fullPath,sessionId:T,resume:!!T,toolsSettings:U,permissionMode:f,model:gt,images:M}}),Q(""),Le([]),Ye(new Map),u(new Map),pt(!1),D.current&&(D.current.style.height="auto"),t&&Je.removeItem(`draft_input_${t.name}`)},[O,se,t,ue,T,r,mt,f,m,gt,o,Q,Le,Ye,u,pt,D,Z,B,fe,ht,Qe,ut,W,A,Qt,Ze]),as=s.useCallback(l=>!l||mt!=="claude"?{success:!1}:qo(l.entry),[mt]),Ut=s.useCallback((l,w)=>{const N=(Array.isArray(l)?l:[l]).filter(Boolean);N.length!==0&&(N.forEach(P=>{o({type:"claude-permission-response",requestId:P,allow:!!w?.allow,updatedInput:w?.updatedInput,message:w?.message,rememberEntry:w?.rememberEntry})}),oe(P=>{const K=P.filter(ce=>!N.includes(ce.requestId));return K.length===0&&ht(null),K}))},[o]);s.useEffect(()=>{vr.current=jt},[jt]);const ns=l=>{if(!l)return;const w=O.slice(0,Zr),M=O.slice(Zr),N=M.indexOf(" "),P=N!==-1?M.slice(N):"",K=w+l.name+" "+P;Q(K),lt(!1),xt(-1),ct(""),dt(-1),We.current&&clearTimeout(We.current),Qt(l)},Ca=l=>{if(Vt&&vt.length>0){if(l.key==="ArrowDown"){l.preventDefault(),dt(w=>w<vt.length-1?w+1:0);return}if(l.key==="ArrowUp"){l.preventDefault(),dt(w=>w>0?w-1:vt.length-1);return}if(l.key==="Tab"||l.key==="Enter"){l.preventDefault(),br>=0?ns(vt[br]):vt.length>0&&ns(vt[0]);return}if(l.key==="Escape"){l.preventDefault(),lt(!1),xt(-1),ct(""),dt(-1),We.current&&clearTimeout(We.current);return}}if(_t&&tt.length>0){if(l.key==="ArrowDown"){l.preventDefault(),Ft(w=>w<tt.length-1?w+1:0);return}if(l.key==="ArrowUp"){l.preventDefault(),Ft(w=>w>0?w-1:tt.length-1);return}if(l.key==="Tab"||l.key==="Enter"){l.preventDefault(),At>=0?jr(tt[At]):tt.length>0&&jr(tt[0]);return}if(l.key==="Escape"){l.preventDefault(),bt(!1);return}}if(l.key==="Tab"&&!_t&&!Vt){l.preventDefault();const w=["default","acceptEdits","bypassPermissions","plan"],N=(w.indexOf(f)+1)%w.length,P=w[N];y(P),r?.id&&localStorage.setItem(`permissionMode-${r.id}`,P);return}if(l.key==="Enter"){if(l.nativeEvent.isComposing)return;(l.ctrlKey||l.metaKey)&&!l.shiftKey?(l.preventDefault(),jt(l)):!l.shiftKey&&!l.ctrlKey&&!l.metaKey&&(x||(l.preventDefault(),jt(l)))}},jr=l=>{const w=O.slice(0,R),M=O.slice(R),N=M.indexOf(" "),P=N!==-1?M.slice(N):"",K=w+"@"+l.path+" "+P,ce=w.length+1+l.path.length+1;D.current&&!D.current.matches(":focus")&&D.current.focus(),Q(K),at(ce),bt(!1),V(-1),D.current&&requestAnimationFrame(()=>{D.current&&(D.current.setSelectionRange(ce,ce),D.current.matches(":focus")||D.current.focus())})},Ea=l=>{const w=l.target.value,M=l.target.selectionStart;if(!T&&w.trim(),Q(w),at(M),!w.trim()){l.target.style.height="auto",pt(!1),lt(!1),xt(-1),ct("");return}const N=w.slice(0,M);if((N.match(/```/g)||[]).length%2===1){lt(!1),xt(-1),ct("");return}const ce=/(^|\s)\/(\S*)$/,U=N.match(ce);if(U){const ee=U.index+U[1].length,be=U[2];xt(ee),lt(!0),dt(-1),We.current&&clearTimeout(We.current),We.current=setTimeout(()=>{ct(be)},150)}else lt(!1),xt(-1),ct(""),We.current&&clearTimeout(We.current)},Ma=l=>{at(l.target.selectionStart)},La=()=>{T&&de&&o({type:"abort-session",sessionId:T,provider:mt})},Da=()=>{const l=["default","acceptEdits","bypassPermissions","plan"],M=(l.indexOf(f)+1)%l.length,N=l[M];y(N),r?.id&&localStorage.setItem(`permissionMode-${r.id}`,N)};return t?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
|
|
73
|
+
${ee}`:ee:Te.push({type:"assistant",content:ee,timestamp:new Date,isStreaming:!0}),Te})},100)))}break;case"claude-interactive-prompt":Z(U=>[...U,{type:"assistant",content:c.data,timestamp:new Date,isInteractivePrompt:!0}]);break;case"claude-permission-request":{if(!c.requestId)break;oe(U=>U.some(ee=>ee.requestId===c.requestId)?U:[...U,{requestId:c.requestId,toolName:c.toolName||"UnknownTool",input:c.input,context:c.context,sessionId:c.sessionId||null,receivedAt:new Date}]),B(!0),fe(!0),ht({text:"等待权限",tokens:0,can_interrupt:!0});break}case"claude-permission-cancelled":{if(!c.requestId)break;oe(U=>U.filter(ee=>ee.requestId!==c.requestId));break}case"claude-error":Z(U=>[...U,{type:"error",content:`错误: ${c.error}`,timestamp:new Date}]),B(!1),fe(!1),ht(null),oe([]),T&&(x&&x(T),b&&b(T));break;case"claude-complete":const P=c.sessionId||T||sessionStorage.getItem("pendingSessionId");(P===T||!T)&&(B(!1),fe(!1),ht(null)),P&&(x&&x(P),b&&b(P));const K=sessionStorage.getItem("pendingSessionId");K&&!T&&c.exitCode===0&&(_(K),sessionStorage.removeItem("pendingSessionId"),console.log("✅ New session complete, ID set to:",K)),t&&c.exitCode===0&&Je.removeItem(`chat_messages_${t.name}`),oe([]);break;case"session-aborted":{const U=c.sessionId||T;U===T&&(B(!1),fe(!1),ht(null)),U&&(x&&x(U),b&&b(U)),oe([]),Z(ee=>[...ee,{type:"assistant",content:"会话已被用户中断。",timestamp:new Date}]);break}case"session-status":{const U=c.sessionId;(U===T||r&&U===r.id)&&c.isProcessing&&(B(!0),fe(!0),p&&p(U));break}case"claude-status":const ce=c.data;if(ce){let U={text:"处理中...",tokens:0,can_interrupt:!0};ce.message?U.text=ce.message:ce.status?U.text=ce.status:typeof ce=="string"&&(U.text=ce),ce.tokens?U.tokens=ce.tokens:ce.token_count&&(U.tokens=ce.token_count),ce.can_interrupt!==void 0&&(U.can_interrupt=ce.can_interrupt),ht(U),B(!0),fe(U.can_interrupt)}break}}},[n]),s.useEffect(()=>{t&&fa()},[t]);const fa=async()=>{try{const c=await we.getFiles(t.name);if(c.ok){const N=await c.json(),L=os(N);yt(L)}}catch(c){console.error("Error fetching files:",c)}},os=(c,N="")=>{let L=[];for(const S of c){const P=N?`${N}/${S.name}`:S.name;S.type==="directory"&&S.children?L=L.concat(os(S.children,P)):S.type==="file"&&L.push({name:S.name,path:P,relativePath:S.path})}return L};s.useEffect(()=>{const c=F.slice(0,Gt),N=c.lastIndexOf("@");if(N!==-1){const L=c.slice(N+1);if(L.includes(" "))bt(!1),G(-1);else{G(N),bt(!0);const S=Kt.filter(P=>P.name.toLowerCase().includes(L.toLowerCase())||P.path.toLowerCase().includes(L.toLowerCase())).slice(0,10);hr(S),Ot(-1)}}else bt(!1),G(-1)},[F,Gt,Kt]),s.useEffect(()=>{const c=setTimeout(()=>{et(F)},150);return()=>clearTimeout(c)},[F]);const is=s.useMemo(()=>ie.length<=Ft?ie:ie.slice(-Ft),[ie,Ft]);s.useEffect(()=>{if(!E&&De.current){const c=De.current;gr.current={height:c.scrollHeight,top:c.scrollTop}}}),s.useEffect(()=>{if(De.current&&ie.length>0)if(E)it||setTimeout(()=>ut(),50);else{const c=De.current,N=gr.current.height,L=gr.current.top,P=c.scrollHeight-N;P>0&&L>0&&(c.scrollTop=L+P)}},[ie.length,it,ut,E]),s.useEffect(()=>{De.current&&ie.length>0&&!q.current&&(Qe(!1),setTimeout(()=>{ut()},200))},[r?.id,t?.name]),s.useEffect(()=>{const c=De.current;if(c)return c.addEventListener("scroll",Bt),()=>c.removeEventListener("scroll",Bt)},[Bt]),s.useEffect(()=>{if(D.current){D.current.style.height="auto",D.current.style.height=D.current.scrollHeight+"px";const c=parseInt(window.getComputedStyle(D.current).lineHeight),N=D.current.scrollHeight>c*2;pt(N)}},[]),s.useEffect(()=>{D.current&&!F.trim()&&(D.current.style.height="auto",pt(!1))},[F]),s.useEffect(()=>{if(!t||!r?.id||r.id.startsWith("new-session-")){St(null);return}(async()=>{try{const N=`/api/projects/${t.name}/sessions/${r.id}/token-usage`,L=await ne(N);if(L.ok){const S=await L.json();St(S)}else St(null)}catch(N){console.error("Failed to fetch initial token usage:",N)}})()},[r?.id,r?.__provider,t?.path]);const ba=s.useCallback(c=>{c.trim()&&Q(N=>{const L=N.trim()?`${N} ${c}`:c;return setTimeout(()=>{if(D.current){D.current.style.height="auto",D.current.style.height=D.current.scrollHeight+"px";const S=parseInt(window.getComputedStyle(D.current).lineHeight),P=D.current.scrollHeight>S*2;pt(P)}},0),L})},[]),ya=s.useCallback(()=>{la(c=>c+100)},[]),er=s.useCallback(c=>{const N=c.filter(L=>{try{if(!L||typeof L!="object")return console.warn("Invalid file object:",L),!1;if(!L.type||!L.type.startsWith("image/"))return!1;if(!L.size||L.size>5242880){const S=L.name||"Unknown file";return u(P=>{const K=new Map(P);return K.set(S,"文件太大(最大 5MB)"),K}),!1}return!0}catch(S){return console.error("Error validating file:",S,L),!1}});N.length>0&&Le(L=>[...L,...N].slice(0,5))},[]),va=s.useCallback(async c=>{const N=c.target.files;if(!(!N||N.length===0||!t)){X(!0);try{const L=new FormData;Array.from(N).forEach(K=>{L.append("files",K)});const S=await we.uploadFiles(t.name,L);if(!S.ok){const K=await S.json();throw new Error(K.error||"上传失败")}const P=await S.json();if(P.files&&P.files.length>0){const K=P.files.map(U=>`@${U.name}`).join(" "),ce=F?`${F} ${K} `:`${K} `;Q(ce),D.current&&D.current.focus()}}catch(L){console.error("File upload failed:",L)}finally{X(!1),Ie.current&&(Ie.current.value="")}}},[t,F]),ja=s.useCallback(async c=>{const N=Array.from(c.clipboardData.items);for(const L of N)if(L.type.startsWith("image/")){const S=L.getAsFile();S&&er([S])}if(N.length===0&&c.clipboardData.files.length>0){const S=Array.from(c.clipboardData.files).filter(P=>P.type.startsWith("image/"));S.length>0&&er(S)}},[er]),{getRootProps:wa,getInputProps:ka,isDragActive:Na,open:Sa}=Gr({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:er,noClick:!0,noKeyboard:!0}),jt=s.useCallback(async c=>{if(c.preventDefault(),!F.trim()||se||!t)return;const N=F.trim();if(N.startsWith("/")){const ee=N.indexOf(" "),be=ee!==-1?N.slice(0,ee):N,Te=Ze.find(Ue=>Ue.name===be&&Ue.namespace==="builtin");if(Te){Zt(Te);return}}if(W){const ee=await W();if(ee&&!ee.allowed){R?.(ee.reason);return}}let L=[];if(ue.length>0){const ee=new FormData;ue.forEach(be=>{ee.append("images",be)});try{const be=await ne(`/api/projects/${t.name}/upload-images`,{method:"POST",headers:{},body:ee});if(!be.ok)throw new Error("图片上传失败");L=(await be.json()).images}catch(be){console.error("Image upload failed:",be),Z(Te=>[...Te,{type:"error",content:`图片上传失败: ${be.message}`,timestamp:new Date}]);return}}const S={type:"user",content:F,images:L,timestamp:new Date};Z(ee=>[...ee,S]),B(!0),fe(!0),ht({text:"处理中",tokens:0,can_interrupt:!0}),Qe(!1),setTimeout(()=>ut(),100);const K=T||r?.id||`new-session-${Date.now()}`;d&&d(K);const U=(()=>{try{const ee=Je.getItem("claude-settings");if(ee)return JSON.parse(ee)}catch(ee){console.error("Error loading tools settings:",ee)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})();o({type:"claude-command",command:F,options:{projectPath:t.path,cwd:t.fullPath,sessionId:T,resume:!!T,toolsSettings:U,permissionMode:f,model:gt,images:L}}),Q(""),Le([]),Ye(new Map),u(new Map),pt(!1),D.current&&(D.current.style.height="auto"),t&&Je.removeItem(`draft_input_${t.name}`)},[F,se,t,ue,T,r,mt,f,d,gt,o,Q,Le,Ye,u,pt,D,Z,B,fe,ht,Qe,ut,W,R,Zt,Ze]),ls=s.useCallback(c=>!c||mt!=="claude"?{success:!1}:qo(c.entry),[mt]),Ut=s.useCallback((c,N)=>{const S=(Array.isArray(c)?c:[c]).filter(Boolean);S.length!==0&&(S.forEach(P=>{o({type:"claude-permission-response",requestId:P,allow:!!N?.allow,updatedInput:N?.updatedInput,message:N?.message,rememberEntry:N?.rememberEntry})}),oe(P=>{const K=P.filter(ce=>!S.includes(ce.requestId));return K.length===0&&ht(null),K}))},[o]);s.useEffect(()=>{vr.current=jt},[jt]);const cs=c=>{if(!c)return;const N=F.slice(0,rs),L=F.slice(rs),S=L.indexOf(" "),P=S!==-1?L.slice(S):"",K=N+c.name+" "+P;Q(K),lt(!1),xt(-1),ct(""),dt(-1),We.current&&clearTimeout(We.current),Zt(c)},Ca=c=>{if(Vt&&vt.length>0){if(c.key==="ArrowDown"){c.preventDefault(),dt(N=>N<vt.length-1?N+1:0);return}if(c.key==="ArrowUp"){c.preventDefault(),dt(N=>N>0?N-1:vt.length-1);return}if(c.key==="Tab"||c.key==="Enter"){c.preventDefault(),br>=0?cs(vt[br]):vt.length>0&&cs(vt[0]);return}if(c.key==="Escape"){c.preventDefault(),lt(!1),xt(-1),ct(""),dt(-1),We.current&&clearTimeout(We.current);return}}if(_t&&tt.length>0){if(c.key==="ArrowDown"){c.preventDefault(),Ot(N=>N<tt.length-1?N+1:0);return}if(c.key==="ArrowUp"){c.preventDefault(),Ot(N=>N>0?N-1:tt.length-1);return}if(c.key==="Tab"||c.key==="Enter"){c.preventDefault(),At>=0?jr(tt[At]):tt.length>0&&jr(tt[0]);return}if(c.key==="Escape"){c.preventDefault(),bt(!1);return}}if(c.key==="Tab"&&!_t&&!Vt){c.preventDefault();const N=["default","acceptEdits","bypassPermissions","plan"],S=(N.indexOf(f)+1)%N.length,P=N[S];v(P),r?.id&&localStorage.setItem(`permissionMode-${r.id}`,P);return}if(c.key==="Enter"){if(c.nativeEvent.isComposing)return;(c.ctrlKey||c.metaKey)&&!c.shiftKey?(c.preventDefault(),jt(c)):!c.shiftKey&&!c.ctrlKey&&!c.metaKey&&(g||(c.preventDefault(),jt(c)))}},jr=c=>{const N=F.slice(0,z),L=F.slice(z),S=L.indexOf(" "),P=S!==-1?L.slice(S):"",K=N+"@"+c.path+" "+P,ce=N.length+1+c.path.length+1;D.current&&!D.current.matches(":focus")&&D.current.focus(),Q(K),at(ce),bt(!1),G(-1),D.current&&requestAnimationFrame(()=>{D.current&&(D.current.setSelectionRange(ce,ce),D.current.matches(":focus")||D.current.focus())})},Ea=c=>{const N=c.target.value,L=c.target.selectionStart;if(!T&&N.trim(),Q(N),at(L),!N.trim()){c.target.style.height="auto",pt(!1),lt(!1),xt(-1),ct("");return}const S=N.slice(0,L);if((S.match(/```/g)||[]).length%2===1){lt(!1),xt(-1),ct("");return}const ce=/(^|\s)\/(\S*)$/,U=S.match(ce);if(U){const ee=U.index+U[1].length,be=U[2];xt(ee),lt(!0),dt(-1),We.current&&clearTimeout(We.current),We.current=setTimeout(()=>{ct(be)},150)}else lt(!1),xt(-1),ct(""),We.current&&clearTimeout(We.current)},Ma=c=>{at(c.target.selectionStart)},La=()=>{T&&de&&o({type:"abort-session",sessionId:T,provider:mt})},Ia=()=>{const c=["default","acceptEdits","bypassPermissions","plan"],L=(c.indexOf(f)+1)%c.length,S=c[L];v(S),r?.id&&localStorage.setItem(`permissionMode-${r.id}`,S)};return t?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
|
|
74
74
|
details[open] .details-chevron {
|
|
75
75
|
transform: rotate(180deg);
|
|
76
76
|
}
|
|
77
|
-
`}),e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{ref:Ie,onWheel:Bt,onTouchMove:Bt,className:"flex-1 overflow-y-auto overflow-x-hidden px-0 py-3 sm:p-4 space-y-3 sm:space-y-4 relative",children:[xe&&ie.length===0?e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 mt-8",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),e.jsx("p",{children:"正在加载会话消息..."})]})}):ie.length===0?e.jsxs("div",{className:"flex items-center justify-center h-full",children:[!r&&!T&&e.jsxs("div",{className:"text-center px-6 sm:px-4 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-3",children:"开始新对话"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-8",children:"与 Claude 对话以获取代码帮助"}),e.jsx("div",{className:"flex flex-col items-center justify-center mb-8",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx(ot,{className:"w-10 h-10"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-gray-900 dark:text-white",children:"Claude"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"by Anthropic"})]})]})}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"选择模型"}),e.jsx("select",{value:gt,onChange:l=>{const w=l.target.value;Xr(w),localStorage.setItem("claude-model",w)},className:"pl-4 pr-10 py-2 text-sm bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 min-w-[140px]",children:Ms.OPTIONS.map(({value:l,label:w})=>e.jsx("option",{value:l,children:w},l))})]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["已准备好使用 Claude ",gt,"。请在下方输入您的消息。"]})]}),r&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 px-6 sm:px-4",children:[e.jsx("p",{className:"font-bold text-lg sm:text-xl mb-3",children:"继续您的对话"}),e.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:"询问代码问题、请求修改或获取开发任务帮助"})]})]}):e.jsxs(e.Fragment,{children:[Ce&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 py-3",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),e.jsx("p",{className:"text-sm",children:"正在加载历史消息..."})]})}),Se&&!Ce&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 text-sm py-2 border-b border-gray-200 dark:border-gray-700",children:Ee>0&&e.jsxs("span",{children:["显示 ",ae.length," 条 / 共 ",Ee," 条消息 •",e.jsx("span",{className:"text-xs",children:"向上滚动加载更多"})]})}),!Se&&ie.length>Ot&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 text-sm py-2 border-b border-gray-200 dark:border-gray-700",children:["显示最近 ",Ot," 条消息(共 ",ie.length," 条) •",e.jsx("button",{className:"ml-1 text-blue-600 hover:text-blue-700 underline",onClick:ya,children:"加载更早的消息"})]}),ss.map((l,w)=>{const M=w>0?ss[w-1]:null,N=l.id||`${l.type}-${l.timestamp?.getTime?.()||w}-${w}`;return e.jsx(Vo,{message:l,index:w,prevMessage:M,createDiff:xa,onFileOpen:c,onShowSettings:g,onGrantToolPermission:as,autoExpandTools:$,showRawParameters:L,showThinking:I,selectedProject:t,provider:mt},N)})]}),se&&e.jsx("div",{className:"chat-message assistant",children:e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1 bg-transparent",children:e.jsx(ot,{className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Claude"})]}),e.jsx("div",{className:"w-full text-sm text-gray-500 dark:text-gray-400 pl-3 sm:pl-0",children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("div",{className:"animate-pulse",children:"●"}),e.jsx("div",{className:"animate-pulse",style:{animationDelay:"0.2s"},children:"●"}),e.jsx("div",{className:"animate-pulse",style:{animationDelay:"0.4s"},children:"●"}),e.jsx("span",{className:"ml-2",children:"思考中..."})]})})]})}),e.jsx("div",{ref:te})]}),e.jsxs("div",{className:"p-2 sm:p-4 md:p-4 flex-shrink-0 pb-2 sm:pb-4 md:pb-6",children:[e.jsx("div",{className:"flex-1",children:e.jsx(Fo,{status:ca,isLoading:se,onAbort:La,provider:mt,showThinking:I})}),e.jsxs("div",{ref:Be,className:"max-w-4xl mx-auto mb-3",children:[F.length>0&&e.jsx("div",{className:"mb-3 space-y-2",children:F.map(l=>{const w=Ls(l.input),M=Br(l.toolName,w),N=Gr(),P=M?N.allowedTools.includes(M):!1,K=P?"已允许(已保存)":"允许并记住",ce=M?F.filter(U=>Br(U.toolName,Ls(U.input))===M).map(U=>U.requestId):[l.requestId];return l.toolName==="AskUserQuestion"?e.jsx(Ko,{request:l,onSubmit:U=>{Ut(l.requestId,{allow:!0,updatedInput:{...l.input,answers:U}})},onSkip:()=>Ut(l.requestId,{allow:!1,message:"用户跳过问题"})},l.requestId):e.jsxs("div",{className:"rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-900/20 p-3 shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-amber-900 dark:text-amber-100",children:"需要权限"}),e.jsxs("div",{className:"text-xs text-amber-800 dark:text-amber-200",children:["工具: ",e.jsx("span",{className:"font-mono",children:l.toolName})]})]}),M&&e.jsxs("div",{className:"text-xs text-amber-700 dark:text-amber-300",children:["允许规则: ",e.jsx("span",{className:"font-mono",children:M})]})]}),w&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"cursor-pointer text-xs text-amber-800 dark:text-amber-200 hover:text-amber-900 dark:hover:text-amber-100",children:"查看工具输入"}),e.jsx("pre",{className:"mt-2 max-h-40 overflow-auto rounded-md bg-white/80 dark:bg-gray-900/60 border border-amber-200/60 dark:border-amber-800/60 p-2 text-xs text-amber-900 dark:text-amber-100 whitespace-pre-wrap",children:w})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>Ut(l.requestId,{allow:!0}),className:"inline-flex items-center gap-2 rounded-md bg-amber-600 text-white text-xs font-medium px-3 py-1.5 hover:bg-amber-700 transition-colors",children:"允许一次"}),e.jsx("button",{type:"button",onClick:()=>{M&&!P&&as({entry:M,toolName:l.toolName}),Ut(ce,{allow:!0,rememberEntry:M})},className:`inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border transition-colors ${M?"border-amber-300 text-amber-800 hover:bg-amber-100 dark:border-amber-700 dark:text-amber-100 dark:hover:bg-amber-900/30":"border-gray-300 text-gray-400 cursor-not-allowed"}`,disabled:!M,children:K}),e.jsx("button",{type:"button",onClick:()=>Ut(l.requestId,{allow:!1,message:"用户拒绝工具使用"}),className:"inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border border-red-300 text-red-700 hover:bg-red-50 dark:border-red-800 dark:text-red-200 dark:hover:bg-red-900/30 transition-colors",children:"拒绝"})]})]},l.requestId)})}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx("button",{type:"button",onClick:Da,className:`px-3 py-1.5 rounded-lg text-sm font-medium border transition-all duration-200 ${f==="default"?"bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 border-gray-300 dark:border-gray-600 hover:bg-gray-200 dark:hover:bg-gray-600":f==="acceptEdits"?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-300 border-green-300 dark:border-green-600 hover:bg-green-100 dark:hover:bg-green-900/30":f==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/20 text-orange-700 dark:text-orange-300 border-orange-300 dark:border-orange-600 hover:bg-orange-100 dark:hover:bg-orange-900/30":"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300 border-blue-300 dark:border-blue-600 hover:bg-blue-100 dark:hover:bg-blue-900/30"}`,title:"点击切换权限模式(或在输入框中按 Tab)",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${f==="default"?"bg-gray-500":f==="acceptEdits"?"bg-green-500":f==="bypassPermissions"?"bg-orange-500":"bg-blue-500"}`}),e.jsxs("span",{children:[f==="default"&&"默认模式",f==="acceptEdits"&&"接受编辑",f==="bypassPermissions"&&"跳过权限",f==="plan"&&"计划模式"]})]})}),e.jsxs("button",{type:"button",onClick:()=>{const l=!Vt;lt(l),ct(""),dt(-1),l&&Gt(Ze),D.current&&D.current.focus()},disabled:S&&!S.allowed,className:"relative w-8 h-8 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 rounded-full flex items-center justify-center transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:ring-offset-gray-800 disabled:opacity-50 disabled:cursor-not-allowed",title:S&&!S.allowed?"使用上限已达到":"显示所有命令",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:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),Ze.length>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-blue-600 text-white text-xs font-bold rounded-full w-5 h-5 flex items-center justify-center",style:{fontSize:"10px"},children:Ze.length})]}),O.trim()&&e.jsx("button",{type:"button",onClick:l=>{l.preventDefault(),l.stopPropagation(),Q(""),D.current&&(D.current.style.height="auto",D.current.focus()),pt(!1)},className:"w-8 h-8 bg-white dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-full flex items-center justify-center transition-all duration-200 group shadow-sm",title:"清除输入",children:e.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300 group-hover:text-gray-800 dark:group-hover:text-gray-100 transition-colors",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"})})}),it&&ie.length>0&&e.jsx("button",{onClick:ut,className:"w-8 h-8 bg-blue-600 hover:bg-blue-700 text-white rounded-full shadow-lg flex items-center justify-center transition-all duration-200 hover:scale-105 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:ring-offset-gray-800",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:"M19 14l-7 7m0 0l-7-7m7 7V3"})})})]})]}),e.jsxs("form",{onSubmit:jt,className:"relative max-w-4xl mx-auto",children:[Na&&e.jsx("div",{className:"absolute inset-0 bg-blue-500/20 border-2 border-dashed border-blue-500 rounded-lg flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-4 shadow-lg",children:[e.jsx("svg",{className:"w-8 h-8 text-blue-500 mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),e.jsx("p",{className:"text-sm font-medium",children:"将图片拖放到这里"})]})}),ue.length>0&&e.jsx("div",{className:"mb-2 p-2 bg-gray-50 dark:bg-gray-800 rounded-lg",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:ue.map((l,w)=>e.jsx(Go,{file:l,onRemove:()=>{Le(M=>M.filter((N,P)=>P!==w))},uploadProgress:He.get(l.name),error:qe.get(l.name)},w))})}),_t&&tt.length>0&&e.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600 rounded-lg shadow-lg max-h-48 overflow-y-auto z-50 backdrop-blur-sm",children:tt.map((l,w)=>e.jsxs("div",{className:`px-4 py-3 cursor-pointer border-b border-gray-100 dark:border-gray-700 last:border-b-0 touch-manipulation ${w===At?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300"}`,onMouseDown:M=>{M.preventDefault(),M.stopPropagation()},onClick:M=>{M.preventDefault(),M.stopPropagation(),jr(l)},children:[e.jsx("div",{className:"font-medium text-sm",children:l.name}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:l.path})]},l.path))}),e.jsx(Bo,{commands:vt,selectedIndex:br,onSelect:ma,onClose:()=>{lt(!1),xt(-1),ct(""),dt(-1)},position:{top:D.current?Math.max(16,D.current.getBoundingClientRect().top-316):0,left:D.current?D.current.getBoundingClientRect().left:16,bottom:D.current?window.innerHeight-D.current.getBoundingClientRect().top+8:90},isOpen:Vt,frequentCommands:Yt?[]:da}),e.jsxs("div",{...wa(),className:`relative bg-white dark:bg-gray-800 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-600 focus-within:ring-2 focus-within:ring-blue-500 dark:focus-within:ring-blue-500 focus-within:border-blue-500 transition-all duration-200 overflow-hidden ${ia?"chat-input-expanded":""}`,children:[e.jsx("input",{...ka()}),e.jsx("textarea",{ref:D,value:O,onChange:Ea,onClick:Ma,onKeyDown:Ca,onPaste:ja,onFocus:()=>pe(!0),onBlur:()=>pe(!1),onInput:l=>{l.target.style.height="auto",l.target.style.height=l.target.scrollHeight+"px",at(l.target.selectionStart);const w=parseInt(window.getComputedStyle(l.target).lineHeight),M=l.target.scrollHeight>w*2;pt(M)},placeholder:S&&!S.allowed?S.reason==="total_limit_exceeded"?"使用上限已达到,请联系管理员":"今日使用上限已达到":"输入 / 使用命令,@ 引用文件,或向 Claude 提问...",disabled:se||S&&!S.allowed,className:"chat-input-placeholder block w-full pl-20 pr-20 sm:pr-40 py-1.5 sm:py-4 bg-transparent rounded-2xl focus:outline-none text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 disabled:opacity-50 resize-none min-h-[50px] sm:min-h-[80px] max-h-[40vh] sm:max-h-[300px] overflow-y-auto text-sm sm:text-base leading-[21px] sm:leading-6 transition-all duration-200",style:{height:"50px"}}),e.jsx("button",{type:"button",onClick:Sa,disabled:S&&!S.allowed,className:"absolute left-2 top-1/2 transform -translate-y-1/2 p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:S&&!S.allowed?"使用上限已达到":"添加图片",children:e.jsx("svg",{className:"w-5 h-5 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),e.jsx("input",{type:"file",ref:De,onChange:va,className:"hidden",multiple:!0}),e.jsx("button",{type:"button",onClick:()=>De.current?.click(),disabled:_||!t||S&&!S.allowed,className:"absolute left-10 top-1/2 transform -translate-y-1/2 p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:S&&!S.allowed?"使用上限已达到":"上传文件并引用",children:_?e.jsxs("svg",{className:"w-5 h-5 text-gray-500 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):e.jsx("svg",{className:"w-5 h-5 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}),e.jsx("div",{className:"absolute right-16 sm:right-16 top-1/2 transform -translate-y-1/2",style:{display:"none"},children:e.jsx(Wo,{onTranscript:ba,className:"w-10 h-10 sm:w-10 sm:h-10"})}),e.jsx("button",{type:"submit",disabled:!O.trim()||se,onMouseDown:l=>{l.preventDefault(),jt(l)},onTouchStart:l=>{l.preventDefault(),jt(l)},className:"absolute right-2 top-1/2 transform -translate-y-1/2 w-12 h-12 sm:w-12 sm:h-12 bg-blue-600 hover:bg-blue-700 disabled:bg-gray-400 disabled:cursor-not-allowed rounded-full flex items-center justify-center transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:ring-offset-gray-800",children:e.jsx("svg",{className:"w-4 h-4 sm:w-5 sm:h-5 text-white transform rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})}),e.jsx("div",{className:`absolute bottom-1 left-20 right-14 sm:right-40 text-xs text-gray-400 dark:text-gray-500 pointer-events-none hidden sm:block transition-opacity duration-200 ${O.trim()?"opacity-0":"opacity-100"}`,children:x?"Ctrl+Enter 发送 • Shift+Enter 换行 • Tab 切换模式 • / 使用命令":"Enter 发送 • Shift+Enter 换行 • Tab 切换模式 • / 使用命令"})]})]})]})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:"选择一个项目开始与 Claude 对话"})})})}const Qo=Xe.memo(Yo);function Ur({file:t,onClose:r,projectPath:a,isSidebar:o=!1,isExpanded:n=!1,onToggleExpand:c=null}){const[i,m]=s.useState(""),[h,p]=s.useState(!0),[b,E]=s.useState(!1),[v,j]=s.useState(!1),[g,$]=s.useState(()=>{const B=localStorage.getItem("codeEditorTheme");return B?B==="dark":!0}),[L,I]=s.useState(!1),[C,x]=s.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[d,k]=s.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[S,A]=s.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),W=s.useRef(null),O=s.useMemo(()=>{const B=()=>{const T=document.createElement("div");T.className="cm-editor-toolbar-panel";const z=()=>{let Y='<div style="display: flex; align-items: center; justify-content: flex-end; width: 100%;">';Y+='<div style="display: flex; align-items: center; gap: 4px;">',Y+=`
|
|
77
|
+
`}),e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{ref:De,onWheel:Bt,onTouchMove:Bt,className:"flex-1 overflow-y-auto overflow-x-hidden px-0 py-3 sm:p-4 space-y-3 sm:space-y-4 relative",children:[xe&&ie.length===0?e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 mt-8",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),e.jsx("p",{children:"正在加载会话消息..."})]})}):ie.length===0?e.jsxs("div",{className:"flex items-center justify-center h-full",children:[!r&&!T&&e.jsxs("div",{className:"text-center px-6 sm:px-4 py-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white mb-3",children:"开始新对话"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-8",children:"与 Claude 对话以获取代码帮助"}),e.jsx("div",{className:"flex flex-col items-center justify-center mb-8",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx(ot,{className:"w-10 h-10"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-gray-900 dark:text-white",children:"Claude"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"by Anthropic"})]})]})}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"选择模型"}),e.jsx("select",{value:gt,onChange:c=>{const N=c.target.value;ss(N),localStorage.setItem("claude-model",N)},className:"pl-4 pr-10 py-2 text-sm bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-purple-500 min-w-[140px]",children:Ts.OPTIONS.map(({value:c,label:N})=>e.jsx("option",{value:c,children:N},c))})]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["已准备好使用 Claude ",gt,"。请在下方输入您的消息。"]})]}),r&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 px-6 sm:px-4",children:[e.jsx("p",{className:"font-bold text-lg sm:text-xl mb-3",children:"继续您的对话"}),e.jsx("p",{className:"text-sm sm:text-base leading-relaxed",children:"询问代码问题、请求修改或获取开发任务帮助"})]})]}):e.jsxs(e.Fragment,{children:[Ce&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 py-3",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),e.jsx("p",{className:"text-sm",children:"正在加载历史消息..."})]})}),Se&&!Ce&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 text-sm py-2 border-b border-gray-200 dark:border-gray-700",children:Ee>0&&e.jsxs("span",{children:["显示 ",ae.length," 条 / 共 ",Ee," 条消息 •",e.jsx("span",{className:"text-xs",children:"向上滚动加载更多"})]})}),!Se&&ie.length>Ft&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 text-sm py-2 border-b border-gray-200 dark:border-gray-700",children:["显示最近 ",Ft," 条消息(共 ",ie.length," 条) •",e.jsx("button",{className:"ml-1 text-blue-600 hover:text-blue-700 underline",onClick:ya,children:"加载更早的消息"})]}),is.map((c,N)=>{const L=N>0?is[N-1]:null,S=c.id||`${c.type}-${c.timestamp?.getTime?.()||N}-${N}`;return e.jsx(Go,{message:c,index:N,prevMessage:L,createDiff:xa,onFileOpen:l,onShowSettings:h,onGrantToolPermission:ls,autoExpandTools:$,showRawParameters:M,showThinking:I,selectedProject:t,provider:mt},S)})]}),se&&e.jsx("div",{className:"chat-message assistant",children:e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1 bg-transparent",children:e.jsx(ot,{className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Claude"})]}),e.jsx("div",{className:"w-full text-sm text-gray-500 dark:text-gray-400 pl-3 sm:pl-0",children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("div",{className:"animate-pulse",children:"●"}),e.jsx("div",{className:"animate-pulse",style:{animationDelay:"0.2s"},children:"●"}),e.jsx("div",{className:"animate-pulse",style:{animationDelay:"0.4s"},children:"●"}),e.jsx("span",{className:"ml-2",children:"思考中..."})]})})]})}),e.jsx("div",{ref:te})]}),e.jsxs("div",{className:"p-2 sm:p-4 md:p-4 flex-shrink-0 pb-2 sm:pb-4 md:pb-6",children:[e.jsx("div",{className:"flex-1",children:e.jsx(Oo,{status:ca,isLoading:se,onAbort:La,provider:mt,showThinking:I})}),e.jsxs("div",{ref:Be,className:"max-w-4xl mx-auto mb-3",children:[O.length>0&&e.jsx("div",{className:"mb-3 space-y-2",children:O.map(c=>{const N=Rs(c.input),L=Br(c.toolName,N),S=Vr(),P=L?S.allowedTools.includes(L):!1,K=P?"已允许(已保存)":"允许并记住",ce=L?O.filter(U=>Br(U.toolName,Rs(U.input))===L).map(U=>U.requestId):[c.requestId];return c.toolName==="AskUserQuestion"?e.jsx(Ko,{request:c,onSubmit:U=>{Ut(c.requestId,{allow:!0,updatedInput:{...c.input,answers:U}})},onSkip:()=>Ut(c.requestId,{allow:!1,message:"用户跳过问题"})},c.requestId):e.jsxs("div",{className:"rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-900/20 p-3 shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-amber-900 dark:text-amber-100",children:"需要权限"}),e.jsxs("div",{className:"text-xs text-amber-800 dark:text-amber-200",children:["工具: ",e.jsx("span",{className:"font-mono",children:c.toolName})]})]}),L&&e.jsxs("div",{className:"text-xs text-amber-700 dark:text-amber-300",children:["允许规则: ",e.jsx("span",{className:"font-mono",children:L})]})]}),N&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"cursor-pointer text-xs text-amber-800 dark:text-amber-200 hover:text-amber-900 dark:hover:text-amber-100",children:"查看工具输入"}),e.jsx("pre",{className:"mt-2 max-h-40 overflow-auto rounded-md bg-white/80 dark:bg-gray-900/60 border border-amber-200/60 dark:border-amber-800/60 p-2 text-xs text-amber-900 dark:text-amber-100 whitespace-pre-wrap",children:N})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>Ut(c.requestId,{allow:!0}),className:"inline-flex items-center gap-2 rounded-md bg-amber-600 text-white text-xs font-medium px-3 py-1.5 hover:bg-amber-700 transition-colors",children:"允许一次"}),e.jsx("button",{type:"button",onClick:()=>{L&&!P&&ls({entry:L,toolName:c.toolName}),Ut(ce,{allow:!0,rememberEntry:L})},className:`inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border transition-colors ${L?"border-amber-300 text-amber-800 hover:bg-amber-100 dark:border-amber-700 dark:text-amber-100 dark:hover:bg-amber-900/30":"border-gray-300 text-gray-400 cursor-not-allowed"}`,disabled:!L,children:K}),e.jsx("button",{type:"button",onClick:()=>Ut(c.requestId,{allow:!1,message:"用户拒绝工具使用"}),className:"inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border border-red-300 text-red-700 hover:bg-red-50 dark:border-red-800 dark:text-red-200 dark:hover:bg-red-900/30 transition-colors",children:"拒绝"})]})]},c.requestId)})}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx("button",{type:"button",onClick:Ia,className:`px-3 py-1.5 rounded-lg text-sm font-medium border transition-all duration-200 ${f==="default"?"bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 border-gray-300 dark:border-gray-600 hover:bg-gray-200 dark:hover:bg-gray-600":f==="acceptEdits"?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-300 border-green-300 dark:border-green-600 hover:bg-green-100 dark:hover:bg-green-900/30":f==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/20 text-orange-700 dark:text-orange-300 border-orange-300 dark:border-orange-600 hover:bg-orange-100 dark:hover:bg-orange-900/30":"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300 border-blue-300 dark:border-blue-600 hover:bg-blue-100 dark:hover:bg-blue-900/30"}`,title:"点击切换权限模式(或在输入框中按 Tab)",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${f==="default"?"bg-gray-500":f==="acceptEdits"?"bg-green-500":f==="bypassPermissions"?"bg-orange-500":"bg-blue-500"}`}),e.jsxs("span",{children:[f==="default"&&"默认模式",f==="acceptEdits"&&"接受编辑",f==="bypassPermissions"&&"跳过权限",f==="plan"&&"计划模式"]})]})}),e.jsxs("button",{type:"button",onClick:()=>{const c=!Vt;lt(c),ct(""),dt(-1),c&&Yt(Ze),D.current&&D.current.focus()},disabled:w&&!w.allowed,className:"relative w-8 h-8 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 rounded-full flex items-center justify-center transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:ring-offset-gray-800 disabled:opacity-50 disabled:cursor-not-allowed",title:w&&!w.allowed?"使用上限已达到":"显示所有命令",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:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),Ze.length>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-blue-600 text-white text-xs font-bold rounded-full w-5 h-5 flex items-center justify-center",style:{fontSize:"10px"},children:Ze.length})]}),F.trim()&&e.jsx("button",{type:"button",onClick:c=>{c.preventDefault(),c.stopPropagation(),Q(""),D.current&&(D.current.style.height="auto",D.current.focus()),pt(!1)},className:"w-8 h-8 bg-white dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-full flex items-center justify-center transition-all duration-200 group shadow-sm",title:"清除输入",children:e.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300 group-hover:text-gray-800 dark:group-hover:text-gray-100 transition-colors",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"})})}),it&&ie.length>0&&e.jsx("button",{onClick:ut,className:"w-8 h-8 bg-blue-600 hover:bg-blue-700 text-white rounded-full shadow-lg flex items-center justify-center transition-all duration-200 hover:scale-105 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:ring-offset-gray-800",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:"M19 14l-7 7m0 0l-7-7m7 7V3"})})})]})]}),e.jsxs("form",{onSubmit:jt,className:"relative max-w-4xl mx-auto",children:[Na&&e.jsx("div",{className:"absolute inset-0 bg-blue-500/20 border-2 border-dashed border-blue-500 rounded-lg flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-4 shadow-lg",children:[e.jsx("svg",{className:"w-8 h-8 text-blue-500 mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),e.jsx("p",{className:"text-sm font-medium",children:"将图片拖放到这里"})]})}),ue.length>0&&e.jsx("div",{className:"mb-2 p-2 bg-gray-50 dark:bg-gray-800 rounded-lg",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:ue.map((c,N)=>e.jsx(Vo,{file:c,onRemove:()=>{Le(L=>L.filter((S,P)=>P!==N))},uploadProgress:He.get(c.name),error:qe.get(c.name)},N))})}),_t&&tt.length>0&&e.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600 rounded-lg shadow-lg max-h-48 overflow-y-auto z-50 backdrop-blur-sm",children:tt.map((c,N)=>e.jsxs("div",{className:`px-4 py-3 cursor-pointer border-b border-gray-100 dark:border-gray-700 last:border-b-0 touch-manipulation ${N===At?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300"}`,onMouseDown:L=>{L.preventDefault(),L.stopPropagation()},onClick:L=>{L.preventDefault(),L.stopPropagation(),jr(c)},children:[e.jsx("div",{className:"font-medium text-sm",children:c.name}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 font-mono",children:c.path})]},c.path))}),e.jsx(Bo,{commands:vt,selectedIndex:br,onSelect:ma,onClose:()=>{lt(!1),xt(-1),ct(""),dt(-1)},position:{top:D.current?Math.max(16,D.current.getBoundingClientRect().top-316):0,left:D.current?D.current.getBoundingClientRect().left:16,bottom:D.current?window.innerHeight-D.current.getBoundingClientRect().top+8:90},isOpen:Vt,frequentCommands:Qt?[]:da}),e.jsxs("div",{...wa(),className:`relative bg-white dark:bg-gray-800 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-600 focus-within:ring-2 focus-within:ring-blue-500 dark:focus-within:ring-blue-500 focus-within:border-blue-500 transition-all duration-200 overflow-hidden ${ia?"chat-input-expanded":""}`,children:[e.jsx("input",{...ka()}),e.jsx("textarea",{ref:D,value:F,onChange:Ea,onClick:Ma,onKeyDown:Ca,onPaste:ja,onFocus:()=>pe(!0),onBlur:()=>pe(!1),onInput:c=>{c.target.style.height="auto",c.target.style.height=c.target.scrollHeight+"px",at(c.target.selectionStart);const N=parseInt(window.getComputedStyle(c.target).lineHeight),L=c.target.scrollHeight>N*2;pt(L)},placeholder:w&&!w.allowed?w.reason==="total_limit_exceeded"?"使用上限已达到,请联系管理员":"今日使用上限已达到":"输入 / 使用命令,@ 引用文件,或向 Claude 提问...",disabled:se||w&&!w.allowed,className:"chat-input-placeholder block w-full pl-20 pr-20 sm:pr-40 py-1.5 sm:py-4 bg-transparent rounded-2xl focus:outline-none text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 disabled:opacity-50 resize-none min-h-[50px] sm:min-h-[80px] max-h-[40vh] sm:max-h-[300px] overflow-y-auto text-sm sm:text-base leading-[21px] sm:leading-6 transition-all duration-200",style:{height:"50px"}}),e.jsx("button",{type:"button",onClick:Sa,disabled:w&&!w.allowed,className:"absolute left-2 top-1/2 transform -translate-y-1/2 p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:w&&!w.allowed?"使用上限已达到":"添加图片",children:e.jsx("svg",{className:"w-5 h-5 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),e.jsx("input",{type:"file",ref:Ie,onChange:va,className:"hidden",multiple:!0}),e.jsx("button",{type:"button",onClick:()=>Ie.current?.click(),disabled:A||!t||w&&!w.allowed,className:"absolute left-10 top-1/2 transform -translate-y-1/2 p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:w&&!w.allowed?"使用上限已达到":"上传文件并引用",children:A?e.jsxs("svg",{className:"w-5 h-5 text-gray-500 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):e.jsx("svg",{className:"w-5 h-5 text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}),e.jsx("div",{className:"absolute right-16 sm:right-16 top-1/2 transform -translate-y-1/2",style:{display:"none"},children:e.jsx(Wo,{onTranscript:ba,className:"w-10 h-10 sm:w-10 sm:h-10"})}),e.jsx("button",{type:"submit",disabled:!F.trim()||se,onMouseDown:c=>{c.preventDefault(),jt(c)},onTouchStart:c=>{c.preventDefault(),jt(c)},className:"absolute right-2 top-1/2 transform -translate-y-1/2 w-12 h-12 sm:w-12 sm:h-12 bg-blue-600 hover:bg-blue-700 disabled:bg-gray-400 disabled:cursor-not-allowed rounded-full flex items-center justify-center transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:ring-offset-gray-800",children:e.jsx("svg",{className:"w-4 h-4 sm:w-5 sm:h-5 text-white transform rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})}),e.jsx("div",{className:`absolute bottom-1 left-20 right-14 sm:right-40 text-xs text-gray-400 dark:text-gray-500 pointer-events-none hidden sm:block transition-opacity duration-200 ${F.trim()?"opacity-0":"opacity-100"}`,children:g?"Ctrl+Enter 发送 • Shift+Enter 换行 • Tab 切换模式 • / 使用命令":"Enter 发送 • Shift+Enter 换行 • Tab 切换模式 • / 使用命令"})]})]})]})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:"选择一个项目开始与 Claude 对话"})})})}const Qo=Xe.memo(Yo);function Ur({file:t,onClose:r,projectPath:a,isSidebar:o=!1,isExpanded:n=!1,onToggleExpand:l=null}){const[i,d]=s.useState(""),[x,p]=s.useState(!0),[b,C]=s.useState(!1),[j,y]=s.useState(!1),[h,$]=s.useState(()=>{const B=localStorage.getItem("codeEditorTheme");return B?B==="dark":!0}),[M,I]=s.useState(!1),[E,g]=s.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[m,k]=s.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[w,R]=s.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),W=s.useRef(null),F=s.useMemo(()=>{const B=()=>{const T=document.createElement("div");T.className="cm-editor-toolbar-panel";const _=()=>{let Y='<div style="display: flex; align-items: center; justify-content: flex-end; width: 100%;">';Y+='<div style="display: flex; align-items: center; gap: 4px;">',Y+=`
|
|
78
78
|
<button class="cm-toolbar-btn cm-settings-btn" title="Editor Settings">
|
|
79
79
|
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
80
80
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
|
81
81
|
</svg>
|
|
82
82
|
</button>
|
|
83
|
-
`,o&&
|
|
83
|
+
`,o&&l&&(Y+=`
|
|
84
84
|
<button class="cm-toolbar-btn cm-expand-btn" title="${n?"Collapse editor":"Expand editor to full width"}">
|
|
85
85
|
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
86
86
|
${n?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />'}
|
|
87
87
|
</svg>
|
|
88
88
|
</button>
|
|
89
|
-
`),Y+="</div>",Y+="</div>",T.innerHTML=Y,T.querySelector(".cm-settings-btn")?.addEventListener("click",()=>{window.openSettings&&window.openSettings("appearance")}),o&&
|
|
89
|
+
`),Y+="</div>",Y+="</div>",T.innerHTML=Y,T.querySelector(".cm-settings-btn")?.addEventListener("click",()=>{window.openSettings&&window.openSettings("appearance")}),o&&l&&T.querySelector(".cm-expand-btn")?.addEventListener("click",()=>{l()})};return _(),{top:!0,dom:T,update:_}};return[Da.of(B)]},[o,n,l]),Q=B=>{const T=B.split(".").pop()?.toLowerCase();switch(T){case"js":case"jsx":case"ts":case"tsx":return[Fa({jsx:!0,typescript:T.includes("ts")})];case"py":return[Oa()];case"html":case"htm":return[Aa()];case"css":case"scss":case"less":return[_a()];case"json":return[za()];case"md":case"markdown":return[$a()];default:return[]}};s.useEffect(()=>{(async()=>{try{p(!0);const T=await we.readFile(t.projectName,t.path);if(!T.ok)throw new Error(`Failed to load file: ${T.status} ${T.statusText}`);const _=await T.json();d(_.content)}catch(T){console.error("Error loading file:",T),d(`// Error loading file: ${T.message}
|
|
90
90
|
// File: ${t.name}
|
|
91
|
-
// Path: ${t.path}`)}finally{p(!1)}})()},[t,a]);const ie=async()=>{
|
|
91
|
+
// Path: ${t.path}`)}finally{p(!1)}})()},[t,a]);const ie=async()=>{C(!0);try{console.log("Saving file:",{projectName:t.projectName,path:t.path,contentLength:i?.length});const B=await we.saveFile(t.projectName,t.path,i);if(console.log("Save response:",{status:B.status,ok:B.ok,contentType:B.headers.get("content-type")}),!B.ok){const _=B.headers.get("content-type");if(_&&_.includes("application/json")){const Y=await B.json();throw new Error(Y.error||`Save failed: ${B.status}`)}else{const Y=await B.text();throw console.error("Non-JSON error response:",Y),new Error(`Save failed: ${B.status} ${B.statusText}`)}}const T=await B.json();console.log("Save successful:",T),I(!0),setTimeout(()=>I(!1),2e3)}catch(B){console.error("Error saving file:",B),alert(`Error saving file: ${B.message}`)}finally{C(!1)}},Z=()=>{const B=new Blob([i],{type:"text/plain"}),T=URL.createObjectURL(B),_=document.createElement("a");_.href=T,_.download=t.name,document.body.appendChild(_),_.click(),document.body.removeChild(_),URL.revokeObjectURL(T)},se=()=>{y(!j)};return s.useEffect(()=>{localStorage.setItem("codeEditorTheme",h?"dark":"light")},[h]),s.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",E.toString())},[E]),s.useEffect(()=>{const B=()=>{const T=localStorage.getItem("codeEditorTheme");T&&$(T==="dark");const _=localStorage.getItem("codeEditorWordWrap");_!==null&&g(_==="true");const Y=localStorage.getItem("codeEditorLineNumbers");Y!==null&&k(Y!=="false");const pe=localStorage.getItem("codeEditorFontSize");pe&&R(pe)};return window.addEventListener("storage",B),window.addEventListener("codeEditorSettingsChanged",B),()=>{window.removeEventListener("storage",B),window.removeEventListener("codeEditorSettingsChanged",B)}},[]),s.useEffect(()=>{const B=T=>{(T.ctrlKey||T.metaKey)&&(T.key==="s"?(T.preventDefault(),ie()):T.key==="Escape"&&(T.preventDefault(),r()))};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[i]),x?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
|
|
92
92
|
.code-editor-loading {
|
|
93
|
-
background-color: ${
|
|
93
|
+
background-color: ${h?"#111827":"#ffffff"} !important;
|
|
94
94
|
}
|
|
95
95
|
.code-editor-loading:hover {
|
|
96
|
-
background-color: ${
|
|
96
|
+
background-color: ${h?"#111827":"#ffffff"} !important;
|
|
97
97
|
}
|
|
98
98
|
`}),o?e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-background",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsxs("span",{className:"text-gray-900 dark:text-white",children:["Loading ",t.name,"..."]})]})}):e.jsx("div",{className:"fixed inset-0 z-40 md:bg-black/50 md:flex md:items-center md:justify-center",children:e.jsx("div",{className:"code-editor-loading w-full h-full md:rounded-lg md:w-auto md:h-auto p-8 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsxs("span",{className:"text-gray-900 dark:text-white",children:["Loading ",t.name,"..."]})]})})})]}):e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
|
|
99
99
|
/* Editor toolbar panel styling */
|
|
100
100
|
.cm-editor-toolbar-panel {
|
|
101
101
|
padding: 8px 12px;
|
|
102
|
-
background-color: ${
|
|
103
|
-
border-bottom: 1px solid ${
|
|
104
|
-
color: ${
|
|
102
|
+
background-color: ${h?"#1f2937":"#ffffff"};
|
|
103
|
+
border-bottom: 1px solid ${h?"#374151":"#e5e7eb"};
|
|
104
|
+
color: ${h?"#d1d5db":"#374151"};
|
|
105
105
|
font-size: 14px;
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -119,10 +119,10 @@ ${ee}`:ee:Te.push({type:"assistant",content:ee,timestamp:new Date,isStreaming:!0
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
.cm-toolbar-btn:hover {
|
|
122
|
-
background-color: ${
|
|
122
|
+
background-color: ${h?"#374151":"#f3f4f6"};
|
|
123
123
|
}
|
|
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 ${
|
|
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 Zo({file:t,onClose:r}){const a=`/api/projects/${t.projectName}/files/content?path=${encodeURIComponent(t.path)}`,[o,n]=s.useState(null),[c,i]=s.useState(null),[m,h]=s.useState(!0);return s.useEffect(()=>{let p;const b=new AbortController;return(async()=>{try{h(!0),i(null),n(null);const v=await ne(a,{signal:b.signal});if(!v.ok)throw new Error(`Request failed with status ${v.status}`);const j=await v.blob();p=URL.createObjectURL(j),n(p)}catch(v){if(v.name==="AbortError")return;console.error("Error loading image:",v),i("无法加载图像")}finally{h(!1)}})(),()=>{b.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(J,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:e.jsx(Oe,{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:[m&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:"加载图像中…"})}),!m&&o&&e.jsx("img",{src:o,alt:t.name,className:"max-w-full max-h-[70vh] object-contain rounded-lg shadow-md"}),!m&&!o&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("p",{children:c||"无法加载图像"}),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 Xo({selectedProject:t}){const[r,a]=s.useState([]),[o,n]=s.useState(!1),[c,i]=s.useState(new Set),[m,h]=s.useState(new Set),[p,b]=s.useState(new Set),[E,v]=s.useState(null),[j,g]=s.useState(null),[$,L]=s.useState("detailed"),[I,C]=s.useState(""),[x,d]=s.useState([]),[k,S]=s.useState(!1),[A,W]=s.useState(!1),[O,Q]=s.useState(null),[ie,Z]=s.useState({}),[se,B]=s.useState(null);s.useEffect(()=>{t&&(i(new Set),b(new Set),h(new Set),z())},[t]),s.useEffect(()=>{const H=localStorage.getItem("file-tree-view-mode");H&&["simple","detailed","compact"].includes(H)&&L(H)},[]),s.useEffect(()=>{if(!I.trim())d(r);else{const H=T(r,I.toLowerCase());d(H);const f=y=>{y.forEach(F=>{F.type==="directory"&&F.children&&F.children.length>0&&(i(oe=>new Set(oe.add(F.path))),f(F.children))})};f(H)}},[r,I]);const T=(H,f)=>H.reduce((y,F)=>{const oe=F.name.toLowerCase().includes(f);let ue=[];return F.type==="directory"&&F.children&&(ue=T(F.children,f)),(oe||ue.length>0)&&y.push({...F,children:ue}),y},[]),z=async()=>{n(!0);try{const H=await we.getFiles(t.name,{depth:1});if(!H.ok){const y=await H.text();console.error("❌ File fetch failed:",H.status,y),a([]);return}const f=await H.json();a(f)}catch(H){console.error("❌ Error fetching files:",H),a([])}finally{n(!1)}},Y=async H=>{if(!(p.has(H)||m.has(H))){h(f=>new Set([...f,H]));try{const f=await we.getFiles(t.name,{dirPath:H,depth:1});if(!f.ok){console.error("Failed to load directory:",H);return}const y=await f.json();a(F=>pe(F,H,y)),b(F=>new Set([...F,H]))}catch(f){console.error("Error loading directory:",f)}finally{h(f=>{const y=new Set(f);return y.delete(H),y})}}},pe=(H,f,y)=>H.map(F=>F.path===f?{...F,children:y}:F.type==="directory"&&F.children&&F.children.length>0?{...F,children:pe(F.children,f,y)}:F),ae=s.useCallback(async H=>{if(!t||H.length===0)return;W(!0),Q(null);const f=new FormData;H.forEach(F=>{f.append("files",F)});const y={};H.forEach(F=>{y[F.name]=0}),Z(y);try{const F=await we.uploadFiles(t.name,f);if(!F.ok){const ue=await F.json();throw new Error(ue.error||"Upload failed")}const oe={};H.forEach(ue=>{oe[ue.name]=100}),Z(oe),await z(),setTimeout(()=>{S(!1),Z({})},1e3)}catch(F){console.error("Upload failed:",F),Q(F.message)}finally{W(!1)}},[t]),{getRootProps:G,getInputProps:xe,isDragActive:Ne,open:Ce}=Vr({onDrop:ae,noClick:!0,noKeyboard:!0}),je=async H=>{if(t)try{const f=await we.deleteFile(t.name,H);if(!f.ok){const y=await f.json();throw new Error(y.error||"Delete failed")}await z(),B(null)}catch(f){console.error("Delete failed:",f),alert(`Failed to delete: ${f.message}`)}},_e=async(H,f)=>{const y=new Set(c);y.has(H)?y.delete(H):(y.add(H),f&&!p.has(H)&&await Y(H)),i(y)},he=H=>{L(H),localStorage.setItem("file-tree-view-mode",H)},Se=H=>{if(!H||H===0)return"0 B";const f=1024,y=["B","KB","MB","GB"],F=Math.floor(Math.log(H)/Math.log(f));return parseFloat((H/Math.pow(f,F)).toFixed(1))+" "+y[F]},ke=H=>{if(!H)return"-";const f=new Date,y=new Date(H),F=Math.floor((f-y)/1e3);return F<60?"just now":F<3600?`${Math.floor(F/60)} min ago`:F<86400?`${Math.floor(F/3600)} hours ago`:F<2592e3?`${Math.floor(F/86400)} days ago`:y.toLocaleDateString()},Ee=(H,f=0)=>H.map(y=>{const F=m.has(y.path),oe=c.has(y.path),ue=y.hasChildren||y.children&&y.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:Fe("w-full flex items-center justify-between p-2 hover:bg-accent cursor-pointer"),style:{paddingLeft:`${f*16+12}px`},onClick:()=>{y.type==="directory"?_e(y.path,ue):ye(y.name)?g({name:y.name,path:y.path,projectPath:t.path,projectName:t.name}):v({name:y.name,path:y.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[y.type==="directory"?F?e.jsx(ft,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):oe?e.jsx(kt,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):ue?e.jsx(rt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):Pe(y.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:y.name}),y.type==="directory"&&ue&&!oe&&!F&&e.jsx(Lt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity flex-shrink-0",onClick:Le=>{Le.stopPropagation(),B({path:y.path,name:y.name,type:y.type})},title:`删除${y.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ve,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]}),y.type==="directory"&&oe&&e.jsx("div",{children:F?e.jsxs("div",{className:"flex items-center gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(f+1)*16+12}px`},children:[e.jsx(ft,{className:"w-3 h-3 animate-spin"}),"加载中..."]}):y.children&&y.children.length>0?Ee(y.children,f+1):e.jsx("div",{className:"p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(f+1)*16+12}px`},children:"空文件夹"})})]},y.path)}),ye=H=>{const f=H.split(".").pop()?.toLowerCase();return["png","jpg","jpeg","gif","svg","webp","ico","bmp"].includes(f)},Pe=H=>{const f=H.split(".").pop()?.toLowerCase(),y=["js","jsx","ts","tsx","py","java","cpp","c","php","rb","go","rs"],F=["md","txt","doc","pdf"],oe=["png","jpg","jpeg","gif","svg","webp","ico","bmp"];return y.includes(f)?e.jsx(rn,{className:"w-4 h-4 text-green-500 flex-shrink-0"}):F.includes(f)?e.jsx(_s,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):oe.includes(f)?e.jsx(cs,{className:"w-4 h-4 text-purple-500 flex-shrink-0"}):e.jsx(cs,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"})},Re=(H,f=0)=>H.map(y=>{const F=m.has(y.path),oe=c.has(y.path),ue=y.hasChildren||y.children&&y.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:Fe("grid grid-cols-12 gap-2 p-2 hover:bg-accent cursor-pointer items-center"),style:{paddingLeft:`${f*16+12}px`},onClick:()=>{y.type==="directory"?_e(y.path,ue):ye(y.name)?g({name:y.name,path:y.path,projectPath:t.path,projectName:t.name}):v({name:y.name,path:y.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"col-span-4 flex items-center gap-2 min-w-0",children:[y.type==="directory"?F?e.jsx(ft,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):oe?e.jsx(kt,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):ue?e.jsx(rt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):Pe(y.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:y.name}),y.type==="directory"&&ue&&!oe&&!F&&e.jsx(Lt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground",children:y.type==="file"?Se(y.size):"-"}),e.jsx("div",{className:"col-span-3 text-sm text-muted-foreground",children:ke(y.modified)}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground font-mono",children:y.permissionsRwx||"-"}),e.jsx("div",{className:"col-span-1 flex justify-end",children:e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:Le=>{Le.stopPropagation(),B({path:y.path,name:y.name,type:y.type})},title:`删除${y.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ve,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})})]}),y.type==="directory"&&oe&&e.jsx("div",{children:F?e.jsx("div",{className:"grid grid-cols-12 gap-2 p-2 text-sm text-muted-foreground items-center",style:{paddingLeft:`${(f+1)*16+12}px`},children:e.jsxs("div",{className:"col-span-4 flex items-center gap-2",children:[e.jsx(ft,{className:"w-3 h-3 animate-spin"}),"加载中..."]})}):y.children&&y.children.length>0?Re(y.children,f+1):e.jsx("div",{className:"grid grid-cols-12 gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(f+1)*16+12}px`},children:e.jsx("div",{className:"col-span-4",children:"空文件夹"})})})]},y.path)}),Me=(H,f=0)=>H.map(y=>{const F=m.has(y.path),oe=c.has(y.path),ue=y.hasChildren||y.children&&y.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:Fe("flex items-center justify-between p-2 hover:bg-accent cursor-pointer"),style:{paddingLeft:`${f*16+12}px`},onClick:()=>{y.type==="directory"?_e(y.path,ue):ye(y.name)?g({name:y.name,path:y.path,projectPath:t.path,projectName:t.name}):v({name:y.name,path:y.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[y.type==="directory"?F?e.jsx(ft,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):oe?e.jsx(kt,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):ue?e.jsx(rt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):Pe(y.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:y.name}),y.type==="directory"&&ue&&!oe&&!F&&e.jsx(Lt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[y.type==="file"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:Se(y.size)}),e.jsx("span",{className:"font-mono",children:y.permissionsRwx})]}),e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:Le=>{Le.stopPropagation(),B({path:y.path,name:y.name,type:y.type})},title:`删除${y.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ve,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]})]}),y.type==="directory"&&oe&&e.jsx("div",{children:F?e.jsxs("div",{className:"flex items-center gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(f+1)*16+12}px`},children:[e.jsx(ft,{className:"w-3 h-3 animate-spin"}),"加载中..."]}):y.children&&y.children.length>0?Me(y.children,f+1):e.jsx("div",{className:"p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(f+1)*16+12}px`},children:"空文件夹"})})]},y.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",{...G(),className:Fe("h-full flex flex-col bg-card relative",Ne&&"ring-2 ring-primary ring-inset"),children:[e.jsx("input",{...xe()}),Ne&&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(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>S(!0),title:"上传文件",children:e.jsx(ls,{className:"w-4 h-4"})}),e.jsx(J,{variant:$==="simple"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>he("simple"),title:"简单视图",children:e.jsx(en,{className:"w-4 h-4"})}),e.jsx(J,{variant:$==="compact"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>he("compact"),title:"紧凑视图",children:e.jsx(zs,{className:"w-4 h-4"})}),e.jsx(J,{variant:$==="detailed"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>he("detailed"),title:"详细视图",children:e.jsx(tn,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(It,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Ke,{type:"text",placeholder:"搜索文件和文件夹...",value:I,onChange:H=>C(H.target.value),className:"pl-8 pr-8 h-8 text-sm"}),I&&e.jsx(J,{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(Oe,{className:"w-3 h-3"})})]})]}),$==="detailed"&&x.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(Jr,{className:"flex-1 p-4",children:r.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(rt,{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:"检查项目路径是否可访问"})]}):x.length===0&&I?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(It,{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:$==="detailed"?"":"space-y-1",children:[$==="simple"&&Ee(x),$==="compact"&&Me(x),$==="detailed"&&Re(x)]})}),E&&e.jsx(Ur,{file:E,onClose:()=>v(null),projectPath:E.projectPath}),j&&e.jsx(Zo,{file:j,onClose:()=>g(null)}),k&&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(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{S(!1),Q(null),Z({})},children:e.jsx(Oe,{className:"w-4 h-4"})})]}),e.jsxs("div",{onClick:Ce,className:Fe("border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors","border-border hover:border-primary/50"),children:[e.jsx(ls,{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(ie).length>0&&e.jsx("div",{className:"mt-4 space-y-2 max-h-40 overflow-y-auto",children:Object.entries(ie).map(([H,f])=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm truncate flex-1 text-foreground",children:H}),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:`${f}%`}})}),e.jsxs("span",{className:"text-xs text-muted-foreground w-10",children:[f,"%"]})]},H))}),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})}),A&&e.jsx("div",{className:"mt-4 text-center text-sm text-muted-foreground",children:"上传中..."})]})}),se&&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:["确定要删除",se.type==="directory"?"文件夹":"文件"," ",e.jsxs("span",{className:"font-medium text-foreground",children:['"',se.name,'"']}),"?",se.type==="directory"&&e.jsx("span",{className:"block mt-1 text-destructive",children:"这将删除内部的所有内容。"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{variant:"outline",size:"sm",onClick:()=>B(null),children:"取消"}),e.jsx(J,{variant:"destructive",size:"sm",onClick:()=>je(se.path),children:"删除"})]})]})})]})}var ea=Cn(),ta=En(),ra=Mn(),sa=Ln();const ei=`
|
|
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 ${j?"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"+(j?" 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:Z,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(qr,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsx("button",{onClick:ie,disabled:b,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 ${M?"bg-green-600 hover:bg-green-700":"bg-blue-600 hover:bg-blue-700"}`,children:M?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(As,{className:"w-5 h-5 md:w-4 md:h-4"}),e.jsx("span",{className:"hidden sm:inline",children:b?"Saving...":"Save"})]})}),!o&&e.jsx("button",{onClick:se,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:j?"Exit fullscreen":"Fullscreen",children:j?e.jsx(Xa,{className:"w-4 h-4"}):e.jsx(Os,{className:"w-4 h-4"})}),e.jsx("button",{onClick:r,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(Fe,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(Ta,{ref:W,value:i,onChange:d,extensions:[...Q(t.name),...F,...E?[Pa.lineWrapping]:[]],theme:h?Ra: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 Zo({file:t,onClose:r}){const a=`/api/projects/${t.projectName}/files/content?path=${encodeURIComponent(t.path)}`,[o,n]=s.useState(null),[l,i]=s.useState(null),[d,x]=s.useState(!0);return s.useEffect(()=>{let p;const b=new AbortController;return(async()=>{try{x(!0),i(null),n(null);const j=await ne(a,{signal:b.signal});if(!j.ok)throw new Error(`Request failed with status ${j.status}`);const y=await j.blob();p=URL.createObjectURL(y),n(p)}catch(j){if(j.name==="AbortError")return;console.error("Error loading image:",j),i("无法加载图像")}finally{x(!1)}})(),()=>{b.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(J,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:e.jsx(Fe,{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 Xo({selectedProject:t}){const[r,a]=s.useState([]),[o,n]=s.useState(!1),[l,i]=s.useState(new Set),[d,x]=s.useState(new Set),[p,b]=s.useState(new Set),[C,j]=s.useState(null),[y,h]=s.useState(null),[$,M]=s.useState("detailed"),[I,E]=s.useState(""),[g,m]=s.useState([]),[k,w]=s.useState(!1),[R,W]=s.useState(!1),[F,Q]=s.useState(null),[ie,Z]=s.useState({}),[se,B]=s.useState(null);s.useEffect(()=>{t&&(i(new Set),b(new Set),x(new Set),_())},[t]),s.useEffect(()=>{const H=localStorage.getItem("file-tree-view-mode");H&&["simple","detailed","compact"].includes(H)&&M(H)},[]),s.useEffect(()=>{if(!I.trim())m(r);else{const H=T(r,I.toLowerCase());m(H);const f=v=>{v.forEach(O=>{O.type==="directory"&&O.children&&O.children.length>0&&(i(oe=>new Set(oe.add(O.path))),f(O.children))})};f(H)}},[r,I]);const T=(H,f)=>H.reduce((v,O)=>{const oe=O.name.toLowerCase().includes(f);let ue=[];return O.type==="directory"&&O.children&&(ue=T(O.children,f)),(oe||ue.length>0)&&v.push({...O,children:ue}),v},[]),_=async()=>{n(!0);try{const H=await we.getFiles(t.name,{depth:1});if(!H.ok){const v=await H.text();console.error("❌ File fetch failed:",H.status,v),a([]);return}const f=await H.json();a(f)}catch(H){console.error("❌ Error fetching files:",H),a([])}finally{n(!1)}},Y=async H=>{if(!(p.has(H)||d.has(H))){x(f=>new Set([...f,H]));try{const f=await we.getFiles(t.name,{dirPath:H,depth:1});if(!f.ok){console.error("Failed to load directory:",H);return}const v=await f.json();a(O=>pe(O,H,v)),b(O=>new Set([...O,H]))}catch(f){console.error("Error loading directory:",f)}finally{x(f=>{const v=new Set(f);return v.delete(H),v})}}},pe=(H,f,v)=>H.map(O=>O.path===f?{...O,children:v}:O.type==="directory"&&O.children&&O.children.length>0?{...O,children:pe(O.children,f,v)}:O),ae=s.useCallback(async H=>{if(!t||H.length===0)return;W(!0),Q(null);const f=new FormData;H.forEach(O=>{f.append("files",O)});const v={};H.forEach(O=>{v[O.name]=0}),Z(v);try{const O=await we.uploadFiles(t.name,f);if(!O.ok){const ue=await O.json();throw new Error(ue.error||"Upload failed")}const oe={};H.forEach(ue=>{oe[ue.name]=100}),Z(oe),await _(),setTimeout(()=>{w(!1),Z({})},1e3)}catch(O){console.error("Upload failed:",O),Q(O.message)}finally{W(!1)}},[t]),{getRootProps:V,getInputProps:xe,isDragActive:Ne,open:Ce}=Gr({onDrop:ae,noClick:!0,noKeyboard:!0}),je=async H=>{if(t)try{const f=await we.deleteFile(t.name,H);if(!f.ok){const v=await f.json();throw new Error(v.error||"Delete failed")}await _(),B(null)}catch(f){console.error("Delete failed:",f),alert(`Failed to delete: ${f.message}`)}},_e=async(H,f)=>{const v=new Set(l);v.has(H)?v.delete(H):(v.add(H),f&&!p.has(H)&&await Y(H)),i(v)},he=H=>{M(H),localStorage.setItem("file-tree-view-mode",H)},Se=H=>{if(!H||H===0)return"0 B";const f=1024,v=["B","KB","MB","GB"],O=Math.floor(Math.log(H)/Math.log(f));return parseFloat((H/Math.pow(f,O)).toFixed(1))+" "+v[O]},ke=H=>{if(!H)return"-";const f=new Date,v=new Date(H),O=Math.floor((f-v)/1e3);return O<60?"just now":O<3600?`${Math.floor(O/60)} min ago`:O<86400?`${Math.floor(O/3600)} hours ago`:O<2592e3?`${Math.floor(O/86400)} days ago`:v.toLocaleDateString()},Ee=(H,f=0)=>H.map(v=>{const O=d.has(v.path),oe=l.has(v.path),ue=v.hasChildren||v.children&&v.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:Oe("w-full flex items-center justify-between p-2 hover:bg-accent cursor-pointer"),style:{paddingLeft:`${f*16+12}px`},onClick:()=>{v.type==="directory"?_e(v.path,ue):ye(v.name)?h({name:v.name,path:v.path,projectPath:t.path,projectName:t.name}):j({name:v.name,path:v.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[v.type==="directory"?O?e.jsx(ft,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):oe?e.jsx(kt,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):ue?e.jsx(rt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):Re(v.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:v.name}),v.type==="directory"&&ue&&!oe&&!O&&e.jsx(Lt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity flex-shrink-0",onClick:Le=>{Le.stopPropagation(),B({path:v.path,name:v.name,type:v.type})},title:`删除${v.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ge,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]}),v.type==="directory"&&oe&&e.jsx("div",{children:O?e.jsxs("div",{className:"flex items-center gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(f+1)*16+12}px`},children:[e.jsx(ft,{className:"w-3 h-3 animate-spin"}),"加载中..."]}):v.children&&v.children.length>0?Ee(v.children,f+1):e.jsx("div",{className:"p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(f+1)*16+12}px`},children:"空文件夹"})})]},v.path)}),ye=H=>{const f=H.split(".").pop()?.toLowerCase();return["png","jpg","jpeg","gif","svg","webp","ico","bmp"].includes(f)},Re=H=>{const f=H.split(".").pop()?.toLowerCase(),v=["js","jsx","ts","tsx","py","java","cpp","c","php","rb","go","rs"],O=["md","txt","doc","pdf"],oe=["png","jpg","jpeg","gif","svg","webp","ico","bmp"];return v.includes(f)?e.jsx(rn,{className:"w-4 h-4 text-green-500 flex-shrink-0"}):O.includes(f)?e.jsx(Ws,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):oe.includes(f)?e.jsx(ps,{className:"w-4 h-4 text-purple-500 flex-shrink-0"}):e.jsx(ps,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"})},Pe=(H,f=0)=>H.map(v=>{const O=d.has(v.path),oe=l.has(v.path),ue=v.hasChildren||v.children&&v.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:Oe("grid grid-cols-12 gap-2 p-2 hover:bg-accent cursor-pointer items-center"),style:{paddingLeft:`${f*16+12}px`},onClick:()=>{v.type==="directory"?_e(v.path,ue):ye(v.name)?h({name:v.name,path:v.path,projectPath:t.path,projectName:t.name}):j({name:v.name,path:v.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"col-span-4 flex items-center gap-2 min-w-0",children:[v.type==="directory"?O?e.jsx(ft,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):oe?e.jsx(kt,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):ue?e.jsx(rt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):Re(v.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:v.name}),v.type==="directory"&&ue&&!oe&&!O&&e.jsx(Lt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground",children:v.type==="file"?Se(v.size):"-"}),e.jsx("div",{className:"col-span-3 text-sm text-muted-foreground",children:ke(v.modified)}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground font-mono",children:v.permissionsRwx||"-"}),e.jsx("div",{className:"col-span-1 flex justify-end",children:e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:Le=>{Le.stopPropagation(),B({path:v.path,name:v.name,type:v.type})},title:`删除${v.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ge,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})})]}),v.type==="directory"&&oe&&e.jsx("div",{children:O?e.jsx("div",{className:"grid grid-cols-12 gap-2 p-2 text-sm text-muted-foreground items-center",style:{paddingLeft:`${(f+1)*16+12}px`},children:e.jsxs("div",{className:"col-span-4 flex items-center gap-2",children:[e.jsx(ft,{className:"w-3 h-3 animate-spin"}),"加载中..."]})}):v.children&&v.children.length>0?Pe(v.children,f+1):e.jsx("div",{className:"grid grid-cols-12 gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(f+1)*16+12}px`},children:e.jsx("div",{className:"col-span-4",children:"空文件夹"})})})]},v.path)}),Me=(H,f=0)=>H.map(v=>{const O=d.has(v.path),oe=l.has(v.path),ue=v.hasChildren||v.children&&v.children.length>0;return e.jsxs("div",{className:"select-none group/item",children:[e.jsxs("div",{className:Oe("flex items-center justify-between p-2 hover:bg-accent cursor-pointer"),style:{paddingLeft:`${f*16+12}px`},onClick:()=>{v.type==="directory"?_e(v.path,ue):ye(v.name)?h({name:v.name,path:v.path,projectPath:t.path,projectName:t.name}):j({name:v.name,path:v.path,projectPath:t.path,projectName:t.name})},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[v.type==="directory"?O?e.jsx(ft,{className:"w-4 h-4 text-blue-500 flex-shrink-0 animate-spin"}):oe?e.jsx(kt,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):ue?e.jsx(rt,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}):e.jsx(rt,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}):Re(v.name),e.jsx("span",{className:"text-sm truncate text-foreground",children:v.name}),v.type==="directory"&&ue&&!oe&&!O&&e.jsx(Lt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[v.type==="file"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:Se(v.size)}),e.jsx("span",{className:"font-mono",children:v.permissionsRwx})]}),e.jsx(J,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover/item:opacity-100 transition-opacity",onClick:Le=>{Le.stopPropagation(),B({path:v.path,name:v.name,type:v.type})},title:`删除${v.type==="directory"?"文件夹":"文件"}`,children:e.jsx(Ge,{className:"w-3.5 h-3.5 text-muted-foreground hover:text-destructive"})})]})]}),v.type==="directory"&&oe&&e.jsx("div",{children:O?e.jsxs("div",{className:"flex items-center gap-2 p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(f+1)*16+12}px`},children:[e.jsx(ft,{className:"w-3 h-3 animate-spin"}),"加载中..."]}):v.children&&v.children.length>0?Me(v.children,f+1):e.jsx("div",{className:"p-2 text-sm text-muted-foreground",style:{paddingLeft:`${(f+1)*16+12}px`},children:"空文件夹"})})]},v.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",{...V(),className:Oe("h-full flex flex-col bg-card relative",Ne&&"ring-2 ring-primary ring-inset"),children:[e.jsx("input",{...xe()}),Ne&&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(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>w(!0),title:"上传文件",children:e.jsx(us,{className:"w-4 h-4"})}),e.jsx(J,{variant:$==="simple"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>he("simple"),title:"简单视图",children:e.jsx(en,{className:"w-4 h-4"})}),e.jsx(J,{variant:$==="compact"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>he("compact"),title:"紧凑视图",children:e.jsx(Fs,{className:"w-4 h-4"})}),e.jsx(J,{variant:$==="detailed"?"default":"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>he("detailed"),title:"详细视图",children:e.jsx(tn,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Dt,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Ke,{type:"text",placeholder:"搜索文件和文件夹...",value:I,onChange:H=>E(H.target.value),className:"pl-8 pr-8 h-8 text-sm"}),I&&e.jsx(J,{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:()=>E(""),title:"清除搜索",children:e.jsx(Fe,{className:"w-3 h-3"})})]})]}),$==="detailed"&&g.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(Jr,{className:"flex-1 p-4",children:r.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(rt,{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:"检查项目路径是否可访问"})]}):g.length===0&&I?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(Dt,{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:$==="detailed"?"":"space-y-1",children:[$==="simple"&&Ee(g),$==="compact"&&Me(g),$==="detailed"&&Pe(g)]})}),C&&e.jsx(Ur,{file:C,onClose:()=>j(null),projectPath:C.projectPath}),y&&e.jsx(Zo,{file:y,onClose:()=>h(null)}),k&&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(J,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{w(!1),Q(null),Z({})},children:e.jsx(Fe,{className:"w-4 h-4"})})]}),e.jsxs("div",{onClick:Ce,className:Oe("border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors","border-border hover:border-primary/50"),children:[e.jsx(us,{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(ie).length>0&&e.jsx("div",{className:"mt-4 space-y-2 max-h-40 overflow-y-auto",children:Object.entries(ie).map(([H,f])=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm truncate flex-1 text-foreground",children:H}),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:`${f}%`}})}),e.jsxs("span",{className:"text-xs text-muted-foreground w-10",children:[f,"%"]})]},H))}),F&&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:F})}),R&&e.jsx("div",{className:"mt-4 text-center text-sm text-muted-foreground",children:"上传中..."})]})}),se&&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:["确定要删除",se.type==="directory"?"文件夹":"文件"," ",e.jsxs("span",{className:"font-medium text-foreground",children:['"',se.name,'"']}),"?",se.type==="directory"&&e.jsx("span",{className:"block mt-1 text-destructive",children:"这将删除内部的所有内容。"})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{variant:"outline",size:"sm",onClick:()=>B(null),children:"取消"}),e.jsx(J,{variant:"destructive",size:"sm",onClick:()=>je(se.path),children:"删除"})]})]})})]})}var Yr=Cn(),Qr=En(),Zr=Mn(),Xr=Ln();const ei=`
|
|
126
126
|
.xterm .xterm-screen {
|
|
127
127
|
outline: none !important;
|
|
128
128
|
}
|
|
@@ -132,20 +132,20 @@ ${ee}`:ee:Te.push({type:"assistant",content:ee,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=ei,document.head.appendChild(t)}function ti({selectedProject:t,selectedSession:r,initialCommand:a,isPlainShell:o=!1,onProcessComplete:n,minimal:c=!1,autoConnect:i=!1}){const m=s.useRef(null),h=s.useRef(null),p=s.useRef(null),b=s.useRef(null),[E,v]=s.useState(!1),[j,g]=s.useState(!1),[$,L]=s.useState(!1),[I,C]=s.useState(null),[x,d]=s.useState(!1),k=s.useRef(t),S=s.useRef(r),A=s.useRef(a),W=s.useRef(o),O=s.useRef(n);s.useEffect(()=>{k.current=t,S.current=r,A.current=a,W.current=o,O.current=n});const Q=s.useCallback(async()=>{if(!(x||E))try{let pe;{const ae=localStorage.getItem("auth-token");if(!ae){console.error("No authentication token found for Shell WebSocket connection");return}pe=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(ae)}`}b.current=new WebSocket(pe),b.current.onopen=()=>{v(!0),d(!1),setTimeout(()=>{p.current&&h.current&&(p.current.fit(),b.current.send(JSON.stringify({type:"init",projectPath:k.current.fullPath||k.current.path,sessionId:W.current?null:S.current?.id,hasSession:W.current?!1:!!S.current,provider:W.current?"plain-shell":S.current?.__provider||"claude",cols:h.current.cols,rows:h.current.rows,initialCommand:A.current,isPlainShell:W.current})))},100)},b.current.onmessage=ae=>{try{const G=JSON.parse(ae.data);if(G.type==="output"){let xe=G.data;if(W.current&&O.current){const Ne=xe.replace(/\x1b\[[0-9;]*m/g,"");if(Ne.includes("Process exited with code 0"))O.current(0);else if(Ne.match(/Process exited with code (\d+)/)){const Ce=parseInt(Ne.match(/Process exited with code (\d+)/)[1]);Ce!==0&&O.current(Ce)}}h.current&&h.current.write(xe)}else G.type==="url_open"&&window.open(G.url,"_blank")}catch(G){console.error("[Shell] Error handling WebSocket message:",G,ae.data)}},b.current.onclose=ae=>{v(!1),d(!1),h.current&&(h.current.clear(),h.current.write("\x1B[2J\x1B[H"))},b.current.onerror=ae=>{v(!1),d(!1)}}catch{v(!1),d(!1)}},[x,E]),ie=s.useCallback(()=>{!j||E||x||(d(!0),Q())},[j,E,x,Q]),Z=s.useCallback(()=>{b.current&&(b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"terminate"})),b.current.close(),b.current=null),h.current&&(h.current.clear(),h.current.write("\x1B[2J\x1B[H")),v(!1),d(!1)},[]),se=s.useMemo(()=>r?r.__provider==="cursor"?r.name||"Untitled Session":r.summary||"New Session":null,[r]),B=s.useMemo(()=>se?se.slice(0,30):null,[se]),T=s.useMemo(()=>se?se.slice(0,50):null,[se]),z=()=>{L(!0),b.current&&(b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"terminate"})),b.current.close(),b.current=null),h.current&&(h.current.dispose(),h.current=null,p.current=null),v(!1),g(!1),setTimeout(()=>{L(!1)},200)};return s.useEffect(()=>{const Y=r?.id||null;I!==null&&I!==Y&&j&&Z(),C(Y)},[r?.id,j,Z]),s.useEffect(()=>{if(!m.current||!t||$||h.current)return;h.current=new ea.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 ta.FitAddon;const Y=new ra.WebglAddon,pe=new sa.WebLinksAddon;h.current.loadAddon(p.current),h.current.loadAddon(pe);try{h.current.loadAddon(Y)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}h.current.open(m.current),h.current.attachCustomKeyEventHandler(G=>(G.ctrlKey||G.metaKey)&&G.key==="c"&&h.current.hasSelection()?(document.execCommand("copy"),!1):(G.ctrlKey||G.metaKey)&&G.key==="v"?(navigator.clipboard.readText().then(xe=>{b.current&&b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"input",data:xe}))}).catch(()=>{}),!1):!0),setTimeout(()=>{p.current&&(p.current.fit(),h.current&&b.current&&b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"resize",cols:h.current.cols,rows:h.current.rows})))},100),g(!0),h.current.onData(G=>{b.current&&b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"input",data:G}))});const ae=new ResizeObserver(()=>{p.current&&h.current&&setTimeout(()=>{p.current.fit(),b.current&&b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"resize",cols:h.current.cols,rows:h.current.rows}))},50)});return m.current&&ae.observe(m.current),()=>{ae.disconnect(),b.current&&(b.current.readyState===WebSocket.OPEN||b.current.readyState===WebSocket.CONNECTING)&&b.current.close(),b.current=null,h.current&&(h.current.dispose(),h.current=null)}},[t?.path||t?.fullPath,$]),s.useEffect(()=>{!i||!j||x||E||ie()},[i,j,x,E,ie]),t?c?e.jsx("div",{className:"h-full w-full bg-gray-900",children:e.jsx("div",{ref:m,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 ${E?"bg-green-500":"bg-red-500"}`}),r&&e.jsxs("span",{className:"text-xs text-blue-300",children:["(",B,"...)"]}),!r&&e.jsx("span",{className:"text-xs text-gray-400",children:"(新会话)"}),!j&&e.jsx("span",{className:"text-xs text-yellow-400",children:"(正在初始化...)"}),$&&e.jsx("span",{className:"text-xs text-blue-400",children:"(正在重启...)"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[E&&e.jsxs("button",{onClick:Z,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:z,disabled:$||E,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:m,className:"h-full w-full focus:outline-none",style:{outline:"none"}}),!j&&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:"加载终端中..."})}),j&&!E&&!x&&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:ie,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}`:r?`Resume session: ${T}...`:"Start a new Claude session"})]})}),x&&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 ri({project:t,session:r=null,command:a=null,isPlainShell:o=null,autoConnect:n=!0,onComplete:c=null,onClose:i=null,title:m=null,className:h="",showHeader:p=!0,compact:b=!1,minimal:E=!1}){const[v,j]=s.useState(!1),g=o!==null?o:a!==null,$=s.useCallback(L=>{j(!0),c&&c(L)},[c]);return t?e.jsxs("div",{className:`h-full w-full flex flex-col ${h}`,children:[!E&&p&&m&&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:m}),v&&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(ti,{selectedProject:t,selectedSession:r,initialCommand:a,isPlainShell:g,onProcessComplete:$,minimal:E,autoConnect:E?!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 si({selectedProject:t,minimal:r=!1,autoConnect:a=!1}){const o=s.useRef(null),n=s.useRef(null),c=s.useRef(null),i=s.useRef(null),[m,h]=s.useState(!1),[p,b]=s.useState(!1),[E,v]=s.useState(!1),[j,g]=s.useState(!1),$=s.useRef(t);s.useEffect(()=>{$.current=t});const L=s.useCallback(async()=>{if(!(j||m))try{let k;{const S=localStorage.getItem("auth-token");if(!S){console.error("No authentication token found for Codex WebSocket connection");return}k=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/codex?token=${encodeURIComponent(S)}`}i.current=new WebSocket(k),i.current.onopen=()=>{h(!0),g(!1),setTimeout(()=>{c.current&&n.current&&(c.current.fit(),i.current.send(JSON.stringify({type:"init",projectPath:$.current.fullPath||$.current.path,cols:n.current.cols,rows:n.current.rows})))},100)},i.current.onmessage=S=>{try{const A=JSON.parse(S.data);A.type==="output"?n.current&&n.current.write(A.data):A.type==="url_open"&&window.open(A.url,"_blank")}catch(A){console.error("[CodexShell] Error handling WebSocket message:",A)}},i.current.onclose=()=>{h(!1),g(!1),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H"))},i.current.onerror=()=>{h(!1),g(!1)}}catch{h(!1),g(!1)}},[j,m]),I=s.useCallback(()=>{!p||m||j||(g(!0),L())},[p,m,j,L]),C=s.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),g(!1)},[]),x=()=>{v(!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,c.current=null),h(!1),b(!1),setTimeout(()=>v(!1),200)};return s.useEffect(()=>{if(!o.current||!t||E||n.current)return;n.current=new ea.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"}}),c.current=new ta.FitAddon;const d=new ra.WebglAddon,k=new sa.WebLinksAddon;n.current.loadAddon(c.current),n.current.loadAddon(k);try{n.current.loadAddon(d)}catch{console.warn("[CodexShell] WebGL renderer unavailable, using Canvas fallback")}n.current.open(o.current),n.current.attachCustomKeyEventHandler(A=>(A.ctrlKey||A.metaKey)&&A.key==="c"&&n.current.hasSelection()?(document.execCommand("copy"),!1):(A.ctrlKey||A.metaKey)&&A.key==="v"?(navigator.clipboard.readText().then(W=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:W}))}).catch(()=>{}),!1):!0),setTimeout(()=>{c.current&&(c.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),b(!0),n.current.onData(A=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:A}))});const S=new ResizeObserver(()=>{c.current&&n.current&&setTimeout(()=>{c.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&&S.observe(o.current),()=>{S.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,E]),s.useEffect(()=>{!a||!p||j||m||I()},[a,p,j,m,I]),t?r?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 ${m?"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:"(正在初始化...)"}),E&&e.jsx("span",{className:"text-xs text-blue-400",children:"(正在重启...)"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[m&&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:x,disabled:E||m,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&&!m&&!j&&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:I,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"]})]})}),j&&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 ai({project:t,autoConnect:r=!0,onClose:a=null,className:o="",showHeader:n=!0,minimal:c=!1}){return t?e.jsxs("div",{className:`h-full w-full flex flex-col ${o}`,children:[!c&&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(si,{selectedProject:t,minimal:c,autoConnect:c?!0:r})})]}):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 需要一个项目"})]})})}class ni extends Xe.Component{constructor(r){super(r),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(r){return{hasError:!0}}componentDidCatch(r,a){console.error("ErrorBoundary caught an error:",r,a),this.setState({error:r,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 ar=({children:t,content:r,position:a="top",className:o="",delay:n=500})=>{const[c,i]=s.useState(!1),[m,h]=s.useState(null),p=()=>{const j=setTimeout(()=>{i(!0)},n);h(j)},b=()=>{m&&(clearTimeout(m),h(null)),i(!1)},E=()=>{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"}},v=()=>{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 r?e.jsxs("div",{className:"relative inline-block",onMouseEnter:p,onMouseLeave:b,children:[t,c&&e.jsxs("div",{className:Fe("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",E(),o),children:[r,e.jsx("div",{className:Fe("absolute w-0 h-0 border-4 border-transparent",v())})]})]}):t};function oi({selectedProject:t,selectedSession:r,activeTab:a,setActiveTab:o,ws:n,sendMessage:c,messages:i,isMobile:m,isPWA:h,onMenuClick:p,isLoading:b,onInputFocusChange:E,onSessionActive:v,onSessionInactive:j,onSessionProcessing:g,onSessionNotProcessing:$,processingSessions:L,onReplaceTemporarySession:I,onNavigateToSession:C,onShowSettings:x,autoExpandTools:d,showRawParameters:k,showThinking:S,autoScrollToBottom:A,sendByCtrlEnter:W,externalMessageUpdate:O,limitStatus:Q,onLimitBlocked:ie,checkLimitStatus:Z}){const[se,B]=s.useState(null),[T,z]=s.useState(600),[Y,pe]=s.useState(!1),[ae,G]=s.useState(!1),xe=s.useRef(null);s.useEffect(()=>{a==="shell"&&Z&&Z()},[a,Z]);const Ne=(he,Se=null)=>{const ke={name:he.split("/").pop(),path:he,projectName:t?.name,diffInfo:Se};B(ke)},Ce=()=>{B(null),G(!1)},je=()=>{G(!ae)},_e=he=>{m||(pe(!0),he.preventDefault())};return s.useEffect(()=>{const he=ke=>{if(!Y)return;const Ee=xe.current?.parentElement;if(!Ee)return;const ye=Ee.getBoundingClientRect(),Pe=ye.right-ke.clientX,Re=300,Me=ye.width*.8;Pe>=Re&&Pe<=Me&&z(Pe)},Se=()=>{pe(!1)};return Y&&(document.addEventListener("mousemove",he),document.addEventListener("mouseup",Se),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",Se),document.body.style.cursor="",document.body.style.userSelect=""}},[Y]),b?e.jsxs("div",{className:"h-full flex flex-col",children:[m&&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:[m&&e.jsx("button",{onClick:p,onTouchStart:he=>{he.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"&&r&&e.jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:e.jsx(ot,{className:"w-4 h-4"})}),e.jsx("div",{className:"min-w-0 flex-1",children:a==="chat"&&r?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:r.summary||"新会话"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.displayName})]}):a==="chat"&&!r?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(ar,{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(ar,{content:Q&&!Q.allowed?"使用已达上限":"Shell",position:"bottom",children:e.jsx("button",{onClick:()=>{if(Q&&!Q.allowed){ie?.(Q.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 ${Q&&!Q.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",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("span",{className:"hidden md:hidden lg:inline",children:"Shell"})]})})}),e.jsx(ar,{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(ar,{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:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Codex"})]})})})]})})]})}),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 ${se?"mr-0":""} ${ae?"hidden":""}`,children:[e.jsx("div",{className:`h-full ${a==="chat"?"block":"hidden"}`,children:e.jsx(ni,{showDetails:!0,children:e.jsx(Qo,{selectedProject:t,selectedSession:r,ws:n,sendMessage:c,messages:i,onFileOpen:Ne,onInputFocusChange:E,onSessionActive:v,onSessionInactive:j,onSessionProcessing:g,onSessionNotProcessing:$,processingSessions:L,onReplaceTemporarySession:I,onNavigateToSession:C,onShowSettings:x,autoExpandTools:d,showRawParameters:k,showThinking:S,autoScrollToBottom:A,sendByCtrlEnter:W,externalMessageUpdate:O,limitStatus:Q,onLimitExceeded:ie,checkLimitStatus:Z})})}),a==="files"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(Xo,{selectedProject:t})}),a==="shell"&&e.jsxs("div",{className:"h-full w-full overflow-hidden relative",children:[e.jsx(ri,{project:t,session:r,showHeader:!1}),Q&&!Q.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:Q.reason==="total_limit_exceeded"?"使用上限已达到":"今日使用上限已达到"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:Q.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(ai,{project:t,showHeader:!1})}),e.jsx("div",{className:`h-full overflow-hidden ${a==="preview"?"block":"hidden"}`})]}),se&&!m&&e.jsxs(e.Fragment,{children:[!ae&&e.jsx("div",{ref:xe,onMouseDown:_e,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 ${ae?"flex-1":""}`,style:ae?{}:{width:`${T}px`},children:e.jsx(Ur,{file:se,onClose:Ce,projectPath:t?.path,isSidebar:!0,isExpanded:ae,onToggleExpand:je})})]})]}),se&&m&&e.jsx(Ur,{file:se,onClose:Ce,projectPath:t?.path,isSidebar:!1})]}):e.jsxs("div",{className:"h-full flex flex-col",children:[m&&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:"提示:"})," ",m?"点击上方菜单按钮访问项目":"点击侧边栏中的文件夹图标创建新项目"]})})]})})]})}const ii=Xe.memo(oi);function li({activeTab:t,setActiveTab:r,isInputFocused:a}){const o=[{id:"chat",icon:Dt,onClick:()=>r("chat")},{id:"shell",icon:mr,onClick:()=>r("shell")},{id:"files",icon:rt,onClick:()=>r("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 c=n.icon,i=t===n.id;return e.jsxs("button",{onClick:n.onClick,onTouchStart:m=>{m.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(c,{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 aa=s.createContext(),Yr=()=>{const t=s.useContext(aa);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t},ci=({children:t})=>{const[r,a]=s.useState(()=>{const c=localStorage.getItem("theme");return c?c==="dark":window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1});s.useEffect(()=>{if(r){document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark");const c=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');c&&c.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 c=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');c&&c.setAttribute("content","default");const i=document.querySelector('meta[name="theme-color"]');i&&i.setAttribute("content","#ffffff")}},[r]),s.useEffect(()=>{if(!window.matchMedia)return;const c=window.matchMedia("(prefers-color-scheme: dark)"),i=m=>{localStorage.getItem("theme")||a(m.matches)};return c.addEventListener("change",i),()=>c.removeEventListener("change",i)},[]);const n={isDarkMode:r,toggleDarkMode:()=>{a(c=>!c)}};return e.jsx(aa.Provider,{value:n,children:t})},na=s.createContext({user:null,token:null,login:()=>{},sendCode:()=>{},verifyCode:()=>{},logout:()=>{},isLoading:!0,needsSetup:!1,smtpConfigured:!1,error:null,isAdmin:!1,limitStatus:{allowed:!0},checkLimitStatus:()=>{},setLimitStatus:()=>{}}),$t=()=>{const t=s.useContext(na);if(!t)throw new Error("useAuth must be used within an AuthProvider");return t},di=({children:t})=>{const[r,a]=s.useState(null),[o,n]=s.useState(localStorage.getItem("auth-token")),[c,i]=s.useState(!0),[m,h]=s.useState(!1),[p,b]=s.useState(!1),[E,v]=s.useState(null),[j,g]=s.useState({allowed:!0});s.useEffect(()=>{$()},[]);const $=async()=>{try{i(!0),v(null);const A=await(await we.auth.status()).json();if(b(A.smtpConfigured||!1),A.needsSetup){h(!0),i(!1);return}if(o)try{const W=await we.auth.user();if(W.ok){const O=await W.json();a(O.user),h(!1)}else localStorage.removeItem("auth-token"),n(null),a(null)}catch(W){console.error("Token verification failed:",W),localStorage.removeItem("auth-token"),n(null),a(null)}}catch(S){console.error("[AuthContext] Auth status check failed:",S),v("Failed to check authentication status")}finally{i(!1)}},L=async S=>{try{v(null);const A=await we.auth.sendCode(S),W=await A.json();return A.ok?{success:!0,type:W.type}:{success:!1,error:W.error||"发送验证码失败",waitSeconds:W.waitSeconds}}catch(A){return console.error("Send code error:",A),{success:!1,error:"网络错误,请稍后再试"}}},I=async(S,A)=>{try{v(null);const W=await we.auth.verifyCode(S,A),O=await W.json();return W.ok?(n(O.token),a(O.user),h(!1),localStorage.setItem("auth-token",O.token),{success:!0}):(v(O.error||"验证失败"),{success:!1,error:O.error||"验证失败"})}catch(W){return console.error("Verify code error:",W),{success:!1,error:"网络错误,请稍后再试"}}},C=async(S,A)=>{try{v(null);const W=await we.auth.login(S,A),O=await W.json();return W.ok?(n(O.token),a(O.user),localStorage.setItem("auth-token",O.token),{success:!0}):(v(O.error||"登录失败"),{success:!1,error:O.error||"登录失败"})}catch(W){console.error("Login error:",W);const O="网络错误,请稍后再试";return v(O),{success:!1,error:O}}},x=()=>{n(null),a(null),g({allowed:!0}),localStorage.removeItem("auth-token"),o&&we.auth.logout().catch(S=>{console.error("Logout endpoint error:",S)})},d=async()=>{if(!r)return{allowed:!0};try{const S=await we.auth.limitStatus();if(S.ok){const A=await S.json();return g(A),A}}catch(S){console.error("Error checking limit status:",S)}return{allowed:!0}};s.useEffect(()=>{r&&!c&&d()},[r,c]);const k={user:r,token:o,login:C,sendCode:L,verifyCode:I,logout:x,isLoading:c,needsSetup:m,smtpConfigured:p,error:E,isAdmin:r?.role==="admin",limitStatus:j,checkLimitStatus:d,setLimitStatus:g};return e.jsx(na.Provider,{value:k,children:t})},mi=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],ui=["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 pi({skipPermissions:t,setSkipPermissions:r,allowedTools:a,setAllowedTools:o,disallowedTools:n,setDisallowedTools:c,newAllowedTool:i,setNewAllowedTool:m,newDisallowedTool:h,setNewDisallowedTool:p}){const b=g=>{g&&!a.includes(g)&&(o([...a,g]),m(""))},E=g=>{o(a.filter($=>$!==g))},v=g=>{g&&!n.includes(g)&&(c([...n,g]),p(""))},j=g=>{c(n.filter($=>$!==g))};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(As,{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(Pt,{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:g=>r(g.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(ur,{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(Ke,{value:i,onChange:g=>m(g.target.value),placeholder:'e.g., "Bash(git log:*)" or "Write"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),b(i))},className:"flex-1 h-10"}),e.jsxs(J,{onClick:()=>b(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{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:mi.map(g=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>b(g),disabled:a.includes(g),className:"text-xs h-8",children:g},g))})]}),e.jsxs("div",{className:"space-y-2",children:[a.map(g=>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:g}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>E(g),className:"text-green-600 hover:text-green-700",children:e.jsx(Oe,{className:"w-4 h-4"})})]},g)),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(Pt,{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(Ke,{value:h,onChange:g=>p(g.target.value),placeholder:'e.g., "Bash(rm:*)"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),v(h))},className:"flex-1 h-10"}),e.jsxs(J,{onClick:()=>v(h),disabled:!h,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{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(g=>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:g}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>j(g),className:"text-red-600 hover:text-red-700",children:e.jsx(Oe,{className:"w-4 h-4"})})]},g)),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 xi({skipPermissions:t,setSkipPermissions:r,allowedCommands:a,setAllowedCommands:o,disallowedCommands:n,setDisallowedCommands:c,newAllowedCommand:i,setNewAllowedCommand:m,newDisallowedCommand:h,setNewDisallowedCommand:p}){const b=g=>{g&&!a.includes(g)&&(o([...a,g]),m(""))},E=g=>{o(a.filter($=>$!==g))},v=g=>{g&&!n.includes(g)&&(c([...n,g]),p(""))},j=g=>{c(n.filter($=>$!==g))};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(Pt,{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:g=>r(g.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(ur,{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(Ke,{value:i,onChange:g=>m(g.target.value),placeholder:'e.g., "Shell(ls)" or "Shell(git status)"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),b(i))},className:"flex-1 h-10"}),e.jsxs(J,{onClick:()=>b(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{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:ui.map(g=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>b(g),disabled:a.includes(g),className:"text-xs h-8",children:g},g))})]}),e.jsxs("div",{className:"space-y-2",children:[a.map(g=>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:g}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>E(g),className:"text-green-600 hover:text-green-700",children:e.jsx(Oe,{className:"w-4 h-4"})})]},g)),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(Pt,{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(Ke,{value:h,onChange:g=>p(g.target.value),placeholder:'e.g., "Shell(rm -rf)" or "Shell(sudo)"',onKeyPress:g=>{g.key==="Enter"&&(g.preventDefault(),v(h))},className:"flex-1 h-10"}),e.jsxs(J,{onClick:()=>v(h),disabled:!h,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{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(g=>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:g}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>j(g),className:"text-red-600 hover:text-red-700",children:e.jsx(Oe,{className:"w-4 h-4"})})]},g)),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 hi({permissionMode:t,setPermissionMode:r}){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(ur,{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:()=>r("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:()=>r("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:()=>r("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:()=>r("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:()=>r("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:()=>r("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(Pt,{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 gi({agent:t,...r}){return t==="claude"?e.jsx(pi,{...r}):t==="cursor"?e.jsx(xi,{...r}):t==="codex"?e.jsx(hi,{...r}):null}const fi=t=>{switch(t){case"stdio":return e.jsx(mr,{className:"w-4 h-4"});case"sse":return e.jsx(sn,{className:"w-4 h-4"});case"http":return e.jsx(Tr,{className:"w-4 h-4"});default:return e.jsx(pr,{className:"w-4 h-4"})}};function bi({servers:t,onAdd:r,onEdit:a,onDelete:o,onTest:n,onDiscoverTools:c,testResults:i,serverTools:m,toolsLoading:h}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pr,{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(J,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(st,{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:[fi(p.type),e.jsx("span",{className:"font-medium text-foreground",children:p.name}),e.jsx(Ge,{variant:"outline",className:"text-xs",children:p.type}),e.jsx(Ge,{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})}),m?.[p.id]&&m[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:["工具(",m[p.id].tools.length,"):"]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[m[p.id].tools.slice(0,5).map((b,E)=>e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:b.name},E)),m[p.id].tools.length>5&&e.jsxs("span",{className:"text-xs opacity-75",children:["+",m[p.id].tools.length-5," 更多"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(J,{onClick:()=>a(p),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"编辑服务器",children:e.jsx(Ht,{className:"w-4 h-4"})}),e.jsx(J,{onClick:()=>o(p.id,p.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"删除服务器",children:e.jsx(Ve,{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 yi({servers:t,onAdd:r,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(pr,{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(J,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(st,{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(mr,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:n.name}),e.jsx(Ge,{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(J,{onClick:()=>a(n),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",children:e.jsx(Ht,{className:"w-4 h-4"})}),e.jsx(J,{onClick:()=>o(n.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",children:e.jsx(Ve,{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 vi({servers:t,onAdd:r,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(pr,{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(J,{onClick:r,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[e.jsx(st,{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(mr,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:n.name}),e.jsx(Ge,{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(([c,i])=>`${c}=${i}`).join(", ")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(J,{onClick:()=>a(n),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"编辑服务器",children:e.jsx(Ht,{className:"w-4 h-4"})}),e.jsx(J,{onClick:()=>o(n.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"删除服务器",children:e.jsx(Ve,{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 ji({agent:t,...r}){return t==="claude"?e.jsx(bi,{...r}):t==="cursor"?e.jsx(yi,{...r}):t==="codex"?e.jsx(vi,{...r}):null}const wi=[{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)使用的模型"}];function ki(){const[t,r]=s.useState({}),[a,o]=s.useState({}),[n,c]=s.useState(!0),[i,m]=s.useState(!1),[h,p]=s.useState(null),[b,E]=s.useState(null);s.useEffect(()=>{v()},[]),s.useEffect(()=>{if(h){const L=setTimeout(()=>p(null),3e3);return()=>clearTimeout(L)}},[h]);const v=async()=>{try{c(!0),E(null);const L=await ne("/api/settings/models");if(L.ok){const I=await L.json();r(I.models||{}),o(I.models||{})}else{const I=await L.json();E(I.error||"加载模型配置失败")}}catch(L){E(L.message)}finally{c(!1)}},j=async()=>{try{m(!0),p(null);const L=await ne("/api/settings/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:t})});if(L.ok)p("success"),o({...t});else{const I=await L.json();p("error"),E(I.error||"保存失败")}}catch(L){p("error"),E(L.message)}finally{m(!1)}},g=()=>{r({...a}),p(null)},$=JSON.stringify(t)!==JSON.stringify(a);return n?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(As,{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。"})]})]}),b&&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:b}),wi.map(L=>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:L.label}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:L.description})]}),e.jsx("input",{type:"text",value:t[L.key]||"",onChange:I=>r(C=>({...C,[L.key]:I.target.value})),placeholder:L.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:L.key})]})},L.key)),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("div",{children:[h==="success"&&e.jsx("span",{className:"text-sm text-green-600 dark:text-green-400",children:"模型配置已保存"}),h==="error"&&e.jsx("span",{className:"text-sm text-red-600 dark:text-red-400",children:"保存失败"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:g,disabled:!$,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-gray-300 dark:border-gray-600 text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(an,{className:"w-3.5 h-3.5"}),"重置"]}),e.jsxs("button",{onClick:j,disabled:!$||i,className:"inline-flex items-center gap-1.5 px-4 py-1.5 text-sm rounded-lg bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(Rs,{className:"w-3.5 h-3.5"}),i?"保存中...":"保存"]})]})]})]})}function Ni({onNavigateToUsage:t}){const[r,a]=s.useState([]),[o,n]=s.useState({}),[c,i]=s.useState(!0),[m,h]=s.useState(null),[p,b]=s.useState(!1),[E,v]=s.useState(""),[j,g]=s.useState(""),[$,L]=s.useState(""),[I,C]=s.useState(!1),[x,d]=s.useState(null),[k,S]=s.useState({total_limit_usd:"",daily_limit_usd:""}),[A,W]=s.useState(""),[O,Q]=s.useState(!1),[ie,Z]=s.useState(null),[se,B]=s.useState(""),[T,z]=s.useState(""),[Y,pe]=s.useState(""),[ae,G]=s.useState(!1),xe=async()=>{try{const f=await ne("/api/admin/users");if(f.ok){const y=await f.json();a(y.users)}}catch(f){console.error("Error fetching users:",f)}finally{i(!1)}},Ne=async()=>{try{const f=await ne("/api/admin/usage/summary");if(f.ok){const y=await f.json(),F={};for(const oe of y.users)F[oe.user_uuid]={total_cost:oe.total_cost||0,total_requests:oe.total_requests||0,last_active:oe.last_active};n(F)}}catch(f){console.error("Error fetching usage data:",f)}};s.useEffect(()=>{xe(),Ne()},[]);const Ce=f=>!f||f===0?"$0.00":f<.01?`$${f.toFixed(4)}`:`$${f.toFixed(2)}`,je=async(f,y)=>{const F=y==="active"?"disabled":"active";h(f);try{(await ne(`/api/admin/users/${f}`,{method:"PATCH",body:JSON.stringify({status:F})})).ok&&a(r.map(ue=>ue.id===f?{...ue,status:F}:ue))}catch(oe){console.error("Error updating user status:",oe)}finally{h(null)}},_e=async(f,y)=>{if(confirm(`确定要删除用户 "${y}"?这将删除其所有数据。`)){h(f);try{(await ne(`/api/admin/users/${f}`,{method:"DELETE"})).ok&&a(r.filter(oe=>oe.id!==f))}catch(F){console.error("Error deleting user:",F)}finally{h(null)}}},he=async f=>{if(f.preventDefault(),L(""),!E||!j){L("用户名和密码不能为空");return}if(E.length<3){L("用户名至少3个字符");return}if(j.length<6){L("密码至少6个字符");return}C(!0);try{const y=await we.admin.createUser(E,j),F=await y.json();y.ok?(await xe(),b(!1),v(""),g("")):L(F.error||"创建用户失败")}catch(y){console.error("Error creating user:",y),L("网络错误,请稍后再试")}finally{C(!1)}},Se=()=>{b(!1),v(""),g(""),L("")},ke=f=>{d(f),S({total_limit_usd:f.total_limit_usd!==null&&f.total_limit_usd!==void 0?String(f.total_limit_usd):"",daily_limit_usd:f.daily_limit_usd!==null&&f.daily_limit_usd!==void 0?String(f.daily_limit_usd):""}),W("")},Ee=()=>{d(null),S({total_limit_usd:"",daily_limit_usd:""}),W("")},ye=async f=>{f.preventDefault(),W("");const y=k.total_limit_usd.trim()===""?null:parseFloat(k.total_limit_usd),F=k.daily_limit_usd.trim()===""?null:parseFloat(k.daily_limit_usd);if(y!==null&&(isNaN(y)||y<0)){W("总额度限制必须是正数或留空");return}if(F!==null&&(isNaN(F)||F<0)){W("每日额度限制必须是正数或留空");return}Q(!0);try{const oe=await we.admin.updateUserLimits(x.id,{total_limit_usd:y,daily_limit_usd:F}),ue=await oe.json();oe.ok?(a(r.map(Le=>Le.id===x.id?{...Le,total_limit_usd:y,daily_limit_usd:F}:Le)),Ee()):W(ue.error||"更新限制失败")}catch(oe){console.error("Error updating limits:",oe),W("网络错误,请稍后再试")}finally{Q(!1)}},Pe=f=>f==null?"无限制":`$${f.toFixed(2)}`,Re=f=>{Z(f),B(""),z(""),pe("")},Me=()=>{Z(null),B(""),z(""),pe("")},H=async f=>{if(f.preventDefault(),pe(""),!se){pe("请输入新密码");return}if(se.length<6){pe("密码至少需要6个字符");return}if(se!==T){pe("两次输入的密码不一致");return}G(!0);try{const y=await we.admin.resetUserPassword(ie.id,se),F=await y.json();y.ok?Me():pe(F.error||"重置密码失败")}catch(y){console.error("Error resetting password:",y),pe("网络错误,请稍后再试")}finally{G(!1)}};return c?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(J,{variant:"default",size:"sm",onClick:()=>b(!0),className:"flex items-center gap-2",children:[e.jsx(nn,{className:"w-4 h-4"}),"创建用户"]}),t&&e.jsxs(J,{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:r.map(f=>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:[f.role==="admin"?e.jsx(ur,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):e.jsx(Fs,{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:f.username||f.email}),f.email&&f.username&&e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:f.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 ${f.role==="admin"?"bg-blue-500/20 text-blue-400":"bg-gray-500/20 text-gray-400"}`,children:f.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 ${f.status==="active"?"bg-green-500":"bg-red-500"}`,title:f.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:Ce(o[f.uuid]?.total_cost)})}),e.jsx("td",{className:"px-3 py-2 text-right",children:f.role!=="admin"?e.jsx("button",{onClick:()=>ke(f),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline font-mono whitespace-nowrap",title:"点击编辑额度限制",children:f.total_limit_usd!==null||f.daily_limit_usd!==null?e.jsxs("span",{className:"flex flex-col items-end text-[11px] leading-tight",children:[e.jsxs("span",{children:["总:",Pe(f.total_limit_usd)]}),e.jsxs("span",{children:["日:",Pe(f.daily_limit_usd)]})]}):e.jsxs("span",{className:"flex items-center gap-1 justify-end",children:[e.jsx(Os,{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(f.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("div",{className:"flex items-center justify-end gap-1",children:f.role!=="admin"&&e.jsxs(e.Fragment,{children:[f.username&&e.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>Re(f),disabled:m===f.id,title:"重置密码",children:e.jsx(Ws,{className:"w-4 h-4 text-blue-500"})}),e.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>je(f.id,f.status),disabled:m===f.id,title:f.status==="active"?"禁用用户":"启用用户",children:f.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(J,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>_e(f.id,f.username||f.email),disabled:m===f.id,title:"删除用户",children:e.jsx(Ve,{className:"w-4 h-4 text-red-500"})})]})})})]},f.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(Oe,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:he,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:E,onChange:f=>v(f.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:I})]}),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:j,onChange:f=>g(f.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:I})]}),$&&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:$})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{type:"button",variant:"outline",onClick:Se,disabled:I,children:"取消"}),e.jsx(J,{type:"submit",disabled:I,children:I?"创建中...":"创建"})]})]})]})}),x&&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:["设置额度限制 - ",x.username||x.email]}),e.jsx("button",{onClick:Ee,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Oe,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:ye,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:k.total_limit_usd,onChange:f=>S(y=>({...y,total_limit_usd:f.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:k.daily_limit_usd,onChange:f=>S(y=>({...y,daily_limit_usd:f.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[x.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:Ce(o[x.uuid]?.total_cost)})]})}),A&&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:A})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{type:"button",variant:"outline",onClick:Ee,disabled:O,children:"取消"}),e.jsx(J,{type:"submit",disabled:O,children:O?"保存中...":"保存"})]})]})]})}),ie&&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:["重置密码 - ",ie.username]}),e.jsx("button",{onClick:Me,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Oe,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:H,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:se,onChange:f=>B(f.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:ae})]}),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:T,onChange:f=>z(f.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:ae})]}),Y&&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:Y})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{type:"button",variant:"outline",onClick:Me,disabled:ae,children:"取消"}),e.jsx(J,{type:"submit",disabled:ae,children:ae?"重置中...":"重置密码"})]})]})]})})]})}function Si(){const[t,r]=s.useState([]),[a,o]=s.useState(!0),[n,c]=s.useState(null),[i,m]=s.useState(!1),[h,p]=s.useState(""),[b,E]=s.useState(""),[v,j]=s.useState(!1),g=async()=>{try{const C=await we.admin.getEmailDomains();if(C.ok){const x=await C.json();r(x.domains)}}catch(C){console.error("Error fetching email domains:",C)}finally{o(!1)}};s.useEffect(()=>{g()},[]);const $=async C=>{if(C.preventDefault(),E(""),!h){E("域名不能为空");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)){E("域名格式无效,例如: example.com");return}j(!0);try{const d=await we.admin.addEmailDomain(h.toLowerCase()),k=await d.json();d.ok?(await g(),m(!1),p("")):E(k.error||"添加域名失败")}catch(d){console.error("Error adding domain:",d),E("网络错误,请稍后再试")}finally{j(!1)}},L=async(C,x)=>{if(confirm(`确定要删除域名 "${x}"?删除后该域名的邮箱将无法注册。`)){c(C);try{(await we.admin.removeEmailDomain(C)).ok&&r(t.filter(k=>k.id!==C))}catch(d){console.error("Error removing domain:",d)}finally{c(null)}}},I=()=>{m(!1),p(""),E("")};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(J,{variant:"default",size:"sm",onClick:()=>m(!0),className:"flex items-center gap-2",children:[e.jsx(st,{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(ir,{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(J,{variant:"ghost",size:"sm",onClick:()=>L(C.id,C.domain),disabled:n===C.id,title:"删除域名",children:e.jsx(Ve,{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(ir,{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:I,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Oe,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:$,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:v}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"输入域名后,该域名下的所有邮箱(如 user@example.com)都可以注册"})]}),b&&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:b})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{type:"button",variant:"outline",onClick:I,disabled:v,children:"取消"}),e.jsx(J,{type:"submit",disabled:v,children:v?"添加中...":"添加"})]})]})]})})]})}function Ci({onBack:t}){const[r,a]=s.useState("week"),[o,n]=s.useState(null),[c,i]=s.useState(!0),[m,h]=s.useState(!1),p=async()=>{try{const I=await ne(`/api/admin/usage/dashboard?period=${r}`);if(I.ok){const C=await I.json();n(C)}}catch(I){console.error("Error fetching dashboard data:",I)}finally{i(!1),h(!1)}};s.useEffect(()=>{i(!0),p()},[r]);const b=async()=>{try{h(!0),await ne("/api/admin/usage/scan",{method:"POST"}),await p()}catch(I){console.error("Error triggering scan:",I),h(!1)}},E=I=>!I||I===0?"$0.00":I<.01?`$${I.toFixed(4)}`:`$${I.toFixed(2)}`,v=I=>I?I>=1e6?`${(I/1e6).toFixed(1)}M`:I>=1e3?`${(I/1e3).toFixed(1)}K`:I.toString():"0";if(c)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"text-muted-foreground",children:"加载仪表板中..."})});const{totals:j,dailyTrend:g,modelDistribution:$,topUsers:L}=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(J,{variant:"ghost",size:"sm",onClick:t,children:[e.jsx(xr,{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(I=>e.jsx("button",{onClick:()=>a(I),className:`px-4 py-2 text-sm font-medium transition-colors ${r===I?"bg-primary text-primary-foreground":"bg-background text-foreground hover:bg-muted"}`,children:I==="week"?"周":"月"},I))}),e.jsx(J,{variant:"outline",size:"sm",onClick:b,disabled:m,title:"扫描新的使用数据",children:e.jsx(or,{className:`w-4 h-4 ${m?"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(Os,{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:E(j?.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:[j?.activeUsers||0," / ",j?.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(Dt,{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:v(j?.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:v(j?.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:"每日成本趋势"}),g&&g.length>0?e.jsx("div",{className:"space-y-2",children:g.map(I=>{const C=Math.max(...g.map(d=>d.cost||0),.01),x=(I.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(I.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:`${x}%`}})}),e.jsx("span",{className:"text-sm font-mono text-foreground w-16 text-right",children:E(I.cost)})]},I.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:"模型成本"}),$&&$.length>0?e.jsx("div",{className:"space-y-3",children:$.map(I=>{const C=$.reduce((A,W)=>A+(W.cost||0),0)||1,x=(I.cost||0)/C*100,d=(I.normalized_model||I.model||"").toLowerCase(),S=(A=>A.includes("codex")?"bg-orange-500":A.includes("opus")?"bg-purple-500":A.includes("sonnet")?"bg-blue-500":A.includes("haiku")?"bg-green-500":"bg-gray-500")(d);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(Ge,{variant:"secondary",className:"truncate max-w-[200px]",title:I.model,children:I.model}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[v(I.requests)," 请求"]})]}),e.jsx("span",{className:"text-sm font-mono text-foreground whitespace-nowrap ml-2",children:E(I.cost)})]}),e.jsx("div",{className:"h-2 bg-gray-100 dark:bg-gray-800 rounded overflow-hidden",children:e.jsx("div",{className:`h-full ${S} rounded`,style:{width:`${x}%`}})})]},I.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:"用户成本"}),L&&L.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:L.map((I,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:I.username}),e.jsx("td",{className:"py-2 text-sm text-right text-muted-foreground",children:v(I.total_requests)}),e.jsx("td",{className:"py-2 text-sm text-right font-mono text-foreground",children:E(I.total_cost)})]},I.user_uuid))})]})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"无可用的使用数据"})]})]})}function Ei({onClose:t,onInstalled:r,onOpenRepoManager:a}){const[o,n]=s.useState([]),[c,i]=s.useState([]),[m,h]=s.useState(!0),[p,b]=s.useState(null),[E,v]=s.useState(""),[j,g]=s.useState("all"),[$,L]=s.useState(null);s.useEffect(()=>{I()},[]);const I=async()=>{try{h(!0),b(null);const[d,k]=await Promise.all([ne("/api/skills/available"),ne("/api/skills/repos")]);if(d.ok){const S=await d.json();n(S.skills||[])}if(k.ok){const S=await k.json();i(S.repos||[])}}catch(d){b(d.message)}finally{h(!1)}},C=async d=>{try{L(d.name);const k=await ne(`/api/skills/install/${d.name}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({skillPath:d.path})});if(k.ok)I(),r?.();else{const S=await k.json();alert(S.error||"Failed to install skill")}}catch(k){alert(k.message)}finally{L(null)}},x=o.filter(d=>{if(E){const k=E.toLowerCase();if(!d.name.toLowerCase().includes(k)&&!d.title?.toLowerCase().includes(k)&&!d.description?.toLowerCase().includes(k))return!1}return!(j!=="all"&&d.repository!==j)});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(J,{variant:"ghost",size:"sm",onClick:I,disabled:m,children:[e.jsx(or,{className:`w-4 h-4 ${m?"animate-spin":""}`}),e.jsx("span",{className:"ml-1 hidden sm:inline",children:"刷新"})]}),e.jsxs(J,{variant:"ghost",size:"sm",onClick:a,children:[e.jsx(Tt,{className:"w-4 h-4"}),e.jsx("span",{className:"ml-1 hidden sm:inline",children:"仓库管理"})]}),e.jsx(J,{variant:"ghost",size:"icon",onClick:t,children:e.jsx(Oe,{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(It,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Ke,{type:"text",placeholder:"搜索技能名称或描述...",value:E,onChange:d=>v(d.target.value),className:"pl-10"})]})}),e.jsxs("select",{value:j,onChange:d=>g(d.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:"全部"}),c.map(d=>e.jsxs("option",{value:`${d.owner}/${d.repo}`,children:[d.owner,"/",d.repo]},`${d.owner}/${d.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}),m?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"加载中..."}):x.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(J,{variant:"outline",size:"sm",className:"mt-4",onClick:a,children:[e.jsx(Tt,{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:x.map(d=>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:d.title||d.name}),e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["skills/",d.name]}),e.jsx(Ge,{variant:"outline",className:"text-xs ml-2",children:d.repository})]})]}),d.description&&e.jsx("p",{className:"text-sm text-muted-foreground flex-1 line-clamp-3 mb-3",children:d.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-auto pt-2",children:[e.jsxs(J,{variant:"ghost",size:"sm",onClick:()=>window.open(`https://github.com/${d.repository}`,"_blank"),children:[e.jsx(Bs,{className:"w-4 h-4 mr-1"}),"查看"]}),d.installed?e.jsx(J,{size:"sm",disabled:!0,variant:"outline",className:"ml-auto",children:"已安装"}):e.jsxs(J,{size:"sm",className:"bg-amber-600 hover:bg-amber-700 text-white ml-auto",onClick:()=>C(d),disabled:$===d.name,children:[e.jsx(qr,{className:"w-4 h-4 mr-1"}),$===d.name?"安装中...":"安装"]})]})]})},`${d.repository}-${d.name}`))})]})]})})}function Mi({onClose:t,onChanged:r}){const[a,o]=s.useState([]),[n,c]=s.useState(!0),[i,m]=s.useState(null),[h,p]=s.useState(""),[b,E]=s.useState("main"),[v,j]=s.useState(!1),[g,$]=s.useState(null);s.useEffect(()=>{L()},[]);const L=async()=>{try{c(!0),m(null);const x=await ne("/api/skills/repos");if(x.ok){const d=await x.json();o(d.repos||[])}else{const d=await x.json();m(d.error||"Failed to fetch repos")}}catch(x){m(x.message)}finally{c(!1)}},I=async x=>{if(x.preventDefault(),!h.trim()){m("请输入仓库 URL");return}try{j(!0),m(null);const d=await ne("/api/skills/repos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:h.trim(),branch:b.trim()||"main"})});if(d.ok)p(""),E("main"),L(),r?.();else{const k=await d.json();m(k.error||"Failed to add repo")}}catch(d){m(d.message)}finally{j(!1)}},C=async(x,d)=>{if(confirm(`确定要移除仓库 "${x}/${d}" 吗?`))try{$(`${x}/${d}`);const k=await ne(`/api/skills/repos/${x}/${d}`,{method:"DELETE"});if(k.ok)L(),r?.();else{const S=await k.json();alert(S.error||"Failed to remove repo")}}catch(k){alert(k.message)}finally{$(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(J,{variant:"ghost",size:"icon",onClick:t,children:e.jsx(xr,{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:I,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(Ke,{type:"text",placeholder:"owner/name 或 https://github.com/owner/name",value:h,onChange:x=>p(x.target.value),disabled:v})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-muted-foreground mb-1",children:"分支"}),e.jsx(Ke,{type:"text",placeholder:"main",value:b,onChange:x=>E(x.target.value),disabled:v})]}),e.jsxs(J,{type:"submit",disabled:v||!h.trim(),className:"bg-amber-600 hover:bg-amber-700 text-white",children:[e.jsx(st,{className:"w-4 h-4 mr-2"}),v?"添加中...":"添加仓库"]})]})]}),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(x=>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:[x.owner,"/",x.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(Ge,{variant:"outline",className:"text-xs",children:["识别到 ",x.skillCount," 个技能"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>window.open(x.url,"_blank"),children:e.jsx(Bs,{className:"w-4 h-4"})}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>C(x.owner,x.repo),disabled:g===`${x.owner}/${x.repo}`,className:"text-red-500 hover:text-red-600",children:e.jsx(Ve,{className:"w-4 h-4"})})]})]})},`${x.owner}/${x.repo}`))]})]})]})})}function Li(){const[t,r]=s.useState([]),[a,o]=s.useState(!0),[n,c]=s.useState(null),[i,m]=s.useState(!1),[h,p]=s.useState(!1),[b,E]=s.useState(!1),v=s.useRef(null);s.useEffect(()=>{j()},[]);const j=async()=>{try{o(!0),c(null);const C=await ne("/api/skills");if(C.ok){const x=await C.json();r(x.skills||[])}else{const x=await C.json();c(x.error||"Failed to fetch skills")}}catch(C){c(C.message)}finally{o(!1)}},g=async C=>{if(confirm(`确定要删除技能 "${C}" 吗?`))try{const x=await ne(`/api/skills/${C}`,{method:"DELETE"});if(x.ok)j();else{const d=await x.json();alert(d.error||"Failed to delete skill")}}catch(x){alert(x.message)}},$=()=>{v.current?.click()},L=async C=>{const x=C.target.files?.[0];if(x)try{E(!0);const d=new FormData;d.append("skillZip",x);const k=await ne("/api/skills/import",{method:"POST",body:d});if(k.ok)j();else{const S=await k.json();alert(S.error||"Failed to import skill")}}catch(d){alert(d.message)}finally{E(!1),v.current&&(v.current.value="")}},I=(C,x)=>{switch(C){case"repo":return e.jsx(Ge,{variant:"outline",className:"text-xs bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300",children:x||"仓库"});case"imported":return e.jsx(Ge,{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(Ge,{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(Pr,{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:v,type:"file",accept:".zip",className:"hidden",onChange:L}),e.jsxs(J,{onClick:$,variant:"outline",size:"sm",disabled:b,children:[e.jsx(qr,{className:"w-4 h-4 mr-2"}),b?"导入中...":"导入已有"]}),e.jsxs(J,{onClick:()=>m(!0),className:"bg-amber-600 hover:bg-amber-700 text-white",size:"sm",children:[e.jsx(It,{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(Pr,{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}),I(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(J,{variant:"ghost",size:"sm",onClick:()=>g(C.name),className:"text-red-500 hover:text-red-600",title:"删除技能",children:e.jsx(Ve,{className:"w-4 h-4"})})})]})},C.name))}),i&&e.jsx(Ei,{onClose:()=>m(!1),onInstalled:j,onOpenRepoManager:()=>{m(!1),p(!0)}}),h&&e.jsx(Mi,{onClose:()=>p(!1),onChanged:()=>{}})]})}function Di({isOpen:t,onClose:r,projects:a=[],initialTab:o="agents"}){const n=Is(),{isDarkMode:c,toggleDarkMode:i}=Yr(),{user:m,logout:h}=$t(),p=m?.role==="admin",[b,E]=s.useState([]),[v,j]=s.useState([]),[g,$]=s.useState(""),[L,I]=s.useState(""),[C,x]=s.useState(!1),[d,k]=s.useState(!1),[S,A]=s.useState(null),[W,O]=s.useState("name"),[Q,ie]=s.useState([]),[Z,se]=s.useState(!1),[B,T]=s.useState(null),[z,Y]=s.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[pe,ae]=s.useState(!1),[G,xe]=s.useState({}),[Ne,Ce]=s.useState({}),[je,_e]=s.useState({}),[he,Se]=s.useState(o),[ke,Ee]=s.useState(""),[ye,Pe]=s.useState("permissions"),[Re,Me]=s.useState(!1),[H,f]=s.useState(""),[y,F]=s.useState(""),[oe,ue]=s.useState(""),[Le,He]=s.useState(""),[Ye,qe]=s.useState(""),[u,_]=s.useState(!1),[X,te]=s.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[D,De]=s.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[Be,Ie]=s.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[q,me]=s.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[re,le]=s.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),ve=async()=>{try{const R=await ne("/api/mcp/config/read");if(R.ok){const fe=await R.json();if(fe.success&&fe.servers){ie(fe.servers);return}}const V=await ne("/api/mcp/cli/list");if(V.ok){const fe=await V.json();if(fe.success&&fe.servers){const it=fe.servers.map(Qe=>({id:Qe.name,name:Qe.name,type:Qe.type,scope:"user",config:{command:Qe.command||"",args:Qe.args||[],env:Qe.env||{},url:Qe.url||"",headers:Qe.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));ie(it);return}}const de=await ne("/api/mcp/servers?scope=user");if(de.ok){const fe=await de.json();ie(fe.servers||[])}else console.error("Failed to fetch MCP servers")}catch(R){console.error("Error fetching MCP servers:",R)}},ze=async R=>{try{B&&await ge(B.id,"user");const V=await ne("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:R.name,type:R.type,scope:R.scope,projectPath:R.projectPath,command:R.config?.command,args:R.config?.args||[],url:R.config?.url,headers:R.config?.headers||{},env:R.config?.env||{}})});if(V.ok){const de=await V.json();if(de.success)return await ve(),!0;throw new Error(de.error||"Failed to save server via Claude CLI")}else{const de=await V.json();throw new Error(de.error||"Failed to save server")}}catch(V){throw console.error("Error saving MCP server:",V),V}},ge=async(R,V="user")=>{try{const de=await ne(`/api/mcp/cli/remove/${R}?scope=${V}`,{method:"DELETE"});if(de.ok){const fe=await de.json();if(fe.success)return await ve(),!0;throw new Error(fe.error||"Failed to delete server via Claude CLI")}else{const fe=await de.json();throw new Error(fe.error||"Failed to delete server")}}catch(de){throw console.error("Error deleting MCP server:",de),de}},We=async(R,V="user")=>{try{const de=await ne(`/api/mcp/servers/${R}/test?scope=${V}`,{method:"POST"});if(de.ok)return(await de.json()).testResult;{const fe=await de.json();throw new Error(fe.error||"Failed to test server")}}catch(de){throw console.error("Error testing MCP server:",de),de}},zt=async(R,V="user")=>{try{const de=await ne(`/api/mcp/servers/${R}/tools?scope=${V}`,{method:"POST"});if(de.ok)return(await de.json()).toolsResult;{const fe=await de.json();throw new Error(fe.error||"Failed to discover tools")}}catch(de){throw console.error("Error discovering MCP tools:",de),de}};s.useEffect(()=>{t&&(et(),Se(o),Me(!1))},[t,o]),s.useEffect(()=>{localStorage.setItem("codeEditorTheme",X),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[X]),s.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",D.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[D]),s.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",Be.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Be]),s.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",q.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[q]),s.useEffect(()=>{localStorage.setItem("codeEditorFontSize",re),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[re]);const et=async()=>{try{const R=localStorage.getItem("claude-settings");if(R){const V=JSON.parse(R);E(V.allowedTools||[]),j(V.disallowedTools||[]),x(V.skipPermissions||!1),O(V.projectSortOrder||"name")}else E([]),j([]),x(!1),O("name");await ve()}catch(R){console.error("Error loading tool settings:",R),E([]),j([]),x(!1),O("name")}},_t=()=>{k(!0),A(null);try{const R={allowedTools:b,disallowedTools:v,skipPermissions:C,projectSortOrder:W,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(R)),A("success"),setTimeout(()=>{r()},1e3)}catch(R){console.error("Error saving tool settings:",R),A("error")}finally{k(!1)}},bt=async R=>{if(R.preventDefault(),He(""),qe(""),!H){He("请输入当前密码");return}if(!y){He("请输入新密码");return}if(y.length<6){He("新密码至少需要6个字符");return}if(y!==oe){He("两次输入的新密码不一致");return}_(!0);try{const V=await we.auth.changePassword(H,y),de=await V.json();V.ok?(qe("密码修改成功"),f(""),F(""),ue("")):He(de.error||"修改密码失败")}catch(V){console.error("Error changing password:",V),He("网络错误,请稍后再试")}finally{_(!1)}},Jt=m?.username&&!m.username.includes("@"),yt=()=>{Y({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),T(null),se(!1),Ee("")},tt=(R=null)=>{R?(T(R),Y({name:R.name,type:R.type,scope:R.scope,projectPath:R.projectPath||"",config:{...R.config},raw:R.raw,importMode:"form",jsonInput:""})):yt(),se(!0)},hr=async R=>{R.preventDefault(),ae(!0);try{if(z.importMode==="json"){const V=await ne("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:z.name,jsonConfig:z.jsonInput,scope:z.scope,projectPath:z.projectPath})});if(V.ok){const de=await V.json();if(de.success)await ve(),yt(),A("success");else throw new Error(de.error||"Failed to add server via JSON")}else{const de=await V.json();throw new Error(de.error||"Failed to add server")}}else await ze(z),yt(),A("success")}catch(V){alert(`Error: ${V.message}`),A("error")}finally{ae(!1)}},At=async(R,V)=>{if(confirm("确定要删除此 MCP 服务器吗?"))try{await ge(R,V),A("success")}catch(de){alert(`Error: ${de.message}`),A("error")}},Ft=async(R,V)=>{try{xe({...G,[R]:{loading:!0}});const de=await We(R,V);xe({...G,[R]:de})}catch(de){xe({...G,[R]:{success:!1,message:de.message,details:[]}})}},Kt=async(R,V)=>{try{_e({...je,[R]:!0});const de=await zt(R,V);Ce({...Ne,[R]:de})}catch{Ce({...Ne,[R]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{_e({...je,[R]:!1})}},at=(R,V)=>{Y(de=>({...de,config:{...de.config,[R]:V}}))};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(Tt,{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(J,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:e.jsx(Oe,{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 ${he==="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 ${he==="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 ${he==="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 ${he==="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:[he==="appearance"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:he==="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":c,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${c?"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:c?e.jsx(Rr,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx($r,{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:W,onChange:R=>O(R.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:()=>te(X==="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":X==="dark","aria-label":"Toggle editor theme",children:[e.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),e.jsx("span",{className:`${X==="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:X==="dark"?e.jsx(Rr,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx($r,{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:()=>De(!D),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":D,"aria-label":"Toggle word wrap",children:[e.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),e.jsx("span",{className:`${D?"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:()=>Ie(!Be),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,"aria-label":"Toggle minimap",children:[e.jsx("span",{className:"sr-only",children:"Toggle minimap"}),e.jsx("span",{className:`${Be?"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:()=>me(!q),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":q,"aria-label":"Toggle line numbers",children:[e.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),e.jsx("span",{className:`${q?"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:re,onChange:R=>le(R.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"})]})]})})]})]})}),he==="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:()=>Pe("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 ${ye==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"权限"}),e.jsx("button",{onClick:()=>Pe("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 ${ye==="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:()=>Pe("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 ${ye==="skills"?"border-amber-600 text-amber-600 dark:text-amber-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"技能"}),e.jsx("button",{onClick:()=>Pe("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 ${ye==="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:[ye==="permissions"&&e.jsx(gi,{agent:"claude",skipPermissions:C,setSkipPermissions:x,allowedTools:b,setAllowedTools:E,disallowedTools:v,setDisallowedTools:j,newAllowedTool:g,setNewAllowedTool:$,newDisallowedTool:L,setNewDisallowedTool:I}),ye==="mcp"&&e.jsx(ji,{agent:"claude",servers:Q,onAdd:()=>tt(),onEdit:R=>tt(R),onDelete:(R,V)=>At(R,V),onTest:(R,V)=>Ft(R,V),onDiscoverTools:(R,V)=>Kt(R,V),testResults:G,serverTools:Ne,toolsLoading:je}),ye==="skills"&&e.jsx(Li,{}),ye==="models"&&e.jsx(ki,{})]})]})}),he==="users"&&p&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:Re?e.jsx(Ci,{onBack:()=>Me(!1)}):e.jsxs(e.Fragment,{children:[e.jsx(Ni,{onNavigateToUsage:()=>Me(!0)}),e.jsx(Si,{})]})}),he==="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:m?.username?.charAt(0).toUpperCase()})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:m?.username}),e.jsx("div",{className:"text-sm text-muted-foreground",children:m?.role==="admin"?"管理员":"用户"})]})]})}),Jt&&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(Ws,{className:"w-5 h-5 text-blue-600"}),e.jsx("div",{className:"font-medium text-foreground",children:"修改密码"})]}),e.jsxs("form",{onSubmit:bt,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:H,onChange:R=>f(R.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:u})]}),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:y,onChange:R=>F(R.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:u})]}),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:oe,onChange:R=>ue(R.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:u})]}),Le&&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:Le})}),Ye&&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:Ye})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(J,{type:"submit",disabled:u,className:"bg-blue-600 hover:bg-blue-700",children: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",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"退出登录"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"结束当前会话"})]}),e.jsxs(J,{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("确定要退出登录吗?")&&(r(),n("/"),h())},children:[e.jsx(xn,{className:"w-4 h-4"}),"退出"]})]})})]})}),Z&&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:B?"编辑 MCP 服务器":"添加 MCP 服务器"}),e.jsx(J,{variant:"ghost",size:"sm",onClick:yt,children:e.jsx(Oe,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:hr,className:"p-4 space-y-4",children:[!B&&e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("button",{type:"button",onClick:()=>Y(R=>({...R,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${z.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:()=>Y(R=>({...R,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${z.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 导入"})]}),z.importMode==="form"&&B&&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:[z.scope==="user"?e.jsx(Tr,{className:"w-4 h-4"}):e.jsx(kt,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:z.scope==="user"?"用户(全局)":"项目(本地)"}),z.scope==="local"&&z.projectPath&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",z.projectPath]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"编辑现有服务器时无法更改作用域"})]}),z.importMode==="form"&&!B&&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:()=>Y(R=>({...R,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${z.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(Tr,{className:"w-4 h-4"}),e.jsx("span",{children:"用户(全局)"})]})}),e.jsx("button",{type:"button",onClick:()=>Y(R=>({...R,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${z.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(kt,{className:"w-4 h-4"}),e.jsx("span",{children:"项目(本地)"})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:z.scope==="user"?"用户作用域:在您机器上的所有项目中可用":"本地作用域:仅在选定的项目中可用"})]}),z.scope==="local"&&!B&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"项目 *"}),e.jsxs("select",{value:z.projectPath,onChange:R=>Y(V=>({...V,projectPath:R.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:z.scope==="local",children:[e.jsx("option",{value:"",children:"选择项目..."}),a.map(R=>e.jsx("option",{value:R.path||R.fullPath,children:R.displayName||R.name},R.name))]}),z.projectPath&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Path: ",z.projectPath]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:z.importMode==="json"?"md:col-span-2":"",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"服务器名称 *"}),e.jsx(Ke,{value:z.name,onChange:R=>{Y(V=>({...V,name:R.target.value}))},placeholder:"my-server",required:!0})]}),z.importMode==="form"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"传输类型 *"}),e.jsxs("select",{value:z.type,onChange:R=>{Y(V=>({...V,type:R.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"})]})]})]}),B&&z.raw&&z.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 ",B.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(z.raw,null,2)})]}),z.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:z.jsonInput,onChange:R=>{Y(V=>({...V,jsonInput:R.target.value}));try{if(R.target.value.trim()){const V=JSON.parse(R.target.value);V.type?V.type==="stdio"&&!V.command?Ee("stdio 类型需要 command 字段"):(V.type==="http"||V.type==="sse")&&!V.url?Ee(`${V.type} 类型需要 url 字段`):Ee(""):Ee("缺少必填字段:type")}}catch{R.target.value.trim()?Ee("无效的 JSON 格式"):Ee("")}},className:`w-full px-3 py-2 border ${ke?"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=ei,document.head.appendChild(t)}function ti({selectedProject:t,selectedSession:r,initialCommand:a,isPlainShell:o=!1,onProcessComplete:n,minimal:l=!1,autoConnect:i=!1}){const d=s.useRef(null),x=s.useRef(null),p=s.useRef(null),b=s.useRef(null),[C,j]=s.useState(!1),[y,h]=s.useState(!1),[$,M]=s.useState(!1),[I,E]=s.useState(null),[g,m]=s.useState(!1),k=s.useRef(t),w=s.useRef(r),R=s.useRef(a),W=s.useRef(o),F=s.useRef(n);s.useEffect(()=>{k.current=t,w.current=r,R.current=a,W.current=o,F.current=n});const Q=s.useCallback(async()=>{if(!(g||C))try{let pe;{const ae=localStorage.getItem("auth-token");if(!ae){console.error("No authentication token found for Shell WebSocket connection");return}pe=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/shell?token=${encodeURIComponent(ae)}`}b.current=new WebSocket(pe),b.current.onopen=()=>{j(!0),m(!1),setTimeout(()=>{p.current&&x.current&&(p.current.fit(),b.current.send(JSON.stringify({type:"init",projectPath:k.current.fullPath||k.current.path,sessionId:W.current?null:w.current?.id,hasSession:W.current?!1:!!w.current,provider:W.current?"plain-shell":w.current?.__provider||"claude",cols:x.current.cols,rows:x.current.rows,initialCommand:R.current,isPlainShell:W.current})))},100)},b.current.onmessage=ae=>{try{const V=JSON.parse(ae.data);if(V.type==="output"){let xe=V.data;if(W.current&&F.current){const Ne=xe.replace(/\x1b\[[0-9;]*m/g,"");if(Ne.includes("Process exited with code 0"))F.current(0);else if(Ne.match(/Process exited with code (\d+)/)){const Ce=parseInt(Ne.match(/Process exited with code (\d+)/)[1]);Ce!==0&&F.current(Ce)}}x.current&&x.current.write(xe)}else V.type==="url_open"&&window.open(V.url,"_blank")}catch(V){console.error("[Shell] Error handling WebSocket message:",V,ae.data)}},b.current.onclose=ae=>{j(!1),m(!1),x.current&&(x.current.clear(),x.current.write("\x1B[2J\x1B[H"))},b.current.onerror=ae=>{j(!1),m(!1)}}catch{j(!1),m(!1)}},[g,C]),ie=s.useCallback(()=>{!y||C||g||(m(!0),Q())},[y,C,g,Q]),Z=s.useCallback(()=>{b.current&&(b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"terminate"})),b.current.close(),b.current=null),x.current&&(x.current.clear(),x.current.write("\x1B[2J\x1B[H")),j(!1),m(!1)},[]),se=s.useMemo(()=>r?r.__provider==="cursor"?r.name||"Untitled Session":r.summary||"New Session":null,[r]),B=s.useMemo(()=>se?se.slice(0,30):null,[se]),T=s.useMemo(()=>se?se.slice(0,50):null,[se]),_=()=>{M(!0),b.current&&(b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"terminate"})),b.current.close(),b.current=null),x.current&&(x.current.dispose(),x.current=null,p.current=null),j(!1),h(!1),setTimeout(()=>{M(!1)},200)};return s.useEffect(()=>{const Y=r?.id||null;I!==null&&I!==Y&&y&&Z(),E(Y)},[r?.id,y,Z]),s.useEffect(()=>{if(!d.current||!t||$||x.current)return;x.current=new Yr.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 Qr.FitAddon;const Y=new Zr.WebglAddon,pe=new Xr.WebLinksAddon;x.current.loadAddon(p.current),x.current.loadAddon(pe);try{x.current.loadAddon(Y)}catch{console.warn("[Shell] WebGL renderer unavailable, using Canvas fallback")}x.current.open(d.current),x.current.attachCustomKeyEventHandler(V=>(V.ctrlKey||V.metaKey)&&V.key==="c"&&x.current.hasSelection()?(document.execCommand("copy"),!1):(V.ctrlKey||V.metaKey)&&V.key==="v"?(navigator.clipboard.readText().then(xe=>{b.current&&b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"input",data:xe}))}).catch(()=>{}),!1):!0),setTimeout(()=>{p.current&&(p.current.fit(),x.current&&b.current&&b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"resize",cols:x.current.cols,rows:x.current.rows})))},100),h(!0),x.current.onData(V=>{b.current&&b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"input",data:V}))});const ae=new ResizeObserver(()=>{p.current&&x.current&&setTimeout(()=>{p.current.fit(),b.current&&b.current.readyState===WebSocket.OPEN&&b.current.send(JSON.stringify({type:"resize",cols:x.current.cols,rows:x.current.rows}))},50)});return d.current&&ae.observe(d.current),()=>{ae.disconnect(),b.current&&(b.current.readyState===WebSocket.OPEN||b.current.readyState===WebSocket.CONNECTING)&&b.current.close(),b.current=null,x.current&&(x.current.dispose(),x.current=null)}},[t?.path||t?.fullPath,$]),s.useEffect(()=>{!i||!y||g||C||ie()},[i,y,g,C,ie]),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 ${C?"bg-green-500":"bg-red-500"}`}),r&&e.jsxs("span",{className:"text-xs text-blue-300",children:["(",B,"...)"]}),!r&&e.jsx("span",{className:"text-xs text-gray-400",children:"(新会话)"}),!y&&e.jsx("span",{className:"text-xs text-yellow-400",children:"(正在初始化...)"}),$&&e.jsx("span",{className:"text-xs text-blue-400",children:"(正在重启...)"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[C&&e.jsxs("button",{onClick:Z,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:$||C,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"}}),!y&&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:"加载终端中..."})}),y&&!C&&!g&&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:ie,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}`:r?`Resume session: ${T}...`:"Start a new Claude session"})]})}),g&&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 ri({project:t,session:r=null,command:a=null,isPlainShell:o=null,autoConnect:n=!0,onComplete:l=null,onClose:i=null,title:d=null,className:x="",showHeader:p=!0,compact:b=!1,minimal:C=!1}){const[j,y]=s.useState(!1),h=o!==null?o:a!==null,$=s.useCallback(M=>{y(!0),l&&l(M)},[l]);return t?e.jsxs("div",{className:`h-full w-full flex flex-col ${x}`,children:[!C&&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}),j&&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(ti,{selectedProject:t,selectedSession:r,initialCommand:a,isPlainShell:h,onProcessComplete:$,minimal:C,autoConnect:C?!0:n})})]}):e.jsx("div",{className:`h-full flex items-center justify-center ${x}`,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 si({selectedProject:t,minimal:r=!1,autoConnect:a=!1}){const o=s.useRef(null),n=s.useRef(null),l=s.useRef(null),i=s.useRef(null),[d,x]=s.useState(!1),[p,b]=s.useState(!1),[C,j]=s.useState(!1),[y,h]=s.useState(!1),$=s.useRef(t);s.useEffect(()=>{$.current=t});const M=s.useCallback(async()=>{if(!(y||d))try{let k;{const w=localStorage.getItem("auth-token");if(!w){console.error("No authentication token found for Codex WebSocket connection");return}k=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/codex?token=${encodeURIComponent(w)}`}i.current=new WebSocket(k),i.current.onopen=()=>{x(!0),h(!1),setTimeout(()=>{l.current&&n.current&&(l.current.fit(),i.current.send(JSON.stringify({type:"init",projectPath:$.current.fullPath||$.current.path,cols:n.current.cols,rows:n.current.rows})))},100)},i.current.onmessage=w=>{try{const R=JSON.parse(w.data);R.type==="output"?n.current&&n.current.write(R.data):R.type==="url_open"&&window.open(R.url,"_blank")}catch(R){console.error("[CodexShell] Error handling WebSocket message:",R)}},i.current.onclose=()=>{x(!1),h(!1),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H"))},i.current.onerror=()=>{x(!1),h(!1)}}catch{x(!1),h(!1)}},[y,d]),I=s.useCallback(()=>{!p||d||y||(h(!0),M())},[p,d,y,M]),E=s.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")),x(!1),h(!1)},[]),g=()=>{j(!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),x(!1),b(!1),setTimeout(()=>j(!1),200)};return s.useEffect(()=>{if(!o.current||!t||C||n.current)return;n.current=new Yr.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 Qr.FitAddon;const m=new Zr.WebglAddon,k=new Xr.WebLinksAddon;n.current.loadAddon(l.current),n.current.loadAddon(k);try{n.current.loadAddon(m)}catch{console.warn("[CodexShell] WebGL renderer unavailable, using Canvas fallback")}n.current.open(o.current),n.current.attachCustomKeyEventHandler(R=>(R.ctrlKey||R.metaKey)&&R.key==="c"&&n.current.hasSelection()?(document.execCommand("copy"),!1):(R.ctrlKey||R.metaKey)&&R.key==="v"?(navigator.clipboard.readText().then(W=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:W}))}).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),b(!0),n.current.onData(R=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:R}))});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,C]),s.useEffect(()=>{!a||!p||y||d||I()},[a,p,y,d,I]),t?r?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:"(正在初始化...)"}),C&&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:E,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:g,disabled:C||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&&!y&&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:I,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"]})]})}),y&&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 ai({project:t,autoConnect:r=!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(si,{selectedProject:t,minimal:l,autoConnect:l?!0:r})})]}):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 ni({selectedProject:t,minimal:r=!1,autoConnect:a=!1}){const o=s.useRef(null),n=s.useRef(null),l=s.useRef(null),i=s.useRef(null),[d,x]=s.useState(!1),[p,b]=s.useState(!1),[C,j]=s.useState(!1),[y,h]=s.useState(!1),$=s.useRef(t);s.useEffect(()=>{$.current=t});const M=s.useCallback(async()=>{if(!(y||d))try{let k;{const w=localStorage.getItem("auth-token");if(!w){console.error("No authentication token found for Gemini WebSocket connection");return}k=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/gemini?token=${encodeURIComponent(w)}`}i.current=new WebSocket(k),i.current.onopen=()=>{x(!0),h(!1),setTimeout(()=>{l.current&&n.current&&(l.current.fit(),i.current.send(JSON.stringify({type:"init",projectPath:$.current.fullPath||$.current.path,cols:n.current.cols,rows:n.current.rows})))},100)},i.current.onmessage=w=>{try{const R=JSON.parse(w.data);R.type==="output"?n.current&&n.current.write(R.data):R.type==="url_open"&&window.open(R.url,"_blank")}catch(R){console.error("[GeminiShell] Error handling WebSocket message:",R)}},i.current.onclose=()=>{x(!1),h(!1),n.current&&(n.current.clear(),n.current.write("\x1B[2J\x1B[H"))},i.current.onerror=()=>{x(!1),h(!1)}}catch{x(!1),h(!1)}},[y,d]),I=s.useCallback(()=>{!p||d||y||(h(!0),M())},[p,d,y,M]),E=s.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")),x(!1),h(!1)},[]),g=()=>{j(!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),x(!1),b(!1),setTimeout(()=>j(!1),200)};return s.useEffect(()=>{if(!o.current||!t||C||n.current)return;n.current=new Yr.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 Qr.FitAddon;const m=new Zr.WebglAddon,k=new Xr.WebLinksAddon;n.current.loadAddon(l.current),n.current.loadAddon(k);try{n.current.loadAddon(m)}catch{console.warn("[GeminiShell] WebGL renderer unavailable, using Canvas fallback")}n.current.open(o.current),n.current.attachCustomKeyEventHandler(R=>(R.ctrlKey||R.metaKey)&&R.key==="c"&&n.current.hasSelection()?(document.execCommand("copy"),!1):(R.ctrlKey||R.metaKey)&&R.key==="v"?(navigator.clipboard.readText().then(W=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:W}))}).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),b(!0),n.current.onData(R=>{i.current&&i.current.readyState===WebSocket.OPEN&&i.current.send(JSON.stringify({type:"input",data:R}))});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,C]),s.useEffect(()=>{!a||!p||y||d||I()},[a,p,y,d,I]),t?r?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:"(正在初始化...)"}),C&&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:E,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:g,disabled:C||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&&!y&&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:I,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"]})]})}),y&&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 oi({project:t,autoConnect:r=!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(ni,{selectedProject:t,minimal:l,autoConnect:l?!0:r})})]}):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 ii extends Xe.Component{constructor(r){super(r),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(r){return{hasError:!0}}componentDidCatch(r,a){console.error("ErrorBoundary caught an error:",r,a),this.setState({error:r,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 Ht=({children:t,content:r,position:a="top",className:o="",delay:n=500})=>{const[l,i]=s.useState(!1),[d,x]=s.useState(null),p=()=>{const y=setTimeout(()=>{i(!0)},n);x(y)},b=()=>{d&&(clearTimeout(d),x(null)),i(!1)},C=()=>{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"}},j=()=>{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 r?e.jsxs("div",{className:"relative inline-block",onMouseEnter:p,onMouseLeave:b,children:[t,l&&e.jsxs("div",{className:Oe("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",C(),o),children:[r,e.jsx("div",{className:Oe("absolute w-0 h-0 border-4 border-transparent",j())})]})]}):t};function li({selectedProject:t,selectedSession:r,activeTab:a,setActiveTab:o,ws:n,sendMessage:l,messages:i,isMobile:d,isPWA:x,onMenuClick:p,isLoading:b,onInputFocusChange:C,onSessionActive:j,onSessionInactive:y,onSessionProcessing:h,onSessionNotProcessing:$,processingSessions:M,onReplaceTemporarySession:I,onNavigateToSession:E,onShowSettings:g,autoExpandTools:m,showRawParameters:k,showThinking:w,autoScrollToBottom:R,sendByCtrlEnter:W,externalMessageUpdate:F,limitStatus:Q,onLimitBlocked:ie,checkLimitStatus:Z}){const[se,B]=s.useState(null),[T,_]=s.useState(600),[Y,pe]=s.useState(!1),[ae,V]=s.useState(!1),xe=s.useRef(null);s.useEffect(()=>{a==="shell"&&Z&&Z()},[a,Z]);const Ne=(he,Se=null)=>{const ke={name:he.split("/").pop(),path:he,projectName:t?.name,diffInfo:Se};B(ke)},Ce=()=>{B(null),V(!1)},je=()=>{V(!ae)},_e=he=>{d||(pe(!0),he.preventDefault())};return s.useEffect(()=>{const he=ke=>{if(!Y)return;const Ee=xe.current?.parentElement;if(!Ee)return;const ye=Ee.getBoundingClientRect(),Re=ye.right-ke.clientX,Pe=300,Me=ye.width*.8;Re>=Pe&&Re<=Me&&_(Re)},Se=()=>{pe(!1)};return Y&&(document.addEventListener("mousemove",he),document.addEventListener("mouseup",Se),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",Se),document.body.style.cursor="",document.body.style.userSelect=""}},[Y]),b?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:he=>{he.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"&&r&&e.jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:e.jsx(ot,{className:"w-4 h-4"})}),e.jsx("div",{className:"min-w-0 flex-1",children:a==="chat"&&r?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:r.summary||"新会话"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.displayName})]}):a==="chat"&&!r?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(Ht,{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(Ht,{content:Q&&!Q.allowed?"使用已达上限":"Shell",position:"bottom",children:e.jsx("button",{onClick:()=>{if(Q&&!Q.allowed){ie?.(Q.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 ${Q&&!Q.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",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("span",{className:"hidden md:hidden lg:inline",children:"Shell"})]})})}),e.jsx(Ht,{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(Ht,{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:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Codex"})]})})}),e.jsx(Ht,{content:"Gemini",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.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:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})}),e.jsx("span",{className:"hidden md:hidden lg:inline",children:"Gemini"})]})})})]})})]})}),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 ${se?"mr-0":""} ${ae?"hidden":""}`,children:[e.jsx("div",{className:`h-full ${a==="chat"?"block":"hidden"}`,children:e.jsx(ii,{showDetails:!0,children:e.jsx(Qo,{selectedProject:t,selectedSession:r,ws:n,sendMessage:l,messages:i,onFileOpen:Ne,onInputFocusChange:C,onSessionActive:j,onSessionInactive:y,onSessionProcessing:h,onSessionNotProcessing:$,processingSessions:M,onReplaceTemporarySession:I,onNavigateToSession:E,onShowSettings:g,autoExpandTools:m,showRawParameters:k,showThinking:w,autoScrollToBottom:R,sendByCtrlEnter:W,externalMessageUpdate:F,limitStatus:Q,onLimitExceeded:ie,checkLimitStatus:Z})})}),a==="files"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(Xo,{selectedProject:t})}),a==="shell"&&e.jsxs("div",{className:"h-full w-full overflow-hidden relative",children:[e.jsx(ri,{project:t,session:r,showHeader:!1}),Q&&!Q.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:Q.reason==="total_limit_exceeded"?"使用上限已达到":"今日使用上限已达到"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:Q.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(ai,{project:t,showHeader:!1})}),a==="gemini"&&e.jsx("div",{className:"h-full w-full overflow-hidden relative",children:e.jsx(oi,{project:t,showHeader:!1})}),e.jsx("div",{className:`h-full overflow-hidden ${a==="preview"?"block":"hidden"}`})]}),se&&!d&&e.jsxs(e.Fragment,{children:[!ae&&e.jsx("div",{ref:xe,onMouseDown:_e,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 ${ae?"flex-1":""}`,style:ae?{}:{width:`${T}px`},children:e.jsx(Ur,{file:se,onClose:Ce,projectPath:t?.path,isSidebar:!0,isExpanded:ae,onToggleExpand:je})})]})]}),se&&d&&e.jsx(Ur,{file:se,onClose:Ce,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 ci=Xe.memo(li);function di({activeTab:t,setActiveTab:r,isInputFocused:a}){const o=[{id:"chat",icon:It,onClick:()=>r("chat")},{id:"shell",icon:mr,onClick:()=>r("shell")},{id:"files",icon:rt,onClick:()=>r("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 aa=s.createContext(),es=()=>{const t=s.useContext(aa);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t},mi=({children:t})=>{const[r,a]=s.useState(()=>{const l=localStorage.getItem("theme");return l?l==="dark":window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1});s.useEffect(()=>{if(r){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")}},[r]),s.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:r,toggleDarkMode:()=>{a(l=>!l)}};return e.jsx(aa.Provider,{value:n,children:t})},na=s.createContext({user:null,token:null,login:()=>{},sendCode:()=>{},verifyCode:()=>{},logout:()=>{},isLoading:!0,needsSetup:!1,smtpConfigured:!1,error:null,isAdmin:!1,limitStatus:{allowed:!0},checkLimitStatus:()=>{},setLimitStatus:()=>{}}),$t=()=>{const t=s.useContext(na);if(!t)throw new Error("useAuth must be used within an AuthProvider");return t},ui=({children:t})=>{const[r,a]=s.useState(null),[o,n]=s.useState(localStorage.getItem("auth-token")),[l,i]=s.useState(!0),[d,x]=s.useState(!1),[p,b]=s.useState(!1),[C,j]=s.useState(null),[y,h]=s.useState({allowed:!0});s.useEffect(()=>{$()},[]);const $=async()=>{try{i(!0),j(null);const R=await(await we.auth.status()).json();if(b(R.smtpConfigured||!1),R.needsSetup){x(!0),i(!1);return}if(o)try{const W=await we.auth.user();if(W.ok){const F=await W.json();a(F.user),x(!1)}else localStorage.removeItem("auth-token"),n(null),a(null)}catch(W){console.error("Token verification failed:",W),localStorage.removeItem("auth-token"),n(null),a(null)}}catch(w){console.error("[AuthContext] Auth status check failed:",w),j("Failed to check authentication status")}finally{i(!1)}},M=async w=>{try{j(null);const R=await we.auth.sendCode(w),W=await R.json();return R.ok?{success:!0,type:W.type}:{success:!1,error:W.error||"发送验证码失败",waitSeconds:W.waitSeconds}}catch(R){return console.error("Send code error:",R),{success:!1,error:"网络错误,请稍后再试"}}},I=async(w,R)=>{try{j(null);const W=await we.auth.verifyCode(w,R),F=await W.json();return W.ok?(n(F.token),a(F.user),x(!1),localStorage.setItem("auth-token",F.token),{success:!0}):(j(F.error||"验证失败"),{success:!1,error:F.error||"验证失败"})}catch(W){return console.error("Verify code error:",W),{success:!1,error:"网络错误,请稍后再试"}}},E=async(w,R)=>{try{j(null);const W=await we.auth.login(w,R),F=await W.json();return W.ok?(n(F.token),a(F.user),localStorage.setItem("auth-token",F.token),{success:!0}):(j(F.error||"登录失败"),{success:!1,error:F.error||"登录失败"})}catch(W){console.error("Login error:",W);const F="网络错误,请稍后再试";return j(F),{success:!1,error:F}}},g=()=>{n(null),a(null),h({allowed:!0}),localStorage.removeItem("auth-token"),o&&we.auth.logout().catch(w=>{console.error("Logout endpoint error:",w)})},m=async()=>{if(!r)return{allowed:!0};try{const w=await we.auth.limitStatus();if(w.ok){const R=await w.json();return h(R),R}}catch(w){console.error("Error checking limit status:",w)}return{allowed:!0}};s.useEffect(()=>{r&&!l&&m()},[r,l]);const k={user:r,token:o,login:E,sendCode:M,verifyCode:I,logout:g,isLoading:l,needsSetup:d,smtpConfigured:p,error:C,isAdmin:r?.role==="admin",limitStatus:y,checkLimitStatus:m,setLimitStatus:h};return e.jsx(na.Provider,{value:k,children:t})},pi=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],xi=["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 hi({skipPermissions:t,setSkipPermissions:r,allowedTools:a,setAllowedTools:o,disallowedTools:n,setDisallowedTools:l,newAllowedTool:i,setNewAllowedTool:d,newDisallowedTool:x,setNewDisallowedTool:p}){const b=h=>{h&&!a.includes(h)&&(o([...a,h]),d(""))},C=h=>{o(a.filter($=>$!==h))},j=h=>{h&&!n.includes(h)&&(l([...n,h]),p(""))},y=h=>{l(n.filter($=>$!==h))};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(Bs,{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(Rt,{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:h=>r(h.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(ur,{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(Ke,{value:i,onChange:h=>d(h.target.value),placeholder:'e.g., "Bash(git log:*)" or "Write"',onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),b(i))},className:"flex-1 h-10"}),e.jsxs(J,{onClick:()=>b(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{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:pi.map(h=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>b(h),disabled:a.includes(h),className:"text-xs h-8",children:h},h))})]}),e.jsxs("div",{className:"space-y-2",children:[a.map(h=>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:h}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>C(h),className:"text-green-600 hover:text-green-700",children:e.jsx(Fe,{className:"w-4 h-4"})})]},h)),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(Rt,{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(Ke,{value:x,onChange:h=>p(h.target.value),placeholder:'e.g., "Bash(rm:*)"',onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),j(x))},className:"flex-1 h-10"}),e.jsxs(J,{onClick:()=>j(x),disabled:!x,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{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(h=>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:h}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>y(h),className:"text-red-600 hover:text-red-700",children:e.jsx(Fe,{className:"w-4 h-4"})})]},h)),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 gi({skipPermissions:t,setSkipPermissions:r,allowedCommands:a,setAllowedCommands:o,disallowedCommands:n,setDisallowedCommands:l,newAllowedCommand:i,setNewAllowedCommand:d,newDisallowedCommand:x,setNewDisallowedCommand:p}){const b=h=>{h&&!a.includes(h)&&(o([...a,h]),d(""))},C=h=>{o(a.filter($=>$!==h))},j=h=>{h&&!n.includes(h)&&(l([...n,h]),p(""))},y=h=>{l(n.filter($=>$!==h))};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(Rt,{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:h=>r(h.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(ur,{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(Ke,{value:i,onChange:h=>d(h.target.value),placeholder:'e.g., "Shell(ls)" or "Shell(git status)"',onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),b(i))},className:"flex-1 h-10"}),e.jsxs(J,{onClick:()=>b(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{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(h=>e.jsx(J,{variant:"outline",size:"sm",onClick:()=>b(h),disabled:a.includes(h),className:"text-xs h-8",children:h},h))})]}),e.jsxs("div",{className:"space-y-2",children:[a.map(h=>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:h}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>C(h),className:"text-green-600 hover:text-green-700",children:e.jsx(Fe,{className:"w-4 h-4"})})]},h)),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(Rt,{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(Ke,{value:x,onChange:h=>p(h.target.value),placeholder:'e.g., "Shell(rm -rf)" or "Shell(sudo)"',onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),j(x))},className:"flex-1 h-10"}),e.jsxs(J,{onClick:()=>j(x),disabled:!x,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{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(h=>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:h}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>y(h),className:"text-red-600 hover:text-red-700",children:e.jsx(Fe,{className:"w-4 h-4"})})]},h)),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 fi({permissionMode:t,setPermissionMode:r}){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(ur,{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:()=>r("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:()=>r("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:()=>r("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:()=>r("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:()=>r("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:()=>r("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(Rt,{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 bi({agent:t,...r}){return t==="claude"?e.jsx(hi,{...r}):t==="cursor"?e.jsx(gi,{...r}):t==="codex"?e.jsx(fi,{...r}):null}const yi=t=>{switch(t){case"stdio":return e.jsx(mr,{className:"w-4 h-4"});case"sse":return e.jsx(sn,{className:"w-4 h-4"});case"http":return e.jsx(Tr,{className:"w-4 h-4"});default:return e.jsx(pr,{className:"w-4 h-4"})}};function vi({servers:t,onAdd:r,onEdit:a,onDelete:o,onTest:n,onDiscoverTools:l,testResults:i,serverTools:d,toolsLoading:x}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pr,{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(J,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(st,{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:[yi(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((b,C)=>e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:b.name},C)),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(J,{onClick:()=>a(p),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"编辑服务器",children:e.jsx(qt,{className:"w-4 h-4"})}),e.jsx(J,{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 ji({servers:t,onAdd:r,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(pr,{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(J,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(st,{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(mr,{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(J,{onClick:()=>a(n),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",children:e.jsx(qt,{className:"w-4 h-4"})}),e.jsx(J,{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 wi({servers:t,onAdd:r,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(pr,{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(J,{onClick:r,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[e.jsx(st,{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(mr,{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(J,{onClick:()=>a(n),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:"编辑服务器",children:e.jsx(qt,{className:"w-4 h-4"})}),e.jsx(J,{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 ki({agent:t,...r}){return t==="claude"?e.jsx(vi,{...r}):t==="cursor"?e.jsx(ji,{...r}):t==="codex"?e.jsx(wi,{...r}):null}const Ni=[{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)使用的模型"}];function Si(){const[t,r]=s.useState({}),[a,o]=s.useState({}),[n,l]=s.useState(!0),[i,d]=s.useState(!1),[x,p]=s.useState(null),[b,C]=s.useState(null);s.useEffect(()=>{j()},[]),s.useEffect(()=>{if(x){const M=setTimeout(()=>p(null),3e3);return()=>clearTimeout(M)}},[x]);const j=async()=>{try{l(!0),C(null);const M=await ne("/api/settings/models");if(M.ok){const I=await M.json();r(I.models||{}),o(I.models||{})}else{const I=await M.json();C(I.error||"加载模型配置失败")}}catch(M){C(M.message)}finally{l(!1)}},y=async()=>{try{d(!0),p(null);const M=await ne("/api/settings/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:t})});if(M.ok)p("success"),o({...t});else{const I=await M.json();p("error"),C(I.error||"保存失败")}}catch(M){p("error"),C(M.message)}finally{d(!1)}},h=()=>{r({...a}),p(null)},$=JSON.stringify(t)!==JSON.stringify(a);return n?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(Bs,{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。"})]})]}),b&&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:b}),Ni.map(M=>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:M.label}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:M.description})]}),e.jsx("input",{type:"text",value:t[M.key]||"",onChange:I=>r(E=>({...E,[M.key]:I.target.value})),placeholder:M.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:M.key})]})},M.key)),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("div",{children:[x==="success"&&e.jsx("span",{className:"text-sm text-green-600 dark:text-green-400",children:"模型配置已保存"}),x==="error"&&e.jsx("span",{className:"text-sm text-red-600 dark:text-red-400",children:"保存失败"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:h,disabled:!$,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg border border-gray-300 dark:border-gray-600 text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(an,{className:"w-3.5 h-3.5"}),"重置"]}),e.jsxs("button",{onClick:y,disabled:!$||i,className:"inline-flex items-center gap-1.5 px-4 py-1.5 text-sm rounded-lg bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(As,{className:"w-3.5 h-3.5"}),i?"保存中...":"保存"]})]})]})]})}function Ci({onNavigateToUsage:t}){const[r,a]=s.useState([]),[o,n]=s.useState({}),[l,i]=s.useState(!0),[d,x]=s.useState(null),[p,b]=s.useState(!1),[C,j]=s.useState(""),[y,h]=s.useState(""),[$,M]=s.useState(""),[I,E]=s.useState(!1),[g,m]=s.useState(null),[k,w]=s.useState({total_limit_usd:"",daily_limit_usd:""}),[R,W]=s.useState(""),[F,Q]=s.useState(!1),[ie,Z]=s.useState(null),[se,B]=s.useState(""),[T,_]=s.useState(""),[Y,pe]=s.useState(""),[ae,V]=s.useState(!1),xe=async()=>{try{const f=await ne("/api/admin/users");if(f.ok){const v=await f.json();a(v.users)}}catch(f){console.error("Error fetching users:",f)}finally{i(!1)}},Ne=async()=>{try{const f=await ne("/api/admin/usage/summary");if(f.ok){const v=await f.json(),O={};for(const oe of v.users)O[oe.user_uuid]={total_cost:oe.total_cost||0,total_requests:oe.total_requests||0,last_active:oe.last_active};n(O)}}catch(f){console.error("Error fetching usage data:",f)}};s.useEffect(()=>{xe(),Ne()},[]);const Ce=f=>!f||f===0?"$0.00":f<.01?`$${f.toFixed(4)}`:`$${f.toFixed(2)}`,je=async(f,v)=>{const O=v==="active"?"disabled":"active";x(f);try{(await ne(`/api/admin/users/${f}`,{method:"PATCH",body:JSON.stringify({status:O})})).ok&&a(r.map(ue=>ue.id===f?{...ue,status:O}:ue))}catch(oe){console.error("Error updating user status:",oe)}finally{x(null)}},_e=async(f,v)=>{if(confirm(`确定要删除用户 "${v}"?这将删除其所有数据。`)){x(f);try{(await ne(`/api/admin/users/${f}`,{method:"DELETE"})).ok&&a(r.filter(oe=>oe.id!==f))}catch(O){console.error("Error deleting user:",O)}finally{x(null)}}},he=async f=>{if(f.preventDefault(),M(""),!C||!y){M("用户名和密码不能为空");return}if(C.length<3){M("用户名至少3个字符");return}if(y.length<6){M("密码至少6个字符");return}E(!0);try{const v=await we.admin.createUser(C,y),O=await v.json();v.ok?(await xe(),b(!1),j(""),h("")):M(O.error||"创建用户失败")}catch(v){console.error("Error creating user:",v),M("网络错误,请稍后再试")}finally{E(!1)}},Se=()=>{b(!1),j(""),h(""),M("")},ke=f=>{m(f),w({total_limit_usd:f.total_limit_usd!==null&&f.total_limit_usd!==void 0?String(f.total_limit_usd):"",daily_limit_usd:f.daily_limit_usd!==null&&f.daily_limit_usd!==void 0?String(f.daily_limit_usd):""}),W("")},Ee=()=>{m(null),w({total_limit_usd:"",daily_limit_usd:""}),W("")},ye=async f=>{f.preventDefault(),W("");const v=k.total_limit_usd.trim()===""?null:parseFloat(k.total_limit_usd),O=k.daily_limit_usd.trim()===""?null:parseFloat(k.daily_limit_usd);if(v!==null&&(isNaN(v)||v<0)){W("总额度限制必须是正数或留空");return}if(O!==null&&(isNaN(O)||O<0)){W("每日额度限制必须是正数或留空");return}Q(!0);try{const oe=await we.admin.updateUserLimits(g.id,{total_limit_usd:v,daily_limit_usd:O}),ue=await oe.json();oe.ok?(a(r.map(Le=>Le.id===g.id?{...Le,total_limit_usd:v,daily_limit_usd:O}:Le)),Ee()):W(ue.error||"更新限制失败")}catch(oe){console.error("Error updating limits:",oe),W("网络错误,请稍后再试")}finally{Q(!1)}},Re=f=>f==null?"无限制":`$${f.toFixed(2)}`,Pe=f=>{Z(f),B(""),_(""),pe("")},Me=()=>{Z(null),B(""),_(""),pe("")},H=async f=>{if(f.preventDefault(),pe(""),!se){pe("请输入新密码");return}if(se.length<6){pe("密码至少需要6个字符");return}if(se!==T){pe("两次输入的密码不一致");return}V(!0);try{const v=await we.admin.resetUserPassword(ie.id,se),O=await v.json();v.ok?Me():pe(O.error||"重置密码失败")}catch(v){console.error("Error resetting password:",v),pe("网络错误,请稍后再试")}finally{V(!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(J,{variant:"default",size:"sm",onClick:()=>b(!0),className:"flex items-center gap-2",children:[e.jsx(nn,{className:"w-4 h-4"}),"创建用户"]}),t&&e.jsxs(J,{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:r.map(f=>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:[f.role==="admin"?e.jsx(ur,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):e.jsx(Us,{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:f.username||f.email}),f.email&&f.username&&e.jsx("div",{className:"text-xs text-muted-foreground truncate",children:f.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 ${f.role==="admin"?"bg-blue-500/20 text-blue-400":"bg-gray-500/20 text-gray-400"}`,children:f.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 ${f.status==="active"?"bg-green-500":"bg-red-500"}`,title:f.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:Ce(o[f.uuid]?.total_cost)})}),e.jsx("td",{className:"px-3 py-2 text-right",children:f.role!=="admin"?e.jsx("button",{onClick:()=>ke(f),className:"text-xs text-blue-600 dark:text-blue-400 hover:underline font-mono whitespace-nowrap",title:"点击编辑额度限制",children:f.total_limit_usd!==null||f.daily_limit_usd!==null?e.jsxs("span",{className:"flex flex-col items-end text-[11px] leading-tight",children:[e.jsxs("span",{children:["总:",Re(f.total_limit_usd)]}),e.jsxs("span",{children:["日:",Re(f.daily_limit_usd)]})]}):e.jsxs("span",{className:"flex items-center gap-1 justify-end",children:[e.jsx(Hs,{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(f.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-3 py-2",children:e.jsx("div",{className:"flex items-center justify-end gap-1",children:f.role!=="admin"&&e.jsxs(e.Fragment,{children:[f.username&&e.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>Pe(f),disabled:d===f.id,title:"重置密码",children:e.jsx(qs,{className:"w-4 h-4 text-blue-500"})}),e.jsx(J,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>je(f.id,f.status),disabled:d===f.id,title:f.status==="active"?"禁用用户":"启用用户",children:f.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(J,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>_e(f.id,f.username||f.email),disabled:d===f.id,title:"删除用户",children:e.jsx(Ge,{className:"w-4 h-4 text-red-500"})})]})})})]},f.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(Fe,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:he,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:C,onChange:f=>j(f.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:I})]}),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:y,onChange:f=>h(f.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:I})]}),$&&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:$})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{type:"button",variant:"outline",onClick:Se,disabled:I,children:"取消"}),e.jsx(J,{type:"submit",disabled:I,children:I?"创建中...":"创建"})]})]})]})}),g&&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:["设置额度限制 - ",g.username||g.email]}),e.jsx("button",{onClick:Ee,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Fe,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:ye,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:k.total_limit_usd,onChange:f=>w(v=>({...v,total_limit_usd:f.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:F}),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:k.daily_limit_usd,onChange:f=>w(v=>({...v,daily_limit_usd:f.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:F}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"用户每日使用金额达到此限制后,需等待次日重置"})]}),o[g.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:Ce(o[g.uuid]?.total_cost)})]})}),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(J,{type:"button",variant:"outline",onClick:Ee,disabled:F,children:"取消"}),e.jsx(J,{type:"submit",disabled:F,children:F?"保存中...":"保存"})]})]})]})}),ie&&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:["重置密码 - ",ie.username]}),e.jsx("button",{onClick:Me,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Fe,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:H,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:se,onChange:f=>B(f.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:ae})]}),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:T,onChange:f=>_(f.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:ae})]}),Y&&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:Y})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{type:"button",variant:"outline",onClick:Me,disabled:ae,children:"取消"}),e.jsx(J,{type:"submit",disabled:ae,children:ae?"重置中...":"重置密码"})]})]})]})})]})}function Ei(){const[t,r]=s.useState([]),[a,o]=s.useState(!0),[n,l]=s.useState(null),[i,d]=s.useState(!1),[x,p]=s.useState(""),[b,C]=s.useState(""),[j,y]=s.useState(!1),h=async()=>{try{const E=await we.admin.getEmailDomains();if(E.ok){const g=await E.json();r(g.domains)}}catch(E){console.error("Error fetching email domains:",E)}finally{o(!1)}};s.useEffect(()=>{h()},[]);const $=async E=>{if(E.preventDefault(),C(""),!x){C("域名不能为空");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(x)){C("域名格式无效,例如: example.com");return}y(!0);try{const m=await we.admin.addEmailDomain(x.toLowerCase()),k=await m.json();m.ok?(await h(),d(!1),p("")):C(k.error||"添加域名失败")}catch(m){console.error("Error adding domain:",m),C("网络错误,请稍后再试")}finally{y(!1)}},M=async(E,g)=>{if(confirm(`确定要删除域名 "${g}"?删除后该域名的邮箱将无法注册。`)){l(E);try{(await we.admin.removeEmailDomain(E)).ok&&r(t.filter(k=>k.id!==E))}catch(m){console.error("Error removing domain:",m)}finally{l(null)}}},I=()=>{d(!1),p(""),C("")};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(J,{variant:"default",size:"sm",onClick:()=>d(!0),className:"flex items-center gap-2",children:[e.jsx(st,{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(E=>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(ir,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"font-medium text-foreground",children:E.domain})]})}),e.jsx("td",{className:"px-4 py-3 text-sm text-muted-foreground",children:new Date(E.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>M(E.id,E.domain),disabled:n===E.id,title:"删除域名",children:e.jsx(Ge,{className:"w-4 h-4 text-red-500"})})})})]},E.id))})]})}):e.jsxs("div",{className:"border border-dashed border-gray-300 dark:border-gray-600 rounded-lg p-8 text-center",children:[e.jsx(ir,{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:I,className:"text-muted-foreground hover:text-foreground",children:e.jsx(Fe,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:$,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:x,onChange:E=>p(E.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:j}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"输入域名后,该域名下的所有邮箱(如 user@example.com)都可以注册"})]}),b&&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:b})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{type:"button",variant:"outline",onClick:I,disabled:j,children:"取消"}),e.jsx(J,{type:"submit",disabled:j,children:j?"添加中...":"添加"})]})]})]})})]})}function Mi({onBack:t}){const[r,a]=s.useState("week"),[o,n]=s.useState(null),[l,i]=s.useState(!0),[d,x]=s.useState(!1),p=async()=>{try{const I=await ne(`/api/admin/usage/dashboard?period=${r}`);if(I.ok){const E=await I.json();n(E)}}catch(I){console.error("Error fetching dashboard data:",I)}finally{i(!1),x(!1)}};s.useEffect(()=>{i(!0),p()},[r]);const b=async()=>{try{x(!0),await ne("/api/admin/usage/scan",{method:"POST"}),await p()}catch(I){console.error("Error triggering scan:",I),x(!1)}},C=I=>!I||I===0?"$0.00":I<.01?`$${I.toFixed(4)}`:`$${I.toFixed(2)}`,j=I=>I?I>=1e6?`${(I/1e6).toFixed(1)}M`:I>=1e3?`${(I/1e3).toFixed(1)}K`:I.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:y,dailyTrend:h,modelDistribution:$,topUsers:M}=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(J,{variant:"ghost",size:"sm",onClick:t,children:[e.jsx(xr,{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(I=>e.jsx("button",{onClick:()=>a(I),className:`px-4 py-2 text-sm font-medium transition-colors ${r===I?"bg-primary text-primary-foreground":"bg-background text-foreground hover:bg-muted"}`,children:I==="week"?"周":"月"},I))}),e.jsx(J,{variant:"outline",size:"sm",onClick:b,disabled:d,title:"扫描新的使用数据",children:e.jsx(or,{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(Hs,{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:C(y?.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:[y?.activeUsers||0," / ",y?.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(It,{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:j(y?.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:j(y?.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:"每日成本趋势"}),h&&h.length>0?e.jsx("div",{className:"space-y-2",children:h.map(I=>{const E=Math.max(...h.map(m=>m.cost||0),.01),g=(I.cost||0)/E*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(I.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:`${g}%`}})}),e.jsx("span",{className:"text-sm font-mono text-foreground w-16 text-right",children:C(I.cost)})]},I.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:"模型成本"}),$&&$.length>0?e.jsx("div",{className:"space-y-3",children:$.map(I=>{const E=$.reduce((R,W)=>R+(W.cost||0),0)||1,g=(I.cost||0)/E*100,m=(I.normalized_model||I.model||"").toLowerCase(),w=(R=>R.includes("codex")?"bg-orange-500":R.includes("opus")?"bg-purple-500":R.includes("sonnet")?"bg-blue-500":R.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:I.model,children:I.model}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[j(I.requests)," 请求"]})]}),e.jsx("span",{className:"text-sm font-mono text-foreground whitespace-nowrap ml-2",children:C(I.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:`${g}%`}})})]},I.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:"用户成本"}),M&&M.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:M.map((I,E)=>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:["#",E+1]}),e.jsx("td",{className:"py-2 text-sm font-medium text-foreground",children:I.username}),e.jsx("td",{className:"py-2 text-sm text-right text-muted-foreground",children:j(I.total_requests)}),e.jsx("td",{className:"py-2 text-sm text-right font-mono text-foreground",children:C(I.total_cost)})]},I.user_uuid))})]})}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"无可用的使用数据"})]})]})}function Li({onClose:t,onInstalled:r,onOpenRepoManager:a}){const[o,n]=s.useState([]),[l,i]=s.useState([]),[d,x]=s.useState(!0),[p,b]=s.useState(null),[C,j]=s.useState(""),[y,h]=s.useState("all"),[$,M]=s.useState(null);s.useEffect(()=>{I()},[]);const I=async()=>{try{x(!0),b(null);const[m,k]=await Promise.all([ne("/api/skills/available"),ne("/api/skills/repos")]);if(m.ok){const w=await m.json();n(w.skills||[])}if(k.ok){const w=await k.json();i(w.repos||[])}}catch(m){b(m.message)}finally{x(!1)}},E=async m=>{try{M(m.name);const k=await ne(`/api/skills/install/${m.name}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({skillPath:m.path})});if(k.ok)I(),r?.();else{const w=await k.json();alert(w.error||"Failed to install skill")}}catch(k){alert(k.message)}finally{M(null)}},g=o.filter(m=>{if(C){const k=C.toLowerCase();if(!m.name.toLowerCase().includes(k)&&!m.title?.toLowerCase().includes(k)&&!m.description?.toLowerCase().includes(k))return!1}return!(y!=="all"&&m.repository!==y)});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(J,{variant:"ghost",size:"sm",onClick:I,disabled:d,children:[e.jsx(or,{className:`w-4 h-4 ${d?"animate-spin":""}`}),e.jsx("span",{className:"ml-1 hidden sm:inline",children:"刷新"})]}),e.jsxs(J,{variant:"ghost",size:"sm",onClick:a,children:[e.jsx(Tt,{className:"w-4 h-4"}),e.jsx("span",{className:"ml-1 hidden sm:inline",children:"仓库管理"})]}),e.jsx(J,{variant:"ghost",size:"icon",onClick:t,children:e.jsx(Fe,{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(Dt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(Ke,{type:"text",placeholder:"搜索技能名称或描述...",value:C,onChange:m=>j(m.target.value),className:"pl-10"})]})}),e.jsxs("select",{value:y,onChange:m=>h(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:"加载中..."}):g.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(J,{variant:"outline",size:"sm",className:"mt-4",onClick:a,children:[e.jsx(Tt,{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:g.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(J,{variant:"ghost",size:"sm",onClick:()=>window.open(`https://github.com/${m.repository}`,"_blank"),children:[e.jsx(Js,{className:"w-4 h-4 mr-1"}),"查看"]}),m.installed?e.jsx(J,{size:"sm",disabled:!0,variant:"outline",className:"ml-auto",children:"已安装"}):e.jsxs(J,{size:"sm",className:"bg-amber-600 hover:bg-amber-700 text-white ml-auto",onClick:()=>E(m),disabled:$===m.name,children:[e.jsx(qr,{className:"w-4 h-4 mr-1"}),$===m.name?"安装中...":"安装"]})]})]})},`${m.repository}-${m.name}`))})]})]})})}function Ii({onClose:t,onChanged:r}){const[a,o]=s.useState([]),[n,l]=s.useState(!0),[i,d]=s.useState(null),[x,p]=s.useState(""),[b,C]=s.useState("main"),[j,y]=s.useState(!1),[h,$]=s.useState(null);s.useEffect(()=>{M()},[]);const M=async()=>{try{l(!0),d(null);const g=await ne("/api/skills/repos");if(g.ok){const m=await g.json();o(m.repos||[])}else{const m=await g.json();d(m.error||"Failed to fetch repos")}}catch(g){d(g.message)}finally{l(!1)}},I=async g=>{if(g.preventDefault(),!x.trim()){d("请输入仓库 URL");return}try{y(!0),d(null);const m=await ne("/api/skills/repos",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:x.trim(),branch:b.trim()||"main"})});if(m.ok)p(""),C("main"),M(),r?.();else{const k=await m.json();d(k.error||"Failed to add repo")}}catch(m){d(m.message)}finally{y(!1)}},E=async(g,m)=>{if(confirm(`确定要移除仓库 "${g}/${m}" 吗?`))try{$(`${g}/${m}`);const k=await ne(`/api/skills/repos/${g}/${m}`,{method:"DELETE"});if(k.ok)M(),r?.();else{const w=await k.json();alert(w.error||"Failed to remove repo")}}catch(k){alert(k.message)}finally{$(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(J,{variant:"ghost",size:"icon",onClick:t,children:e.jsx(xr,{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:I,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(Ke,{type:"text",placeholder:"owner/name 或 https://github.com/owner/name",value:x,onChange:g=>p(g.target.value),disabled:j})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm text-muted-foreground mb-1",children:"分支"}),e.jsx(Ke,{type:"text",placeholder:"main",value:b,onChange:g=>C(g.target.value),disabled:j})]}),e.jsxs(J,{type:"submit",disabled:j||!x.trim(),className:"bg-amber-600 hover:bg-amber-700 text-white",children:[e.jsx(st,{className:"w-4 h-4 mr-2"}),j?"添加中...":"添加仓库"]})]})]}),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(g=>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:[g.owner,"/",g.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(Ve,{variant:"outline",className:"text-xs",children:["识别到 ",g.skillCount," 个技能"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>window.open(g.url,"_blank"),children:e.jsx(Js,{className:"w-4 h-4"})}),e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>E(g.owner,g.repo),disabled:h===`${g.owner}/${g.repo}`,className:"text-red-500 hover:text-red-600",children:e.jsx(Ge,{className:"w-4 h-4"})})]})]})},`${g.owner}/${g.repo}`))]})]})]})})}function Di(){const[t,r]=s.useState([]),[a,o]=s.useState(!0),[n,l]=s.useState(null),[i,d]=s.useState(!1),[x,p]=s.useState(!1),[b,C]=s.useState(!1),j=s.useRef(null);s.useEffect(()=>{y()},[]);const y=async()=>{try{o(!0),l(null);const E=await ne("/api/skills");if(E.ok){const g=await E.json();r(g.skills||[])}else{const g=await E.json();l(g.error||"Failed to fetch skills")}}catch(E){l(E.message)}finally{o(!1)}},h=async E=>{if(confirm(`确定要删除技能 "${E}" 吗?`))try{const g=await ne(`/api/skills/${E}`,{method:"DELETE"});if(g.ok)y();else{const m=await g.json();alert(m.error||"Failed to delete skill")}}catch(g){alert(g.message)}},$=()=>{j.current?.click()},M=async E=>{const g=E.target.files?.[0];if(g)try{C(!0);const m=new FormData;m.append("skillZip",g);const k=await ne("/api/skills/import",{method:"POST",body:m});if(k.ok)y();else{const w=await k.json();alert(w.error||"Failed to import skill")}}catch(m){alert(m.message)}finally{C(!1),j.current&&(j.current.value="")}},I=(E,g)=>{switch(E){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:g||"仓库"});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(Rr,{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:j,type:"file",accept:".zip",className:"hidden",onChange:M}),e.jsxs(J,{onClick:$,variant:"outline",size:"sm",disabled:b,children:[e.jsx(qr,{className:"w-4 h-4 mr-2"}),b?"导入中...":"导入已有"]}),e.jsxs(J,{onClick:()=>d(!0),className:"bg-amber-600 hover:bg-amber-700 text-white",size:"sm",children:[e.jsx(Dt,{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(Rr,{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(E=>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:E.title||E.name}),I(E.source,E.repository)]}),E.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:E.description})]}),e.jsx("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:e.jsx(J,{variant:"ghost",size:"sm",onClick:()=>h(E.name),className:"text-red-500 hover:text-red-600",title:"删除技能",children:e.jsx(Ge,{className:"w-4 h-4"})})})]})},E.name))}),i&&e.jsx(Li,{onClose:()=>d(!1),onInstalled:y,onOpenRepoManager:()=>{d(!1),p(!0)}}),x&&e.jsx(Ii,{onClose:()=>p(!1),onChanged:()=>{}})]})}function Ti({isOpen:t,onClose:r,projects:a=[],initialTab:o="agents"}){const n=$s(),{isDarkMode:l,toggleDarkMode:i}=es(),{user:d,logout:x}=$t(),p=d?.role==="admin",[b,C]=s.useState([]),[j,y]=s.useState([]),[h,$]=s.useState(""),[M,I]=s.useState(""),[E,g]=s.useState(!1),[m,k]=s.useState(!1),[w,R]=s.useState(null),[W,F]=s.useState("name"),[Q,ie]=s.useState([]),[Z,se]=s.useState(!1),[B,T]=s.useState(null),[_,Y]=s.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[pe,ae]=s.useState(!1),[V,xe]=s.useState({}),[Ne,Ce]=s.useState({}),[je,_e]=s.useState({}),[he,Se]=s.useState(o),[ke,Ee]=s.useState(""),[ye,Re]=s.useState("permissions"),[Pe,Me]=s.useState(!1),[H,f]=s.useState(""),[v,O]=s.useState(""),[oe,ue]=s.useState(""),[Le,He]=s.useState(""),[Ye,qe]=s.useState(""),[u,A]=s.useState(!1),[X,te]=s.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[D,Ie]=s.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[Be,De]=s.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[q,me]=s.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[re,le]=s.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),ve=async()=>{try{const z=await ne("/api/mcp/config/read");if(z.ok){const fe=await z.json();if(fe.success&&fe.servers){ie(fe.servers);return}}const G=await ne("/api/mcp/cli/list");if(G.ok){const fe=await G.json();if(fe.success&&fe.servers){const it=fe.servers.map(Qe=>({id:Qe.name,name:Qe.name,type:Qe.type,scope:"user",config:{command:Qe.command||"",args:Qe.args||[],env:Qe.env||{},url:Qe.url||"",headers:Qe.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));ie(it);return}}const de=await ne("/api/mcp/servers?scope=user");if(de.ok){const fe=await de.json();ie(fe.servers||[])}else console.error("Failed to fetch MCP servers")}catch(z){console.error("Error fetching MCP servers:",z)}},ze=async z=>{try{B&&await ge(B.id,"user");const G=await ne("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:z.name,type:z.type,scope:z.scope,projectPath:z.projectPath,command:z.config?.command,args:z.config?.args||[],url:z.config?.url,headers:z.config?.headers||{},env:z.config?.env||{}})});if(G.ok){const de=await G.json();if(de.success)return await ve(),!0;throw new Error(de.error||"Failed to save server via Claude CLI")}else{const de=await G.json();throw new Error(de.error||"Failed to save server")}}catch(G){throw console.error("Error saving MCP server:",G),G}},ge=async(z,G="user")=>{try{const de=await ne(`/api/mcp/cli/remove/${z}?scope=${G}`,{method:"DELETE"});if(de.ok){const fe=await de.json();if(fe.success)return await ve(),!0;throw new Error(fe.error||"Failed to delete server via Claude CLI")}else{const fe=await de.json();throw new Error(fe.error||"Failed to delete server")}}catch(de){throw console.error("Error deleting MCP server:",de),de}},We=async(z,G="user")=>{try{const de=await ne(`/api/mcp/servers/${z}/test?scope=${G}`,{method:"POST"});if(de.ok)return(await de.json()).testResult;{const fe=await de.json();throw new Error(fe.error||"Failed to test server")}}catch(de){throw console.error("Error testing MCP server:",de),de}},zt=async(z,G="user")=>{try{const de=await ne(`/api/mcp/servers/${z}/tools?scope=${G}`,{method:"POST"});if(de.ok)return(await de.json()).toolsResult;{const fe=await de.json();throw new Error(fe.error||"Failed to discover tools")}}catch(de){throw console.error("Error discovering MCP tools:",de),de}};s.useEffect(()=>{t&&(et(),Se(o),Me(!1))},[t,o]),s.useEffect(()=>{localStorage.setItem("codeEditorTheme",X),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[X]),s.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",D.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[D]),s.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",Be.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Be]),s.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",q.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[q]),s.useEffect(()=>{localStorage.setItem("codeEditorFontSize",re),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[re]);const et=async()=>{try{const z=localStorage.getItem("claude-settings");if(z){const G=JSON.parse(z);C(G.allowedTools||[]),y(G.disallowedTools||[]),g(G.skipPermissions||!1),F(G.projectSortOrder||"name")}else C([]),y([]),g(!1),F("name");await ve()}catch(z){console.error("Error loading tool settings:",z),C([]),y([]),g(!1),F("name")}},_t=()=>{k(!0),R(null);try{const z={allowedTools:b,disallowedTools:j,skipPermissions:E,projectSortOrder:W,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(z)),R("success"),setTimeout(()=>{r()},1e3)}catch(z){console.error("Error saving tool settings:",z),R("error")}finally{k(!1)}},bt=async z=>{if(z.preventDefault(),He(""),qe(""),!H){He("请输入当前密码");return}if(!v){He("请输入新密码");return}if(v.length<6){He("新密码至少需要6个字符");return}if(v!==oe){He("两次输入的新密码不一致");return}A(!0);try{const G=await we.auth.changePassword(H,v),de=await G.json();G.ok?(qe("密码修改成功"),f(""),O(""),ue("")):He(de.error||"修改密码失败")}catch(G){console.error("Error changing password:",G),He("网络错误,请稍后再试")}finally{A(!1)}},Kt=d?.username&&!d.username.includes("@"),yt=()=>{Y({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),T(null),se(!1),Ee("")},tt=(z=null)=>{z?(T(z),Y({name:z.name,type:z.type,scope:z.scope,projectPath:z.projectPath||"",config:{...z.config},raw:z.raw,importMode:"form",jsonInput:""})):yt(),se(!0)},hr=async z=>{z.preventDefault(),ae(!0);try{if(_.importMode==="json"){const G=await ne("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:_.name,jsonConfig:_.jsonInput,scope:_.scope,projectPath:_.projectPath})});if(G.ok){const de=await G.json();if(de.success)await ve(),yt(),R("success");else throw new Error(de.error||"Failed to add server via JSON")}else{const de=await G.json();throw new Error(de.error||"Failed to add server")}}else await ze(_),yt(),R("success")}catch(G){alert(`Error: ${G.message}`),R("error")}finally{ae(!1)}},At=async(z,G)=>{if(confirm("确定要删除此 MCP 服务器吗?"))try{await ge(z,G),R("success")}catch(de){alert(`Error: ${de.message}`),R("error")}},Ot=async(z,G)=>{try{xe({...V,[z]:{loading:!0}});const de=await We(z,G);xe({...V,[z]:de})}catch(de){xe({...V,[z]:{success:!1,message:de.message,details:[]}})}},Gt=async(z,G)=>{try{_e({...je,[z]:!0});const de=await zt(z,G);Ce({...Ne,[z]:de})}catch{Ce({...Ne,[z]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{_e({...je,[z]:!1})}},at=(z,G)=>{Y(de=>({...de,config:{...de.config,[z]:G}}))};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(Tt,{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(J,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:e.jsx(Fe,{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 ${he==="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 ${he==="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 ${he==="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 ${he==="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:[he==="appearance"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:he==="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(Pr,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx($r,{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:W,onChange:z=>F(z.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:()=>te(X==="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":X==="dark","aria-label":"Toggle editor theme",children:[e.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),e.jsx("span",{className:`${X==="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:X==="dark"?e.jsx(Pr,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx($r,{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:()=>Ie(!D),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":D,"aria-label":"Toggle word wrap",children:[e.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),e.jsx("span",{className:`${D?"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:()=>De(!Be),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,"aria-label":"Toggle minimap",children:[e.jsx("span",{className:"sr-only",children:"Toggle minimap"}),e.jsx("span",{className:`${Be?"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:()=>me(!q),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":q,"aria-label":"Toggle line numbers",children:[e.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),e.jsx("span",{className:`${q?"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:re,onChange:z=>le(z.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"})]})]})})]})]})}),he==="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:()=>Re("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 ${ye==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"权限"}),e.jsx("button",{onClick:()=>Re("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 ${ye==="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:()=>Re("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 ${ye==="skills"?"border-amber-600 text-amber-600 dark:text-amber-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:"技能"}),e.jsx("button",{onClick:()=>Re("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 ${ye==="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:[ye==="permissions"&&e.jsx(bi,{agent:"claude",skipPermissions:E,setSkipPermissions:g,allowedTools:b,setAllowedTools:C,disallowedTools:j,setDisallowedTools:y,newAllowedTool:h,setNewAllowedTool:$,newDisallowedTool:M,setNewDisallowedTool:I}),ye==="mcp"&&e.jsx(ki,{agent:"claude",servers:Q,onAdd:()=>tt(),onEdit:z=>tt(z),onDelete:(z,G)=>At(z,G),onTest:(z,G)=>Ot(z,G),onDiscoverTools:(z,G)=>Gt(z,G),testResults:V,serverTools:Ne,toolsLoading:je}),ye==="skills"&&e.jsx(Di,{}),ye==="models"&&e.jsx(Si,{})]})]})}),he==="users"&&p&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:Pe?e.jsx(Mi,{onBack:()=>Me(!1)}):e.jsxs(e.Fragment,{children:[e.jsx(Ci,{onNavigateToUsage:()=>Me(!0)}),e.jsx(Ei,{})]})}),he==="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"?"管理员":"用户"})]})]})}),Kt&&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(qs,{className:"w-5 h-5 text-blue-600"}),e.jsx("div",{className:"font-medium text-foreground",children:"修改密码"})]}),e.jsxs("form",{onSubmit:bt,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:H,onChange:z=>f(z.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:u})]}),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:z=>O(z.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:u})]}),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:oe,onChange:z=>ue(z.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:u})]}),Le&&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:Le})}),Ye&&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:Ye})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(J,{type:"submit",disabled:u,className:"bg-blue-600 hover:bg-blue-700",children: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",{children:[e.jsx("div",{className:"font-medium text-foreground",children:"退出登录"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"结束当前会话"})]}),e.jsxs(J,{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("确定要退出登录吗?")&&(r(),n("/"),x())},children:[e.jsx(xn,{className:"w-4 h-4"}),"退出"]})]})})]})}),Z&&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:B?"编辑 MCP 服务器":"添加 MCP 服务器"}),e.jsx(J,{variant:"ghost",size:"sm",onClick:yt,children:e.jsx(Fe,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:hr,className:"p-4 space-y-4",children:[!B&&e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("button",{type:"button",onClick:()=>Y(z=>({...z,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:()=>Y(z=>({...z,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"&&B&&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(Tr,{className:"w-4 h-4"}):e.jsx(kt,{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"&&!B&&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:()=>Y(z=>({...z,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(Tr,{className:"w-4 h-4"}),e.jsx("span",{children:"用户(全局)"})]})}),e.jsx("button",{type:"button",onClick:()=>Y(z=>({...z,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(kt,{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"&&!B&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"项目 *"}),e.jsxs("select",{value:_.projectPath,onChange:z=>Y(G=>({...G,projectPath:z.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(z=>e.jsx("option",{value:z.path||z.fullPath,children:z.displayName||z.name},z.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(Ke,{value:_.name,onChange:z=>{Y(G=>({...G,name:z.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:z=>{Y(G=>({...G,type:z.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"})]})]})]}),B&&_.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 ",B.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:z=>{Y(G=>({...G,jsonInput:z.target.value}));try{if(z.target.value.trim()){const G=JSON.parse(z.target.value);G.type?G.type==="stdio"&&!G.command?Ee("stdio 类型需要 command 字段"):(G.type==="http"||G.type==="sse")&&!G.url?Ee(`${G.type} 类型需要 url 字段`):Ee(""):Ee("缺少必填字段:type")}}catch{z.target.value.trim()?Ee("无效的 JSON 格式"):Ee("")}},className:`w-full px-3 py-2 border ${ke?"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}),ke&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:ke}),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"}']})]})}),
|
|
143
|
-
`):"",onChange:
|
|
144
|
-
`).filter(
|
|
145
|
-
abc123`})]})]}),
|
|
146
|
-
`),onChange:
|
|
147
|
-
`).forEach(de=>{const[fe,...it]=de.split("=");fe&&fe.trim()&&(
|
|
148
|
-
DEBUG=true`})]}),
|
|
149
|
-
`),onChange:
|
|
150
|
-
`).forEach(de=>{const[fe,...it]=de.split("=");fe&&fe.trim()&&(
|
|
151
|
-
X-API-Key=your-key`})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(J,{type:"button",variant:"outline",onClick:yt,children:"取消"}),e.jsx(J,{type:"submit",disabled:pe,className:"bg-purple-600 hover:bg-purple-700 disabled:opacity-50",children:pe?"保存中...":B?"更新服务器":"添加服务器"})]})]})]})})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-4 md:p-6 border-t border-border flex-shrink-0 gap-3 pb-safe-area-inset-bottom",children:[e.jsxs("div",{className:"flex items-center justify-center sm:justify-start gap-2 order-2 sm:order-1",children:[S==="success"&&e.jsxs("div",{className:"text-green-600 dark:text-green-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),"设置保存成功!"]}),S==="error"&&e.jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),"保存设置失败"]})]}),e.jsxs("div",{className:"flex items-center gap-3 order-1 sm:order-2",children:[e.jsx(J,{variant:"outline",onClick:r,disabled:d,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:"取消"}),e.jsx(J,{onClick:_t,disabled:d,className:"flex-1 sm:flex-none h-10 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 touch-manipulation",children:d?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),"保存中..."]}):"保存设置"})]})]})]})}):null}function Ii(){const{isDarkMode:t,toggleDarkMode:r}=Yr();return e.jsxs("button",{onClick:r,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":t,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${t?"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:t?e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})}):e.jsx("svg",{className:"w-3.5 h-3.5 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})})})]})}const Ti=({isOpen:t,onToggle:r,autoExpandTools:a,onAutoExpandChange:o,showRawParameters:n,onShowRawParametersChange:c,showThinking:i,onShowThinkingChange:m,autoScrollToBottom:h,onAutoScrollChange:p,sendByCtrlEnter:b,onSendByCtrlEnterChange:E,isMobile:v})=>{const[j,g]=s.useState(t),[$,L]=s.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:I}=Yr(),[C,x]=s.useState(()=>{const G=localStorage.getItem("quickSettingsHandlePosition");if(G)try{return JSON.parse(G).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[d,k]=s.useState(!1),[S,A]=s.useState(0),[W,O]=s.useState(0),[Q,ie]=s.useState(!1),Z=s.useRef(null),se=s.useRef({min:10,max:90}),B=5;s.useEffect(()=>{g(t)},[t]),s.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:C}))},[C]);const T=s.useCallback(()=>v?{bottom:`${window.innerHeight*C/100}px`}:{top:`${C}%`,transform:"translateY(-50%)"},[C,v]),z=s.useCallback(G=>{G.stopPropagation();const xe=G.type.includes("touch")?G.touches[0].clientY:G.clientY;A(xe),O(C),ie(!1),k(!1)},[C]),Y=s.useCallback(G=>{if(S===0)return;const xe=G.type.includes("touch")?G.touches[0].clientY:G.clientY,Ne=Math.abs(xe-S);if(!d&&Ne>B&&(k(!0),ie(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",G.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!d)return;G.type.includes("touch")&&G.preventDefault();const Ce=xe-S;let je;v?je=-(Ce/window.innerHeight)*100:je=Ce/window.innerHeight*100;let _e=W+je;_e=Math.max(se.current.min,Math.min(se.current.max,_e)),x(_e)},[d,S,W,v,B]),pe=s.useCallback(()=>{k(!1),A(0),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]);s.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]),s.useEffect(()=>{if(S!==0){const G=je=>Y(je),xe=()=>pe(),Ne=je=>Y(je),Ce=()=>pe();return document.addEventListener("mousemove",G),document.addEventListener("mouseup",xe),document.addEventListener("touchmove",Ne,{passive:!1}),document.addEventListener("touchend",Ce),()=>{document.removeEventListener("mousemove",G),document.removeEventListener("mouseup",xe),document.removeEventListener("touchmove",Ne),document.removeEventListener("touchend",Ce)}}},[S,Y,pe]);const ae=G=>{if(Q){G.preventDefault(),ie(!1);return}const xe=!j;g(xe),r(xe)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:Z,onClick:ae,onMouseDown:G=>{z(G)},onTouchStart:G=>{z(G)},className:`fixed ${j?"right-64":"right-0"} z-50 ${d?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${d?"border-blue-500 dark:border-blue-400":"border-gray-200 dark:border-gray-700"} rounded-l-md p-2 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors shadow-lg ${d?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{...T(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":d?"拖动手柄":j?"关闭设置面板":"打开设置面板",title:d?"拖动中...":"点击切换,拖动移动",children:d?e.jsx(hn,{className:"h-5 w-5 text-blue-500 dark:text-blue-400"}):j?e.jsx(Lt,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):e.jsx(gn,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),e.jsx("div",{className:`fixed top-0 right-0 h-full w-64 bg-background border-l border-border shadow-xl transform transition-transform duration-150 ease-out z-40 ${j?"translate-x-0":"translate-x-full"} ${v?"h-screen":""}`,children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(fn,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}),"快速设置"]})}),e.jsxs("div",{className:`flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-6 bg-background ${v?"pb-mobile-nav":""}`,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:"外观"}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[I?e.jsx(Rr,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):e.jsx($r,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"深色模式"]}),e.jsx(Ii,{})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:"工具显示"}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx($s,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"自动展开工具"]}),e.jsx("input",{type:"checkbox",checked:a,onChange:G=>o(G.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(zs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"显示原始参数"]}),e.jsx("input",{type:"checkbox",checked:n,onChange:G=>c(G.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(Ps,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"显示思考过程"]}),e.jsx("input",{type:"checkbox",checked:i,onChange:G=>m(G.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:"视图选项"}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(bn,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"自动滚动到底部"]}),e.jsx("input",{type:"checkbox",checked:h,onChange:G=>p(G.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:"输入设置"}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(yn,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"使用 Ctrl+Enter 发送"]}),e.jsx("input",{type:"checkbox",checked:b,onChange:G=>E(G.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 ml-3",children:"启用后,按 Ctrl+Enter 发送消息而不是 Enter。这对于输入法用户很有用,可以避免误发送。"})]}),e.jsxs("div",{className:"space-y-2",style:{display:"none"},children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:"语音输入"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"default",checked:$==="default",onChange:()=>{L("default"),localStorage.setItem("whisperMode","default"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(nr,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"默认模式"]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"直接转录您的语音"})]})]}),e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"prompt",checked:$==="prompt",onChange:()=>{L("prompt"),localStorage.setItem("whisperMode","prompt"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(Pr,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"提示词增强"]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"将粗略的想法转化为清晰、详细的 AI 提示词"})]})]}),e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"vibe",checked:$==="vibe"||$==="instructions"||$==="architect",onChange:()=>{L("vibe"),localStorage.setItem("whisperMode","vibe"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(_s,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"氛围模式"]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"将想法格式化为带有详细说明的代理指令"})]})]})]})]})]})]})}),j&&e.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:ae})]})};function Pi({isOpen:t,limitType:r,onClose:a}){if(!t)return null;const o=r==="total_limit_exceeded";return e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[100]",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-xl w-full max-w-md p-6 mx-4 animate-in fade-in zoom-in-95 duration-200",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-red-100 dark:bg-red-900/30 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx(Pt,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:o?"使用上限已达到":"今日使用上限已达到"})})]}),e.jsx("button",{onClick:a,className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:e.jsx(Oe,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"mb-6 text-muted-foreground space-y-3",children:o?e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"您的账户已达到使用总额度上限。"}),e.jsx("p",{className:"text-sm",children:"请联系管理员提升您的额度限制,以继续使用 Claude 服务。"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"您已达到今日使用额度上限。"}),e.jsx("p",{className:"text-sm",children:"您可以等待明日额度重置后继续使用,或联系管理员提升您的每日额度限制。"})]})}),e.jsx("div",{className:"mb-6 p-3 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg",children:e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:o?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"提示:"}),"请联系您的管理员,申请提升使用额度。"]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"提示:"}),"每日额度将在次日 00:00 自动重置,您也可以联系管理员调整限额。"]})})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(J,{variant:"default",onClick:a,children:"我知道了"})})]})})}function Ri(){const[t,r]=s.useState(null),[a,o]=s.useState([]),[n,c]=s.useState(!1),i=s.useRef(null),m=s.useRef(null),{token:h}=$t();s.useEffect(()=>(i.current&&(clearTimeout(i.current),i.current=null),m.current&&(m.current.close(),m.current=null),h||!1?p():(c(!1),r(null)),()=>{i.current&&clearTimeout(i.current),m.current&&m.current.close()}),[h]);const p=()=>{try{let v;{const g=h||localStorage.getItem("auth-token");if(!g){console.warn("No authentication token found for WebSocket connection");return}v=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws?token=${encodeURIComponent(g)}`}const j=new WebSocket(v);m.current=j,j.onopen=()=>{c(!0),r(j)},j.onmessage=g=>{try{const $=JSON.parse(g.data);o(L=>[...L,$])}catch($){console.error("Error parsing WebSocket message:",$)}},j.onclose=()=>{c(!1),r(null),m.current=null,localStorage.getItem("auth-token")&&(i.current=setTimeout(()=>{p()},3e3))},j.onerror=g=>{console.error("WebSocket error:",g)}}catch(E){console.error("Error creating WebSocket connection:",E)}};return{ws:t,sendMessage:E=>{t&&n?t.send(JSON.stringify(E)):console.warn("WebSocket not connected")},messages:a,isConnected:n}}const oa=s.createContext({ws:null,sendMessage:()=>{},messages:[],isConnected:!1}),$i=()=>{const t=s.useContext(oa);if(!t)throw new Error("useWebSocketContext must be used within a WebSocketProvider");return t},zi=({children:t})=>{const r=Ri();return e.jsx(oa.Provider,{value:r,children:t})},_i=()=>{const[t,r]=s.useState("email"),[a,o]=s.useState(""),[n,c]=s.useState(""),[i,m]=s.useState(!1),[h,p]=s.useState(""),[b,E]=s.useState(0),{sendCode:v,verifyCode:j,smtpConfigured:g}=$t();s.useEffect(()=>{if(b>0){const x=setTimeout(()=>E(b-1),1e3);return()=>clearTimeout(x)}},[b]);const $=async x=>{if(x.preventDefault(),p(""),!a||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)){p("请输入有效的邮箱地址");return}m(!0);const k=await v(a);k.success?(r("code"),E(60)):(p(k.error),k.waitSeconds&&E(k.waitSeconds)),m(!1)},L=async x=>{if(x.preventDefault(),p(""),!n||n.length!==6){p("请输入6位验证码");return}m(!0);const d=await j(a,n);d.success||p(d.error),m(!1)},I=async()=>{if(b>0)return;p(""),m(!0);const x=await v(a);x.success?E(60):p(x.error),m(!1)},C=()=>{r("email"),c(""),p("")};return g?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(ot,{size:64})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:t==="email"?"欢迎使用 AgentHub":"创建管理员账户"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:t==="email"?"输入邮箱创建管理员账户":`验证码已发送至 ${a}`})]}),t==="email"&&e.jsxs("form",{onSubmit:$,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-foreground mb-1",children:"邮箱地址"}),e.jsxs("div",{className:"relative",children:[e.jsx(ir,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-muted-foreground"}),e.jsx("input",{type:"email",id:"email",value:a,onChange:x=>o(x.target.value),className:"w-full pl-10 pr-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入邮箱地址",required:!0,disabled:i,autoComplete:"email"})]})]}),h&&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:h})}),e.jsx("button",{type:"submit",disabled:i||b>0,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:i?"发送中...":b>0?`${b}秒后可重新发送`:"获取验证码"})]}),t==="code"&&e.jsxs("form",{onSubmit:L,className:"space-y-4",children:[e.jsxs("button",{type:"button",onClick:C,className:"flex items-center text-sm text-muted-foreground hover:text-foreground",children:[e.jsx(xr,{className:"w-4 h-4 mr-1"}),"返回修改邮箱"]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"code",className:"block text-sm font-medium text-foreground mb-1",children:"验证码"}),e.jsx("input",{type:"text",id:"code",value:n,onChange:x=>c(x.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground text-center text-2xl tracking-widest focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"000000",required:!0,disabled:i,maxLength:6,autoComplete:"one-time-code"})]}),h&&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:h})}),e.jsx("button",{type:"submit",disabled:i||n.length!==6,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:i?"创建中...":"创建管理员账户"}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:I,disabled:b>0||i,className:"text-sm text-blue-500 hover:text-blue-600 disabled:text-muted-foreground",children:b>0?`${b}秒后可重新发送`:"重新发送验证码"})})]}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"首个注册的用户将成为管理员"})})]})})}):e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(ot,{size:64})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"欢迎使用 AgentHub"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"系统初始化"})]}),e.jsxs("div",{className:"p-4 bg-yellow-100 dark:bg-yellow-900/20 border border-yellow-300 dark:border-yellow-800 rounded-md",children:[e.jsx("p",{className:"text-sm text-yellow-700 dark:text-yellow-400",children:"SMTP 邮件服务未配置。请联系管理员配置以下环境变量后重启服务:"}),e.jsxs("ul",{className:"mt-2 text-sm text-yellow-700 dark:text-yellow-400 list-disc list-inside",children:[e.jsx("li",{children:"SMTP_SERVER"}),e.jsx("li",{children:"SMTP_PORT"}),e.jsx("li",{children:"SMTP_USERNAME"}),e.jsx("li",{children:"SMTP_PASSWORD"})]})]})]})})})},Ai=()=>{const[t,r]=s.useState("email"),[a,o]=s.useState("email"),[n,c]=s.useState(""),[i,m]=s.useState(""),[h,p]=s.useState(""),[b,E]=s.useState(""),[v,j]=s.useState(!1),[g,$]=s.useState(""),[L,I]=s.useState(0),[C,x]=s.useState(!1),{login:d,sendCode:k,verifyCode:S,smtpConfigured:A}=$t();s.useEffect(()=>{if(L>0){const T=setTimeout(()=>I(L-1),1e3);return()=>clearTimeout(T)}},[L]),s.useEffect(()=>{A||r("password")},[A]);const W=async T=>{if(T.preventDefault(),$(""),!n||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)){$("请输入有效的邮箱地址");return}j(!0);const Y=await k(n);Y.success?(o("code"),I(60),x(Y.type==="register")):($(Y.error),Y.waitSeconds&&I(Y.waitSeconds)),j(!1)},O=async T=>{if(T.preventDefault(),$(""),!i||i.length!==6){$("请输入6位验证码");return}j(!0);const z=await S(n,i);z.success||$(z.error),j(!1)},Q=async()=>{if(L>0)return;$(""),j(!0);const T=await k(n);T.success?I(60):$(T.error),j(!1)},ie=async T=>{if(T.preventDefault(),$(""),!h||!b){$("请输入用户名和密码");return}j(!0);const z=await d(h,b);z.success||$(z.error),j(!1)},Z=()=>{o("email"),m(""),$("")},se=()=>{r("email"),o("email"),$("")},B=()=>{r("password"),$("")};return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"w-16 h-16 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:e.jsx(Dt,{className:"w-8 h-8 text-primary-foreground"})})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:t==="email"?a==="email"?"欢迎使用 AgentHub":C?"创建您的账户":"验证您的身份":"欢迎回来"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:t==="email"?a==="email"?"输入邮箱以接收验证码":`验证码已发送至 ${n}`:"使用账号密码登录"})]}),t==="email"&&a==="email"&&e.jsxs("form",{onSubmit:W,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-foreground mb-1",children:"邮箱地址"}),e.jsxs("div",{className:"relative",children:[e.jsx(ir,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-muted-foreground"}),e.jsx("input",{type:"email",id:"email",value:n,onChange:T=>c(T.target.value),className:"w-full pl-10 pr-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入邮箱地址",required:!0,disabled:v,autoComplete:"email"})]})]}),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.jsx("button",{type:"submit",disabled:v||L>0,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:v?"发送中...":L>0?`${L}秒后可重新发送`:"获取验证码"})]}),t==="email"&&a==="code"&&e.jsxs("form",{onSubmit:O,className:"space-y-4",children:[e.jsxs("button",{type:"button",onClick:Z,className:"flex items-center text-sm text-muted-foreground hover:text-foreground",children:[e.jsx(xr,{className:"w-4 h-4 mr-1"}),"返回修改邮箱"]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"code",className:"block text-sm font-medium text-foreground mb-1",children:"验证码"}),e.jsx("input",{type:"text",id:"code",value:i,onChange:T=>m(T.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground text-center text-2xl tracking-widest focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"000000",required:!0,disabled:v,maxLength:6,autoComplete:"one-time-code"})]}),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.jsx("button",{type:"submit",disabled:v||i.length!==6,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:v?"验证中...":C?"创建账户并登录":"登录"}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:Q,disabled:L>0||v,className:"text-sm text-blue-500 hover:text-blue-600 disabled:text-muted-foreground",children:L>0?`${L}秒后可重新发送`:"重新发送验证码"})})]}),t==="password"&&e.jsxs("form",{onSubmit:ie,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-foreground mb-1",children:"用户名"}),e.jsxs("div",{className:"relative",children:[e.jsx(Fs,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-muted-foreground"}),e.jsx("input",{type:"text",id:"username",value:h,onChange:T=>p(T.target.value),className:"w-full pl-10 pr-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入用户名",required:!0,disabled:v})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:"密码"}),e.jsxs("div",{className:"relative",children:[e.jsx(vn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-muted-foreground"}),e.jsx("input",{type:"password",id:"password",value:b,onChange:T=>E(T.target.value),className:"w-full pl-10 pr-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入密码",required:!0,disabled:v})]})]}),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.jsx("button",{type:"submit",disabled:v,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:v?"登录中...":"登录"})]}),e.jsx("div",{className:"text-center pt-4 border-t border-border",children:t==="email"&&A?e.jsx("button",{type:"button",onClick:B,className:"text-sm text-muted-foreground hover:text-foreground",children:"使用账号密码登录"}):t==="password"&&A?e.jsx("button",{type:"button",onClick:se,className:"text-sm text-muted-foreground hover:text-foreground",children:"使用邮箱验证码登录"}):null})]})})})},Fi=()=>e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"w-16 h-16 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:e.jsx(Dt,{className:"w-8 h-8 text-primary-foreground"})})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"AgentHub"}),e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full animate-bounce"}),e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"加载中..."})]})}),Oi=({children:t})=>{const{user:r,isLoading:a,needsSetup:o}=$t();return a?e.jsx(Fi,{}):o?e.jsx(_i,{}):r?t:e.jsx(Ai,{})};function Mt(t,r){const[a,o]=s.useState(()=>{if(typeof window>"u")return r;try{const c=window.localStorage.getItem(t);return c?JSON.parse(c):r}catch(c){return console.log(c),r}});return[a,c=>{if(!(typeof window>"u"))try{const i=c instanceof Function?c(a):c;window.localStorage.setItem(t,JSON.stringify(i)),o(i)}catch(i){console.log(i)}}]}function Ds(){const t=Is(),{sessionId:r}=qa(),{limitStatus:a,setLimitStatus:o,checkLimitStatus:n}=$t(),[c,i]=s.useState([]),[m,h]=s.useState(null),[p,b]=s.useState(null),[E,v]=s.useState("chat"),[j,g]=s.useState(!1),[$,L]=s.useState(!1),[I,C]=s.useState(!0),[x,d]=s.useState(!1),[k,S]=s.useState(!1),[A,W]=s.useState("agents"),[O,Q]=s.useState(!1),[ie,Z]=Mt("autoExpandTools",!1),[se,B]=Mt("showRawParameters",!1),[T,z]=Mt("showThinking",!0),[Y,pe]=Mt("autoScrollToBottom",!0),[ae,G]=Mt("sendByCtrlEnter",!1),[xe,Ne]=Mt("sidebarVisible",!0),[Ce,je]=s.useState(!1),[_e,he]=s.useState(null),[Se,ke]=s.useState(new Set),[Ee,ye]=s.useState(new Set),[Pe,Re]=s.useState(0),{ws:Me,sendMessage:H,messages:f}=$i(),y=s.useCallback(q=>{he(q),je(!0)},[]),[F,oe]=s.useState(!1);s.useEffect(()=>{const q=()=>{const me=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone||document.referrer.includes("android-app://");oe(me),document.addEventListener("touchstart",{}),me?(document.documentElement.classList.add("pwa-mode"),document.body.classList.add("pwa-mode")):(document.documentElement.classList.remove("pwa-mode"),document.body.classList.remove("pwa-mode"))};return q(),window.matchMedia("(display-mode: standalone)").addEventListener("change",q),()=>{window.matchMedia("(display-mode: standalone)").removeEventListener("change",q)}},[]),s.useEffect(()=>{const q=()=>{g(window.innerWidth<768)};return q(),window.addEventListener("resize",q),()=>window.removeEventListener("resize",q)},[]),s.useEffect(()=>{Le()},[]);const ue=(q,me,re,le)=>{if(!re||!le)return!0;const ve=q?.find(et=>et.name===re.name),ze=me?.find(et=>et.name===re.name);if(!ve||!ze)return!1;const ge=ve.sessions?.find(et=>et.id===le.id),We=ze.sessions?.find(et=>et.id===le.id);return!ge||!We?!1:ge.id===We.id&&ge.title===We.title&&ge.created_at===We.created_at&&ge.updated_at===We.updated_at};s.useEffect(()=>{if(f.length>0){const q=f[f.length-1];if(q.type==="projects_updated"){if(q.changedFile&&p&&m){const ve=q.changedFile.replace(/\\/g,"/").split("/");ve.length>=2&&ve[ve.length-1].replace(".jsonl","")===p.id&&(Se.has(p.id)||Re(zt=>zt+1))}if(p&&Se.has(p.id)||Se.size>0&&Array.from(Se).some(le=>le.startsWith("new-session-"))){const le=q.projects;if(!ue(c,le,m,p))return}const re=q.projects;if(i(re),m){const le=re.find(ve=>ve.name===m.name);le&&(JSON.stringify(le)!==JSON.stringify(m)&&h(le),p&&([...le.sessions||[]].find(ge=>ge.id===p.id)||b(null)))}}}},[f,m,p,Se]);const Le=async()=>{try{C(!0);const me=await(await we.projects()).json();i(re=>re.length===0||me.some((ve,ze)=>{const ge=re[ze];return ge?ve.name!==ge.name||ve.displayName!==ge.displayName||ve.fullPath!==ge.fullPath||JSON.stringify(ve.sessionMeta)!==JSON.stringify(ge.sessionMeta)||JSON.stringify(ve.sessions)!==JSON.stringify(ge.sessions):!0})||me.length!==re.length?me:re)}catch(q){console.error("Error fetching projects:",q)}finally{C(!1)}};window.refreshProjects=Le,window.openSettings=s.useCallback((q="tools")=>{W(q),S(!0)},[]),s.useEffect(()=>{if(r&&c.length>0){const q=!p||p.id!==r;for(const me of c){let re=me.sessions?.find(le=>le.id===r);if(re){h(me),b({...re,__provider:"claude"}),q&&v("chat");return}}}},[r,c,t]);const He=q=>{h(q),b(null),t("/"),j&&L(!1)},Ye=q=>{if(b(q),E!=="git"&&E!=="preview"&&v("chat"),j){const me=q.__projectName,re=m?.name;me!==re&&L(!1)}t(`/session/${q.id}`)},qe=q=>{h(q),b(null),v("chat"),t("/"),j&&L(!1)},u=q=>{p?.id===q&&(b(null),t("/")),i(me=>me.map(re=>({...re,sessions:re.sessions?.filter(le=>le.id!==q)||[],sessionMeta:{...re.sessionMeta,total:Math.max(0,(re.sessionMeta?.total||0)-1)}})))},_=async()=>{try{const me=await(await we.projects()).json();if(i(re=>me.some((ve,ze)=>{const ge=re[ze];return ge?ve.name!==ge.name||ve.displayName!==ge.displayName||ve.fullPath!==ge.fullPath||JSON.stringify(ve.sessionMeta)!==JSON.stringify(ge.sessionMeta)||JSON.stringify(ve.sessions)!==JSON.stringify(ge.sessions):!0})||me.length!==re.length?me:re),m){const re=me.find(le=>le.name===m.name);if(re&&(JSON.stringify(re)!==JSON.stringify(m)&&h(re),p)){const le=re.sessions?.find(ve=>ve.id===p.id);le&&JSON.stringify(le)!==JSON.stringify(p)&&b(le)}}}catch(q){console.error("Error refreshing sidebar:",q)}},X=q=>{m?.name===q&&(h(null),b(null),t("/")),i(me=>me.filter(re=>re.name!==q))},te=s.useCallback(q=>{q&&ke(me=>new Set([...me,q]))},[]),D=s.useCallback(q=>{q&&ke(me=>{const re=new Set(me);return re.delete(q),re})},[]),De=s.useCallback(q=>{q&&ye(me=>new Set([...me,q]))},[]),Be=s.useCallback(q=>{q&&ye(me=>{const re=new Set(me);return re.delete(q),re})},[]),Ie=s.useCallback(q=>{q&&ke(me=>{const re=new Set;for(const le of me)le.startsWith("new-session-")||re.add(le);return re.add(q),re})},[]);return e.jsxs("div",{className:"fixed inset-0 flex bg-background",children:[!j&&e.jsx("div",{className:`h-full flex-shrink-0 border-r border-border bg-card transition-all duration-300 ${xe?"w-80":"w-14"}`,children:e.jsx("div",{className:"h-full overflow-hidden",children:xe?e.jsx(us,{projects:c,selectedProject:m,selectedSession:p,onProjectSelect:He,onSessionSelect:Ye,onNewSession:qe,onSessionDelete:u,onProjectDelete:X,isLoading:I,onRefresh:_,onShowSettings:()=>S(!0),isPWA:F,isMobile:j,onToggleSidebar:()=>Ne(!1)}):e.jsxs("div",{className:"h-full flex flex-col items-center py-4 gap-4",children:[e.jsx("button",{onClick:()=>Ne(!0),className:"p-2 hover:bg-accent rounded-md transition-colors duration-200 group","aria-label":"Show sidebar",title:"Show sidebar",children:e.jsx("svg",{className:"w-5 h-5 text-foreground group-hover:scale-110 transition-transform",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 5l7 7-7 7M5 5l7 7-7 7"})})}),e.jsx("button",{onClick:()=>S(!0),className:"p-2 hover:bg-accent rounded-md transition-colors duration-200","aria-label":"Settings",title:"Settings",children:e.jsx(Tt,{className:"w-5 h-5 text-muted-foreground hover:text-foreground transition-colors"})})]})})}),j&&e.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${$?"opacity-100 visible":"opacity-0 invisible"}`,children:[e.jsx("button",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm transition-opacity duration-150 ease-out",onClick:q=>{q.stopPropagation(),L(!1)},onTouchStart:q=>{q.preventDefault(),q.stopPropagation(),L(!1)},"aria-label":"Close sidebar"}),e.jsx("div",{className:`relative w-[85vw] max-w-sm sm:w-80 h-full bg-card border-r border-border transform transition-transform duration-150 ease-out ${$?"translate-x-0":"-translate-x-full"}`,onClick:q=>q.stopPropagation(),onTouchStart:q=>q.stopPropagation(),children:e.jsx(us,{projects:c,selectedProject:m,selectedSession:p,onProjectSelect:He,onSessionSelect:Ye,onNewSession:qe,onSessionDelete:u,onProjectDelete:X,isLoading:I,onRefresh:_,onShowSettings:()=>S(!0),isPWA:F,isMobile:j,onToggleSidebar:()=>Ne(!1)})})]}),e.jsx("div",{className:`flex-1 flex flex-col min-w-0 ${j&&!x?"pb-mobile-nav":""}`,children:e.jsx(ii,{selectedProject:m,selectedSession:p,activeTab:E,setActiveTab:v,ws:Me,sendMessage:H,messages:f,isMobile:j,isPWA:F,onMenuClick:()=>L(!0),isLoading:I,onInputFocusChange:d,onSessionActive:te,onSessionInactive:D,onSessionProcessing:De,onSessionNotProcessing:Be,processingSessions:Ee,onReplaceTemporarySession:Ie,onNavigateToSession:q=>t(`/session/${q}`),onShowSettings:()=>S(!0),autoExpandTools:ie,showRawParameters:se,showThinking:T,autoScrollToBottom:Y,sendByCtrlEnter:ae,externalMessageUpdate:Pe,limitStatus:a,onLimitBlocked:y,checkLimitStatus:n})}),j&&e.jsx(li,{activeTab:E,setActiveTab:v,isInputFocused:x}),E==="chat"&&e.jsx(Ti,{isOpen:O,onToggle:Q,autoExpandTools:ie,onAutoExpandChange:Z,showRawParameters:se,onShowRawParametersChange:B,showThinking:T,onShowThinkingChange:z,autoScrollToBottom:Y,onAutoScrollChange:pe,sendByCtrlEnter:ae,onSendByCtrlEnterChange:G,isMobile:j}),e.jsx(Di,{isOpen:k,onClose:()=>S(!1),projects:c,initialTab:A}),e.jsx(Pi,{isOpen:Ce,limitType:_e,onClose:()=>je(!1)})]})}function Wi(){return e.jsx(ci,{children:e.jsx(di,{children:e.jsx(zi,{children:e.jsx(Oi,{children:e.jsx(Ua,{children:e.jsxs(Ha,{children:[e.jsx(os,{path:"/",element:e.jsx(Ds,{})}),e.jsx(os,{path:"/session/:sessionId",element:e.jsx(Ds,{})})]})})})})})})}"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(r=>{r.unregister()})}).catch(t=>{console.warn("Failed to unregister service workers:",t)});Tn.createRoot(document.getElementById("root")).render(e.jsx(Xe.StrictMode,{children:e.jsx(Wi,{})}));
|
|
142
|
+
}`,required:!0}),ke&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:ke}),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(Ke,{value:_.config.command,onChange:z=>at("command",z.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
|
+
`):"",onChange:z=>at("args",z.target.value.split(`
|
|
144
|
+
`).filter(G=>G.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(Ke,{value:_.config.url,onChange:z=>at("url",z.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(([z,G])=>`${z}=${G}`).join(`
|
|
146
|
+
`),onChange:z=>{const G={};z.target.value.split(`
|
|
147
|
+
`).forEach(de=>{const[fe,...it]=de.split("=");fe&&fe.trim()&&(G[fe.trim()]=it.join("=").trim())}),at("env",G)},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
|
+
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(([z,G])=>`${z}=${G}`).join(`
|
|
149
|
+
`),onChange:z=>{const G={};z.target.value.split(`
|
|
150
|
+
`).forEach(de=>{const[fe,...it]=de.split("=");fe&&fe.trim()&&(G[fe.trim()]=it.join("=").trim())}),at("headers",G)},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:`Authorization=Bearer token
|
|
151
|
+
X-API-Key=your-key`})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(J,{type:"button",variant:"outline",onClick:yt,children:"取消"}),e.jsx(J,{type:"submit",disabled:pe,className:"bg-purple-600 hover:bg-purple-700 disabled:opacity-50",children:pe?"保存中...":B?"更新服务器":"添加服务器"})]})]})]})})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-4 md:p-6 border-t border-border flex-shrink-0 gap-3 pb-safe-area-inset-bottom",children:[e.jsxs("div",{className:"flex items-center justify-center sm:justify-start gap-2 order-2 sm:order-1",children:[w==="success"&&e.jsxs("div",{className:"text-green-600 dark:text-green-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),"设置保存成功!"]}),w==="error"&&e.jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),"保存设置失败"]})]}),e.jsxs("div",{className:"flex items-center gap-3 order-1 sm:order-2",children:[e.jsx(J,{variant:"outline",onClick:r,disabled:m,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:"取消"}),e.jsx(J,{onClick:_t,disabled:m,className:"flex-1 sm:flex-none h-10 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 touch-manipulation",children:m?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),"保存中..."]}):"保存设置"})]})]})]})}):null}function Ri(){const{isDarkMode:t,toggleDarkMode:r}=es();return e.jsxs("button",{onClick:r,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":t,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${t?"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:t?e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})}):e.jsx("svg",{className:"w-3.5 h-3.5 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})})})]})}const Pi=({isOpen:t,onToggle:r,autoExpandTools:a,onAutoExpandChange:o,showRawParameters:n,onShowRawParametersChange:l,showThinking:i,onShowThinkingChange:d,autoScrollToBottom:x,onAutoScrollChange:p,sendByCtrlEnter:b,onSendByCtrlEnterChange:C,isMobile:j})=>{const[y,h]=s.useState(t),[$,M]=s.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:I}=es(),[E,g]=s.useState(()=>{const V=localStorage.getItem("quickSettingsHandlePosition");if(V)try{return JSON.parse(V).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[m,k]=s.useState(!1),[w,R]=s.useState(0),[W,F]=s.useState(0),[Q,ie]=s.useState(!1),Z=s.useRef(null),se=s.useRef({min:10,max:90}),B=5;s.useEffect(()=>{h(t)},[t]),s.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:E}))},[E]);const T=s.useCallback(()=>j?{bottom:`${window.innerHeight*E/100}px`}:{top:`${E}%`,transform:"translateY(-50%)"},[E,j]),_=s.useCallback(V=>{V.stopPropagation();const xe=V.type.includes("touch")?V.touches[0].clientY:V.clientY;R(xe),F(E),ie(!1),k(!1)},[E]),Y=s.useCallback(V=>{if(w===0)return;const xe=V.type.includes("touch")?V.touches[0].clientY:V.clientY,Ne=Math.abs(xe-w);if(!m&&Ne>B&&(k(!0),ie(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",V.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!m)return;V.type.includes("touch")&&V.preventDefault();const Ce=xe-w;let je;j?je=-(Ce/window.innerHeight)*100:je=Ce/window.innerHeight*100;let _e=W+je;_e=Math.max(se.current.min,Math.min(se.current.max,_e)),g(_e)},[m,w,W,j,B]),pe=s.useCallback(()=>{k(!1),R(0),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]);s.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]),s.useEffect(()=>{if(w!==0){const V=je=>Y(je),xe=()=>pe(),Ne=je=>Y(je),Ce=()=>pe();return document.addEventListener("mousemove",V),document.addEventListener("mouseup",xe),document.addEventListener("touchmove",Ne,{passive:!1}),document.addEventListener("touchend",Ce),()=>{document.removeEventListener("mousemove",V),document.removeEventListener("mouseup",xe),document.removeEventListener("touchmove",Ne),document.removeEventListener("touchend",Ce)}}},[w,Y,pe]);const ae=V=>{if(Q){V.preventDefault(),ie(!1);return}const xe=!y;h(xe),r(xe)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:Z,onClick:ae,onMouseDown:V=>{_(V)},onTouchStart:V=>{_(V)},className:`fixed ${y?"right-64":"right-0"} z-50 ${m?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${m?"border-blue-500 dark:border-blue-400":"border-gray-200 dark:border-gray-700"} rounded-l-md p-2 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors shadow-lg ${m?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{...T(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":m?"拖动手柄":y?"关闭设置面板":"打开设置面板",title:m?"拖动中...":"点击切换,拖动移动",children:m?e.jsx(hn,{className:"h-5 w-5 text-blue-500 dark:text-blue-400"}):y?e.jsx(Lt,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):e.jsx(gn,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),e.jsx("div",{className:`fixed top-0 right-0 h-full w-64 bg-background border-l border-border shadow-xl transform transition-transform duration-150 ease-out z-40 ${y?"translate-x-0":"translate-x-full"} ${j?"h-screen":""}`,children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(fn,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}),"快速设置"]})}),e.jsxs("div",{className:`flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-6 bg-background ${j?"pb-mobile-nav":""}`,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:"外观"}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[I?e.jsx(Pr,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):e.jsx($r,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"深色模式"]}),e.jsx(Ri,{})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:"工具显示"}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(Os,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"自动展开工具"]}),e.jsx("input",{type:"checkbox",checked:a,onChange:V=>o(V.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(Fs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"显示原始参数"]}),e.jsx("input",{type:"checkbox",checked:n,onChange:V=>l(V.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(_s,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"显示思考过程"]}),e.jsx("input",{type:"checkbox",checked:i,onChange:V=>d(V.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:"视图选项"}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(bn,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"自动滚动到底部"]}),e.jsx("input",{type:"checkbox",checked:x,onChange:V=>p(V.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:"输入设置"}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(yn,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"使用 Ctrl+Enter 发送"]}),e.jsx("input",{type:"checkbox",checked:b,onChange:V=>C(V.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 ml-3",children:"启用后,按 Ctrl+Enter 发送消息而不是 Enter。这对于输入法用户很有用,可以避免误发送。"})]}),e.jsxs("div",{className:"space-y-2",style:{display:"none"},children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:"语音输入"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"default",checked:$==="default",onChange:()=>{M("default"),localStorage.setItem("whisperMode","default"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(nr,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"默认模式"]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"直接转录您的语音"})]})]}),e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"prompt",checked:$==="prompt",onChange:()=>{M("prompt"),localStorage.setItem("whisperMode","prompt"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(Rr,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"提示词增强"]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"将粗略的想法转化为清晰、详细的 AI 提示词"})]})]}),e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"vibe",checked:$==="vibe"||$==="instructions"||$==="architect",onChange:()=>{M("vibe"),localStorage.setItem("whisperMode","vibe"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(Ws,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),"氛围模式"]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"将想法格式化为带有详细说明的代理指令"})]})]})]})]})]})]})}),y&&e.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:ae})]})};function $i({isOpen:t,limitType:r,onClose:a}){if(!t)return null;const o=r==="total_limit_exceeded";return e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[100]",children:e.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-xl w-full max-w-md p-6 mx-4 animate-in fade-in zoom-in-95 duration-200",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-red-100 dark:bg-red-900/30 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx(Rt,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:o?"使用上限已达到":"今日使用上限已达到"})})]}),e.jsx("button",{onClick:a,className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:e.jsx(Fe,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"mb-6 text-muted-foreground space-y-3",children:o?e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"您的账户已达到使用总额度上限。"}),e.jsx("p",{className:"text-sm",children:"请联系管理员提升您的额度限制,以继续使用 Claude 服务。"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"您已达到今日使用额度上限。"}),e.jsx("p",{className:"text-sm",children:"您可以等待明日额度重置后继续使用,或联系管理员提升您的每日额度限制。"})]})}),e.jsx("div",{className:"mb-6 p-3 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg",children:e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:o?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"提示:"}),"请联系您的管理员,申请提升使用额度。"]}):e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"提示:"}),"每日额度将在次日 00:00 自动重置,您也可以联系管理员调整限额。"]})})}),e.jsx("div",{className:"flex justify-end",children:e.jsx(J,{variant:"default",onClick:a,children:"我知道了"})})]})})}function zi(){const[t,r]=s.useState(null),[a,o]=s.useState([]),[n,l]=s.useState(!1),i=s.useRef(null),d=s.useRef(null),{token:x}=$t();s.useEffect(()=>(i.current&&(clearTimeout(i.current),i.current=null),d.current&&(d.current.close(),d.current=null),x||!1?p():(l(!1),r(null)),()=>{i.current&&clearTimeout(i.current),d.current&&d.current.close()}),[x]);const p=()=>{try{let j;{const h=x||localStorage.getItem("auth-token");if(!h){console.warn("No authentication token found for WebSocket connection");return}j=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws?token=${encodeURIComponent(h)}`}const y=new WebSocket(j);d.current=y,y.onopen=()=>{l(!0),r(y)},y.onmessage=h=>{try{const $=JSON.parse(h.data);o(M=>[...M,$])}catch($){console.error("Error parsing WebSocket message:",$)}},y.onclose=()=>{l(!1),r(null),d.current=null,localStorage.getItem("auth-token")&&(i.current=setTimeout(()=>{p()},3e3))},y.onerror=h=>{console.error("WebSocket error:",h)}}catch(C){console.error("Error creating WebSocket connection:",C)}};return{ws:t,sendMessage:C=>{t&&n?t.send(JSON.stringify(C)):console.warn("WebSocket not connected")},messages:a,isConnected:n}}const oa=s.createContext({ws:null,sendMessage:()=>{},messages:[],isConnected:!1}),_i=()=>{const t=s.useContext(oa);if(!t)throw new Error("useWebSocketContext must be used within a WebSocketProvider");return t},Ai=({children:t})=>{const r=zi();return e.jsx(oa.Provider,{value:r,children:t})},Oi=()=>{const[t,r]=s.useState("email"),[a,o]=s.useState(""),[n,l]=s.useState(""),[i,d]=s.useState(!1),[x,p]=s.useState(""),[b,C]=s.useState(0),{sendCode:j,verifyCode:y,smtpConfigured:h}=$t();s.useEffect(()=>{if(b>0){const g=setTimeout(()=>C(b-1),1e3);return()=>clearTimeout(g)}},[b]);const $=async g=>{if(g.preventDefault(),p(""),!a||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)){p("请输入有效的邮箱地址");return}d(!0);const k=await j(a);k.success?(r("code"),C(60)):(p(k.error),k.waitSeconds&&C(k.waitSeconds)),d(!1)},M=async g=>{if(g.preventDefault(),p(""),!n||n.length!==6){p("请输入6位验证码");return}d(!0);const m=await y(a,n);m.success||p(m.error),d(!1)},I=async()=>{if(b>0)return;p(""),d(!0);const g=await j(a);g.success?C(60):p(g.error),d(!1)},E=()=>{r("email"),l(""),p("")};return h?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(ot,{size:64})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:t==="email"?"欢迎使用 AgentHub":"创建管理员账户"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:t==="email"?"输入邮箱创建管理员账户":`验证码已发送至 ${a}`})]}),t==="email"&&e.jsxs("form",{onSubmit:$,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-foreground mb-1",children:"邮箱地址"}),e.jsxs("div",{className:"relative",children:[e.jsx(ir,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-muted-foreground"}),e.jsx("input",{type:"email",id:"email",value:a,onChange:g=>o(g.target.value),className:"w-full pl-10 pr-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入邮箱地址",required:!0,disabled:i,autoComplete:"email"})]})]}),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.jsx("button",{type:"submit",disabled:i||b>0,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:i?"发送中...":b>0?`${b}秒后可重新发送`:"获取验证码"})]}),t==="code"&&e.jsxs("form",{onSubmit:M,className:"space-y-4",children:[e.jsxs("button",{type:"button",onClick:E,className:"flex items-center text-sm text-muted-foreground hover:text-foreground",children:[e.jsx(xr,{className:"w-4 h-4 mr-1"}),"返回修改邮箱"]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"code",className:"block text-sm font-medium text-foreground mb-1",children:"验证码"}),e.jsx("input",{type:"text",id:"code",value:n,onChange:g=>l(g.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground text-center text-2xl tracking-widest focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"000000",required:!0,disabled:i,maxLength:6,autoComplete:"one-time-code"})]}),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.jsx("button",{type:"submit",disabled:i||n.length!==6,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:i?"创建中...":"创建管理员账户"}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:I,disabled:b>0||i,className:"text-sm text-blue-500 hover:text-blue-600 disabled:text-muted-foreground",children:b>0?`${b}秒后可重新发送`:"重新发送验证码"})})]}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"首个注册的用户将成为管理员"})})]})})}):e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(ot,{size:64})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"欢迎使用 AgentHub"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"系统初始化"})]}),e.jsxs("div",{className:"p-4 bg-yellow-100 dark:bg-yellow-900/20 border border-yellow-300 dark:border-yellow-800 rounded-md",children:[e.jsx("p",{className:"text-sm text-yellow-700 dark:text-yellow-400",children:"SMTP 邮件服务未配置。请联系管理员配置以下环境变量后重启服务:"}),e.jsxs("ul",{className:"mt-2 text-sm text-yellow-700 dark:text-yellow-400 list-disc list-inside",children:[e.jsx("li",{children:"SMTP_SERVER"}),e.jsx("li",{children:"SMTP_PORT"}),e.jsx("li",{children:"SMTP_USERNAME"}),e.jsx("li",{children:"SMTP_PASSWORD"})]})]})]})})})},Fi=()=>{const[t,r]=s.useState("email"),[a,o]=s.useState("email"),[n,l]=s.useState(""),[i,d]=s.useState(""),[x,p]=s.useState(""),[b,C]=s.useState(""),[j,y]=s.useState(!1),[h,$]=s.useState(""),[M,I]=s.useState(0),[E,g]=s.useState(!1),{login:m,sendCode:k,verifyCode:w,smtpConfigured:R}=$t();s.useEffect(()=>{if(M>0){const T=setTimeout(()=>I(M-1),1e3);return()=>clearTimeout(T)}},[M]),s.useEffect(()=>{R||r("password")},[R]);const W=async T=>{if(T.preventDefault(),$(""),!n||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)){$("请输入有效的邮箱地址");return}y(!0);const Y=await k(n);Y.success?(o("code"),I(60),g(Y.type==="register")):($(Y.error),Y.waitSeconds&&I(Y.waitSeconds)),y(!1)},F=async T=>{if(T.preventDefault(),$(""),!i||i.length!==6){$("请输入6位验证码");return}y(!0);const _=await w(n,i);_.success||$(_.error),y(!1)},Q=async()=>{if(M>0)return;$(""),y(!0);const T=await k(n);T.success?I(60):$(T.error),y(!1)},ie=async T=>{if(T.preventDefault(),$(""),!x||!b){$("请输入用户名和密码");return}y(!0);const _=await m(x,b);_.success||$(_.error),y(!1)},Z=()=>{o("email"),d(""),$("")},se=()=>{r("email"),o("email"),$("")},B=()=>{r("password"),$("")};return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"w-16 h-16 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:e.jsx(It,{className:"w-8 h-8 text-primary-foreground"})})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:t==="email"?a==="email"?"欢迎使用 AgentHub":E?"创建您的账户":"验证您的身份":"欢迎回来"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:t==="email"?a==="email"?"输入邮箱以接收验证码":`验证码已发送至 ${n}`:"使用账号密码登录"})]}),t==="email"&&a==="email"&&e.jsxs("form",{onSubmit:W,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-foreground mb-1",children:"邮箱地址"}),e.jsxs("div",{className:"relative",children:[e.jsx(ir,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-muted-foreground"}),e.jsx("input",{type:"email",id:"email",value:n,onChange:T=>l(T.target.value),className:"w-full pl-10 pr-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入邮箱地址",required:!0,disabled:j,autoComplete:"email"})]})]}),h&&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:h})}),e.jsx("button",{type:"submit",disabled:j||M>0,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:j?"发送中...":M>0?`${M}秒后可重新发送`:"获取验证码"})]}),t==="email"&&a==="code"&&e.jsxs("form",{onSubmit:F,className:"space-y-4",children:[e.jsxs("button",{type:"button",onClick:Z,className:"flex items-center text-sm text-muted-foreground hover:text-foreground",children:[e.jsx(xr,{className:"w-4 h-4 mr-1"}),"返回修改邮箱"]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"code",className:"block text-sm font-medium text-foreground mb-1",children:"验证码"}),e.jsx("input",{type:"text",id:"code",value:i,onChange:T=>d(T.target.value.replace(/\D/g,"").slice(0,6)),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground text-center text-2xl tracking-widest focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"000000",required:!0,disabled:j,maxLength:6,autoComplete:"one-time-code"})]}),h&&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:h})}),e.jsx("button",{type:"submit",disabled:j||i.length!==6,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:j?"验证中...":E?"创建账户并登录":"登录"}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:Q,disabled:M>0||j,className:"text-sm text-blue-500 hover:text-blue-600 disabled:text-muted-foreground",children:M>0?`${M}秒后可重新发送`:"重新发送验证码"})})]}),t==="password"&&e.jsxs("form",{onSubmit:ie,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-foreground mb-1",children:"用户名"}),e.jsxs("div",{className:"relative",children:[e.jsx(Us,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-muted-foreground"}),e.jsx("input",{type:"text",id:"username",value:x,onChange:T=>p(T.target.value),className:"w-full pl-10 pr-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入用户名",required:!0,disabled:j})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:"密码"}),e.jsxs("div",{className:"relative",children:[e.jsx(vn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-muted-foreground"}),e.jsx("input",{type:"password",id:"password",value:b,onChange:T=>C(T.target.value),className:"w-full pl-10 pr-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"请输入密码",required:!0,disabled:j})]})]}),h&&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:h})}),e.jsx("button",{type:"submit",disabled:j,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:j?"登录中...":"登录"})]}),e.jsx("div",{className:"text-center pt-4 border-t border-border",children:t==="email"&&R?e.jsx("button",{type:"button",onClick:B,className:"text-sm text-muted-foreground hover:text-foreground",children:"使用账号密码登录"}):t==="password"&&R?e.jsx("button",{type:"button",onClick:se,className:"text-sm text-muted-foreground hover:text-foreground",children:"使用邮箱验证码登录"}):null})]})})})},Wi=()=>e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"w-16 h-16 bg-primary rounded-lg flex items-center justify-center shadow-sm",children:e.jsx(It,{className:"w-8 h-8 text-primary-foreground"})})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"AgentHub"}),e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full animate-bounce"}),e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"加载中..."})]})}),Bi=({children:t})=>{const{user:r,isLoading:a,needsSetup:o}=$t();return a?e.jsx(Wi,{}):o?e.jsx(Oi,{}):r?t:e.jsx(Fi,{})};function Mt(t,r){const[a,o]=s.useState(()=>{if(typeof window>"u")return r;try{const l=window.localStorage.getItem(t);return l?JSON.parse(l):r}catch(l){return console.log(l),r}});return[a,l=>{if(!(typeof window>"u"))try{const i=l instanceof Function?l(a):l;window.localStorage.setItem(t,JSON.stringify(i)),o(i)}catch(i){console.log(i)}}]}function Ps(){const t=$s(),{sessionId:r}=qa(),{limitStatus:a,setLimitStatus:o,checkLimitStatus:n}=$t(),[l,i]=s.useState([]),[d,x]=s.useState(null),[p,b]=s.useState(null),[C,j]=s.useState("chat"),[y,h]=s.useState(!1),[$,M]=s.useState(!1),[I,E]=s.useState(!0),[g,m]=s.useState(!1),[k,w]=s.useState(!1),[R,W]=s.useState("agents"),[F,Q]=s.useState(!1),[ie,Z]=Mt("autoExpandTools",!1),[se,B]=Mt("showRawParameters",!1),[T,_]=Mt("showThinking",!0),[Y,pe]=Mt("autoScrollToBottom",!0),[ae,V]=Mt("sendByCtrlEnter",!1),[xe,Ne]=Mt("sidebarVisible",!0),[Ce,je]=s.useState(!1),[_e,he]=s.useState(null),[Se,ke]=s.useState(new Set),[Ee,ye]=s.useState(new Set),[Re,Pe]=s.useState(0),{ws:Me,sendMessage:H,messages:f}=_i(),v=s.useCallback(q=>{he(q),je(!0)},[]),[O,oe]=s.useState(!1);s.useEffect(()=>{const q=()=>{const me=window.matchMedia("(display-mode: standalone)").matches||window.navigator.standalone||document.referrer.includes("android-app://");oe(me),document.addEventListener("touchstart",{}),me?(document.documentElement.classList.add("pwa-mode"),document.body.classList.add("pwa-mode")):(document.documentElement.classList.remove("pwa-mode"),document.body.classList.remove("pwa-mode"))};return q(),window.matchMedia("(display-mode: standalone)").addEventListener("change",q),()=>{window.matchMedia("(display-mode: standalone)").removeEventListener("change",q)}},[]),s.useEffect(()=>{const q=()=>{h(window.innerWidth<768)};return q(),window.addEventListener("resize",q),()=>window.removeEventListener("resize",q)},[]),s.useEffect(()=>{Le()},[]);const ue=(q,me,re,le)=>{if(!re||!le)return!0;const ve=q?.find(et=>et.name===re.name),ze=me?.find(et=>et.name===re.name);if(!ve||!ze)return!1;const ge=ve.sessions?.find(et=>et.id===le.id),We=ze.sessions?.find(et=>et.id===le.id);return!ge||!We?!1:ge.id===We.id&&ge.title===We.title&&ge.created_at===We.created_at&&ge.updated_at===We.updated_at};s.useEffect(()=>{if(f.length>0){const q=f[f.length-1];if(q.type==="projects_updated"){if(q.changedFile&&p&&d){const ve=q.changedFile.replace(/\\/g,"/").split("/");ve.length>=2&&ve[ve.length-1].replace(".jsonl","")===p.id&&(Se.has(p.id)||Pe(zt=>zt+1))}if(p&&Se.has(p.id)||Se.size>0&&Array.from(Se).some(le=>le.startsWith("new-session-"))){const le=q.projects;if(!ue(l,le,d,p))return}const re=q.projects;if(i(re),d){const le=re.find(ve=>ve.name===d.name);le&&(JSON.stringify(le)!==JSON.stringify(d)&&x(le),p&&([...le.sessions||[]].find(ge=>ge.id===p.id)||b(null)))}}}},[f,d,p,Se]);const Le=async()=>{try{E(!0);const me=await(await we.projects()).json();i(re=>re.length===0||me.some((ve,ze)=>{const ge=re[ze];return ge?ve.name!==ge.name||ve.displayName!==ge.displayName||ve.fullPath!==ge.fullPath||JSON.stringify(ve.sessionMeta)!==JSON.stringify(ge.sessionMeta)||JSON.stringify(ve.sessions)!==JSON.stringify(ge.sessions):!0})||me.length!==re.length?me:re)}catch(q){console.error("Error fetching projects:",q)}finally{E(!1)}};window.refreshProjects=Le,window.openSettings=s.useCallback((q="tools")=>{W(q),w(!0)},[]),s.useEffect(()=>{if(r&&l.length>0){const q=!p||p.id!==r;for(const me of l){let re=me.sessions?.find(le=>le.id===r);if(re){x(me),b({...re,__provider:"claude"}),q&&j("chat");return}}}},[r,l,t]);const He=q=>{x(q),b(null),t("/"),y&&M(!1)},Ye=q=>{if(b(q),C!=="git"&&C!=="preview"&&j("chat"),y){const me=q.__projectName,re=d?.name;me!==re&&M(!1)}t(`/session/${q.id}`)},qe=q=>{x(q),b(null),j("chat"),t("/"),y&&M(!1)},u=q=>{p?.id===q&&(b(null),t("/")),i(me=>me.map(re=>({...re,sessions:re.sessions?.filter(le=>le.id!==q)||[],sessionMeta:{...re.sessionMeta,total:Math.max(0,(re.sessionMeta?.total||0)-1)}})))},A=async()=>{try{const me=await(await we.projects()).json();if(i(re=>me.some((ve,ze)=>{const ge=re[ze];return ge?ve.name!==ge.name||ve.displayName!==ge.displayName||ve.fullPath!==ge.fullPath||JSON.stringify(ve.sessionMeta)!==JSON.stringify(ge.sessionMeta)||JSON.stringify(ve.sessions)!==JSON.stringify(ge.sessions):!0})||me.length!==re.length?me:re),d){const re=me.find(le=>le.name===d.name);if(re&&(JSON.stringify(re)!==JSON.stringify(d)&&x(re),p)){const le=re.sessions?.find(ve=>ve.id===p.id);le&&JSON.stringify(le)!==JSON.stringify(p)&&b(le)}}}catch(q){console.error("Error refreshing sidebar:",q)}},X=q=>{d?.name===q&&(x(null),b(null),t("/")),i(me=>me.filter(re=>re.name!==q))},te=s.useCallback(q=>{q&&ke(me=>new Set([...me,q]))},[]),D=s.useCallback(q=>{q&&ke(me=>{const re=new Set(me);return re.delete(q),re})},[]),Ie=s.useCallback(q=>{q&&ye(me=>new Set([...me,q]))},[]),Be=s.useCallback(q=>{q&&ye(me=>{const re=new Set(me);return re.delete(q),re})},[]),De=s.useCallback(q=>{q&&ke(me=>{const re=new Set;for(const le of me)le.startsWith("new-session-")||re.add(le);return re.add(q),re})},[]);return e.jsxs("div",{className:"fixed inset-0 flex bg-background",children:[!y&&e.jsx("div",{className:`h-full flex-shrink-0 border-r border-border bg-card transition-all duration-300 ${xe?"w-80":"w-14"}`,children:e.jsx("div",{className:"h-full overflow-hidden",children:xe?e.jsx(gs,{projects:l,selectedProject:d,selectedSession:p,onProjectSelect:He,onSessionSelect:Ye,onNewSession:qe,onSessionDelete:u,onProjectDelete:X,isLoading:I,onRefresh:A,onShowSettings:()=>w(!0),isPWA:O,isMobile:y,onToggleSidebar:()=>Ne(!1)}):e.jsxs("div",{className:"h-full flex flex-col items-center py-4 gap-4",children:[e.jsx("button",{onClick:()=>Ne(!0),className:"p-2 hover:bg-accent rounded-md transition-colors duration-200 group","aria-label":"Show sidebar",title:"Show sidebar",children:e.jsx("svg",{className:"w-5 h-5 text-foreground group-hover:scale-110 transition-transform",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 5l7 7-7 7M5 5l7 7-7 7"})})}),e.jsx("button",{onClick:()=>w(!0),className:"p-2 hover:bg-accent rounded-md transition-colors duration-200","aria-label":"Settings",title:"Settings",children:e.jsx(Tt,{className:"w-5 h-5 text-muted-foreground hover:text-foreground transition-colors"})})]})})}),y&&e.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${$?"opacity-100 visible":"opacity-0 invisible"}`,children:[e.jsx("button",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm transition-opacity duration-150 ease-out",onClick:q=>{q.stopPropagation(),M(!1)},onTouchStart:q=>{q.preventDefault(),q.stopPropagation(),M(!1)},"aria-label":"Close sidebar"}),e.jsx("div",{className:`relative w-[85vw] max-w-sm sm:w-80 h-full bg-card border-r border-border transform transition-transform duration-150 ease-out ${$?"translate-x-0":"-translate-x-full"}`,onClick:q=>q.stopPropagation(),onTouchStart:q=>q.stopPropagation(),children:e.jsx(gs,{projects:l,selectedProject:d,selectedSession:p,onProjectSelect:He,onSessionSelect:Ye,onNewSession:qe,onSessionDelete:u,onProjectDelete:X,isLoading:I,onRefresh:A,onShowSettings:()=>w(!0),isPWA:O,isMobile:y,onToggleSidebar:()=>Ne(!1)})})]}),e.jsx("div",{className:`flex-1 flex flex-col min-w-0 ${y&&!g?"pb-mobile-nav":""}`,children:e.jsx(ci,{selectedProject:d,selectedSession:p,activeTab:C,setActiveTab:j,ws:Me,sendMessage:H,messages:f,isMobile:y,isPWA:O,onMenuClick:()=>M(!0),isLoading:I,onInputFocusChange:m,onSessionActive:te,onSessionInactive:D,onSessionProcessing:Ie,onSessionNotProcessing:Be,processingSessions:Ee,onReplaceTemporarySession:De,onNavigateToSession:q=>t(`/session/${q}`),onShowSettings:()=>w(!0),autoExpandTools:ie,showRawParameters:se,showThinking:T,autoScrollToBottom:Y,sendByCtrlEnter:ae,externalMessageUpdate:Re,limitStatus:a,onLimitBlocked:v,checkLimitStatus:n})}),y&&e.jsx(di,{activeTab:C,setActiveTab:j,isInputFocused:g}),C==="chat"&&e.jsx(Pi,{isOpen:F,onToggle:Q,autoExpandTools:ie,onAutoExpandChange:Z,showRawParameters:se,onShowRawParametersChange:B,showThinking:T,onShowThinkingChange:_,autoScrollToBottom:Y,onAutoScrollChange:pe,sendByCtrlEnter:ae,onSendByCtrlEnterChange:V,isMobile:y}),e.jsx(Ti,{isOpen:k,onClose:()=>w(!1),projects:l,initialTab:R}),e.jsx($i,{isOpen:Ce,limitType:_e,onClose:()=>je(!1)})]})}function Ui(){return e.jsx(mi,{children:e.jsx(ui,{children:e.jsx(Ai,{children:e.jsx(Bi,{children:e.jsx(Ua,{children:e.jsxs(Ha,{children:[e.jsx(ds,{path:"/",element:e.jsx(Ps,{})}),e.jsx(ds,{path:"/session/:sessionId",element:e.jsx(Ps,{})})]})})})})})})}"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(r=>{r.unregister()})}).catch(t=>{console.warn("Failed to unregister service workers:",t)});Tn.createRoot(document.getElementById("root")).render(e.jsx(Xe.StrictMode,{children:e.jsx(Ui,{})}));
|