tide-commander 1.35.0 → 1.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/assets/{BossLogsModal-B_dgVF7L.js → BossLogsModal-B6meUM1T.js} +1 -1
  2. package/dist/assets/BossSpawnModal-DzWs1NNZ.js +1 -0
  3. package/dist/assets/{ControlsModal-WMTTqbca.js → ControlsModal-D2QDZ20h.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-THzhLHch.js → DockerLogsModal-Bh1ghgFV.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-DWLKJYav.js → EmbeddedEditor-C4rKc9Ys.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-DN9ceaS6.js → GmailOAuthSetup-E5_WFtyX.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-bVST2EOB.js → GoogleOAuthSetup-B7NLxSSp.js} +1 -1
  8. package/dist/assets/{IframeModal-BELsjvgi.js → IframeModal-CGbINL-o.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-DwDr4BRt.js → IntegrationsPanel-DZmbjiXV.js} +2 -2
  10. package/dist/assets/{LogViewerModal-CMe04PO5.js → LogViewerModal-KI2L074n.js} +1 -1
  11. package/dist/assets/{MonitoringModal-CqSalNeY.js → MonitoringModal-CWqjvTra.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-CCmCDxVt.js → PM2LogsModal-DRHybuUO.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-IfzPidIv.js → RestoreArchivedAreaModal-DjpKSz7P.js} +1 -1
  14. package/dist/assets/{SaveSnapshotModal-DUhrVD5l.js → SaveSnapshotModal-CWtf3rgg.js} +1 -1
  15. package/dist/assets/Scene2DCanvas-CSfRDtXw.js +1 -0
  16. package/dist/assets/SceneManager-Do4NpOsy.js +104 -0
  17. package/dist/assets/{SkillsPanel-CPFOI4Tl.js → SkillsPanel-BqZSNfNW.js} +3 -3
  18. package/dist/assets/{SnapshotManager-Cbu0tJBz.js → SnapshotManager-DyqyIhWz.js} +1 -1
  19. package/dist/assets/SpawnModal-CGFj_b9I.js +1 -0
  20. package/dist/assets/SubordinateAssignmentModal-DGFoupVt.js +1 -0
  21. package/dist/assets/{SupervisorPanel-BvX-dlk_.js → SupervisorPanel-B1PVopnm.js} +1 -1
  22. package/dist/assets/{TriggerManagerPanel-RUVFmKmf.js → TriggerManagerPanel-CFez7_vm.js} +2 -2
  23. package/dist/assets/{WorkflowEditorPanel-CwZpEqzM.js → WorkflowEditorPanel-ClMl5U8g.js} +1 -1
  24. package/dist/assets/{index-DDPUtz8-.js → index-B4SUGrVB.js} +1 -1
  25. package/dist/assets/{index-CiD1Rwaq.js → index-BK3kI8Cb.js} +1 -1
  26. package/dist/assets/{index-BFguOWBW.js → index-Bf3KKyiV.js} +2 -2
  27. package/dist/assets/{index-D4nfDvz4.js → index-Bmu_CPsU.js} +3 -3
  28. package/dist/assets/index-CbzHGOPP.js +1 -0
  29. package/dist/assets/index-CpZt7iSV.js +1 -0
  30. package/dist/assets/{index-B-wV06cR.js → index-CxtzptPF.js} +5 -5
  31. package/dist/assets/{index-EH8IBvSU.js → index-D2_-BBP8.js} +3 -3
  32. package/dist/assets/main-C6uuUPJ0.css +1 -0
  33. package/dist/assets/main-CtGyoZXd.js +152 -0
  34. package/dist/assets/{web-D1vWYL8u.js → web-C2JUUvGB.js} +1 -1
  35. package/dist/assets/{web-DUq3Undh.js → web-D4EcUHSn.js} +1 -1
  36. package/dist/index.html +2 -2
  37. package/dist/src/packages/server/routes/agents.js +209 -1
  38. package/dist/src/packages/server/routes/areas.js +25 -0
  39. package/dist/src/packages/server/routes/index.js +2 -0
  40. package/dist/src/packages/server/routes/workspaces.js +123 -0
  41. package/dist/src/packages/server/services/agent-service.js +87 -1
  42. package/dist/src/packages/server/services/area-layout-service.js +260 -0
  43. package/dist/src/packages/server/services/workspace-service.js +104 -0
  44. package/package.json +1 -1
  45. package/dist/assets/BossSpawnModal-CSO1bYxA.js +0 -1
  46. package/dist/assets/Scene2DCanvas-Bl5DUC7w.js +0 -1
  47. package/dist/assets/SceneManager-BGO9tiaI.js +0 -104
  48. package/dist/assets/SpawnModal-BqDbsYLY.js +0 -1
  49. package/dist/assets/SubordinateAssignmentModal-DOqkhL_L.js +0 -1
  50. package/dist/assets/camera-D_KeL_pz.js +0 -1
  51. package/dist/assets/index-C7gqY2AA.js +0 -1
  52. package/dist/assets/index-H0PzHVFw.js +0 -1
  53. package/dist/assets/main-Cjm0d8dZ.js +0 -152
  54. package/dist/assets/main-DqC9_fF4.css +0 -1
@@ -1,8 +1,8 @@
1
- import{ae as sa,u as E,j as e,N as v,ah as Fs,ai as $s,O as He,s as P,aj as Ms,D as q,a0 as ee,a1 as Ge,f as aa,ak as ta,r as o,J as na,S as la,h as ia,a2 as Ke}from"./main-Cjm0d8dZ.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ra=[{value:"",labelKey:"terminal:building.colorDefault"},{value:"#2a2a3a",labelKey:"terminal:building.colorDarkGray"},{value:"#3a2a2a",labelKey:"terminal:building.colorDarkRed"},{value:"#2a3a2a",labelKey:"terminal:building.colorDarkGreen"},{value:"#2a2a4a",labelKey:"terminal:building.colorDarkBlue"},{value:"#3a3a2a",labelKey:"terminal:building.colorDarkYellow"},{value:"#3a2a3a",labelKey:"terminal:building.colorDarkPurple"},{value:"#2a3a3a",labelKey:"terminal:building.colorDarkCyan"},{value:"#4a3a3a",labelKey:"terminal:building.colorWarmBrown"},{value:"#3a4a4a",labelKey:"terminal:building.colorCoolSteel"}];function oa(a){return sa.t(a)}function Ve(a){if(a===0)return"0 B";const l=1024,c=["B","KB","MB","GB"],h=Math.floor(Math.log(a)/Math.log(l));return parseFloat((a/Math.pow(l,h)).toFixed(1))+" "+c[h]}function ca(a){const c=Date.now()-a,h=Math.floor(c/(1e3*60*60)),t=Math.floor(c%(1e3*60*60)/(1e3*60));return h>0?`${h}h ${t}m`:`${t}m`}const Us={30:"#1a1a1a",31:"#e74c3c",32:"#2ecc71",33:"#f39c12",34:"#3498db",35:"#9b59b6",36:"#00bcd4",37:"#ecf0f1",90:"#7f8c8d",91:"#ff6b6b",92:"#4ade80",93:"#fbbf24",94:"#60a5fa",95:"#c084fc",96:"#22d3ee",97:"#ffffff"};function Ks(a){const l=[],c=/\x1B\[([0-9;]*)m/g;let h=0,t=null,r;for(;(r=c.exec(a))!==null;){if(r.index>h){const m=a.slice(h,r.index);t?l.push(e.jsx("span",{style:{color:t},children:m},l.length)):l.push(m)}const g=r[1].split(";").map(Number);for(const m of g)m===0||m===39?t=null:Us[m]&&(t=Us[m]);h=c.lastIndex}if(h<a.length){const g=a.slice(h);t?l.push(e.jsx("span",{style:{color:t},children:g},l.length)):l.push(g)}return l.length>0?l:[a]}function ma({buildingName:a,onClose:l,onConfirm:c}){const{t:h}=E(["terminal","common"]);return e.jsx("div",{className:"modal-overlay visible",onClick:l,children:e.jsxs("div",{className:"modal confirm-modal",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:h("terminal:building.deleteBuilding")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:h("terminal:building.deleteConfirm",{name:a})}),e.jsx("p",{className:"confirm-modal-note",children:h("terminal:building.deleteNote")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:l,children:h("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-danger",onClick:c,autoFocus:!0,children:h("common:buttons.delete")})]})]})})}function da({usePM2:a,setUsePM2:l}){const{t:c}=E(["terminal"]);return e.jsxs("div",{className:"form-section pm2-toggle-section",children:[e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",className:"toggle-input",checked:a,onChange:h=>l(h.target.checked)}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})}),e.jsxs("span",{className:"toggle-label",children:[e.jsx("span",{className:"pm2-badge",children:"PM2"}),c("terminal:building.usePM2")]})]}),e.jsx("div",{className:"form-hint",children:c("terminal:building.pm2Hint")})]})}function ua({usePM2:a,pm2Script:l,setPm2Script:c,pm2Args:h,setPm2Args:t,pm2Interpreter:r,setPm2Interpreter:g,pm2InterpreterArgs:m,setPm2InterpreterArgs:d,pm2Env:s,setPm2Env:u,isEditMode:b,building:x,handleCommand:N}){var y;const{t:p}=E(["terminal","common"]);return a?e.jsxs("div",{className:"form-section pm2-config-section",children:[e.jsx("label",{className:"form-label",children:p("terminal:building.pm2Configuration")}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Script"),e.jsx(v,{text:p("terminal:building.helpPm2Script"),title:p("terminal:building.pm2Script"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:l,onChange:j=>c(j.target.value),placeholder:"npm, java, python, ./app.js",required:a})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Arguments"),e.jsx(v,{text:p("terminal:building.helpPm2Arguments"),title:p("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:h,onChange:j=>t(j.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Interpreter"),e.jsx(v,{text:p("terminal:building.helpPm2Interpreter"),title:p("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:r,onChange:j=>g(j.target.value),children:Object.keys(Fs).map(j=>e.jsx("option",{value:j,children:Fs[j].label},j))})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2InterpArgs"),e.jsx(v,{text:p("terminal:building.helpPm2InterpArgs"),title:p("terminal:building.pm2InterpArgs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:m,onChange:j=>d(j.target.value),placeholder:"-jar (for Java)"})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Environment"),e.jsx(v,{text:p("terminal:building.helpPm2Environment"),title:p("terminal:building.pm2Environment"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:s,onChange:j=>u(j.target.value),placeholder:`KEY=value
1
+ import{ak as sa,u as E,j as e,X as v,an as Fs,ao as $s,Y as He,s as P,ap as Ms,D as V,a6 as ee,a7 as Ge,f as aa,aq as ta,r,P as na,S as la,h as ia,a8 as Ke}from"./main-CtGyoZXd.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const oa=[{value:"",labelKey:"terminal:building.colorDefault"},{value:"#2a2a3a",labelKey:"terminal:building.colorDarkGray"},{value:"#3a2a2a",labelKey:"terminal:building.colorDarkRed"},{value:"#2a3a2a",labelKey:"terminal:building.colorDarkGreen"},{value:"#2a2a4a",labelKey:"terminal:building.colorDarkBlue"},{value:"#3a3a2a",labelKey:"terminal:building.colorDarkYellow"},{value:"#3a2a3a",labelKey:"terminal:building.colorDarkPurple"},{value:"#2a3a3a",labelKey:"terminal:building.colorDarkCyan"},{value:"#4a3a3a",labelKey:"terminal:building.colorWarmBrown"},{value:"#3a4a4a",labelKey:"terminal:building.colorCoolSteel"}];function ra(a){return sa.t(a)}function qe(a){if(a===0)return"0 B";const l=1024,c=["B","KB","MB","GB"],h=Math.floor(Math.log(a)/Math.log(l));return parseFloat((a/Math.pow(l,h)).toFixed(1))+" "+c[h]}function ca(a){const c=Date.now()-a,h=Math.floor(c/(1e3*60*60)),t=Math.floor(c%(1e3*60*60)/(1e3*60));return h>0?`${h}h ${t}m`:`${t}m`}const Us={30:"#1a1a1a",31:"#e74c3c",32:"#2ecc71",33:"#f39c12",34:"#3498db",35:"#9b59b6",36:"#00bcd4",37:"#ecf0f1",90:"#7f8c8d",91:"#ff6b6b",92:"#4ade80",93:"#fbbf24",94:"#60a5fa",95:"#c084fc",96:"#22d3ee",97:"#ffffff"};function Ks(a){const l=[],c=/\x1B\[([0-9;]*)m/g;let h=0,t=null,o;for(;(o=c.exec(a))!==null;){if(o.index>h){const m=a.slice(h,o.index);t?l.push(e.jsx("span",{style:{color:t},children:m},l.length)):l.push(m)}const g=o[1].split(";").map(Number);for(const m of g)m===0||m===39?t=null:Us[m]&&(t=Us[m]);h=c.lastIndex}if(h<a.length){const g=a.slice(h);t?l.push(e.jsx("span",{style:{color:t},children:g},l.length)):l.push(g)}return l.length>0?l:[a]}function ma({buildingName:a,onClose:l,onConfirm:c}){const{t:h}=E(["terminal","common"]);return e.jsx("div",{className:"modal-overlay visible",onClick:l,children:e.jsxs("div",{className:"modal confirm-modal",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:h("terminal:building.deleteBuilding")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:h("terminal:building.deleteConfirm",{name:a})}),e.jsx("p",{className:"confirm-modal-note",children:h("terminal:building.deleteNote")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:l,children:h("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-danger",onClick:c,autoFocus:!0,children:h("common:buttons.delete")})]})]})})}function da({usePM2:a,setUsePM2:l}){const{t:c}=E(["terminal"]);return e.jsxs("div",{className:"form-section pm2-toggle-section",children:[e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",className:"toggle-input",checked:a,onChange:h=>l(h.target.checked)}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})}),e.jsxs("span",{className:"toggle-label",children:[e.jsx("span",{className:"pm2-badge",children:"PM2"}),c("terminal:building.usePM2")]})]}),e.jsx("div",{className:"form-hint",children:c("terminal:building.pm2Hint")})]})}function ua({usePM2:a,pm2Script:l,setPm2Script:c,pm2Args:h,setPm2Args:t,pm2Interpreter:o,setPm2Interpreter:g,pm2InterpreterArgs:m,setPm2InterpreterArgs:d,pm2Env:s,setPm2Env:u,isEditMode:b,building:x,handleCommand:N}){var y;const{t:p}=E(["terminal","common"]);return a?e.jsxs("div",{className:"form-section pm2-config-section",children:[e.jsx("label",{className:"form-label",children:p("terminal:building.pm2Configuration")}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Script"),e.jsx(v,{text:p("terminal:building.helpPm2Script"),title:p("terminal:building.pm2Script"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:l,onChange:j=>c(j.target.value),placeholder:"npm, java, python, ./app.js",required:a})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Arguments"),e.jsx(v,{text:p("terminal:building.helpPm2Arguments"),title:p("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:h,onChange:j=>t(j.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Interpreter"),e.jsx(v,{text:p("terminal:building.helpPm2Interpreter"),title:p("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:o,onChange:j=>g(j.target.value),children:Object.keys(Fs).map(j=>e.jsx("option",{value:j,children:Fs[j].label},j))})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2InterpArgs"),e.jsx(v,{text:p("terminal:building.helpPm2InterpArgs"),title:p("terminal:building.pm2InterpArgs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:m,onChange:j=>d(j.target.value),placeholder:"-jar (for Java)"})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:[p("terminal:building.pm2Environment"),e.jsx(v,{text:p("terminal:building.helpPm2Environment"),title:p("terminal:building.pm2Environment"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:s,onChange:j=>u(j.target.value),placeholder:`KEY=value
2
2
  SERVER_PORT=7201
