tide-commander 1.181.0 → 1.182.0

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.
Files changed (151) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +21 -1
  3. package/dist/assets/{AudioPlayer-BAtnEqGO.js → AudioPlayer-BwhOjJ2c.js} +1 -1
  4. package/dist/assets/{BossLogsModal-DKPlKlOF.js → BossLogsModal-DAHZQ1pi.js} +1 -1
  5. package/dist/assets/BossSpawnModal-E7SGuXA2.js +1 -0
  6. package/dist/assets/ControlsModal-bAaYejMT.js +1 -0
  7. package/dist/assets/{DockerLogsModal-hn265l_A.js → DockerLogsModal-BJx8N4kK.js} +1 -1
  8. package/dist/assets/{EmbeddedEditor-Cj5jPNh6.js → EmbeddedEditor-Be-cO4-9.js} +1 -1
  9. package/dist/assets/{FcStdViewer-CFxBBNQq.js → FcStdViewer-DEwQ08Bb.js} +1 -1
  10. package/dist/assets/{GcodeViewer-3z7qkN29.js → GcodeViewer-ncf61wWb.js} +1 -1
  11. package/dist/assets/{GlbViewer-CaOGrb_f.js → GlbViewer-D12gmnGd.js} +1 -1
  12. package/dist/assets/{GmailOAuthSetup-Bk6jecTI.js → GmailOAuthSetup-C-GvDGQm.js} +1 -1
  13. package/dist/assets/{GoogleOAuthSetup-DVeeuuWe.js → GoogleOAuthSetup-BDjIAgur.js} +1 -1
  14. package/dist/assets/{IframeModal-wSJPMjiR.js → IframeModal-CCocGfa7.js} +1 -1
  15. package/dist/assets/{IntegrationsPanel-BorSz1f6.js → IntegrationsPanel-CBpaeiJG.js} +2 -2
  16. package/dist/assets/{LogViewerModal-Bc_8Tjwp.js → LogViewerModal-CaN7XU8z.js} +1 -1
  17. package/dist/assets/{MonitoringModal-_K-xK58O.js → MonitoringModal-I3nCNlbU.js} +1 -1
  18. package/dist/assets/{PM2LogsModal-RP5kh78y.js → PM2LogsModal-Bki_LCvj.js} +1 -1
  19. package/dist/assets/RestoreArchivedAreaModal-Ciy6t7et.js +1 -0
  20. package/dist/assets/{Scene2DCanvas-BD8gC5GG.js → Scene2DCanvas-DR56E5p7.js} +1 -1
  21. package/dist/assets/{SceneManager-B1FWKQrV.js → SceneManager-DKg8ugY_.js} +1 -1
  22. package/dist/assets/{SkillsPanel-B3sV8qgJ.js → SkillsPanel-C_dxzS6F.js} +2 -2
  23. package/dist/assets/{SlackMultiInstanceSetup-By9kD-7V.js → SlackMultiInstanceSetup-BwiTMMvL.js} +1 -1
  24. package/dist/assets/SpawnModal-DUMcIHoz.js +1 -0
  25. package/dist/assets/{StatisticsModal-k-Zow1Lc.js → StatisticsModal-BKXcBthy.js} +1 -1
  26. package/dist/assets/{StlViewer-CvwylgqD.js → StlViewer-DjdLvysP.js} +1 -1
  27. package/dist/assets/{SubordinateAssignmentModal-BgZoihF2.js → SubordinateAssignmentModal-Rl4cdHpe.js} +1 -1
  28. package/dist/assets/{ThreeAreaSelector-CBoLZACl.js → ThreeAreaSelector-C-9JJ1Hh.js} +1 -1
  29. package/dist/assets/{ThreeViewShortcuts-CwWPyQ1I.js → ThreeViewShortcuts-DL0Hmuj0.js} +1 -1
  30. package/dist/assets/{TriggerManagerPanel-8dCnF4zG.js → TriggerManagerPanel-BtCOoX1g.js} +1 -1
  31. package/dist/assets/{VideoPlayer-CFfNly_q.js → VideoPlayer-BoTr9gkT.js} +1 -1
  32. package/dist/assets/{WorkflowEditorPanel-DaoqmmDI.js → WorkflowEditorPanel-DlcSaDPD.js} +1 -1
  33. package/dist/assets/{abnfDiagram-VRR7QNED-AVCJRSGv.js → abnfDiagram-VRR7QNED-CEBRXYsw.js} +1 -1
  34. package/dist/assets/{arc-BozrtqGC.js → arc-COf9R405.js} +1 -1
  35. package/dist/assets/{architectureDiagram-ZJ3FMSHR-DIbqkKKH.js → architectureDiagram-ZJ3FMSHR-DGBRfu4B.js} +1 -1
  36. package/dist/assets/{area-logos-_xssrP4-.js → area-logos-BRuKyQ5J.js} +1 -1
  37. package/dist/assets/{blockDiagram-677ZJIJ3-cUooA8WG.js → blockDiagram-677ZJIJ3-CN0t4U2k.js} +1 -1
  38. package/dist/assets/{c4Diagram-LMCZKHZV-BN-pAlnh.js → c4Diagram-LMCZKHZV-Cq0IftW5.js} +1 -1
  39. package/dist/assets/channel-DF_pUJhw.js +1 -0
  40. package/dist/assets/{chunk-2Q5K7J3B-Df3QaYQM.js → chunk-2Q5K7J3B-adR2VoGA.js} +1 -1
  41. package/dist/assets/{chunk-32BRIVSS-eWsLMUAK.js → chunk-32BRIVSS-B6LCChZq.js} +1 -1
  42. package/dist/assets/{chunk-5VM5RSS4-D8L5MdGs.js → chunk-5VM5RSS4-CcH2c7y_.js} +1 -1
  43. package/dist/assets/{chunk-EX3LRPZG-D9F-m38t.js → chunk-EX3LRPZG-zBWa-mu2.js} +1 -1
  44. package/dist/assets/{chunk-JWPE2WC7-CTPQZilc.js → chunk-JWPE2WC7-DBQlYiWn.js} +1 -1
  45. package/dist/assets/{chunk-MOJQB5TN-BI5XLi89.js → chunk-MOJQB5TN-BjbsCplS.js} +1 -1
  46. package/dist/assets/{chunk-RYQCIY6F-aUw8CA0H.js → chunk-RYQCIY6F-B946ZxlN.js} +1 -1
  47. package/dist/assets/{chunk-V7JOEXUC-Bvn63xfp.js → chunk-V7JOEXUC-DEeYHnRT.js} +1 -1
  48. package/dist/assets/{chunk-VR4S4FIN-DuQCapS-.js → chunk-VR4S4FIN-B_QmrVGt.js} +1 -1
  49. package/dist/assets/{chunk-XXDRQBXY--Q2M75o8.js → chunk-XXDRQBXY-cgYh6YrW.js} +1 -1
  50. package/dist/assets/classDiagram-OUVF2IWQ-CeYNs9YM.js +1 -0
  51. package/dist/assets/classDiagram-v2-EOCWNBFH-CeYNs9YM.js +1 -0
  52. package/dist/assets/{cose-bilkent-JH36ORCC-CnOCRlHl.js → cose-bilkent-JH36ORCC-DJUmw0Ip.js} +1 -1
  53. package/dist/assets/{cynefin-VYW2F7L2-CVOENzFv.js → cynefin-VYW2F7L2-BUxR220i.js} +1 -1
  54. package/dist/assets/{cynefinDiagram-TSTJHNR4-BLe8BxZL.js → cynefinDiagram-TSTJHNR4-nYR1MwE2.js} +1 -1
  55. package/dist/assets/{dagre-VKFMJZFB-xtW7I5Nk.js → dagre-VKFMJZFB-A5VPim2l.js} +1 -1
  56. package/dist/assets/{diagram-FQU43EPY-BIr_QEk-.js → diagram-FQU43EPY-wdgwDoVg.js} +1 -1
  57. package/dist/assets/{diagram-G47NLZAW-BJd55qXW.js → diagram-G47NLZAW-CylyJQBQ.js} +1 -1
  58. package/dist/assets/{diagram-NH7WQ7WH-CZsKPct7.js → diagram-NH7WQ7WH-BOF1uKhH.js} +1 -1
  59. package/dist/assets/{diagram-OA4YK3LP-BaG39QNH.js → diagram-OA4YK3LP-B0B5zmh5.js} +1 -1
  60. package/dist/assets/{diagram-WEI45ONY-ShUVdCXz.js → diagram-WEI45ONY-vKP2IU9q.js} +1 -1
  61. package/dist/assets/{ebnfDiagram-CCIWWBDH-T9Sx10gP.js → ebnfDiagram-CCIWWBDH-DM8hIEJM.js} +1 -1
  62. package/dist/assets/{erDiagram-Q63AITRT-CwT0KHCH.js → erDiagram-Q63AITRT-iuRH3hWX.js} +1 -1
  63. package/dist/assets/{flowDiagram-23GEKE2U-DpfmSS0V.js → flowDiagram-23GEKE2U-CddCUoGB.js} +1 -1
  64. package/dist/assets/{ganttDiagram-NO4QXBWP-DFHqNARc.js → ganttDiagram-NO4QXBWP-CIfvQLcu.js} +1 -1
  65. package/dist/assets/{gitGraphDiagram-IHSO6WYX-DiG1nj1m.js → gitGraphDiagram-IHSO6WYX-CbW0FQci.js} +1 -1
  66. package/dist/assets/index-B4YklnOy.js +1 -0
  67. package/dist/assets/{index-CeUo--0k.js → index-BmD7ycmn.js} +1 -1
  68. package/dist/assets/{index-B8WCuK1N.js → index-CIcFjlRX.js} +2 -2
  69. package/dist/assets/{index-BMINDCB0.js → index-CRhUiTuD.js} +3 -3
  70. package/dist/assets/{index-COqQ_1sL.css → index-D1GfjaTN.css} +1 -1
  71. package/dist/assets/index-DHuT10Pa.js +1 -0
  72. package/dist/assets/{index-BmmzETKL.js → index-DoJdznbY.js} +5 -5
  73. package/dist/assets/index-Du8eK_OX.js +1 -0
  74. package/dist/assets/index-HYcYan1q.js +19 -0
  75. package/dist/assets/index-HhAZ3SIm.js +2 -0
  76. package/dist/assets/{infoDiagram-FWYZ7A6U-CT7RBQSN.js → infoDiagram-FWYZ7A6U-C0it9hLc.js} +1 -1
  77. package/dist/assets/{ishikawaDiagram-FXEZZL3T-Bv_eTPfi.js → ishikawaDiagram-FXEZZL3T-pKZnNgqp.js} +1 -1
  78. package/dist/assets/{journeyDiagram-5HDEW3XC-BwKya-ih.js → journeyDiagram-5HDEW3XC-Ib9FpXdB.js} +1 -1
  79. package/dist/assets/{kanban-definition-HUTT4EX6-VrWxcMn7.js → kanban-definition-HUTT4EX6-aOTfe6f6.js} +1 -1
  80. package/dist/assets/{linear-BsocX-C-.js → linear-B_ipWlyx.js} +1 -1
  81. package/dist/assets/main-Bvn8CMZc.css +1 -0
  82. package/dist/assets/{main-B9DphKOa.js → main-m3NNcAo4.js} +115 -115
  83. package/dist/assets/{mermaid.core-Uz36XO2-.js → mermaid.core-EY9hyXLz.js} +4 -4
  84. package/dist/assets/{mindmap-definition-LN4V7U3C-Bv9DlPAr.js → mindmap-definition-LN4V7U3C-B_p1LOAa.js} +1 -1
  85. package/dist/assets/{pegDiagram-2B236MQR-CRG-2pCa.js → pegDiagram-2B236MQR-BgCd9rWg.js} +1 -1
  86. package/dist/assets/{pieDiagram-ENE6RG2P-dkVFz981.js → pieDiagram-ENE6RG2P-d8ofNooq.js} +1 -1
  87. package/dist/assets/{quadrantDiagram-ABIIQ3AL-D6Y-oPfA.js → quadrantDiagram-ABIIQ3AL-27DPJdZF.js} +1 -1
  88. package/dist/assets/{railroadDiagram-RFXS5EU6-DnBPGcSS.js → railroadDiagram-RFXS5EU6-C7S8pppU.js} +1 -1
  89. package/dist/assets/{requirementDiagram-TGXJPOKE-BfXBQgDX.js → requirementDiagram-TGXJPOKE-BbTkDbLO.js} +1 -1
  90. package/dist/assets/{sankeyDiagram-HTMAVEWB-B2plq2xb.js → sankeyDiagram-HTMAVEWB-lU57KWVw.js} +1 -1
  91. package/dist/assets/{sequenceDiagram-DBY2YBRQ-5HYSSRy3.js → sequenceDiagram-DBY2YBRQ-Bg18P0LT.js} +1 -1
  92. package/dist/assets/{sizeCapture-X5ZJPWSS-Dhd1V1RM.js → sizeCapture-X5ZJPWSS-FDhyxAiu.js} +1 -1
  93. package/dist/assets/{stateDiagram-2N3HPSRC-BawpJoTz.js → stateDiagram-2N3HPSRC-pp9KUH2d.js} +1 -1
  94. package/dist/assets/stateDiagram-v2-6OUMAXLB-BmoS7QDQ.js +1 -0
  95. package/dist/assets/{swimlanes-5IMT3BWC-BYunKpK9.js → swimlanes-5IMT3BWC-BCUZKORl.js} +2 -2
  96. package/dist/assets/swimlanesDiagram-G3AALYLV-Da6QbdiL.js +8 -0
  97. package/dist/assets/{timeline-definition-FHXFAJF6-BA1n8ny7.js → timeline-definition-FHXFAJF6-BaeOwVlH.js} +1 -1
  98. package/dist/assets/{vennDiagram-L72KCM5P-DfSgfnDb.js → vennDiagram-L72KCM5P-BkhqU_hz.js} +1 -1
  99. package/dist/assets/{wardleyDiagram-EHGQE667-Ccum1Sj1.js → wardleyDiagram-EHGQE667-DvPxIC6q.js} +1 -1
  100. package/dist/assets/{web-24bQZmaT.js → web-BhVPxATx.js} +1 -1
  101. package/dist/assets/{web-CDfC-TTs.js → web-CR-app3U.js} +1 -1
  102. package/dist/assets/{web-C4jAxolp.js → web-DOiXCdVs.js} +1 -1
  103. package/dist/assets/{xychartDiagram-FW5EYKEG-CZKJCuVt.js → xychartDiagram-FW5EYKEG-B9MrBAD_.js} +1 -1
  104. package/dist/build-info.json +1 -1
  105. package/dist/index.html +2 -2
  106. package/dist/locales/de/config.json +5 -0
  107. package/dist/locales/de/terminal.json +1 -0
  108. package/dist/locales/en/config.json +5 -0
  109. package/dist/locales/en/terminal.json +2 -0
  110. package/dist/locales/es/config.json +5 -0
  111. package/dist/locales/es/terminal.json +11 -0
  112. package/dist/locales/fr/config.json +5 -0
  113. package/dist/locales/fr/terminal.json +1 -0
  114. package/dist/locales/hi/config.json +5 -0
  115. package/dist/locales/hi/terminal.json +1 -0
  116. package/dist/locales/it/config.json +5 -0
  117. package/dist/locales/it/terminal.json +1 -0
  118. package/dist/locales/ja/config.json +5 -0
  119. package/dist/locales/ja/terminal.json +1 -0
  120. package/dist/locales/pt/config.json +5 -0
  121. package/dist/locales/pt/terminal.json +1 -0
  122. package/dist/locales/ru/config.json +5 -0
  123. package/dist/locales/ru/terminal.json +1 -0
  124. package/dist/locales/zh-CN/config.json +5 -0
  125. package/dist/locales/zh-CN/terminal.json +1 -0
  126. package/dist/src/packages/server/data/builtin-skills/boss-instructions.js +1 -1
  127. package/dist/src/packages/server/grok/backend.js +7 -10
  128. package/dist/src/packages/server/index.js +61 -34
  129. package/dist/src/packages/server/routes/files.js +45 -19
  130. package/dist/src/packages/server/services/global-file-search.js +281 -0
  131. package/dist/src/packages/server/websocket/handler.js +16 -6
  132. package/dist/src/packages/server/websocket/listeners/runtime-listeners.js +7 -0
  133. package/dist/src/packages/shared/agent-types.js +56 -4
  134. package/dist/src/packages/shared/file-search.js +49 -0
  135. package/dist/src/packages/shared/types.js +1 -0
  136. package/package.json +1 -1
  137. package/dist/assets/BossSpawnModal-CvFw8BPQ.js +0 -1
  138. package/dist/assets/ControlsModal-f4JvuTMY.js +0 -1
  139. package/dist/assets/RestoreArchivedAreaModal-C_cQr4Ay.js +0 -1
  140. package/dist/assets/SpawnModal-yPfAItLC.js +0 -1
  141. package/dist/assets/channel-Dz9gemPm.js +0 -1
  142. package/dist/assets/classDiagram-OUVF2IWQ-D29jX9yn.js +0 -1
  143. package/dist/assets/classDiagram-v2-EOCWNBFH-D29jX9yn.js +0 -1
  144. package/dist/assets/index-B5DZivhj.js +0 -19
  145. package/dist/assets/index-B_A7-K2O.js +0 -1
  146. package/dist/assets/index-CzZH0S0F.js +0 -1
  147. package/dist/assets/index-DHN-Bqnw.js +0 -1
  148. package/dist/assets/index-Dhfk8xKP.js +0 -2
  149. package/dist/assets/main-4CZSv3SH.css +0 -1
  150. package/dist/assets/stateDiagram-v2-6OUMAXLB-ChimTXB4.js +0 -1
  151. package/dist/assets/swimlanesDiagram-G3AALYLV-4ZzygVvO.js +0 -8
