import{bD as xe,bE as w,bF as Re,r as s,bG as ye,bH as Ds,bI as Ps,E as ge,bJ as _s,bK as Fs,q as e,bL as As,bM as Ls,bN as Kt,bO as Gt,bP as Os,bQ as zs,bR as $s,bS as Ks,bT as X,bU as q,bV as en,bW as tn,bX as Y,bY as ht,bZ as he,b_ as nn,b$ as I,c0 as Gs,c1 as tt,c2 as Bs,c3 as Us,c4 as Vs,c5 as Ws,c6 as Hs,c7 as Xs,c8 as qs,c9 as Ys,ca as Qs,cb as Zs,cc as Js,cd as er,ce as tr,cf as nr,cg as Bt,ch as sr,ci as sn,cj as rn,ck as rr,cl as or,cm as ar,cn as ir,co as cr,cp as Ne,cq as nt,cr as lr,cs as Ee,ct as dr,cu as pt,cv as on,cw as ur,cx as an,cy as cn,cz as gt,cA as xr,cB as fr,cC as hr,cD as st,cE as mr,cF as Ge,cG as $,cH as Ie,cI as pr,cJ as gr,cK as br,cL as vr,cM as Cr,cN as jr,cO as yr,cP as Nr,cQ as wr,cR as Sr,cS as Mr,cT as kr,cU as Ze,cV as Tr,cW as Er,cX as bt,cY as ln,cZ as dn,c_ as un,c$ as Rr,d0 as Ir,d1 as Dr,d2 as xn,d3 as fn,d4 as hn,d5 as Ae,d6 as Le,d7 as Oe,d8 as ze,d9 as Ye,da as Qe,db as mn,dc as pn,dd as Pr,de as Be,df as _r,dg as Fr,dh as Ar,di as Lr,dj as Or,dk as zr,dl as $r,dm as Kr,dn as Gr,dp as Br,dq as Ur,dr as Vr,ds as Wr,dt as Hr,du as Xr,dv as _e,dw as qr,dx as Ut,dy as Yr,dz as Qr,dA as Zr,dB as Jr,dC as eo,dD as to,dE as no}from"./index-CSWkpG4m.js";import"./splashScene-C8lWNnm4.js";/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const so=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],ro=xe("arrow-down",so);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const oo=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],ao=xe("case-sensitive",oo);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const io=[["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"}]],Vt=xe("clipboard-copy",io);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const co=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],lo=xe("columns-2",co);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const uo=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]],gn=xe("file-plus",uo);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const xo=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 17h.01",key:"p32p05"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}]],fo=xe("file-question-mark",xo);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ho=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],bn=xe("folder-plus",ho);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const mo=[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]],po=xe("regex",mo);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const go=[["path",{d:"m16 16-3 3 3 3",key:"117b85"}],["path",{d:"M3 12h14.5a1 1 0 0 1 0 7H13",key:"18xa6z"}],["path",{d:"M3 19h6",key:"1ygdsz"}],["path",{d:"M3 5h18",key:"1u36vt"}]],bo=xe("text-wrap",go);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const vo=[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]],Co=xe("whole-word",vo);function jo(t){return n=>{if(!(n.metaKey||n.ctrlKey))return;const r=Ds(n);if(r==="p"&&!n.shiftKey){n.preventDefault(),n.stopPropagation(),t.onToggleQuickOpen();return}if(r==="f"&&n.shiftKey){n.preventDefault(),n.stopPropagation(),t.onToggleSearchPanel();return}if(r==="f"&&!n.shiftKey){n.preventDefault(),n.stopPropagation();const a=t.getEditorView();a&&Ps(a);return}if(r==="g"&&!n.shiftKey){n.preventDefault(),n.stopPropagation(),t.onToggleGoToLine();return}if(r==="s"&&!n.shiftKey){n.preventDefault(),n.stopPropagation(),t.activeTabId&&t.saveFile(t.activeTabId);return}if(r==="s"&&n.shiftKey){n.preventDefault(),n.stopPropagation(),t.hasUnsavedChanges()&&t.saveAllFiles();return}if(r==="m"&&n.shiftKey){n.preventDefault(),n.stopPropagation(),t.onToggleMdSplit?.();return}if(r==="v"&&n.shiftKey){n.preventDefault(),n.stopPropagation(),t.onToggleMdPreview?.();return}if(r==="w"&&n.shiftKey&&!n.altKey){n.preventDefault(),n.stopPropagation(),t.onToggleLineWrap();return}if(r==="w"&&!n.shiftKey&&!n.altKey){if(n.preventDefault(),n.stopPropagation(),t.activeTabId){const a=new CustomEvent("editor-close-tab",{detail:t.activeTabId});window.dispatchEvent(a)}return}if(r==="b"){n.preventDefault(),n.stopPropagation(),t.onToggleSidebar();return}if(r==="]"&&n.shiftKey){n.preventDefault(),n.stopPropagation();const a=t.openTabs.findIndex(c=>c.id===t.activeTabId);a!==-1&&a<t.openTabs.length-1?t.setActiveEditorTab(t.openTabs[a+1].id):t.openTabs.length>0&&t.setActiveEditorTab(t.openTabs[0].id);return}if(r==="["&&n.shiftKey){n.preventDefault(),n.stopPropagation();const a=t.openTabs.findIndex(c=>c.id===t.activeTabId);a>0?t.setActiveEditorTab(t.openTabs[a-1].id):t.openTabs.length>0&&t.setActiveEditorTab(t.openTabs[t.openTabs.length-1].id);return}if(n.ctrlKey&&r==="Tab"){n.preventDefault(),n.stopPropagation();const a=t.openTabs.findIndex(c=>c.id===t.activeTabId);if(n.shiftKey){const c=a>0?a-1:t.openTabs.length-1;t.openTabs[c]&&t.setActiveEditorTab(t.openTabs[c].id)}else{const c=a<t.openTabs.length-1?a+1:0;t.openTabs[c]&&t.setActiveEditorTab(t.openTabs[c].id)}}}}function yo({onToggleQuickOpen:t,onToggleSearchPanel:n,onToggleGoToLine:o,onToggleSidebar:r,onClose:a,onToggleMdSplit:c,onToggleMdPreview:x}){const{openTabs:l,activeTabId:u}=w(Re(N=>({openTabs:N.editorOpenTabs,activeTabId:N.editorActiveTabId}))),i=w(N=>N.setActiveEditorTab),f=w(N=>N.saveFile),d=w(N=>N.saveAllFiles),m=w(N=>N.hasUnsavedChanges),y=w(N=>N.toggleLineWrap),v=s.useRef(null);v.current={activeTabId:u,openTabs:l,setActiveEditorTab:i,saveFile:f,saveAllFiles:d,hasUnsavedChanges:m,onToggleQuickOpen:t,onToggleSearchPanel:n,onToggleGoToLine:o,onToggleSidebar:r,onToggleLineWrap:y,onToggleMdSplit:c,onToggleMdPreview:x,getEditorView:()=>ye.getView()};const j=s.useCallback(N=>{jo(v.current)(N)},[]);s.useEffect(()=>(window.addEventListener("keydown",j,!0),()=>window.removeEventListener("keydown",j,!0)),[j])}function No(){if(typeof navigator>"u")return!1;const t=navigator.userAgentData?.platform??navigator.userAgent;return/mac/i.test(t)}const vn=No();function te(t,n){return vn?t:n}const Cn=999,xt=he.memo(function({active:n,onClick:o,tooltip:r,shortcut:a,children:c}){return e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx("button",{type:"button",className:nn("flex size-[22px] items-center justify-center rounded transition-colors",n?"bg-blue-500/20 text-blue-400":"text-[var(--color-text-muted)] hover:bg-[var(--color-surface-raised)] hover:text-[var(--color-text-secondary)]"),onClick:o,tabIndex:-1,children:c})}),e.jsxs(Y,{side:"bottom",children:[e.jsx("span",{children:r}),a&&e.jsx("span",{className:"ml-1.5 text-[var(--color-text-muted)]",children:a})]})]})});function wo(t,n){if(!t.valid||!t.search)return 0;try{const o=t.getCursor(n);let r=0;for(;!o.next().done;)if(r++,r>Cn)return-1;return r}catch{return 0}}const So=({view:t,initialSearch:n,initialReplace:o,initialCaseSensitive:r,initialRegexp:a,initialWholeWord:c,registerUpdateNotifier:x})=>{const[l,u]=s.useState(n),[i,f]=s.useState(o),[d,m]=s.useState(r),[y,v]=s.useState(a),[j,N]=s.useState(c),[b,S]=s.useState(!1),[E,L]=s.useState(0),O=s.useRef(null);s.useEffect(()=>{requestAnimationFrame(()=>{O.current?.focus(),O.current?.select()})},[]);const _=s.useMemo(()=>new As({search:l,replace:i,caseSensitive:d,regexp:y,wholeWord:j}),[l,i,d,y,j]);s.useEffect(()=>{t.dispatch({effects:Ls.of(_)})},[_,t]),s.useEffect(()=>{x(()=>L(T=>T+1))},[x]);const C=s.useMemo(()=>wo(_,t.state),[_,t,E]),D=s.useCallback(()=>{Kt(t)},[t]),P=s.useCallback(()=>{Gt(t)},[t]),k=s.useCallback(()=>{Os(t)},[t]),z=s.useCallback(()=>{zs(t)},[t]),H=s.useCallback(()=>{$s(t),t.focus()},[t]),ce=s.useCallback(T=>{T.key==="Escape"?(T.preventDefault(),H()):T.key==="Enter"&&(T.preventDefault(),T.shiftKey?Gt(t):Kt(t))},[t,H]),ae=s.useCallback(T=>{T.key==="Escape"?(T.preventDefault(),H()):T.key==="Enter"&&(T.preventDefault(),k())},[H,k]),le=l?C===-1?`${Cn}+`:C===0?"无结果":`${C} found`:"";return e.jsx(Ks,{delayDuration:400,children:e.jsxs("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx("button",{type:"button",className:"flex h-[22px] w-5 items-center justify-center rounded text-[var(--color-text-muted)] transition-colors hover:text-[var(--color-text-secondary)]",onClick:()=>S(T=>!T),tabIndex:-1,children:b?e.jsx(en,{className:"size-3.5"}):e.jsx(tn,{className:"size-3.5"})})}),e.jsx(Y,{side:"bottom",children:"显示/隐藏替换"})]}),e.jsx(ht,{ref:O,className:"h-[26px] min-w-[180px] flex-1 rounded border-[var(--color-border)] bg-[var(--color-surface)] px-2 text-xs",placeholder:"搜索",value:l,onChange:T=>u(T.target.value),onKeyDown:ce,spellCheck:!1}),e.jsx(xt,{active:d,onClick:()=>m(T=>!T),tooltip:"区分大小写",children:e.jsx(ao,{className:"size-[14px]"})}),e.jsx(xt,{active:j,onClick:()=>N(T=>!T),tooltip:"全词匹配",children:e.jsx(Co,{className:"size-[14px]"})}),e.jsx(xt,{active:y,onClick:()=>v(T=>!T),tooltip:"使用正则表达式",children:e.jsx(po,{className:"size-[14px]"})}),e.jsx("div",{className:"mx-0.5 h-4 w-px bg-[var(--color-border)]"}),le&&e.jsx("span",{className:nn("min-w-[60px] whitespace-nowrap text-center text-xs tabular-nums",C===0&&l?"text-red-400":"text-[var(--color-text-muted)]"),children:le}),e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"size-[22px] text-[var(--color-text-muted)] hover:text-[var(--color-text)]",onClick:P,disabled:C===0,tabIndex:-1,children:e.jsx(Gs,{className:"size-3.5"})})}),e.jsxs(Y,{side:"bottom",children:["上一个匹配 ",e.jsx("span",{className:"text-[var(--color-text-muted)]",children:"⇧Enter"})]})]}),e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"size-[22px] text-[var(--color-text-muted)] hover:text-[var(--color-text)]",onClick:D,disabled:C===0,tabIndex:-1,children:e.jsx(ro,{className:"size-3.5"})})}),e.jsxs(Y,{side:"bottom",children:["下一个匹配 ",e.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Enter"})]})]}),e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"size-[22px] text-[var(--color-text-muted)] hover:text-[var(--color-text)]",onClick:H,tabIndex:-1,children:e.jsx(tt,{className:"size-3.5"})})}),e.jsxs(Y,{side:"bottom",children:["关闭 ",e.jsx("span",{className:"text-[var(--color-text-muted)]",children:"Esc"})]})]})]}),b&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-5 shrink-0"}),e.jsx(ht,{className:"h-[26px] min-w-[180px] flex-1 rounded border-[var(--color-border)] bg-[var(--color-surface)] px-2 text-xs",placeholder:"替换",value:i,onChange:T=>f(T.target.value),onKeyDown:ae,spellCheck:!1}),e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"sm",className:"h-[22px] px-2 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",onClick:k,disabled:C===0,tabIndex:-1,children:"替换"})}),e.jsx(Y,{side:"bottom",children:"替换下一个"})]}),e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"sm",className:"h-[22px] px-2 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",onClick:z,disabled:C===0,tabIndex:-1,children:"全部"})}),e.jsx(Y,{side:"bottom",children:"全部替换"})]})]})]})})};function Mo(t){const n=document.createElement("div"),o=_s.createRoot(n),r=Fs(t.state),a=t.state.selection.main,c=a.empty?"":t.state.sliceDoc(a.from,a.to),x=c&&!c.includes(`
`)?c:r.search;let l=null;return o.render(e.jsx(So,{view:t,initialSearch:x,initialReplace:r.replace,initialCaseSensitive:r.caseSensitive,initialRegexp:r.regexp,initialWholeWord:r.wholeWord,registerUpdateNotifier:u=>{l=u}})),{dom:n,top:!0,update(u){u.docChanged&&l?.()},destroy(){l=null,o.unmount()}}}const ko=ge.theme({".cm-panels":{backgroundColor:"var(--color-surface)",color:"var(--color-text)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},".cm-panels-top":{borderBottom:"1px solid var(--color-border)"},".cm-panels-bottom":{borderTop:"1px solid var(--color-border)"},".cm-searchMatch":{backgroundColor:"var(--highlight-bg-inactive)",borderRadius:"2px"},".cm-searchMatch-selected":{backgroundColor:"var(--highlight-bg) !important",borderRadius:"2px"}}),To=150,Wt=5e3;function Ht(t,n){const o=t.coordsAtPos(n.to);if(!o)return null;let r=t.state.sliceDoc(n.from,n.to);return r.length>Wt&&(r=r.slice(0,Wt)+"…"),{text:r,filePath:"",fromLine:t.state.doc.lineAt(n.from).number,toLine:t.state.doc.lineAt(n.to).number,screenRect:{top:o.top,right:o.right??o.left,bottom:o.bottom}}}const Eo=30,Ro=300,Io=3e4,Do=500*1024,Xt=10,qt=new Bs;function Po(t,n,o,r,a,c){const x=Vs(t),l=Ws(t),u=[Hs,Xs(sr),qs(),Ys(),Qs(),Zs(),Js(),er(),tr(),nr({createPanel:Mo}),ko,Bt.of([{key:"Mod-s",run:()=>(n(),!0)},{key:"Mod-z",run:i=>sn(i)},{key:"Mod-Shift-z",run:i=>rn(i)}]),Bt.of([...rr,...or,...ar.filter(i=>i.run!==cr),...ir]),ge.updateListener.of(i=>{if(i.docChanged&&o(),i.selectionSet||i.docChanged){const f=i.state.selection.main.head,d=i.state.doc.lineAt(f);r(d.number,f-d.from+1);const m=i.state.selection.main;m.empty?a(null):a(Ht(i.view,m))}}),ge.domEventHandlers({scroll:(i,f)=>{const d=f.state.selection.main;d.empty||c(Ht(f,d))}})];return x?u.push(x):l&&u.push(l.support??[]),u}function _o(t,n){try{if(n.length>Do)return;const o=`editor-draft:${t}`,r=JSON.stringify({content:n,timestamp:Date.now()});localStorage.setItem(o,r),Fo()}catch{}}function Fo(){try{const t=[];for(let n=0;n<localStorage.length;n++){const o=localStorage.key(n);if(o?.startsWith("editor-draft:"))try{const r=JSON.parse(localStorage.getItem(o));t.push({key:o,timestamp:r.timestamp})}catch{localStorage.removeItem(o)}}if(t.length>Xt){t.sort((o,r)=>o.timestamp-r.timestamp);const n=t.slice(0,t.length-Xt);for(const o of n)localStorage.removeItem(o.key)}}catch{}}const Ao=150,Lo=({filePath:t,content:n,fileName:o,mtimeMs:r,onCursorChange:a,onDraftRecovered:c,onSelectionChange:x,onDocChange:l})=>{const u=s.useRef(null),i=s.useRef(null),f=s.useRef(new Map),d=s.useRef(new Map),m=s.useRef([]),y=s.useRef(null),v=s.useRef(null),j=s.useRef(null),N=s.useRef(null),b=w(p=>p.markFileModified),S=w(p=>p.discardChanges),E=w(p=>p.saveFile),L=w(p=>p.editorLineWrap),O=s.useRef(t);O.current=t;const _=s.useRef(a);_.current=a;const C=s.useRef(c);C.current=c;const D=s.useRef(x);D.current=x;const P=s.useRef(l);P.current=l;const k=s.useRef(L);k.current=L;const z=s.useCallback(()=>{E(O.current)},[E]),H=s.useCallback(()=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{b(O.current)},Ro),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{const p=i.current;p&&_o(O.current,p.state.doc.toString())},Io),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{const p=i.current;p&&P.current?.(p.state.doc.toString())},Ao)},[b]),ce=s.useCallback((p,R)=>{_.current?.(p,R)},[]),ae=s.useCallback(p=>{if(!p){j.current&&clearTimeout(j.current),D.current?.(null);return}j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{D.current?.({...p,filePath:O.current})},To)},[]),le=s.useCallback(p=>{j.current&&clearTimeout(j.current),p?D.current?.({...p,filePath:O.current}):D.current?.(null)},[]),T=s.useCallback(p=>{const R=m.current,F=R.indexOf(p);for(F!==-1&&R.splice(F,1),R.push(p);R.length>Eo;){const W=R.shift();f.current.delete(W),d.current.delete(W),S(W)}},[S]);s.useEffect(()=>{if(!u.current)return;const p=Po(o,z,H,ce,ae,le);p.push(qt.of(k.current?ge.lineWrapping:[]));let R=f.current.get(t);if(!R){let Me=n,be=!1;try{const ve=localStorage.getItem(`editor-draft:${t}`);if(ve){const re=JSON.parse(ve),me=r??0;me===0||re.timestamp>me?(Me=re.content,be=!0):localStorage.removeItem(`editor-draft:${t}`)}}catch{}R=Us.create({doc:Me,extensions:p}),f.current.set(t,R),be&&(b(t),C.current?.(t))}T(t);const F=new ge({state:R,parent:u.current}),W=d.current.get(t);W!==void 0&&(F.scrollDOM.scrollTop=W),i.current=F,ye.register(f.current,d.current,F);const ie=F.state.selection.main.head,ne=F.state.doc.lineAt(ie);_.current?.(ne.number,ie-ne.from+1);const de=d.current,se=f.current,V=y,ue=v,Z=j,fe=N;return()=>{de.set(t,F.scrollDOM.scrollTop),se.set(t,F.state),V.current&&clearTimeout(V.current),ue.current&&clearTimeout(ue.current),Z.current&&clearTimeout(Z.current),fe.current&&clearTimeout(fe.current),F.destroy(),i.current=null}},[t]),s.useEffect(()=>{const p=i.current;p&&p.dispatch({effects:qt.reconfigure(L?ge.lineWrapping:[])})},[L]);const U=w(p=>p.editorPendingGoToLine),K=w(p=>p.setPendingGoToLine);return s.useEffect(()=>{const p=i.current;if(!p||!U)return;const R=p.state.doc.lines,F=Math.min(Math.max(1,U),R),W=p.state.doc.line(F);p.dispatch({selection:{anchor:W.from},effects:ge.scrollIntoView(W.from,{y:"center"})}),K(null)},[U,K,t]),s.useEffect(()=>()=>{ye.unregister()},[]),e.jsx("div",{ref:u,className:"size-full overflow-hidden"})},Oo=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico"]),zo=10*1024*1024;function $o(t){const n=t.lastIndexOf(".");return n===-1?"":t.slice(n+1).toLowerCase()}function jn(t){const n=$o(t);return Oo.has(n)?"image":"unknown"}function Ko(t,n){return jn(t)==="image"?n<=zo:!1}const yn=({filePath:t,fileName:n,size:o})=>{const r=w(x=>x.editorProjectPath),a=o<1024?`${o} B`:o<1024*1024?`${(o/1024).toFixed(1)} KB`:`${(o/1024/1024).toFixed(1)} MB`,c=()=>{Ne.openPath(t,r??void 0).catch(console.error)};return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-text-muted",children:[e.jsx(fo,{className:"size-12 opacity-30"}),e.jsx("p",{className:"text-sm font-medium text-text-secondary",children:n}),e.jsxs("p",{className:"text-xs",children:["Binary file (",a,")"]}),e.jsx(I,{variant:"outline",size:"sm",className:"mt-2",onClick:c,children:"Open in System Viewer"})]})},Go=({filePath:t,fileName:n,size:o})=>{const r=w(S=>S.editorProjectPath),[a,c]=s.useState(null),[x,l]=s.useState(!0),[u,i]=s.useState(null),[f,d]=s.useState(!1),[m,y]=s.useState(null),v=s.useRef(null);s.useEffect(()=>{l(!0),i(null),c(null),y(null),d(!1)},[t]),s.useEffect(()=>{let S=!1;return Ne.editor.readBinaryPreview(t).then(E=>{S||c(`data:${E.mimeType};base64,${E.base64}`)}).catch(E=>{S||i(E.message)}).finally(()=>{S||l(!1)}),()=>{S=!0}},[t]);const j=s.useCallback(()=>{const S=v.current;S&&y({w:S.naturalWidth,h:S.naturalHeight})},[]),N=s.useCallback(()=>{Ne.openPath(t,r??void 0).catch(console.error)},[t,r]),b=o<1024?`${o} B`:o<1024*1024?`${(o/1024).toFixed(1)} KB`:`${(o/1024/1024).toFixed(1)} MB`;return x?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-text-muted",children:[e.jsx(nt,{className:"size-8 animate-spin opacity-40"}),e.jsx("p",{className:"text-xs",children:"正在加载预览…"})]}):u||!a?e.jsx(yn,{filePath:t,fileName:n,size:o}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4 p-6",children:[e.jsx("button",{type:"button",className:"checkerboard-bg flex max-h-[60vh] max-w-[80%] cursor-zoom-in items-center justify-center overflow-hidden rounded-lg border border-border-subtle p-1",onClick:()=>d(!0),"aria-label":"打开完整尺寸预览",children:e.jsx("img",{ref:v,src:a,alt:n,className:"max-h-[60vh] object-contain",onLoad:j,draggable:!1})}),e.jsxs("p",{className:"text-xs text-text-muted",children:[n,m?` — ${m.w}×${m.h}`:"",` — ${b}`]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(I,{variant:"outline",size:"sm",onClick:N,children:"Open in System Viewer"})}),e.jsx(lr,{open:f,onClose:()=>d(!1),src:a,alt:n})]})},Bo=({filePath:t,size:n})=>{const o=Ee(t)||t;return jn(o)==="image"&&Ko(o,n)?e.jsx(Go,{filePath:t,fileName:o,size:n}):e.jsx(yn,{filePath:t,fileName:o,size:n})},Uo=[{keys:te("⌘ P","Ctrl+P"),label:"快速打开"},{keys:te("⌘ ⇧ F","Ctrl+Shift+F"),label:"在文件中搜索"},{keys:te("⌘ S","Ctrl+S"),label:"保存"},{keys:te("⌘ B","Ctrl+B"),label:"切换侧边栏"},{keys:te("⌘ G","Ctrl+G"),label:"跳转到行"},{keys:"Esc",label:"关闭编辑器"}],Vo=()=>e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-4 text-text-muted",children:[e.jsx(dr,{className:"size-12 opacity-30"}),e.jsx("p",{className:"text-sm",children:"从文件树中选择文件开始编辑"}),e.jsx("div",{className:"mt-2 grid grid-cols-2 gap-x-6 gap-y-1.5",children:Uo.map(t=>e.jsxs("div",{className:"flex items-center justify-between gap-4 text-xs",children:[e.jsx("span",{className:"text-text-muted",children:t.label}),e.jsx("kbd",{className:"rounded border border-border bg-surface-raised px-1.5 py-0.5 font-mono text-[10px] text-text-secondary",children:t.keys})]},t.keys))})]});class Wo extends he.Component{state={hasError:!1,error:null};static getDerivedStateFromError(n){return{hasError:!0,error:n.message}}componentDidCatch(n,o){console.error(`[EditorErrorBoundary] ${this.props.filePath}:`,n,o.componentStack)}handleRetry=()=>{this.setState({hasError:!1,error:null}),this.props.onRetry?.()};render(){return this.state.hasError?e.jsxs("div",{role:"alert","aria-live":"polite",className:"flex h-full flex-col items-center justify-center gap-3 text-text-muted",children:[e.jsx(pt,{"aria-hidden":"true",className:"size-12 text-red-400 opacity-50"}),e.jsxs("p",{className:"max-w-md text-center text-sm text-text-secondary",children:["编辑器崩溃：",this.state.error??"未知错误"]}),e.jsx("button",{type:"button",onClick:this.handleRetry,className:"rounded border border-border px-3 py-1.5 text-xs text-text-secondary transition-colors hover:bg-surface-raised",children:"重试"})]}):e.jsx(e.Fragment,{children:this.props.children})}}const Ho=({error:t,onRetry:n,onClose:o})=>e.jsxs("div",{role:"alert","aria-live":"polite",className:"flex h-full flex-col items-center justify-center gap-3 text-text-muted",children:[e.jsx(pt,{"aria-hidden":"true",className:"size-12 text-yellow-500 opacity-50"}),e.jsx("p",{className:"max-w-md text-center text-sm text-text-secondary",children:t}),e.jsxs("div",{className:"flex gap-2",children:[n&&e.jsx(I,{variant:"outline",size:"sm",onClick:n,children:"重试"}),o&&e.jsx(I,{variant:"outline",size:"sm",onClick:o,children:"关闭标签页"})]})]});function Xo(t){return[...t].sort((n,o)=>n.isFile!==o.isFile?n.isFile?1:-1:n.name.localeCompare(o.name))}var mt=["Enter"," "],qo=["ArrowDown","PageUp","Home"],Nn=["ArrowUp","PageDown","End"],Yo=[...qo,...Nn],Qo={ltr:[...mt,"ArrowRight"],rtl:[...mt,"ArrowLeft"]},Zo={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ue="Menu",[$e,Jo,ea]=ur(Ue),[we,wn]=on(Ue,[ea,an,cn]),rt=an(),Sn=cn(),[ta,Se]=we(Ue),[na,Ve]=we(Ue),Mn=t=>{const{__scopeMenu:n,open:o=!1,children:r,dir:a,onOpenChange:c,modal:x=!0}=t,l=rt(n),[u,i]=s.useState(null),f=s.useRef(!1),d=gt(c),m=xr(a);return s.useEffect(()=>{const y=()=>{f.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>f.current=!1;return document.addEventListener("keydown",y,{capture:!0}),()=>{document.removeEventListener("keydown",y,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),e.jsx(fr,{...l,children:e.jsx(ta,{scope:n,open:o,onOpenChange:d,content:u,onContentChange:i,children:e.jsx(na,{scope:n,onClose:s.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:f,dir:m,modal:x,children:r})})})};Mn.displayName=Ue;var sa="MenuAnchor",vt=s.forwardRef((t,n)=>{const{__scopeMenu:o,...r}=t,a=rt(o);return e.jsx(hr,{...a,...r,ref:n})});vt.displayName=sa;var Ct="MenuPortal",[ra,kn]=we(Ct,{forceMount:void 0}),Tn=t=>{const{__scopeMenu:n,forceMount:o,children:r,container:a}=t,c=Se(Ct,n);return e.jsx(ra,{scope:n,forceMount:o,children:e.jsx(st,{present:o||c.open,children:e.jsx(mr,{asChild:!0,container:a,children:r})})})};Tn.displayName=Ct;var oe="MenuContent",[oa,jt]=we(oe),En=s.forwardRef((t,n)=>{const o=kn(oe,t.__scopeMenu),{forceMount:r=o.forceMount,...a}=t,c=Se(oe,t.__scopeMenu),x=Ve(oe,t.__scopeMenu);return e.jsx($e.Provider,{scope:t.__scopeMenu,children:e.jsx(st,{present:r||c.open,children:e.jsx($e.Slot,{scope:t.__scopeMenu,children:x.modal?e.jsx(aa,{...a,ref:n}):e.jsx(ia,{...a,ref:n})})})})}),aa=s.forwardRef((t,n)=>{const o=Se(oe,t.__scopeMenu),r=s.useRef(null),a=Ge(n,r);return s.useEffect(()=>{const c=r.current;if(c)return pr(c)},[]),e.jsx(yt,{...t,ref:a,trapFocus:o.open,disableOutsidePointerEvents:o.open,disableOutsideScroll:!0,onFocusOutside:$(t.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>o.onOpenChange(!1)})}),ia=s.forwardRef((t,n)=>{const o=Se(oe,t.__scopeMenu);return e.jsx(yt,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>o.onOpenChange(!1)})}),ca=jr("MenuContent.ScrollLock"),yt=s.forwardRef((t,n)=>{const{__scopeMenu:o,loop:r=!1,trapFocus:a,onOpenAutoFocus:c,onCloseAutoFocus:x,disableOutsidePointerEvents:l,onEntryFocus:u,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:d,onInteractOutside:m,onDismiss:y,disableOutsideScroll:v,...j}=t,N=Se(oe,o),b=Ve(oe,o),S=rt(o),E=Sn(o),L=Jo(o),[O,_]=s.useState(null),C=s.useRef(null),D=Ge(n,C,N.onContentChange),P=s.useRef(0),k=s.useRef(""),z=s.useRef(0),H=s.useRef(null),ce=s.useRef("right"),ae=s.useRef(0),le=v?Cr:s.Fragment,T=v?{as:ca,allowPinchZoom:!0}:void 0,U=p=>{const R=k.current+p,F=L().filter(V=>!V.disabled),W=document.activeElement,ie=F.find(V=>V.ref.current===W)?.textValue,ne=F.map(V=>V.textValue),de=Ca(ne,R,ie),se=F.find(V=>V.textValue===de)?.ref.current;(function V(ue){k.current=ue,window.clearTimeout(P.current),ue!==""&&(P.current=window.setTimeout(()=>V(""),1e3))})(R),se&&setTimeout(()=>se.focus())};s.useEffect(()=>()=>window.clearTimeout(P.current),[]),vr();const K=s.useCallback(p=>ce.current===H.current?.side&&ya(p,H.current?.area),[]);return e.jsx(oa,{scope:o,searchRef:k,onItemEnter:s.useCallback(p=>{K(p)&&p.preventDefault()},[K]),onItemLeave:s.useCallback(p=>{K(p)||(C.current?.focus(),_(null))},[K]),onTriggerLeave:s.useCallback(p=>{K(p)&&p.preventDefault()},[K]),pointerGraceTimerRef:z,onPointerGraceIntentChange:s.useCallback(p=>{H.current=p},[]),children:e.jsx(le,{...T,children:e.jsx(yr,{asChild:!0,trapped:a,onMountAutoFocus:$(c,p=>{p.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:x,children:e.jsx(Nr,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:d,onInteractOutside:m,onDismiss:y,children:e.jsx(wr,{asChild:!0,...E,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:O,onCurrentTabStopIdChange:_,onEntryFocus:$(u,p=>{b.isUsingKeyboardRef.current||p.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(Sr,{role:"menu","aria-orientation":"vertical","data-state":Vn(N.open),"data-radix-menu-content":"",dir:b.dir,...S,...j,ref:D,style:{outline:"none",...j.style},onKeyDown:$(j.onKeyDown,p=>{const F=p.target.closest("[data-radix-menu-content]")===p.currentTarget,W=p.ctrlKey||p.altKey||p.metaKey,ie=p.key.length===1;F&&(p.key==="Tab"&&p.preventDefault(),!W&&ie&&U(p.key));const ne=C.current;if(p.target!==ne||!Yo.includes(p.key))return;p.preventDefault();const se=L().filter(V=>!V.disabled).map(V=>V.ref.current);Nn.includes(p.key)&&se.reverse(),ba(se)}),onBlur:$(t.onBlur,p=>{p.currentTarget.contains(p.target)||(window.clearTimeout(P.current),k.current="")}),onPointerMove:$(t.onPointerMove,Ke(p=>{const R=p.target,F=ae.current!==p.clientX;if(p.currentTarget.contains(R)&&F){const W=p.clientX>ae.current?"right":"left";ce.current=W,ae.current=p.clientX}}))})})})})})})});En.displayName=oe;var la="MenuGroup",Nt=s.forwardRef((t,n)=>{const{__scopeMenu:o,...r}=t;return e.jsx(Ie.div,{role:"group",...r,ref:n})});Nt.displayName=la;var da="MenuLabel",Rn=s.forwardRef((t,n)=>{const{__scopeMenu:o,...r}=t;return e.jsx(Ie.div,{...r,ref:n})});Rn.displayName=da;var Je="MenuItem",Yt="menu.itemSelect",ot=s.forwardRef((t,n)=>{const{disabled:o=!1,onSelect:r,...a}=t,c=s.useRef(null),x=Ve(Je,t.__scopeMenu),l=jt(Je,t.__scopeMenu),u=Ge(n,c),i=s.useRef(!1),f=()=>{const d=c.current;if(!o&&d){const m=new CustomEvent(Yt,{bubbles:!0,cancelable:!0});d.addEventListener(Yt,y=>r?.(y),{once:!0}),br(d,m),m.defaultPrevented?i.current=!1:x.onClose()}};return e.jsx(In,{...a,ref:u,disabled:o,onClick:$(t.onClick,f),onPointerDown:d=>{t.onPointerDown?.(d),i.current=!0},onPointerUp:$(t.onPointerUp,d=>{i.current||d.currentTarget?.click()}),onKeyDown:$(t.onKeyDown,d=>{const m=l.searchRef.current!=="";o||m&&d.key===" "||mt.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});ot.displayName=Je;var In=s.forwardRef((t,n)=>{const{__scopeMenu:o,disabled:r=!1,textValue:a,...c}=t,x=jt(Je,o),l=Sn(o),u=s.useRef(null),i=Ge(n,u),[f,d]=s.useState(!1),[m,y]=s.useState("");return s.useEffect(()=>{const v=u.current;v&&y((v.textContent??"").trim())},[c.children]),e.jsx($e.ItemSlot,{scope:o,disabled:r,textValue:a??m,children:e.jsx(gr,{asChild:!0,...l,focusable:!r,children:e.jsx(Ie.div,{role:"menuitem","data-highlighted":f?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...c,ref:i,onPointerMove:$(t.onPointerMove,Ke(v=>{r?x.onItemLeave(v):(x.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:$(t.onPointerLeave,Ke(v=>x.onItemLeave(v))),onFocus:$(t.onFocus,()=>d(!0)),onBlur:$(t.onBlur,()=>d(!1))})})})}),ua="MenuCheckboxItem",Dn=s.forwardRef((t,n)=>{const{checked:o=!1,onCheckedChange:r,...a}=t;return e.jsx(Ln,{scope:t.__scopeMenu,checked:o,children:e.jsx(ot,{role:"menuitemcheckbox","aria-checked":et(o)?"mixed":o,...a,ref:n,"data-state":St(o),onSelect:$(a.onSelect,()=>r?.(et(o)?!0:!o),{checkForDefaultPrevented:!1})})})});Dn.displayName=ua;var Pn="MenuRadioGroup",[xa,fa]=we(Pn,{value:void 0,onValueChange:()=>{}}),_n=s.forwardRef((t,n)=>{const{value:o,onValueChange:r,...a}=t,c=gt(r);return e.jsx(xa,{scope:t.__scopeMenu,value:o,onValueChange:c,children:e.jsx(Nt,{...a,ref:n})})});_n.displayName=Pn;var Fn="MenuRadioItem",An=s.forwardRef((t,n)=>{const{value:o,...r}=t,a=fa(Fn,t.__scopeMenu),c=o===a.value;return e.jsx(Ln,{scope:t.__scopeMenu,checked:c,children:e.jsx(ot,{role:"menuitemradio","aria-checked":c,...r,ref:n,"data-state":St(c),onSelect:$(r.onSelect,()=>a.onValueChange?.(o),{checkForDefaultPrevented:!1})})})});An.displayName=Fn;var wt="MenuItemIndicator",[Ln,ha]=we(wt,{checked:!1}),On=s.forwardRef((t,n)=>{const{__scopeMenu:o,forceMount:r,...a}=t,c=ha(wt,o);return e.jsx(st,{present:r||et(c.checked)||c.checked===!0,children:e.jsx(Ie.span,{...a,ref:n,"data-state":St(c.checked)})})});On.displayName=wt;var ma="MenuSeparator",zn=s.forwardRef((t,n)=>{const{__scopeMenu:o,...r}=t;return e.jsx(Ie.div,{role:"separator","aria-orientation":"horizontal",...r,ref:n})});zn.displayName=ma;var pa="MenuArrow",$n=s.forwardRef((t,n)=>{const{__scopeMenu:o,...r}=t,a=rt(o);return e.jsx(Mr,{...a,...r,ref:n})});$n.displayName=pa;var ga="MenuSub",[Ki,Kn]=we(ga),Fe="MenuSubTrigger",Gn=s.forwardRef((t,n)=>{const o=Se(Fe,t.__scopeMenu),r=Ve(Fe,t.__scopeMenu),a=Kn(Fe,t.__scopeMenu),c=jt(Fe,t.__scopeMenu),x=s.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:u}=c,i={__scopeMenu:t.__scopeMenu},f=s.useCallback(()=>{x.current&&window.clearTimeout(x.current),x.current=null},[]);return s.useEffect(()=>f,[f]),s.useEffect(()=>{const d=l.current;return()=>{window.clearTimeout(d),u(null)}},[l,u]),e.jsx(vt,{asChild:!0,...i,children:e.jsx(In,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":a.contentId,"data-state":Vn(o.open),...t,ref:kr(n,a.onTriggerChange),onClick:d=>{t.onClick?.(d),!(t.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),o.open||o.onOpenChange(!0))},onPointerMove:$(t.onPointerMove,Ke(d=>{c.onItemEnter(d),!d.defaultPrevented&&!t.disabled&&!o.open&&!x.current&&(c.onPointerGraceIntentChange(null),x.current=window.setTimeout(()=>{o.onOpenChange(!0),f()},100))})),onPointerLeave:$(t.onPointerLeave,Ke(d=>{f();const m=o.content?.getBoundingClientRect();if(m){const y=o.content?.dataset.side,v=y==="right",j=v?-5:5,N=m[v?"left":"right"],b=m[v?"right":"left"];c.onPointerGraceIntentChange({area:[{x:d.clientX+j,y:d.clientY},{x:N,y:m.top},{x:b,y:m.top},{x:b,y:m.bottom},{x:N,y:m.bottom}],side:y}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>c.onPointerGraceIntentChange(null),300)}else{if(c.onTriggerLeave(d),d.defaultPrevented)return;c.onPointerGraceIntentChange(null)}})),onKeyDown:$(t.onKeyDown,d=>{const m=c.searchRef.current!=="";t.disabled||m&&d.key===" "||Qo[r.dir].includes(d.key)&&(o.onOpenChange(!0),o.content?.focus(),d.preventDefault())})})})});Gn.displayName=Fe;var Bn="MenuSubContent",Un=s.forwardRef((t,n)=>{const o=kn(oe,t.__scopeMenu),{forceMount:r=o.forceMount,...a}=t,c=Se(oe,t.__scopeMenu),x=Ve(oe,t.__scopeMenu),l=Kn(Bn,t.__scopeMenu),u=s.useRef(null),i=Ge(n,u);return e.jsx($e.Provider,{scope:t.__scopeMenu,children:e.jsx(st,{present:r||c.open,children:e.jsx($e.Slot,{scope:t.__scopeMenu,children:e.jsx(yt,{id:l.contentId,"aria-labelledby":l.triggerId,...a,ref:i,align:"start",side:x.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:f=>{x.isUsingKeyboardRef.current&&u.current?.focus(),f.preventDefault()},onCloseAutoFocus:f=>f.preventDefault(),onFocusOutside:$(t.onFocusOutside,f=>{f.target!==l.trigger&&c.onOpenChange(!1)}),onEscapeKeyDown:$(t.onEscapeKeyDown,f=>{x.onClose(),f.preventDefault()}),onKeyDown:$(t.onKeyDown,f=>{const d=f.currentTarget.contains(f.target),m=Zo[x.dir].includes(f.key);d&&m&&(c.onOpenChange(!1),l.trigger?.focus(),f.preventDefault())})})})})})});Un.displayName=Bn;function Vn(t){return t?"open":"closed"}function et(t){return t==="indeterminate"}function St(t){return et(t)?"indeterminate":t?"checked":"unchecked"}function ba(t){const n=document.activeElement;for(const o of t)if(o===n||(o.focus(),document.activeElement!==n))return}function va(t,n){return t.map((o,r)=>t[(n+r)%t.length])}function Ca(t,n,o){const a=n.length>1&&Array.from(n).every(i=>i===n[0])?n[0]:n,c=o?t.indexOf(o):-1;let x=va(t,Math.max(c,0));a.length===1&&(x=x.filter(i=>i!==o));const u=x.find(i=>i.toLowerCase().startsWith(a.toLowerCase()));return u!==o?u:void 0}function ja(t,n){const{x:o,y:r}=t;let a=!1;for(let c=0,x=n.length-1;c<n.length;x=c++){const l=n[c],u=n[x],i=l.x,f=l.y,d=u.x,m=u.y;f>r!=m>r&&o<(d-i)*(r-f)/(m-f)+i&&(a=!a)}return a}function ya(t,n){if(!n)return!1;const o={x:t.clientX,y:t.clientY};return ja(o,n)}function Ke(t){return n=>n.pointerType==="mouse"?t(n):void 0}var Na=Mn,wa=vt,Sa=Tn,Ma=En,ka=Nt,Ta=Rn,Ea=ot,Ra=Dn,Ia=_n,Da=An,Pa=On,_a=zn,Fa=$n,Aa=Gn,La=Un,Mt="ContextMenu",[Oa]=on(Mt,[wn]),Q=wn(),[za,Wn]=Oa(Mt),Hn=t=>{const{__scopeContextMenu:n,children:o,onOpenChange:r,dir:a,modal:c=!0}=t,[x,l]=s.useState(!1),u=Q(n),i=gt(r),f=s.useCallback(d=>{l(d),i(d)},[i]);return e.jsx(za,{scope:n,open:x,onOpenChange:f,modal:c,children:e.jsx(Na,{...u,dir:a,open:x,onOpenChange:f,modal:c,children:o})})};Hn.displayName=Mt;var Xn="ContextMenuTrigger",qn=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,disabled:r=!1,...a}=t,c=Wn(Xn,o),x=Q(o),l=s.useRef({x:0,y:0}),u=s.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),i=s.useRef(0),f=s.useCallback(()=>window.clearTimeout(i.current),[]),d=m=>{l.current={x:m.clientX,y:m.clientY},c.onOpenChange(!0)};return s.useEffect(()=>f,[f]),s.useEffect(()=>void(r&&f()),[r,f]),e.jsxs(e.Fragment,{children:[e.jsx(wa,{...x,virtualRef:u}),e.jsx(Ie.span,{"data-state":c.open?"open":"closed","data-disabled":r?"":void 0,...a,ref:n,style:{WebkitTouchCallout:"none",...t.style},onContextMenu:r?t.onContextMenu:$(t.onContextMenu,m=>{f(),d(m),m.preventDefault()}),onPointerDown:r?t.onPointerDown:$(t.onPointerDown,qe(m=>{f(),i.current=window.setTimeout(()=>d(m),700)})),onPointerMove:r?t.onPointerMove:$(t.onPointerMove,qe(f)),onPointerCancel:r?t.onPointerCancel:$(t.onPointerCancel,qe(f)),onPointerUp:r?t.onPointerUp:$(t.onPointerUp,qe(f))})]})});qn.displayName=Xn;var $a="ContextMenuPortal",Yn=t=>{const{__scopeContextMenu:n,...o}=t,r=Q(n);return e.jsx(Sa,{...r,...o})};Yn.displayName=$a;var Qn="ContextMenuContent",Zn=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Wn(Qn,o),c=Q(o),x=s.useRef(!1);return e.jsx(Ma,{...c,...r,ref:n,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:l=>{t.onCloseAutoFocus?.(l),!l.defaultPrevented&&x.current&&l.preventDefault(),x.current=!1},onInteractOutside:l=>{t.onInteractOutside?.(l),!l.defaultPrevented&&!a.modal&&(x.current=!0)},style:{...t.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)"}})});Zn.displayName=Qn;var Ka="ContextMenuGroup",Ga=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Q(o);return e.jsx(ka,{...a,...r,ref:n})});Ga.displayName=Ka;var Ba="ContextMenuLabel",Ua=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Q(o);return e.jsx(Ta,{...a,...r,ref:n})});Ua.displayName=Ba;var Va="ContextMenuItem",Jn=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Q(o);return e.jsx(Ea,{...a,...r,ref:n})});Jn.displayName=Va;var Wa="ContextMenuCheckboxItem",Ha=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Q(o);return e.jsx(Ra,{...a,...r,ref:n})});Ha.displayName=Wa;var Xa="ContextMenuRadioGroup",qa=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Q(o);return e.jsx(Ia,{...a,...r,ref:n})});qa.displayName=Xa;var Ya="ContextMenuRadioItem",Qa=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Q(o);return e.jsx(Da,{...a,...r,ref:n})});Qa.displayName=Ya;var Za="ContextMenuItemIndicator",Ja=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Q(o);return e.jsx(Pa,{...a,...r,ref:n})});Ja.displayName=Za;var ei="ContextMenuSeparator",es=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Q(o);return e.jsx(_a,{...a,...r,ref:n})});es.displayName=ei;var ti="ContextMenuArrow",ni=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Q(o);return e.jsx(Fa,{...a,...r,ref:n})});ni.displayName=ti;var si="ContextMenuSubTrigger",ri=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Q(o);return e.jsx(Aa,{...a,...r,ref:n})});ri.displayName=si;var oi="ContextMenuSubContent",ai=s.forwardRef((t,n)=>{const{__scopeContextMenu:o,...r}=t,a=Q(o);return e.jsx(La,{...a,...r,ref:n,style:{...t.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)"}})});ai.displayName=oi;function qe(t){return n=>n.pointerType!=="mouse"?t(n):void 0}var ts=Hn,ns=qn,ss=Yn,rs=Zn,ee=Jn,Te=es;const ii=({children:t,projectPath:n,onNewFile:o,onNewFolder:r,onDelete:a,onRename:c,onSendMessage:x})=>{const[l,u]=s.useState(null),i=s.useRef(null),f=s.useCallback(m=>{let y=m.target;for(;y&&y!==m.currentTarget;){const v=y.getAttribute("data-editor-path");if(v){const j=y.getAttribute("data-editor-type"),N=y.getAttribute("data-editor-sensitive");u({path:v,isDir:j==="directory",isSensitive:N==="true"});return}y=y.parentElement}u(null)},[]),d=l?l.isDir?l.path:l.path.substring(0,Ze(l.path)):null;return e.jsxs(ts,{children:[e.jsx(ns,{asChild:!0,children:e.jsx("div",{ref:i,onContextMenu:f,className:"h-full",children:t})}),e.jsx(ss,{children:e.jsxs(rs,{className:"z-50 min-w-[180px] rounded-md border border-border-emphasis bg-surface-overlay p-1 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",children:[d&&e.jsxs(e.Fragment,{children:[e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:()=>o(d),children:[e.jsx(gn,{className:"size-3.5 text-text-muted"}),"New File"]}),e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:()=>r(d),children:[e.jsx(bn,{className:"size-3.5 text-text-muted"}),"New Folder"]}),e.jsx(Te,{className:"my-1 h-px bg-border"})]}),l&&e.jsxs(e.Fragment,{children:[e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-50",disabled:l.isSensitive,onSelect:()=>c(l.path),children:[e.jsx(Tr,{className:"size-3.5 text-text-muted"}),"Rename"]}),e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-red-400 outline-none hover:bg-surface-raised focus:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-50",disabled:l.isSensitive,onSelect:()=>a(l.path),children:[e.jsx(Er,{className:"size-3.5"}),"Delete"]}),e.jsx(Te,{className:"my-1 h-px bg-border"})]}),l&&e.jsxs(e.Fragment,{children:[e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:()=>void navigator.clipboard.writeText(l.path),children:[e.jsx(Vt,{className:"size-3.5 text-text-muted"}),"Copy Path"]}),n&&l.path.startsWith(n)&&e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:()=>{const m=l.path.slice(n.length+1);navigator.clipboard.writeText(m)},children:[e.jsx(Vt,{className:"size-3.5 text-text-muted"}),"Copy Relative Path"]}),e.jsx(Te,{className:"my-1 h-px bg-border"}),e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:()=>{Ne.showInFolder(l.path)},children:[e.jsx(bt,{className:"size-3.5 text-text-muted"}),"Reveal in Finder"]})]}),l&&!l.isDir&&x&&e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"my-1 h-px bg-border"}),e.jsxs(ee,{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:()=>x(l.path),children:[e.jsx(ln,{className:"size-3.5 text-text-muted"}),"Write Teammate"]})]})]})})]})},ci={modified:{letter:"M",color:"text-orange-400"},untracked:{letter:"U",color:"text-green-400"},staged:{letter:"A",color:"text-green-400"},deleted:{letter:"D",color:"text-red-400"},conflict:{letter:"C",color:"text-red-400 font-bold"},renamed:{letter:"R",color:"text-cyan-400"}},li=he.memo(function({status:n}){const o=ci[n];return e.jsx("span",{className:`ml-auto shrink-0 text-[10px] leading-none ${o.color}`,title:n,children:o.letter})}),di=/[\x00-\x1f/\\:*?"<>|]/;function ui(t){const n=t.trim();return n.length===0?"Name cannot be empty":n==="."||n===".."?"Invalid name":di.test(n)?"Name contains invalid characters":n.length>255?"Name is too long":null}const xi=({type:t,parentDir:n,onSubmit:o,onCancel:r})=>{const[a,c]=s.useState(""),[x,l]=s.useState(null),u=s.useRef(null),i=s.useRef(null);s.useEffect(()=>{const v=setTimeout(()=>{u.current?.focus()},100);return()=>clearTimeout(v)},[]),s.useEffect(()=>{const v=N=>{i.current&&!i.current.contains(N.target)&&r()},j=setTimeout(()=>{document.addEventListener("pointerdown",v,!0)},150);return()=>{clearTimeout(j),document.removeEventListener("pointerdown",v,!0)}},[r]);const f=s.useCallback(()=>{const v=a.trim(),j=ui(v);if(j){l(j);return}o(v)},[a,o]),d=s.useCallback(v=>{v.key==="Enter"?(v.preventDefault(),f()):v.key==="Escape"&&(v.preventDefault(),r()),v.stopPropagation()},[f,r]),m=s.useCallback(v=>{c(v.target.value),l(null)},[]),y=t==="file"?gn:bn;return e.jsxs("div",{ref:i,className:"flex flex-col px-2 py-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(y,{className:"size-3.5 shrink-0 text-text-muted"}),e.jsx("input",{ref:u,type:"text",value:a,onChange:m,onKeyDown:d,onBlur:()=>requestAnimationFrame(()=>u.current?.focus()),placeholder:t==="file"?"文件名...":"文件夹名...",className:"min-w-0 flex-1 rounded border border-border-emphasis bg-surface px-1.5 py-0.5 text-xs text-text outline-none focus:border-blue-500","aria-label":t==="file"?"新文件名":"新文件夹名"})]}),x&&e.jsx("span",{className:"mt-0.5 pl-5 text-[10px] text-red-400",children:x})]})},fi=28,os=12,as=12,hi=500;let ft=0;const mi=({selectedFilePath:t,onFileSelect:n,onSendMessage:o})=>{ft++,ft%5===0&&console.debug(`[perf] EditorFileTree render #${ft}`);const{fileTree:r,expandedDirs:a,loading:c,error:x,gitFiles:l,projectPath:u}=w(Re(g=>({fileTree:g.editorFileTree,expandedDirs:g.editorExpandedDirs,loading:g.editorFileTreeLoading,error:g.editorFileTreeError,gitFiles:g.editorGitFiles,projectPath:g.editorProjectPath}))),i=w(g=>g.expandDirectory),f=w(g=>g.collapseDirectory),d=w(g=>g.createFileInTree),m=w(g=>g.createDirInTree),y=w(g=>g.deleteFileFromTree),v=w(g=>g.moveFileInTree),j=w(g=>g.renameFileInTree),N=w(g=>g.openFile),[b,S]=s.useState(null),[E,L]=s.useState(null),[O,_]=s.useState(null),[C,D]=s.useState(null),[P,k]=s.useState(null),z=s.useRef(null),H=s.useRef(null),[ce,ae]=s.useState(!1);s.useEffect(()=>{const g=requestAnimationFrame(()=>{requestAnimationFrame(()=>ae(!0))});return()=>cancelAnimationFrame(g)},[]),s.useEffect(()=>()=>{z.current&&clearTimeout(z.current)},[]);const le=dn(un(mn,{activationConstraint:{distance:5}})),T=s.useMemo(()=>{if(!r)return[];const g=performance.now(),M=Xo(ls(r)),A=performance.now()-g;return A>2&&console.debug(`[perf] treeNodes: ${A.toFixed(1)}ms, nodes=${M.length}`),M},[r]),U=s.useMemo(()=>{const g=performance.now(),M=[];ds(T,a,M,0);const A=performance.now()-g;return A>2&&console.debug(`[perf] flatItems: ${A.toFixed(1)}ms, items=${M.length}`),M},[T,a]),K=s.useMemo(()=>{const g=new Map;for(const M of U)g.set(M.node.fullPath,M);return g},[U]),p=s.useMemo(()=>{if(!b)return null;const{parentDir:g}=b,M=U.findIndex(A=>A.node.fullPath===g);return M===-1?{index:0,depth:0}:{index:M+1,depth:U[M].depth+1}},[b,U]),R=Rr({count:U.length+(p?1:0),getScrollElement:()=>H.current,estimateSize:()=>fi,overscan:ce?C?20:10:3});s.useEffect(()=>{if(!t)return;const g=U.findIndex(M=>M.node.fullPath===t);g>=0&&R.scrollToIndex(g,{align:"center"})},[t,U,R]);const F=s.useMemo(()=>{const g=performance.now(),M=new Map;if(!l?.length||!u)return M;for(const B of l){const je=Ir(u,...Dr(B.path));M.set(je,B.status)}const A=performance.now()-g;return A>2&&console.debug(`[perf] gitStatusMap: ${A.toFixed(1)}ms, files=${l.length}`),M},[l,u]),W=t,ie=s.useCallback(g=>{g.data&&(g.data.isSensitive||(g.isFile?n(g.data.path):a[g.fullPath]?f(g.fullPath):i(g.fullPath)))},[n,a,i,f]),ne=s.useCallback(g=>{g!==u&&!a[g]&&i(g),S({parentDir:g,type:"file"})},[u,a,i]),de=s.useCallback(g=>{g!==u&&!a[g]&&i(g),S({parentDir:g,type:"directory"})},[u,a,i]),se=s.useCallback(g=>{_(g)},[]),V=s.useCallback(async()=>{O&&(await y(O),_(null))},[O,y]),ue=s.useCallback(()=>{_(null)},[]),Z=s.useCallback(g=>{L(g)},[]),fe=s.useCallback(async g=>{E&&(await j(E,g),L(null))},[E,j]),Me=s.useCallback(()=>{L(null)},[]),be=s.useCallback(async g=>{if(b){if(b.type==="file"){const M=await d(b.parentDir,g);M&&N(M)}else await m(b.parentDir,g);S(null)}},[b,d,m,N]),ve=s.useCallback(()=>{S(null)},[]),re=s.useCallback(()=>{z.current&&(clearTimeout(z.current),z.current=null)},[]),me=s.useCallback(g=>{const M=String(g.active.id),A=K.get(M);A&&D(A)},[K]),We=s.useCallback(g=>{const{over:M}=g;if(!M||!C){k(null),re();return}const A=String(M.id);let B=null;if(A==="root-drop-zone")B=u;else if(A.startsWith("drop:"))B=A.slice(5);else{const je=K.get(A);if(je){const Xe=je.node.fullPath;B=Xe.substring(0,Ze(Xe))}}B!==P&&(k(B),re(),B&&B!==u&&!a[B]&&(z.current=setTimeout(()=>{i(B)},hi)))},[C,P,u,K,a,i,re]),Ce=s.useCallback(g=>{re();const M=C?.node.fullPath;if(!M||!P||!g.over){D(null),k(null);return}const A=P;if(M.substring(0,Ze(M))===A){D(null),k(null);return}if(xn(M,A)){D(null),k(null);return}if(C?.node.data?.isSensitive){D(null),k(null);return}v(M,A),D(null),k(null)},[C,P,v,re]),He=s.useCallback(()=>{re(),D(null),k(null)},[re]);return x?e.jsxs("div",{className:"p-3 text-xs text-red-400",children:["文件加载失败：",x]}):c&&!r?e.jsx("div",{className:"p-3 text-xs text-text-muted",children:"正在加载文件..."}):T.length===0?e.jsx("div",{className:"p-3 text-xs text-text-muted",children:"未找到文件"}):e.jsxs(ii,{projectPath:u,onNewFile:ne,onNewFolder:de,onDelete:se,onRename:Z,onSendMessage:o,children:[e.jsxs(fn,{sensors:le,onDragStart:me,onDragOver:We,onDragEnd:Ce,onDragCancel:He,autoScroll:{threshold:{x:0,y:.15}},children:[e.jsxs(is,{ref:H,projectPath:u,isDropTarget:P===u,children:[e.jsx("div",{style:{height:`${R.getTotalSize()}px`,width:"100%",position:"relative"},children:R.getVirtualItems().map(g=>{const{index:M}=g;if(M===p?.index)return e.jsx("div",{style:{position:"absolute",top:`${g.start}px`,left:0,width:"100%",height:`${g.size}px`,paddingLeft:`${Math.min(p.depth,as)*os}px`},children:e.jsx(xi,{type:b.type,parentDir:b.parentDir,onSubmit:be,onCancel:ve})},"__new-item-input__");const A=p&&M>p.index?M-1:M,B=U[A];return e.jsx("div",{style:{position:"absolute",top:`${g.start}px`,left:0,width:"100%",height:`${g.size}px`},children:e.jsx(cs,{item:B,activeNodePath:W,gitStatus:F.get(B.node.fullPath),dropTargetPath:P,isDragActive:!!C,onClick:ie,isRenaming:E===B.node.fullPath,onRenameSubmit:fe,onRenameCancel:Me})},B.node.fullPath)})}),C&&e.jsx("div",{className:"h-16 w-full shrink-0","aria-label":"拖到此处可移到项目根目录"})]}),e.jsx(hn,{dropAnimation:null,children:C&&e.jsx(pi,{item:C})})]}),e.jsx(Ae,{open:!!O,onOpenChange:g=>!g&&ue(),children:e.jsxs(Le,{className:"w-96 max-w-96",children:[e.jsxs(Oe,{children:[e.jsx(ze,{className:"text-sm",children:"移到废纸篓"}),e.jsxs(Ye,{children:["将 “",O?Ee(O):"","” 移到废纸篓？"]})]}),e.jsxs(Qe,{children:[e.jsx(I,{variant:"ghost",size:"sm",onClick:ue,children:"取消"}),e.jsx(I,{variant:"destructive",size:"sm",onClick:()=>void V(),children:"移到废纸篓"})]})]})})]})},is=he.forwardRef(({projectPath:t,isDropTarget:n,children:o},r)=>{const{setNodeRef:a}=pn({id:"root-drop-zone",data:{isRoot:!0,path:t}}),c=s.useCallback(x=>{a(x),typeof r=="function"?r(x):r&&(r.current=x)},[r,a]);return e.jsx("div",{ref:c,className:`scrollbar-thin h-full overflow-y-auto transition-colors ${n?"bg-blue-400/5 ring-1 ring-inset ring-blue-400/30":""}`,role:"tree",children:o})});is.displayName="RootDropZone";const cs=he.memo(({item:t,activeNodePath:n,gitStatus:o,dropTargetPath:r,isDragActive:a,onClick:c,isRenaming:x,onRenameSubmit:l,onRenameCancel:u})=>{const{node:i,depth:f,isExpanded:d}=t,m=n===i.fullPath,y=Math.min(f,as),v=i.data?.isSensitive,{attributes:j,listeners:N,setNodeRef:b,isDragging:S}=Pr({id:i.fullPath,data:{node:i,depth:f},disabled:!!v}),{setNodeRef:E}=pn({id:"drop:"+i.fullPath,data:{node:i},disabled:i.isFile}),L=s.useCallback(z=>{b(z),i.isFile||E(z)},[b,E,i.isFile]),O=!i.isFile&&r===i.fullPath,_=r!=null&&r!==i.fullPath&&xn(r,i.fullPath),C={};i.data&&(C["data-editor-path"]=i.data.path,C["data-editor-type"]=i.data.type,i.data.isSensitive&&(C["data-editor-sensitive"]="true"));const D=()=>{a||c(i)},P=z=>{(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),D())};let k;return i.data?.isSensitive?k=e.jsx(_r,{className:"size-3.5 shrink-0 text-yellow-500"}):i.isFile?k=e.jsx(Be,{fileName:i.name,className:"size-3.5"}):d?k=e.jsx(bt,{className:"size-3.5 shrink-0 text-text-muted"}):k=e.jsx(Fr,{className:"size-3.5 shrink-0 text-text-muted"}),e.jsxs("div",{ref:L,...j,...N,role:"treeitem","aria-selected":i.isFile?m:void 0,"aria-expanded":i.isFile?void 0:d,className:`flex h-full cursor-pointer select-none items-center gap-1 truncate px-2 text-xs transition-colors hover:bg-surface-raised ${m?"bg-surface-raised text-text":"text-text-secondary"} ${S?"opacity-30":""} ${O?"rounded bg-blue-400/10 ring-2 ring-blue-400/50":""} ${_&&!O?"border-l-2 border-l-blue-400/40 bg-blue-400/5":""}`,style:{paddingLeft:`${y*os+8}px`},onClick:D,onKeyDown:P,tabIndex:0,title:i.data?.path??i.fullPath,...C,children:[!i.isFile&&(d?e.jsx(en,{className:"size-3 shrink-0 text-text-muted"}):e.jsx(tn,{className:"size-3 shrink-0 text-text-muted"})),k,x?e.jsx(gi,{initialName:i.name,onSubmit:l,onCancel:u}):e.jsx("span",{className:"truncate",children:i.name}),!x&&o&&e.jsx(li,{status:o})]})});cs.displayName="DraggableTreeItem";const pi=({item:t})=>{const{node:n}=t;let o;return n.isFile?o=e.jsx(Be,{fileName:n.name,className:"size-3.5"}):o=e.jsx(bt,{className:"size-3.5 text-text-muted"}),e.jsxs("div",{className:"flex items-center gap-1.5 rounded border border-border-emphasis bg-surface-overlay px-3 py-1 text-xs text-text shadow-lg",children:[o,e.jsx("span",{className:"truncate",children:n.name})]})},gi=({initialName:t,onSubmit:n,onCancel:o})=>{const[r,a]=s.useState(t),c=s.useRef(!1),x=s.useRef(null);s.useEffect(()=>{const u=setTimeout(()=>{const i=x.current;if(!i)return;i.focus();const f=t.lastIndexOf(".");f>0?i.setSelectionRange(0,f):i.select()},100);return()=>clearTimeout(u)},[t]),s.useEffect(()=>{const u=f=>{x.current&&!x.current.contains(f.target)&&l()},i=setTimeout(()=>{document.addEventListener("pointerdown",u,!0)},150);return()=>{clearTimeout(i),document.removeEventListener("pointerdown",u,!0)}},[]);const l=()=>{if(c.current)return;c.current=!0;const u=x.current?.value.trim()??"";u&&u!==t?n(u):o()};return e.jsx("input",{ref:x,value:r,onChange:u=>a(u.target.value),onKeyDown:u=>{u.key==="Enter"?(u.preventDefault(),l()):u.key==="Escape"&&(u.preventDefault(),o()),u.stopPropagation()},onBlur:()=>requestAnimationFrame(()=>x.current?.focus()),onClick:u=>u.stopPropagation(),className:"min-w-0 flex-1 rounded border border-blue-400/50 bg-surface px-1 py-0 text-xs text-text outline-none focus:ring-1 focus:ring-blue-400/50"})};function ls(t){return Array.isArray(t)?t.flatMap(n=>{if(!n||typeof n!="object")return[];const o=n;if(typeof o.name!="string"||typeof o.path!="string"||o.type!=="file"&&o.type!=="directory")return[];const r={...o,children:Array.isArray(o.children)?o.children:void 0};return[{name:r.name,fullPath:r.path,isFile:r.type==="file",data:r,children:ls(r.children)}]}):[]}function ds(t,n,o,r){for(const a of t){const c=!a.isFile&&n[a.fullPath]===!0;o.push({node:a,depth:r,isExpanded:c}),c&&a.children.length>0&&ds(a.children,n,o,r+1)}}const Qt=8,Zt=68,bi=32,vi=({info:t,containerRect:n,onSendMessage:o})=>{if(!t.text.trim())return null;const r=t.screenRect.top-n.top,a=t.screenRect.right-n.left+Qt,c=t.screenRect.top-n.top;if(t.screenRect.bottom-n.top<0||c>n.height)return null;const l=Math.max(0,Math.min(r,n.height-bi)),u=a+Zt>n.width?t.screenRect.right-n.left-Zt-Qt:a;return e.jsx("div",{className:"pointer-events-auto absolute z-20 flex items-center gap-0.5 rounded-md border border-border-emphasis bg-surface-overlay p-0.5 shadow-lg animate-in fade-in-0 zoom-in-95",style:{top:l,left:Math.max(0,u)},children:e.jsx(Ci,{icon:e.jsx(ln,{className:"size-3.5"}),label:"Write Teammate",onClick:o})})},Ci=({icon:t,label:n,onClick:o})=>e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",tabIndex:-1,"aria-label":n,onClick:o,onMouseDown:r=>r.preventDefault(),className:"size-7 p-1.5 text-text-secondary",children:t})}),e.jsx(Y,{side:"top",sideOffset:6,children:n})]}),ji=[{title:"文件操作",shortcuts:[{mac:"⌘ P",other:"Ctrl+P",description:"快速打开"},{mac:"⌘ S",other:"Ctrl+S",description:"保存"},{mac:"⌘ ⇧ S",other:"Ctrl+Shift+S",description:"全部保存"},{mac:"⌘ W",other:"Ctrl+W",description:"关闭标签页"}]},{title:"搜索",shortcuts:[{mac:"⌘ F",other:"Ctrl+F",description:"在文件中查找"},{mac:"⌘ ⇧ F",other:"Ctrl+Shift+F",description:"在文件中搜索"},{mac:"⌘ G",other:"Ctrl+G",description:"跳转到行"}]},{title:"导航",shortcuts:[{mac:"⌘ ⇧ ]",other:"Ctrl+Shift+]",description:"下一个标签页"},{mac:"⌘ ⇧ [",other:"Ctrl+Shift+[",description:"上一个标签页"},{mac:"⌃ Tab",other:"Ctrl+Tab",description:"循环切换标签页"},{mac:"⌘ B",other:"Ctrl+B",description:"切换侧边栏"}]},{title:"编辑",shortcuts:[{mac:"⌘ Z",other:"Ctrl+Z",description:"撤销"},{mac:"⌘ ⇧ Z",other:"Ctrl+Y",description:"重做"},{mac:"⌘ D",other:"Ctrl+D",description:"选择下一个匹配项"},{mac:"⌘ /",other:"Ctrl+/",description:"切换注释"}]},{title:"Markdown",shortcuts:[{mac:"⌘ ⇧ M",other:"Ctrl+Shift+M",description:"拆分预览"},{mac:"⌘ ⇧ V",other:"Ctrl+Shift+V",description:"完整预览"}]},{title:"通用",shortcuts:[{mac:"Esc",other:"Esc",description:"关闭编辑器"}]}],yi=({onClose:t})=>{const n=s.useMemo(()=>ji.map(o=>({...o,shortcuts:o.shortcuts.map(r=>({keys:vn?r.mac:r.other,description:r.description}))})),[]);return e.jsx(Ae,{open:!0,onOpenChange:o=>!o&&t(),children:e.jsxs(Le,{className:"w-[480px] max-w-[480px]",children:[e.jsx(Oe,{children:e.jsx(ze,{className:"text-sm",children:"快捷键"})}),e.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-4",children:n.map(o=>e.jsxs("div",{children:[e.jsx("h3",{className:"mb-1.5 text-xs font-medium text-text-secondary",children:o.title}),e.jsx("div",{className:"space-y-1",children:o.shortcuts.map(r=>e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-text-muted",children:r.description}),e.jsx("kbd",{className:"rounded border border-border bg-surface-raised px-1.5 py-0.5 font-mono text-[10px] text-text-secondary",children:r.keys})]},r.keys))})]},o.title))})]})})},Ni=he.memo(function({line:n,col:o,language:r}){const{gitBranch:a,isGitRepo:c,watcherEnabled:x}=w(Re(u=>({gitBranch:u.editorGitBranch,isGitRepo:u.editorIsGitRepo,watcherEnabled:u.editorWatcherEnabled}))),l=w(u=>u.toggleWatcher);return e.jsxs("div",{className:"flex h-6 shrink-0 items-center justify-between border-t border-border bg-surface-sidebar px-3 text-[11px] text-text-muted",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("span",{children:["Ln ",n,", Col ",o]}),c&&a&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ar,{className:"size-3"}),a]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx("button",{type:"button",onClick:()=>void l(!x),className:`rounded px-1.5 py-0.5 text-[10px] font-medium transition-colors ${x?"bg-green-500/15 text-green-400 hover:bg-green-500/20":"text-text-muted hover:bg-surface-raised hover:text-text-secondary"}`,"aria-label":x?"Disable file watcher":"Enable file watcher","aria-pressed":x,children:x?"watching":"watch"})}),e.jsx(Y,{side:"top",children:x?"Disable external change watcher":"Watch for external changes"})]}),e.jsx("span",{children:r}),e.jsx("span",{children:"UTF-8"}),e.jsx("span",{children:"Spaces: 2"})]})]})}),wi=({children:t,tabId:n,tabIndex:o,totalTabs:r,onClose:a,onCloseOthers:c,onCloseToLeft:x,onCloseToRight:l,onCloseAll:u})=>{const i=o>0,f=o<r-1,d=r>1;return e.jsxs(ts,{children:[e.jsx(ns,{asChild:!0,children:e.jsx("div",{className:"flex h-full",children:t})}),e.jsx(ss,{children:e.jsxs(rs,{className:"z-50 min-w-[180px] rounded-md border border-border-emphasis bg-surface-overlay p-1 shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",children:[e.jsx(ee,{className:"flex cursor-pointer items-center rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:()=>a(n),children:"Close"}),e.jsx(ee,{className:"flex cursor-pointer items-center rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-40",disabled:!d,onSelect:()=>c(n),children:"Close Others"}),e.jsx(Te,{className:"my-1 h-px bg-border"}),e.jsx(ee,{className:"flex cursor-pointer items-center rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-40",disabled:!i,onSelect:()=>x(n),children:"Close Tabs to the Left"}),e.jsx(ee,{className:"flex cursor-pointer items-center rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-40",disabled:!f,onSelect:()=>l(n),children:"Close Tabs to the Right"}),e.jsx(Te,{className:"my-1 h-px bg-border"}),e.jsx(ee,{className:"flex cursor-pointer items-center rounded px-2 py-1.5 text-xs text-text outline-none hover:bg-surface-raised focus:bg-surface-raised",onSelect:u,children:"Close All"})]})})]})},Si=({onRequestCloseTab:t})=>{const{tabs:n,activeTabId:o,modifiedFiles:r}=w(Re(b=>({tabs:b.editorOpenTabs,activeTabId:b.editorActiveTabId,modifiedFiles:b.editorModifiedFiles}))),a=w(b=>b.setActiveEditorTab),c=w(b=>b.reorderEditorTabs),x=w(b=>b.closeOtherEditorTabs),l=w(b=>b.closeEditorTabsToLeft),u=w(b=>b.closeEditorTabsToRight),i=w(b=>b.closeAllEditorTabs),[f,d]=s.useState(null),m=s.useMemo(()=>n.map(b=>b.id),[n]),y=dn(un(mn,{activationConstraint:{distance:5}})),v=s.useCallback(b=>{const S=n.find(E=>E.id===b.active.id);d(S??null)},[n]),j=s.useCallback(b=>{d(null);const{active:S,over:E}=b;E&&S.id!==E.id&&c(String(S.id),String(E.id))},[c]),N=s.useCallback(()=>{d(null)},[]);return n.length===0?null:e.jsxs(fn,{sensors:y,collisionDetection:Lr,onDragStart:v,onDragEnd:j,onDragCancel:N,children:[e.jsx("div",{className:"flex h-8 shrink-0 items-center overflow-x-auto border-b border-border bg-surface-sidebar",role:"tablist",children:e.jsx(Or,{items:m,strategy:zr,children:n.map((b,S)=>e.jsx(Mi,{tab:b,tabIndex:S,totalTabs:n.length,isActive:b.id===o,isModified:!!r[b.filePath],onActivate:()=>a(b.id),onRequestClose:t,onCloseOthers:x,onCloseToLeft:l,onCloseToRight:u,onCloseAll:i},b.id))})}),e.jsx(hn,{dropAnimation:null,children:f&&e.jsx(ki,{tab:f})})]})},Mi=({tab:t,tabIndex:n,totalTabs:o,isActive:r,isModified:a,onActivate:c,onRequestClose:x,onCloseOthers:l,onCloseToLeft:u,onCloseToRight:i,onCloseAll:f})=>{const{attributes:d,listeners:m,setNodeRef:y,transform:v,transition:j,isDragging:N}=$r({id:t.id}),b={transform:Kr.Transform.toString(v),transition:N?"none":j,opacity:N?.3:1},S=L=>{L.stopPropagation(),x(t.id)},E=L=>{L.button===1&&(L.preventDefault(),x(t.id))};return e.jsx("div",{ref:y,style:b,className:"flex h-full shrink-0",...d,...m,children:e.jsx(wi,{tabId:t.id,tabIndex:n,totalTabs:o,onClose:x,onCloseOthers:l,onCloseToLeft:u,onCloseToRight:i,onCloseAll:f,children:e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsxs("button",{onClick:c,onAuxClick:E,role:"tab","aria-selected":r,className:`group flex h-full shrink-0 cursor-grab items-center gap-1.5 border-r border-border px-3 text-xs transition-colors ${r?"bg-surface text-text":"bg-surface-sidebar text-text-muted hover:bg-surface-raised hover:text-text-secondary"}`,children:[a&&e.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-amber-400","aria-label":"Unsaved changes"}),e.jsx(Be,{fileName:t.fileName,className:"size-3.5"}),e.jsxs("span",{className:"max-w-40 truncate",children:[t.fileName,t.disambiguatedLabel&&e.jsx("span",{className:"ml-1 text-text-muted",children:t.disambiguatedLabel})]}),e.jsx("span",{onClick:S,onPointerDown:L=>L.stopPropagation(),className:"ml-1 rounded p-0.5 opacity-0 transition-opacity hover:bg-surface-raised group-hover:opacity-100",role:"button","aria-label":`Close ${t.fileName}`,tabIndex:-1,children:e.jsx(tt,{className:"size-3"})})]})}),e.jsx(Y,{side:"bottom",children:t.filePath})]})})})},ki=({tab:t})=>e.jsxs("div",{className:"flex items-center gap-1.5 rounded border border-border-emphasis bg-surface-raised px-3 py-1 text-xs text-text shadow-lg",children:[e.jsx(Be,{fileName:t.fileName,className:"size-3.5"}),e.jsx("span",{className:"max-w-40 truncate",children:t.fileName})]}),Ti=({isMarkdown:t=!1,mdPreviewMode:n="off",onToggleSplit:o,onToggleFullPreview:r})=>{const{activeTabId:a,modifiedFiles:c,saving:x,lineWrap:l}=w(Re(j=>({activeTabId:j.editorActiveTabId,modifiedFiles:j.editorModifiedFiles,saving:j.editorSaving,lineWrap:j.editorLineWrap}))),u=w(j=>j.saveFile),i=w(j=>j.toggleLineWrap);if(!a)return null;const f=!!c[a],d=!!x[a],m=()=>{u(a)},y=()=>{const j=ye.getView();j&&sn(j)},v=()=>{const j=ye.getView();j&&rn(j)};return e.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-1 border-b border-border bg-surface px-2",children:[e.jsx(ke,{icon:e.jsx(Gr,{className:"size-3.5"}),label:"Save",shortcut:te("⌘ S","Ctrl+S"),onClick:m,disabled:!f||d}),e.jsx(ke,{icon:e.jsx(Br,{className:"size-3.5"}),label:"Undo",shortcut:te("⌘ Z","Ctrl+Z"),onClick:y}),e.jsx(ke,{icon:e.jsx(Ur,{className:"size-3.5"}),label:"Redo",shortcut:te("⌘ ⇧ Z","Ctrl+Y"),onClick:v}),e.jsx("div",{className:"mx-1 h-4 w-px bg-border"}),e.jsx(ke,{icon:e.jsx(bo,{className:"size-3.5"}),label:l?"Disable word wrap":"Enable word wrap",shortcut:te("⌘ ⇧ W","Ctrl+Shift+W"),onClick:i,active:l}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mx-1 h-4 w-px bg-border"}),e.jsx(ke,{icon:e.jsx(lo,{className:"size-3.5"}),label:n==="split"?"Close split preview":"Split preview",shortcut:te("⌘ ⇧ M","Ctrl+Shift+M"),onClick:o??(()=>{}),active:n==="split"}),e.jsx(ke,{icon:e.jsx(Vr,{className:"size-3.5"}),label:n==="preview"?"Close preview":"Full preview",shortcut:te("⌘ ⇧ V","Ctrl+Shift+V"),onClick:r??(()=>{}),active:n==="preview"})]})]})},ke=he.memo(function({icon:n,label:o,shortcut:r,onClick:a,disabled:c=!1,active:x=!1}){return e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx(I,{variant:"ghost",onClick:a,disabled:c,className:`h-auto gap-1 px-1.5 py-0.5 text-xs ${x?"bg-surface-raised text-text":"text-text-muted"}`,"aria-label":`${o} (${r})`,"aria-pressed":x,children:n})}),e.jsxs(Y,{side:"bottom",children:[o," (",r,")"]})]})});function Ei(t,n){const o=t.trim();if(!o)return null;const[r,a]=o.split(":"),c=a?parseInt(a,10):void 0;if(c!==void 0&&(isNaN(c)||c<1))return null;const x=r.trim();if(!x)return null;const l=n.state.doc.lines;if(x.endsWith("%")){const f=parseFloat(x.slice(0,-1));return isNaN(f)?null:{line:Math.max(1,Math.min(l,Math.round(f/100*l))),col:c}}if(x.startsWith("+")||x.startsWith("-")){const f=parseInt(x,10);if(isNaN(f))return null;const d=n.state.selection.main.head,m=n.state.doc.lineAt(d).number;return{line:Math.max(1,Math.min(l,m+f)),col:c}}const u=parseInt(x,10);return isNaN(u)?null:{line:Math.max(1,Math.min(l,u)),col:c}}const Ri=({onClose:t})=>{const[n,o]=s.useState(""),r=s.useRef(null);s.useEffect(()=>{r.current?.focus()},[]),s.useEffect(()=>{const i=f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),t())};return window.addEventListener("keydown",i,!0),()=>window.removeEventListener("keydown",i,!0)},[t]);const a=s.useCallback(()=>{const i=ye.getView();if(!i)return;const f=Ei(n,i);if(!f)return;const d=i.state.doc.line(f.line),m=f.col?Math.min(f.col-1,d.length):0,y=d.from+m;i.dispatch({selection:{anchor:y},effects:ge.scrollIntoView(y,{y:"center"})}),i.focus(),t()},[n,t]),c=s.useCallback(i=>{i.key==="Enter"&&(i.preventDefault(),a())},[a]),x=ye.getView(),l=x?.state.doc.lines??0,u=x?x.state.doc.lineAt(x.state.selection.main.head).number:0;return e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-start justify-center pt-[15vh]",children:[e.jsx("div",{className:"fixed inset-0 bg-black/40",onClick:t,onKeyDown:i=>{i.key==="Escape"&&t()},role:"presentation"}),e.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"跳转到行",className:"relative z-10 w-[360px] overflow-hidden rounded-lg border border-border-emphasis bg-surface shadow-2xl",children:e.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("span",{className:"text-xs text-text-secondary",children:["跳转到行"," ",e.jsxs("span",{className:"text-text-muted",children:["（当前：",u,"，总行数：",l,"）"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ht,{ref:r,className:"h-8 flex-1 bg-transparent text-sm",placeholder:"行号、+偏移、-偏移或百分比",value:n,onChange:i=>o(i.target.value),onKeyDown:c,spellCheck:!1,autoComplete:"off"}),e.jsx(I,{variant:"secondary",size:"sm",className:"h-8 px-4",onClick:a,disabled:!n.trim(),children:"跳转"})]})]})})]})},Ii=.2,Di=.8,Jt=4,Pi=he.memo(function({content:n,mode:o,splitRatio:r,onSplitRatioChange:a,viewKey:c,baseDir:x}){const[l,u]=s.useState(!1),i=s.useRef(null),f=Wr(o==="split",c),d=s.useCallback(j=>{const N=i.current?.parentElement;if(!N)return;const b=N.getBoundingClientRect(),S=j.clientX-b.left,E=Math.min(Di,Math.max(Ii,S/b.width));a(E)},[a]),m=s.useCallback(()=>{u(!1)},[]);s.useEffect(()=>{if(l)return document.addEventListener("mousemove",d),document.addEventListener("mouseup",m),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",m),document.body.style.cursor="",document.body.style.userSelect=""}},[l,d,m]);const y=j=>{j.preventDefault(),u(!0)},v=o==="preview"?"100%":`calc(${(1-r)*100}% - ${Jt}px)`;return e.jsxs("div",{ref:i,className:"flex h-full",style:{width:v},children:[o==="split"&&e.jsx("div",{className:`shrink-0 cursor-col-resize border-x border-border transition-colors ${l?"bg-blue-500/50":"hover:bg-blue-500/30"}`,style:{width:Jt},onMouseDown:y}),e.jsx("div",{className:"flex-1 overflow-hidden bg-surface",children:e.jsx(Hr,{content:n,scrollRef:f.previewScrollRef,onScroll:f.handlePreviewScroll,baseDir:x})})]})}),_i=({onClose:t,onSelectFile:n})=>{const o=w(d=>d.editorProjectPath),r=s.useRef(null),[a,c]=s.useState([]),[x,l]=s.useState(!0);s.useEffect(()=>{let d=!1;return l(!0),Ne.editor.listFiles().then(m=>{d||(c(m),l(!1))}).catch(()=>{d||l(!1)}),()=>{d=!0}},[o]);const u=s.useCallback(d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),t())},[t]);s.useEffect(()=>(window.addEventListener("keydown",u,!0),()=>window.removeEventListener("keydown",u,!0)),[u]);const i=s.useCallback(d=>{const m=a.find(y=>y.relativePath===d);m&&(n(m.path),t())},[a,n,t]),f=s.useMemo(()=>a.map(d=>({...d,iconInfo:Xr(d.name)})),[a]);return e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-start justify-center pt-[15vh]",children:[e.jsx("div",{className:"fixed inset-0 bg-black/40",onClick:t,onKeyDown:d=>{d.key==="Escape"&&t()},role:"presentation"}),e.jsx("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":"快速打开",className:"relative z-10 w-[520px] overflow-hidden rounded-lg border border-border-emphasis bg-surface shadow-2xl",children:e.jsxs(_e,{label:"快速打开",shouldFilter:!0,children:[e.jsx(_e.Input,{placeholder:"按文件名搜索...",className:"w-full border-b border-border bg-transparent px-4 py-3 text-sm text-text outline-none placeholder:text-text-muted",autoFocus:!0}),e.jsxs(_e.List,{className:"max-h-80 overflow-y-auto p-1",children:[x&&e.jsxs("div",{className:"flex items-center justify-center gap-2 p-6 text-sm text-text-muted",children:[e.jsx(nt,{className:"size-4 animate-spin"}),e.jsx("span",{children:"正在加载文件..."})]}),!x&&e.jsx(_e.Empty,{className:"p-6 text-center text-sm text-text-muted",children:"未找到文件"}),f.map(d=>{const m=d.iconInfo.icon;return e.jsxs(_e.Item,{value:d.relativePath,onSelect:()=>i(d.relativePath),className:"flex cursor-pointer items-center gap-2 rounded px-3 py-1.5 text-sm text-text-secondary aria-selected:bg-surface-raised aria-selected:text-text",children:[e.jsx(m,{className:"size-4 shrink-0",style:{color:d.iconInfo.color}}),e.jsx("span",{className:"truncate font-medium",children:d.name}),e.jsx("span",{className:"ml-auto truncate text-xs text-text-muted",children:d.relativePath})]},d.path)})]})]})})]})},Fi=300,Ai=({projectPath:t,onClose:n,onSelectMatch:o})=>{const[r,a]=s.useState(""),[c,x]=s.useState(!1),[l,u]=s.useState(null),[i,f]=s.useState(!1),[d,m]=s.useState(null),[y,v]=s.useState(new Set),j=s.useRef(null),N=s.useRef(void 0),b=s.useRef(0);s.useEffect(()=>{j.current?.focus()},[]),s.useEffect(()=>{const C=D=>{D.key==="Escape"&&(D.preventDefault(),D.stopPropagation(),n())};return window.addEventListener("keydown",C,!0),()=>window.removeEventListener("keydown",C,!0)},[n]);const S=s.useCallback(async(C,D)=>{if(!C.trim()){u(null),f(!1),m(null);return}const P=++b.current;f(!0),m(null);try{const k=await Ne.editor.searchInFiles({query:C,caseSensitive:D});if(b.current!==P)return;u(k);const z=new Set(k.results.slice(0,5).map(H=>H.filePath));v(z)}catch(k){if(b.current!==P)return;const z=k instanceof Error?k.message:String(k);m(z)}finally{b.current===P&&f(!1)}},[]),E=s.useCallback(C=>{a(C),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{S(C,c)},Fi)},[c,S]),L=s.useCallback(()=>{const C=!c;x(C),r.trim()&&(N.current&&clearTimeout(N.current),S(r,C))},[c,r,S]),O=s.useCallback(C=>{v(D=>{const P=new Set(D);return P.has(C)?P.delete(C):P.add(C),P})},[]),_=s.useCallback(C=>C.startsWith(t)?C.slice(t.length+1):C,[t]);return e.jsxs("div",{className:"flex h-full flex-col border-r border-border bg-surface-sidebar",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"在文件中搜索"}),e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"size-6 text-text-muted",onClick:n,"aria-label":"关闭搜索",children:e.jsx(tt,{className:"size-3.5"})})}),e.jsx(Y,{side:"bottom",children:"关闭搜索（Esc）"})]})]}),e.jsxs("div",{className:"border-b border-border p-2",children:[e.jsxs("div",{className:"flex items-center gap-1 rounded border border-border bg-surface px-2 py-1",children:[e.jsx(qr,{className:"size-3.5 shrink-0 text-text-muted"}),e.jsx("input",{ref:j,type:"text",value:r,onChange:C=>E(C.target.value),placeholder:"搜索...",className:"flex-1 bg-transparent text-xs text-text outline-none placeholder:text-text-muted"}),i&&e.jsx(nt,{className:"size-3 shrink-0 animate-spin text-text-muted"})]}),e.jsx("div",{className:"mt-1.5 flex items-center gap-2",children:e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx("button",{onClick:L,className:`rounded px-1.5 py-0.5 text-[10px] font-medium transition-colors ${c?"bg-blue-500/20 text-blue-400":"text-text-muted hover:bg-surface-raised"}`,"aria-label":"区分大小写","aria-pressed":c,children:"Aa"})}),e.jsx(Y,{side:"bottom",children:"区分大小写"})]})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[d&&e.jsx("div",{className:"p-3 text-xs text-red-400",children:d}),l?.totalMatches===0&&r.trim()&&e.jsx("div",{className:"p-4 text-center text-xs text-text-muted",children:"未找到结果"}),l&&l.totalMatches>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-b border-border px-3 py-1.5 text-[10px] text-text-muted",children:[l.results.length," 个文件中有 ",l.totalMatches," 个匹配",l.truncated&&"（已截断）"]}),l.results.map(C=>e.jsx(Li,{fileResult:C,relativePath:_(C.filePath),expanded:y.has(C.filePath),onToggle:()=>O(C.filePath),onSelectMatch:D=>o(C.filePath,D),query:r,caseSensitive:c},C.filePath))]})]})]})},Li=({fileResult:t,relativePath:n,expanded:o,onToggle:r,onSelectMatch:a,query:c,caseSensitive:x})=>{const l=Ee(n)||n,u=Ze(n),i=u>=0?n.slice(0,u):"";return e.jsxs("div",{className:"border-border/50 border-b",children:[e.jsxs("button",{onClick:r,className:"flex w-full items-center gap-1.5 px-3 py-1 text-left transition-colors hover:bg-surface-raised",children:[e.jsx("span",{className:"text-[10px] text-text-muted",children:o?"▼":"▶"}),e.jsx(Be,{fileName:l,className:"size-3.5"}),e.jsx("span",{className:"truncate text-xs font-medium text-text",children:l}),i&&e.jsx("span",{className:"ml-1 truncate text-[10px] text-text-muted",children:i}),e.jsx("span",{className:"ml-auto shrink-0 text-[10px] text-text-muted",children:t.matches.length})]}),o&&e.jsx("div",{className:"pb-1",children:t.matches.map((f,d)=>e.jsxs("button",{onClick:()=>a(f.line),className:"flex w-full items-center gap-2 px-6 py-0.5 text-left transition-colors hover:bg-surface-raised",children:[e.jsx("span",{className:"w-8 shrink-0 text-right text-[10px] text-text-muted",children:f.line}),e.jsx(Oi,{text:f.lineContent,query:c,caseSensitive:x})]},`${f.line}-${d}`))})]})},Oi=he.memo(function({text:n,query:o,caseSensitive:r}){if(!o)return e.jsx("span",{className:"truncate text-[11px] text-text-secondary",children:n});const a=r?n:n.toLowerCase(),c=r?o:o.toLowerCase(),x=[];let l=0,u=a.indexOf(c);for(;u!==-1;)u>l&&x.push(e.jsx("span",{className:"text-text-secondary",children:n.slice(l,u)},`t-${l}`)),x.push(e.jsx("span",{className:"rounded bg-yellow-500/30 text-yellow-200",children:n.slice(u,u+o.length)},`h-${u}`)),l=u+o.length,u=a.indexOf(c,l);return l<n.length&&x.push(e.jsx("span",{className:"text-text-secondary",children:n.slice(l)},`t-${l}`)),e.jsx("span",{className:"truncate text-[11px]",children:x})}),Gi=({projectPath:t,onClose:n,onEditorAction:o})=>{const{activeTabId:r,openTabs:a,modifiedFiles:c,saveErrors:x,externalChanges:l,conflictFile:u}=w(Re(h=>({activeTabId:h.editorActiveTabId,openTabs:h.editorOpenTabs,modifiedFiles:h.editorModifiedFiles,saveErrors:h.editorSaveError,externalChanges:h.editorExternalChanges,conflictFile:h.editorConflictFile}))),i=w(h=>h.openEditor),f=w(h=>h.closeEditor),d=w(h=>h.openFile),m=w(h=>h.closeEditorTab),y=w(h=>h.saveFile),v=w(h=>h.hasUnsavedChanges),j=w(h=>h.saveAllFiles),N=w(h=>h.discardChanges),b=w(h=>h.clearExternalChange),S=w(h=>h.forceOverwrite),E=w(h=>h.resolveConflict),L=w(h=>h.setFileMtime),O=w(h=>h.fetchGitStatus),[_,C]=s.useState(null),[D,P]=s.useState(!1),[k,z]=s.useState(null),[H,ce]=s.useState(1),[ae,le]=s.useState(1),[T,U]=s.useState(!1),[K,p]=s.useState(null),[R,F]=s.useState(null),[W,ie]=s.useState(0),[ne,de]=s.useState(null),se=s.useRef(null),[V,ue]=s.useState(()=>new DOMRect),[Z,fe]=s.useState("off"),[Me,be]=s.useState(""),[ve,re]=s.useState(()=>{try{const h=localStorage.getItem("editor:mdSplitRatio");return h?Math.max(.2,Math.min(.8,Number(h))):.5}catch{return .5}}),[me,We]=s.useState(!1),[Ce,He]=s.useState(!1),[g,M]=s.useState(!1),[A,B]=s.useState(!1),[je,Xe]=s.useState(()=>{try{return localStorage.getItem("editor-sidebar-visible")!=="false"}catch{return!0}}),kt=s.useRef(null),at=s.useRef(new Map),it=a.find(h=>h.id===r)??null,De=it?.language==="Markdown";s.useEffect(()=>{fe(De?h=>h==="off"?"split":h:"off")},[De,r]);const us=s.useCallback(h=>{re(h);try{localStorage.setItem("editor:mdSplitRatio",String(h))}catch{}},[]),xs=s.useCallback(h=>{be(h)},[]),Tt=s.useCallback(()=>{fe(h=>h==="split"?"off":"split")},[]),Et=s.useCallback(()=>{fe(h=>h==="preview"?"off":"preview")},[]);s.useEffect(()=>{Z!=="off"&&_?.content&&be(_.content)},[Z,_?.content]);const fs=Me||_?.content||"",pe=s.useCallback(async h=>{P(!0),z(null),C(null);try{const G=performance.now();let J=at.current.get(h);const Rs=!!J;J||(J=Ne.editor.readFile(h),at.current.set(h,J),J.finally(()=>at.current.delete(h)));const Pe=await J,Is=performance.now()-G;console.debug(`[perf] loadFileContent: IPC=${Is.toFixed(1)}ms, size=${Pe.size}, truncated=${Pe.truncated}, cached=${Rs}, file=${Ee(h)}`),C(Pe),Pe.mtimeMs&&L(h,Pe.mtimeMs)}catch(G){const J=G instanceof Error?G.message:String(G);z(J)}finally{P(!1)}},[L]),Rt=r?x[r]??null:null,ct=w(h=>h.editorPendingRevealFile),It=w(h=>h.revealAndOpenFile);s.useEffect(()=>(i(t),()=>{f()}),[t,i,f]);const Dt=w(h=>h.editorFileTreeLoading),Pt=w(h=>h.editorFileTree!==null);s.useEffect(()=>{ct&&!Dt&&Pt&&It(ct)},[ct,Dt,Pt,It]),s.useEffect(()=>{const h=se.current;if(!h)return;const G=()=>ue(h.getBoundingClientRect());G();const J=new ResizeObserver(G);return J.observe(h),()=>J.disconnect()},[]),s.useEffect(()=>{const h=G=>{if(G.key==="Escape"){if(G.defaultPrevented||me||Ce||A||T||K||u)return;G.preventDefault(),lt()}G.key==="F5"&&(G.preventDefault(),zt())};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[me,Ce,A,T,K,u]),s.useEffect(()=>{kt.current?.focus()},[]),s.useEffect(()=>{if(de(null),!r){C(null),P(!1),z(null);return}pe(r)},[r,pe]),s.useEffect(()=>{r!==R&&F(null)},[r,R]);const _t=s.useCallback(h=>{d(h)},[d]),Ft=s.useCallback(()=>{r&&pe(r)},[r,pe]),hs=s.useCallback((h,G)=>{ce(h),le(G)},[]),lt=s.useCallback(()=>{v()?U(!0):n()},[n,v]),ms=s.useCallback(async()=>{await j(),U(!1),n()},[j,n]),ps=s.useCallback(()=>{U(!1),n()},[n]),At=s.useCallback(()=>{U(!1)},[]),dt=s.useCallback(h=>{c[h]?p(h):m(h)},[c,m]);s.useEffect(()=>{const h=G=>{const J=G.detail;dt(J)};return window.addEventListener("editor-close-tab",h),()=>window.removeEventListener("editor-close-tab",h)},[dt]);const gs=s.useCallback(async()=>{K&&(await y(K),m(K),p(null))},[K,y,m]),bs=s.useCallback(()=>{K&&(m(K),p(null))},[K,m]),Lt=s.useCallback(()=>{p(null)},[]),vs=s.useCallback(h=>{F(h)},[]),Cs=s.useCallback(()=>{!R||!r||(N(R),F(null),C(null),ie(h=>h+1),pe(r))},[R,r,N,pe]),js=s.useCallback(()=>{F(null)},[]),ys=s.useCallback(()=>{u&&S(u)},[u,S]),Ot=s.useCallback(()=>{E()},[E]),Ns=s.useCallback(()=>{r&&(b(r),N(r),C(null),ie(h=>h+1),pe(r))},[r,b,N,pe]),ws=s.useCallback(()=>{r&&b(r)},[r,b]),zt=s.useCallback(()=>{O()},[O]),Ss=s.useCallback(()=>{We(h=>!h)},[]),Ms=s.useCallback(()=>{He(h=>!h)},[]),ks=s.useCallback(()=>{M(h=>!h)},[]),ut=s.useCallback(()=>{Xe(h=>{const G=!h;try{localStorage.setItem("editor-sidebar-visible",String(G))}catch{}return G})},[]),$t=w(h=>h.setPendingGoToLine),Ts=s.useCallback((h,G)=>{$t(G),d(h)},[d,$t]);yo({onToggleQuickOpen:Ss,onToggleSearchPanel:Ms,onToggleGoToLine:ks,onToggleSidebar:ut,onClose:lt,onToggleMdSplit:De?Tt:void 0,onToggleMdPreview:De?Et:void 0});const Es=Ee(t)||t;return e.jsxs("div",{ref:kt,className:"fixed inset-0 z-50 m-0 flex h-screen w-screen flex-col overflow-hidden border-0 bg-surface",tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"项目编辑器",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between border-b border-border px-3",style:{paddingLeft:"var(--macos-traffic-light-padding-left, 72px)"},children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-secondary",children:[e.jsx("span",{className:"font-medium text-text",children:Es}),e.jsx("span",{className:"text-text-muted",children:t})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"size-7 text-text-muted",onClick:zt,"aria-label":"刷新（F5）",children:e.jsx(Ut,{className:"size-4"})})}),e.jsx(Y,{side:"bottom",children:"刷新 Git 状态（F5）"})]}),e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"size-7 text-text-muted",onClick:()=>B(!0),"aria-label":"快捷键",children:e.jsx(Yr,{className:"size-4"})})}),e.jsx(Y,{side:"bottom",children:"快捷键"})]}),e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"size-7 text-text-muted",onClick:lt,"aria-label":"关闭编辑器",children:e.jsx(tt,{className:"size-4"})})}),e.jsx(Y,{side:"bottom",children:"关闭编辑器（Esc）"})]})]})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[Ce&&e.jsx("div",{className:"w-72 shrink-0",children:e.jsx(Ai,{projectPath:t,onClose:()=>He(!1),onSelectMatch:Ts})}),je&&!Ce&&e.jsxs("div",{className:"flex w-60 shrink-0 flex-col border-r border-border bg-surface-sidebar",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border px-2 py-1",children:[e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-wider text-text-muted",children:"资源管理器"}),e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx(I,{variant:"ghost",size:"icon",className:"size-6 text-text-muted",onClick:ut,"aria-label":"隐藏侧边栏",children:e.jsx(Qr,{className:"size-3.5"})})}),e.jsxs(Y,{side:"bottom",children:["隐藏侧边栏（",te("⌘ B","Ctrl+B"),"）"]})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(mi,{selectedFilePath:r,onFileSelect:_t,onSendMessage:o?h=>o(Zr("sendMessage",h,t)):void 0})})]}),!je&&!Ce&&e.jsxs(X,{children:[e.jsx(q,{asChild:!0,children:e.jsx(I,{variant:"ghost",className:"flex h-full w-6 shrink-0 items-start justify-center rounded-none border-r border-border bg-surface-sidebar pt-2 text-text-muted",onClick:ut,"aria-label":"显示侧边栏",children:e.jsx(Jr,{className:"size-3.5"})})}),e.jsxs(Y,{side:"right",children:["显示侧边栏（",te("⌘ B","Ctrl+B"),"）"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx(Si,{onRequestCloseTab:dt}),e.jsx(Ti,{isMarkdown:De,mdPreviewMode:Z,onToggleSplit:Tt,onToggleFullPreview:Et}),R&&r===R&&e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b px-3 py-1.5 text-xs",style:{backgroundColor:"var(--warning-bg)",borderColor:"var(--warning-border)",color:"var(--warning-text)"},children:[e.jsx(eo,{className:"size-3.5 shrink-0"}),e.jsx("span",{children:"已从上次会话恢复未保存的更改。"}),e.jsx(I,{variant:"ghost",size:"sm",className:"ml-auto h-auto px-2 py-0.5",onClick:js,children:"保留"}),e.jsx(I,{variant:"destructive",size:"sm",className:"h-auto px-2 py-0.5",onClick:Cs,children:"丢弃"})]}),Rt&&e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-red-500/30 bg-red-500/10 px-3 py-1.5 text-xs text-red-300",children:[e.jsx(pt,{className:"size-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:["保存失败：",Rt]}),e.jsx(I,{variant:"ghost",size:"sm",className:"ml-auto h-auto shrink-0 px-2 py-0.5",onClick:()=>r&&void y(r),children:"重试"})]}),r&&l[r]&&e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-blue-400/30 bg-blue-100/50 px-3 py-1.5 text-xs text-blue-700 dark:border-blue-500/30 dark:bg-blue-500/10 dark:text-blue-300",children:[e.jsx(Ut,{className:"size-3.5 shrink-0"}),e.jsx("span",{children:l[r]==="delete"?"文件已从磁盘中删除。":"文件已在磁盘上被修改。"}),l[r]==="delete"?e.jsx(I,{variant:"ghost",size:"sm",className:"ml-auto h-auto px-2 py-0.5",onClick:()=>m(r),children:"关闭标签页"}):e.jsxs(e.Fragment,{children:[e.jsx(I,{variant:"ghost",size:"sm",className:"ml-auto h-auto px-2 py-0.5",onClick:Ns,children:"重新加载"}),e.jsx(I,{variant:"ghost",size:"sm",className:"h-auto px-2 py-0.5",onClick:ws,children:"保留我的版本"})]})]}),e.jsxs("div",{ref:se,className:"relative flex-1 overflow-hidden",children:[D&&e.jsx("div",{className:"flex h-full items-center justify-center text-text-muted",children:e.jsx(nt,{className:"size-5 animate-spin"})}),k&&e.jsx(Ho,{error:k,onRetry:Ft}),_?.isBinary&&r&&e.jsx(Bo,{filePath:r,size:_.size}),_&&!_.isBinary&&r&&e.jsxs("div",{className:"flex h-full",children:[e.jsx("div",{className:"h-full overflow-hidden",style:{display:Z==="preview"?"none":"block",width:Z==="split"?`${ve*100}%`:"100%"},children:e.jsx(Wo,{filePath:r,onRetry:Ft,children:e.jsx(Lo,{filePath:r,content:_.content,fileName:Ee(r)||"file",mtimeMs:_.mtimeMs,onCursorChange:hs,onDraftRecovered:vs,onSelectionChange:de,onDocChange:Z!=="off"?xs:void 0},`${r}-${W}`)})}),Z!=="off"&&e.jsx(Pi,{content:fs,mode:Z,splitRatio:ve,onSplitRatioChange:us,viewKey:r,baseDir:r?to(r):void 0})]}),!D&&!k&&!_&&!r&&e.jsx(Vo,{}),ne&&o&&e.jsx(vi,{info:ne,containerRect:V,onSendMessage:()=>{o(no("sendMessage",ne)),de(null)}})]}),it&&e.jsx(Ni,{line:H,col:ae,language:it.language})]})]}),me&&e.jsx(_i,{onClose:()=>We(!1),onSelectFile:_t}),g&&e.jsx(Ri,{onClose:()=>M(!1)}),A&&e.jsx(yi,{onClose:()=>B(!1)}),e.jsx(Ae,{open:T,onOpenChange:h=>!h&&At(),children:e.jsxs(Le,{className:"w-96 max-w-96",children:[e.jsxs(Oe,{children:[e.jsx(ze,{className:"text-sm",children:"未保存的更改"}),e.jsx(Ye,{children:"你有未保存的更改。要如何处理？"})]}),e.jsxs(Qe,{children:[e.jsx(I,{variant:"ghost",size:"sm",onClick:At,children:"取消"}),e.jsx(I,{variant:"destructive",size:"sm",onClick:ps,children:"丢弃并关闭"}),e.jsx(I,{size:"sm",onClick:()=>void ms(),children:"全部保存并关闭"})]})]})}),e.jsx(Ae,{open:!!u,onOpenChange:h=>!h&&Ot(),children:e.jsxs(Le,{className:"w-96 max-w-96",children:[e.jsxs(Oe,{children:[e.jsx(ze,{className:"text-sm",children:"保存冲突"}),e.jsx(Ye,{children:"该文件在打开后被外部修改。是否用你的更改覆盖？"})]}),e.jsxs(Qe,{children:[e.jsx(I,{variant:"ghost",size:"sm",onClick:Ot,children:"取消"}),e.jsx(I,{variant:"destructive",size:"sm",onClick:ys,children:"覆盖"})]})]})}),e.jsx(Ae,{open:!!K,onOpenChange:h=>!h&&Lt(),children:e.jsxs(Le,{className:"w-96 max-w-96",children:[e.jsxs(Oe,{children:[e.jsx(ze,{className:"text-sm",children:"未保存的更改"}),e.jsx(Ye,{children:"此文件有未保存的更改。要如何处理？"})]}),e.jsxs(Qe,{children:[e.jsx(I,{variant:"ghost",size:"sm",onClick:Lt,children:"取消"}),e.jsx(I,{variant:"destructive",size:"sm",onClick:bs,children:"丢弃"}),e.jsx(I,{size:"sm",onClick:()=>void gs(),children:"保存"})]})]})})]})};export{Gi as ProjectEditorOverlay};
