tide-commander 1.166.0 → 1.167.1

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 (128) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/assets/{BossLogsModal-CsMSjCZp.js → BossLogsModal-C1fvmbcN.js} +1 -1
  3. package/dist/assets/BossSpawnModal-B-1O9ZP7.js +1 -0
  4. package/dist/assets/ControlsModal-DxDjUTGb.js +1 -0
  5. package/dist/assets/DockerLogsModal-Da9yHnmj.js +2 -0
  6. package/dist/assets/{EmbeddedEditor-n2QnK4hA.js → EmbeddedEditor-Bt471BjS.js} +1 -1
  7. package/dist/assets/{GmailOAuthSetup-DhKifdH0.js → GmailOAuthSetup-N5JL1wj1.js} +1 -1
  8. package/dist/assets/{GoogleOAuthSetup-D14lS0lT.js → GoogleOAuthSetup-DB_L3CSU.js} +1 -1
  9. package/dist/assets/{IframeModal-c2Go5TIq.js → IframeModal-Cp-zWTdB.js} +1 -1
  10. package/dist/assets/IntegrationsPanel-CDbEslW3.js +2 -0
  11. package/dist/assets/{LogViewerModal-onBz0hK3.js → LogViewerModal-CvE-S6la.js} +1 -1
  12. package/dist/assets/{MonitoringModal-D58Oka-L.js → MonitoringModal-CnWOSvDm.js} +1 -1
  13. package/dist/assets/{PM2LogsModal-DtEHMB6v.js → PM2LogsModal-BA5dIvFa.js} +2 -2
  14. package/dist/assets/RestoreArchivedAreaModal-BWE1vBbp.js +1 -0
  15. package/dist/assets/Scene2DCanvas-Bkw11_k3.js +1 -0
  16. package/dist/assets/SceneManager-DcIJ0fwQ.js +104 -0
  17. package/dist/assets/{SkillsPanel-aK_Vhyhx.js → SkillsPanel-CiUnZ-p6.js} +1 -1
  18. package/dist/assets/{SlackMultiInstanceSetup-CR9tuDCR.js → SlackMultiInstanceSetup-D72RPfOJ.js} +1 -1
  19. package/dist/assets/SpawnModal-C7SE5U7Q.js +1 -0
  20. package/dist/assets/StatisticsModal-DToMH_hE.js +1 -0
  21. package/dist/assets/SubordinateAssignmentModal-B2vDLdp1.js +1 -0
  22. package/dist/assets/{TriggerManagerPanel-CtDALyfM.js → TriggerManagerPanel-Bl-7r3SA.js} +1 -1
  23. package/dist/assets/{WorkflowEditorPanel-CEYKw625.js → WorkflowEditorPanel-B5WatRJn.js} +1 -1
  24. package/dist/assets/abnfDiagram-VRR7QNED-CZtFQa7q.js +1 -0
  25. package/dist/assets/arc-DpOW7Rzk.js +1 -0
  26. package/dist/assets/architectureDiagram-ZJ3FMSHR-BaxzpkYc.js +36 -0
  27. package/dist/assets/{area-logos-HooY4aHb.js → area-logos-viFj5Uls.js} +1 -1
  28. package/dist/assets/blockDiagram-677ZJIJ3-CdSlu9z0.js +132 -0
  29. package/dist/assets/c4Diagram-LMCZKHZV-QEoKm8Zq.js +10 -0
  30. package/dist/assets/channel-2V7dJeDN.js +1 -0
  31. package/dist/assets/chunk-2Q5K7J3B-CPHPRLk0.js +1 -0
  32. package/dist/assets/chunk-32BRIVSS-Cuk_gIdG.js +1 -0
  33. package/dist/assets/chunk-5VM5RSS4-5r6zermk.js +15 -0
  34. package/dist/assets/chunk-EX3LRPZG-Cs5LqZTp.js +231 -0
  35. package/dist/assets/chunk-JWPE2WC7-CqbF8JzJ.js +1 -0
  36. package/dist/assets/chunk-MOJQB5TN-CFmxz4-y.js +88 -0
  37. package/dist/assets/chunk-RYQCIY6F-C3kPXotN.js +1 -0
  38. package/dist/assets/chunk-V7JOEXUC-wG8nLKy3.js +206 -0
  39. package/dist/assets/chunk-VR4S4FIN-Z8m3eai1.js +1 -0
  40. package/dist/assets/chunk-XXDRQBXY-Cvxssa50.js +1 -0
  41. package/dist/assets/classDiagram-OUVF2IWQ-D7WYtecl.js +1 -0
  42. package/dist/assets/classDiagram-v2-EOCWNBFH-D7WYtecl.js +1 -0
  43. package/dist/assets/cose-bilkent-JH36ORCC-CZGh2_1m.js +1 -0
  44. package/dist/assets/cynefin-VYW2F7L2-D1ekvVHL.js +178 -0
  45. package/dist/assets/cynefinDiagram-TSTJHNR4-DG8TQQPp.js +62 -0
  46. package/dist/assets/cytoscape.esm-DTSO7Bv0.js +331 -0
  47. package/dist/assets/dagre-VKFMJZFB-BaiXaaS0.js +4 -0
  48. package/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
  49. package/dist/assets/diagram-FQU43EPY-CeqWvREU.js +3 -0
  50. package/dist/assets/diagram-G47NLZAW-DFCzg162.js +24 -0
  51. package/dist/assets/diagram-NH7WQ7WH-C0YAgzIc.js +24 -0
  52. package/dist/assets/diagram-OA4YK3LP-jOEhkL10.js +30 -0
  53. package/dist/assets/diagram-WEI45ONY-lgBM2AIi.js +41 -0
  54. package/dist/assets/ebnfDiagram-CCIWWBDH-CyJH9jIa.js +1 -0
  55. package/dist/assets/erDiagram-Q63AITRT-ClSGogYA.js +85 -0
  56. package/dist/assets/flowDiagram-23GEKE2U-BT_kAtVI.js +156 -0
  57. package/dist/assets/ganttDiagram-NO4QXBWP-B9GC2kvS.js +292 -0
  58. package/dist/assets/gitGraphDiagram-IHSO6WYX-DBrpQaop.js +106 -0
  59. package/dist/assets/graph-C9eacEi8.js +1 -0
  60. package/dist/assets/index-3dubbj4M.js +1 -0
  61. package/dist/assets/index-5JAolFEo.js +1 -0
  62. package/dist/assets/{index-DdCk239w.js → index-B17qBYiT.js} +6 -6
  63. package/dist/assets/index-B7SDYZt7.js +2 -0
  64. package/dist/assets/{index-BxPFO5EJ.js → index-C8QDHgbv.js} +3 -3
  65. package/dist/assets/index-Cl65xHPu.js +1 -0
  66. package/dist/assets/index-D-MHMY5o.js +2 -0
  67. package/dist/assets/{index-BSPc0AE-.js → index-D9zcjksy.js} +6 -6
  68. package/dist/assets/index-_Zoawk3E.js +1 -0
  69. package/dist/assets/infoDiagram-FWYZ7A6U-BQ2RoWJP.js +2 -0
  70. package/dist/assets/init-Gi6I4Gst.js +1 -0
  71. package/dist/assets/ishikawaDiagram-FXEZZL3T-Cu_l3XL1.js +70 -0
  72. package/dist/assets/journeyDiagram-5HDEW3XC-DLd41wKP.js +139 -0
  73. package/dist/assets/kanban-definition-HUTT4EX6-C7s5ZCmY.js +89 -0
  74. package/dist/assets/katex-C5jXJg4s.js +257 -0
  75. package/dist/assets/layout-DEXfKzaS.js +1 -0
  76. package/dist/assets/linear-BSpfaY-I.js +1 -0
  77. package/dist/assets/{main-D6IBl2Xu.js → main-B9Esx3nK.js} +137 -137
  78. package/dist/assets/map-Czzmt4hB.js +1 -0
  79. package/dist/assets/mermaid.core-DEflf7Dd.js +314 -0
  80. package/dist/assets/mindmap-definition-LN4V7U3C-BDK-VY2F.js +96 -0
  81. package/dist/assets/ordinal-Cboi1Yqb.js +1 -0
  82. package/dist/assets/pegDiagram-2B236MQR-B62yTbzD.js +1 -0
  83. package/dist/assets/pieDiagram-ENE6RG2P-D4gWoKL0.js +39 -0
  84. package/dist/assets/quadrantDiagram-ABIIQ3AL-DVfsHeV1.js +7 -0
  85. package/dist/assets/railroadDiagram-RFXS5EU6-CmSiouVY.js +1 -0
  86. package/dist/assets/requirementDiagram-TGXJPOKE-tWX1wqNI.js +84 -0
  87. package/dist/assets/sankeyDiagram-HTMAVEWB-IBtqbfIe.js +40 -0
  88. package/dist/assets/sequenceDiagram-DBY2YBRQ-DEpwIJoi.js +162 -0
  89. package/dist/assets/sizeCapture-X5ZJPWSS-lKEocil5.js +1 -0
  90. package/dist/assets/stateDiagram-2N3HPSRC-CKaeiZlp.js +1 -0
  91. package/dist/assets/stateDiagram-v2-6OUMAXLB-Cp1B1MYN.js +1 -0
  92. package/dist/assets/swimlanes-5IMT3BWC-CJmBE5ud.js +2 -0
  93. package/dist/assets/swimlanesDiagram-G3AALYLV-DGhMYKaY.js +8 -0
  94. package/dist/assets/timeline-definition-FHXFAJF6-BFSV77MF.js +120 -0
  95. package/dist/assets/{vendor-three-Chj50gSY.js → vendor-three-3OKhI9bz.js} +1 -1
  96. package/dist/assets/vennDiagram-L72KCM5P-DYJN4_O_.js +34 -0
  97. package/dist/assets/wardleyDiagram-EHGQE667-DrCdYDR9.js +78 -0
  98. package/dist/assets/{web-BVrXaF9j.js → web-CZN__NfW.js} +1 -1
  99. package/dist/assets/{web-B6Lyhp8u.js → web-CudwTJjC.js} +1 -1
  100. package/dist/assets/{web-DQi4Jy_X.js → web-wwQhOb-1.js} +1 -1
  101. package/dist/assets/xychartDiagram-FW5EYKEG-BT8ULt0d.js +7 -0
  102. package/dist/build-info.json +1 -1
  103. package/dist/index.html +2 -2
  104. package/dist/src/packages/server/claude/runner/watchdog.js +27 -0
  105. package/dist/src/packages/server/codex/app-server/codex-app-server-runner.js +34 -4
  106. package/dist/src/packages/server/data/builtin-skills/index.js +2 -0
  107. package/dist/src/packages/server/data/builtin-skills/mermaid-diagrams.js +76 -0
  108. package/dist/src/packages/server/opencode/server/opencode-server-process.js +102 -7
  109. package/dist/src/packages/server/opencode/server/opencode-server-runner.js +13 -0
  110. package/dist/src/packages/server/services/agent-service.js +7 -0
  111. package/dist/src/packages/server/services/runtime-events.js +1 -0
  112. package/package.json +2 -1
  113. package/dist/assets/BossSpawnModal-Z6ZZuraP.js +0 -1
  114. package/dist/assets/ControlsModal-UAWrBPnS.js +0 -1
  115. package/dist/assets/DockerLogsModal-Dvk09sbP.js +0 -2
  116. package/dist/assets/IntegrationsPanel-CkZyLCWN.js +0 -2
  117. package/dist/assets/RestoreArchivedAreaModal-BKgjpTYA.js +0 -1
  118. package/dist/assets/Scene2DCanvas-BSe1eM97.js +0 -1
  119. package/dist/assets/SceneManager-Bv_J6Asr.js +0 -104
  120. package/dist/assets/SpawnModal-BGoN5C1p.js +0 -1
  121. package/dist/assets/StatisticsModal-BY9pHl-m.js +0 -1
  122. package/dist/assets/SubordinateAssignmentModal-2bO3Y-zS.js +0 -1
  123. package/dist/assets/index-BTaesMkc.js +0 -1
  124. package/dist/assets/index-CCZsNuvk.js +0 -1
  125. package/dist/assets/index-CUfnGcms.js +0 -2
  126. package/dist/assets/index-CwjljR04.js +0 -1
  127. package/dist/assets/index-DPJj90PK.js +0 -2
  128. package/dist/assets/index-I8PSiTLl.js +0 -1