3
- NODE_ENV=production`,rows:3})]}),e.jsx("div",{className:"pm2-examples",children:e.jsxs("details",{children:[e.jsx("summary",{children:p("terminal:building.pm2Examples")}),e.jsxs("div",{className:"pm2-examples-content",children:[e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Node.js:"})," Script: ",e.jsx("code",{children:"npm"}),", Args: ",e.jsx("code",{children:"run dev"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Symfony:"})," Script: ",e.jsx("code",{children:"symfony"}),", Args: ",e.jsx("code",{children:"serve --no-daemon"}),", Interpreter: ",e.jsx("code",{children:"None"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Java JAR:"})," Script: ",e.jsx("code",{children:"app.jar"}),", Interpreter: ",e.jsx("code",{children:"Java"}),", Interp. Args: ",e.jsx("code",{children:"-jar"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Python:"})," Script: ",e.jsx("code",{children:"app.py"}),", Interpreter: ",e.jsx("code",{children:"Python 3"})]})]})]})}),b&&(x==null?void 0:x.pm2Status)&&e.jsx("div",{className:"pm2-status-display",children:e.jsxs("div",{className:"pm2-status-row",children:[e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"PID"}),e.jsx("span",{className:"pm2-metric-value",children:x.pm2Status.pid||"-"})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"CPU"}),e.jsxs("span",{className:"pm2-metric-value",children:[((y=x.pm2Status.cpu)==null?void 0:y.toFixed(1))||"0","%"]})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"MEM"}),e.jsx("span",{className:"pm2-metric-value",children:Ve(x.pm2Status.memory||0)})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Restarts"}),e.jsx("span",{className:"pm2-metric-value",children:x.pm2Status.restarts||0})]}),x.pm2Status.uptime&&e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Uptime"}),e.jsx("span",{className:"pm2-metric-value",children:ca(x.pm2Status.uptime)})]})]})}),b&&e.jsxs("div",{className:"pm2-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>N("start"),children:p("common:buttons.start")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>N("stop"),children:p("common:buttons.stop")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>N("restart"),children:p("terminal:buildingAction.restart")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>N("logs"),children:p("terminal:logs.title")})]})]}):null}function pa({dockerMode:a,setDockerMode:l,dockerImage:c,setDockerImage:h,dockerContainerName:t,setDockerContainerName:r,dockerCommand:g,setDockerCommand:m,dockerPorts:d,setDockerPorts:s,dockerVolumes:u,setDockerVolumes:b,dockerNetwork:x,setDockerNetwork:N,dockerRestart:p,setDockerRestart:y,dockerPull:j,setDockerPull:F,dockerEnv:$,setDockerEnv:z,dockerComposePath:Y,setDockerComposePath:M,dockerComposeProject:J,setDockerComposeProject:U,dockerComposeServices:W,setDockerComposeServices:K,selectedExistingContainer:R,setSelectedExistingContainer:H,dockerContainersList:O,isEditMode:T,building:k,handleCommand:L}){const{t:A}=E(["config","common"]);return e.jsxs("div",{className:"form-section docker-config-section",children:[e.jsx("label",{className:"form-label",children:A("config:buildings.dockerConfig")}),e.jsxs("div",{className:"docker-mode-selector",children:[e.jsxs("label",{className:`docker-mode-option ${a==="container"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"container",checked:a==="container",onChange:()=>l("container")}),e.jsx("span",{className:"docker-mode-icon",children:"📦"}),e.jsx("span",{className:"docker-mode-label",children:"Container"}),e.jsx("span",{className:"docker-mode-desc",children:"Create a new container"})]}),e.jsxs("label",{className:`docker-mode-option ${a==="compose"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"compose",checked:a==="compose",onChange:()=>l("compose")}),e.jsx("span",{className:"docker-mode-icon",children:"🛠"}),e.jsx("span",{className:"docker-mode-label",children:"Compose"}),e.jsx("span",{className:"docker-mode-desc",children:"Manage multiple services"})]}),e.jsxs("label",{className:`docker-mode-option ${a==="existing"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"existing",checked:a==="existing",onChange:()=>l("existing")}),e.jsx("span",{className:"docker-mode-icon",children:"🔎"}),e.jsx("span",{className:"docker-mode-label",children:"Existing"}),e.jsx("span",{className:"docker-mode-desc",children:"Adopt existing container"})]})]}),a==="container"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Image:",e.jsx(v,{text:"Docker image to run, e.g., nginx:latest, redis:alpine, my-app:v1",title:"Image",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:c,onChange:n=>h(n.target.value),placeholder:"nginx:latest",required:!0})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Container Name:",e.jsx(v,{text:"Custom name for the container. If empty, auto-generated based on building name.",title:"Container Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:t,onChange:n=>r(n.target.value),placeholder:"Auto-generated (tc-{name}-{id})"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Command:",e.jsx(v,{text:"Override the default container command. Leave empty to use image's CMD.",title:"Command Override",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:n=>m(n.target.value),placeholder:"Optional command override"})]}),e.jsxs("div",{className:"form-section docker-ports-section",children:[e.jsxs("label",{className:"form-label",children:["Port Mappings",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>s([...d,""]),children:"+ Add"})]}),d.map((n,C)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:n,onChange:B=>{const D=[...d];D[C]=B.target.value,s(D)},placeholder:"8080:80 or 3000"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>s(d.filter((B,D)=>D!==C)),children:"x"})]},C)),d.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host:container (e.g., 8080:80) or same port (e.g., 3000)"})]}),e.jsxs("div",{className:"form-section docker-volumes-section",children:[e.jsxs("label",{className:"form-label",children:["Volume Mounts",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>b([...u,""]),children:"+ Add"})]}),u.map((n,C)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:n,onChange:B=>{const D=[...u];D[C]=B.target.value,b(D)},placeholder:"./data:/app/data or /host/path:/container/path"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>b(u.filter((B,D)=>D!==C)),children:"x"})]},C)),u.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host_path:container_path (relative paths resolved from working directory)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Network:",e.jsx(v,{text:"Docker network to connect to. Leave empty for default bridge network.",title:"Network",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:x,onChange:n=>N(n.target.value),placeholder:"bridge (default)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Restart Policy:",e.jsx(v,{text:"When should Docker restart the container automatically?",title:"Restart Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:p,onChange:n=>y(n.target.value),children:Object.keys($s).map(n=>e.jsx("option",{value:n,children:$s[n].label},n))})]})]}),a==="compose"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Compose File:",e.jsx(v,{text:"Path to docker-compose.yml file, relative to working directory.",title:"Compose File",position:"top",size:"sm"})]}),e.jsx(He,{value:Y,onChange:M,placeholder:"docker-compose.yml",className:"form-input",directoriesOnly:!1})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Project Name:",e.jsx(v,{text:"Override the compose project name. Leave empty for auto-generated name.",title:"Project Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:J,onChange:n=>U(n.target.value),placeholder:"Auto-generated"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Services:",e.jsx(v,{text:"Specific services to manage (comma-separated). Leave empty for all services.",title:"Services",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:W,onChange:n=>K(n.target.value),placeholder:"All services (or: api, db, redis)"})]})]}),a==="existing"&&e.jsxs("div",{className:"docker-existing-section",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Select Container:",e.jsx(v,{text:"Choose an existing Docker container to monitor and control. The container will not be deleted when removing the building.",title:"Existing Container",position:"top",size:"sm"})]}),e.jsxs("div",{className:"docker-existing-select-wrapper",children:[e.jsxs("select",{className:"form-input form-select",value:R,onChange:n=>H(n.target.value),required:a==="existing",children:[e.jsx("option",{value:"",children:"Select a container..."}),O.map(n=>e.jsxs("option",{value:n.name,children:[n.name," (",n.image,") - ",n.state]},n.id))]}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.requestDockerContainersList(),title:"Refresh container list",children:"↻"})]})]}),O.length===0&&e.jsx("div",{className:"form-hint docker-existing-hint",children:"No containers found. Make sure Docker is running and you have containers available."}),R&&e.jsx("div",{className:"docker-existing-info",children:(()=>{const n=O.find(C=>C.name===R);return n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Image:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.image})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Status:"}),e.jsx("span",{className:`docker-existing-info-value docker-status-${n.status}`,children:n.state})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"ID:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.id.slice(0,12)})]}),n.ports.length>0&&e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Ports:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.ports.map(C=>`${C.host}:${C.container}/${C.protocol}`).join(", ")})]})]}):null})()}),e.jsx("div",{className:"form-hint",children:"Note: Existing containers will not be deleted when you remove this building."})]}),a!=="existing"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Pull Policy:",e.jsx(v,{text:"When to pull images: always, only if missing, or never.",title:"Pull Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:j,onChange:n=>F(n.target.value),children:Object.keys(Ms).map(n=>e.jsx("option",{value:n,children:Ms[n].label},n))})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:["Environment:",e.jsx(v,{text:"Environment variables in KEY=value format, one per line.",title:"Environment Variables",position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:$,onChange:n=>z(n.target.value),placeholder:`KEY=value
3
+ NODE_ENV=production`,rows:3})]}),e.jsx("div",{className:"pm2-examples",children:e.jsxs("details",{children:[e.jsx("summary",{children:p("terminal:building.pm2Examples")}),e.jsxs("div",{className:"pm2-examples-content",children:[e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Node.js:"})," Script: ",e.jsx("code",{children:"npm"}),", Args: ",e.jsx("code",{children:"run dev"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Symfony:"})," Script: ",e.jsx("code",{children:"symfony"}),", Args: ",e.jsx("code",{children:"serve --no-daemon"}),", Interpreter: ",e.jsx("code",{children:"None"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Java JAR:"})," Script: ",e.jsx("code",{children:"app.jar"}),", Interpreter: ",e.jsx("code",{children:"Java"}),", Interp. Args: ",e.jsx("code",{children:"-jar"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Python:"})," Script: ",e.jsx("code",{children:"app.py"}),", Interpreter: ",e.jsx("code",{children:"Python 3"})]})]})]})}),b&&(x==null?void 0:x.pm2Status)&&e.jsx("div",{className:"pm2-status-display",children:e.jsxs("div",{className:"pm2-status-row",children:[e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"PID"}),e.jsx("span",{className:"pm2-metric-value",children:x.pm2Status.pid||"-"})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"CPU"}),e.jsxs("span",{className:"pm2-metric-value",children:[((y=x.pm2Status.cpu)==null?void 0:y.toFixed(1))||"0","%"]})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"MEM"}),e.jsx("span",{className:"pm2-metric-value",children:qe(x.pm2Status.memory||0)})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Restarts"}),e.jsx("span",{className:"pm2-metric-value",children:x.pm2Status.restarts||0})]}),x.pm2Status.uptime&&e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Uptime"}),e.jsx("span",{className:"pm2-metric-value",children:ca(x.pm2Status.uptime)})]})]})}),b&&e.jsxs("div",{className:"pm2-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>N("start"),children:p("common:buttons.start")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>N("stop"),children:p("common:buttons.stop")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>N("restart"),children:p("terminal:buildingAction.restart")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>N("logs"),children:p("terminal:logs.title")})]})]}):null}function pa({dockerMode:a,setDockerMode:l,dockerImage:c,setDockerImage:h,dockerContainerName:t,setDockerContainerName:o,dockerCommand:g,setDockerCommand:m,dockerPorts:d,setDockerPorts:s,dockerVolumes:u,setDockerVolumes:b,dockerNetwork:x,setDockerNetwork:N,dockerRestart:p,setDockerRestart:y,dockerPull:j,setDockerPull:F,dockerEnv:$,setDockerEnv:z,dockerComposePath:Y,setDockerComposePath:M,dockerComposeProject:J,setDockerComposeProject:U,dockerComposeServices:W,setDockerComposeServices:K,selectedExistingContainer:R,setSelectedExistingContainer:H,dockerContainersList:O,isEditMode:T,building:k,handleCommand:L}){const{t:A}=E(["config","common"]);return e.jsxs("div",{className:"form-section docker-config-section",children:[e.jsx("label",{className:"form-label",children:A("config:buildings.dockerConfig")}),e.jsxs("div",{className:"docker-mode-selector",children:[e.jsxs("label",{className:`docker-mode-option ${a==="container"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"container",checked:a==="container",onChange:()=>l("container")}),e.jsx("span",{className:"docker-mode-icon",children:"📦"}),e.jsx("span",{className:"docker-mode-label",children:"Container"}),e.jsx("span",{className:"docker-mode-desc",children:"Create a new container"})]}),e.jsxs("label",{className:`docker-mode-option ${a==="compose"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"compose",checked:a==="compose",onChange:()=>l("compose")}),e.jsx("span",{className:"docker-mode-icon",children:"🛠"}),e.jsx("span",{className:"docker-mode-label",children:"Compose"}),e.jsx("span",{className:"docker-mode-desc",children:"Manage multiple services"})]}),e.jsxs("label",{className:`docker-mode-option ${a==="existing"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"existing",checked:a==="existing",onChange:()=>l("existing")}),e.jsx("span",{className:"docker-mode-icon",children:"🔎"}),e.jsx("span",{className:"docker-mode-label",children:"Existing"}),e.jsx("span",{className:"docker-mode-desc",children:"Adopt existing container"})]})]}),a==="container"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Image:",e.jsx(v,{text:"Docker image to run, e.g., nginx:latest, redis:alpine, my-app:v1",title:"Image",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:c,onChange:n=>h(n.target.value),placeholder:"nginx:latest",required:!0})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Container Name:",e.jsx(v,{text:"Custom name for the container. If empty, auto-generated based on building name.",title:"Container Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:t,onChange:n=>o(n.target.value),placeholder:"Auto-generated (tc-{name}-{id})"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Command:",e.jsx(v,{text:"Override the default container command. Leave empty to use image's CMD.",title:"Command Override",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:n=>m(n.target.value),placeholder:"Optional command override"})]}),e.jsxs("div",{className:"form-section docker-ports-section",children:[e.jsxs("label",{className:"form-label",children:["Port Mappings",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>s([...d,""]),children:"+ Add"})]}),d.map((n,C)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:n,onChange:B=>{const D=[...d];D[C]=B.target.value,s(D)},placeholder:"8080:80 or 3000"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>s(d.filter((B,D)=>D!==C)),children:"x"})]},C)),d.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host:container (e.g., 8080:80) or same port (e.g., 3000)"})]}),e.jsxs("div",{className:"form-section docker-volumes-section",children:[e.jsxs("label",{className:"form-label",children:["Volume Mounts",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>b([...u,""]),children:"+ Add"})]}),u.map((n,C)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:n,onChange:B=>{const D=[...u];D[C]=B.target.value,b(D)},placeholder:"./data:/app/data or /host/path:/container/path"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>b(u.filter((B,D)=>D!==C)),children:"x"})]},C)),u.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host_path:container_path (relative paths resolved from working directory)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Network:",e.jsx(v,{text:"Docker network to connect to. Leave empty for default bridge network.",title:"Network",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:x,onChange:n=>N(n.target.value),placeholder:"bridge (default)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Restart Policy:",e.jsx(v,{text:"When should Docker restart the container automatically?",title:"Restart Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:p,onChange:n=>y(n.target.value),children:Object.keys($s).map(n=>e.jsx("option",{value:n,children:$s[n].label},n))})]})]}),a==="compose"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Compose File:",e.jsx(v,{text:"Path to docker-compose.yml file, relative to working directory.",title:"Compose File",position:"top",size:"sm"})]}),e.jsx(He,{value:Y,onChange:M,placeholder:"docker-compose.yml",className:"form-input",directoriesOnly:!1})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Project Name:",e.jsx(v,{text:"Override the compose project name. Leave empty for auto-generated name.",title:"Project Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:J,onChange:n=>U(n.target.value),placeholder:"Auto-generated"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Services:",e.jsx(v,{text:"Specific services to manage (comma-separated). Leave empty for all services.",title:"Services",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:W,onChange:n=>K(n.target.value),placeholder:"All services (or: api, db, redis)"})]})]}),a==="existing"&&e.jsxs("div",{className:"docker-existing-section",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Select Container:",e.jsx(v,{text:"Choose an existing Docker container to monitor and control. The container will not be deleted when removing the building.",title:"Existing Container",position:"top",size:"sm"})]}),e.jsxs("div",{className:"docker-existing-select-wrapper",children:[e.jsxs("select",{className:"form-input form-select",value:R,onChange:n=>H(n.target.value),required:a==="existing",children:[e.jsx("option",{value:"",children:"Select a container..."}),O.map(n=>e.jsxs("option",{value:n.name,children:[n.name," (",n.image,") - ",n.state]},n.id))]}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.requestDockerContainersList(),title:"Refresh container list",children:"↻"})]})]}),O.length===0&&e.jsx("div",{className:"form-hint docker-existing-hint",children:"No containers found. Make sure Docker is running and you have containers available."}),R&&e.jsx("div",{className:"docker-existing-info",children:(()=>{const n=O.find(C=>C.name===R);return n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Image:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.image})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Status:"}),e.jsx("span",{className:`docker-existing-info-value docker-status-${n.status}`,children:n.state})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"ID:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.id.slice(0,12)})]}),n.ports.length>0&&e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Ports:"}),e.jsx("span",{className:"docker-existing-info-value",children:n.ports.map(C=>`${C.host}:${C.container}/${C.protocol}`).join(", ")})]})]}):null})()}),e.jsx("div",{className:"form-hint",children:"Note: Existing containers will not be deleted when you remove this building."})]}),a!=="existing"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Pull Policy:",e.jsx(v,{text:"When to pull images: always, only if missing, or never.",title:"Pull Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:j,onChange:n=>F(n.target.value),children:Object.keys(Ms).map(n=>e.jsx("option",{value:n,children:Ms[n].label},n))})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:["Environment:",e.jsx(v,{text:"Environment variables in KEY=value format, one per line.",title:"Environment Variables",position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:$,onChange:n=>z(n.target.value),placeholder:`KEY=value
4
4
  DATABASE_URL=postgres://...
5
- NODE_ENV=production`,rows:3})]})]}),T&&(k==null?void 0:k.dockerStatus)&&e.jsxs("div",{className:"docker-status-display",children:[e.jsxs("div",{className:"docker-status-row",children:[e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"ID"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.containerId||"-"})]}),e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"Status"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.status||"-"})]}),k.dockerStatus.health&&k.dockerStatus.health!=="none"&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"Health"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.health})]}),k.dockerStatus.cpu!==void 0&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"CPU"}),e.jsxs("span",{className:"docker-metric-value",children:[k.dockerStatus.cpu.toFixed(1),"%"]})]}),k.dockerStatus.memory!==void 0&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"MEM"}),e.jsxs("span",{className:"docker-metric-value",children:[Ve(k.dockerStatus.memory),k.dockerStatus.memoryLimit?` / ${Ve(k.dockerStatus.memoryLimit)}`:""]})]})]}),k.dockerStatus.ports&&k.dockerStatus.ports.length>0&&e.jsxs("div",{className:"docker-ports-row",children:[e.jsx("span",{className:"docker-metric-label",children:"Ports:"}),k.dockerStatus.ports.map((n,C)=>e.jsxs("a",{href:`http://localhost:${n.host}`,target:"_blank",rel:"noopener noreferrer",className:"docker-port-link",children:[n.host,":",n.container,"/",n.protocol]},C))]}),k.dockerStatus.services&&k.dockerStatus.services.length>0&&e.jsxs("div",{className:"docker-services-status",children:[e.jsx("span",{className:"docker-metric-label",children:"Services:"}),e.jsx("div",{className:"docker-services-grid",children:k.dockerStatus.services.map((n,C)=>e.jsxs("div",{className:"docker-service-item",children:[e.jsx("span",{className:"docker-service-indicator",style:{backgroundColor:n.status==="running"?"#4ade80":"#f87171"}}),e.jsx("span",{className:"docker-service-name",children:n.name}),e.jsx("span",{className:"docker-service-status",children:n.status})]},C))})]})]}),T&&e.jsxs("div",{className:"docker-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>L("start"),children:"Start"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>L("stop"),children:"Stop"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>L("restart"),children:"Restart"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>L("logs"),children:"Logs"})]})]})}function ha({dbConnections:a,setDbConnections:l,activeDbConnectionId:c,setActiveDbConnectionId:h}){const{t}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section database-config-section",children:[e.jsxs("label",{className:"form-label",children:[t("terminal:building.dbConnections"),e.jsx(v,{text:t("terminal:building.helpDbConnections"),title:t("terminal:building.dbConnections"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>{const r={id:`conn_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,name:`Connection ${a.length+1}`,engine:"mysql",host:"localhost",port:3306,username:"root"};l([...a,r]),c||h(r.id)},children:t("terminal:database.addConnection")})]}),a.length===0&&e.jsx("div",{className:"form-hint",children:t("terminal:building.dbGetStarted")}),a.map((r,g)=>e.jsxs("div",{className:"db-connection-card",children:[e.jsxs("div",{className:"db-connection-header",children:[e.jsxs("label",{className:"db-connection-active",children:[e.jsx("input",{type:"radio",name:"activeConnection",checked:c===r.id,onChange:()=>h(r.id)}),t("common:labels.default"),e.jsx(v,{text:t("terminal:building.helpDbDefault"),position:"top",size:"sm"})]}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>{const m=a.filter(d=>d.id!==r.id);l(m),c===r.id&&m.length>0?h(m[0].id):m.length===0&&h(void 0)},children:t("common:buttons.remove")})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("common:labels.name")}),e.jsx("input",{type:"text",className:"form-input",value:r.name,onChange:m=>{const d=[...a];d[g]={...r,name:m.target.value},l(d)},placeholder:"My Database"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:t("terminal:building.dbEngine")}),e.jsx("select",{className:"form-input form-select",value:r.engine,onChange:m=>{const d=m.target.value,s=[...a];s[g]={...r,engine:d,port:q[d].defaultPort},l(s)},children:Object.keys(q).map(m=>e.jsxs("option",{value:m,children:[q[m].icon," ",q[m].label]},m))})]})]}),r.engine==="sqlite"?e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbFilepath")}),e.jsx("input",{type:"text",className:"form-input",value:r.filepath||"",onChange:m=>{const d=[...a];d[g]={...r,filepath:m.target.value||void 0},l(d)},placeholder:"/path/to/database.db"})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbHost")}),e.jsx("input",{type:"text",className:"form-input",value:r.host,onChange:m=>{const d=[...a];d[g]={...r,host:m.target.value},l(d)},placeholder:"localhost"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:t("terminal:building.dbPort")}),e.jsx("input",{type:"number",className:"form-input",value:r.port,onChange:m=>{const d=[...a];d[g]={...r,port:parseInt(m.target.value)||q[r.engine].defaultPort},l(d)}})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("terminal:building.dbUsername")}),e.jsx("input",{type:"text",className:"form-input",value:r.username,onChange:m=>{const d=[...a];d[g]={...r,username:m.target.value},l(d)},placeholder:"root"})]}),e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("terminal:building.dbPassword")}),e.jsx("input",{type:"password",className:"form-input",value:r.password||"",onChange:m=>{const d=[...a];d[g]={...r,password:m.target.value||void 0},l(d)},placeholder:"Optional"})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbDefaultDatabase")}),e.jsx("input",{type:"text",className:"form-input",value:r.database||"",onChange:m=>{const d=[...a];d[g]={...r,database:m.target.value||void 0},l(d)},placeholder:"Optional - select after connecting"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsxs("label",{children:["SSL",e.jsx(v,{text:t("terminal:building.helpDbSsl"),position:"top",size:"sm"})]}),e.jsxs("label",{className:"toggle-switch toggle-switch--small",children:[e.jsx("input",{type:"checkbox",checked:r.ssl||!1,onChange:m=>{const d=[...a];d[g]={...r,ssl:m.target.checked},l(d)}}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})})]})]})]})]})]},r.id)),a.length>0&&e.jsx("div",{className:"form-hint",children:t("terminal:building.dbAfterSaving")})]})}function xa({buildings:a,buildingId:l,subordinateBuildingIds:c,setSubordinateBuildingIds:h,isEditMode:t,showBossLogs:r,setShowBossLogs:g,currentBossLogs:m,bossLogsContainerRef:d}){const{t:s}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section boss-building-section",children:[e.jsxs("label",{className:"form-label",children:[s("terminal:building.managedBuildings"),e.jsx(v,{text:s("terminal:building.helpManagedBuildings"),title:s("terminal:building.managedBuildings"),position:"top",size:"sm"})]}),e.jsx("div",{className:"form-hint",children:s("terminal:building.managedBuildingsHint")}),e.jsxs("div",{className:"subordinate-buildings-list",children:[Array.from(a.values()).filter(u=>u.id!==l&&u.type!=="boss"&&u.type!=="link"&&u.type!=="folder").map(u=>e.jsxs("label",{className:"subordinate-building-item",children:[e.jsx("input",{type:"checkbox",checked:c.includes(u.id),onChange:b=>{b.target.checked?h([...c,u.id]):h(c.filter(x=>x!==u.id))}}),e.jsx("span",{className:"subordinate-building-icon",children:ee[u.type].icon}),e.jsx("span",{className:"subordinate-building-name",children:u.name}),e.jsx("span",{className:"subordinate-building-status",style:{backgroundColor:Ge[u.status]}})]},u.id)),Array.from(a.values()).filter(u=>u.id!==l&&u.type!=="boss"&&u.type!=="link"&&u.type!=="folder").length===0&&e.jsx("div",{className:"form-hint no-buildings-hint",children:s("terminal:building.noManageableBuildings")})]}),t&&c.length>0&&e.jsxs("div",{className:"boss-building-actions",children:[e.jsxs("div",{className:"boss-actions-header",children:[s("terminal:building.bulkActions"),e.jsx(v,{text:s("terminal:building.helpBulkActions"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"boss-actions-row",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>P.sendBossBuildingCommand(l,"start_all"),children:s("terminal:building.startAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>P.sendBossBuildingCommand(l,"stop_all"),children:s("terminal:building.stopAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>P.sendBossBuildingCommand(l,"restart_all"),children:s("terminal:building.restartAll")}),e.jsx("button",{type:"button",className:`btn btn-sm ${r?"btn-primary":""}`,onClick:()=>{r?(P.stopBossLogStreaming(l),g(!1)):(P.startBossLogStreaming(l),g(!0))},children:s(r?"terminal:building.hideLogs":"terminal:building.unifiedLogs")})]}),e.jsxs("div",{className:"boss-subordinates-status",children:[e.jsx("div",{className:"boss-status-header",children:s("terminal:building.statusOverview")}),e.jsx("div",{className:"boss-status-grid",children:c.map(u=>{const b=a.get(u);return b?e.jsxs("div",{className:"boss-status-item",children:[e.jsx("span",{className:"boss-status-indicator",style:{backgroundColor:Ge[b.status]}}),e.jsx("span",{className:"boss-status-name",children:b.name}),e.jsx("span",{className:"boss-status-label",children:b.status})]},u):null})})]})]}),t&&r&&e.jsxs("div",{className:"form-section boss-logs-section",children:[e.jsxs("label",{className:"form-label",children:[s("terminal:building.unifiedLogs"),e.jsx(v,{text:s("terminal:building.helpUnifiedLogs"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.clearBossStreamingLogs(l),children:s("common:buttons.clear")})]}),e.jsxs("div",{className:"boss-logs-container",ref:d,children:[m.map((u,b)=>e.jsxs("div",{className:"boss-log-entry",children:[e.jsxs("span",{className:"boss-log-source",children:["[",u.subordinateName,"]"]}),e.jsx("span",{className:"boss-log-content",children:Ks(u.chunk)})]},b)),m.length===0&&e.jsx("div",{className:"boss-logs-empty",children:s("terminal:building.waitingForLogs")})]})]})]})}function ba({startCmd:a,setStartCmd:l,stopCmd:c,setStopCmd:h,restartCmd:t,setRestartCmd:r,healthCheckCmd:g,setHealthCheckCmd:m,logsCmd:d,setLogsCmd:s,isEditMode:u,handleCommand:b}){const{t:x}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section commands-section",children:[e.jsxs("label",{className:"form-label",children:[x("terminal:building.commands"),e.jsx(v,{text:x("terminal:building.helpCommands"),title:x("terminal:building.commands"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"command-inputs",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdStart"),e.jsx(v,{text:x("terminal:building.helpCmdStart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:a,onChange:N=>l(N.target.value),placeholder:"npm run dev"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>b("start"),disabled:!a,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdStop"),e.jsx(v,{text:x("terminal:building.helpCmdStop"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:c,onChange:N=>h(N.target.value),placeholder:"pkill -f 'npm run dev'"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>b("stop"),disabled:!c,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdRestart"),e.jsx(v,{text:x("terminal:building.helpCmdRestart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:t,onChange:N=>r(N.target.value),placeholder:"npm run restart"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>b("restart"),disabled:!t,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdHealthCheck"),e.jsx(v,{text:x("terminal:building.helpCmdHealthCheck"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:N=>m(N.target.value),placeholder:"curl -s http://localhost:3000/health"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>b("healthCheck"),disabled:!g,children:x("terminal:building.check")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdLogs"),e.jsx(v,{text:x("terminal:building.helpCmdLogs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:d,onChange:N=>s(N.target.value),placeholder:"tail -n 100 /var/log/app.log"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>b("logs"),children:x("terminal:building.fetch")})]})]})]})}const ja=[{value:"",label:"Default ($SHELL)"},{value:"/bin/bash",label:"Bash"},{value:"/bin/zsh",label:"Zsh"},{value:"/usr/bin/fish",label:"Fish"},{value:"/bin/sh",label:"sh"}];function ga({terminalShell:a,setTerminalShell:l,terminalPort:c,setTerminalPort:h,terminalSaveSession:t,setTerminalSaveSession:r,terminalArgs:g,setTerminalArgs:m,isEditMode:d,building:s,handleCommand:u,onOpenTerminal:b,onOpenBelow:x}){const{t:N}=E(["config"]),p=(s==null?void 0:s.status)==="running",y=s==null?void 0:s.terminalStatus;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:N("config:buildings.terminalConfig",{defaultValue:"Terminal Configuration"})}),e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-field",children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalShell",{defaultValue:"Shell"})}),e.jsx("select",{className:"form-input",value:a,onChange:j=>l(j.target.value),children:ja.map(j=>e.jsx("option",{value:j.value,children:j.label},j.value))})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalPort",{defaultValue:"Port"})}),e.jsx("input",{type:"number",className:"form-input",value:c,onChange:j=>h(j.target.value),placeholder:"Auto",min:1024,max:65535})]})]}),e.jsx("div",{className:"form-row",style:{marginTop:"8px"},children:e.jsxs("label",{className:"form-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:j=>r(j.target.checked)}),e.jsx("span",{children:N("config:buildings.terminalSaveSession",{defaultValue:"Persist session (tmux)"})})]})}),e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalArgs",{defaultValue:"Extra ttyd args"})}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:j=>m(j.target.value),placeholder:"--client-option titleFixed=Terminal"}),e.jsx("div",{className:"form-hint",children:"Additional command-line arguments passed to ttyd"})]})]}),d&&s&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:N("config:buildings.terminalControls",{defaultValue:"Terminal Controls"})}),y&&e.jsxs("div",{className:"building-runtime-info",children:[e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Proxy"}),e.jsx("span",{className:"runtime-value",style:{color:"#4a9eff"},children:y.url})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"PID"}),e.jsx("span",{className:"runtime-value",children:y.pid})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Port"}),e.jsx("span",{className:"runtime-value",children:y.port})]}),y.tmuxSession&&e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Session"}),e.jsx("span",{className:"runtime-value",children:y.tmuxSession})]})]}),e.jsxs("div",{className:"building-actions",style:{marginTop:"8px"},children:[!p&&e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>u("start"),children:"▶ Start"}),p&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>u("restart"),children:"🔄 Restart"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>u("stop"),children:"⏹ Stop"}),(y==null?void 0:y.url)&&e.jsxs(e.Fragment,{children:[b&&e.jsx("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>b(y.url),children:"🖥 Modal"}),x&&s&&e.jsx("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>x(s.id),children:"⬇ Below"})]})]})]})]})]})}function va({logs:a,buildingId:l,logsContainerRef:c}){return e.jsxs("div",{className:"form-section logs-section",children:[e.jsxs("label",{className:"form-label",children:["Logs",e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.clearBuildingLogs(l),children:"Clear"})]}),e.jsx("div",{className:"logs-container",ref:c,children:a.map((h,t)=>e.jsx("pre",{className:"log-entry",children:Ks(h)},t))})]})}function Ca({isOpen:a,onClose:l,buildingId:c,initialPosition:h}){const{t}=E(["config","common"]),{buildings:r,buildingLogs:g,bossStreamingLogs:m}=aa(),d=ta(),s=c?r.get(c):null,u=c?m.get(c)||[]:[],b=!!s,[x,N]=o.useState(""),[p,y]=o.useState("server"),[j,F]=o.useState("server-rack"),[$,z]=o.useState(""),[Y,M]=o.useState(""),[J,U]=o.useState(""),[W,K]=o.useState(""),[R,H]=o.useState(""),[O,T]=o.useState(""),[k,L]=o.useState(""),[A,n]=o.useState([]),[C,B]=o.useState(!1),[D,se]=o.useState(""),[G,Z]=o.useState(1),[V,ae]=o.useState(!1),[qe,te]=o.useState(""),[Ye,ne]=o.useState(""),[Je,le]=o.useState(""),[We,ie]=o.useState(""),[Ze,re]=o.useState(""),[Hs,oe]=o.useState(!1),[w,ce]=o.useState("container"),[me,de]=o.useState(""),[Qe,ue]=o.useState(""),[pe,he]=o.useState(""),[xe,be]=o.useState([]),[je,ge]=o.useState([]),[Xe,ve]=o.useState(""),[Ne,fe]=o.useState(""),[ke,ye]=o.useState(""),[es,Ce]=o.useState("unless-stopped"),[ss,Se]=o.useState("missing"),[we,Pe]=o.useState(""),[De,Ee]=o.useState(""),[Le,Ae]=o.useState(""),[Be,ze]=o.useState([]),[Gs,Vs]=o.useState(!1),[Re,Oe]=o.useState([]),[as,Te]=o.useState(void 0),[ts,_e]=o.useState(""),[Ie,Fe]=o.useState(""),[ns,$e]=o.useState(!1),[ls,Me]=o.useState(""),is=o.useRef(null),qs=o.useRef(null),Q=o.useRef(null);o.useEffect(()=>{var i,f,S,_,ms,ds,us,ps,hs,xs,bs,js,gs,vs,Ns,fs,ks,ys,Cs,Ss,ws,Ps,Ds,Es,Ls,As,Bs,zs,Rs,Os,Ts,_s,Is;a&&(s?(N(s.name),y(s.type),F(s.style||"server-rack"),z(s.color||""),M(s.cwd||""),U(((i=s.commands)==null?void 0:i.start)||""),K(((f=s.commands)==null?void 0:f.stop)||""),H(((S=s.commands)==null?void 0:S.restart)||""),T(((_=s.commands)==null?void 0:_.healthCheck)||""),L(((ms=s.commands)==null?void 0:ms.logs)||""),n(s.urls||[]),se(s.folderPath||""),Z(s.scale||1),ae(((ds=s.pm2)==null?void 0:ds.enabled)||!1),te(((us=s.pm2)==null?void 0:us.script)||""),ne(((ps=s.pm2)==null?void 0:ps.args)||""),le(((hs=s.pm2)==null?void 0:hs.interpreter)||""),ie(((xs=s.pm2)==null?void 0:xs.interpreterArgs)||""),re((bs=s.pm2)!=null&&bs.env?Object.entries(s.pm2.env).map(([I,Ue])=>`${I}=${Ue}`).join(`
5
+ NODE_ENV=production`,rows:3})]})]}),T&&(k==null?void 0:k.dockerStatus)&&e.jsxs("div",{className:"docker-status-display",children:[e.jsxs("div",{className:"docker-status-row",children:[e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"ID"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.containerId||"-"})]}),e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"Status"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.status||"-"})]}),k.dockerStatus.health&&k.dockerStatus.health!=="none"&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"Health"}),e.jsx("span",{className:"docker-metric-value",children:k.dockerStatus.health})]}),k.dockerStatus.cpu!==void 0&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"CPU"}),e.jsxs("span",{className:"docker-metric-value",children:[k.dockerStatus.cpu.toFixed(1),"%"]})]}),k.dockerStatus.memory!==void 0&&e.jsxs("span",{className:"docker-metric",children:[e.jsx("span",{className:"docker-metric-label",children:"MEM"}),e.jsxs("span",{className:"docker-metric-value",children:[qe(k.dockerStatus.memory),k.dockerStatus.memoryLimit?` / ${qe(k.dockerStatus.memoryLimit)}`:""]})]})]}),k.dockerStatus.ports&&k.dockerStatus.ports.length>0&&e.jsxs("div",{className:"docker-ports-row",children:[e.jsx("span",{className:"docker-metric-label",children:"Ports:"}),k.dockerStatus.ports.map((n,C)=>e.jsxs("a",{href:`http://localhost:${n.host}`,target:"_blank",rel:"noopener noreferrer",className:"docker-port-link",children:[n.host,":",n.container,"/",n.protocol]},C))]}),k.dockerStatus.services&&k.dockerStatus.services.length>0&&e.jsxs("div",{className:"docker-services-status",children:[e.jsx("span",{className:"docker-metric-label",children:"Services:"}),e.jsx("div",{className:"docker-services-grid",children:k.dockerStatus.services.map((n,C)=>e.jsxs("div",{className:"docker-service-item",children:[e.jsx("span",{className:"docker-service-indicator",style:{backgroundColor:n.status==="running"?"#4ade80":"#f87171"}}),e.jsx("span",{className:"docker-service-name",children:n.name}),e.jsx("span",{className:"docker-service-status",children:n.status})]},C))})]})]}),T&&e.jsxs("div",{className:"docker-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>L("start"),children:"Start"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>L("stop"),children:"Stop"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>L("restart"),children:"Restart"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>L("logs"),children:"Logs"})]})]})}function ha({dbConnections:a,setDbConnections:l,activeDbConnectionId:c,setActiveDbConnectionId:h}){const{t}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section database-config-section",children:[e.jsxs("label",{className:"form-label",children:[t("terminal:building.dbConnections"),e.jsx(v,{text:t("terminal:building.helpDbConnections"),title:t("terminal:building.dbConnections"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>{const o={id:`conn_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,name:`Connection ${a.length+1}`,engine:"mysql",host:"localhost",port:3306,username:"root"};l([...a,o]),c||h(o.id)},children:t("terminal:database.addConnection")})]}),a.length===0&&e.jsx("div",{className:"form-hint",children:t("terminal:building.dbGetStarted")}),a.map((o,g)=>e.jsxs("div",{className:"db-connection-card",children:[e.jsxs("div",{className:"db-connection-header",children:[e.jsxs("label",{className:"db-connection-active",children:[e.jsx("input",{type:"radio",name:"activeConnection",checked:c===o.id,onChange:()=>h(o.id)}),t("common:labels.default"),e.jsx(v,{text:t("terminal:building.helpDbDefault"),position:"top",size:"sm"})]}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>{const m=a.filter(d=>d.id!==o.id);l(m),c===o.id&&m.length>0?h(m[0].id):m.length===0&&h(void 0)},children:t("common:buttons.remove")})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("common:labels.name")}),e.jsx("input",{type:"text",className:"form-input",value:o.name,onChange:m=>{const d=[...a];d[g]={...o,name:m.target.value},l(d)},placeholder:"My Database"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:t("terminal:building.dbEngine")}),e.jsx("select",{className:"form-input form-select",value:o.engine,onChange:m=>{const d=m.target.value,s=[...a];s[g]={...o,engine:d,port:V[d].defaultPort},l(s)},children:Object.keys(V).map(m=>e.jsxs("option",{value:m,children:[V[m].icon," ",V[m].label]},m))})]})]}),o.engine==="sqlite"?e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbFilepath")}),e.jsx("input",{type:"text",className:"form-input",value:o.filepath||"",onChange:m=>{const d=[...a];d[g]={...o,filepath:m.target.value||void 0},l(d)},placeholder:"/path/to/database.db"})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbHost")}),e.jsx("input",{type:"text",className:"form-input",value:o.host,onChange:m=>{const d=[...a];d[g]={...o,host:m.target.value},l(d)},placeholder:"localhost"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:t("terminal:building.dbPort")}),e.jsx("input",{type:"number",className:"form-input",value:o.port,onChange:m=>{const d=[...a];d[g]={...o,port:parseInt(m.target.value)||V[o.engine].defaultPort},l(d)}})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("terminal:building.dbUsername")}),e.jsx("input",{type:"text",className:"form-input",value:o.username,onChange:m=>{const d=[...a];d[g]={...o,username:m.target.value},l(d)},placeholder:"root"})]}),e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:t("terminal:building.dbPassword")}),e.jsx("input",{type:"password",className:"form-input",value:o.password||"",onChange:m=>{const d=[...a];d[g]={...o,password:m.target.value||void 0},l(d)},placeholder:"Optional"})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:t("terminal:building.dbDefaultDatabase")}),e.jsx("input",{type:"text",className:"form-input",value:o.database||"",onChange:m=>{const d=[...a];d[g]={...o,database:m.target.value||void 0},l(d)},placeholder:"Optional - select after connecting"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsxs("label",{children:["SSL",e.jsx(v,{text:t("terminal:building.helpDbSsl"),position:"top",size:"sm"})]}),e.jsxs("label",{className:"toggle-switch toggle-switch--small",children:[e.jsx("input",{type:"checkbox",checked:o.ssl||!1,onChange:m=>{const d=[...a];d[g]={...o,ssl:m.target.checked},l(d)}}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})})]})]})]})]})]},o.id)),a.length>0&&e.jsx("div",{className:"form-hint",children:t("terminal:building.dbAfterSaving")})]})}function xa({buildings:a,buildingId:l,subordinateBuildingIds:c,setSubordinateBuildingIds:h,isEditMode:t,showBossLogs:o,setShowBossLogs:g,currentBossLogs:m,bossLogsContainerRef:d}){const{t:s}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section boss-building-section",children:[e.jsxs("label",{className:"form-label",children:[s("terminal:building.managedBuildings"),e.jsx(v,{text:s("terminal:building.helpManagedBuildings"),title:s("terminal:building.managedBuildings"),position:"top",size:"sm"})]}),e.jsx("div",{className:"form-hint",children:s("terminal:building.managedBuildingsHint")}),e.jsxs("div",{className:"subordinate-buildings-list",children:[Array.from(a.values()).filter(u=>u.id!==l&&u.type!=="boss"&&u.type!=="link"&&u.type!=="folder").map(u=>e.jsxs("label",{className:"subordinate-building-item",children:[e.jsx("input",{type:"checkbox",checked:c.includes(u.id),onChange:b=>{b.target.checked?h([...c,u.id]):h(c.filter(x=>x!==u.id))}}),e.jsx("span",{className:"subordinate-building-icon",children:ee[u.type].icon}),e.jsx("span",{className:"subordinate-building-name",children:u.name}),e.jsx("span",{className:"subordinate-building-status",style:{backgroundColor:Ge[u.status]}})]},u.id)),Array.from(a.values()).filter(u=>u.id!==l&&u.type!=="boss"&&u.type!=="link"&&u.type!=="folder").length===0&&e.jsx("div",{className:"form-hint no-buildings-hint",children:s("terminal:building.noManageableBuildings")})]}),t&&c.length>0&&e.jsxs("div",{className:"boss-building-actions",children:[e.jsxs("div",{className:"boss-actions-header",children:[s("terminal:building.bulkActions"),e.jsx(v,{text:s("terminal:building.helpBulkActions"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"boss-actions-row",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>P.sendBossBuildingCommand(l,"start_all"),children:s("terminal:building.startAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>P.sendBossBuildingCommand(l,"stop_all"),children:s("terminal:building.stopAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>P.sendBossBuildingCommand(l,"restart_all"),children:s("terminal:building.restartAll")}),e.jsx("button",{type:"button",className:`btn btn-sm ${o?"btn-primary":""}`,onClick:()=>{o?(P.stopBossLogStreaming(l),g(!1)):(P.startBossLogStreaming(l),g(!0))},children:s(o?"terminal:building.hideLogs":"terminal:building.unifiedLogs")})]}),e.jsxs("div",{className:"boss-subordinates-status",children:[e.jsx("div",{className:"boss-status-header",children:s("terminal:building.statusOverview")}),e.jsx("div",{className:"boss-status-grid",children:c.map(u=>{const b=a.get(u);return b?e.jsxs("div",{className:"boss-status-item",children:[e.jsx("span",{className:"boss-status-indicator",style:{backgroundColor:Ge[b.status]}}),e.jsx("span",{className:"boss-status-name",children:b.name}),e.jsx("span",{className:"boss-status-label",children:b.status})]},u):null})})]})]}),t&&o&&e.jsxs("div",{className:"form-section boss-logs-section",children:[e.jsxs("label",{className:"form-label",children:[s("terminal:building.unifiedLogs"),e.jsx(v,{text:s("terminal:building.helpUnifiedLogs"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.clearBossStreamingLogs(l),children:s("common:buttons.clear")})]}),e.jsxs("div",{className:"boss-logs-container",ref:d,children:[m.map((u,b)=>e.jsxs("div",{className:"boss-log-entry",children:[e.jsxs("span",{className:"boss-log-source",children:["[",u.subordinateName,"]"]}),e.jsx("span",{className:"boss-log-content",children:Ks(u.chunk)})]},b)),m.length===0&&e.jsx("div",{className:"boss-logs-empty",children:s("terminal:building.waitingForLogs")})]})]})]})}function ba({startCmd:a,setStartCmd:l,stopCmd:c,setStopCmd:h,restartCmd:t,setRestartCmd:o,healthCheckCmd:g,setHealthCheckCmd:m,logsCmd:d,setLogsCmd:s,isEditMode:u,handleCommand:b}){const{t:x}=E(["terminal","common"]);return e.jsxs("div",{className:"form-section commands-section",children:[e.jsxs("label",{className:"form-label",children:[x("terminal:building.commands"),e.jsx(v,{text:x("terminal:building.helpCommands"),title:x("terminal:building.commands"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"command-inputs",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdStart"),e.jsx(v,{text:x("terminal:building.helpCmdStart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:a,onChange:N=>l(N.target.value),placeholder:"npm run dev"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>b("start"),disabled:!a,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdStop"),e.jsx(v,{text:x("terminal:building.helpCmdStop"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:c,onChange:N=>h(N.target.value),placeholder:"pkill -f 'npm run dev'"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>b("stop"),disabled:!c,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdRestart"),e.jsx(v,{text:x("terminal:building.helpCmdRestart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:t,onChange:N=>o(N.target.value),placeholder:"npm run restart"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>b("restart"),disabled:!t,children:x("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdHealthCheck"),e.jsx(v,{text:x("terminal:building.helpCmdHealthCheck"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:N=>m(N.target.value),placeholder:"curl -s http://localhost:3000/health"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>b("healthCheck"),disabled:!g,children:x("terminal:building.check")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[x("terminal:building.cmdLogs"),e.jsx(v,{text:x("terminal:building.helpCmdLogs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:d,onChange:N=>s(N.target.value),placeholder:"tail -n 100 /var/log/app.log"}),u&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>b("logs"),children:x("terminal:building.fetch")})]})]})]})}const ja=[{value:"",label:"Default ($SHELL)"},{value:"/bin/bash",label:"Bash"},{value:"/bin/zsh",label:"Zsh"},{value:"/usr/bin/fish",label:"Fish"},{value:"/bin/sh",label:"sh"}];function ga({terminalShell:a,setTerminalShell:l,terminalPort:c,setTerminalPort:h,terminalSaveSession:t,setTerminalSaveSession:o,terminalArgs:g,setTerminalArgs:m,isEditMode:d,building:s,handleCommand:u,onOpenTerminal:b,onOpenBelow:x}){const{t:N}=E(["config"]),p=(s==null?void 0:s.status)==="running",y=s==null?void 0:s.terminalStatus;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:N("config:buildings.terminalConfig",{defaultValue:"Terminal Configuration"})}),e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-field",children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalShell",{defaultValue:"Shell"})}),e.jsx("select",{className:"form-input",value:a,onChange:j=>l(j.target.value),children:ja.map(j=>e.jsx("option",{value:j.value,children:j.label},j.value))})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalPort",{defaultValue:"Port"})}),e.jsx("input",{type:"number",className:"form-input",value:c,onChange:j=>h(j.target.value),placeholder:"Auto",min:1024,max:65535})]})]}),e.jsx("div",{className:"form-row",style:{marginTop:"8px"},children:e.jsxs("label",{className:"form-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:j=>o(j.target.checked)}),e.jsx("span",{children:N("config:buildings.terminalSaveSession",{defaultValue:"Persist session (tmux)"})})]})}),e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsx("label",{className:"form-sublabel",children:N("config:buildings.terminalArgs",{defaultValue:"Extra ttyd args"})}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:j=>m(j.target.value),placeholder:"--client-option titleFixed=Terminal"}),e.jsx("div",{className:"form-hint",children:"Additional command-line arguments passed to ttyd"})]})]}),d&&s&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:N("config:buildings.terminalControls",{defaultValue:"Terminal Controls"})}),y&&e.jsxs("div",{className:"building-runtime-info",children:[e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Proxy"}),e.jsx("span",{className:"runtime-value",style:{color:"#4a9eff"},children:y.url})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"PID"}),e.jsx("span",{className:"runtime-value",children:y.pid})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Port"}),e.jsx("span",{className:"runtime-value",children:y.port})]}),y.tmuxSession&&e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Session"}),e.jsx("span",{className:"runtime-value",children:y.tmuxSession})]})]}),e.jsxs("div",{className:"building-actions",style:{marginTop:"8px"},children:[!p&&e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>u("start"),children:"▶ Start"}),p&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>u("restart"),children:"🔄 Restart"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>u("stop"),children:"⏹ Stop"}),(y==null?void 0:y.url)&&e.jsxs(e.Fragment,{children:[b&&e.jsx("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>b(y.url),children:"🖥 Modal"}),x&&s&&e.jsx("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>x(s.id),children:"⬇ Below"})]})]})]})]})]})}function va({logs:a,buildingId:l,logsContainerRef:c}){return e.jsxs("div",{className:"form-section logs-section",children:[e.jsxs("label",{className:"form-label",children:["Logs",e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>P.clearBuildingLogs(l),children:"Clear"})]}),e.jsx("div",{className:"logs-container",ref:c,children:a.map((h,t)=>e.jsx("pre",{className:"log-entry",children:Ks(h)},t))})]})}function Ca({isOpen:a,onClose:l,buildingId:c,initialPosition:h}){const{t}=E(["config","common"]),{buildings:o,buildingLogs:g,bossStreamingLogs:m}=aa(),d=ta(),s=c?o.get(c):null,u=c?m.get(c)||[]:[],b=!!s,[x,N]=r.useState(""),[p,y]=r.useState("server"),[j,F]=r.useState("server-rack"),[$,z]=r.useState(""),[Y,M]=r.useState(""),[J,U]=r.useState(""),[W,K]=r.useState(""),[R,H]=r.useState(""),[O,T]=r.useState(""),[k,L]=r.useState(""),[A,n]=r.useState([]),[C,B]=r.useState(!1),[D,se]=r.useState(""),[G,X]=r.useState(1),[q,ae]=r.useState(!1),[Ve,te]=r.useState(""),[Ye,ne]=r.useState(""),[Je,le]=r.useState(""),[We,ie]=r.useState(""),[Xe,oe]=r.useState(""),[Hs,re]=r.useState(!1),[w,ce]=r.useState("container"),[me,de]=r.useState(""),[Ze,ue]=r.useState(""),[pe,he]=r.useState(""),[xe,be]=r.useState([]),[je,ge]=r.useState([]),[Qe,ve]=r.useState(""),[Ne,fe]=r.useState(""),[ke,ye]=r.useState(""),[es,Ce]=r.useState("unless-stopped"),[ss,Se]=r.useState("missing"),[we,Pe]=r.useState(""),[De,Ee]=r.useState(""),[Le,Ae]=r.useState(""),[Be,ze]=r.useState([]),[Gs,qs]=r.useState(!1),[Re,Oe]=r.useState([]),[as,Te]=r.useState(void 0),[ts,_e]=r.useState(""),[Ie,Fe]=r.useState(""),[ns,$e]=r.useState(!1),[ls,Me]=r.useState(""),is=r.useRef(null),Vs=r.useRef(null),Z=r.useRef(null);r.useEffect(()=>{var i,f,S,_,ms,ds,us,ps,hs,xs,bs,js,gs,vs,Ns,fs,ks,ys,Cs,Ss,ws,Ps,Ds,Es,Ls,As,Bs,zs,Rs,Os,Ts,_s,Is;a&&(s?(N(s.name),y(s.type),F(s.style||"server-rack"),z(s.color||""),M(s.cwd||""),U(((i=s.commands)==null?void 0:i.start)||""),K(((f=s.commands)==null?void 0:f.stop)||""),H(((S=s.commands)==null?void 0:S.restart)||""),T(((_=s.commands)==null?void 0:_.healthCheck)||""),L(((ms=s.commands)==null?void 0:ms.logs)||""),n(s.urls||[]),se(s.folderPath||""),X(s.scale||1),ae(((ds=s.pm2)==null?void 0:ds.enabled)||!1),te(((us=s.pm2)==null?void 0:us.script)||""),ne(((ps=s.pm2)==null?void 0:ps.args)||""),le(((hs=s.pm2)==null?void 0:hs.interpreter)||""),ie(((xs=s.pm2)==null?void 0:xs.interpreterArgs)||""),oe((bs=s.pm2)!=null&&bs.env?Object.entries(s.pm2.env).map(([I,Ue])=>`${I}=${Ue}`).join(`
6
6
  `):""),ce(((js=s.docker)==null?void 0:js.mode)||"container"),de(((gs=s.docker)==null?void 0:gs.mode)==="existing"&&((vs=s.docker)==null?void 0:vs.containerName)||""),ue(((Ns=s.docker)==null?void 0:Ns.image)||""),he(((fs=s.docker)==null?void 0:fs.containerName)||""),be(((ks=s.docker)==null?void 0:ks.ports)||[]),ge(((ys=s.docker)==null?void 0:ys.volumes)||[]),ve((Cs=s.docker)!=null&&Cs.env?Object.entries(s.docker.env).map(([I,Ue])=>`${I}=${Ue}`).join(`
7
- `):""),fe(((Ss=s.docker)==null?void 0:Ss.network)||""),ye(((ws=s.docker)==null?void 0:ws.command)||""),Ce(((Ps=s.docker)==null?void 0:Ps.restart)||"unless-stopped"),Se(((Ds=s.docker)==null?void 0:Ds.pull)||"missing"),Pe(((Es=s.docker)==null?void 0:Es.composePath)||""),Ee(((Ls=s.docker)==null?void 0:Ls.composeProject)||""),Ae(((Bs=(As=s.docker)==null?void 0:As.services)==null?void 0:Bs.join(", "))||""),ze(s.subordinateBuildingIds||[]),Oe(((zs=s.database)==null?void 0:zs.connections)||[]),Te((Rs=s.database)==null?void 0:Rs.activeConnectionId),_e(((Os=s.terminal)==null?void 0:Os.shell)||""),Fe((Ts=s.terminal)!=null&&Ts.port?String(s.terminal.port):""),$e(((_s=s.terminal)==null?void 0:_s.saveSession)||!1),Me(((Is=s.terminal)==null?void 0:Is.args)||"")):(N("New Server"),y("server"),F("server-rack"),z(""),M(na(la.LAST_CWD)),U(""),K(""),H(""),T(""),L(""),n([]),se(""),Z(1),ae(!1),te(""),ne(""),le(""),ie(""),re(""),ce("container"),de(""),ue(""),he(""),be([]),ge([]),ve(""),fe(""),ye(""),Ce("unless-stopped"),Se("missing"),Pe(""),Ee(""),Ae(""),ze([]),Oe([]),Te(void 0),_e(""),Fe(""),$e(!1),Me("")),setTimeout(()=>{var I;return(I=is.current)==null?void 0:I.focus()},100))},[a,s]),o.useEffect(()=>{Q.current&&(Q.current.scrollTop=Q.current.scrollHeight)},[g]),o.useEffect(()=>{p==="docker"&&w==="existing"&&P.requestDockerContainersList()},[p,w]);const rs=i=>{if(i.trim())return Object.fromEntries(i.trim().split(`
8
- `).map(f=>f.trim()).filter(f=>f&&f.includes("=")).map(f=>{const S=f.indexOf("=");return[f.slice(0,S),f.slice(S+1)]}))},Ys=i=>{i.preventDefault();const f={name:x,type:p,style:j,color:$||void 0,position:h||(s==null?void 0:s.position)||{x:0,z:0},cwd:Y||void 0,folderPath:D||void 0,commands:V?void 0:{start:J||void 0,stop:W||void 0,restart:R||void 0,healthCheck:O||void 0,logs:k||void 0},pm2:V?{enabled:!0,script:qe,args:Ye||void 0,interpreter:Je||void 0,interpreterArgs:We||void 0,env:rs(Ze)}:void 0,docker:p==="docker"?{enabled:!0,mode:w,image:w==="container"?Qe:void 0,containerName:w==="container"&&pe?pe:w==="existing"&&me?me:void 0,ports:w==="container"&&xe.length>0?xe:void 0,volumes:w==="container"&&je.length>0?je:void 0,env:rs(Xe),network:w==="container"&&Ne?Ne:void 0,command:w==="container"&&ke?ke:void 0,restart:w==="container"?es:void 0,pull:w!=="existing"?ss:void 0,composePath:w==="compose"&&we?we:void 0,composeProject:w==="compose"&&De?De:void 0,services:w==="compose"&&Le?Le.split(",").map(S=>S.trim()).filter(S=>S):void 0}:void 0,urls:A.length>0?A:void 0,scale:G!==1?G:void 0,subordinateBuildingIds:p==="boss"&&Be.length>0?Be:void 0,database:p==="database"&&Re.length>0?{connections:Re,activeConnectionId:as}:void 0,terminal:p==="terminal"?{enabled:!0,shell:ts||void 0,port:Ie?parseInt(Ie,10):void 0,saveSession:ns||void 0,args:ls||void 0}:void 0};b&&c?P.updateBuilding(c,f):P.createBuilding(f),l()},Js=()=>{oe(!0)},Ws=()=>{c&&(P.deleteBuilding(c),oe(!1),l())},X=i=>{c&&(P.sendBuildingCommand(c,i),i==="logs"&&B(!0))},Zs=()=>{n([...A,{label:"",url:""}])},Qs=i=>{n(A.filter((f,S)=>S!==i))},os=(i,f,S)=>{const _=[...A];_[i]={..._[i],[f]:S},n(_)},{handleMouseDown:Xs,handleClick:ea}=ia(l);if(!a)return null;const cs=c?P.getBuildingLogs(c):[];return e.jsxs("div",{className:"modal-overlay visible",onMouseDown:Xs,onClick:ea,children:[e.jsxs("div",{className:"modal building-config-modal",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("span",{children:t(b?"config:buildings.editBuilding":"config:buildings.addBuilding")}),b&&s&&e.jsx("span",{className:"building-status-badge",style:{backgroundColor:Ge[s.status]},children:s.status})]}),e.jsxs("form",{onSubmit:Ys,children:[e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.name")}),e.jsx("input",{ref:is,type:"text",className:"form-input",value:x,onChange:i=>N(i.target.value),placeholder:t("config:buildings.namePlaceholder"),required:!0})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.type")}),e.jsx("div",{className:"building-type-selector",children:Object.keys(ee).map(i=>e.jsxs("button",{type:"button",className:`building-type-btn ${p===i?"active":""}`,onClick:()=>y(i),title:ee[i].description,children:[e.jsx("span",{className:"building-type-icon",children:ee[i].icon}),e.jsx("span",{className:"building-type-name",children:i})]},i))})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("config:buildings.style")}),e.jsx("div",{className:"building-style-selector",children:Object.keys(Ke).map(i=>e.jsxs("button",{type:"button",className:`building-style-btn ${j===i?"active":""}`,onClick:()=>F(i),title:Ke[i].description,children:[e.jsx("span",{className:"building-style-preview","data-style":i}),e.jsx("span",{className:"building-style-name",children:Ke[i].label})]},i))})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.color")}),e.jsxs("div",{className:"building-color-selector",children:[ra.map(i=>e.jsx("button",{type:"button",className:`building-color-btn ${$===i.value?"active":""}`,onClick:()=>z(i.value),title:oa(i.labelKey),style:i.value?{backgroundColor:i.value}:void 0,children:!i.value&&e.jsx("span",{className:"color-default-icon",children:"⚙"})},i.value||"default")),e.jsx("input",{type:"color",className:"building-color-picker",value:$||"#2a2a3a",onChange:i=>z(i.target.value),title:"Custom color"})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.size")}),e.jsxs("div",{className:"building-size-control",children:[e.jsxs("div",{className:"size-slider-row",children:[e.jsx("input",{type:"range",className:"size-slider",min:"0",max:"100",step:"1",value:Math.log(G/.1)/Math.log(100)*100,onChange:i=>{const f=parseFloat(i.target.value),S=.1*Math.pow(100,f/100);Z(Math.round(S*100)/100)}}),e.jsxs("span",{className:"size-value",children:[G.toFixed(2),"x"]})]}),e.jsx("div",{className:"size-presets",children:[.5,.75,1,1.25,1.5,2].map(i=>e.jsxs("button",{type:"button",className:`size-preset-btn ${G===i?"active":""}`,onClick:()=>Z(i),children:[i,"x"]},i))})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("config:buildings.directory")}),e.jsx(He,{value:Y,onChange:M,placeholder:"/path/to/project",className:"form-input",directoriesOnly:!0})]}),p==="folder"&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("config:buildings.folderPath")}),e.jsx(He,{value:D,onChange:se,placeholder:"/path/to/folder",className:"form-input",directoriesOnly:!0}),e.jsx("div",{className:"form-hint",children:"Click this building to open the file explorer at this path"})]}),p==="boss"&&e.jsx(xa,{buildings:r,buildingId:c,subordinateBuildingIds:Be,setSubordinateBuildingIds:ze,isEditMode:b,showBossLogs:Gs,setShowBossLogs:Vs,currentBossLogs:u,bossLogsContainerRef:qs}),p==="database"&&e.jsx(ha,{dbConnections:Re,setDbConnections:Oe,activeDbConnectionId:as,setActiveDbConnectionId:Te}),p==="server"&&e.jsx(da,{usePM2:V,setUsePM2:ae}),p==="server"&&e.jsx(ua,{usePM2:V,pm2Script:qe,setPm2Script:te,pm2Args:Ye,setPm2Args:ne,pm2Interpreter:Je,setPm2Interpreter:le,pm2InterpreterArgs:We,setPm2InterpreterArgs:ie,pm2Env:Ze,setPm2Env:re,isEditMode:b,building:s??null,handleCommand:X}),p==="docker"&&e.jsx(pa,{dockerMode:w,setDockerMode:ce,dockerImage:Qe,setDockerImage:ue,dockerContainerName:pe,setDockerContainerName:he,dockerCommand:ke,setDockerCommand:ye,dockerPorts:xe,setDockerPorts:be,dockerVolumes:je,setDockerVolumes:ge,dockerNetwork:Ne,setDockerNetwork:fe,dockerRestart:es,setDockerRestart:Ce,dockerPull:ss,setDockerPull:Se,dockerEnv:Xe,setDockerEnv:ve,dockerComposePath:we,setDockerComposePath:Pe,dockerComposeProject:De,setDockerComposeProject:Ee,dockerComposeServices:Le,setDockerComposeServices:Ae,selectedExistingContainer:me,setSelectedExistingContainer:de,dockerContainersList:d,isEditMode:b,building:s??null,handleCommand:X}),p==="terminal"&&e.jsx(ga,{terminalShell:ts,setTerminalShell:_e,terminalPort:Ie,setTerminalPort:Fe,terminalSaveSession:ns,setTerminalSaveSession:$e,terminalArgs:ls,setTerminalArgs:Me,isEditMode:b,building:s??null,handleCommand:X,onOpenTerminal:()=>{s!=null&&s.id&&window.dispatchEvent(new CustomEvent("tide:open-iframe-modal",{detail:{buildingId:s.id}}))},onOpenBelow:i=>{window.dispatchEvent(new CustomEvent("tide:open-bottom-terminal",{detail:{buildingId:i}}))}}),p==="server"&&!V&&e.jsx(ba,{startCmd:J,setStartCmd:U,stopCmd:W,setStopCmd:K,restartCmd:R,setRestartCmd:H,healthCheckCmd:O,setHealthCheckCmd:T,logsCmd:k,setLogsCmd:L,isEditMode:b,handleCommand:X}),e.jsxs("div",{className:"form-section",children:[e.jsxs("label",{className:"form-label",children:[t("config:buildings.links"),e.jsxs("button",{type:"button",className:"btn btn-sm btn-add",onClick:Zs,children:["+ ",t("common:buttons.add")]})]}),A.map((i,f)=>e.jsxs("div",{className:"url-row",children:[e.jsx("input",{type:"text",className:"form-input url-label",value:i.label,onChange:S=>os(f,"label",S.target.value),placeholder:"Label"}),e.jsx("input",{type:"text",className:"form-input url-value",value:i.url,onChange:S=>os(f,"url",S.target.value),placeholder:"https://..."}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>Qs(f),children:"x"})]},f))]}),b&&C&&cs.length>0&&e.jsx(va,{logs:cs,buildingId:c,logsContainerRef:Q})]}),e.jsxs("div",{className:"modal-footer",children:[b&&e.jsx("button",{type:"button",className:"btn btn-danger",onClick:Js,children:t("common:buttons.delete")}),e.jsx("div",{className:"footer-spacer"}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:l,children:t("common:buttons.cancel")}),e.jsx("button",{type:"submit",className:"btn btn-primary",children:t(b?"common:buttons.save":"common:buttons.create")})]})]})]}),Hs&&s&&e.jsx(ma,{buildingName:s.name,onClose:()=>oe(!1),onConfirm:Ws})]})}export{Ca as BuildingConfigModal};
7
+ `):""),fe(((Ss=s.docker)==null?void 0:Ss.network)||""),ye(((ws=s.docker)==null?void 0:ws.command)||""),Ce(((Ps=s.docker)==null?void 0:Ps.restart)||"unless-stopped"),Se(((Ds=s.docker)==null?void 0:Ds.pull)||"missing"),Pe(((Es=s.docker)==null?void 0:Es.composePath)||""),Ee(((Ls=s.docker)==null?void 0:Ls.composeProject)||""),Ae(((Bs=(As=s.docker)==null?void 0:As.services)==null?void 0:Bs.join(", "))||""),ze(s.subordinateBuildingIds||[]),Oe(((zs=s.database)==null?void 0:zs.connections)||[]),Te((Rs=s.database)==null?void 0:Rs.activeConnectionId),_e(((Os=s.terminal)==null?void 0:Os.shell)||""),Fe((Ts=s.terminal)!=null&&Ts.port?String(s.terminal.port):""),$e(((_s=s.terminal)==null?void 0:_s.saveSession)||!1),Me(((Is=s.terminal)==null?void 0:Is.args)||"")):(N("New Server"),y("server"),F("server-rack"),z(""),M(na(la.LAST_CWD)),U(""),K(""),H(""),T(""),L(""),n([]),se(""),X(1),ae(!1),te(""),ne(""),le(""),ie(""),oe(""),ce("container"),de(""),ue(""),he(""),be([]),ge([]),ve(""),fe(""),ye(""),Ce("unless-stopped"),Se("missing"),Pe(""),Ee(""),Ae(""),ze([]),Oe([]),Te(void 0),_e(""),Fe(""),$e(!1),Me("")),setTimeout(()=>{var I;return(I=is.current)==null?void 0:I.focus()},100))},[a,s]),r.useEffect(()=>{Z.current&&(Z.current.scrollTop=Z.current.scrollHeight)},[g]),r.useEffect(()=>{p==="docker"&&w==="existing"&&P.requestDockerContainersList()},[p,w]);const os=i=>{if(i.trim())return Object.fromEntries(i.trim().split(`
8
+ `).map(f=>f.trim()).filter(f=>f&&f.includes("=")).map(f=>{const S=f.indexOf("=");return[f.slice(0,S),f.slice(S+1)]}))},Ys=i=>{i.preventDefault();const f={name:x,type:p,style:j,color:$||void 0,position:h||(s==null?void 0:s.position)||{x:0,z:0},cwd:Y||void 0,folderPath:D||void 0,commands:q?void 0:{start:J||void 0,stop:W||void 0,restart:R||void 0,healthCheck:O||void 0,logs:k||void 0},pm2:q?{enabled:!0,script:Ve,args:Ye||void 0,interpreter:Je||void 0,interpreterArgs:We||void 0,env:os(Xe)}:void 0,docker:p==="docker"?{enabled:!0,mode:w,image:w==="container"?Ze:void 0,containerName:w==="container"&&pe?pe:w==="existing"&&me?me:void 0,ports:w==="container"&&xe.length>0?xe:void 0,volumes:w==="container"&&je.length>0?je:void 0,env:os(Qe),network:w==="container"&&Ne?Ne:void 0,command:w==="container"&&ke?ke:void 0,restart:w==="container"?es:void 0,pull:w!=="existing"?ss:void 0,composePath:w==="compose"&&we?we:void 0,composeProject:w==="compose"&&De?De:void 0,services:w==="compose"&&Le?Le.split(",").map(S=>S.trim()).filter(S=>S):void 0}:void 0,urls:A.length>0?A:void 0,scale:G!==1?G:void 0,subordinateBuildingIds:p==="boss"&&Be.length>0?Be:void 0,database:p==="database"&&Re.length>0?{connections:Re,activeConnectionId:as}:void 0,terminal:p==="terminal"?{enabled:!0,shell:ts||void 0,port:Ie?parseInt(Ie,10):void 0,saveSession:ns||void 0,args:ls||void 0}:void 0};b&&c?P.updateBuilding(c,f):P.createBuilding(f),l()},Js=()=>{re(!0)},Ws=()=>{c&&(P.deleteBuilding(c),re(!1),l())},Q=i=>{c&&(P.sendBuildingCommand(c,i),i==="logs"&&B(!0))},Xs=()=>{n([...A,{label:"",url:""}])},Zs=i=>{n(A.filter((f,S)=>S!==i))},rs=(i,f,S)=>{const _=[...A];_[i]={..._[i],[f]:S},n(_)},{handleMouseDown:Qs,handleClick:ea}=ia(l);if(!a)return null;const cs=c?P.getBuildingLogs(c):[];return e.jsxs("div",{className:"modal-overlay visible",onMouseDown:Qs,onClick:ea,children:[e.jsxs("div",{className:"modal building-config-modal",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("span",{children:t(b?"config:buildings.editBuilding":"config:buildings.addBuilding")}),b&&s&&e.jsx("span",{className:"building-status-badge",style:{backgroundColor:Ge[s.status]},children:s.status})]}),e.jsxs("form",{onSubmit:Ys,children:[e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.name")}),e.jsx("input",{ref:is,type:"text",className:"form-input",value:x,onChange:i=>N(i.target.value),placeholder:t("config:buildings.namePlaceholder"),required:!0})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.type")}),e.jsx("div",{className:"building-type-selector",children:Object.keys(ee).map(i=>e.jsxs("button",{type:"button",className:`building-type-btn ${p===i?"active":""}`,onClick:()=>y(i),title:ee[i].description,children:[e.jsx("span",{className:"building-type-icon",children:ee[i].icon}),e.jsx("span",{className:"building-type-name",children:i})]},i))})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("config:buildings.style")}),e.jsx("div",{className:"building-style-selector",children:Object.keys(Ke).map(i=>e.jsxs("button",{type:"button",className:`building-style-btn ${j===i?"active":""}`,onClick:()=>F(i),title:Ke[i].description,children:[e.jsx("span",{className:"building-style-preview","data-style":i}),e.jsx("span",{className:"building-style-name",children:Ke[i].label})]},i))})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.color")}),e.jsxs("div",{className:"building-color-selector",children:[oa.map(i=>e.jsx("button",{type:"button",className:`building-color-btn ${$===i.value?"active":""}`,onClick:()=>z(i.value),title:ra(i.labelKey),style:i.value?{backgroundColor:i.value}:void 0,children:!i.value&&e.jsx("span",{className:"color-default-icon",children:"⚙"})},i.value||"default")),e.jsx("input",{type:"color",className:"building-color-picker",value:$||"#2a2a3a",onChange:i=>z(i.target.value),title:"Custom color"})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("common:labels.size")}),e.jsxs("div",{className:"building-size-control",children:[e.jsxs("div",{className:"size-slider-row",children:[e.jsx("input",{type:"range",className:"size-slider",min:"0",max:"100",step:"1",value:Math.log(G/.1)/Math.log(100)*100,onChange:i=>{const f=parseFloat(i.target.value),S=.1*Math.pow(100,f/100);X(Math.round(S*100)/100)}}),e.jsxs("span",{className:"size-value",children:[G.toFixed(2),"x"]})]}),e.jsx("div",{className:"size-presets",children:[.5,.75,1,1.25,1.5,2].map(i=>e.jsxs("button",{type:"button",className:`size-preset-btn ${G===i?"active":""}`,onClick:()=>X(i),children:[i,"x"]},i))})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("config:buildings.directory")}),e.jsx(He,{value:Y,onChange:M,placeholder:"/path/to/project",className:"form-input",directoriesOnly:!0})]}),p==="folder"&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:t("config:buildings.folderPath")}),e.jsx(He,{value:D,onChange:se,placeholder:"/path/to/folder",className:"form-input",directoriesOnly:!0}),e.jsx("div",{className:"form-hint",children:"Click this building to open the file explorer at this path"})]}),p==="boss"&&e.jsx(xa,{buildings:o,buildingId:c,subordinateBuildingIds:Be,setSubordinateBuildingIds:ze,isEditMode:b,showBossLogs:Gs,setShowBossLogs:qs,currentBossLogs:u,bossLogsContainerRef:Vs}),p==="database"&&e.jsx(ha,{dbConnections:Re,setDbConnections:Oe,activeDbConnectionId:as,setActiveDbConnectionId:Te}),p==="server"&&e.jsx(da,{usePM2:q,setUsePM2:ae}),p==="server"&&e.jsx(ua,{usePM2:q,pm2Script:Ve,setPm2Script:te,pm2Args:Ye,setPm2Args:ne,pm2Interpreter:Je,setPm2Interpreter:le,pm2InterpreterArgs:We,setPm2InterpreterArgs:ie,pm2Env:Xe,setPm2Env:oe,isEditMode:b,building:s??null,handleCommand:Q}),p==="docker"&&e.jsx(pa,{dockerMode:w,setDockerMode:ce,dockerImage:Ze,setDockerImage:ue,dockerContainerName:pe,setDockerContainerName:he,dockerCommand:ke,setDockerCommand:ye,dockerPorts:xe,setDockerPorts:be,dockerVolumes:je,setDockerVolumes:ge,dockerNetwork:Ne,setDockerNetwork:fe,dockerRestart:es,setDockerRestart:Ce,dockerPull:ss,setDockerPull:Se,dockerEnv:Qe,setDockerEnv:ve,dockerComposePath:we,setDockerComposePath:Pe,dockerComposeProject:De,setDockerComposeProject:Ee,dockerComposeServices:Le,setDockerComposeServices:Ae,selectedExistingContainer:me,setSelectedExistingContainer:de,dockerContainersList:d,isEditMode:b,building:s??null,handleCommand:Q}),p==="terminal"&&e.jsx(ga,{terminalShell:ts,setTerminalShell:_e,terminalPort:Ie,setTerminalPort:Fe,terminalSaveSession:ns,setTerminalSaveSession:$e,terminalArgs:ls,setTerminalArgs:Me,isEditMode:b,building:s??null,handleCommand:Q,onOpenTerminal:()=>{s!=null&&s.id&&window.dispatchEvent(new CustomEvent("tide:open-iframe-modal",{detail:{buildingId:s.id}}))},onOpenBelow:i=>{window.dispatchEvent(new CustomEvent("tide:open-bottom-terminal",{detail:{buildingId:i}}))}}),p==="server"&&!q&&e.jsx(ba,{startCmd:J,setStartCmd:U,stopCmd:W,setStopCmd:K,restartCmd:R,setRestartCmd:H,healthCheckCmd:O,setHealthCheckCmd:T,logsCmd:k,setLogsCmd:L,isEditMode:b,handleCommand:Q}),e.jsxs("div",{className:"form-section",children:[e.jsxs("label",{className:"form-label",children:[t("config:buildings.links"),e.jsxs("button",{type:"button",className:"btn btn-sm btn-add",onClick:Xs,children:["+ ",t("common:buttons.add")]})]}),A.map((i,f)=>e.jsxs("div",{className:"url-row",children:[e.jsx("input",{type:"text",className:"form-input url-label",value:i.label,onChange:S=>rs(f,"label",S.target.value),placeholder:"Label"}),e.jsx("input",{type:"text",className:"form-input url-value",value:i.url,onChange:S=>rs(f,"url",S.target.value),placeholder:"https://..."}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>Zs(f),children:"x"})]},f))]}),b&&C&&cs.length>0&&e.jsx(va,{logs:cs,buildingId:c,logsContainerRef:Z})]}),e.jsxs("div",{className:"modal-footer",children:[b&&e.jsx("button",{type:"button",className:"btn btn-danger",onClick:Js,children:t("common:buttons.delete")}),e.jsx("div",{className:"footer-spacer"}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:l,children:t("common:buttons.cancel")}),e.jsx("button",{type:"submit",className:"btn btn-primary",children:t(b?"common:buttons.save":"common:buttons.create")})]})]})]}),Hs&&s&&e.jsx(ma,{buildingName:s.name,onClose:()=>re(!1),onConfirm:Ws})]})}export{Ca as BuildingConfigModal};
@@ -1,5 +1,5 @@
1
- import{al as Te,r as t,s as M,p as Me,am as ye,L as $e,j as e,u as fe,an as Le,ao as Fe,ap as Ee,aq as Oe,ar as _e,k as He,as as Be,at as Ie,au as Ue,av as Ke,aw as We,ax as Ve,Y as ze,J as Se,S as le,O as Ge,K as qe,A as Ye,W as Ne,y as Je,B as Xe,ay as Qe,m as Q,az as Ze}from"./main-Cjm0d8dZ.js";import{F as et}from"./index-D4nfDvz4.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ke={status:"all",activity:"all",sort:"activity"},tt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},be=20,me=3,st={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},nt=12e4;function at(s){return s.trim().replace(/\r\n/g,`
2
- `)}function De(s,a){return`${s}:${at(a)}`}function ot(s,a,o,f){if(s.uuid&&a.has(s.uuid))return!1;const p=s.isUserPrompt?"user":"assistant",u=De(p,s.text),A=s.timestamp||0,S=o.get(u);return S!==void 0&&Math.abs(A-S)<=nt?!1:A>f}function lt({isOpen:s,agents:a}){const o=Te(),[f,p]=t.useState(new Map),u=t.useRef(new Set);t.useRef(a);const A=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),S=t.useMemo(()=>Array.from(a.values()).map(x=>`${x.id}:${x.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{s||(u.current.clear(),p(new Map))},[s]),t.useEffect(()=>{if(!s)return;const x=new Set(Array.from(a.keys()));for(const m of u.current)x.has(m)||u.current.delete(m);let v=null;o>0&&(v=M.preserveOutputs(),u.current.clear());const w=async(m,C,O=0)=>{if(u.current.add(m.id),O>0&&await new Promise(h=>setTimeout(h,O)),p(h=>{const I=new Map(h);return I.set(m.id,{agentId:m.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),I}),!m.sessionId){C&&C.length>0&&M.mergeOutputsWithHistory(m.id,[],C),p(h=>{const I=new Map(h);return I.set(m.id,{agentId:m.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),I});return}try{const I=await(await $e(Me(`/api/agents/${m.id}/history?limit=${ye}&offset=0`))).json(),D=I.messages||[],B=D.length>0?Math.max(...D.map(j=>j.timestamp?new Date(j.timestamp).getTime():0)):0,z=new Set(D.map(j=>j.uuid).filter(j=>!!j)),U=new Map;for(const j of D){if(j.type!=="user"&&j.type!=="assistant")continue;const l=De(j.type,j.content),_=j.timestamp?new Date(j.timestamp).getTime():0,L=U.get(l)??0;_>L&&U.set(l,_)}const K=M.getOutputs(m.id),Y=(C&&C.length>0?[...C,...K]:K).filter(j=>ot(j,z,U,B));M.clearOutputs(m.id);for(const j of Y)M.addOutput(m.id,j);p(j=>{const l=new Map(j);return l.set(m.id,{agentId:m.id,messages:D,loading:!1,hasMore:I.hasMore||!1,totalCount:I.totalCount||0}),l})}catch(h){if(console.error(`Failed to load history for ${m.name}:`,h),C&&C.length>0){M.clearOutputs(m.id);for(const I of C)M.addOutput(m.id,I)}p(I=>{const D=new Map(I);return D.set(m.id,{agentId:m.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),D})}},i=o>0?500:0,y=Array.from(a.values());for(const m of y)if(!u.current.has(m.id)){const C=v==null?void 0:v.get(m.id);w(m,C,i)}},[s,A,S,o]);const R=t.useRef(a),N=t.useRef(f);R.current=a,N.current=f;const b=t.useCallback(async x=>{const v=R.current.get(x),w=N.current.get(x);if(!(v!=null&&v.sessionId)||!w||!w.hasMore)return;const i=w.messages.length;try{const m=await(await fetch(Me(`/api/agents/${x}/history?limit=${ye}&offset=${i}`))).json();m.messages&&m.messages.length>0&&p(C=>{const O=new Map(C),h=C.get(x);return h&&O.set(x,{...h,messages:[...m.messages,...h.messages],hasMore:m.hasMore||!1}),O})}catch(y){console.error(`Failed to load more history for agent ${x}:`,y)}},[]),E=t.useCallback(x=>{u.current.delete(x),p(v=>{const w=new Map(v),i=v.get(x);return i&&w.set(x,{...i,messages:[],hasMore:!1,totalCount:0,loading:!1}),w})},[]);return{histories:f,loadMoreHistory:b,clearAgentHistory:E}}function ct({command:s,onCommandChange:a,useTextarea:o,forceTextarea:f,onForceTextarea:p,onSend:u,canSend:A,attachedFiles:S,onAddFile:R,onRemoveFile:N,uploadFile:b,onAddPastedText:E,placeholder:x="Message...",className:v="",compact:w=!1,inputRef:i}){const y=t.useRef(null),m=t.useRef(null),C=t.useRef(o);t.useEffect(()=>{if(o&&!C.current&&m.current){const l=m.current;l.focus(),l.selectionStart=l.selectionEnd=l.value.length}C.current=o},[o]),t.useEffect(()=>{const l=m.current;if(!l||!o)return;l.style.height="auto";const _=w?120:180,L=Math.min(l.scrollHeight,_);l.style.height=`${L}px`},[s,o,w]);const O=t.useCallback(async l=>{const _=l.clipboardData.items;for(const H of _)if(H.type.startsWith("image/")){l.preventDefault();const $=H.getAsFile();if($){const T=await b($);T&&R(T)}return}const L=l.clipboardData.files;if(L.length>0){l.preventDefault();for(const H of L){const $=await b(H);$&&R($)}return}const J=l.clipboardData.getData("text"),G=(J.match(/\n/g)||[]).length+1;if(G>5){l.preventDefault();const $=`[Pasted text #${E(J)} +${G} lines]`,T=l.target,W=T.selectionStart||0,se=T.selectionEnd||0,ne=s.slice(0,W)+$+s.slice(se);a(ne),o||p(!0)}},[s,a,o,p,b,R,E]),h=t.useCallback(async l=>{const _=l.target.files;if(_){for(const L of _){const J=await b(L);J&&R(J)}y.current&&(y.current.value="")}},[b,R]),I=t.useCallback(l=>{if(l.key==="Enter"&&l.shiftKey){o||(l.preventDefault(),p(!0));return}l.key==="Enter"&&(l.preventDefault(),u())},[o,p,u]),D=t.useCallback(l=>{},[]),B=t.useCallback(l=>{l.button===1&&(l.preventDefault(),l.stopPropagation())},[]),z=t.useCallback(l=>{m.current=l,i==null||i(l)},[i]),U=w?"agent-panel-input":"guake-input",K=w?"agent-panel-input-container":"guake-input-container",ee=w?"agent-panel-attach-btn":"guake-attach-btn",Y=w?"agent-panel-send-btn":"",j=o?w?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[S.length>0&&e.jsx("div",{className:w?"agent-panel-attachments":"guake-attachments",children:S.map(l=>e.jsxs("div",{className:`${w?"agent-panel-attachment":"guake-attachment"} ${l.isImage?"is-image":""}`,children:[e.jsx("span",{className:w?"agent-panel-attachment-icon":"guake-attachment-icon",children:l.isImage?"🖼️":"📎"}),e.jsx("span",{className:w?"agent-panel-attachment-name":"guake-attachment-name",title:l.path,children:l.name}),!w&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(l.size/1024),"KB)"]}),e.jsx("button",{className:w?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>N(l.id),title:"Remove",children:"×"})]},l.id))}),e.jsxs("div",{className:`${U} ${j} ${v}`,children:[e.jsx("input",{ref:y,type:"file",multiple:!0,onChange:h,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:K,onAuxClick:B,children:[e.jsx("button",{className:ee,onClick:()=>{var l;return(l=y.current)==null?void 0:l.click()},title:"Attach file (or paste image)",children:"📎"}),o?e.jsx("textarea",{ref:z,placeholder:x,value:s,onChange:l=>a(l.target.value),onKeyDown:I,onPaste:O,onMouseDown:D}):e.jsx("input",{ref:i,type:"text",placeholder:x,value:s,onChange:l=>a(l.target.value),onKeyDown:I,onPaste:O,onMouseDown:D}),e.jsx("button",{className:Y,onClick:u,disabled:!A,title:"Send",children:"➤"})]})]})]})}function rt(s){const a=Math.floor(s/1e3),o=Math.floor(a/60),f=a%60;return`${o}:${f.toString().padStart(2,"0")}`}const it=t.memo(function({agentId:a,isWorking:o,timestamp:f}){const{t:p}=fe(["terminal"]),[u,A]=t.useState(0);return t.useEffect(()=>{if(!o||!f){A(0);return}A(Date.now()-f);const S=setInterval(()=>{A(Date.now()-f)},1e3);return()=>clearInterval(S)},[o,f]),o?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:rt(u)}),e.jsxs("button",{className:"guake-stop-btn",onClick:()=>M.stopAgent(a),title:p("terminal:input.stopOperation"),children:[e.jsx("span",{className:"stop-icon",children:"■"}),e.jsx("span",{className:"stop-label",children:p("terminal:input.stop")})]})]}):null});function dt({agent:s,history:a,outputs:o,isExpanded:f,isFocused:p,advancedView:u,onExpand:A,onFocus:S,inputRef:R,onLoadMore:N,onClearHistory:b}){const{t:E}=fe(["terminal","common"]),x=Le(),v=Fe(s.id),w=t.useRef(null),[i,y]=t.useState(!1),m=t.useRef(0),C=t.useRef(!1),[O,h]=t.useState(!0),[I,D]=t.useState(!1),[B,z]=t.useState(null),[U,K]=t.useState(null),[ee,Y]=t.useState(null);Ee(`commander-image-modal-${s.id}`,B!==null,()=>z(null));const{command:j,setCommand:l,forceTextarea:_,setForceTextarea:L,useTextarea:J,setPastedTexts:G,incrementPastedCount:H,resetPastedCount:$,attachedFiles:T,setAttachedFiles:W,removeAttachedFile:se,uploadFile:ne,expandPastedTexts:ce}=Oe({selectedAgentId:s.id}),ae=j.trim().length>0||T.length>0,c=_e({outputs:o,viewMode:u?"advanced":"simple"}),g=t.useMemo(()=>x!=null&&x.agentSummaries?x.agentSummaries.find(k=>k.agentId===s.id||k.agentName===s.name):null,[x,s.id,s.name]),d=t.useMemo(()=>{const k=He(s);return{usedPercent:k.usedPercent,freePercent:k.freePercent,hasData:!!s.contextStats,totalTokens:k.totalTokens,contextWindow:k.contextWindow}},[s.contextStats,s.contextUsed,s.contextLimit]),P=t.useCallback(()=>{!i&&(a!=null&&a.hasMore)&&N&&(y(!0),m.current=w.current?w.current.scrollHeight-w.current.scrollTop:0,N())},[i,a==null?void 0:a.hasMore,N]);t.useEffect(()=>{i&&a&&!a.loading&&y(!1)},[a,i]);const te=t.useCallback(()=>{C.current=!0,h(!1)},[]),Z=t.useRef(f),V=t.useRef(p);t.useEffect(()=>{(f&&!Z.current||p&&!V.current)&&(C.current=!1,h(!0),D(!0)),Z.current=f,V.current=p},[f,p]);const re=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{re.current&&!(a!=null&&a.loading)&&(C.current=!1,h(!0),D(!0)),re.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{C.current||h(!0)},[c.length]);const pe=t.useCallback(()=>!1,[]),he=t.useCallback(k=>{const F=H();return G(q=>new Map(q).set(F,k)),F},[H,G]),ge=t.useCallback(k=>{W(F=>[...F,k])},[W]),xe=t.useCallback(()=>{if(!ae)return;if(j.trim()==="/clear"&&T.length===0){M.clearContext(s.id),b(),l(""),L(!1),G(new Map),W([]),$();return}let k=ce(j.trim());if(T.length>0){const F=T.map(q=>q.isImage?`[Image: ${q.path}]`:`[File: ${q.path}]`).join(`
1
+ import{ar as Te,r as t,s as M,w as Me,as as Ie,V as $e,j as e,u as fe,at as Fe,au as Le,av as Ee,aw as _e,ax as Oe,k as He,ay as Ue,az as Re,aA as Be,aB as Ke,aC as We,aD as Ve,a2 as ze,P as Se,S as ce,Y as Ge,U as Ye,A as qe,a0 as Ne,H as Je,J as Xe,aE as Qe,m as Q,aF as Ze}from"./main-CtGyoZXd.js";import{F as et}from"./index-Bmu_CPsU.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ke={status:"all",activity:"all",sort:"activity"},tt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},be=20,me=3,st={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},nt=12e4;function at(s){return s.trim().replace(/\r\n/g,`
2
+ `)}function De(s,a){return`${s}:${at(a)}`}function ot(s,a,o,f){if(s.uuid&&a.has(s.uuid))return!1;const p=s.isUserPrompt?"user":"assistant",u=De(p,s.text),A=s.timestamp||0,S=o.get(u);return S!==void 0&&Math.abs(A-S)<=nt?!1:A>f}function ct({isOpen:s,agents:a}){const o=Te(),[f,p]=t.useState(new Map),u=t.useRef(new Set);t.useRef(a);const A=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),S=t.useMemo(()=>Array.from(a.values()).map(x=>`${x.id}:${x.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{s||(u.current.clear(),p(new Map))},[s]),t.useEffect(()=>{if(!s)return;const x=new Set(Array.from(a.keys()));for(const m of u.current)x.has(m)||u.current.delete(m);let v=null;o>0&&(v=M.preserveOutputs(),u.current.clear());const w=async(m,C,_=0)=>{if(u.current.add(m.id),_>0&&await new Promise(h=>setTimeout(h,_)),p(h=>{const R=new Map(h);return R.set(m.id,{agentId:m.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),R}),!m.sessionId){C&&C.length>0&&M.mergeOutputsWithHistory(m.id,[],C),p(h=>{const R=new Map(h);return R.set(m.id,{agentId:m.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),R});return}try{const R=await(await $e(Me(`/api/agents/${m.id}/history?limit=${Ie}&offset=0`))).json(),D=R.messages||[],U=D.length>0?Math.max(...D.map(j=>j.timestamp?new Date(j.timestamp).getTime():0)):0,z=new Set(D.map(j=>j.uuid).filter(j=>!!j)),B=new Map;for(const j of D){if(j.type!=="user"&&j.type!=="assistant")continue;const c=De(j.type,j.content),O=j.timestamp?new Date(j.timestamp).getTime():0,F=B.get(c)??0;O>F&&B.set(c,O)}const K=M.getOutputs(m.id),q=(C&&C.length>0?[...C,...K]:K).filter(j=>ot(j,z,B,U));M.clearOutputs(m.id);for(const j of q)M.addOutput(m.id,j);p(j=>{const c=new Map(j);return c.set(m.id,{agentId:m.id,messages:D,loading:!1,hasMore:R.hasMore||!1,totalCount:R.totalCount||0}),c})}catch(h){if(console.error(`Failed to load history for ${m.name}:`,h),C&&C.length>0){M.clearOutputs(m.id);for(const R of C)M.addOutput(m.id,R)}p(R=>{const D=new Map(R);return D.set(m.id,{agentId:m.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),D})}},i=o>0?500:0,I=Array.from(a.values());for(const m of I)if(!u.current.has(m.id)){const C=v==null?void 0:v.get(m.id);w(m,C,i)}},[s,A,S,o]);const y=t.useRef(a),N=t.useRef(f);y.current=a,N.current=f;const b=t.useCallback(async x=>{const v=y.current.get(x),w=N.current.get(x);if(!(v!=null&&v.sessionId)||!w||!w.hasMore)return;const i=w.messages.length;try{const m=await(await fetch(Me(`/api/agents/${x}/history?limit=${Ie}&offset=${i}`))).json();m.messages&&m.messages.length>0&&p(C=>{const _=new Map(C),h=C.get(x);return h&&_.set(x,{...h,messages:[...m.messages,...h.messages],hasMore:m.hasMore||!1}),_})}catch(I){console.error(`Failed to load more history for agent ${x}:`,I)}},[]),E=t.useCallback(x=>{u.current.delete(x),p(v=>{const w=new Map(v),i=v.get(x);return i&&w.set(x,{...i,messages:[],hasMore:!1,totalCount:0,loading:!1}),w})},[]);return{histories:f,loadMoreHistory:b,clearAgentHistory:E}}function lt({command:s,onCommandChange:a,useTextarea:o,forceTextarea:f,onForceTextarea:p,onSend:u,canSend:A,attachedFiles:S,onAddFile:y,onRemoveFile:N,uploadFile:b,onAddPastedText:E,placeholder:x="Message...",className:v="",compact:w=!1,inputRef:i}){const I=t.useRef(null),m=t.useRef(null),C=t.useRef(o);t.useEffect(()=>{if(o&&!C.current&&m.current){const c=m.current;c.focus(),c.selectionStart=c.selectionEnd=c.value.length}C.current=o},[o]),t.useEffect(()=>{const c=m.current;if(!c||!o)return;c.style.height="auto";const O=w?120:180,F=Math.min(c.scrollHeight,O);c.style.height=`${F}px`},[s,o,w]);const _=t.useCallback(async c=>{const O=c.clipboardData.items;for(const H of O)if(H.type.startsWith("image/")){c.preventDefault();const $=H.getAsFile();if($){const T=await b($);T&&y(T)}return}const F=c.clipboardData.files;if(F.length>0){c.preventDefault();for(const H of F){const $=await b(H);$&&y($)}return}const J=c.clipboardData.getData("text"),G=(J.match(/\n/g)||[]).length+1;if(G>5){c.preventDefault();const $=`[Pasted text #${E(J)} +${G} lines]`,T=c.target,W=T.selectionStart||0,se=T.selectionEnd||0,ne=s.slice(0,W)+$+s.slice(se);a(ne),o||p(!0)}},[s,a,o,p,b,y,E]),h=t.useCallback(async c=>{const O=c.target.files;if(O){for(const F of O){const J=await b(F);J&&y(J)}I.current&&(I.current.value="")}},[b,y]),R=t.useCallback(c=>{if(c.key==="Enter"&&c.shiftKey){o||(c.preventDefault(),p(!0));return}c.key==="Enter"&&(c.preventDefault(),u())},[o,p,u]),D=t.useCallback(c=>{},[]),U=t.useCallback(c=>{c.button===1&&(c.preventDefault(),c.stopPropagation())},[]),z=t.useCallback(c=>{m.current=c,i==null||i(c)},[i]),B=w?"agent-panel-input":"guake-input",K=w?"agent-panel-input-container":"guake-input-container",ee=w?"agent-panel-attach-btn":"guake-attach-btn",q=w?"agent-panel-send-btn":"",j=o?w?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[S.length>0&&e.jsx("div",{className:w?"agent-panel-attachments":"guake-attachments",children:S.map(c=>e.jsxs("div",{className:`${w?"agent-panel-attachment":"guake-attachment"} ${c.isImage?"is-image":""}`,children:[e.jsx("span",{className:w?"agent-panel-attachment-icon":"guake-attachment-icon",children:c.isImage?"🖼️":"📎"}),e.jsx("span",{className:w?"agent-panel-attachment-name":"guake-attachment-name",title:c.path,children:c.name}),!w&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(c.size/1024),"KB)"]}),e.jsx("button",{className:w?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>N(c.id),title:"Remove",children:"×"})]},c.id))}),e.jsxs("div",{className:`${B} ${j} ${v}`,children:[e.jsx("input",{ref:I,type:"file",multiple:!0,onChange:h,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:K,onAuxClick:U,children:[e.jsx("button",{className:ee,onClick:()=>{var c;return(c=I.current)==null?void 0:c.click()},title:"Attach file (or paste image)",children:"📎"}),o?e.jsx("textarea",{ref:z,placeholder:x,value:s,onChange:c=>a(c.target.value),onKeyDown:R,onPaste:_,onMouseDown:D}):e.jsx("input",{ref:i,type:"text",placeholder:x,value:s,onChange:c=>a(c.target.value),onKeyDown:R,onPaste:_,onMouseDown:D}),e.jsx("button",{className:q,onClick:u,disabled:!A,title:"Send",children:"➤"})]})]})]})}function rt(s){const a=Math.floor(s/1e3),o=Math.floor(a/60),f=a%60;return`${o}:${f.toString().padStart(2,"0")}`}const it=t.memo(function({agentId:a,isWorking:o,timestamp:f}){const{t:p}=fe(["terminal"]),[u,A]=t.useState(0);return t.useEffect(()=>{if(!o||!f){A(0);return}A(Date.now()-f);const S=setInterval(()=>{A(Date.now()-f)},1e3);return()=>clearInterval(S)},[o,f]),o?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:rt(u)}),e.jsxs("button",{className:"guake-stop-btn",onClick:()=>M.stopAgent(a),title:p("terminal:input.stopOperation"),children:[e.jsx("span",{className:"stop-icon",children:"■"}),e.jsx("span",{className:"stop-label",children:p("terminal:input.stop")})]})]}):null});function dt({agent:s,history:a,outputs:o,isExpanded:f,isFocused:p,advancedView:u,onExpand:A,onFocus:S,inputRef:y,onLoadMore:N,onClearHistory:b}){const{t:E}=fe(["terminal","common"]),x=Fe(),v=Le(s.id),w=t.useRef(null),[i,I]=t.useState(!1),m=t.useRef(0),C=t.useRef(!1),[_,h]=t.useState(!0),[R,D]=t.useState(!1),[U,z]=t.useState(null),[B,K]=t.useState(null),[ee,q]=t.useState(null);Ee(`commander-image-modal-${s.id}`,U!==null,()=>z(null));const{command:j,setCommand:c,forceTextarea:O,setForceTextarea:F,useTextarea:J,setPastedTexts:G,incrementPastedCount:H,resetPastedCount:$,attachedFiles:T,setAttachedFiles:W,removeAttachedFile:se,uploadFile:ne,expandPastedTexts:le}=_e({selectedAgentId:s.id}),ae=j.trim().length>0||T.length>0,l=Oe({outputs:o,viewMode:u?"advanced":"simple"}),g=t.useMemo(()=>x!=null&&x.agentSummaries?x.agentSummaries.find(k=>k.agentId===s.id||k.agentName===s.name):null,[x,s.id,s.name]),d=t.useMemo(()=>{const k=He(s);return{usedPercent:k.usedPercent,freePercent:k.freePercent,hasData:!!s.contextStats,totalTokens:k.totalTokens,contextWindow:k.contextWindow}},[s.contextStats,s.contextUsed,s.contextLimit]),P=t.useCallback(()=>{!i&&(a!=null&&a.hasMore)&&N&&(I(!0),m.current=w.current?w.current.scrollHeight-w.current.scrollTop:0,N())},[i,a==null?void 0:a.hasMore,N]);t.useEffect(()=>{i&&a&&!a.loading&&I(!1)},[a,i]);const te=t.useCallback(()=>{C.current=!0,h(!1)},[]),Z=t.useRef(f),V=t.useRef(p);t.useEffect(()=>{(f&&!Z.current||p&&!V.current)&&(C.current=!1,h(!0),D(!0)),Z.current=f,V.current=p},[f,p]);const re=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{re.current&&!(a!=null&&a.loading)&&(C.current=!1,h(!0),D(!0)),re.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{C.current||h(!0)},[l.length]);const pe=t.useCallback(()=>!1,[]),he=t.useCallback(k=>{const L=H();return G(Y=>new Map(Y).set(L,k)),L},[H,G]),ge=t.useCallback(k=>{W(L=>[...L,k])},[W]),xe=t.useCallback(()=>{if(!ae)return;if(j.trim()==="/clear"&&T.length===0){M.clearContext(s.id),b(),c(""),F(!1),G(new Map),W([]),$();return}let k=le(j.trim());if(T.length>0){const L=T.map(Y=>Y.isImage?`[Image: ${Y.path}]`:`[File: ${Y.path}]`).join(`
3
3
  `);k=k?`${k}
4
4
 
5
- ${F}`:F}M.sendCommand(s.id,k),l(""),L(!1),G(new Map),W([]),$()},[s.id,j,ae,T,ce,b,$,l,L,G,W]),ve=t.useCallback((k,F)=>{z({url:k,name:F})},[]),we=t.useCallback((k,F)=>{const q=Be(k,s.cwd),Pe=q.line?{...F||{},targetLine:q.line}:F;M.setFileViewerPath(q.path,Pe,s.cwd)},[s.cwd]),Ce=t.useCallback((k,F)=>{K({command:k,output:F,isLive:F==="Running..."})},[]),je=t.useCallback(k=>{Y(k)},[]),r=t.useCallback(()=>D(!1),[]),X=t.useCallback(()=>z(null),[]),de=t.useCallback(()=>K(null),[]),ie=t.useCallback(()=>Y(null),[]),ue=t.useCallback(k=>{k.stopPropagation(),A()},[A]),Ae=st[s.status]||"#888888",oe=(a==null?void 0:a.messages)||[];return e.jsxs("div",{className:`agent-panel ${s.status==="working"?"working":""} ${f?"expanded":""} ${p?"focused":""}`,onClick:p?void 0:S,children:[e.jsxs("div",{className:"agent-panel-header",onClick:p?S:void 0,children:[e.jsxs("div",{className:"agent-panel-info",children:[e.jsx("span",{className:"agent-panel-status",style:{background:Ae},title:s.status}),e.jsxs("span",{className:"agent-panel-name",children:[(s.isBoss||s.class==="boss")&&e.jsx("span",{className:"agent-panel-boss-crown",children:"👑"}),s.name]}),e.jsx("span",{className:`agent-panel-status-label ${s.status}`,children:s.status}),e.jsx("span",{className:"agent-panel-class",children:s.class}),e.jsx("span",{className:`agent-panel-provider ${s.provider==="codex"?"codex":"claude"}`,children:s.provider==="codex"?"codex":"claude"}),e.jsxs("span",{className:"agent-panel-id",title:`ID: ${s.id}`,children:["[",s.id.substring(0,4),"]"]}),s.taskLabel?e.jsxs("div",{className:"agent-panel-task agent-panel-task-label",title:s.taskLabel,children:["📋 ",s.taskLabel]}):s.currentTask?e.jsxs("div",{className:"agent-panel-task",title:s.currentTask,children:[s.currentTask.substring(0,40),"..."]}):null]}),e.jsxs("div",{className:"agent-panel-context",title:`Context: ${Math.round(d.usedPercent)}% used (${Ie(d.totalTokens)} / ${Ie(d.contextWindow)})`,children:[e.jsx("div",{className:"agent-panel-context-bar",style:{background:d.freePercent<20?"#ff4a4a":d.freePercent<50?"#ff9e4a":"#4aff9e",width:`${d.freePercent}%`}}),e.jsxs("span",{className:"agent-panel-context-text",children:[Math.round(d.freePercent),"%"]})]}),e.jsx("div",{className:"agent-panel-actions",children:e.jsx("button",{className:"agent-panel-expand",onClick:ue,title:E(f?"commander.collapsePanel":"commander.expandPanel"),children:f?e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"4 14 10 14 10 20"}),e.jsx("polyline",{points:"20 10 14 10 14 4"}),e.jsx("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("polyline",{points:"9 21 3 21 3 15"}),e.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})})})]}),g&&e.jsx("div",{className:"agent-panel-supervisor-status",children:g.statusDescription}),e.jsx("div",{className:"agent-panel-content",ref:w,children:a!=null&&a.loading?e.jsx("div",{className:"agent-panel-loading",children:E("common:status.loading")}):e.jsx(e.Fragment,{children:!oe.length&&!c.length?e.jsxs("div",{className:"agent-panel-empty",children:[E("commander.noMessages"),!s.sessionId&&e.jsx("div",{style:{fontSize:"10px",color:"#666"},children:E("commander.noSessionId")})]}):e.jsx(Ue,{historyMessages:oe,liveOutputs:c,agentId:s.id,viewMode:u?"advanced":"simple",selectedMessageIndex:null,isMessageSelected:pe,onImageClick:ve,onFileClick:we,onBashClick:Ce,onViewMarkdown:je,scrollContainerRef:w,onScrollTopReached:P,isLoadingMore:i,hasMore:a==null?void 0:a.hasMore,shouldAutoScroll:O,onUserScroll:te,pinToBottom:I,onPinCancel:r,isLoadingHistory:a==null?void 0:a.loading})})}),e.jsxs("div",{className:`guake-input-wrapper ${s.status==="working"?"has-stop-btn is-working":""}`,children:[e.jsx(it,{agentId:s.id,isWorking:s.status==="working",timestamp:v==null?void 0:v.timestamp}),e.jsx(ct,{command:j,onCommandChange:l,useTextarea:J,forceTextarea:_,onForceTextarea:L,onSend:xe,canSend:ae,attachedFiles:T,onAddFile:ge,onRemoveFile:se,uploadFile:ne,onAddPastedText:he,placeholder:E("commander.command",{name:s.name}),compact:!1,inputRef:R})]}),B&&e.jsx(Ke,{url:B.url,name:B.name,onClose:X}),U&&e.jsx(We,{state:U,onClose:de}),e.jsx(Ve,{agent:s,content:ee,onClose:ie})]})}function ut({currentArea:s,onClose:a}){const{t:o}=fe(["terminal","common"]),[f,p]=t.useState(()=>{const i=new Set(Array.from(M.getState().agents.values()).map(y=>y.name));return ze.find(y=>!i.has(y))||`Agent-${Date.now().toString(36)}`}),[u,A]=t.useState(()=>Se(le.LAST_CWD)),[S,R]=t.useState("scout"),[N,b]=t.useState("claude"),[E,x]=t.useState(!1),v=()=>{if(!f.trim()||!u.trim())return;x(!0),Ne(le.LAST_CWD,u);let i;s&&(i={x:s.center.x,z:s.center.z}),M.spawnAgent(f.trim(),S,u.trim(),i,void 0,void 0,void 0,void 0,N),setTimeout(()=>{a()},500)},w=i=>{i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),v()),i.key==="Escape"&&a()};return e.jsx("div",{className:"commander-spawn-overlay",onClick:a,children:e.jsxs("div",{className:"commander-spawn-form",onClick:i=>i.stopPropagation(),children:[e.jsxs("div",{className:"commander-spawn-header",children:[e.jsx("h3",{children:o("spawn.addNewAgent")}),s&&e.jsxs("span",{className:"commander-spawn-area",children:[e.jsx("span",{className:"commander-spawn-area-dot",style:{background:s.color}}),s.name]})]}),e.jsxs("div",{className:"commander-spawn-body",children:[e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:o("common:labels.name")}),e.jsx("input",{type:"text",value:f,onChange:i=>p(i.target.value),onKeyDown:w,autoFocus:!0})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:o("common:labels.workingDirectory")}),e.jsx(Ge,{value:u,onChange:A,onSubmit:v,placeholder:o("spawn.workingDirPlaceholder"),directoriesOnly:!0})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:o("common:labels.class")}),e.jsx("div",{className:"commander-spawn-classes",children:qe.map(i=>{const y=Ye[i.id];return e.jsxs("button",{className:`commander-spawn-class ${S===i.id?"selected":""}`,onClick:()=>R(i.id),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:y.icon}),e.jsx("span",{children:i.name})]},i.id)})})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:o("common:labels.runtime")}),e.jsxs("div",{className:"commander-spawn-classes",children:[e.jsxs("button",{className:`commander-spawn-class ${N==="claude"?"selected":""}`,onClick:()=>b("claude"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:"🧠"}),e.jsx("span",{children:"Claude"})]}),e.jsxs("button",{className:`commander-spawn-class ${N==="codex"?"selected":""}`,onClick:()=>b("codex"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:"⚙️"}),e.jsx("span",{children:"Codex"})]})]})]})]}),e.jsxs("div",{className:"commander-spawn-footer",children:[e.jsx("button",{className:"commander-spawn-cancel",onClick:a,children:o("common:buttons.cancel")}),e.jsx("button",{className:"commander-spawn-submit",onClick:v,disabled:!f.trim()||!u.trim()||E,children:o(E?"common:buttons.deploying":"common:buttons.deploy")})]})]})})}const Re=t.memo(function({agent:a,history:o,isExpanded:f,isFocused:p,advancedView:u,index:A,onExpand:S,onCollapse:R,onFocus:N,onInputRef:b,onLoadMore:E,onClearHistory:x}){const v=Ze(a.id),w=t.useCallback(()=>{f?R():S(a.id)},[a.id,f,S,R]),i=t.useCallback(()=>{N(p?-1:A)},[A,p,N]),y=t.useCallback(O=>{b(a.id,O)},[a.id,b]),m=t.useCallback(()=>{E(a.id)},[a.id,E]),C=t.useCallback(()=>{x(a.id)},[a.id,x]);return e.jsx(dt,{agent:a,history:o,outputs:v,isExpanded:f,isFocused:p,advancedView:u,onExpand:w,onFocus:i,inputRef:y,onLoadMore:m,onClearHistory:C})});function xt({isOpen:s,onClose:a}){const{t:o}=fe(["terminal","common"]),f=Je(),p=Xe(),[u,A]=t.useState(()=>Se(le.COMMANDER_TAB,"all")),[S,R]=t.useState(0),[N,b]=t.useState(null),E=t.useRef(null),[x,v]=t.useState(0),[w,i]=t.useState(!1),[y,m]=t.useState(null),[C,O]=t.useState(!1),[h,I]=t.useState(()=>{try{const n=Se(le.COMMANDER_FILTERS,"");if(n)return{...ke,...JSON.parse(n)}}catch{}return ke}),D=t.useRef(new Map),B=t.useRef([]),z=t.useRef(0),U=t.useRef([]),K=t.useRef(u),{histories:ee,loadMoreHistory:Y,clearAgentHistory:j}=lt({isOpen:s,agents:f});t.useEffect(()=>{s||(b(null),v(0),i(!1))},[s]);const l=t.useMemo(()=>{const n=Array.from(p.values()).sort((g,d)=>g.name.localeCompare(d.name)),c=[{id:"all",name:o("common:labels.all")}];for(const g of n)c.push({id:g.id,name:g.name,color:g.color});return c.push({id:"unassigned",name:o("commander.unassigned")}),c},[p]),_=t.useMemo(()=>u==="all"||u==="unassigned"?null:p.get(u)||null,[u,p]),L=t.useMemo(()=>{const n=new Map;n.set("all",f.size);let c=0;for(const g of f.values()){const d=M.getAreaForAgent(g.id);d?n.set(d.id,(n.get(d.id)||0)+1):c++}return n.set("unassigned",c),n},[f]),J=h.status!=="all"||h.activity!=="all"||h.sort!=="activity",G=(h.status!=="all"?1:0)+(h.activity!=="all"?1:0)+(h.sort!=="activity"?1:0),H=t.useMemo(()=>{const n=d=>d.isBoss===!0||d.class==="boss",c=Date.now();let g=Array.from(f.values());if(u==="unassigned"?g=g.filter(d=>!M.getAreaForAgent(d.id)):u!=="all"&&(g=g.filter(d=>{const P=M.getAreaForAgent(d.id);return(P==null?void 0:P.id)===u})),h.status!=="all"&&(g=g.filter(d=>{switch(h.status){case"working":return d.status==="working";case"idle":return d.status==="idle";case"error":return d.status==="error"||d.status==="waiting"||d.status==="waiting_permission";case"offline":return d.status==="offline"||d.status==="orphaned";default:return!0}})),h.activity!=="all"){const d=tt[h.activity];g=g.filter(P=>c-(P.lastActivity||0)<d)}return g.sort((d,P)=>{var te,Z;if(n(d)&&!n(P))return-1;if(!n(d)&&n(P))return 1;switch(h.sort){case"activity":return(P.lastActivity||0)-(d.lastActivity||0);case"name":return d.name.localeCompare(P.name);case"created":return(d.createdAt||0)-(P.createdAt||0);case"context":{const V=((te=d.contextStats)==null?void 0:te.usedPercent)??(d.contextUsed||0)/(d.contextLimit||2e5)*100;return(((Z=P.contextStats)==null?void 0:Z.usedPercent)??(P.contextUsed||0)/(P.contextLimit||2e5)*100)-V}default:return(P.lastActivity||0)-(d.lastActivity||0)}}),g},[f,u,h]),$=Math.ceil(H.length/be),T=t.useMemo(()=>H.slice(S*be,(S+1)*be),[H,S]);B.current=T,E.current=N,z.current=x,U.current=l,K.current=u,Ee("commander-expanded",N!==null,()=>b(null));const W=Qe();t.useEffect(()=>{s&&W&&(b(W),M.clearCommanderExpandRequest())},[s,W]);const se=t.useCallback(()=>b(null),[]),ne=t.useCallback(n=>b(n),[]),ce=t.useCallback(n=>v(n),[]),ae=t.useCallback((n,c)=>{c?D.current.set(n,c):D.current.delete(n)},[]);return t.useEffect(()=>{R(0),Ne(le.COMMANDER_TAB,u)},[u]),t.useEffect(()=>{Ne(le.COMMANDER_FILTERS,JSON.stringify(h)),R(0)},[h]),t.useEffect(()=>{var c;if(!s||window.matchMedia("(pointer: coarse)").matches)return;const n=N||((c=B.current[x])==null?void 0:c.id);if(n){const g=D.current.get(n);g&&document.activeElement!==g&&setTimeout(()=>g.focus(),50)}},[s,x,N]),t.useEffect(()=>{if(!s)return;const n=c=>{const g=M.getShortcuts(),d=c.target,P=d.tagName==="INPUT"||d.tagName==="TEXTAREA",te=B.current,Z=te.length-1,V=E.current,re=g.find(r=>r.id==="commander-close");if(Q(c,re)){const{fileViewerPath:r,contextModalAgentId:X}=M.getState();if(r||X)return;c.preventDefault(),c.stopImmediatePropagation(),V?b(null):a();return}const pe=g.find(r=>r.id==="commander-vim-left");if(Q(c,pe)&&!V){c.preventDefault(),v(r=>r>0?r-1:r);return}const he=g.find(r=>r.id==="commander-vim-right");if(Q(c,he)&&!V){c.preventDefault(),v(r=>r<Z?r+1:r);return}const ge=g.find(r=>r.id==="commander-vim-up");if(Q(c,ge)&&!V){c.preventDefault(),v(r=>r>=me?r-me:r);return}const xe=g.find(r=>r.id==="commander-vim-down");if(Q(c,xe)&&!V){c.preventDefault(),v(r=>r+me<=Z?r+me:r);return}const ve=g.find(r=>r.id==="commander-expand");if(Q(c,ve)){if(c.preventDefault(),V)b(null);else{const r=te[z.current];r&&b(r.id)}return}const we=g.find(r=>r.id==="commander-new-agent");if(Q(c,we)){c.preventDefault(),i(!0);return}const Ce=g.find(r=>r.id==="commander-next-tab"),je=g.find(r=>r.id==="commander-prev-tab");if(!P){const r=U.current;if(Q(c,Ce)){const X=M.getState().latestNotificationAgentId;if(X){if(c.preventDefault(),c.stopPropagation(),!M.getState().agents.get(X)){M.setLatestNotificationAgentId(null);return}const oe=M.getAreaForAgent(X);oe&&r.some(k=>k.id===oe.id)?A(oe.id):A("unassigned"),b(X),v(0),R(0),M.setLatestNotificationAgentId(null);return}c.preventDefault(),c.stopPropagation();const ie=(r.findIndex(ue=>ue.id===K.current)+1)%r.length;A(r[ie].id),v(0);return}if(Q(c,je)){c.preventDefault(),c.stopPropagation();const de=(r.findIndex(ie=>ie.id===K.current)-1+r.length)%r.length;A(r[de].id),v(0);return}}};return document.addEventListener("keydown",n,!0),()=>document.removeEventListener("keydown",n,!0)},[s,a]),s?e.jsx("div",{className:"commander-overlay",onClick:a,children:e.jsxs("div",{className:"commander-view",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"commander-header",children:[e.jsxs("div",{className:"commander-title-section",children:[e.jsx("h2",{className:"commander-title",children:o("commander.title")}),e.jsx("span",{className:"commander-shortcuts",children:o("commander.shortcuts")})]}),e.jsxs("div",{className:"commander-controls",children:[e.jsx("button",{className:`commander-view-toggle ${C?"active":""}`,onClick:()=>O(!C),title:o(C?"commander.simple":"commander.advanced"),children:C?`◉ ${o("commander.advanced")}`:`○ ${o("commander.simple")}`}),e.jsx("button",{className:"commander-add-btn",onClick:()=>i(!0),title:o("commander.addAgent"),children:o("commander.addAgent")}),e.jsx("button",{className:"commander-close",onClick:a,children:o("commander.close")})]})]}),e.jsx("div",{className:"commander-tabs",children:l.map(n=>{const c=n.id!=="all"&&n.id!=="unassigned"?p.get(n.id):null,g=c&&c.directories&&c.directories.length>0;return e.jsxs("button",{className:`commander-tab ${u===n.id?"active":""}`,onClick:()=>{A(n.id),v(0)},style:n.color?{borderBottomColor:u===n.id?n.color:"transparent"}:void 0,children:[n.color&&e.jsx("span",{className:"commander-tab-dot",style:{background:n.color}}),e.jsx("span",{children:n.name}),e.jsx("span",{className:"commander-tab-count",children:L.get(n.id)||0}),g&&e.jsx("span",{className:"commander-tab-folder",onClick:d=>{d.stopPropagation(),m(n.id)},title:o("commander.openFileExplorer"),children:"📁"})]},n.id)})}),e.jsxs("div",{className:"commander-filters",children:[e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:o("commander.filters.status")}),["all","working","idle","error","offline"].map(n=>e.jsx("button",{className:`commander-filter-btn ${h.status===n?"active":""}`,onClick:()=>I(c=>({...c,status:n})),children:n==="all"?o("commander.filters.all"):n==="error"?o("commander.filters.needsAttn"):n.charAt(0).toUpperCase()+n.slice(1)},n))]}),e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:o("commander.filters.active")}),["all","1h","6h","24h"].map(n=>e.jsx("button",{className:`commander-filter-btn ${h.activity===n?"active":""}`,onClick:()=>I(c=>({...c,activity:n})),children:n==="all"?o("commander.filters.any"):`< ${n}`},n))]}),e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:o("commander.filters.sort")}),["activity","name","created","context"].map(n=>e.jsx("button",{className:`commander-filter-btn ${h.sort===n?"active":""}`,onClick:()=>I(c=>({...c,sort:n})),children:n==="activity"?o("commander.filters.recent"):n==="context"?o("commander.filters.context"):n.charAt(0).toUpperCase()+n.slice(1)},n))]}),J&&e.jsx("button",{className:"commander-filter-clear",onClick:()=>I(ke),title:o("commander.clearFilters"),children:o("commander.filters.clearFilters",{count:G})})]}),$>1&&e.jsxs("div",{className:"commander-pagination",children:[e.jsxs("button",{className:"commander-page-btn",onClick:()=>R(n=>Math.max(0,n-1)),disabled:S===0,children:["← ",o("commander.prev")]}),e.jsx("span",{className:"commander-page-info",children:o("commander.page",{current:S+1,total:$,count:H.length})}),e.jsxs("button",{className:"commander-page-btn",onClick:()=>R(n=>Math.min($-1,n+1)),disabled:S===$-1,children:[o("commander.next")," →"]})]}),e.jsx("div",{className:`commander-grid ${N?"has-expanded":""}`,"data-agent-count":N?1:T.length,children:T.length===0?e.jsx("div",{className:"commander-empty",children:o(u==="all"?"commander.noAgentsAll":u==="unassigned"?"commander.noAgentsUnassigned":"commander.noAgentsArea")}):N?(()=>{const n=f.get(N);return n?e.jsx(Re,{agent:n,history:ee.get(n.id),isExpanded:!0,isFocused:!0,advancedView:C,index:0,onExpand:ne,onCollapse:se,onFocus:ce,onInputRef:ae,onLoadMore:Y,onClearHistory:j},n.id):null})():T.map((n,c)=>e.jsx(Re,{agent:n,history:ee.get(n.id),isExpanded:!1,isFocused:c===x,advancedView:C,index:c,onExpand:ne,onCollapse:se,onFocus:ce,onInputRef:ae,onLoadMore:Y,onClearHistory:j},n.id))}),w&&e.jsx(ut,{currentArea:_,onClose:()=>i(!1)}),y&&e.jsx(et,{isOpen:!0,areaId:y,onClose:()=>m(null),onChangeArea:n=>m(n)})]})}):null}export{xt as CommanderView};
5
+ ${L}`:L}M.sendCommand(s.id,k),c(""),F(!1),G(new Map),W([]),$()},[s.id,j,ae,T,le,b,$,c,F,G,W]),ve=t.useCallback((k,L)=>{z({url:k,name:L})},[]),we=t.useCallback((k,L)=>{const Y=Ue(k,s.cwd),Pe=Y.line?{...L||{},targetLine:Y.line}:L;M.setFileViewerPath(Y.path,Pe,s.cwd)},[s.cwd]),Ce=t.useCallback((k,L)=>{K({command:k,output:L,isLive:L==="Running..."})},[]),je=t.useCallback(k=>{q(k)},[]),r=t.useCallback(()=>D(!1),[]),X=t.useCallback(()=>z(null),[]),de=t.useCallback(()=>K(null),[]),ie=t.useCallback(()=>q(null),[]),ue=t.useCallback(k=>{k.stopPropagation(),A()},[A]),Ae=st[s.status]||"#888888",oe=(a==null?void 0:a.messages)||[];return e.jsxs("div",{className:`agent-panel ${s.status==="working"?"working":""} ${f?"expanded":""} ${p?"focused":""}`,onClick:p?void 0:S,children:[e.jsxs("div",{className:"agent-panel-header",onClick:p?S:void 0,children:[e.jsxs("div",{className:"agent-panel-info",children:[e.jsx("span",{className:"agent-panel-status",style:{background:Ae},title:s.status}),e.jsxs("span",{className:"agent-panel-name",children:[(s.isBoss||s.class==="boss")&&e.jsx("span",{className:"agent-panel-boss-crown",children:"👑"}),s.name]}),e.jsx("span",{className:`agent-panel-status-label ${s.status}`,children:s.status}),e.jsx("span",{className:"agent-panel-class",children:s.class}),e.jsx("span",{className:`agent-panel-provider ${s.provider==="codex"?"codex":"claude"}`,children:s.provider==="codex"?"codex":"claude"}),e.jsxs("span",{className:"agent-panel-id",title:`ID: ${s.id}`,children:["[",s.id.substring(0,4),"]"]}),s.taskLabel?e.jsxs("div",{className:"agent-panel-task agent-panel-task-label",title:s.taskLabel,children:["📋 ",s.taskLabel]}):s.currentTask?e.jsxs("div",{className:"agent-panel-task",title:s.currentTask,children:[s.currentTask.substring(0,40),"..."]}):null]}),e.jsxs("div",{className:"agent-panel-context",title:`Context: ${Math.round(d.usedPercent)}% used (${Re(d.totalTokens)} / ${Re(d.contextWindow)})`,children:[e.jsx("div",{className:"agent-panel-context-bar",style:{background:d.freePercent<20?"#ff4a4a":d.freePercent<50?"#ff9e4a":"#4aff9e",width:`${d.freePercent}%`}}),e.jsxs("span",{className:"agent-panel-context-text",children:[Math.round(d.freePercent),"%"]})]}),e.jsx("div",{className:"agent-panel-actions",children:e.jsx("button",{className:"agent-panel-expand",onClick:ue,title:E(f?"commander.collapsePanel":"commander.expandPanel"),children:f?e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"4 14 10 14 10 20"}),e.jsx("polyline",{points:"20 10 14 10 14 4"}),e.jsx("line",{x1:"14",y1:"10",x2:"21",y2:"3"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]}):e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("polyline",{points:"9 21 3 21 3 15"}),e.jsx("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),e.jsx("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})})})]}),g&&e.jsx("div",{className:"agent-panel-supervisor-status",children:g.statusDescription}),e.jsx("div",{className:"agent-panel-content",ref:w,children:a!=null&&a.loading?e.jsx("div",{className:"agent-panel-loading",children:E("common:status.loading")}):e.jsx(e.Fragment,{children:!oe.length&&!l.length?e.jsxs("div",{className:"agent-panel-empty",children:[E("commander.noMessages"),!s.sessionId&&e.jsx("div",{style:{fontSize:"10px",color:"#666"},children:E("commander.noSessionId")})]}):e.jsx(Be,{historyMessages:oe,liveOutputs:l,agentId:s.id,viewMode:u?"advanced":"simple",selectedMessageIndex:null,isMessageSelected:pe,onImageClick:ve,onFileClick:we,onBashClick:Ce,onViewMarkdown:je,scrollContainerRef:w,onScrollTopReached:P,isLoadingMore:i,hasMore:a==null?void 0:a.hasMore,shouldAutoScroll:_,onUserScroll:te,pinToBottom:R,onPinCancel:r,isLoadingHistory:a==null?void 0:a.loading})})}),e.jsxs("div",{className:`guake-input-wrapper ${s.status==="working"?"has-stop-btn is-working":""}`,children:[e.jsx(it,{agentId:s.id,isWorking:s.status==="working",timestamp:v==null?void 0:v.timestamp}),e.jsx(lt,{command:j,onCommandChange:c,useTextarea:J,forceTextarea:O,onForceTextarea:F,onSend:xe,canSend:ae,attachedFiles:T,onAddFile:ge,onRemoveFile:se,uploadFile:ne,onAddPastedText:he,placeholder:E("commander.command",{name:s.name}),compact:!1,inputRef:y})]}),U&&e.jsx(Ke,{url:U.url,name:U.name,onClose:X}),B&&e.jsx(We,{state:B,onClose:de}),e.jsx(Ve,{agent:s,content:ee,onClose:ie})]})}function ut({currentArea:s,onClose:a}){const{t:o}=fe(["terminal","common"]),[f,p]=t.useState(()=>{const i=new Set(Array.from(M.getState().agents.values()).map(I=>I.name));return ze.find(I=>!i.has(I))||`Agent-${Date.now().toString(36)}`}),[u,A]=t.useState(()=>Se(ce.LAST_CWD)),[S,y]=t.useState("scout"),[N,b]=t.useState("claude"),[E,x]=t.useState(!1),v=()=>{if(!f.trim()||!u.trim())return;x(!0),Ne(ce.LAST_CWD,u);let i;s&&(i={x:s.center.x,z:s.center.z}),M.spawnAgent(f.trim(),S,u.trim(),i,void 0,void 0,void 0,void 0,N),setTimeout(()=>{a()},500)},w=i=>{i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),v()),i.key==="Escape"&&a()};return e.jsx("div",{className:"commander-spawn-overlay",onClick:a,children:e.jsxs("div",{className:"commander-spawn-form",onClick:i=>i.stopPropagation(),children:[e.jsxs("div",{className:"commander-spawn-header",children:[e.jsx("h3",{children:o("spawn.addNewAgent")}),s&&e.jsxs("span",{className:"commander-spawn-area",children:[e.jsx("span",{className:"commander-spawn-area-dot",style:{background:s.color}}),s.name]})]}),e.jsxs("div",{className:"commander-spawn-body",children:[e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:o("common:labels.name")}),e.jsx("input",{type:"text",value:f,onChange:i=>p(i.target.value),onKeyDown:w,autoFocus:!0})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:o("common:labels.workingDirectory")}),e.jsx(Ge,{value:u,onChange:A,onSubmit:v,placeholder:o("spawn.workingDirPlaceholder"),directoriesOnly:!0})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:o("common:labels.class")}),e.jsx("div",{className:"commander-spawn-classes",children:Ye.map(i=>{const I=qe[i.id];return e.jsxs("button",{className:`commander-spawn-class ${S===i.id?"selected":""}`,onClick:()=>y(i.id),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:I.icon}),e.jsx("span",{children:i.name})]},i.id)})})]}),e.jsxs("div",{className:"commander-spawn-field",children:[e.jsx("label",{children:o("common:labels.runtime")}),e.jsxs("div",{className:"commander-spawn-classes",children:[e.jsxs("button",{className:`commander-spawn-class ${N==="claude"?"selected":""}`,onClick:()=>b("claude"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:"🧠"}),e.jsx("span",{children:"Claude"})]}),e.jsxs("button",{className:`commander-spawn-class ${N==="codex"?"selected":""}`,onClick:()=>b("codex"),children:[e.jsx("span",{className:"commander-spawn-class-icon",children:"⚙️"}),e.jsx("span",{children:"Codex"})]})]})]})]}),e.jsxs("div",{className:"commander-spawn-footer",children:[e.jsx("button",{className:"commander-spawn-cancel",onClick:a,children:o("common:buttons.cancel")}),e.jsx("button",{className:"commander-spawn-submit",onClick:v,disabled:!f.trim()||!u.trim()||E,children:o(E?"common:buttons.deploying":"common:buttons.deploy")})]})]})})}const ye=t.memo(function({agent:a,history:o,isExpanded:f,isFocused:p,advancedView:u,index:A,onExpand:S,onCollapse:y,onFocus:N,onInputRef:b,onLoadMore:E,onClearHistory:x}){const v=Ze(a.id),w=t.useCallback(()=>{f?y():S(a.id)},[a.id,f,S,y]),i=t.useCallback(()=>{N(p?-1:A)},[A,p,N]),I=t.useCallback(_=>{b(a.id,_)},[a.id,b]),m=t.useCallback(()=>{E(a.id)},[a.id,E]),C=t.useCallback(()=>{x(a.id)},[a.id,x]);return e.jsx(dt,{agent:a,history:o,outputs:v,isExpanded:f,isFocused:p,advancedView:u,onExpand:w,onFocus:i,inputRef:I,onLoadMore:m,onClearHistory:C})});function xt({isOpen:s,onClose:a}){const{t:o}=fe(["terminal","common"]),f=Je(),p=Xe(),[u,A]=t.useState(()=>Se(ce.COMMANDER_TAB,"all")),[S,y]=t.useState(0),[N,b]=t.useState(null),E=t.useRef(null),[x,v]=t.useState(0),[w,i]=t.useState(!1),[I,m]=t.useState(null),[C,_]=t.useState(!1),[h,R]=t.useState(()=>{try{const n=Se(ce.COMMANDER_FILTERS,"");if(n)return{...ke,...JSON.parse(n)}}catch{}return ke}),D=t.useRef(new Map),U=t.useRef([]),z=t.useRef(0),B=t.useRef([]),K=t.useRef(u),{histories:ee,loadMoreHistory:q,clearAgentHistory:j}=ct({isOpen:s,agents:f});t.useEffect(()=>{s||(b(null),v(0),i(!1))},[s]);const c=t.useMemo(()=>{const n=Array.from(p.values()).sort((g,d)=>g.name.localeCompare(d.name)),l=[{id:"all",name:o("common:labels.all")}];for(const g of n)l.push({id:g.id,name:g.name,color:g.color});return l.push({id:"unassigned",name:o("commander.unassigned")}),l},[p]),O=t.useMemo(()=>u==="all"||u==="unassigned"?null:p.get(u)||null,[u,p]),F=t.useMemo(()=>{const n=new Map;n.set("all",f.size);let l=0;for(const g of f.values()){const d=M.getAreaForAgent(g.id);d?n.set(d.id,(n.get(d.id)||0)+1):l++}return n.set("unassigned",l),n},[f]),J=h.status!=="all"||h.activity!=="all"||h.sort!=="activity",G=(h.status!=="all"?1:0)+(h.activity!=="all"?1:0)+(h.sort!=="activity"?1:0),H=t.useMemo(()=>{const n=d=>d.isBoss===!0||d.class==="boss",l=Date.now();let g=Array.from(f.values());if(u==="unassigned"?g=g.filter(d=>!M.getAreaForAgent(d.id)):u!=="all"&&(g=g.filter(d=>{const P=M.getAreaForAgent(d.id);return(P==null?void 0:P.id)===u})),h.status!=="all"&&(g=g.filter(d=>{switch(h.status){case"working":return d.status==="working";case"idle":return d.status==="idle";case"error":return d.status==="error"||d.status==="waiting"||d.status==="waiting_permission";case"offline":return d.status==="offline"||d.status==="orphaned";default:return!0}})),h.activity!=="all"){const d=tt[h.activity];g=g.filter(P=>l-(P.lastActivity||0)<d)}return g.sort((d,P)=>{var te,Z;if(n(d)&&!n(P))return-1;if(!n(d)&&n(P))return 1;switch(h.sort){case"activity":return(P.lastActivity||0)-(d.lastActivity||0);case"name":return d.name.localeCompare(P.name);case"created":return(d.createdAt||0)-(P.createdAt||0);case"context":{const V=((te=d.contextStats)==null?void 0:te.usedPercent)??(d.contextUsed||0)/(d.contextLimit||2e5)*100;return(((Z=P.contextStats)==null?void 0:Z.usedPercent)??(P.contextUsed||0)/(P.contextLimit||2e5)*100)-V}default:return(P.lastActivity||0)-(d.lastActivity||0)}}),g},[f,u,h]),$=Math.ceil(H.length/be),T=t.useMemo(()=>H.slice(S*be,(S+1)*be),[H,S]);U.current=T,E.current=N,z.current=x,B.current=c,K.current=u,Ee("commander-expanded",N!==null,()=>b(null));const W=Qe();t.useEffect(()=>{s&&W&&(b(W),M.clearCommanderExpandRequest())},[s,W]);const se=t.useCallback(()=>b(null),[]),ne=t.useCallback(n=>b(n),[]),le=t.useCallback(n=>v(n),[]),ae=t.useCallback((n,l)=>{l?D.current.set(n,l):D.current.delete(n)},[]);return t.useEffect(()=>{y(0),Ne(ce.COMMANDER_TAB,u)},[u]),t.useEffect(()=>{Ne(ce.COMMANDER_FILTERS,JSON.stringify(h)),y(0)},[h]),t.useEffect(()=>{var l;if(!s||window.matchMedia("(pointer: coarse)").matches)return;const n=N||((l=U.current[x])==null?void 0:l.id);if(n){const g=D.current.get(n);g&&document.activeElement!==g&&setTimeout(()=>g.focus(),50)}},[s,x,N]),t.useEffect(()=>{if(!s)return;const n=l=>{const g=M.getShortcuts(),d=l.target,P=d.tagName==="INPUT"||d.tagName==="TEXTAREA",te=U.current,Z=te.length-1,V=E.current,re=g.find(r=>r.id==="commander-close");if(Q(l,re)){const{fileViewerPath:r,contextModalAgentId:X}=M.getState();if(r||X)return;l.preventDefault(),l.stopImmediatePropagation(),V?b(null):a();return}const pe=g.find(r=>r.id==="commander-vim-left");if(Q(l,pe)&&!V){l.preventDefault(),v(r=>r>0?r-1:r);return}const he=g.find(r=>r.id==="commander-vim-right");if(Q(l,he)&&!V){l.preventDefault(),v(r=>r<Z?r+1:r);return}const ge=g.find(r=>r.id==="commander-vim-up");if(Q(l,ge)&&!V){l.preventDefault(),v(r=>r>=me?r-me:r);return}const xe=g.find(r=>r.id==="commander-vim-down");if(Q(l,xe)&&!V){l.preventDefault(),v(r=>r+me<=Z?r+me:r);return}const ve=g.find(r=>r.id==="commander-expand");if(Q(l,ve)){if(l.preventDefault(),V)b(null);else{const r=te[z.current];r&&b(r.id)}return}const we=g.find(r=>r.id==="commander-new-agent");if(Q(l,we)){l.preventDefault(),i(!0);return}const Ce=g.find(r=>r.id==="commander-next-tab"),je=g.find(r=>r.id==="commander-prev-tab");if(!P){const r=B.current;if(Q(l,Ce)){const X=M.getState().latestNotificationAgentId;if(X){if(l.preventDefault(),l.stopPropagation(),!M.getState().agents.get(X)){M.setLatestNotificationAgentId(null);return}const oe=M.getAreaForAgent(X);oe&&r.some(k=>k.id===oe.id)?A(oe.id):A("unassigned"),b(X),v(0),y(0),M.setLatestNotificationAgentId(null);return}l.preventDefault(),l.stopPropagation();const ie=(r.findIndex(ue=>ue.id===K.current)+1)%r.length;A(r[ie].id),v(0);return}if(Q(l,je)){l.preventDefault(),l.stopPropagation();const de=(r.findIndex(ie=>ie.id===K.current)-1+r.length)%r.length;A(r[de].id),v(0);return}}};return document.addEventListener("keydown",n,!0),()=>document.removeEventListener("keydown",n,!0)},[s,a]),s?e.jsx("div",{className:"commander-overlay",onClick:a,children:e.jsxs("div",{className:"commander-view",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"commander-header",children:[e.jsxs("div",{className:"commander-title-section",children:[e.jsx("h2",{className:"commander-title",children:o("commander.title")}),e.jsx("span",{className:"commander-shortcuts",children:o("commander.shortcuts")})]}),e.jsxs("div",{className:"commander-controls",children:[e.jsx("button",{className:`commander-view-toggle ${C?"active":""}`,onClick:()=>_(!C),title:o(C?"commander.simple":"commander.advanced"),children:C?`◉ ${o("commander.advanced")}`:`○ ${o("commander.simple")}`}),e.jsx("button",{className:"commander-add-btn",onClick:()=>i(!0),title:o("commander.addAgent"),children:o("commander.addAgent")}),e.jsx("button",{className:"commander-close",onClick:a,children:o("commander.close")})]})]}),e.jsx("div",{className:"commander-tabs",children:c.map(n=>{const l=n.id!=="all"&&n.id!=="unassigned"?p.get(n.id):null,g=l&&l.directories&&l.directories.length>0;return e.jsxs("button",{className:`commander-tab ${u===n.id?"active":""}`,onClick:()=>{A(n.id),v(0)},style:n.color?{borderBottomColor:u===n.id?n.color:"transparent"}:void 0,children:[n.color&&e.jsx("span",{className:"commander-tab-dot",style:{background:n.color}}),e.jsx("span",{children:n.name}),e.jsx("span",{className:"commander-tab-count",children:F.get(n.id)||0}),g&&e.jsx("span",{className:"commander-tab-folder",onClick:d=>{d.stopPropagation(),m(n.id)},title:o("commander.openFileExplorer"),children:"📁"})]},n.id)})}),e.jsxs("div",{className:"commander-filters",children:[e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:o("commander.filters.status")}),["all","working","idle","error","offline"].map(n=>e.jsx("button",{className:`commander-filter-btn ${h.status===n?"active":""}`,onClick:()=>R(l=>({...l,status:n})),children:n==="all"?o("commander.filters.all"):n==="error"?o("commander.filters.needsAttn"):n.charAt(0).toUpperCase()+n.slice(1)},n))]}),e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:o("commander.filters.active")}),["all","1h","6h","24h"].map(n=>e.jsx("button",{className:`commander-filter-btn ${h.activity===n?"active":""}`,onClick:()=>R(l=>({...l,activity:n})),children:n==="all"?o("commander.filters.any"):`< ${n}`},n))]}),e.jsxs("div",{className:"commander-filter-group",children:[e.jsx("span",{className:"commander-filter-label",children:o("commander.filters.sort")}),["activity","name","created","context"].map(n=>e.jsx("button",{className:`commander-filter-btn ${h.sort===n?"active":""}`,onClick:()=>R(l=>({...l,sort:n})),children:n==="activity"?o("commander.filters.recent"):n==="context"?o("commander.filters.context"):n.charAt(0).toUpperCase()+n.slice(1)},n))]}),J&&e.jsx("button",{className:"commander-filter-clear",onClick:()=>R(ke),title:o("commander.clearFilters"),children:o("commander.filters.clearFilters",{count:G})})]}),$>1&&e.jsxs("div",{className:"commander-pagination",children:[e.jsxs("button",{className:"commander-page-btn",onClick:()=>y(n=>Math.max(0,n-1)),disabled:S===0,children:["← ",o("commander.prev")]}),e.jsx("span",{className:"commander-page-info",children:o("commander.page",{current:S+1,total:$,count:H.length})}),e.jsxs("button",{className:"commander-page-btn",onClick:()=>y(n=>Math.min($-1,n+1)),disabled:S===$-1,children:[o("commander.next")," →"]})]}),e.jsx("div",{className:`commander-grid ${N?"has-expanded":""}`,"data-agent-count":N?1:T.length,children:T.length===0?e.jsx("div",{className:"commander-empty",children:o(u==="all"?"commander.noAgentsAll":u==="unassigned"?"commander.noAgentsUnassigned":"commander.noAgentsArea")}):N?(()=>{const n=f.get(N);return n?e.jsx(ye,{agent:n,history:ee.get(n.id),isExpanded:!0,isFocused:!0,advancedView:C,index:0,onExpand:ne,onCollapse:se,onFocus:le,onInputRef:ae,onLoadMore:q,onClearHistory:j},n.id):null})():T.map((n,l)=>e.jsx(ye,{agent:n,history:ee.get(n.id),isExpanded:!1,isFocused:l===x,advancedView:C,index:l,onExpand:ne,onCollapse:se,onFocus:le,onInputRef:ae,onLoadMore:q,onClearHistory:j},n.id))}),w&&e.jsx(ut,{currentArea:O,onClose:()=>i(!1)}),I&&e.jsx(et,{isOpen:!0,areaId:I,onClose:()=>m(null),onChangeArea:n=>m(n)})]})}):null}export{xt as CommanderView};