@tom2012/cc-web 2026.4.19-w → 2026.4.19-x
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/README.md +1 -1
- package/backend/dist/memory-prompts.d.ts.map +1 -1
- package/backend/dist/memory-prompts.js +7 -3
- package/backend/dist/memory-prompts.js.map +1 -1
- package/frontend/dist/assets/{AssistantMessageContent-ZKbU1jlC.js → AssistantMessageContent-DRo_wwOE.js} +1 -1
- package/frontend/dist/assets/{GraphPreview-FNlubgv_.js → GraphPreview-8jsVSDTu.js} +1 -1
- package/frontend/dist/assets/{MobilePage-C0xGtLMa.js → MobilePage-DtNZ_N9c.js} +3 -3
- package/frontend/dist/assets/{OfficePreview-THZQ5px4.js → OfficePreview-BcxUD2mr.js} +2 -2
- package/frontend/dist/assets/{ProjectPage-CTEe2Tdp.js → ProjectPage-CsTaTE7W.js} +4 -4
- package/frontend/dist/assets/{SettingsPage-DAflwmGB.js → SettingsPage-BSbsMogo.js} +1 -1
- package/frontend/dist/assets/{SkillHubPage-PxI0FGcw.js → SkillHubPage-LLy7t8L7.js} +1 -1
- package/frontend/dist/assets/{chevron-down-DtcZkqFf.js → chevron-down-D_RQtGy2.js} +1 -1
- package/frontend/dist/assets/{chevron-up-CUW9T6yb.js → chevron-up-C0jadenI.js} +1 -1
- package/frontend/dist/assets/{index-DCiTw3F5.css → index-BKYCkXv1.css} +1 -1
- package/frontend/dist/assets/{index-fJX6wxPU.js → index-CBleER0a.js} +2 -2
- package/frontend/dist/assets/{index-D1P-udhw.js → index-DO12wrd9.js} +1 -1
- package/frontend/dist/assets/{index-rGoP4nhR.js → index-dMJLjPxi.js} +1 -1
- package/frontend/dist/assets/{jszip.min-Dz4RfJJo.js → jszip.min-xWErx4Qu.js} +1 -1
- package/frontend/dist/assets/{search-28CWGQwO.js → search-CLatOUMz.js} +1 -1
- package/frontend/dist/index.html +2 -2
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GraphPreview-
|
|
2
|
-
var e,t,i,s,r,n;import{c as o,u as a,r as l,a as h,g as c,b as d,w as u,t as f,j as _,d as p,E as m,P as g,M as v,e as S,X as b,f as w,h as y,S as x,R as C,_ as k,s as E,i as R,k as D,D as M,T as L,l as N,F as P,m as T,n as B,C as j,o as A,A as O,p as I,q as z,v as W,B as H,x as F,y as $,I as U,z as K,G as q,H as V,J as Y,K as X,L as G,N as J,O as Z,Q,U as ee,V as te,W as ie,Y as se,Z as re,$ as ne,a0 as oe,a1 as ae,a2 as le,a3 as he,a4 as ce,a5 as de,a6 as ue,a7 as fe,a8 as _e,a9 as pe,aa as me,ab as ge,ac as ve,ad as Se,ae as be,af as we,ag as ye,ah as xe,ai as Ce,aj as ke,ak as Ee,al as Re,am as De,an as Me,ao as Le,ap as Ne,aq as Pe,ar as Te,as as Be,at as je,au as Ae,av as Oe,aw as Ie,ax as ze,ay as We,az as He,aA as Fe,aB as $e,aC as Ue,aD as Ke,aE as qe,aF as Ve,aG as Ye,aH as Xe,aI as Ge,aJ as Je,aK as Ze,aL as Qe,aM as et,aN as tt,aO as it,aP as st,aQ as rt,aR as nt,aS as ot,aT as at,aU as lt,aV as ht}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GraphPreview-8jsVSDTu.js","assets/index-CBleER0a.js","assets/index-BKYCkXv1.css","assets/purify.es-CgRAQgUo.js","assets/AssistantMessageContent-DRo_wwOE.js","assets/chevron-down-D_RQtGy2.js","assets/chevron-up-C0jadenI.js","assets/AssistantMessageContent-wklAmtGL.css","assets/index-DO12wrd9.js","assets/search-CLatOUMz.js","assets/OfficePreview-BcxUD2mr.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var e,t,i,s,r,n;import{c as o,u as a,r as l,a as h,g as c,b as d,w as u,t as f,j as _,d as p,E as m,P as g,M as v,e as S,X as b,f as w,h as y,S as x,R as C,_ as k,s as E,i as R,k as D,D as M,T as L,l as N,F as P,m as T,n as B,C as j,o as A,A as O,p as I,q as z,v as W,B as H,x as F,y as $,I as U,z as K,G as q,H as V,J as Y,K as X,L as G,N as J,O as Z,Q,U as ee,V as te,W as ie,Y as se,Z as re,$ as ne,a0 as oe,a1 as ae,a2 as le,a3 as he,a4 as ce,a5 as de,a6 as ue,a7 as fe,a8 as _e,a9 as pe,aa as me,ab as ge,ac as ve,ad as Se,ae as be,af as we,ag as ye,ah as xe,ai as Ce,aj as ke,ak as Ee,al as Re,am as De,an as Me,ao as Le,ap as Ne,aq as Pe,ar as Te,as as Be,at as je,au as Ae,av as Oe,aw as Ie,ax as ze,ay as We,az as He,aA as Fe,aB as $e,aC as Ue,aD as Ke,aE as qe,aF as Ve,aG as Ye,aH as Xe,aI as Ge,aJ as Je,aK as Ze,aL as Qe,aM as et,aN as tt,aO as it,aP as st,aQ as rt,aR as nt,aS as ot,aT as at,aU as lt,aV as ht}from"./index-CBleER0a.js";import{p as ct}from"./purify.es-CgRAQgUo.js";import{F as dt,M as ut,r as ft,a as _t,b as pt,h as mt,o as gt,c as vt,I as St,u as bt,A as wt,d as yt}from"./AssistantMessageContent-DRo_wwOE.js";import{S as xt,U as Ct,T as kt,a as Et,b as Rt,c as Dt,u as Mt,R as Lt,A as Nt,d as Pt,e as Tt,f as Bt,I as jt,g as At,C as Ot,h as It,i as zt,j as Wt}from"./index-DO12wrd9.js";import{C as Ht}from"./chevron-down-D_RQtGy2.js";import{S as Ft}from"./search-CLatOUMz.js";import{C as $t}from"./chevron-up-C0jadenI.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license lucide-react v0.309.0 - ISC
|
|
5
5
|
*
|
|
6
6
|
* This source code is licensed under the ISC license.
|
|
7
7
|
* See the LICENSE file in the root directory of this source tree.
|
|
8
|
-
*/const Ut=o("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),Kt=o("ClipboardCopy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),qt=o("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]),Vt=o("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),Yt=o("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),Xt=o("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),Gt=o("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]),Jt=o("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]),Zt=o("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]),Qt=o("MoreVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),ei=o("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),ti=o("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),ii=o("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),si=o("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]),ri=o("StopCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{width:"6",height:"6",x:"9",y:"9",key:"1wrtvo"}]]),ni=o("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),oi=o("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),ai=C.lazy(()=>k(()=>import("./GraphPreview-
|
|
8
|
+
*/const Ut=o("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),Kt=o("ClipboardCopy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),qt=o("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]),Vt=o("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),Yt=o("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),Xt=o("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),Gt=o("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]),Jt=o("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]),Zt=o("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]),Qt=o("MoreVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),ei=o("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),ti=o("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),ii=o("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),si=o("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]),ri=o("StopCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{width:"6",height:"6",x:"9",y:"9",key:"1wrtvo"}]]),ni=o("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),oi=o("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),ai=C.lazy(()=>k(()=>import("./GraphPreview-8jsVSDTu.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])).then(e=>({default:e.GraphPreview}))),li=C.lazy(()=>k(()=>import("./OfficePreview-BcxUD2mr.js"),__vite__mapDeps([10,1,2,3])).then(e=>({default:e.OfficePreview}))),hi=new Set(["docx","xlsx","xls","pptx"]),ci={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",yaml:"yaml",yml:"yaml",json:"json",toml:"toml",html:"html",htm:"html",xml:"xml",svg:"xml",css:"css",scss:"scss",less:"less",sql:"sql",graphql:"graphql",gql:"graphql",dockerfile:"docker",makefile:"makefile",r:"r",lua:"lua",dart:"dart",zig:"zig"};
|
|
9
9
|
/**
|
|
10
10
|
* @license lucide-react v0.309.0 - ISC
|
|
11
11
|
*
|
|
12
12
|
* This source code is licensed under the ISC license.
|
|
13
13
|
* See the LICENSE file in the root directory of this source tree.
|
|
14
|
-
*/const di=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif","tiff","tif"]);function ui(e){return"md"===e?"Markdown":"html"===e||"htm"===e?"HTML":"高亮"}const fi=[50,75,100,125,150,200,250,300],_i=100;function pi({filePath:e,onClose:t}){const i=a(),s=e.endsWith("/.notebook/graph.yaml"),r=s?e.replace(/\/.notebook\/graph\.yaml$/,""):"",[n,o]=l.useState(null),[C,k]=l.useState(null),[R,D]=l.useState(()=>s?"graph":"rendered"),[M,L]=l.useState(!1),[N,P]=l.useState(_i),[T,B]=l.useState(""),[j,A]=l.useState(!1),[O,I]=l.useState(!1),z=l.useRef(null),[W,H]=l.useState(!0),{resolved:F}=h(),$=e.split("/").pop()??e,U=l.useMemo(()=>function(e){const t=e.split("/").pop()??"",i=t.toLowerCase();if("dockerfile"===i)return"dockerfile";if("makefile"===i)return"makefile";const s=t.lastIndexOf(".");return s>=0?t.slice(s+1).toLowerCase():""}(e),[e]),K=di.has(U),q=hi.has(U),V=function(e){return"md"===e||"html"===e||"htm"===e||e in ci}(U),Y=ci[U]||U,X=l.useMemo(()=>{if(!K)return"";const t=w(e),i=c(),s=`${t}&t=${Date.now()}`;return i?`${s}&token=${encodeURIComponent(i)}`:s},[e,K]);l.useEffect(()=>{if(H(!0),o(null),k(null),P(function(e){const t=y(x.fileZoom,{},!0)[e];return fi.includes(t)?t:_i}(e)),I(!1),K||q)return o({path:e,binary:!1,tooLarge:!1,size:0,content:null}),void D("rendered");D(e.endsWith("/.notebook/graph.yaml")?"graph":"rendered"),d(e).then(e=>{o(e),B(e.content??"")}).catch(e=>k(e instanceof Error?e.message:"Failed to load file"))},[e,K,q]);const G=l.useCallback(async()=>{A(!0);try{await u(e,T),o(e=>e?{...e,content:T,size:new Blob([T]).size}:e),I(!1)}catch(t){f.error(t instanceof Error?t.message:"保存失败")}finally{A(!1)}},[e,T]);l.useEffect(()=>{const e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&"edit"===R&&(e.preventDefault(),G())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[R,G]),l.useEffect(()=>{const e=async e=>{if("Escape"===e.key&&W){if(O){if(!(await i({description:"有未保存的修改,确定关闭?",confirmLabel:"放弃修改",destructive:!0})))return}t()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[W,t,O,i]);const J=async()=>{if(O){if(!(await i({description:"有未保存的修改,确定退出编辑?",confirmLabel:"放弃修改",destructive:!0})))return}D(s?"graph":V?"rendered":"plain"),I(!1)},Z=t=>{P(t),function(e,t){const i=y(x.fileZoom,{},!0);t===_i?delete i[e]:i[e]=t,E(x.fileZoom,i,!0)}(e,t)},Q=(null==n?void 0:n.content)??"",ee="dark"===F?gt:vt,te=N/100*12,ie=n&&!n.binary&&!n.tooLarge,se=l.useDeferredValue(T),re=l.useMemo(()=>{var e,t;if(!n||n.binary||n.tooLarge)return null;if(K||q)return null;const i="edit"===R?se:Q;if(null==i)return null;return{bytes:new Blob([i]).size,words:((null==(e=i.match(/[\u4e00-\u9fff\u3400-\u4dbf]/g))?void 0:e.length)??0)+((null==(t=i.replace(/[\u4e00-\u9fff\u3400-\u4dbf]/g," ").match(/[a-zA-Z0-9]+/g))?void 0:t.length)??0),lines:""===i?0:i.split("\n").length}},[n,K,q,R,se,Q]);return _.jsx("div",{className:p("fixed inset-0 z-50 flex items-center justify-center transition-all duration-200",W?"bg-black/60 backdrop-blur-sm pointer-events-auto":"bg-transparent pointer-events-none"),onClick:e=>{e.target===e.currentTarget&&H(!1)},children:_.jsxs("div",{className:p("relative flex flex-col bg-background border border-border shadow-2xl transition-all duration-200 pointer-events-auto",M?"w-screen h-screen rounded-none":"w-[72vw] max-w-4xl h-[80vh] rounded-lg",!W&&!M&&"opacity-50"),onClick:()=>H(!0),onFocus:e=>{e.stopPropagation(),H(!0)},children:[_.jsxs("div",{className:"flex items-center gap-2 px-4 h-10 border-b border-border flex-shrink-0",children:[_.jsx(dt,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),_.jsxs("span",{className:"flex-1 text-sm text-foreground font-medium truncate",title:e,children:[$,O&&_.jsx("span",{className:"text-muted-foreground ml-1",children:"*"}),re&&_.jsxs("span",{className:"text-muted-foreground font-normal ml-2 text-xs tabular-nums",children:[(ne=re.bytes,ne<1024?`${ne} B`:ne<1048576?`${(ne/1024).toFixed(1)} KB`:`${(ne/1024/1024).toFixed(2)} MB`)," · ",re.words.toLocaleString()," 词 · ",re.lines.toLocaleString()," 行"]})]}),ie&&!K&&!q&&_.jsxs("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5",children:[V&&_.jsxs(_.Fragment,{children:[_.jsxs("button",{onClick:()=>"edit"===R?J():D("plain"),className:p("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs","plain"===R?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"纯文本",children:[_.jsx(qt,{className:"h-3 w-3"}),_.jsx("span",{className:"hidden sm:inline",children:"源码"})]}),_.jsxs("button",{onClick:()=>"edit"===R?J():D("rendered"),className:p("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs","rendered"===R?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:ui(U),children:[_.jsx(m,{className:"h-3 w-3"}),_.jsx("span",{className:"hidden sm:inline",children:ui(U)})]})]}),s&&_.jsxs("button",{onClick:()=>"edit"===R?J():D("graph"),className:p("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs","graph"===R?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"图谱",children:[_.jsx(ei,{className:"h-3 w-3"}),_.jsx("span",{className:"hidden sm:inline",children:"图谱"})]}),_.jsxs("button",{onClick:()=>"edit"===R?J():(B((null==n?void 0:n.content)??""),I(!1),D("edit"),void setTimeout(()=>{var e;return null==(e=z.current)?void 0:e.focus()},0)),className:p("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs","edit"===R?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"编辑",children:[_.jsx(g,{className:"h-3 w-3"}),_.jsx("span",{className:"hidden sm:inline",children:"编辑"})]})]}),"edit"===R&&_.jsxs("button",{onClick:()=>{G()},disabled:j||!O,className:p("flex items-center gap-1 text-xs px-2 py-1 rounded transition-colors",O?"bg-blue-600 hover:bg-blue-500 text-white":"bg-muted text-muted-foreground"),title:"保存 (⌘S)",children:[_.jsx(xt,{className:"h-3 w-3"}),j?"保存中...":"保存"]}),(ie||K)&&"edit"!==R&&"graph"!==R&&_.jsxs("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5 gap-0.5",children:[_.jsx("button",{onClick:()=>{const e=[...fi].reverse().find(e=>e<N);e&&Z(e)},disabled:N<=fi[0],className:"p-1 rounded-sm text-muted-foreground hover:text-foreground transition-colors disabled:opacity-30",title:"缩小",children:_.jsx(oi,{className:"h-3 w-3"})}),_.jsxs("button",{onClick:()=>Z(_i),className:"px-1 text-xs text-muted-foreground hover:text-foreground transition-colors min-w-[36px] text-center",title:"重置缩放",children:[N,"%"]}),_.jsx("button",{onClick:()=>{const e=fi.find(e=>e>N);e&&Z(e)},disabled:N>=fi[fi.length-1],className:"p-1 rounded-sm text-muted-foreground hover:text-foreground transition-colors disabled:opacity-30",title:"放大",children:_.jsx(ni,{className:"h-3 w-3"})})]}),_.jsx("button",{className:"p-1 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:()=>L(e=>!e),title:M?"退出全屏":"全屏",children:M?_.jsx(v,{className:"h-3.5 w-3.5"}):_.jsx(S,{className:"h-3.5 w-3.5"})}),_.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:async()=>{if(O){if(!(await i({description:"有未保存的修改,确定关闭?",confirmLabel:"放弃修改",destructive:!0})))return}t()},children:_.jsx(b,{className:"h-4 w-4"})})]}),_.jsxs("div",{className:p("flex-1 min-h-0","graph"===R?"overflow-hidden":"overflow-auto"),children:["graph"===R&&_.jsx(l.Suspense,{fallback:_.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),children:_.jsx(ai,{folderPath:r})}),"graph"!==R&&!n&&!C&&_.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),"graph"!==R&&C&&_.jsx("p",{className:"text-sm text-red-400 p-4",children:C}),"graph"!==R&&K&&n&&_.jsx("div",{className:"flex items-center justify-center p-4 h-full",children:_.jsx("img",{src:X,alt:$,className:"max-w-full max-h-full object-contain rounded",style:{transform:`scale(${N/100})`,transformOrigin:"center center"},draggable:!1})}),"graph"!==R&&q&&n&&_.jsx(l.Suspense,{fallback:_.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),children:_.jsx(li,{filePath:e,ext:U,zoom:N})}),"graph"!==R&&!K&&!q&&n&&n.binary&&_.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-muted-foreground p-4",children:[_.jsx(dt,{className:"h-8 w-8"}),_.jsx("p",{className:"text-sm",children:"Binary file — cannot preview"}),_.jsxs("p",{className:"text-xs text-muted-foreground",children:[(n.size/1024).toFixed(1)," KB"]})]}),"graph"!==R&&!q&&n&&n.tooLarge&&_.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-muted-foreground p-4",children:[_.jsx(dt,{className:"h-8 w-8"}),_.jsx("p",{className:"text-sm",children:"File too large to preview"}),_.jsxs("p",{className:"text-xs text-muted-foreground",children:[(n.size/1024/1024).toFixed(2)," MB (limit 5 MB)"]})]}),"graph"!==R&&ie&&null!==Q&&_.jsxs(_.Fragment,{children:["edit"===R&&_.jsx("textarea",{ref:z,value:T,onChange:e=>{B(e.target.value),I(!0)},className:"w-full h-full bg-transparent text-foreground font-mono outline-none resize-none p-4 leading-relaxed",style:{fontSize:`${te}px`,minHeight:"100%"},spellCheck:!1}),"edit"!==R&&_.jsxs("div",{className:"p-4",style:{fontSize:`${te}px`},children:["plain"===R&&_.jsx("pre",{className:"font-mono text-foreground whitespace-pre-wrap break-words leading-relaxed",style:{fontSize:"inherit"},children:Q}),"rendered"===R&&"md"===U&&_.jsx("div",{className:"prose dark:prose-invert max-w-none prose-pre:bg-muted prose-pre:border prose-pre:border-border prose-code:text-foreground",style:{fontSize:"inherit"},children:_.jsx(ut,{remarkPlugins:[_t,pt],rehypePlugins:[ft],components:{code({className:e,children:t,...i}){const s=/language-(\w+)/.exec(e||"");return!s&&!e?_.jsx("code",{className:e,...i,children:t}):_.jsx(mt,{style:ee,language:(null==s?void 0:s[1])||"text",PreTag:"div",customStyle:{fontSize:"inherit",borderRadius:"6px",margin:0},children:String(t).replace(/\n$/,"")})}},children:Q})}),"rendered"===R&&("html"===U||"htm"===U)&&_.jsx("iframe",{srcDoc:ct.sanitize(Q,{WHOLE_DOCUMENT:!0,ADD_TAGS:["style","link"]}),className:"w-full h-full border-0 rounded bg-white",sandbox:"",title:$,style:{minHeight:"60vh",transform:`scale(${N/100})`,transformOrigin:"top left",width:1e4/N+"%",height:1e4/N+"%"}}),"rendered"===R&&"md"!==U&&"html"!==U&&"htm"!==U&&Y&&_.jsx(mt,{style:ee,language:Y,showLineNumbers:!0,lineNumberStyle:{color:"dark"===F?"#555":"#aaa",fontSize:"inherit"},customStyle:{fontSize:"inherit",borderRadius:"6px",margin:0,background:"transparent"},children:Q}),"rendered"===R&&!V&&_.jsx("pre",{className:"font-mono text-foreground whitespace-pre-wrap break-words leading-relaxed",style:{fontSize:"inherit"},children:Q})]})]})]})]})});var ne}const mi=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif","tiff","tif"]);function gi(e){const t=e.lastIndexOf(".");return t>=0&&mi.has(e.slice(t+1).toLowerCase())}function vi({projectPath:e,projectId:t}){const[i,s]=l.useState(new Map),[r,n]=l.useState(new Set([e])),[o,h]=l.useState(new Set),d=R(e=>e.get(t).filePreviewPath),u=R(e=>e.setFilePreviewPath),m=e=>u(t,e),[g,v]=l.useState(null),[S,b]=l.useState(!1),[y,x]=l.useState(!1),C=a(),k=l.useRef(null),E=l.useRef(null);l.useEffect(()=>{if(!g)return;const e=()=>v(null);return window.addEventListener("click",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("click",e),window.removeEventListener("scroll",e,!0)}},[g]);const z=async t=>{if(0!==t.length){b(!0);try{await B(e,t),W(e)}catch(i){console.error("[FileTree] Upload failed:",i)}finally{b(!1)}}},W=l.useCallback(async e=>{h(t=>{if(t.has(e))return t;const i=new Set(t);return i.add(e),i});try{const t=await D(e);s(i=>new Map(i).set(e,t.entries))}catch(t){console.error("[FileTree] Failed to load:",e,t),s(t=>new Map(t).set(e,[]))}finally{h(t=>{const i=new Set(t);return i.delete(e),i})}},[]);l.useEffect(()=>{s(new Map),n(new Set([e])),h(new Set),W(e)},[e,W]);const H=l.useCallback(e=>{n(t=>{const s=new Set(t);return s.has(e)?s.delete(e):(s.add(e),i.has(e)||W(e)),s})},[i,W]),F=l.useCallback(()=>{s(new Map),n(new Set([e])),h(new Set),W(e)},[e,W]),$=(e,t)=>e.map(e=>{const s=r.has(e.path),n=o.has(e.path),a=i.get(e.path),l=e.name.startsWith(".");return _.jsxs("div",{children:[_.jsxs("div",{className:p("flex items-center gap-1 py-[3px] rounded cursor-pointer","hover:bg-muted",l&&"opacity-50"),style:{paddingLeft:14*t+6+"px",paddingRight:"6px"},onClick:()=>"dir"===e.type?H(e.path):m(e.path),onContextMenu:t=>{t.preventDefault(),v({x:t.clientX,y:t.clientY,filePath:e.path,fileName:e.name,type:e.type})},children:[_.jsx("span",{className:"w-3 flex-shrink-0 text-muted-foreground",children:"dir"===e.type&&(n?_.jsx(N,{className:"h-2.5 w-2.5 animate-spin"}):s?_.jsx(Ht,{className:"h-2.5 w-2.5"}):_.jsx(j,{className:"h-2.5 w-2.5"}))}),"dir"===e.type?s?_.jsx(P,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}):_.jsx(A,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}):gi(e.name)?_.jsx(St,{className:"h-3.5 w-3.5 text-green-400 flex-shrink-0"}):_.jsx(dt,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),_.jsx("span",{className:p("text-xs truncate leading-none","dir"===e.type?"text-foreground":"text-muted-foreground"),title:e.path,children:e.name})]}),_.jsx(O,{initial:!1,children:"dir"===e.type&&s&&_.jsxs(I.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15,ease:"easeInOut"},className:"overflow-hidden",children:[!a&&!n&&_.jsx("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:14*(t+1)+6+16+"px"},children:"—"}),0===(null==a?void 0:a.length)&&_.jsx("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:14*(t+1)+6+16+"px"},children:"empty"}),a&&a.length>0&&$(a,t+1)]})})]},e.path)}),U=i.get(e),K=o.has(e),q=e.split("/").filter(Boolean).pop()??e;return _.jsxs(_.Fragment,{children:[d&&_.jsx(pi,{filePath:d,onClose:()=>m(null)}),g&&_.jsxs("div",{ref:k,className:"fixed z-50 min-w-[140px] bg-popover border border-border rounded-md shadow-md py-1",style:{left:g.x,top:g.y},onClick:e=>e.stopPropagation(),children:[_.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{const t=g.filePath.startsWith(e+"/")?g.filePath.slice(e.length+1):g.filePath;navigator.clipboard.writeText(t),f.success("已复制相对路径"),v(null)},children:[_.jsx(Vt,{className:"h-3.5 w-3.5"}),"复制相对路径"]}),_.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{navigator.clipboard.writeText(g.filePath),f.success("已复制绝对路径"),v(null)},children:[_.jsx(Kt,{className:"h-3.5 w-3.5"}),"复制绝对路径"]}),"file"===g.type&&_.jsxs(_.Fragment,{children:[_.jsx("div",{className:"my-1 border-t border-border"}),_.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{(async(e,t)=>{let i=w(e);const s=c();s&&(i+=`${i.includes("?")?"&":"?"}token=${encodeURIComponent(s)}`),i+=(i.includes("?")?"&":"?")+"dl=1";try{const e=await fetch(i);if(!e.ok){const t=await e.text().catch(()=>"");let i=`下载失败 (${e.status})`;try{i=JSON.parse(t).error||i}catch{}return void f.error(i)}const s=await e.blob(),r=URL.createObjectURL(s),n=document.createElement("a");n.href=r,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}catch{f.error("下载失败:网络错误")}})(g.filePath,g.fileName),v(null)},children:[_.jsx(M,{className:"h-3.5 w-3.5"}),"下载"]})]}),_.jsx("div",{className:"my-1 border-t border-border"}),_.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-destructive/80 hover:text-destructive-foreground text-left",onClick:()=>{(async(t,s,r)=>{const n="dir"===r?`文件夹 "${s}" 及其所有内容`:`文件 "${s}"`;if(await C({title:"确认删除",description:`确认删除${n}?此操作不可撤销。`,destructive:!0,confirmLabel:"删除"}))try{await T(t),f.success(`已删除: ${s}`);const r=t.substring(0,t.lastIndexOf("/"));r&&i.has(r)?W(r):W(e)}catch(o){f.error(`删除失败: ${o.message}`)}})(g.filePath,g.fileName,g.type),v(null)},children:[_.jsx(L,{className:"h-3.5 w-3.5"}),"删除"]})]}),_.jsxs("div",{className:"h-full flex flex-col bg-background text-foreground select-none",children:[_.jsxs("div",{className:"flex items-center justify-between px-3 h-9 border-b border-border flex-shrink-0",children:[_.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Files"}),_.jsxs("div",{className:"flex items-center gap-0.5",children:[_.jsx("input",{ref:E,type:"file",multiple:!0,className:"hidden",onChange:e=>{const t=Array.from(e.target.files??[]);t.length>0&&z(t),e.target.value=""}}),_.jsx("button",{className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",onClick:()=>{var e;return null==(e=E.current)?void 0:e.click()},disabled:S,title:"上传文件",children:_.jsx(Ct,{className:p("h-3 w-3",S&&"animate-pulse")})}),_.jsx("button",{className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",onClick:F,title:"Refresh file tree",children:_.jsx(N,{className:p("h-3 w-3",K&&"animate-spin")})})]})]}),_.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-border flex-shrink-0",children:[_.jsx(P,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}),_.jsx("span",{className:"text-xs text-foreground font-medium truncate",title:e,children:q})]}),_.jsxs("div",{className:p("flex-1 overflow-y-auto py-1 min-h-0 transition-colors",y&&"bg-accent/30 ring-1 ring-inset ring-accent"),onDragOver:e=>{e.preventDefault(),x(!0)},onDragEnter:e=>{e.preventDefault(),x(!0)},onDragLeave:()=>x(!1),onDrop:e=>{e.preventDefault(),x(!1);const t=Array.from(e.dataTransfer.files);t.length>0&&z(t)},children:[S&&_.jsx("div",{className:"text-xs text-muted-foreground px-4 py-1",children:"上传中..."}),y&&!S&&_.jsx("div",{className:"text-xs text-muted-foreground px-4 py-1",children:"松开以上传文件"}),K&&!U?_.jsx("div",{className:"text-xs text-muted-foreground px-4 py-3",children:"Loading…"}):U&&0!==U.length?$(U,0):_.jsx("div",{className:"text-xs text-muted-foreground px-4 py-3",children:"Empty folder"})]})]})]})}function Si(e){const t=new Date(e),i=Date.now()-t.getTime();return i<36e5?`${Math.floor(i/6e4)}分钟前`:i<864e5?`${Math.floor(i/36e5)}小时前`:i<6048e5?`${Math.floor(i/864e5)}天前`:t.toLocaleDateString()}function bi({projectId:e}){const[t,i]=l.useState(null),[s,r]=l.useState(!0),[n,o]=l.useState(null),[a,h]=l.useState(null),[c,d]=l.useState(""),[u,m]=l.useState(!1),[g,v]=l.useState([]),[S,b]=l.useState(0),[w,y]=l.useState(!0),[x,C]=l.useState(!1),k=l.useCallback(async()=>{r(!0);try{i(await z(e))}catch{i(null)}finally{r(!1)}},[e]),E=l.useCallback(async(t=!1)=>{C(!0);try{const i=t?g.length:0,s=await W(e,30,i);v(e=>t?[...e,...s.commits]:s.commits),b(s.total)}catch{}finally{C(!1)}},[e,g.length]);l.useEffect(()=>{k(),E()},[e]);const R=async t=>{try{const{diff:i}=await K(e,t);o(i||"(no diff)"),h(t??"all changes")}catch{f.error("获取 diff 失败")}},D=async t=>{try{await q(e,[t]),f.success(`已暂存 ${t}`),await k()}catch{f.error("git add 失败")}},M=async()=>{if(c.trim()){m(!0);try{await V(e,c),f.success("提交成功"),d(""),await k()}catch(t){f.error(t instanceof Error?t.message:"提交失败")}finally{m(!1)}}};if(!t&&s)return _.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50 text-xs",children:[_.jsx(Xt,{className:"h-5 w-5"}),_.jsx("p",{children:"加载中…"})]});if(!t||!t.isRepo)return _.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50 text-xs",children:[_.jsx(Xt,{className:"h-5 w-5"}),_.jsx("p",{children:t?"非 Git 仓库":"加载失败"}),_.jsx(H,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{k()},children:"重试"})]});const L=[...t.modified??[],...t.deleted??[]],P=t.staged??[],T=t.untracked??[];return _.jsxs("div",{className:"flex flex-col h-full overflow-y-auto p-2 space-y-2 text-xs",children:[_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground font-medium",children:[_.jsx(Xt,{className:"h-3 w-3"}),_.jsx("span",{children:t.branch}),(t.ahead??0)>0&&_.jsxs("span",{className:"text-blue-400",children:["↑",t.ahead]}),(t.behind??0)>0&&_.jsxs("span",{className:"text-yellow-400",children:["↓",t.behind]})]}),_.jsx(H,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{k()},disabled:s,children:_.jsx(N,{className:p("h-3 w-3",s&&"animate-spin")})})]}),P.length>0&&_.jsxs("div",{children:[_.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["已暂存 (",P.length,")"]}),P.map(e=>_.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted",children:[_.jsx(F,{className:"h-2.5 w-2.5 text-green-500 flex-shrink-0"}),_.jsx("button",{className:"flex-1 text-left truncate text-green-400",onClick:()=>{R(e)},children:e})]},e))]}),L.length>0&&_.jsxs("div",{children:[_.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["未暂存 (",L.length,")"]}),L.map(e=>_.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted",children:[_.jsx("button",{className:"flex-shrink-0 h-4 w-4 flex items-center justify-center rounded hover:bg-green-500/20 text-muted-foreground hover:text-green-400",title:"git add",onClick:()=>{D(e)},children:_.jsx($,{className:"h-2.5 w-2.5"})}),_.jsx("button",{className:"flex-1 text-left truncate text-yellow-400",onClick:()=>{R(e)},children:e})]},e))]}),T.length>0&&_.jsxs("div",{children:[_.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["未跟踪 (",T.length,")"]}),T.map(e=>_.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted",children:[_.jsx("button",{className:"flex-shrink-0 h-4 w-4 flex items-center justify-center rounded hover:bg-green-500/20 text-muted-foreground hover:text-green-400",title:"git add",onClick:()=>{D(e)},children:_.jsx($,{className:"h-2.5 w-2.5"})}),_.jsx("span",{className:"flex-1 truncate text-muted-foreground",children:e})]},e))]}),0===L.length&&0===P.length&&0===T.length&&_.jsx("p",{className:"text-muted-foreground/50 text-center py-4",children:"工作区干净"}),P.length>0&&_.jsxs("div",{className:"space-y-1.5 pt-1 border-t border-border",children:[_.jsx(U,{placeholder:"提交消息…",value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||M()},className:"h-7 text-xs"}),_.jsx(H,{size:"sm",className:"w-full h-7 text-xs",onClick:()=>{M()},disabled:!c.trim()||u,children:u?"提交中…":`提交 (${P.length} 文件)`})]}),(null==t?void 0:t.isRepo)&&_.jsxs("div",{className:"border-t border-border pt-2",children:[_.jsxs("button",{className:"flex items-center gap-1 text-muted-foreground font-medium mb-1 w-full text-left",onClick:()=>y(e=>!e),children:[_.jsx(Ht,{className:p("h-3 w-3 transition-transform",!w&&"-rotate-90")}),_.jsx(Gt,{className:"h-3 w-3"}),_.jsxs("span",{children:["提交历史 (",S,")"]})]}),w&&_.jsxs("div",{className:"space-y-0.5",children:[g.map((e,t)=>{const i=e.parents.length>1;return _.jsxs("div",{className:"flex gap-1.5 items-start group",children:[_.jsxs("div",{className:"flex flex-col items-center flex-shrink-0 w-3",children:[_.jsx("div",{className:p("w-2 h-2 rounded-full flex-shrink-0 mt-1",0===t?"bg-blue-400":i?"bg-purple-400":"bg-muted-foreground/40")}),t<g.length-1&&_.jsx("div",{className:"w-px flex-1 bg-border min-h-[12px]"})]}),_.jsxs("div",{className:"flex-1 min-w-0 pb-1",children:[_.jsxs("div",{className:"flex items-baseline gap-1",children:[_.jsx("span",{className:"font-mono text-muted-foreground/60 text-[10px] flex-shrink-0",children:e.hashShort}),_.jsx("span",{className:"truncate leading-tight",children:e.message.split("\n")[0]})]}),_.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground/50 mt-0.5",children:[_.jsx("span",{children:e.author}),_.jsx("span",{children:Si(e.date)}),e.branches.length>0&&e.branches.slice(0,2).map(e=>_.jsx("span",{className:"px-1 py-px rounded bg-blue-500/10 text-blue-400 text-[9px]",children:e.replace("remotes/origin/","↑")},e))]})]})]},e.hash)}),g.length<S&&_.jsx("button",{className:"w-full text-center text-[10px] text-muted-foreground hover:text-foreground py-1",onClick:()=>{E(!0)},disabled:x,children:x?"加载中...":`加载更多 (${g.length}/${S})`})]})]}),null!==n&&_.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>o(null),children:[_.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),_.jsxs("div",{className:"relative z-10 w-[700px] max-w-[95vw] max-h-[80vh] flex flex-col bg-background border border-border rounded-lg shadow-2xl",onClick:e=>e.stopPropagation(),children:[_.jsxs("div",{className:"flex items-center justify-between px-4 h-10 border-b border-border text-sm font-medium flex-shrink-0",children:[_.jsx("span",{className:"truncate text-muted-foreground",children:a}),_.jsx("button",{className:"text-muted-foreground hover:text-foreground",onClick:()=>o(null),children:"✕"})]}),_.jsx("pre",{className:"flex-1 overflow-auto p-3 text-[11px] font-mono whitespace-pre leading-relaxed",children:n.split("\n").map((e,t)=>_.jsx("span",{className:p("block",e.startsWith("+")&&!e.startsWith("+++")&&"text-green-400 bg-green-400/5",e.startsWith("-")&&!e.startsWith("---")&&"text-red-400 bg-red-400/5",e.startsWith("@@")&&"text-blue-400"),children:e},t))})]})]})]})}function wi({projectPath:e,projectId:t}){const[i,s]=Y(x.leftPanelTab,"files"),r="git"===i?"git":"files";return _.jsxs(kt,{value:r,onValueChange:e=>s(e),orientation:"vertical",className:"h-full flex bg-muted/40 text-foreground overflow-hidden",children:[_.jsxs(Et,{className:p("flex flex-col items-center justify-start shrink-0","h-full w-9 bg-muted/60 border-r border-border rounded-none p-1 gap-1"),children:[_.jsx(Rt,{value:"files",title:"Files","aria-label":"Files",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:_.jsx(P,{className:"h-3.5 w-3.5"})}),_.jsx(Rt,{value:"git",title:"Git","aria-label":"Git",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:_.jsx(Xt,{className:"h-3.5 w-3.5"})})]}),_.jsxs("div",{className:"flex-1 min-w-0 flex flex-col bg-background border-l border-border",children:[_.jsx(Dt,{value:"files",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:_.jsx(vi,{projectPath:e,projectId:t})}),_.jsx(Dt,{value:"git",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:_.jsx(bi,{projectId:t})})]})]})}function yi(e){const t=xi(e),i=l.forwardRef((e,i)=>{const{children:s,...r}=e,n=l.Children.toArray(s),o=n.find(ki);if(o){const e=o.props.children,s=n.map(t=>t===o?l.Children.count(e)>1?l.Children.only(null):l.isValidElement(e)?e.props.children:null:t);return _.jsx(t,{...r,ref:i,children:l.isValidElement(e)?l.cloneElement(e,void 0,s):null})}return _.jsx(t,{...r,ref:i,children:s})});return i.displayName=`${e}.Slot`,i}function xi(e){const t=l.forwardRef((e,t)=>{const{children:i,...s}=e;if(l.isValidElement(i)){const e=function(e){var t,i;let s=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,r=s&&"isReactWarning"in s&&s.isReactWarning;if(r)return e.ref;if(s=null==(i=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:i.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),r=function(e,t){const i={...t};for(const s in t){const r=e[s],n=t[s];/^on[A-Z]/.test(s)?r&&n?i[s]=(...e)=>{const t=n(...e);return r(...e),t}:r&&(i[s]=r):"style"===s?i[s]={...r,...n}:"className"===s&&(i[s]=[r,n].filter(Boolean).join(" "))}return{...e,...i}}(s,i.props);return i.type!==l.Fragment&&(r.ref=t?X(t,e):e),l.cloneElement(i,r)}return l.Children.count(i)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ci=Symbol("radix.slottable");function ki(e){return l.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Ci}var Ei=["Enter"," "],Ri=["ArrowUp","PageDown","End"],Di=["ArrowDown","PageUp","Home",...Ri],Mi={ltr:[...Ei,"ArrowRight"],rtl:[...Ei,"ArrowLeft"]},Li={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ni="Menu",[Pi,Ti,Bi]=Bt(Ni),[ji,Ai]=J(Ni,[Bi,Pt,Tt]),Oi=Pt(),Ii=Tt(),[zi,Wi]=ji(Ni),[Hi,Fi]=ji(Ni),$i=e=>{const{__scopeMenu:t,open:i=!1,children:s,dir:r,onOpenChange:n,modal:o=!0}=e,a=Oi(t),[h,c]=l.useState(null),d=l.useRef(!1),u=G(n),f=Mt(r);return l.useEffect(()=>{const e=()=>{d.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>d.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}},[]),_.jsx(Lt,{...a,children:_.jsx(zi,{scope:t,open:i,onOpenChange:u,content:h,onContentChange:c,children:_.jsx(Hi,{scope:t,onClose:l.useCallback(()=>u(!1),[u]),isUsingKeyboardRef:d,dir:f,modal:o,children:s})})})};$i.displayName=Ni;var Ui=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e,r=Oi(i);return _.jsx(Nt,{...r,...s,ref:t})});Ui.displayName="MenuAnchor";var Ki="MenuPortal",[qi,Vi]=ji(Ki,{forceMount:void 0}),Yi=e=>{const{__scopeMenu:t,forceMount:i,children:s,container:r}=e,n=Wi(Ki,t);return _.jsx(qi,{scope:t,forceMount:i,children:_.jsx(Z,{present:i||n.open,children:_.jsx(Q,{asChild:!0,container:r,children:s})})})};Yi.displayName=Ki;var Xi="MenuContent",[Gi,Ji]=ji(Xi),Zi=l.forwardRef((e,t)=>{const i=Vi(Xi,e.__scopeMenu),{forceMount:s=i.forceMount,...r}=e,n=Wi(Xi,e.__scopeMenu),o=Fi(Xi,e.__scopeMenu);return _.jsx(Pi.Provider,{scope:e.__scopeMenu,children:_.jsx(Z,{present:s||n.open,children:_.jsx(Pi.Slot,{scope:e.__scopeMenu,children:o.modal?_.jsx(Qi,{...r,ref:t}):_.jsx(es,{...r,ref:t})})})})}),Qi=l.forwardRef((e,t)=>{const i=Wi(Xi,e.__scopeMenu),s=l.useRef(null),r=ee(t,s);return l.useEffect(()=>{const e=s.current;if(e)return se(e)},[]),_.jsx(is,{...e,ref:r,trapFocus:i.open,disableOutsidePointerEvents:i.open,disableOutsideScroll:!0,onFocusOutside:te(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>i.onOpenChange(!1)})}),es=l.forwardRef((e,t)=>{const i=Wi(Xi,e.__scopeMenu);return _.jsx(is,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>i.onOpenChange(!1)})}),ts=yi("MenuContent.ScrollLock"),is=l.forwardRef((e,t)=>{const{__scopeMenu:i,loop:s=!1,trapFocus:r,onOpenAutoFocus:n,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:h,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...g}=e,v=Wi(Xi,i),S=Fi(Xi,i),b=Oi(i),w=Ii(i),y=Ti(i),[x,C]=l.useState(null),k=l.useRef(null),E=ee(t,k,v.onContentChange),R=l.useRef(0),D=l.useRef(""),M=l.useRef(0),L=l.useRef(null),N=l.useRef("right"),P=l.useRef(0),T=m?oe:l.Fragment,B=m?{as:ts,allowPinchZoom:!0}:void 0,j=e=>{var t,i;const s=D.current+e,r=y().filter(e=>!e.disabled),n=document.activeElement,o=null==(t=r.find(e=>e.ref.current===n))?void 0:t.textValue,a=function(e,t,i){const s=t.length>1&&Array.from(t).every(e=>e===t[0]),r=s?t[0]:t,n=i?e.indexOf(i):-1;let o=(a=e,l=Math.max(n,0),a.map((e,t)=>a[(l+t)%a.length]));var a,l;1===r.length&&(o=o.filter(e=>e!==i));const h=o.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return h!==i?h:void 0}(r.map(e=>e.textValue),s,o),l=null==(i=r.find(e=>e.textValue===a))?void 0:i.ref.current;!function e(t){D.current=t,window.clearTimeout(R.current),""!==t&&(R.current=window.setTimeout(()=>e(""),1e3))}(s),l&&setTimeout(()=>l.focus())};l.useEffect(()=>()=>window.clearTimeout(R.current),[]),ne();const A=l.useCallback(e=>{var t,i;return N.current===(null==(t=L.current)?void 0:t.side)&&function(e,t){if(!t)return!1;const i={x:e.clientX,y:e.clientY};return function(e,t){const{x:i,y:s}=e;let r=!1;for(let n=0,o=t.length-1;n<t.length;o=n++){const e=t[n],a=t[o],l=e.x,h=e.y,c=a.x,d=a.y;h>s!=d>s&&i<(c-l)*(s-h)/(d-h)+l&&(r=!r)}return r}(i,t)}(e,null==(i=L.current)?void 0:i.area)},[]);return _.jsx(Gi,{scope:i,searchRef:D,onItemEnter:l.useCallback(e=>{A(e)&&e.preventDefault()},[A]),onItemLeave:l.useCallback(e=>{var t;A(e)||(null==(t=k.current)||t.focus(),C(null))},[A]),onTriggerLeave:l.useCallback(e=>{A(e)&&e.preventDefault()},[A]),pointerGraceTimerRef:M,onPointerGraceIntentChange:l.useCallback(e=>{L.current=e},[]),children:_.jsx(T,{...B,children:_.jsx(ae,{asChild:!0,trapped:r,onMountAutoFocus:te(n,e=>{var t;e.preventDefault(),null==(t=k.current)||t.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:_.jsx(le,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:f,onDismiss:p,children:_.jsx(At,{asChild:!0,...w,dir:S.dir,orientation:"vertical",loop:s,currentTabStopId:x,onCurrentTabStopIdChange:C,onEntryFocus:te(h,e=>{S.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:_.jsx(Ot,{role:"menu","aria-orientation":"vertical","data-state":Ds(v.open),"data-radix-menu-content":"",dir:S.dir,...b,...g,ref:E,style:{outline:"none",...g.style},onKeyDown:te(g.onKeyDown,e=>{const t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,i=e.ctrlKey||e.altKey||e.metaKey,s=1===e.key.length;t&&("Tab"===e.key&&e.preventDefault(),!i&&s&&j(e.key));const r=k.current;if(e.target!==r)return;if(!Di.includes(e.key))return;e.preventDefault();const n=y().filter(e=>!e.disabled).map(e=>e.ref.current);Ri.includes(e.key)&&n.reverse(),function(e){const t=document.activeElement;for(const i of e){if(i===t)return;if(i.focus(),document.activeElement!==t)return}}(n)}),onBlur:te(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(R.current),D.current="")}),onPointerMove:te(e.onPointerMove,Ns(e=>{const t=e.target,i=P.current!==e.clientX;if(e.currentTarget.contains(t)&&i){const t=e.clientX>P.current?"right":"left";N.current=t,P.current=e.clientX}}))})})})})})})});Zi.displayName=Xi;var ss=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e;return _.jsx(ie.div,{role:"group",...s,ref:t})});ss.displayName="MenuGroup";var rs=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e;return _.jsx(ie.div,{...s,ref:t})});rs.displayName="MenuLabel";var ns="MenuItem",os="menu.itemSelect",as=l.forwardRef((e,t)=>{const{disabled:i=!1,onSelect:s,...r}=e,n=l.useRef(null),o=Fi(ns,e.__scopeMenu),a=Ji(ns,e.__scopeMenu),h=ee(t,n),c=l.useRef(!1);return _.jsx(ls,{...r,ref:h,disabled:i,onClick:te(e.onClick,()=>{const e=n.current;if(!i&&e){const t=new CustomEvent(os,{bubbles:!0,cancelable:!0});e.addEventListener(os,e=>null==s?void 0:s(e),{once:!0}),re(e,t),t.defaultPrevented?c.current=!1:o.onClose()}}),onPointerDown:t=>{var i;null==(i=e.onPointerDown)||i.call(e,t),c.current=!0},onPointerUp:te(e.onPointerUp,e=>{var t;c.current||null==(t=e.currentTarget)||t.click()}),onKeyDown:te(e.onKeyDown,e=>{const t=""!==a.searchRef.current;i||t&&" "===e.key||Ei.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});as.displayName=ns;var ls=l.forwardRef((e,t)=>{const{__scopeMenu:i,disabled:s=!1,textValue:r,...n}=e,o=Ji(ns,i),a=Ii(i),h=l.useRef(null),c=ee(t,h),[d,u]=l.useState(!1),[f,p]=l.useState("");return l.useEffect(()=>{const e=h.current;e&&p((e.textContent??"").trim())},[n.children]),_.jsx(Pi.ItemSlot,{scope:i,disabled:s,textValue:r??f,children:_.jsx(jt,{asChild:!0,...a,focusable:!s,children:_.jsx(ie.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...n,ref:c,onPointerMove:te(e.onPointerMove,Ns(e=>{if(s)o.onItemLeave(e);else if(o.onItemEnter(e),!e.defaultPrevented){e.currentTarget.focus({preventScroll:!0})}})),onPointerLeave:te(e.onPointerLeave,Ns(e=>o.onItemLeave(e))),onFocus:te(e.onFocus,()=>u(!0)),onBlur:te(e.onBlur,()=>u(!1))})})})}),hs=l.forwardRef((e,t)=>{const{checked:i=!1,onCheckedChange:s,...r}=e;return _.jsx(gs,{scope:e.__scopeMenu,checked:i,children:_.jsx(as,{role:"menuitemcheckbox","aria-checked":Ms(i)?"mixed":i,...r,ref:t,"data-state":Ls(i),onSelect:te(r.onSelect,()=>null==s?void 0:s(!!Ms(i)||!i),{checkForDefaultPrevented:!1})})})});hs.displayName="MenuCheckboxItem";var cs="MenuRadioGroup",[ds,us]=ji(cs,{value:void 0,onValueChange:()=>{}}),fs=l.forwardRef((e,t)=>{const{value:i,onValueChange:s,...r}=e,n=G(s);return _.jsx(ds,{scope:e.__scopeMenu,value:i,onValueChange:n,children:_.jsx(ss,{...r,ref:t})})});fs.displayName=cs;var _s="MenuRadioItem",ps=l.forwardRef((e,t)=>{const{value:i,...s}=e,r=us(_s,e.__scopeMenu),n=i===r.value;return _.jsx(gs,{scope:e.__scopeMenu,checked:n,children:_.jsx(as,{role:"menuitemradio","aria-checked":n,...s,ref:t,"data-state":Ls(n),onSelect:te(s.onSelect,()=>{var e;return null==(e=r.onValueChange)?void 0:e.call(r,i)},{checkForDefaultPrevented:!1})})})});ps.displayName=_s;var ms="MenuItemIndicator",[gs,vs]=ji(ms,{checked:!1}),Ss=l.forwardRef((e,t)=>{const{__scopeMenu:i,forceMount:s,...r}=e,n=vs(ms,i);return _.jsx(Z,{present:s||Ms(n.checked)||!0===n.checked,children:_.jsx(ie.span,{...r,ref:t,"data-state":Ls(n.checked)})})});Ss.displayName=ms;var bs=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e;return _.jsx(ie.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});bs.displayName="MenuSeparator";var ws=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e,r=Oi(i);return _.jsx(It,{...r,...s,ref:t})});ws.displayName="MenuArrow";var[ys,xs]=ji("MenuSub"),Cs="MenuSubTrigger",ks=l.forwardRef((e,t)=>{const i=Wi(Cs,e.__scopeMenu),s=Fi(Cs,e.__scopeMenu),r=xs(Cs,e.__scopeMenu),n=Ji(Cs,e.__scopeMenu),o=l.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:h}=n,c={__scopeMenu:e.__scopeMenu},d=l.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return l.useEffect(()=>d,[d]),l.useEffect(()=>{const e=a.current;return()=>{window.clearTimeout(e),h(null)}},[a,h]),_.jsx(Ui,{asChild:!0,...c,children:_.jsx(ls,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":r.contentId,"data-state":Ds(i.open),...e,ref:X(t,r.onTriggerChange),onClick:t=>{var s;null==(s=e.onClick)||s.call(e,t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),i.open||i.onOpenChange(!0))},onPointerMove:te(e.onPointerMove,Ns(t=>{n.onItemEnter(t),t.defaultPrevented||e.disabled||i.open||o.current||(n.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{i.onOpenChange(!0),d()},100))})),onPointerLeave:te(e.onPointerLeave,Ns(e=>{var t,s;d();const r=null==(t=i.content)?void 0:t.getBoundingClientRect();if(r){const t=null==(s=i.content)?void 0:s.dataset.side,o="right"===t,l=o?-5:5,h=r[o?"left":"right"],c=r[o?"right":"left"];n.onPointerGraceIntentChange({area:[{x:e.clientX+l,y:e.clientY},{x:h,y:r.top},{x:c,y:r.top},{x:c,y:r.bottom},{x:h,y:r.bottom}],side:t}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>n.onPointerGraceIntentChange(null),300)}else{if(n.onTriggerLeave(e),e.defaultPrevented)return;n.onPointerGraceIntentChange(null)}})),onKeyDown:te(e.onKeyDown,t=>{var r;const o=""!==n.searchRef.current;e.disabled||o&&" "===t.key||Mi[s.dir].includes(t.key)&&(i.onOpenChange(!0),null==(r=i.content)||r.focus(),t.preventDefault())})})})});ks.displayName=Cs;var Es="MenuSubContent",Rs=l.forwardRef((e,t)=>{const i=Vi(Xi,e.__scopeMenu),{forceMount:s=i.forceMount,...r}=e,n=Wi(Xi,e.__scopeMenu),o=Fi(Xi,e.__scopeMenu),a=xs(Es,e.__scopeMenu),h=l.useRef(null),c=ee(t,h);return _.jsx(Pi.Provider,{scope:e.__scopeMenu,children:_.jsx(Z,{present:s||n.open,children:_.jsx(Pi.Slot,{scope:e.__scopeMenu,children:_.jsx(is,{id:a.contentId,"aria-labelledby":a.triggerId,...r,ref:c,align:"start",side:"rtl"===o.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{var t;o.isUsingKeyboardRef.current&&(null==(t=h.current)||t.focus()),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:te(e.onFocusOutside,e=>{e.target!==a.trigger&&n.onOpenChange(!1)}),onEscapeKeyDown:te(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:te(e.onKeyDown,e=>{var t;const i=e.currentTarget.contains(e.target),s=Li[o.dir].includes(e.key);i&&s&&(n.onOpenChange(!1),null==(t=a.trigger)||t.focus(),e.preventDefault())})})})})})});function Ds(e){return e?"open":"closed"}function Ms(e){return"indeterminate"===e}function Ls(e){return Ms(e)?"indeterminate":e?"checked":"unchecked"}function Ns(e){return t=>"mouse"===t.pointerType?e(t):void 0}Rs.displayName=Es;var Ps=$i,Ts=Ui,Bs=Yi,js=Zi,As=ss,Os=rs,Is=as,zs=hs,Ws=fs,Hs=ps,Fs=Ss,$s=bs,Us=ws,Ks=ks,qs=Rs,Vs="ContextMenu",[Ys]=J(Vs,[Ai]),Xs=Ai(),[Gs,Js]=Ys(Vs),Zs=e=>{const{__scopeContextMenu:t,children:i,onOpenChange:s,dir:r,modal:n=!0}=e,[o,a]=l.useState(!1),h=Xs(t),c=G(s),d=l.useCallback(e=>{a(e),c(e)},[c]);return _.jsx(Gs,{scope:t,open:o,onOpenChange:d,modal:n,children:_.jsx(Ps,{...h,dir:r,open:o,onOpenChange:d,modal:n,children:i})})};Zs.displayName=Vs;var Qs="ContextMenuTrigger",er=l.forwardRef((e,t)=>{const{__scopeContextMenu:i,disabled:s=!1,...r}=e,n=Js(Qs,i),o=Xs(i),a=l.useRef({x:0,y:0}),h=l.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),c=l.useRef(0),d=l.useCallback(()=>window.clearTimeout(c.current),[]),u=e=>{a.current={x:e.clientX,y:e.clientY},n.onOpenChange(!0)};return l.useEffect(()=>d,[d]),l.useEffect(()=>{s&&d()},[s,d]),_.jsxs(_.Fragment,{children:[_.jsx(Ts,{...o,virtualRef:h}),_.jsx(ie.span,{"data-state":n.open?"open":"closed","data-disabled":s?"":void 0,...r,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:s?e.onContextMenu:te(e.onContextMenu,e=>{d(),u(e),e.preventDefault()}),onPointerDown:s?e.onPointerDown:te(e.onPointerDown,or(e=>{d(),c.current=window.setTimeout(()=>u(e),700)})),onPointerMove:s?e.onPointerMove:te(e.onPointerMove,or(d)),onPointerCancel:s?e.onPointerCancel:te(e.onPointerCancel,or(d)),onPointerUp:s?e.onPointerUp:te(e.onPointerUp,or(d))})]})});er.displayName=Qs;var tr=e=>{const{__scopeContextMenu:t,...i}=e,s=Xs(t);return _.jsx(Bs,{...s,...i})};tr.displayName="ContextMenuPortal";var ir="ContextMenuContent",sr=l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Js(ir,i),n=Xs(i),o=l.useRef(!1);return _.jsx(js,{...n,...s,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:t=>{var i;null==(i=e.onCloseAutoFocus)||i.call(e,t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{var i;null==(i=e.onInteractOutside)||i.call(e,t),t.defaultPrevented||r.modal||(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});sr.displayName=ir;l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(As,{...r,...s,ref:t})}).displayName="ContextMenuGroup";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(Os,{...r,...s,ref:t})}).displayName="ContextMenuLabel";var rr=l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(Is,{...r,...s,ref:t})});rr.displayName="ContextMenuItem";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(zs,{...r,...s,ref:t})}).displayName="ContextMenuCheckboxItem";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(Ws,{...r,...s,ref:t})}).displayName="ContextMenuRadioGroup";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(Hs,{...r,...s,ref:t})}).displayName="ContextMenuRadioItem";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(Fs,{...r,...s,ref:t})}).displayName="ContextMenuItemIndicator";var nr=l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx($s,{...r,...s,ref:t})});nr.displayName="ContextMenuSeparator";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(Us,{...r,...s,ref:t})}).displayName="ContextMenuArrow";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(Ks,{...r,...s,ref:t})}).displayName="ContextMenuSubTrigger";function or(e){return t=>"mouse"!==t.pointerType?e(t):void 0}l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(qs,{...r,...s,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})}).displayName="ContextMenuSubContent";var ar=tr,lr=sr,hr=rr,cr=nr;const dr=Zs,ur=er,fr=l.forwardRef(({className:e,...t},i)=>_.jsx(ar,{children:_.jsx(lr,{ref:i,className:p("z-50 min-w-[10rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",e),...t})}));fr.displayName=lr.displayName;const _r=l.forwardRef(({className:e,destructive:t,...i},s)=>_.jsx(hr,{ref:s,className:p("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-accent focus:text-accent-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"text-red-500 focus:text-red-500 focus:bg-red-500/10",e),...i}));_r.displayName=hr.displayName;const pr=l.forwardRef(({className:e,...t},i)=>_.jsx(cr,{ref:i,className:p("-mx-1 my-1 h-px bg-border",e),...t}));function mr({kind:e,label:t,preview:i,inserted:s,unclicked:r,onLeftClick:n,onEdit:o,onDelete:a,onShare:h,footer:c,readOnly:d,noContextMenu:u}){const f=l.useRef(null),m=p("agent-prompt"===e?s?"border-green-500/50 bg-green-500/10 hover:bg-green-500/15":"border-dashed border-border hover:border-border/80 hover:bg-muted/50":r?"border-blue-500/30 bg-blue-500/15 hover:bg-blue-500/20 dark:bg-blue-500/15 dark:hover:bg-blue-500/25":"border-transparent bg-muted hover:bg-accent hover:border-muted-foreground/30"),v="agent-prompt"===e,S="quick-prompt"===e?u?"点击发送":"点击发送 · 右键更多":(s?"点击从 CLAUDE.md 移除":"点击插入 CLAUDE.md")+(u?"":" · 右键更多"),b=_.jsxs("div",{ref:f,className:p("group relative rounded-md border text-xs transition-colors cursor-pointer select-none",m),onClick:n,title:S,children:[v&&_.jsx("span",{"aria-hidden":!0,className:p("absolute top-1.5 left-1.5 h-2 w-2 rounded-full transition-colors",s?"bg-green-500 ring-1 ring-green-500/40":"border border-muted-foreground/40 bg-transparent")}),_.jsxs("div",{className:p("py-1.5",u?"pr-2":"pr-7",v?"pl-5":"pl-3"),children:[_.jsx("div",{className:"font-medium truncate",children:t}),i&&i!==t&&_.jsx("div",{className:"mt-0.5 text-muted-foreground/80 truncate font-mono",children:i}),c]}),!u&&_.jsx("button",{onClick:e=>{e.stopPropagation(),e.preventDefault();const t=f.current;if(!t)return;const i=t.getBoundingClientRect(),s=new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:i.right-8,clientY:i.top+i.height/2,button:2});t.dispatchEvent(s)},className:p("absolute top-1 right-1 p-0.5 rounded transition-opacity","md:opacity-0 md:group-hover:opacity-100 md:focus-visible:opacity-100","hover:bg-muted focus-visible:bg-muted","text-muted-foreground hover:text-foreground"),title:"更多","aria-label":"更多操作",children:_.jsx(Qt,{className:"h-3.5 w-3.5"})})]});return u?_.jsx("div",{onContextMenu:e=>e.preventDefault(),children:b}):_.jsxs(dr,{children:[_.jsx(ur,{asChild:!0,children:b}),_.jsxs(fr,{children:[!d&&o&&a&&_.jsxs(_.Fragment,{children:[_.jsxs(_r,{onSelect:o,children:[_.jsx(g,{className:"h-3.5 w-3.5"}),"编辑"]}),_.jsxs(_r,{destructive:!0,onSelect:a,children:[_.jsx(L,{className:"h-3.5 w-3.5"}),"删除"]}),_.jsx(pr,{})]}),h&&_.jsxs(_r,{onSelect:h,children:[_.jsx(he,{className:"h-3.5 w-3.5"}),"共享到 ccweb-hub"]})]})]})}function gr({open:e,onOpenChange:t,initialLabel:i,initialCommand:s,title:r,onSave:n}){const[o,a]=l.useState(i),[h,c]=l.useState(s),[d,u]=l.useState(!0);l.useEffect(()=>{e&&u(!0)},[e]),l.useEffect(()=>{e&&(a(i),c(s))},[e,i,s]);const f=()=>{const e=h.trim();e&&(n(o.trim()||e,e),t(!1))};return _.jsx(me,{open:e,onOpenChange:t,modal:!1,children:_.jsxs(ge,{noOverlay:!0,className:p("sm:max-w-2xl max-h-[85vh] flex flex-col transition-opacity",!d&&"opacity-50"),onInteractOutside:e=>{e.preventDefault(),u(!1)},onClick:()=>u(!0),children:[_.jsxs(ve,{children:[_.jsx(Se,{children:r}),_.jsx(be,{children:"左键点击卡片会把此命令发送到 CLI。"})]}),_.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col",children:[_.jsxs("div",{className:"space-y-2",children:[_.jsx(we,{htmlFor:"qp-label",children:"标签"}),_.jsx(U,{id:"qp-label",placeholder:"显示名(可选,默认用命令文本)",value:o,onChange:e=>a(e.target.value),className:"text-base",autoFocus:!0})]}),_.jsxs("div",{className:"space-y-2 flex-1 flex flex-col min-h-0",children:[_.jsx(we,{htmlFor:"qp-command",children:"命令"}),_.jsx("textarea",{id:"qp-command",placeholder:"输入要发送的命令...",value:h,onChange:e=>c(e.target.value),className:p("flex-1 min-h-[200px] w-full rounded-md border border-input bg-background px-4 py-3","text-base leading-relaxed font-mono","ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","resize-none"),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),f())}})]})]}),_.jsxs(ye,{className:"flex items-center justify-between sm:justify-between",children:[_.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ 保存"}),_.jsxs("div",{className:"flex gap-2",children:[_.jsx(H,{variant:"outline",onClick:()=>t(!1),children:"取消"}),_.jsx(H,{onClick:f,disabled:!h.trim(),children:"保存"})]})]})]})})}function vr({title:e,count:t,onAdd:i,children:s}){return _.jsxs("div",{className:"px-2 py-2",children:[_.jsxs("div",{className:"flex items-center justify-between mb-1.5 px-1",children:[_.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground uppercase tracking-wider",children:[_.jsx("span",{children:e}),_.jsxs("span",{className:"text-muted-foreground/60 normal-case tracking-normal",children:["(",t,")"]})]}),_.jsx("button",{onClick:i,className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"新建","aria-label":"新建",children:_.jsx($,{className:"h-3 w-3"})})]}),s]})}function Sr({projectId:e,onSend:t}){const i=a(),[s,r]=l.useState([]),[n,o]=l.useState([]),h=R(),c=h.get(e),[d,u]=l.useState({open:!1}),[f,p]=l.useState(c.shareHubOpen),[m,g]=l.useState(c.shareHubLabel),[v,S]=l.useState(c.shareHubCommand),b=x.usedShortcuts(e),[w,y]=l.useState(()=>{try{const e=localStorage.getItem(b);if(!e)return new Set;const t=JSON.parse(e);return new Set(Array.isArray(t)?t:[])}catch{return new Set}}),C=l.useCallback(e=>{y(t=>{if(t.has(e))return t;const i=new Set(t);i.add(e);try{localStorage.setItem(b,JSON.stringify([...i]))}catch{}return i})},[b]);l.useEffect(()=>{ce(e).then(r).catch(()=>r([]))},[e]),l.useEffect(()=>{de().then(o).catch(()=>o([]))},[]);const k=l.useCallback(e=>{const t=[],i=new Set;let s=e;const r=[];for(;s&&!i.has(s.id);)i.add(s.id),r.unshift(s),s=s.parentId?n.find(e=>e.id===s.parentId):void 0;for(const n of r)t.push(n.command);return t},[n]),E=l.useCallback(e=>{k(e).forEach((e,i)=>{setTimeout(()=>t(e+"\r"),500*i)})},[k,t]),D=e=>u({open:!0,mode:"create",scope:e}),M=(t,i)=>{g(t),S(i),p(!0),h.setShareHub(e,!0,t,i)};return _.jsxs("div",{className:"h-full flex flex-col text-foreground overflow-hidden",children:[_.jsxs("div",{className:"px-3 pt-2.5 pb-2 border-b border-border/50 shrink-0",children:[_.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Quick Prompts"}),_.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70 leading-snug",children:"点击卡片发送命令到 CLI;新建的命令在首次点击前以浅蓝色标识"})]}),_.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0",children:[_.jsx(vr,{title:"项目",count:s.length,onAdd:()=>D("project"),children:0===s.length?_.jsx("div",{className:"px-1 py-3 text-xs text-muted-foreground/60",children:"暂无项目命令"}):_.jsx("div",{className:"space-y-1.5",children:s.map(s=>_.jsx(mr,{kind:"quick-prompt",label:s.label,preview:s.label!==s.command?s.command:"",unclicked:!w.has(s.id),onLeftClick:()=>(e=>{t(e.command+"\r"),C(e.id)})(s),onEdit:()=>(e=>u({open:!0,mode:"edit",scope:"project",id:e.id,label:e.label,command:e.command}))(s),onDelete:()=>{(async t=>{if(await i({title:"删除项目快捷 Prompt",description:`确认删除「${t.label}」?此操作不可撤销。`,destructive:!0,confirmLabel:"删除"}))try{await _e(e,t.id),r(e=>e.filter(e=>e.id!==t.id)),y(e=>{if(!e.has(t.id))return e;const i=new Set(e);i.delete(t.id);try{localStorage.setItem(b,JSON.stringify([...i]))}catch{}return i})}catch(s){console.error("Failed to delete shortcut:",s)}})(s)},onShare:()=>M(s.label,s.command)},s.id))})}),_.jsx("div",{className:"h-px bg-border mx-2"}),_.jsx(vr,{title:"全局",count:n.length,onAdd:()=>D("global"),children:0===n.length?_.jsx("div",{className:"px-1 py-3 text-xs text-muted-foreground/60",children:"暂无全局命令"}):_.jsx("div",{className:"space-y-1.5",children:n.map(e=>{var t;const s=e.parentId?null==(t=n.find(t=>t.id===e.parentId))?void 0:t.label:void 0;return _.jsx(mr,{kind:"quick-prompt",label:e.label,preview:s?"":e.label!==e.command?e.command:"",onLeftClick:()=>E(e),onEdit:()=>(e=>u({open:!0,mode:"edit",scope:"global",id:e.id,label:e.label,command:e.command}))(e),onDelete:()=>{(async e=>{const t=n.filter(t=>t.parentId===e.id);if(await i({title:"删除全局快捷 Prompt",description:t.length>0?`「${e.label}」被 ${t.length} 个其他全局命令继承。删除后这些命令的继承会断链。确认删除?`:`确认删除「${e.label}」?此操作不可撤销。`,destructive:!0,confirmLabel:"删除"}))try{await pe(e.id),o(t=>t.filter(t=>t.id!==e.id))}catch(s){console.error("Failed to delete global shortcut:",s)}})(e)},onShare:()=>M(e.label,e.command),footer:s?_.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[_.jsx(ue,{className:"h-2.5 w-2.5 text-muted-foreground"}),_.jsxs("span",{className:"text-muted-foreground truncate",children:["继承: ",s,"(继承链仅可在 Dashboard 编辑)"]})]}):null},e.id)})})})]}),_.jsx(gr,{open:d.open,onOpenChange:e=>{e||u({open:!1})},initialLabel:d.open&&"edit"===d.mode?d.label:"",initialCommand:d.open&&"edit"===d.mode?d.command:"",title:d.open?"create"===d.mode?`新建${"global"===d.scope?"全局":"项目"}命令`:"编辑命令":"",onSave:(t,i)=>{(async(t,i)=>{if(d.open)try{if("create"===d.mode)if("global"===d.scope){const e=await xe({label:t,command:i});o(t=>[...t,e])}else{const s=await Ce(e,{label:t,command:i});r(e=>[...e,s])}else if("global"===d.scope){const e=n.find(e=>e.id===d.id),s=await ke(d.id,{label:t,command:i,parentId:(null==e?void 0:e.parentId)??null});o(e=>e.map(e=>e.id===s.id?s:e))}else{const s=await Ee(e,d.id,{label:t,command:i});r(e=>e.map(e=>e.id===s.id?s:e))}}catch(s){console.error("Failed to save shortcut:",s)}})(t,i)}}),_.jsx(fe,{open:f,onOpenChange:t=>{p(t),t||h.setShareHub(e,!1)},kind:"quick-prompt",label:m,content:v})]})}pr.displayName=cr.displayName;function br({open:e,onOpenChange:t,title:i,initialLabel:s,initialCommand:r,onSave:n}){const[o,a]=l.useState(s),[h,c]=l.useState(r),[d,u]=l.useState(!0);l.useEffect(()=>{e&&(a(s),c(r),u(!0))},[e,s,r]);const f=o.trim(),m=h.trim(),g=f.length>100,v=m.length>8e3,S=m.length>0&&f.length>0&&!g&&!v,b=()=>{S&&(n(f,h),t(!1))};return _.jsx(me,{open:e,onOpenChange:t,modal:!1,children:_.jsxs(ge,{noOverlay:!0,className:p("sm:max-w-2xl max-h-[85vh] flex flex-col transition-opacity",!d&&"opacity-50"),onInteractOutside:e=>{e.preventDefault(),u(!1)},onClick:()=>u(!0),children:[_.jsxs(ve,{children:[_.jsx(Se,{children:i}),_.jsx(be,{children:"This prompt can be clicked once in the sidebar to insert into CLAUDE.md, and clicked again to remove (by exact text match)."})]}),_.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col",children:[_.jsxs("div",{className:"space-y-2",children:[_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx(we,{htmlFor:"prompt-label",children:"Label"}),_.jsxs("span",{className:p("text-xs text-muted-foreground",g&&"text-red-500"),children:[f.length," / ",100]})]}),_.jsx(U,{id:"prompt-label",placeholder:"A short name for this prompt",value:o,onChange:e=>a(e.target.value),className:"text-base",autoFocus:!0})]}),_.jsxs("div",{className:"space-y-2 flex-1 flex flex-col min-h-0",children:[_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx(we,{htmlFor:"prompt-command",children:"Prompt"}),_.jsxs("span",{className:p("text-xs text-muted-foreground",v&&"text-red-500"),children:[m.length," / ",8e3]})]}),_.jsx("textarea",{id:"prompt-command",placeholder:"The exact text that will be appended to CLAUDE.md...",value:h,onChange:e=>c(e.target.value),className:p("flex-1 min-h-[200px] w-full rounded-md border border-input bg-background px-4 py-3","text-sm leading-relaxed font-mono","ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","resize-none"),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),b())}})]})]}),_.jsxs(ye,{className:"flex items-center justify-between sm:justify-between",children:[_.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ to save"}),_.jsxs("div",{className:"flex gap-2",children:[_.jsx(H,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),_.jsx(H,{onClick:b,disabled:!S,children:"Save"})]})]})]})})}function wr({projectId:e}){const t=a(),[i,s]=l.useState([]),[r,n]=l.useState([]),[o,h]=l.useState(!0),[c,d]=l.useState({open:!1}),[u,p]=l.useState({open:!1,label:"",content:""}),m=l.useCallback(async()=>{try{const t=await Re(e);s(t.global),n(t.project)}catch(t){f.error(`加载提示词失败: ${t.message}`)}finally{h(!1)}},[e]);l.useEffect(()=>{h(!0),m()},[m]);const g=l.useRef(new Set),v=l.useCallback(async(t,i)=>{if(g.current.has(i.id))return;g.current.add(i.id);const r=i.inserted?"remove":"insert",o=e=>e.map(e=>e.id===i.id?{...e,inserted:!e.inserted}:e);"global"===t?s(o):n(o);try{const t=await De(e,i.command,r);if("remove"===r&&!1===t.changed)return"not-found"===t.reason?f.error("CLAUDE.md 中找不到该提示词的精确文本,请自行编辑 CLAUDE.md 移除。"):f.warning("该提示词当前不在 CLAUDE.md 中(可能被手动编辑过),已重新同步状态。"),void m();m()}catch(a){f.error(`操作失败: ${a.message}`),"global"===t?s(o):n(o)}finally{g.current.delete(i.id)}},[e,m]),S=l.useCallback(async(t,i,s,r,n)=>{try{if("create"===t)"global"===i?await Me({label:r,command:n}):await Le(e,{label:r,command:n}),f.success("已添加");else{if(!s)return;"global"===i?await Ne(s,{label:r,command:n}):await Pe(e,s,{label:r,command:n}),f.success("已更新")}m()}catch(o){f.error(`保存失败: ${o.message}`)}},[e,m]),b=l.useCallback(async(i,s)=>{const r=s.inserted?'此提示词目前已插入当前项目的 CLAUDE.md。\n\n删除后它会在 CLAUDE.md 中成为"孤儿文本"——仅删除提示词记录,不会自动从 CLAUDE.md 移除。\n\n确认删除?':"确认删除此提示词?此操作不可撤销。";if(await t({title:"删除提示词",description:r,destructive:!0,confirmLabel:"删除"}))try{"global"===i?await Te(s.id):await Be(e,s.id),f.success("已删除"),m()}catch(n){f.error(`删除失败: ${n.message}`)}},[e,m,t]),w=l.useCallback(e=>{p({open:!0,label:e.label,content:e.command})},[]);return _.jsxs("div",{className:"flex flex-col h-full overflow-y-auto",children:[_.jsxs("div",{className:"px-3 pt-2.5 pb-2 border-b border-border/50 shrink-0",children:[_.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Agent Prompts"}),_.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70 leading-snug",children:"点击卡片插入 / 移出当前项目的 CLAUDE.md;左上角绿点表示已插入"})]}),_.jsx(yr,{title:"项目",count:r.length,loading:o,prompts:r,emptyText:"暂无项目提示词",onAdd:()=>d({open:!0,mode:"create",scope:"project"}),onToggle:e=>{v("project",e)},onEdit:e=>d({open:!0,mode:"edit",scope:"project",id:e.id,label:e.label,command:e.command}),onDelete:e=>{b("project",e)},onShare:w}),_.jsx("div",{className:"h-px bg-border mx-2"}),_.jsx(yr,{title:"全局",count:i.length,loading:o,prompts:i,emptyText:"暂无全局提示词",onAdd:()=>d({open:!0,mode:"create",scope:"global"}),onToggle:e=>{v("global",e)},onEdit:e=>d({open:!0,mode:"edit",scope:"global",id:e.id,label:e.label,command:e.command}),onDelete:e=>{b("global",e)},onShare:w}),_.jsx(br,{open:c.open,onOpenChange:e=>{e||d({open:!1})},title:!1===c.open?"":"create"===c.mode?`新建${"global"===c.scope?"全局":"项目"}提示词`:`编辑${"global"===c.scope?"全局":"项目"}提示词`,initialLabel:c.open&&"edit"===c.mode?c.label:"",initialCommand:c.open&&"edit"===c.mode?c.command:"",onSave:(e,t)=>{if(!c.open)return;const i="edit"===c.mode?c.id:null;S(c.mode,c.scope,i,e,t)}}),_.jsx(fe,{open:u.open,onOpenChange:e=>p(t=>({...t,open:e})),kind:"agent-prompt",label:u.label,content:u.content})]})}function yr({title:e,count:t,loading:i,prompts:s,emptyText:r,onAdd:n,onToggle:o,onEdit:a,onDelete:l,onShare:h}){return _.jsxs("div",{className:"px-2 py-2",children:[_.jsxs("div",{className:"flex items-center justify-between mb-1.5 px-1",children:[_.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground uppercase tracking-wider",children:[_.jsx("span",{children:e}),_.jsxs("span",{className:"text-muted-foreground/60 normal-case tracking-normal",children:["(",t,")"]})]}),_.jsx("button",{onClick:n,className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",title:"新建","aria-label":"新建",children:_.jsx($,{className:"h-3 w-3"})})]}),i?_.jsx("div",{className:"px-1 py-3 text-xs text-muted-foreground/60",children:"加载中…"}):0===s.length?_.jsx("div",{className:"px-1 py-3 text-xs text-muted-foreground/60",children:r}):_.jsx("div",{className:"space-y-1.5",children:s.map(e=>{const t=e.command.split("\n").find(e=>e.trim())??e.command.trim();return _.jsx(mr,{kind:"agent-prompt",label:e.label,preview:t,inserted:e.inserted,onLeftClick:()=>o(e),onEdit:()=>a(e),onDelete:()=>l(e),onShare:()=>h(e)},e.id)})})]})}function xr({projectId:e}){const[t,i]=l.useState([]),[s,r]=l.useState(!0),n=l.useRef(new Set),o=l.useCallback(async()=>{r(!0);try{const t=await je(e);i(t)}catch(t){f.error(`加载失败: ${t.message}`)}finally{r(!1)}},[e]);l.useEffect(()=>{o()},[o]);const a=l.useCallback(async t=>{if(n.current.has(t.filename))return;n.current.add(t.filename),i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:!e.inserted}:e));const s=t.inserted?"remove":"insert";try{const r=await Ae(e,t.filename,s);if(!r.ok)return f.error("操作失败"+(r.reason?`(${r.reason})`:"")),void o();i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:r.inserted}:e)),"insert"===s&&"refreshed"===r.reason&&f.info(`${t.name} 已更新(文件内容有变化)`)}catch(r){f.error(`操作失败: ${r.message}`),i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:t.inserted}:e))}finally{n.current.delete(t.filename)}},[e,o]);return _.jsxs("div",{className:"flex flex-col h-full overflow-y-auto",children:[_.jsxs("div",{className:"px-3 pt-2.5 pb-2 border-b border-border/50 shrink-0",children:[_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Memory Prompts"}),_.jsx("button",{onClick:()=>{o()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors",title:"刷新(重新扫描 .ccweb/memory/)",children:_.jsx(N,{className:p("h-3.5 w-3.5",s&&"animate-spin")})})]}),_.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground/70 leading-snug",children:["来自 ",_.jsx("code",{className:"text-[11px]",children:".ccweb/memory/*.md"})," 的文件,点击插入 / 移除 CLAUDE.md(以",_.jsx("code",{className:"text-[11px]",children:" START 名 / END 名 "}),"包裹)"]})]}),_.jsx("div",{className:"px-2 py-2 flex-1 min-h-0",children:s&&0===t.length?_.jsx("div",{className:"px-1 py-6 text-xs text-muted-foreground/60 text-center",children:"加载中…"}):0===t.length?_.jsxs("div",{className:"px-1 py-8 text-xs text-muted-foreground/60 flex flex-col items-center gap-2",children:[_.jsx(Yt,{className:"h-5 w-5"}),_.jsxs("div",{className:"text-center leading-relaxed",children:["暂无 memory 文件",_.jsx("br",{}),"新建 ",_.jsx("code",{className:"text-[11px]",children:".ccweb/memory/*.md"})," 文件后点刷新"]})]}):_.jsx("div",{className:"space-y-1.5",children:t.map(e=>_.jsx(mr,{kind:"agent-prompt",noContextMenu:!0,label:e.name,preview:e.preview,inserted:e.inserted,onLeftClick:()=>{a(e)}},e.filename))})})]})}function Cr({projectId:e,onSend:t}){const[i,s]=Y(x.rightPanelTab,"shortcuts"),r="prompts"===i?"prompts":"memory"===i?"memory":"shortcuts";return _.jsxs(kt,{value:r,onValueChange:e=>s(e),orientation:"vertical",className:"h-full flex bg-muted/40 text-foreground overflow-hidden",children:[_.jsxs("div",{className:"flex-1 min-w-0 flex flex-col bg-background border-r border-border",children:[_.jsx(Dt,{value:"shortcuts",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:_.jsx(Sr,{projectId:e,onSend:t})}),_.jsx(Dt,{value:"prompts",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:_.jsx(wr,{projectId:e})}),_.jsx(Dt,{value:"memory",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:_.jsx(xr,{projectId:e})})]}),_.jsxs(Et,{className:p("flex flex-col items-center justify-start shrink-0","h-full w-9 bg-muted/60 border-l border-border rounded-none p-1 gap-1"),children:[_.jsx(Rt,{value:"shortcuts",title:"Quick Prompts (快捷 Prompts)","aria-label":"Quick Prompts",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:_.jsx(Oe,{className:"h-3.5 w-3.5"})}),_.jsx(Rt,{value:"prompts",title:"Agent Prompts","aria-label":"Agent Prompts",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:_.jsx(Ie,{className:"h-3.5 w-3.5"})}),_.jsx(Rt,{value:"memory",title:"Memory Prompts (.ccweb/memory/*.md)","aria-label":"Memory Prompts",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:_.jsx(Yt,{className:"h-3.5 w-3.5"})})]})]})}function kr({status:e}){return _.jsxs("span",{className:p("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",{running:"bg-green-500/10 text-green-600 border-green-500/20",stopped:"bg-muted text-muted-foreground border-border",restarting:"bg-yellow-500/10 text-yellow-600 border-yellow-500/20"}[e]),children:[_.jsx("span",{className:p("w-1.5 h-1.5 rounded-full",{"bg-green-500":"running"===e,"bg-muted-foreground":"stopped"===e,"bg-yellow-400 animate-pulse":"restarting"===e})}),e.charAt(0).toUpperCase()+e.slice(1)]})}function Er({project:e,projectId:t,showFileTree:i,showShortcuts:s,showChatOverlay:r,onToggleFileTree:n,onToggleShortcuts:o,onToggleChatOverlay:a,onProjectUpdate:h}){const c=ze(),[d,u]=l.useState(!1),[m,g]=l.useState(!1),[b,w]=l.useState(!1),[y,x]=l.useState(!1);l.useEffect(()=>{const e=()=>x(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]);return _.jsx("header",{className:"border-b border-border flex-shrink-0 bg-muted/50",children:_.jsxs("div",{className:"px-3 h-12 flex items-center gap-2",children:[_.jsx(H,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c("/"),children:_.jsx(We,{className:"h-4 w-4"})}),_.jsx("button",{className:p("p-1 rounded transition-colors",i?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:n,title:"Toggle file tree",children:_.jsx(ti,{className:"h-4 w-4"})}),_.jsx("button",{className:p("p-1 rounded transition-colors",s?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:o,title:"Toggle right panel",children:_.jsx(ii,{className:"h-4 w-4"})}),"terminal"!==e.cliTool&&_.jsx("button",{className:p("p-1 rounded transition-colors",r?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:a,title:"对话框 (Ctrl+I)",children:_.jsx(Jt,{className:"h-4 w-4"})}),_.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2 ml-1",children:[_.jsx("h1",{className:"font-semibold text-foreground truncate text-sm",children:e.name}),_.jsx(kr,{status:e.status}),_.jsx(He,{variant:"outline",className:"text-xs",children:"unlimited"===e.permissionMode?"Unlimited":"Limited"}),_.jsx("span",{className:"text-xs text-muted-foreground font-mono truncate hidden lg:block",children:e.folderPath})]}),_.jsx(Fe,{}),_.jsx($e,{}),_.jsx(H,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()},title:y?"退出全屏":"全屏",children:y?_.jsx(v,{className:"h-3.5 w-3.5"}):_.jsx(S,{className:"h-3.5 w-3.5"})}),_.jsxs(H,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>{(async()=>{if(!b){w(!0);try{const e=await qe(t);e.skipped?f.info("该项目正在同步中,跳过"):e.ok?f.success(`同步完成:${e.filesTransferred} 文件,耗时 ${Math.round(e.durationMs/1e3)}s`):f.error("同步失败"+(e.reason?`(${e.reason})`:""))}catch(e){f.error(e instanceof Error?e.message:"同步失败")}finally{w(!1)}}})()},disabled:b,title:"同步到 rsync 服务器(在设置里配置)",children:[b?_.jsx(Ue,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):_.jsx(Ke,{className:"h-3.5 w-3.5 mr-1.5"}),"同步"]}),_.jsxs(H,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>{(async()=>{g(!0);try{await Ve(t)}catch(e){f.error(e instanceof Error?e.message:"备份失败")}finally{g(!1)}})()},disabled:m,title:"备份到云盘(即将废弃,请使用同步)",children:[m?_.jsx(Ue,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):_.jsx(zt,{className:"h-3.5 w-3.5 mr-1.5"}),"备份"]}),"stopped"===e.status&&_.jsxs(H,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>{(async()=>{u(!0);try{h(await Ye(e.id))}catch(t){console.error(t)}finally{u(!1)}})()},disabled:d,children:[_.jsx(si,{className:"h-3.5 w-3.5 mr-1.5"}),"Start"]})]})})}
|
|
14
|
+
*/const di=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif","tiff","tif"]);function ui(e){return"md"===e?"Markdown":"html"===e||"htm"===e?"HTML":"高亮"}const fi=[50,75,100,125,150,200,250,300],_i=100;function pi({filePath:e,onClose:t}){const i=a(),s=e.endsWith("/.notebook/graph.yaml"),r=s?e.replace(/\/.notebook\/graph\.yaml$/,""):"",[n,o]=l.useState(null),[C,k]=l.useState(null),[R,D]=l.useState(()=>s?"graph":"rendered"),[M,L]=l.useState(!1),[N,P]=l.useState(_i),[T,B]=l.useState(""),[j,A]=l.useState(!1),[O,I]=l.useState(!1),z=l.useRef(null),[W,H]=l.useState(!0),{resolved:F}=h(),$=e.split("/").pop()??e,U=l.useMemo(()=>function(e){const t=e.split("/").pop()??"",i=t.toLowerCase();if("dockerfile"===i)return"dockerfile";if("makefile"===i)return"makefile";const s=t.lastIndexOf(".");return s>=0?t.slice(s+1).toLowerCase():""}(e),[e]),K=di.has(U),q=hi.has(U),V=function(e){return"md"===e||"html"===e||"htm"===e||e in ci}(U),Y=ci[U]||U,X=l.useMemo(()=>{if(!K)return"";const t=w(e),i=c(),s=`${t}&t=${Date.now()}`;return i?`${s}&token=${encodeURIComponent(i)}`:s},[e,K]);l.useEffect(()=>{if(H(!0),o(null),k(null),P(function(e){const t=y(x.fileZoom,{},!0)[e];return fi.includes(t)?t:_i}(e)),I(!1),K||q)return o({path:e,binary:!1,tooLarge:!1,size:0,content:null}),void D("rendered");D(e.endsWith("/.notebook/graph.yaml")?"graph":"rendered"),d(e).then(e=>{o(e),B(e.content??"")}).catch(e=>k(e instanceof Error?e.message:"Failed to load file"))},[e,K,q]);const G=l.useCallback(async()=>{A(!0);try{await u(e,T),o(e=>e?{...e,content:T,size:new Blob([T]).size}:e),I(!1)}catch(t){f.error(t instanceof Error?t.message:"保存失败")}finally{A(!1)}},[e,T]);l.useEffect(()=>{const e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&"edit"===R&&(e.preventDefault(),G())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[R,G]),l.useEffect(()=>{const e=async e=>{if("Escape"===e.key&&W){if(O){if(!(await i({description:"有未保存的修改,确定关闭?",confirmLabel:"放弃修改",destructive:!0})))return}t()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[W,t,O,i]);const J=async()=>{if(O){if(!(await i({description:"有未保存的修改,确定退出编辑?",confirmLabel:"放弃修改",destructive:!0})))return}D(s?"graph":V?"rendered":"plain"),I(!1)},Z=t=>{P(t),function(e,t){const i=y(x.fileZoom,{},!0);t===_i?delete i[e]:i[e]=t,E(x.fileZoom,i,!0)}(e,t)},Q=(null==n?void 0:n.content)??"",ee="dark"===F?gt:vt,te=N/100*12,ie=n&&!n.binary&&!n.tooLarge,se=l.useDeferredValue(T),re=l.useMemo(()=>{var e,t;if(!n||n.binary||n.tooLarge)return null;if(K||q)return null;const i="edit"===R?se:Q;if(null==i)return null;return{bytes:new Blob([i]).size,words:((null==(e=i.match(/[\u4e00-\u9fff\u3400-\u4dbf]/g))?void 0:e.length)??0)+((null==(t=i.replace(/[\u4e00-\u9fff\u3400-\u4dbf]/g," ").match(/[a-zA-Z0-9]+/g))?void 0:t.length)??0),lines:""===i?0:i.split("\n").length}},[n,K,q,R,se,Q]);return _.jsx("div",{className:p("fixed inset-0 z-50 flex items-center justify-center transition-all duration-200",W?"bg-black/60 backdrop-blur-sm pointer-events-auto":"bg-transparent pointer-events-none"),onClick:e=>{e.target===e.currentTarget&&H(!1)},children:_.jsxs("div",{className:p("relative flex flex-col bg-background border border-border shadow-2xl transition-all duration-200 pointer-events-auto",M?"w-screen h-screen rounded-none":"w-[72vw] max-w-4xl h-[80vh] rounded-lg",!W&&!M&&"opacity-50"),onClick:()=>H(!0),onFocus:e=>{e.stopPropagation(),H(!0)},children:[_.jsxs("div",{className:"flex items-center gap-2 px-4 h-10 border-b border-border flex-shrink-0",children:[_.jsx(dt,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),_.jsxs("span",{className:"flex-1 text-sm text-foreground font-medium truncate",title:e,children:[$,O&&_.jsx("span",{className:"text-muted-foreground ml-1",children:"*"}),re&&_.jsxs("span",{className:"text-muted-foreground font-normal ml-2 text-xs tabular-nums",children:[(ne=re.bytes,ne<1024?`${ne} B`:ne<1048576?`${(ne/1024).toFixed(1)} KB`:`${(ne/1024/1024).toFixed(2)} MB`)," · ",re.words.toLocaleString()," 词 · ",re.lines.toLocaleString()," 行"]})]}),ie&&!K&&!q&&_.jsxs("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5",children:[V&&_.jsxs(_.Fragment,{children:[_.jsxs("button",{onClick:()=>"edit"===R?J():D("plain"),className:p("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs","plain"===R?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"纯文本",children:[_.jsx(qt,{className:"h-3 w-3"}),_.jsx("span",{className:"hidden sm:inline",children:"源码"})]}),_.jsxs("button",{onClick:()=>"edit"===R?J():D("rendered"),className:p("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs","rendered"===R?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:ui(U),children:[_.jsx(m,{className:"h-3 w-3"}),_.jsx("span",{className:"hidden sm:inline",children:ui(U)})]})]}),s&&_.jsxs("button",{onClick:()=>"edit"===R?J():D("graph"),className:p("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs","graph"===R?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"图谱",children:[_.jsx(ei,{className:"h-3 w-3"}),_.jsx("span",{className:"hidden sm:inline",children:"图谱"})]}),_.jsxs("button",{onClick:()=>"edit"===R?J():(B((null==n?void 0:n.content)??""),I(!1),D("edit"),void setTimeout(()=>{var e;return null==(e=z.current)?void 0:e.focus()},0)),className:p("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs","edit"===R?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"编辑",children:[_.jsx(g,{className:"h-3 w-3"}),_.jsx("span",{className:"hidden sm:inline",children:"编辑"})]})]}),"edit"===R&&_.jsxs("button",{onClick:()=>{G()},disabled:j||!O,className:p("flex items-center gap-1 text-xs px-2 py-1 rounded transition-colors",O?"bg-blue-600 hover:bg-blue-500 text-white":"bg-muted text-muted-foreground"),title:"保存 (⌘S)",children:[_.jsx(xt,{className:"h-3 w-3"}),j?"保存中...":"保存"]}),(ie||K)&&"edit"!==R&&"graph"!==R&&_.jsxs("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5 gap-0.5",children:[_.jsx("button",{onClick:()=>{const e=[...fi].reverse().find(e=>e<N);e&&Z(e)},disabled:N<=fi[0],className:"p-1 rounded-sm text-muted-foreground hover:text-foreground transition-colors disabled:opacity-30",title:"缩小",children:_.jsx(oi,{className:"h-3 w-3"})}),_.jsxs("button",{onClick:()=>Z(_i),className:"px-1 text-xs text-muted-foreground hover:text-foreground transition-colors min-w-[36px] text-center",title:"重置缩放",children:[N,"%"]}),_.jsx("button",{onClick:()=>{const e=fi.find(e=>e>N);e&&Z(e)},disabled:N>=fi[fi.length-1],className:"p-1 rounded-sm text-muted-foreground hover:text-foreground transition-colors disabled:opacity-30",title:"放大",children:_.jsx(ni,{className:"h-3 w-3"})})]}),_.jsx("button",{className:"p-1 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:()=>L(e=>!e),title:M?"退出全屏":"全屏",children:M?_.jsx(v,{className:"h-3.5 w-3.5"}):_.jsx(S,{className:"h-3.5 w-3.5"})}),_.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:async()=>{if(O){if(!(await i({description:"有未保存的修改,确定关闭?",confirmLabel:"放弃修改",destructive:!0})))return}t()},children:_.jsx(b,{className:"h-4 w-4"})})]}),_.jsxs("div",{className:p("flex-1 min-h-0","graph"===R?"overflow-hidden":"overflow-auto"),children:["graph"===R&&_.jsx(l.Suspense,{fallback:_.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),children:_.jsx(ai,{folderPath:r})}),"graph"!==R&&!n&&!C&&_.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),"graph"!==R&&C&&_.jsx("p",{className:"text-sm text-red-400 p-4",children:C}),"graph"!==R&&K&&n&&_.jsx("div",{className:"flex items-center justify-center p-4 h-full",children:_.jsx("img",{src:X,alt:$,className:"max-w-full max-h-full object-contain rounded",style:{transform:`scale(${N/100})`,transformOrigin:"center center"},draggable:!1})}),"graph"!==R&&q&&n&&_.jsx(l.Suspense,{fallback:_.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),children:_.jsx(li,{filePath:e,ext:U,zoom:N})}),"graph"!==R&&!K&&!q&&n&&n.binary&&_.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-muted-foreground p-4",children:[_.jsx(dt,{className:"h-8 w-8"}),_.jsx("p",{className:"text-sm",children:"Binary file — cannot preview"}),_.jsxs("p",{className:"text-xs text-muted-foreground",children:[(n.size/1024).toFixed(1)," KB"]})]}),"graph"!==R&&!q&&n&&n.tooLarge&&_.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-muted-foreground p-4",children:[_.jsx(dt,{className:"h-8 w-8"}),_.jsx("p",{className:"text-sm",children:"File too large to preview"}),_.jsxs("p",{className:"text-xs text-muted-foreground",children:[(n.size/1024/1024).toFixed(2)," MB (limit 5 MB)"]})]}),"graph"!==R&&ie&&null!==Q&&_.jsxs(_.Fragment,{children:["edit"===R&&_.jsx("textarea",{ref:z,value:T,onChange:e=>{B(e.target.value),I(!0)},className:"w-full h-full bg-transparent text-foreground font-mono outline-none resize-none p-4 leading-relaxed",style:{fontSize:`${te}px`,minHeight:"100%"},spellCheck:!1}),"edit"!==R&&_.jsxs("div",{className:"p-4",style:{fontSize:`${te}px`},children:["plain"===R&&_.jsx("pre",{className:"font-mono text-foreground whitespace-pre-wrap break-words leading-relaxed",style:{fontSize:"inherit"},children:Q}),"rendered"===R&&"md"===U&&_.jsx("div",{className:"prose dark:prose-invert max-w-none prose-pre:bg-muted prose-pre:border prose-pre:border-border prose-code:text-foreground",style:{fontSize:"inherit"},children:_.jsx(ut,{remarkPlugins:[_t,pt],rehypePlugins:[ft],components:{code({className:e,children:t,...i}){const s=/language-(\w+)/.exec(e||"");return!s&&!e?_.jsx("code",{className:e,...i,children:t}):_.jsx(mt,{style:ee,language:(null==s?void 0:s[1])||"text",PreTag:"div",customStyle:{fontSize:"inherit",borderRadius:"6px",margin:0},children:String(t).replace(/\n$/,"")})}},children:Q})}),"rendered"===R&&("html"===U||"htm"===U)&&_.jsx("iframe",{srcDoc:ct.sanitize(Q,{WHOLE_DOCUMENT:!0,ADD_TAGS:["style","link"]}),className:"w-full h-full border-0 rounded bg-white",sandbox:"",title:$,style:{minHeight:"60vh",transform:`scale(${N/100})`,transformOrigin:"top left",width:1e4/N+"%",height:1e4/N+"%"}}),"rendered"===R&&"md"!==U&&"html"!==U&&"htm"!==U&&Y&&_.jsx(mt,{style:ee,language:Y,showLineNumbers:!0,lineNumberStyle:{color:"dark"===F?"#555":"#aaa",fontSize:"inherit"},customStyle:{fontSize:"inherit",borderRadius:"6px",margin:0,background:"transparent"},children:Q}),"rendered"===R&&!V&&_.jsx("pre",{className:"font-mono text-foreground whitespace-pre-wrap break-words leading-relaxed",style:{fontSize:"inherit"},children:Q})]})]})]})]})});var ne}const mi=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif","tiff","tif"]);function gi(e){const t=e.lastIndexOf(".");return t>=0&&mi.has(e.slice(t+1).toLowerCase())}function vi({projectPath:e,projectId:t}){const[i,s]=l.useState(new Map),[r,n]=l.useState(new Set([e])),[o,h]=l.useState(new Set),d=R(e=>e.get(t).filePreviewPath),u=R(e=>e.setFilePreviewPath),m=e=>u(t,e),[g,v]=l.useState(null),[S,b]=l.useState(!1),[y,x]=l.useState(!1),C=a(),k=l.useRef(null),E=l.useRef(null);l.useEffect(()=>{if(!g)return;const e=()=>v(null);return window.addEventListener("click",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("click",e),window.removeEventListener("scroll",e,!0)}},[g]);const z=async t=>{if(0!==t.length){b(!0);try{await B(e,t),W(e)}catch(i){console.error("[FileTree] Upload failed:",i)}finally{b(!1)}}},W=l.useCallback(async e=>{h(t=>{if(t.has(e))return t;const i=new Set(t);return i.add(e),i});try{const t=await D(e);s(i=>new Map(i).set(e,t.entries))}catch(t){console.error("[FileTree] Failed to load:",e,t),s(t=>new Map(t).set(e,[]))}finally{h(t=>{const i=new Set(t);return i.delete(e),i})}},[]);l.useEffect(()=>{s(new Map),n(new Set([e])),h(new Set),W(e)},[e,W]);const H=l.useCallback(e=>{n(t=>{const s=new Set(t);return s.has(e)?s.delete(e):(s.add(e),i.has(e)||W(e)),s})},[i,W]),F=l.useCallback(()=>{s(new Map),n(new Set([e])),h(new Set),W(e)},[e,W]),$=(e,t)=>e.map(e=>{const s=r.has(e.path),n=o.has(e.path),a=i.get(e.path),l=e.name.startsWith(".");return _.jsxs("div",{children:[_.jsxs("div",{className:p("flex items-center gap-1 py-[3px] rounded cursor-pointer","hover:bg-muted-foreground/10",l&&"opacity-50"),style:{paddingLeft:14*t+6+"px",paddingRight:"6px"},onClick:()=>"dir"===e.type?H(e.path):m(e.path),onContextMenu:t=>{t.preventDefault(),v({x:t.clientX,y:t.clientY,filePath:e.path,fileName:e.name,type:e.type})},children:[_.jsx("span",{className:"w-3 flex-shrink-0 text-muted-foreground",children:"dir"===e.type&&(n?_.jsx(N,{className:"h-2.5 w-2.5 animate-spin"}):s?_.jsx(Ht,{className:"h-2.5 w-2.5"}):_.jsx(j,{className:"h-2.5 w-2.5"}))}),"dir"===e.type?s?_.jsx(P,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}):_.jsx(A,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}):gi(e.name)?_.jsx(St,{className:"h-3.5 w-3.5 text-green-400 flex-shrink-0"}):_.jsx(dt,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),_.jsx("span",{className:p("text-xs truncate leading-none","dir"===e.type?"text-foreground":"text-muted-foreground"),title:e.path,children:e.name})]}),_.jsx(O,{initial:!1,children:"dir"===e.type&&s&&_.jsxs(I.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15,ease:"easeInOut"},className:"overflow-hidden",children:[!a&&!n&&_.jsx("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:14*(t+1)+6+16+"px"},children:"—"}),0===(null==a?void 0:a.length)&&_.jsx("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:14*(t+1)+6+16+"px"},children:"empty"}),a&&a.length>0&&$(a,t+1)]})})]},e.path)}),U=i.get(e),K=o.has(e),q=e.split("/").filter(Boolean).pop()??e;return _.jsxs(_.Fragment,{children:[d&&_.jsx(pi,{filePath:d,onClose:()=>m(null)}),g&&_.jsxs("div",{ref:k,className:"fixed z-50 min-w-[140px] bg-popover border border-border rounded-md shadow-md py-1",style:{left:g.x,top:g.y},onClick:e=>e.stopPropagation(),children:[_.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{const t=g.filePath.startsWith(e+"/")?g.filePath.slice(e.length+1):g.filePath;navigator.clipboard.writeText(t),f.success("已复制相对路径"),v(null)},children:[_.jsx(Vt,{className:"h-3.5 w-3.5"}),"复制相对路径"]}),_.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{navigator.clipboard.writeText(g.filePath),f.success("已复制绝对路径"),v(null)},children:[_.jsx(Kt,{className:"h-3.5 w-3.5"}),"复制绝对路径"]}),"file"===g.type&&_.jsxs(_.Fragment,{children:[_.jsx("div",{className:"my-1 border-t border-border"}),_.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{(async(e,t)=>{let i=w(e);const s=c();s&&(i+=`${i.includes("?")?"&":"?"}token=${encodeURIComponent(s)}`),i+=(i.includes("?")?"&":"?")+"dl=1";try{const e=await fetch(i);if(!e.ok){const t=await e.text().catch(()=>"");let i=`下载失败 (${e.status})`;try{i=JSON.parse(t).error||i}catch{}return void f.error(i)}const s=await e.blob(),r=URL.createObjectURL(s),n=document.createElement("a");n.href=r,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}catch{f.error("下载失败:网络错误")}})(g.filePath,g.fileName),v(null)},children:[_.jsx(M,{className:"h-3.5 w-3.5"}),"下载"]})]}),_.jsx("div",{className:"my-1 border-t border-border"}),_.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-destructive/80 hover:text-destructive-foreground text-left",onClick:()=>{(async(t,s,r)=>{const n="dir"===r?`文件夹 "${s}" 及其所有内容`:`文件 "${s}"`;if(await C({title:"确认删除",description:`确认删除${n}?此操作不可撤销。`,destructive:!0,confirmLabel:"删除"}))try{await T(t),f.success(`已删除: ${s}`);const r=t.substring(0,t.lastIndexOf("/"));r&&i.has(r)?W(r):W(e)}catch(o){f.error(`删除失败: ${o.message}`)}})(g.filePath,g.fileName,g.type),v(null)},children:[_.jsx(L,{className:"h-3.5 w-3.5"}),"删除"]})]}),_.jsxs("div",{className:"h-full flex flex-col text-foreground select-none",children:[_.jsxs("div",{className:"flex items-center justify-between px-3 h-9 border-b border-border flex-shrink-0",children:[_.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Files"}),_.jsxs("div",{className:"flex items-center gap-0.5",children:[_.jsx("input",{ref:E,type:"file",multiple:!0,className:"hidden",onChange:e=>{const t=Array.from(e.target.files??[]);t.length>0&&z(t),e.target.value=""}}),_.jsx("button",{className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",onClick:()=>{var e;return null==(e=E.current)?void 0:e.click()},disabled:S,title:"上传文件",children:_.jsx(Ct,{className:p("h-3 w-3",S&&"animate-pulse")})}),_.jsx("button",{className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",onClick:F,title:"Refresh file tree",children:_.jsx(N,{className:p("h-3 w-3",K&&"animate-spin")})})]})]}),_.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-border flex-shrink-0",children:[_.jsx(P,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}),_.jsx("span",{className:"text-xs text-foreground font-medium truncate",title:e,children:q})]}),_.jsxs("div",{className:p("flex-1 overflow-y-auto py-1 min-h-0 transition-colors",y&&"bg-accent/30 ring-1 ring-inset ring-accent"),onDragOver:e=>{e.preventDefault(),x(!0)},onDragEnter:e=>{e.preventDefault(),x(!0)},onDragLeave:()=>x(!1),onDrop:e=>{e.preventDefault(),x(!1);const t=Array.from(e.dataTransfer.files);t.length>0&&z(t)},children:[S&&_.jsx("div",{className:"text-xs text-muted-foreground px-4 py-1",children:"上传中..."}),y&&!S&&_.jsx("div",{className:"text-xs text-muted-foreground px-4 py-1",children:"松开以上传文件"}),K&&!U?_.jsx("div",{className:"text-xs text-muted-foreground px-4 py-3",children:"Loading…"}):U&&0!==U.length?$(U,0):_.jsx("div",{className:"text-xs text-muted-foreground px-4 py-3",children:"Empty folder"})]})]})]})}function Si(e){const t=new Date(e),i=Date.now()-t.getTime();return i<36e5?`${Math.floor(i/6e4)}分钟前`:i<864e5?`${Math.floor(i/36e5)}小时前`:i<6048e5?`${Math.floor(i/864e5)}天前`:t.toLocaleDateString()}function bi({projectId:e}){const[t,i]=l.useState(null),[s,r]=l.useState(!0),[n,o]=l.useState(null),[a,h]=l.useState(null),[c,d]=l.useState(""),[u,m]=l.useState(!1),[g,v]=l.useState([]),[S,b]=l.useState(0),[w,y]=l.useState(!0),[x,C]=l.useState(!1),k=l.useCallback(async()=>{r(!0);try{i(await z(e))}catch{i(null)}finally{r(!1)}},[e]),E=l.useCallback(async(t=!1)=>{C(!0);try{const i=t?g.length:0,s=await W(e,30,i);v(e=>t?[...e,...s.commits]:s.commits),b(s.total)}catch{}finally{C(!1)}},[e,g.length]);l.useEffect(()=>{k(),E()},[e]);const R=async t=>{try{const{diff:i}=await K(e,t);o(i||"(no diff)"),h(t??"all changes")}catch{f.error("获取 diff 失败")}},D=async t=>{try{await q(e,[t]),f.success(`已暂存 ${t}`),await k()}catch{f.error("git add 失败")}},M=async()=>{if(c.trim()){m(!0);try{await V(e,c),f.success("提交成功"),d(""),await k()}catch(t){f.error(t instanceof Error?t.message:"提交失败")}finally{m(!1)}}};if(!t&&s)return _.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50 text-xs",children:[_.jsx(Xt,{className:"h-5 w-5"}),_.jsx("p",{children:"加载中…"})]});if(!t||!t.isRepo)return _.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50 text-xs",children:[_.jsx(Xt,{className:"h-5 w-5"}),_.jsx("p",{children:t?"非 Git 仓库":"加载失败"}),_.jsx(H,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{k()},children:"重试"})]});const L=[...t.modified??[],...t.deleted??[]],P=t.staged??[],T=t.untracked??[];return _.jsxs("div",{className:"flex flex-col h-full overflow-y-auto p-2 space-y-2 text-xs",children:[_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground font-medium",children:[_.jsx(Xt,{className:"h-3 w-3"}),_.jsx("span",{children:t.branch}),(t.ahead??0)>0&&_.jsxs("span",{className:"text-blue-400",children:["↑",t.ahead]}),(t.behind??0)>0&&_.jsxs("span",{className:"text-yellow-400",children:["↓",t.behind]})]}),_.jsx(H,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{k()},disabled:s,children:_.jsx(N,{className:p("h-3 w-3",s&&"animate-spin")})})]}),P.length>0&&_.jsxs("div",{children:[_.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["已暂存 (",P.length,")"]}),P.map(e=>_.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted-foreground/10",children:[_.jsx(F,{className:"h-2.5 w-2.5 text-green-500 flex-shrink-0"}),_.jsx("button",{className:"flex-1 text-left truncate text-green-400",onClick:()=>{R(e)},children:e})]},e))]}),L.length>0&&_.jsxs("div",{children:[_.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["未暂存 (",L.length,")"]}),L.map(e=>_.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted-foreground/10",children:[_.jsx("button",{className:"flex-shrink-0 h-4 w-4 flex items-center justify-center rounded hover:bg-green-500/20 text-muted-foreground hover:text-green-400",title:"git add",onClick:()=>{D(e)},children:_.jsx($,{className:"h-2.5 w-2.5"})}),_.jsx("button",{className:"flex-1 text-left truncate text-yellow-400",onClick:()=>{R(e)},children:e})]},e))]}),T.length>0&&_.jsxs("div",{children:[_.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["未跟踪 (",T.length,")"]}),T.map(e=>_.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted-foreground/10",children:[_.jsx("button",{className:"flex-shrink-0 h-4 w-4 flex items-center justify-center rounded hover:bg-green-500/20 text-muted-foreground hover:text-green-400",title:"git add",onClick:()=>{D(e)},children:_.jsx($,{className:"h-2.5 w-2.5"})}),_.jsx("span",{className:"flex-1 truncate text-muted-foreground",children:e})]},e))]}),0===L.length&&0===P.length&&0===T.length&&_.jsx("p",{className:"text-muted-foreground/50 text-center py-4",children:"工作区干净"}),P.length>0&&_.jsxs("div",{className:"space-y-1.5 pt-1 border-t border-border",children:[_.jsx(U,{placeholder:"提交消息…",value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||M()},className:"h-7 text-xs"}),_.jsx(H,{size:"sm",className:"w-full h-7 text-xs",onClick:()=>{M()},disabled:!c.trim()||u,children:u?"提交中…":`提交 (${P.length} 文件)`})]}),(null==t?void 0:t.isRepo)&&_.jsxs("div",{className:"border-t border-border pt-2",children:[_.jsxs("button",{className:"flex items-center gap-1 text-muted-foreground font-medium mb-1 w-full text-left",onClick:()=>y(e=>!e),children:[_.jsx(Ht,{className:p("h-3 w-3 transition-transform",!w&&"-rotate-90")}),_.jsx(Gt,{className:"h-3 w-3"}),_.jsxs("span",{children:["提交历史 (",S,")"]})]}),w&&_.jsxs("div",{className:"space-y-0.5",children:[g.map((e,t)=>{const i=e.parents.length>1;return _.jsxs("div",{className:"flex gap-1.5 items-start group",children:[_.jsxs("div",{className:"flex flex-col items-center flex-shrink-0 w-3",children:[_.jsx("div",{className:p("w-2 h-2 rounded-full flex-shrink-0 mt-1",0===t?"bg-blue-400":i?"bg-purple-400":"bg-muted-foreground/40")}),t<g.length-1&&_.jsx("div",{className:"w-px flex-1 bg-border min-h-[12px]"})]}),_.jsxs("div",{className:"flex-1 min-w-0 pb-1",children:[_.jsxs("div",{className:"flex items-baseline gap-1",children:[_.jsx("span",{className:"font-mono text-muted-foreground/60 text-[10px] flex-shrink-0",children:e.hashShort}),_.jsx("span",{className:"truncate leading-tight",children:e.message.split("\n")[0]})]}),_.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground/50 mt-0.5",children:[_.jsx("span",{children:e.author}),_.jsx("span",{children:Si(e.date)}),e.branches.length>0&&e.branches.slice(0,2).map(e=>_.jsx("span",{className:"px-1 py-px rounded bg-blue-500/10 text-blue-400 text-[9px]",children:e.replace("remotes/origin/","↑")},e))]})]})]},e.hash)}),g.length<S&&_.jsx("button",{className:"w-full text-center text-[10px] text-muted-foreground hover:text-foreground py-1",onClick:()=>{E(!0)},disabled:x,children:x?"加载中...":`加载更多 (${g.length}/${S})`})]})]}),null!==n&&_.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>o(null),children:[_.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),_.jsxs("div",{className:"relative z-10 w-[700px] max-w-[95vw] max-h-[80vh] flex flex-col bg-background border border-border rounded-lg shadow-2xl",onClick:e=>e.stopPropagation(),children:[_.jsxs("div",{className:"flex items-center justify-between px-4 h-10 border-b border-border text-sm font-medium flex-shrink-0",children:[_.jsx("span",{className:"truncate text-muted-foreground",children:a}),_.jsx("button",{className:"text-muted-foreground hover:text-foreground",onClick:()=>o(null),children:"✕"})]}),_.jsx("pre",{className:"flex-1 overflow-auto p-3 text-[11px] font-mono whitespace-pre leading-relaxed",children:n.split("\n").map((e,t)=>_.jsx("span",{className:p("block",e.startsWith("+")&&!e.startsWith("+++")&&"text-green-400 bg-green-400/5",e.startsWith("-")&&!e.startsWith("---")&&"text-red-400 bg-red-400/5",e.startsWith("@@")&&"text-blue-400"),children:e},t))})]})]})]})}function wi({projectPath:e,projectId:t}){const[i,s]=Y(x.leftPanelTab,"files"),r="git"===i?"git":"files";return _.jsxs(kt,{value:r,onValueChange:e=>s(e),orientation:"vertical",className:"h-full flex bg-muted text-foreground overflow-hidden",children:[_.jsxs(Et,{className:p("flex flex-col items-center justify-start shrink-0","h-full w-9 border-r border-border rounded-none p-1 gap-1"),children:[_.jsx(Rt,{value:"files",title:"Files","aria-label":"Files",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:_.jsx(P,{className:"h-3.5 w-3.5"})}),_.jsx(Rt,{value:"git",title:"Git","aria-label":"Git",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:_.jsx(Xt,{className:"h-3.5 w-3.5"})})]}),_.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-l border-border",children:[_.jsx(Dt,{value:"files",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:_.jsx(vi,{projectPath:e,projectId:t})}),_.jsx(Dt,{value:"git",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:_.jsx(bi,{projectId:t})})]})]})}function yi(e){const t=xi(e),i=l.forwardRef((e,i)=>{const{children:s,...r}=e,n=l.Children.toArray(s),o=n.find(ki);if(o){const e=o.props.children,s=n.map(t=>t===o?l.Children.count(e)>1?l.Children.only(null):l.isValidElement(e)?e.props.children:null:t);return _.jsx(t,{...r,ref:i,children:l.isValidElement(e)?l.cloneElement(e,void 0,s):null})}return _.jsx(t,{...r,ref:i,children:s})});return i.displayName=`${e}.Slot`,i}function xi(e){const t=l.forwardRef((e,t)=>{const{children:i,...s}=e;if(l.isValidElement(i)){const e=function(e){var t,i;let s=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,r=s&&"isReactWarning"in s&&s.isReactWarning;if(r)return e.ref;if(s=null==(i=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:i.get,r=s&&"isReactWarning"in s&&s.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(i),r=function(e,t){const i={...t};for(const s in t){const r=e[s],n=t[s];/^on[A-Z]/.test(s)?r&&n?i[s]=(...e)=>{const t=n(...e);return r(...e),t}:r&&(i[s]=r):"style"===s?i[s]={...r,...n}:"className"===s&&(i[s]=[r,n].filter(Boolean).join(" "))}return{...e,...i}}(s,i.props);return i.type!==l.Fragment&&(r.ref=t?X(t,e):e),l.cloneElement(i,r)}return l.Children.count(i)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ci=Symbol("radix.slottable");function ki(e){return l.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===Ci}var Ei=["Enter"," "],Ri=["ArrowUp","PageDown","End"],Di=["ArrowDown","PageUp","Home",...Ri],Mi={ltr:[...Ei,"ArrowRight"],rtl:[...Ei,"ArrowLeft"]},Li={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ni="Menu",[Pi,Ti,Bi]=Bt(Ni),[ji,Ai]=J(Ni,[Bi,Pt,Tt]),Oi=Pt(),Ii=Tt(),[zi,Wi]=ji(Ni),[Hi,Fi]=ji(Ni),$i=e=>{const{__scopeMenu:t,open:i=!1,children:s,dir:r,onOpenChange:n,modal:o=!0}=e,a=Oi(t),[h,c]=l.useState(null),d=l.useRef(!1),u=G(n),f=Mt(r);return l.useEffect(()=>{const e=()=>{d.current=!0,document.addEventListener("pointerdown",t,{capture:!0,once:!0}),document.addEventListener("pointermove",t,{capture:!0,once:!0})},t=()=>d.current=!1;return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",t,{capture:!0}),document.removeEventListener("pointermove",t,{capture:!0})}},[]),_.jsx(Lt,{...a,children:_.jsx(zi,{scope:t,open:i,onOpenChange:u,content:h,onContentChange:c,children:_.jsx(Hi,{scope:t,onClose:l.useCallback(()=>u(!1),[u]),isUsingKeyboardRef:d,dir:f,modal:o,children:s})})})};$i.displayName=Ni;var Ui=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e,r=Oi(i);return _.jsx(Nt,{...r,...s,ref:t})});Ui.displayName="MenuAnchor";var Ki="MenuPortal",[qi,Vi]=ji(Ki,{forceMount:void 0}),Yi=e=>{const{__scopeMenu:t,forceMount:i,children:s,container:r}=e,n=Wi(Ki,t);return _.jsx(qi,{scope:t,forceMount:i,children:_.jsx(Z,{present:i||n.open,children:_.jsx(Q,{asChild:!0,container:r,children:s})})})};Yi.displayName=Ki;var Xi="MenuContent",[Gi,Ji]=ji(Xi),Zi=l.forwardRef((e,t)=>{const i=Vi(Xi,e.__scopeMenu),{forceMount:s=i.forceMount,...r}=e,n=Wi(Xi,e.__scopeMenu),o=Fi(Xi,e.__scopeMenu);return _.jsx(Pi.Provider,{scope:e.__scopeMenu,children:_.jsx(Z,{present:s||n.open,children:_.jsx(Pi.Slot,{scope:e.__scopeMenu,children:o.modal?_.jsx(Qi,{...r,ref:t}):_.jsx(es,{...r,ref:t})})})})}),Qi=l.forwardRef((e,t)=>{const i=Wi(Xi,e.__scopeMenu),s=l.useRef(null),r=ee(t,s);return l.useEffect(()=>{const e=s.current;if(e)return se(e)},[]),_.jsx(is,{...e,ref:r,trapFocus:i.open,disableOutsidePointerEvents:i.open,disableOutsideScroll:!0,onFocusOutside:te(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>i.onOpenChange(!1)})}),es=l.forwardRef((e,t)=>{const i=Wi(Xi,e.__scopeMenu);return _.jsx(is,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>i.onOpenChange(!1)})}),ts=yi("MenuContent.ScrollLock"),is=l.forwardRef((e,t)=>{const{__scopeMenu:i,loop:s=!1,trapFocus:r,onOpenAutoFocus:n,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:h,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...g}=e,v=Wi(Xi,i),S=Fi(Xi,i),b=Oi(i),w=Ii(i),y=Ti(i),[x,C]=l.useState(null),k=l.useRef(null),E=ee(t,k,v.onContentChange),R=l.useRef(0),D=l.useRef(""),M=l.useRef(0),L=l.useRef(null),N=l.useRef("right"),P=l.useRef(0),T=m?oe:l.Fragment,B=m?{as:ts,allowPinchZoom:!0}:void 0,j=e=>{var t,i;const s=D.current+e,r=y().filter(e=>!e.disabled),n=document.activeElement,o=null==(t=r.find(e=>e.ref.current===n))?void 0:t.textValue,a=function(e,t,i){const s=t.length>1&&Array.from(t).every(e=>e===t[0]),r=s?t[0]:t,n=i?e.indexOf(i):-1;let o=(a=e,l=Math.max(n,0),a.map((e,t)=>a[(l+t)%a.length]));var a,l;1===r.length&&(o=o.filter(e=>e!==i));const h=o.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return h!==i?h:void 0}(r.map(e=>e.textValue),s,o),l=null==(i=r.find(e=>e.textValue===a))?void 0:i.ref.current;!function e(t){D.current=t,window.clearTimeout(R.current),""!==t&&(R.current=window.setTimeout(()=>e(""),1e3))}(s),l&&setTimeout(()=>l.focus())};l.useEffect(()=>()=>window.clearTimeout(R.current),[]),ne();const A=l.useCallback(e=>{var t,i;return N.current===(null==(t=L.current)?void 0:t.side)&&function(e,t){if(!t)return!1;const i={x:e.clientX,y:e.clientY};return function(e,t){const{x:i,y:s}=e;let r=!1;for(let n=0,o=t.length-1;n<t.length;o=n++){const e=t[n],a=t[o],l=e.x,h=e.y,c=a.x,d=a.y;h>s!=d>s&&i<(c-l)*(s-h)/(d-h)+l&&(r=!r)}return r}(i,t)}(e,null==(i=L.current)?void 0:i.area)},[]);return _.jsx(Gi,{scope:i,searchRef:D,onItemEnter:l.useCallback(e=>{A(e)&&e.preventDefault()},[A]),onItemLeave:l.useCallback(e=>{var t;A(e)||(null==(t=k.current)||t.focus(),C(null))},[A]),onTriggerLeave:l.useCallback(e=>{A(e)&&e.preventDefault()},[A]),pointerGraceTimerRef:M,onPointerGraceIntentChange:l.useCallback(e=>{L.current=e},[]),children:_.jsx(T,{...B,children:_.jsx(ae,{asChild:!0,trapped:r,onMountAutoFocus:te(n,e=>{var t;e.preventDefault(),null==(t=k.current)||t.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:_.jsx(le,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:f,onDismiss:p,children:_.jsx(At,{asChild:!0,...w,dir:S.dir,orientation:"vertical",loop:s,currentTabStopId:x,onCurrentTabStopIdChange:C,onEntryFocus:te(h,e=>{S.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:_.jsx(Ot,{role:"menu","aria-orientation":"vertical","data-state":Ds(v.open),"data-radix-menu-content":"",dir:S.dir,...b,...g,ref:E,style:{outline:"none",...g.style},onKeyDown:te(g.onKeyDown,e=>{const t=e.target.closest("[data-radix-menu-content]")===e.currentTarget,i=e.ctrlKey||e.altKey||e.metaKey,s=1===e.key.length;t&&("Tab"===e.key&&e.preventDefault(),!i&&s&&j(e.key));const r=k.current;if(e.target!==r)return;if(!Di.includes(e.key))return;e.preventDefault();const n=y().filter(e=>!e.disabled).map(e=>e.ref.current);Ri.includes(e.key)&&n.reverse(),function(e){const t=document.activeElement;for(const i of e){if(i===t)return;if(i.focus(),document.activeElement!==t)return}}(n)}),onBlur:te(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(R.current),D.current="")}),onPointerMove:te(e.onPointerMove,Ns(e=>{const t=e.target,i=P.current!==e.clientX;if(e.currentTarget.contains(t)&&i){const t=e.clientX>P.current?"right":"left";N.current=t,P.current=e.clientX}}))})})})})})})});Zi.displayName=Xi;var ss=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e;return _.jsx(ie.div,{role:"group",...s,ref:t})});ss.displayName="MenuGroup";var rs=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e;return _.jsx(ie.div,{...s,ref:t})});rs.displayName="MenuLabel";var ns="MenuItem",os="menu.itemSelect",as=l.forwardRef((e,t)=>{const{disabled:i=!1,onSelect:s,...r}=e,n=l.useRef(null),o=Fi(ns,e.__scopeMenu),a=Ji(ns,e.__scopeMenu),h=ee(t,n),c=l.useRef(!1);return _.jsx(ls,{...r,ref:h,disabled:i,onClick:te(e.onClick,()=>{const e=n.current;if(!i&&e){const t=new CustomEvent(os,{bubbles:!0,cancelable:!0});e.addEventListener(os,e=>null==s?void 0:s(e),{once:!0}),re(e,t),t.defaultPrevented?c.current=!1:o.onClose()}}),onPointerDown:t=>{var i;null==(i=e.onPointerDown)||i.call(e,t),c.current=!0},onPointerUp:te(e.onPointerUp,e=>{var t;c.current||null==(t=e.currentTarget)||t.click()}),onKeyDown:te(e.onKeyDown,e=>{const t=""!==a.searchRef.current;i||t&&" "===e.key||Ei.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});as.displayName=ns;var ls=l.forwardRef((e,t)=>{const{__scopeMenu:i,disabled:s=!1,textValue:r,...n}=e,o=Ji(ns,i),a=Ii(i),h=l.useRef(null),c=ee(t,h),[d,u]=l.useState(!1),[f,p]=l.useState("");return l.useEffect(()=>{const e=h.current;e&&p((e.textContent??"").trim())},[n.children]),_.jsx(Pi.ItemSlot,{scope:i,disabled:s,textValue:r??f,children:_.jsx(jt,{asChild:!0,...a,focusable:!s,children:_.jsx(ie.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...n,ref:c,onPointerMove:te(e.onPointerMove,Ns(e=>{if(s)o.onItemLeave(e);else if(o.onItemEnter(e),!e.defaultPrevented){e.currentTarget.focus({preventScroll:!0})}})),onPointerLeave:te(e.onPointerLeave,Ns(e=>o.onItemLeave(e))),onFocus:te(e.onFocus,()=>u(!0)),onBlur:te(e.onBlur,()=>u(!1))})})})}),hs=l.forwardRef((e,t)=>{const{checked:i=!1,onCheckedChange:s,...r}=e;return _.jsx(gs,{scope:e.__scopeMenu,checked:i,children:_.jsx(as,{role:"menuitemcheckbox","aria-checked":Ms(i)?"mixed":i,...r,ref:t,"data-state":Ls(i),onSelect:te(r.onSelect,()=>null==s?void 0:s(!!Ms(i)||!i),{checkForDefaultPrevented:!1})})})});hs.displayName="MenuCheckboxItem";var cs="MenuRadioGroup",[ds,us]=ji(cs,{value:void 0,onValueChange:()=>{}}),fs=l.forwardRef((e,t)=>{const{value:i,onValueChange:s,...r}=e,n=G(s);return _.jsx(ds,{scope:e.__scopeMenu,value:i,onValueChange:n,children:_.jsx(ss,{...r,ref:t})})});fs.displayName=cs;var _s="MenuRadioItem",ps=l.forwardRef((e,t)=>{const{value:i,...s}=e,r=us(_s,e.__scopeMenu),n=i===r.value;return _.jsx(gs,{scope:e.__scopeMenu,checked:n,children:_.jsx(as,{role:"menuitemradio","aria-checked":n,...s,ref:t,"data-state":Ls(n),onSelect:te(s.onSelect,()=>{var e;return null==(e=r.onValueChange)?void 0:e.call(r,i)},{checkForDefaultPrevented:!1})})})});ps.displayName=_s;var ms="MenuItemIndicator",[gs,vs]=ji(ms,{checked:!1}),Ss=l.forwardRef((e,t)=>{const{__scopeMenu:i,forceMount:s,...r}=e,n=vs(ms,i);return _.jsx(Z,{present:s||Ms(n.checked)||!0===n.checked,children:_.jsx(ie.span,{...r,ref:t,"data-state":Ls(n.checked)})})});Ss.displayName=ms;var bs=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e;return _.jsx(ie.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});bs.displayName="MenuSeparator";var ws=l.forwardRef((e,t)=>{const{__scopeMenu:i,...s}=e,r=Oi(i);return _.jsx(It,{...r,...s,ref:t})});ws.displayName="MenuArrow";var[ys,xs]=ji("MenuSub"),Cs="MenuSubTrigger",ks=l.forwardRef((e,t)=>{const i=Wi(Cs,e.__scopeMenu),s=Fi(Cs,e.__scopeMenu),r=xs(Cs,e.__scopeMenu),n=Ji(Cs,e.__scopeMenu),o=l.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:h}=n,c={__scopeMenu:e.__scopeMenu},d=l.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return l.useEffect(()=>d,[d]),l.useEffect(()=>{const e=a.current;return()=>{window.clearTimeout(e),h(null)}},[a,h]),_.jsx(Ui,{asChild:!0,...c,children:_.jsx(ls,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":r.contentId,"data-state":Ds(i.open),...e,ref:X(t,r.onTriggerChange),onClick:t=>{var s;null==(s=e.onClick)||s.call(e,t),e.disabled||t.defaultPrevented||(t.currentTarget.focus(),i.open||i.onOpenChange(!0))},onPointerMove:te(e.onPointerMove,Ns(t=>{n.onItemEnter(t),t.defaultPrevented||e.disabled||i.open||o.current||(n.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{i.onOpenChange(!0),d()},100))})),onPointerLeave:te(e.onPointerLeave,Ns(e=>{var t,s;d();const r=null==(t=i.content)?void 0:t.getBoundingClientRect();if(r){const t=null==(s=i.content)?void 0:s.dataset.side,o="right"===t,l=o?-5:5,h=r[o?"left":"right"],c=r[o?"right":"left"];n.onPointerGraceIntentChange({area:[{x:e.clientX+l,y:e.clientY},{x:h,y:r.top},{x:c,y:r.top},{x:c,y:r.bottom},{x:h,y:r.bottom}],side:t}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>n.onPointerGraceIntentChange(null),300)}else{if(n.onTriggerLeave(e),e.defaultPrevented)return;n.onPointerGraceIntentChange(null)}})),onKeyDown:te(e.onKeyDown,t=>{var r;const o=""!==n.searchRef.current;e.disabled||o&&" "===t.key||Mi[s.dir].includes(t.key)&&(i.onOpenChange(!0),null==(r=i.content)||r.focus(),t.preventDefault())})})})});ks.displayName=Cs;var Es="MenuSubContent",Rs=l.forwardRef((e,t)=>{const i=Vi(Xi,e.__scopeMenu),{forceMount:s=i.forceMount,...r}=e,n=Wi(Xi,e.__scopeMenu),o=Fi(Xi,e.__scopeMenu),a=xs(Es,e.__scopeMenu),h=l.useRef(null),c=ee(t,h);return _.jsx(Pi.Provider,{scope:e.__scopeMenu,children:_.jsx(Z,{present:s||n.open,children:_.jsx(Pi.Slot,{scope:e.__scopeMenu,children:_.jsx(is,{id:a.contentId,"aria-labelledby":a.triggerId,...r,ref:c,align:"start",side:"rtl"===o.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{var t;o.isUsingKeyboardRef.current&&(null==(t=h.current)||t.focus()),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:te(e.onFocusOutside,e=>{e.target!==a.trigger&&n.onOpenChange(!1)}),onEscapeKeyDown:te(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:te(e.onKeyDown,e=>{var t;const i=e.currentTarget.contains(e.target),s=Li[o.dir].includes(e.key);i&&s&&(n.onOpenChange(!1),null==(t=a.trigger)||t.focus(),e.preventDefault())})})})})})});function Ds(e){return e?"open":"closed"}function Ms(e){return"indeterminate"===e}function Ls(e){return Ms(e)?"indeterminate":e?"checked":"unchecked"}function Ns(e){return t=>"mouse"===t.pointerType?e(t):void 0}Rs.displayName=Es;var Ps=$i,Ts=Ui,Bs=Yi,js=Zi,As=ss,Os=rs,Is=as,zs=hs,Ws=fs,Hs=ps,Fs=Ss,$s=bs,Us=ws,Ks=ks,qs=Rs,Vs="ContextMenu",[Ys]=J(Vs,[Ai]),Xs=Ai(),[Gs,Js]=Ys(Vs),Zs=e=>{const{__scopeContextMenu:t,children:i,onOpenChange:s,dir:r,modal:n=!0}=e,[o,a]=l.useState(!1),h=Xs(t),c=G(s),d=l.useCallback(e=>{a(e),c(e)},[c]);return _.jsx(Gs,{scope:t,open:o,onOpenChange:d,modal:n,children:_.jsx(Ps,{...h,dir:r,open:o,onOpenChange:d,modal:n,children:i})})};Zs.displayName=Vs;var Qs="ContextMenuTrigger",er=l.forwardRef((e,t)=>{const{__scopeContextMenu:i,disabled:s=!1,...r}=e,n=Js(Qs,i),o=Xs(i),a=l.useRef({x:0,y:0}),h=l.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),c=l.useRef(0),d=l.useCallback(()=>window.clearTimeout(c.current),[]),u=e=>{a.current={x:e.clientX,y:e.clientY},n.onOpenChange(!0)};return l.useEffect(()=>d,[d]),l.useEffect(()=>{s&&d()},[s,d]),_.jsxs(_.Fragment,{children:[_.jsx(Ts,{...o,virtualRef:h}),_.jsx(ie.span,{"data-state":n.open?"open":"closed","data-disabled":s?"":void 0,...r,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:s?e.onContextMenu:te(e.onContextMenu,e=>{d(),u(e),e.preventDefault()}),onPointerDown:s?e.onPointerDown:te(e.onPointerDown,or(e=>{d(),c.current=window.setTimeout(()=>u(e),700)})),onPointerMove:s?e.onPointerMove:te(e.onPointerMove,or(d)),onPointerCancel:s?e.onPointerCancel:te(e.onPointerCancel,or(d)),onPointerUp:s?e.onPointerUp:te(e.onPointerUp,or(d))})]})});er.displayName=Qs;var tr=e=>{const{__scopeContextMenu:t,...i}=e,s=Xs(t);return _.jsx(Bs,{...s,...i})};tr.displayName="ContextMenuPortal";var ir="ContextMenuContent",sr=l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Js(ir,i),n=Xs(i),o=l.useRef(!1);return _.jsx(js,{...n,...s,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:t=>{var i;null==(i=e.onCloseAutoFocus)||i.call(e,t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{var i;null==(i=e.onInteractOutside)||i.call(e,t),t.defaultPrevented||r.modal||(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});sr.displayName=ir;l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(As,{...r,...s,ref:t})}).displayName="ContextMenuGroup";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(Os,{...r,...s,ref:t})}).displayName="ContextMenuLabel";var rr=l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(Is,{...r,...s,ref:t})});rr.displayName="ContextMenuItem";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(zs,{...r,...s,ref:t})}).displayName="ContextMenuCheckboxItem";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(Ws,{...r,...s,ref:t})}).displayName="ContextMenuRadioGroup";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(Hs,{...r,...s,ref:t})}).displayName="ContextMenuRadioItem";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(Fs,{...r,...s,ref:t})}).displayName="ContextMenuItemIndicator";var nr=l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx($s,{...r,...s,ref:t})});nr.displayName="ContextMenuSeparator";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(Us,{...r,...s,ref:t})}).displayName="ContextMenuArrow";l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(Ks,{...r,...s,ref:t})}).displayName="ContextMenuSubTrigger";function or(e){return t=>"mouse"!==t.pointerType?e(t):void 0}l.forwardRef((e,t)=>{const{__scopeContextMenu:i,...s}=e,r=Xs(i);return _.jsx(qs,{...r,...s,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})}).displayName="ContextMenuSubContent";var ar=tr,lr=sr,hr=rr,cr=nr;const dr=Zs,ur=er,fr=l.forwardRef(({className:e,...t},i)=>_.jsx(ar,{children:_.jsx(lr,{ref:i,className:p("z-50 min-w-[10rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",e),...t})}));fr.displayName=lr.displayName;const _r=l.forwardRef(({className:e,destructive:t,...i},s)=>_.jsx(hr,{ref:s,className:p("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-accent focus:text-accent-foreground","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"text-red-500 focus:text-red-500 focus:bg-red-500/10",e),...i}));_r.displayName=hr.displayName;const pr=l.forwardRef(({className:e,...t},i)=>_.jsx(cr,{ref:i,className:p("-mx-1 my-1 h-px bg-border",e),...t}));function mr({kind:e,label:t,preview:i,inserted:s,unclicked:r,onLeftClick:n,onEdit:o,onDelete:a,onShare:h,onRefresh:c,footer:d,readOnly:u,noContextMenu:f}){const m=l.useRef(null),v=p("agent-prompt"===e?s?"border-green-500/50 bg-green-500/10 hover:bg-green-500/15":"border-dashed border-border hover:border-border/80 hover:bg-muted-foreground/10 dark:hover:bg-muted-foreground/20":r?"border-blue-500/30 bg-blue-500/15 hover:bg-blue-500/20 dark:bg-blue-500/15 dark:hover:bg-blue-500/25":"border-transparent bg-background dark:bg-muted-foreground/10 hover:bg-muted-foreground/10 dark:hover:bg-muted-foreground/20 hover:border-muted-foreground/30"),S="agent-prompt"===e,b=!f||c?" · 右键更多":"",w="quick-prompt"===e?`点击发送${b}`:(s?"点击从 CLAUDE.md 移除":"点击插入 CLAUDE.md")+b,y=_.jsxs("div",{ref:m,className:p("group relative rounded-md border text-xs transition-colors cursor-pointer select-none",v),onClick:n,title:w,children:[S&&_.jsx("span",{"aria-hidden":!0,className:p("absolute top-1.5 left-1.5 h-2 w-2 rounded-full transition-colors",s?"bg-green-500 ring-1 ring-green-500/40":"border border-muted-foreground/40 bg-transparent")}),_.jsxs("div",{className:p("py-1.5",f?"pr-2":"pr-7",S?"pl-5":"pl-3"),children:[_.jsx("div",{className:"font-medium truncate",children:t}),i&&i!==t&&_.jsx("div",{className:"mt-0.5 text-muted-foreground/80 truncate font-mono",children:i}),d]}),!f&&_.jsx("button",{onClick:e=>{e.stopPropagation(),e.preventDefault();const t=m.current;if(!t)return;const i=t.getBoundingClientRect(),s=new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:i.right-8,clientY:i.top+i.height/2,button:2});t.dispatchEvent(s)},className:p("absolute top-1 right-1 p-0.5 rounded transition-opacity","md:opacity-0 md:group-hover:opacity-100 md:focus-visible:opacity-100","hover:bg-muted-foreground/10 focus-visible:bg-muted-foreground/10","text-muted-foreground hover:text-foreground"),title:"更多","aria-label":"更多操作",children:_.jsx(Qt,{className:"h-3.5 w-3.5"})})]});return!(!c&&(f||!o&&!a&&!h))?_.jsxs(dr,{children:[_.jsx(ur,{asChild:!0,children:y}),_.jsxs(fr,{children:[c&&_.jsxs(_r,{onSelect:c,children:[_.jsx(N,{className:"h-3.5 w-3.5"}),"更新"]}),!f&&!u&&o&&a&&_.jsxs(_.Fragment,{children:[c&&_.jsx(pr,{}),_.jsxs(_r,{onSelect:o,children:[_.jsx(g,{className:"h-3.5 w-3.5"}),"编辑"]}),_.jsxs(_r,{destructive:!0,onSelect:a,children:[_.jsx(L,{className:"h-3.5 w-3.5"}),"删除"]}),h&&_.jsx(pr,{})]}),!f&&h&&_.jsxs(_r,{onSelect:h,children:[_.jsx(he,{className:"h-3.5 w-3.5"}),"共享到 ccweb-hub"]})]})]}):_.jsx("div",{onContextMenu:e=>e.preventDefault(),children:y})}function gr({open:e,onOpenChange:t,initialLabel:i,initialCommand:s,title:r,onSave:n}){const[o,a]=l.useState(i),[h,c]=l.useState(s),[d,u]=l.useState(!0);l.useEffect(()=>{e&&u(!0)},[e]),l.useEffect(()=>{e&&(a(i),c(s))},[e,i,s]);const f=()=>{const e=h.trim();e&&(n(o.trim()||e,e),t(!1))};return _.jsx(me,{open:e,onOpenChange:t,modal:!1,children:_.jsxs(ge,{noOverlay:!0,className:p("sm:max-w-2xl max-h-[85vh] flex flex-col transition-opacity",!d&&"opacity-50"),onInteractOutside:e=>{e.preventDefault(),u(!1)},onClick:()=>u(!0),children:[_.jsxs(ve,{children:[_.jsx(Se,{children:r}),_.jsx(be,{children:"左键点击卡片会把此命令发送到 CLI。"})]}),_.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col",children:[_.jsxs("div",{className:"space-y-2",children:[_.jsx(we,{htmlFor:"qp-label",children:"标签"}),_.jsx(U,{id:"qp-label",placeholder:"显示名(可选,默认用命令文本)",value:o,onChange:e=>a(e.target.value),className:"text-base",autoFocus:!0})]}),_.jsxs("div",{className:"space-y-2 flex-1 flex flex-col min-h-0",children:[_.jsx(we,{htmlFor:"qp-command",children:"命令"}),_.jsx("textarea",{id:"qp-command",placeholder:"输入要发送的命令...",value:h,onChange:e=>c(e.target.value),className:p("flex-1 min-h-[200px] w-full rounded-md border border-input bg-background px-4 py-3","text-base leading-relaxed font-mono","ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","resize-none"),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),f())}})]})]}),_.jsxs(ye,{className:"flex items-center justify-between sm:justify-between",children:[_.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ 保存"}),_.jsxs("div",{className:"flex gap-2",children:[_.jsx(H,{variant:"outline",onClick:()=>t(!1),children:"取消"}),_.jsx(H,{onClick:f,disabled:!h.trim(),children:"保存"})]})]})]})})}function vr({title:e,count:t,onAdd:i,children:s}){return _.jsxs("div",{className:"px-2 py-2",children:[_.jsxs("div",{className:"flex items-center justify-between mb-1.5 px-1",children:[_.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground uppercase tracking-wider",children:[_.jsx("span",{children:e}),_.jsxs("span",{className:"text-muted-foreground/60 normal-case tracking-normal",children:["(",t,")"]})]}),_.jsx("button",{onClick:i,className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted-foreground/10 transition-colors",title:"新建","aria-label":"新建",children:_.jsx($,{className:"h-3 w-3"})})]}),s]})}function Sr({projectId:e,onSend:t}){const i=a(),[s,r]=l.useState([]),[n,o]=l.useState([]),h=R(),c=h.get(e),[d,u]=l.useState({open:!1}),[f,p]=l.useState(c.shareHubOpen),[m,g]=l.useState(c.shareHubLabel),[v,S]=l.useState(c.shareHubCommand),b=x.usedShortcuts(e),[w,y]=l.useState(()=>{try{const e=localStorage.getItem(b);if(!e)return new Set;const t=JSON.parse(e);return new Set(Array.isArray(t)?t:[])}catch{return new Set}}),C=l.useCallback(e=>{y(t=>{if(t.has(e))return t;const i=new Set(t);i.add(e);try{localStorage.setItem(b,JSON.stringify([...i]))}catch{}return i})},[b]);l.useEffect(()=>{ce(e).then(r).catch(()=>r([]))},[e]),l.useEffect(()=>{de().then(o).catch(()=>o([]))},[]);const k=l.useCallback(e=>{const t=[],i=new Set;let s=e;const r=[];for(;s&&!i.has(s.id);)i.add(s.id),r.unshift(s),s=s.parentId?n.find(e=>e.id===s.parentId):void 0;for(const n of r)t.push(n.command);return t},[n]),E=l.useCallback(e=>{k(e).forEach((e,i)=>{setTimeout(()=>t(e+"\r"),500*i)})},[k,t]),D=e=>u({open:!0,mode:"create",scope:e}),M=(t,i)=>{g(t),S(i),p(!0),h.setShareHub(e,!0,t,i)};return _.jsxs("div",{className:"h-full flex flex-col text-foreground overflow-hidden",children:[_.jsxs("div",{className:"px-3 pt-2.5 pb-2 border-b border-border/50 shrink-0",children:[_.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Quick Prompts"}),_.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70 leading-snug",children:"点击卡片发送命令到 CLI;新建的命令在首次点击前以浅蓝色标识"})]}),_.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0",children:[_.jsx(vr,{title:"项目",count:s.length,onAdd:()=>D("project"),children:0===s.length?_.jsx("div",{className:"px-1 py-3 text-xs text-muted-foreground/60",children:"暂无项目命令"}):_.jsx("div",{className:"space-y-1.5",children:s.map(s=>_.jsx(mr,{kind:"quick-prompt",label:s.label,preview:s.label!==s.command?s.command:"",unclicked:!w.has(s.id),onLeftClick:()=>(e=>{t(e.command+"\r"),C(e.id)})(s),onEdit:()=>(e=>u({open:!0,mode:"edit",scope:"project",id:e.id,label:e.label,command:e.command}))(s),onDelete:()=>{(async t=>{if(await i({title:"删除项目快捷 Prompt",description:`确认删除「${t.label}」?此操作不可撤销。`,destructive:!0,confirmLabel:"删除"}))try{await _e(e,t.id),r(e=>e.filter(e=>e.id!==t.id)),y(e=>{if(!e.has(t.id))return e;const i=new Set(e);i.delete(t.id);try{localStorage.setItem(b,JSON.stringify([...i]))}catch{}return i})}catch(s){console.error("Failed to delete shortcut:",s)}})(s)},onShare:()=>M(s.label,s.command)},s.id))})}),_.jsx("div",{className:"h-px bg-border mx-2"}),_.jsx(vr,{title:"全局",count:n.length,onAdd:()=>D("global"),children:0===n.length?_.jsx("div",{className:"px-1 py-3 text-xs text-muted-foreground/60",children:"暂无全局命令"}):_.jsx("div",{className:"space-y-1.5",children:n.map(e=>{var t;const s=e.parentId?null==(t=n.find(t=>t.id===e.parentId))?void 0:t.label:void 0;return _.jsx(mr,{kind:"quick-prompt",label:e.label,preview:s?"":e.label!==e.command?e.command:"",onLeftClick:()=>E(e),onEdit:()=>(e=>u({open:!0,mode:"edit",scope:"global",id:e.id,label:e.label,command:e.command}))(e),onDelete:()=>{(async e=>{const t=n.filter(t=>t.parentId===e.id);if(await i({title:"删除全局快捷 Prompt",description:t.length>0?`「${e.label}」被 ${t.length} 个其他全局命令继承。删除后这些命令的继承会断链。确认删除?`:`确认删除「${e.label}」?此操作不可撤销。`,destructive:!0,confirmLabel:"删除"}))try{await pe(e.id),o(t=>t.filter(t=>t.id!==e.id))}catch(s){console.error("Failed to delete global shortcut:",s)}})(e)},onShare:()=>M(e.label,e.command),footer:s?_.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[_.jsx(ue,{className:"h-2.5 w-2.5 text-muted-foreground"}),_.jsxs("span",{className:"text-muted-foreground truncate",children:["继承: ",s,"(继承链仅可在 Dashboard 编辑)"]})]}):null},e.id)})})})]}),_.jsx(gr,{open:d.open,onOpenChange:e=>{e||u({open:!1})},initialLabel:d.open&&"edit"===d.mode?d.label:"",initialCommand:d.open&&"edit"===d.mode?d.command:"",title:d.open?"create"===d.mode?`新建${"global"===d.scope?"全局":"项目"}命令`:"编辑命令":"",onSave:(t,i)=>{(async(t,i)=>{if(d.open)try{if("create"===d.mode)if("global"===d.scope){const e=await xe({label:t,command:i});o(t=>[...t,e])}else{const s=await Ce(e,{label:t,command:i});r(e=>[...e,s])}else if("global"===d.scope){const e=n.find(e=>e.id===d.id),s=await ke(d.id,{label:t,command:i,parentId:(null==e?void 0:e.parentId)??null});o(e=>e.map(e=>e.id===s.id?s:e))}else{const s=await Ee(e,d.id,{label:t,command:i});r(e=>e.map(e=>e.id===s.id?s:e))}}catch(s){console.error("Failed to save shortcut:",s)}})(t,i)}}),_.jsx(fe,{open:f,onOpenChange:t=>{p(t),t||h.setShareHub(e,!1)},kind:"quick-prompt",label:m,content:v})]})}pr.displayName=cr.displayName;function br({open:e,onOpenChange:t,title:i,initialLabel:s,initialCommand:r,onSave:n}){const[o,a]=l.useState(s),[h,c]=l.useState(r),[d,u]=l.useState(!0);l.useEffect(()=>{e&&(a(s),c(r),u(!0))},[e,s,r]);const f=o.trim(),m=h.trim(),g=f.length>100,v=m.length>8e3,S=m.length>0&&f.length>0&&!g&&!v,b=()=>{S&&(n(f,h),t(!1))};return _.jsx(me,{open:e,onOpenChange:t,modal:!1,children:_.jsxs(ge,{noOverlay:!0,className:p("sm:max-w-2xl max-h-[85vh] flex flex-col transition-opacity",!d&&"opacity-50"),onInteractOutside:e=>{e.preventDefault(),u(!1)},onClick:()=>u(!0),children:[_.jsxs(ve,{children:[_.jsx(Se,{children:i}),_.jsx(be,{children:"This prompt can be clicked once in the sidebar to insert into CLAUDE.md, and clicked again to remove (by exact text match)."})]}),_.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col",children:[_.jsxs("div",{className:"space-y-2",children:[_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx(we,{htmlFor:"prompt-label",children:"Label"}),_.jsxs("span",{className:p("text-xs text-muted-foreground",g&&"text-red-500"),children:[f.length," / ",100]})]}),_.jsx(U,{id:"prompt-label",placeholder:"A short name for this prompt",value:o,onChange:e=>a(e.target.value),className:"text-base",autoFocus:!0})]}),_.jsxs("div",{className:"space-y-2 flex-1 flex flex-col min-h-0",children:[_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx(we,{htmlFor:"prompt-command",children:"Prompt"}),_.jsxs("span",{className:p("text-xs text-muted-foreground",v&&"text-red-500"),children:[m.length," / ",8e3]})]}),_.jsx("textarea",{id:"prompt-command",placeholder:"The exact text that will be appended to CLAUDE.md...",value:h,onChange:e=>c(e.target.value),className:p("flex-1 min-h-[200px] w-full rounded-md border border-input bg-background px-4 py-3","text-sm leading-relaxed font-mono","ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","resize-none"),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),b())}})]})]}),_.jsxs(ye,{className:"flex items-center justify-between sm:justify-between",children:[_.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ to save"}),_.jsxs("div",{className:"flex gap-2",children:[_.jsx(H,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),_.jsx(H,{onClick:b,disabled:!S,children:"Save"})]})]})]})})}function wr({projectId:e}){const t=a(),[i,s]=l.useState([]),[r,n]=l.useState([]),[o,h]=l.useState(!0),[c,d]=l.useState({open:!1}),[u,p]=l.useState({open:!1,label:"",content:""}),m=l.useCallback(async()=>{try{const t=await Re(e);s(t.global),n(t.project)}catch(t){f.error(`加载提示词失败: ${t.message}`)}finally{h(!1)}},[e]);l.useEffect(()=>{h(!0),m()},[m]);const g=l.useRef(new Set),v=l.useCallback(async(t,i)=>{if(g.current.has(i.id))return;g.current.add(i.id);const r=i.inserted?"remove":"insert",o=e=>e.map(e=>e.id===i.id?{...e,inserted:!e.inserted}:e);"global"===t?s(o):n(o);try{const t=await De(e,i.command,r);if("remove"===r&&!1===t.changed)return"not-found"===t.reason?f.error("CLAUDE.md 中找不到该提示词的精确文本,请自行编辑 CLAUDE.md 移除。"):f.warning("该提示词当前不在 CLAUDE.md 中(可能被手动编辑过),已重新同步状态。"),void m();m()}catch(a){f.error(`操作失败: ${a.message}`),"global"===t?s(o):n(o)}finally{g.current.delete(i.id)}},[e,m]),S=l.useCallback(async(t,i,s,r,n)=>{try{if("create"===t)"global"===i?await Me({label:r,command:n}):await Le(e,{label:r,command:n}),f.success("已添加");else{if(!s)return;"global"===i?await Ne(s,{label:r,command:n}):await Pe(e,s,{label:r,command:n}),f.success("已更新")}m()}catch(o){f.error(`保存失败: ${o.message}`)}},[e,m]),b=l.useCallback(async(i,s)=>{const r=s.inserted?'此提示词目前已插入当前项目的 CLAUDE.md。\n\n删除后它会在 CLAUDE.md 中成为"孤儿文本"——仅删除提示词记录,不会自动从 CLAUDE.md 移除。\n\n确认删除?':"确认删除此提示词?此操作不可撤销。";if(await t({title:"删除提示词",description:r,destructive:!0,confirmLabel:"删除"}))try{"global"===i?await Te(s.id):await Be(e,s.id),f.success("已删除"),m()}catch(n){f.error(`删除失败: ${n.message}`)}},[e,m,t]),w=l.useCallback(e=>{p({open:!0,label:e.label,content:e.command})},[]);return _.jsxs("div",{className:"flex flex-col h-full overflow-y-auto",children:[_.jsxs("div",{className:"px-3 pt-2.5 pb-2 border-b border-border/50 shrink-0",children:[_.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Agent Prompts"}),_.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70 leading-snug",children:"点击卡片插入 / 移出当前项目的 CLAUDE.md;左上角绿点表示已插入"})]}),_.jsx(yr,{title:"项目",count:r.length,loading:o,prompts:r,emptyText:"暂无项目提示词",onAdd:()=>d({open:!0,mode:"create",scope:"project"}),onToggle:e=>{v("project",e)},onEdit:e=>d({open:!0,mode:"edit",scope:"project",id:e.id,label:e.label,command:e.command}),onDelete:e=>{b("project",e)},onShare:w}),_.jsx("div",{className:"h-px bg-border mx-2"}),_.jsx(yr,{title:"全局",count:i.length,loading:o,prompts:i,emptyText:"暂无全局提示词",onAdd:()=>d({open:!0,mode:"create",scope:"global"}),onToggle:e=>{v("global",e)},onEdit:e=>d({open:!0,mode:"edit",scope:"global",id:e.id,label:e.label,command:e.command}),onDelete:e=>{b("global",e)},onShare:w}),_.jsx(br,{open:c.open,onOpenChange:e=>{e||d({open:!1})},title:!1===c.open?"":"create"===c.mode?`新建${"global"===c.scope?"全局":"项目"}提示词`:`编辑${"global"===c.scope?"全局":"项目"}提示词`,initialLabel:c.open&&"edit"===c.mode?c.label:"",initialCommand:c.open&&"edit"===c.mode?c.command:"",onSave:(e,t)=>{if(!c.open)return;const i="edit"===c.mode?c.id:null;S(c.mode,c.scope,i,e,t)}}),_.jsx(fe,{open:u.open,onOpenChange:e=>p(t=>({...t,open:e})),kind:"agent-prompt",label:u.label,content:u.content})]})}function yr({title:e,count:t,loading:i,prompts:s,emptyText:r,onAdd:n,onToggle:o,onEdit:a,onDelete:l,onShare:h}){return _.jsxs("div",{className:"px-2 py-2",children:[_.jsxs("div",{className:"flex items-center justify-between mb-1.5 px-1",children:[_.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground uppercase tracking-wider",children:[_.jsx("span",{children:e}),_.jsxs("span",{className:"text-muted-foreground/60 normal-case tracking-normal",children:["(",t,")"]})]}),_.jsx("button",{onClick:n,className:"p-0.5 rounded text-muted-foreground hover:text-foreground hover:bg-muted-foreground/10 transition-colors",title:"新建","aria-label":"新建",children:_.jsx($,{className:"h-3 w-3"})})]}),i?_.jsx("div",{className:"px-1 py-3 text-xs text-muted-foreground/60",children:"加载中…"}):0===s.length?_.jsx("div",{className:"px-1 py-3 text-xs text-muted-foreground/60",children:r}):_.jsx("div",{className:"space-y-1.5",children:s.map(e=>{const t=e.command.split("\n").find(e=>e.trim())??e.command.trim();return _.jsx(mr,{kind:"agent-prompt",label:e.label,preview:t,inserted:e.inserted,onLeftClick:()=>o(e),onEdit:()=>a(e),onDelete:()=>l(e),onShare:()=>h(e)},e.id)})})]})}function xr({projectId:e}){const[t,i]=l.useState([]),[s,r]=l.useState(!0),n=l.useRef(new Set),o=l.useCallback(async()=>{r(!0);try{const t=await je(e);i(t)}catch(t){f.error(`加载失败: ${t.message}`)}finally{r(!1)}},[e]);l.useEffect(()=>{o()},[o]);const a=l.useCallback(async t=>{if(n.current.has(t.filename))return;n.current.add(t.filename),i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:!e.inserted}:e));const s=t.inserted?"remove":"insert";try{const r=await Ae(e,t.filename,s);if(!r.ok)return f.error("操作失败"+(r.reason?`(${r.reason})`:"")),void o();i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:r.inserted}:e)),"insert"===s&&"refreshed"===r.reason&&f.info(`${t.name} 已更新(文件内容有变化)`)}catch(r){f.error(`操作失败: ${r.message}`),i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:t.inserted}:e))}finally{n.current.delete(t.filename)}},[e,o]),h=l.useCallback(async t=>{if(!n.current.has(t.filename))if(t.inserted){n.current.add(t.filename);try{const s=await Ae(e,t.filename,"insert");if(!s.ok)return f.error("更新失败"+(s.reason?`(${s.reason})`:"")),void o();i(e=>e.map(e=>e.filename===t.filename?{...e,inserted:s.inserted}:e)),f.success(`${t.name} 已从磁盘重新加载`)}catch(s){f.error(`更新失败: ${s.message}`)}finally{n.current.delete(t.filename)}}else f.info("卡片未插入,无需更新")},[e,o]);return _.jsxs("div",{className:"flex flex-col h-full overflow-y-auto",children:[_.jsxs("div",{className:"px-3 pt-2.5 pb-2 border-b border-border/50 shrink-0",children:[_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Memory Prompts"}),_.jsx("button",{onClick:()=>{o()},className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors",title:"刷新(重新扫描 .ccweb/memory/)",children:_.jsx(N,{className:p("h-3.5 w-3.5",s&&"animate-spin")})})]}),_.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground/70 leading-snug",children:["来自 ",_.jsx("code",{className:"text-[11px]",children:".ccweb/memory/*.md"})," 的文件,点击插入 / 移除 CLAUDE.md(以",_.jsx("code",{className:"text-[11px]",children:" START 名 / END 名 "}),"包裹)"]})]}),_.jsx("div",{className:"px-2 py-2 flex-1 min-h-0",children:s&&0===t.length?_.jsx("div",{className:"px-1 py-6 text-xs text-muted-foreground/60 text-center",children:"加载中…"}):0===t.length?_.jsxs("div",{className:"px-1 py-8 text-xs text-muted-foreground/60 flex flex-col items-center gap-2",children:[_.jsx(Yt,{className:"h-5 w-5"}),_.jsxs("div",{className:"text-center leading-relaxed",children:["暂无 memory 文件",_.jsx("br",{}),"新建 ",_.jsx("code",{className:"text-[11px]",children:".ccweb/memory/*.md"})," 文件后点刷新"]})]}):_.jsx("div",{className:"space-y-1.5",children:t.map(e=>_.jsx(mr,{kind:"agent-prompt",noContextMenu:!0,label:e.name,preview:e.preview,inserted:e.inserted,onLeftClick:()=>{a(e)},onRefresh:e.inserted?()=>{h(e)}:void 0},e.filename))})})]})}function Cr({projectId:e,onSend:t}){const[i,s]=Y(x.rightPanelTab,"shortcuts"),r="prompts"===i?"prompts":"memory"===i?"memory":"shortcuts";return _.jsxs(kt,{value:r,onValueChange:e=>s(e),orientation:"vertical",className:"h-full flex bg-muted text-foreground overflow-hidden",children:[_.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-border",children:[_.jsx(Dt,{value:"shortcuts",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:_.jsx(Sr,{projectId:e,onSend:t})}),_.jsx(Dt,{value:"prompts",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:_.jsx(wr,{projectId:e})}),_.jsx(Dt,{value:"memory",className:"flex-1 min-h-0 mt-0 data-[state=inactive]:hidden",children:_.jsx(xr,{projectId:e})})]}),_.jsxs(Et,{className:p("flex flex-col items-center justify-start shrink-0","h-full w-9 border-l border-border rounded-none p-1 gap-1"),children:[_.jsx(Rt,{value:"shortcuts",title:"Quick Prompts (快捷 Prompts)","aria-label":"Quick Prompts",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:_.jsx(Oe,{className:"h-3.5 w-3.5"})}),_.jsx(Rt,{value:"prompts",title:"Agent Prompts","aria-label":"Agent Prompts",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:_.jsx(Ie,{className:"h-3.5 w-3.5"})}),_.jsx(Rt,{value:"memory",title:"Memory Prompts (.ccweb/memory/*.md)","aria-label":"Memory Prompts",className:p("h-7 w-7 p-0 rounded-md flex items-center justify-center"),children:_.jsx(Yt,{className:"h-3.5 w-3.5"})})]})]})}function kr({status:e}){return _.jsxs("span",{className:p("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",{running:"bg-green-500/10 text-green-600 border-green-500/20",stopped:"bg-muted text-muted-foreground border-border",restarting:"bg-yellow-500/10 text-yellow-600 border-yellow-500/20"}[e]),children:[_.jsx("span",{className:p("w-1.5 h-1.5 rounded-full",{"bg-green-500":"running"===e,"bg-muted-foreground":"stopped"===e,"bg-yellow-400 animate-pulse":"restarting"===e})}),e.charAt(0).toUpperCase()+e.slice(1)]})}function Er({project:e,projectId:t,showFileTree:i,showShortcuts:s,showChatOverlay:r,onToggleFileTree:n,onToggleShortcuts:o,onToggleChatOverlay:a,onProjectUpdate:h}){const c=ze(),[d,u]=l.useState(!1),[m,g]=l.useState(!1),[b,w]=l.useState(!1),[y,x]=l.useState(!1);l.useEffect(()=>{const e=()=>x(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]);return _.jsx("header",{className:"border-b border-border flex-shrink-0 bg-muted/50",children:_.jsxs("div",{className:"px-3 h-12 flex items-center gap-2",children:[_.jsx(H,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c("/"),children:_.jsx(We,{className:"h-4 w-4"})}),_.jsx("button",{className:p("p-1 rounded transition-colors",i?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:n,title:"Toggle file tree",children:_.jsx(ti,{className:"h-4 w-4"})}),_.jsx("button",{className:p("p-1 rounded transition-colors",s?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:o,title:"Toggle right panel",children:_.jsx(ii,{className:"h-4 w-4"})}),"terminal"!==e.cliTool&&_.jsx("button",{className:p("p-1 rounded transition-colors",r?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:a,title:"对话框 (Ctrl+I)",children:_.jsx(Jt,{className:"h-4 w-4"})}),_.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2 ml-1",children:[_.jsx("h1",{className:"font-semibold text-foreground truncate text-sm",children:e.name}),_.jsx(kr,{status:e.status}),_.jsx(He,{variant:"outline",className:"text-xs",children:"unlimited"===e.permissionMode?"Unlimited":"Limited"}),_.jsx("span",{className:"text-xs text-muted-foreground font-mono truncate hidden lg:block",children:e.folderPath})]}),_.jsx(Fe,{}),_.jsx($e,{}),_.jsx(H,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()},title:y?"退出全屏":"全屏",children:y?_.jsx(v,{className:"h-3.5 w-3.5"}):_.jsx(S,{className:"h-3.5 w-3.5"})}),_.jsxs(H,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>{(async()=>{if(!b){w(!0);try{const e=await qe(t);e.skipped?f.info("该项目正在同步中,跳过"):e.ok?f.success(`同步完成:${e.filesTransferred} 文件,耗时 ${Math.round(e.durationMs/1e3)}s`):f.error("同步失败"+(e.reason?`(${e.reason})`:""))}catch(e){f.error(e instanceof Error?e.message:"同步失败")}finally{w(!1)}}})()},disabled:b,title:"同步到 rsync 服务器(在设置里配置)",children:[b?_.jsx(Ue,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):_.jsx(Ke,{className:"h-3.5 w-3.5 mr-1.5"}),"同步"]}),_.jsxs(H,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>{(async()=>{g(!0);try{await Ve(t)}catch(e){f.error(e instanceof Error?e.message:"备份失败")}finally{g(!1)}})()},disabled:m,title:"备份到云盘(即将废弃,请使用同步)",children:[m?_.jsx(Ue,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):_.jsx(zt,{className:"h-3.5 w-3.5 mr-1.5"}),"备份"]}),"stopped"===e.status&&_.jsxs(H,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>{(async()=>{u(!0);try{h(await Ye(e.id))}catch(t){console.error(t)}finally{u(!1)}})()},disabled:d,children:[_.jsx(si,{className:"h-3.5 w-3.5 mr-1.5"}),"Start"]})]})})}
|
|
15
15
|
/**
|
|
16
16
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
17
17
|
* @license MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as e,r as s,U as t,aW as a,j as n,W as r,V as l,N as o,d as i,K as c,aX as d,aJ as u,Q as h,aY as x,L as m,Y as p,$ as f,a0 as v,a1 as g,a2 as j,x as y,aZ as b,aa as w,ab as N,ac as k,ad as S,ae as C,B as R,af as _,I as P,ag as T,a_ as E,a$ as I,b0 as D,b1 as M,b2 as O,az as A,b3 as H,l as L,T as V,b4 as z,t as F,aC as W,D as B,b5 as $,b6 as K,b7 as U,u as q,b8 as G,b9 as Z,ba as X,ax as Q,bb as Y,bc as J,h as ee,S as se,bd as te,ay as ae,be as ne,y as re,A as le,p as oe,X as ie,s as ce,bf as de,bg as ue,bh as he,bi as xe,bj as me,bk as pe,bl as fe,bm as ve}from"./index-
|
|
1
|
+
import{c as e,r as s,U as t,aW as a,j as n,W as r,V as l,N as o,d as i,K as c,aX as d,aJ as u,Q as h,aY as x,L as m,Y as p,$ as f,a0 as v,a1 as g,a2 as j,x as y,aZ as b,aa as w,ab as N,ac as k,ad as S,ae as C,B as R,af as _,I as P,ag as T,a_ as E,a$ as I,b0 as D,b1 as M,b2 as O,az as A,b3 as H,l as L,T as V,b4 as z,t as F,aC as W,D as B,b5 as $,b6 as K,b7 as U,u as q,b8 as G,b9 as Z,ba as X,ax as Q,bb as Y,bc as J,h as ee,S as se,bd as te,ay as ae,be as ne,y as re,A as le,p as oe,X as ie,s as ce,bf as de,bg as ue,bh as he,bi as xe,bj as me,bk as pe,bl as fe,bm as ve}from"./index-CBleER0a.js";import{k as ge,u as je,R as ye,d as be,f as we,A as Ne,C as ke,j as Se,h as Ce,S as Re,U as _e,T as Pe,a as Te,b as Ee,i as Ie,c as De}from"./index-DO12wrd9.js";import{C as Me}from"./chevron-down-D_RQtGy2.js";import{C as Oe,a as Ae}from"./chevron-up-C0jadenI.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license lucide-react v0.309.0 - ISC
|
|
4
4
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as e,ax as s,r as t,bn as a,bo as r,t as n,bp as l,bq as i,br as c,a5 as d,bs as o,j as m,B as x,ay as u,d as p,I as h,T as g,p as f,D as j,av as b,aw as N,A as y,ah as v,an as k}from"./index-
|
|
1
|
+
import{c as e,ax as s,r as t,bn as a,bo as r,t as n,bp as l,bq as i,br as c,a5 as d,bs as o,j as m,B as x,ay as u,d as p,I as h,T as g,p as f,D as j,av as b,aw as N,A as y,ah as v,an as k}from"./index-CBleER0a.js";import{S as w}from"./search-CLatOUMz.js";import{C}from"./chevron-down-D_RQtGy2.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license lucide-react v0.309.0 - ISC
|
|
4
4
|
*
|