@@ -1,8 +1,8 @@
1
- import{bU as ta,u as A,j as e,bc as j,b$ as Ms,c0 as Fs,bd as X,s as D,c1 as $s,r as m,D as Q,I as F,ag as Us,bl as qe,m as na,bm as la,l as ia,c2 as ra,_ as oa,S as ca,n as da,af as Ks,bn as Ue}from"./main-D6IBl2Xu.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ma=[{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 ua(r){return ta.t(r)}function Ve(r){if(r===0)return"0 B";const p=1024,u=["B","KB","MB","GB"],x=Math.floor(Math.log(r)/Math.log(p));return parseFloat((r/Math.pow(p,x)).toFixed(1))+" "+u[x]}function pa(r){const u=Date.now()-r,x=Math.floor(u/(1e3*60*60)),n=Math.floor(u%(1e3*60*60)/(1e3*60));return x>0?`${x}h ${n}m`:`${n}m`}const Hs={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 qs(r){const p=[],u=/\x1B\[([0-9;]*)m/g;let x=0,n=null,y;for(;(y=u.exec(r))!==null;){if(y.index>x){const g=r.slice(x,y.index);n?p.push(e.jsx("span",{style:{color:n},children:g},p.length)):p.push(g)}const C=y[1].split(";").map(Number);for(const g of C)g===0||g===39?n=null:Hs[g]&&(n=Hs[g]);x=u.lastIndex}if(x<r.length){const C=r.slice(x);n?p.push(e.jsx("span",{style:{color:n},children:C},p.length)):p.push(C)}return p.length>0?p:[r]}function ha({buildingName:r,onClose:p,onConfirm:u}){const{t:x}=A(["terminal","common"]);return e.jsx("div",{className:"modal-overlay visible",onClick:p,children:e.jsxs("div",{className:"modal confirm-modal",onClick:n=>n.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:x("terminal:building.deleteBuilding")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:x("terminal:building.deleteConfirm",{name:r})}),e.jsx("p",{className:"confirm-modal-note",children:x("terminal:building.deleteNote")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:p,children:x("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-danger",onClick:u,autoFocus:!0,children:x("common:buttons.delete")})]})]})})}function xa({usePM2:r,setUsePM2:p}){const{t:u}=A(["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:r,onChange:x=>p(x.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"}),u("terminal:building.usePM2")]})]}),e.jsx("div",{className:"form-hint",children:u("terminal:building.pm2Hint")})]})}function ba({usePM2:r,pm2Script:p,setPm2Script:u,pm2Args:x,setPm2Args:n,pm2Interpreter:y,setPm2Interpreter:C,pm2InterpreterArgs:g,setPm2InterpreterArgs:v,pm2Env:s,setPm2Env:h,isEditMode:a,building:t,handleCommand:c}){var f;const{t:i}=A(["terminal","common"]);return r?e.jsxs("div",{className:"form-section pm2-config-section",children:[e.jsx("label",{className:"form-label",children:i("terminal:building.pm2Configuration")}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Script"),e.jsx(j,{text:i("terminal:building.helpPm2Script"),title:i("terminal:building.pm2Script"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:p,onChange:b=>u(b.target.value),placeholder:"npm, java, python, ./app.js",required:r})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Arguments"),e.jsx(j,{text:i("terminal:building.helpPm2Arguments"),title:i("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:x,onChange:b=>n(b.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Interpreter"),e.jsx(j,{text:i("terminal:building.helpPm2Interpreter"),title:i("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:y,onChange:b=>C(b.target.value),children:Object.keys(Ms).map(b=>e.jsx("option",{value:b,children:Ms[b].label},b))})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2InterpArgs"),e.jsx(j,{text:i("terminal:building.helpPm2InterpArgs"),title:i("terminal:building.pm2InterpArgs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:b=>v(b.target.value),placeholder:"-jar (for Java)"})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Environment"),e.jsx(j,{text:i("terminal:building.helpPm2Environment"),title:i("terminal:building.pm2Environment"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:s,onChange:b=>h(b.target.value),placeholder:`KEY=value
1
+ import{bX as ta,u as A,j as e,H as j,bY as Ms,bZ as Fs,F as Q,s as D,b_ as $s,r as m,aH as X,I as F,ad as Us,b$ as qe,f as na,c0 as la,e as ia,c1 as ra,m as oa,S as ca,g as da,bc as Hs,c2 as Ue}from"./main-B9Esx3nK.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.js";const ma=[{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 ua(r){return ta.t(r)}function Ve(r){if(r===0)return"0 B";const p=1024,u=["B","KB","MB","GB"],x=Math.floor(Math.log(r)/Math.log(p));return parseFloat((r/Math.pow(p,x)).toFixed(1))+" "+u[x]}function pa(r){const u=Date.now()-r,x=Math.floor(u/(1e3*60*60)),n=Math.floor(u%(1e3*60*60)/(1e3*60));return x>0?`${x}h ${n}m`:`${n}m`}const Ks={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 qs(r){const p=[],u=/\x1B\[([0-9;]*)m/g;let x=0,n=null,y;for(;(y=u.exec(r))!==null;){if(y.index>x){const g=r.slice(x,y.index);n?p.push(e.jsx("span",{style:{color:n},children:g},p.length)):p.push(g)}const C=y[1].split(";").map(Number);for(const g of C)g===0||g===39?n=null:Ks[g]&&(n=Ks[g]);x=u.lastIndex}if(x<r.length){const C=r.slice(x);n?p.push(e.jsx("span",{style:{color:n},children:C},p.length)):p.push(C)}return p.length>0?p:[r]}function ha({buildingName:r,onClose:p,onConfirm:u}){const{t:x}=A(["terminal","common"]);return e.jsx("div",{className:"modal-overlay visible",onClick:p,children:e.jsxs("div",{className:"modal confirm-modal",onClick:n=>n.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:x("terminal:building.deleteBuilding")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:x("terminal:building.deleteConfirm",{name:r})}),e.jsx("p",{className:"confirm-modal-note",children:x("terminal:building.deleteNote")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:p,children:x("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-danger",onClick:u,autoFocus:!0,children:x("common:buttons.delete")})]})]})})}function xa({usePM2:r,setUsePM2:p}){const{t:u}=A(["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:r,onChange:x=>p(x.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"}),u("terminal:building.usePM2")]})]}),e.jsx("div",{className:"form-hint",children:u("terminal:building.pm2Hint")})]})}function ba({usePM2:r,pm2Script:p,setPm2Script:u,pm2Args:x,setPm2Args:n,pm2Interpreter:y,setPm2Interpreter:C,pm2InterpreterArgs:g,setPm2InterpreterArgs:v,pm2Env:s,setPm2Env:h,isEditMode:a,building:t,handleCommand:c}){var f;const{t:i}=A(["terminal","common"]);return r?e.jsxs("div",{className:"form-section pm2-config-section",children:[e.jsx("label",{className:"form-label",children:i("terminal:building.pm2Configuration")}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Script"),e.jsx(j,{text:i("terminal:building.helpPm2Script"),title:i("terminal:building.pm2Script"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:p,onChange:b=>u(b.target.value),placeholder:"npm, java, python, ./app.js",required:r})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Arguments"),e.jsx(j,{text:i("terminal:building.helpPm2Arguments"),title:i("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:x,onChange:b=>n(b.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Interpreter"),e.jsx(j,{text:i("terminal:building.helpPm2Interpreter"),title:i("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:y,onChange:b=>C(b.target.value),children:Object.keys(Ms).map(b=>e.jsx("option",{value:b,children:Ms[b].label},b))})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2InterpArgs"),e.jsx(j,{text:i("terminal:building.helpPm2InterpArgs"),title:i("terminal:building.pm2InterpArgs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:b=>v(b.target.value),placeholder:"-jar (for Java)"})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Environment"),e.jsx(j,{text:i("terminal:building.helpPm2Environment"),title:i("terminal:building.pm2Environment"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:s,onChange:b=>h(b.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:i("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"})]})]})]})}),a&&(t==null?void 0:t.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:t.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:[((f=t.pm2Status.cpu)==null?void 0:f.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(t.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:t.pm2Status.restarts||0})]}),t.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:pa(t.pm2Status.uptime)})]})]})}),a&&e.jsxs("div",{className:"pm2-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>c("start"),children:i("common:buttons.start")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>c("stop"),children:i("common:buttons.stop")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>c("restart"),children:i("terminal:buildingAction.restart")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>c("logs"),children:i("terminal:logs.title")})]})]}):null}function ja({dockerMode:r,setDockerMode:p,dockerImage:u,setDockerImage:x,dockerContainerName:n,setDockerContainerName:y,dockerCommand:C,setDockerCommand:g,dockerPorts:v,setDockerPorts:s,dockerVolumes:h,setDockerVolumes:a,dockerNetwork:t,setDockerNetwork:c,dockerRestart:i,setDockerRestart:f,dockerPull:b,setDockerPull:z,dockerEnv:T,setDockerEnv:B,dockerComposePath:$,setDockerComposePath:R,dockerComposeProject:K,setDockerComposeProject:I,dockerComposeServices:H,setDockerComposeServices:O,selectedExistingContainer:d,setSelectedExistingContainer:L,dockerContainersList:q,isEditMode:V,building:k,handleCommand:_}){const{t:M}=A(["config","common"]);return e.jsxs("div",{className:"form-section docker-config-section",children:[e.jsx("label",{className:"form-label",children:M("config:buildings.dockerConfig")}),e.jsxs("div",{className:"docker-mode-selector",children:[e.jsxs("label",{className:`docker-mode-option ${r==="container"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"container",checked:r==="container",onChange:()=>p("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 ${r==="compose"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"compose",checked:r==="compose",onChange:()=>p("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 ${r==="existing"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"existing",checked:r==="existing",onChange:()=>p("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"})]})]}),r==="container"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Image:",e.jsx(j,{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:u,onChange:l=>x(l.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(j,{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:n,onChange:l=>y(l.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(j,{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:C,onChange:l=>g(l.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([...v,""]),children:"+ Add"})]}),v.map((l,S)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:l,onChange:U=>{const E=[...v];E[S]=U.target.value,s(E)},placeholder:"8080:80 or 3000"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>s(v.filter((U,E)=>E!==S)),children:"x"})]},S)),v.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:()=>a([...h,""]),children:"+ Add"})]}),h.map((l,S)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:l,onChange:U=>{const E=[...h];E[S]=U.target.value,a(E)},placeholder:"./data:/app/data or /host/path:/container/path"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>a(h.filter((U,E)=>E!==S)),children:"x"})]},S)),h.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(j,{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:t,onChange:l=>c(l.target.value),placeholder:"bridge (default)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Restart Policy:",e.jsx(j,{text:"When should Docker restart the container automatically?",title:"Restart Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:i,onChange:l=>f(l.target.value),children:Object.keys(Fs).map(l=>e.jsx("option",{value:l,children:Fs[l].label},l))})]})]}),r==="compose"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Compose File:",e.jsx(j,{text:"Path to docker-compose.yml file, relative to working directory.",title:"Compose File",position:"top",size:"sm"})]}),e.jsx(X,{value:$,onChange:R,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(j,{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:K,onChange:l=>I(l.target.value),placeholder:"Auto-generated"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Services:",e.jsx(j,{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:H,onChange:l=>O(l.target.value),placeholder:"All services (or: api, db, redis)"})]})]}),r==="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(j,{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:d,onChange:l=>L(l.target.value),required:r==="existing",children:[e.jsx("option",{value:"",children:"Select a container..."}),q.map(l=>e.jsxs("option",{value:l.name,children:[l.name," (",l.image,") - ",l.state]},l.id))]}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>D.requestDockerContainersList(),title:"Refresh container list",children:"↻"})]})]}),q.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."}),d&&e.jsx("div",{className:"docker-existing-info",children:(()=>{const l=q.find(S=>S.name===d);return l?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:l.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-${l.status}`,children:l.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:l.id.slice(0,12)})]}),l.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:l.ports.map(S=>`${S.host}:${S.container}/${S.protocol}`).join(", ")})]})]}):null})()}),e.jsx("div",{className:"form-hint",children:"Note: Existing containers will not be deleted when you remove this building."})]}),r!=="existing"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Pull Policy:",e.jsx(j,{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:b,onChange:l=>z(l.target.value),children:Object.keys($s).map(l=>e.jsx("option",{value:l,children:$s[l].label},l))})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:["Environment:",e.jsx(j,{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:T,onChange:l=>B(l.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:i("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"})]})]})]})}),a&&(t==null?void 0:t.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:t.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:[((f=t.pm2Status.cpu)==null?void 0:f.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(t.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:t.pm2Status.restarts||0})]}),t.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:pa(t.pm2Status.uptime)})]})]})}),a&&e.jsxs("div",{className:"pm2-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>c("start"),children:i("common:buttons.start")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>c("stop"),children:i("common:buttons.stop")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>c("restart"),children:i("terminal:buildingAction.restart")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>c("logs"),children:i("terminal:logs.title")})]})]}):null}function ja({dockerMode:r,setDockerMode:p,dockerImage:u,setDockerImage:x,dockerContainerName:n,setDockerContainerName:y,dockerCommand:C,setDockerCommand:g,dockerPorts:v,setDockerPorts:s,dockerVolumes:h,setDockerVolumes:a,dockerNetwork:t,setDockerNetwork:c,dockerRestart:i,setDockerRestart:f,dockerPull:b,setDockerPull:z,dockerEnv:T,setDockerEnv:B,dockerComposePath:$,setDockerComposePath:R,dockerComposeProject:H,setDockerComposeProject:I,dockerComposeServices:K,setDockerComposeServices:O,selectedExistingContainer:d,setSelectedExistingContainer:L,dockerContainersList:q,isEditMode:V,building:k,handleCommand:_}){const{t:M}=A(["config","common"]);return e.jsxs("div",{className:"form-section docker-config-section",children:[e.jsx("label",{className:"form-label",children:M("config:buildings.dockerConfig")}),e.jsxs("div",{className:"docker-mode-selector",children:[e.jsxs("label",{className:`docker-mode-option ${r==="container"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"container",checked:r==="container",onChange:()=>p("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 ${r==="compose"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"compose",checked:r==="compose",onChange:()=>p("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 ${r==="existing"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"existing",checked:r==="existing",onChange:()=>p("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"})]})]}),r==="container"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Image:",e.jsx(j,{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:u,onChange:l=>x(l.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(j,{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:n,onChange:l=>y(l.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(j,{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:C,onChange:l=>g(l.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([...v,""]),children:"+ Add"})]}),v.map((l,S)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:l,onChange:U=>{const E=[...v];E[S]=U.target.value,s(E)},placeholder:"8080:80 or 3000"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>s(v.filter((U,E)=>E!==S)),children:"x"})]},S)),v.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:()=>a([...h,""]),children:"+ Add"})]}),h.map((l,S)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:l,onChange:U=>{const E=[...h];E[S]=U.target.value,a(E)},placeholder:"./data:/app/data or /host/path:/container/path"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>a(h.filter((U,E)=>E!==S)),children:"x"})]},S)),h.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(j,{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:t,onChange:l=>c(l.target.value),placeholder:"bridge (default)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Restart Policy:",e.jsx(j,{text:"When should Docker restart the container automatically?",title:"Restart Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:i,onChange:l=>f(l.target.value),children:Object.keys(Fs).map(l=>e.jsx("option",{value:l,children:Fs[l].label},l))})]})]}),r==="compose"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Compose File:",e.jsx(j,{text:"Path to docker-compose.yml file, relative to working directory.",title:"Compose File",position:"top",size:"sm"})]}),e.jsx(Q,{value:$,onChange:R,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(j,{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:H,onChange:l=>I(l.target.value),placeholder:"Auto-generated"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Services:",e.jsx(j,{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:K,onChange:l=>O(l.target.value),placeholder:"All services (or: api, db, redis)"})]})]}),r==="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(j,{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:d,onChange:l=>L(l.target.value),required:r==="existing",children:[e.jsx("option",{value:"",children:"Select a container..."}),q.map(l=>e.jsxs("option",{value:l.name,children:[l.name," (",l.image,") - ",l.state]},l.id))]}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>D.requestDockerContainersList(),title:"Refresh container list",children:"↻"})]})]}),q.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."}),d&&e.jsx("div",{className:"docker-existing-info",children:(()=>{const l=q.find(S=>S.name===d);return l?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:l.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-${l.status}`,children:l.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:l.id.slice(0,12)})]}),l.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:l.ports.map(S=>`${S.host}:${S.container}/${S.protocol}`).join(", ")})]})]}):null})()}),e.jsx("div",{className:"form-hint",children:"Note: Existing containers will not be deleted when you remove this building."})]}),r!=="existing"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Pull Policy:",e.jsx(j,{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:b,onChange:l=>z(l.target.value),children:Object.keys($s).map(l=>e.jsx("option",{value:l,children:$s[l].label},l))})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:["Environment:",e.jsx(j,{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:T,onChange:l=>B(l.target.value),placeholder:`KEY=value
4
4
  DATABASE_URL=postgres://...
5
- NODE_ENV=production`,rows:3})]})]}),V&&(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((l,S)=>e.jsxs("a",{href:`http://${window.location.hostname}:${l.host}`,target:"_blank",rel:"noopener noreferrer",className:"docker-port-link",children:[l.host,":",l.container,"/",l.protocol]},S))]}),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((l,S)=>e.jsxs("div",{className:"docker-service-item",children:[e.jsx("span",{className:"docker-service-indicator",style:{backgroundColor:l.status==="running"?"#4ade80":"#f87171"}}),e.jsx("span",{className:"docker-service-name",children:l.name}),e.jsx("span",{className:"docker-service-status",children:l.status})]},S))})]})]}),V&&e.jsxs("div",{className:"docker-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>_("start"),children:"Start"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>_("stop"),children:"Stop"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>_("restart"),children:"Restart"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>_("logs"),children:"Logs"})]})]})}const ga={enabled:!1,host:"",port:22,username:"",authMethod:"password"};function va({dbConnections:r,setDbConnections:p,activeDbConnectionId:u,setActiveDbConnectionId:x}){const{t:n}=A(["terminal","common"]),[y,C]=m.useState({}),g=m.useRef(new Map);m.useEffect(()=>{const a=t=>{const c=t.detail;if(!c||!c.requestId)return;const i=g.current.get(c.requestId);i&&(g.current.delete(c.requestId),C(f=>({...f,[i]:c.success?{status:"success",serverVersion:c.serverVersion}:{status:"error",error:c.error||"Connection failed"}})))};return window.addEventListener("tide:db-test-result",a),()=>window.removeEventListener("tide:db-test-result",a)},[]);const v=(a,t)=>{const c=[...r];c[a]={...c[a],...t},p(c)},s=(a,t)=>{const i={...r[a].ssh??ga,...t};v(a,{ssh:i})},h=a=>{const t=`test_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;g.current.set(t,a.id),C(c=>({...c,[a.id]:{status:"testing"}})),D.testDatabaseConnectionTransient(t,a),window.setTimeout(()=>{g.current.has(t)&&(g.current.delete(t),C(c=>{const i=c[a.id];return(i==null?void 0:i.status)!=="testing"?c:{...c,[a.id]:{status:"error",error:"Test connection timed out after 30s"}}}))},3e4)};return e.jsxs("div",{className:"form-section database-config-section",children:[e.jsxs("label",{className:"form-label",children:[n("terminal:building.dbConnections"),e.jsx(j,{text:n("terminal:building.helpDbConnections"),title:n("terminal:building.dbConnections"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>{const a={id:`conn_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,name:`Connection ${r.length+1}`,engine:"mysql",host:"localhost",port:3306,username:"root"};p([...r,a]),u||x(a.id)},children:n("terminal:database.addConnection")})]}),r.length===0&&e.jsx("div",{className:"form-hint",children:n("terminal:building.dbGetStarted")}),r.map((a,t)=>{var f,b,z,T,B,$,R,K,I,H,O;const c=y[a.id]??{status:"idle"},i=((f=a.ssh)==null?void 0:f.enabled)===!0;return 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:u===a.id,onChange:()=>x(a.id)}),n("common:labels.default"),e.jsx(j,{text:n("terminal:building.helpDbDefault"),position:"top",size:"sm"})]}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>{const d=r.filter(L=>L.id!==a.id);p(d),u===a.id&&d.length>0?x(d[0].id):d.length===0&&x(void 0)},children:n("common:buttons.remove")})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:n("common:labels.name")}),e.jsx("input",{type:"text",className:"form-input",value:a.name,onChange:d=>v(t,{name:d.target.value}),placeholder:"My Database"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:n("terminal:building.dbEngine")}),e.jsx("select",{className:"form-input form-select",value:a.engine,onChange:d=>{const L=d.target.value;v(t,{engine:L,port:Q[L].defaultPort})},children:Object.keys(Q).map(d=>e.jsxs("option",{value:d,children:[Q[d].icon," ",Q[d].label]},d))})]})]}),a.engine==="sqlite"?e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:n("terminal:building.dbFilepath")}),e.jsx("input",{type:"text",className:"form-input",value:a.filepath||"",onChange:d=>v(t,{filepath:d.target.value||void 0}),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.jsxs("label",{children:[n("terminal:building.dbHost"),i&&e.jsx(j,{text:"Host as seen FROM the SSH server (often 'localhost' or 127.0.0.1).",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:a.host,onChange:d=>v(t,{host:d.target.value}),placeholder:i?"127.0.0.1":"localhost"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:n("terminal:building.dbPort")}),e.jsx("input",{type:"number",className:"form-input",value:a.port,onChange:d=>v(t,{port:parseInt(d.target.value)||Q[a.engine].defaultPort})})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:n("terminal:building.dbUsername")}),e.jsx("input",{type:"text",className:"form-input",value:a.username,onChange:d=>v(t,{username:d.target.value}),placeholder:"root"})]}),e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:n("terminal:building.dbPassword")}),e.jsx("input",{type:"password",className:"form-input",value:a.password||"",onChange:d=>v(t,{password:d.target.value||void 0}),placeholder:"Optional",autoComplete:"off"})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:n("terminal:building.dbDefaultDatabase")}),e.jsx("input",{type:"text",className:"form-input",value:a.database||"",onChange:d=>v(t,{database:d.target.value||void 0}),placeholder:"Optional - select after connecting"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsxs("label",{children:["SSL",e.jsx(j,{text:n("terminal:building.helpDbSsl"),position:"top",size:"sm"})]}),e.jsxs("label",{className:"toggle-switch toggle-switch--small",children:[e.jsx("input",{type:"checkbox",checked:a.ssl||!1,onChange:d=>v(t,{ssl:d.target.checked})}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})})]})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsx("div",{className:"db-field db-field--grow",children:e.jsxs("label",{children:["SSH Tunnel",e.jsx(j,{text:"Forward DB traffic through an SSH jump host. Required when the DB is only reachable from inside a private network.",position:"top",size:"sm"})]})}),e.jsx("div",{className:"db-field db-field--small",children:e.jsxs("label",{className:"toggle-switch toggle-switch--small",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:d=>s(t,{enabled:d.target.checked})}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})})]})})]}),i&&e.jsxs("div",{className:"db-ssh-subsection",children:[e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:"SSH Host"}),e.jsx("input",{type:"text",className:"form-input",value:((b=a.ssh)==null?void 0:b.host)||"",onChange:d=>s(t,{host:d.target.value}),placeholder:"bastion.example.com"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:"SSH Port"}),e.jsx("input",{type:"number",className:"form-input",value:((z=a.ssh)==null?void 0:z.port)||22,onChange:d=>s(t,{port:parseInt(d.target.value)||22})})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:"SSH Username"}),e.jsx("input",{type:"text",className:"form-input",value:((T=a.ssh)==null?void 0:T.username)||"",onChange:d=>s(t,{username:d.target.value}),placeholder:"ubuntu"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:"Auth Method"}),e.jsxs("select",{className:"form-input form-select",value:((B=a.ssh)==null?void 0:B.authMethod)||"password",onChange:d=>s(t,{authMethod:d.target.value}),children:[e.jsx("option",{value:"password",children:"Password"}),e.jsx("option",{value:"privateKey",children:"Private Key"})]})]})]}),((($=a.ssh)==null?void 0:$.authMethod)||"password")==="password"?e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:"SSH Password"}),e.jsx("input",{type:"password",className:"form-input",value:((R=a.ssh)==null?void 0:R.password)||"",onChange:d=>s(t,{password:d.target.value||void 0}),placeholder:"SSH password",autoComplete:"off"})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsxs("label",{children:["Private Key Path",e.jsx(j,{text:"Path to a private key file on the server, e.g. ~/.ssh/id_rsa. Use this OR paste the key contents below.",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:((K=a.ssh)==null?void 0:K.privateKeyPath)||"",onChange:d=>s(t,{privateKeyPath:d.target.value||void 0}),placeholder:"/home/user/.ssh/id_rsa"})]})}),e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsxs("label",{children:["Private Key Contents (PEM)",e.jsx(j,{text:"Paste the full private key contents inline. Encrypted at rest.",position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input",value:((I=a.ssh)==null?void 0:I.privateKey)||"",onChange:d=>s(t,{privateKey:d.target.value||void 0}),placeholder:"-----BEGIN OPENSSH PRIVATE KEY-----\\n...",rows:4,style:{fontFamily:"monospace",fontSize:12}})]})}),e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:"Key Passphrase (optional)"}),e.jsx("input",{type:"password",className:"form-input",value:((H=a.ssh)==null?void 0:H.passphrase)||"",onChange:d=>s(t,{passphrase:d.target.value||void 0}),placeholder:"If your key is encrypted",autoComplete:"off"})]})})]}),e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--small",children:[e.jsxs("label",{children:["Local Port",e.jsx(j,{text:"Optional fixed local forwarded port. Leave blank to auto-assign.",position:"top",size:"sm"})]}),e.jsx("input",{type:"number",className:"form-input",value:((O=a.ssh)==null?void 0:O.localPort)??"",onChange:d=>{const L=d.target.value.trim();s(t,{localPort:L?parseInt(L):void 0})},placeholder:"auto"})]})})]}),e.jsxs("div",{className:"db-connection-row",style:{alignItems:"center",gap:8},children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-primary",disabled:c.status==="testing",onClick:()=>h(a),children:c.status==="testing"?"Testing…":"Test Connection"}),c.status==="success"&&e.jsxs("span",{style:{color:"#4aff9e",fontSize:12},children:["✓ Connected",c.serverVersion?` — ${c.serverVersion}`:""]}),c.status==="error"&&e.jsxs("span",{style:{color:"#ff6b6b",fontSize:12},title:c.error,children:["✗ ",c.error]})]})]})]},a.id)}),r.length>0&&e.jsx("div",{className:"form-hint",children:n("terminal:building.dbAfterSaving")})]})}function fa({buildings:r,buildingId:p,subordinateBuildingIds:u,setSubordinateBuildingIds:x,isEditMode:n,showBossLogs:y,setShowBossLogs:C,currentBossLogs:g,bossLogsContainerRef:v}){const{t:s}=A(["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(j,{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(r.values()).filter(h=>h.id!==p&&h.type!=="boss"&&h.type!=="link"&&h.type!=="folder").map(h=>e.jsxs("label",{className:"subordinate-building-item",children:[e.jsx("input",{type:"checkbox",checked:u.includes(h.id),onChange:a=>{a.target.checked?x([...u,h.id]):x(u.filter(t=>t!==h.id))}}),e.jsx("span",{className:"subordinate-building-icon",children:e.jsx(F,{name:Us(h.type),size:14})}),e.jsx("span",{className:"subordinate-building-name",children:h.name}),e.jsx("span",{className:"subordinate-building-status",style:{backgroundColor:qe[h.status]}})]},h.id)),Array.from(r.values()).filter(h=>h.id!==p&&h.type!=="boss"&&h.type!=="link"&&h.type!=="folder").length===0&&e.jsx("div",{className:"form-hint no-buildings-hint",children:s("terminal:building.noManageableBuildings")})]}),n&&u.length>0&&e.jsxs("div",{className:"boss-building-actions",children:[e.jsxs("div",{className:"boss-actions-header",children:[s("terminal:building.bulkActions"),e.jsx(j,{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:()=>D.sendBossBuildingCommand(p,"start_all"),children:s("terminal:building.startAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>D.sendBossBuildingCommand(p,"stop_all"),children:s("terminal:building.stopAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>D.sendBossBuildingCommand(p,"restart_all"),children:s("terminal:building.restartAll")}),e.jsx("button",{type:"button",className:`btn btn-sm ${y?"btn-primary":""}`,onClick:()=>{y?(D.stopBossLogStreaming(p),C(!1)):(D.startBossLogStreaming(p),C(!0))},children:s(y?"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:u.map(h=>{const a=r.get(h);return a?e.jsxs("div",{className:"boss-status-item",children:[e.jsx("span",{className:"boss-status-indicator",style:{backgroundColor:qe[a.status]}}),e.jsx("span",{className:"boss-status-name",children:a.name}),e.jsx("span",{className:"boss-status-label",children:a.status})]},h):null})})]})]}),n&&y&&e.jsxs("div",{className:"form-section boss-logs-section",children:[e.jsxs("label",{className:"form-label",children:[s("terminal:building.unifiedLogs"),e.jsx(j,{text:s("terminal:building.helpUnifiedLogs"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>D.clearBossStreamingLogs(p),children:s("common:buttons.clear")})]}),e.jsxs("div",{className:"boss-logs-container",ref:v,children:[g.map((h,a)=>e.jsxs("div",{className:"boss-log-entry",children:[e.jsxs("span",{className:"boss-log-source",children:["[",h.subordinateName,"]"]}),e.jsx("span",{className:"boss-log-content",children:qs(h.chunk)})]},a)),g.length===0&&e.jsx("div",{className:"boss-logs-empty",children:s("terminal:building.waitingForLogs")})]})]})]})}function Na({startCmd:r,setStartCmd:p,stopCmd:u,setStopCmd:x,restartCmd:n,setRestartCmd:y,healthCheckCmd:C,setHealthCheckCmd:g,logsCmd:v,setLogsCmd:s,isEditMode:h,handleCommand:a}){const{t}=A(["terminal","common"]);return e.jsxs("div",{className:"form-section commands-section",children:[e.jsxs("label",{className:"form-label",children:[t("terminal:building.commands"),e.jsx(j,{text:t("terminal:building.helpCommands"),title:t("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:[t("terminal:building.cmdStart"),e.jsx(j,{text:t("terminal:building.helpCmdStart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:r,onChange:c=>p(c.target.value),placeholder:"npm run dev"}),h&&e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>a("start"),disabled:!r,children:t("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[t("terminal:building.cmdStop"),e.jsx(j,{text:t("terminal:building.helpCmdStop"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:u,onChange:c=>x(c.target.value),placeholder:"pkill -f 'npm run dev'"}),h&&e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>a("stop"),disabled:!u,children:t("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[t("terminal:building.cmdRestart"),e.jsx(j,{text:t("terminal:building.helpCmdRestart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:n,onChange:c=>y(c.target.value),placeholder:"npm run restart"}),h&&e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>a("restart"),disabled:!n,children:t("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[t("terminal:building.cmdHealthCheck"),e.jsx(j,{text:t("terminal:building.helpCmdHealthCheck"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:C,onChange:c=>g(c.target.value),placeholder:"curl -s http://localhost:3000/health"}),h&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>a("healthCheck"),disabled:!C,children:t("terminal:building.check")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[t("terminal:building.cmdLogs"),e.jsx(j,{text:t("terminal:building.helpCmdLogs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:v,onChange:c=>s(c.target.value),placeholder:"tail -n 100 /var/log/app.log"}),h&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>a("logs"),children:t("terminal:building.fetch")})]})]})]})}const ka=[{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 ya({terminalShell:r,setTerminalShell:p,terminalPort:u,setTerminalPort:x,terminalSaveSession:n,setTerminalSaveSession:y,terminalArgs:C,setTerminalArgs:g,isEditMode:v,building:s,handleCommand:h,onOpenTerminal:a,onOpenBelow:t}){const{t:c}=A(["config"]),i=(s==null?void 0:s.status)==="running",f=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:c("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:c("config:buildings.terminalShell",{defaultValue:"Shell"})}),e.jsx("select",{className:"form-input",value:r,onChange:b=>p(b.target.value),children:ka.map(b=>e.jsx("option",{value:b.value,children:b.label},b.value))})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{className:"form-sublabel",children:c("config:buildings.terminalPort",{defaultValue:"Port"})}),e.jsx("input",{type:"number",className:"form-input",value:u,onChange:b=>x(b.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:n,onChange:b=>y(b.target.checked)}),e.jsx("span",{children:c("config:buildings.terminalSaveSession",{defaultValue:"Persist session (tmux)"})})]})}),e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsx("label",{className:"form-sublabel",children:c("config:buildings.terminalArgs",{defaultValue:"Extra ttyd args"})}),e.jsx("input",{type:"text",className:"form-input",value:C,onChange:b=>g(b.target.value),placeholder:"--client-option titleFixed=Terminal"}),e.jsx("div",{className:"form-hint",children:"Additional command-line arguments passed to ttyd"})]})]}),v&&s&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:c("config:buildings.terminalControls",{defaultValue:"Terminal Controls"})}),f&&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:f.url})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"PID"}),e.jsx("span",{className:"runtime-value",children:f.pid})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Port"}),e.jsx("span",{className:"runtime-value",children:f.port})]}),f.tmuxSession&&e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Session"}),e.jsx("span",{className:"runtime-value",children:f.tmuxSession})]})]}),e.jsxs("div",{className:"building-actions",style:{marginTop:"8px"},children:[!i&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>h("start"),children:[e.jsx(F,{name:"play",size:12})," Start"]}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>h("restart"),children:[e.jsx(F,{name:"refresh",size:12})," Restart"]}),e.jsxs("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>h("stop"),children:[e.jsx(F,{name:"stop",size:12})," Stop"]}),(f==null?void 0:f.url)&&e.jsxs(e.Fragment,{children:[a&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>a(f.url),children:[e.jsx(F,{name:"desktop",size:12})," Modal"]}),t&&s&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>t(s.id),children:[e.jsx(F,{name:"arrow-down",size:12})," Below"]})]})]})]})]})]})}function Ca({logs:r,buildingId:p,logsContainerRef:u}){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:()=>D.clearBuildingLogs(p),children:"Clear"})]}),e.jsx("div",{className:"logs-container",ref:u,children:r.map((x,n)=>e.jsx("pre",{className:"log-entry",children:qs(x)},n))})]})}function Da({isOpen:r,onClose:p,buildingId:u,initialPosition:x}){const{t:n}=A(["config","common"]),y=na(),C=la(),g=ia(),v=ra(),s=u?y.get(u):null,h=u?g.get(u)||[]:[],a=!!s,[t,c]=m.useState(""),[i,f]=m.useState("server"),[b,z]=m.useState("server-rack"),[T,B]=m.useState(""),[$,R]=m.useState(""),[K,I]=m.useState(""),[H,O]=m.useState(""),[d,L]=m.useState(""),[q,V]=m.useState(""),[k,_]=m.useState(""),[M,l]=m.useState([]),[S,U]=m.useState(!1),[E,J]=m.useState(""),[W,ee]=m.useState(1),[Z,te]=m.useState(!1),[Ge,ne]=m.useState(""),[Ye,le]=m.useState(""),[Je,ie]=m.useState(""),[We,re]=m.useState(""),[Ze,oe]=m.useState(""),[Vs,ce]=m.useState(!1),[P,de]=m.useState("container"),[me,ue]=m.useState(""),[Qe,pe]=m.useState(""),[he,xe]=m.useState(""),[be,je]=m.useState([]),[ge,ve]=m.useState([]),[Xe,fe]=m.useState(""),[Ne,ke]=m.useState(""),[ye,Ce]=m.useState(""),[es,Se]=m.useState("unless-stopped"),[ss,we]=m.useState("missing"),[Pe,De]=m.useState(""),[Ee,Le]=m.useState(""),[ze,Be]=m.useState(""),[Ae,Te]=m.useState([]),[Gs,Ys]=m.useState(!1),[Re,Ie]=m.useState([]),[as,Oe]=m.useState(void 0),[ts,_e]=m.useState(""),[Me,Fe]=m.useState(""),[ns,$e]=m.useState(!1),[ls,Ke]=m.useState(""),is=m.useRef(null),Js=m.useRef(null),se=m.useRef(null);m.useEffect(()=>{var o,N,w,G,ds,ms,us,ps,hs,xs,bs,js,gs,vs,fs,Ns,ks,ys,Cs,Ss,ws,Ps,Ds,Es,Ls,zs,Bs,As,Ts,Rs,Is,Os,_s;r&&(s?(c(s.name),f(s.type),z(s.style||"server-rack"),B(s.color||""),R(s.cwd||""),I(((o=s.commands)==null?void 0:o.start)||""),O(((N=s.commands)==null?void 0:N.stop)||""),L(((w=s.commands)==null?void 0:w.restart)||""),V(((G=s.commands)==null?void 0:G.healthCheck)||""),_(((ds=s.commands)==null?void 0:ds.logs)||""),l(s.urls||[]),J(s.folderPath||""),ee(s.scale||1),te(((ms=s.pm2)==null?void 0:ms.enabled)||!1),ne(((us=s.pm2)==null?void 0:us.script)||""),le(((ps=s.pm2)==null?void 0:ps.args)||""),ie(((hs=s.pm2)==null?void 0:hs.interpreter)||""),re(((xs=s.pm2)==null?void 0:xs.interpreterArgs)||""),oe((bs=s.pm2)!=null&&bs.env?Object.entries(s.pm2.env).map(([Y,He])=>`${Y}=${He}`).join(`
6
- `):""),de(((js=s.docker)==null?void 0:js.mode)||"container"),ue(((gs=s.docker)==null?void 0:gs.mode)==="existing"&&((vs=s.docker)==null?void 0:vs.containerName)||""),pe(((fs=s.docker)==null?void 0:fs.image)||""),xe(((Ns=s.docker)==null?void 0:Ns.containerName)||""),je(((ks=s.docker)==null?void 0:ks.ports)||[]),ve(((ys=s.docker)==null?void 0:ys.volumes)||[]),fe((Cs=s.docker)!=null&&Cs.env?Object.entries(s.docker.env).map(([Y,He])=>`${Y}=${He}`).join(`
7
- `):""),ke(((Ss=s.docker)==null?void 0:Ss.network)||""),Ce(((ws=s.docker)==null?void 0:ws.command)||""),Se(((Ps=s.docker)==null?void 0:Ps.restart)||"unless-stopped"),we(((Ds=s.docker)==null?void 0:Ds.pull)||"missing"),De(((Es=s.docker)==null?void 0:Es.composePath)||""),Le(((Ls=s.docker)==null?void 0:Ls.composeProject)||""),Be(((Bs=(zs=s.docker)==null?void 0:zs.services)==null?void 0:Bs.join(", "))||""),Te(s.subordinateBuildingIds||[]),Ie(((As=s.database)==null?void 0:As.connections)||[]),Oe((Ts=s.database)==null?void 0:Ts.activeConnectionId),_e(((Rs=s.terminal)==null?void 0:Rs.shell)||""),Fe((Is=s.terminal)!=null&&Is.port?String(s.terminal.port):""),$e(((Os=s.terminal)==null?void 0:Os.saveSession)||!1),Ke(((_s=s.terminal)==null?void 0:_s.args)||"")):(c("New Server"),f("server"),z("server-rack"),B(""),R(oa(ca.LAST_CWD)),I(""),O(""),L(""),V(""),_(""),l([]),J(""),ee(1),te(!1),ne(""),le(""),ie(""),re(""),oe(""),de("container"),ue(""),pe(""),xe(""),je([]),ve([]),fe(""),ke(""),Ce(""),Se("unless-stopped"),we("missing"),De(""),Le(""),Be(""),Te([]),Ie([]),Oe(void 0),_e(""),Fe(""),$e(!1),Ke("")),setTimeout(()=>{var Y;return(Y=is.current)==null?void 0:Y.focus()},100))},[r,s]),m.useEffect(()=>{se.current&&(se.current.scrollTop=se.current.scrollHeight)},[C]),m.useEffect(()=>{i==="docker"&&P==="existing"&&D.requestDockerContainersList()},[i,P]);const rs=o=>{if(o.trim())return Object.fromEntries(o.trim().split(`
8
- `).map(N=>N.trim()).filter(N=>N&&N.includes("=")).map(N=>{const w=N.indexOf("=");return[N.slice(0,w),N.slice(w+1)]}))},Ws=o=>{o.preventDefault();const N={name:t,type:i,style:b,color:T||void 0,position:x||(s==null?void 0:s.position)||{x:0,z:0},cwd:$||void 0,folderPath:E||void 0,commands:Z?void 0:{start:K||void 0,stop:H||void 0,restart:d||void 0,healthCheck:q||void 0,logs:k||void 0},pm2:Z?{enabled:!0,script:Ge,args:Ye||void 0,interpreter:Je||void 0,interpreterArgs:We||void 0,env:rs(Ze)}:void 0,docker:i==="docker"?{enabled:!0,mode:P,image:P==="container"?Qe:void 0,containerName:P==="container"&&he?he:P==="existing"&&me?me:void 0,ports:P==="container"&&be.length>0?be:void 0,volumes:P==="container"&&ge.length>0?ge:void 0,env:rs(Xe),network:P==="container"&&Ne?Ne:void 0,command:P==="container"&&ye?ye:void 0,restart:P==="container"?es:void 0,pull:P!=="existing"?ss:void 0,composePath:P==="compose"&&Pe?Pe:void 0,composeProject:P==="compose"&&Ee?Ee:void 0,services:P==="compose"&&ze?ze.split(",").map(w=>w.trim()).filter(w=>w):void 0}:void 0,urls:M.length>0?M:void 0,scale:W!==1?W:void 0,subordinateBuildingIds:i==="boss"&&Ae.length>0?Ae:void 0,database:i==="database"&&Re.length>0?{connections:Re,activeConnectionId:as}:void 0,terminal:i==="terminal"?{enabled:!0,shell:ts||void 0,port:Me?parseInt(Me,10):void 0,saveSession:ns||void 0,args:ls||void 0}:void 0};a&&u?D.updateBuilding(u,N):D.createBuilding(N),p()},Zs=()=>{ce(!0)},Qs=()=>{u&&(D.deleteBuilding(u),ce(!1),p())},ae=o=>{u&&(D.sendBuildingCommand(u,o),o==="logs"&&U(!0))},Xs=()=>{l([...M,{label:"",url:""}])},ea=o=>{l(M.filter((N,w)=>w!==o))},os=(o,N,w)=>{const G=[...M];G[o]={...G[o],[N]:w},l(G)},{handleMouseDown:sa,handleClick:aa}=da(p);if(!r)return null;const cs=u?D.getBuildingLogs(u):[];return e.jsxs("div",{className:"modal-overlay visible",onMouseDown:sa,onClick:aa,children:[e.jsxs("div",{className:"modal building-config-modal",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("span",{children:n(a?"config:buildings.editBuilding":"config:buildings.addBuilding")}),a&&s&&e.jsx("span",{className:"building-status-badge",style:{backgroundColor:qe[s.status]},children:s.status})]}),e.jsxs("form",{onSubmit:Ws,children:[e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("common:labels.name")}),e.jsx("input",{ref:is,type:"text",className:"form-input",value:t,onChange:o=>c(o.target.value),placeholder:n("config:buildings.namePlaceholder"),required:!0})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("common:labels.type")}),e.jsx("div",{className:"building-type-selector",children:Object.keys(Ks).map(o=>e.jsxs("button",{type:"button",className:`building-type-btn ${i===o?"active":""}`,onClick:()=>{f(o),o==="database"&&b==="server-rack"&&z("filing-cabinet"),o==="tests"&&b==="server-rack"&&z("dome"),o==="http"&&b==="server-rack"&&z("satellite")},title:Ks[o].description,children:[e.jsx("span",{className:"building-type-icon",children:e.jsx(F,{name:Us(o),size:16})}),e.jsx("span",{className:"building-type-name",children:o})]},o))})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("config:buildings.style")}),e.jsx("div",{className:"building-style-selector",children:Object.keys(Ue).map(o=>e.jsxs("button",{type:"button",className:`building-style-btn ${b===o?"active":""}`,onClick:()=>z(o),title:Ue[o].description,children:[e.jsx("span",{className:"building-style-preview","data-style":o}),e.jsx("span",{className:"building-style-name",children:Ue[o].label})]},o))})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("common:labels.color")}),e.jsxs("div",{className:"building-color-selector",children:[ma.map(o=>e.jsx("button",{type:"button",className:`building-color-btn ${T===o.value?"active":""}`,onClick:()=>B(o.value),title:ua(o.labelKey),style:o.value?{backgroundColor:o.value}:void 0,children:!o.value&&e.jsx("span",{className:"color-default-icon",children:e.jsx(F,{name:"gear",size:12})})},o.value||"default")),e.jsx("input",{type:"color",className:"building-color-picker",value:T||"#2a2a3a",onChange:o=>B(o.target.value),title:"Custom color"})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("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(W/.1)/Math.log(100)*100,onChange:o=>{const N=parseFloat(o.target.value),w=.1*Math.pow(100,N/100);ee(Math.round(w*100)/100)}}),e.jsxs("span",{className:"size-value",children:[W.toFixed(2),"x"]})]}),e.jsx("div",{className:"size-presets",children:[.5,.75,1,1.25,1.5,2].map(o=>e.jsxs("button",{type:"button",className:`size-preset-btn ${W===o?"active":""}`,onClick:()=>ee(o),children:[o,"x"]},o))})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("config:buildings.directory")}),e.jsx(X,{value:$,onChange:R,placeholder:"/path/to/project",className:"form-input",directoriesOnly:!0})]}),i==="folder"&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("config:buildings.folderPath")}),e.jsx(X,{value:E,onChange:J,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"})]}),i==="tests"&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:"Tests Folder"}),e.jsx(X,{value:E,onChange:J,placeholder:"/path/to/project/src/test",className:"form-input",directoriesOnly:!0}),e.jsx("div",{className:"form-hint",children:"Click this building to browse, search and run the tests of this folder (any folder inside a Maven module works)"})]}),i==="http"&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:"Requests Folder"}),e.jsx(X,{value:E,onChange:J,placeholder:"/path/to/project/http-requests",className:"form-input",directoriesOnly:!0}),e.jsx("div",{className:"form-hint",children:"Click this building to browse and fire the .http request files of this folder (IntelliJ HTTP Client style; http-client.env.json environments supported)"})]}),i==="boss"&&e.jsx(fa,{buildings:y,buildingId:u,subordinateBuildingIds:Ae,setSubordinateBuildingIds:Te,isEditMode:a,showBossLogs:Gs,setShowBossLogs:Ys,currentBossLogs:h,bossLogsContainerRef:Js}),i==="database"&&e.jsx(va,{dbConnections:Re,setDbConnections:Ie,activeDbConnectionId:as,setActiveDbConnectionId:Oe}),i==="server"&&e.jsx(xa,{usePM2:Z,setUsePM2:te}),i==="server"&&e.jsx(ba,{usePM2:Z,pm2Script:Ge,setPm2Script:ne,pm2Args:Ye,setPm2Args:le,pm2Interpreter:Je,setPm2Interpreter:ie,pm2InterpreterArgs:We,setPm2InterpreterArgs:re,pm2Env:Ze,setPm2Env:oe,isEditMode:a,building:s??null,handleCommand:ae}),i==="docker"&&e.jsx(ja,{dockerMode:P,setDockerMode:de,dockerImage:Qe,setDockerImage:pe,dockerContainerName:he,setDockerContainerName:xe,dockerCommand:ye,setDockerCommand:Ce,dockerPorts:be,setDockerPorts:je,dockerVolumes:ge,setDockerVolumes:ve,dockerNetwork:Ne,setDockerNetwork:ke,dockerRestart:es,setDockerRestart:Se,dockerPull:ss,setDockerPull:we,dockerEnv:Xe,setDockerEnv:fe,dockerComposePath:Pe,setDockerComposePath:De,dockerComposeProject:Ee,setDockerComposeProject:Le,dockerComposeServices:ze,setDockerComposeServices:Be,selectedExistingContainer:me,setSelectedExistingContainer:ue,dockerContainersList:v,isEditMode:a,building:s??null,handleCommand:ae}),i==="terminal"&&e.jsx(ya,{terminalShell:ts,setTerminalShell:_e,terminalPort:Me,setTerminalPort:Fe,terminalSaveSession:ns,setTerminalSaveSession:$e,terminalArgs:ls,setTerminalArgs:Ke,isEditMode:a,building:s??null,handleCommand:ae,onOpenTerminal:()=>{s!=null&&s.id&&window.dispatchEvent(new CustomEvent("tide:open-iframe-modal",{detail:{buildingId:s.id}}))},onOpenBelow:o=>{window.dispatchEvent(new CustomEvent("tide:open-bottom-terminal",{detail:{buildingId:o}}))}}),i==="server"&&!Z&&e.jsx(Na,{startCmd:K,setStartCmd:I,stopCmd:H,setStopCmd:O,restartCmd:d,setRestartCmd:L,healthCheckCmd:q,setHealthCheckCmd:V,logsCmd:k,setLogsCmd:_,isEditMode:a,handleCommand:ae}),e.jsxs("div",{className:"form-section",children:[e.jsxs("label",{className:"form-label",children:[n("config:buildings.links"),e.jsxs("button",{type:"button",className:"btn btn-sm btn-add",onClick:Xs,children:["+ ",n("common:buttons.add")]})]}),M.map((o,N)=>e.jsxs("div",{className:"url-row",children:[e.jsx("input",{type:"text",className:"form-input url-label",value:o.label,onChange:w=>os(N,"label",w.target.value),placeholder:"Label"}),e.jsx("input",{type:"text",className:"form-input url-value",value:o.url,onChange:w=>os(N,"url",w.target.value),placeholder:"https://..."}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>ea(N),children:"x"})]},N))]}),a&&S&&cs.length>0&&e.jsx(Ca,{logs:cs,buildingId:u,logsContainerRef:se})]}),e.jsxs("div",{className:"modal-footer",children:[a&&e.jsx("button",{type:"button",className:"btn btn-danger",onClick:Zs,children:n("common:buttons.delete")}),e.jsx("div",{className:"footer-spacer"}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:p,children:n("common:buttons.cancel")}),e.jsx("button",{type:"submit",className:"btn btn-primary",children:n(a?"common:buttons.save":"common:buttons.create")})]})]})]}),Vs&&s&&e.jsx(ha,{buildingName:s.name,onClose:()=>ce(!1),onConfirm:Qs})]})}export{Da as BuildingConfigModal};
5
+ NODE_ENV=production`,rows:3})]})]}),V&&(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((l,S)=>e.jsxs("a",{href:`http://${window.location.hostname}:${l.host}`,target:"_blank",rel:"noopener noreferrer",className:"docker-port-link",children:[l.host,":",l.container,"/",l.protocol]},S))]}),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((l,S)=>e.jsxs("div",{className:"docker-service-item",children:[e.jsx("span",{className:"docker-service-indicator",style:{backgroundColor:l.status==="running"?"#4ade80":"#f87171"}}),e.jsx("span",{className:"docker-service-name",children:l.name}),e.jsx("span",{className:"docker-service-status",children:l.status})]},S))})]})]}),V&&e.jsxs("div",{className:"docker-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>_("start"),children:"Start"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>_("stop"),children:"Stop"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>_("restart"),children:"Restart"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>_("logs"),children:"Logs"})]})]})}const ga={enabled:!1,host:"",port:22,username:"",authMethod:"password"};function va({dbConnections:r,setDbConnections:p,activeDbConnectionId:u,setActiveDbConnectionId:x}){const{t:n}=A(["terminal","common"]),[y,C]=m.useState({}),g=m.useRef(new Map);m.useEffect(()=>{const a=t=>{const c=t.detail;if(!c||!c.requestId)return;const i=g.current.get(c.requestId);i&&(g.current.delete(c.requestId),C(f=>({...f,[i]:c.success?{status:"success",serverVersion:c.serverVersion}:{status:"error",error:c.error||"Connection failed"}})))};return window.addEventListener("tide:db-test-result",a),()=>window.removeEventListener("tide:db-test-result",a)},[]);const v=(a,t)=>{const c=[...r];c[a]={...c[a],...t},p(c)},s=(a,t)=>{const i={...r[a].ssh??ga,...t};v(a,{ssh:i})},h=a=>{const t=`test_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;g.current.set(t,a.id),C(c=>({...c,[a.id]:{status:"testing"}})),D.testDatabaseConnectionTransient(t,a),window.setTimeout(()=>{g.current.has(t)&&(g.current.delete(t),C(c=>{const i=c[a.id];return(i==null?void 0:i.status)!=="testing"?c:{...c,[a.id]:{status:"error",error:"Test connection timed out after 30s"}}}))},3e4)};return e.jsxs("div",{className:"form-section database-config-section",children:[e.jsxs("label",{className:"form-label",children:[n("terminal:building.dbConnections"),e.jsx(j,{text:n("terminal:building.helpDbConnections"),title:n("terminal:building.dbConnections"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>{const a={id:`conn_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,name:`Connection ${r.length+1}`,engine:"mysql",host:"localhost",port:3306,username:"root"};p([...r,a]),u||x(a.id)},children:n("terminal:database.addConnection")})]}),r.length===0&&e.jsx("div",{className:"form-hint",children:n("terminal:building.dbGetStarted")}),r.map((a,t)=>{var f,b,z,T,B,$,R,H,I,K,O;const c=y[a.id]??{status:"idle"},i=((f=a.ssh)==null?void 0:f.enabled)===!0;return 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:u===a.id,onChange:()=>x(a.id)}),n("common:labels.default"),e.jsx(j,{text:n("terminal:building.helpDbDefault"),position:"top",size:"sm"})]}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>{const d=r.filter(L=>L.id!==a.id);p(d),u===a.id&&d.length>0?x(d[0].id):d.length===0&&x(void 0)},children:n("common:buttons.remove")})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:n("common:labels.name")}),e.jsx("input",{type:"text",className:"form-input",value:a.name,onChange:d=>v(t,{name:d.target.value}),placeholder:"My Database"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:n("terminal:building.dbEngine")}),e.jsx("select",{className:"form-input form-select",value:a.engine,onChange:d=>{const L=d.target.value;v(t,{engine:L,port:X[L].defaultPort})},children:Object.keys(X).map(d=>e.jsxs("option",{value:d,children:[X[d].icon," ",X[d].label]},d))})]})]}),a.engine==="sqlite"?e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:n("terminal:building.dbFilepath")}),e.jsx("input",{type:"text",className:"form-input",value:a.filepath||"",onChange:d=>v(t,{filepath:d.target.value||void 0}),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.jsxs("label",{children:[n("terminal:building.dbHost"),i&&e.jsx(j,{text:"Host as seen FROM the SSH server (often 'localhost' or 127.0.0.1).",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:a.host,onChange:d=>v(t,{host:d.target.value}),placeholder:i?"127.0.0.1":"localhost"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:n("terminal:building.dbPort")}),e.jsx("input",{type:"number",className:"form-input",value:a.port,onChange:d=>v(t,{port:parseInt(d.target.value)||X[a.engine].defaultPort})})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:n("terminal:building.dbUsername")}),e.jsx("input",{type:"text",className:"form-input",value:a.username,onChange:d=>v(t,{username:d.target.value}),placeholder:"root"})]}),e.jsxs("div",{className:"db-field",children:[e.jsx("label",{children:n("terminal:building.dbPassword")}),e.jsx("input",{type:"password",className:"form-input",value:a.password||"",onChange:d=>v(t,{password:d.target.value||void 0}),placeholder:"Optional",autoComplete:"off"})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:n("terminal:building.dbDefaultDatabase")}),e.jsx("input",{type:"text",className:"form-input",value:a.database||"",onChange:d=>v(t,{database:d.target.value||void 0}),placeholder:"Optional - select after connecting"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsxs("label",{children:["SSL",e.jsx(j,{text:n("terminal:building.helpDbSsl"),position:"top",size:"sm"})]}),e.jsxs("label",{className:"toggle-switch toggle-switch--small",children:[e.jsx("input",{type:"checkbox",checked:a.ssl||!1,onChange:d=>v(t,{ssl:d.target.checked})}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})})]})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsx("div",{className:"db-field db-field--grow",children:e.jsxs("label",{children:["SSH Tunnel",e.jsx(j,{text:"Forward DB traffic through an SSH jump host. Required when the DB is only reachable from inside a private network.",position:"top",size:"sm"})]})}),e.jsx("div",{className:"db-field db-field--small",children:e.jsxs("label",{className:"toggle-switch toggle-switch--small",children:[e.jsx("input",{type:"checkbox",checked:i,onChange:d=>s(t,{enabled:d.target.checked})}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})})]})})]}),i&&e.jsxs("div",{className:"db-ssh-subsection",children:[e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:"SSH Host"}),e.jsx("input",{type:"text",className:"form-input",value:((b=a.ssh)==null?void 0:b.host)||"",onChange:d=>s(t,{host:d.target.value}),placeholder:"bastion.example.com"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:"SSH Port"}),e.jsx("input",{type:"number",className:"form-input",value:((z=a.ssh)==null?void 0:z.port)||22,onChange:d=>s(t,{port:parseInt(d.target.value)||22})})]})]}),e.jsxs("div",{className:"db-connection-row",children:[e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:"SSH Username"}),e.jsx("input",{type:"text",className:"form-input",value:((T=a.ssh)==null?void 0:T.username)||"",onChange:d=>s(t,{username:d.target.value}),placeholder:"ubuntu"})]}),e.jsxs("div",{className:"db-field db-field--small",children:[e.jsx("label",{children:"Auth Method"}),e.jsxs("select",{className:"form-input form-select",value:((B=a.ssh)==null?void 0:B.authMethod)||"password",onChange:d=>s(t,{authMethod:d.target.value}),children:[e.jsx("option",{value:"password",children:"Password"}),e.jsx("option",{value:"privateKey",children:"Private Key"})]})]})]}),((($=a.ssh)==null?void 0:$.authMethod)||"password")==="password"?e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:"SSH Password"}),e.jsx("input",{type:"password",className:"form-input",value:((R=a.ssh)==null?void 0:R.password)||"",onChange:d=>s(t,{password:d.target.value||void 0}),placeholder:"SSH password",autoComplete:"off"})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsxs("label",{children:["Private Key Path",e.jsx(j,{text:"Path to a private key file on the server, e.g. ~/.ssh/id_rsa. Use this OR paste the key contents below.",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:((H=a.ssh)==null?void 0:H.privateKeyPath)||"",onChange:d=>s(t,{privateKeyPath:d.target.value||void 0}),placeholder:"/home/user/.ssh/id_rsa"})]})}),e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsxs("label",{children:["Private Key Contents (PEM)",e.jsx(j,{text:"Paste the full private key contents inline. Encrypted at rest.",position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input",value:((I=a.ssh)==null?void 0:I.privateKey)||"",onChange:d=>s(t,{privateKey:d.target.value||void 0}),placeholder:"-----BEGIN OPENSSH PRIVATE KEY-----\\n...",rows:4,style:{fontFamily:"monospace",fontSize:12}})]})}),e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--grow",children:[e.jsx("label",{children:"Key Passphrase (optional)"}),e.jsx("input",{type:"password",className:"form-input",value:((K=a.ssh)==null?void 0:K.passphrase)||"",onChange:d=>s(t,{passphrase:d.target.value||void 0}),placeholder:"If your key is encrypted",autoComplete:"off"})]})})]}),e.jsx("div",{className:"db-connection-row",children:e.jsxs("div",{className:"db-field db-field--small",children:[e.jsxs("label",{children:["Local Port",e.jsx(j,{text:"Optional fixed local forwarded port. Leave blank to auto-assign.",position:"top",size:"sm"})]}),e.jsx("input",{type:"number",className:"form-input",value:((O=a.ssh)==null?void 0:O.localPort)??"",onChange:d=>{const L=d.target.value.trim();s(t,{localPort:L?parseInt(L):void 0})},placeholder:"auto"})]})})]}),e.jsxs("div",{className:"db-connection-row",style:{alignItems:"center",gap:8},children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-primary",disabled:c.status==="testing",onClick:()=>h(a),children:c.status==="testing"?"Testing…":"Test Connection"}),c.status==="success"&&e.jsxs("span",{style:{color:"#4aff9e",fontSize:12},children:["✓ Connected",c.serverVersion?` — ${c.serverVersion}`:""]}),c.status==="error"&&e.jsxs("span",{style:{color:"#ff6b6b",fontSize:12},title:c.error,children:["✗ ",c.error]})]})]})]},a.id)}),r.length>0&&e.jsx("div",{className:"form-hint",children:n("terminal:building.dbAfterSaving")})]})}function fa({buildings:r,buildingId:p,subordinateBuildingIds:u,setSubordinateBuildingIds:x,isEditMode:n,showBossLogs:y,setShowBossLogs:C,currentBossLogs:g,bossLogsContainerRef:v}){const{t:s}=A(["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(j,{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(r.values()).filter(h=>h.id!==p&&h.type!=="boss"&&h.type!=="link"&&h.type!=="folder").map(h=>e.jsxs("label",{className:"subordinate-building-item",children:[e.jsx("input",{type:"checkbox",checked:u.includes(h.id),onChange:a=>{a.target.checked?x([...u,h.id]):x(u.filter(t=>t!==h.id))}}),e.jsx("span",{className:"subordinate-building-icon",children:e.jsx(F,{name:Us(h.type),size:14})}),e.jsx("span",{className:"subordinate-building-name",children:h.name}),e.jsx("span",{className:"subordinate-building-status",style:{backgroundColor:qe[h.status]}})]},h.id)),Array.from(r.values()).filter(h=>h.id!==p&&h.type!=="boss"&&h.type!=="link"&&h.type!=="folder").length===0&&e.jsx("div",{className:"form-hint no-buildings-hint",children:s("terminal:building.noManageableBuildings")})]}),n&&u.length>0&&e.jsxs("div",{className:"boss-building-actions",children:[e.jsxs("div",{className:"boss-actions-header",children:[s("terminal:building.bulkActions"),e.jsx(j,{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:()=>D.sendBossBuildingCommand(p,"start_all"),children:s("terminal:building.startAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>D.sendBossBuildingCommand(p,"stop_all"),children:s("terminal:building.stopAll")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>D.sendBossBuildingCommand(p,"restart_all"),children:s("terminal:building.restartAll")}),e.jsx("button",{type:"button",className:`btn btn-sm ${y?"btn-primary":""}`,onClick:()=>{y?(D.stopBossLogStreaming(p),C(!1)):(D.startBossLogStreaming(p),C(!0))},children:s(y?"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:u.map(h=>{const a=r.get(h);return a?e.jsxs("div",{className:"boss-status-item",children:[e.jsx("span",{className:"boss-status-indicator",style:{backgroundColor:qe[a.status]}}),e.jsx("span",{className:"boss-status-name",children:a.name}),e.jsx("span",{className:"boss-status-label",children:a.status})]},h):null})})]})]}),n&&y&&e.jsxs("div",{className:"form-section boss-logs-section",children:[e.jsxs("label",{className:"form-label",children:[s("terminal:building.unifiedLogs"),e.jsx(j,{text:s("terminal:building.helpUnifiedLogs"),position:"top",size:"sm"}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>D.clearBossStreamingLogs(p),children:s("common:buttons.clear")})]}),e.jsxs("div",{className:"boss-logs-container",ref:v,children:[g.map((h,a)=>e.jsxs("div",{className:"boss-log-entry",children:[e.jsxs("span",{className:"boss-log-source",children:["[",h.subordinateName,"]"]}),e.jsx("span",{className:"boss-log-content",children:qs(h.chunk)})]},a)),g.length===0&&e.jsx("div",{className:"boss-logs-empty",children:s("terminal:building.waitingForLogs")})]})]})]})}function Na({startCmd:r,setStartCmd:p,stopCmd:u,setStopCmd:x,restartCmd:n,setRestartCmd:y,healthCheckCmd:C,setHealthCheckCmd:g,logsCmd:v,setLogsCmd:s,isEditMode:h,handleCommand:a}){const{t}=A(["terminal","common"]);return e.jsxs("div",{className:"form-section commands-section",children:[e.jsxs("label",{className:"form-label",children:[t("terminal:building.commands"),e.jsx(j,{text:t("terminal:building.helpCommands"),title:t("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:[t("terminal:building.cmdStart"),e.jsx(j,{text:t("terminal:building.helpCmdStart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:r,onChange:c=>p(c.target.value),placeholder:"npm run dev"}),h&&e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>a("start"),disabled:!r,children:t("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[t("terminal:building.cmdStop"),e.jsx(j,{text:t("terminal:building.helpCmdStop"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:u,onChange:c=>x(c.target.value),placeholder:"pkill -f 'npm run dev'"}),h&&e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>a("stop"),disabled:!u,children:t("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[t("terminal:building.cmdRestart"),e.jsx(j,{text:t("terminal:building.helpCmdRestart"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:n,onChange:c=>y(c.target.value),placeholder:"npm run restart"}),h&&e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>a("restart"),disabled:!n,children:t("common:buttons2.run")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[t("terminal:building.cmdHealthCheck"),e.jsx(j,{text:t("terminal:building.helpCmdHealthCheck"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:C,onChange:c=>g(c.target.value),placeholder:"curl -s http://localhost:3000/health"}),h&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>a("healthCheck"),disabled:!C,children:t("terminal:building.check")})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[t("terminal:building.cmdLogs"),e.jsx(j,{text:t("terminal:building.helpCmdLogs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:v,onChange:c=>s(c.target.value),placeholder:"tail -n 100 /var/log/app.log"}),h&&e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>a("logs"),children:t("terminal:building.fetch")})]})]})]})}const ka=[{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 ya({terminalShell:r,setTerminalShell:p,terminalPort:u,setTerminalPort:x,terminalSaveSession:n,setTerminalSaveSession:y,terminalArgs:C,setTerminalArgs:g,isEditMode:v,building:s,handleCommand:h,onOpenTerminal:a,onOpenBelow:t}){const{t:c}=A(["config"]),i=(s==null?void 0:s.status)==="running",f=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:c("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:c("config:buildings.terminalShell",{defaultValue:"Shell"})}),e.jsx("select",{className:"form-input",value:r,onChange:b=>p(b.target.value),children:ka.map(b=>e.jsx("option",{value:b.value,children:b.label},b.value))})]}),e.jsxs("div",{className:"form-field",children:[e.jsx("label",{className:"form-sublabel",children:c("config:buildings.terminalPort",{defaultValue:"Port"})}),e.jsx("input",{type:"number",className:"form-input",value:u,onChange:b=>x(b.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:n,onChange:b=>y(b.target.checked)}),e.jsx("span",{children:c("config:buildings.terminalSaveSession",{defaultValue:"Persist session (tmux)"})})]})}),e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsx("label",{className:"form-sublabel",children:c("config:buildings.terminalArgs",{defaultValue:"Extra ttyd args"})}),e.jsx("input",{type:"text",className:"form-input",value:C,onChange:b=>g(b.target.value),placeholder:"--client-option titleFixed=Terminal"}),e.jsx("div",{className:"form-hint",children:"Additional command-line arguments passed to ttyd"})]})]}),v&&s&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:c("config:buildings.terminalControls",{defaultValue:"Terminal Controls"})}),f&&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:f.url})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"PID"}),e.jsx("span",{className:"runtime-value",children:f.pid})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Port"}),e.jsx("span",{className:"runtime-value",children:f.port})]}),f.tmuxSession&&e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Session"}),e.jsx("span",{className:"runtime-value",children:f.tmuxSession})]})]}),e.jsxs("div",{className:"building-actions",style:{marginTop:"8px"},children:[!i&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>h("start"),children:[e.jsx(F,{name:"play",size:12})," Start"]}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>h("restart"),children:[e.jsx(F,{name:"refresh",size:12})," Restart"]}),e.jsxs("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>h("stop"),children:[e.jsx(F,{name:"stop",size:12})," Stop"]}),(f==null?void 0:f.url)&&e.jsxs(e.Fragment,{children:[a&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>a(f.url),children:[e.jsx(F,{name:"desktop",size:12})," Modal"]}),t&&s&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>t(s.id),children:[e.jsx(F,{name:"arrow-down",size:12})," Below"]})]})]})]})]})]})}function Ca({logs:r,buildingId:p,logsContainerRef:u}){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:()=>D.clearBuildingLogs(p),children:"Clear"})]}),e.jsx("div",{className:"logs-container",ref:u,children:r.map((x,n)=>e.jsx("pre",{className:"log-entry",children:qs(x)},n))})]})}function Da({isOpen:r,onClose:p,buildingId:u,initialPosition:x}){const{t:n}=A(["config","common"]),y=na(),C=la(),g=ia(),v=ra(),s=u?y.get(u):null,h=u?g.get(u)||[]:[],a=!!s,[t,c]=m.useState(""),[i,f]=m.useState("server"),[b,z]=m.useState("server-rack"),[T,B]=m.useState(""),[$,R]=m.useState(""),[H,I]=m.useState(""),[K,O]=m.useState(""),[d,L]=m.useState(""),[q,V]=m.useState(""),[k,_]=m.useState(""),[M,l]=m.useState([]),[S,U]=m.useState(!1),[E,J]=m.useState(""),[W,ee]=m.useState(1),[Z,te]=m.useState(!1),[Ge,ne]=m.useState(""),[Ye,le]=m.useState(""),[Je,ie]=m.useState(""),[We,re]=m.useState(""),[Ze,oe]=m.useState(""),[Vs,ce]=m.useState(!1),[P,de]=m.useState("container"),[me,ue]=m.useState(""),[Xe,pe]=m.useState(""),[he,xe]=m.useState(""),[be,je]=m.useState([]),[ge,ve]=m.useState([]),[Qe,fe]=m.useState(""),[Ne,ke]=m.useState(""),[ye,Ce]=m.useState(""),[es,Se]=m.useState("unless-stopped"),[ss,we]=m.useState("missing"),[Pe,De]=m.useState(""),[Ee,Le]=m.useState(""),[ze,Be]=m.useState(""),[Ae,Te]=m.useState([]),[Gs,Ys]=m.useState(!1),[Re,Ie]=m.useState([]),[as,Oe]=m.useState(void 0),[ts,_e]=m.useState(""),[Me,Fe]=m.useState(""),[ns,$e]=m.useState(!1),[ls,He]=m.useState(""),is=m.useRef(null),Js=m.useRef(null),se=m.useRef(null);m.useEffect(()=>{var o,N,w,G,ds,ms,us,ps,hs,xs,bs,js,gs,vs,fs,Ns,ks,ys,Cs,Ss,ws,Ps,Ds,Es,Ls,zs,Bs,As,Ts,Rs,Is,Os,_s;r&&(s?(c(s.name),f(s.type),z(s.style||"server-rack"),B(s.color||""),R(s.cwd||""),I(((o=s.commands)==null?void 0:o.start)||""),O(((N=s.commands)==null?void 0:N.stop)||""),L(((w=s.commands)==null?void 0:w.restart)||""),V(((G=s.commands)==null?void 0:G.healthCheck)||""),_(((ds=s.commands)==null?void 0:ds.logs)||""),l(s.urls||[]),J(s.folderPath||""),ee(s.scale||1),te(((ms=s.pm2)==null?void 0:ms.enabled)||!1),ne(((us=s.pm2)==null?void 0:us.script)||""),le(((ps=s.pm2)==null?void 0:ps.args)||""),ie(((hs=s.pm2)==null?void 0:hs.interpreter)||""),re(((xs=s.pm2)==null?void 0:xs.interpreterArgs)||""),oe((bs=s.pm2)!=null&&bs.env?Object.entries(s.pm2.env).map(([Y,Ke])=>`${Y}=${Ke}`).join(`
6
+ `):""),de(((js=s.docker)==null?void 0:js.mode)||"container"),ue(((gs=s.docker)==null?void 0:gs.mode)==="existing"&&((vs=s.docker)==null?void 0:vs.containerName)||""),pe(((fs=s.docker)==null?void 0:fs.image)||""),xe(((Ns=s.docker)==null?void 0:Ns.containerName)||""),je(((ks=s.docker)==null?void 0:ks.ports)||[]),ve(((ys=s.docker)==null?void 0:ys.volumes)||[]),fe((Cs=s.docker)!=null&&Cs.env?Object.entries(s.docker.env).map(([Y,Ke])=>`${Y}=${Ke}`).join(`
7
+ `):""),ke(((Ss=s.docker)==null?void 0:Ss.network)||""),Ce(((ws=s.docker)==null?void 0:ws.command)||""),Se(((Ps=s.docker)==null?void 0:Ps.restart)||"unless-stopped"),we(((Ds=s.docker)==null?void 0:Ds.pull)||"missing"),De(((Es=s.docker)==null?void 0:Es.composePath)||""),Le(((Ls=s.docker)==null?void 0:Ls.composeProject)||""),Be(((Bs=(zs=s.docker)==null?void 0:zs.services)==null?void 0:Bs.join(", "))||""),Te(s.subordinateBuildingIds||[]),Ie(((As=s.database)==null?void 0:As.connections)||[]),Oe((Ts=s.database)==null?void 0:Ts.activeConnectionId),_e(((Rs=s.terminal)==null?void 0:Rs.shell)||""),Fe((Is=s.terminal)!=null&&Is.port?String(s.terminal.port):""),$e(((Os=s.terminal)==null?void 0:Os.saveSession)||!1),He(((_s=s.terminal)==null?void 0:_s.args)||"")):(c("New Server"),f("server"),z("server-rack"),B(""),R(oa(ca.LAST_CWD)),I(""),O(""),L(""),V(""),_(""),l([]),J(""),ee(1),te(!1),ne(""),le(""),ie(""),re(""),oe(""),de("container"),ue(""),pe(""),xe(""),je([]),ve([]),fe(""),ke(""),Ce(""),Se("unless-stopped"),we("missing"),De(""),Le(""),Be(""),Te([]),Ie([]),Oe(void 0),_e(""),Fe(""),$e(!1),He("")),setTimeout(()=>{var Y;return(Y=is.current)==null?void 0:Y.focus()},100))},[r,s]),m.useEffect(()=>{se.current&&(se.current.scrollTop=se.current.scrollHeight)},[C]),m.useEffect(()=>{i==="docker"&&P==="existing"&&D.requestDockerContainersList()},[i,P]);const rs=o=>{if(o.trim())return Object.fromEntries(o.trim().split(`
8
+ `).map(N=>N.trim()).filter(N=>N&&N.includes("=")).map(N=>{const w=N.indexOf("=");return[N.slice(0,w),N.slice(w+1)]}))},Ws=o=>{o.preventDefault();const N={name:t,type:i,style:b,color:T||void 0,position:x||(s==null?void 0:s.position)||{x:0,z:0},cwd:$||void 0,folderPath:E||void 0,commands:Z?void 0:{start:H||void 0,stop:K||void 0,restart:d||void 0,healthCheck:q||void 0,logs:k||void 0},pm2:Z?{enabled:!0,script:Ge,args:Ye||void 0,interpreter:Je||void 0,interpreterArgs:We||void 0,env:rs(Ze)}:void 0,docker:i==="docker"?{enabled:!0,mode:P,image:P==="container"?Xe:void 0,containerName:P==="container"&&he?he:P==="existing"&&me?me:void 0,ports:P==="container"&&be.length>0?be:void 0,volumes:P==="container"&&ge.length>0?ge:void 0,env:rs(Qe),network:P==="container"&&Ne?Ne:void 0,command:P==="container"&&ye?ye:void 0,restart:P==="container"?es:void 0,pull:P!=="existing"?ss:void 0,composePath:P==="compose"&&Pe?Pe:void 0,composeProject:P==="compose"&&Ee?Ee:void 0,services:P==="compose"&&ze?ze.split(",").map(w=>w.trim()).filter(w=>w):void 0}:void 0,urls:M.length>0?M:void 0,scale:W!==1?W:void 0,subordinateBuildingIds:i==="boss"&&Ae.length>0?Ae:void 0,database:i==="database"&&Re.length>0?{connections:Re,activeConnectionId:as}:void 0,terminal:i==="terminal"?{enabled:!0,shell:ts||void 0,port:Me?parseInt(Me,10):void 0,saveSession:ns||void 0,args:ls||void 0}:void 0};a&&u?D.updateBuilding(u,N):D.createBuilding(N),p()},Zs=()=>{ce(!0)},Xs=()=>{u&&(D.deleteBuilding(u),ce(!1),p())},ae=o=>{u&&(D.sendBuildingCommand(u,o),o==="logs"&&U(!0))},Qs=()=>{l([...M,{label:"",url:""}])},ea=o=>{l(M.filter((N,w)=>w!==o))},os=(o,N,w)=>{const G=[...M];G[o]={...G[o],[N]:w},l(G)},{handleMouseDown:sa,handleClick:aa}=da(p);if(!r)return null;const cs=u?D.getBuildingLogs(u):[];return e.jsxs("div",{className:"modal-overlay visible",onMouseDown:sa,onClick:aa,children:[e.jsxs("div",{className:"modal building-config-modal",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("span",{children:n(a?"config:buildings.editBuilding":"config:buildings.addBuilding")}),a&&s&&e.jsx("span",{className:"building-status-badge",style:{backgroundColor:qe[s.status]},children:s.status})]}),e.jsxs("form",{onSubmit:Ws,children:[e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("common:labels.name")}),e.jsx("input",{ref:is,type:"text",className:"form-input",value:t,onChange:o=>c(o.target.value),placeholder:n("config:buildings.namePlaceholder"),required:!0})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("common:labels.type")}),e.jsx("div",{className:"building-type-selector",children:Object.keys(Hs).map(o=>e.jsxs("button",{type:"button",className:`building-type-btn ${i===o?"active":""}`,onClick:()=>{f(o),o==="database"&&b==="server-rack"&&z("filing-cabinet"),o==="tests"&&b==="server-rack"&&z("dome"),o==="http"&&b==="server-rack"&&z("satellite")},title:Hs[o].description,children:[e.jsx("span",{className:"building-type-icon",children:e.jsx(F,{name:Us(o),size:16})}),e.jsx("span",{className:"building-type-name",children:o})]},o))})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("config:buildings.style")}),e.jsx("div",{className:"building-style-selector",children:Object.keys(Ue).map(o=>e.jsxs("button",{type:"button",className:`building-style-btn ${b===o?"active":""}`,onClick:()=>z(o),title:Ue[o].description,children:[e.jsx("span",{className:"building-style-preview","data-style":o}),e.jsx("span",{className:"building-style-name",children:Ue[o].label})]},o))})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("common:labels.color")}),e.jsxs("div",{className:"building-color-selector",children:[ma.map(o=>e.jsx("button",{type:"button",className:`building-color-btn ${T===o.value?"active":""}`,onClick:()=>B(o.value),title:ua(o.labelKey),style:o.value?{backgroundColor:o.value}:void 0,children:!o.value&&e.jsx("span",{className:"color-default-icon",children:e.jsx(F,{name:"gear",size:12})})},o.value||"default")),e.jsx("input",{type:"color",className:"building-color-picker",value:T||"#2a2a3a",onChange:o=>B(o.target.value),title:"Custom color"})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("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(W/.1)/Math.log(100)*100,onChange:o=>{const N=parseFloat(o.target.value),w=.1*Math.pow(100,N/100);ee(Math.round(w*100)/100)}}),e.jsxs("span",{className:"size-value",children:[W.toFixed(2),"x"]})]}),e.jsx("div",{className:"size-presets",children:[.5,.75,1,1.25,1.5,2].map(o=>e.jsxs("button",{type:"button",className:`size-preset-btn ${W===o?"active":""}`,onClick:()=>ee(o),children:[o,"x"]},o))})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("config:buildings.directory")}),e.jsx(Q,{value:$,onChange:R,placeholder:"/path/to/project",className:"form-input",directoriesOnly:!0})]}),i==="folder"&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("config:buildings.folderPath")}),e.jsx(Q,{value:E,onChange:J,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"})]}),i==="tests"&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:"Tests Folder"}),e.jsx(Q,{value:E,onChange:J,placeholder:"/path/to/project/src/test",className:"form-input",directoriesOnly:!0}),e.jsx("div",{className:"form-hint",children:"Click this building to browse, search and run the tests of this folder (any folder inside a Maven module works)"})]}),i==="http"&&e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:"Requests Folder"}),e.jsx(Q,{value:E,onChange:J,placeholder:"/path/to/project/http-requests",className:"form-input",directoriesOnly:!0}),e.jsx("div",{className:"form-hint",children:"Click this building to browse and fire the .http request files of this folder (IntelliJ HTTP Client style; http-client.env.json environments supported)"})]}),i==="boss"&&e.jsx(fa,{buildings:y,buildingId:u,subordinateBuildingIds:Ae,setSubordinateBuildingIds:Te,isEditMode:a,showBossLogs:Gs,setShowBossLogs:Ys,currentBossLogs:h,bossLogsContainerRef:Js}),i==="database"&&e.jsx(va,{dbConnections:Re,setDbConnections:Ie,activeDbConnectionId:as,setActiveDbConnectionId:Oe}),i==="server"&&e.jsx(xa,{usePM2:Z,setUsePM2:te}),i==="server"&&e.jsx(ba,{usePM2:Z,pm2Script:Ge,setPm2Script:ne,pm2Args:Ye,setPm2Args:le,pm2Interpreter:Je,setPm2Interpreter:ie,pm2InterpreterArgs:We,setPm2InterpreterArgs:re,pm2Env:Ze,setPm2Env:oe,isEditMode:a,building:s??null,handleCommand:ae}),i==="docker"&&e.jsx(ja,{dockerMode:P,setDockerMode:de,dockerImage:Xe,setDockerImage:pe,dockerContainerName:he,setDockerContainerName:xe,dockerCommand:ye,setDockerCommand:Ce,dockerPorts:be,setDockerPorts:je,dockerVolumes:ge,setDockerVolumes:ve,dockerNetwork:Ne,setDockerNetwork:ke,dockerRestart:es,setDockerRestart:Se,dockerPull:ss,setDockerPull:we,dockerEnv:Qe,setDockerEnv:fe,dockerComposePath:Pe,setDockerComposePath:De,dockerComposeProject:Ee,setDockerComposeProject:Le,dockerComposeServices:ze,setDockerComposeServices:Be,selectedExistingContainer:me,setSelectedExistingContainer:ue,dockerContainersList:v,isEditMode:a,building:s??null,handleCommand:ae}),i==="terminal"&&e.jsx(ya,{terminalShell:ts,setTerminalShell:_e,terminalPort:Me,setTerminalPort:Fe,terminalSaveSession:ns,setTerminalSaveSession:$e,terminalArgs:ls,setTerminalArgs:He,isEditMode:a,building:s??null,handleCommand:ae,onOpenTerminal:()=>{s!=null&&s.id&&window.dispatchEvent(new CustomEvent("tide:open-iframe-modal",{detail:{buildingId:s.id}}))},onOpenBelow:o=>{window.dispatchEvent(new CustomEvent("tide:open-bottom-terminal",{detail:{buildingId:o}}))}}),i==="server"&&!Z&&e.jsx(Na,{startCmd:H,setStartCmd:I,stopCmd:K,setStopCmd:O,restartCmd:d,setRestartCmd:L,healthCheckCmd:q,setHealthCheckCmd:V,logsCmd:k,setLogsCmd:_,isEditMode:a,handleCommand:ae}),e.jsxs("div",{className:"form-section",children:[e.jsxs("label",{className:"form-label",children:[n("config:buildings.links"),e.jsxs("button",{type:"button",className:"btn btn-sm btn-add",onClick:Qs,children:["+ ",n("common:buttons.add")]})]}),M.map((o,N)=>e.jsxs("div",{className:"url-row",children:[e.jsx("input",{type:"text",className:"form-input url-label",value:o.label,onChange:w=>os(N,"label",w.target.value),placeholder:"Label"}),e.jsx("input",{type:"text",className:"form-input url-value",value:o.url,onChange:w=>os(N,"url",w.target.value),placeholder:"https://..."}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>ea(N),children:"x"})]},N))]}),a&&S&&cs.length>0&&e.jsx(Ca,{logs:cs,buildingId:u,logsContainerRef:se})]}),e.jsxs("div",{className:"modal-footer",children:[a&&e.jsx("button",{type:"button",className:"btn btn-danger",onClick:Zs,children:n("common:buttons.delete")}),e.jsx("div",{className:"footer-spacer"}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:p,children:n("common:buttons.cancel")}),e.jsx("button",{type:"submit",className:"btn btn-primary",children:n(a?"common:buttons.save":"common:buttons.create")})]})]})]}),Vs&&s&&e.jsx(ha,{buildingName:s.name,onClose:()=>ce(!1),onConfirm:Xs})]})}export{Da as BuildingConfigModal};
@@ -0,0 +1,2 @@
1
+ import{r as s,aP as Aa,aQ as ea,K as ma,aR as pa,j as e,aS as fa,aT as Ea,u as Kt,aU as Ma,aV as Ia,aW as Ta,aX as La,aY as Pa,an as $a,ae as Ra,av as ha,m as ta,S as M,w as aa,aZ as Yt,a_ as na,a$ as Mt,b0 as _e,b1 as Da,s as g,_ as ga,f as xa,b2 as za,b3 as sa,b4 as ia,I as d,b5 as Oa,ay as Ba,b6 as Fa,n as ba,b7 as _a,b8 as wa,b9 as va,ba as Wa,bb as Ha,bc as Ua,ad as Ga,bd as Va,be as Xa,bf as qa,aB as Ya,aC as Ka,aD as Za,bg as Ja,bh as Qa,bi as la,X as en,R as tn,E as ra,bj as an,bk as nn,bl as sn,bm as ln,bn as rn,bo as on,bp as cn,bq as dn,br as un,bs as mn,x as pn,bt as fn,bu as hn,bv as gn,bw as xn,bx as it,by as bn,bz as _n,bA as wn,bB as vn,bC as gt,bD as jn,bE as Cn,bF as kn,bG as Nn,p as yn,q as oa,o as Sn}from"./main-B9Esx3nK.js";import{g as An}from"./area-logos-viFj5Uls.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-3OKhI9bz.js";function En(c){const r=s.useRef(c);r.current=c,s.useEffect(()=>{if(!Aa())return;let p=null,b=!1;return ea.addListener("backButton",()=>{r.current()==="exit"&&ea.exitApp()}).then(N=>{b?N.remove():p=N}),()=>{b=!0,p&&(p.remove(),p=null)}},[])}async function Mn(c){const r=ma(),p=await fetch(`${pa()}/api/agents/${c}/terminal`,{method:"POST",headers:{Authorization:`Bearer ${r}`}});if(!p.ok){const b=await p.json().catch(()=>({}));throw new Error((b==null?void 0:b.error)||`Failed to start terminal (${p.status})`)}return p.json()}async function In(c){const r=ma();await fetch(`${pa()}/api/agents/${c}/terminal`,{method:"DELETE",headers:{Authorization:`Bearer ${r}`}})}const xt=new Map;function Tn({agentId:c}){const[r,p]=s.useState(null),[b,N]=s.useState(null);return s.useEffect(()=>{let I=!1;const A=xt.get(c);return A&&(clearTimeout(A),xt.delete(c)),p(null),N(null),Mn(c).then(y=>{I||p(y.url)}).catch(y=>{I||N(y instanceof Error?y.message:"Failed to start terminal")}),()=>{I=!0;const y=xt.get(c);y&&clearTimeout(y),xt.set(c,setTimeout(()=>{xt.delete(c),In(c)},2500))}},[c]),b?e.jsx("div",{className:"flat-classic-terminal flat-classic-terminal--message",children:e.jsx("span",{children:b})}):r?e.jsx("div",{className:"flat-classic-terminal",children:e.jsx(fa,{terminalUrl:r,visible:!0})}):e.jsx("div",{className:"flat-classic-terminal flat-classic-terminal--message",children:e.jsx("span",{children:"Attaching to interactive session…"})})}const Gt=new Map,Ln=6e4;function ca(c){return Number.isFinite(c)?Math.abs(c)>=1e3?c.toLocaleString(void 0,{maximumFractionDigits:0}):c.toLocaleString(void 0,{maximumFractionDigits:2}):String(c)}function Pn(c,r){var N,I,A;const p=[];if(!c.rateLimits)return p;if(c.provider==="claude"){const y=c,K=[{key:"fiveHour",label:r("terminal:usage.currentSession"),window:y.rateLimits.fiveHour},{key:"sevenDay",label:r("terminal:usage.currentWeekAll"),window:y.rateLimits.sevenDay},{key:"sevenDayOpus",label:r("terminal:usage.currentWeekOpus"),window:y.rateLimits.sevenDayOpus},{key:"sevenDayFable",label:r("terminal:usage.currentWeekFable"),window:y.rateLimits.sevenDayFable}];for(const v of K)(v.window||v.key==="sevenDayFable")&&p.push(v);return p}const b=c;return(N=b.rateLimits)!=null&&N.weekly&&p.push({key:"weekly",label:r("terminal:usage.weeklyLimit"),window:b.rateLimits.weekly}),(I=b.rateLimits)!=null&&I.monthly&&p.push({key:"monthly",label:r("terminal:usage.monthlyLimit"),window:b.rateLimits.monthly}),(A=b.rateLimits)!=null&&A.onDemand&&p.push({key:"onDemand",label:r("terminal:usage.onDemandLimit"),window:b.rateLimits.onDemand}),p}function $n({agentId:c,contextSummary:r}){const{t:p}=Kt(["terminal","common"]),[b,N]=s.useState(()=>{var R;return((R=Gt.get(c))==null?void 0:R.snapshot)??null}),[I,A]=s.useState(!1),[y,K]=s.useState(null),v=s.useRef(0);s.useEffect(()=>{const R=Gt.get(c);if(R&&Date.now()-R.fetchedAt<Ln){N(R.snapshot);return}const re=++v.current;A(!0),K(null),Ma(c).then(T=>{re===v.current&&(Gt.set(c,{snapshot:T,fetchedAt:Date.now()}),N(T),A(!1))}).catch(T=>{re===v.current&&(K(T.message||"Failed to load plan limits"),A(!1))})},[c]);const H=b?Pn(b,p):[];return e.jsxs("div",{className:"plan-limits-tooltip",children:[r&&e.jsx("div",{className:"plan-limits-tooltip__context",children:r}),e.jsx("div",{className:"plan-limits-tooltip__title",children:p("terminal:usage.limits")}),I&&!b&&e.jsxs("div",{className:"plan-limits-tooltip__muted",children:[p("common:status.loading"),"…"]}),!I&&y&&!b&&e.jsx("div",{className:"plan-limits-tooltip__muted",children:p("terminal:usage.limitsError",{message:y})}),H.length>0?e.jsx("div",{className:"plan-limits-tooltip__gauges",children:H.map(({key:R,label:re,window:T})=>{const Ee=T?Math.max(0,Math.min(100,T.utilization)):0,oe=Ta(Ee),ce=T!=null&&typeof T.used=="number"&&typeof T.limit=="number"&&Number.isFinite(T.used)&&Number.isFinite(T.limit);return e.jsxs("div",{className:"plan-limits-tooltip__gauge",children:[e.jsxs("div",{className:"plan-limits-tooltip__gauge-head",children:[e.jsx("span",{className:"plan-limits-tooltip__gauge-label",children:re}),e.jsx("span",{className:"plan-limits-tooltip__gauge-percent",style:{color:oe},children:p("terminal:usage.percentUsed",{percent:Math.round(Ee)})})]}),e.jsx("div",{className:"plan-limits-tooltip__bar",children:e.jsx("div",{className:"plan-limits-tooltip__bar-fill",style:{width:`${Ee}%`,background:oe}})}),e.jsxs("div",{className:"plan-limits-tooltip__reset",children:[T&&p("terminal:usage.resets",{time:Ia(T.resetsAt)}),ce&&e.jsx("span",{style:{marginLeft:8},children:p("terminal:usage.creditsUsed",{used:ca(T.used),limit:ca(T.limit)})})]})]},R)})}):b&&!I&&e.jsx("div",{className:"plan-limits-tooltip__muted",children:b.rateLimitsError?p("terminal:usage.limitsError",{message:b.rateLimitsError}):b.cliHint})]})}function Rn({agentId:c,disabled:r,contextSummary:p,children:b}){return e.jsx(Ea,{position:"top",maxWidth:320,disabled:r,className:"plan-limits-tooltip-wrapper",triggerStyle:{display:"inline-flex",alignItems:"center"},content:e.jsx($n,{agentId:c,contextSummary:p}),children:b})}const Dn=s.memo(function({className:r=""}){const{t:p}=Kt(["common"]),[b,N]=La(),I=s.useRef(null),[A,y]=s.useState(null);s.useLayoutEffect(()=>{const v=I.current;if(!v)return;const H=v.querySelector(".view-mode-toggle__btn--active");H&&y({left:H.offsetLeft,width:H.offsetWidth})},[b]);const K=s.useCallback(v=>{if(v!==b){if(typeof window<"u"&&window.dispatchEvent(new CustomEvent("tide:viewmode-switch-pressed",{detail:{mode:v}})),v==="3d"){requestAnimationFrame(()=>N(v));return}N(v)}},[b,N]);return e.jsxs("div",{className:`view-mode-toggle ${r}`,ref:I,children:[A&&e.jsx("div",{className:"view-mode-toggle__indicator",style:{left:A.left,width:A.width}}),Pa.map(v=>e.jsxs("button",{className:`view-mode-toggle__btn ${b===v?"view-mode-toggle__btn--active":""}`,onClick:()=>K(v),title:p(`common:viewMode.descriptions.${v}`),children:[e.jsxs("span",{className:"view-mode-toggle__icon",children:[v==="2d"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]}),v==="3d"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),e.jsx("path",{d:"M2 17l10 5 10-5"}),e.jsx("path",{d:"M2 12l10 5 10-5"})]}),v==="flat"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1"})]}),v==="dashboard"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"9",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"5",rx:"1"}),e.jsx("rect",{x:"14",y:"12",width:"7",height:"9",rx:"1"}),e.jsx("rect",{x:"3",y:"16",width:"7",height:"5",rx:"1"})]})]}),e.jsx("span",{className:"view-mode-toggle__label",children:p(`common:viewMode.labels.${v}`)})]},v))]})}),It=3,Tt=280,da=320,Vt=240,ua=64,zn=["simple","chat","advanced"],On={simple:"Simple",chat:"Chat",advanced:"Advanced"},Bn={simple:"○",chat:"◐",advanced:"◉"},Fn={simple:"Simple view — clean messages only",chat:"Chat view — assistant replies (no tool calls)",advanced:"Advanced view — everything including tools"},Xt="flat-clear-context",ja="tide:flat-embedded-panels";function Ca(){try{const c=localStorage.getItem(ja),r=c?JSON.parse(c):{};return r&&typeof r=="object"?r:{}}catch{return{}}}function qt(c,r){try{const p=Ca();r?p[c]=r:delete p[c],localStorage.setItem(ja,JSON.stringify(p))}catch{}}function Wn(c){const r=c.split("/").filter(Boolean);return r.length===0?c:r.slice(-2).join("/")}function Hn(c){if(c.provider==="codex"){const I=c.codexModel||"gpt-5.6-luna",A=yn[I];return{model:(A==null?void 0:A.label)||I}}if(c.provider==="opencode")return{model:c.opencodeModel||"opencode"};if(c.provider==="grok"){const I=c.grokModel||"grok-4.5",A=c.effort,y=A?oa[A]:void 0;return{model:I,effort:y==null?void 0:y.label}}const r=c.model||"sonnet",p=Sn[r],b=c.effort,N=b?oa[b]:void 0;return{model:(p==null?void 0:p.label)||r,effort:N==null?void 0:N.label}}function Un(c,r){if(r.type==="rectangle"&&r.width&&r.height){const p=r.width/2,b=r.height/2;return c.x>=r.center.x-p&&c.x<=r.center.x+p&&c.z>=r.center.z-b&&c.z<=r.center.z+b}if(r.type==="circle"&&r.radius){const p=c.x-r.center.x,b=c.z-r.center.z;return p*p+b*b<=r.radius*r.radius}return!1}const Gn=tn.memo(function({agentId:r,terminalViewMode:p,onTerminalViewModeChange:b,inspectorOpen:N,onToggleInspector:I,onShowTaskBoard:A,onImageClick:y,onFileClick:K,onBashClick:v,onViewMarkdown:H,onRequestClearSubordinates:R,keyboard:re,canNavigateBack:T,canNavigateForward:Ee,onNavigateBack:oe,onNavigateForward:ce,agentInfoOpen:Oe,onToggleAgentInfo:bt,onHeaderContextMenu:we,onBuildingContextMenu:ve}){var Nt,yt;const u=ra(r),D=xa(),Me=an(),Ie=s.useRef(null),Ze=s.useRef(null),{displayedAgentId:Te,fadingOut:Lt}=nn(r),_t=ra(Te),Je=!!Me.interactiveMode&&((u==null?void 0:u.provider)??"claude")==="claude"&&!!(u!=null&&u.sessionId),[de,Qe]=s.useState(!1),[Be,ue]=s.useState(!1),$=s.useCallback(()=>ue(!1),[]);ha("flat-chat-actions",Be,$),s.useEffect(()=>{const a=()=>ue(o=>!o);return window.addEventListener("tide:toggle-chat-actions",a),()=>window.removeEventListener("tide:toggle-chat-actions",a)},[]),s.useEffect(()=>{Qe(!1),ue(!1)},[r]),s.useEffect(()=>{!Je&&de&&Qe(!1)},[Je,de]),s.useEffect(()=>{const a=Ze.current;if(!a)return;const o=m=>{m.button===3?(m.preventDefault(),m.stopPropagation(),oe()):m.button===4&&(m.preventDefault(),m.stopPropagation(),ce())},i=m=>{(m.button===3||m.button===4)&&m.preventDefault()};return a.addEventListener("mouseup",o),a.addEventListener("mousedown",i),()=>{a.removeEventListener("mouseup",o),a.removeEventListener("mousedown",i)}},[oe,ce]),s.useEffect(()=>{const a=Ze.current;if(!a)return;let o=0,i=0,m=0;const X=250,Q=600,L=80,st=1.5,ae=ne=>{let U=ne instanceof HTMLElement?ne:null;for(;U&&U!==a;){const St=window.getComputedStyle(U).overflowX;if((St==="auto"||St==="scroll")&&U.scrollWidth>U.clientWidth)return!0;U=U.parentElement}return!1},Ye=ne=>{const U=Date.now();if(U<m){ne.preventDefault();return}if(Math.abs(ne.deltaX)<=Math.abs(ne.deltaY)*st){o=0;return}if(ae(ne.target)){o=0;return}U-i>X&&(o=0),i=U,o+=ne.deltaX,o<=-L?(o=0,m=U+Q,ne.preventDefault(),oe()):o>=L&&(o=0,m=U+Q,ne.preventDefault(),ce())};return a.addEventListener("wheel",Ye,{passive:!1}),()=>a.removeEventListener("wheel",Ye)},[oe,ce]);const me=ga(),lt=s.useMemo(()=>{if(!u)return null;const a=new Set,o=[];for(const i of me.values())i.archived||i.directories.length===0||i.assignedAgentIds.includes(r)&&(a.add(i.id),o.push(i));for(const i of me.values())i.archived||i.directories.length===0||a.has(i.id)||Un({x:u.position.x,z:u.position.z},i)&&(a.add(i.id),o.push(i));return o.length===0?null:o.flatMap(i=>i.directories.filter(m=>m&&m.trim().length>0).map(m=>({areaId:i.id,areaName:i.name,dir:m})))},[u,r,me]),{branches:wt,fetchRemote:Fe,fetchingDirs:Le}=sn(lt),pe=s.useMemo(()=>{var i;const a=g.getAreaForAgent(r);if(!a)return[];const o=[];for(const m of D.values())m.type==="terminal"&&g.isPositionInArea(m.position,a)&&o.push({id:m.id,name:m.name,hasUrl:!!((i=m.terminalStatus)!=null&&i.url)});return o},[r,D]),je=s.useMemo(()=>{var i;const a=g.getAreaForAgent(r);if(!a)return[];const o=[];for(const m of D.values())m.type==="server"&&((i=m.pm2)!=null&&i.enabled)&&g.isPositionInArea(m.position,a)&&o.push({id:m.id,name:m.name});return o},[r,D]),Z=s.useMemo(()=>{const a=g.getAreaForAgent(r);if(!a)return[];const o=[];for(const i of D.values())i.type==="database"&&i.database&&g.isPositionInArea(i.position,a)&&o.push({id:i.id,name:i.name});return o},[r,D]),We=ln(),se=s.useMemo(()=>{const a=g.getAreaForAgent(r);if(!a)return[];const o=[];for(const i of D.values())if(i.type==="tests"&&g.isPositionInArea(i.position,a)){const m=!!i.folderPath&&We.some(X=>rn(X,i.folderPath));o.push({id:i.id,name:i.name,working:m})}return o},[r,D,We]),ie=s.useMemo(()=>{const a=g.getAreaForAgent(r);if(!a)return[];const o=[];for(const i of D.values())i.type==="http"&&g.isPositionInArea(i.position,a)&&o.push({id:i.id,name:i.name});return o},[r,D]),[,Pt]=s.useReducer(a=>a+1,0),Ce=((Nt=Ie.current)==null?void 0:Nt.search.searchMode)??!1,rt=s.useCallback(()=>{var a;(a=Ie.current)==null||a.search.toggleSearch(),Pt()},[]),Pe=on(),$e=Pe.isPending(Xt),[j,te]=s.useState(null),J=j?D.get(j.buildingId):null,[He,Re]=s.useState(""),[Ue,$t]=s.useState(()=>cn()),z=s.useMemo(()=>{var a;return((a=g.getAreaForAgent(r))==null?void 0:a.id)??null},[r,D]),Ge=s.useCallback((a,o)=>{Re(""),te(i=>{const m=(i==null?void 0:i.buildingId)===o?null:{type:a,buildingId:o};return z&&qt(z,m),m})},[z]),ke=s.useCallback(()=>{Re(""),te(null),z&&qt(z,null)},[z]);s.useEffect(()=>{if((j==null?void 0:j.type)!=="pm2-logs")return;const a=j.buildingId;return g.startLogStreaming(a,200),()=>g.stopLogStreaming(a)},[j]);const{height:Rt,onResizeStart:Dt}=dn(),{sidePanelWidth:zt,handleSidePanelResizeStart:ot}=un(),[w,vt]=s.useState(()=>Yt(M.GIT_PANEL_OPEN,!1)),[De,fe]=s.useState(()=>Yt(M.BUILDINGS_PANEL_OPEN,!1)),[O,Ve]=s.useState(!1),ct=s.useCallback(()=>{Ve(a=>{const o=!a;return o&&mn.setEnabled(!0),o})},[]),Ot=s.useCallback(()=>Ve(!1),[]),jt=s.useCallback(()=>{vt(a=>{const o=!a;return _e(M.GIT_PANEL_OPEN,o),o})},[]),Ct=s.useCallback(()=>{fe(a=>{const o=!a;return _e(M.BUILDINGS_PANEL_OPEN,o),o})},[]),Bt=s.useCallback(()=>{vt(!1),_e(M.GIT_PANEL_OPEN,!1)},[]),dt=s.useCallback(()=>{fe(!1),_e(M.BUILDINGS_PANEL_OPEN,!1)},[]),Xe=pn(),he=s.useMemo(()=>({terminal:pe,"pm2-logs":je,database:Z,tests:se,http:ie}),[pe,je,Z,se,ie]);s.useEffect(()=>{if(!j)return;he[j.type].some(o=>o.id===j.buildingId)||(Re(""),te(null))},[j,he]);const Ne=s.useRef(void 0);s.useEffect(()=>{var o;if(Ne.current===z)return;Ne.current=z;const a=z?Ca()[z]:void 0;Re(""),a&&((o=he[a.type])!=null&&o.some(i=>i.id===a.buildingId))?te(a):te(null)},[z,he]),s.useEffect(()=>{const a=o=>{var X;const i=o.detail;if(!(i!=null&&i.buildingId)||!(i!=null&&i.type)||!((X=he[i.type])!=null&&X.some(Q=>Q.id===i.buildingId)))return;i.handled=!0,Re("");const m={type:i.type,buildingId:i.buildingId};te(m),z&&qt(z,m)};return window.addEventListener("tide:dock-building-flat",a),()=>window.removeEventListener("tide:dock-building-flat",a)},[he,z]);const[qe,B]=s.useState(!1),ge=s.useRef(null);if(s.useEffect(()=>{if(!qe)return;const a=o=>{ge.current&&!ge.current.contains(o.target)&&B(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[qe]),!u)return e.jsx("div",{className:"flat-chat flat-chat--empty",children:e.jsxs("div",{className:"flat-chat__placeholder",children:[e.jsx("span",{className:"flat-chat__placeholder-icon",children:"💬"}),e.jsx("span",{className:"flat-chat__placeholder-text",children:"Select an agent to start chatting"})]})});const ye=u.contextStats,ut=!!ye,et=ye?ye.totalTokens:u.contextUsed||0,mt=ye?ye.contextWindow:u.contextLimit||(u.provider==="grok"?5e5:2e5),Ft=ye?ye.usedPercent:Math.round(et/mt*100),ze=Math.max(0,Math.min(100,Ft)),kt=Math.round(ze*10)/10,xe=Math.round((100-ze)*10)/10,tt=ze>=80?"#ff4a4a":ze>=60?"#ff9e4a":ze>=40?"#ffd700":"#4aff9e",at=(et/1e3).toFixed(1),pt=(mt/1e3).toFixed(1),be=u.cwd,ft=be?Wn(be):null,Se=((yt=u.subordinateIds)==null?void 0:yt.length)||0,nt=Se>0;return e.jsxs("div",{ref:Ze,className:`flat-terminal-wrapper ${w||De||O?"flat-terminal-wrapper--with-side-panel":""} ${Lt?"pane-fading-out":""}`,style:{"--guake-side-panel-width":`min(${zt}px, 70%)`},children:[e.jsxs("div",{className:"flat-terminal-wrapper__header",children:[e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__header-main ${Oe?"flat-terminal-wrapper__header-main--active":""}`,onClick:bt,onContextMenu:a=>{a.preventDefault(),a.stopPropagation(),we({x:a.clientX,y:a.clientY})},title:Oe?"Hide agent info":"Show agent info","aria-pressed":Oe,children:[e.jsx("span",{className:`flat-terminal-wrapper__header-avatar${u.status==="working"?" is-working":""}`,children:e.jsx(ba,{agent:u,size:28})}),e.jsxs("span",{className:"flat-terminal-wrapper__header-info",children:[e.jsx("span",{className:"flat-terminal-wrapper__header-name",children:u.name}),e.jsx("span",{className:"flat-terminal-wrapper__header-status",style:{color:va(u.status)},title:u.status==="error"&&u.lastError?u.lastError:void 0,children:u.status})]}),u.taskLabel&&e.jsxs("span",{className:"flat-terminal-wrapper__header-task",title:u.taskLabel,children:["📋 ",u.taskLabel]}),e.jsxs("span",{className:"flat-terminal-wrapper__header-model",children:[e.jsx("img",{src:wa(u.provider,"/"),alt:u.provider,className:"flat-terminal-wrapper__header-provider-icon",title:_a(u.provider)}),(()=>{const{model:a,effort:o}=Hn(u);return e.jsxs("span",{className:"flat-terminal-wrapper__header-model-chip",title:o?`Model: ${a} · Effort: ${o}`:`Model: ${a}`,children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-name",children:a}),o&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-sep","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"flat-terminal-wrapper__header-model-effort",children:o})]})]})})()]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__header-meta",children:[e.jsxs("div",{className:"flat-terminal-wrapper__view-mode",role:"group","aria-label":"Message view mode",children:[zn.map(a=>e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${!de&&p===a?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>{Qe(!1),b(a)},title:Fn[a],"aria-pressed":!de&&p===a,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:Bn[a]}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:On[a]})]},a)),Je&&e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${de?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>Qe(a=>!a),title:"Classic TUI — attach to the live interactive claude session in a terminal","aria-pressed":de,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:e.jsx(d,{name:"terminal",size:13})}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:"Classic TUI"})]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__actions",role:"group","aria-label":"Terminal actions",children:[e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:oe,disabled:!T,title:"Back to previous agent","aria-label":"Back to previous agent",children:e.jsx(d,{name:"arrow-left",size:14})}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:ce,disabled:!Ee,title:"Forward to next agent","aria-label":"Forward to next agent",children:e.jsx(d,{name:"arrow-right",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${Ce?"flat-terminal-wrapper__action-btn--active":""}`,onClick:rt,title:Ce?"Close search":"Search messages","aria-pressed":Ce,children:e.jsx(d,{name:Ce?"cross":"search",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn flat-terminal-wrapper__action-btn--danger ${$e?"flat-terminal-wrapper__action-btn--confirm":""}`,onClick:()=>Pe.handleClick(Xt,()=>{var a;g.clearContext(r),(a=Ie.current)==null||a.historyLoader.clearHistory()}),title:$e?"Click again to confirm clear context":"Clear context",children:e.jsx(d,{name:$e?"question":"clear",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${w?"flat-terminal-wrapper__action-btn--active":""}`,onClick:jt,title:w?"Hide git panel":"Show git changes","aria-pressed":w,children:e.jsx(d,{name:"git-branch",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${De?"flat-terminal-wrapper__action-btn--active":""}`,onClick:Ct,title:De?"Hide buildings panel":"Show area buildings","aria-pressed":De,children:e.jsx(d,{name:"buildings",size:14})}),e.jsxs("div",{className:"flat-terminal-wrapper__more",ref:ge,children:[e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${qe?"flat-terminal-wrapper__action-btn--active":""}`,onClick:()=>B(a=>!a),title:"More actions","aria-expanded":qe,children:"⋮"}),qe&&e.jsxs("div",{className:"flat-terminal-wrapper__more-menu",role:"menu",children:[e.jsxs("button",{type:"button",role:"menuitem",className:`flat-terminal-wrapper__more-item ${O?"flat-terminal-wrapper__more-item--active":""}`,onClick:()=>{ct(),B(!1)},title:O?"Hide Debug Panel":"Show Debug Panel",children:[e.jsx(d,{name:"bug",size:14}),e.jsx("span",{children:O?"Hide Debug Panel":"Show Debug Panel"})]}),e.jsx("div",{className:"flat-terminal-wrapper__more-divider"}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item",onClick:()=>{g.collapseContext(r),B(!1)},disabled:u.status!=="idle",title:u.status!=="idle"?"Agent must be idle to collapse context":"Collapse context",children:[e.jsx(d,{name:"package",size:14}),e.jsx("span",{children:"Collapse context"})]}),nt&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{R(r,Se),B(!1)},children:[e.jsx(d,{name:"crown",size:14}),e.jsxs("span",{children:["Clear ",Se," subordinate",Se===1?"":"s"]})]}),e.jsx("div",{className:"flat-terminal-wrapper__more-divider"}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{g.killAgent(r),B(!1)},children:[e.jsx(d,{name:"cross",size:14}),e.jsx("span",{children:"Remove agent"})]})]})]})]}),e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__inspector-toggle ${N?"flat-terminal-wrapper__inspector-toggle--active":""}`,onClick:I,title:N?"Hide inspector panel":"Show inspector panel","aria-label":N?"Hide inspector panel":"Show inspector panel","aria-pressed":N,children:[e.jsx("span",{className:"flat-terminal-wrapper__inspector-icon","aria-hidden":"true",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"}),e.jsx("line",{x1:"10",y1:"2.5",x2:"10",y2:"13.5"})]})}),e.jsx("span",{className:"flat-terminal-wrapper__inspector-label",children:"Inspector"})]}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__close",onClick:()=>g.deselectAll(),title:"Close chat","aria-label":"Close chat",children:e.jsx(d,{name:"cross",size:14})})]})]}),Be&&e.jsxs("div",{className:"flat-chat-actions-sheet-root",role:"presentation",children:[e.jsx("div",{className:"flat-chat-actions-sheet__backdrop",onClick:$}),e.jsxs("div",{className:"flat-chat-actions-sheet",role:"menu","aria-label":"Chat actions",children:[e.jsx("div",{className:"flat-chat-actions-sheet__grabber","aria-hidden":"true"}),e.jsxs("div",{className:"flat-chat-actions-sheet__title-row",children:[e.jsx("span",{className:"flat-chat-actions-sheet__title",children:u.name}),e.jsx("button",{type:"button",className:"flat-chat-actions-sheet__done",onClick:$,children:"Done"})]}),e.jsxs("div",{className:"flat-chat-actions-sheet__grid",children:[e.jsxs("button",{type:"button",role:"menuitem",className:`flat-chat-actions-sheet__item ${Ce?"is-active":""}`,onClick:()=>{rt(),$()},children:[e.jsx(d,{name:Ce?"cross":"search",size:20}),e.jsx("span",{children:Ce?"Close search":"Search"})]}),e.jsxs("button",{type:"button",role:"menuitem",className:`flat-chat-actions-sheet__item ${w?"is-active":""}`,onClick:()=>{jt(),$()},children:[e.jsx(d,{name:"git-branch",size:20}),e.jsx("span",{children:"Git changes"})]}),e.jsxs("button",{type:"button",role:"menuitem",className:`flat-chat-actions-sheet__item ${De?"is-active":""}`,onClick:()=>{Ct(),$()},children:[e.jsx(d,{name:"buildings",size:20}),e.jsx("span",{children:"Buildings"})]}),e.jsxs("button",{type:"button",role:"menuitem",className:`flat-chat-actions-sheet__item ${O?"is-active":""}`,onClick:()=>{ct(),$()},children:[e.jsx(d,{name:"bug",size:20}),e.jsx("span",{children:"Debug"})]})]}),e.jsxs("div",{className:"flat-chat-actions-sheet__list",children:[e.jsxs("button",{type:"button",role:"menuitem",className:`flat-chat-actions-sheet__row flat-chat-actions-sheet__row--danger ${$e?"is-armed":""}`,onClick:()=>Pe.handleClick(Xt,()=>{var a;g.clearContext(r),(a=Ie.current)==null||a.historyLoader.clearHistory(),$()}),children:[e.jsx(d,{name:$e?"question":"clear",size:18}),e.jsx("span",{children:$e?"Tap again to confirm clear":"Clear context"})]}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-chat-actions-sheet__row",disabled:u.status!=="idle",onClick:()=>{g.collapseContext(r),$()},children:[e.jsx(d,{name:"package",size:18}),e.jsx("span",{children:"Collapse context"})]}),nt&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-chat-actions-sheet__row flat-chat-actions-sheet__row--danger",onClick:()=>{R(r,Se),$()},children:[e.jsx(d,{name:"crown",size:18}),e.jsxs("span",{children:["Clear ",Se," subordinate",Se===1?"":"s"]})]}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-chat-actions-sheet__row flat-chat-actions-sheet__row--danger",onClick:()=>{g.killAgent(r),$()},children:[e.jsx(d,{name:"cross",size:18}),e.jsx("span",{children:"Remove agent"})]})]})]})]}),e.jsx(fn,{agent:u,onClick:A}),de&&Je?e.jsx(Tn,{agentId:r}):Te&&_t?e.jsx(hn,{ref:Ie,agentId:Te,agent:_t,viewMode:p,isOpen:!0,onImageClick:y,onFileClick:K,onBashClick:v,onViewMarkdown:H,keyboard:re,hasModalOpen:!1},Te):null,j&&J&&(()=>{var X,Q;const a=j.type,o={terminal:"terminal","pm2-logs":"scroll",database:"hard-drives",tests:"flask",http:"globe"},i=a==="terminal"&&!((X=J.terminalStatus)!=null&&X.url),m=!i;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:Dt,role:"separator","aria-orientation":"horizontal","aria-label":"Resize embedded panel"}),e.jsxs("div",{className:"flat-bottom-panel",role:"region","aria-label":`${J.name} panel`,style:{height:Rt},children:[e.jsxs("div",{className:"flat-bottom-panel__header",children:[e.jsxs("span",{className:"flat-bottom-panel__title",children:[e.jsx(d,{name:o[a],size:12}),e.jsx("span",{children:J.name}),i&&e.jsx("span",{className:"flat-bottom-panel__muted",children:"(starting...)"})]}),e.jsxs("span",{className:"flat-bottom-panel__header-actions",children:[a==="pm2-logs"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:"guake-bottom-terminal-filter",value:He,onChange:L=>Re(L.target.value),placeholder:"Filter logs","aria-label":`Filter logs for ${J.name}`,spellCheck:!1}),e.jsx("select",{className:"guake-bottom-terminal-retention",value:Ue===null?"unlimited":String(Ue),onChange:L=>{const st=L.target.value==="unlimited"?null:Number(L.target.value);$t(st),xn(st)},"aria-label":`Max log retention for ${J.name}`,children:gn.map(L=>e.jsx("option",{value:L===null?"unlimited":String(L),children:L===null?"Unlimited":`${L.toLocaleString()} lines`},L===null?"unlimited":L))}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>g.clearStreamingLogs(j.buildingId),title:"Clear logs",children:e.jsx(d,{name:"trash",size:12})}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>g.sendBuildingCommand(j.buildingId,"restart"),title:"Restart",children:e.jsx(d,{name:"restart",size:12})})]}),m&&e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>{ke(),it(j.buildingId)},title:"Maximize — open as modal","aria-label":"Open as modal",children:e.jsx(d,{name:"fullscreen",size:12})}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:ke,title:"Close panel","aria-label":"Close panel",children:e.jsx(d,{name:"cross",size:12})})]})]}),e.jsx("div",{className:"flat-bottom-panel__body",children:a==="terminal"?(Q=J.terminalStatus)!=null&&Q.url?e.jsx(fa,{terminalUrl:J.terminalStatus.url,visible:!0}):e.jsx("div",{className:"flat-bottom-panel__placeholder",children:"Starting terminal..."}):a==="pm2-logs"?e.jsx(bn,{buildingId:j.buildingId,filterText:He,maxRetention:Ue}):a==="database"?e.jsx(_n,{building:J}):a==="tests"?e.jsx("div",{className:"tests-panel-host",children:e.jsx(wn,{building:J,autoFocusSearch:!1})}):e.jsx("div",{className:"http-requests-panel-host",children:e.jsx(vn,{building:J,autoFocusSearch:!1})})})]})]})})(),e.jsxs("div",{className:"flat-terminal-wrapper__statusbar",role:"contentinfo",children:[u.isDetached&&e.jsxs("span",{className:"flat-terminal-wrapper__detached",title:"Reattaching session...",children:[e.jsx(d,{name:"refresh",size:12}),e.jsx("span",{children:"Reattaching"})]}),be&&ft&&e.jsxs("span",{className:"flat-terminal-wrapper__cwd",title:`Open in file explorer: ${be}`,"aria-label":`Open ${be} in file explorer`,role:"button",tabIndex:0,onClick:()=>g.openFileExplorer(be),onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),g.openFileExplorer(be))},children:[e.jsx("span",{className:"flat-terminal-wrapper__cwd-icon",children:e.jsx(d,{name:"folder",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__cwd-text",children:ft})]}),lt&&lt.map(({areaId:a,areaName:o,dir:i})=>{const m=wt.get(i),X=Le.has(i),Q=i.split("/").filter(Boolean).pop()||i;return e.jsxs("span",{className:"flat-terminal-wrapper__area-dir",title:`${o}: ${i}${m?` (${m.branch}${m.ahead?` ↑${m.ahead}`:""}${m.behind?` ↓${m.behind}`:""})`:""}`,onClick:()=>g.openFileExplorerForAreaFolder(a,i),children:[e.jsx(d,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-terminal-wrapper__area-dir-name",children:Q}),m&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flat-terminal-wrapper__area-dir-branch",children:[e.jsx(d,{name:"git-branch",size:10})," ",m.branch]}),m.ahead>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-ahead",title:`${m.ahead} ahead`,children:[e.jsx(d,{name:"arrow-up",size:9}),m.ahead]}),m.behind>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-behind",title:`${m.behind} behind`,children:[e.jsx(d,{name:"arrow-down",size:9}),m.behind]}),e.jsx("span",{className:`flat-terminal-wrapper__area-fetch ${X?"flat-terminal-wrapper__area-fetch--fetching":""}`,title:"Git fetch",onClick:L=>{L.stopPropagation(),Fe(i)},children:e.jsx(d,{name:X?"hourglass":"download",size:12})})]})]},`${a}:${i}`)}),e.jsx(Rn,{agentId:r,disabled:((u==null?void 0:u.provider)??"claude")!=="claude"&&((u==null?void 0:u.provider)??"claude")!=="grok",contextSummary:ut?`Context: ${at}k / ${pt}k tokens (${kt}% used)`:void 0,children:e.jsxs("span",{className:"flat-terminal-wrapper__context",tabIndex:0,role:"button",onClick:()=>g.setContextModalAgentId(r),onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),g.setContextModalAgentId(r))},title:((u==null?void 0:u.provider)??"claude")!=="claude"&&((u==null?void 0:u.provider)??"claude")!=="grok"?ut?`Context usage: ${at}k / ${pt}k tokens (${kt}% used). Click to view stats.`:"Click to fetch context stats":void 0,children:[e.jsx("span",{className:"flat-terminal-wrapper__context-icon",children:e.jsx(d,{name:"dashboard",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__context-label",children:"Ctx:"}),e.jsx("span",{className:"flat-terminal-wrapper__context-bar",children:e.jsx("span",{className:"flat-terminal-wrapper__context-bar-fill",style:{width:`${ze}%`,backgroundColor:tt}})}),e.jsxs("span",{className:"flat-terminal-wrapper__context-tokens",style:{color:tt},children:[at,"k/",pt,"k"]}),e.jsxs("span",{className:"flat-terminal-wrapper__context-free",children:["(",xe,"% free)"]}),!ut&&e.jsx("span",{className:"flat-terminal-wrapper__context-warning",title:"No context stats yet",children:e.jsx(d,{name:"warn",size:12})})]})}),e.jsx("div",{className:"flat-terminal-wrapper__statusbar-spacer","aria-hidden":"true"}),pe.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area terminals",children:pe.map(a=>{const o=(j==null?void 0:j.buildingId)===a.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${o?"flat-terminal-wrapper__building-btn--active":""} ${a.hasUrl?"":"flat-terminal-wrapper__building-btn--offline"}`,title:`${o?"Hide":"Show"} terminal: ${a.name}${a.hasUrl?"":" (starting...)"}`,onClick:()=>{if(o){ke();return}if(a.hasUrl&&gt(a.id)==="modal"){it(a.id);return}a.hasUrl||g.sendBuildingCommand(a.id,"start"),Ge("terminal",a.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),ve(a.id,{x:i.clientX,y:i.clientY})},children:e.jsx(d,{name:"terminal",size:14})},a.id)})}),je.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area PM2 logs",children:je.map(a=>{const o=(j==null?void 0:j.buildingId)===a.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${o?"flat-terminal-wrapper__building-btn--active":""}`,title:`${o?"Hide":"Show"} logs: ${a.name}`,onClick:()=>{o?ke():gt(a.id)==="modal"?it(a.id):Ge("pm2-logs",a.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),ve(a.id,{x:i.clientX,y:i.clientY})},children:e.jsx(d,{name:"scroll",size:14})},a.id)})}),Z.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area databases",children:Z.map(a=>{const o=(j==null?void 0:j.buildingId)===a.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${o?"flat-terminal-wrapper__building-btn--active":""}`,title:`${o?"Hide":"Show"} database: ${a.name}`,onClick:()=>{o?ke():gt(a.id)==="modal"?it(a.id):Ge("database",a.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),ve(a.id,{x:i.clientX,y:i.clientY})},children:e.jsx(d,{name:"hard-drives",size:14})},a.id)})}),se.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area tests",children:se.map(a=>{const o=(j==null?void 0:j.buildingId)===a.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${o?"flat-terminal-wrapper__building-btn--active":""} ${a.working?"flat-terminal-wrapper__building-btn--tests-working":""}`,title:a.working?`Running tests: ${a.name}`:`${o?"Hide":"Show"} tests: ${a.name}`,onClick:()=>{o?ke():gt(a.id)==="modal"?it(a.id):Ge("tests",a.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),ve(a.id,{x:i.clientX,y:i.clientY})},children:e.jsx(d,{name:"flask",size:14})},a.id)})}),ie.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area HTTP requests",children:ie.map(a=>{const o=(j==null?void 0:j.buildingId)===a.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${o?"flat-terminal-wrapper__building-btn--active":""}`,title:`${o?"Hide":"Show"} HTTP requests: ${a.name}`,onClick:()=>{o?ke():gt(a.id)==="modal"?it(a.id):Ge("http",a.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),ve(a.id,{x:i.clientX,y:i.clientY})},children:e.jsx(d,{name:"globe",size:14})},a.id)})}),e.jsx("div",{className:"flat-terminal-wrapper__theme",children:e.jsx(jn,{})})]}),w&&e.jsx(Cn,{agentId:r,agents:Xe,onClose:Bt,branchInfoMap:wt,fetchRemote:Fe,fetchingDirs:Le,onResizeStart:a=>ot(a,"right")}),De&&e.jsx(kn,{agentId:r,onClose:dt}),O&&e.jsx(Nn,{agentId:r,onClose:Ot})]})}),Vn={groups:[],gridCols:1,gridRows:1,positions:new Map};function Zn({onAgentClick:c,onBuildingClick:r,onBuildingDoubleClick:p,onBuildingPopup:b,onAreaContextMenu:N,onOpenSpawnModal:I,onOpenBossSpawnModal:A,onOpenAreaModal:y}){const{t:K}=Kt(["common"]),v=$a(),H=Ra(),[R,re]=s.useState(null),[T,Ee]=s.useState(null),[oe,ce]=s.useState(null);ha("flatview-image-modal",R!==null,()=>re(null));const[Oe,bt]=s.useState(null),[we,ve]=s.useState(null),[u,D]=s.useState(null),[Me,Ie]=s.useState(null),[Ze,Te]=s.useState(!1),Lt=s.useCallback(()=>{Te(t=>!t)},[]),_t=s.useCallback(()=>{Te(!1)},[]),[Je,de]=s.useState(()=>{const t=ta(M.VIEW_MODE);return t==="simple"||t==="chat"||t==="advanced"?t:"simple"}),Qe=s.useCallback(t=>{de(t),aa(M.VIEW_MODE,t)},[]);s.useEffect(()=>{const t=n=>{if(n.key!==M.VIEW_MODE)return;const l=n.newValue;(l==="simple"||l==="chat"||l==="advanced")&&de(l)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const[Be,ue]=s.useState(()=>Yt(M.FLAT_INSPECTOR_OPEN,!1)),[$,me]=s.useState(!1),lt=s.useCallback(()=>me(t=>!t),[]),wt=s.useCallback(()=>me(!1),[]);s.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-agents-drawer-state",{detail:{open:$}}))},[$]),s.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-inspector-state",{detail:{open:Be}}))},[Be]),s.useEffect(()=>{const t=()=>me(k=>!k),n=()=>{ue(k=>{const E=!k;return _e(M.FLAT_INSPECTOR_OPEN,E),E})},l=()=>{me(!1),ue(!1),_e(M.FLAT_INSPECTOR_OPEN,!1)},x=()=>me(!1),_=()=>{ue(!1),_e(M.FLAT_INSPECTOR_OPEN,!1)};return window.addEventListener("tide-toggle-flat-agents-drawer",t),window.addEventListener("tide-toggle-flat-inspector",n),window.addEventListener("tide-close-flat-side-views",l),window.addEventListener("tide-close-flat-agents-drawer-only",x),window.addEventListener("tide-close-flat-inspector-only",_),()=>{window.removeEventListener("tide-toggle-flat-agents-drawer",t),window.removeEventListener("tide-toggle-flat-inspector",n),window.removeEventListener("tide-close-flat-side-views",l),window.removeEventListener("tide-close-flat-agents-drawer-only",x),window.removeEventListener("tide-close-flat-inspector-only",_)}},[]);const Fe=s.useRef(null),Le=s.useRef(null),[pe,je]=s.useState(()=>{const t=na(M.FLAT_MIDDLE_WIDTH,0);return t>=Tt?t:null}),[Z,We]=s.useState(()=>{const t=na(M.FLAT_INSPECTOR_WIDTH,0);return t>=Vt?t:null}),se=s.useCallback(t=>{if(typeof window>"u")return t;const n=Z!==null?It+Z:0,l=window.innerWidth-ua-It-da-n;return Math.max(Tt,Math.min(Math.max(l,Tt),t))},[Z]),ie=s.useCallback(t=>{var _;if(typeof window>"u")return t;const n=(_=Fe.current)==null?void 0:_.querySelector(".flat-middle"),l=(n==null?void 0:n.getBoundingClientRect().width)??Tt,x=window.innerWidth-ua-l-It-da-It;return Math.max(Vt,Math.min(Math.max(x,Vt),t))},[]);s.useEffect(()=>{if(pe===null&&Z===null)return;const t=()=>{je(n=>{if(n===null)return n;const l=se(n);return l===n?n:l}),We(n=>{if(n===null)return n;const l=ie(n);return l===n?n:l})};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[pe,Z,se,ie]);const Pt=s.useCallback(t=>{var l;if(t.button!==0)return;const n=(l=Fe.current)==null?void 0:l.querySelector(".flat-middle");n&&(t.currentTarget.setPointerCapture(t.pointerId),Le.current={kind:"middle",startX:t.clientX,startWidth:n.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),Ce=s.useCallback(t=>{var l;if(t.button!==0)return;const n=(l=Fe.current)==null?void 0:l.querySelector(".flat-inspector");n&&(t.currentTarget.setPointerCapture(t.pointerId),Le.current={kind:"inspector",startX:t.clientX,startWidth:n.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),rt=s.useCallback(t=>{const n=Le.current;if(!n||t.pointerId!==n.pointerId)return;const l=t.clientX-n.startX;n.kind==="middle"?je(se(n.startWidth+l)):We(ie(n.startWidth-l))},[se,ie]),Pe=s.useCallback(t=>{const n=Le.current;if(!n||t.pointerId!==n.pointerId)return;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}if(Le.current=null,document.body.classList.remove("flat-splitter-dragging"),!(Math.abs(t.clientX-n.startX)>2))return;const x=t.clientX-n.startX;if(n.kind==="middle"){const _=se(n.startWidth+x);je(_),Mt(M.FLAT_MIDDLE_WIDTH,_)}else{const _=ie(n.startWidth-x);We(_),Mt(M.FLAT_INSPECTOR_WIDTH,_)}},[se,ie]),$e=s.useCallback(()=>{je(null),Mt(M.FLAT_MIDDLE_WIDTH,0)},[]),j=s.useCallback(()=>{We(null),Mt(M.FLAT_INSPECTOR_WIDTH,0)},[]),[te,J]=s.useState(()=>ta(M.FLAT_INSPECTOR_VIEW)==="tracking"?"tracking":"agent"),He=s.useCallback(t=>{J(t),aa(M.FLAT_INSPECTOR_VIEW,t)},[]),Re=s.useCallback(()=>{ue(t=>{const n=!t;return _e(M.FLAT_INSPECTOR_OPEN,n),n})},[]),Ue=s.useCallback(()=>{ue(!1),_e(M.FLAT_INSPECTOR_OPEN,!1)},[]),$t=s.useCallback(()=>{He("tracking"),ue(!0),_e(M.FLAT_INSPECTOR_OPEN,!0)},[He]),z=Da(),Ge=s.useCallback((t,n)=>{re({url:t,name:n})},[]),ke=s.useCallback((t,n)=>{Ee({command:t,output:n,isLive:!1})},[]),Rt=s.useCallback((t,n)=>{var _;const l=H.size>0?Array.from(H)[0]:null,x=l?(_=g.getState().agents.get(l))==null?void 0:_.cwd:void 0;g.setFileViewerPath(t,n,x)},[H]),Dt=s.useCallback(t=>{ce(t)},[]),zt=s.useCallback((t,n)=>{bt({agentId:t,count:n})},[]),ot=s.useCallback(t=>{p?p(t):r(t)},[r,p]),w=s.useMemo(()=>H.size>0?Array.from(H)[0]:null,[H]),vt=s.useCallback(t=>{w&&ve({agentId:w,position:t})},[w]),De=s.useCallback((t,n)=>{D({buildingId:t,position:n})},[]);s.useEffect(()=>{Te(!1)},[w]);const fe=s.useRef([]),O=s.useRef(-1),Ve=s.useRef(!1),ct=s.useRef(null),[Ot,jt]=s.useState(!1),[Ct,Bt]=s.useState(!1),dt=s.useRef(!1),Xe=s.useRef(null),he=s.useRef(!1),Ne=s.useMemo(()=>new Set(v.map(t=>t.id)),[v]),qe=s.useMemo(()=>{const t=new Map(v.map(l=>[l.id,l])),n=new Map;for(const l of v)if((l.isBoss||l.class==="boss")&&l.subordinateIds&&l.subordinateIds.length>0){const x=l.subordinateIds.map(_=>t.get(_)).filter(_=>_!==void 0);x.length>0&&n.set(l.id,x)}return n},[v]),B=s.useCallback(()=>{const t=fe.current,n=O.current;jt(n>0),Bt(n>=0&&n<t.length-1)},[]),ge=s.useCallback(t=>{const n=fe.current;if(n.length===0)return;let l=O.current+t;for(;l>=0&&l<n.length;){const x=n[l];if(Ne.has(x)){Ve.current=!0,O.current=l,B(),g.selectAgent(x);return}l+=t}},[Ne,B]),ye=s.useCallback(()=>ge(-1),[ge]),ut=s.useCallback(()=>ge(1),[ge]);En(s.useCallback(()=>{const t=fe.current,n=O.current;return t.length>0&&n>0?(ge(-1),"handled"):"exit"},[ge]));const et=s.useCallback((t,n)=>{if(typeof window>"u")return;const l=window.history.state,_={...typeof l=="object"&&l!==null?l:{},__flatAgentNav:{agentId:t}};n==="replace"?window.history.replaceState(_,"",window.location.href):window.history.pushState(_,"",window.location.href)},[]);s.useEffect(()=>{if(!w){dt.current=!1,Xe.current=null;return}if(!dt.current){et(w,"replace"),dt.current=!0,Xe.current=w;return}if(he.current){he.current=!1,Xe.current=w;return}Xe.current!==w&&(et(w,"push"),Xe.current=w)},[w,et]),s.useEffect(()=>{const t=n=>{var k,E;const l=(E=(k=n.state)==null?void 0:k.__flatAgentNav)==null?void 0:E.agentId;if(!l||typeof l!="string"||!Ne.has(l)||l===w)return;he.current=!0,Ve.current=!0;const x=fe.current,_=x.lastIndexOf(l);_>=0?O.current=_:(x.push(l),O.current=x.length-1),B(),g.selectAgent(l)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[Ne,w,B]),s.useEffect(()=>{if(!w){fe.current=[],O.current=-1,B();return}if(ct.current=w,Ve.current){Ve.current=!1,B();return}const t=fe.current,n=O.current;if(n>=0&&t[n]===w){B();return}const l=n<t.length-1?t.slice(0,n+1):t.slice();l.push(w),l.length>100&&l.shift(),fe.current=l,O.current=l.length-1,B()},[w,B]);const mt=s.useCallback(t=>{c(t),me(!1)},[c]),Ft=w??"",ze=s.useCallback(()=>{},[]),kt=s.useCallback(t=>{mt(t)},[mt]),xe=Be,[tt,at]=s.useState(xe),[pt,be]=s.useState(xe);s.useEffect(()=>{if(xe){at(!0);return}be(!1);const t=setTimeout(()=>at(!1),240);return()=>clearTimeout(t)},[xe]),s.useEffect(()=>{if(!tt||!xe)return;let t=0;const n=requestAnimationFrame(()=>{t=requestAnimationFrame(()=>be(!0))});return()=>{cancelAnimationFrame(n),cancelAnimationFrame(t)}},[tt,xe]);const ft=s.useRef(null);s.useEffect(()=>{if(w)return;const t=n=>{if(n.key!==" "&&n.key!=="Backspace")return;const l=n.target;if(l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.isContentEditable)return;const x=ct.current;!x||!Ne.has(x)||(n.preventDefault(),g.selectAgent(x))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[w,Ne]);const[Se,nt]=s.useState(new Set),Nt=s.useCallback(t=>{nt(n=>{const l=new Set(n);return l.has(t)?l.delete(t):l.add(t),l})},[]),yt=s.useCallback(t=>{nt(new Set(t))},[]),[a,o]=s.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches);s.useEffect(()=>{if(typeof window>"u")return;const t=window.matchMedia("(max-width: 768px)"),n=l=>o(l.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[]);const[i,m]=s.useState(null),X=s.useCallback(t=>{m(n=>n===t?null:t)},[]),Q=ga(),L=xa(),[st]=za(),ae=s.useMemo(()=>{if(w)return Vn;const t=new Map,n=[];for(const h of v){const C=g.getAreaForAgent(h.id);if(!sa((C==null?void 0:C.id)??null))continue;if(!C||C.archived){n.push(h);continue}const P=t.get(C.id);P?P.push(h):t.set(C.id,[h])}const l=new Map,x=[];for(const h of L.values()){let C=!1;for(const P of Q.values())if(!P.archived&&ia(P.id)&&g.isPositionInArea(h.position,P)){const le=l.get(P.id);le?le.push(h):l.set(P.id,[h]),C=!0;break}!C&&sa(null)&&x.push(h)}const _=[];for(const[,h]of Q){if(h.archived||!ia(h.id))continue;const C=t.get(h.id),P=l.get(h.id)??[];(C&&C.length>0||P.length>0)&&_.push({area:h,agents:C??[],buildings:P})}(n.length>0||x.length>0)&&_.push({area:{id:"__unassigned__",name:"Unassigned",color:"#6272a4",center:{x:0,z:0},type:"circle",radius:0,directories:[],archived:!1,assignedAgentIds:[],zIndex:0},agents:n,buildings:x});const k=_.filter(h=>h.area.id!=="__unassigned__"),E=_.filter(h=>h.area.id==="__unassigned__");let G=1,F=1;const f=new Map;if(k.length>1){let h=1/0,C=-1/0,P=1/0,le=-1/0;for(const q of k)h=Math.min(h,q.area.center.x),C=Math.max(C,q.area.center.x),P=Math.min(P,q.area.center.z),le=Math.max(le,q.area.center.z);const Ae=C-h||1,At=le-P||1;if(k.length<=4){G=k.length,F=1;const q=[...k].sort((Y,Wt)=>Y.area.center.x-Wt.area.center.x);for(let Y=0;Y<q.length;Y++)f.set(q[Y].area.id,{row:1,col:Y+1})}else{const q=[...k].sort((S,W)=>S.area.center.x-W.area.center.x),Y=[];for(let S=1;S<q.length;S++)Y.push(q[S].area.center.x-q[S-1].area.center.x);const Wt=Y.reduce((S,W)=>S+W,0)/Y.length||1;let Zt=1;for(const S of Y)S>Wt*1.3&&Zt++;G=Math.max(2,Math.min(Zt,k.length));const Ht=[...k].sort((S,W)=>S.area.center.z-W.area.center.z),Et=[];for(let S=1;S<Ht.length;S++)Et.push(Ht[S].area.center.z-Ht[S-1].area.center.z);const ka=Et.reduce((S,W)=>S+W,0)/Et.length||1;let Jt=1;for(const S of Et)S>ka*1.3&&Jt++;F=Math.max(2,Math.min(Jt,k.length)),G=Math.max(G,Math.ceil(k.length/F)),F=Math.max(F,Math.ceil(k.length/G));const Na=Ae/G,ya=At/F,Ut=new Set;for(const S of k){let W=Math.min(G-1,Math.max(0,Math.floor((S.area.center.x-h)/Na))),Ke=Math.min(F-1,Math.max(0,Math.floor((S.area.center.z-P)/ya))),ht=`${Ke},${W}`,Qt=0;const Sa=F*G;for(;Ut.has(ht)&&Qt<Sa;)W++,W>=G&&(W=0,Ke=(Ke+1)%F),ht=`${Ke},${W}`,Qt++;Ut.has(ht)&&(Ke=F,W=0,ht=`${Ke},${W}`,F++),Ut.add(ht),f.set(S.area.id,{row:Ke+1,col:W+1})}}}const ee=h=>{h.sort((C,P)=>{var Ae,At,q,Y;const le=(((Ae=C.position)==null?void 0:Ae.z)??0)-(((At=P.position)==null?void 0:At.z)??0);return le!==0?le:(((q=C.position)==null?void 0:q.x)??0)-(((Y=P.position)==null?void 0:Y.x)??0)})};for(const h of k)ee(h.agents);for(const h of E)ee(h.agents);const V=[...k,...E].sort((h,C)=>h.area.name.localeCompare(C.area.name,void 0,{sensitivity:"base",numeric:!0})||h.area.id.localeCompare(C.area.id));return f.clear(),V.forEach((h,C)=>{f.set(h.area.id,{row:Math.floor(C/G)+1,col:C%G+1})}),F=Math.max(1,Math.ceil(V.length/G)),{groups:V,gridCols:G,gridRows:F,positions:f}},[v,Q,L,st,w]),Ye=s.useMemo(()=>{let t=0,n=0;for(const l of ae.groups)t+=l.agents.length,n+=l.agents.filter(x=>x.status==="working").length;return{areaCount:ae.groups.length,agentCount:t,workingCount:n}},[ae]),ne=s.useMemo(()=>{if(!we)return[];const t=v.find(n=>n.id===we.agentId);return t?[{id:"edit-agent",label:"Edit Agent",icon:e.jsx(d,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:open-agent-edit",{detail:{agentId:t.id}}))}},{id:"open-chat",label:"Open Chat",icon:e.jsx(d,{name:"chat",size:14}),onClick:()=>c(t.id)},{id:"clone-agent",label:"Clone Agent",icon:e.jsx(d,{name:"clipboard",size:14}),onClick:()=>g.cloneAgent(t.id)},{id:"fork-agent",label:"Fork Agent (with history)",icon:e.jsx(d,{name:"git-branch",size:14}),onClick:()=>g.forkAgent(t.id)},{id:"delete-agent",label:"Delete Agent",icon:e.jsx(d,{name:"trash",size:14}),danger:!0,onClick:()=>{Ie({agentId:t.id,name:t.name})}}]:[]},[we,v,c]),U=s.useMemo(()=>{var k;if(!u)return[];const t=L.get(u.buildingId);if(!t)return[];const n=[],l=t.type==="server"||t.type==="docker"||t.type==="terminal",x=t.status==="running",_=t.type==="boss";if(n.push({id:"open",label:t.type==="database"?"Open Database":t.type==="folder"?"Open Folder":t.type==="tests"?"Open Tests":t.type==="http"?"Open Requests":t.type==="boss"?"View Boss Logs":t.type==="terminal"?"Open Terminal":t.type==="server"&&((k=t.pm2)!=null&&k.enabled)?"View PM2 Logs":"Open",icon:e.jsx(d,{name:t.type==="database"?"database":t.type==="folder"?"folder":t.type==="tests"?"flask":t.type==="http"?"globe":t.type==="terminal"?"terminal":"eye",size:14}),onClick:()=>ot(t.id)}),l&&(x||n.push({id:"start",label:"Start",icon:e.jsx(d,{name:"play",size:14}),onClick:()=>g.sendBuildingCommand(t.id,"start")}),x&&(n.push({id:"restart",label:"Restart",icon:e.jsx(d,{name:"refresh",size:14}),onClick:()=>g.sendBuildingCommand(t.id,"restart")}),n.push({id:"stop",label:"Stop",icon:e.jsx(d,{name:"stop",size:14}),onClick:()=>g.sendBuildingCommand(t.id,"stop")}))),_&&t.subordinateBuildingIds&&t.subordinateBuildingIds.length>0&&(n.push({id:"start-all",label:"Start All Subordinates",icon:e.jsx(d,{name:"launch",size:14}),onClick:()=>{for(const E of t.subordinateBuildingIds)g.sendBuildingCommand(E,"start")}}),n.push({id:"stop-all",label:"Stop All Subordinates",icon:e.jsx(d,{name:"pause",size:14}),onClick:()=>{for(const E of t.subordinateBuildingIds)g.sendBuildingCommand(E,"stop")}}),n.push({id:"restart-all",label:"Restart All Subordinates",icon:e.jsx(d,{name:"restart",size:14}),onClick:()=>{for(const E of t.subordinateBuildingIds)g.sendBuildingCommand(E,"restart")}})),l&&n.push({id:"health-check",label:"Health Check",icon:e.jsx(d,{name:"health",size:14}),onClick:()=>g.sendBuildingCommand(t.id,"healthCheck")}),n.push({id:"divider-edit",label:"",divider:!0,onClick:()=>{}}),n.push({id:"edit",label:"Edit Building",icon:e.jsx(d,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:building-edit",{detail:{buildingId:t.id}}))}}),n.push({id:"clone",label:"Clone Building",icon:e.jsx(d,{name:"copy",size:14}),onClick:()=>{g.createBuilding({name:`${t.name} (Copy)`,type:t.type,style:t.style,color:t.color,scale:t.scale,position:{x:t.position.x+2,z:t.position.z+2},cwd:t.cwd,folderPath:t.folderPath,commands:t.commands,pm2:t.pm2,docker:t.docker,database:t.database,terminal:t.terminal,urls:t.urls,subordinateBuildingIds:t.subordinateBuildingIds})}}),t.urls&&t.urls.length>0)for(const E of t.urls)n.push({id:`url-${E.label}`,label:E.label,icon:e.jsx(d,{name:"link",size:14}),onClick:()=>window.open(E.url,"_blank","noopener,noreferrer")});return n.push({id:"divider-danger",label:"",divider:!0,onClick:()=>{}}),n.push({id:"delete",label:"Delete Building",icon:e.jsx(d,{name:"trash",size:14}),danger:!0,onClick:()=>g.deleteBuilding(t.id)}),n},[u,L,ot]),St=s.useCallback(t=>{nt(new Set([t])),requestAnimationFrame(()=>{const n=ft.current;if(!n)return;const l=n.querySelector(`[data-area-id="${t}"]`);if(!l)return;const x=n.getBoundingClientRect(),k=l.getBoundingClientRect().top-x.top+n.scrollTop-8;n.scrollTo({top:Math.max(0,k),behavior:"smooth"})})},[]);return e.jsxs("div",{ref:Fe,className:`flat-view ${xe?"flat-view--with-inspector":""} ${w?"flat-view--has-chat":""} ${$?"flat-view--mobile-sidebar-open":""}`,style:(()=>{if(pe===null&&Z===null)return;const t={};return pe!==null&&(t["--flat-middle-width"]=`${pe}px`),Z!==null&&(t["--flat-inspector-width"]=`${Z}px`),t})(),children:[$&&e.jsx("div",{className:"flat-mobile-sidebar-backdrop",onClick:wt,"aria-hidden":"true"}),e.jsxs("div",{className:"flat-middle",children:[e.jsx("div",{className:"flat-middle__header",children:e.jsxs("div",{className:"flat-middle__actions",children:[e.jsx("button",{className:"flat-cta-btn flat-cta-btn--agent",onClick:I,title:"Create new agent",children:"+ Agent"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--boss",onClick:A,title:"Create new boss agent",children:"+ Boss"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--area",onClick:y,title:"Create new area",children:"+ Area"})]})}),e.jsx("div",{className:"flat-middle__content",children:e.jsx(Oa,{activeAgentId:Ft,onClose:ze,onSelectAgent:kt,expandedAreas:Se,onToggleArea:Nt,onSetExpandedAreas:yt,agentListRef:ft})})]}),e.jsx("div",{className:"flat-splitter flat-splitter--middle",role:"separator","aria-orientation":"vertical","aria-label":"Resize agents panel",title:"Drag to resize · Double-click to reset",onPointerDown:Pt,onPointerMove:rt,onPointerUp:Pe,onPointerCancel:Pe,onDoubleClick:$e}),e.jsxs("div",{className:"flat-right",children:[e.jsxs("button",{type:"button",className:"flat-mobile-sidebar-toggle","aria-label":$?"Close agents sidebar":"Open agents sidebar","aria-expanded":$,onClick:lt,children:[e.jsx(d,{name:"list",size:18}),e.jsx("span",{className:"flat-mobile-sidebar-toggle__label",children:"Agents"})]}),w?e.jsx(Gn,{agentId:w,terminalViewMode:Je,onTerminalViewModeChange:Qe,inspectorOpen:Be,onToggleInspector:Re,onShowTaskBoard:$t,onImageClick:Ge,onFileClick:Rt,onBashClick:ke,onViewMarkdown:Dt,onRequestClearSubordinates:zt,keyboard:z,canNavigateBack:Ot,canNavigateForward:Ct,onNavigateBack:ye,onNavigateForward:ut,agentInfoOpen:Ze,onToggleAgentInfo:Lt,onHeaderContextMenu:vt,onBuildingContextMenu:De}):e.jsx("div",{className:"flat-chat flat-chat--empty",children:e.jsxs("div",{className:"flat-map",children:[e.jsxs("div",{className:"flat-map__header",children:[e.jsx("span",{className:"flat-map__title",children:"🗺️ Areas"}),e.jsx("span",{className:"flat-map__hint",children:"Click an area to focus it, or an agent to chat"}),e.jsxs("span",{className:"flat-map__stats",children:[e.jsxs("span",{children:[Ye.areaCount," areas"]}),e.jsxs("span",{children:[Ye.agentCount," agents"]}),Ye.workingCount>0&&e.jsxs("span",{className:"flat-map__stats-working",children:[e.jsx("span",{className:"flat-map__stats-dot","aria-hidden":"true"}),Ye.workingCount," working"]})]}),e.jsx(Dn,{className:"flat-map__view-mode"})]}),e.jsx("div",{className:"flat-map__grid",style:{gridTemplateColumns:a?"repeat(2, minmax(0, 1fr))":`repeat(${ae.gridCols}, 1fr)`},children:ae.groups.length===0?e.jsx("div",{className:"flat-map__empty",children:e.jsx("span",{children:"No areas or agents yet"})}):(a?[...ae.groups].sort((n,l)=>{const x=ae.positions.get(n.area.id),_=ae.positions.get(l.area.id);return!x&&!_?0:x?_?x.row-_.row||x.col-_.col:-1:1}):ae.groups).map(n=>{var F;const l=n.area.id,x=ae.positions.get(l),_=n.agents.filter(f=>f.status==="working").length,k=_>0,E=a&&i!==l,G=a&&!E;return e.jsxs("div",{className:`flat-map-area-card${k?" flat-map-area-card--working":""}${E?" flat-map-area-card--collapsed":""}${G?" flat-map-area-card--expanded":""}`,style:{"--area-color":n.area.color,gridRow:a||x==null?void 0:x.row,gridColumn:a||x==null?void 0:x.col},onContextMenu:f=>{N&&(f.preventDefault(),f.stopPropagation(),N(l,{x:f.clientX,y:f.clientY}))},children:[e.jsxs("button",{type:"button",className:"flat-map-area-card__header",onClick:()=>a?X(l):St(l),title:a?E?`Expand ${n.area.name}`:`Collapse ${n.area.name}`:`Focus ${n.area.name} in left panel`,"aria-expanded":a?!E:void 0,children:[e.jsx("span",{className:"flat-map-area-card__color",style:{background:n.area.color}}),((F=n.area.logo)==null?void 0:F.filename)&&e.jsx("img",{className:"flat-map-area-card__logo",src:An(n.area.logo.filename),alt:"","aria-hidden":"true",onError:f=>{f.currentTarget.style.display="none"}}),e.jsx("span",{className:"flat-map-area-card__name",children:n.area.name}),e.jsxs("span",{className:"flat-map-area-card__count",title:`${n.agents.length} agent${n.agents.length===1?"":"s"}`,"aria-label":`${n.agents.length} agent${n.agents.length===1?"":"s"}`,children:[e.jsx(d,{name:"users",size:10}),n.agents.length]}),k&&e.jsxs("span",{className:"flat-map-area-card__working",title:`${_} working agent${_===1?"":"s"}`,"aria-label":`${_} working agent${_===1?"":"s"}`,children:[e.jsxs("span",{className:"flat-map-area-card__working-bars","aria-hidden":"true",children:[e.jsx("i",{}),e.jsx("i",{}),e.jsx("i",{})]}),e.jsx("span",{className:"flat-map-area-card__working-count",children:_})]}),a&&e.jsx(d,{name:E?"caret-down":"caret-up",size:11,className:"flat-map-area-card__caret"})]}),e.jsx("div",{className:"flat-map-area-card__agents",children:n.agents.map(f=>{const ee=f.isBoss||f.class==="boss",V=ee?qe.get(f.id):void 0,h=Ba(f),C=h.usedPercent>=80?"#ff4a4a":h.usedPercent>=60?"#ff9e4a":h.usedPercent>=40?"#ffd700":"#4aff9e",P=`Context: ${(h.totalTokens/1e3).toFixed(1)}k / ${(h.contextWindow/1e3).toFixed(1)}k (${h.usedPercent}% used, ${h.freePercent}% free)`,le=f.latestTodos&&f.latestTodos.length>0||V&&V.length>0;return e.jsx(Fa,{todos:f.latestTodos,subordinates:V,position:"top",children:e.jsxs("button",{type:"button",className:`flat-map-agent-chip ${f.status}`,onClick:()=>c(f.id),onContextMenu:Ae=>{Ae.preventDefault(),Ae.stopPropagation(),ve({agentId:f.id,position:{x:Ae.clientX,y:Ae.clientY}})},title:le?void 0:`${ee?"Boss · ":""}Open chat with ${f.name}
2
+ ${P}`,children:[e.jsx(ba,{agent:f,size:16}),ee&&e.jsx("span",{className:"flat-map-agent-chip__crown","aria-hidden":"true",children:e.jsx(d,{name:"crown",size:11,color:"#ffd700",weight:"fill"})}),e.jsx("span",{className:"flat-map-agent-chip__name",children:f.name}),e.jsx("img",{src:wa(f.provider,"/"),alt:f.provider,className:"flat-map-agent-chip__provider-icon",title:_a(f.provider)}),e.jsx("span",{className:"flat-map-agent-chip__dot",style:{backgroundColor:va(f.status)}}),f.latestTodos&&f.latestTodos.length>0&&e.jsx(Wa,{todos:f.latestTodos,maxDots:6}),ee&&V&&V.length>0&&e.jsx(Ha,{subordinates:V,maxDots:6}),e.jsx("span",{className:"flat-map-agent-chip__context-bar","aria-hidden":"true",children:e.jsx("span",{className:"flat-map-agent-chip__context-bar-fill",style:{width:`${h.usedPercent}%`,backgroundColor:C}})})]})},f.id)})}),n.area.directories.length>0&&e.jsx("div",{className:"flat-map-area-card__folders",role:"group","aria-label":`${n.area.name} folders`,children:n.area.directories.map(f=>{const ee=f.split("/").filter(Boolean).pop()||f;return e.jsxs("button",{type:"button",className:"flat-map-folder-chip",onClick:V=>{V.stopPropagation(),g.openFileExplorerForAreaFolder(l,f)},title:`Open in file explorer: ${f}`,children:[e.jsx(d,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-map-folder-chip__name",children:ee})]},f)})}),n.buildings.length>0&&e.jsx("div",{className:"flat-map-area-card__buildings",children:n.buildings.map(f=>{var V;const ee=(V=Ua[f.type])==null?void 0:V.color;return e.jsxs("button",{type:"button",className:`flat-map-building-chip flat-map-building-chip--${f.status}`,style:ee?{"--building-type-color":ee}:void 0,onClick:h=>{if(b){const C=h.currentTarget.getBoundingClientRect();b(f.id,{x:C.right,y:C.top+C.height/2})}else ot(f.id)},onContextMenu:h=>{h.preventDefault(),h.stopPropagation(),D({buildingId:f.id,position:{x:h.clientX,y:h.clientY}})},title:`${f.name} · ${f.type} · ${f.status}`,children:[e.jsx(d,{name:Ga(f.type),size:12,color:ee}),e.jsx("span",{className:"flat-map-building-chip__name",children:f.name}),e.jsx("span",{className:"flat-map-building-chip__dot",style:{backgroundColor:Va(f.status)}})]},f.id)})})]},l)})})]})})]}),xe&&e.jsx("div",{className:"flat-splitter flat-splitter--inspector",role:"separator","aria-orientation":"vertical","aria-label":"Resize inspector panel",title:"Drag to resize · Double-click to reset",onPointerDown:Ce,onPointerMove:rt,onPointerUp:Pe,onPointerCancel:Pe,onDoubleClick:j}),tt&&e.jsxs("aside",{className:`flat-inspector ${pt?"flat-inspector--open":"flat-inspector--closing"}`,"aria-label":"Inspector panel",children:[e.jsxs("div",{className:"flat-inspector__header",children:[e.jsxs("div",{className:"flat-inspector__tabs",role:"tablist","aria-label":"Inspector view",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":te==="agent",className:`flat-inspector__tab ${te==="agent"?"flat-inspector__tab--active":""}`,onClick:()=>He("agent"),children:"Agent"}),e.jsx("button",{type:"button",role:"tab","aria-selected":te==="tracking",className:`flat-inspector__tab ${te==="tracking"?"flat-inspector__tab--active":""}`,onClick:()=>He("tracking"),children:"Tracking"})]}),e.jsx("button",{type:"button",className:"flat-inspector__close",onClick:Ue,title:"Close inspector","aria-label":"Close inspector",children:"✕"})]}),e.jsx("div",{className:"flat-inspector__body",children:te==="tracking"?e.jsx(Xa,{activeAgentId:w??"",onSelectAgent:t=>{c(t),window.innerWidth<=768&&Ue()}}):(()=>{if(!w)return e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Select an agent to inspect"})});const t=v.find(n=>n.id===w);return t?e.jsx(qa,{agent:t,onFocusAgent:n=>{c(n),window.innerWidth<=768&&Ue()},onKillAgent:n=>g.killAgent(n)}):e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Agent not found"})})})()})]}),R&&e.jsx(Ya,{url:R.url,name:R.name,onClose:()=>re(null)}),T&&e.jsx(Ka,{state:T,onClose:()=>Ee(null)}),e.jsx(Za,{agent:w?v.find(t=>t.id===w)??null:null,content:oe,onClose:()=>ce(null)}),Oe&&e.jsx(Ja,{action:"clear-subordinates",selectedAgentId:Oe.agentId,subordinateCount:Oe.count,onClose:()=>bt(null),onClearHistory:()=>{}}),e.jsx(Qa,{agent:w?v.find(t=>t.id===w)??null:null,isOpen:Ze&&!!w,onClose:_t}),e.jsx(la,{isOpen:we!==null,position:(we==null?void 0:we.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:ne,onClose:()=>ve(null)}),e.jsx(la,{isOpen:u!==null,position:(u==null?void 0:u.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:U,onClose:()=>D(null)}),e.jsx(en,{isOpen:Me!==null,title:K("common:confirm.removeAgentTitle"),message:K("common:confirm.removeAgentMessage",{name:(Me==null?void 0:Me.name)??""}),confirmLabel:K("common:buttons.remove"),cancelLabel:K("common:buttons.cancel"),variant:"danger",onConfirm:()=>{Me&&g.removeAgentFromServer(Me.agentId)},onClose:()=>Ie(null)})]})}export{Zn as FlatView};