agentstudio 0.1.21 → 0.1.22

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 (130) hide show
  1. package/index.d.ts.map +1 -1
  2. package/index.js +2 -0
  3. package/index.js.map +1 -1
  4. package/package.json +1 -1
  5. package/public/assets/{AgentsPage-Nvg2xu6K.js → AgentsPage-CtuoPrly.js} +2 -2
  6. package/public/assets/{Button-Co56C389.js → Button-DtXXTa68.js} +1 -1
  7. package/public/assets/{ChatPage-D6sol0ad.js → ChatPage-Ht-lF7H1.js} +178 -149
  8. package/public/assets/CloudflareTunnelPage-BJNk2Ilw.js +1 -0
  9. package/public/assets/{CommandForm-Bk7F_HU8.js → CommandForm-hHwraC0y.js} +1 -1
  10. package/public/assets/{CommandsPage-DZHyOdKd.js → CommandsPage-DLySuqrX.js} +1 -1
  11. package/public/assets/DashboardPage-BuUwTPV6.js +1 -0
  12. package/public/assets/{FileBrowser-BYweUPH4.js → FileBrowser-CDuDggHj.js} +5 -5
  13. package/public/assets/{FileExplorer-DNYj6Tsx.js → FileExplorer-D5l2HgDS.js} +1 -1
  14. package/public/assets/{GeneralSettingsPage-D9Xa7Nd8.js → GeneralSettingsPage-EODcSgWo.js} +1 -1
  15. package/public/assets/LandingPage-BAPul_Kj.js +1 -0
  16. package/public/assets/{LoginPage-DcaGNCXH.js → LoginPage-CQo-eq6b.js} +4 -4
  17. package/public/assets/McpAdminSettingsPage-BlEhZLV9.js +7 -0
  18. package/public/assets/{McpPage-CtWf1CoL.js → McpPage-DLMLfSAG.js} +4 -4
  19. package/public/assets/{MemorySettingsPage-JTry4Ccp.js → MemorySettingsPage-By_AtsBT.js} +1 -1
  20. package/public/assets/{PluginsPage-D-BHjQ3P.js → PluginsPage-1Z4TkAow.js} +1 -1
  21. package/public/assets/ProjectSelector-2mn8IO5d.js +1 -0
  22. package/public/assets/{ProjectsPage-lLUk4-Xa.js → ProjectsPage-CWWZuVNb.js} +5 -5
  23. package/public/assets/ScheduledTasksPage-BcosBF2P.js +1 -0
  24. package/public/assets/SettingsLayout-a2GRHdeo.js +1 -0
  25. package/public/assets/SkillsPage-zIEnU63B.js +18 -0
  26. package/public/assets/{SubagentForm-BdUK1U4y.js → SubagentForm-DEzelVPW.js} +1 -1
  27. package/public/assets/{SubagentsPage-Dnq70IFd.js → SubagentsPage-CS6hYApE.js} +1 -1
  28. package/public/assets/{ToastTestPage-BfJQRFIm.js → ToastTestPage-7Uhhhl-X.js} +1 -1
  29. package/public/assets/{ToolsList-Dl5F2fWk.js → ToolsList-I7JqIU7m.js} +1 -1
  30. package/public/assets/UnifiedToolSelector-Cw1xKmPZ.js +1 -0
  31. package/public/assets/{VersionSettingsPage-BfoCcham.js → VersionSettingsPage-7qtAfOC7.js} +3 -3
  32. package/public/assets/{_basePickBy-7C_e0Xv1.js → _basePickBy-DQTDhNdw.js} +1 -1
  33. package/public/assets/{_baseUniq-eGJNLBzx.js → _baseUniq-B_gfAzTb.js} +1 -1
  34. package/public/assets/{agents-ChrA1R0y.js → agents-B3InAIfY.js} +1 -1
  35. package/public/assets/{arc-CuA752eE.js → arc-Do_7w4P3.js} +1 -1
  36. package/public/assets/architectureDiagram-VXUJARFQ-CGxYnv44.js +36 -0
  37. package/public/assets/{blockDiagram-VD42YOAC-72nsMt_i.js → blockDiagram-VD42YOAC-DMToAyob.js} +1 -1
  38. package/public/assets/{c4Diagram-YG6GDRKO-BNJSAXcg.js → c4Diagram-YG6GDRKO-CEukDAnl.js} +1 -1
  39. package/public/assets/channel-Cr4EWrFf.js +1 -0
  40. package/public/assets/{chunk-4BX2VUAB-RPxkCWhH.js → chunk-4BX2VUAB-Djex-iWv.js} +1 -1
  41. package/public/assets/{chunk-55IACEB6-3ePDt0kp.js → chunk-55IACEB6-Dq-JM11t.js} +1 -1
  42. package/public/assets/{chunk-B4BG7PRW-CBg_BBfl.js → chunk-B4BG7PRW-COcDV1Bz.js} +1 -1
  43. package/public/assets/{chunk-DI55MBZ5-DIh69TUJ.js → chunk-DI55MBZ5-AiToZLMc.js} +1 -1
  44. package/public/assets/{chunk-FMBD7UC4-BbjwhyTe.js → chunk-FMBD7UC4-CIUbRtI8.js} +1 -1
  45. package/public/assets/{chunk-QN33PNHL-BpH-o_YR.js → chunk-QN33PNHL-DWVKAIM5.js} +1 -1
  46. package/public/assets/{chunk-QZHKN3VN-DYB7rh5Q.js → chunk-QZHKN3VN-CH3FeiqK.js} +1 -1
  47. package/public/assets/{chunk-TZMSLE5B-DPCYEVb3.js → chunk-TZMSLE5B-DAEUDEL5.js} +1 -1
  48. package/public/assets/classDiagram-2ON5EDUG-BCYMgV2U.js +1 -0
  49. package/public/assets/classDiagram-v2-WZHVMYZB-BCYMgV2U.js +1 -0
  50. package/public/assets/clone-T66nRwp8.js +1 -0
  51. package/public/assets/cose-bilkent-S5V4N54A-CyCeb_x1.js +1 -0
  52. package/public/assets/dagre-6UL2VRFP-D2pLZr7B.js +4 -0
  53. package/public/assets/diagram-PSM6KHXK-D3y-uGlf.js +24 -0
  54. package/public/assets/diagram-QEK2KX5R-BWiK1jr7.js +43 -0
  55. package/public/assets/diagram-S2PKOQOG-Cbs-OyQV.js +24 -0
  56. package/public/assets/{erDiagram-Q2GNP2WA-BX1DpOGx.js → erDiagram-Q2GNP2WA-mmj7cEQ3.js} +1 -1
  57. package/public/assets/{flowDiagram-NV44I4VS-HAAlzNbq.js → flowDiagram-NV44I4VS-C-D2yYgt.js} +1 -1
  58. package/public/assets/ganttDiagram-LVOFAZNH-CjVweKuf.js +267 -0
  59. package/public/assets/gitGraphDiagram-NY62KEGX-B5Fajpr9.js +65 -0
  60. package/public/assets/{graph-m515btDj.js → graph-BkrzwQTG.js} +1 -1
  61. package/public/assets/{index-Bn3v3S9-.js → index-C8oBHB0h.js} +41 -41
  62. package/public/assets/index-C9P0ZrJZ.css +1 -0
  63. package/public/assets/infoDiagram-F6ZHWCRC-KYBfowoc.js +2 -0
  64. package/public/assets/{journeyDiagram-XKPGCS4Q-BfzTomS0.js → journeyDiagram-XKPGCS4Q-G0GXThg3.js} +1 -1
  65. package/public/assets/{kanban-definition-3W4ZIXB7-Cgju7b-L.js → kanban-definition-3W4ZIXB7-CL5GnHw8.js} +1 -1
  66. package/public/assets/{layout-BKQfQSxJ.js → layout-Dv8_9WGx.js} +1 -1
  67. package/public/assets/{linear-DigtLz3B.js → linear-Bo6VfLsh.js} +1 -1
  68. package/public/assets/{mindmap-definition-VGOIOE7T-qopraVFy.js → mindmap-definition-VGOIOE7T-Bs3tu0GR.js} +1 -1
  69. package/public/assets/{pieDiagram-ADFJNKIX-BcoaAI-L.js → pieDiagram-ADFJNKIX-Cb8bwKps.js} +1 -1
  70. package/public/assets/{quadrantDiagram-AYHSOK5B-D-DwcoSd.js → quadrantDiagram-AYHSOK5B-Dbrv0MtL.js} +1 -1
  71. package/public/assets/{requirementDiagram-UZGBJVZJ-DbQCpx77.js → requirementDiagram-UZGBJVZJ-nBiRIqA6.js} +1 -1
  72. package/public/assets/sankeyDiagram-TZEHDZUN-CxJ9tzJO.js +10 -0
  73. package/public/assets/{sequenceDiagram-WL72ISMW-BdzICjxO.js → sequenceDiagram-WL72ISMW-Cd7CbJ23.js} +1 -1
  74. package/public/assets/stateDiagram-FKZM4ZOC-BUzdDNZC.js +1 -0
  75. package/public/assets/stateDiagram-v2-4FDKWEC3-TEx1vYfv.js +1 -0
  76. package/public/assets/{table-D0L2RL5i.js → table-CHBLEjZn.js} +1 -1
  77. package/public/assets/{timeline-definition-IT6M3QCI-BAvjPYvX.js → timeline-definition-IT6M3QCI-DJ3qh1sp.js} +1 -1
  78. package/public/assets/{tools-IcPNZlPj.js → tools-CUwQTL-8.js} +1 -1
  79. package/public/assets/{treemap-KMMF4GRG-DtkpVA56.js → treemap-KMMF4GRG-pUUUNNXu.js} +1 -1
  80. package/public/assets/{ui-components-D1St49qC.js → ui-components-icUM6BEH.js} +110 -110
  81. package/public/assets/{useAgents-BnDTkOG8.js → useAgents-HXlzUYSz.js} +2 -2
  82. package/public/assets/{useClaudeVersions-CD59tFWM.js → useClaudeVersions-DQ5Wg6Zy.js} +1 -1
  83. package/public/assets/{useCommands-mvMu3mMD.js → useCommands-vX47i_1v.js} +1 -1
  84. package/public/assets/{useProjects-YXOjaOwL.js → useProjects-DR0CTJHB.js} +1 -1
  85. package/public/assets/useSessions-CanqFxtL.js +1 -0
  86. package/public/assets/{xychartDiagram-PRI3JC2R-ByBTDWE2.js → xychartDiagram-PRI3JC2R-HeLAL-7k.js} +1 -1
  87. package/public/index.html +5 -5
  88. package/public/screenshot-chat.png +0 -0
  89. package/public/screenshot-mcp.png +0 -0
  90. package/routes/agents.d.ts.map +1 -1
  91. package/routes/agents.js +17 -0
  92. package/routes/agents.js.map +1 -1
  93. package/routes/cloudflareTunnel.d.ts +4 -0
  94. package/routes/cloudflareTunnel.d.ts.map +1 -0
  95. package/routes/cloudflareTunnel.js +250 -0
  96. package/routes/cloudflareTunnel.js.map +1 -0
  97. package/services/claudeSession.d.ts +9 -0
  98. package/services/claudeSession.d.ts.map +1 -1
  99. package/services/claudeSession.js +16 -0
  100. package/services/claudeSession.js.map +1 -1
  101. package/services/sessionManager.d.ts +6 -0
  102. package/services/sessionManager.d.ts.map +1 -1
  103. package/services/sessionManager.js +37 -2
  104. package/services/sessionManager.js.map +1 -1
  105. package/public/assets/DashboardPage-29qC7Ev1.js +0 -15
  106. package/public/assets/LandingPage-CjnT-cvO.js +0 -1
  107. package/public/assets/McpAdminSettingsPage-DgR3E2Bd.js +0 -7
  108. package/public/assets/ProjectSelector-DSXOjMQC.js +0 -1
  109. package/public/assets/ScheduledTasksPage-5hPbd9Vs.js +0 -1
  110. package/public/assets/SettingsLayout-DGJspXLp.js +0 -1
  111. package/public/assets/SkillsPage-DBw0m7D2.js +0 -18
  112. package/public/assets/UnifiedToolSelector-CNbPsiuq.js +0 -1
  113. package/public/assets/architectureDiagram-VXUJARFQ-BnPYh1OW.js +0 -36
  114. package/public/assets/channel-CIunGC5m.js +0 -1
  115. package/public/assets/classDiagram-2ON5EDUG-aUQHFsTA.js +0 -1
  116. package/public/assets/classDiagram-v2-WZHVMYZB-aUQHFsTA.js +0 -1
  117. package/public/assets/clone-Ckf7tA1V.js +0 -1
  118. package/public/assets/cose-bilkent-S5V4N54A-CnpfmL-Y.js +0 -1
  119. package/public/assets/dagre-6UL2VRFP-DR9x77Xf.js +0 -4
  120. package/public/assets/diagram-PSM6KHXK-SONPsQNx.js +0 -24
  121. package/public/assets/diagram-QEK2KX5R-BKYFSfC1.js +0 -43
  122. package/public/assets/diagram-S2PKOQOG-CkM0APZj.js +0 -24
  123. package/public/assets/ganttDiagram-LVOFAZNH-BqzWexqa.js +0 -267
  124. package/public/assets/gitGraphDiagram-NY62KEGX-CIPmSp43.js +0 -65
  125. package/public/assets/index-DWieeYj4.css +0 -1
  126. package/public/assets/infoDiagram-F6ZHWCRC-Pn4yNWrF.js +0 -2
  127. package/public/assets/sankeyDiagram-TZEHDZUN-BVk8387S.js +0 -10
  128. package/public/assets/stateDiagram-FKZM4ZOC-CYY-uUvJ.js +0 -1
  129. package/public/assets/stateDiagram-v2-4FDKWEC3-Dh2Kvomq.js +0 -1
  130. package/public/assets/tabManager-B2LQO_Ll.js +0 -30