@@ -1,19 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/EmbeddedEditor-Cj5jPNh6.js","assets/main-B9DphKOa.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-CBPuP1jE.js","assets/main-4CZSv3SH.css","assets/EmbeddedEditor-BipHj7Fz.css","assets/AudioPlayer-BAtnEqGO.js","assets/VideoPlayer-CFfNly_q.js"])))=>i.map(i=>d[i]);
2
- import{r as s,c as W,d as O,L as It,ce as Vn,cf as Kn,b3 as Xs,S as Ot,b4 as Qs,s as Ve,u as le,j as e,I as M,cg as Ut,bo as Wn,ch as Zs,a0 as as,ci as en,cj as tn,ck as qn,cl as Jn,ar as zt,cm as Yn,cn as Xn,co as Qn,a7 as ot,cp as Zn,cq as rs,cr as ea,cs as sn,ct as Ht,cu as At,bn as it,cv as xt,cw as yt,cx as Os,cy as ta,a3 as sa,cz as ns,$ as na,cA as aa,cB as ra,cC as Lt,cD as ia,cE as la,cF as oa,cG as ca,cH as da,cI as Us,Y as ua,ao as ha}from"./main-B9DphKOa.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-CBPuP1jE.js";function ma(t){const[n,l]=s.useState(null),[c,r]=s.useState(!1),i=s.useCallback(async()=>{if(t){r(!0);try{const h=await W(O(`/api/files/git-status?path=${encodeURIComponent(t)}`)),o=await h.json();h.ok?l(o):l({isGitRepo:!1,files:[]})}catch(h){console.error("[FileExplorer] Failed to load git status:",h),l({isGitRepo:!1,files:[]})}finally{r(!1)}}},[t]);return{gitStatus:n,loading:c,loadGitStatus:i}}async function pa(t){try{const n=await W(O(`/api/files/git-original?path=${encodeURIComponent(t)}`)),l=await n.json();return n.ok&&!l.isNew?{content:l.content,isNew:!1}:{content:null,isNew:!0}}catch(n){return console.error("[FileExplorer] Failed to load original file:",n),{content:null,isNew:!0}}}const fa=new Set([".txt",".md",".markdown",".json",".yaml",".yml",".xml",".html",".htm",".css",".scss",".sass",".less",".js",".jsx",".ts",".tsx",".mjs",".cjs",".py",".rb",".c",".cpp",".h",".hpp",".cs",".go",".rs",".swift",".kt",".scala",".clj",".ex",".exs",".erl",".hs",".ml",".fs",".sql",".sh",".bash",".zsh",".fish",".ps1",".bat",".cmd",".toml",".ini",".cfg",".conf",".env",".gitignore",".dockerignore",".editorconfig",".prettierrc",".eslintrc",".babelrc",".log",".csv",".tsv",".svg",""]),ga=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".ico",".svg"]),xa=new Set([".pdf"]),ya=new Set([".xlsx",".xls",".docx",".doc",".pptx",".ppt",".zip",".tar",".gz",".rar",".7z",".exe",".dmg",".app",".deb",".rpm",".apk",".aab",".ipa",".msi",".ttf",".otf",".woff",".woff2",".eot",".sqlite",".db",".so",".dll",".dylib",".a",".o",".obj",".bin",".dat",".iso",".img",".jar",".war",".ear",".class"]);function ba(t){const n=t.toLowerCase();return ga.has(n)?"image":xa.has(n)?"pdf":Vn(n)?"audio":Kn(n)?"video":ya.has(n)?"binary":(fa.has(n),"text")}function ja(){const[t,n]=s.useState(null),[l,c]=s.useState(!1),[r,i]=s.useState(null),h=s.useCallback(async d=>{var f,b;c(!0),i(null);try{const p=d.substring(d.lastIndexOf(".")).toLowerCase(),v=ba(p),N=d.substring(d.lastIndexOf("/")+1);if(v==="image"){const k=await W(O(`/api/files/binary?path=${encodeURIComponent(d)}`));if(!k.ok){const w=await k.json().catch(()=>({error:"Failed to load image"}));i(w.error||"Failed to load image"),n(null);return}const g=await k.blob(),j=URL.createObjectURL(g);n({path:d,filename:N,extension:p,content:"",size:g.size,modified:new Date().toISOString(),fileType:"image",dataUrl:j});return}if(v==="pdf"){const k=await W(O(`/api/files/info?path=${encodeURIComponent(d)}`)),g=await k.json();if(!k.ok){i(g.error||"Failed to load PDF info"),n(null);return}n({path:d,filename:N,extension:p,content:"",size:g.size,modified:g.modified,fileType:"pdf",dataUrl:O(`/api/files/binary?path=${encodeURIComponent(d)}&token=${encodeURIComponent(It())}`)});return}if(v==="audio"||v==="video"){const k=await W(O(`/api/files/info?path=${encodeURIComponent(d)}`)),g=await k.json();if(!k.ok){i(g.error||"Failed to load media info"),n(null);return}const j=v==="video"?`&token=${encodeURIComponent(It())}`:"";n({path:d,filename:N,extension:p,content:"",size:g.size,modified:g.modified,fileType:v,dataUrl:O(`/api/files/binary?path=${encodeURIComponent(d)}${j}`)});return}if(v==="binary"){const k=await W(O(`/api/files/info?path=${encodeURIComponent(d)}`)),g=await k.json();if(!k.ok){i(g.error||"Failed to load file info"),n(null);return}n({path:d,filename:N,extension:p,content:"",size:g.size,modified:g.modified,fileType:"binary",dataUrl:O(`/api/files/binary?path=${encodeURIComponent(d)}&download=true&token=${encodeURIComponent(It())}`)});return}const R=await W(O(`/api/files/read?path=${encodeURIComponent(d)}`)),x=await R.json();if(!R.ok){if((f=x.error)!=null&&f.includes("too large")||(b=x.error)!=null&&b.includes("binary")){const k=await W(O(`/api/files/info?path=${encodeURIComponent(d)}`)),g=await k.json();if(k.ok){n({path:d,filename:N,extension:p,content:"",size:g.size,modified:g.modified,fileType:"binary",dataUrl:O(`/api/files/binary?path=${encodeURIComponent(d)}&download=true&token=${encodeURIComponent(It())}`)});return}}i(x.error||"Failed to load file"),n(null);return}n({...x,fileType:"text"})}catch(p){const v=p instanceof Error?p.message:"Failed to load file";i(v),n(null)}finally{c(!1)}},[]),o=s.useCallback(()=>{n(d=>(d!=null&&d.dataUrl&&d.dataUrl.startsWith("blob:")&&URL.revokeObjectURL(d.dataUrl),null)),i(null)},[]);return{file:t,loading:l,error:r,loadFile:h,clearFile:o,setFile:n}}const va="file-explorer-state",Gs="file-explorer-recent-projects",wa=10080*60*1e3,Ca=12;function es(t){return`${va}-folder-${t}`}async function Na(t){try{const n=await W(O(`/api/files/exists?path=${encodeURIComponent(t)}`));return n.ok?(await n.json()).exists===!0:!1}catch{return!1}}function ka(){const t=s.useCallback(async r=>{if(!r)return null;try{const i=localStorage.getItem(es(r));if(!i)return null;const h=JSON.parse(i);if(Date.now()-h.timestamp>wa)return localStorage.removeItem(es(r)),null;const d=(await Promise.all((h.tabs||[]).map(async b=>({tab:b,exists:await Na(b.path)})))).filter(({exists:b})=>b).map(({tab:b})=>b);let f=h.activeTabPath;return f&&!d.some(b=>b.path===f)&&(f=d.length>0?d[0].path:null),{tabs:d,activeTabPath:f,viewMode:h.viewMode||"files",expandedPaths:new Set(h.expandedPaths||[])}}catch(i){return console.error("[FileExplorerStorage] Failed to load project state:",i),null}},[]),n=s.useCallback((r,i)=>{if(r)try{const h={tabs:i.tabs,activeTabPath:i.activeTabPath,viewMode:i.viewMode,expandedPaths:Array.from(i.expandedPaths),timestamp:Date.now()};localStorage.setItem(es(r),JSON.stringify(h))}catch(h){console.error("[FileExplorerStorage] Failed to save project state:",h)}},[]),l=s.useCallback(()=>{try{const r=localStorage.getItem(Gs);if(!r)return[];const i=JSON.parse(r);return Array.isArray(i)?i.filter(h=>typeof h=="string"):[]}catch{return[]}},[]),c=s.useCallback(r=>{if(!r)return l();const i=[r,...l().filter(h=>h!==r)].slice(0,Ca);try{localStorage.setItem(Gs,JSON.stringify(i))}catch{}return i},[l]);return{loadProjectState:t,saveProjectState:n,loadRecentProjects:l,pushRecentProject:c}}const _s=280,Bs=150,Vs=1200;function Ea(){const[t,n]=s.useState(()=>{const f=Xs(Ot.TREE_PANEL_WIDTH,_s);return f>=Bs&&f<=Vs?f:_s}),l=s.useRef(!1),[c,r]=s.useState(!1),i=s.useRef(0),h=s.useRef(0),o=s.useRef(t);o.current=t;const d=s.useCallback(f=>{f.preventDefault(),l.current=!0,r(!0),i.current=f.clientX,h.current=t,document.body.style.cursor="ew-resize",document.body.style.userSelect="none"},[t]);return s.useEffect(()=>{const f=p=>{if(!l.current)return;const v=p.clientX-i.current,N=Math.min(Vs,Math.max(Bs,h.current+v));n(N)},b=()=>{l.current&&(l.current=!1,r(!1),document.body.style.cursor="",document.body.style.userSelect="",Qs(Ot.TREE_PANEL_WIDTH,o.current))};return document.addEventListener("mousemove",f),document.addEventListener("mouseup",b),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",b)}},[]),{treePanelWidth:t,handleResizeStart:d,isResizing:c}}const Sa=100,Ta=.65,Ma=36;function Da(){const[t,n]=s.useState(()=>Xs(Ot.MOBILE_TREE_PANEL_HEIGHT,0)),l=s.useRef(t);l.current=t;const c=s.useRef(0),r=s.useRef(0),i=()=>Math.floor((window.innerHeight-Ma)*Ta),h=p=>Math.min(i(),Math.max(Sa,p)),o=s.useCallback(p=>{n(p);const v=document.querySelector(".file-explorer-main");v&&v.style.setProperty("--fe-mobile-tree-height",`${p}px`)},[]),d=s.useCallback(()=>{document.body.style.cursor="",document.body.style.userSelect="",Qs(Ot.MOBILE_TREE_PANEL_HEIGHT,l.current),Ve.setTerminalResizing(!1)},[]),f=s.useCallback(p=>{p.preventDefault();const v=document.querySelector(".file-explorer-tree-panel"),N=l.current>0?l.current:(v==null?void 0:v.getBoundingClientRect().height)??240;c.current=p.clientY,r.current=N,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",Ve.setTerminalResizing(!0);const R=k=>{const g=k.clientY-c.current;o(h(r.current+g))},x=()=>{document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",x),d()};document.addEventListener("mousemove",R),document.addEventListener("mouseup",x)},[o,d]),b=s.useCallback(p=>{if(p.touches.length!==1)return;const v=document.querySelector(".file-explorer-tree-panel"),N=l.current>0?l.current:(v==null?void 0:v.getBoundingClientRect().height)??240;c.current=p.touches[0].clientY,r.current=N,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",Ve.setTerminalResizing(!0);const R=k=>{if(k.touches.length!==1)return;k.preventDefault();const g=k.touches[0].clientY-c.current;o(h(r.current+g))},x=()=>{document.removeEventListener("touchmove",R),document.removeEventListener("touchend",x),document.removeEventListener("touchcancel",x),d()};document.addEventListener("touchmove",R,{passive:!1}),document.addEventListener("touchend",x),document.addEventListener("touchcancel",x)},[o,d]);return{mobileTreeHeight:t,handleResizeMouseDown:f,handleResizeTouchStart:b}}function is(){const[t,n]=s.useState([]),[l,c]=s.useState(!1),[r,i]=s.useState(null),[h,o]=s.useState(null),d=s.useCallback(async k=>{c(!0),i(null);try{const g=await W(O(`/api/files/git-branches?path=${encodeURIComponent(k)}`)),j=await g.json();g.ok?n(j.branches||[]):(i(j.error||"Failed to load branches"),n([]))}catch(g){console.error("[GitBranches] Failed to load branches:",g),i("Failed to load branches"),n([])}finally{c(!1)}},[]),f=s.useCallback(async(k,g)=>{o("checkout"),i(null);try{const j=await W(O("/api/files/git-checkout"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k,branch:g})}),w=await j.json();return j.ok||i(w.error||"Checkout failed"),w}catch(j){console.error("[GitBranches] Checkout failed:",j);const w={success:!1,error:"Checkout failed"};return i(w.error),w}finally{o(null)}},[]),b=s.useCallback(async(k,g,j)=>{o("create"),i(null);try{const w=await W(O("/api/files/git-branch-create"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k,name:g,startPoint:j})}),T=await w.json();return w.ok||i(T.error||"Failed to create branch"),T}catch(w){console.error("[GitBranches] Create branch failed:",w);const T={success:!1,error:"Failed to create branch"};return i(T.error),T}finally{o(null)}},[]),p=s.useCallback(async k=>{o("pull"),i(null);try{const g=await W(O("/api/files/git-pull"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k})}),j=await g.json();return!g.ok&&!j.conflicts&&i(j.error||"Pull failed"),j}catch(g){console.error("[GitBranches] Pull failed:",g);const j={success:!1,error:"Pull failed"};return i(j.error),j}finally{o(null)}},[]),v=s.useCallback(async k=>{o("push"),i(null);try{const g=await W(O("/api/files/git-push"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k})}),j=await g.json();return g.ok||i(j.error||"Push failed"),j}catch(g){console.error("[GitBranches] Push failed:",g);const j={success:!1,error:"Push failed"};return i(j.error),j}finally{o(null)}},[]),N=s.useCallback(async(k,g)=>{o("merge"),i(null);try{const j=await W(O("/api/files/git-merge"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k,branch:g})}),w=await j.json();return!j.ok&&!w.conflicts&&i(w.error||"Merge failed"),w}catch(j){console.error("[GitBranches] Merge failed:",j);const w={success:!1,error:"Merge failed"};return i(w.error),w}finally{o(null)}},[]),R=s.useCallback(async k=>{o("merge-abort"),i(null);try{const g=await W(O("/api/files/git-merge-abort"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k})}),j=await g.json();return g.ok||i(j.error||"Merge abort failed"),j}catch(g){console.error("[GitBranches] Merge abort failed:",g);const j={success:!1,error:"Merge abort failed"};return i(j.error),j}finally{o(null)}},[]),x=s.useCallback(async k=>{o("merge-continue"),i(null);try{const g=await W(O("/api/files/git-merge-continue"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k})}),j=await g.json();return g.ok||i(j.error||"Merge continue failed"),j}catch(g){console.error("[GitBranches] Merge continue failed:",g);const j={success:!1,error:"Merge continue failed"};return i(j.error),j}finally{o(null)}},[]);return{branches:t,loading:l,error:r,operationInProgress:h,loadBranches:d,checkoutBranch:f,createBranch:b,pullFromRemote:p,pushToRemote:v,mergeBranch:N,mergeAbort:R,mergeContinue:x}}const Ra=50,Fa=400,Ks={branch:"",author:"",since:"",until:"",searchPath:"",search:""};function Pa(){const[t,n]=s.useState([]),[l,c]=s.useState(!1),[r,i]=s.useState(!1),[h,o]=s.useState(null),[d,f]=s.useState(!1),[b,p]=s.useState(0),[v,N]=s.useState({...Ks}),[R,x]=s.useState(null),[k,g]=s.useState([]),[j,w]=s.useState(!1),[T,A]=s.useState([]),[V,C]=s.useState(!1),U=s.useRef(null),ae=s.useRef(""),Y=s.useCallback((_,Z,P)=>{const G=P||v,I=new URLSearchParams;return I.set("path",_),I.set("limit",String(Ra)),I.set("offset",String(Z)),G.branch&&I.set("branch",G.branch),G.author&&I.set("author",G.author),G.since&&I.set("since",G.since),G.until&&I.set("until",G.until),G.searchPath&&I.set("searchPath",G.searchPath),G.search&&I.set("search",G.search),I.toString()},[v]),D=s.useCallback(async _=>{ae.current=_,c(!0),o(null),x(null),g([]);try{const Z=Y(_,0),P=await W(O(`/api/files/git-log?${Z}`)),G=await P.json();P.ok?(n(G.commits||[]),p(G.total||0),f(G.hasMore||!1)):(o(G.error||"Failed to load git history"),n([]))}catch(Z){console.error("[useGitHistory] loadHistory error:",Z),o("Failed to load git history"),n([])}finally{c(!1)}},[Y]),F=s.useCallback(async _=>{if(!(r||!d)){i(!0);try{const Z=Y(_,t.length),P=await W(O(`/api/files/git-log?${Z}`)),G=await P.json();P.ok&&(n(I=>[...I,...G.commits||[]]),p(G.total||0),f(G.hasMore||!1))}catch(Z){console.error("[useGitHistory] loadMore error:",Z)}finally{i(!1)}}},[Y,t.length,d,r]),K=s.useCallback(async _=>{if(x(_),!_){g([]);return}w(!0);try{const Z=ae.current,P=new URLSearchParams({path:Z,hash:_.hash}),G=await W(O(`/api/files/git-commit-files?${P}`)),I=await G.json();G.ok?g(I.files||[]):g([])}catch(Z){console.error("[useGitHistory] selectCommit files error:",Z),g([])}finally{w(!1)}},[]),ne=s.useCallback((_,Z)=>{N(P=>({...P,[_]:Z}))},[]),re=s.useCallback(()=>{N({...Ks})},[]);s.useEffect(()=>{const _=ae.current;if(_)return U.current&&clearTimeout(U.current),U.current=setTimeout(()=>{D(_)},Fa),()=>{U.current&&clearTimeout(U.current)}},[v]);const je=s.useCallback(async _=>{C(!0);try{const Z=new URLSearchParams({path:_}),P=await W(O(`/api/files/git-authors?${Z}`)),G=await P.json();P.ok&&A(G.authors||[])}catch(Z){console.error("[useGitHistory] loadAuthors error:",Z)}finally{C(!1)}},[]);return{commits:t,loading:l,loadingMore:r,error:h,hasMore:d,total:b,filters:v,setFilter:ne,resetFilters:re,selectedCommit:R,selectCommit:K,commitFiles:k,commitFilesLoading:j,loadHistory:D,loadMore:F,authors:T,authorsLoading:V,loadAuthors:je}}function Ia(t){if(!t.current)return null;const n=[".file-viewer-code-with-lines",".file-viewer-markdown-wrapper",".file-viewer-code-wrapper",".file-viewer-diagram-wrapper",".file-viewer-image-wrapper",".file-viewer-pdf-wrapper"];for(const l of n){const c=t.current.querySelector(l);if(c&&Ws(c))return c}return Ws(t.current)?t.current:null}function Ws(t){const n=["auto","scroll"].includes(getComputedStyle(t).overflowY),l=t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth;return n&&l}function nn(t){if(!t)return 19.5;const n=parseFloat(getComputedStyle(t).lineHeight);return isNaN(n)?19.5:n}function ts(t,n=!0){const l=n?t.scrollHeight:0;t.scrollTo({top:l,behavior:"smooth"})}function La(t){const{scrollTop:n,scrollHeight:l,clientHeight:c}=t;return l<=c?100:Math.round(n/(l-c)*100)}function $a(t,n){const l=nn(t),c=t.scrollTop,r=Math.floor(c/l)+1,i=n.split(`
3
- `).length;return Math.min(r,i)}function za(t,n,l=!1){if(!n)return[];l||t.toLowerCase();const c=l?n:n.toLowerCase(),r=[];let i=0;const h=t.split(`
4
- `);let o=0;for(let d=0;d<h.length;d++){const f=h[d],b=l?f:f.toLowerCase();let p=0,v=b.indexOf(c);for(;v!==-1;){const N=o+v;r.push({index:i++,line:d+1,column:v,length:c.length,charIndex:N}),p=v+c.length,v=b.indexOf(c,p)}o+=f.length+1}return r}function lt(t){return/[\w]/.test(t)}function Ke(t){return/\s/.test(t)}function Ha(t,n,l){let c=n-1,r=l;const i=t.length,h=t[c]||"";if(r<h.length){const f=lt(h[r]);if(!Ke(h[r]))for(;r<h.length&&!Ke(h[r])&&lt(h[r])===f;)r++}for(;c<i;){const f=t[c]||"";for(;r<f.length&&Ke(f[r]);)r++;if(r<f.length)return{line:c+1,col:r};c++,r=0}const o=i,d=Math.max(0,(t[i-1]||"").length-1);return{line:o,col:d}}function Aa(t,n,l){let c=n-1,r=l+1;const i=t.length;for(;c<i;){const d=t[c]||"";for(;r<d.length&&Ke(d[r]);)r++;if(r<d.length)break;c++,r=0}if(c>=i)return{line:i,col:Math.max(0,(t[i-1]||"").length-1)};const h=t[c]||"",o=lt(h[r]);for(;r+1<h.length&&!Ke(h[r+1])&&lt(h[r+1])===o;)r++;return{line:c+1,col:r}}function Oa(t,n,l){let c=n-1,r=l-1;for(;c>=0;){const o=t[c]||"";for(;r>=0&&Ke(o[r]);)r--;if(r>=0)break;c--,c>=0&&(r=(t[c]||"").length-1)}if(c<0)return{line:1,col:0};const i=t[c]||"",h=lt(i[r]);for(;r>0&&!Ke(i[r-1])&&lt(i[r-1])===h;)r--;return{line:c+1,col:r}}function Ua(t,n,l,c){if(c==="none")return"";const{anchorLine:r,anchorCol:i,headLine:h,headCol:o}=l;if(c==="line"){const N=Math.min(r,h),R=Math.max(r,h);return n.slice(N-1,R).join(`
5
- `)}let d,f,b,p;if(r<h||r===h&&i<=o?(d=r,f=i,b=h,p=o):(d=h,f=o,b=r,p=i),d===b)return(n[d-1]||"").substring(f,p+1);const v=[];v.push((n[d-1]||"").substring(f));for(let N=d;N<b-1;N++)v.push(n[N]||"");return v.push((n[b-1]||"").substring(0,p+1)),v.join(`
6
- `)}function an(t){const{containerRef:n,isEnabled:l=!0,content:c="",onClose:r,onSearchOpen:i}=t,h=s.useRef({percentage:0,line:1,column:1}),o=s.useRef(null),d=s.useRef(19.5),f=s.useMemo(()=>c.split(`
7
- `),[c]),b=f.length,[p,v]=s.useState(1),[N,R]=s.useState(0),[x,k]=s.useState(!1),[g,j]=s.useState("none"),[w,T]=s.useState(null),[A,V]=s.useState(!1),[C,U]=s.useState(""),[ae,Y]=s.useState(0),[D,F]=s.useState(!1),K=s.useMemo(()=>za(c,C,!1),[c,C]),ne=s.useCallback(()=>{const m=o.current;if(!m)return;const X=La(m),oe=$a(m,c),$=Math.max(1,Math.round(m.scrollLeft/7.8)+1);h.current={percentage:X,line:oe,column:$}},[c]),re=s.useCallback(()=>{V(!0),U(""),Y(0),i==null||i()},[i]),je=s.useCallback(()=>{V(!1),U(""),Y(0)},[]),_=s.useCallback(()=>{F(m=>!m)},[]),Z=s.useCallback(m=>{const X=o.current;if(!X)return;const oe=X.querySelector(".file-viewer-pre"),H=oe&&parseFloat(getComputedStyle(oe).lineHeight)||d.current,$=oe&&parseFloat(getComputedStyle(oe).paddingTop)||0,te=(oe?oe.offsetTop:0)+$+(m-1)*H,Q=H*3;X.scrollTo({top:Math.max(0,te-Q),behavior:"smooth"})},[]);s.useEffect(()=>{!A||K.length===0||Y(0)},[K,A]),s.useEffect(()=>{if(!A||K.length===0)return;const m=K[ae];m&&(v(m.line),R(m.column),Z(m.line))},[A,K,ae,Z]);const P=s.useCallback(()=>{K.length!==0&&Y(m=>(m+1)%K.length)},[K]),G=s.useCallback(()=>{K.length!==0&&Y(m=>(m-1+K.length)%K.length)},[K]),I=s.useCallback(m=>{const X=o.current;if(!X)return;const oe=X.querySelector(".file-viewer-pre");if(!oe)return;const H=parseFloat(getComputedStyle(oe).lineHeight),$=isNaN(H)?d.current:H,S=parseFloat(getComputedStyle(oe).paddingTop)||0,Q=oe.offsetTop+S+(m-1)*$,de=Q+$,fe=X.scrollTop,se=fe+X.clientHeight;Q<fe?X.scrollTo({top:Math.max(0,Q),behavior:"auto"}):de>se&&X.scrollTo({top:de-X.clientHeight,behavior:"auto"})},[]),ie=s.useCallback((m,X)=>{v(m),R(X),I(m),g!=="none"&&T(oe=>oe?{...oe,headLine:m,headCol:X}:null)},[g,I]),ee=s.useCallback(()=>{if(g==="none"||!w)return;const m=Ua(c,f,w,g);m&&navigator.clipboard.writeText(m).catch(()=>{const X=document.createElement("textarea");X.value=m,X.style.position="fixed",X.style.left="-9999px",document.body.appendChild(X),X.select(),document.execCommand("copy"),document.body.removeChild(X)}),j("none"),T(null)},[g,w,c,f]),ve=s.useCallback(m=>{const X=m.target;if((X.tagName==="INPUT"||X.tagName==="TEXTAREA")&&m.key!=="Escape")return;const H=o.current;if(!H)return;let $=!1;const S=d.current,te=Math.max(1,Math.floor(H.clientHeight/S)),Q=Math.max(1,Math.floor(te/2)),de=(se,we)=>{const Ge=Math.max(0,(f[se-1]||"").length-1);return Math.min(we,Math.max(0,Ge))},fe=(se,we)=>{const Ge=de(se,we);ie(se,Ge)};if(m.key==="v"&&!m.shiftKey&&!m.ctrlKey&&!A)m.preventDefault(),m.stopPropagation(),g==="char"?(j("none"),T(null)):(j("char"),T({anchorLine:p,anchorCol:N,headLine:p,headCol:N})),$=!0;else if(m.key==="V"&&m.shiftKey&&!m.ctrlKey&&!A)m.preventDefault(),m.stopPropagation(),g==="line"?(j("none"),T(null)):(j("line"),T({anchorLine:p,anchorCol:0,headLine:p,headCol:0})),$=!0;else if(m.key==="y"&&!m.ctrlKey&&g!=="none")m.preventDefault(),m.stopPropagation(),ee(),$=!0;else if(m.key==="j"||m.key==="ArrowDown"){m.preventDefault(),m.stopPropagation();const se=Math.min(p+1,b);fe(se,N),$=!0}else if(m.key==="k"||m.key==="ArrowUp"){m.preventDefault(),m.stopPropagation();const se=Math.max(p-1,1);fe(se,N),$=!0}else if(m.key==="d"&&m.ctrlKey||m.key==="d"&&g==="none"&&!A){m.preventDefault(),m.stopPropagation();const se=Math.min(p+Q,b);fe(se,N),$=!0}else if(m.key==="u"&&m.ctrlKey||m.key==="u"&&g==="none"&&!A){m.preventDefault(),m.stopPropagation();const se=Math.max(p-Q,1);fe(se,N),$=!0}else if((m.ctrlKey||m.metaKey)&&m.key==="f")m.preventDefault(),m.stopPropagation(),re(),$=!0;else if(m.key==="f"&&!m.ctrlKey&&!m.metaKey&&g==="none"&&!A){m.preventDefault(),m.stopPropagation();const se=Math.min(p+te,b);fe(se,N),$=!0}else if(m.key===" "||m.key==="PageDown"){m.preventDefault(),m.stopPropagation();const se=Math.min(p+te,b);fe(se,N),$=!0}else if(m.key==="b"&&!x&&g==="none"&&!A||m.key==="PageUp"){m.preventDefault(),m.stopPropagation();const se=Math.max(p-te,1);fe(se,N),$=!0}else if(m.key==="g"&&!m.shiftKey&&g==="none"&&!A)m.preventDefault(),m.stopPropagation(),ie(1,0),ts(H,!1),$=!0;else if(m.key==="Home")m.preventDefault(),m.stopPropagation(),ie(1,0),ts(H,!1),$=!0;else if(m.key==="G"&&m.shiftKey||m.key==="End")m.preventDefault(),m.stopPropagation(),ie(b,0),ts(H,!0),$=!0;else if(m.key==="h"||m.key==="ArrowLeft")m.preventDefault(),m.stopPropagation(),ie(p,Math.max(0,N-1)),$=!0;else if(m.key==="l"||m.key==="ArrowRight"){m.preventDefault(),m.stopPropagation();const se=(f[p-1]||"").length;ie(p,Math.min(N+1,Math.max(0,se-1))),$=!0}else if(m.key==="w"&&!m.ctrlKey&&!A){m.preventDefault(),m.stopPropagation();const se=Ha(f,p,N);ie(se.line,se.col),$=!0}else if(m.key==="e"&&!m.ctrlKey&&!A){m.preventDefault(),m.stopPropagation();const se=Aa(f,p,N);ie(se.line,se.col),$=!0}else if(m.key==="b"&&!A){m.preventDefault(),m.stopPropagation();const se=Oa(f,p,N);ie(se.line,se.col),$=!0}else if(m.key==="0")m.preventDefault(),m.stopPropagation(),ie(p,0),$=!0;else if(m.key==="$")m.preventDefault(),m.stopPropagation(),ie(p,Math.max(0,(f[p-1]||"").length-1)),$=!0;else if(m.key==="^"){m.preventDefault(),m.stopPropagation();const we=(f[p-1]||"").search(/\S/);ie(p,we>=0?we:0),$=!0}else m.key==="/"?(m.preventDefault(),m.stopPropagation(),re(),$=!0):m.key==="n"&&!A?(m.preventDefault(),m.stopPropagation(),P(),$=!0):m.key==="N"&&m.shiftKey&&!A?(m.preventDefault(),m.stopPropagation(),G(),$=!0):m.key==="?"&&g==="none"?(m.preventDefault(),m.stopPropagation(),_(),$=!0):m.key==="q"&&g==="none"?(m.preventDefault(),m.stopPropagation(),r==null||r(),$=!0):m.key==="Escape"&&(g!=="none"?(m.preventDefault(),m.stopPropagation(),j("none"),T(null),$=!0):A?(m.preventDefault(),m.stopPropagation(),je(),$=!0):x&&(m.preventDefault(),m.stopPropagation(),k(!1),$=!0));$&&(m.key!=="Escape"&&!x&&k(!0),requestAnimationFrame(ne))},[r,ne,b,f,p,N,I,A,je,g,x,ie,ee,re,P,G,_]);return s.useEffect(()=>{if(!l)return;const m=Ia(n);if(o.current=m,!m){console.warn("[useLessNavigation] Could not find scrollable container");return}d.current=nn(m);const X=()=>{ne()};return window.addEventListener("keydown",ve,{capture:!0}),m.addEventListener("scroll",X,{passive:!0}),ne(),()=>{window.removeEventListener("keydown",ve,{capture:!0}),m.removeEventListener("scroll",X)}},[l,ve,ne]),{scrollPercentage:h.current.percentage,currentLine:h.current.line,currentColumn:h.current.column,totalLines:b,cursorLine:p,cursorCol:N,cursorModeActive:x,visualMode:g,selection:w,searchActive:A,searchQuery:C,searchMatches:K,currentMatchIndex:ae,startSearch:re,setSearchQuery:U,nextMatch:P,prevMatch:G,clearSearch:je,helpActive:D,toggleHelp:_}}const ls=({query:t,onQueryChange:n,matchCount:l,currentIndex:c,onNext:r,onPrev:i,onClose:h})=>{const{t:o}=le(["terminal"]),d=s.useRef(null);s.useEffect(()=>{var p;(p=d.current)==null||p.focus()},[]);const f=s.useCallback(p=>{p.stopPropagation(),p.key==="Enter"||p.key==="ArrowDown"?(p.preventDefault(),r()):p.key==="ArrowUp"&&(p.preventDefault(),i())},[r,i]),b=l===0&&t?o("terminal:fileExplorer.noMatches"):l>0?`${c+1}/${l}`:"";return e.jsxs("div",{className:"file-viewer-search-bar",children:[e.jsxs("div",{className:"file-viewer-search-input-wrapper",children:[e.jsx("span",{className:"file-viewer-search-prefix",children:"/"}),e.jsx("input",{ref:d,type:"text",className:"file-viewer-search-input",placeholder:o("terminal:fileExplorer.searchInFile"),value:t,onChange:p=>n(p.target.value),onKeyDown:f,autoComplete:"off",spellCheck:"false"})]}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"file-viewer-search-counter",children:b}),e.jsxs("div",{className:"file-viewer-search-nav",children:[e.jsx("button",{className:"file-viewer-search-btn file-viewer-search-prev",onClick:i,disabled:l===0,title:o("terminal:fileExplorer.previousMatch"),"aria-label":o("terminal:fileExplorer.previousMatch"),children:e.jsx(M,{name:"caret-up",size:10})}),e.jsx("button",{className:"file-viewer-search-btn file-viewer-search-next",onClick:r,disabled:l===0,title:o("terminal:fileExplorer.nextMatch"),"aria-label":o("terminal:fileExplorer.nextMatch"),children:e.jsx(M,{name:"caret-down",size:10})})]})]}),e.jsx("button",{className:"file-viewer-search-close",onClick:h,title:o("terminal:fileExplorer.closeSearch"),"aria-label":o("terminal:fileExplorer.closeSearch"),children:e.jsx(M,{name:"close",size:12})})]})};ls.displayName="SearchBar";const Ga=[{keys:["j","↓"],description:"Move cursor down one line",category:"Navigation"},{keys:["k","↑"],description:"Move cursor up one line",category:"Navigation"},{keys:["h","←"],description:"Move cursor left",category:"Navigation"},{keys:["l","→"],description:"Move cursor right",category:"Navigation"},{keys:["0"],description:"Jump to start of line",category:"Navigation"},{keys:["$"],description:"Jump to end of line",category:"Navigation"},{keys:["^"],description:"First non-whitespace char",category:"Navigation"},{keys:["d","Ctrl+D"],description:"Half page down",category:"Navigation"},{keys:["u","Ctrl+U"],description:"Half page up",category:"Navigation"},{keys:["f","Space"],description:"Full page down",category:"Navigation"},{keys:["b","Page Up"],description:"Full page up",category:"Navigation"},{keys:["g","Home"],description:"Jump to top of file",category:"Navigation"},{keys:["G","End"],description:"Jump to bottom of file",category:"Navigation"},{keys:["w"],description:"Next word start",category:"Word Motion"},{keys:["e"],description:"Next word end",category:"Word Motion"},{keys:["b"],description:"Previous word start",category:"Word Motion"},{keys:["v"],description:"Character visual mode",category:"Visual Mode"},{keys:["V"],description:"Line visual mode",category:"Visual Mode"},{keys:["y"],description:"Yank (copy) selection",category:"Visual Mode"},{keys:["Escape"],description:"Exit visual mode",category:"Visual Mode"},{keys:["/"],description:"Open search bar",category:"Search"},{keys:["n"],description:"Next match",category:"Search"},{keys:["N"],description:"Previous match",category:"Search"},{keys:["?"],description:"Toggle this help overlay",category:"Help"},{keys:["Escape"],description:"Exit cursor mode (or visual/search)",category:"Help"},{keys:["Alt+E"],description:"Close file viewer",category:"Help"},{keys:["q"],description:"Close file viewer",category:"Help"}],os=({onClose:t})=>{const{t:n}=le(["terminal"]),l=s.useCallback(i=>{i.target===i.currentTarget&&t()},[t]),c=s.useCallback(i=>{(i.key==="Escape"||i.key==="?")&&(i.preventDefault(),i.stopPropagation(),t())},[t]),r=Ga.reduce((i,h)=>(i[h.category]||(i[h.category]=[]),i[h.category].push(h),i),{});return e.jsx("div",{className:"keybindings-help-overlay",onClick:l,onKeyDown:c,tabIndex:0,role:"dialog","aria-label":n("terminal:fileExplorer.keybindingsHelp"),children:e.jsxs("div",{className:"keybindings-help-content",children:[e.jsx("button",{className:"keybindings-help-close",onClick:t,"aria-label":n("terminal:fileExplorer.closeHelp"),title:n("terminal:fileExplorer.pressEscapeToClose"),children:e.jsx(M,{name:"close",size:14})}),e.jsx("h2",{className:"keybindings-help-title",children:n("terminal:fileExplorer.keybindingsHelp")}),e.jsx("p",{className:"keybindings-help-subtitle",children:n("terminal:fileExplorer.keybindingsSubtitle")}),e.jsx("div",{className:"keybindings-help-categories",children:Object.entries(r).map(([i,h])=>e.jsxs("div",{className:"keybindings-help-category",children:[e.jsx("h3",{className:"keybindings-help-category-title",children:i}),e.jsx("div",{className:"keybindings-help-list",children:h.map((o,d)=>e.jsxs("div",{className:"keybindings-help-item",children:[e.jsx("div",{className:"keybindings-help-keys",children:o.keys.map((f,b)=>e.jsx("kbd",{className:"keybindings-help-key",children:f},b))}),e.jsx("div",{className:"keybindings-help-description",children:o.description})]},d))})]},i))}),e.jsx("p",{className:"keybindings-help-footer",children:n("terminal:fileExplorer.keybindingsFooter")})]})})};os.displayName="KeybindingsHelp";const qs=s.lazy(()=>as(()=>import("./EmbeddedEditor-Cj5jPNh6.js"),__vite__mapDeps([0,1,2,3,4,5])).then(t=>({default:t.EmbeddedEditor}))),_a=s.lazy(()=>as(()=>import("./AudioPlayer-BAtnEqGO.js"),__vite__mapDeps([6,1,2,3,4])).then(t=>({default:t.AudioPlayer}))),Ba=s.lazy(()=>as(()=>import("./VideoPlayer-CFfNly_q.js"),__vite__mapDeps([7,1,2,3,4])).then(t=>({default:t.VideoPlayer}))),Va=[".md",".mdx",".markdown"],Js="file-viewer-markdown-render",Ka=[".puml",".plantuml",".iuml",".pu"],Ys="file-viewer-plantuml-render",Wa="https://kroki.io/plantuml/svg";function qa(t){return Va.includes(t.toLowerCase())}function Ja(t){return Ka.includes(t.toLowerCase())}function Ya(){const[t,n]=s.useState(()=>{try{const c=localStorage.getItem(Js);return c===null?!0:c==="true"}catch{return!0}}),l=s.useCallback(()=>{n(c=>{const r=!c;try{localStorage.setItem(Js,String(r))}catch{}return r})},[]);return[t,l]}function Xa(){const[t,n]=s.useState(()=>{try{const c=localStorage.getItem(Ys);return c===null?!0:c==="true"}catch{return!0}}),l=s.useCallback(()=>{n(c=>{const r=!c;try{localStorage.setItem(Ys,String(r))}catch{}return r})},[]);return[t,l]}function Qa(t){const n=new TextEncoder().encode(t);let l="";for(const c of n)l+=String.fromCharCode(c);return`data:image/svg+xml;base64,${window.btoa(l)}`}function ze({file:t,rightContent:n,onRevealInTree:l,editMode:c,onToggleEdit:r}){const{t:i}=le(["terminal","common"]),[h,o]=s.useState("idle"),[d,f]=s.useState("idle"),[b,p]=s.useState("idle"),v=t.fileType==="text"?Ut(t.extension):t.extension.slice(1).toUpperCase(),N=t.fileType==="text"&&t.content!=null,R=Wn(),x=async()=>{try{await zt(t.content),p("copied"),setTimeout(()=>p("idle"),2e3)}catch{p("error"),setTimeout(()=>p("idle"),2e3)}},k=async()=>{const T=O(`/api/files/binary?path=${encodeURIComponent(t.path)}&download=true`);await ot(T,t.filename,"text/plain;charset=utf-8")},g=async()=>{o("loading");try{const T=await W(O("/api/files/open-in-editor"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t.path,...R.externalEditorCommand&&{editorCommand:R.externalEditorCommand}})});if(!T.ok){const A=await T.json().catch(()=>({error:"Unknown error"}));console.error("Failed to open in editor:",A),o("error"),setTimeout(()=>o("idle"),2e3);return}o("success"),setTimeout(()=>o("idle"),2e3)}catch(T){console.error("Error opening file in editor:",T),o("error"),setTimeout(()=>o("idle"),2e3)}},j=async()=>{if(t.path)try{await Zn(t.path),f("success"),setTimeout(()=>f("idle"),2e3)}catch(T){console.error("Error opening file explorer:",T),f("error"),setTimeout(()=>f("idle"),2e3)}},w=i("terminal:fileExplorer.openInFileExplorer");return e.jsxs("div",{className:"file-viewer-header",children:[e.jsxs("div",{className:"file-viewer-header-left",children:[e.jsx("span",{className:"file-viewer-filename",children:t.filename}),e.jsxs("span",{className:"file-viewer-meta",children:[Zs(t.size)," • ",v,t.content&&` • ${t.content.split(`
8
- `).length} lines`]})]}),e.jsxs("div",{className:"file-viewer-header-right",children:[r&&t.fileType==="text"&&e.jsx("button",{className:`file-viewer-edit-btn${c?" active":""}`,onClick:r,title:i(c?"terminal:fileExplorer.exitEdit":"terminal:fileExplorer.editFile"),children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L3.463 11.1a.25.25 0 00-.064.108l-.558 1.953 1.953-.558a.25.25 0 00.108-.064l8.61-8.61a.25.25 0 000-.354l-1.086-1.086z"})})}),N&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:`file-viewer-copy-html-btn ${b}`,onClick:x,title:i("terminal:fileExplorer.copyAllTitle"),children:i(b==="copied"?"terminal:fileExplorer.copied":b==="error"?"terminal:fileExplorer.copyError":"terminal:fileExplorer.copyAll")}),e.jsx("button",{className:"file-viewer-download-btn",onClick:k,title:i("terminal:fileExplorer.downloadFileTitle"),children:i("common:buttons.download")})]}),e.jsx("button",{className:`file-viewer-reveal-explorer-btn ${d}`,onClick:j,disabled:!t.path,title:w,"aria-label":w,children:d==="success"?e.jsx(M,{name:"check",size:14}):d==="error"?e.jsx(M,{name:"cross",size:14}):e.jsx(M,{name:"folder-open",size:14})}),e.jsx("button",{className:`file-viewer-open-editor-btn ${h}`,onClick:g,disabled:h==="loading",title:i(h==="error"?"terminal:fileExplorer.failedToOpenEditor":h==="success"?"terminal:fileExplorer.openingInEditor":"terminal:fileExplorer.openInEditor"),children:h==="success"?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 11-1.06-1.06l7.25-7.25a.75.75 0 011.06 0z"})}):h==="error"?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"})}):e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M1.5 1h6v1.5h-5v11h11v-5H15v6.5H0V1h1.5zm8 0H15v5.5h-1.5V3.56L7.28 9.78l-1.06-1.06L12.44 2.5H9.5V1z"})})}),l&&e.jsx("button",{className:"file-viewer-locate-btn",onClick:()=>l(t.path),title:i("terminal:fileExplorer.locateInTree"),children:e.jsx(M,{name:"target",size:14})}),n]})]})}function Za({file:t,onRevealInTree:n,renderMarkdown:l,onToggleRender:c,editMode:r,onToggleEdit:i}){const h=s.useRef(null),o=s.useRef(null),d=s.useRef(null),{t:f}=le(["terminal","common"]),[b,p]=s.useState("idle"),[v,N]=s.useState("idle"),[R,x]=s.useState("idle"),[k,g]=s.useState("idle"),j=an({containerRef:d,isEnabled:!0,content:t.content});s.useEffect(()=>{if(!l&&h.current){const U=Ut(t.extension);en(U).then(()=>{h.current&&tn(h.current)})}},[t,l]);const w=s.useCallback(async()=>{if(!o.current){p("error"),setTimeout(()=>p("idle"),2e3);return}try{const U=o.current.innerHTML,ae=qn(U),Y=o.current.innerText;await Jn(ae,Y),p("copied"),setTimeout(()=>p("idle"),2e3)}catch{p("error"),setTimeout(()=>p("idle"),2e3)}},[]),T=s.useCallback(async()=>{if(!o.current){N("error"),setTimeout(()=>N("idle"),2e3);return}try{const U=o.current.innerHTML;await zt(U),N("copied"),setTimeout(()=>N("idle"),2e3)}catch{N("error"),setTimeout(()=>N("idle"),2e3)}},[]),A=s.useCallback(async()=>{try{await zt(t.content),x("copied"),setTimeout(()=>x("idle"),2e3)}catch{x("error"),setTimeout(()=>x("idle"),2e3)}},[t.content]),V=s.useCallback(async()=>{try{await zt(t.content),g("copied"),setTimeout(()=>g("idle"),2e3)}catch{g("error"),setTimeout(()=>g("idle"),2e3)}},[t.content]),C=e.jsxs("div",{className:"file-viewer-header-buttons",children:[l&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:`file-viewer-copy-html-btn ${b}`,onClick:w,title:f("terminal:fileExplorer.copyRichTextTitle"),children:f(b==="copied"?"terminal:fileExplorer.copied":b==="error"?"terminal:fileExplorer.copyError":"terminal:fileExplorer.copyRichText")}),e.jsx("button",{className:`file-viewer-copy-html-btn ${v}`,onClick:T,title:f("terminal:fileExplorer.copyHtmlTitle"),children:f(v==="copied"?"terminal:fileExplorer.copied":v==="error"?"terminal:fileExplorer.copyError":"terminal:fileExplorer.copyHtml")}),e.jsx("button",{className:`file-viewer-copy-html-btn ${R}`,onClick:A,title:f("terminal:fileExplorer.copyMarkdownTitle"),children:f(R==="copied"?"terminal:fileExplorer.copied":R==="error"?"terminal:fileExplorer.copyError":"terminal:fileExplorer.copyMarkdown")}),e.jsx("button",{className:`file-viewer-copy-html-btn ${k}`,onClick:V,title:f("terminal:fileExplorer.copyOriginalTitle"),children:f(k==="copied"?"terminal:fileExplorer.copied":k==="error"?"terminal:fileExplorer.copyError":"terminal:fileExplorer.copyOriginal")})]}),e.jsx("button",{className:`file-viewer-render-toggle ${l?"active":""}`,onClick:c,title:f(l?"terminal:fileExplorer.showSource":"terminal:fileExplorer.renderMarkdown"),children:l?"</>":"Aa"})]});return e.jsxs(e.Fragment,{children:[e.jsx(ze,{file:t,onRevealInTree:n,rightContent:C,editMode:r,onToggleEdit:i}),e.jsxs("div",{className:"file-viewer-content-wrapper",ref:d,children:[l?e.jsx("div",{className:"file-viewer-markdown-wrapper",children:e.jsx("div",{className:"markdown-content",ref:o,children:e.jsx(Yn,{remarkPlugins:[Xn],children:t.content})})}):e.jsx("div",{className:"file-viewer-code-wrapper",children:e.jsx("pre",{className:"file-viewer-pre",children:e.jsx("code",{ref:h,className:"language-markdown",children:t.content})})}),e.jsx("div",{className:"file-viewer-scroll-indicator",title:`Line ${j.currentLine}/${j.totalLines}`,children:j.scrollPercentage===100?"END":j.scrollPercentage===0?"TOP":`${j.scrollPercentage}%`}),j.searchActive&&e.jsx(ls,{query:j.searchQuery,onQueryChange:j.setSearchQuery,matchCount:j.searchMatches.length,currentIndex:j.currentMatchIndex,onNext:j.nextMatch,onPrev:j.prevMatch,onClose:j.clearSearch})]}),j.helpActive&&e.jsx(os,{onClose:j.toggleHelp})]})}function er({file:t,onRevealInTree:n,renderPlantUml:l,onToggleRender:c,editMode:r,onToggleEdit:i}){const{t:h}=le(["terminal"]),o=s.useRef(null),d=s.useRef(null),[f,b]=s.useState(null),[p,v]=s.useState(!1),[N,R]=s.useState(null),x=an({containerRef:d,isEnabled:!0,content:t.content});s.useEffect(()=>{if(!l&&o.current){const g=Ut(t.extension);en(g).then(()=>{o.current&&tn(o.current)})}},[t,l]),s.useEffect(()=>{if(!l)return;if(!t.content.trim()){b(null),R("Diagram is empty");return}const g=new AbortController;return v(!0),R(null),(async()=>{try{const w=await fetch(Wa,{method:"POST",headers:{"Content-Type":"text/plain; charset=utf-8",Accept:"image/svg+xml"},body:t.content,signal:g.signal});if(!w.ok)throw new Error(`Render failed (${w.status})`);const T=await w.text();if(!T.includes("<svg"))throw new Error("Invalid SVG output");b(Qa(T))}catch(w){if(g.signal.aborted)return;const T=w instanceof Error?w.message:"Failed to render diagram";R(T),b(null)}finally{g.signal.aborted||v(!1)}})(),()=>g.abort()},[t.path,t.content,l]);const k=e.jsx("div",{className:"file-viewer-header-buttons",children:e.jsx("button",{className:`file-viewer-render-toggle ${l?"active":""}`,onClick:c,title:h(l?"terminal:fileExplorer.showSource":"terminal:fileExplorer.renderDiagram"),children:l?"</>":h("terminal:fileExplorer.diagram")})});return e.jsxs(e.Fragment,{children:[e.jsx(ze,{file:t,onRevealInTree:n,rightContent:k,editMode:r,onToggleEdit:i}),e.jsxs("div",{className:"file-viewer-content-wrapper",ref:d,children:[l?e.jsxs("div",{className:"file-viewer-diagram-wrapper",children:[p&&e.jsx("div",{className:"file-viewer-placeholder",children:h("terminal:fileExplorer.renderingDiagram")}),!p&&f&&e.jsx("img",{src:f,alt:t.filename,className:"file-viewer-diagram-image"}),!p&&N&&e.jsxs("div",{className:"file-viewer-diagram-error",children:[e.jsxs("div",{children:[h("terminal:fileExplorer.couldNotRender"),": ",N]}),e.jsx("button",{className:"file-viewer-render-toggle",onClick:c,children:h("terminal:fileExplorer.showSource")})]})]}):e.jsx("div",{className:"file-viewer-code-wrapper",children:e.jsx("pre",{className:"file-viewer-pre",children:e.jsx("code",{ref:o,className:"language-plaintext",children:t.content})})}),e.jsx("div",{className:"file-viewer-scroll-indicator",title:`Line ${x.currentLine}/${x.totalLines}`,children:x.scrollPercentage===100?"END":x.scrollPercentage===0?"TOP":`${x.scrollPercentage}%`}),x.searchActive&&e.jsx(ls,{query:x.searchQuery,onQueryChange:x.setSearchQuery,matchCount:x.searchMatches.length,currentIndex:x.currentMatchIndex,onNext:x.nextMatch,onPrev:x.prevMatch,onClose:x.clearSearch})]}),x.helpActive&&e.jsx(os,{onClose:x.toggleHelp})]})}function tr({file:t,onRevealInTree:n}){const{t:l}=le(["common","terminal"]),c=async()=>{const r=O(`/api/files/binary?path=${encodeURIComponent(t.path)}&download=true`);await ot(r,t.filename)};return e.jsxs(e.Fragment,{children:[e.jsx(ze,{file:t,onRevealInTree:n,rightContent:e.jsx("button",{className:"file-viewer-download-btn",onClick:c,title:l("common:buttons.download"),children:l("common:buttons.download")})}),e.jsx("div",{className:"file-viewer-image-wrapper zoomable",children:t.dataUrl?e.jsx(Qn,{src:t.dataUrl,alt:t.filename}):e.jsx("div",{className:"file-viewer-placeholder",children:l("terminal:fileExplorer.failedToLoadImage")})})]})}function sr({file:t,onRevealInTree:n}){const{t:l}=le(["common","terminal"]),c=async()=>{const r=O(`/api/files/binary?path=${encodeURIComponent(t.path)}&download=true`);await ot(r,t.filename,"application/pdf")};return e.jsxs(e.Fragment,{children:[e.jsx(ze,{file:t,onRevealInTree:n,rightContent:e.jsx("button",{className:"file-viewer-download-btn",onClick:c,title:l("common:buttons.download"),children:l("common:buttons.download")})}),e.jsx("div",{className:"file-viewer-pdf-wrapper",children:t.dataUrl?e.jsx("iframe",{src:t.dataUrl,title:t.filename,className:"file-viewer-pdf"}):e.jsx("div",{className:"file-viewer-placeholder",children:l("terminal:fileExplorer.failedToLoadPdf")})})]})}function nr({file:t,onRevealInTree:n}){const{t:l}=le(["common","terminal"]),c=async()=>{const r=O(`/api/files/binary?path=${encodeURIComponent(t.path)}&download=true`);await ot(r,t.filename)};return e.jsxs(e.Fragment,{children:[e.jsx(ze,{file:t,onRevealInTree:n,rightContent:e.jsx("button",{className:"file-viewer-download-btn",onClick:c,title:l("common:buttons.download"),children:l("common:buttons.download")})}),e.jsx("div",{className:"file-viewer-audio-wrapper",children:t.dataUrl?e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"file-viewer-placeholder",children:l("common:status.loading")}),children:e.jsx(_a,{url:t.dataUrl,filename:t.filename})}):e.jsx("div",{className:"file-viewer-placeholder",children:l("terminal:audioPlayer.loadError",{defaultValue:"Could not load audio"})})})]})}function ar({file:t,onRevealInTree:n}){const{t:l}=le(["common","terminal"]),c=O(`/api/files/binary?path=${encodeURIComponent(t.path)}&download=true`),r=async()=>{await ot(c,t.filename)};return e.jsxs(e.Fragment,{children:[e.jsx(ze,{file:t,onRevealInTree:n,rightContent:e.jsx("button",{className:"file-viewer-download-btn",onClick:r,title:l("common:buttons.download"),children:l("common:buttons.download")})}),e.jsx("div",{className:"file-viewer-video-wrapper",children:t.dataUrl?e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"file-viewer-placeholder",children:l("common:status.loading")}),children:e.jsx(Ba,{url:t.dataUrl,downloadUrl:c,filename:t.filename})}):e.jsx("div",{className:"file-viewer-placeholder",children:l("terminal:videoPlayer.loadError",{defaultValue:"Could not load video"})})})]})}function rr({file:t,onRevealInTree:n}){const{t:l}=le(["terminal","common"]),c=async()=>{const i=O(`/api/files/binary?path=${encodeURIComponent(t.path)}&download=true`);await ot(i,t.filename)},r=()=>{const i=t.extension.toLowerCase();return[".xlsx",".xls"].includes(i)?e.jsx(M,{name:"dashboard",size:48}):[".docx",".doc"].includes(i)?e.jsx(M,{name:"edit",size:48}):[".pptx",".ppt"].includes(i)?e.jsx(M,{name:"film",size:48}):[".zip",".tar",".gz",".rar",".7z"].includes(i)?e.jsx(M,{name:"file-zip",size:48}):[".mp3",".wav",".flac",".ogg"].includes(i)?e.jsx(M,{name:"music-note",size:48}):[".mp4",".avi",".mov",".mkv",".webm"].includes(i)?e.jsx(M,{name:"film",size:48}):[".exe",".dmg",".app",".msi"].includes(i)?e.jsx(M,{name:"gear",size:48}):[".apk",".aab",".ipa"].includes(i)?e.jsx(M,{name:"mobile",size:48}):[".jar",".war",".ear"].includes(i)?e.jsx(M,{name:"coffee",size:48}):[".iso",".img"].includes(i)?e.jsx(M,{name:"disc",size:48}):[".so",".dll",".dylib"].includes(i)?e.jsx(M,{name:"wrench",size:48}):e.jsx(M,{name:"folder",size:48})};return e.jsxs(e.Fragment,{children:[e.jsx(ze,{file:t,onRevealInTree:n}),e.jsxs("div",{className:"file-viewer-binary",children:[e.jsx("div",{className:"file-viewer-binary-icon",children:r()}),e.jsx("div",{className:"file-viewer-binary-name",children:t.filename}),e.jsx("div",{className:"file-viewer-binary-size",children:Zs(t.size)}),e.jsx("div",{className:"file-viewer-binary-message",children:l("terminal:fileExplorer.cannotPreview")}),e.jsx("button",{className:"file-viewer-download-btn large",onClick:c,children:l("terminal:fileExplorer.downloadFile")})]})]})}function ir({file:t,loading:n,error:l,onRevealInTree:c,onFileEdited:r}){const{t:i}=le(["terminal","common"]),[h,o]=Ya(),[d,f]=Xa(),[b,p]=s.useState(!1);s.useEffect(()=>{p(!1)},[t==null?void 0:t.path]);const v=s.useCallback(async w=>{if(!t)return;const T=await W(O("/api/files/write"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t.path,content:w})});if(!T.ok){const A=await T.json().catch(()=>({error:"Save failed"}));throw new Error(A.error||"Save failed")}},[t]),N=s.useCallback(()=>{p(w=>(w&&t&&(r==null||r(t.path)),!w))},[t,r]),R=s.useCallback(()=>{t&&(r==null||r(t.path))},[t,r]);if(n)return e.jsx("div",{className:"file-viewer-placeholder",children:i("common:status.loading")});if(l)return e.jsx("div",{className:"file-viewer-placeholder error",children:l});if(!t)return e.jsxs("div",{className:"file-viewer-placeholder",children:[e.jsx("div",{className:"placeholder-icon",children:e.jsx(M,{name:"folder-open",size:32})}),e.jsx("div",{className:"placeholder-text",children:i("terminal:fileExplorer.selectFileToView")})]});const x=t.fileType||"text",k=x==="text"&&qa(t.extension),g=x==="text"&&Ja(t.extension),j=k||g;return j&&b&&t.content!=null?e.jsxs("div",{className:"file-viewer-content",children:[e.jsx(ze,{file:t,onRevealInTree:c,editMode:!0,onToggleEdit:N}),e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"file-viewer-placeholder",children:i("common:status.loading")}),children:e.jsx(qs,{content:t.content,extension:t.extension,onSave:v,onCancel:N},t.path)})]}):x==="text"&&!j&&t.content!=null?e.jsxs("div",{className:"file-viewer-content",children:[e.jsx(ze,{file:t,onRevealInTree:c}),e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"file-viewer-placeholder",children:i("common:status.loading")}),children:e.jsx(qs,{content:t.content,extension:t.extension,onSave:v,onCancel:R},t.path)})]}):e.jsxs("div",{className:"file-viewer-content",children:[k&&e.jsx(Za,{file:t,onRevealInTree:c,renderMarkdown:h,onToggleRender:o,editMode:b,onToggleEdit:N}),g&&!k&&e.jsx(er,{file:t,onRevealInTree:c,renderPlantUml:d,onToggleRender:f,editMode:b,onToggleEdit:N}),x==="image"&&e.jsx(tr,{file:t,onRevealInTree:c}),x==="pdf"&&e.jsx(sr,{file:t,onRevealInTree:c}),x==="audio"&&e.jsx(nr,{file:t,onRevealInTree:c}),x==="video"&&e.jsx(ar,{file:t,onRevealInTree:c}),x==="binary"&&e.jsx(rr,{file:t,onRevealInTree:c})]})}const rn=s.memo(ir,(t,n)=>t.loading!==n.loading||t.error!==n.error?!1:t.file===null&&n.file===null?!0:t.file===null||n.file===null?!1:t.file.path===n.file.path&&t.file.content===n.file.content&&t.file.modified===n.file.modified);rn.displayName="FileViewer";function ln({text:t,query:n}){if(!n)return e.jsx(e.Fragment,{children:t});const l=ea(t,n);if(l)return e.jsxs(e.Fragment,{children:[t.slice(0,l.start),e.jsx("mark",{className:"search-highlight",children:t.slice(l.start,l.end)}),t.slice(l.end)]});const c=n.toLowerCase(),i=t.toLowerCase().indexOf(c);return i===-1?e.jsx(e.Fragment,{children:t}):e.jsxs(e.Fragment,{children:[t.slice(0,i),e.jsx("mark",{className:"search-highlight",children:t.slice(i,i+n.length)}),t.slice(i+n.length)]})}const lr=s.memo(function({node:n,query:l,isSelected:c,onSelect:r,lineNumber:i}){const h=n.isDirectory?null:rs(n),o=n.path.split("/");o[o.length-1];const d=o.slice(0,-1).join("/");return e.jsxs("div",{className:`search-result-item ${c?"selected":""}`,onClick:()=>r(n),children:[n.isDirectory?e.jsx("span",{className:"search-result-icon",children:e.jsx(M,{name:"folder",size:14})}):h?e.jsx("span",{className:"search-result-icon",style:{backgroundImage:`url('${h}')`},role:"img","aria-label":"file icon"}):e.jsx("span",{className:"search-result-icon",children:e.jsx(M,{name:"file-text",size:14})}),e.jsxs("div",{className:"search-result-info",children:[e.jsxs("span",{className:"search-result-name",children:[e.jsx(ln,{text:n.name,query:l}),i&&e.jsxs("span",{className:"search-result-line-badge",children:[":",i]})]}),e.jsx("span",{className:"search-result-path",children:d})]})]})}),or=s.memo(function({match:n,query:l,isSelected:c,onSelect:r}){const{t:i}=le(["terminal"]),h={name:n.name,path:n.path,isDirectory:!1,extension:n.extension},o=rs(h),d=n.path.split("/"),f=d[d.length-1],b=d.slice(0,-1).join("/");return e.jsxs("div",{className:`content-search-item ${c?"selected":""}`,children:[e.jsxs("div",{className:`content-search-header ${c?"selected":""}`,onClick:()=>r(n.path),children:[o?e.jsx("span",{className:"content-search-icon",style:{backgroundImage:`url('${o}')`},role:"img","aria-label":"file icon"}):e.jsx("span",{className:"content-search-icon",children:e.jsx(M,{name:"file-text",size:14})}),e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"2px"},children:[e.jsx("span",{className:"content-search-name",children:f}),e.jsx("span",{className:"search-result-path",style:{fontSize:"10px"},children:b})]}),e.jsx("span",{className:"content-search-count",children:n.matches.length})]}),e.jsxs("div",{className:"content-search-matches",children:[n.matches.slice(0,5).map((p,v)=>e.jsxs("div",{className:"content-search-match",onClick:()=>r(n.path,p.line),children:[e.jsx("span",{className:"content-search-line-num",children:p.line}),e.jsx("span",{className:"content-search-line-content",children:e.jsx(ln,{text:p.content.trim(),query:l})})]},`${n.path}-${p.line}-${v}`)),n.matches.length>5&&e.jsxs("div",{className:"content-search-match",style:{opacity:.6,cursor:"default"},children:[e.jsx("span",{className:"content-search-line-num",children:"..."}),e.jsx("span",{className:"content-search-line-content",children:i("terminal:fileExplorer.moreMatches",{count:n.matches.length-5})})]})]})]})});function cr({filenameResults:t,contentResults:n,onSelectFile:l,onSelectContent:c,selectedPath:r,query:i,lineNumber:h}){const{t:o}=le(["terminal"]),d=t.length>0,f=n.length>0;return!d&&!f?e.jsx("div",{className:"search-no-results",children:o("terminal:fileExplorer.noMatchesFound")}):e.jsxs("div",{className:"unified-search-results",children:[d&&e.jsxs("div",{className:"unified-search-section",children:[e.jsxs("div",{className:"unified-search-section-header",children:[e.jsx("span",{className:"unified-search-section-icon",children:e.jsx(M,{name:"file-text",size:14})}),e.jsx("span",{className:"unified-search-section-title",children:o("terminal:fileExplorer.files")}),e.jsx("span",{className:"unified-search-section-count",children:t.length})]}),e.jsx("div",{className:"unified-search-section-content",children:t.map(b=>e.jsx(lr,{node:b,query:i,isSelected:r===b.path,onSelect:l,lineNumber:h},b.path))})]}),f&&e.jsxs("div",{className:"unified-search-section",children:[e.jsxs("div",{className:"unified-search-section-header",children:[e.jsx("span",{className:"unified-search-section-icon",children:e.jsx(M,{name:"edit",size:14})}),e.jsx("span",{className:"unified-search-section-title",children:o("terminal:fileExplorer.content")}),e.jsx("span",{className:"unified-search-section-count",children:o("terminal:fileExplorer.matchesInFiles",{matches:n.reduce((b,p)=>b+p.matches.length,0),files:n.length})})]}),e.jsx("div",{className:"unified-search-section-content",children:n.map(b=>e.jsx(or,{match:b,query:i,isSelected:r===b.path,onSelect:c},b.path))})]})]})}const on=s.memo(cr,(t,n)=>!(t.query!==n.query||t.selectedPath!==n.selectedPath||t.filenameResults.length!==n.filenameResults.length||t.contentResults.length!==n.contentResults.length));on.displayName="UnifiedSearchResults";const dr=s.memo(function({file:n,isSelected:l,onSelect:c,onStage:r,isStaging:i,showDirPath:h,isChecked:o,onToggleCheck:d,onContextMenu:f,onDiscard:b}){const{t:p}=le(["terminal"]),v=n.status,N=yt[v],R=v==="deleted",x=v==="untracked"&&r,k=n.name.includes(".")?"."+n.name.split(".").pop():"",g=h&&n.path.includes("/")?n.path.slice(0,n.path.lastIndexOf("/")):"";return e.jsxs("div",{className:`git-file-item ${l?"selected":""}`,onClick:()=>!R&&c(n.path,v),onContextMenu:j=>{j.preventDefault(),f==null||f(j,n,v)},style:{cursor:R?"not-allowed":"pointer"},title:n.path,children:[d&&e.jsx("input",{type:"checkbox",className:"git-file-checkbox",checked:o||!1,onChange:j=>{j.stopPropagation(),d(n.path)},onClick:j=>j.stopPropagation()}),e.jsx("img",{className:"tree-icon",src:xt(k),alt:"file"}),e.jsxs("span",{className:"git-file-name",children:[n.name,g&&e.jsx("span",{className:"git-file-dir",children:g})]}),e.jsx("span",{className:"git-file-status",style:{color:N.color},children:N.icon}),n.oldPath&&e.jsxs("span",{className:"git-file-renamed",children:[e.jsx(M,{name:"subitem",size:10,style:{transform:"rotate(180deg)"}})," ",n.oldPath.split("/").pop()]}),x&&e.jsx("button",{className:`git-stage-btn ${i?"staging":""}`,onClick:j=>{j.stopPropagation(),i||r(n.path)},title:p("terminal:fileExplorer.stageFile"),disabled:i,children:i?"...":"+"}),b&&e.jsx("button",{className:"git-discard-btn",onClick:j=>{j.stopPropagation(),b(n,v)},title:v==="untracked"||v==="added"?"Delete file":"Discard changes",children:e.jsx(M,{name:"revert",size:12})})]})}),ur=16,hr=22,mr=s.memo(function t({node:n,depth:l,expandedDirs:c,onToggleDir:r,selectedPath:i,onSelect:h,onStage:o,stagingPaths:d,checkedFiles:f,onToggleCheck:b,onContextMenu:p,onDirContextMenu:v,onDiscard:N}){const{t:R}=le(["terminal"]),x=l*ur;if(!n.isDirectory){const g=n.file.status,j=yt[g];return e.jsxs("div",{className:`git-file-item ${i===n.path?"selected":""}`,onClick:()=>g!=="deleted"&&h(n.file.path,g),onContextMenu:w=>{w.preventDefault(),p==null||p(w,n.file,g)},style:{paddingLeft:`${x+hr}px`,cursor:g==="deleted"?"not-allowed":"pointer"},title:n.file.path,children:[b&&e.jsx("input",{type:"checkbox",className:"git-file-checkbox",checked:(f==null?void 0:f.has(n.file.path))||!1,onChange:w=>{w.stopPropagation(),b(n.file.path)},onClick:w=>w.stopPropagation()}),e.jsx("img",{className:"tree-icon",src:xt(n.file.name.includes(".")?"."+n.file.name.split(".").pop():""),alt:"file"}),e.jsx("span",{className:"git-file-name",children:n.file.name}),e.jsx("span",{className:"git-file-status",style:{color:j.color},children:j.icon}),n.file.oldPath&&e.jsxs("span",{className:"git-file-renamed",children:[e.jsx(M,{name:"subitem",size:10,style:{transform:"rotate(180deg)"}})," ",n.file.oldPath.split("/").pop()]}),g==="untracked"&&o&&e.jsx("button",{className:`git-stage-btn ${d!=null&&d.has(n.path)?"staging":""}`,onClick:w=>{w.stopPropagation(),d!=null&&d.has(n.path)||o(n.file.path)},title:R("terminal:fileExplorer.stageFile"),disabled:d==null?void 0:d.has(n.path),children:d!=null&&d.has(n.path)?"...":"+"}),N&&e.jsx("button",{className:"git-discard-btn",onClick:w=>{w.stopPropagation(),N(n.file,g)},title:g==="untracked"||g==="added"?"Delete file":"Discard changes",children:e.jsx(M,{name:"revert",size:12})})]})}const k=c.has(n.path);return e.jsxs("div",{className:"tree-node-wrapper",children:[e.jsxs("div",{className:`tree-node directory ${k?"expanded":""}`,style:{paddingLeft:`${x}px`},onClick:()=>r(n.path),onContextMenu:g=>{g.preventDefault(),g.stopPropagation(),v==null||v(g,n)},children:[e.jsx("span",{className:`tree-arrow ${k?"expanded":""}`,children:e.jsx(M,{name:"caret-right",size:10})}),e.jsx("img",{className:"tree-folder-icon",src:k?"/assets/vscode-icons/default_folder_opened.svg":"/assets/vscode-icons/default_folder.svg",alt:"folder"}),e.jsx("span",{className:"tree-name",children:n.name}),e.jsx("span",{className:"git-tree-file-count",children:R("terminal:fileExplorer.fileCount",{count:n.fileCount})})]}),k&&e.jsx("div",{className:"tree-children",children:n.children.map(g=>e.jsx(t,{node:g,depth:l+1,expandedDirs:c,onToggleDir:r,selectedPath:i,onSelect:h,onStage:o,stagingPaths:d,checkedFiles:f,onToggleCheck:b,onContextMenu:p,onDirContextMenu:v,onDiscard:N},g.path))})]})}),ss=s.memo(function({groupLabel:n,groupIcon:l,groupColor:c,files:r,treeNodes:i,viewMode:h,selectedPath:o,expandedDirs:d,onToggleDir:f,onFileSelect:b,onStageFile:p,onStageAll:v,stagingPaths:N,checkedFiles:R,onToggleCheck:x,onContextMenu:k,onDirContextMenu:g,onDiscardFile:j,onDiscardAll:w}){const{t:T}=le(["terminal"]);if(r.length===0)return null;const A=r.some(U=>U.status==="untracked"),V=A&&v&&r.length>0,C=N?r.every(U=>N.has(U.path)):!1;return e.jsxs("div",{className:"git-status-group",children:[e.jsxs("div",{className:"git-status-group-header",style:{color:c},children:[e.jsx("span",{className:"git-status-badge",style:{background:c},children:l}),n," (",r.length,")",V&&e.jsx("button",{className:`git-stage-all-btn ${C?"staging":""}`,onClick:U=>{U.stopPropagation(),C||v()},title:T("terminal:fileExplorer.stageAllUntracked"),disabled:C,children:C?"...":T("terminal:fileExplorer.stageAll")}),w&&e.jsxs("button",{className:"git-discard-all-btn",onClick:U=>{U.stopPropagation(),w()},title:A?`Delete all ${r.length} files`:`Discard all ${r.length} changes`,children:[e.jsx(M,{name:"revert",size:12})," All"]})]}),h==="tree"?e.jsx("div",{className:"git-tree-content",children:i.map(U=>e.jsx(mr,{node:U,depth:0,expandedDirs:d,onToggleDir:f,selectedPath:o,onSelect:b,onStage:p,stagingPaths:N,checkedFiles:R,onToggleCheck:x,onContextMenu:k,onDirContextMenu:g,onDiscard:j},U.path))}):e.jsx("div",{className:"git-flat-content",children:r.map(U=>e.jsx(dr,{file:U,isSelected:o===U.path,onSelect:b,onStage:U.status==="untracked"?p:void 0,isStaging:N==null?void 0:N.has(U.path),showDirPath:!0,isChecked:R==null?void 0:R.has(U.path),onToggleCheck:x,onContextMenu:k,onDiscard:j},U.path))})]})});function pr({gitStatus:t,loading:n,onFileSelect:l,selectedPath:c,onRefresh:r,onStageFiles:i,stagingPaths:h,currentFolder:o,onCommitComplete:d,mergeInProgress:f,mergingBranch:b,onMergeContinue:p,onMergeAbort:v,onConflictOpen:N,onRevealInTree:R}){const{t:x}=le(["terminal","common"]),[k,g]=s.useState("tree"),[j,w]=s.useState(new Set),[T,A]=s.useState(""),[V,C]=s.useState(""),[U,ae]=s.useState(!1),[Y,D]=s.useState(new Set),[F,K]=s.useState(!1),[ne,re]=s.useState(null),je=s.useRef(null),{showToast:_}=sn(),[Z,P]=s.useState(null),[G,I]=s.useState(null),[ie,ee]=s.useState(null),ve=s.useCallback((E,L)=>{ee({files:[E],label:E.name})},[]),m=s.useCallback(async()=>{if(!(!ie||!o))try{const E=await W(O("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:ie.files.map(B=>({path:B.path,status:B.status})),directory:o})}),L=await E.json();E.ok&&L.success?(_("success","Discarded",`Reverted ${ie.files.length} file(s)`),r()):_("error","Discard Failed",L.error||"Could not discard changes")}catch{_("error","Discard Failed","Network error")}finally{ee(null)}},[ie,o,r,_]),X=s.useCallback((E,L,B)=>{E.preventDefault(),E.stopPropagation(),P({isOpen:!0,position:{x:E.clientX,y:E.clientY},file:L,status:B})},[]),oe=s.useCallback(async(E,L)=>{if(o)try{const B=await W(O("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[{path:E.path,status:L}],directory:o})}),be=await B.json();B.ok&&be.success?(_("success","Discarded",`Restored ${E.name}`),r()):_("error","Discard Failed",be.error||"Could not discard changes")}catch{_("error","Discard Failed","Network error")}},[o,r,_]),H=s.useCallback(async E=>{try{await navigator.clipboard.writeText(E),_("success","Copied","Full path copied")}catch{_("error","Copy Failed","Could not copy path")}},[_]),$=s.useCallback(async E=>{const L=o&&E.startsWith(o+"/")?E.slice(o.length+1):E;try{await navigator.clipboard.writeText(L),_("success","Copied","Relative path copied")}catch{_("error","Copy Failed","Could not copy path")}},[o,_]),S=s.useMemo(()=>{if(!Z)return[];const{file:E,status:L}=Z,B=[];return L==="conflict"&&N?B.push({id:"open-conflict",label:x("terminal:fileExplorer.gitContextMenu.openConflictResolver"),icon:e.jsx(M,{name:"warn",size:14}),onClick:()=>N(E.path)}):L!=="deleted"&&B.push({id:"open-file",label:x("terminal:fileExplorer.gitContextMenu.openFile"),icon:e.jsx(M,{name:"file-text",size:14}),onClick:()=>l(E.path,L)}),L!=="conflict"&&B.push({id:"stage-file",label:x("terminal:fileExplorer.gitContextMenu.stageFile"),icon:e.jsx(M,{name:"plus",size:14}),onClick:()=>{i([E.path])}}),B.push({id:"divider-1",label:"",divider:!0,onClick:()=>{}}),(L==="modified"||L==="deleted"||L==="renamed"||L==="conflict")&&B.push({id:"discard-changes",label:x("terminal:fileExplorer.gitContextMenu.discardChanges"),icon:e.jsx(M,{name:"revert",size:14}),danger:!0,onClick:()=>{oe(E,L)}}),(L==="untracked"||L==="added")&&B.push({id:"delete-file",label:x("terminal:fileExplorer.gitContextMenu.deleteFile"),icon:e.jsx(M,{name:"trash",size:14}),danger:!0,onClick:()=>{oe(E,L)}}),B.push({id:"divider-2",label:"",divider:!0,onClick:()=>{}}),B.push({id:"copy-full-path",label:x("terminal:fileExplorer.gitContextMenu.copyFullPath"),icon:e.jsx(M,{name:"pin",size:14}),onClick:()=>{H(E.path)}}),B.push({id:"copy-relative-path",label:x("terminal:fileExplorer.gitContextMenu.copyRelativePath"),icon:e.jsx(M,{name:"clipboard",size:14}),onClick:()=>{$(E.path)}}),R&&L!=="deleted"&&B.push({id:"reveal-in-tree",label:x("terminal:fileExplorer.gitContextMenu.revealInTree"),icon:e.jsx(M,{name:"target",size:14}),onClick:()=>R(E.path)}),B},[Z,l,i,N,R,oe,H,$,x]),te=s.useCallback((E,L)=>{E.preventDefault(),E.stopPropagation(),I({isOpen:!0,position:{x:E.clientX,y:E.clientY},node:L})},[]),Q=s.useCallback(E=>!E.isDirectory&&E.file?[E.file]:E.children.flatMap(L=>Q(L)),[]),de=s.useCallback(async E=>{if(!o)return;const L=Q(E);if(L.length!==0)try{const B=await W(O("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:L.map(Me=>({path:Me.path,status:Me.status})),directory:o})}),be=await B.json();B.ok&&be.success?(_("success","Discarded",`Reverted ${L.length} file(s) in ${E.name}`),r()):_("error","Discard Failed",be.error||"Could not discard changes")}catch{_("error","Discard Failed","Network error")}},[o,Q,r,_]),fe=s.useMemo(()=>{if(!G)return[];const{node:E}=G,L=Q(E);return[{id:"discard-dir",label:`Discard Changes (${L.length} files)`,icon:e.jsx(M,{name:"revert",size:14}),danger:!0,onClick:()=>{de(E)}},{id:"stage-dir",label:`Stage All (${L.length} files)`,icon:e.jsx(M,{name:"plus",size:14}),onClick:()=>{i(L.map(B=>B.path))}}]},[G,Q,de,i]),se=s.useCallback(E=>{w(L=>{const B=new Set(L);return B.has(E)?B.delete(E):B.add(E),B})},[]),{conflictFiles:we,conflictTree:Ge,changesFiles:He,changesTree:Gt,untrackedFiles:Ae,untrackedTree:bt,allDirPaths:_e}=s.useMemo(()=>{if(!t||!t.isGitRepo||t.files.length===0)return{conflictFiles:[],conflictTree:[],changesFiles:[],changesTree:[],untrackedFiles:[],untrackedTree:[],allDirPaths:new Set};const E=new Set,L=t.files.filter(me=>me.status==="conflict"),B=Ht(L);At(B,E);const be=t.files.filter(me=>me.status==="modified"||me.status==="added"||me.status==="deleted"||me.status==="renamed"),Me=Ht(be);At(Me,E);const qe=t.files.filter(me=>me.status==="untracked"),dt=Ht(qe);return At(dt,E),{conflictFiles:L,conflictTree:B,changesFiles:be,changesTree:Me,untrackedFiles:qe,untrackedTree:dt,allDirPaths:E}},[t]);s.useEffect(()=>{w(_e)},[_e]),s.useEffect(()=>{t!=null&&t.files&&D(new Set(t.files.map(E=>E.path)))},[t==null?void 0:t.files]);const ct=s.useCallback(()=>{He.length!==0&&ee({files:He,label:`${He.length} changed files`})},[He]),jt=s.useCallback(()=>{Ae.length!==0&&ee({files:Ae,label:`${Ae.length} unversioned files`})},[Ae]),vt=s.useCallback(()=>{we.length!==0&&ee({files:we,label:`${we.length} conflicted files`})},[we]),wt=we.length>0;s.useEffect(()=>{if(ne){const E=ne.type==="error"?8e3:4e3,L=setTimeout(()=>re(null),E);return()=>clearTimeout(L)}},[ne]);const Ct=s.useCallback(async()=>{const E=!U;if(ae(E),E&&o){C(T);try{const B=await(await W(O(`/api/files/git-log-message?path=${encodeURIComponent(o)}`))).json();B.message&&A(B.message)}catch{}}else A(V)},[U,o,T,V]),ye=s.useCallback(E=>{D(L=>{const B=new Set(L);return B.has(E)?B.delete(E):B.add(E),B})},[]),ue=s.useCallback(()=>{if(!(t!=null&&t.files))return;const E=t.files.map(B=>B.path),L=E.every(B=>Y.has(B));D(L?new Set:new Set(E))},[t==null?void 0:t.files,Y]),xe=s.useCallback(async E=>{if(!(!o||!T.trim()||Y.size===0||F)){K(!0),re(null);try{const L=await W(O("/api/files/git-commit"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:o,message:T.trim(),amend:U,paths:Array.from(Y)})}),B=await L.json();if(!L.ok||!B.success){re({type:"error",text:B.error||"Commit failed"}),K(!1);return}if(E)try{const be=await W(O("/api/files/git-push"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:o})}),Me=await be.json();be.ok&&Me.success?re({type:"success",text:x("terminal:fileExplorer.committedAndPushed")}):re({type:"error",text:x("terminal:fileExplorer.committedButPushFailed",{error:Me.error||"Unknown error"})})}catch{re({type:"error",text:x("terminal:fileExplorer.committedButPushFailed",{error:"Network error"})})}else re({type:"success",text:x("terminal:fileExplorer.committedSuccessfully")});A(""),C(""),ae(!1),r(),d==null||d()}catch(L){re({type:"error",text:L.message||"Commit failed"})}finally{K(!1)}}},[o,T,U,Y,F,r,d]);if(n)return e.jsx("div",{className:"git-changes-loading",children:x("terminal:fileExplorer.loadingGitStatus")});if(!t||!t.isGitRepo)return e.jsxs("div",{className:"git-changes-empty",children:[e.jsx("div",{className:"git-empty-icon",children:e.jsx(M,{name:"package",size:32})}),e.jsx("div",{className:"git-empty-text",children:x("terminal:fileExplorer.notGitRepo")})]});if(t.files.length===0)return e.jsxs("div",{className:"git-changes-empty",children:[e.jsx("div",{className:"git-empty-icon",children:e.jsx(M,{name:"sparkle",size:32})}),e.jsx("div",{className:"git-empty-text",children:x("terminal:fileExplorer.workingTreeClean")}),e.jsx("div",{className:"git-empty-branch",children:x("terminal:fileExplorer.onBranch",{branch:t.branch})})]});const ke=E=>{i([E])},We=()=>{const E=Ae.map(L=>L.path);E.length>0&&i(E)},Re=(E,L)=>{L==="conflict"&&N?N(E):l(E,L)};return e.jsxs("div",{className:"git-changes",children:[e.jsxs("div",{className:"git-changes-header",children:[e.jsxs("span",{className:"git-branch",children:[e.jsx("span",{className:"git-branch-icon",children:e.jsx(M,{name:"git-branch",size:12})}),t.branch]}),t.counts&&e.jsxs("div",{className:"git-changes-summary",children:[(t.counts.conflict??0)>0&&e.jsxs("span",{className:"git-count conflict",children:[t.counts.conflict,"C"]}),t.counts.modified>0&&e.jsxs("span",{className:"git-count modified",children:[t.counts.modified,"M"]}),t.counts.added>0&&e.jsxs("span",{className:"git-count added",children:[t.counts.added,"A"]}),t.counts.deleted>0&&e.jsxs("span",{className:"git-count deleted",children:[t.counts.deleted,"D"]}),t.counts.untracked>0&&e.jsxs("span",{className:"git-count untracked",children:[t.counts.untracked,"?"]})]}),e.jsxs("div",{className:"git-view-toggle",children:[e.jsx("button",{className:`git-view-toggle-btn ${k==="flat"?"active":""}`,onClick:()=>g("flat"),title:x("terminal:fileExplorer.flatList"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:[e.jsx("rect",{x:"2",y:"3",width:"12",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"2",y:"7",width:"12",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"2",y:"11",width:"12",height:"1.5",rx:"0.5"})]})}),e.jsx("button",{className:`git-view-toggle-btn ${k==="tree"?"active":""}`,onClick:()=>g("tree"),title:x("terminal:fileExplorer.directoryTree"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:[e.jsx("rect",{x:"1",y:"2",width:"6",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"4",y:"5.5",width:"8",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"4",y:"9",width:"8",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"7",y:"12.5",width:"7",height:"1.5",rx:"0.5"})]})})]}),e.jsx("button",{className:"git-refresh-btn",onClick:r,title:x("common:buttons.refresh"),children:e.jsx(M,{name:"refresh",size:12})})]}),f&&e.jsxs("div",{className:"git-merge-banner",children:[e.jsx("span",{className:"git-merge-banner-icon",children:"⚠"}),e.jsx("span",{className:"git-merge-banner-text",children:x("terminal:fileExplorer.mergeInProgress",{branch:b?` (${b})`:""})}),e.jsxs("div",{className:"git-merge-actions",children:[e.jsx("button",{className:"git-merge-continue-btn",onClick:p,disabled:wt,title:x(wt?"terminal:fileExplorer.resolveAllConflictsFirst":"terminal:fileExplorer.continueMerge"),children:x("terminal:fileExplorer.continue")}),e.jsx("button",{className:"git-merge-abort-btn",onClick:v,title:x("terminal:fileExplorer.abortMerge"),children:x("terminal:fileExplorer.abort")})]})]}),e.jsxs("div",{className:"git-changes-list",children:[e.jsx(ss,{groupLabel:x("terminal:fileExplorer.gitGroups.conflicts"),groupIcon:"C",groupColor:"#ff5555",files:we,treeNodes:Ge,viewMode:k,selectedPath:c,expandedDirs:j,onToggleDir:se,onFileSelect:Re,checkedFiles:Y,onToggleCheck:ye,onContextMenu:X,onDirContextMenu:te,onDiscardFile:ve,onDiscardAll:vt}),e.jsx(ss,{groupLabel:x("terminal:fileExplorer.gitGroups.changes"),groupIcon:"~",groupColor:"#c89a5a",files:He,treeNodes:Gt,viewMode:k,selectedPath:c,expandedDirs:j,onToggleDir:se,onFileSelect:Re,checkedFiles:Y,onToggleCheck:ye,onContextMenu:X,onDirContextMenu:te,onDiscardFile:ve,onDiscardAll:ct}),e.jsx(ss,{groupLabel:x("terminal:fileExplorer.gitGroups.unversioned"),groupIcon:"?",groupColor:"#6ab8c8",files:Ae,treeNodes:bt,viewMode:k,selectedPath:c,expandedDirs:j,onToggleDir:se,onFileSelect:Re,onStageFile:ke,onStageAll:We,stagingPaths:h,checkedFiles:Y,onToggleCheck:ye,onContextMenu:X,onDirContextMenu:te,onDiscardFile:ve,onDiscardAll:jt})]}),e.jsxs("div",{className:"git-commit-panel",children:[e.jsxs("div",{className:"git-commit-options",children:[e.jsxs("label",{className:"git-commit-amend-label",children:[e.jsx("input",{type:"checkbox",className:"git-commit-amend-checkbox",checked:U,onChange:Ct}),x("terminal:fileExplorer.amend")]}),e.jsx("span",{className:"git-commit-file-count",children:x("terminal:fileExplorer.fileCount",{count:Y.size})}),e.jsx("button",{className:"git-commit-select-toggle",onClick:ue,title:Y.size===t.files.length?x("terminal:fileExplorer.deselectAll"):x("terminal:fileExplorer.selectAll"),children:Y.size===t.files.length?x("terminal:fileExplorer.deselectAll"):x("terminal:fileExplorer.selectAll")})]}),e.jsx("textarea",{ref:je,className:"git-commit-message",placeholder:x("terminal:fileExplorer.commitMessagePlaceholder"),value:T,onChange:E=>A(E.target.value),onKeyDown:E=>{(E.metaKey||E.ctrlKey)&&E.key==="Enter"&&(E.preventDefault(),xe(!1)),(E.metaKey||E.ctrlKey)&&E.shiftKey&&E.key==="Enter"&&(E.preventDefault(),xe(!0)),E.stopPropagation()},rows:3,disabled:F}),ne&&e.jsx("div",{className:`git-commit-status ${ne.type}`,children:ne.text}),e.jsxs("div",{className:"git-commit-actions",children:[e.jsx("button",{className:"git-commit-btn",onClick:()=>xe(!1),disabled:!T.trim()||Y.size===0||F,title:x("terminal:fileExplorer.commitCtrlEnter"),children:x(F?"terminal:fileExplorer.committing":"terminal:fileExplorer.commitAction")}),e.jsx("button",{className:"git-commit-push-btn",onClick:()=>xe(!0),disabled:!T.trim()||Y.size===0||F,title:x("terminal:fileExplorer.commitAndPushCtrlShiftEnter"),children:F?"...":x("terminal:fileExplorer.commitAndPush")})]})]}),Z&&e.jsx(it,{isOpen:Z.isOpen,position:Z.position,worldPosition:{x:0,z:0},actions:S,onClose:()=>P(null)}),G&&e.jsx(it,{isOpen:G.isOpen,position:G.position,worldPosition:{x:0,z:0},actions:fe,onClose:()=>I(null)}),ie&&e.jsx("div",{className:"git-discard-confirm-overlay",onClick:()=>ee(null),children:e.jsxs("div",{className:"git-discard-confirm",onClick:E=>E.stopPropagation(),children:[e.jsx("p",{children:ie.files.some(E=>E.status==="untracked"||E.status==="added")?e.jsxs(e.Fragment,{children:["Delete ",e.jsx("strong",{children:ie.label}),"?"]}):e.jsxs(e.Fragment,{children:["Discard changes to ",e.jsx("strong",{children:ie.label}),"?"]})}),e.jsx("p",{className:"git-discard-confirm-hint",children:"This cannot be undone."}),e.jsxs("div",{className:"git-discard-confirm-actions",children:[e.jsx("button",{className:"git-discard-confirm-cancel",onClick:()=>ee(null),children:"Cancel"}),e.jsx("button",{className:"git-discard-confirm-btn",onClick:m,children:ie.files.some(E=>E.status==="untracked"||E.status==="added")?"Delete":"Discard"})]})]})})]})}const cn=s.memo(pr,(t,n)=>t.loading!==n.loading||t.selectedPath!==n.selectedPath||t.stagingPaths!==n.stagingPaths||t.currentFolder!==n.currentFolder||t.mergeInProgress!==n.mergeInProgress||t.mergingBranch!==n.mergingBranch?!1:t.gitStatus===null&&n.gitStatus===null?!0:!(t.gitStatus===null||n.gitStatus===null||t.gitStatus.isGitRepo!==n.gitStatus.isGitRepo||t.gitStatus.branch!==n.gitStatus.branch||t.gitStatus.files.length!==n.gitStatus.files.length||t.gitStatus.mergeInProgress!==n.gitStatus.mergeInProgress));cn.displayName="GitChanges";const fr=s.memo(function({tab:n,isActive:l,onSelect:c,onClose:r,onContextMenu:i}){const{t:h}=le(["terminal"]),o={name:n.filename,path:n.path,isDirectory:!1,extension:n.extension},d=s.useCallback(()=>{c(n.path)},[c,n.path]),f=s.useCallback(v=>{v.button===1&&(v.preventDefault(),v.stopPropagation(),r(n.path))},[r,n.path]),b=s.useCallback(v=>{v.preventDefault(),v.stopPropagation(),r(n.path)},[r,n.path]),p=s.useCallback(v=>{v.preventDefault(),v.stopPropagation(),i(v,n)},[i,n]);return e.jsxs("div",{className:`file-tab ${l?"active":""}`,onClick:d,onMouseDown:f,onContextMenu:p,title:n.path,children:[e.jsx("img",{className:"file-tab-icon",src:rs(o),alt:"file"}),e.jsx("span",{className:"file-tab-name",children:n.filename}),e.jsx("button",{className:"file-tab-close",onClick:b,title:h("terminal:fileExplorer.closeMiddleClick"),children:"×"})]})});function gr(t){return typeof t.path=="string"&&t.path.startsWith("/")}function xr({tabs:t,activeTabPath:n,onSelectTab:l,onCloseTab:c,onCloseAllTabs:r,onShowGitHistory:i}){const{t:h}=le(["terminal"]),[o,d]=s.useState(null),f=s.useCallback((v,N)=>{d({isOpen:!0,position:{x:v.clientX,y:v.clientY},tab:N})},[]),b=s.useCallback(()=>d(null),[]),p=s.useMemo(()=>{if(!o)return[];const v=o.tab,N=!!i&&gr(v),R=[{id:"git-history",label:h("terminal:fileExplorer.showGitHistory")??"Show Git History",icon:e.jsx(M,{name:"git-commit",size:14}),disabled:!N,onClick:()=>{N&&i(v.path)}}];return r&&R.push({id:"divider-close-all",label:"",divider:!0,onClick:()=>{}},{id:"close-all-tabs",label:h("terminal:fileExplorer.closeAllTabs")??"Close all tabs",icon:e.jsx(M,{name:"cross",size:14}),danger:!0,onClick:()=>r()}),R},[o,i,r,h]);return t.length===0?null:e.jsxs("div",{className:"file-tabs-bar",children:[e.jsx("div",{className:"file-tabs-container",children:t.map(v=>e.jsx(fr,{tab:v,isActive:n===v.path,onSelect:l,onClose:c,onContextMenu:f},v.path))}),o&&e.jsx(it,{isOpen:o.isOpen,position:o.position,worldPosition:{x:0,z:0},actions:p,onClose:b})]})}const dn=s.memo(xr,(t,n)=>{if(t.activeTabPath!==n.activeTabPath||t.tabs.length!==n.tabs.length||t.onShowGitHistory!==n.onShowGitHistory||t.onCloseAllTabs!==n.onCloseAllTabs)return!1;for(let l=0;l<t.tabs.length;l++)if(t.tabs[l].path!==n.tabs[l].path)return!1;return!0});dn.displayName="FileTabs";const yr=s.memo(function({currentFolder:n,gitStatus:l,onBranchChanged:c,onMerge:r,onCompare:i,onPullConflicts:h}){const{t:o}=le(["terminal","common"]),[d,f]=s.useState(!1),[b,p]=s.useState(""),[v,N]=s.useState(!1),[R,x]=s.useState(""),[k,g]=s.useState(!1),[j,w]=s.useState(null),[T,A]=s.useState(null),V=s.useRef(null),C=s.useRef(null),U=s.useRef(null),{branches:ae,loading:Y,operationInProgress:D,loadBranches:F,checkoutBranch:K,createBranch:ne,pullFromRemote:re,pushToRemote:je}=is();s.useEffect(()=>{d&&n&&(F(n),setTimeout(()=>{var S;return(S=C.current)==null?void 0:S.focus()},50)),d||(p(""),N(!1),x(""),w(null))},[d,n,F]),s.useEffect(()=>{if(j){const S=j.type==="error"?8e3:3e3,te=setTimeout(()=>w(null),S);return()=>clearTimeout(te)}},[j]),s.useEffect(()=>{v&&setTimeout(()=>{var S;return(S=U.current)==null?void 0:S.focus()},50)},[v]),s.useEffect(()=>{if(!d)return;const S=Q=>{const de=Q.target;!de.closest(".branch-widget-selector")&&!de.closest(".branch-widget-dropdown")&&f(!1)},te=Q=>{Q.key==="Escape"&&(Q.preventDefault(),Q.stopPropagation(),f(!1))};return document.addEventListener("click",S),document.addEventListener("keydown",te,!0),()=>{document.removeEventListener("click",S),document.removeEventListener("keydown",te,!0)}},[d]);const _=s.useCallback(async S=>{if(!n||D||S.isCurrent)return;const te=await K(n,S.name);te.success?(w({type:"success",text:o("terminal:fileExplorer.switchedToBranch",{branch:te.branch||S.name})}),c(),F(n)):w({type:"error",text:te.error||o("terminal:fileExplorer.checkoutFailed")})},[n,D,K,c,F]),Z=s.useCallback(async()=>{if(!n||!R.trim()||D)return;const S=await ne(n,R.trim());S.success?(w({type:"success",text:o("terminal:fileExplorer.createdBranch",{branch:S.branch})}),N(!1),x(""),c(),F(n)):w({type:"error",text:S.error||o("terminal:fileExplorer.createBranchFailed")})},[n,R,D,ne,c,F]),P=s.useCallback(async()=>{if(!n||D)return;const S=await re(n);S.success?(S.stashConflicts&&S.stashConflicts.length>0?(w({type:"error",text:`Pull succeeded but stash pop had conflicts: ${S.stashConflicts.length} file(s). Resolve manually.`}),h==null||h(S.stashConflicts),f(!1)):S.stashed?w({type:"success",text:"Pull complete. Local changes were auto-stashed and restored."}):w({type:"success",text:o("terminal:fileExplorer.pullComplete")}),c(),F(n)):S.conflicts&&S.conflicts.length>0?(w({type:"error",text:`Pull conflicts: ${S.conflicts.length} file(s)`}),h==null||h(S.conflicts),f(!1)):w({type:"error",text:S.error||o("terminal:fileExplorer.pullFailed")})},[n,D,re,c,F,h]),G=s.useCallback(async()=>{if(!n||D)return;const S=await je(n);S.success?w({type:"success",text:o("terminal:fileExplorer.pushComplete")}):w({type:"error",text:S.error||o("terminal:fileExplorer.pushFailed")})},[n,D,je]),[I,ie]=s.useState(!1),ee=s.useCallback(async()=>{if(!(!n||D||I)){ie(!0);try{const S=await W(O("/api/files/git-fetch"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})});if(S.ok)w({type:"success",text:"Fetch complete"}),c(),F(n);else{const te=await S.json().catch(()=>({error:"Fetch failed"}));w({type:"error",text:te.error||"Fetch failed"})}}catch{w({type:"error",text:"Fetch failed"})}finally{ie(!1)}}},[n,D,I,c,F]),ve=(l==null?void 0:l.branch)||"unknown",m=!!D,X=s.useCallback((S,te)=>{te.isCurrent||(S.preventDefault(),S.stopPropagation(),A({isOpen:!0,position:{x:S.clientX,y:S.clientY},branch:te.name}))},[]),oe=s.useMemo(()=>{if(!T)return[];const S=!!D||(l==null?void 0:l.mergeInProgress);return[{id:"compare",label:o("terminal:fileExplorer.showDiffWith",{branch:T.branch}),icon:e.jsx(M,{name:"arrows-horizontal",size:14}),disabled:!!D,onClick:()=>{i==null||i(T.branch),f(!1)}},{id:"merge",label:o("terminal:fileExplorer.mergeInto",{source:T.branch,target:ve}),icon:"⤵",disabled:!!S,onClick:()=>{r&&r(T.branch),f(!1)}},{id:"divider-1",label:"",divider:!0,onClick:()=>{}},{id:"checkout",label:o("terminal:fileExplorer.checkoutBranch",{branch:T.branch}),icon:e.jsx(M,{name:"git-branch",size:14}),disabled:!!D,onClick:()=>{const te=ae.find(Q=>Q.name===T.branch);te&&_(te)}}]},[T,D,l==null?void 0:l.mergeInProgress,ve,r,i,ae,_]),H=s.useMemo(()=>{const S=ae.filter(Q=>!Q.isRemote);if(!b)return S;const te=b.toLowerCase();return S.filter(Q=>Q.name.toLowerCase().includes(te))},[ae,b]),$=s.useMemo(()=>{const S=ae.filter(Q=>Q.isRemote);if(!b)return S;const te=b.toLowerCase();return S.filter(Q=>Q.name.toLowerCase().includes(te))},[ae,b]);return e.jsxs("div",{className:"branch-widget",style:{position:"relative"},children:[e.jsxs("div",{className:"branch-widget-selector",onClick:S=>{S.stopPropagation(),f(!d)},title:`Branch: ${ve}`,children:[e.jsx("svg",{className:"branch-widget-icon",width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M5 3.25a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Zm0 2.122a2.25 2.25 0 1 0-1 0v1.836A2.25 2.25 0 0 0 5.75 9.5h1.378a2.251 2.251 0 1 0 0-1H5.75a1.25 1.25 0 0 1-1.25-1.25V5.372Zm7.75 4.878a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3-8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"})}),e.jsx("span",{className:"branch-widget-name",children:ve}),e.jsx("span",{className:"branch-widget-arrow",children:"▼"})]}),d&&e.jsxs("div",{className:"branch-widget-dropdown",ref:V,children:[e.jsx("div",{className:"branch-widget-search",children:e.jsx("input",{ref:C,type:"text",className:"branch-widget-search-input",placeholder:o("terminal:fileExplorer.searchBranches"),value:b,onChange:S=>p(S.target.value),onKeyDown:S=>S.stopPropagation()})}),j&&e.jsx("div",{className:`branch-widget-status ${j.type}`,children:j.text}),e.jsx("div",{className:"branch-widget-section-header",children:o("terminal:fileExplorer.actions")}),e.jsxs("div",{className:"branch-widget-actions",children:[e.jsxs("div",{className:`branch-widget-action-item ${m||I?"disabled":""}`,onClick:ee,children:[e.jsx("span",{className:"branch-widget-action-icon",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 13l-3-3h2V6h2v4h2l-3 3zM8 3l3 3h-2v4H7V6H5l3-3z"})})}),e.jsx("span",{className:"branch-widget-action-label",children:I?"Fetching...":"Fetch"})]}),e.jsxs("div",{className:`branch-widget-action-item ${m?"disabled":""}`,onClick:P,children:[e.jsx("span",{className:"branch-widget-action-icon",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 12l-4-4h2.5V3h3v5H12L8 12z"})})}),e.jsx("span",{className:"branch-widget-action-label",children:o(D==="pull"?"terminal:fileExplorer.pulling":"terminal:fileExplorer.pull")})]}),e.jsxs("div",{className:`branch-widget-action-item ${m?"disabled":""}`,onClick:G,children:[e.jsx("span",{className:"branch-widget-action-icon",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 4l4 4h-2.5v5h-3V8H4l4-4z"})})}),e.jsx("span",{className:"branch-widget-action-label",children:o(D==="push"?"terminal:fileExplorer.pushing":"terminal:fileExplorer.push")})]}),e.jsxs("div",{className:`branch-widget-action-item ${m?"disabled":""}`,onClick:()=>{m||N(!v)},children:[e.jsx("span",{className:"branch-widget-action-icon",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 2v5H3v2h5v5h2V9h5V7H10V2H8z"})})}),e.jsx("span",{className:"branch-widget-action-label",children:o("terminal:fileExplorer.newBranch")})]})]}),v&&e.jsxs("div",{className:"branch-widget-new-branch",children:[e.jsx("input",{ref:U,type:"text",className:"branch-widget-new-branch-input",placeholder:o("terminal:fileExplorer.branchNamePlaceholder"),value:R,onChange:S=>x(S.target.value),onKeyDown:S=>{S.stopPropagation(),S.key==="Enter"&&Z(),S.key==="Escape"&&(N(!1),x(""))}}),e.jsx("button",{className:"branch-widget-new-branch-confirm",onClick:Z,disabled:!R.trim()||m,children:D==="create"?"...":o("common:buttons.create")})]}),e.jsxs("div",{className:"branch-widget-section-header",children:[o("terminal:fileExplorer.localBranches"),Y&&e.jsxs("span",{className:"branch-widget-loading-hint",children:[" ",o("terminal:fileExplorer.loading")]})]}),e.jsxs("div",{className:"branch-widget-branch-list",children:[H.length===0&&!Y&&e.jsx("div",{className:"branch-widget-empty",children:o("terminal:fileExplorer.noBranchesFound")}),H.map(S=>e.jsxs("div",{className:`branch-widget-branch-item ${S.isCurrent?"current":""} ${m?"disabled":""}`,onClick:()=>_(S),onContextMenu:te=>X(te,S),title:S.lastMessage||S.name,children:[e.jsxs("span",{className:"branch-widget-branch-name",children:[S.isCurrent&&e.jsx("span",{className:"branch-widget-current-marker",children:"*"}),S.name]}),S.lastCommit&&e.jsx("span",{className:"branch-widget-branch-commit",children:S.lastCommit})]},S.name))]}),$.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"branch-widget-section-header clickable",onClick:()=>g(!k),children:[e.jsx("span",{className:"branch-widget-section-toggle",children:k?"▾":"▸"}),o("terminal:fileExplorer.remoteBranches",{count:$.length})]}),k&&e.jsx("div",{className:"branch-widget-branch-list",children:$.map(S=>e.jsxs("div",{className:`branch-widget-branch-item remote ${m?"disabled":""}`,onClick:()=>_(S),onContextMenu:te=>X(te,S),title:S.lastMessage||S.name,children:[e.jsx("span",{className:"branch-widget-branch-name",children:S.name}),S.lastCommit&&e.jsx("span",{className:"branch-widget-branch-commit",children:S.lastCommit})]},S.name))})]})]}),T&&e.jsx(it,{isOpen:T.isOpen,position:T.position,worldPosition:{x:0,z:0},actions:oe,onClose:()=>A(null)})]})});function br(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function $t(t,n){if(!t)return"";const l=Os.languages[n];return l?Os.highlight(t,l,n):br(t)}function jr(t){const n=[],l=t.split(`
9
- `);let c=[],r=!1,i=[],h=[],o=!1;for(const d of l)d.startsWith("<<<<<<<")?(c.length>0&&(n.push({type:"unchanged",content:c.join(`
10
- `)}),c=[]),r=!0,o=!1,i=[],h=[]):d.startsWith("=======")&&r?o=!0:d.startsWith(">>>>>>>")&&r?(n.push({type:"conflict",ours:i.join(`
11
- `),theirs:h.join(`
12
- `),resolved:null}),r=!1,o=!1):r?o?h.push(d):i.push(d):c.push(d);return c.length>0&&n.push({type:"unchanged",content:c.join(`
13
- `)}),n}const vr=s.memo(function({file:n,versions:l,loading:c,onResolve:r,onClose:i,currentBranch:h,mergingBranch:o}){const{t:d}=le(["terminal"]),f=s.useMemo(()=>{var F;if(!(l!=null&&l.filename))return"plaintext";const D="."+((F=l.filename.split(".").pop())==null?void 0:F.toLowerCase());return Ut(D)},[l==null?void 0:l.filename]),b=s.useMemo(()=>l!=null&&l.merged?jr(l.merged):[],[l==null?void 0:l.merged]),[p,v]=s.useState(b),[N,R]=s.useState(!1);s.useMemo(()=>{v(b)},[b]);const x=s.useRef(null),[k,g]=s.useState(0),j=s.useMemo(()=>p.map((D,F)=>D.type==="conflict"?F:-1).filter(D=>D!==-1),[p]),w=j.length,T=s.useCallback(D=>{const F=x.current;if(!F||D<0||D>=j.length)return;const K=j[D],ne=F.querySelector(`[data-section-idx="${K}"]`);ne&&(ne.scrollIntoView({behavior:"smooth",block:"center"}),g(D))},[j]),A=s.useCallback(()=>{T(k>0?k-1:j.length-1)},[k,j.length,T]),V=s.useCallback(()=>{T(k<j.length-1?k+1:0)},[k,j.length,T]);s.useEffect(()=>{if(j.length>0&&x.current){const D=setTimeout(()=>T(0),100);return()=>clearTimeout(D)}},[j.length,T]);const C=s.useMemo(()=>{const D=p.filter(F=>F.type==="conflict");return D.length>0&&D.every(F=>F.resolved!==null)},[p]),U=s.useCallback((D,F)=>{v(K=>K.map((ne,re)=>re!==D||ne.type!=="conflict"?ne:{...ne,resolved:F}))},[]),ae=s.useCallback(D=>{v(F=>F.map(K=>K.type!=="conflict"?K:{...K,resolved:D}))},[]),Y=s.useCallback(async()=>{R(!0);try{const D=p.map(F=>F.type==="unchanged"?F.content:F.resolved==="ours"?F.ours:F.resolved==="theirs"?F.theirs:F.resolved==="both"?F.ours+`
14
- `+F.theirs:`<<<<<<< ${h}
15
- ${F.ours}
16
- =======
17
- ${F.theirs}
18
- >>>>>>> ${o}`).join(`
19
- `);await r(D)}finally{R(!1)}},[p,r,h,o]);return e.jsxs("div",{className:"conflict-resolver",children:[e.jsxs("div",{className:"conflict-header",children:[e.jsx("span",{className:"conflict-header-title",children:d("terminal:fileExplorer.resolveFile",{filename:l==null?void 0:l.filename})}),w>0&&e.jsxs("div",{className:"conflict-nav",children:[e.jsx("button",{className:"conflict-nav-btn",onClick:A,title:d("terminal:fileExplorer.prevConflict"),children:e.jsx(M,{name:"caret-up",size:10})}),e.jsxs("span",{className:"conflict-nav-counter",children:[k+1," / ",w]}),e.jsx("button",{className:"conflict-nav-btn",onClick:V,title:d("terminal:fileExplorer.nextConflict"),children:e.jsx(M,{name:"caret-down",size:10})})]}),e.jsx("button",{className:"conflict-close-btn",onClick:i,children:"×"})]}),c||!l?e.jsx("div",{className:"conflict-loading",children:d("terminal:fileExplorer.loadingConflictData")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"conflict-pane-headers",children:[e.jsx("div",{className:"conflict-pane-header current",children:d("terminal:fileExplorer.currentBranchLabel",{branch:h})}),e.jsx("div",{className:"conflict-pane-header incoming",children:d("terminal:fileExplorer.incomingBranchLabel",{branch:o})})]}),e.jsx("div",{className:"conflict-content",ref:x,children:p.map((D,F)=>D.type==="unchanged"?e.jsx("div",{className:"conflict-section-unchanged",children:e.jsxs("div",{className:"conflict-panes",children:[e.jsx("div",{className:"conflict-pane ours",children:e.jsx("pre",{dangerouslySetInnerHTML:{__html:$t(D.content,f)}})}),e.jsx("div",{className:"conflict-pane theirs",children:e.jsx("pre",{dangerouslySetInnerHTML:{__html:$t(D.content,f)}})})]})},F):e.jsxs("div",{"data-section-idx":F,className:`conflict-section-conflict ${D.resolved?"resolved":""}`,children:[e.jsxs("div",{className:"conflict-panes",children:[e.jsxs("div",{className:`conflict-pane ours ${D.resolved==="ours"||D.resolved==="both"?"accepted":""}`,children:[e.jsx("pre",{dangerouslySetInnerHTML:{__html:$t(D.ours,f)}}),e.jsx("button",{className:"conflict-accept-btn ours",onClick:()=>U(F,"ours"),disabled:D.resolved==="ours",children:D.resolved==="ours"?d("terminal:fileExplorer.accepted"):d("terminal:fileExplorer.acceptCurrent")})]}),e.jsxs("div",{className:`conflict-pane theirs ${D.resolved==="theirs"||D.resolved==="both"?"accepted":""}`,children:[e.jsx("pre",{dangerouslySetInnerHTML:{__html:$t(D.theirs,f)}}),e.jsx("button",{className:"conflict-accept-btn theirs",onClick:()=>U(F,"theirs"),disabled:D.resolved==="theirs",children:D.resolved==="theirs"?d("terminal:fileExplorer.accepted"):d("terminal:fileExplorer.acceptIncoming")})]})]}),e.jsx("button",{className:`conflict-accept-both-btn ${D.resolved==="both"?"accepted":""}`,onClick:()=>U(F,"both"),disabled:D.resolved==="both",children:D.resolved==="both"?d("terminal:fileExplorer.accepted"):d("terminal:fileExplorer.acceptBoth")})]},F))}),e.jsxs("div",{className:"conflict-actions",children:[e.jsx("button",{className:"conflict-action-btn accept-all-current",onClick:()=>ae("ours"),children:d("terminal:fileExplorer.acceptAllCurrent")}),e.jsx("button",{className:"conflict-action-btn accept-all-incoming",onClick:()=>ae("theirs"),children:d("terminal:fileExplorer.acceptAllIncoming")}),e.jsx("button",{className:"conflict-action-btn accept-all-both",onClick:()=>ae("both"),children:d("terminal:fileExplorer.acceptAllBoth")}),e.jsx("button",{className:"conflict-action-btn save-resolved",onClick:Y,disabled:!C||N,children:d(N?"terminal:fileExplorer.saving":"terminal:fileExplorer.saveAndResolve")})]})]})]})}),wr=16,Cr=s.memo(function t({node:n,depth:l,expandedDirs:c,onToggleDir:r,selectedPath:i,onSelect:h}){const{t:o}=le(["terminal"]),d=l*wr;if(!n.isDirectory){const b=n.file.status,p=yt[b],v=b==="deleted",N=n.file.name.includes(".")?"."+n.file.name.split(".").pop():"";return e.jsxs("div",{className:`git-file-item ${i===n.path?"selected":""}`,onClick:()=>!v&&h(n.file.path,b),style:{paddingLeft:`${d+4}px`,cursor:v?"not-allowed":"pointer"},title:n.file.path,children:[e.jsx("span",{className:"tree-arrow-spacer"}),e.jsx("img",{className:"tree-icon",src:xt(N),alt:"file"}),e.jsx("span",{className:"git-file-name",children:n.file.name}),e.jsx("span",{className:"git-file-status",style:{color:p.color},children:p.icon}),n.file.oldPath&&e.jsxs("span",{className:"git-file-renamed",children:["← ",n.file.oldPath.split("/").pop()]})]})}const f=c.has(n.path);return e.jsxs("div",{className:"tree-node-wrapper",children:[e.jsxs("div",{className:`tree-node directory ${f?"expanded":""}`,style:{paddingLeft:`${d+4}px`},onClick:()=>r(n.path),children:[e.jsx("span",{className:`tree-arrow ${f?"expanded":""}`,children:"►"}),e.jsx("img",{className:"tree-folder-icon",src:f?"/assets/vscode-icons/default_folder_opened.svg":"/assets/vscode-icons/default_folder.svg",alt:"folder"}),e.jsx("span",{className:"tree-name",children:n.name}),e.jsx("span",{className:"git-tree-file-count",children:o("terminal:fileExplorer.fileCount",{count:n.fileCount})})]}),f&&e.jsx("div",{className:"tree-children",children:n.children.map(b=>e.jsx(t,{node:b,depth:l+1,expandedDirs:c,onToggleDir:r,selectedPath:i,onSelect:h},b.path))})]})}),Nr=s.memo(function({file:n,isSelected:l,onSelect:c}){const r=yt[n.status],i=n.status==="deleted",h=n.name.includes(".")?"."+n.name.split(".").pop():"",o=n.path.includes("/")?n.path.slice(0,n.path.lastIndexOf("/")):"";return e.jsxs("div",{className:`git-file-item ${l?"selected":""}`,onClick:()=>!i&&c(n.path,n.status),style:{cursor:i?"not-allowed":"pointer"},title:n.path,children:[e.jsx("span",{className:"tree-arrow-spacer"}),e.jsx("img",{className:"tree-icon",src:xt(h),alt:"file"}),e.jsxs("span",{className:"git-file-name",children:[n.name,o&&e.jsx("span",{className:"git-file-dir",children:o})]}),e.jsx("span",{className:"git-file-status",style:{color:r.color},children:r.icon}),n.oldPath&&e.jsxs("span",{className:"git-file-renamed",children:["← ",n.oldPath.split("/").pop()]})]})});function kr({compareResult:t,loading:n,onFileSelect:l,selectedPath:c,onClose:r}){const{t:i}=le(["terminal"]),[h,o]=s.useState("tree"),[d,f]=s.useState(new Set),b=s.useMemo(()=>!t||t.files.length===0?[]:Ht(t.files),[t]),p=s.useMemo(()=>{const w=new Set;return At(b,w),w},[b]);s.useEffect(()=>{f(p)},[p]);const v=s.useCallback(w=>{f(T=>{const A=new Set(T);return A.has(w)?A.delete(w):A.add(w),A})},[]),N=s.useMemo(()=>t?[...t.files].sort((w,T)=>w.path.toLowerCase().localeCompare(T.path.toLowerCase())):[],[t]);if(n)return e.jsxs("div",{className:"branch-comparison",children:[e.jsxs("div",{className:"branch-comparison-header",children:[e.jsx("span",{className:"branch-comparison-title",children:i("terminal:fileExplorer.comparingBranches")}),e.jsx("button",{className:"branch-comparison-close",onClick:r,title:i("terminal:fileExplorer.closeComparison"),children:"×"})]}),e.jsx("div",{className:"branch-comparison-empty",children:e.jsx("div",{className:"branch-comparison-empty-text",children:i("terminal:fileExplorer.comparingBranches")})})]});if(!t)return null;const{files:R,counts:x,baseBranch:k,currentBranch:g}=t,j=R.length;return j===0?e.jsxs("div",{className:"branch-comparison",children:[e.jsxs("div",{className:"branch-comparison-header",children:[e.jsxs("span",{className:"branch-comparison-title",children:[g," vs ",k]}),e.jsx("button",{className:"branch-comparison-close",onClick:r,title:i("terminal:fileExplorer.closeComparison"),children:"×"})]}),e.jsxs("div",{className:"branch-comparison-empty",children:[e.jsx("div",{className:"branch-comparison-empty-icon",children:"✨"}),e.jsx("div",{className:"branch-comparison-empty-text",children:i("terminal:fileExplorer.noDifferences")})]})]}):e.jsxs("div",{className:"branch-comparison",children:[e.jsxs("div",{className:"branch-comparison-header",children:[e.jsxs("span",{className:"branch-comparison-title",children:["⇔ ",g," vs ",k]}),e.jsx("span",{className:"branch-comparison-file-count",children:i("terminal:fileExplorer.fileCount",{count:j})}),e.jsxs("div",{className:"git-changes-summary",children:[x.modified>0&&e.jsxs("span",{className:"git-count modified",children:[x.modified,"M"]}),x.added>0&&e.jsxs("span",{className:"git-count added",children:[x.added,"A"]}),x.deleted>0&&e.jsxs("span",{className:"git-count deleted",children:[x.deleted,"D"]}),x.renamed>0&&e.jsxs("span",{className:"git-count renamed",children:[x.renamed,"R"]}),(x.conflict??0)>0&&e.jsxs("span",{className:"git-count conflict",children:[x.conflict,"C"]})]}),e.jsxs("div",{className:"git-view-toggle",children:[e.jsx("button",{className:`git-view-toggle-btn ${h==="flat"?"active":""}`,onClick:()=>o("flat"),title:i("terminal:fileExplorer.flatList"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:[e.jsx("rect",{x:"2",y:"3",width:"12",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"2",y:"7",width:"12",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"2",y:"11",width:"12",height:"1.5",rx:"0.5"})]})}),e.jsx("button",{className:`git-view-toggle-btn ${h==="tree"?"active":""}`,onClick:()=>o("tree"),title:i("terminal:fileExplorer.directoryTree"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:[e.jsx("rect",{x:"1",y:"2",width:"6",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"4",y:"5.5",width:"8",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"4",y:"9",width:"8",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"7",y:"12.5",width:"7",height:"1.5",rx:"0.5"})]})})]}),e.jsx("button",{className:"branch-comparison-close",onClick:r,title:i("terminal:fileExplorer.closeComparison"),children:"×"})]}),e.jsx("div",{className:"branch-comparison-list",children:h==="tree"?b.map(w=>e.jsx(Cr,{node:w,depth:0,expandedDirs:d,onToggleDir:v,selectedPath:c,onSelect:l},w.path)):N.map(w=>e.jsx(Nr,{file:w,isSelected:c===w.path,onSelect:l},w.path))})]})}const un=s.memo(kr);un.displayName="BranchComparison";function Er(t){const n=new Date(t);if(isNaN(n.getTime()))return t||"—";const c=Date.now()-n.getTime(),r=Math.floor(c/6e4),i=Math.floor(r/60),h=Math.floor(i/24);if(h<4)return r<1?"just now":r<60?`${r}m ago`:i<24?`${i}h ago`:`${h}d ago`;const o=n.getFullYear(),d=String(n.getMonth()+1).padStart(2,"0"),f=String(n.getDate()).padStart(2,"0"),b=String(n.getHours()).padStart(2,"0"),p=String(n.getMinutes()).padStart(2,"0");return`${o}-${d}-${f} ${b}:${p}`}const Sr=s.memo(function({commit:n,isSelected:l,onSelect:c}){return e.jsxs("div",{className:`gh-row ${l?"selected":""}`,onClick:()=>c(n),children:[e.jsx("span",{className:"gh-col-hash",children:n.shortHash}),e.jsxs("span",{className:"gh-col-message",children:[e.jsx("span",{className:"gh-subject",children:n.subject}),n.refs.isHead&&e.jsx("span",{className:"gh-badge gh-badge-head",children:"HEAD"}),n.refs.branches.map(r=>e.jsx("span",{className:"gh-badge gh-badge-branch",children:r},r)),n.refs.tags.map(r=>e.jsx("span",{className:"gh-badge gh-badge-tag",children:r},r))]}),e.jsx("span",{className:"gh-col-author",children:n.author}),e.jsx("span",{className:"gh-col-date",children:Er(n.date)})]})}),Tr=s.memo(function({files:n,loading:l,selectedFilePath:c,onSelectFile:r}){const{t:i}=le(["common"]);return l?e.jsx("div",{className:"gh-files-loading",children:i("common:status.loading")}):n.length===0?e.jsx("div",{className:"gh-files-empty",children:"No changed files"}):e.jsx("div",{className:"gh-files-list",children:n.map(h=>{const o=h.path.split("/").pop()||h.path,d=h.path.includes("/")?h.path.substring(0,h.path.lastIndexOf("/")):"",f=yt[h.status],b=o.includes(".")?"."+o.split(".").pop():"";return e.jsxs("div",{className:`gh-file-row ${c===h.path?"selected":""}`,onClick:()=>r==null?void 0:r(h.path),title:h.path,children:[e.jsx("span",{className:"gh-file-status",style:{color:f.color},children:f.icon}),e.jsx("img",{className:"gh-file-icon",src:xt(b),alt:""}),e.jsx("span",{className:"gh-file-name",children:o}),d&&e.jsx("span",{className:"gh-file-dir",children:d})]},h.path)})})}),Mr=s.memo(function({history:n,currentFolder:l,onFileSelect:c}){const{t:r}=le(["terminal","common"]),i=s.useRef(null),[h,o]=s.useState(null),[d,f]=s.useState(!1),{commits:b,loading:p,loadingMore:v,error:N,hasMore:R,total:x,filters:k,setFilter:g,resetFilters:j,selectedCommit:w,selectCommit:T,commitFiles:A,commitFilesLoading:V,loadHistory:C,loadMore:U,authors:ae,loadAuthors:Y}=n,{branches:D,loadBranches:F}=is();s.useEffect(()=>{l&&(C(l),Y(l),F(l))},[l,C,Y,F]);const K=ta({count:b.length,getScrollElement:()=>i.current,estimateSize:()=>28,overscan:20}),ne=s.useCallback(()=>{const P=i.current;if(!P||v||!R||!l)return;const{scrollTop:G,scrollHeight:I,clientHeight:ie}=P;I-G-ie<200&&U(l)},[v,R,l,U]),re=s.useCallback(P=>{o(P),c&&w&&c(P,w.hash)},[c,w]),je=s.useMemo(()=>D.filter(P=>!P.isRemote).map(P=>P.name),[D]),_=!!(k.branch||k.author||k.since||k.until||k.searchPath||k.search),Z=K.getVirtualItems();return e.jsxs("div",{className:"gh-panel",children:[e.jsxs("div",{className:"gh-toolbar",children:[e.jsx("span",{className:"gh-toolbar-title",children:r("terminal:fileExplorer.gitHistory.title")}),e.jsx("span",{className:"gh-toolbar-count",children:p?"...":x>0?x:b.length}),e.jsx("input",{type:"text",className:"gh-search-input",placeholder:r("terminal:fileExplorer.gitHistory.searchPlaceholder"),value:k.search,onChange:P=>g("search",P.target.value)}),e.jsx("button",{className:`gh-filter-toggle ${d?"active":""} ${_?"has-filters":""}`,onClick:()=>f(!d),title:"Filters",children:e.jsx(M,{name:"gear",size:12})}),_&&e.jsx("button",{className:"gh-reset-btn",onClick:j,children:r("terminal:fileExplorer.gitHistory.resetFilters")})]}),d&&e.jsxs("div",{className:"gh-filters-row",children:[e.jsxs("select",{className:"gh-filter-select",value:k.branch,onChange:P=>g("branch",P.target.value),children:[e.jsx("option",{value:"",children:r("terminal:fileExplorer.gitHistory.allBranches")}),je.map(P=>e.jsx("option",{value:P,children:P},P))]}),e.jsxs("select",{className:"gh-filter-select",value:k.author,onChange:P=>g("author",P.target.value),children:[e.jsx("option",{value:"",children:r("terminal:fileExplorer.gitHistory.allAuthors")}),ae.map(P=>e.jsx("option",{value:P,children:P},P))]}),e.jsx("input",{type:"date",className:"gh-filter-input gh-date-input",value:k.since,onChange:P=>g("since",P.target.value),title:r("terminal:fileExplorer.gitHistory.since")}),e.jsx("input",{type:"date",className:"gh-filter-input gh-date-input",value:k.until,onChange:P=>g("until",P.target.value),title:r("terminal:fileExplorer.gitHistory.until")}),e.jsx("input",{type:"text",className:"gh-filter-input",placeholder:r("terminal:fileExplorer.gitHistory.pathFilter"),value:k.searchPath,onChange:P=>g("searchPath",P.target.value)})]}),e.jsxs("div",{className:"gh-body",children:[e.jsxs("div",{className:"gh-commits-section",children:[e.jsxs("div",{className:"gh-header-row",children:[e.jsx("span",{className:"gh-col-hash",children:"Hash"}),e.jsx("span",{className:"gh-col-message",children:"Message"}),e.jsx("span",{className:"gh-col-author",children:"Author"}),e.jsx("span",{className:"gh-col-date",children:"Date"})]}),p&&b.length===0?e.jsx("div",{className:"gh-state-msg",children:r("common:status.loading")}):N?e.jsx("div",{className:"gh-state-msg gh-error",children:N}):b.length===0?e.jsx("div",{className:"gh-state-msg",children:r("terminal:fileExplorer.gitHistory.noCommits")}):e.jsxs("div",{className:"gh-commit-scroll",ref:i,onScroll:ne,children:[e.jsx("div",{style:{height:`${K.getTotalSize()}px`,width:"100%",position:"relative"},children:Z.map(P=>e.jsx("div",{"data-index":P.index,ref:K.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${P.start}px)`},children:e.jsx(Sr,{commit:b[P.index],isSelected:(w==null?void 0:w.hash)===b[P.index].hash,onSelect:T})},P.key))}),v&&e.jsx("div",{className:"gh-loading-more",children:r("common:status.loading")})]})]}),w&&e.jsxs("div",{className:"gh-files-section",children:[e.jsxs("div",{className:"gh-files-header",children:[e.jsxs("span",{className:"gh-files-title",children:[A.length," ",A.length===1?"file":"files"]}),e.jsx("span",{className:"gh-files-commit-info",children:w.shortHash})]}),e.jsx(Tr,{files:A,loading:V,selectedFilePath:h,onSelectFile:re})]})]})]})});async function Dr({path:t,cwd:n,limit:l}){const c=new URLSearchParams({path:t,cwd:n});Number.isFinite(l)&&c.set("limit",String(l));const r=await W(O(`/api/files/git-file-history?${c.toString()}`));if(!r.ok){const h=await r.json().catch(()=>({}));throw new Error(h.error||`Failed to load file git history: ${r.statusText}`)}const i=await r.json();return{commits:Array.isArray(i.commits)?i.commits:[]}}async function Rr({path:t,cwd:n,sha:l}){const c=new URLSearchParams({path:t,cwd:n,sha:l}),r=await W(O(`/api/files/git-file-commit-diff?${c.toString()}`));if(!r.ok){const h=await r.json().catch(()=>({}));throw new Error(h.error||`Failed to load commit diff: ${r.statusText}`)}const i=await r.json();return i.binary===!0?{binary:!0,filename:i.filename??"",changeType:i.changeType??"modified"}:{binary:!1,filename:i.filename??"",language:i.language??"plaintext",changeType:i.changeType??"modified",originalContent:typeof i.originalContent=="string"?i.originalContent:"",modifiedContent:typeof i.modifiedContent=="string"?i.modifiedContent:""}}const Fr=100;function Pr(t){if(!t)return"";const n=Date.parse(t);if(Number.isNaN(n))return t;const l=Date.now()-n,c=Math.round(l/1e3);if(c<60)return`${c}s ago`;const r=Math.round(c/60);if(r<60)return`${r}m ago`;const i=Math.round(r/60);if(i<24)return`${i}h ago`;const h=Math.round(i/24);if(h<30)return`${h}d ago`;const o=Math.round(h/30);return o<12?`${o}mo ago`:`${Math.round(o/12)}y ago`}function Ir(t){if(!t)return"";const n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function Lr({isOpen:t,onClose:n,filePath:l,cwd:c}){const{t:r}=le(["terminal","common"]),[i,h]=s.useState([]),[o,d]=s.useState(!1),[f,b]=s.useState(null),[p,v]=s.useState(null),[N,R]=s.useState(null),[x,k]=s.useState(!1),[g,j]=s.useState(null);s.useEffect(()=>{if(!t)return;let V=!1;return h([]),v(null),R(null),j(null),b(null),d(!0),(async()=>{try{const C=await Dr({path:l,cwd:c,limit:Fr});if(V)return;h(C.commits),C.commits.length>0&&v(C.commits[0].sha)}catch(C){if(V)return;b(C instanceof Error?C.message:r("terminal:fileGitHistory.error"))}finally{V||d(!1)}})(),()=>{V=!0}},[t,l,c,r]),s.useEffect(()=>{if(!t||!p){R(null);return}let V=!1;return k(!0),j(null),R(null),(async()=>{try{const C=await Rr({path:l,cwd:c,sha:p});if(V)return;R(C)}catch(C){if(V)return;j(C instanceof Error?C.message:r("terminal:fileGitHistory.error"))}finally{V||k(!1)}})(),()=>{V=!0}},[t,p,l,c,r]);const w=s.useCallback(V=>{V.key==="Escape"&&(V.preventDefault(),n())},[n]),T=s.useMemo(()=>Ir(l),[l]),A=()=>x?e.jsxs("div",{className:"git-file-history-loading",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:r("terminal:fileGitHistory.loading")})]}):g?e.jsxs("div",{className:"git-file-history-empty",children:[e.jsx(M,{name:"warn",size:20}),e.jsx("p",{children:g})]}):N?N.binary?e.jsxs("div",{className:"git-file-history-empty",children:[e.jsx(M,{name:"file",size:20}),e.jsx("p",{children:r("terminal:fileGitHistory.binaryFile")})]}):e.jsx(ns,{originalContent:N.originalContent,modifiedContent:N.modifiedContent,filename:N.filename||T,filePath:l,language:N.language}):e.jsx("div",{className:"git-file-history-empty",children:e.jsx("p",{children:r("terminal:fileGitHistory.selectCommit")})});return t?e.jsx(sa,{children:e.jsx("div",{className:"modal-overlay visible",onClick:n,children:e.jsxs("div",{className:"git-file-history-modal",onClick:V=>V.stopPropagation(),onKeyDown:w,tabIndex:-1,children:[e.jsxs("div",{className:"modal-header",children:[e.jsxs("div",{className:"git-file-history-title",children:[e.jsx("h2",{children:r("terminal:fileGitHistory.title")}),e.jsx("span",{className:"git-file-history-filepath",title:l,children:T})]}),e.jsx("button",{className:"modal-close",onClick:n,"aria-label":"Close",children:e.jsx(M,{name:"close",size:16})})]}),e.jsxs("div",{className:"git-file-history-body",children:[e.jsx("aside",{className:"git-file-history-commit-list","aria-label":r("terminal:fileGitHistory.title"),children:o?e.jsxs("div",{className:"git-file-history-loading",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:r("terminal:fileGitHistory.loading")})]}):f?e.jsxs("div",{className:"git-file-history-empty",children:[e.jsx(M,{name:"warn",size:18}),e.jsx("p",{children:f})]}):i.length===0?e.jsx("div",{className:"git-file-history-empty",children:e.jsx("p",{children:r("terminal:fileGitHistory.empty")})}):e.jsx("ul",{className:"git-file-history-commits",role:"listbox",children:i.map(V=>{const C=V.sha===p;return e.jsxs("li",{className:`git-file-history-commit ${C?"selected":""}`,role:"option","aria-selected":C,onClick:()=>v(V.sha),children:[e.jsxs("div",{className:"git-file-history-commit-row",children:[e.jsx("span",{className:"git-file-history-sha",children:V.shortSha}),e.jsx("span",{className:"git-file-history-date",title:V.date,children:Pr(V.date)})]}),e.jsx("div",{className:"git-file-history-subject",title:V.subject,children:V.subject}),e.jsx("div",{className:"git-file-history-author",title:V.email,children:V.author})]},V.sha)})})}),e.jsx("section",{className:"git-file-history-diff","aria-live":"polite",children:A()})]})]})})}):null}function Ar({isOpen:t,areaId:n,onClose:l,onChangeArea:c,folderPath:r}){const{t:i}=le(["terminal","common"]),h=na(),o=aa(),d=ra(),f=!!r&&!n,b=!f&&n?h.get(n):null,p=f?[r]:(b==null?void 0:b.directories)||[],v=Array.from(h.values()),[N,R]=s.useState(0),[x,k]=s.useState(null),[g,j]=s.useState(!1),[w,T]=s.useState(""),A=s.useRef(null),V=p[N]||p[0]||null,C=V?V.replace(/\\/g,"/"):null,U=C?Lt(C):"";s.useEffect(()=>{R(0)},[r,f]),s.useEffect(()=>{!f&&r&&k(r)},[f,r]),s.useEffect(()=>{if(t)try{f&&r?localStorage.setItem("file-explorer-last-opened",JSON.stringify({type:"folder",path:r})):n&&localStorage.setItem("file-explorer-last-opened",JSON.stringify({type:"area",areaId:n}))}catch{}},[t,f,r,n]);const ae=s.useMemo(()=>{const a=[];for(const u of v)for(const y of u.directories)a.push({path:y,areaId:u.id,areaName:u.name,areaColor:u.color});return a},[v]),Y=s.useMemo(()=>{const a=w.trim().toLowerCase();return a?ae.filter(u=>{const y=(u.path.split("/").pop()||u.path).toLowerCase();return u.path.toLowerCase().includes(a)||y.includes(a)}):ae},[ae,w]);s.useEffect(()=>{var a;g?(a=A.current)==null||a.focus():T("")},[g]);const{tree:D,loading:F,expandedPaths:K,loadTree:ne,reloadDirectory:re,renamePathInTree:je,togglePath:_,expandToPath:Z,restoreExpandedPaths:P,setExpandedPaths:G}=ia(C),{gitStatus:I,loading:ie,loadGitStatus:ee}=ma(C),{mergeBranch:ve,mergeAbort:m,mergeContinue:X}=is(),oe=Pa(),{showToast:H}=sn(),{file:$,loading:S,error:te,loadFile:Q,clearFile:de,setFile:fe}=ja(),{treePanelWidth:se,handleResizeStart:we,isResizing:Ge}=Ea(),{mobileTreeHeight:He,handleResizeMouseDown:Gt,handleResizeTouchStart:Ae}=Da(),{loadProjectState:bt,saveProjectState:_e,loadRecentProjects:ct,pushRecentProject:jt}=ka(),[vt,wt]=s.useState(()=>ct()),Ct=s.useMemo(()=>{const a=new Map(ae.map(y=>[y.path.replace(/\\/g,"/"),y])),u=[];for(const y of vt){const z=a.get(y);if(z&&u.push(z),u.length>=5)break}return u},[vt,ae]),[ye,ue]=s.useState(null),[xe,ke]=s.useState("files"),[We,Re]=s.useState(""),[E,L]=s.useState([]),[B,be]=s.useState([]),[Me,qe]=s.useState(!1),[dt,me]=s.useState(null),[hn,Fe]=s.useState(null),[cs,Nt]=s.useState(!1),[Pe,_t]=s.useState(!1),[ut,mn]=s.useState(!1),[pn,ds]=s.useState(new Set),[us]=s.useState(!1),[Bt,fn]=s.useState(!1),[Vt,gn]=s.useState(250),ht=s.useRef(null),[Oe,kt]=s.useState(null),[xn,hs]=s.useState(!1),[Je,ms]=s.useState(null),[Ye,ps]=s.useState(null),[Xe,yn]=s.useState(null),[Kt,Wt]=s.useState({open:!1,path:"",cwd:""}),[pe,Be]=s.useState({isOpen:!1,node:null,value:"",submitting:!1}),[Ce,Qe]=s.useState({isOpen:!1,parentDir:"",isDirectory:!1,value:"",submitting:!1}),[Se,fs]=s.useState(null),bn=la(),Et=oa(bn),jn=ca(),[Ie,Ue]=s.useState([]),[he,De]=s.useState(null),[,qt]=s.useState(void 0),[gs,Ze]=s.useState(null),[mt,pt]=s.useState(null),[vn,et]=s.useState(null),[wn,xs]=s.useState(!1),[St,Jt]=s.useState(null),[ys,Yt]=s.useState(!1),[Tt,Mt]=s.useState(null),bs=s.useRef(null),Xt=s.useRef(null),js=s.useRef(null),ft=s.useRef(null),vs=s.useRef(C);s.useEffect(()=>{vs.current=C},[C]);const Dt=s.useRef(!1);s.useEffect(()=>{Dt.current=!1},[n,r]),s.useEffect(()=>{if(!t||Dt.current)return;if(f){Dt.current=!0,R(0);return}if(p.length===0)return;if(Dt.current=!0,x){const y=p.indexOf(x);R(y>=0?y:0),k(null);return}const a=p.map(y=>y.replace(/\\/g,"/")),u=ct().find(y=>a.includes(y));R(u?a.indexOf(u):0)},[t,f,p,x,ct]),s.useEffect(()=>{if(!t||!C)return;const a=setTimeout(()=>wt(jt(C)),250);return()=>clearTimeout(a)},[t,C,jt]),s.useEffect(()=>{if(!t||Pe||!C)return;const a=C;(async()=>{const y=await bt(a);vs.current===a&&(y?(Ue(y.tabs),De(y.activeTabPath),ke(y.viewMode),G(y.expandedPaths),ft.current=y.expandedPaths,Nt(!0),y.activeTabPath?(ue(y.activeTabPath),Q(y.activeTabPath)):(ue(null),de())):(Ue([]),De(null),ue(null),de(),ft.current=null),_t(!0))})()},[t,Pe,C,bt,G,Q,de]),s.useEffect(()=>{if(ft.current&&!F&&D.length>0){const a=ft.current;ft.current=null,P(a)}},[F,D,Pe,P]);const ws=s.useRef(null);s.useEffect(()=>{ws.current=Pe&&C?{key:C,state:{tabs:Ie,activeTabPath:he,viewMode:xe,expandedPaths:K}}:null},[Pe,C,Ie,he,xe,K]);const gt=s.useCallback(()=>{const a=ws.current;a&&_e(a.key,a.state)},[_e]);s.useEffect(()=>{if(!t||!Pe||!C)return;const a=C,u=setTimeout(()=>{_e(a,{tabs:Ie,activeTabPath:he,viewMode:xe,expandedPaths:K})},500);return()=>clearTimeout(u)},[t,Pe,C,Ie,he,xe,K,_e]),s.useEffect(()=>()=>gt(),[gt]);const Cs=s.useRef(t);s.useEffect(()=>{Cs.current&&!t&&gt(),Cs.current=t},[t,gt]),s.useEffect(()=>{_t(!1)},[C]),s.useEffect(()=>{if(!pe.isOpen)return;const a=window.setTimeout(()=>{var u,y;(u=Xt.current)==null||u.focus(),(y=Xt.current)==null||y.select()},0);return()=>window.clearTimeout(a)},[pe.isOpen]),s.useEffect(()=>{if(!Ce.isOpen)return;const a=window.setTimeout(()=>{var u;(u=js.current)==null||u.focus()},0);return()=>window.clearTimeout(a)},[Ce.isOpen]);const Le=s.useMemo(()=>{const a=We.trim(),u=a.match(/^(.+):(\d+)$/);return u?{query:u[1],lineNumber:parseInt(u[2],10)}:{query:a,lineNumber:void 0}},[We]);s.useEffect(()=>{if(!Le.query||!C){L([]),be([]),qe(!1);return}qe(!0);const a=new AbortController,{signal:u}=a,y=setTimeout(async()=>{try{const z=Le.query,J=W(O(`/api/files/search?path=${encodeURIComponent(C)}&q=${encodeURIComponent(z)}&limit=200`),{signal:u}).then(ge=>ge.json()).catch(()=>({results:[]})),q=z.length>=2&&!Le.lineNumber?W(O(`/api/files/search-content?path=${encodeURIComponent(C)}&q=${encodeURIComponent(z)}&limit=200`),{signal:u}).then(ge=>ge.json()).catch(()=>({results:[]})):Promise.resolve({results:[]}),[Ne,ce]=await Promise.all([J,q]);if(u.aborted)return;L(Ne.results||[]),be(ce.results||[])}catch(z){if(u.aborted)return;console.error("[FileExplorer] Search failed:",z),L([]),be([])}u.aborted||qe(!1)},300);return()=>{clearTimeout(y),a.abort()}},[Le.query,Le.lineNumber,C]),s.useEffect(()=>{t&&C&&(de(),ue(null),me(null),Fe(null),Nt(!1),ne(),ee())},[t,C,ne,ee,de]),s.useEffect(()=>{if(o&&t){const a=o;if(d){const u=Lt(a),y=a.substring(a.lastIndexOf(".")).toLowerCase();Rt(a,u,y),Ft(a)}else Q(a),ue(a);Ve.clearFileViewerPath()}},[o,d,t,Q]),s.useEffect(()=>{Pe&&!cs&&I&&Nt(!0)},[I,cs,Pe,xe]),s.useEffect(()=>{if(n&&(de(),ue(null),Re(""),be([]),L([]),me(null),Fe(null),Nt(!1),_t(!1),x)){const a=h.get(n);a!=null&&a.directories.includes(x)||k(null)}},[n,x,h,de]),s.useEffect(()=>{const a=y=>{var J;if(!t)return;if(y.altKey&&y.key==="e"){y.preventDefault(),y.stopPropagation(),l();return}if(y.key==="Escape"){if(pe.isOpen){y.preventDefault(),y.stopPropagation(),pe.submitting||Be({isOpen:!1,node:null,value:"",submitting:!1});return}if(us)return;if(g){y.preventDefault(),y.stopPropagation(),j(!1);return}y.preventDefault(),y.stopPropagation(),l();return}(y.metaKey||y.ctrlKey)&&y.key==="p"&&(y.preventDefault(),(J=bs.current)==null||J.focus());const z=Ve.getShortcuts().find(q=>q.id==="file-explorer-close-tab");if(ha(y,z)){if(y.repeat)return;y.preventDefault(),y.stopPropagation(),he&&Ss(he)}},u=y=>{const z=y.target;g&&!z.closest(".file-explorer-folder-selector")&&!z.closest(".file-explorer-folder-dropdown")&&j(!1)};return document.addEventListener("keydown",a,!0),document.addEventListener("click",u),()=>{document.removeEventListener("keydown",a,!0),document.removeEventListener("click",u)}},[t,l,g,he,us,pe]);const Ns=s.useMemo(()=>{const a=new Map;if(I!=null&&I.files)for(const u of I.files)a.set(u.path,u.status);return a},[I==null?void 0:I.files]),Qt=s.useMemo(()=>{const a=new Map;if(!(I!=null&&I.files))return a;const u={conflict:0,modified:1,added:2,deleted:3,untracked:4,renamed:5};for(const y of I.files){let z=y.path.replace(/\\/g,"/");for(;;){const J=z.lastIndexOf("/");if(J<=0)break;z=z.substring(0,J);const q=a.get(z);q?u[y.status]<u[q]&&a.set(z,y.status):a.set(z,y.status)}}return a},[I==null?void 0:I.files]),ks=s.useMemo(()=>{const a=u=>({...u,gitStatus:u.isDirectory?Qt.get(u.path):Ns.get(u.path),hasGitChanges:u.isDirectory&&Qt.has(u.path)||void 0,children:u.children?u.children.map(a):void 0});return D.map(a)},[D,Ns,Qt]),Rt=(a,u,y,z)=>{if(!Ie.find(q=>q.path===a)){const q={path:a,filename:u,extension:y};Ue(Ne=>[...Ne,q])}De(a),ue(a),qt(z),Q(a)},Es=async a=>{if(a.isDirectory){ke("files"),Re(""),await Z(a.path),ue(a.path),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let u=a.path,y=document.querySelector(`[data-path="${u}"]`);for(;!y&&u.includes("/");)u=u.substring(0,u.lastIndexOf("/")),y=document.querySelector(`[data-path="${u}"]`);y instanceof HTMLElement&&y.scrollIntoView({behavior:"smooth",block:"center"})})});return}Fe(null),me(null),Rt(a.path,a.name,a.extension,Le.lineNumber)},Cn=(a,u)=>{Fe(null),me(null);const y=Lt(a),z=a.substring(a.lastIndexOf(".")).toLowerCase();Rt(a,y,z,u)},Nn=async(a,u)=>{Fe(u),me(null);const y=Lt(a),z=a.substring(a.lastIndexOf(".")).toLowerCase();if(Rt(a,y,z),u==="modified"){const{content:J}=await pa(a);J!==null&&me(J)}},kn=a=>{De(a),ue(a),Fe(null),me(null),qt(void 0);const u=Ie.find(y=>y.path===a);u!=null&&u.data||Q(a)},Ss=a=>{Ue(u=>{var J;const y=u.filter(q=>q.path!==a),z=u.findIndex(q=>q.path===a);if(z!==-1&&((J=u[z])==null?void 0:J.path)===a&&(he===a||u.find(q=>q.path===he)),y.length>0){if(!y.some(Ne=>Ne.path===he)){const Ne=u.findIndex(Ee=>Ee.path===a),ce=Math.max(0,Math.min(Ne,y.length-1)),ge=y[ce];ge&&(De(ge.path),ue(ge.path),Q(ge.path))}}else De(null),ue(null),de();return y})},En=s.useCallback(()=>{Ue([]),De(null),ue(null),de()},[de]),Zt=a=>{if(j(!1),a.path.replace(/\\/g,"/")!==C)if(gt(),a.areaId!==n)k(a.path),c&&c(a.areaId);else{const u=p.indexOf(a.path);R(u>=0?u:0)}},$e=s.useCallback(a=>{const u=a.lastIndexOf("/");return u<=0?"/":a.slice(0,u)},[]),tt=s.useCallback((a,u,y)=>a===u?y:a.startsWith(`${u}/`)?`${y}${a.slice(u.length)}`:a,[]),Sn=s.useCallback((a,u)=>{ue(u.path),ms({isOpen:!0,position:{x:a.clientX,y:a.clientY},node:u})},[]),Tn=s.useCallback(a=>{a.defaultPrevented||C&&(a.preventDefault(),ps({isOpen:!0,position:{x:a.clientX,y:a.clientY},parentDir:C}))},[C]),Ts=s.useCallback(a=>{Be({isOpen:!0,node:a,value:a.name,submitting:!1})},[]),st=s.useCallback(()=>{Be({isOpen:!1,node:null,value:"",submitting:!1})},[]),nt=s.useCallback((a,u)=>{a&&Qe({isOpen:!0,parentDir:a,isDirectory:u,value:"",submitting:!1})},[]),at=s.useCallback(()=>{Qe({isOpen:!1,parentDir:"",isDirectory:!1,value:"",submitting:!1})},[]),Ms=s.useCallback(a=>{fs({node:a})},[]),Mn=s.useCallback(async()=>{const a=Se==null?void 0:Se.node;if(a)try{const u=await W(O("/api/files/delete"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a.path,recursive:a.isDirectory})}),y=await u.json().catch(()=>({}));if(!u.ok){H("error","Delete Failed",y.error||"Unable to delete item");return}Ue(J=>J.filter(q=>q.path!==a.path&&!q.path.startsWith(`${a.path}/`))),(he===a.path||he!=null&&he.startsWith(`${a.path}/`))&&(De(null),de()),(ye===a.path||ye!=null&&ye.startsWith(`${a.path}/`))&&ue(null);const z=$e(a.path);await re(z),await ee(),H("success",a.isDirectory?"Folder Deleted":"File Deleted",a.name)}catch(u){console.error("[FileExplorer] Delete failed:",u),H("error","Delete Failed","Unable to delete item")}},[Se,he,ye,$e,re,ee,H,de]),Ds=s.useCallback(async()=>{const{parentDir:a,isDirectory:u,value:y}=Ce,z=y.trim();if(!a||!z){at();return}if(z.includes("/")||z.includes("\\")){H("error","Invalid Name","Name must not contain path separators");return}Qe(J=>({...J,submitting:!0}));try{const J=await W(O("/api/files/create"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parentDir:a,name:z,isDirectory:u})}),q=await J.json();if(!J.ok){H("error","Create Failed",q.error||"Unable to create item"),Qe(ge=>({...ge,submitting:!1}));return}const Ne=q.path,ce=new Set(K);ce.add(a),await re(a),G(ce),await ee(),ue(Ne),H("success",u?"Folder Created":"File Created",z),at()}catch(J){console.error("[FileExplorer] Create failed:",J),H("error","Create Failed","Unable to create item"),Qe(q=>({...q,submitting:!1}))}},[Ce,K,re,G,ee,H,at]),Rs=s.useCallback(async()=>{const a=pe.node;if(!a)return;const u=pe.value.trim();if(!u||u===a.name){st();return}Be(y=>({...y,submitting:!0}));try{const y=await W(O("/api/files/rename"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a.path,newName:u})}),z=await y.json();if(!y.ok){H("error","Rename Failed",z.error||"Unable to rename item"),Be(Ee=>({...Ee,submitting:!1}));return}const J=z.newPath,q=a.path,Ne=new Set(Array.from(K).map(Ee=>tt(Ee,q,J))),ce=$e(q),ge=$e(J);if(Ue(Ee=>Ee.map(Te=>{if(!Te.path.startsWith(q))return Te;const rt=tt(Te.path,q,J),Pt=rt.split("/").pop()||rt,As=Pt.includes(".")?`.${Pt.split(".").pop()}`:"";return{...Te,path:rt,filename:Pt,extension:As.toLowerCase(),data:Te.data?{...Te.data,path:rt,filename:Pt,extension:As.toLowerCase()}:Te.data}})),he&&De(tt(he,q,J)),ye&&ue(tt(ye,q,J)),$!=null&&$.path){const Ee=tt($.path,q,J);if(Ee!==$.path){const Te=Ee.split("/").pop()||Ee,rt=Te.includes(".")?`.${Te.split(".").pop()}`:"";fe({...$,path:Ee,filename:Te,extension:rt.toLowerCase()})}}je(q,J),G(Ne),await re(ce),ge!==ce&&await re(ge),await ee(),H("success","Renamed",`${a.name} renamed`),st()}catch(y){console.error("[FileExplorer] Rename failed:",y),H("error","Rename Failed","Unable to rename item"),Be(z=>({...z,submitting:!1}))}},[pe,st,he,ye,$,K,tt,$e,je,G,re,ee,H,fe]),Fs=s.useCallback(a=>{yn({sourcePath:a.path,isDirectory:a.isDirectory,name:a.name}),H("info","Copied",`${a.name} ready to paste`)},[H]),Ps=s.useCallback(async a=>{if(!Xe)return;const u=a.isDirectory?a.path:$e(a.path),y=new Set(K);y.add(u);try{const z=await W(O("/api/files/paste"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourcePath:Xe.sourcePath,targetDir:u})}),J=await z.json();if(!z.ok){H("error","Paste Failed",J.error||"Unable to paste item");return}await re(u),G(y),await ee(),J.destinationPath&&ue(J.destinationPath),H("success","Pasted",`${Xe.name} pasted`)}catch(z){console.error("[FileExplorer] Paste failed:",z),H("error","Paste Failed","Unable to paste item")}},[Xe,$e,K,re,G,ee,H]),Is=s.useCallback(async a=>{try{await navigator.clipboard.writeText(a.path),H("success","Copied","Full path copied")}catch(u){console.error("[FileExplorer] Copy path failed:",u),H("error","Copy Failed","Could not copy path")}},[H]),Ls=s.useCallback(a=>{a.isDirectory||!C||Wt({open:!0,path:a.path,cwd:C})},[C]),Dn=s.useCallback(a=>{!C||!a||Wt({open:!0,path:a,cwd:C})},[C]),$s=s.useCallback(async a=>{try{await Ve.runTests(a.path)}catch(u){H("error","Run Tests Failed",u instanceof Error?u.message:"Unable to start tests")}},[H]),Rn=s.useMemo(()=>{if(!Je)return[];const a=Je.node,u=a.isDirectory?a.path:$e(a.path),y=[{id:"create-file",label:a.isDirectory?"New File...":"New File Here...",icon:e.jsx(M,{name:"file-text",size:14}),onClick:()=>nt(u,!1)},{id:"create-folder",label:a.isDirectory?"New Folder...":"New Folder Here...",icon:e.jsx(M,{name:"folder",size:14}),onClick:()=>nt(u,!0)},{id:"divider-create",label:"",divider:!0,onClick:()=>{}},{id:"rename",label:a.isDirectory?"Rename Folder":"Rename File",icon:e.jsx(M,{name:"edit",size:14}),onClick:()=>Ts(a)},{id:"copy",label:a.isDirectory?"Copy Folder":"Copy File",icon:e.jsx(M,{name:"file-text",size:14}),onClick:()=>Fs(a)},{id:"paste",label:a.isDirectory?"Paste Into Folder":"Paste Here",icon:e.jsx(M,{name:"clipboard",size:14}),disabled:!Xe,onClick:()=>{Ps(a)}},{id:"divider-1",label:"",divider:!0,onClick:()=>{}},{id:"copy-full-path",label:"Copy Full Path",icon:e.jsx(M,{name:"pin",size:14}),onClick:()=>{Is(a)}}];return a.runnerType&&y.push({id:"divider-run-tests",label:"",divider:!0,onClick:()=>{}},{id:"run-tests",label:a.isDirectory?"Run Tests":"Run This Test",icon:e.jsx(M,{name:"flask",size:14}),onClick:()=>{$s(a)}}),a.isDirectory||y.push({id:"divider-git-history",label:"",divider:!0,onClick:()=>{}},{id:"git-history",label:i("terminal:fileExplorer.showGitHistory")??"Show Git History",icon:e.jsx(M,{name:"git-commit",size:14}),onClick:()=>Ls(a)}),y.push({id:"divider-delete",label:"",divider:!0,onClick:()=>{}},{id:"delete",label:a.isDirectory?"Delete Folder":"Delete File",icon:e.jsx(M,{name:"trash",size:14}),danger:!0,onClick:()=>Ms(a)}),y},[Je,Xe,$e,nt,Ts,Fs,Ps,Is,Ls,Ms,$s,i]),Fn=s.useMemo(()=>{if(!Ye)return[];const a=Ye.parentDir;return[{id:"create-file-root",label:"New File...",icon:e.jsx(M,{name:"file-text",size:14}),onClick:()=>nt(a,!1)},{id:"create-folder-root",label:"New Folder...",icon:e.jsx(M,{name:"folder",size:14}),onClick:()=>nt(a,!0)}]},[Ye,nt]),Ft=s.useCallback(async a=>{ke("files"),Re(""),await Z(a),ue(a),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let u=a,y=document.querySelector(`[data-path="${u}"]`);for(;!y&&u.includes("/");)u=u.substring(0,u.lastIndexOf("/")),y=document.querySelector(`[data-path="${u}"]`);y instanceof HTMLElement&&y.scrollIntoView({behavior:"smooth",block:"center"})})})},[Z]),Pn=s.useCallback(async a=>{if(!(!C||a.length===0)){ds(u=>{const y=new Set(u);for(const z of a)y.add(z);return y});try{const u=await W(O("/api/files/git-add"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:a,directory:C})});if(u.ok)await ee();else{const y=await u.json();console.error("[FileExplorer] Git add failed:",y.error)}}catch(u){console.error("[FileExplorer] Git add failed:",u)}finally{ds(u=>{const y=new Set(u);for(const z of a)y.delete(z);return y})}}},[C,ee]),In=s.useCallback(async a=>{if(!C)return;Ze(a);const u=await ve(C,a);if(await ee(),u.success)Ze(null),H("success","Merge Complete",`Merged '${a}' successfully`),ne();else if(u.conflicts&&u.conflicts.length>0){const y=u.conflicts.length;H("warning","Merge Conflicts",`${y} conflict${y>1?"s":""} found — resolve to continue`),ke("git")}else Ze(null),H("error","Merge Failed",u.error||"Merge failed")},[C,ve,ee,ne,H]),Ln=s.useCallback(async a=>{Ze("remote"),await ee();const u=a.length;H("warning","Pull Conflicts",`${u} conflict${u>1?"s":""} found — resolve to continue`),ke("git")},[ee,H]),$n=s.useCallback(async a=>{if(C){pt(a),xs(!0),et(null);try{const u=await W(O(`/api/files/git-conflict-file?path=${encodeURIComponent(C)}&file=${encodeURIComponent(a)}`)),y=await u.json();u.ok?et(y):console.error("[FileExplorer] Failed to load conflict file:",y.error)}catch(u){console.error("[FileExplorer] Failed to load conflict file:",u)}finally{xs(!1)}}},[C]),zn=s.useCallback(async a=>{if(!(!C||!mt))try{const u=await W(O("/api/files/git-resolve-conflict"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:C,file:mt,content:a})}),y=await u.json();u.ok&&y.success?(pt(null),et(null),await ee()):console.error("[FileExplorer] Failed to resolve conflict:",y.error)}catch(u){console.error("[FileExplorer] Failed to resolve conflict:",u)}},[C,mt,ee]),Hn=s.useCallback(async()=>{if(!C)return;const a=await X(C);a.success?(Ze(null),pt(null),et(null),H("success","Merge Complete","Merge completed successfully"),await ee(),ne()):H("error","Merge Failed",a.error||"Merge continue failed")},[C,X,ee,ne,H]),An=s.useCallback(async()=>{if(!C)return;const a=await m(C);a.success?(Ze(null),pt(null),et(null),H("info","Merge Aborted","Merge has been aborted"),await ee(),ne()):H("error","Abort Failed",a.error||"Failed to abort merge")},[C,m,ee,ne,H]),On=s.useCallback(async a=>{if(C){Mt(a),Yt(!0),Jt(null),ke("compare");try{const u=await W(O(`/api/files/git-branch-compare?directory=${encodeURIComponent(C)}&branch=${encodeURIComponent(a)}`)),y=await u.json();u.ok?Jt(y):(H("error","Compare Failed",y.error||"Failed to compare branches"),ke("files"),Mt(null))}catch(u){console.error("[FileExplorer] Branch compare failed:",u),H("error","Compare Failed","Network error during comparison"),ke("files"),Mt(null)}finally{Yt(!1)}}},[C,H]),Un=s.useCallback(async(a,u)=>{if(!C||!Tt)return;const y=a.split("/").pop()||a,z=a.substring(a.lastIndexOf(".")).toLowerCase();Ie.find(ce=>ce.path===a)||Ue(ce=>[...ce,{path:a,filename:y,extension:z}]),De(a),ue(a),qt(void 0);const q=async ce=>{try{const ge=await W(O(`/api/files/git-show?path=${encodeURIComponent(a)}&ref=${encodeURIComponent(ce)}`)),Ee=await ge.json();return ge.ok?Ee.content??"":""}catch{return""}},Ne=ce=>({path:a,filename:y,extension:z,content:ce,fileType:"text",size:ce.length,modified:""});if(u==="modified"||u==="renamed"){const[ce,ge]=await Promise.all([q(Tt),q("HEAD")]);me(ce),fe(Ne(ge)),Fe("modified")}else if(u==="deleted"){const ce=await q(Tt);me(ce),fe(Ne("")),Fe("modified")}else if(u==="added"){const ce=await q("HEAD");me(""),fe(Ne(ce)),Fe("modified")}},[C,Tt,Ie]),zs=s.useCallback(()=>{ke("files"),Jt(null),Mt(null),Yt(!1)},[]),Gn=s.useCallback(async(a,u)=>{if(C){hs(!0);try{const y=new URLSearchParams({path:C,hash:u,file:a}),z=await W(O(`/api/files/git-commit-file-diff?${y}`)),J=await z.json();z.ok?kt(J):kt(null)}catch(y){console.error("[FileExplorer] commit diff fetch error:",y),kt(null)}finally{hs(!1)}}},[C]),_n=s.useCallback(()=>{kt(null)},[]),Bn=s.useCallback(a=>{a.preventDefault(),ht.current={startY:a.clientY,startHeight:Vt};const u=z=>{if(!ht.current)return;const J=ht.current.startY-z.clientY,q=Math.max(120,Math.min(600,ht.current.startHeight+J));gn(q)},y=()=>{ht.current=null,document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",y)};document.addEventListener("mousemove",u),document.addEventListener("mouseup",y)},[Vt]);if(!t||!b&&!f)return null;const Hs=(I==null?void 0:I.files.length)||0;return e.jsxs("div",{className:"file-explorer-panel ide-style",children:[e.jsxs("div",{className:"file-explorer-panel-header",children:[e.jsxs("div",{className:"file-explorer-panel-header-row",children:[e.jsxs("div",{className:"file-explorer-panel-title",children:[C&&e.jsxs("div",{className:"file-explorer-folder-selector",onClick:()=>ae.length>0&&j(!g),style:{cursor:ae.length>0?"pointer":"default"},title:C,children:[e.jsx("span",{className:"file-explorer-panel-dot",style:{background:(b==null?void 0:b.color)||"#ffd700"}}),e.jsx("span",{className:"file-explorer-folder-name",children:U}),e.jsx("span",{className:"file-explorer-folder-path-hint",children:C}),ae.length>1&&e.jsx("span",{className:"file-explorer-folder-dropdown-icon",children:e.jsx(M,{name:"caret-down",size:10})})]}),(I==null?void 0:I.isGitRepo)&&C&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"file-explorer-path-separator",children:"/"}),e.jsx(yr,{currentFolder:C,gitStatus:I,onBranchChanged:()=>{ee(),ne()},onMerge:In,onCompare:On,onPullConflicts:Ln})]}),$&&e.jsxs("span",{className:"file-explorer-current-file",children:["/ ",$.filename]}),g&&ae.length>0&&e.jsxs("div",{className:"file-explorer-folder-dropdown",onWheel:a=>{a.preventDefault(),a.currentTarget.scrollTop+=a.deltaY*.35},children:[e.jsx("div",{className:"file-explorer-folder-dropdown-search",onClick:a=>a.stopPropagation(),children:e.jsx("input",{ref:A,type:"text",className:"file-explorer-folder-dropdown-search-input",placeholder:"Filter folders…",value:w,onChange:a=>T(a.target.value),onKeyDown:a=>{a.key==="Enter"&&Y.length>0&&(a.preventDefault(),Zt(Y[0]))},spellCheck:!1,autoComplete:"off","aria-label":"Filter folders"})}),Y.length===0?e.jsx("div",{className:"file-explorer-folder-dropdown-empty",children:"No matching folders"}):Y.map(a=>e.jsxs("div",{className:`file-explorer-folder-option ${a.path===C?"active":""}`,onClick:u=>{u.stopPropagation(),Zt(a)},children:[e.jsxs("span",{className:"file-explorer-folder-option-name",children:[e.jsx("span",{className:"file-explorer-folder-option-dot",style:{background:a.areaColor}}),a.path.split("/").pop()||a.path]}),(a.path.split("/").pop()||a.path)!==a.path&&e.jsx("span",{className:"file-explorer-folder-option-path",children:a.path}),e.jsx("span",{className:"file-explorer-folder-option-area",children:a.areaName})]},`${a.areaId}-${a.path}`))]})]}),(I==null?void 0:I.isGitRepo)&&e.jsx("button",{className:`file-explorer-history-toggle ${Bt?"active":""}`,onClick:()=>fn(!Bt),title:i("terminal:fileExplorer.gitHistory.title"),children:e.jsx(M,{name:"status-waiting-input",size:14})}),Et&&!jn&&e.jsxs("button",{className:`file-explorer-test-results-toggle status-${Et.status}`,onClick:()=>Ve.openTestResults(),title:Et.status==="running"?"Tests running — open results":"Open last test results",children:[e.jsx(M,{name:"flask",size:14}),Et.status==="running"&&e.jsx("span",{className:"fe-test-run-dot"})]}),e.jsx("button",{className:"file-explorer-panel-close",onClick:l,children:"×"})]}),Ct.length>1&&e.jsx("div",{className:"file-explorer-recent-projects",role:"group","aria-label":"Recent projects",children:Ct.map(a=>{const u=a.path.split("/").pop()||a.path,y=a.path.replace(/\\/g,"/")===C;return e.jsxs("button",{type:"button",className:`file-explorer-recent-chip ${y?"active":""}`,onClick:()=>Zt(a),title:a.path,children:[e.jsx("span",{className:"file-explorer-recent-chip-dot",style:{background:a.areaColor}}),e.jsx("span",{className:"file-explorer-recent-chip-name",children:u})]},`${a.areaId}-${a.path}`)})})]}),e.jsxs("div",{className:"file-explorer-main",style:He>0?{"--fe-mobile-tree-height":`${He}px`}:void 0,children:[e.jsxs("div",{className:`file-explorer-tree-panel ${ut?"collapsed":""}`,style:{width:se},children:[e.jsxs("div",{className:"file-explorer-tabs",children:[e.jsx("button",{className:"file-explorer-tree-toggle",onClick:()=>mn(!ut),title:i(ut?"terminal:fileExplorer.expandTree":"terminal:fileExplorer.collapseTree"),children:e.jsx(M,{name:ut?"caret-down":"caret-up",size:12})}),e.jsxs("button",{className:`file-explorer-tab ${xe==="files"?"active":""}`,onClick:()=>ke("files"),children:[e.jsx("span",{className:"tab-icon",children:e.jsx(M,{name:"folder",size:14})}),i("terminal:spotlight.files")]}),e.jsxs("button",{className:`file-explorer-tab ${xe==="git"?"active":""}`,onClick:()=>ke("git"),children:[e.jsx("span",{className:"tab-icon",children:e.jsx(M,{name:"git-branch",size:14})}),i("terminal:fileExplorer.gitChanges"),Hs>0&&e.jsx("span",{className:"tab-badge",children:Hs})]}),(St||ys)&&e.jsxs("button",{className:`file-explorer-tab ${xe==="compare"?"active":""}`,onClick:()=>ke("compare"),children:[e.jsx("span",{className:"tab-icon",children:e.jsx(M,{name:"arrows-horizontal",size:14})}),i("terminal:fileExplorer.diffView"),St&&e.jsx("span",{className:"tab-badge",children:St.files.length}),e.jsx("span",{className:"tab-close-btn",onClick:a=>{a.stopPropagation(),zs()},children:"×"})]})]}),xe==="files"&&e.jsxs("div",{className:"file-explorer-toolbar",children:[e.jsxs("div",{className:"file-explorer-search",children:[e.jsx("span",{className:"file-explorer-search-icon",children:e.jsx(M,{name:"search",size:14})}),e.jsx("input",{ref:bs,type:"text",className:"file-explorer-search-input",placeholder:i("terminal:fileExplorer.searchPlaceholder"),value:We,onChange:a=>Re(a.target.value)}),We&&e.jsx("button",{className:"file-explorer-search-clear",onClick:()=>Re(""),children:"×"})]}),e.jsxs("div",{className:"file-explorer-toolbar-buttons",children:[e.jsx("button",{className:"file-explorer-toolbar-btn",onClick:()=>G(new Set),title:i("terminal:fileExplorer.collapseAll"),children:"⊟"}),he&&e.jsx("button",{className:"file-explorer-toolbar-btn",onClick:()=>Ft(he),title:i("terminal:fileExplorer.revealInTree"),children:e.jsx(M,{name:"target",size:14})})]})]}),e.jsx("div",{className:"file-explorer-tree-content",onContextMenu:xe==="files"?Tn:void 0,children:xe==="compare"?e.jsx(un,{compareResult:St,loading:ys,onFileSelect:Un,selectedPath:ye,onClose:zs}):xe==="files"?F?e.jsx("div",{className:"tree-loading",children:i("common:status.loading")}):Le.query?Me?e.jsx("div",{className:"tree-loading",children:i("terminal:fileExplorer.searching")}):e.jsx(on,{filenameResults:E,contentResults:B,onSelectFile:Es,onSelectContent:Cn,selectedPath:ye,query:Le.query,lineNumber:Le.lineNumber}):e.jsx("div",{className:"file-tree",children:ks.length===0?e.jsx("div",{className:"tree-empty",children:i("terminal:fileExplorer.noDirectoriesLinked")}):ks.map(a=>e.jsx(da,{node:a,depth:0,selectedPath:ye,expandedPaths:K,onSelect:Es,onToggle:_,onContextMenu:Sn,searchQuery:""},a.path))}):e.jsx(cn,{gitStatus:I,loading:ie,onFileSelect:Nn,selectedPath:ye,onRefresh:ee,onStageFiles:Pn,stagingPaths:pn,currentFolder:C,onCommitComplete:()=>{ee(),ne()},mergeInProgress:I==null?void 0:I.mergeInProgress,mergingBranch:gs,onMergeContinue:Hn,onMergeAbort:An,onConflictOpen:$n,onRevealInTree:Ft})})]}),e.jsx("div",{className:`file-explorer-resize-handle ${Ge?"active":""}`,onMouseDown:we}),!ut&&e.jsx("div",{className:"fe-mobile-resize-handle",onMouseDown:Gt,onTouchStart:Ae}),e.jsx("div",{className:"file-explorer-viewer-panel",children:mt?e.jsx(vr,{file:mt,versions:vn,loading:wn,onResolve:zn,onClose:()=>{pt(null),et(null)},currentBranch:(I==null?void 0:I.branch)||"HEAD",mergingBranch:gs||"incoming"}):Oe?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"commit-diff-header",children:[e.jsx("span",{className:"commit-diff-file",children:Oe.filePath}),e.jsx("span",{className:"commit-diff-hash",children:Oe.hash.slice(0,8)}),e.jsx("button",{className:"commit-diff-close",onClick:_n,children:"×"})]}),e.jsx(ns,{originalContent:Oe.beforeContent,modifiedContent:Oe.afterContent,filename:Oe.filename,filePath:Oe.filePath,language:Us[Oe.extension]||"plaintext"})]}):xn?e.jsx("div",{className:"commit-diff-loading",children:i("common:status.loading")}):e.jsxs(e.Fragment,{children:[e.jsx(dn,{tabs:Ie,activeTabPath:he,onSelectTab:kn,onCloseTab:Ss,onCloseAllTabs:En,onShowGitHistory:Dn}),hn==="modified"&&dt!==null&&$?e.jsx(ns,{originalContent:dt,modifiedContent:$.content,filename:$.filename,filePath:$.path,language:Us[$.extension]||"plaintext"}):e.jsx(rn,{file:$,loading:S,error:te,onRevealInTree:Ft,onFileEdited:Q})]})})]}),Bt&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"git-history-resize-handle",onMouseDown:Bn}),e.jsx("div",{className:"git-history-bottom-panel",style:{height:Vt},children:e.jsx(Mr,{history:oe,currentFolder:C,onFileSelect:Gn})})]}),pe.isOpen&&pe.node&&e.jsx("div",{className:"file-explorer-rename-overlay",onClick:st,children:e.jsxs("div",{className:"file-explorer-rename-dialog",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"file-explorer-rename-title",children:["Rename ",pe.node.isDirectory?"Folder":"File"]}),e.jsx("div",{className:"file-explorer-rename-path",title:pe.node.path,children:pe.node.path}),e.jsx("input",{ref:Xt,type:"text",className:"file-explorer-rename-input",value:pe.value,onChange:a=>Be(u=>({...u,value:a.target.value})),onKeyDown:a=>{a.key==="Enter"?(a.preventDefault(),Rs()):a.key==="Escape"&&(a.preventDefault(),st())},disabled:pe.submitting}),e.jsxs("div",{className:"file-explorer-rename-actions",children:[e.jsx("button",{className:"file-explorer-rename-btn",onClick:st,disabled:pe.submitting,children:"Cancel"}),e.jsx("button",{className:"file-explorer-rename-btn primary",onClick:()=>{Rs()},disabled:pe.submitting||!pe.value.trim(),children:pe.submitting?"Renaming...":"Rename"})]})]})}),Je&&e.jsx(it,{isOpen:Je.isOpen,position:Je.position,worldPosition:{x:0,z:0},actions:Rn,onClose:()=>ms(null)}),Ye&&e.jsx(it,{isOpen:Ye.isOpen,position:Ye.position,worldPosition:{x:0,z:0},actions:Fn,onClose:()=>ps(null)}),Ce.isOpen&&e.jsx("div",{className:"file-explorer-rename-overlay",onClick:at,children:e.jsxs("div",{className:"file-explorer-rename-dialog",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"file-explorer-rename-title",children:["New ",Ce.isDirectory?"Folder":"File"]}),e.jsx("div",{className:"file-explorer-rename-path",title:Ce.parentDir,children:Ce.parentDir}),e.jsx("input",{ref:js,type:"text",className:"file-explorer-rename-input",placeholder:Ce.isDirectory?"folder name":"file name",value:Ce.value,onChange:a=>Qe(u=>({...u,value:a.target.value})),onKeyDown:a=>{a.key==="Enter"?(a.preventDefault(),Ds()):a.key==="Escape"&&(a.preventDefault(),at())},disabled:Ce.submitting}),e.jsxs("div",{className:"file-explorer-rename-actions",children:[e.jsx("button",{className:"file-explorer-rename-btn",onClick:at,disabled:Ce.submitting,children:"Cancel"}),e.jsx("button",{className:"file-explorer-rename-btn primary",onClick:()=>{Ds()},disabled:Ce.submitting||!Ce.value.trim(),children:Ce.submitting?"Creating...":"Create"})]})]})}),e.jsx(Lr,{isOpen:Kt.open,filePath:Kt.path,cwd:Kt.cwd,onClose:()=>Wt(a=>({...a,open:!1}))}),e.jsx(ua,{isOpen:!!Se,title:Se!=null&&Se.node.isDirectory?"Delete Folder":"Delete File",message:Se?e.jsxs(e.Fragment,{children:["Permanently delete ",e.jsx("strong",{children:Se.node.name}),"?"]}):"",note:Se!=null&&Se.node.isDirectory?"The folder and everything inside it will be removed from disk.":"The file will be removed from disk.",confirmLabel:"Delete",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{Mn()},onClose:()=>fs(null)})]})}export{Ar as FileExplorerPanel};
@@ -1 +0,0 @@
1
- import{c as Ft,d as wt,y as It,$ as vt,f as bt,bM as Bt,bN as _t,a9 as Dt,r as f,x as Rt,S as ge,bO as Tt,aq as kt,bP as me,s as P,bQ as $t,j as m,I as X,U as et,bR as tt,n as st,bS as Lt,bT as jt,bU as Se,T as Re,m as Nt,ap as lt,u as ve,bV as nt}from"./main-B9DphKOa.js";import{bW as Qs,bX as Gs,bY as Ws,bZ as Us,b_ as Hs}from"./main-B9DphKOa.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-CBPuP1jE.js";function ie(t){return Array.isArray?Array.isArray(t):dt(t)==="[object Array]"}function Pt(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Kt(t){return t==null?"":Pt(t)}function ee(t){return typeof t=="string"}function ht(t){return typeof t=="number"}function zt(t){return t===!0||t===!1||Ot(t)&&dt(t)=="[object Boolean]"}function ft(t){return typeof t=="object"}function Ot(t){return ft(t)&&t!==null}function U(t){return t!=null}function Te(t){return!t.trim().length}function dt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Qt="Incorrect 'index' type",Gt=t=>`Invalid value for key ${t}`,Wt=t=>`Pattern length exceeds max of ${t}.`,Ut=t=>`Missing ${t} property in key`,Ht=t=>`Property 'weight' in key '${t}' must be a positive integer`,rt=Object.prototype.hasOwnProperty;class Yt{constructor(e){this._keys=[],this._keyMap={};let n=0;e.forEach(r=>{let i=mt(r);this._keys.push(i),this._keyMap[i.id]=i,n+=i.weight}),this._keys.forEach(r=>{r.weight/=n})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function mt(t){let e=null,n=null,r=null,i=1,o=null;if(ee(t)||ie(t))r=t,e=it(t),n=ke(t);else{if(!rt.call(t,"name"))throw new Error(Ut("name"));const c=t.name;if(r=c,rt.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(Ht(c));e=it(c),n=ke(c),o=t.getFn}return{path:e,id:n,weight:i,src:r,getFn:o}}function it(t){return ie(t)?t:t.split(".")}function ke(t){return ie(t)?t.join("."):t}function Vt(t,e){let n=[],r=!1;const i=(o,c,a)=>{if(U(o))if(!c[a])n.push(o);else{let u=c[a];const l=o[u];if(!U(l))return;if(a===c.length-1&&(ee(l)||ht(l)||zt(l)))n.push(Kt(l));else if(ie(l)){r=!0;for(let d=0,x=l.length;d<x;d+=1)i(l[d],c,a+1)}else c.length&&i(l,c,a+1)}};return i(t,ee(e)?e.split("."):e,0),r?n:n[0]}const qt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Jt={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},Xt={location:0,threshold:.6,distance:100},Zt={useExtendedSearch:!1,getFn:Vt,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var M={...Jt,...qt,...Xt,...Zt};const es=/[^ ]+/g;function ts(t=1,e=3){const n=new Map,r=Math.pow(10,e);return{get(i){const o=i.match(es).length;if(n.has(o))return n.get(o);const c=1/Math.pow(o,.5*t),a=parseFloat(Math.round(c*r)/r);return n.set(o,a),a},clear(){n.clear()}}}class Ke{constructor({getFn:e=M.getFn,fieldNormWeight:n=M.fieldNormWeight}={}){this.norm=ts(n,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((n,r)=>{this._keysMap[n.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,ee(this.docs[0])?this.docs.forEach((e,n)=>{this._addString(e,n)}):this.docs.forEach((e,n)=>{this._addObject(e,n)}),this.norm.clear())}add(e){const n=this.size();ee(e)?this._addString(e,n):this._addObject(e,n)}removeAt(e){this.records.splice(e,1);for(let n=e,r=this.size();n<r;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(e,n){return e[this._keysMap[n]]}size(){return this.records.length}_addString(e,n){if(!U(e)||Te(e))return;let r={v:e,i:n,n:this.norm.get(e)};this.records.push(r)}_addObject(e,n){let r={i:n,$:{}};this.keys.forEach((i,o)=>{let c=i.getFn?i.getFn(e):this.getFn(e,i.path);if(U(c)){if(ie(c)){let a=[];const u=[{nestedArrIndex:-1,value:c}];for(;u.length;){const{nestedArrIndex:l,value:d}=u.pop();if(U(d))if(ee(d)&&!Te(d)){let x={v:d,i:l,n:this.norm.get(d)};a.push(x)}else ie(d)&&d.forEach((x,S)=>{u.push({nestedArrIndex:S,value:x})})}r.$[o]=a}else if(ee(c)&&!Te(c)){let a={v:c,n:this.norm.get(c)};r.$[o]=a}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function pt(t,e,{getFn:n=M.getFn,fieldNormWeight:r=M.fieldNormWeight}={}){const i=new Ke({getFn:n,fieldNormWeight:r});return i.setKeys(t.map(mt)),i.setSources(e),i.create(),i}function ss(t,{getFn:e=M.getFn,fieldNormWeight:n=M.fieldNormWeight}={}){const{keys:r,records:i}=t,o=new Ke({getFn:e,fieldNormWeight:n});return o.setKeys(r),o.setIndexRecords(i),o}function Fe(t,{errors:e=0,currentLocation:n=0,expectedLocation:r=0,distance:i=M.distance,ignoreLocation:o=M.ignoreLocation}={}){const c=e/t.length;if(o)return c;const a=Math.abs(r-n);return i?c+a/i:a?1:c}function ns(t=[],e=M.minMatchCharLength){let n=[],r=-1,i=-1,o=0;for(let c=t.length;o<c;o+=1){let a=t[o];a&&r===-1?r=o:!a&&r!==-1&&(i=o-1,i-r+1>=e&&n.push([r,i]),r=-1)}return t[o-1]&&o-r>=e&&n.push([r,o-1]),n}const le=32;function rs(t,e,n,{location:r=M.location,distance:i=M.distance,threshold:o=M.threshold,findAllMatches:c=M.findAllMatches,minMatchCharLength:a=M.minMatchCharLength,includeMatches:u=M.includeMatches,ignoreLocation:l=M.ignoreLocation}={}){if(e.length>le)throw new Error(Wt(le));const d=e.length,x=t.length,S=Math.max(0,Math.min(r,x));let E=o,p=S;const w=a>1||u,B=w?Array(x):[];let _;for(;(_=t.indexOf(e,p))>-1;){let N=Fe(e,{currentLocation:_,expectedLocation:S,distance:i,ignoreLocation:l});if(E=Math.min(N,E),p=_+d,w){let G=0;for(;G<d;)B[_+G]=1,G+=1}}p=-1;let L=[],H=1,Q=d+x;const he=1<<d-1;for(let N=0;N<d;N+=1){let G=0,K=Q;for(;G<K;)Fe(e,{errors:N,currentLocation:S+K,expectedLocation:S,distance:i,ignoreLocation:l})<=E?G=K:Q=K,K=Math.floor((Q-G)/2+G);Q=K;let J=Math.max(1,S-K+1),k=c?x:Math.min(S+K,x)+d,V=Array(k+2);V[k+1]=(1<<N)-1;for(let y=k;y>=J;y-=1){let $=y-1,ae=n[t.charAt($)];if(w&&(B[$]=+!!ae),V[y]=(V[y+1]<<1|1)&ae,N&&(V[y]|=(L[y+1]|L[y])<<1|1|L[y+1]),V[y]&he&&(H=Fe(e,{errors:N,currentLocation:$,expectedLocation:S,distance:i,ignoreLocation:l}),H<=E)){if(E=H,p=$,p<=S)break;J=Math.max(1,2*S-p)}}if(Fe(e,{errors:N+1,currentLocation:S,expectedLocation:S,distance:i,ignoreLocation:l})>E)break;L=V}const te={isMatch:p>=0,score:Math.max(.001,H)};if(w){const N=ns(B,a);N.length?u&&(te.indices=N):te.isMatch=!1}return te}function is(t){let e={};for(let n=0,r=t.length;n<r;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<r-n-1}return e}const we=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class gt{constructor(e,{location:n=M.location,threshold:r=M.threshold,distance:i=M.distance,includeMatches:o=M.includeMatches,findAllMatches:c=M.findAllMatches,minMatchCharLength:a=M.minMatchCharLength,isCaseSensitive:u=M.isCaseSensitive,ignoreDiacritics:l=M.ignoreDiacritics,ignoreLocation:d=M.ignoreLocation}={}){if(this.options={location:n,threshold:r,distance:i,includeMatches:o,findAllMatches:c,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:d},e=u?e:e.toLowerCase(),e=l?we(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const x=(E,p)=>{this.chunks.push({pattern:E,alphabet:is(E),startIndex:p})},S=this.pattern.length;if(S>le){let E=0;const p=S%le,w=S-p;for(;E<w;)x(this.pattern.substr(E,le),E),E+=le;if(p){const B=S-le;x(this.pattern.substr(B),B)}}else x(this.pattern,0)}searchIn(e){const{isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i}=this.options;if(e=n?e:e.toLowerCase(),e=r?we(e):e,this.pattern===e){let w={isMatch:!0,score:0};return i&&(w.indices=[[0,e.length-1]]),w}const{location:o,distance:c,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:d}=this.options;let x=[],S=0,E=!1;this.chunks.forEach(({pattern:w,alphabet:B,startIndex:_})=>{const{isMatch:L,score:H,indices:Q}=rs(e,w,B,{location:o+_,distance:c,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:i,ignoreLocation:d});L&&(E=!0),S+=H,L&&Q&&(x=[...x,...Q])});let p={isMatch:E,score:E?S/this.chunks.length:1};return E&&i&&(p.indices=x),p}}class ce{constructor(e){this.pattern=e}static isMultiMatch(e){return ot(e,this.multiRegex)}static isSingleMatch(e){return ot(e,this.singleRegex)}search(){}}function ot(t,e){const n=t.match(e);return n?n[1]:null}class os extends ce{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const n=e===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class cs extends ce{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const r=e.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class as extends ce{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const n=e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class us extends ce{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const n=!e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class ls extends ce{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const n=e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class hs extends ce{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const n=!e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class At extends ce{constructor(e,{location:n=M.location,threshold:r=M.threshold,distance:i=M.distance,includeMatches:o=M.includeMatches,findAllMatches:c=M.findAllMatches,minMatchCharLength:a=M.minMatchCharLength,isCaseSensitive:u=M.isCaseSensitive,ignoreDiacritics:l=M.ignoreDiacritics,ignoreLocation:d=M.ignoreLocation}={}){super(e),this._bitapSearch=new gt(e,{location:n,threshold:r,distance:i,includeMatches:o,findAllMatches:c,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:d})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class yt extends ce{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let n=0,r;const i=[],o=this.pattern.length;for(;(r=e.indexOf(this.pattern,n))>-1;)n=r+o,i.push([r,n-1]);const c=!!i.length;return{isMatch:c,score:c?0:1,indices:i}}}const $e=[os,yt,as,us,hs,ls,cs,At],ct=$e.length,fs=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,ds="|";function ms(t,e={}){return t.split(ds).map(n=>{let r=n.trim().split(fs).filter(o=>o&&!!o.trim()),i=[];for(let o=0,c=r.length;o<c;o+=1){const a=r[o];let u=!1,l=-1;for(;!u&&++l<ct;){const d=$e[l];let x=d.isMultiMatch(a);x&&(i.push(new d(x,e)),u=!0)}if(!u)for(l=-1;++l<ct;){const d=$e[l];let x=d.isSingleMatch(a);if(x){i.push(new d(x,e));break}}}return i})}const ps=new Set([At.type,yt.type]);class gs{constructor(e,{isCaseSensitive:n=M.isCaseSensitive,ignoreDiacritics:r=M.ignoreDiacritics,includeMatches:i=M.includeMatches,minMatchCharLength:o=M.minMatchCharLength,ignoreLocation:c=M.ignoreLocation,findAllMatches:a=M.findAllMatches,location:u=M.location,threshold:l=M.threshold,distance:d=M.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i,minMatchCharLength:o,findAllMatches:a,ignoreLocation:c,location:u,threshold:l,distance:d},e=n?e:e.toLowerCase(),e=r?we(e):e,this.pattern=e,this.query=ms(this.pattern,this.options)}static condition(e,n){return n.useExtendedSearch}searchIn(e){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:i,ignoreDiacritics:o}=this.options;e=i?e:e.toLowerCase(),e=o?we(e):e;let c=0,a=[],u=0;for(let l=0,d=n.length;l<d;l+=1){const x=n[l];a.length=0,c=0;for(let S=0,E=x.length;S<E;S+=1){const p=x[S],{isMatch:w,indices:B,score:_}=p.search(e);if(w){if(c+=1,u+=_,r){const L=p.constructor.type;ps.has(L)?a=[...a,...B]:a.push(B)}}else{u=0,c=0,a.length=0;break}}if(c){let S={isMatch:!0,score:u/c};return r&&(S.indices=a),S}}return{isMatch:!1,score:1}}}const Le=[];function As(...t){Le.push(...t)}function je(t,e){for(let n=0,r=Le.length;n<r;n+=1){let i=Le[n];if(i.condition(t,e))return new i(t,e)}return new gt(t,e)}const Ie={AND:"$and",OR:"$or"},Ne={PATH:"$path",PATTERN:"$val"},Pe=t=>!!(t[Ie.AND]||t[Ie.OR]),ys=t=>!!t[Ne.PATH],Es=t=>!ie(t)&&ft(t)&&!Pe(t),at=t=>({[Ie.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Et(t,e,{auto:n=!0}={}){const r=i=>{let o=Object.keys(i);const c=ys(i);if(!c&&o.length>1&&!Pe(i))return r(at(i));if(Es(i)){const u=c?i[Ne.PATH]:o[0],l=c?i[Ne.PATTERN]:i[u];if(!ee(l))throw new Error(Gt(u));const d={keyId:ke(u),pattern:l};return n&&(d.searcher=je(l,e)),d}let a={children:[],operator:o[0]};return o.forEach(u=>{const l=i[u];ie(l)&&l.forEach(d=>{a.children.push(r(d))})}),a};return Pe(t)||(t=at(t)),r(t)}function xs(t,{ignoreFieldNorm:e=M.ignoreFieldNorm}){t.forEach(n=>{let r=1;n.matches.forEach(({key:i,norm:o,score:c})=>{const a=i?i.weight:null;r*=Math.pow(c===0&&a?Number.EPSILON:c,(a||1)*(e?1:o))}),n.score=r})}function Ms(t,e){const n=t.matches;e.matches=[],U(n)&&n.forEach(r=>{if(!U(r.indices)||!r.indices.length)return;const{indices:i,value:o}=r;let c={indices:i,value:o};r.key&&(c.key=r.key.src),r.idx>-1&&(c.refIndex=r.idx),e.matches.push(c)})}function Cs(t,e){e.score=t.score}function Ss(t,e,{includeMatches:n=M.includeMatches,includeScore:r=M.includeScore}={}){const i=[];return n&&i.push(Ms),r&&i.push(Cs),t.map(o=>{const{idx:c}=o,a={item:e[c],refIndex:c};return i.length&&i.forEach(u=>{u(o,a)}),a})}class Z{constructor(e,n={},r){this.options={...M,...n},this.options.useExtendedSearch,this._keyStore=new Yt(this.options.keys),this.setCollection(e,r)}setCollection(e,n){if(this._docs=e,n&&!(n instanceof Ke))throw new Error(Qt);this._myIndex=n||pt(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){U(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const n=[];for(let r=0,i=this._docs.length;r<i;r+=1){const o=this._docs[r];e(o,r)&&(this.removeAt(r),r-=1,i-=1,n.push(o))}return n}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:n=-1}={}){const{includeMatches:r,includeScore:i,shouldSort:o,sortFn:c,ignoreFieldNorm:a}=this.options;let u=ee(e)?ee(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return xs(u,{ignoreFieldNorm:a}),o&&u.sort(c),ht(n)&&n>-1&&(u=u.slice(0,n)),Ss(u,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e){const n=je(e,this.options),{records:r}=this._myIndex,i=[];return r.forEach(({v:o,i:c,n:a})=>{if(!U(o))return;const{isMatch:u,score:l,indices:d}=n.searchIn(o);u&&i.push({item:o,idx:c,matches:[{score:l,value:o,norm:a,indices:d}]})}),i}_searchLogical(e){const n=Et(e,this.options),r=(a,u,l)=>{if(!a.children){const{keyId:x,searcher:S}=a,E=this._findMatches({key:this._keyStore.get(x),value:this._myIndex.getValueForItemAtKeyId(u,x),searcher:S});return E&&E.length?[{idx:l,item:u,matches:E}]:[]}const d=[];for(let x=0,S=a.children.length;x<S;x+=1){const E=a.children[x],p=r(E,u,l);if(p.length)d.push(...p);else if(a.operator===Ie.AND)return[]}return d},i=this._myIndex.records,o={},c=[];return i.forEach(({$:a,i:u})=>{if(U(a)){let l=r(n,a,u);l.length&&(o[u]||(o[u]={idx:u,item:a,matches:[]},c.push(o[u])),l.forEach(({matches:d})=>{o[u].matches.push(...d)}))}}),c}_searchObjectList(e){const n=je(e,this.options),{keys:r,records:i}=this._myIndex,o=[];return i.forEach(({$:c,i:a})=>{if(!U(c))return;let u=[];r.forEach((l,d)=>{u.push(...this._findMatches({key:l,value:c[d],searcher:n}))}),u.length&&o.push({idx:a,item:c,matches:u})}),o}_findMatches({key:e,value:n,searcher:r}){if(!U(n))return[];let i=[];if(ie(n))n.forEach(({v:o,i:c,n:a})=>{if(!U(o))return;const{isMatch:u,score:l,indices:d}=r.searchIn(o);u&&i.push({score:l,key:e,value:o,idx:c,norm:a,indices:d})});else{const{v:o,n:c}=n,{isMatch:a,score:u,indices:l}=r.searchIn(o);a&&i.push({score:u,key:e,value:o,norm:c,indices:l})}return i}}Z.version="7.1.0";Z.createIndex=pt;Z.parseIndex=ss;Z.config=M;Z.parseQuery=Et;As(gs);async function Fs(t){const e=new URLSearchParams({q:t}),n=await Ft(wt(`/api/folders/search?${e.toString()}`));if(!n.ok){const i=await n.json().catch(()=>({}));throw new Error(i.error||`Failed to search folders: ${n.statusText}`)}const r=await n.json();return Array.isArray(r.folders)?r.folders:[]}const ws=["command","agent","building","area","folder","modified-file","session"],Is=2,vs=3,bs=6;function Bs(){const t=lt(ge.SPOTLIGHT_TAB,"all");return me.includes(t)?t:"all"}function ut(){return Nt(ge.SPOTLIGHT_QUERY,"")}function _s(){const t=lt(ge.AOP_CONFIG,{});return t.sortMode==="name"||t.sortMode==="status"||t.sortMode==="recent"?t.sortMode:"recent"}function Ds({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:o,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l,onOpenSessionFinder:d}){const x=It(),S=vt(),E=bt(),p=Bt(),w=_t(),B=Dt(),_=f.useRef(e);_.current=e;const L=f.useRef(n);L.current=n;const H=f.useRef(r);H.current=r;const Q=f.useRef(i);Q.current=i;const he=f.useRef(o);he.current=o;const te=f.useRef(c);te.current=c;const N=f.useRef(a);N.current=a;const G=f.useRef(u);G.current=u;const K=f.useRef(l);K.current=l;const J=f.useRef(d);J.current=d;const[k,V]=f.useState(ut),[D,y]=f.useState(0),[$,ae]=f.useState(Bs),[oe,Ae]=f.useState([]),[ye,Ee]=f.useState({query:"",rows:[]}),xt=f.useCallback(s=>{V(s),Rt(ge.SPOTLIGHT_QUERY,s)},[]);f.useEffect(()=>{t&&(V(ut()),y(0))},[t]),f.useEffect(()=>{if(!t){Ae([]);return}const s=k.trim();if(s.length<Is){Ae([]);return}let h=!1;const g=setTimeout(()=>{Fs(s).then(C=>{h||Ae(C)}).catch(()=>{h||Ae([])})},250);return()=>{h=!0,clearTimeout(g)}},[t,k]),f.useEffect(()=>{if(!t){Ee({query:"",rows:[]});return}const s=k.trim();if(s.length<vs){Ee({query:"",rows:[]});return}let h=!1;const g=setTimeout(()=>{Tt(s,{limit:bs}).then(C=>{h||Ee({query:s,rows:C})}).catch(()=>{h||Ee({query:"",rows:[]})})},250);return()=>{h=!0,clearTimeout(g)}},[t,k]);const be=f.useCallback(s=>{ae(s),kt(ge.SPOTLIGHT_TAB,s)},[]),ze=f.useRef($);ze.current=$;const Mt=f.useCallback(s=>{const h=me.indexOf(ze.current),g=me[(h+s+me.length)%me.length];be(g)},[be]);f.useEffect(()=>{y(0)},[$]);const Be=P.getShortcuts(),pe=f.useMemo(()=>t?$t():{},[t]),xe=f.useMemo(()=>{if(!t)return[];const s=window.matchMedia("(pointer: coarse)").matches,h=Be.find(C=>C.id==="spawn-agent"),g=Be.find(C=>C.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:s?"":h?et(h):"Alt+N",icon:m.jsx(X,{name:"plus",size:16}),action:()=>{_.current(),L.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:s?"":g!=null&&g.key?et(g):"Tab",icon:m.jsx(X,{name:"dashboard",size:16}),action:()=>{_.current(),H.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:m.jsx(X,{name:"gear",size:16}),action:()=>{_.current(),Q.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:m.jsx(X,{name:"chart-line",size:16}),action:()=>{var C;_.current(),(C=K.current)==null||C.call(K)}}]},[t,Be]),fe=f.useMemo(()=>t?Array.from(x.values()).map(s=>{const h=(p||[]).filter(Y=>Y.agentId===s.id).map(Y=>Y.filePath),g=[...new Set(h)],C=g.map(Y=>Y.split("/").pop()||Y),F=[];s.lastAssignedTask&&F.push(s.lastAssignedTask);const R=`${s.class} • ${s.cwd}`;let v=`${s.name} ${s.class} ${s.status} ${s.cwd}`;s.taskLabel&&(v+=` ${s.taskLabel}`),C.length>0&&(v+=` ${C.join(" ")} ${g.join(" ")}`),F.length>0&&(v+=` ${F.join(" ")}`);const j=Date.now()-s.lastActivity;let z;return s.lastAssignedTask&&(s.lastAssignedTask.length>150?z=s.lastAssignedTask.slice(0,150)+"...":z=s.lastAssignedTask),{id:`agent-${s.id}`,type:"agent",title:s.name,subtitle:R,lastUserInput:z,timeAway:j,icon:m.jsx(st,{agent:s,size:20}),_searchText:v,_modifiedFiles:g,_userQueries:F,_agentId:s.id,_lastActivity:s.lastActivity,_taskLabel:s.taskLabel,_status:s.status,action:()=>{_.current(),tt(s.id),P.selectAgent(s.id),P.getState().viewMode!=="flat"&&P.requestTerminalExpand()}}}):[],[t,x,p]),Me=f.useMemo(()=>t?Array.from(S.values()).map(s=>{var h;return{id:`area-${s.id}`,type:"area",title:s.name,subtitle:`${s.assignedAgentIds.length} agents • ${((h=s.directories)==null?void 0:h.length)||0} folders`,icon:m.jsx(X,{name:"map",size:16}),action:()=>{_.current(),P.selectArea(s.id)}}}):[],[t,S]),Oe=f.useMemo(()=>{const s=new Map;for(const h of fe)h._agentId&&s.set(h._agentId,h);return s},[fe]),Qe=f.useMemo(()=>{const s=new Map;if(!t)return s;for(const h of x.values()){const g=P.getAreaForAgent(h.id);if(!g||g.archived)continue;const C=s.get(g.id);C?C.push(h):s.set(g.id,[h])}return s},[t,x,S]),Ge=f.useMemo(()=>{const s=new Map;for(const h of w)s.has(h.agentId)||s.set(h.agentId,h.timestamp);return s},[w]),_e=f.useMemo(()=>{if(!t)return[];const s=k.trim().toLowerCase(),h=Lt({sortMode:_s(),agentsWithUnseenOutput:B,getLatestToolTimestamp:F=>Ge.get(F)}),g=Array.from(S.values()).filter(F=>!F.archived).filter(F=>s?F.name.toLowerCase().includes(s):!0).sort((F,R)=>F.name.localeCompare(R.name,void 0,{sensitivity:"base"})),C=[];for(const F of g){const v=(Qe.get(F.id)||[]).slice().sort(h).map(j=>Oe.get(j.id)).filter(j=>!!j);!s&&v.length===0||C.push({areaId:F.id,areaName:F.name,areaColor:F.color,agents:v})}return C},[t,k,S,Qe,Oe,B,Ge]),Ce=f.useMemo(()=>t?Array.from(E.values()).filter(s=>s.type==="server"||s.type==="boss"||s.type==="database"||s.type==="tests").map(s=>{var j,z,Y,ue,se;const h=s.status==="running"?"#4ade80":s.status==="stopped"?"#f87171":"#facc15",g=s.type==="boss"?"crown":s.type==="database"?"database":s.type==="tests"?"flask":"desktop",C=s.type==="boss"?"Boss":s.type==="database"?"Database":s.type==="tests"?"Tests":"Server";let F=`${C} • ${s.status}`;if(s.type==="database"&&((z=(j=s.database)==null?void 0:j.connections)!=null&&z.length)){const W=s.database.connections[0];F+=` • ${W.engine} @ ${W.host}`}else s.type==="tests"&&s.folderPath?F=`${C} • ${s.folderPath}`:s.cwd&&(F+=` • ${s.cwd}`);const R=((Y=s.pm2Status)==null?void 0:Y.ports)||[];let v=`${s.name} ${s.type} ${s.status} ${s.cwd||""} ${((ue=s.pm2)==null?void 0:ue.name)||""}`;if(s.type==="tests"&&(v+=` ${s.folderPath||""} tests junit maven`),R.length>0&&(v+=` ${R.join(" ")}`),s.type==="database"&&((se=s.database)!=null&&se.connections))for(const W of s.database.connections)v+=` ${W.name} ${W.engine} ${W.host} ${W.database||""} mysql postgresql sql`;return{id:`building-${s.id}`,type:"building",title:s.name,subtitle:F,_ports:R,icon:m.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[m.jsx(X,{name:"status-pending",size:10,weight:"fill",color:h}),m.jsx(X,{name:g,size:16})]}),_searchText:v,action:()=>{var W;_.current(),s.type==="boss"?N.current(s.id):s.type==="database"?G.current(s.id):s.type==="tests"?P.openTestsBuilding(s.id):s.type==="http"?P.openHttpBuilding(s.id):(W=s.pm2)!=null&&W.enabled&&te.current(s.id)}}}):[],[t,E]),We=f.useMemo(()=>{if(!t)return[];const s=p||[],h=new Set,g=[];for(const C of s){if(h.has(C.filePath))continue;h.add(C.filePath);const F=C.filePath.split("/").pop()||C.filePath,R=C.action==="created"?"Created":C.action==="modified"?"Modified":C.action==="deleted"?"Deleted":"Read";if(g.push({id:`modified-${C.filePath}-${C.timestamp}`,type:"modified-file",title:F,subtitle:`${R} by ${C.agentName} • ${C.filePath}`,matchedText:C.filePath,icon:C.action==="deleted"?m.jsx(X,{name:"trash",size:16}):jt(C.filePath),action:()=>{_.current();const v=Array.from(P.getState().areas.values());for(const j of v)for(const z of j.directories||[])if(C.filePath.startsWith(z)){P.setFileViewerPath(C.filePath),he.current(j.id);return}P.selectAgent(C.agentId)}}),g.length>=50)break}return g},[t,p]),Ue=f.useMemo(()=>t?oe.map(s=>{const h=s.isGitRepo&&s.gitBranch?`${s.path} • ${s.gitBranch}`:s.path;return{id:`folder-${s.path}`,type:"folder",title:s.name,subtitle:h,matchedText:s.path,icon:m.jsx(X,{name:s.isGitRepo?"git-branch":"folder",size:16}),_searchText:`${s.name} ${s.path}`,_isGitRepo:s.isGitRepo,_gitBranch:s.gitBranch,action:()=>{_.current(),P.openFileExplorer(s.path)}}}):[],[t,oe]),He=f.useMemo(()=>{if(!t)return[];const s=h=>{const g=Date.now()-new Date(h).getTime();return!Number.isFinite(g)||g<0?"":g<36e5?`${Math.max(1,Math.floor(g/6e4))}m`:g<864e5?`${Math.floor(g/36e5)}h`:`${Math.floor(g/864e5)}d`};return ye.rows.map(h=>{const g=Array.from(x.values()).find(v=>v.sessionId===h.sessionId),C=(h.firstPrompt||h.snippet||h.sessionId).slice(0,90),F=[h.projectPath||h.projectDir];g&&F.push(`→ ${g.name}`);const R=s(h.lastModified);return R&&F.push(R),F.push(`${h.totalMatches}×`),{id:`session-${h.sessionId}`,type:"session",title:C,subtitle:F.join(" • "),matchedQuery:h.snippet||void 0,icon:g?m.jsx(st,{agent:g,size:20}):m.jsx(X,{name:"history",size:16}),action:()=>{var j;_.current();const v=Array.from(P.getState().agents.values()).find(z=>z.sessionId===h.sessionId);v?(tt(v.id),P.selectAgent(v.id),P.getState().viewMode!=="flat"&&P.requestTerminalExpand(),P.requestTerminalSearch(v.id,ye.query)):(j=J.current)==null||j.call(J,{initialQuery:ye.query,initialSessionKey:`${h.projectPath}::${h.sessionId}`})}}})},[t,ye,x]),Ye=f.useMemo(()=>new Z(fe,{keys:["title","subtitle","_searchText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[fe]),Ve=f.useMemo(()=>new Z(xe,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[xe]),qe=f.useMemo(()=>new Z(Me,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[Me]),Je=f.useMemo(()=>new Z(We,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[We]),Xe=f.useMemo(()=>new Z(Ce,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Ce]),de=f.useMemo(()=>{if(!k.trim()){const A=[];A.push(...Ce);const I=[...fe].sort((T,O)=>{const ne=Se(T._agentId,T._lastActivity,pe);return Se(O._agentId,O._lastActivity,pe)-ne});A.push(...I),A.push(...xe.slice(0,2)),A.push(...Me.slice(0,2));const b={};return ws.forEach((T,O)=>{b[T]=O}),A.sort((T,O)=>(b[T.type]??999)-(b[O.type]??999)),A}const s=k.trim().toLowerCase(),h=Ye.search(k).slice(0,8),g=Ve.search(k).slice(0,3),C=qe.search(k).slice(0,2),F=Je.search(k).slice(0,3),R=Ue.slice(0,8),v=Xe.search(k).filter(A=>{const I=A.score??1;return`${A.item.title} ${A.item.subtitle||""} ${A.item._searchText||""}`.toLowerCase().includes(s)||I<=.2}).slice(0,4),j={agent:6,building:5,folder:4,command:3,area:2,"modified-file":1,session:0},z=A=>{if(!s)return 1;const I=A.title.toLowerCase();return I===s?6:I.startsWith(s)?5:I.split(/[^a-z0-9]+/i).includes(s)?4:I.includes(s)?3:`${A.subtitle||""} ${A._searchText||""} ${A.matchedText||""}`.toLowerCase().includes(s)?2:1},Y=(A,I)=>{const b=(1-Math.min(1,I??1))*4;return z(A)*100+(j[A.type]??0)*5+b},ue=new Map,se=(A,I)=>{const b=ue.get(A.type),T={item:A,score:Y(A,I)};b?b.push(T):ue.set(A.type,[T])};for(const A of h){const I={...A.item};if(I._modifiedFiles&&I._modifiedFiles.length>0){const b=I._modifiedFiles.filter(T=>{var re;const O=((re=T.split("/").pop())==null?void 0:re.toLowerCase())||"",ne=T.toLowerCase();return O.includes(s)||ne.includes(s)});b.length>0&&(I.matchedFiles=b)}if(I._userQueries&&I._userQueries.length>0){const b=I._userQueries.find(T=>T.toLowerCase().includes(s));if(b)if(b.length>200){const O=b.toLowerCase().indexOf(s),ne=Math.max(0,O-60),re=Math.min(b.length,O+s.length+100);I.matchedQuery=(ne>0?"...":"")+b.slice(ne,re)+(re<b.length?"...":"")}else I.matchedQuery=b}se(I,A.score)}for(const A of v)se(A.item,A.score);for(const A of g)se(A.item,A.score);for(const A of C)se(A.item,A.score);for(const A of F)se(A.item,A.score);for(const A of R)se(A,void 0);for(const[A,I]of ue)A==="agent"?I.sort((b,T)=>{const O=z(b.item),ne=z(T.item);if(ne!==O)return ne-O;const re=Se(b.item._agentId,b.item._lastActivity,pe),Ze=Se(T.item._agentId,T.item._lastActivity,pe);return Ze!==re?Ze-re:T.score-b.score}):I.sort((b,T)=>T.score-b.score);const W=A=>A.reduce((I,b)=>Math.max(I,b.score),-1),De=[];Array.from(ue.values()).sort((A,I)=>W(I)-W(A)).forEach(A=>{for(const I of A)De.push(I.item)});for(const A of He)De.push(A);return De},[k,Ye,Ve,qe,Je,Xe,xe,fe,Me,Ce,Ue,He,pe]),q=f.useMemo(()=>{switch($){case"agents":return de.filter(s=>s.type==="agent");case"buildings":return de.filter(s=>s.type==="building");case"commands":return de.filter(s=>s.type==="command");case"folders":return de.filter(s=>s.type==="folder");case"areas":return _e.flatMap(s=>s.agents);case"all":default:return de}},[$,de,_e]);f.useEffect(()=>{D>=q.length&&y(Math.max(0,q.length-1))},[q.length,D]);const Ct=f.useCallback(s=>{if(s.altKey&&!s.ctrlKey&&!s.metaKey&&(s.key==="p"||s.key==="n"||s.key==="P"||s.key==="N")){s.preventDefault(),s.stopPropagation(),s.nativeEvent.stopImmediatePropagation();const h=s.key.toLowerCase();y(h==="p"?g=>g>0?g-1:q.length-1:g=>g<q.length-1?g+1:0);return}switch(s.key){case"Escape":s.preventDefault(),_.current();break;case"ArrowUp":s.preventDefault(),y(h=>h>0?h-1:q.length-1);break;case"ArrowDown":s.preventDefault(),y(h=>h<q.length-1?h+1:0);break;case"Enter":s.preventDefault(),q[D]&&q[D].action();break}},[q,D]),St=f.useCallback((s,h)=>{if(!h||!s)return s;const g=s.toLowerCase(),C=h.toLowerCase(),F=[];let R=0,v=g.indexOf(C),j=0;for(;v!==-1;)v>R&&F.push(s.slice(R,v)),F.push(Re.createElement("mark",{key:j++,className:"spotlight-highlight"},s.slice(v,v+h.length))),R=v+h.length,v=g.indexOf(C,R);return R<s.length&&F.push(s.slice(R)),F.length>0?Re.createElement(Re.Fragment,null,...F):s},[]);return{query:k,setQuery:xt,selectedIndex:D,setSelectedIndex:y,results:q,activeTab:$,setActiveTab:be,cycleTab:Mt,areaSections:_e,handleKeyDown:Ct,highlightMatch:St}}const Rs=f.forwardRef(function({query:e,onQueryChange:n,onKeyDown:r,onResetSelection:i},o){const{t:c}=ve(["common"]);return m.jsxs("div",{className:"spotlight-input-wrapper",children:[m.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),m.jsx("input",{ref:o,type:"text",className:"spotlight-input",placeholder:c("common:search.spotlightPlaceholder"),value:e,onChange:a=>{n(a.target.value),i()},onKeyDown:r,autoFocus:!0,spellCheck:!1}),m.jsxs("div",{className:"spotlight-input-hints",children:[m.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),m.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),m.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Ts=f.memo(function({activeTab:e,onSelect:n}){const{t:r}=ve(["terminal"]);return m.jsxs("div",{className:"spotlight-tabs",role:"tablist","aria-label":r("terminal:spotlight.tabsLabel"),children:[me.map(i=>m.jsx("button",{type:"button",role:"tab","aria-selected":i===e,tabIndex:-1,className:`spotlight-tab${i===e?" active":""}`,onClick:()=>n(i),children:r(`terminal:spotlight.tabs.${i}`)},i)),m.jsx("span",{className:"spotlight-tabs-hint",children:m.jsx("kbd",{children:"Tab"})})]})}),ks=f.forwardRef(function({results:e,selectedIndex:n,query:r,activeTab:i,areaSections:o,highlightMatch:c,onSelectIndex:a},u){const{t:l}=ve(["terminal"]),d=f.useRef(!1);f.useEffect(()=>{d.current=!1},[e]),f.useEffect(()=>{const E=typeof u=="function"?null:u==null?void 0:u.current;if(!E)return;const p=()=>{d.current=!0};return E.addEventListener("mousemove",p),()=>{E.removeEventListener("mousemove",p)}},[u,e]);const x={command:l("terminal:spotlight.categories.commands"),agent:l("terminal:spotlight.categories.agents"),building:l("terminal:spotlight.categories.infrastructure"),area:l("terminal:spotlight.categories.areas"),folder:l("terminal:spotlight.categories.folders"),"modified-file":l("terminal:spotlight.categories.modifiedFiles"),session:l("terminal:spotlight.categories.sessions")},S=f.useMemo(()=>{const E=[];let p=null,w=[];return e.forEach((B,_)=>{B.type!==p&&(p!==null&&w.length>0&&E.push([p,w]),p=B.type,w=[]),w.push({result:B,index:_})}),p!==null&&w.length>0&&E.push([p,w]),E},[e]);if(f.useEffect(()=>{if(!u||typeof u=="function")return;const E=u.current;if(!E)return;const p=E.querySelector(".spotlight-item.selected");p&&p.scrollIntoView({block:"nearest",behavior:"smooth"})},[n,u]),i==="areas"){if(o.length===0)return m.jsx("div",{className:"spotlight-results",ref:u,children:m.jsx("div",{className:"spotlight-empty",children:l("terminal:spotlight.noResults")})});let E=0;return m.jsx("div",{className:"spotlight-results",ref:u,children:o.map(p=>m.jsxs("div",{children:[m.jsxs("div",{className:"spotlight-category-header spotlight-area-section-header",children:[m.jsx("span",{className:"spotlight-area-dot",style:{background:p.areaColor},"aria-hidden":"true"}),m.jsx("span",{className:"spotlight-area-name",children:p.areaName}),m.jsx("span",{className:"spotlight-area-count",children:p.agents.length})]}),p.agents.length===0?m.jsx("div",{className:"spotlight-area-empty",children:l("terminal:spotlight.noAgentsInArea")}):p.agents.map(w=>{const B=E++;return m.jsx(nt,{result:w,isSelected:B===n,query:r,highlightMatch:c,onClick:()=>w.action(),onMouseEnter:()=>{d.current&&a(B)}},w.id)})]},p.areaId))})}return e.length===0?m.jsx("div",{className:"spotlight-results",ref:u,children:m.jsx("div",{className:"spotlight-empty",children:l("terminal:spotlight.noResults")})}):m.jsx("div",{className:"spotlight-results",ref:u,children:S.map(([E,p])=>m.jsxs("div",{children:[S.length>1&&m.jsx("div",{className:"spotlight-category-header",children:x[E]||E}),p.map(({result:w,index:B})=>m.jsx(nt,{result:w,isSelected:B===n,query:r,highlightMatch:c,onClick:()=>w.action(),onMouseEnter:()=>{d.current&&a(B)}},w.id))]},E))})}),$s=f.memo(function(){const{t:e}=ve(["terminal"]);return m.jsxs("div",{className:"spotlight-footer",children:[m.jsxs("div",{className:"spotlight-footer-left",children:[m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"↑"}),m.jsx("kbd",{children:"↓"})," ",m.jsx("kbd",{children:"Alt+N"}),m.jsx("kbd",{children:"Alt+P"})," ",e("terminal:spotlight.navigate")]}),m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"Enter"})," ",e("terminal:spotlight.select")]}),m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"Tab"})," ",e("terminal:spotlight.switchTabs")]})]}),m.jsx("div",{className:"spotlight-footer-right",children:m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"Esc"})," ",e("common:buttons.close")]})})]})}),Ls=768;function Ks({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:o,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l,onOpenSessionFinder:d}){const x=f.useRef(null),S=f.useRef(null),E=f.useRef(null),p=f.useRef(0),{query:w,setQuery:B,selectedIndex:_,setSelectedIndex:L,results:H,activeTab:Q,setActiveTab:he,cycleTab:te,areaSections:N,handleKeyDown:G,highlightMatch:K}=Ds({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:o,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l,onOpenSessionFinder:d});p.current=H.length;const J=f.useRef(te);J.current=te,f.useEffect(()=>{t&&setTimeout(()=>{var D,y;(D=x.current)==null||D.focus(),(y=x.current)==null||y.select()},50)},[t]),f.useEffect(()=>{if(!t)return;const D=window.visualViewport;if(!D||window.innerWidth>Ls)return;const y=()=>{const $=S.current;$&&($.style.height=`${D.height}px`,$.style.top=`${D.offsetTop}px`)};return y(),D.addEventListener("resize",y),D.addEventListener("scroll",y),()=>{D.removeEventListener("resize",y),D.removeEventListener("scroll",y);const $=S.current;$&&($.style.height="",$.style.top="")}},[t]),f.useEffect(()=>{if(!t)return;const D=y=>{if(y.key==="Escape"){y.preventDefault(),y.stopPropagation(),y.stopImmediatePropagation(),e();return}if(y.key==="Tab"){y.preventDefault(),y.stopPropagation(),y.stopImmediatePropagation(),J.current(y.shiftKey?-1:1);return}if(y.altKey&&!y.ctrlKey&&!y.metaKey&&(y.key==="n"||y.key==="p"||y.key==="N"||y.key==="P")){y.preventDefault(),y.stopPropagation(),y.stopImmediatePropagation();const $=y.key.toLowerCase(),ae=p.current;L($==="p"?oe=>oe>0?oe-1:ae-1:oe=>oe<ae-1?oe+1:0);return}};return window.addEventListener("keydown",D,{capture:!0}),()=>{window.removeEventListener("keydown",D,{capture:!0})}},[t,e]);const k=f.useCallback(D=>{D.target===D.currentTarget&&e()},[e]),V=f.useCallback(()=>{L(0)},[L]);return t?m.jsx("div",{ref:S,className:"spotlight-overlay",onClick:k,children:m.jsxs("div",{className:"spotlight-modal",children:[m.jsx(Rs,{ref:x,query:w,onQueryChange:B,onKeyDown:G,onResetSelection:V}),m.jsx(Ts,{activeTab:Q,onSelect:he}),m.jsx(ks,{ref:E,results:H,selectedIndex:_,query:w,activeTab:Q,areaSections:N,highlightMatch:K,onSelectIndex:L}),m.jsx($s,{})]})}):null}export{Qs as FILE_ICON_NAMES,Ks as Spotlight,$s as SpotlightFooter,Rs as SpotlightInput,nt as SpotlightItem,ks as SpotlightResults,Gs as formatDuration,Ws as formatRelativeTime,Us as getAgentIcon,jt as getFileIconFromPath,Hs as getTypeLabel,Ds as useSpotlightSearch};
@@ -1 +0,0 @@
1
- import{T as ts,u as rs,a9 as _s,aa as vs,ab as Is,j as s,I as U,n as $s,ac as Es,ad as Ds,ae as Ms,af as Ls,r as o,ag as Ss,y as Xs,f as Ps,$ as Ys,ah as Rs,ai as Gs,aj as Us,ak as Fs,al as Hs,am as Zs,s as M,an as Bs,ao as G}from"./main-B9DphKOa.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-CBPuP1jE.js";const bs=ts.memo(({agent:a,isSelected:z,isKeyboardFocused:F=!1,onSelect:L,onDoubleClick:r,onChat:g,onFocus:h,onKill:p,onDragStart:S})=>{const{t:x}=rs(["dashboard","common"]),X=_s().has(a.id),N=vs(a.status),H=Is(a),j=Ls(H),I=a.taskLabel?s.jsxs(s.Fragment,{children:[s.jsx(U,{name:"task",size:12})," ",a.taskLabel]}):a.currentTask||a.lastAssignedTask,m=a.status==="idle"&&a.lastActivity>0,[,Z]=ts.useState(0);return ts.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>Z(q=>q+1),15e3);return()=>window.clearInterval(b)},[m]),s.jsxs("div",{className:`dash-card dash-card--${N} ${z?"dash-card--selected":""} ${F?"dash-card--keyboard-focused":""}`,"data-agent-id":a.id,onClick:()=>L(a.id),onDoubleClick:b=>{b.stopPropagation(),r(a.id)},onDragStart:b=>{S==null||S(a),b.dataTransfer.effectAllowed="move"},draggable:!0,title:x("cards.doubleClickHint"),children:[s.jsxs("div",{className:"dash-card__row1",children:[s.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${N}`}),s.jsx("span",{className:"dash-card__name",children:a.name}),s.jsxs("span",{className:"dash-card__class",children:[s.jsx($s,{agent:a,size:14})," ",a.class]}),s.jsxs("span",{className:`dash-card__provider dash-card__provider--${a.provider}`,children:[s.jsx(U,{name:a.provider==="codex"||a.provider==="opencode"||a.provider==="grok"||a.provider==="pi"?"status-pending":"robot",size:11,weight:a.provider==="codex"||a.provider==="opencode"||a.provider==="grok"||a.provider==="pi"?"fill":"regular",color:a.provider==="codex"?"#a16207":a.provider==="opencode"?"#4ade80":a.provider==="grok"?"#6366f1":a.provider==="pi"?"#a855f7":void 0})," ",a.provider]}),X&&s.jsx("span",{className:"dash-card__unseen-badge",title:"New output available - click to view",children:"!"})]}),s.jsxs("div",{className:"dash-card__row2",children:[s.jsx("span",{className:`dash-card__status dash-card__status--${N}`,children:X?"Unseen":a.status}),s.jsxs("div",{className:"dash-card__context",children:[s.jsx("div",{className:"dash-card__context-bar",children:s.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${j}`,style:{width:`${H}%`}})}),s.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${j}`,children:[H,"%"]})]})]}),s.jsxs("div",{className:"dash-card__row3",children:[s.jsxs("span",{className:"dash-card__workdir",title:a.cwd,children:[s.jsx(U,{name:"folder",size:11})," ",a.cwd.split("/").pop()||a.cwd]}),m&&s.jsxs("span",{className:"dash-card__idle-time",style:{color:Ms(a.lastActivity)},title:Ds(a.lastActivity),children:[s.jsx(U,{name:"status-waiting-input",size:10})," ",Es(a.lastActivity)]})]}),I&&s.jsx("div",{className:"dash-card__row4",children:s.jsx("span",{className:"dash-card__task",children:I})}),s.jsxs("div",{className:"dash-card__actions",children:[g&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:b=>{b.stopPropagation(),g(a.id)},title:x("cards.openTerminal"),children:x("cards.chat")}),p&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:b=>{b.stopPropagation(),p(a.id)},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});bs.displayName="AgentCard";const fs=({buildings:a,onSelectBuilding:z})=>{const{t:F}=rs(["dashboard"]),L=o.useMemo(()=>Array.from(a.values()).sort((r,g)=>r.name.localeCompare(g.name)),[a]);return s.jsxs("div",{className:"dashboard-view__buildings",children:[s.jsxs("div",{className:"dashboard-view__buildings-header",children:[s.jsx("span",{className:"dashboard-view__buildings-title",children:F("buildings.title")}),s.jsx("span",{className:"dashboard-view__buildings-count",children:L.length})]}),s.jsx("div",{className:"dashboard-view__buildings-row",children:L.map(r=>{const g=vs(r.status),h=Ss(r.type);return s.jsxs("button",{className:`dash-pill dash-pill--${g}`,onClick:()=>z==null?void 0:z(r.id),title:`${r.name} (${r.type}) - ${r.status}`,children:[s.jsx("span",{className:"dash-pill__icon",children:s.jsx(U,{name:h,size:14})}),s.jsx("span",{className:"dash-pill__name",children:r.name}),s.jsx("span",{className:`dash-pill__dot dash-pill__dot--${g}`})]},r.id)})})]})};fs.displayName="BuildingPills";function qs({onSelectAgent:a,onFocusAgent:z,onKillAgent:F,onSelectBuilding:L,onOpenTerminal:r,onFocusZone:g}){const{t:h}=rs(["dashboard","common"]),p=Xs(),S=Ps(),x=Ys(),ns=Rs(),X=_s(),[N,H]=o.useState(""),[j,I]=o.useState("all"),[m,Z]=o.useState("zone"),[b,q]=o.useState(new Set),[k,T]=o.useState(null),[ps,K]=o.useState(null),[P,J]=o.useState(!1),[w,B]=o.useState(null),W=o.useMemo(()=>{const e=Array.from(p.values());return{total:e.length,working:e.filter(d=>d.status==="working"||d.status==="waiting"||d.status==="waiting_permission").length,idle:e.filter(d=>d.status==="idle").length,error:e.filter(d=>d.status==="error"||d.status==="offline"||d.status==="orphaned").length}},[p]),is=o.useMemo(()=>m==="zone"?Gs(p,x):m==="status"?Us(p,X):Fs(p),[p,x,m,X]),Q=o.useMemo(()=>{const e=N.toLowerCase().trim(),d=is.map(l=>({...l,agents:l.agents.filter(_=>{if(j==="working"){if(_.status!=="working"&&_.status!=="waiting"&&_.status!=="waiting_permission")return!1}else if(j==="error"&&_.status!=="error"&&_.status!=="offline"&&_.status!=="orphaned")return!1;return!(e&&!_.name.toLowerCase().includes(e)&&!_.class.toLowerCase().includes(e))})}));return m==="zone"?d:d.filter(l=>l.agents.length>0)},[is,j,N,m]),O=o.useCallback(e=>e.area?`area:${e.area.id}`:`${m}:${e.label}`,[m]),ss=o.useMemo(()=>Q.map(e=>({...e,sortedAgents:m==="status"?Hs(e.agents,{prioritizeRecentlyIdle:!0}):Zs(e.agents)})),[Q,m]),C=o.useMemo(()=>{const e=[];return ss.forEach(d=>{const l=O(d);b.has(l)||e.push(...d.sortedAgents)}),e},[ss,b,O]),ws=o.useCallback(e=>{q(d=>{const l=new Set(d);return l.has(e)?l.delete(e):l.add(e),l})},[]),gs=o.useCallback(e=>{r==null||r(e)},[r]),xs=o.useCallback(e=>{a==null||a(e),J(!0),B(e)},[a]),js=o.useCallback(e=>{r==null||r(e)},[r]),Ns=o.useCallback(e=>{T(e)},[]),ks=o.useCallback((e,d)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",K(d)},[]),Cs=o.useCallback(()=>{K(null)},[]),ys=o.useCallback(e=>{if(!k)return;if(e===null){const $=M.getState(),t=Array.from($.areas.values()).find(n=>n.assignedAgentIds.includes(k.id));t&&M.unassignAgentFromArea(k.id,t.id),T(null),K(null);return}const d=x.get(e);if(!d)return;const l=Array.from(p.values()),_=Bs(d,l,k.position);M.updateAgent({...k,position:{...k.position,x:_.x,z:_.z}}),M.assignAgentToArea(k.id,e),T(null),K(null)},[k,x,p]);return o.useEffect(()=>{if(C.length===0){J(!1),B(null);return}P&&(!w||!C.some(e=>e.id===w))&&(B(C[0].id),a==null||a(C[0].id))},[C,P,w,a]),o.useEffect(()=>{const e=t=>t instanceof HTMLElement?t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||t.isContentEditable:!1,d=t=>t instanceof HTMLElement?!!t.closest(".guake-terminal")||t.classList.contains("guake-input")||t.classList.contains("agent-panel-input"):!1,l=t=>{const n=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(A=>A.dataset.agentId===t);n==null||n.scrollIntoView({block:"nearest",inline:"nearest"})},_=(t,n)=>{var os,cs,ls,us,hs,ms;const A=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(i=>{const u=i.dataset.agentId;if(!u)return null;const y=i.getBoundingClientRect();return{id:u,centerX:y.left+y.width/2,centerY:y.top+y.height/2,height:y.height}}).filter(i=>i!==null).sort((i,u)=>i.centerY-u.centerY||i.centerX-u.centerX);if(A.length===0)return t;const es=A.reduce((i,u)=>i+u.height,0)/A.length,as=Math.max(18,es*.6),f=[];for(const i of A){const u=f[f.length-1];if(!u){f.push([{id:i.id,centerX:i.centerX,centerY:i.centerY}]);continue}const y=u.reduce((As,zs)=>As+zs.centerY,0)/u.length;Math.abs(i.centerY-y)<=as?u.push({id:i.id,centerX:i.centerX,centerY:i.centerY}):f.push([{id:i.id,centerX:i.centerX,centerY:i.centerY}])}f.forEach(i=>i.sort((u,y)=>u.centerX-y.centerX));const Y=f.findIndex(i=>i.some(u=>u.id===t));if(Y===-1)return((cs=(os=f[0])==null?void 0:os[0])==null?void 0:cs.id)??t;const E=f[Y],v=E.findIndex(i=>i.id===t);if(v===-1)return((us=(ls=f[0])==null?void 0:ls[0])==null?void 0:us.id)??t;if(n==="left")return((hs=E[Math.max(0,v-1)])==null?void 0:hs.id)??t;if(n==="right")return((ms=E[Math.min(E.length-1,v+1)])==null?void 0:ms.id)??t;const V=n==="up"?Math.max(0,Y-1):Math.min(f.length-1,Y+1),c=f[V],R=E[v].centerX;let D=c[0],ds=Math.abs(D.centerX-R);for(const i of c){const u=Math.abs(i.centerX-R);u<ds&&(D=i,ds=u)}return(D==null?void 0:D.id)??t},$=t=>{const n=M.getShortcuts(),A=n.find(c=>c.id==="dashboard-selector-toggle"),es=n.find(c=>c.id==="dashboard-vim-left"),as=n.find(c=>c.id==="dashboard-vim-down"),f=n.find(c=>c.id==="dashboard-vim-up"),Y=n.find(c=>c.id==="dashboard-vim-right"),E=n.find(c=>c.id==="open-terminal"),v=M.getState();if(e(t.target))if(!v.terminalOpen&&d(t.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(G(t,A)){if(C.length===0)return;t.preventDefault(),t.stopPropagation(),J(!0),B(c=>{const R=c&&C.some(D=>D.id===c)?c:C[0].id;return a==null||a(R),window.setTimeout(()=>l(R),0),R});return}const V=G(t,es)||t.key==="ArrowLeft"?"left":G(t,as)||t.key==="ArrowDown"?"down":G(t,f)||t.key==="ArrowUp"?"up":G(t,Y)||t.key==="ArrowRight"?"right":null;if(V&&P&&w){t.preventDefault(),t.stopPropagation();const c=_(w,V);c!==w&&(B(c),a==null||a(c),window.setTimeout(()=>l(c),0));return}if(G(t,E)){if(v.terminalOpen)return;if(P&&w&&v.agents.has(w)){t.preventDefault(),r==null||r(w);return}if(v.selectedAgentIds.size===1){t.preventDefault();const c=Array.from(v.selectedAgentIds)[0];r==null||r(c);return}if(v.lastSelectedAgentId&&v.agents.has(v.lastSelectedAgentId)){t.preventDefault(),r==null||r(v.lastSelectedAgentId);return}}};return document.addEventListener("keydown",$,!0),()=>document.removeEventListener("keydown",$,!0)},[C,P,w,r,a]),o.useEffect(()=>{const e=document.activeElement;e instanceof HTMLElement&&e.closest(".guake-terminal")&&!M.getState().terminalOpen&&e.blur()},[]),s.jsxs("div",{className:"dashboard-view",children:[s.jsxs("div",{className:"dashboard-view__topbar",children:[s.jsxs("div",{className:"dashboard-view__metrics",children:[s.jsxs("button",{className:`dashboard-view__metric-btn ${j==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:W.total}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:labels.agents")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${j==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("working"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:W.working}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.working")})]}),s.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:W.idle}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.idle")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${j==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("error"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:W.error}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.error")})]})]}),s.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:h("searchPlaceholder"),value:N,onChange:e=>H(e.target.value)})]}),s.jsxs("div",{className:"dashboard-view__grouping",children:[s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("zone"),children:h("grouping.byZone")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("status"),children:h("grouping.byStatus")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("activity"),children:h("grouping.byActivity")})]}),s.jsxs("div",{className:"dashboard-view__content",children:[ss.map(e=>{const d=O(e),l=b.has(d),_=e.sortedAgents,$=e.agents.filter(n=>n.status==="working"||n.status==="waiting"||n.status==="waiting_permission").length,t=e.agents.filter(n=>X.has(n.id)).length;return s.jsxs("div",{className:`dashboard-view__zone ${ps===(e.area?e.area.id:null)&&k?"dashboard-view__zone--drag-over":""}`,onDragOver:n=>ks(n,e.area?e.area.id:null),onDragLeave:Cs,onDrop:()=>ys(e.area?e.area.id:null),children:[s.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>ws(d),children:[s.jsxs("div",{className:"dashboard-view__zone-left",children:[s.jsx("span",{className:`dashboard-view__zone-chevron ${l?"dashboard-view__zone-chevron--collapsed":""}`,children:s.jsx(U,{name:"caret-down",size:12})}),s.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:e.color}}),s.jsx("span",{className:"dashboard-view__zone-name",children:e.label}),s.jsxs("span",{className:"dashboard-view__zone-count",children:[h("agentCount",{count:e.agents.length}),$>0&&s.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",$," ",h("working")]}),t>0&&s.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",t," Unseen"]})]})]}),e.area&&g&&s.jsx("button",{className:"dashboard-view__zone-focus",onClick:n=>{n.stopPropagation(),g(e.area.id)},title:h("focusZone"),children:h("focusZone")})]}),!l&&s.jsx("div",{className:"dashboard-view__zone-grid",children:_.map(n=>s.jsx(bs,{agent:n,isSelected:ns.has(n.id),isKeyboardFocused:P&&w===n.id,onSelect:xs,onDoubleClick:gs,onChat:js,onFocus:z,onKill:F,onDragStart:Ns},n.id))})]},d)}),Q.length===0&&s.jsx("div",{className:"dashboard-view__empty",children:N?h("noAgentsMatching",{search:N}):h("noAgentsSpawned")}),S.size>0&&s.jsx(fs,{buildings:S,onSelectBuilding:L})]})]})}export{qs as DashboardView};