@@ -0,0 +1 @@
1
+ import{j as e}from"./data-structures-C0h9Oap1.js";import{r as a,W as de}from"./monaco-editor-DHKm5-VF.js";import{b as ie}from"./index-C8oBHB0h.js";import{u as ce}from"./tools-CUwQTL-8.js";import{R as z,a2 as O,j as W,a3 as m,a4 as g,a5 as _,T as oe,a6 as o,l as J,a7 as xe,G as ge,z as C,v as ue}from"./ui-components-icUM6BEH.js";import"./syntax-highlighting-CnREyncB.js";import"./agents-B3InAIfY.js";const we=()=>{const{t:r}=ce("pages"),{isMobile:w}=ie(),[l,M]=a.useState(null),[h,S]=a.useState(""),[b,T]=a.useState(""),[E,H]=a.useState(""),[I,K]=a.useState("4936"),[Q,f]=a.useState(!1),[F,A]=a.useState(!1),[D,P]=a.useState(!1),[$,d]=a.useState(null),[U,u]=a.useState(null),[L,R]=a.useState(!1),[V,q]=a.useState(!1),[c,k]=a.useState(null),[x,i]=a.useState("intro"),[B,p]=a.useState(!0);a.useEffect(()=>{j()},[]),a.useEffect(()=>{l&&(l.activeTunnel?(i("done"),p(!1)):l.hasApiToken&&l.hasAccountId?i("create"):i("credentials"))},[l]);const j=async()=>{f(!0),d(null);try{const t=await fetch("/api/cloudflare-tunnel/config",{headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}});if(!t.ok)throw new Error("Failed to load configuration");const s=await t.json();M(s)}catch(t){console.error("Error loading config:",t),d(t instanceof Error?t.message:"Failed to load configuration")}finally{f(!1)}},X=async()=>{if(!h||!b){d(r("settings.cloudflare.errors.credentialsRequired"));return}A(!0),d(null),u(null);try{const t=await fetch("/api/cloudflare-tunnel/config",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("jwt")}`},body:JSON.stringify({apiToken:h,accountId:b})});if(!t.ok){const s=await t.json();throw new Error(s.message||"Failed to save credentials")}u(r("settings.cloudflare.credentialsSaved")),await j(),i("create"),S(""),T("")}catch(t){console.error("Error saving credentials:",t),d(t instanceof Error?t.message:"Failed to save credentials")}finally{A(!1)}},Y=async()=>{P(!0),d(null),u(null),k(null);try{const t=await fetch("/api/cloudflare-tunnel/create",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("jwt")}`},body:JSON.stringify({subdomain:E||void 0,localPort:parseInt(I)})});if(!t.ok){const n=await t.json();throw new Error(n.message||"Failed to create tunnel")}const s=await t.json();k(s.tunnel),u(r("settings.cloudflare.tunnelCreated")),i("start"),await j()}catch(t){console.error("Error creating tunnel:",t),d(t instanceof Error?t.message:"Failed to create tunnel")}finally{P(!1)}},Z=async t=>{if(confirm(r("settings.cloudflare.confirmDelete"))){f(!0),d(null);try{const s=await fetch(`/api/cloudflare-tunnel/delete/${t}`,{method:"DELETE",headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}});if(!s.ok){const n=await s.json();throw new Error(n.message||"Failed to delete tunnel")}u(r("settings.cloudflare.tunnelDeleted")),k(null),i("intro"),p(!0),await j()}catch(s){console.error("Error deleting tunnel:",s),d(s instanceof Error?s.message:"Failed to delete tunnel")}finally{f(!1)}}},N=async(t,s)=>{try{await navigator.clipboard.writeText(t),s==="url"?(R(!0),setTimeout(()=>R(!1),2e3)):(q(!0),setTimeout(()=>q(!1),2e3))}catch(n){console.error("Failed to copy:",n)}},ee=()=>{const t=[{id:"intro",label:r("settings.cloudflare.wizard.steps.intro"),icon:g},{id:"credentials",label:r("settings.cloudflare.wizard.steps.credentials"),icon:O},{id:"create",label:r("settings.cloudflare.wizard.steps.create"),icon:_},{id:"start",label:r("settings.cloudflare.wizard.steps.start"),icon:oe},{id:"done",label:r("settings.cloudflare.wizard.steps.done"),icon:o}],s=t.findIndex(n=>n.id===x);return e.jsx("div",{className:"mb-8",children:e.jsx("div",{className:"flex items-center justify-between",children:t.map((n,v)=>{const ne=n.icon,G=v===s,y=v<s;return e.jsxs(de.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${G?"bg-blue-600 text-white":y?"bg-green-600 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-400"}`,children:y?e.jsx(m,{className:"w-5 h-5"}):e.jsx(ne,{className:"w-5 h-5"})}),e.jsx("span",{className:`mt-2 text-xs ${G||y?"text-gray-900 dark:text-white font-medium":"text-gray-400"}`,children:n.label})]}),v<t.length-1&&e.jsx("div",{className:`flex-1 h-0.5 mx-2 ${y?"bg-green-600":"bg-gray-200 dark:bg-gray-700"}`})]},n.id)})})})},re=()=>e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-6",children:[e.jsxs("h3",{className:"text-lg font-semibold text-blue-900 dark:text-blue-100 mb-4 flex items-center",children:[e.jsx(g,{className:"w-5 h-5 mr-2"}),r("settings.cloudflare.wizard.intro.title")]}),e.jsxs("div",{className:"space-y-3 text-sm text-blue-800 dark:text-blue-200",children:[e.jsx("p",{children:r("settings.cloudflare.wizard.intro.description")}),e.jsxs("ul",{className:"list-disc list-inside space-y-2 ml-2",children:[e.jsx("li",{children:r("settings.cloudflare.wizard.intro.benefit1")}),e.jsx("li",{children:r("settings.cloudflare.wizard.intro.benefit2")}),e.jsx("li",{children:r("settings.cloudflare.wizard.intro.benefit3")}),e.jsx("li",{children:r("settings.cloudflare.wizard.intro.benefit4")})]})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-6",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-3",children:r("settings.cloudflare.wizard.intro.requirements")}),e.jsxs("div",{className:"space-y-2 text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("div",{className:"flex items-start",children:[e.jsx(o,{className:"w-4 h-4 text-green-600 mr-2 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:r("settings.cloudflare.wizard.intro.req1")})]}),e.jsxs("div",{className:"flex items-start",children:[e.jsx(o,{className:"w-4 h-4 text-green-600 mr-2 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:r("settings.cloudflare.wizard.intro.req2")})]}),e.jsxs("div",{className:"flex items-start",children:[e.jsx(o,{className:"w-4 h-4 text-green-600 mr-2 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:r("settings.cloudflare.wizard.intro.req3")})]})]})]}),e.jsxs("button",{onClick:()=>i("credentials"),className:"w-full px-4 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 flex items-center justify-center space-x-2",children:[e.jsx("span",{children:r("settings.cloudflare.wizard.intro.getStarted")}),e.jsx(J,{className:"w-5 h-5"})]})]}),te=()=>e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx(g,{className:"w-5 h-5 text-yellow-600 dark:text-yellow-400 mr-3 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-yellow-800 dark:text-yellow-200",children:[e.jsx("p",{className:"font-medium mb-2",children:r("settings.cloudflare.wizard.credentials.howToGet")}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 ml-2",children:[e.jsx("li",{children:r("settings.cloudflare.wizard.credentials.step1")}),e.jsx("li",{children:r("settings.cloudflare.wizard.credentials.step2")}),e.jsx("li",{children:r("settings.cloudflare.wizard.credentials.step3")})]}),e.jsxs("a",{href:"https://dash.cloudflare.com/profile/api-tokens",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center mt-3 text-yellow-700 dark:text-yellow-300 hover:underline font-medium",children:[r("settings.cloudflare.wizard.credentials.openDashboard"),e.jsx(xe,{className:"w-4 h-4 ml-1"})]})]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("settings.cloudflare.credentials.apiToken")}),e.jsx("input",{type:"password",value:h,onChange:t=>S(t.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white",placeholder:"Enter Cloudflare API Token"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("settings.cloudflare.credentials.accountId")}),e.jsx("input",{type:"text",value:b,onChange:t=>T(t.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white",placeholder:"Enter Cloudflare Account ID"})]}),e.jsx("button",{onClick:X,disabled:F||!h||!b,className:"w-full px-4 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center space-x-2",children:F?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:r("settings.cloudflare.credentials.saving")})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:r("settings.cloudflare.wizard.credentials.saveAndContinue")}),e.jsx(J,{className:"w-5 h-5"})]})})]})]}),se=()=>e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx(g,{className:"w-5 h-5 text-blue-600 dark:text-blue-400 mr-3 mt-0.5 flex-shrink-0"}),e.jsx("div",{className:"text-sm text-blue-800 dark:text-blue-200",children:e.jsx("p",{children:r("settings.cloudflare.wizard.create.description")})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("settings.cloudflare.tunnel.subdomain")}),e.jsx("input",{type:"text",value:E,onChange:t=>H(t.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white",placeholder:r("settings.cloudflare.tunnel.subdomainPlaceholder")}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:r("settings.cloudflare.tunnel.subdomainHelp")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:r("settings.cloudflare.tunnel.localPort")}),e.jsx("input",{type:"number",value:I,onChange:t=>K(t.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white",placeholder:"4936"})]}),e.jsx("button",{onClick:Y,disabled:D,className:"w-full px-4 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center space-x-2",children:D?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:r("settings.cloudflare.tunnel.creating")})]}):e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"w-5 h-5"}),e.jsx("span",{children:r("settings.cloudflare.wizard.create.createButton")})]})})]})]}),ae=()=>c?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx(o,{className:"w-5 h-5 text-green-600 dark:text-green-400 mr-3 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-green-800 dark:text-green-200",children:[e.jsx("p",{className:"font-medium",children:r("settings.cloudflare.wizard.start.tunnelCreated")}),e.jsx("p",{className:"mt-1",children:r("settings.cloudflare.wizard.start.nextStep")})]})]})}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-6",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-4",children:r("settings.cloudflare.wizard.start.yourPublicUrl")}),e.jsxs("div",{className:"flex items-center space-x-2 p-3 bg-gray-50 dark:bg-gray-900 rounded border border-gray-200 dark:border-gray-700",children:[e.jsx(ge,{className:"w-5 h-5 text-blue-600 flex-shrink-0"}),e.jsx("a",{href:c.publicUrl,target:"_blank",rel:"noopener noreferrer",className:"flex-1 text-blue-600 dark:text-blue-400 hover:underline font-mono text-sm break-all",children:c.publicUrl}),e.jsx("button",{onClick:()=>N(c.publicUrl,"url"),className:"p-2 hover:bg-gray-200 dark:hover:bg-gray-700 rounded flex-shrink-0",children:L?e.jsx(m,{className:"w-4 h-4 text-green-600"}):e.jsx(C,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx(W,{className:"w-5 h-5 text-yellow-600 dark:text-yellow-400 mr-3 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-yellow-800 dark:text-yellow-200",children:[e.jsx("p",{className:"font-medium mb-2",children:r("settings.cloudflare.wizard.start.importantNote")}),e.jsx("p",{children:r("settings.cloudflare.wizard.start.needToStartClient")})]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white",children:r("settings.cloudflare.wizard.start.howToStart")}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[r("settings.cloudflare.wizard.start.option1")," (",r("settings.cloudflare.wizard.start.recommended"),")"]}),e.jsx("button",{onClick:()=>N(c.instructions.docker,"command"),className:"text-xs px-2 py-1 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 rounded flex items-center space-x-1",children:V?e.jsxs(e.Fragment,{children:[e.jsx(m,{className:"w-3 h-3"}),e.jsx("span",{children:r("settings.cloudflare.wizard.start.copied")})]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"w-3 h-3"}),e.jsx("span",{children:r("settings.cloudflare.wizard.start.copy")})]})})]}),e.jsx("code",{className:"block text-xs bg-white dark:bg-gray-800 p-3 rounded border border-gray-300 dark:border-gray-600 overflow-x-auto",children:c.instructions.docker})]}),e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("div",{className:"mb-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:r("settings.cloudflare.wizard.start.option2")})}),e.jsxs("div",{className:"space-y-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsxs("p",{children:["1. ",r("settings.cloudflare.wizard.start.installCloudfared")]}),e.jsx("code",{className:"block bg-white dark:bg-gray-800 p-2 rounded border border-gray-300 dark:border-gray-600",children:"brew install cloudflare/cloudflare/cloudflared"}),e.jsxs("p",{children:["2. ",r("settings.cloudflare.wizard.start.runCommand")]}),e.jsx("code",{className:"block bg-white dark:bg-gray-800 p-2 rounded border border-gray-300 dark:border-gray-600 overflow-x-auto",children:c.instructions.cli})]})]})]}),e.jsxs("button",{onClick:()=>{i("done"),p(!1)},className:"w-full px-4 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 flex items-center justify-center space-x-2",children:[e.jsx(o,{className:"w-5 h-5"}),e.jsx("span",{children:r("settings.cloudflare.wizard.start.finishSetup")})]})]}):null,le=()=>l?.activeTunnel?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-6 text-center",children:[e.jsx(o,{className:"w-16 h-16 text-green-600 dark:text-green-400 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-semibold text-green-900 dark:text-green-100 mb-2",children:r("settings.cloudflare.wizard.done.title")}),e.jsx("p",{className:"text-green-800 dark:text-green-200",children:r("settings.cloudflare.wizard.done.description")})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white",children:r("settings.cloudflare.tunnel.active")}),e.jsxs("button",{onClick:()=>Z(l.activeTunnel.tunnelId),className:"text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 text-sm flex items-center space-x-1",children:[e.jsx(ue,{className:"w-4 h-4"}),e.jsx("span",{children:r("settings.cloudflare.wizard.done.deleteTunnel")})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:[r("settings.cloudflare.tunnel.publicUrl"),":"]}),e.jsxs("div",{className:"flex items-center space-x-2 mt-1 p-2 bg-gray-50 dark:bg-gray-900 rounded",children:[e.jsx("a",{href:l.activeTunnel.publicUrl,target:"_blank",rel:"noopener noreferrer",className:"flex-1 text-blue-600 dark:text-blue-400 hover:underline font-mono text-sm break-all",children:l.activeTunnel.publicUrl}),e.jsx("button",{onClick:()=>N(l.activeTunnel.publicUrl,"url"),className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:L?e.jsx(m,{className:"w-4 h-4 text-green-600"}):e.jsx(C,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsxs("span",{className:"text-gray-600 dark:text-gray-400",children:[r("settings.cloudflare.tunnel.name"),":"]}),e.jsx("p",{className:"font-mono text-gray-900 dark:text-white",children:l.activeTunnel.tunnelName})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-gray-600 dark:text-gray-400",children:[r("settings.cloudflare.tunnel.localPort"),":"]}),e.jsx("p",{className:"font-mono text-gray-900 dark:text-white",children:l.activeTunnel.localPort})]})]}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[r("settings.cloudflare.tunnel.createdAt"),": ",new Date(l.activeTunnel.createdAt).toLocaleString()]})]})]}),e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx(g,{className:"w-5 h-5 text-blue-600 dark:text-blue-400 mr-3 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200",children:[e.jsx("p",{className:"font-medium mb-1",children:r("settings.cloudflare.wizard.done.reminder")}),e.jsx("p",{children:r("settings.cloudflare.wizard.done.keepClientRunning")})]})]})})]}):null;return Q&&!l?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(z,{className:"w-8 h-8 animate-spin text-blue-500"})}):e.jsxs("div",{className:`${w?"space-y-4":"space-y-6"}`,children:[e.jsxs("div",{children:[e.jsxs("h2",{className:`${w?"text-xl":"text-2xl"} font-bold text-gray-900 dark:text-white mb-2 flex items-center space-x-2`,children:[e.jsx(O,{className:`${w?"w-5 h-5":"w-6 h-6"}`}),e.jsx("span",{children:r("settings.cloudflare.title")})]}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:r("settings.cloudflare.description")})]}),$&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start space-x-3",children:[e.jsx(W,{className:"w-5 h-5 text-red-500 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:$})]}),U&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4 flex items-start space-x-3",children:[e.jsx(m,{className:"w-5 h-5 text-green-500 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-green-700 dark:text-green-400",children:U})]}),B&&e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:[ee(),x==="intro"&&re(),x==="credentials"&&te(),x==="create"&&se(),x==="start"&&ae(),x==="done"&&le()]}),!B&&l?.activeTunnel&&e.jsxs("button",{onClick:()=>p(!0),className:"text-blue-600 dark:text-blue-400 hover:underline text-sm flex items-center space-x-1",children:[e.jsx(g,{className:"w-4 h-4"}),e.jsx("span",{children:r("settings.cloudflare.wizard.showGuide")})]})]})};export{we as CloudflareTunnelPage};
@@ -1,4 +1,4 @@
1
- import{j as e}from"./data-structures-C0h9Oap1.js";import{r as l}from"./monaco-editor-DHKm5-VF.js";import{b as I,c as Z,d as J,e as K}from"./useCommands-mvMu3mMD.js";import{U as Q}from"./UnifiedToolSelector-CNbPsiuq.js";import{u as U}from"./tools-IcPNZlPj.js";import{d as V,o as X,y as Y,j as ee}from"./ui-components-D1St49qC.js";const le=({command:o,projectId:x,onClose:_,onSuccess:z})=>{const{t:a}=U("components"),{t:C}=U("common"),[s,n]=l.useState({name:o?"":"optimize",description:o?"":a("commandForm.exampleDescription"),content:o?"":a("commandForm.exampleContent"),scope:x?"project":"user",namespace:o?"":"frontend",argumentHint:o?"":"[filename] [options]",allowedTools:[],model:""}),[c,T]=l.useState({}),[u,q]=l.useState(!1),[S,p]=l.useState(""),[H,f]=l.useState(!0),[M,$]=l.useState(!1),[m,E]=l.useState([]),[i,j]=l.useState([]),[R,P]=l.useState(!1),w=x?I(x):Z(),N=x?J(x):K(),h=!!o,k=r=>{const t=[];return r.description&&t.push(`description: ${r.description}`),r.argumentHint&&t.push(`argument-hint: ${r.argumentHint}`),r.namespace&&t.push(`namespace: ${r.namespace}`),r.allowedTools&&r.allowedTools.length>0&&t.push(`allowed-tools: ${r.allowedTools.join(", ")}`),r.model&&t.push(`model: ${r.model}`),t.length>0?`---
1
+ import{j as e}from"./data-structures-C0h9Oap1.js";import{r as l}from"./monaco-editor-DHKm5-VF.js";import{b as I,c as K,d as Z,e as J}from"./useCommands-vX47i_1v.js";import{U as Q}from"./UnifiedToolSelector-Cw1xKmPZ.js";import{u as U}from"./tools-CUwQTL-8.js";import{d as V,o as X,K as Y,j as ee}from"./ui-components-icUM6BEH.js";const le=({command:o,projectId:x,onClose:_,onSuccess:z})=>{const{t:a}=U("components"),{t:C}=U("common"),[s,n]=l.useState({name:o?"":"optimize",description:o?"":a("commandForm.exampleDescription"),content:o?"":a("commandForm.exampleContent"),scope:x?"project":"user",namespace:o?"":"frontend",argumentHint:o?"":"[filename] [options]",allowedTools:[],model:""}),[c,T]=l.useState({}),[u,q]=l.useState(!1),[S,p]=l.useState(""),[H,f]=l.useState(!0),[M,$]=l.useState(!1),[m,E]=l.useState([]),[i,j]=l.useState([]),[R,P]=l.useState(!1),w=x?I(x):K(),N=x?Z(x):J(),h=!!o,k=r=>{const t=[];return r.description&&t.push(`description: ${r.description}`),r.argumentHint&&t.push(`argument-hint: ${r.argumentHint}`),r.namespace&&t.push(`namespace: ${r.namespace}`),r.allowedTools&&r.allowedTools.length>0&&t.push(`allowed-tools: ${r.allowedTools.join(", ")}`),r.model&&t.push(`model: ${r.model}`),t.length>0?`---
2
2
  ${t.join(`
3
3
  `)}
4
4
  ---
@@ -1 +1 @@
1
- import{j as e}from"./data-structures-C0h9Oap1.js";import{r as i}from"./monaco-editor-DHKm5-VF.js";import{T as P,a as D,b as j,c as m,d as B,e as x}from"./table-D0L2RL5i.js";import{u as L,a as R}from"./useCommands-mvMu3mMD.js";import{C as q}from"./CommandForm-Bk7F_HU8.js";import{f as N}from"./dateFormat-CXa8VnEC.js";import{u as z}from"./index-Bn3v3S9-.js";import{T as f}from"./ToolsList-Dl5F2fWk.js";import{u as G}from"./tools-IcPNZlPj.js";import{j as v,g as I,p as J,o as k,m as w,u as C,v as $,E as K}from"./ui-components-D1St49qC.js";import"./syntax-highlighting-CnREyncB.js";import"./agents-ChrA1R0y.js";import"./UnifiedToolSelector-CNbPsiuq.js";const re=()=>{const{t}=G("pages"),{isMobile:a}=z(),[d]=i.useState({scope:"user"}),[n,T]=i.useState(""),[S,r]=i.useState(!1),[F,l]=i.useState(null),[g,o]=i.useState(null),[u,b]=i.useState({}),{data:A=[],isLoading:M,error:E,refetch:y}=L({...d,search:n.trim()||void 0}),h=R(),H=async s=>{try{await h.mutateAsync(s.id),o(null)}catch(c){console.error("Failed to delete command:",c)}},p=A.filter(s=>!(d.scope&&d.scope!=="all"&&s.scope!==d.scope||d.namespace&&s.namespace!==d.namespace));return M?e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-32 w-32 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("commands.loading")})]})}):E?e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(v,{className:"h-16 w-16 text-red-500 mx-auto mb-4"}),e.jsx("p",{className:"text-red-600 text-lg mb-2",children:t("commands.error.loadFailed")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:t("commands.error.cannotLoadCommands")}),e.jsx("button",{onClick:()=>y(),className:"bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg transition-colors",children:t("commands.error.retry")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:`${a?"mb-4":"flex items-center justify-between mb-6"}`,children:e.jsxs("div",{children:[e.jsx("h1",{className:`${a?"text-2xl":"text-3xl"} font-bold text-gray-900 dark:text-white`,children:t("commands.title")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${a?"mt-1":"mt-2"}`,children:t("commands.subtitle")})]})}),e.jsxs("div",{className:`${a?"space-y-3":"flex items-center space-x-4"}`,children:[e.jsxs("div",{className:`${a?"":"flex-1"} relative`,children:[e.jsx(I,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 ${a?"w-4 h-4":"w-5 h-5"}`}),e.jsx("input",{type:"text",placeholder:t("commands.searchPlaceholder"),value:n,onChange:s=>T(s.target.value),className:`pl-10 pr-4 ${a?"py-2":"py-3"} w-full border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white ${a?"text-sm":""}`})]}),e.jsxs("button",{onClick:()=>{l(null),r(!0)},className:`${a?"w-full py-2.5 px-4":"flex items-center space-x-2 px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors ${a?"text-sm":""}`,children:[e.jsx(J,{className:`${a?"w-4 h-4":"w-5 h-5"}`}),e.jsx("span",{children:t("commands.createButton")})]})]})]}),p.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:`${a?"text-4xl":"text-6xl"} mb-4`,children:"⚡"}),e.jsx("h3",{className:`${a?"text-lg":"text-xl"} font-medium text-gray-900 dark:text-white mb-2`,children:t(n?"commands.empty.noMatchingCommands":"commands.empty.noCommands")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:t(n?"commands.empty.adjustSearch":"commands.empty.createFirst")}),!n&&e.jsx("button",{onClick:()=>{l(null),r(!0)},className:`${a?"w-full py-3 px-4":"px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:t("commands.createButton")})]}):e.jsx(e.Fragment,{children:a?e.jsx("div",{className:"space-y-4",children:p.map((s,c)=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-4",children:[e.jsx("div",{className:"flex items-start justify-between mb-3",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`${a?"text-lg":"text-xl"} mr-3`,children:"⚡"}),e.jsxs("div",{children:[e.jsxs("div",{className:`${a?"text-sm":"text-base"} font-medium text-gray-900 dark:text-white`,children:[s.namespace?`/${s.namespace}:${s.name}`:`/${s.name}`,s.argumentHint&&e.jsx("code",{className:"ml-2 bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300 px-1.5 py-0.5 rounded text-xs",children:s.argumentHint})]}),s.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:s.description})]})]})}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("div",{className:"flex items-center text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2",children:[t("commands.table.model"),":"]}),s.model?e.jsxs("div",{className:"flex items-center text-gray-900 dark:text-white",children:[e.jsx(k,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-sm",children:s.model})]}):e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("commands.table.inheritSettings")})]}),e.jsx("div",{className:"mb-3",children:e.jsxs("div",{className:"flex items-start text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2 mt-1",children:[t("commands.table.tools"),":"]}),e.jsx("div",{className:"flex-1",children:e.jsx(f,{tools:s.allowedTools||[],id:s.id,expandedTools:u,setExpandedTools:b,isMobile:!0,emptyMessage:t("commands.table.inheritSettings")})})]})}),e.jsxs("div",{className:"flex items-center text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2",children:[t("commands.table.createdAt"),":"]}),e.jsxs("div",{className:"flex items-center text-gray-500 dark:text-gray-400",children:[e.jsx(w,{className:"w-4 h-4 mr-1"}),e.jsx("span",{children:N(s.createdAt||s.updatedAt)})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end space-x-2 pt-3 border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("button",{onClick:()=>{l(s),r(!0)},className:"inline-flex items-center px-3 py-2 text-sm font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",children:[e.jsx(C,{className:"w-3 h-3 mr-1"}),t("commands.actions.edit")]}),e.jsx("button",{onClick:()=>o(s),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:t("commands.actions.deleteCommand"),children:e.jsx($,{className:"w-4 h-4"})})]})]},s.id+"-"+c))}):e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:e.jsxs(P,{children:[e.jsx(D,{children:e.jsxs(j,{children:[e.jsx(m,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.command")}),e.jsx(m,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.model")}),e.jsx(m,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.tools")}),e.jsx(m,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.createdAt")}),e.jsx(m,{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.actions")})]})}),e.jsx(B,{children:p.map((s,c)=>e.jsxs(j,{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx(x,{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"text-xl mr-3",children:"⚡"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:s.namespace?`/${s.namespace}:${s.name}`:`/${s.name}`}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${s.source==="plugin"?"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300":"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300"}`,children:s.source==="plugin"?t("commands.source.plugin"):t("commands.source.local")}),s.argumentHint&&e.jsx("code",{className:"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300 px-1.5 py-0.5 rounded text-xs",children:s.argumentHint})]}),s.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate max-w-xs mt-1",children:s.description})]})]})}),e.jsx(x,{className:"px-6 py-4",children:s.model?e.jsxs("div",{className:"text-sm text-gray-900 dark:text-white",children:[e.jsx(k,{className:"w-3 h-3 inline mr-1"}),s.model]}):e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("commands.table.inheritSettings")})}),e.jsx(x,{className:"px-6 py-4",children:e.jsx(f,{tools:s.allowedTools||[],id:s.id,expandedTools:u,setExpandedTools:b,isMobile:!1,emptyMessage:t("commands.table.inheritSettings")})}),e.jsx(x,{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(w,{className:"w-4 h-4"}),e.jsx("span",{children:N(s.createdAt||s.updatedAt)})]})}),e.jsx(x,{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.source==="plugin"?e.jsxs("button",{onClick:()=>{l(s),r(!0)},className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",title:t("commands.actions.view"),children:[e.jsx(K,{className:"w-3 h-3 mr-1"}),t("commands.actions.view")]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{l(s),r(!0)},className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",title:t("commands.actions.editCommand"),children:[e.jsx(C,{className:"w-3 h-3 mr-1"}),t("commands.actions.edit")]}),e.jsx("button",{onClick:()=>o(s),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:t("commands.actions.deleteCommand"),children:e.jsx($,{className:"w-4 h-4"})})]})})})]},s.id+"-"+c))})]})})}),S&&e.jsx(q,{command:F,onClose:()=>{r(!1),l(null)},onSuccess:()=>{r(!1),l(null),y()}}),g&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-lg shadow-xl ${a?"w-full max-w-sm":"max-w-md w-full mx-4"} p-6`,children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-4",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(v,{className:`${a?"h-5 w-5":"h-6 w-6"} text-red-600`})}),e.jsx("div",{className:"flex-1",children:e.jsx("h3",{className:`${a?"text-base":"text-lg"} font-medium text-gray-900 dark:text-white`,children:t("commands.delete.title")})})]}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${a?"mb-4 text-sm":"mb-6"}`,children:t("commands.delete.confirmMessage",{name:g.name})}),e.jsxs("div",{className:`${a?"grid grid-cols-2 gap-2":"flex justify-end space-x-3"}`,children:[e.jsx("button",{onClick:()=>o(null),className:`${a?"px-3 py-2.5 text-sm":"px-4 py-2"} text-gray-700 dark:text-gray-300 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 rounded-lg transition-colors`,children:t("commands.delete.cancel")}),e.jsx("button",{onClick:()=>H(g),disabled:h.isPending,className:`${a?"px-3 py-2.5 text-sm":"px-4 py-2"} bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors disabled:opacity-50`,children:h.isPending?t("commands.delete.deleting"):t("commands.delete.delete")})]})]})})]})};export{re as CommandsPage};
1
+ import{j as e}from"./data-structures-C0h9Oap1.js";import{r as i}from"./monaco-editor-DHKm5-VF.js";import{T as P,a as D,b as j,c as m,d as B,e as x}from"./table-CHBLEjZn.js";import{u as L,a as R}from"./useCommands-vX47i_1v.js";import{C as q}from"./CommandForm-hHwraC0y.js";import{f as N}from"./dateFormat-CXa8VnEC.js";import{b as z}from"./index-C8oBHB0h.js";import{T as f}from"./ToolsList-I7JqIU7m.js";import{u as G}from"./tools-CUwQTL-8.js";import{j as v,g as I,t as J,o as k,m as w,D as C,v as $,E as K}from"./ui-components-icUM6BEH.js";import"./syntax-highlighting-CnREyncB.js";import"./agents-B3InAIfY.js";import"./UnifiedToolSelector-Cw1xKmPZ.js";const re=()=>{const{t}=G("pages"),{isMobile:a}=z(),[d]=i.useState({scope:"user"}),[n,T]=i.useState(""),[S,r]=i.useState(!1),[F,l]=i.useState(null),[g,o]=i.useState(null),[u,b]=i.useState({}),{data:A=[],isLoading:M,error:E,refetch:y}=L({...d,search:n.trim()||void 0}),h=R(),H=async s=>{try{await h.mutateAsync(s.id),o(null)}catch(c){console.error("Failed to delete command:",c)}},p=A.filter(s=>!(d.scope&&d.scope!=="all"&&s.scope!==d.scope||d.namespace&&s.namespace!==d.namespace));return M?e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-32 w-32 border-b-2 border-blue-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:t("commands.loading")})]})}):E?e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(v,{className:"h-16 w-16 text-red-500 mx-auto mb-4"}),e.jsx("p",{className:"text-red-600 text-lg mb-2",children:t("commands.error.loadFailed")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:t("commands.error.cannotLoadCommands")}),e.jsx("button",{onClick:()=>y(),className:"bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg transition-colors",children:t("commands.error.retry")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:`${a?"mb-4":"flex items-center justify-between mb-6"}`,children:e.jsxs("div",{children:[e.jsx("h1",{className:`${a?"text-2xl":"text-3xl"} font-bold text-gray-900 dark:text-white`,children:t("commands.title")}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${a?"mt-1":"mt-2"}`,children:t("commands.subtitle")})]})}),e.jsxs("div",{className:`${a?"space-y-3":"flex items-center space-x-4"}`,children:[e.jsxs("div",{className:`${a?"":"flex-1"} relative`,children:[e.jsx(I,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 ${a?"w-4 h-4":"w-5 h-5"}`}),e.jsx("input",{type:"text",placeholder:t("commands.searchPlaceholder"),value:n,onChange:s=>T(s.target.value),className:`pl-10 pr-4 ${a?"py-2":"py-3"} w-full border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white ${a?"text-sm":""}`})]}),e.jsxs("button",{onClick:()=>{l(null),r(!0)},className:`${a?"w-full py-2.5 px-4":"flex items-center space-x-2 px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors ${a?"text-sm":""}`,children:[e.jsx(J,{className:`${a?"w-4 h-4":"w-5 h-5"}`}),e.jsx("span",{children:t("commands.createButton")})]})]})]}),p.length===0?e.jsxs("div",{className:"text-center py-16 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:`${a?"text-4xl":"text-6xl"} mb-4`,children:"⚡"}),e.jsx("h3",{className:`${a?"text-lg":"text-xl"} font-medium text-gray-900 dark:text-white mb-2`,children:t(n?"commands.empty.noMatchingCommands":"commands.empty.noCommands")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:t(n?"commands.empty.adjustSearch":"commands.empty.createFirst")}),!n&&e.jsx("button",{onClick:()=>{l(null),r(!0)},className:`${a?"w-full py-3 px-4":"px-6 py-3"} bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors`,children:t("commands.createButton")})]}):e.jsx(e.Fragment,{children:a?e.jsx("div",{className:"space-y-4",children:p.map((s,c)=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-4",children:[e.jsx("div",{className:"flex items-start justify-between mb-3",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`${a?"text-lg":"text-xl"} mr-3`,children:"⚡"}),e.jsxs("div",{children:[e.jsxs("div",{className:`${a?"text-sm":"text-base"} font-medium text-gray-900 dark:text-white`,children:[s.namespace?`/${s.namespace}:${s.name}`:`/${s.name}`,s.argumentHint&&e.jsx("code",{className:"ml-2 bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300 px-1.5 py-0.5 rounded text-xs",children:s.argumentHint})]}),s.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:s.description})]})]})}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("div",{className:"flex items-center text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2",children:[t("commands.table.model"),":"]}),s.model?e.jsxs("div",{className:"flex items-center text-gray-900 dark:text-white",children:[e.jsx(k,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-sm",children:s.model})]}):e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("commands.table.inheritSettings")})]}),e.jsx("div",{className:"mb-3",children:e.jsxs("div",{className:"flex items-start text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2 mt-1",children:[t("commands.table.tools"),":"]}),e.jsx("div",{className:"flex-1",children:e.jsx(f,{tools:s.allowedTools||[],id:s.id,expandedTools:u,setExpandedTools:b,isMobile:!0,emptyMessage:t("commands.table.inheritSettings")})})]})}),e.jsxs("div",{className:"flex items-center text-sm",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 mr-2",children:[t("commands.table.createdAt"),":"]}),e.jsxs("div",{className:"flex items-center text-gray-500 dark:text-gray-400",children:[e.jsx(w,{className:"w-4 h-4 mr-1"}),e.jsx("span",{children:N(s.createdAt||s.updatedAt)})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end space-x-2 pt-3 border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("button",{onClick:()=>{l(s),r(!0)},className:"inline-flex items-center px-3 py-2 text-sm font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",children:[e.jsx(C,{className:"w-3 h-3 mr-1"}),t("commands.actions.edit")]}),e.jsx("button",{onClick:()=>o(s),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:t("commands.actions.deleteCommand"),children:e.jsx($,{className:"w-4 h-4"})})]})]},s.id+"-"+c))}):e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:e.jsxs(P,{children:[e.jsx(D,{children:e.jsxs(j,{children:[e.jsx(m,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.command")}),e.jsx(m,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.model")}),e.jsx(m,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.tools")}),e.jsx(m,{className:"px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.createdAt")}),e.jsx(m,{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:t("commands.table.actions")})]})}),e.jsx(B,{children:p.map((s,c)=>e.jsxs(j,{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[e.jsx(x,{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"text-xl mr-3",children:"⚡"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:s.namespace?`/${s.namespace}:${s.name}`:`/${s.name}`}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${s.source==="plugin"?"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300":"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300"}`,children:s.source==="plugin"?t("commands.source.plugin"):t("commands.source.local")}),s.argumentHint&&e.jsx("code",{className:"bg-gray-100 dark:bg-gray-700 text-gray-800 dark:text-gray-300 px-1.5 py-0.5 rounded text-xs",children:s.argumentHint})]}),s.description&&e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 truncate max-w-xs mt-1",children:s.description})]})]})}),e.jsx(x,{className:"px-6 py-4",children:s.model?e.jsxs("div",{className:"text-sm text-gray-900 dark:text-white",children:[e.jsx(k,{className:"w-3 h-3 inline mr-1"}),s.model]}):e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("commands.table.inheritSettings")})}),e.jsx(x,{className:"px-6 py-4",children:e.jsx(f,{tools:s.allowedTools||[],id:s.id,expandedTools:u,setExpandedTools:b,isMobile:!1,emptyMessage:t("commands.table.inheritSettings")})}),e.jsx(x,{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(w,{className:"w-4 h-4"}),e.jsx("span",{children:N(s.createdAt||s.updatedAt)})]})}),e.jsx(x,{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:e.jsx("div",{className:"flex items-center justify-end space-x-2",children:s.source==="plugin"?e.jsxs("button",{onClick:()=>{l(s),r(!0)},className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",title:t("commands.actions.view"),children:[e.jsx(K,{className:"w-3 h-3 mr-1"}),t("commands.actions.view")]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{l(s),r(!0)},className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 dark:bg-blue-900/50 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/70 transition-colors",title:t("commands.actions.editCommand"),children:[e.jsx(C,{className:"w-3 h-3 mr-1"}),t("commands.actions.edit")]}),e.jsx("button",{onClick:()=>o(s),className:"p-2 text-red-600 hover:bg-red-50 dark:hover:bg-red-900/50 rounded-lg transition-colors",title:t("commands.actions.deleteCommand"),children:e.jsx($,{className:"w-4 h-4"})})]})})})]},s.id+"-"+c))})]})})}),S&&e.jsx(q,{command:F,onClose:()=>{r(!1),l(null)},onSuccess:()=>{r(!1),l(null),y()}}),g&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-lg shadow-xl ${a?"w-full max-w-sm":"max-w-md w-full mx-4"} p-6`,children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-4",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx(v,{className:`${a?"h-5 w-5":"h-6 w-6"} text-red-600`})}),e.jsx("div",{className:"flex-1",children:e.jsx("h3",{className:`${a?"text-base":"text-lg"} font-medium text-gray-900 dark:text-white`,children:t("commands.delete.title")})})]}),e.jsx("p",{className:`text-gray-600 dark:text-gray-400 ${a?"mb-4 text-sm":"mb-6"}`,children:t("commands.delete.confirmMessage",{name:g.name})}),e.jsxs("div",{className:`${a?"grid grid-cols-2 gap-2":"flex justify-end space-x-3"}`,children:[e.jsx("button",{onClick:()=>o(null),className:`${a?"px-3 py-2.5 text-sm":"px-4 py-2"} text-gray-700 dark:text-gray-300 bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 rounded-lg transition-colors`,children:t("commands.delete.cancel")}),e.jsx("button",{onClick:()=>H(g),disabled:h.isPending,className:`${a?"px-3 py-2.5 text-sm":"px-4 py-2"} bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors disabled:opacity-50`,children:h.isPending?t("commands.delete.deleting"):t("commands.delete.delete")})]})]})})]})};export{re as CommandsPage};
@@ -0,0 +1 @@
1
+ import{j as e}from"./data-structures-C0h9Oap1.js";import{r as d}from"./monaco-editor-DHKm5-VF.js";import{u as Q}from"./useProjects-DR0CTJHB.js";import{u as B,a as O}from"./useAgents-HXlzUYSz.js";import{u as U,c as Z,a as X}from"./useSessions-CanqFxtL.js";import{u as G}from"./agents-B3InAIfY.js";import{u as J,s as m,a as S}from"./index-C8oBHB0h.js";import{u as W}from"./tools-CUwQTL-8.js";import{o as Y,e as _,M as ee,Z as ae,f as se,p as te,q as re,r as le,s as h,L as g,t as de,k as oe,u as ne,v as ie,j as ce,X as ue}from"./ui-components-icUM6BEH.js";import"./syntax-highlighting-CnREyncB.js";const ve=()=>{const{t:s}=W("pages"),b=J(),A=G(),{data:I,isLoading:$}=Q(),{data:q}=B(!0),{data:F,refetch:p}=U(),M=O(),[i,f]=d.useState(""),[r,u]=d.useState(null),[j,x]=d.useState(!1),[y,k]=d.useState(!1),[w,v]=d.useState(!1),[N,C]=d.useState(null),o=I?.projects||[],n=q?.agents||[],c=F?.sessions||[];d.useEffect(()=>{o.length>0&&!r&&u(o[0])},[o,r]);const V=a=>{if(!a)return n[0];if(a.defaultAgent){const t=n.find(l=>l.id===a.defaultAgent);if(t)return t}return n[0]},T=async()=>{const a=n.find(t=>t.id==="claude-code")||n[0];if(a){k(!0);try{const t="default-workspace",l=await M.mutateAsync({agentId:a.id,projectName:t});await A.invalidateQueries({queryKey:["projects"]}),u(l.project),m(s("dashboard.projectCreated.title",{defaultValue:"项目创建成功"}),s("dashboard.projectCreated.message",{defaultValue:"已经为您创建项目:{{name}},你现在可以开始与 Agent 工作了。",name:t}))}catch(t){console.error("Failed to create default project:",t)}finally{k(!1)}}},P=()=>{const a=V(r);if(!i.trim()||!r||!a)return;const t=encodeURIComponent(i);b(`/chat/${a.id}?project=${encodeURIComponent(r.path)}&message=${t}`)},D=async a=>{C(a);try{await X(a),await p(),m(s("dashboard.sessions.closed",{defaultValue:"会话已关闭"}),s("dashboard.sessions.closedMessage",{defaultValue:"会话已成功关闭"}))}catch(t){console.error("Failed to close session:",t),S(s("dashboard.sessions.closeFailed",{defaultValue:"关闭失败"}),t instanceof Error?t.message:s("dashboard.sessions.closeError",{defaultValue:"无法关闭会话"}))}finally{C(null)}},E=async()=>{if(c.length!==0){v(!0);try{const a=await Z();await p(),m(s("dashboard.sessions.allCleared",{defaultValue:"全部清除"}),s("dashboard.sessions.allClearedMessage",{defaultValue:"已清除 {{count}} 个会话",count:a.clearedCount}))}catch(a){console.error("Failed to clear all sessions:",a),S(s("dashboard.sessions.clearFailed",{defaultValue:"清除失败"}),a instanceof Error?a.message:s("dashboard.sessions.clearError",{defaultValue:"无法清除会话"}))}finally{v(!1)}}},L=[{icon:Y,label:s("dashboard.templates.codeReview",{defaultValue:"代码审查"}),prompt:"帮我审查一下这个项目的代码质量"},{icon:_,label:s("dashboard.templates.writeDoc",{defaultValue:"写文档"}),prompt:"帮我写一份项目文档"},{icon:ee,label:s("dashboard.templates.askQuestion",{defaultValue:"问问题"}),prompt:""},{icon:ae,label:s("dashboard.templates.quickTask",{defaultValue:"快速任务"}),prompt:""}],H=[{icon:se,label:s("dashboard.quickLinks.projects",{defaultValue:"项目管理"}),path:"/projects",color:"text-blue-500 bg-blue-50 dark:bg-blue-900/30"},{icon:te,label:s("dashboard.quickLinks.modelSettings",{defaultValue:"模型供应商"}),path:"/settings/suppliers",color:"text-purple-500 bg-purple-50 dark:bg-purple-900/30"},{icon:re,label:s("dashboard.quickLinks.scheduledTasks",{defaultValue:"定时任务"}),path:"/scheduled-tasks",color:"text-green-500 bg-green-50 dark:bg-green-900/30"},{icon:le,label:s("dashboard.quickLinks.customAgents",{defaultValue:"自定义 Agent"}),path:"/agents",color:"text-orange-500 bg-orange-50 dark:bg-orange-900/30"}],R=a=>{a&&f(a)},z=!$&&o.length===0,K=a=>{const t=Math.floor(a/1e3);if(t<60)return`${t}s`;const l=Math.floor(t/60);return l<60?`${l}m`:`${Math.floor(l/60)}h`};return e.jsx("div",{className:"h-full flex flex-col bg-gray-50 dark:bg-gray-900 overflow-auto",children:e.jsxs("div",{className:"flex-1 flex flex-col items-center px-6 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-bold text-gray-900 dark:text-white mb-4",children:s("dashboard.welcome.title",{defaultValue:"有什么可以帮你的?"})}),e.jsx("p",{className:"text-lg text-gray-500 dark:text-gray-400 max-w-xl mx-auto",children:s("dashboard.welcome.subtitle",{defaultValue:"选择一个项目,开始与 AI 协作完成任务"})})]}),e.jsxs("div",{className:"w-full max-w-2xl",children:[z&&e.jsxs("div",{className:"mb-6 p-6 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-2xl text-center",children:[e.jsx(h,{className:"w-12 h-12 text-amber-500 mx-auto mb-3"}),e.jsx("h3",{className:"text-lg font-medium text-amber-800 dark:text-amber-200 mb-2",children:s("dashboard.noProjectsHint.title",{defaultValue:"还没有项目"})}),e.jsx("p",{className:"text-sm text-amber-600 dark:text-amber-300 mb-4",children:s("dashboard.noProjectsHint.description",{defaultValue:"创建一个项目来开始与 AI 协作"})}),e.jsx("button",{onClick:T,disabled:y||n.length===0,className:"inline-flex items-center gap-2 px-5 py-2.5 bg-amber-600 hover:bg-amber-700 disabled:bg-amber-400 text-white rounded-xl font-medium transition-colors",children:y?e.jsxs(e.Fragment,{children:[e.jsx(g,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:s("dashboard.noProjectsHint.creating",{defaultValue:"创建中..."})})]}):e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"w-4 h-4"}),e.jsx("span",{children:s("dashboard.noProjectsHint.createButton",{defaultValue:"一键创建默认项目"})})]})})]}),e.jsx("div",{className:"mb-4 flex justify-center",children:e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>x(!j),className:"flex items-center gap-2 px-4 py-2 bg-white dark:bg-gray-800 rounded-full border border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600 transition-colors shadow-sm",children:[e.jsx(h,{className:"w-4 h-4 text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:r?.name||s("dashboard.selectProject",{defaultValue:"选择项目"})}),e.jsx(oe,{className:"w-4 h-4 text-gray-400"})]}),j&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>x(!1)}),e.jsxs("div",{className:"absolute left-1/2 -translate-x-1/2 top-full mt-2 w-72 bg-white dark:bg-gray-800 rounded-xl shadow-xl border border-gray-200 dark:border-gray-700 z-20 max-h-80 overflow-y-auto",children:[o.map(a=>e.jsxs("button",{onClick:()=>{u(a),x(!1)},className:`w-full px-4 py-3 text-left hover:bg-gray-50 dark:hover:bg-gray-700/50 flex items-center gap-3 first:rounded-t-xl last:rounded-b-xl ${r?.id===a.id?"bg-blue-50 dark:bg-blue-900/20":""}`,children:[e.jsx(h,{className:`w-4 h-4 flex-shrink-0 ${r?.id===a.id?"text-blue-500":"text-gray-400"}`}),e.jsx("span",{className:`text-sm truncate ${r?.id===a.id?"text-blue-600 dark:text-blue-400 font-medium":"text-gray-700 dark:text-gray-300"}`,children:a.name})]},a.id)),o.length===0&&e.jsx("div",{className:"px-4 py-6 text-center text-gray-500 text-sm",children:s("dashboard.noProjects",{defaultValue:"暂无项目"})})]})]})]})}),e.jsx("div",{className:"relative",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-2xl shadow-lg border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsx("textarea",{value:i,onChange:a=>f(a.target.value),onKeyDown:a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),P())},placeholder:s("dashboard.inputPlaceholder",{defaultValue:"描述你想要完成的任务..."}),className:"w-full px-5 py-4 text-base bg-transparent border-none outline-none resize-none text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-gray-500",rows:3}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-100 dark:border-gray-700",children:[e.jsx("span",{className:"text-sm text-gray-400",children:s("dashboard.footer.hint",{defaultValue:"Enter 发送,Shift + Enter 换行"})}),e.jsxs("button",{onClick:P,disabled:!i.trim()||!r||!V(r),className:"flex items-center gap-2 px-5 py-2 bg-blue-600 hover:bg-blue-700 disabled:bg-gray-300 dark:disabled:bg-gray-600 text-white rounded-xl font-medium transition-colors disabled:cursor-not-allowed",children:[e.jsx("span",{children:s("dashboard.startChat",{defaultValue:"开始对话"})}),e.jsx(ne,{className:"w-4 h-4"})]})]})]})}),e.jsx("div",{className:"mt-6 flex flex-wrap justify-center gap-3",children:L.map((a,t)=>e.jsxs("button",{onClick:()=>R(a.prompt),className:"flex items-center gap-2 px-4 py-2 bg-white dark:bg-gray-800 rounded-full border border-gray-200 dark:border-gray-700 hover:border-blue-300 dark:hover:border-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/20 text-sm text-gray-600 dark:text-gray-400 transition-colors",children:[e.jsx(a.icon,{className:"w-4 h-4"}),e.jsx("span",{children:a.label})]},t))}),e.jsxs("div",{className:"mt-10",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 mb-4 text-center",children:s("dashboard.quickLinks.title",{defaultValue:"快捷入口"})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:H.map((a,t)=>e.jsxs("button",{onClick:()=>b(a.path),className:"flex flex-col items-center gap-2 p-4 bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600 hover:shadow-md transition-all group",children:[e.jsx("div",{className:`p-2.5 rounded-lg ${a.color}`,children:e.jsx(a.icon,{className:"w-5 h-5"})}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-white transition-colors",children:a.label})]},t))})]}),c.length>0&&e.jsxs("div",{className:"mt-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:[s("dashboard.sessions.title",{defaultValue:"活跃会话"})," (",c.length,")"]}),e.jsxs("button",{onClick:E,disabled:w,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors disabled:opacity-50",children:[w?e.jsx(g,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(ie,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:s("dashboard.sessions.clearAll",{defaultValue:"清除全部"})})]})]}),e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 divide-y divide-gray-100 dark:divide-gray-700 max-h-64 overflow-y-auto",children:c.map(a=>{const t=a.projectPath?a.projectPath.split("/").pop()||a.projectPath:"-",l=a.sessionTitle||`${s("dashboard.sessions.session",{defaultValue:"会话"})} ${a.sessionId.slice(0,8)}`;return e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 hover:bg-gray-50 dark:hover:bg-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${a.status==="confirmed"?"bg-green-500":"bg-amber-500"}`}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 truncate font-medium",children:l}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-400 mt-0.5",children:[e.jsx("span",{className:"truncate max-w-[120px]",title:t,children:t}),e.jsx("span",{children:"•"}),e.jsx("span",{children:a.agentId}),a.modelId&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{className:"bg-gray-100 dark:bg-gray-700 px-1.5 py-0.5 rounded",children:a.modelId.replace("claude-","").replace("-20241022","")})]}),e.jsx("span",{children:"•"}),e.jsx("span",{children:K(a.idleTimeMs)}),a.heartbeatTimedOut&&e.jsx("span",{className:"text-amber-500 flex items-center gap-1",children:e.jsx(ce,{className:"w-3 h-3"})})]})]})]}),e.jsx("button",{onClick:()=>D(a.sessionId),disabled:N===a.sessionId,className:"p-1.5 text-gray-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors disabled:opacity-50",title:s("dashboard.sessions.close",{defaultValue:"关闭会话"}),children:N===a.sessionId?e.jsx(g,{className:"w-4 h-4 animate-spin"}):e.jsx(ue,{className:"w-4 h-4"})})]},a.sessionId)})})]})]})]})})};export{ve as DashboardPage};
@@ -1,6 +1,6 @@
1
- import{j as e}from"./data-structures-C0h9Oap1.js";import{r as o}from"./monaco-editor-DHKm5-VF.js";import{a as K,A as W}from"./agents-ChrA1R0y.js";import{b as de}from"./index-Bn3v3S9-.js";import{u as ee}from"./tools-IcPNZlPj.js";import{X as V,aa as te,ab as Y,g as _,ac as q,l as G,ad as ae,ae as Z,a4 as ce,t as xe,s as ge,k as he,af as ye,ag as me,V as be,J as ue,E as pe,Y as re,e as fe,ah as we}from"./ui-components-D1St49qC.js";const ve=({filePath:F,onClose:h})=>{const{t}=ee("components"),[p,A]=o.useState([]),[N,U]=o.useState(!0),[M,s]=o.useState(null),[d,T]=o.useState(""),[i,b]=o.useState(1),[P,$]=o.useState(!1),[v]=o.useState(50),[O,H]=o.useState(""),z=c=>{const n=c.split(`
2
- `).filter(x=>x.trim()),g=[];for(const x of n){const u=[];let S="",D=!1;for(let L=0;L<x.length;L++){const R=x[L];R==='"'?D&&x[L+1]==='"'?(S+='"',L++):D=!D:R===","&&!D?(u.push(S.trim()),S=""):S+=R}u.push(S.trim()),g.push(u)}return g};o.useEffect(()=>{(async()=>{try{U(!0),s(null);const n=F.split(/[/\\]/).pop()||"unknown.csv";H(n);const g=await K(`${W}/files/read?path=${encodeURIComponent(F)}`);if(!g.ok)throw new Error(t("csvPreview.errors.loadFailed"));const x=await g.json(),u=z(x.content);A(u)}catch(n){console.error("Failed to load CSV:",n),s(n instanceof Error?n.message:t("csvPreview.errors.unknownError"))}finally{U(!1)}})()},[F,t]);const j=o.useMemo(()=>{if(!d)return p;const c=d.toLowerCase();return p.filter(n=>n.some(g=>g.toLowerCase().includes(c)))},[p,d]),y=Math.ceil(j.length/v),f=(i-1)*v,C=f+v,m=j.slice(f,C);o.useEffect(()=>{b(1)},[d]),o.useEffect(()=>{const c=n=>{n.key==="Escape"?h():n.key==="ArrowLeft"&&i>1?b(i-1):n.key==="ArrowRight"&&i<y?b(i+1):n.ctrlKey&&n.key==="f"&&(n.preventDefault(),document.getElementById("csv-search")?.focus())};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[h,i,y]);const k=()=>{const c=p.map(x=>x.map(u=>u.includes(",")||u.includes('"')||u.includes(`
1
+ import{j as e}from"./data-structures-C0h9Oap1.js";import{r as o}from"./monaco-editor-DHKm5-VF.js";import{a as K,A as W}from"./agents-B3InAIfY.js";import{a as de}from"./index-C8oBHB0h.js";import{u as ee}from"./tools-CUwQTL-8.js";import{X as T,aj as te,ak as X,g as Y,al as _,l as q,am as ae,an as Z,a3 as ce,z as xe,y as ge,k as he,ao as ye,ap as me,a8 as be,Y as ue,E as pe,s as re,e as fe,aq as we}from"./ui-components-icUM6BEH.js";const ve=({filePath:F,onClose:h})=>{const{t}=ee("components"),[p,A]=o.useState([]),[N,U]=o.useState(!0),[M,s]=o.useState(null),[d,V]=o.useState(""),[i,b]=o.useState(1),[P,$]=o.useState(!1),[v]=o.useState(50),[z,H]=o.useState(""),O=c=>{const n=c.split(`
2
+ `).filter(x=>x.trim()),g=[];for(const x of n){const u=[];let S="",D=!1;for(let L=0;L<x.length;L++){const R=x[L];R==='"'?D&&x[L+1]==='"'?(S+='"',L++):D=!D:R===","&&!D?(u.push(S.trim()),S=""):S+=R}u.push(S.trim()),g.push(u)}return g};o.useEffect(()=>{(async()=>{try{U(!0),s(null);const n=F.split(/[/\\]/).pop()||"unknown.csv";H(n);const g=await K(`${W}/files/read?path=${encodeURIComponent(F)}`);if(!g.ok)throw new Error(t("csvPreview.errors.loadFailed"));const x=await g.json(),u=O(x.content);A(u)}catch(n){console.error("Failed to load CSV:",n),s(n instanceof Error?n.message:t("csvPreview.errors.unknownError"))}finally{U(!1)}})()},[F,t]);const j=o.useMemo(()=>{if(!d)return p;const c=d.toLowerCase();return p.filter(n=>n.some(g=>g.toLowerCase().includes(c)))},[p,d]),y=Math.ceil(j.length/v),f=(i-1)*v,C=f+v,m=j.slice(f,C);o.useEffect(()=>{b(1)},[d]),o.useEffect(()=>{const c=n=>{n.key==="Escape"?h():n.key==="ArrowLeft"&&i>1?b(i-1):n.key==="ArrowRight"&&i<y?b(i+1):n.ctrlKey&&n.key==="f"&&(n.preventDefault(),document.getElementById("csv-search")?.focus())};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[h,i,y]);const k=()=>{const c=p.map(x=>x.map(u=>u.includes(",")||u.includes('"')||u.includes(`
3
3
  `)?`"${u.replace(/"/g,'""')}"`:u).join(",")).join(`
4
- `),n=new Blob([c],{type:"text/csv;charset=utf-8;"}),g=document.createElement("a");g.href=URL.createObjectURL(n),g.download=O,g.click(),URL.revokeObjectURL(g.href)};if(N)return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 flex items-center space-x-4",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:t("csvPreview.loading")})]})});if(M)return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:t("csvPreview.errors.title")}),e.jsx("button",{onClick:h,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsx("p",{className:"text-red-600 dark:text-red-400",children:M}),e.jsx("button",{onClick:h,className:"mt-4 px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors",children:t("csvPreview.actions.close")})]})});const J=P?"fixed inset-4 bg-white dark:bg-gray-900 flex flex-col z-50":"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50";return e.jsx("div",{className:J,children:P?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:O}),e.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("csvPreview.info.rowCount",{count:j.length}),d&&` (${t("csvPreview.info.filtered")})`]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>$(!1),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("csvPreview.actions.minimize"),children:e.jsx(te,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:k,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("csvPreview.actions.download"),children:e.jsx(Y,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:h,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("csvPreview.actions.close"),children:e.jsx(V,{className:"w-5 h-5 text-gray-600 dark:text-gray-400"})})]})]}),e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"relative",children:[e.jsx(_,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{id:"csv-search",type:"text",value:d,onChange:c=>T(c.target.value),placeholder:t("csvPreview.search.placeholder"),className:"w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-800 dark:text-white dark:placeholder-gray-400"})]})}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:m.length>0?e.jsx("div",{className:"min-w-full",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800 sticky top-0",children:e.jsx("tr",{children:m[0]?.map((c,n)=>e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider border-b border-gray-200 dark:border-gray-700",children:c||t("csvPreview.table.untitled")},n))})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700",children:m.slice(1).map((c,n)=>e.jsx("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-800",children:c.map((g,x)=>e.jsx("td",{className:"px-4 py-2 text-sm text-gray-900 dark:text-white whitespace-nowrap border-b border-gray-100 dark:border-gray-800",children:g||"-"},x))},n))})]})}):e.jsx("div",{className:"text-center py-12 text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:t("csvPreview.empty.noData")})})}),y>1&&e.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("csvPreview.pagination.showing",{start:f+1,end:Math.min(C,j.length),total:j.length})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>b(Math.max(1,i-1)),disabled:i===1,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t("csvPreview.pagination.previous"),children:e.jsx(q,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400 px-3",children:[i," / ",y]}),e.jsx("button",{onClick:()=>b(Math.min(y,i+1)),disabled:i===y,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t("csvPreview.pagination.next"),children:e.jsx(G,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})})]})]})]}):e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-6xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:O}),e.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("csvPreview.info.rowCount",{count:j.length}),d&&` (${t("csvPreview.info.filtered")})`]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>$(!0),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:t("csvPreview.actions.maximize"),children:e.jsx(ae,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:k,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:t("csvPreview.actions.download"),children:e.jsx(Y,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:h,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:t("csvPreview.actions.close"),children:e.jsx(V,{className:"w-5 h-5 text-gray-600 dark:text-gray-400"})})]})]}),e.jsx("div",{className:"p-4 border-b border-gray-100 dark:border-gray-700",children:e.jsxs("div",{className:"relative",children:[e.jsx(_,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{id:"csv-search",type:"text",value:d,onChange:c=>T(c.target.value),placeholder:t("csvPreview.search.placeholder"),className:"w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white dark:placeholder-gray-400"})]})}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:m.length>0?e.jsx("div",{className:"min-w-full",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800 sticky top-0",children:e.jsx("tr",{children:m[0]?.map((c,n)=>e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider border-b border-gray-200 dark:border-gray-700",children:c||t("csvPreview.table.untitled")},n))})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700",children:m.slice(1).map((c,n)=>e.jsx("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-800",children:c.map((g,x)=>e.jsx("td",{className:"px-4 py-2 text-sm text-gray-900 dark:text-white whitespace-nowrap border-b border-gray-100 dark:border-gray-800",children:g||"-"},x))},n))})]})}):e.jsx("div",{className:"text-center py-12 text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:t("csvPreview.empty.noData")})})}),y>1&&e.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("csvPreview.pagination.showing",{start:f+1,end:Math.min(C,j.length),total:j.length})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>b(Math.max(1,i-1)),disabled:i===1,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t("csvPreview.pagination.previous"),children:e.jsx(q,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400 px-3",children:[i," / ",y]}),e.jsx("button",{onClick:()=>b(Math.min(y,i+1)),disabled:i===y,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t("csvPreview.pagination.next"),children:e.jsx(G,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})})]})]}),e.jsx("div",{className:"px-4 py-2 text-xs text-gray-500 dark:text-gray-400 text-center border-t border-gray-100 dark:border-gray-700",children:t("csvPreview.instructions")})]})})},je=({filePath:F,onClose:h})=>{const{t}=ee("components"),[p,A]=o.useState([]),[N,U]=o.useState(!0),[M,s]=o.useState(null),[d,T]=o.useState(""),[i,b]=o.useState(1),[P,$]=o.useState(!1),[v]=o.useState(20),[O,H]=o.useState(""),[z,j]=o.useState(new Set),[y,f]=o.useState(null),C=a=>{const l=a.split(`
5
- `),w=[];for(let B=0;B<l.length;B++){const I=l[B].trim();if(I)try{const Q=JSON.parse(I);w.push({lineNumber:B+1,data:Q,raw:I})}catch{w.push({lineNumber:B+1,data:null,error:t("jsonlPreview.errors.parseError"),raw:I})}}return w};o.useEffect(()=>{(async()=>{try{U(!0),s(null);const l=F.split(/[/\\]/).pop()||"unknown.jsonl";H(l);const w=await K(`${W}/files/read?path=${encodeURIComponent(F)}`);if(!w.ok)throw new Error(t("jsonlPreview.errors.loadFailed"));const B=await w.json(),I=C(B.content);A(I)}catch(l){console.error("Failed to load JSONL:",l),s(l instanceof Error?l.message:t("jsonlPreview.errors.unknownError"))}finally{U(!1)}})()},[F,t]);const m=o.useMemo(()=>{if(!d)return p;const a=d.toLowerCase();return p.filter(l=>l.raw.toLowerCase().includes(a))},[p,d]),k=Math.ceil(m.length/v),J=(i-1)*v,c=J+v,n=m.slice(J,c);o.useEffect(()=>{b(1)},[d]),o.useEffect(()=>{const a=l=>{l.key==="Escape"?h():l.key==="ArrowLeft"&&i>1?b(i-1):l.key==="ArrowRight"&&i<k?b(i+1):l.ctrlKey&&l.key==="f"&&(l.preventDefault(),document.getElementById("jsonl-search")?.focus())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[h,i,k]);const g=a=>{const l=new Set(z);l.has(a)?l.delete(a):l.add(a),j(l)},x=async(a,l)=>{try{await navigator.clipboard.writeText(a),f(l),setTimeout(()=>f(null),2e3)}catch(w){console.error("Failed to copy:",w)}},u=()=>{const a=new Blob([p.map(w=>w.raw).join(`
6
- `)],{type:"application/jsonl;charset=utf-8;"}),l=document.createElement("a");l.href=URL.createObjectURL(a),l.download=O,l.click(),URL.revokeObjectURL(l.href)},S=(a,l=50)=>a.length<=l?a:a.substring(0,l)+"...";if(N)return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 flex items-center space-x-4",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-amber-600"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:t("jsonlPreview.loading")})]})});if(M)return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:t("jsonlPreview.errors.title")}),e.jsx("button",{onClick:h,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsx("p",{className:"text-red-600 dark:text-red-400",children:M}),e.jsx("button",{onClick:h,className:"mt-4 px-4 py-2 bg-amber-600 text-white rounded hover:bg-amber-700 transition-colors",children:t("jsonlPreview.actions.close")})]})});const D=p.filter(a=>a.error).length,L=P?"fixed inset-4 bg-white dark:bg-gray-900 flex flex-col z-50 rounded-lg shadow-2xl":"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",R=()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Z,{className:"w-5 h-5 text-amber-500"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:O})]}),e.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("jsonlPreview.info.recordCount",{count:m.length}),D>0&&e.jsxs("span",{className:"ml-2 text-red-500",children:["(",t("jsonlPreview.info.errorCount",{count:D}),")"]}),d&&` (${t("jsonlPreview.info.filtered")})`]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[!P&&e.jsx("button",{onClick:()=>$(!0),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("jsonlPreview.actions.maximize"),children:e.jsx(ae,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),P&&e.jsx("button",{onClick:()=>$(!1),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("jsonlPreview.actions.minimize"),children:e.jsx(te,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:u,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("jsonlPreview.actions.download"),children:e.jsx(Y,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:h,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("jsonlPreview.actions.close"),children:e.jsx(V,{className:"w-5 h-5 text-gray-600 dark:text-gray-400"})})]})]}),e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"relative",children:[e.jsx(_,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{id:"jsonl-search",type:"text",value:d,onChange:a=>T(a.target.value),placeholder:t("jsonlPreview.search.placeholder"),className:"w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-amber-500 focus:border-transparent dark:bg-gray-800 dark:text-white dark:placeholder-gray-400"})]})}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:n.length>0?e.jsx("div",{className:"space-y-2",children:n.map(a=>e.jsxs("div",{className:`border rounded-lg overflow-hidden ${a.error?"border-red-300 dark:border-red-700 bg-red-50 dark:bg-red-900/20":"border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800"}`,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",onClick:()=>g(a.lineNumber),children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsxs("span",{className:"text-xs font-mono text-gray-400 dark:text-gray-500 w-12",children:["#",a.lineNumber]}),a.error?e.jsx("span",{className:"text-sm text-red-600 dark:text-red-400",children:a.error}):e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300 font-mono",children:S(a.raw,80)})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:l=>{l.stopPropagation(),x(a.raw,a.lineNumber)},className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-600 rounded transition-colors",title:t("jsonlPreview.actions.copy"),children:y===a.lineNumber?e.jsx(ce,{className:"w-4 h-4 text-green-500"}):e.jsx(xe,{className:"w-4 h-4 text-gray-400"})}),z.has(a.lineNumber)?e.jsx(ge,{className:"w-4 h-4 text-gray-400"}):e.jsx(he,{className:"w-4 h-4 text-gray-400"})]})]}),z.has(a.lineNumber)&&a.data&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4 bg-gray-50 dark:bg-gray-900/50",children:e.jsx("pre",{className:"text-sm text-gray-800 dark:text-gray-200 font-mono whitespace-pre-wrap overflow-x-auto",children:JSON.stringify(a.data,null,2)})}),z.has(a.lineNumber)&&a.error&&e.jsx("div",{className:"border-t border-red-200 dark:border-red-700 p-4 bg-red-50 dark:bg-red-900/30",children:e.jsx("pre",{className:"text-sm text-red-700 dark:text-red-300 font-mono whitespace-pre-wrap overflow-x-auto break-all",children:a.raw})})]},a.lineNumber))}):e.jsxs("div",{className:"text-center py-12 text-gray-500 dark:text-gray-400",children:[e.jsx(Z,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:t("jsonlPreview.empty.noData")})]})}),k>1&&e.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("jsonlPreview.pagination.showing",{start:J+1,end:Math.min(c,m.length),total:m.length})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>b(Math.max(1,i-1)),disabled:i===1,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t("jsonlPreview.pagination.previous"),children:e.jsx(q,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400 px-3",children:[i," / ",k]}),e.jsx("button",{onClick:()=>b(Math.min(k,i+1)),disabled:i===k,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t("jsonlPreview.pagination.next"),children:e.jsx(G,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})})]})]}),e.jsx("div",{className:"px-4 py-2 text-xs text-gray-500 dark:text-gray-400 text-center border-t border-gray-100 dark:border-gray-700",children:t("jsonlPreview.instructions")})]});return e.jsx("div",{className:L,children:P?R():e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-4xl max-h-[90vh] flex flex-col shadow-2xl",children:R()})})},Ee=({title:F,initialPath:h,allowFiles:t=!0,allowDirectories:p=!0,allowNewDirectory:A=!1,restrictToProject:N=!1,onSelect:U,onClose:M})=>{const{t:s}=ee("components"),[d,T]=o.useState(null),[i,b]=o.useState(!0),[P,$]=o.useState(null),[v,O]=o.useState(!1),[H,z]=o.useState(null),[j,y]=o.useState(!1),[f,C]=o.useState(""),[m,k]=o.useState(!1),[J,c]=o.useState(null),[n,g]=o.useState(null),x=async r=>{b(!0),$(null);try{const E=new URLSearchParams;r&&E.set("path",r);const le=`${W}/files/browse?${E.toString()}`,X=await K(le);if(!X.ok){const ie=await X.json();throw new Error(ie.error||s("fileBrowser.errors.browseFailed"))}const ne=await X.json();T(ne)}catch(E){console.error("Failed to fetch directory:",E),$(E instanceof Error?E.message:s("fileBrowser.errors.loadFailed"))}finally{b(!1)}};o.useEffect(()=>{x(h)},[h]);const u=r=>{r.isDirectory?x(r.path):z(r.path)},S=r=>{(r.isDirectory&&p||!r.isDirectory&&t)&&U(r.path,r.isDirectory)},D=()=>{d?.parentPath&&(!N||d.parentPath.startsWith(h||""))&&x(d.parentPath)},L=()=>{N?h&&x(h):x()},R=async()=>{if(!(!f.trim()||!d?.currentPath)){k(!0);try{const r=await K(`${W}/files/create-directory`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parentPath:d.currentPath,directoryName:f.trim()})});if(!r.ok){const E=await r.json();throw new Error(E.error||s("fileBrowser.errors.createFailed"))}await x(d.currentPath),y(!1),C("")}catch(r){console.error("Failed to create directory:",r),de(s("fileBrowser.errors.createFailed"),r instanceof Error?r.message:void 0)}finally{k(!1)}}},a=d?.items.filter(r=>v||!r.isHidden)||[],l=r=>r===null?"":r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:r<1024*1024*1024?`${(r/1024/1024).toFixed(1)} MB`:`${(r/1024/1024/1024).toFixed(1)} GB`,w=r=>r.toLowerCase().endsWith(".csv"),B=r=>r.toLowerCase().endsWith(".jsonl"),I=r=>{c(r)},Q=()=>{c(null)},se=r=>{g(r)},oe=()=>{g(null)};return e.jsxs("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg w-full max-w-4xl max-h-[80vh] mx-4 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:F||s("fileBrowser.title")}),e.jsx("button",{onClick:M,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex items-center space-x-2 p-4 border-b border-gray-100 dark:border-gray-700",children:[e.jsx("button",{onClick:L,className:`p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors ${N?"opacity-50 cursor-not-allowed":""}`,title:s(N?"fileBrowser.toolbar.restrictedToProject":"fileBrowser.toolbar.homeDirectory"),disabled:N,children:e.jsx(ye,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:D,disabled:!d?.parentPath||N&&d?.currentPath===h,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:s("fileBrowser.toolbar.parentDirectory"),children:e.jsx(me,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("div",{className:"flex-1 px-3 py-2 bg-gray-50 dark:bg-gray-900 rounded text-sm text-gray-600 dark:text-gray-400 font-mono",children:d?.currentPath||s("fileBrowser.toolbar.loadingPath")}),A&&e.jsx("button",{onClick:()=>y(!0),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:s("fileBrowser.toolbar.newDirectory"),children:e.jsx(be,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:()=>O(!v),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:s(v?"fileBrowser.toolbar.hideHidden":"fileBrowser.toolbar.showHidden"),children:v?e.jsx(ue,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"}):e.jsx(pe,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:i?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):P?e.jsx("div",{className:"flex items-center justify-center h-64 text-red-600",children:e.jsxs("p",{children:[s("fileBrowser.errors.error"),": ",P]})}):e.jsxs("div",{className:"flex-1 overflow-y-auto",onWheel:r=>{r.stopPropagation()},children:[e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-800 sticky top-0",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("fileBrowser.table.name")}),e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("fileBrowser.table.size")}),e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("fileBrowser.table.modified")}),e.jsx("th",{className:"px-4 py-2 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("fileBrowser.table.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:a.map((r,E)=>e.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors ${H===r.path?"bg-blue-50 dark:bg-blue-900/30":""}`,children:[e.jsx("td",{className:"px-4 py-3 flex items-center space-x-2",children:e.jsxs("div",{className:"flex items-center space-x-2 flex-1 min-w-0",children:[r.isDirectory?e.jsx(re,{className:"w-4 h-4 text-blue-600 flex-shrink-0"}):w(r.name)?e.jsx(fe,{className:"w-4 h-4 text-green-600 flex-shrink-0"}):B(r.name)?e.jsx(Z,{className:"w-4 h-4 text-amber-500 flex-shrink-0"}):e.jsx(we,{className:"w-4 h-4 text-gray-600 dark:text-gray-400 flex-shrink-0"}),e.jsx("button",{onClick:()=>{!r.isDirectory&&t?S(r):u(r)},className:`text-left truncate hover:text-blue-600 dark:hover:text-blue-400 ${r.isHidden?"text-gray-400":"text-gray-900 dark:text-white"} ${!r.isDirectory&&t?"cursor-pointer font-medium":""}`,children:r.name}),r.isDirectory&&e.jsx(G,{className:"w-3 h-3 text-gray-400 dark:text-gray-500 flex-shrink-0"})]})}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400",children:l(r.size)}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400",children:new Date(r.modified).toLocaleDateString("zh-CN")}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[!r.isDirectory&&w(r.name)&&e.jsx("button",{onClick:()=>I(r.path),className:"px-3 py-1 text-sm bg-green-600 text-white rounded hover:bg-green-700 transition-colors",title:s("fileBrowser.actions.previewCSV"),children:s("fileBrowser.actions.preview")}),!r.isDirectory&&B(r.name)&&e.jsx("button",{onClick:()=>se(r.path),className:"px-3 py-1 text-sm bg-amber-500 text-white rounded hover:bg-amber-600 transition-colors",title:s("fileBrowser.actions.previewJSONL"),children:s("fileBrowser.actions.preview")}),e.jsx("button",{onClick:()=>S(r),disabled:r.isDirectory&&!p||!r.isDirectory&&!t,className:"px-3 py-1 text-sm bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:s("fileBrowser.actions.select")})]})})]},E))})]}),a.length===0&&e.jsxs("div",{className:"text-center py-12 text-gray-500 dark:text-gray-400",children:[e.jsx(re,{className:"w-12 h-12 text-gray-300 dark:text-gray-600 mx-auto mb-3"}),e.jsx("p",{children:s("fileBrowser.emptyDirectory")})]})]})}),e.jsxs("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:a.length>0&&e.jsx("span",{children:s("fileBrowser.footer.itemsCount",{count:a.length})})}),e.jsx("button",{onClick:M,className:"px-4 py-2 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 transition-colors",children:s("fileBrowser.actions.cancel")})]})]}),j&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[60]",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg p-6 w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:s("fileBrowser.dialog.newFolder")}),e.jsx("button",{onClick:()=>{y(!1),C("")},className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:s("fileBrowser.dialog.createAt")}),e.jsx("div",{className:"p-2 bg-gray-100 dark:bg-gray-700 rounded text-sm font-mono text-gray-800 dark:text-gray-200 break-all",children:d?.currentPath})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{htmlFor:"folderName",className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("fileBrowser.dialog.folderName")}),e.jsx("input",{id:"folderName",type:"text",value:f,onChange:r=>C(r.target.value),placeholder:s("fileBrowser.dialog.folderNamePlaceholder"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white dark:placeholder-gray-400",autoFocus:!0,onKeyPress:r=>{r.key==="Enter"&&f.trim()&&!m&&R()}})]}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>{y(!1),C("")},disabled:m,className:"px-4 py-2 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 transition-colors disabled:opacity-50",children:s("fileBrowser.actions.cancel")}),e.jsx("button",{onClick:R,disabled:!f.trim()||m,className:"px-4 py-2 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:s(m?"fileBrowser.actions.creating":"fileBrowser.actions.createFolder")})]})]})}),J&&e.jsx(ve,{filePath:J,onClose:Q}),n&&e.jsx(je,{filePath:n,onClose:oe})]})};export{Ee as F};
4
+ `),n=new Blob([c],{type:"text/csv;charset=utf-8;"}),g=document.createElement("a");g.href=URL.createObjectURL(n),g.download=z,g.click(),URL.revokeObjectURL(g.href)};if(N)return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 flex items-center space-x-4",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:t("csvPreview.loading")})]})});if(M)return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:t("csvPreview.errors.title")}),e.jsx("button",{onClick:h,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(T,{className:"w-5 h-5"})})]}),e.jsx("p",{className:"text-red-600 dark:text-red-400",children:M}),e.jsx("button",{onClick:h,className:"mt-4 px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors",children:t("csvPreview.actions.close")})]})});const I=P?"fixed inset-4 bg-white dark:bg-gray-900 flex flex-col z-50":"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50";return e.jsx("div",{className:I,children:P?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:z}),e.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("csvPreview.info.rowCount",{count:j.length}),d&&` (${t("csvPreview.info.filtered")})`]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>$(!1),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("csvPreview.actions.minimize"),children:e.jsx(te,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:k,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("csvPreview.actions.download"),children:e.jsx(X,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:h,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("csvPreview.actions.close"),children:e.jsx(T,{className:"w-5 h-5 text-gray-600 dark:text-gray-400"})})]})]}),e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"relative",children:[e.jsx(Y,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{id:"csv-search",type:"text",value:d,onChange:c=>V(c.target.value),placeholder:t("csvPreview.search.placeholder"),className:"w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-800 dark:text-white dark:placeholder-gray-400"})]})}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:m.length>0?e.jsx("div",{className:"min-w-full",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800 sticky top-0",children:e.jsx("tr",{children:m[0]?.map((c,n)=>e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider border-b border-gray-200 dark:border-gray-700",children:c||t("csvPreview.table.untitled")},n))})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700",children:m.slice(1).map((c,n)=>e.jsx("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-800",children:c.map((g,x)=>e.jsx("td",{className:"px-4 py-2 text-sm text-gray-900 dark:text-white whitespace-nowrap border-b border-gray-100 dark:border-gray-800",children:g||"-"},x))},n))})]})}):e.jsx("div",{className:"text-center py-12 text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:t("csvPreview.empty.noData")})})}),y>1&&e.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("csvPreview.pagination.showing",{start:f+1,end:Math.min(C,j.length),total:j.length})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>b(Math.max(1,i-1)),disabled:i===1,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t("csvPreview.pagination.previous"),children:e.jsx(_,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400 px-3",children:[i," / ",y]}),e.jsx("button",{onClick:()=>b(Math.min(y,i+1)),disabled:i===y,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t("csvPreview.pagination.next"),children:e.jsx(q,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})})]})]})]}):e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-6xl max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:z}),e.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("csvPreview.info.rowCount",{count:j.length}),d&&` (${t("csvPreview.info.filtered")})`]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>$(!0),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:t("csvPreview.actions.maximize"),children:e.jsx(ae,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:k,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:t("csvPreview.actions.download"),children:e.jsx(X,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:h,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:t("csvPreview.actions.close"),children:e.jsx(T,{className:"w-5 h-5 text-gray-600 dark:text-gray-400"})})]})]}),e.jsx("div",{className:"p-4 border-b border-gray-100 dark:border-gray-700",children:e.jsxs("div",{className:"relative",children:[e.jsx(Y,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{id:"csv-search",type:"text",value:d,onChange:c=>V(c.target.value),placeholder:t("csvPreview.search.placeholder"),className:"w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white dark:placeholder-gray-400"})]})}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:m.length>0?e.jsx("div",{className:"min-w-full",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800 sticky top-0",children:e.jsx("tr",{children:m[0]?.map((c,n)=>e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider border-b border-gray-200 dark:border-gray-700",children:c||t("csvPreview.table.untitled")},n))})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700",children:m.slice(1).map((c,n)=>e.jsx("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-800",children:c.map((g,x)=>e.jsx("td",{className:"px-4 py-2 text-sm text-gray-900 dark:text-white whitespace-nowrap border-b border-gray-100 dark:border-gray-800",children:g||"-"},x))},n))})]})}):e.jsx("div",{className:"text-center py-12 text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:t("csvPreview.empty.noData")})})}),y>1&&e.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("csvPreview.pagination.showing",{start:f+1,end:Math.min(C,j.length),total:j.length})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>b(Math.max(1,i-1)),disabled:i===1,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t("csvPreview.pagination.previous"),children:e.jsx(_,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400 px-3",children:[i," / ",y]}),e.jsx("button",{onClick:()=>b(Math.min(y,i+1)),disabled:i===y,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t("csvPreview.pagination.next"),children:e.jsx(q,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})})]})]}),e.jsx("div",{className:"px-4 py-2 text-xs text-gray-500 dark:text-gray-400 text-center border-t border-gray-100 dark:border-gray-700",children:t("csvPreview.instructions")})]})})},je=({filePath:F,onClose:h})=>{const{t}=ee("components"),[p,A]=o.useState([]),[N,U]=o.useState(!0),[M,s]=o.useState(null),[d,V]=o.useState(""),[i,b]=o.useState(1),[P,$]=o.useState(!1),[v]=o.useState(20),[z,H]=o.useState(""),[O,j]=o.useState(new Set),[y,f]=o.useState(null),C=a=>{const l=a.split(`
5
+ `),w=[];for(let B=0;B<l.length;B++){const J=l[B].trim();if(J)try{const G=JSON.parse(J);w.push({lineNumber:B+1,data:G,raw:J})}catch{w.push({lineNumber:B+1,data:null,error:t("jsonlPreview.errors.parseError"),raw:J})}}return w};o.useEffect(()=>{(async()=>{try{U(!0),s(null);const l=F.split(/[/\\]/).pop()||"unknown.jsonl";H(l);const w=await K(`${W}/files/read?path=${encodeURIComponent(F)}`);if(!w.ok)throw new Error(t("jsonlPreview.errors.loadFailed"));const B=await w.json(),J=C(B.content);A(J)}catch(l){console.error("Failed to load JSONL:",l),s(l instanceof Error?l.message:t("jsonlPreview.errors.unknownError"))}finally{U(!1)}})()},[F,t]);const m=o.useMemo(()=>{if(!d)return p;const a=d.toLowerCase();return p.filter(l=>l.raw.toLowerCase().includes(a))},[p,d]),k=Math.ceil(m.length/v),I=(i-1)*v,c=I+v,n=m.slice(I,c);o.useEffect(()=>{b(1)},[d]),o.useEffect(()=>{const a=l=>{l.key==="Escape"?h():l.key==="ArrowLeft"&&i>1?b(i-1):l.key==="ArrowRight"&&i<k?b(i+1):l.ctrlKey&&l.key==="f"&&(l.preventDefault(),document.getElementById("jsonl-search")?.focus())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[h,i,k]);const g=a=>{const l=new Set(O);l.has(a)?l.delete(a):l.add(a),j(l)},x=async(a,l)=>{try{await navigator.clipboard.writeText(a),f(l),setTimeout(()=>f(null),2e3)}catch(w){console.error("Failed to copy:",w)}},u=()=>{const a=new Blob([p.map(w=>w.raw).join(`
6
+ `)],{type:"application/jsonl;charset=utf-8;"}),l=document.createElement("a");l.href=URL.createObjectURL(a),l.download=z,l.click(),URL.revokeObjectURL(l.href)},S=(a,l=50)=>a.length<=l?a:a.substring(0,l)+"...";if(N)return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 flex items-center space-x-4",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-amber-600"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:t("jsonlPreview.loading")})]})});if(M)return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:t("jsonlPreview.errors.title")}),e.jsx("button",{onClick:h,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(T,{className:"w-5 h-5"})})]}),e.jsx("p",{className:"text-red-600 dark:text-red-400",children:M}),e.jsx("button",{onClick:h,className:"mt-4 px-4 py-2 bg-amber-600 text-white rounded hover:bg-amber-700 transition-colors",children:t("jsonlPreview.actions.close")})]})});const D=p.filter(a=>a.error).length,L=P?"fixed inset-4 bg-white dark:bg-gray-900 flex flex-col z-50 rounded-lg shadow-2xl":"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",R=()=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Z,{className:"w-5 h-5 text-amber-500"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:z})]}),e.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t("jsonlPreview.info.recordCount",{count:m.length}),D>0&&e.jsxs("span",{className:"ml-2 text-red-500",children:["(",t("jsonlPreview.info.errorCount",{count:D}),")"]}),d&&` (${t("jsonlPreview.info.filtered")})`]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[!P&&e.jsx("button",{onClick:()=>$(!0),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("jsonlPreview.actions.maximize"),children:e.jsx(ae,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),P&&e.jsx("button",{onClick:()=>$(!1),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("jsonlPreview.actions.minimize"),children:e.jsx(te,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:u,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("jsonlPreview.actions.download"),children:e.jsx(X,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:h,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors",title:t("jsonlPreview.actions.close"),children:e.jsx(T,{className:"w-5 h-5 text-gray-600 dark:text-gray-400"})})]})]}),e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"relative",children:[e.jsx(Y,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{id:"jsonl-search",type:"text",value:d,onChange:a=>V(a.target.value),placeholder:t("jsonlPreview.search.placeholder"),className:"w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-amber-500 focus:border-transparent dark:bg-gray-800 dark:text-white dark:placeholder-gray-400"})]})}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:n.length>0?e.jsx("div",{className:"space-y-2",children:n.map(a=>e.jsxs("div",{className:`border rounded-lg overflow-hidden ${a.error?"border-red-300 dark:border-red-700 bg-red-50 dark:bg-red-900/20":"border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800"}`,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700/50",onClick:()=>g(a.lineNumber),children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsxs("span",{className:"text-xs font-mono text-gray-400 dark:text-gray-500 w-12",children:["#",a.lineNumber]}),a.error?e.jsx("span",{className:"text-sm text-red-600 dark:text-red-400",children:a.error}):e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300 font-mono",children:S(a.raw,80)})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:l=>{l.stopPropagation(),x(a.raw,a.lineNumber)},className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-600 rounded transition-colors",title:t("jsonlPreview.actions.copy"),children:y===a.lineNumber?e.jsx(ce,{className:"w-4 h-4 text-green-500"}):e.jsx(xe,{className:"w-4 h-4 text-gray-400"})}),O.has(a.lineNumber)?e.jsx(ge,{className:"w-4 h-4 text-gray-400"}):e.jsx(he,{className:"w-4 h-4 text-gray-400"})]})]}),O.has(a.lineNumber)&&a.data&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4 bg-gray-50 dark:bg-gray-900/50",children:e.jsx("pre",{className:"text-sm text-gray-800 dark:text-gray-200 font-mono whitespace-pre-wrap overflow-x-auto",children:JSON.stringify(a.data,null,2)})}),O.has(a.lineNumber)&&a.error&&e.jsx("div",{className:"border-t border-red-200 dark:border-red-700 p-4 bg-red-50 dark:bg-red-900/30",children:e.jsx("pre",{className:"text-sm text-red-700 dark:text-red-300 font-mono whitespace-pre-wrap overflow-x-auto break-all",children:a.raw})})]},a.lineNumber))}):e.jsxs("div",{className:"text-center py-12 text-gray-500 dark:text-gray-400",children:[e.jsx(Z,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:t("jsonlPreview.empty.noData")})]})}),k>1&&e.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:t("jsonlPreview.pagination.showing",{start:I+1,end:Math.min(c,m.length),total:m.length})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("button",{onClick:()=>b(Math.max(1,i-1)),disabled:i===1,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t("jsonlPreview.pagination.previous"),children:e.jsx(_,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400 px-3",children:[i," / ",k]}),e.jsx("button",{onClick:()=>b(Math.min(k,i+1)),disabled:i===k,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:t("jsonlPreview.pagination.next"),children:e.jsx(q,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})})]})]}),e.jsx("div",{className:"px-4 py-2 text-xs text-gray-500 dark:text-gray-400 text-center border-t border-gray-100 dark:border-gray-700",children:t("jsonlPreview.instructions")})]});return e.jsx("div",{className:L,children:P?R():e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-4xl max-h-[90vh] flex flex-col shadow-2xl",children:R()})})},Ee=({title:F,initialPath:h,allowFiles:t=!0,allowDirectories:p=!0,allowNewDirectory:A=!1,restrictToProject:N=!1,onSelect:U,onClose:M})=>{const{t:s}=ee("components"),[d,V]=o.useState(null),[i,b]=o.useState(!0),[P,$]=o.useState(null),[v,z]=o.useState(!1),[H,O]=o.useState(null),[j,y]=o.useState(!1),[f,C]=o.useState(""),[m,k]=o.useState(!1),[I,c]=o.useState(null),[n,g]=o.useState(null),x=async r=>{b(!0),$(null);try{const E=new URLSearchParams;r&&E.set("path",r);const le=`${W}/files/browse?${E.toString()}`,Q=await K(le);if(!Q.ok){const ie=await Q.json();throw new Error(ie.error||s("fileBrowser.errors.browseFailed"))}const ne=await Q.json();V(ne)}catch(E){console.error("Failed to fetch directory:",E),$(E instanceof Error?E.message:s("fileBrowser.errors.loadFailed"))}finally{b(!1)}};o.useEffect(()=>{x(h)},[h]);const u=r=>{r.isDirectory?x(r.path):O(r.path)},S=r=>{(r.isDirectory&&p||!r.isDirectory&&t)&&U(r.path,r.isDirectory)},D=()=>{d?.parentPath&&(!N||d.parentPath.startsWith(h||""))&&x(d.parentPath)},L=()=>{N?h&&x(h):x()},R=async()=>{if(!(!f.trim()||!d?.currentPath)){k(!0);try{const r=await K(`${W}/files/create-directory`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parentPath:d.currentPath,directoryName:f.trim()})});if(!r.ok){const E=await r.json();throw new Error(E.error||s("fileBrowser.errors.createFailed"))}await x(d.currentPath),y(!1),C("")}catch(r){console.error("Failed to create directory:",r),de(s("fileBrowser.errors.createFailed"),r instanceof Error?r.message:void 0)}finally{k(!1)}}},a=d?.items.filter(r=>v||!r.isHidden)||[],l=r=>r===null?"":r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:r<1024*1024*1024?`${(r/1024/1024).toFixed(1)} MB`:`${(r/1024/1024/1024).toFixed(1)} GB`,w=r=>r.toLowerCase().endsWith(".csv"),B=r=>r.toLowerCase().endsWith(".jsonl"),J=r=>{c(r)},G=()=>{c(null)},se=r=>{g(r)},oe=()=>{g(null)};return e.jsxs("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg w-full max-w-4xl max-h-[80vh] mx-4 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:F||s("fileBrowser.title")}),e.jsx("button",{onClick:M,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(T,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex items-center space-x-2 p-4 border-b border-gray-100 dark:border-gray-700",children:[e.jsx("button",{onClick:L,className:`p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors ${N?"opacity-50 cursor-not-allowed":""}`,title:s(N?"fileBrowser.toolbar.restrictedToProject":"fileBrowser.toolbar.homeDirectory"),disabled:N,children:e.jsx(ye,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:D,disabled:!d?.parentPath||N&&d?.currentPath===h,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:s("fileBrowser.toolbar.parentDirectory"),children:e.jsx(me,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("div",{className:"flex-1 px-3 py-2 bg-gray-50 dark:bg-gray-900 rounded text-sm text-gray-600 dark:text-gray-400 font-mono",children:d?.currentPath||s("fileBrowser.toolbar.loadingPath")}),A&&e.jsx("button",{onClick:()=>y(!0),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:s("fileBrowser.toolbar.newDirectory"),children:e.jsx(be,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{onClick:()=>z(!v),className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:s(v?"fileBrowser.toolbar.hideHidden":"fileBrowser.toolbar.showHidden"),children:v?e.jsx(ue,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"}):e.jsx(pe,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:i?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):P?e.jsx("div",{className:"flex items-center justify-center h-64 text-red-600",children:e.jsxs("p",{children:[s("fileBrowser.errors.error"),": ",P]})}):e.jsxs("div",{className:"flex-1 overflow-y-auto",onWheel:r=>{r.stopPropagation()},children:[e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-100 dark:bg-gray-800 sticky top-0",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("fileBrowser.table.name")}),e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("fileBrowser.table.size")}),e.jsx("th",{className:"px-4 py-2 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("fileBrowser.table.modified")}),e.jsx("th",{className:"px-4 py-2 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:s("fileBrowser.table.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:a.map((r,E)=>e.jsxs("tr",{className:`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors ${H===r.path?"bg-blue-50 dark:bg-blue-900/30":""}`,children:[e.jsx("td",{className:"px-4 py-3 flex items-center space-x-2",children:e.jsxs("div",{className:"flex items-center space-x-2 flex-1 min-w-0",children:[r.isDirectory?e.jsx(re,{className:"w-4 h-4 text-blue-600 flex-shrink-0"}):w(r.name)?e.jsx(fe,{className:"w-4 h-4 text-green-600 flex-shrink-0"}):B(r.name)?e.jsx(Z,{className:"w-4 h-4 text-amber-500 flex-shrink-0"}):e.jsx(we,{className:"w-4 h-4 text-gray-600 dark:text-gray-400 flex-shrink-0"}),e.jsx("button",{onClick:()=>{!r.isDirectory&&t?S(r):u(r)},className:`text-left truncate hover:text-blue-600 dark:hover:text-blue-400 ${r.isHidden?"text-gray-400":"text-gray-900 dark:text-white"} ${!r.isDirectory&&t?"cursor-pointer font-medium":""}`,children:r.name}),r.isDirectory&&e.jsx(q,{className:"w-3 h-3 text-gray-400 dark:text-gray-500 flex-shrink-0"})]})}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400",children:l(r.size)}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-500 dark:text-gray-400",children:new Date(r.modified).toLocaleDateString("zh-CN")}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[!r.isDirectory&&w(r.name)&&e.jsx("button",{onClick:()=>J(r.path),className:"px-3 py-1 text-sm bg-green-600 text-white rounded hover:bg-green-700 transition-colors",title:s("fileBrowser.actions.previewCSV"),children:s("fileBrowser.actions.preview")}),!r.isDirectory&&B(r.name)&&e.jsx("button",{onClick:()=>se(r.path),className:"px-3 py-1 text-sm bg-amber-500 text-white rounded hover:bg-amber-600 transition-colors",title:s("fileBrowser.actions.previewJSONL"),children:s("fileBrowser.actions.preview")}),e.jsx("button",{onClick:()=>S(r),disabled:r.isDirectory&&!p||!r.isDirectory&&!t,className:"px-3 py-1 text-sm bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:s("fileBrowser.actions.select")})]})})]},E))})]}),a.length===0&&e.jsxs("div",{className:"text-center py-12 text-gray-500 dark:text-gray-400",children:[e.jsx(re,{className:"w-12 h-12 text-gray-300 dark:text-gray-600 mx-auto mb-3"}),e.jsx("p",{children:s("fileBrowser.emptyDirectory")})]})]})}),e.jsxs("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 flex justify-between items-center",children:[e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:a.length>0&&e.jsx("span",{children:s("fileBrowser.footer.itemsCount",{count:a.length})})}),e.jsx("button",{onClick:M,className:"px-4 py-2 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 transition-colors",children:s("fileBrowser.actions.cancel")})]})]}),j&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[60]",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg p-6 w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:s("fileBrowser.dialog.newFolder")}),e.jsx("button",{onClick:()=>{y(!1),C("")},className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(T,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:s("fileBrowser.dialog.createAt")}),e.jsx("div",{className:"p-2 bg-gray-100 dark:bg-gray-700 rounded text-sm font-mono text-gray-800 dark:text-gray-200 break-all",children:d?.currentPath})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{htmlFor:"folderName",className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("fileBrowser.dialog.folderName")}),e.jsx("input",{id:"folderName",type:"text",value:f,onChange:r=>C(r.target.value),placeholder:s("fileBrowser.dialog.folderNamePlaceholder"),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent dark:bg-gray-700 dark:text-white dark:placeholder-gray-400",autoFocus:!0,onKeyPress:r=>{r.key==="Enter"&&f.trim()&&!m&&R()}})]}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>{y(!1),C("")},disabled:m,className:"px-4 py-2 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 transition-colors disabled:opacity-50",children:s("fileBrowser.actions.cancel")}),e.jsx("button",{onClick:R,disabled:!f.trim()||m,className:"px-4 py-2 text-sm bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:s(m?"fileBrowser.actions.creating":"fileBrowser.actions.createFolder")})]})]})}),I&&e.jsx(ve,{filePath:I,onClose:G}),n&&e.jsx(je,{filePath:n,onClose:oe})]})};export{Ee as F};
@@ -1 +1 @@
1
- import{c as Se}from"./syntax-highlighting-CnREyncB.js";import{j as e,T as He}from"./data-structures-C0h9Oap1.js";import{r as c,W as Fe}from"./monaco-editor-DHKm5-VF.js";import{as as u,E as Te,J as Me,R as De,at as Ae,L as T,au as Re,X as ne,av as Ie,k as Oe,l as Ve}from"./ui-components-D1St49qC.js";import{b as me,a as _,A as M}from"./agents-ChrA1R0y.js";import{u as ue}from"./tools-IcPNZlPj.js";function $e(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M0 32l34.9 395.8L192 480l157.1-52.2L384 32H0zm313.1 80l-4.8 47.3L193 208.6l-.3.1h111.5l-12.8 146.6-98.2 28.7-98.8-29.2-6.4-73.9h48.9l3.2 38.3 52.6 13.3 54.7-15.4 3.7-61.6-166.3-.5v-.1l-.2.1-3.6-46.3L193.1 162l6.5-2.7H76.7L70.9 112h242.2z"},child:[]}]})(r)}function ie(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M0 32l34.9 395.8L191.5 480l157.6-52.2L384 32H0zm308.2 127.9H124.4l4.1 49.4h175.6l-13.6 148.4-97.9 27v.3h-1.1l-98.7-27.3-6-75.8h47.7L138 320l53.5 14.5 53.7-14.5 6-62.2H84.3L71.5 112.2h241.1l-4.4 47.7z"},child:[]}]})(r)}function Be(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M277.74 312.9c9.8-6.7 23.4-12.5 23.4-12.5s-38.7 7-77.2 10.2c-47.1 3.9-97.7 4.7-123.1 1.3-60.1-8 33-30.1 33-30.1s-36.1-2.4-80.6 19c-52.5 25.4 130 37 224.5 12.1zm-85.4-32.1c-19-42.7-83.1-80.2 0-145.8C296 53.2 242.84 0 242.84 0c21.5 84.5-75.6 110.1-110.7 162.6-23.9 35.9 11.7 74.4 60.2 118.2zm114.6-176.2c.1 0-175.2 43.8-91.5 140.2 24.7 28.4-6.5 54-6.5 54s62.7-32.4 33.9-72.9c-26.9-37.8-47.5-56.6 64.1-121.3zm-6.1 270.5a12.19 12.19 0 0 1-2 2.6c128.3-33.7 81.1-118.9 19.8-97.3a17.33 17.33 0 0 0-8.2 6.3 70.45 70.45 0 0 1 11-3c31-6.5 75.5 41.5-20.6 91.4zM348 437.4s14.5 11.9-15.9 21.2c-57.9 17.5-240.8 22.8-291.6.7-18.3-7.9 16-19 26.8-21.3 11.2-2.4 17.7-2 17.7-2-20.3-14.3-131.3 28.1-56.4 40.2C232.84 509.4 401 461.3 348 437.4zM124.44 396c-78.7 22 47.9 67.4 148.1 24.5a185.89 185.89 0 0 1-28.2-13.8c-44.7 8.5-65.4 9.1-106 4.5-33.5-3.8-13.9-15.2-13.9-15.2zm179.8 97.2c-78.7 14.8-175.8 13.1-233.3 3.6 0-.1 11.8 9.7 72.4 13.6 92.2 5.9 233.8-3.3 237.1-46.9 0 0-6.4 16.5-76.2 29.7zM260.64 353c-59.2 11.4-93.5 11.1-136.8 6.6-33.5-3.5-11.6-19.7-11.6-19.7-86.8 28.8 48.2 61.4 169.5 25.9a60.37 60.37 0 0 1-21.1-12.8z"},child:[]}]})(r)}function Pe(r){return u({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zM243.8 381.4c0 43.6-25.6 63.5-62.9 63.5-33.7 0-53.2-17.4-63.2-38.5l34.3-20.7c6.6 11.7 12.6 21.6 27.1 21.6 13.8 0 22.6-5.4 22.6-26.5V237.7h42.1v143.7zm99.6 63.5c-39.1 0-64.4-18.6-76.7-43l34.3-19.8c9 14.7 20.8 25.6 41.5 25.6 17.4 0 28.6-8.7 28.6-20.8 0-14.4-11.4-19.5-30.7-28l-10.5-4.5c-30.4-12.9-50.5-29.2-50.5-63.5 0-31.6 24.1-55.6 61.6-55.6 26.8 0 46 9.3 59.8 33.7L368 290c-7.2-12.9-15-18-27.1-18-12.3 0-20.1 7.8-20.1 18 0 12.6 7.8 17.7 25.9 25.6l10.5 4.5c35.8 15.3 55.9 31 55.9 66.2 0 37.8-29.8 58.6-69.7 58.6z"},child:[]}]})(r)}function _e(r){return u({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M593.8 59.1H46.2C20.7 59.1 0 79.8 0 105.2v301.5c0 25.5 20.7 46.2 46.2 46.2h547.7c25.5 0 46.2-20.7 46.1-46.1V105.2c0-25.4-20.7-46.1-46.2-46.1zM338.5 360.6H277v-120l-61.5 76.9-61.5-76.9v120H92.3V151.4h61.5l61.5 76.9 61.5-76.9h61.5v209.2zm135.3 3.1L381.5 256H443V151.4h61.5V256H566z"},child:[]}]})(r)}function qe(r){return u({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(r)}function We(r){return u({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M418.2 177.2c-5.4-1.8-10.8-3.5-16.2-5.1.9-3.7 1.7-7.4 2.5-11.1 12.3-59.6 4.2-107.5-23.1-123.3-26.3-15.1-69.2.6-112.6 38.4-4.3 3.7-8.5 7.6-12.5 11.5-2.7-2.6-5.5-5.2-8.3-7.7-45.5-40.4-91.1-57.4-118.4-41.5-26.2 15.2-34 60.3-23 116.7 1.1 5.6 2.3 11.1 3.7 16.7-6.4 1.8-12.7 3.8-18.6 5.9C38.3 196.2 0 225.4 0 255.6c0 31.2 40.8 62.5 96.3 81.5 4.5 1.5 9 3 13.6 4.3-1.5 6-2.8 11.9-4 18-10.5 55.5-2.3 99.5 23.9 114.6 27 15.6 72.4-.4 116.6-39.1 3.5-3.1 7-6.3 10.5-9.7 4.4 4.3 9 8.4 13.6 12.4 42.8 36.8 85.1 51.7 111.2 36.6 27-15.6 35.8-62.9 24.4-120.5-.9-4.4-1.9-8.9-3-13.5 3.2-.9 6.3-1.9 9.4-2.9 57.7-19.1 99.5-50 99.5-81.7 0-30.3-39.4-59.7-93.8-78.4zM282.9 92.3c37.2-32.4 71.9-45.1 87.7-36 16.9 9.7 23.4 48.9 12.8 100.4-.7 3.4-1.4 6.7-2.3 10-22.2-5-44.7-8.6-67.3-10.6-13-18.6-27.2-36.4-42.6-53.1 3.9-3.7 7.7-7.2 11.7-10.7zM167.2 307.5c5.1 8.7 10.3 17.4 15.8 25.9-15.6-1.7-31.1-4.2-46.4-7.5 4.4-14.4 9.9-29.3 16.3-44.5 4.6 8.8 9.3 17.5 14.3 26.1zm-30.3-120.3c14.4-3.2 29.7-5.8 45.6-7.8-5.3 8.3-10.5 16.8-15.4 25.4-4.9 8.5-9.7 17.2-14.2 26-6.3-14.9-11.6-29.5-16-43.6zm27.4 68.9c6.6-13.8 13.8-27.3 21.4-40.6s15.8-26.2 24.4-38.9c15-1.1 30.3-1.7 45.9-1.7s31 .6 45.9 1.7c8.5 12.6 16.6 25.5 24.3 38.7s14.9 26.7 21.7 40.4c-6.7 13.8-13.9 27.4-21.6 40.8-7.6 13.3-15.7 26.2-24.2 39-14.9 1.1-30.4 1.6-46.1 1.6s-30.9-.5-45.6-1.4c-8.7-12.7-16.9-25.7-24.6-39s-14.8-26.8-21.5-40.6zm180.6 51.2c5.1-8.8 9.9-17.7 14.6-26.7 6.4 14.5 12 29.2 16.9 44.3-15.5 3.5-31.2 6.2-47 8 5.4-8.4 10.5-17 15.5-25.6zm14.4-76.5c-4.7-8.8-9.5-17.6-14.5-26.2-4.9-8.5-10-16.9-15.3-25.2 16.1 2 31.5 4.7 45.9 8-4.6 14.8-10 29.2-16.1 43.4zM256.2 118.3c10.5 11.4 20.4 23.4 29.6 35.8-19.8-.9-39.7-.9-59.5 0 9.8-12.9 19.9-24.9 29.9-35.8zM140.2 57c16.8-9.8 54.1 4.2 93.4 39 2.5 2.2 5 4.6 7.6 7-15.5 16.7-29.8 34.5-42.9 53.1-22.6 2-45 5.5-67.2 10.4-1.3-5.1-2.4-10.3-3.5-15.5-9.4-48.4-3.2-84.9 12.6-94zm-24.5 263.6c-4.2-1.2-8.3-2.5-12.4-3.9-21.3-6.7-45.5-17.3-63-31.2-10.1-7-16.9-17.8-18.8-29.9 0-18.3 31.6-41.7 77.2-57.6 5.7-2 11.5-3.8 17.3-5.5 6.8 21.7 15 43 24.5 63.6-9.6 20.9-17.9 42.5-24.8 64.5zm116.6 98c-16.5 15.1-35.6 27.1-56.4 35.3-11.1 5.3-23.9 5.8-35.3 1.3-15.9-9.2-22.5-44.5-13.5-92 1.1-5.6 2.3-11.2 3.7-16.7 22.4 4.8 45 8.1 67.9 9.8 13.2 18.7 27.7 36.6 43.2 53.4-3.2 3.1-6.4 6.1-9.6 8.9zm24.5-24.3c-10.2-11-20.4-23.2-30.3-36.3 9.6.4 19.5.6 29.5.6 10.3 0 20.4-.2 30.4-.7-9.2 12.7-19.1 24.8-29.6 36.4zm130.7 30c-.9 12.2-6.9 23.6-16.5 31.3-15.9 9.2-49.8-2.8-86.4-34.2-4.2-3.6-8.4-7.5-12.7-11.5 15.3-16.9 29.4-34.8 42.2-53.6 22.9-1.9 45.7-5.4 68.2-10.5 1 4.1 1.9 8.2 2.7 12.2 4.9 21.6 5.7 44.1 2.5 66.3zm18.2-107.5c-2.8.9-5.6 1.8-8.5 2.6-7-21.8-15.6-43.1-25.5-63.8 9.6-20.4 17.7-41.4 24.5-62.9 5.2 1.5 10.2 3.1 15 4.7 46.6 16 79.3 39.8 79.3 58 0 19.6-34.9 44.9-84.8 61.4zm-149.7-15c25.3 0 45.8-20.5 45.8-45.8s-20.5-45.8-45.8-45.8c-25.3 0-45.8 20.5-45.8 45.8s20.5 45.8 45.8 45.8z"},child:[]}]})(r)}function Ue(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M181.9 256.1c-5-16-4.9-46.9-2-46.9 8.4 0 7.6 36.9 2 46.9zm-1.7 47.2c-7.7 20.2-17.3 43.3-28.4 62.7 18.3-7 39-17.2 62.9-21.9-12.7-9.6-24.9-23.4-34.5-40.8zM86.1 428.1c0 .8 13.2-5.4 34.9-40.2-6.7 6.3-29.1 24.5-34.9 40.2zM248 160h136v328c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V24C0 10.7 10.7 0 24 0h200v136c0 13.2 10.8 24 24 24zm-8 171.8c-20-12.2-33.3-29-42.7-53.8 4.5-18.5 11.6-46.6 6.2-64.2-4.7-29.4-42.4-26.5-47.8-6.8-5 18.3-.4 44.1 8.1 77-11.6 27.6-28.7 64.6-40.8 85.8-.1 0-.1.1-.2.1-27.1 13.9-73.6 44.5-54.5 68 5.6 6.9 16 10 21.5 10 17.9 0 35.7-18 61.1-61.8 25.8-8.5 54.1-19.1 79-23.2 21.7 11.8 47.1 19.5 64 19.5 29.2 0 31.2-32 19.7-43.4-13.9-13.6-54.3-9.7-73.6-7.2zM377 105L279 7c-4.5-4.5-10.6-7-17-7h-6v128h128v-6.1c0-6.3-2.5-12.4-7-16.9zm-74.1 255.3c4.1-2.7-2.5-11.9-42.8-9 37.1 15.8 42.8 9 42.8 9z"},child:[]}]})(r)}function le(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm57.1 120H305c7.7 0 13.4 7.1 11.7 14.7l-38 168c-1.2 5.5-6.1 9.3-11.7 9.3h-38c-5.5 0-10.3-3.8-11.6-9.1-25.8-103.5-20.8-81.2-25.6-110.5h-.5c-1.1 14.3-2.4 17.4-25.6 110.5-1.3 5.3-6.1 9.1-11.6 9.1H117c-5.6 0-10.5-3.9-11.7-9.4l-37.8-168c-1.7-7.5 4-14.6 11.7-14.6h24.5c5.7 0 10.7 4 11.8 9.7 15.6 78 20.1 109.5 21 122.2 1.6-10.2 7.3-32.7 29.4-122.7 1.3-5.4 6.1-9.1 11.7-9.1h29.1c5.6 0 10.4 3.8 11.7 9.2 24 100.4 28.8 124 29.6 129.4-.2-11.2-2.6-17.8 21.6-129.2 1-5.6 5.9-9.5 11.5-9.5zM384 121.9v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(r)}function q(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm160-14.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(r)}function Je(r){return u({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M572.694 292.093L500.27 416.248A63.997 63.997 0 0 1 444.989 448H45.025c-18.523 0-30.064-20.093-20.731-36.093l72.424-124.155A64 64 0 0 1 152 256h399.964c18.523 0 30.064 20.093 20.73 36.093zM152 224h328v-48c0-26.51-21.49-48-48-48H272l-64-64H48C21.49 64 0 85.49 0 112v278.046l69.077-118.418C86.214 242.25 117.989 224 152 224z"},child:[]}]})(r)}function Ke(r){return u({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 128H272l-64-64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V176c0-26.51-21.49-48-48-48z"},child:[]}]})(r)}function j(r){return u({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"},child:[]}]})(r)}function Ge(r){return u({attr:{viewBox:"0 0 16 16",fill:"currentColor"},child:[{tag:"path",attr:{d:"M4.708 5.578L2.061 8.224l2.647 2.646-.708.708-3-3V7.87l3-3 .708.708zm7-.708L11 5.578l2.647 2.646L11 10.87l.708.708 3-3V7.87l-3-3zM4.908 13l.894.448 5-10L9.908 3l-5 10z"},child:[]}]})(r)}function oe(r){return u({attr:{viewBox:"0 0 16 16",fill:"currentColor"},child:[{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.984V2h-.09c-.313 0-.616.062-.909.185a2.33 2.33 0 0 0-.775.53 2.23 2.23 0 0 0-.493.753v.001a3.542 3.542 0 0 0-.198.83v.002a6.08 6.08 0 0 0-.024.863c.012.29.018.58.018.869 0 .203-.04.393-.117.572v.001a1.504 1.504 0 0 1-.765.787 1.376 1.376 0 0 1-.558.115H2v.984h.09c.195 0 .38.04.556.121l.001.001c.178.078.329.184.455.318l.002.002c.13.13.233.285.307.465l.001.002c.078.18.117.368.117.566 0 .29-.006.58-.018.869-.012.296-.004.585.024.87v.001c.033.283.099.558.197.824v.001c.106.273.271.524.494.753.223.23.482.407.775.53.293.123.596.185.91.185H6v-.984h-.09c-.2 0-.387-.038-.563-.115a1.613 1.613 0 0 1-.457-.32 1.659 1.659 0 0 1-.309-.467c-.074-.18-.11-.37-.11-.573 0-.228.003-.453.011-.672.008-.228.008-.45 0-.665a4.639 4.639 0 0 0-.055-.64 2.682 2.682 0 0 0-.168-.609A2.284 2.284 0 0 0 3.522 8a2.284 2.284 0 0 0 .738-.955c.08-.192.135-.393.168-.602.033-.21.051-.423.055-.64.008-.22.008-.442 0-.666-.008-.224-.012-.45-.012-.678a1.47 1.47 0 0 1 .877-1.354 1.33 1.33 0 0 1 .563-.121H6zm4 10.032V14h.09c.313 0 .616-.062.909-.185.293-.123.552-.3.775-.53.223-.23.388-.48.493-.753v-.001c.1-.266.165-.543.198-.83v-.002c.028-.28.036-.567.024-.863-.012-.29-.018-.58-.018-.869 0-.203.04-.393.117-.572v-.001a1.502 1.502 0 0 1 .765-.787 1.38 1.38 0 0 1 .558-.115H14v-.984h-.09c-.196 0-.381-.04-.557-.121l-.001-.001a1.376 1.376 0 0 1-.455-.318l-.002-.002a1.415 1.415 0 0 1-.307-.465v-.002a1.405 1.405 0 0 1-.118-.566c0-.29.006-.58.018-.869a6.174 6.174 0 0 0-.024-.87v-.001a3.537 3.537 0 0 0-.197-.824v-.001a2.23 2.23 0 0 0-.494-.753 2.331 2.331 0 0 0-.775-.53 2.325 2.325 0 0 0-.91-.185H10v.984h.09c.2 0 .387.038.562.115.174.082.326.188.457.32.127.134.23.29.309.467.074.18.11.37.11.573 0 .228-.003.452-.011.672-.008.228-.008.45 0 .665.004.222.022.435.055.64.033.214.089.416.168.609a2.285 2.285 0 0 0 .738.955 2.285 2.285 0 0 0-.738.955 2.689 2.689 0 0 0-.168.602c-.033.21-.051.423-.055.64a9.15 9.15 0 0 0 0 .666c.008.224.012.45.012.678a1.471 1.471 0 0 1-.877 1.354 1.33 1.33 0 0 1-.563.121H10z"},child:[]}]})(r)}function de(r){return u({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M1.125 0C.502 0 0 .502 0 1.125v21.75C0 23.498.502 24 1.125 24h21.75c.623 0 1.125-.502 1.125-1.125V1.125C24 .502 23.498 0 22.875 0zm17.363 9.75c.612 0 1.154.037 1.627.111a6.38 6.38 0 0 1 1.306.34v2.458a3.95 3.95 0 0 0-.643-.361 5.093 5.093 0 0 0-.717-.26 5.453 5.453 0 0 0-1.426-.2c-.3 0-.573.028-.819.086a2.1 2.1 0 0 0-.623.242c-.17.104-.3.229-.393.374a.888.888 0 0 0-.14.49c0 .196.053.373.156.529.104.156.252.304.443.444s.423.276.696.41c.273.135.582.274.926.416.47.197.892.407 1.266.628.374.222.695.473.963.753.268.279.472.598.614.957.142.359.214.776.214 1.253 0 .657-.125 1.21-.373 1.656a3.033 3.033 0 0 1-1.012 1.085 4.38 4.38 0 0 1-1.487.596c-.566.12-1.163.18-1.79.18a9.916 9.916 0 0 1-1.84-.164 5.544 5.544 0 0 1-1.512-.493v-2.63a5.033 5.033 0 0 0 3.237 1.2c.333 0 .624-.03.872-.09.249-.06.456-.144.623-.25.166-.108.29-.234.373-.38a1.023 1.023 0 0 0-.074-1.089 2.12 2.12 0 0 0-.537-.5 5.597 5.597 0 0 0-.807-.444 27.72 27.72 0 0 0-1.007-.436c-.918-.383-1.602-.852-2.053-1.405-.45-.553-.676-1.222-.676-2.005 0-.614.123-1.141.369-1.582.246-.441.58-.804 1.004-1.089a4.494 4.494 0 0 1 1.47-.629 7.536 7.536 0 0 1 1.77-.201zm-15.113.188h9.563v2.166H9.506v9.646H6.789v-9.646H3.375z"},child:[]}]})(r)}const Xe=(r,l)=>me({queryKey:["file-content",r,l],queryFn:async()=>{if(!r)throw new Error("File path is required");const d=new URLSearchParams;d.append("path",r),l&&d.append("projectPath",l);const h=await _(`${M}/files/read?${d.toString()}`);if(!h.ok)throw h.status===403?new Error("访问被拒绝:文件在项目目录之外"):h.status===404?new Error("文件不存在"):new Error(`读取文件失败 (${h.status})`);return h.json()},enabled:!!r,staleTime:6e4,retry:!1}),Qe=(r,l)=>me({queryKey:["file-tree-lazy",r,l],queryFn:async()=>{if(!r)throw new Error("Project path is required");const d=new URLSearchParams;d.append("path",r),l&&d.append("showHiddenFiles","true");const h=await _(`${M}/files/browse?${d.toString()}`);if(!h.ok)throw new Error("Failed to browse directory");const i=await h.json(),x=[];for(const f of i.items)f.isDirectory?x.push({...f,children:[]}):x.push(f);return x},enabled:!!r,staleTime:3e4});class Ye{events=new Map;on(l,d){this.events.has(l)||this.events.set(l,[]),this.events.get(l).push(d)}off(l,d){const h=this.events.get(l);if(h){const i=h.indexOf(d);i>-1&&h.splice(i,1)}}emit(l,...d){const h=this.events.get(l);h&&h.forEach(i=>{try{i(...d)}catch(x){console.error(`Error in event handler for ${l}:`,x)}})}clear(){this.events.clear()}}const he=new Ye,xe={AI_RESPONSE_COMPLETE:"ai_response_complete",REFRESH_AGENT_CONTENT:"refresh_agent_content"},Ze=c.lazy(()=>Se(()=>import("./monaco-editor-DHKm5-VF.js").then(r=>r.i),[])),et=new Map([["js",e.jsx(Pe,{color:"#f7df1e"},"js")],["jsx",e.jsx(We,{color:"#61dafb"},"jsx")],["ts",e.jsx(de,{color:"#3178c6"},"ts")],["tsx",e.jsx(de,{color:"#3178c6"},"tsx")],["css",e.jsx($e,{color:"#1572b6"},"css")],["html",e.jsx(ie,{color:"#e34f26"},"html")],["htm",e.jsx(ie,{color:"#e34f26"},"htm")],["json",e.jsx(oe,{color:"#f9d71c"},"json")],["jsonl",e.jsx(oe,{color:"#e6a23c"},"jsonl")],["md",e.jsx(_e,{color:"#083fa1"},"md")],["csv",e.jsx(q,{color:"#00a86b"},"csv")],["pdf",e.jsx(Ue,{color:"#d63031"},"pdf")],["ppt",e.jsx(le,{color:"#d63031"},"ppt")],["pptx",e.jsx(le,{color:"#d63031"},"pptx")],["ico",e.jsx(j,{color:"#a9a9a9"},"ico")],["png",e.jsx(j,{color:"#a9a9a9"},"png")],["jpg",e.jsx(j,{color:"#a9a9a9"},"jpg")],["jpeg",e.jsx(j,{color:"#a9a9a9"},"jpeg")],["gif",e.jsx(j,{color:"#a9a9a9"},"gif")],["svg",e.jsx(j,{color:"#a9a9a9"},"svg")],["webp",e.jsx(j,{color:"#a9a9a9"},"webp")],["py",e.jsx(qe,{color:"#3776ab"},"py")],["java",e.jsx(Be,{color:"#007396"},"java")]]),P=({node:r})=>{const l=r.data.isHidden;if(r.data.isDirectory){const x=l?"#9ca3af":"#87b3d6";return r.isOpen?e.jsx(Je,{color:x}):e.jsx(Ke,{color:x})}const d=r.data.name.split(".").pop()?.toLowerCase()||"",h=l?"#9ca3af":"#6d8a9f",i=l?{opacity:.6}:{};return e.jsx("span",{style:i,children:et.get(d)||e.jsx(q,{color:h})})},tt=(r="")=>{const l=r.toLowerCase();if(l==="dockerfile"||l.startsWith("dockerfile."))return"dockerfile";switch(r.split(".").pop()?.toLowerCase()||""){case"js":case"jsx":return"javascript";case"ts":case"tsx":return"typescript";case"css":case"scss":case"sass":case"less":return"css";case"json":case"jsonl":return"json";case"html":case"htm":return"html";case"md":case"markdown":return"markdown";case"csv":return"csv";case"py":return"python";case"java":return"java";case"xml":return"xml";case"yaml":case"yml":return"yaml";case"sh":case"bash":return"shell";case"conf":case"config":case"ini":return"ini";case"nginx":return"nginx";case"sql":return"sql";case"go":return"go";case"rs":return"rust";case"c":case"cpp":case"cc":case"cxx":return"cpp";case"h":case"hpp":return"cpp";case"cs":return"csharp";case"php":return"php";case"rb":return"ruby";case"swift":return"swift";case"kt":return"kotlin";case"dockerfile":return"dockerfile";default:return"plaintext"}},rt=({imageUrl:r,fileName:l})=>{const{t:d}=ue("components"),[h,i]=c.useState(!0),[x,f]=c.useState(!1);return e.jsx("div",{className:"flex items-center justify-center h-full p-4",children:x?e.jsxs("div",{className:"text-center text-gray-500",children:[e.jsx(j,{className:"w-12 h-12 mx-auto mb-4 text-gray-300"}),e.jsx("p",{children:d("fileExplorer.imageLoadFailed")}),e.jsx("p",{className:"text-sm mt-2",children:l})]}):e.jsxs("div",{className:"relative max-w-full max-h-full",children:[h&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(T,{className:"w-8 h-8 animate-spin text-gray-400"})}),e.jsx("img",{src:r,alt:l,className:"max-w-full max-h-full object-contain bg-white dark:bg-gray-900 rounded shadow-lg",onLoad:()=>i(!1),onError:()=>{i(!1),f(!0)},style:{display:x?"none":"block"}})]})})},st=r=>{const l=r.toLowerCase();if(l==="dockerfile"||l.startsWith("dockerfile."))return"text";const d=r.split(".").pop()?.toLowerCase()||"",h=["js","jsx","ts","tsx","css","scss","sass","less","html","htm","json","jsonl","md","markdown","txt","py","java","xml","yaml","yml","sh","bash","bat","cmd","php","rb","go","rs","cpp","c","h","hpp","cc","cxx","cs","swift","kt","scala","clj","sql","dockerfile","gitignore","env","csv","tsv","conf","config","ini","toml","nginx","apache","properties","cfg"],i=["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff"];return h.includes(d)?"text":i.includes(d)?"image":"binary"},at=({node:r,style:l,dragHandle:d,isLoading:h=!1,onDirectoryToggle:i,onFileSelect:x})=>{const f=c.useCallback(y=>{y.preventDefault(),y.stopPropagation(),r.data.isDirectory?i?.(r):x?.(r)},[r,i,x]);return e.jsxs("div",{style:l,ref:d,className:`flex items-center cursor-pointer px-3 py-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 ${r.isSelected?"bg-blue-100 dark:bg-blue-900/30 text-blue-900 dark:text-blue-300":"text-gray-700 dark:text-gray-300"}`,onClick:f,children:[r.data.isDirectory&&e.jsx("span",{className:"mr-1 flex items-center",children:h?e.jsx(T,{className:"w-3 h-3 animate-spin text-gray-400"}):e.jsx(Ve,{className:`w-3 h-3 transition-transform text-gray-400 ${r.isOpen?"rotate-90":""}`})}),e.jsx("span",{className:"mr-2 flex items-center",children:e.jsx(P,{node:r})}),e.jsx("span",{className:`text-sm truncate flex-1 ${r.data.isHidden?"text-gray-400 dark:text-gray-500 italic":"text-gray-700 dark:text-gray-300"}`,children:r.data.name}),!r.data.isDirectory&&r.data.size&&e.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500 ml-2",children:[(r.data.size/1024).toFixed(1),"KB"]})]})},F=5,mt=({projectPath:r,onFileSelect:l,className:d="",height:h="100vh"})=>{const{t:i}=ue("components"),[x,f]=c.useState([]),[y,D]=c.useState(null),[fe,W]=c.useState(600),[z,A]=c.useState(!1),k=c.useRef(null),R=c.useRef(null),I=c.useRef(null),[U,ge]=c.useState(0),[J,pe]=c.useState(""),[ye,ve]=c.useState(document.documentElement.classList.contains("dark")),[L,S]=c.useState(new Set),[N,K]=c.useState([]),[O,H]=c.useState(new Set),[g,je]=c.useState(!1),[G,X]=c.useState(!1),{data:E,isLoading:V,error:Q,refetch:C}=Qe(r,g),p=c.useMemo(()=>x.find(t=>t.isActive)||null,[x]),{data:Y,isLoading:be,error:Z}=Xe(p?p.path:void 0,r);c.useEffect(()=>{const t=new MutationObserver(s=>{s.forEach(o=>{o.attributeName==="class"&&ve(document.documentElement.classList.contains("dark"))})});return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]),c.useEffect(()=>{if(E){const t=m=>m.filter(a=>g||!a.isHidden).map(a=>({id:a.path,name:a.name,path:a.path,isDirectory:a.isDirectory,size:a.size,modified:a.modified,isHidden:a.isHidden,children:a.children?t(a.children):void 0})),s=(m,a=new Set)=>(m.forEach(n=>{n.isDirectory&&n.children&&n.children.length>0&&(a.add(n.path),s(n.children,a))}),a),o=s(E);S(o),K(t(E))}},[E,g]);const ee=c.useCallback(async t=>{if(!(L.has(t)||O.has(t))){H(s=>new Set(s).add(t));try{const s=new URLSearchParams;s.append("path",t),g&&s.append("showHiddenFiles","true");const o=await _(`${M}/files/browse?${s.toString()}`);if(!o.ok)throw new Error("Failed to browse directory");const m=await o.json(),a=[];for(const n of m.items)n.isDirectory?a.push({...n,children:[]}):a.push(n);K(n=>{const b=Le=>Le.map(w=>w.path===t?{...w,children:a.map(v=>({id:v.path,name:v.name,path:v.path,isDirectory:v.isDirectory,size:v.size,modified:v.modified,isHidden:v.isHidden,children:v.isDirectory?[]:void 0}))}:w.children?{...w,children:b(w.children)}:w);return b(n)}),S(n=>new Set(n).add(t)),I.current&&a.length>0&&a.forEach(n=>{n.isDirectory&&I.current?.close(n.path)})}catch(s){throw console.error("Failed to load directory children:",s),s}finally{H(s=>{const o=new Set(s);return o.delete(t),o})}}},[L,O,g]),$=c.useCallback(()=>{S(new Set),H(new Set),C()},[C]),we=c.useCallback(()=>{je(t=>!t)},[]);c.useEffect(()=>{S(new Set),H(new Set),C()},[g,C]),c.useEffect(()=>{const t=()=>{if(k.current){const m=k.current.getBoundingClientRect(),a=m.height>0?m.height:600;W(a)}};let s=null;k.current&&(s=new ResizeObserver(m=>{for(const a of m){const{height:n}=a.contentRect;n>0&&W(n)}}),s.observe(k.current));const o=setTimeout(t,100);return window.addEventListener("resize",t),()=>{clearTimeout(o),window.removeEventListener("resize",t),s&&s.disconnect()}},[E]),c.useEffect(()=>{const t=s=>{R.current&&!R.current.contains(s.target)&&A(!1)};if(z)return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[z]),c.useEffect(()=>{const t=s=>{console.log("🔄 Received AI_RESPONSE_COMPLETE event in FileExplorer:",s),s.projectPath===r&&(console.log("🔄 Auto-refreshing file tree after AI response completion"),$())};return he.on(xe.AI_RESPONSE_COMPLETE,t),()=>{he.off(xe.AI_RESPONSE_COMPLETE,t)}},[r,$]);const te=N,ke=c.useMemo(()=>{const t={},s=o=>{o.forEach(m=>{m.isDirectory&&(t[m.id]=!1,m.children&&s(m.children))})};return N&&N.length>0&&s(N),t},[N]),re=c.useCallback((t,s=!1)=>({id:`tab-${t.path}`,name:t.name,path:t.path,isPinned:s,isActive:!1}),[]),B=c.useCallback((t,s=!1)=>{f(o=>{const m=o.findIndex(a=>a.path===t.path);if(m!==-1)return o.map((a,n)=>({...a,isActive:n===m,isPinned:s||a.isPinned}));{const a=re(t,s);return!s&&y?(D(a.id),o.map(n=>n.id===y?{...a,isActive:!0}:{...n,isActive:!1})):(s||D(a.id),[...o.map(n=>({...n,isActive:!1})),{...a,isActive:!0}])}}),l?.(t.path)},[re,y,l]),se=c.useCallback(t=>{f(s=>{const o=s.findIndex(n=>n.id===t);if(o===-1)return s;const m=s[o],a=s.filter(n=>n.id!==t);if(m.isActive&&a.length>0){const n=Math.min(o,a.length-1);a[n]={...a[n],isActive:!0}}return y===t&&D(null),a})},[y]),ae=c.useCallback(t=>{f(s=>s.map(o=>({...o,isActive:o.id===t})))},[]),[ce,Ne]=c.useState({}),Ee=c.useCallback(t=>{const s=Date.now(),o=ce[t.data.path]||0;if(s-o<300)return;Ne(b=>({...b,[t.data.path]:s}));const m=t.isOpen,a=t.data.children&&t.data.children.length>0,n=L.has(t.data.path);m?t.close():!a&&!n?(t.open(),ee(t.data.path).catch(b=>{console.error("Failed to load directory children:",b),t.close()})):t.open()},[ce,L,ee]),Ce=c.useCallback(t=>{t.select();const s=Date.now(),o=s-U<300&&J===t.data.path;ge(s),pe(t.data.path),o?B(t.data,!0):setTimeout(()=>{Date.now()-s>=300&&B(t.data,!1)},300)},[B,U,J]),ze=()=>{if(!p)return e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(q,{className:"w-12 h-12 mx-auto mb-4 text-gray-300 dark:text-gray-600"}),e.jsx("p",{children:i("fileExplorer.selectFile")})]})});if(be)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400",children:[e.jsx(T,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:i("fileExplorer.loading")})]})});if(Z)return e.jsx("div",{className:"flex items-center justify-center h-full text-red-500 dark:text-red-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:i("fileExplorer.loadFailed")}),e.jsx("p",{className:"text-sm mt-2 bg-red-50 dark:bg-red-900/30 px-3 py-2 rounded border border-red-200 dark:border-red-800",children:Z.message}),e.jsx("p",{className:"text-xs mt-2 text-gray-500 dark:text-gray-400",children:p.path})]})});switch(st(p.name)){case"image":const s=new URLSearchParams;s.append("path",p.path),r&&s.append("projectPath",r),s.append("binary","true");const o=`${M}/files/read?${s.toString()}`;return e.jsx(rt,{imageUrl:o,fileName:p.name});case"text":return Y?e.jsx(Fe.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-gray-900"})}),children:e.jsx(Ze,{height:"100%",theme:ye?"vs-dark":"vs-light",language:tt(p.name),value:Y.content,options:{readOnly:!0,minimap:{enabled:!1},fontSize:14,wordWrap:"on",scrollBeyondLastLine:!1}})}):e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:i("fileExplorer.cannotReadFile")})});default:return e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Ge,{className:"w-12 h-12 mx-auto mb-4 text-gray-300 dark:text-gray-600"}),e.jsx("p",{children:i("fileExplorer.previewNotSupported")}),e.jsxs("p",{className:"text-sm mt-2",children:[i("fileExplorer.fileLabel"),": ",p.name]})]})})}};return Q?e.jsx("div",{className:`flex items-center justify-center h-full text-red-500 dark:text-red-400 ${d}`,style:{height:h},children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:i("fileExplorer.loadFailed")}),e.jsx("p",{className:"text-sm mt-2 bg-red-50 dark:bg-red-900/30 px-3 py-2 rounded border border-red-200 dark:border-red-800",children:Q.message}),e.jsxs("p",{className:"text-xs mt-2 text-gray-500 dark:text-gray-400",children:[i("fileExplorer.projectPath"),": ",r]}),e.jsx("button",{onClick:()=>C(),className:"mt-4 px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors",children:i("fileExplorer.retry")})]})}):e.jsxs("div",{className:`flex h-full bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden ${d}`,children:[!G&&e.jsxs("div",{className:"w-80 border-r border-gray-200 dark:border-gray-700 flex flex-col h-full",children:[e.jsx("div",{className:"h-12 px-3 border-b border-gray-200 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 flex items-center flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:i("fileExplorer.title")}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("button",{onClick:we,className:`p-1.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors ${g?"text-blue-600 dark:text-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"}`,title:g?"隐藏文件和文件夹":"显示隐藏文件和文件夹",children:g?e.jsx(Te,{className:"w-4 h-4"}):e.jsx(Me,{className:"w-4 h-4"})}),e.jsx("button",{onClick:$,className:"p-1.5 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:i("common:actions.refresh"),disabled:V,children:e.jsx(De,{className:`w-4 h-4 ${V?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>X(!0),className:"p-1.5 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:i("fileExplorer.collapsePanel"),children:e.jsx(Ae,{className:"w-4 h-4"})})]})]})}),e.jsx("div",{ref:k,className:"flex-1 min-h-0 pl-2",children:V?e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400",children:[e.jsx(T,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:i("fileExplorer.loading")})]})}):te.length===0?e.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:e.jsx("p",{className:"text-sm",children:i("fileExplorer.emptyDirectory")})}):e.jsx(He,{data:te,width:320,height:fe,indent:20,rowHeight:36,initialOpenState:ke,ref:I,children:t=>e.jsx(at,{...t,isLoading:O.has(t.node.data.path),onDirectoryToggle:Ee,onFileSelect:Ce})})})]}),e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[e.jsxs("div",{className:"h-12 border-b border-gray-200 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 flex items-center flex-shrink-0",children:[G&&e.jsx("button",{onClick:()=>X(!1),className:"p-1.5 mx-2 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:i("fileExplorer.expandPanel"),children:e.jsx(Re,{className:"w-4 h-4"})}),x.length>0?e.jsxs("div",{className:"flex items-center h-full w-full",children:[e.jsx("div",{className:"flex items-center h-full flex-1",children:x.slice(0,Math.min(F,x.length)).map(t=>e.jsxs("div",{className:`group relative flex items-center h-full px-3 border-r border-gray-200 dark:border-gray-700 cursor-pointer transition-colors ${t.isActive?"bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"} ${t.isPinned?"":"italic"}`,onClick:()=>ae(t.id),title:`${t.path} ${t.isPinned?"(固定)":"(临时)"}`,style:{minWidth:"120px",maxWidth:"180px"},children:[e.jsx(P,{node:{data:{name:t.name,isDirectory:!1},isOpen:!1}}),e.jsx("span",{className:"ml-2 text-sm truncate flex-1",children:t.name}),!t.isPinned&&e.jsx("span",{className:"ml-1 text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:"•"}),e.jsx("button",{className:"ml-2 p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-gray-600 transition-opacity flex-shrink-0",onClick:s=>{s.stopPropagation(),se(t.id)},title:i("common:actions.close"),children:e.jsx(ne,{className:"w-3 h-3"})})]},t.id))}),x.length>F&&e.jsxs("div",{className:"relative",ref:R,children:[e.jsxs("button",{className:"flex items-center h-full px-3 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-gray-900 dark:hover:text-white transition-colors border-l border-gray-200 dark:border-gray-700",onClick:()=>A(!z),title:`${x.length-F} more tabs`,children:[e.jsx(Ie,{className:"w-4 h-4"}),e.jsx(Oe,{className:"w-3 h-3 ml-1"})]}),z&&e.jsx("div",{className:"absolute top-full right-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-50 min-w-48 max-h-64 overflow-y-auto",children:x.slice(F).map(t=>e.jsxs("div",{className:`flex items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700 ${t.isActive?"bg-blue-50 dark:bg-blue-900/30 text-blue-900 dark:text-blue-300":"text-gray-700 dark:text-gray-300"} ${t.isPinned?"":"italic"}`,onClick:()=>{ae(t.id),A(!1)},title:`${t.path} ${t.isPinned?"(固定)":"(临时)"}`,children:[e.jsx(P,{node:{data:{name:t.name,isDirectory:!1},isOpen:!1}}),e.jsx("span",{className:"ml-2 truncate flex-1",children:t.name}),!t.isPinned&&e.jsx("span",{className:"ml-1 text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:"•"}),e.jsx("button",{className:"ml-2 p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-gray-600 transition-opacity flex-shrink-0",onClick:s=>{s.stopPropagation(),se(t.id)},title:i("common:actions.close"),children:e.jsx(ne,{className:"w-3 h-3"})})]},t.id))})]})]}):e.jsx("div",{className:"flex items-center justify-center w-full h-full text-gray-500 dark:text-gray-400",children:e.jsx("span",{className:"text-sm",children:i("fileExplorer.noFiles")})})]}),e.jsx("div",{className:"flex-1 bg-gray-50 dark:bg-gray-900 min-h-0",children:ze()})]})]})};export{xe as E,mt as F,he as e};
1
+ import{c as Se}from"./syntax-highlighting-CnREyncB.js";import{j as e,T as He}from"./data-structures-C0h9Oap1.js";import{r as c,W as Fe}from"./monaco-editor-DHKm5-VF.js";import{aw as u,E as Te,Y as Me,R as De,ax as Ae,L as T,ay as Re,X as ne,az as Ie,k as Oe,l as Ve}from"./ui-components-icUM6BEH.js";import{b as me,a as _,A as M}from"./agents-B3InAIfY.js";import{u as ue}from"./tools-CUwQTL-8.js";function $e(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M0 32l34.9 395.8L192 480l157.1-52.2L384 32H0zm313.1 80l-4.8 47.3L193 208.6l-.3.1h111.5l-12.8 146.6-98.2 28.7-98.8-29.2-6.4-73.9h48.9l3.2 38.3 52.6 13.3 54.7-15.4 3.7-61.6-166.3-.5v-.1l-.2.1-3.6-46.3L193.1 162l6.5-2.7H76.7L70.9 112h242.2z"},child:[]}]})(r)}function ie(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M0 32l34.9 395.8L191.5 480l157.6-52.2L384 32H0zm308.2 127.9H124.4l4.1 49.4h175.6l-13.6 148.4-97.9 27v.3h-1.1l-98.7-27.3-6-75.8h47.7L138 320l53.5 14.5 53.7-14.5 6-62.2H84.3L71.5 112.2h241.1l-4.4 47.7z"},child:[]}]})(r)}function Be(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M277.74 312.9c9.8-6.7 23.4-12.5 23.4-12.5s-38.7 7-77.2 10.2c-47.1 3.9-97.7 4.7-123.1 1.3-60.1-8 33-30.1 33-30.1s-36.1-2.4-80.6 19c-52.5 25.4 130 37 224.5 12.1zm-85.4-32.1c-19-42.7-83.1-80.2 0-145.8C296 53.2 242.84 0 242.84 0c21.5 84.5-75.6 110.1-110.7 162.6-23.9 35.9 11.7 74.4 60.2 118.2zm114.6-176.2c.1 0-175.2 43.8-91.5 140.2 24.7 28.4-6.5 54-6.5 54s62.7-32.4 33.9-72.9c-26.9-37.8-47.5-56.6 64.1-121.3zm-6.1 270.5a12.19 12.19 0 0 1-2 2.6c128.3-33.7 81.1-118.9 19.8-97.3a17.33 17.33 0 0 0-8.2 6.3 70.45 70.45 0 0 1 11-3c31-6.5 75.5 41.5-20.6 91.4zM348 437.4s14.5 11.9-15.9 21.2c-57.9 17.5-240.8 22.8-291.6.7-18.3-7.9 16-19 26.8-21.3 11.2-2.4 17.7-2 17.7-2-20.3-14.3-131.3 28.1-56.4 40.2C232.84 509.4 401 461.3 348 437.4zM124.44 396c-78.7 22 47.9 67.4 148.1 24.5a185.89 185.89 0 0 1-28.2-13.8c-44.7 8.5-65.4 9.1-106 4.5-33.5-3.8-13.9-15.2-13.9-15.2zm179.8 97.2c-78.7 14.8-175.8 13.1-233.3 3.6 0-.1 11.8 9.7 72.4 13.6 92.2 5.9 233.8-3.3 237.1-46.9 0 0-6.4 16.5-76.2 29.7zM260.64 353c-59.2 11.4-93.5 11.1-136.8 6.6-33.5-3.5-11.6-19.7-11.6-19.7-86.8 28.8 48.2 61.4 169.5 25.9a60.37 60.37 0 0 1-21.1-12.8z"},child:[]}]})(r)}function Pe(r){return u({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48zM243.8 381.4c0 43.6-25.6 63.5-62.9 63.5-33.7 0-53.2-17.4-63.2-38.5l34.3-20.7c6.6 11.7 12.6 21.6 27.1 21.6 13.8 0 22.6-5.4 22.6-26.5V237.7h42.1v143.7zm99.6 63.5c-39.1 0-64.4-18.6-76.7-43l34.3-19.8c9 14.7 20.8 25.6 41.5 25.6 17.4 0 28.6-8.7 28.6-20.8 0-14.4-11.4-19.5-30.7-28l-10.5-4.5c-30.4-12.9-50.5-29.2-50.5-63.5 0-31.6 24.1-55.6 61.6-55.6 26.8 0 46 9.3 59.8 33.7L368 290c-7.2-12.9-15-18-27.1-18-12.3 0-20.1 7.8-20.1 18 0 12.6 7.8 17.7 25.9 25.6l10.5 4.5c35.8 15.3 55.9 31 55.9 66.2 0 37.8-29.8 58.6-69.7 58.6z"},child:[]}]})(r)}function _e(r){return u({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M593.8 59.1H46.2C20.7 59.1 0 79.8 0 105.2v301.5c0 25.5 20.7 46.2 46.2 46.2h547.7c25.5 0 46.2-20.7 46.1-46.1V105.2c0-25.4-20.7-46.1-46.2-46.1zM338.5 360.6H277v-120l-61.5 76.9-61.5-76.9v120H92.3V151.4h61.5l61.5 76.9 61.5-76.9h61.5v209.2zm135.3 3.1L381.5 256H443V151.4h61.5V256H566z"},child:[]}]})(r)}function qe(r){return u({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(r)}function We(r){return u({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M418.2 177.2c-5.4-1.8-10.8-3.5-16.2-5.1.9-3.7 1.7-7.4 2.5-11.1 12.3-59.6 4.2-107.5-23.1-123.3-26.3-15.1-69.2.6-112.6 38.4-4.3 3.7-8.5 7.6-12.5 11.5-2.7-2.6-5.5-5.2-8.3-7.7-45.5-40.4-91.1-57.4-118.4-41.5-26.2 15.2-34 60.3-23 116.7 1.1 5.6 2.3 11.1 3.7 16.7-6.4 1.8-12.7 3.8-18.6 5.9C38.3 196.2 0 225.4 0 255.6c0 31.2 40.8 62.5 96.3 81.5 4.5 1.5 9 3 13.6 4.3-1.5 6-2.8 11.9-4 18-10.5 55.5-2.3 99.5 23.9 114.6 27 15.6 72.4-.4 116.6-39.1 3.5-3.1 7-6.3 10.5-9.7 4.4 4.3 9 8.4 13.6 12.4 42.8 36.8 85.1 51.7 111.2 36.6 27-15.6 35.8-62.9 24.4-120.5-.9-4.4-1.9-8.9-3-13.5 3.2-.9 6.3-1.9 9.4-2.9 57.7-19.1 99.5-50 99.5-81.7 0-30.3-39.4-59.7-93.8-78.4zM282.9 92.3c37.2-32.4 71.9-45.1 87.7-36 16.9 9.7 23.4 48.9 12.8 100.4-.7 3.4-1.4 6.7-2.3 10-22.2-5-44.7-8.6-67.3-10.6-13-18.6-27.2-36.4-42.6-53.1 3.9-3.7 7.7-7.2 11.7-10.7zM167.2 307.5c5.1 8.7 10.3 17.4 15.8 25.9-15.6-1.7-31.1-4.2-46.4-7.5 4.4-14.4 9.9-29.3 16.3-44.5 4.6 8.8 9.3 17.5 14.3 26.1zm-30.3-120.3c14.4-3.2 29.7-5.8 45.6-7.8-5.3 8.3-10.5 16.8-15.4 25.4-4.9 8.5-9.7 17.2-14.2 26-6.3-14.9-11.6-29.5-16-43.6zm27.4 68.9c6.6-13.8 13.8-27.3 21.4-40.6s15.8-26.2 24.4-38.9c15-1.1 30.3-1.7 45.9-1.7s31 .6 45.9 1.7c8.5 12.6 16.6 25.5 24.3 38.7s14.9 26.7 21.7 40.4c-6.7 13.8-13.9 27.4-21.6 40.8-7.6 13.3-15.7 26.2-24.2 39-14.9 1.1-30.4 1.6-46.1 1.6s-30.9-.5-45.6-1.4c-8.7-12.7-16.9-25.7-24.6-39s-14.8-26.8-21.5-40.6zm180.6 51.2c5.1-8.8 9.9-17.7 14.6-26.7 6.4 14.5 12 29.2 16.9 44.3-15.5 3.5-31.2 6.2-47 8 5.4-8.4 10.5-17 15.5-25.6zm14.4-76.5c-4.7-8.8-9.5-17.6-14.5-26.2-4.9-8.5-10-16.9-15.3-25.2 16.1 2 31.5 4.7 45.9 8-4.6 14.8-10 29.2-16.1 43.4zM256.2 118.3c10.5 11.4 20.4 23.4 29.6 35.8-19.8-.9-39.7-.9-59.5 0 9.8-12.9 19.9-24.9 29.9-35.8zM140.2 57c16.8-9.8 54.1 4.2 93.4 39 2.5 2.2 5 4.6 7.6 7-15.5 16.7-29.8 34.5-42.9 53.1-22.6 2-45 5.5-67.2 10.4-1.3-5.1-2.4-10.3-3.5-15.5-9.4-48.4-3.2-84.9 12.6-94zm-24.5 263.6c-4.2-1.2-8.3-2.5-12.4-3.9-21.3-6.7-45.5-17.3-63-31.2-10.1-7-16.9-17.8-18.8-29.9 0-18.3 31.6-41.7 77.2-57.6 5.7-2 11.5-3.8 17.3-5.5 6.8 21.7 15 43 24.5 63.6-9.6 20.9-17.9 42.5-24.8 64.5zm116.6 98c-16.5 15.1-35.6 27.1-56.4 35.3-11.1 5.3-23.9 5.8-35.3 1.3-15.9-9.2-22.5-44.5-13.5-92 1.1-5.6 2.3-11.2 3.7-16.7 22.4 4.8 45 8.1 67.9 9.8 13.2 18.7 27.7 36.6 43.2 53.4-3.2 3.1-6.4 6.1-9.6 8.9zm24.5-24.3c-10.2-11-20.4-23.2-30.3-36.3 9.6.4 19.5.6 29.5.6 10.3 0 20.4-.2 30.4-.7-9.2 12.7-19.1 24.8-29.6 36.4zm130.7 30c-.9 12.2-6.9 23.6-16.5 31.3-15.9 9.2-49.8-2.8-86.4-34.2-4.2-3.6-8.4-7.5-12.7-11.5 15.3-16.9 29.4-34.8 42.2-53.6 22.9-1.9 45.7-5.4 68.2-10.5 1 4.1 1.9 8.2 2.7 12.2 4.9 21.6 5.7 44.1 2.5 66.3zm18.2-107.5c-2.8.9-5.6 1.8-8.5 2.6-7-21.8-15.6-43.1-25.5-63.8 9.6-20.4 17.7-41.4 24.5-62.9 5.2 1.5 10.2 3.1 15 4.7 46.6 16 79.3 39.8 79.3 58 0 19.6-34.9 44.9-84.8 61.4zm-149.7-15c25.3 0 45.8-20.5 45.8-45.8s-20.5-45.8-45.8-45.8c-25.3 0-45.8 20.5-45.8 45.8s20.5 45.8 45.8 45.8z"},child:[]}]})(r)}function Ue(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M181.9 256.1c-5-16-4.9-46.9-2-46.9 8.4 0 7.6 36.9 2 46.9zm-1.7 47.2c-7.7 20.2-17.3 43.3-28.4 62.7 18.3-7 39-17.2 62.9-21.9-12.7-9.6-24.9-23.4-34.5-40.8zM86.1 428.1c0 .8 13.2-5.4 34.9-40.2-6.7 6.3-29.1 24.5-34.9 40.2zM248 160h136v328c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V24C0 10.7 10.7 0 24 0h200v136c0 13.2 10.8 24 24 24zm-8 171.8c-20-12.2-33.3-29-42.7-53.8 4.5-18.5 11.6-46.6 6.2-64.2-4.7-29.4-42.4-26.5-47.8-6.8-5 18.3-.4 44.1 8.1 77-11.6 27.6-28.7 64.6-40.8 85.8-.1 0-.1.1-.2.1-27.1 13.9-73.6 44.5-54.5 68 5.6 6.9 16 10 21.5 10 17.9 0 35.7-18 61.1-61.8 25.8-8.5 54.1-19.1 79-23.2 21.7 11.8 47.1 19.5 64 19.5 29.2 0 31.2-32 19.7-43.4-13.9-13.6-54.3-9.7-73.6-7.2zM377 105L279 7c-4.5-4.5-10.6-7-17-7h-6v128h128v-6.1c0-6.3-2.5-12.4-7-16.9zm-74.1 255.3c4.1-2.7-2.5-11.9-42.8-9 37.1 15.8 42.8 9 42.8 9z"},child:[]}]})(r)}function le(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm57.1 120H305c7.7 0 13.4 7.1 11.7 14.7l-38 168c-1.2 5.5-6.1 9.3-11.7 9.3h-38c-5.5 0-10.3-3.8-11.6-9.1-25.8-103.5-20.8-81.2-25.6-110.5h-.5c-1.1 14.3-2.4 17.4-25.6 110.5-1.3 5.3-6.1 9.1-11.6 9.1H117c-5.6 0-10.5-3.9-11.7-9.4l-37.8-168c-1.7-7.5 4-14.6 11.7-14.6h24.5c5.7 0 10.7 4 11.8 9.7 15.6 78 20.1 109.5 21 122.2 1.6-10.2 7.3-32.7 29.4-122.7 1.3-5.4 6.1-9.1 11.7-9.1h29.1c5.6 0 10.4 3.8 11.7 9.2 24 100.4 28.8 124 29.6 129.4-.2-11.2-2.6-17.8 21.6-129.2 1-5.6 5.9-9.5 11.5-9.5zM384 121.9v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(r)}function q(r){return u({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm160-14.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(r)}function Je(r){return u({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M572.694 292.093L500.27 416.248A63.997 63.997 0 0 1 444.989 448H45.025c-18.523 0-30.064-20.093-20.731-36.093l72.424-124.155A64 64 0 0 1 152 256h399.964c18.523 0 30.064 20.093 20.73 36.093zM152 224h328v-48c0-26.51-21.49-48-48-48H272l-64-64H48C21.49 64 0 85.49 0 112v278.046l69.077-118.418C86.214 242.25 117.989 224 152 224z"},child:[]}]})(r)}function Ke(r){return u({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 128H272l-64-64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V176c0-26.51-21.49-48-48-48z"},child:[]}]})(r)}function j(r){return u({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"},child:[]}]})(r)}function Ge(r){return u({attr:{viewBox:"0 0 16 16",fill:"currentColor"},child:[{tag:"path",attr:{d:"M4.708 5.578L2.061 8.224l2.647 2.646-.708.708-3-3V7.87l3-3 .708.708zm7-.708L11 5.578l2.647 2.646L11 10.87l.708.708 3-3V7.87l-3-3zM4.908 13l.894.448 5-10L9.908 3l-5 10z"},child:[]}]})(r)}function oe(r){return u({attr:{viewBox:"0 0 16 16",fill:"currentColor"},child:[{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M6 2.984V2h-.09c-.313 0-.616.062-.909.185a2.33 2.33 0 0 0-.775.53 2.23 2.23 0 0 0-.493.753v.001a3.542 3.542 0 0 0-.198.83v.002a6.08 6.08 0 0 0-.024.863c.012.29.018.58.018.869 0 .203-.04.393-.117.572v.001a1.504 1.504 0 0 1-.765.787 1.376 1.376 0 0 1-.558.115H2v.984h.09c.195 0 .38.04.556.121l.001.001c.178.078.329.184.455.318l.002.002c.13.13.233.285.307.465l.001.002c.078.18.117.368.117.566 0 .29-.006.58-.018.869-.012.296-.004.585.024.87v.001c.033.283.099.558.197.824v.001c.106.273.271.524.494.753.223.23.482.407.775.53.293.123.596.185.91.185H6v-.984h-.09c-.2 0-.387-.038-.563-.115a1.613 1.613 0 0 1-.457-.32 1.659 1.659 0 0 1-.309-.467c-.074-.18-.11-.37-.11-.573 0-.228.003-.453.011-.672.008-.228.008-.45 0-.665a4.639 4.639 0 0 0-.055-.64 2.682 2.682 0 0 0-.168-.609A2.284 2.284 0 0 0 3.522 8a2.284 2.284 0 0 0 .738-.955c.08-.192.135-.393.168-.602.033-.21.051-.423.055-.64.008-.22.008-.442 0-.666-.008-.224-.012-.45-.012-.678a1.47 1.47 0 0 1 .877-1.354 1.33 1.33 0 0 1 .563-.121H6zm4 10.032V14h.09c.313 0 .616-.062.909-.185.293-.123.552-.3.775-.53.223-.23.388-.48.493-.753v-.001c.1-.266.165-.543.198-.83v-.002c.028-.28.036-.567.024-.863-.012-.29-.018-.58-.018-.869 0-.203.04-.393.117-.572v-.001a1.502 1.502 0 0 1 .765-.787 1.38 1.38 0 0 1 .558-.115H14v-.984h-.09c-.196 0-.381-.04-.557-.121l-.001-.001a1.376 1.376 0 0 1-.455-.318l-.002-.002a1.415 1.415 0 0 1-.307-.465v-.002a1.405 1.405 0 0 1-.118-.566c0-.29.006-.58.018-.869a6.174 6.174 0 0 0-.024-.87v-.001a3.537 3.537 0 0 0-.197-.824v-.001a2.23 2.23 0 0 0-.494-.753 2.331 2.331 0 0 0-.775-.53 2.325 2.325 0 0 0-.91-.185H10v.984h.09c.2 0 .387.038.562.115.174.082.326.188.457.32.127.134.23.29.309.467.074.18.11.37.11.573 0 .228-.003.452-.011.672-.008.228-.008.45 0 .665.004.222.022.435.055.64.033.214.089.416.168.609a2.285 2.285 0 0 0 .738.955 2.285 2.285 0 0 0-.738.955 2.689 2.689 0 0 0-.168.602c-.033.21-.051.423-.055.64a9.15 9.15 0 0 0 0 .666c.008.224.012.45.012.678a1.471 1.471 0 0 1-.877 1.354 1.33 1.33 0 0 1-.563.121H10z"},child:[]}]})(r)}function de(r){return u({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M1.125 0C.502 0 0 .502 0 1.125v21.75C0 23.498.502 24 1.125 24h21.75c.623 0 1.125-.502 1.125-1.125V1.125C24 .502 23.498 0 22.875 0zm17.363 9.75c.612 0 1.154.037 1.627.111a6.38 6.38 0 0 1 1.306.34v2.458a3.95 3.95 0 0 0-.643-.361 5.093 5.093 0 0 0-.717-.26 5.453 5.453 0 0 0-1.426-.2c-.3 0-.573.028-.819.086a2.1 2.1 0 0 0-.623.242c-.17.104-.3.229-.393.374a.888.888 0 0 0-.14.49c0 .196.053.373.156.529.104.156.252.304.443.444s.423.276.696.41c.273.135.582.274.926.416.47.197.892.407 1.266.628.374.222.695.473.963.753.268.279.472.598.614.957.142.359.214.776.214 1.253 0 .657-.125 1.21-.373 1.656a3.033 3.033 0 0 1-1.012 1.085 4.38 4.38 0 0 1-1.487.596c-.566.12-1.163.18-1.79.18a9.916 9.916 0 0 1-1.84-.164 5.544 5.544 0 0 1-1.512-.493v-2.63a5.033 5.033 0 0 0 3.237 1.2c.333 0 .624-.03.872-.09.249-.06.456-.144.623-.25.166-.108.29-.234.373-.38a1.023 1.023 0 0 0-.074-1.089 2.12 2.12 0 0 0-.537-.5 5.597 5.597 0 0 0-.807-.444 27.72 27.72 0 0 0-1.007-.436c-.918-.383-1.602-.852-2.053-1.405-.45-.553-.676-1.222-.676-2.005 0-.614.123-1.141.369-1.582.246-.441.58-.804 1.004-1.089a4.494 4.494 0 0 1 1.47-.629 7.536 7.536 0 0 1 1.77-.201zm-15.113.188h9.563v2.166H9.506v9.646H6.789v-9.646H3.375z"},child:[]}]})(r)}const Xe=(r,l)=>me({queryKey:["file-content",r,l],queryFn:async()=>{if(!r)throw new Error("File path is required");const d=new URLSearchParams;d.append("path",r),l&&d.append("projectPath",l);const h=await _(`${M}/files/read?${d.toString()}`);if(!h.ok)throw h.status===403?new Error("访问被拒绝:文件在项目目录之外"):h.status===404?new Error("文件不存在"):new Error(`读取文件失败 (${h.status})`);return h.json()},enabled:!!r,staleTime:6e4,retry:!1}),Qe=(r,l)=>me({queryKey:["file-tree-lazy",r,l],queryFn:async()=>{if(!r)throw new Error("Project path is required");const d=new URLSearchParams;d.append("path",r),l&&d.append("showHiddenFiles","true");const h=await _(`${M}/files/browse?${d.toString()}`);if(!h.ok)throw new Error("Failed to browse directory");const i=await h.json(),x=[];for(const f of i.items)f.isDirectory?x.push({...f,children:[]}):x.push(f);return x},enabled:!!r,staleTime:3e4});class Ye{events=new Map;on(l,d){this.events.has(l)||this.events.set(l,[]),this.events.get(l).push(d)}off(l,d){const h=this.events.get(l);if(h){const i=h.indexOf(d);i>-1&&h.splice(i,1)}}emit(l,...d){const h=this.events.get(l);h&&h.forEach(i=>{try{i(...d)}catch(x){console.error(`Error in event handler for ${l}:`,x)}})}clear(){this.events.clear()}}const he=new Ye,xe={AI_RESPONSE_COMPLETE:"ai_response_complete",REFRESH_AGENT_CONTENT:"refresh_agent_content"},Ze=c.lazy(()=>Se(()=>import("./monaco-editor-DHKm5-VF.js").then(r=>r.i),[])),et=new Map([["js",e.jsx(Pe,{color:"#f7df1e"},"js")],["jsx",e.jsx(We,{color:"#61dafb"},"jsx")],["ts",e.jsx(de,{color:"#3178c6"},"ts")],["tsx",e.jsx(de,{color:"#3178c6"},"tsx")],["css",e.jsx($e,{color:"#1572b6"},"css")],["html",e.jsx(ie,{color:"#e34f26"},"html")],["htm",e.jsx(ie,{color:"#e34f26"},"htm")],["json",e.jsx(oe,{color:"#f9d71c"},"json")],["jsonl",e.jsx(oe,{color:"#e6a23c"},"jsonl")],["md",e.jsx(_e,{color:"#083fa1"},"md")],["csv",e.jsx(q,{color:"#00a86b"},"csv")],["pdf",e.jsx(Ue,{color:"#d63031"},"pdf")],["ppt",e.jsx(le,{color:"#d63031"},"ppt")],["pptx",e.jsx(le,{color:"#d63031"},"pptx")],["ico",e.jsx(j,{color:"#a9a9a9"},"ico")],["png",e.jsx(j,{color:"#a9a9a9"},"png")],["jpg",e.jsx(j,{color:"#a9a9a9"},"jpg")],["jpeg",e.jsx(j,{color:"#a9a9a9"},"jpeg")],["gif",e.jsx(j,{color:"#a9a9a9"},"gif")],["svg",e.jsx(j,{color:"#a9a9a9"},"svg")],["webp",e.jsx(j,{color:"#a9a9a9"},"webp")],["py",e.jsx(qe,{color:"#3776ab"},"py")],["java",e.jsx(Be,{color:"#007396"},"java")]]),P=({node:r})=>{const l=r.data.isHidden;if(r.data.isDirectory){const x=l?"#9ca3af":"#87b3d6";return r.isOpen?e.jsx(Je,{color:x}):e.jsx(Ke,{color:x})}const d=r.data.name.split(".").pop()?.toLowerCase()||"",h=l?"#9ca3af":"#6d8a9f",i=l?{opacity:.6}:{};return e.jsx("span",{style:i,children:et.get(d)||e.jsx(q,{color:h})})},tt=(r="")=>{const l=r.toLowerCase();if(l==="dockerfile"||l.startsWith("dockerfile."))return"dockerfile";switch(r.split(".").pop()?.toLowerCase()||""){case"js":case"jsx":return"javascript";case"ts":case"tsx":return"typescript";case"css":case"scss":case"sass":case"less":return"css";case"json":case"jsonl":return"json";case"html":case"htm":return"html";case"md":case"markdown":return"markdown";case"csv":return"csv";case"py":return"python";case"java":return"java";case"xml":return"xml";case"yaml":case"yml":return"yaml";case"sh":case"bash":return"shell";case"conf":case"config":case"ini":return"ini";case"nginx":return"nginx";case"sql":return"sql";case"go":return"go";case"rs":return"rust";case"c":case"cpp":case"cc":case"cxx":return"cpp";case"h":case"hpp":return"cpp";case"cs":return"csharp";case"php":return"php";case"rb":return"ruby";case"swift":return"swift";case"kt":return"kotlin";case"dockerfile":return"dockerfile";default:return"plaintext"}},rt=({imageUrl:r,fileName:l})=>{const{t:d}=ue("components"),[h,i]=c.useState(!0),[x,f]=c.useState(!1);return e.jsx("div",{className:"flex items-center justify-center h-full p-4",children:x?e.jsxs("div",{className:"text-center text-gray-500",children:[e.jsx(j,{className:"w-12 h-12 mx-auto mb-4 text-gray-300"}),e.jsx("p",{children:d("fileExplorer.imageLoadFailed")}),e.jsx("p",{className:"text-sm mt-2",children:l})]}):e.jsxs("div",{className:"relative max-w-full max-h-full",children:[h&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(T,{className:"w-8 h-8 animate-spin text-gray-400"})}),e.jsx("img",{src:r,alt:l,className:"max-w-full max-h-full object-contain bg-white dark:bg-gray-900 rounded shadow-lg",onLoad:()=>i(!1),onError:()=>{i(!1),f(!0)},style:{display:x?"none":"block"}})]})})},st=r=>{const l=r.toLowerCase();if(l==="dockerfile"||l.startsWith("dockerfile."))return"text";const d=r.split(".").pop()?.toLowerCase()||"",h=["js","jsx","ts","tsx","css","scss","sass","less","html","htm","json","jsonl","md","markdown","txt","py","java","xml","yaml","yml","sh","bash","bat","cmd","php","rb","go","rs","cpp","c","h","hpp","cc","cxx","cs","swift","kt","scala","clj","sql","dockerfile","gitignore","env","csv","tsv","conf","config","ini","toml","nginx","apache","properties","cfg"],i=["png","jpg","jpeg","gif","svg","webp","ico","bmp","tiff"];return h.includes(d)?"text":i.includes(d)?"image":"binary"},at=({node:r,style:l,dragHandle:d,isLoading:h=!1,onDirectoryToggle:i,onFileSelect:x})=>{const f=c.useCallback(y=>{y.preventDefault(),y.stopPropagation(),r.data.isDirectory?i?.(r):x?.(r)},[r,i,x]);return e.jsxs("div",{style:l,ref:d,className:`flex items-center cursor-pointer px-3 py-1.5 hover:bg-gray-100 dark:hover:bg-gray-700 ${r.isSelected?"bg-blue-100 dark:bg-blue-900/30 text-blue-900 dark:text-blue-300":"text-gray-700 dark:text-gray-300"}`,onClick:f,children:[r.data.isDirectory&&e.jsx("span",{className:"mr-1 flex items-center",children:h?e.jsx(T,{className:"w-3 h-3 animate-spin text-gray-400"}):e.jsx(Ve,{className:`w-3 h-3 transition-transform text-gray-400 ${r.isOpen?"rotate-90":""}`})}),e.jsx("span",{className:"mr-2 flex items-center",children:e.jsx(P,{node:r})}),e.jsx("span",{className:`text-sm truncate flex-1 ${r.data.isHidden?"text-gray-400 dark:text-gray-500 italic":"text-gray-700 dark:text-gray-300"}`,children:r.data.name}),!r.data.isDirectory&&r.data.size&&e.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500 ml-2",children:[(r.data.size/1024).toFixed(1),"KB"]})]})},F=5,mt=({projectPath:r,onFileSelect:l,className:d="",height:h="100vh"})=>{const{t:i}=ue("components"),[x,f]=c.useState([]),[y,D]=c.useState(null),[fe,W]=c.useState(600),[z,A]=c.useState(!1),k=c.useRef(null),R=c.useRef(null),I=c.useRef(null),[U,ge]=c.useState(0),[J,pe]=c.useState(""),[ye,ve]=c.useState(document.documentElement.classList.contains("dark")),[L,S]=c.useState(new Set),[N,K]=c.useState([]),[O,H]=c.useState(new Set),[g,je]=c.useState(!1),[G,X]=c.useState(!1),{data:E,isLoading:V,error:Q,refetch:C}=Qe(r,g),p=c.useMemo(()=>x.find(t=>t.isActive)||null,[x]),{data:Y,isLoading:be,error:Z}=Xe(p?p.path:void 0,r);c.useEffect(()=>{const t=new MutationObserver(s=>{s.forEach(o=>{o.attributeName==="class"&&ve(document.documentElement.classList.contains("dark"))})});return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]),c.useEffect(()=>{if(E){const t=m=>m.filter(a=>g||!a.isHidden).map(a=>({id:a.path,name:a.name,path:a.path,isDirectory:a.isDirectory,size:a.size,modified:a.modified,isHidden:a.isHidden,children:a.children?t(a.children):void 0})),s=(m,a=new Set)=>(m.forEach(n=>{n.isDirectory&&n.children&&n.children.length>0&&(a.add(n.path),s(n.children,a))}),a),o=s(E);S(o),K(t(E))}},[E,g]);const ee=c.useCallback(async t=>{if(!(L.has(t)||O.has(t))){H(s=>new Set(s).add(t));try{const s=new URLSearchParams;s.append("path",t),g&&s.append("showHiddenFiles","true");const o=await _(`${M}/files/browse?${s.toString()}`);if(!o.ok)throw new Error("Failed to browse directory");const m=await o.json(),a=[];for(const n of m.items)n.isDirectory?a.push({...n,children:[]}):a.push(n);K(n=>{const b=Le=>Le.map(w=>w.path===t?{...w,children:a.map(v=>({id:v.path,name:v.name,path:v.path,isDirectory:v.isDirectory,size:v.size,modified:v.modified,isHidden:v.isHidden,children:v.isDirectory?[]:void 0}))}:w.children?{...w,children:b(w.children)}:w);return b(n)}),S(n=>new Set(n).add(t)),I.current&&a.length>0&&a.forEach(n=>{n.isDirectory&&I.current?.close(n.path)})}catch(s){throw console.error("Failed to load directory children:",s),s}finally{H(s=>{const o=new Set(s);return o.delete(t),o})}}},[L,O,g]),$=c.useCallback(()=>{S(new Set),H(new Set),C()},[C]),we=c.useCallback(()=>{je(t=>!t)},[]);c.useEffect(()=>{S(new Set),H(new Set),C()},[g,C]),c.useEffect(()=>{const t=()=>{if(k.current){const m=k.current.getBoundingClientRect(),a=m.height>0?m.height:600;W(a)}};let s=null;k.current&&(s=new ResizeObserver(m=>{for(const a of m){const{height:n}=a.contentRect;n>0&&W(n)}}),s.observe(k.current));const o=setTimeout(t,100);return window.addEventListener("resize",t),()=>{clearTimeout(o),window.removeEventListener("resize",t),s&&s.disconnect()}},[E]),c.useEffect(()=>{const t=s=>{R.current&&!R.current.contains(s.target)&&A(!1)};if(z)return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[z]),c.useEffect(()=>{const t=s=>{console.log("🔄 Received AI_RESPONSE_COMPLETE event in FileExplorer:",s),s.projectPath===r&&(console.log("🔄 Auto-refreshing file tree after AI response completion"),$())};return he.on(xe.AI_RESPONSE_COMPLETE,t),()=>{he.off(xe.AI_RESPONSE_COMPLETE,t)}},[r,$]);const te=N,ke=c.useMemo(()=>{const t={},s=o=>{o.forEach(m=>{m.isDirectory&&(t[m.id]=!1,m.children&&s(m.children))})};return N&&N.length>0&&s(N),t},[N]),re=c.useCallback((t,s=!1)=>({id:`tab-${t.path}`,name:t.name,path:t.path,isPinned:s,isActive:!1}),[]),B=c.useCallback((t,s=!1)=>{f(o=>{const m=o.findIndex(a=>a.path===t.path);if(m!==-1)return o.map((a,n)=>({...a,isActive:n===m,isPinned:s||a.isPinned}));{const a=re(t,s);return!s&&y?(D(a.id),o.map(n=>n.id===y?{...a,isActive:!0}:{...n,isActive:!1})):(s||D(a.id),[...o.map(n=>({...n,isActive:!1})),{...a,isActive:!0}])}}),l?.(t.path)},[re,y,l]),se=c.useCallback(t=>{f(s=>{const o=s.findIndex(n=>n.id===t);if(o===-1)return s;const m=s[o],a=s.filter(n=>n.id!==t);if(m.isActive&&a.length>0){const n=Math.min(o,a.length-1);a[n]={...a[n],isActive:!0}}return y===t&&D(null),a})},[y]),ae=c.useCallback(t=>{f(s=>s.map(o=>({...o,isActive:o.id===t})))},[]),[ce,Ne]=c.useState({}),Ee=c.useCallback(t=>{const s=Date.now(),o=ce[t.data.path]||0;if(s-o<300)return;Ne(b=>({...b,[t.data.path]:s}));const m=t.isOpen,a=t.data.children&&t.data.children.length>0,n=L.has(t.data.path);m?t.close():!a&&!n?(t.open(),ee(t.data.path).catch(b=>{console.error("Failed to load directory children:",b),t.close()})):t.open()},[ce,L,ee]),Ce=c.useCallback(t=>{t.select();const s=Date.now(),o=s-U<300&&J===t.data.path;ge(s),pe(t.data.path),o?B(t.data,!0):setTimeout(()=>{Date.now()-s>=300&&B(t.data,!1)},300)},[B,U,J]),ze=()=>{if(!p)return e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(q,{className:"w-12 h-12 mx-auto mb-4 text-gray-300 dark:text-gray-600"}),e.jsx("p",{children:i("fileExplorer.selectFile")})]})});if(be)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400",children:[e.jsx(T,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:i("fileExplorer.loading")})]})});if(Z)return e.jsx("div",{className:"flex items-center justify-center h-full text-red-500 dark:text-red-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:i("fileExplorer.loadFailed")}),e.jsx("p",{className:"text-sm mt-2 bg-red-50 dark:bg-red-900/30 px-3 py-2 rounded border border-red-200 dark:border-red-800",children:Z.message}),e.jsx("p",{className:"text-xs mt-2 text-gray-500 dark:text-gray-400",children:p.path})]})});switch(st(p.name)){case"image":const s=new URLSearchParams;s.append("path",p.path),r&&s.append("projectPath",r),s.append("binary","true");const o=`${M}/files/read?${s.toString()}`;return e.jsx(rt,{imageUrl:o,fileName:p.name});case"text":return Y?e.jsx(Fe.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-gray-900"})}),children:e.jsx(Ze,{height:"100%",theme:ye?"vs-dark":"vs-light",language:tt(p.name),value:Y.content,options:{readOnly:!0,minimap:{enabled:!1},fontSize:14,wordWrap:"on",scrollBeyondLastLine:!1}})}):e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:i("fileExplorer.cannotReadFile")})});default:return e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Ge,{className:"w-12 h-12 mx-auto mb-4 text-gray-300 dark:text-gray-600"}),e.jsx("p",{children:i("fileExplorer.previewNotSupported")}),e.jsxs("p",{className:"text-sm mt-2",children:[i("fileExplorer.fileLabel"),": ",p.name]})]})})}};return Q?e.jsx("div",{className:`flex items-center justify-center h-full text-red-500 dark:text-red-400 ${d}`,style:{height:h},children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:i("fileExplorer.loadFailed")}),e.jsx("p",{className:"text-sm mt-2 bg-red-50 dark:bg-red-900/30 px-3 py-2 rounded border border-red-200 dark:border-red-800",children:Q.message}),e.jsxs("p",{className:"text-xs mt-2 text-gray-500 dark:text-gray-400",children:[i("fileExplorer.projectPath"),": ",r]}),e.jsx("button",{onClick:()=>C(),className:"mt-4 px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors",children:i("fileExplorer.retry")})]})}):e.jsxs("div",{className:`flex h-full bg-gray-50 dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden ${d}`,children:[!G&&e.jsxs("div",{className:"w-80 border-r border-gray-200 dark:border-gray-700 flex flex-col h-full",children:[e.jsx("div",{className:"h-12 px-3 border-b border-gray-200 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 flex items-center flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:i("fileExplorer.title")}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("button",{onClick:we,className:`p-1.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors ${g?"text-blue-600 dark:text-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"}`,title:g?"隐藏文件和文件夹":"显示隐藏文件和文件夹",children:g?e.jsx(Te,{className:"w-4 h-4"}):e.jsx(Me,{className:"w-4 h-4"})}),e.jsx("button",{onClick:$,className:"p-1.5 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:i("common:actions.refresh"),disabled:V,children:e.jsx(De,{className:`w-4 h-4 ${V?"animate-spin":""}`})}),e.jsx("button",{onClick:()=>X(!0),className:"p-1.5 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:i("fileExplorer.collapsePanel"),children:e.jsx(Ae,{className:"w-4 h-4"})})]})]})}),e.jsx("div",{ref:k,className:"flex-1 min-h-0 pl-2",children:V?e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400",children:[e.jsx(T,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:i("fileExplorer.loading")})]})}):te.length===0?e.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400",children:e.jsx("p",{className:"text-sm",children:i("fileExplorer.emptyDirectory")})}):e.jsx(He,{data:te,width:320,height:fe,indent:20,rowHeight:36,initialOpenState:ke,ref:I,children:t=>e.jsx(at,{...t,isLoading:O.has(t.node.data.path),onDirectoryToggle:Ee,onFileSelect:Ce})})})]}),e.jsxs("div",{className:"flex-1 flex flex-col h-full",children:[e.jsxs("div",{className:"h-12 border-b border-gray-200 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 flex items-center flex-shrink-0",children:[G&&e.jsx("button",{onClick:()=>X(!1),className:"p-1.5 mx-2 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded transition-colors",title:i("fileExplorer.expandPanel"),children:e.jsx(Re,{className:"w-4 h-4"})}),x.length>0?e.jsxs("div",{className:"flex items-center h-full w-full",children:[e.jsx("div",{className:"flex items-center h-full flex-1",children:x.slice(0,Math.min(F,x.length)).map(t=>e.jsxs("div",{className:`group relative flex items-center h-full px-3 border-r border-gray-200 dark:border-gray-700 cursor-pointer transition-colors ${t.isActive?"bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-white":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"} ${t.isPinned?"":"italic"}`,onClick:()=>ae(t.id),title:`${t.path} ${t.isPinned?"(固定)":"(临时)"}`,style:{minWidth:"120px",maxWidth:"180px"},children:[e.jsx(P,{node:{data:{name:t.name,isDirectory:!1},isOpen:!1}}),e.jsx("span",{className:"ml-2 text-sm truncate flex-1",children:t.name}),!t.isPinned&&e.jsx("span",{className:"ml-1 text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:"•"}),e.jsx("button",{className:"ml-2 p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-gray-600 transition-opacity flex-shrink-0",onClick:s=>{s.stopPropagation(),se(t.id)},title:i("common:actions.close"),children:e.jsx(ne,{className:"w-3 h-3"})})]},t.id))}),x.length>F&&e.jsxs("div",{className:"relative",ref:R,children:[e.jsxs("button",{className:"flex items-center h-full px-3 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-gray-900 dark:hover:text-white transition-colors border-l border-gray-200 dark:border-gray-700",onClick:()=>A(!z),title:`${x.length-F} more tabs`,children:[e.jsx(Ie,{className:"w-4 h-4"}),e.jsx(Oe,{className:"w-3 h-3 ml-1"})]}),z&&e.jsx("div",{className:"absolute top-full right-0 mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-50 min-w-48 max-h-64 overflow-y-auto",children:x.slice(F).map(t=>e.jsxs("div",{className:`flex items-center px-3 py-2 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-700 ${t.isActive?"bg-blue-50 dark:bg-blue-900/30 text-blue-900 dark:text-blue-300":"text-gray-700 dark:text-gray-300"} ${t.isPinned?"":"italic"}`,onClick:()=>{ae(t.id),A(!1)},title:`${t.path} ${t.isPinned?"(固定)":"(临时)"}`,children:[e.jsx(P,{node:{data:{name:t.name,isDirectory:!1},isOpen:!1}}),e.jsx("span",{className:"ml-2 truncate flex-1",children:t.name}),!t.isPinned&&e.jsx("span",{className:"ml-1 text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:"•"}),e.jsx("button",{className:"ml-2 p-1 rounded opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-gray-600 transition-opacity flex-shrink-0",onClick:s=>{s.stopPropagation(),se(t.id)},title:i("common:actions.close"),children:e.jsx(ne,{className:"w-3 h-3"})})]},t.id))})]})]}):e.jsx("div",{className:"flex items-center justify-center w-full h-full text-gray-500 dark:text-gray-400",children:e.jsx("span",{className:"text-sm",children:i("fileExplorer.noFiles")})})]}),e.jsx("div",{className:"flex-1 bg-gray-50 dark:bg-gray-900 min-h-0",children:ze()})]})]})};export{xe as E,mt as F,he as e};
@@ -1 +1 @@
1
- import{j as e}from"./data-structures-C0h9Oap1.js";import{r as d}from"./monaco-editor-DHKm5-VF.js";import{u as m}from"./index-Bn3v3S9-.js";import{u as o}from"./tools-IcPNZlPj.js";import{M as x,w as h,x as b,G as u}from"./ui-components-D1St49qC.js";import"./syntax-highlighting-CnREyncB.js";import"./agents-ChrA1R0y.js";const $=()=>{const{t:r,i18n:l}=o("pages"),{isMobile:t}=m(),[s,g]=d.useState(()=>localStorage.getItem("theme")||"auto"),[i,n]=d.useState(l.language);d.useEffect(()=>{n(l.language)},[l.language]),d.useEffect(()=>{(()=>{s==="dark"?document.documentElement.classList.add("dark"):s==="light"?document.documentElement.classList.remove("dark"):window.matchMedia("(prefers-color-scheme: dark)").matches?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")})(),localStorage.setItem("theme",s),window.dispatchEvent(new Event("themechange"))},[s]);const c=a=>{n(a),l.changeLanguage(a)};return e.jsxs("div",{className:`${t?"space-y-4":"space-y-6"}`,children:[e.jsxs("div",{children:[e.jsx("h2",{className:`${t?"text-xl":"text-2xl"} font-bold text-gray-900 dark:text-white mb-2`,children:r("settings.general.title")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:r("settings.general.description")})]}),e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 ${t?"p-4":"p-6"}`,children:[e.jsx("h3",{className:`${t?"text-base":"text-lg"} font-semibold text-gray-900 dark:text-white mb-4`,children:r("settings.general.interfaceSettings")}),e.jsxs("div",{className:`${t?"space-y-4":"space-y-6"}`,children:[e.jsxs("div",{children:[e.jsx("label",{className:"block font-medium text-gray-900 dark:text-white mb-3",children:r("settings.general.theme.label")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-4",children:r("settings.general.theme.description")}),e.jsx("div",{className:`${t?"grid grid-cols-1 gap-3":"grid grid-cols-3 gap-3"}`,children:[{value:"auto",label:r("settings.general.theme.auto"),icon:x},{value:"light",label:r("settings.general.theme.light"),icon:h},{value:"dark",label:r("settings.general.theme.dark"),icon:b}].map(a=>e.jsxs("button",{onClick:()=>g(a.value),className:`${t?"p-3":"p-4"} border-2 rounded-lg flex items-center ${t?"flex-row space-x-3":"flex-col space-y-2"} transition-all ${s===a.value?"border-blue-500 bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":"border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-600 dark:text-gray-300 hover:border-gray-300 dark:hover:border-gray-500"}`,children:[e.jsx(a.icon,{className:`${t?"w-5 h-5":"w-6 h-6"}`}),e.jsx("span",{className:"text-sm font-medium",children:a.label})]},a.value))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block font-medium text-gray-900 dark:text-white mb-3 flex items-center space-x-2",children:[e.jsx(u,{className:`${t?"w-4 h-4":"w-5 h-5"}`}),e.jsx("span",{children:r("settings.general.language.label")})]}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-4",children:r("settings.general.language.description")}),e.jsx("div",{className:`${t?"grid grid-cols-1 gap-3":"grid grid-cols-2 gap-3"}`,children:[{value:"zh-CN",label:"中文简体",flag:"🇨🇳"},{value:"en-US",label:"English",flag:"🇺🇸"}].map(a=>e.jsxs("button",{onClick:()=>c(a.value),className:`${t?"p-3":"p-4"} border-2 rounded-lg flex items-center space-x-3 transition-all ${i===a.value?"border-blue-500 bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":"border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-600 dark:text-gray-300 hover:border-gray-300 dark:hover:border-gray-500"}`,children:[e.jsx("span",{className:`${t?"text-xl":"text-2xl"}`,children:a.flag}),e.jsx("span",{className:"text-sm font-medium",children:a.label})]},a.value))})]})]})]})]})};export{$ as GeneralSettingsPage};
1
+ import{j as e}from"./data-structures-C0h9Oap1.js";import{r as d}from"./monaco-editor-DHKm5-VF.js";import{b as m}from"./index-C8oBHB0h.js";import{u as o}from"./tools-CUwQTL-8.js";import{H as x,I as b,J as h,G as u}from"./ui-components-icUM6BEH.js";import"./syntax-highlighting-CnREyncB.js";import"./agents-B3InAIfY.js";const $=()=>{const{t:r,i18n:l}=o("pages"),{isMobile:t}=m(),[s,g]=d.useState(()=>localStorage.getItem("theme")||"auto"),[i,n]=d.useState(l.language);d.useEffect(()=>{n(l.language)},[l.language]),d.useEffect(()=>{(()=>{s==="dark"?document.documentElement.classList.add("dark"):s==="light"?document.documentElement.classList.remove("dark"):window.matchMedia("(prefers-color-scheme: dark)").matches?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")})(),localStorage.setItem("theme",s),window.dispatchEvent(new Event("themechange"))},[s]);const c=a=>{n(a),l.changeLanguage(a)};return e.jsxs("div",{className:`${t?"space-y-4":"space-y-6"}`,children:[e.jsxs("div",{children:[e.jsx("h2",{className:`${t?"text-xl":"text-2xl"} font-bold text-gray-900 dark:text-white mb-2`,children:r("settings.general.title")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:r("settings.general.description")})]}),e.jsxs("div",{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 ${t?"p-4":"p-6"}`,children:[e.jsx("h3",{className:`${t?"text-base":"text-lg"} font-semibold text-gray-900 dark:text-white mb-4`,children:r("settings.general.interfaceSettings")}),e.jsxs("div",{className:`${t?"space-y-4":"space-y-6"}`,children:[e.jsxs("div",{children:[e.jsx("label",{className:"block font-medium text-gray-900 dark:text-white mb-3",children:r("settings.general.theme.label")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-4",children:r("settings.general.theme.description")}),e.jsx("div",{className:`${t?"grid grid-cols-1 gap-3":"grid grid-cols-3 gap-3"}`,children:[{value:"auto",label:r("settings.general.theme.auto"),icon:x},{value:"light",label:r("settings.general.theme.light"),icon:b},{value:"dark",label:r("settings.general.theme.dark"),icon:h}].map(a=>e.jsxs("button",{onClick:()=>g(a.value),className:`${t?"p-3":"p-4"} border-2 rounded-lg flex items-center ${t?"flex-row space-x-3":"flex-col space-y-2"} transition-all ${s===a.value?"border-blue-500 bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":"border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-600 dark:text-gray-300 hover:border-gray-300 dark:hover:border-gray-500"}`,children:[e.jsx(a.icon,{className:`${t?"w-5 h-5":"w-6 h-6"}`}),e.jsx("span",{className:"text-sm font-medium",children:a.label})]},a.value))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block font-medium text-gray-900 dark:text-white mb-3 flex items-center space-x-2",children:[e.jsx(u,{className:`${t?"w-4 h-4":"w-5 h-5"}`}),e.jsx("span",{children:r("settings.general.language.label")})]}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-4",children:r("settings.general.language.description")}),e.jsx("div",{className:`${t?"grid grid-cols-1 gap-3":"grid grid-cols-2 gap-3"}`,children:[{value:"zh-CN",label:"中文简体",flag:"🇨🇳"},{value:"en-US",label:"English",flag:"🇺🇸"}].map(a=>e.jsxs("button",{onClick:()=>c(a.value),className:`${t?"p-3":"p-4"} border-2 rounded-lg flex items-center space-x-3 transition-all ${i===a.value?"border-blue-500 bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":"border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-600 dark:text-gray-300 hover:border-gray-300 dark:hover:border-gray-500"}`,children:[e.jsx("span",{className:`${t?"text-xl":"text-2xl"}`,children:a.flag}),e.jsx("span",{className:"text-sm font-medium",children:a.label})]},a.value))})]})]})]})]})};export{$ as GeneralSettingsPage};