tide-commander 1.129.2 → 1.130.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{BossLogsModal-BMJsPBdB.js → BossLogsModal-B1BJZtYN.js} +1 -1
- package/dist/assets/{BossSpawnModal-DuDDNuE-.js → BossSpawnModal-BWAc8Tl3.js} +1 -1
- package/dist/assets/{ControlsModal-Cn3pkMIT.js → ControlsModal-eWw5Rop8.js} +1 -1
- package/dist/assets/{DockerLogsModal-D5XQ6zSr.js → DockerLogsModal-3KYmSZ0D.js} +1 -1
- package/dist/assets/{EmbeddedEditor-Ct4fmYRC.js → EmbeddedEditor-D-Hr6SKR.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-Cfxh0FZm.js → GmailOAuthSetup-Bj0WdFre.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-Z-Yv0mbQ.js → GoogleOAuthSetup-CKDUM2jS.js} +1 -1
- package/dist/assets/{IframeModal-eyoeBSzE.js → IframeModal-g0eqDvHl.js} +1 -1
- package/dist/assets/{IntegrationsPanel-DzdEuC2w.js → IntegrationsPanel-Cb-oZ4wo.js} +2 -2
- package/dist/assets/{LogViewerModal-fhtTos_b.js → LogViewerModal-BWj_qNc8.js} +1 -1
- package/dist/assets/{MonitoringModal-D_QNY_Zh.js → MonitoringModal-B92PBeU8.js} +1 -1
- package/dist/assets/{PM2LogsModal-DulkKfnA.js → PM2LogsModal-CVf6pfMB.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-BkpEL2dc.js → RestoreArchivedAreaModal-Cl8t248p.js} +1 -1
- package/dist/assets/{Scene2DCanvas-C5E1mERA.js → Scene2DCanvas-CtJ-402V.js} +1 -1
- package/dist/assets/{SceneManager-BA7KiD3q.js → SceneManager-BJNnOvdL.js} +1 -1
- package/dist/assets/{SkillsPanel-uotqhq5s.js → SkillsPanel-avhqZsVK.js} +1 -1
- package/dist/assets/{SlackMultiInstanceSetup-B1QA0scY.js → SlackMultiInstanceSetup-CUkW8jup.js} +1 -1
- package/dist/assets/{SpawnModal-B1d-vt6c.js → SpawnModal-CTflBJPO.js} +1 -1
- package/dist/assets/{StatisticsModal-CpMdoPSG.js → StatisticsModal-Cvg4hAz9.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-ALjpv2DP.js → SubordinateAssignmentModal-CMTYlIWY.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-rrDTH1Oq.js → TriggerManagerPanel-BEHEyek4.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-BcuM9e70.js → WorkflowEditorPanel-Dmi1MoCF.js} +1 -1
- package/dist/assets/{area-logos-BkmhbXfG.js → area-logos-BJJ6AZC2.js} +1 -1
- package/dist/assets/{index-CfEgfolW.js → index-B5iEYrCd.js} +1 -1
- package/dist/assets/{index-BNoB11BS.js → index-BZg6OccM.js} +2 -2
- package/dist/assets/{index-BiXjxgpq.js → index-Bd5vzbeG.js} +1 -1
- package/dist/assets/{index-DMCGsQg5.js → index-C3WlgIxN.js} +1 -1
- package/dist/assets/index-Ch9qOEPa.js +11 -0
- package/dist/assets/{index-C9NJLW6A.js → index-D0khiFSO.js} +3 -3
- package/dist/assets/{index-BoN1bGyV.js → index-D6E2F5UW.js} +3 -3
- package/dist/assets/{index-DI7bDj0E.js → index-D9i6rhAe.js} +5 -5
- package/dist/assets/index-UFc3Wfyr.js +2 -0
- package/dist/assets/main-Bi5x2SM0.css +1 -0
- package/dist/assets/{main-CEKV7I4r.js → main-D6Q3mJMF.js} +110 -110
- package/dist/assets/{web-jSBoGXkW.js → web-B6cscrTU.js} +1 -1
- package/dist/assets/{web-DTb2MfHS.js → web-BxA0OEx8.js} +1 -1
- package/dist/assets/{web-CvCmCymz.js → web-CybtmV4V.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/locales/de/config.json +20 -13
- package/dist/locales/en/config.json +11 -6
- package/dist/locales/es/config.json +20 -13
- package/dist/locales/fr/config.json +20 -13
- package/dist/locales/hi/config.json +20 -13
- package/dist/locales/it/config.json +20 -13
- package/dist/locales/ja/config.json +20 -13
- package/dist/locales/pt/config.json +20 -13
- package/dist/locales/ru/config.json +20 -13
- package/dist/locales/zh-CN/config.json +20 -13
- package/dist/src/packages/server/claude/backend.js +10 -3
- package/dist/src/packages/server/claude/session-loader.js +56 -13
- package/dist/src/packages/server/codex/backend.js +6 -1
- package/package.json +1 -1
- package/dist/assets/index-ZQNyoovC.js +0 -2
- package/dist/assets/index-dfuoBomr.js +0 -11
- package/dist/assets/main-D086vUF0.css +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{br as ta,u as B,j as e,aY as j,bu as Ms,bv as Fs,aZ as ae,s as D,bw as $s,r as m,D as Z,I as F,ab as Us,b6 as qe,f as na,bx as la,W as ia,S as ra,k as oa,aa as Ks,b7 as Ue}from"./main-D6Q3mJMF.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ca=[{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 da(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 ma(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 ua({buildingName:r,onClose:p,onConfirm:u}){const{t:x}=B(["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 pa({usePM2:r,setUsePM2:p}){const{t:u}=B(["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 ha({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:o}){var N;const{t:i}=B(["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:[((N=t.pm2Status.cpu)==null?void 0:N.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:ma(t.pm2Status.uptime)})]})]})}),a&&e.jsxs("div",{className:"pm2-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>r("start"),children:i("common:buttons.start")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>r("stop"),children:i("common:buttons.stop")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>r("restart"),children:i("terminal:buildingAction.restart")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>r("logs"),children:i("terminal:logs.title")})]})]}):null}function xa({dockerMode:o,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:r,dockerRestart:i,setDockerRestart:N,dockerPull:b,setDockerPull:L,dockerEnv:T,setDockerEnv:A,dockerComposePath:$,setDockerComposePath:R,dockerComposeProject:K,setDockerComposeProject:I,dockerComposeServices:H,setDockerComposeServices:O,selectedExistingContainer:d,setSelectedExistingContainer:E,dockerContainersList:q,isEditMode:V,building:k,handleCommand:_}){const{t:M}=B(["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 ${o==="container"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"container",checked:o==="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 ${o==="compose"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"compose",checked:o==="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 ${o==="existing"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"existing",checked:o==="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"})]})]}),o==="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 z=[...v];z[S]=U.target.value,s(z)},placeholder:"8080:80 or 3000"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>s(v.filter((U,z)=>z!==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 z=[...h];z[S]=U.target.value,a(z)},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,z)=>z!==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=>r(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=>N(l.target.value),children:Object.keys(Fs).map(l=>e.jsx("option",{value:l,children:Fs[l].label},l))})]})]}),o==="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(ae,{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)"})]})]}),o==="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=>E(l.target.value),required:o==="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."})]}),o!=="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=>L(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=>A(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:[((N=t.pm2Status.cpu)==null?void 0:N.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:ma(t.pm2Status.uptime)})]})]})}),a&&e.jsxs("div",{className:"pm2-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>o("start"),children:i("common:buttons.start")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>o("stop"),children:i("common:buttons.stop")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>o("restart"),children:i("terminal:buildingAction.restart")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>o("logs"),children:i("terminal:logs.title")})]})]}):null}function xa({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:o,dockerRestart:i,setDockerRestart:N,dockerPull:b,setDockerPull:L,dockerEnv:T,setDockerEnv:A,dockerComposePath:$,setDockerComposePath:R,dockerComposeProject:K,setDockerComposeProject:I,dockerComposeServices:H,setDockerComposeServices:O,selectedExistingContainer:d,setSelectedExistingContainer:E,dockerContainersList:q,isEditMode:V,building:k,handleCommand:_}){const{t:M}=B(["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 z=[...v];z[S]=U.target.value,s(z)},placeholder:"8080:80 or 3000"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>s(v.filter((U,z)=>z!==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 z=[...h];z[S]=U.target.value,a(z)},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,z)=>z!==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=>o(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=>N(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(ae,{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=>E(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=>L(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=>A(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 ba={enabled:!1,host:"",port:22,username:"",authMethod:"password"};function ja({dbConnections:o,setDbConnections:p,activeDbConnectionId:u,setActiveDbConnectionId:x}){const{t:n}=B(["terminal","common"]),[y,C]=m.useState({}),g=m.useRef(new Map);m.useEffect(()=>{const a=t=>{const r=t.detail;if(!r||!r.requestId)return;const i=g.current.get(r.requestId);i&&(g.current.delete(r.requestId),C(N=>({...N,[i]:r.success?{status:"success",serverVersion:r.serverVersion}:{status:"error",error:r.error||"Connection failed"}})))};return window.addEventListener("tide:db-test-result",a),()=>window.removeEventListener("tide:db-test-result",a)},[]);const v=(a,t)=>{const r=[...o];r[a]={...r[a],...t},p(r)},s=(a,t)=>{const i={...o[a].ssh??ba,...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(r=>({...r,[a.id]:{status:"testing"}})),D.testDatabaseConnectionTransient(t,a),window.setTimeout(()=>{g.current.has(t)&&(g.current.delete(t),C(r=>{const i=r[a.id];return(i==null?void 0:i.status)!=="testing"?r:{...r,[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 ${o.length+1}`,engine:"mysql",host:"localhost",port:3306,username:"root"};p([...o,a]),u||x(a.id)},children:n("terminal:database.addConnection")})]}),o.length===0&&e.jsx("div",{className:"form-hint",children:n("terminal:building.dbGetStarted")}),o.map((a,t)=>{var N,b,L,T,A,$,R,K,I,H,O;const r=y[a.id]??{status:"idle"},i=((N=a.ssh)==null?void 0:N.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=o.filter(E=>E.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 E=d.target.value;v(t,{engine:E,port:X[E].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:((L=a.ssh)==null?void 0:L.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:((A=a.ssh)==null?void 0:A.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 E=d.target.value.trim();s(t,{localPort:E?parseInt(E):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:r.status==="testing",onClick:()=>h(a),children:r.status==="testing"?"Testing…":"Test Connection"}),r.status==="success"&&e.jsxs("span",{style:{color:"#4aff9e",fontSize:12},children:["✓ Connected",r.serverVersion?` — ${r.serverVersion}`:""]}),r.status==="error"&&e.jsxs("span",{style:{color:"#ff6b6b",fontSize:12},title:r.error,children:["✗ ",r.error]})]})]})]},a.id)}),o.length>0&&e.jsx("div",{className:"form-hint",children:n("terminal:building.dbAfterSaving")})]})}function ga({buildings:o,buildingId:p,subordinateBuildingIds:u,setSubordinateBuildingIds:x,isEditMode:n,showBossLogs:y,setShowBossLogs:C,currentBossLogs:g,bossLogsContainerRef:v}){const{t:s}=B(["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(o.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(o.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=o.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 va({startCmd:o,setStartCmd:p,stopCmd:u,setStopCmd:x,restartCmd:n,setRestartCmd:y,healthCheckCmd:C,setHealthCheckCmd:g,logsCmd:v,setLogsCmd:s,isEditMode:h,handleCommand:a}){const{t}=B(["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:o,onChange:r=>p(r.target.value),placeholder:"npm run dev"}),h&&e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>a("start"),disabled:!o,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:r=>x(r.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:r=>y(r.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:r=>g(r.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:r=>s(r.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 Na=[{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 fa({terminalShell:o,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:r}=B(["config"]),i=(s==null?void 0:s.status)==="running",N=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:r("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:r("config:buildings.terminalShell",{defaultValue:"Shell"})}),e.jsx("select",{className:"form-input",value:o,onChange:b=>p(b.target.value),children:Na.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:r("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:r("config:buildings.terminalSaveSession",{defaultValue:"Persist session (tmux)"})})]})}),e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsx("label",{className:"form-sublabel",children:r("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:r("config:buildings.terminalControls",{defaultValue:"Terminal Controls"})}),N&&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:N.url})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"PID"}),e.jsx("span",{className:"runtime-value",children:N.pid})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Port"}),e.jsx("span",{className:"runtime-value",children:N.port})]}),N.tmuxSession&&e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Session"}),e.jsx("span",{className:"runtime-value",children:N.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"]}),(N==null?void 0:N.url)&&e.jsxs(e.Fragment,{children:[a&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>a(N.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 ka({logs:o,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:o.map((x,n)=>e.jsx("pre",{className:"log-entry",children:qs(x)},n))})]})}function wa({isOpen:o,onClose:p,buildingId:u,initialPosition:x}){const{t:n}=B(["config","common"]),{buildings:y,buildingLogs:C,bossStreamingLogs:g}=na(),v=la(),s=u?y.get(u):null,h=u?g.get(u)||[]:[],a=!!s,[t,r]=m.useState(""),[i,N]=m.useState("server"),[b,L]=m.useState("server-rack"),[T,A]=m.useState(""),[$,R]=m.useState(""),[K,I]=m.useState(""),[H,O]=m.useState(""),[d,E]=m.useState(""),[q,V]=m.useState(""),[k,_]=m.useState(""),[M,l]=m.useState([]),[S,U]=m.useState(!1),[z,Z]=m.useState(""),[W,Q]=m.useState(1),[J,te]=m.useState(!1),[Ge,ne]=m.useState(""),[Ye,le]=m.useState(""),[We,ie]=m.useState(""),[Je,oe]=m.useState(""),[Xe,re]=m.useState(""),[Vs,ce]=m.useState(!1),[P,de]=m.useState("container"),[me,ue]=m.useState(""),[Ze,pe]=m.useState(""),[he,xe]=m.useState(""),[be,je]=m.useState([]),[ge,ve]=m.useState([]),[Qe,Ne]=m.useState(""),[fe,ke]=m.useState(""),[ye,Ce]=m.useState(""),[es,Se]=m.useState("unless-stopped"),[ss,we]=m.useState("missing"),[Pe,De]=m.useState(""),[Ee,ze]=m.useState(""),[Le,Ae]=m.useState(""),[Be,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),Ws=m.useRef(null),ee=m.useRef(null);m.useEffect(()=>{var c,f,w,G,ds,ms,us,ps,hs,xs,bs,js,gs,vs,Ns,fs,ks,ys,Cs,Ss,ws,Ps,Ds,Es,zs,Ls,As,Bs,Ts,Rs,Is,Os,_s;o&&(s?(r(s.name),N(s.type),L(s.style||"server-rack"),A(s.color||""),R(s.cwd||""),I(((c=s.commands)==null?void 0:c.start)||""),O(((f=s.commands)==null?void 0:f.stop)||""),E(((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||[]),Z(s.folderPath||""),Q(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)||""),oe(((xs=s.pm2)==null?void 0:xs.interpreterArgs)||""),re((bs=s.pm2)!=null&&bs.env?Object.entries(s.pm2.env).map(([Y,He])=>`${Y}=${He}`).join(`
|
|
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 ba={enabled:!1,host:"",port:22,username:"",authMethod:"password"};function ja({dbConnections:r,setDbConnections:p,activeDbConnectionId:u,setActiveDbConnectionId:x}){const{t:n}=B(["terminal","common"]),[y,C]=m.useState({}),g=m.useRef(new Map);m.useEffect(()=>{const a=t=>{const o=t.detail;if(!o||!o.requestId)return;const i=g.current.get(o.requestId);i&&(g.current.delete(o.requestId),C(N=>({...N,[i]:o.success?{status:"success",serverVersion:o.serverVersion}:{status:"error",error:o.error||"Connection failed"}})))};return window.addEventListener("tide:db-test-result",a),()=>window.removeEventListener("tide:db-test-result",a)},[]);const v=(a,t)=>{const o=[...r];o[a]={...o[a],...t},p(o)},s=(a,t)=>{const i={...r[a].ssh??ba,...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(o=>({...o,[a.id]:{status:"testing"}})),D.testDatabaseConnectionTransient(t,a),window.setTimeout(()=>{g.current.has(t)&&(g.current.delete(t),C(o=>{const i=o[a.id];return(i==null?void 0:i.status)!=="testing"?o:{...o,[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 N,b,L,T,A,$,R,K,I,H,O;const o=y[a.id]??{status:"idle"},i=((N=a.ssh)==null?void 0:N.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(E=>E.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 E=d.target.value;v(t,{engine:E,port:Z[E].defaultPort})},children:Object.keys(Z).map(d=>e.jsxs("option",{value:d,children:[Z[d].icon," ",Z[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)||Z[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:((L=a.ssh)==null?void 0:L.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:((A=a.ssh)==null?void 0:A.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 E=d.target.value.trim();s(t,{localPort:E?parseInt(E):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:o.status==="testing",onClick:()=>h(a),children:o.status==="testing"?"Testing…":"Test Connection"}),o.status==="success"&&e.jsxs("span",{style:{color:"#4aff9e",fontSize:12},children:["✓ Connected",o.serverVersion?` — ${o.serverVersion}`:""]}),o.status==="error"&&e.jsxs("span",{style:{color:"#ff6b6b",fontSize:12},title:o.error,children:["✗ ",o.error]})]})]})]},a.id)}),r.length>0&&e.jsx("div",{className:"form-hint",children:n("terminal:building.dbAfterSaving")})]})}function ga({buildings:r,buildingId:p,subordinateBuildingIds:u,setSubordinateBuildingIds:x,isEditMode:n,showBossLogs:y,setShowBossLogs:C,currentBossLogs:g,bossLogsContainerRef:v}){const{t:s}=B(["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 va({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}=B(["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:o=>p(o.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:o=>x(o.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:o=>y(o.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:o=>g(o.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:o=>s(o.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 Na=[{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 fa({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:o}=B(["config"]),i=(s==null?void 0:s.status)==="running",N=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:o("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:o("config:buildings.terminalShell",{defaultValue:"Shell"})}),e.jsx("select",{className:"form-input",value:r,onChange:b=>p(b.target.value),children:Na.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:o("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:o("config:buildings.terminalSaveSession",{defaultValue:"Persist session (tmux)"})})]})}),e.jsxs("div",{style:{marginTop:"8px"},children:[e.jsx("label",{className:"form-sublabel",children:o("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:o("config:buildings.terminalControls",{defaultValue:"Terminal Controls"})}),N&&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:N.url})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"PID"}),e.jsx("span",{className:"runtime-value",children:N.pid})]}),e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Port"}),e.jsx("span",{className:"runtime-value",children:N.port})]}),N.tmuxSession&&e.jsxs("div",{className:"runtime-row",children:[e.jsx("span",{className:"runtime-label",children:"Session"}),e.jsx("span",{className:"runtime-value",children:N.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"]}),(N==null?void 0:N.url)&&e.jsxs(e.Fragment,{children:[a&&e.jsxs("button",{type:"button",className:"btn btn-sm btn-primary",onClick:()=>a(N.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 ka({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 wa({isOpen:r,onClose:p,buildingId:u,initialPosition:x}){const{t:n}=B(["config","common"]),{buildings:y,buildingLogs:C,bossStreamingLogs:g}=na(),v=la(),s=u?y.get(u):null,h=u?g.get(u)||[]:[],a=!!s,[t,o]=m.useState(""),[i,N]=m.useState("server"),[b,L]=m.useState("server-rack"),[T,A]=m.useState(""),[$,R]=m.useState(""),[K,I]=m.useState(""),[H,O]=m.useState(""),[d,E]=m.useState(""),[q,V]=m.useState(""),[k,_]=m.useState(""),[M,l]=m.useState([]),[S,U]=m.useState(!1),[z,Q]=m.useState(""),[W,X]=m.useState(1),[J,te]=m.useState(!1),[Ge,ne]=m.useState(""),[Ye,le]=m.useState(""),[We,ie]=m.useState(""),[Je,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,Ne]=m.useState(""),[fe,ke]=m.useState(""),[ye,Ce]=m.useState(""),[es,Se]=m.useState("unless-stopped"),[ss,we]=m.useState("missing"),[Pe,De]=m.useState(""),[Ee,ze]=m.useState(""),[Le,Ae]=m.useState(""),[Be,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),Ws=m.useRef(null),ee=m.useRef(null);m.useEffect(()=>{var c,f,w,G,ds,ms,us,ps,hs,xs,bs,js,gs,vs,Ns,fs,ks,ys,Cs,Ss,ws,Ps,Ds,Es,zs,Ls,As,Bs,Ts,Rs,Is,Os,_s;r&&(s?(o(s.name),N(s.type),L(s.style||"server-rack"),A(s.color||""),R(s.cwd||""),I(((c=s.commands)==null?void 0:c.start)||""),O(((f=s.commands)==null?void 0:f.stop)||""),E(((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||[]),Q(s.folderPath||""),X(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
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(((Ns=s.docker)==null?void 0:Ns.image)||""),xe(((fs=s.docker)==null?void 0:fs.containerName)||""),je(((ks=s.docker)==null?void 0:ks.ports)||[]),ve(((ys=s.docker)==null?void 0:ys.volumes)||[]),Ne((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)||""),ze(((zs=s.docker)==null?void 0:zs.composeProject)||""),Ae(((As=(Ls=s.docker)==null?void 0:Ls.services)==null?void 0:As.join(", "))||""),Te(s.subordinateBuildingIds||[]),Ie(((Bs=s.database)==null?void 0:Bs.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)||"")):(
|
|
8
|
-
`).map(f=>f.trim()).filter(f=>f&&f.includes("=")).map(f=>{const w=f.indexOf("=");return[f.slice(0,w),f.slice(w+1)]}))},Js=c=>{c.preventDefault();const f={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:z||void 0,commands:J?void 0:{start:K||void 0,stop:H||void 0,restart:d||void 0,healthCheck:q||void 0,logs:k||void 0},pm2:J?{enabled:!0,script:Ge,args:Ye||void 0,interpreter:We||void 0,interpreterArgs:Je||void 0,env:
|
|
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)||""),ze(((zs=s.docker)==null?void 0:zs.composeProject)||""),Ae(((As=(Ls=s.docker)==null?void 0:Ls.services)==null?void 0:As.join(", "))||""),Te(s.subordinateBuildingIds||[]),Ie(((Bs=s.database)==null?void 0:Bs.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)||"")):(o("New Server"),N("server"),L("server-rack"),A(""),R(ia(ra.LAST_CWD)),I(""),O(""),E(""),V(""),_(""),l([]),Q(""),X(1),te(!1),ne(""),le(""),ie(""),re(""),oe(""),de("container"),ue(""),pe(""),xe(""),je([]),ve([]),Ne(""),ke(""),Ce(""),Se("unless-stopped"),we("missing"),De(""),ze(""),Ae(""),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(()=>{ee.current&&(ee.current.scrollTop=ee.current.scrollHeight)},[C]),m.useEffect(()=>{i==="docker"&&P==="existing"&&D.requestDockerContainersList()},[i,P]);const rs=c=>{if(c.trim())return Object.fromEntries(c.trim().split(`
|
|
8
|
+
`).map(f=>f.trim()).filter(f=>f&&f.includes("=")).map(f=>{const w=f.indexOf("=");return[f.slice(0,w),f.slice(w+1)]}))},Js=c=>{c.preventDefault();const f={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:z||void 0,commands:J?void 0:{start:K||void 0,stop:H||void 0,restart:d||void 0,healthCheck:q||void 0,logs:k||void 0},pm2:J?{enabled:!0,script:Ge,args:Ye||void 0,interpreter:We||void 0,interpreterArgs:Je||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"&&fe?fe: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"&&Le?Le.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"&&Be.length>0?Be: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,f):D.createBuilding(f),p()},Zs=()=>{ce(!0)},Qs=()=>{u&&(D.deleteBuilding(u),ce(!1),p())},se=c=>{u&&(D.sendBuildingCommand(u,c),c==="logs"&&U(!0))},Xs=()=>{l([...M,{label:"",url:""}])},ea=c=>{l(M.filter((f,w)=>w!==c))},os=(c,f,w)=>{const G=[...M];G[c]={...G[c],[f]:w},l(G)},{handleMouseDown:sa,handleClick:aa}=oa(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:Js,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:c=>o(c.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(c=>e.jsxs("button",{type:"button",className:`building-type-btn ${i===c?"active":""}`,onClick:()=>{N(c),c==="database"&&b==="server-rack"&&L("filing-cabinet"),c==="tests"&&b==="server-rack"&&L("dome")},title:Ks[c].description,children:[e.jsx("span",{className:"building-type-icon",children:e.jsx(F,{name:Us(c),size:16})}),e.jsx("span",{className:"building-type-name",children:c})]},c))})]}),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(c=>e.jsxs("button",{type:"button",className:`building-style-btn ${b===c?"active":""}`,onClick:()=>L(c),title:Ue[c].description,children:[e.jsx("span",{className:"building-style-preview","data-style":c}),e.jsx("span",{className:"building-style-name",children:Ue[c].label})]},c))})]}),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:[ca.map(c=>e.jsx("button",{type:"button",className:`building-color-btn ${T===c.value?"active":""}`,onClick:()=>A(c.value),title:da(c.labelKey),style:c.value?{backgroundColor:c.value}:void 0,children:!c.value&&e.jsx("span",{className:"color-default-icon",children:e.jsx(F,{name:"gear",size:12})})},c.value||"default")),e.jsx("input",{type:"color",className:"building-color-picker",value:T||"#2a2a3a",onChange:c=>A(c.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:c=>{const f=parseFloat(c.target.value),w=.1*Math.pow(100,f/100);X(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(c=>e.jsxs("button",{type:"button",className:`size-preset-btn ${W===c?"active":""}`,onClick:()=>X(c),children:[c,"x"]},c))})]})]}),e.jsxs("div",{className:"form-section",children:[e.jsx("label",{className:"form-label",children:n("config:buildings.directory")}),e.jsx(ae,{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(ae,{value:z,onChange:Q,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(ae,{value:z,onChange:Q,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==="boss"&&e.jsx(ga,{buildings:y,buildingId:u,subordinateBuildingIds:Be,setSubordinateBuildingIds:Te,isEditMode:a,showBossLogs:Gs,setShowBossLogs:Ys,currentBossLogs:h,bossLogsContainerRef:Ws}),i==="database"&&e.jsx(ja,{dbConnections:Re,setDbConnections:Ie,activeDbConnectionId:as,setActiveDbConnectionId:Oe}),i==="server"&&e.jsx(pa,{usePM2:J,setUsePM2:te}),i==="server"&&e.jsx(ha,{usePM2:J,pm2Script:Ge,setPm2Script:ne,pm2Args:Ye,setPm2Args:le,pm2Interpreter:We,setPm2Interpreter:ie,pm2InterpreterArgs:Je,setPm2InterpreterArgs:re,pm2Env:Ze,setPm2Env:oe,isEditMode:a,building:s??null,handleCommand:se}),i==="docker"&&e.jsx(xa,{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:fe,setDockerNetwork:ke,dockerRestart:es,setDockerRestart:Se,dockerPull:ss,setDockerPull:we,dockerEnv:Xe,setDockerEnv:Ne,dockerComposePath:Pe,setDockerComposePath:De,dockerComposeProject:Ee,setDockerComposeProject:ze,dockerComposeServices:Le,setDockerComposeServices:Ae,selectedExistingContainer:me,setSelectedExistingContainer:ue,dockerContainersList:v,isEditMode:a,building:s??null,handleCommand:se}),i==="terminal"&&e.jsx(fa,{terminalShell:ts,setTerminalShell:_e,terminalPort:Me,setTerminalPort:Fe,terminalSaveSession:ns,setTerminalSaveSession:$e,terminalArgs:ls,setTerminalArgs:Ke,isEditMode:a,building:s??null,handleCommand:se,onOpenTerminal:()=>{s!=null&&s.id&&window.dispatchEvent(new CustomEvent("tide:open-iframe-modal",{detail:{buildingId:s.id}}))},onOpenBelow:c=>{window.dispatchEvent(new CustomEvent("tide:open-bottom-terminal",{detail:{buildingId:c}}))}}),i==="server"&&!J&&e.jsx(va,{startCmd:K,setStartCmd:I,stopCmd:H,setStopCmd:O,restartCmd:d,setRestartCmd:E,healthCheckCmd:q,setHealthCheckCmd:V,logsCmd:k,setLogsCmd:_,isEditMode:a,handleCommand:se}),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((c,f)=>e.jsxs("div",{className:"url-row",children:[e.jsx("input",{type:"text",className:"form-input url-label",value:c.label,onChange:w=>os(f,"label",w.target.value),placeholder:"Label"}),e.jsx("input",{type:"text",className:"form-input url-value",value:c.url,onChange:w=>os(f,"url",w.target.value),placeholder:"https://..."}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>ea(f),children:"x"})]},f))]}),a&&S&&cs.length>0&&e.jsx(ka,{logs:cs,buildingId:u,logsContainerRef:ee})]}),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(ua,{buildingName:s.name,onClose:()=>ce(!1),onConfirm:Qs})]})}export{wa as BuildingConfigModal};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as a,B as mn,E as Bt,G as Zt,H as Jt,j as e,J as Qt,K as fn,u as Rt,L as hn,M as gn,N as xn,O as bn,V as _n,P as wn,U as vn,W as Ft,S,X as Wt,Y as Dt,Z as Ht,_ as xt,$ as ge,a0 as Cn,s as b,a1 as en,a2 as tn,a3 as jn,w as Ut,x as Vt,I as p,a4 as Nn,n as kn,a5 as yn,a6 as nn,a7 as an,a8 as An,a9 as Sn,aa as En,ab as Mn,ac as In,ad as Tn,ae as Pn,af as Ln,ag as Dn,ah as Rn,ai as $n,aj as zn,ak as Xt,C as On,al as Bn,am as Gt,an as Fn,ao as Wn,ap as Hn,aq as Un,ar as Vn,as as Xn,at as Gn,au as qn,av as Yn,aw as Kn,ax as Zn,ay as Jn,az as Qn,aA as ea,aB as ta,aC as na,aD as aa,aE as sa}from"./main-D6Q3mJMF.js";import{g as ia}from"./area-logos-BJJ6AZC2.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function la(u){const r=a.useRef(u);r.current=u,a.useEffect(()=>{if(!mn())return;let m=null,h=!1;return Bt.addListener("backButton",()=>{r.current()==="exit"&&Bt.exitApp()}).then(N=>{h?N.remove():m=N}),()=>{h=!0,m&&(m.remove(),m=null)}},[])}async function ra(u){const r=Zt(),m=await fetch(`${Jt()}/api/agents/${u}/terminal`,{method:"POST",headers:{Authorization:`Bearer ${r}`}});if(!m.ok){const h=await m.json().catch(()=>({}));throw new Error((h==null?void 0:h.error)||`Failed to start terminal (${m.status})`)}return m.json()}async function oa(u){const r=Zt();await fetch(`${Jt()}/api/agents/${u}/terminal`,{method:"DELETE",headers:{Authorization:`Bearer ${r}`}})}const at=new Map;function ca({agentId:u}){const[r,m]=a.useState(null),[h,N]=a.useState(null);return a.useEffect(()=>{let P=!1;const M=at.get(u);return M&&(clearTimeout(M),at.delete(u)),m(null),N(null),ra(u).then(L=>{P||m(L.url)}).catch(L=>{P||N(L instanceof Error?L.message:"Failed to start terminal")}),()=>{P=!0;const L=at.get(u);L&&clearTimeout(L),at.set(u,setTimeout(()=>{at.delete(u),oa(u)},2500))}},[u]),h?e.jsx("div",{className:"flat-classic-terminal flat-classic-terminal--message",children:e.jsx("span",{children:h})}):r?e.jsx("div",{className:"flat-classic-terminal",children:e.jsx(Qt,{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 Pt=new Map,da=6e4;function ua({agentId:u,contextSummary:r}){const{t:m}=Rt(["terminal","common"]),[h,N]=a.useState(()=>{var I;return((I=Pt.get(u))==null?void 0:I.snapshot)??null}),[P,M]=a.useState(!1),[L,G]=a.useState(null),_=a.useRef(0);a.useEffect(()=>{const I=Pt.get(u);if(I&&Date.now()-I.fetchedAt<da){N(I.snapshot);return}const W=++_.current;M(!0),G(null),hn(u).then(U=>{W===_.current&&(Pt.set(u,{snapshot:U,fetchedAt:Date.now()}),N(U),M(!1))}).catch(U=>{W===_.current&&(G(U.message||"Failed to load plan limits"),M(!1))})},[u]);const F=[];if(h!=null&&h.rateLimits){const I=[{key:"fiveHour",label:m("terminal:usage.currentSession"),window:h.rateLimits.fiveHour},{key:"sevenDay",label:m("terminal:usage.currentWeekAll"),window:h.rateLimits.sevenDay},{key:"sevenDayOpus",label:m("terminal:usage.currentWeekOpus"),window:h.rateLimits.sevenDayOpus},{key:"sevenDaySonnet",label:m("terminal:usage.currentWeekSonnet"),window:h.rateLimits.sevenDaySonnet}];for(const W of I)W.window&&F.push({...W,window:W.window})}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:m("terminal:usage.limits")}),P&&!h&&e.jsxs("div",{className:"plan-limits-tooltip__muted",children:[m("common:status.loading"),"…"]}),!P&&L&&!h&&e.jsx("div",{className:"plan-limits-tooltip__muted",children:m("terminal:usage.limitsError",{message:L})}),F.length>0?e.jsx("div",{className:"plan-limits-tooltip__gauges",children:F.map(({key:I,label:W,window:U})=>{const xe=Math.max(0,Math.min(100,U.utilization)),Z=xn(xe);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:W}),e.jsx("span",{className:"plan-limits-tooltip__gauge-percent",style:{color:Z},children:m("terminal:usage.percentUsed",{percent:Math.round(xe)})})]}),e.jsx("div",{className:"plan-limits-tooltip__bar",children:e.jsx("div",{className:"plan-limits-tooltip__bar-fill",style:{width:`${xe}%`,background:Z}})}),e.jsx("div",{className:"plan-limits-tooltip__reset",children:m("terminal:usage.resets",{time:gn(U.resetsAt)})})]},I)})}):h&&!P&&e.jsx("div",{className:"plan-limits-tooltip__muted",children:h.rateLimitsError?m("terminal:usage.limitsError",{message:h.rateLimitsError}):h.cliHint})]})}function pa({agentId:u,disabled:r,contextSummary:m,children:h}){return e.jsx(fn,{position:"top",maxWidth:320,disabled:r,className:"plan-limits-tooltip-wrapper",triggerStyle:{display:"inline-flex",alignItems:"center"},content:e.jsx(ua,{agentId:u,contextSummary:m}),children:h})}const ma=a.memo(function({className:r=""}){const{t:m}=Rt(["common"]),[h,N]=bn(),P=a.useRef(null),[M,L]=a.useState(null);a.useLayoutEffect(()=>{const _=P.current;if(!_)return;const F=_.querySelector(".view-mode-toggle__btn--active");F&&L({left:F.offsetLeft,width:F.offsetWidth})},[h]);const G=a.useCallback(_=>{if(_!==h){if(typeof window<"u"&&window.dispatchEvent(new CustomEvent("tide:viewmode-switch-pressed",{detail:{mode:_}})),_==="3d"){requestAnimationFrame(()=>N(_));return}N(_)}},[h,N]);return e.jsxs("div",{className:`view-mode-toggle ${r}`,ref:P,children:[M&&e.jsx("div",{className:"view-mode-toggle__indicator",style:{left:M.left,width:M.width}}),_n.map(_=>e.jsxs("button",{className:`view-mode-toggle__btn ${h===_?"view-mode-toggle__btn--active":""}`,onClick:()=>G(_),title:m(`common:viewMode.descriptions.${_}`),children:[e.jsxs("span",{className:"view-mode-toggle__icon",children:[_==="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"})]}),_==="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"})]}),_==="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"})]}),_==="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:m(`common:viewMode.labels.${_}`)})]},_))]})}),bt=3,_t=280,qt=320,Lt=240,Yt=64,fa=["simple","chat","advanced"],ha={simple:"Simple",chat:"Chat",advanced:"Advanced"},ga={simple:"○",chat:"◐",advanced:"◉"},xa={simple:"Simple view — clean messages only",chat:"Chat view — assistant replies (no tool calls)",advanced:"Advanced view — everything including tools"},Kt="flat-clear-context";function ba(u){const r=u.split("/").filter(Boolean);return r.length===0?u:r.slice(-2).join("/")}function _a(u){if(u.provider==="codex"){const P=u.codexModel||"gpt-5.3-codex",M=na[P];return{model:(M==null?void 0:M.label)||P}}if(u.provider==="opencode")return{model:u.opencodeModel||"opencode"};const r=u.model||"sonnet",m=sa[r],h=u.effort,N=h?aa[h]:void 0;return{model:(m==null?void 0:m.label)||r,effort:N==null?void 0:N.label}}function wa(u,r){if(r.type==="rectangle"&&r.width&&r.height){const m=r.width/2,h=r.height/2;return u.x>=r.center.x-m&&u.x<=r.center.x+m&&u.z>=r.center.z-h&&u.z<=r.center.z+h}if(r.type==="circle"&&r.radius){const m=u.x-r.center.x,h=u.z-r.center.z;return m*m+h*h<=r.radius*r.radius}return!1}const va=Bn.memo(function({agentId:r,terminalViewMode:m,onTerminalViewModeChange:h,inspectorOpen:N,onToggleInspector:P,onImageClick:M,onFileClick:L,onBashClick:G,onViewMarkdown:_,onRequestClearSubordinates:F,onOpenBuilding:I,keyboard:W,canNavigateBack:U,canNavigateForward:xe,onNavigateBack:Z,onNavigateForward:be,agentInfoOpen:Ee,onToggleAgentInfo:st,onHeaderContextMenu:ae,onBuildingContextMenu:_e}){var ut,pt,K,Ye;const f=Gt(r),H=tn(),we=Fn(),Me=a.useRef(null),We=a.useRef(null),{displayedAgentId:ve,fadingOut:wt}=Wn(r),it=Gt(ve),He=!!we.interactiveMode&&((f==null?void 0:f.provider)??"claude")==="claude"&&!!(f!=null&&f.sessionId),[J,Ue]=a.useState(!1);a.useEffect(()=>{Ue(!1)},[r]),a.useEffect(()=>{!He&&J&&Ue(!1)},[He,J]),a.useEffect(()=>{const s=We.current;if(!s)return;const l=d=>{d.button===3?(d.preventDefault(),d.stopPropagation(),Z()):d.button===4&&(d.preventDefault(),d.stopPropagation(),be())},c=d=>{(d.button===3||d.button===4)&&d.preventDefault()};return s.addEventListener("mouseup",l),s.addEventListener("mousedown",c),()=>{s.removeEventListener("mouseup",l),s.removeEventListener("mousedown",c)}},[Z,be]),a.useEffect(()=>{const s=We.current;if(!s)return;let l=0,c=0,d=0;const Se=250,ze=600,Ke=80,he=1.5,Et=X=>{let R=X instanceof HTMLElement?X:null;for(;R&&R!==s;){const Ze=window.getComputedStyle(R).overflowX;if((Ze==="auto"||Ze==="scroll")&&R.scrollWidth>R.clientWidth)return!0;R=R.parentElement}return!1},Oe=X=>{const R=Date.now();if(R<d){X.preventDefault();return}if(Math.abs(X.deltaX)<=Math.abs(X.deltaY)*he){l=0;return}if(Et(X.target)){l=0;return}R-c>Se&&(l=0),c=R,l+=X.deltaX,l<=-Ke?(l=0,d=R+ze,X.preventDefault(),Z()):l>=Ke&&(l=0,d=R+ze,X.preventDefault(),be())};return s.addEventListener("wheel",Oe,{passive:!1}),()=>s.removeEventListener("wheel",Oe)},[Z,be]);const Ce=en(),se=a.useMemo(()=>{if(!f)return null;const s=new Set,l=[];for(const c of Ce.values())c.archived||c.directories.length===0||c.assignedAgentIds.includes(r)&&(s.add(c.id),l.push(c));for(const c of Ce.values())c.archived||c.directories.length===0||s.has(c.id)||wa({x:f.position.x,z:f.position.z},c)&&(s.add(c.id),l.push(c));return l.length===0?null:l.flatMap(c=>c.directories.filter(d=>d&&d.trim().length>0).map(d=>({areaId:c.id,areaName:c.name,dir:d})))},[f,r,Ce]),{branches:ie,fetchRemote:le,fetchingDirs:lt}=Hn(se),Ve=a.useMemo(()=>{var c;const s=b.getAreaForAgent(r);if(!s)return[];const l=[];for(const d of H.values())d.type==="terminal"&&b.isPositionInArea(d.position,s)&&l.push({id:d.id,name:d.name,hasUrl:!!((c=d.terminalStatus)!=null&&c.url)});return l},[r,H]),Ie=a.useMemo(()=>{var c;const s=b.getAreaForAgent(r);if(!s)return[];const l=[];for(const d of H.values())d.type==="server"&&((c=d.pm2)!=null&&c.enabled)&&b.isPositionInArea(d.position,s)&&l.push({id:d.id,name:d.name});return l},[r,H]),je=a.useMemo(()=>{const s=b.getAreaForAgent(r);if(!s)return[];const l=[];for(const c of H.values())c.type==="database"&&c.database&&b.isPositionInArea(c.position,s)&&l.push({id:c.id,name:c.name});return l},[r,H]),Ne=Un(),Te=a.useMemo(()=>{const s=b.getAreaForAgent(r);if(!s)return[];const l=[];for(const c of H.values())if(c.type==="tests"&&b.isPositionInArea(c.position,s)){const d=!!c.folderPath&&Ne.some(Se=>Vn(Se,c.folderPath));l.push({id:c.id,name:c.name,working:d})}return l},[r,H,Ne]),[,Q]=a.useReducer(s=>s+1,0),re=((ut=Me.current)==null?void 0:ut.search.searchMode)??!1,ke=a.useCallback(()=>{var s;(s=Me.current)==null||s.search.toggleSearch(),Q()},[]),oe=Xn(),Je=oe.isPending(Kt),[ye,Pe]=a.useState(null),q=ye?H.get(ye):null,{height:vt,onResizeStart:Ct}=Gn(),{sidePanelWidth:Le,handleSidePanelResizeStart:jt}=qn(),[Ae,rt]=a.useState(()=>Dt(S.GIT_PANEL_OPEN,!1)),[ce,ot]=a.useState(()=>Dt(S.BUILDINGS_PANEL_OPEN,!1)),[De,ct]=a.useState(!1),Nt=a.useCallback(()=>{ct(s=>{const l=!s;return l&&Yn.setEnabled(!0),l})},[]),kt=a.useCallback(()=>ct(!1),[]),yt=a.useCallback(()=>{rt(s=>{const l=!s;return ge(S.GIT_PANEL_OPEN,l),l})},[]),Xe=a.useCallback(()=>{ot(s=>{const l=!s;return ge(S.BUILDINGS_PANEL_OPEN,l),l})},[]),v=a.useCallback(()=>{rt(!1),ge(S.GIT_PANEL_OPEN,!1)},[]),de=a.useCallback(()=>{ot(!1),ge(S.BUILDINGS_PANEL_OPEN,!1)},[]),Y=Kn();a.useEffect(()=>{if(!ye)return;Ve.some(l=>l.id===ye)||Pe(null)},[ye,Ve]);const[ee,ue]=a.useState(!1),Qe=a.useRef(null);if(a.useEffect(()=>{if(!ee)return;const s=l=>{Qe.current&&!Qe.current.contains(l.target)&&ue(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[ee]),!f)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 pe=f.contextStats,et=!!pe,dt=pe?pe.totalTokens:f.contextUsed||0,Ge=pe?pe.contextWindow:f.contextLimit||2e5,Re=pe?pe.usedPercent:Math.round(dt/Ge*100),te=Math.max(0,Math.min(100,Re)),me=Math.round(te*10)/10,At=Math.round((100-te)*10)/10,V=te>=80?"#ff4a4a":te>=60?"#ff9e4a":te>=40?"#ffd700":"#4aff9e",ne=(dt/1e3).toFixed(1),tt=(Ge/1e3).toFixed(1),fe=f.cwd,qe=fe?ba(fe):null,$e=((pt=f.subordinateIds)==null?void 0:pt.length)||0,St=$e>0;return e.jsxs("div",{ref:We,className:`flat-terminal-wrapper ${Ae||ce||De?"flat-terminal-wrapper--with-side-panel":""} ${wt?"pane-fading-out":""}`,style:{"--guake-side-panel-width":`min(${Le}px, 70%)`},children:[e.jsxs("div",{className:"flat-terminal-wrapper__header",children:[e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__header-main ${Ee?"flat-terminal-wrapper__header-main--active":""}`,onClick:st,onContextMenu:s=>{s.preventDefault(),s.stopPropagation(),ae({x:s.clientX,y:s.clientY})},title:Ee?"Hide agent info":"Show agent info","aria-pressed":Ee,children:[e.jsx(nn,{agent:f,size:28}),e.jsxs("span",{className:"flat-terminal-wrapper__header-info",children:[e.jsx("span",{className:"flat-terminal-wrapper__header-name",children:f.name}),e.jsx("span",{className:"flat-terminal-wrapper__header-status",style:{color:an(f.status)},children:f.status})]}),f.taskLabel&&e.jsxs("span",{className:"flat-terminal-wrapper__header-task",title:f.taskLabel,children:["📋 ",f.taskLabel]}),e.jsxs("span",{className:"flat-terminal-wrapper__header-model",children:[e.jsx("img",{src:f.provider==="codex"?"/assets/codex.png":f.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:f.provider,className:"flat-terminal-wrapper__header-provider-icon",title:f.provider==="codex"?"Codex Agent":f.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),(()=>{const{model:s,effort:l}=_a(f);return e.jsxs("span",{className:"flat-terminal-wrapper__header-model-chip",title:l?`Model: ${s} · Effort: ${l}`:`Model: ${s}`,children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-name",children:s}),l&&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:l})]})]})})()]})]}),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:[fa.map(s=>e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${!J&&m===s?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>{Ue(!1),h(s)},title:xa[s],"aria-pressed":!J&&m===s,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:ga[s]}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:ha[s]})]},s)),He&&e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${J?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>Ue(s=>!s),title:"Classic TUI — attach to the live interactive claude session in a terminal","aria-pressed":J,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:e.jsx(p,{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:Z,disabled:!U,title:"Back to previous agent","aria-label":"Back to previous agent",children:e.jsx(p,{name:"arrow-left",size:14})}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:be,disabled:!xe,title:"Forward to next agent","aria-label":"Forward to next agent",children:e.jsx(p,{name:"arrow-right",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${re?"flat-terminal-wrapper__action-btn--active":""}`,onClick:ke,title:re?"Close search":"Search messages","aria-pressed":re,children:e.jsx(p,{name:re?"cross":"search",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn flat-terminal-wrapper__action-btn--danger ${Je?"flat-terminal-wrapper__action-btn--confirm":""}`,onClick:()=>oe.handleClick(Kt,()=>{var s;b.clearContext(r),(s=Me.current)==null||s.historyLoader.clearHistory()}),title:Je?"Click again to confirm clear context":"Clear context",children:e.jsx(p,{name:Je?"question":"clear",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${Ae?"flat-terminal-wrapper__action-btn--active":""}`,onClick:yt,title:Ae?"Hide git panel":"Show git changes","aria-pressed":Ae,children:e.jsx(p,{name:"git-branch",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${ce?"flat-terminal-wrapper__action-btn--active":""}`,onClick:Xe,title:ce?"Hide buildings panel":"Show area buildings","aria-pressed":ce,children:e.jsx(p,{name:"buildings",size:14})}),e.jsxs("div",{className:"flat-terminal-wrapper__more",ref:Qe,children:[e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${ee?"flat-terminal-wrapper__action-btn--active":""}`,onClick:()=>ue(s=>!s),title:"More actions","aria-expanded":ee,children:"⋮"}),ee&&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 ${De?"flat-terminal-wrapper__more-item--active":""}`,onClick:()=>{Nt(),ue(!1)},title:De?"Hide Debug Panel":"Show Debug Panel",children:[e.jsx(p,{name:"bug",size:14}),e.jsx("span",{children:De?"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:()=>{b.collapseContext(r),ue(!1)},disabled:f.status!=="idle",title:f.status!=="idle"?"Agent must be idle to collapse context":"Collapse context",children:[e.jsx(p,{name:"package",size:14}),e.jsx("span",{children:"Collapse context"})]}),St&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{F(r,$e),ue(!1)},children:[e.jsx(p,{name:"crown",size:14}),e.jsxs("span",{children:["Clear ",$e," subordinate",$e===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:()=>{b.killAgent(r),ue(!1)},children:[e.jsx(p,{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:P,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:()=>b.deselectAll(),title:"Close chat","aria-label":"Close chat",children:e.jsx(p,{name:"cross",size:14})})]})]}),J&&He?e.jsx(ca,{agentId:r}):ve&&it?e.jsx(Zn,{ref:Me,agentId:ve,agent:it,viewMode:m,isOpen:!0,onImageClick:M,onFileClick:L,onBashClick:G,onViewMarkdown:_,keyboard:W,hasModalOpen:!1},ve):null,q&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:Ct,role:"separator","aria-orientation":"horizontal","aria-label":"Resize embedded terminal"}),e.jsxs("div",{className:"flat-bottom-panel",role:"region","aria-label":`Embedded terminal: ${q.name}`,style:{height:vt},children:[e.jsxs("div",{className:"flat-bottom-panel__header",children:[e.jsxs("span",{className:"flat-bottom-panel__title",children:[e.jsx(p,{name:"terminal",size:12}),e.jsx("span",{children:q.name}),!((K=q.terminalStatus)!=null&&K.url)&&e.jsx("span",{className:"flat-bottom-panel__muted",children:"(starting...)"})]}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>Pe(null),title:"Close embedded terminal","aria-label":"Close embedded terminal",children:e.jsx(p,{name:"cross",size:12})})]}),e.jsx("div",{className:"flat-bottom-panel__body",children:(Ye=q.terminalStatus)!=null&&Ye.url?e.jsx(Qt,{terminalUrl:q.terminalStatus.url,visible:!0}):e.jsx("div",{className:"flat-bottom-panel__placeholder",children:"Starting terminal..."})})]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__statusbar",role:"contentinfo",children:[f.isDetached&&e.jsxs("span",{className:"flat-terminal-wrapper__detached",title:"Reattaching session...",children:[e.jsx(p,{name:"refresh",size:12}),e.jsx("span",{children:"Reattaching"})]}),fe&&qe&&e.jsxs("span",{className:"flat-terminal-wrapper__cwd",title:`Open in file explorer: ${fe}`,"aria-label":`Open ${fe} in file explorer`,role:"button",tabIndex:0,onClick:()=>b.openFileExplorer(fe),onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),b.openFileExplorer(fe))},children:[e.jsx("span",{className:"flat-terminal-wrapper__cwd-icon",children:e.jsx(p,{name:"folder",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__cwd-text",children:qe})]}),se&&se.map(({areaId:s,areaName:l,dir:c})=>{const d=ie.get(c),Se=lt.has(c),ze=c.split("/").filter(Boolean).pop()||c;return e.jsxs("span",{className:"flat-terminal-wrapper__area-dir",title:`${l}: ${c}${d?` (${d.branch}${d.ahead?` ↑${d.ahead}`:""}${d.behind?` ↓${d.behind}`:""})`:""}`,onClick:()=>b.openFileExplorerForAreaFolder(s,c),children:[e.jsx(p,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-terminal-wrapper__area-dir-name",children:ze}),d&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flat-terminal-wrapper__area-dir-branch",children:[e.jsx(p,{name:"git-branch",size:10})," ",d.branch]}),d.ahead>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-ahead",title:`${d.ahead} ahead`,children:[e.jsx(p,{name:"arrow-up",size:9}),d.ahead]}),d.behind>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-behind",title:`${d.behind} behind`,children:[e.jsx(p,{name:"arrow-down",size:9}),d.behind]}),e.jsx("span",{className:`flat-terminal-wrapper__area-fetch ${Se?"flat-terminal-wrapper__area-fetch--fetching":""}`,title:"Git fetch",onClick:Ke=>{Ke.stopPropagation(),le(c)},children:e.jsx(p,{name:Se?"hourglass":"download",size:12})})]})]},`${s}:${c}`)}),e.jsx(pa,{agentId:r,disabled:((f==null?void 0:f.provider)??"claude")!=="claude",contextSummary:et?`Context: ${ne}k / ${tt}k tokens (${me}% used)`:void 0,children:e.jsxs("span",{className:"flat-terminal-wrapper__context",tabIndex:0,role:"button",onClick:()=>b.setContextModalAgentId(r),onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),b.setContextModalAgentId(r))},title:((f==null?void 0:f.provider)??"claude")!=="claude"?et?`Context usage: ${ne}k / ${tt}k tokens (${me}% 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(p,{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:`${te}%`,backgroundColor:V}})}),e.jsxs("span",{className:"flat-terminal-wrapper__context-tokens",style:{color:V},children:[ne,"k/",tt,"k"]}),e.jsxs("span",{className:"flat-terminal-wrapper__context-free",children:["(",At,"% free)"]}),!et&&e.jsx("span",{className:"flat-terminal-wrapper__context-warning",title:"No context stats yet",children:e.jsx(p,{name:"warn",size:12})})]})}),e.jsx("div",{className:"flat-terminal-wrapper__statusbar-spacer","aria-hidden":"true"}),Ve.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area terminals",children:Ve.map(s=>{const l=ye===s.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${l?"flat-terminal-wrapper__building-btn--active":""} ${s.hasUrl?"":"flat-terminal-wrapper__building-btn--offline"}`,title:`${l?"Hide":"Show"} terminal: ${s.name}${s.hasUrl?"":" (starting...)"}`,onClick:()=>{if(l){Pe(null);return}s.hasUrl||b.sendBuildingCommand(s.id,"start"),Pe(s.id)},onContextMenu:c=>{c.preventDefault(),c.stopPropagation(),_e(s.id,{x:c.clientX,y:c.clientY})},children:e.jsx(p,{name:"terminal",size:14})},s.id)})}),Ie.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area PM2 logs",children:Ie.map(s=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open logs: ${s.name}`,onClick:()=>I(s.id),onContextMenu:l=>{l.preventDefault(),l.stopPropagation(),_e(s.id,{x:l.clientX,y:l.clientY})},children:e.jsx(p,{name:"scroll",size:14})},s.id))}),je.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area databases",children:je.map(s=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open database: ${s.name}`,onClick:()=>I(s.id),onContextMenu:l=>{l.preventDefault(),l.stopPropagation(),_e(s.id,{x:l.clientX,y:l.clientY})},children:e.jsx(p,{name:"hard-drives",size:14})},s.id))}),Te.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area tests",children:Te.map(s=>e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${s.working?"flat-terminal-wrapper__building-btn--tests-working":""}`,title:s.working?`Running tests: ${s.name}`:`Open tests: ${s.name}`,onClick:()=>I(s.id),onContextMenu:l=>{l.preventDefault(),l.stopPropagation(),_e(s.id,{x:l.clientX,y:l.clientY})},children:e.jsx(p,{name:"flask",size:14})},s.id))}),e.jsx("div",{className:"flat-terminal-wrapper__theme",children:e.jsx(Jn,{})})]}),Ae&&e.jsx(Qn,{agentId:r,agents:Y,onClose:v,branchInfoMap:ie,fetchRemote:le,fetchingDirs:lt,onResizeStart:s=>jt(s,"right")}),ce&&e.jsx(ea,{agentId:r,onClose:de}),De&&e.jsx(ta,{agentId:r,onClose:kt})]})});function ya({onAgentClick:u,onBuildingClick:r,onBuildingDoubleClick:m,onBuildingPopup:h,onAreaContextMenu:N,onOpenSpawnModal:P,onOpenBossSpawnModal:M,onOpenAreaModal:L}){const{t:G}=Rt(["common"]),_=wn(),F=vn(),[I,W]=a.useState(null),[U,xe]=a.useState(null),[Z,be]=a.useState(null),[Ee,st]=a.useState(null),[ae,_e]=a.useState(null),[f,H]=a.useState(null),[we,Me]=a.useState(null),[We,ve]=a.useState(!1),wt=a.useCallback(()=>{ve(t=>!t)},[]),it=a.useCallback(()=>{ve(!1)},[]),[He,J]=a.useState(()=>{const t=Ft(S.VIEW_MODE);return t==="simple"||t==="chat"||t==="advanced"?t:"simple"}),Ue=a.useCallback(t=>{J(t),Wt(S.VIEW_MODE,t)},[]);a.useEffect(()=>{const t=n=>{if(n.key!==S.VIEW_MODE)return;const i=n.newValue;(i==="simple"||i==="chat"||i==="advanced")&&J(i)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const[Ce,se]=a.useState(()=>Dt(S.FLAT_INSPECTOR_OPEN,!1)),[ie,le]=a.useState(!1),lt=a.useCallback(()=>le(t=>!t),[]),Ve=a.useCallback(()=>le(!1),[]);a.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-agents-drawer-state",{detail:{open:ie}}))},[ie]),a.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-inspector-state",{detail:{open:Ce}}))},[Ce]),a.useEffect(()=>{const t=()=>le(C=>!C),n=()=>{se(C=>{const k=!C;return ge(S.FLAT_INSPECTOR_OPEN,k),k})},i=()=>{le(!1),se(!1),ge(S.FLAT_INSPECTOR_OPEN,!1)},g=()=>le(!1),x=()=>{se(!1),ge(S.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",i),window.addEventListener("tide-close-flat-agents-drawer-only",g),window.addEventListener("tide-close-flat-inspector-only",x),()=>{window.removeEventListener("tide-toggle-flat-agents-drawer",t),window.removeEventListener("tide-toggle-flat-inspector",n),window.removeEventListener("tide-close-flat-side-views",i),window.removeEventListener("tide-close-flat-agents-drawer-only",g),window.removeEventListener("tide-close-flat-inspector-only",x)}},[]);const Ie=a.useRef(null),je=a.useRef(null),[Ne,Te]=a.useState(()=>{const t=Ht(S.FLAT_MIDDLE_WIDTH,0);return t>=_t?t:null}),[Q,re]=a.useState(()=>{const t=Ht(S.FLAT_INSPECTOR_WIDTH,0);return t>=Lt?t:null}),ke=a.useCallback(t=>{if(typeof window>"u")return t;const n=Q!==null?bt+Q:0,i=window.innerWidth-Yt-bt-qt-n;return Math.max(_t,Math.min(Math.max(i,_t),t))},[Q]),oe=a.useCallback(t=>{var x;if(typeof window>"u")return t;const n=(x=Ie.current)==null?void 0:x.querySelector(".flat-middle"),i=(n==null?void 0:n.getBoundingClientRect().width)??_t,g=window.innerWidth-Yt-i-bt-qt-bt;return Math.max(Lt,Math.min(Math.max(g,Lt),t))},[]);a.useEffect(()=>{if(Ne===null&&Q===null)return;const t=()=>{Te(n=>{if(n===null)return n;const i=ke(n);return i===n?n:i}),re(n=>{if(n===null)return n;const i=oe(n);return i===n?n:i})};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[Ne,Q,ke,oe]);const Je=a.useCallback(t=>{var i;if(t.button!==0)return;const n=(i=Ie.current)==null?void 0:i.querySelector(".flat-middle");n&&(t.currentTarget.setPointerCapture(t.pointerId),je.current={kind:"middle",startX:t.clientX,startWidth:n.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),ye=a.useCallback(t=>{var i;if(t.button!==0)return;const n=(i=Ie.current)==null?void 0:i.querySelector(".flat-inspector");n&&(t.currentTarget.setPointerCapture(t.pointerId),je.current={kind:"inspector",startX:t.clientX,startWidth:n.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),Pe=a.useCallback(t=>{const n=je.current;if(!n||t.pointerId!==n.pointerId)return;const i=t.clientX-n.startX;n.kind==="middle"?Te(ke(n.startWidth+i)):re(oe(n.startWidth-i))},[ke,oe]),q=a.useCallback(t=>{const n=je.current;if(!n||t.pointerId!==n.pointerId)return;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}if(je.current=null,document.body.classList.remove("flat-splitter-dragging"),!(Math.abs(t.clientX-n.startX)>2))return;const g=t.clientX-n.startX;if(n.kind==="middle"){const x=ke(n.startWidth+g);Te(x),xt(S.FLAT_MIDDLE_WIDTH,x)}else{const x=oe(n.startWidth-g);re(x),xt(S.FLAT_INSPECTOR_WIDTH,x)}},[ke,oe]),vt=a.useCallback(()=>{Te(null),xt(S.FLAT_MIDDLE_WIDTH,0)},[]),Ct=a.useCallback(()=>{re(null),xt(S.FLAT_INSPECTOR_WIDTH,0)},[]),[Le,jt]=a.useState(()=>Ft(S.FLAT_INSPECTOR_VIEW)==="tracking"?"tracking":"agent"),Ae=a.useCallback(t=>{jt(t),Wt(S.FLAT_INSPECTOR_VIEW,t)},[]),rt=a.useCallback(()=>{se(t=>{const n=!t;return ge(S.FLAT_INSPECTOR_OPEN,n),n})},[]),ce=a.useCallback(()=>{se(!1),ge(S.FLAT_INSPECTOR_OPEN,!1)},[]),ot=Cn(),De=a.useCallback((t,n)=>{W({url:t,name:n})},[]),ct=a.useCallback((t,n)=>{xe({command:t,output:n,isLive:!1})},[]),Nt=a.useCallback((t,n)=>{b.setFileViewerPath(t,n)},[]),kt=a.useCallback(t=>{be(t)},[]),yt=a.useCallback((t,n)=>{st({agentId:t,count:n})},[]),Xe=a.useCallback(t=>{m?m(t):r(t)},[r,m]),v=a.useMemo(()=>F.size>0?Array.from(F)[0]:null,[F]);a.useEffect(()=>{ve(!1)},[v]);const de=a.useRef([]),Y=a.useRef(-1),ee=a.useRef(!1),ue=a.useRef(null),[Qe,pe]=a.useState(!1),[et,dt]=a.useState(!1),Ge=a.useRef(!1),Re=a.useRef(null),te=a.useRef(!1),me=a.useMemo(()=>new Set(_.map(t=>t.id)),[_]),At=a.useMemo(()=>{const t=new Map(_.map(i=>[i.id,i])),n=new Map;for(const i of _)if((i.isBoss||i.class==="boss")&&i.subordinateIds&&i.subordinateIds.length>0){const g=i.subordinateIds.map(x=>t.get(x)).filter(x=>x!==void 0);g.length>0&&n.set(i.id,g)}return n},[_]),V=a.useCallback(()=>{const t=de.current,n=Y.current;pe(n>0),dt(n>=0&&n<t.length-1)},[]),ne=a.useCallback(t=>{const n=de.current;if(n.length===0)return;let i=Y.current+t;for(;i>=0&&i<n.length;){const g=n[i];if(me.has(g)){ee.current=!0,Y.current=i,V(),b.selectAgent(g);return}i+=t}},[me,V]),tt=a.useCallback(()=>ne(-1),[ne]),fe=a.useCallback(()=>ne(1),[ne]);la(a.useCallback(()=>{const t=de.current,n=Y.current;return t.length>0&&n>0?(ne(-1),"handled"):"exit"},[ne]));const qe=a.useCallback((t,n)=>{if(typeof window>"u")return;const i=window.history.state,x={...typeof i=="object"&&i!==null?i:{},__flatAgentNav:{agentId:t}};n==="replace"?window.history.replaceState(x,"",window.location.href):window.history.pushState(x,"",window.location.href)},[]);a.useEffect(()=>{if(!v){Ge.current=!1,Re.current=null;return}if(!Ge.current){qe(v,"replace"),Ge.current=!0,Re.current=v;return}if(te.current){te.current=!1,Re.current=v;return}Re.current!==v&&(qe(v,"push"),Re.current=v)},[v,qe]),a.useEffect(()=>{const t=n=>{var C,k;const i=(k=(C=n.state)==null?void 0:C.__flatAgentNav)==null?void 0:k.agentId;if(!i||typeof i!="string"||!me.has(i)||i===v)return;te.current=!0,ee.current=!0;const g=de.current,x=g.lastIndexOf(i);x>=0?Y.current=x:(g.push(i),Y.current=g.length-1),V(),b.selectAgent(i)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[me,v,V]),a.useEffect(()=>{if(!v){de.current=[],Y.current=-1,V();return}if(ue.current=v,ee.current){ee.current=!1,V();return}const t=de.current,n=Y.current;if(n>=0&&t[n]===v){V();return}const i=n<t.length-1?t.slice(0,n+1):t.slice();i.push(v),i.length>100&&i.shift(),de.current=i,Y.current=i.length-1,V()},[v,V]);const $e=a.useCallback(t=>{u(t),le(!1)},[u]),St=v??"",ut=a.useCallback(()=>{},[]),pt=a.useCallback(t=>{$e(t)},[$e]),K=Ce,[Ye,s]=a.useState(K),[l,c]=a.useState(K);a.useEffect(()=>{if(K){s(!0);return}c(!1);const t=setTimeout(()=>s(!1),240);return()=>clearTimeout(t)},[K]),a.useEffect(()=>{if(!Ye||!K)return;let t=0;const n=requestAnimationFrame(()=>{t=requestAnimationFrame(()=>c(!0))});return()=>{cancelAnimationFrame(n),cancelAnimationFrame(t)}},[Ye,K]);const d=a.useRef(null);a.useEffect(()=>{if(v)return;const t=n=>{if(n.key!==" "&&n.key!=="Backspace")return;const i=n.target;if(i.tagName==="INPUT"||i.tagName==="TEXTAREA"||i.isContentEditable)return;const g=ue.current;!g||!me.has(g)||(n.preventDefault(),b.selectAgent(g))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[v,me]);const[Se,ze]=a.useState(new Set),Ke=a.useCallback(t=>{ze(n=>{const i=new Set(n);return i.has(t)?i.delete(t):i.add(t),i})},[]),[he,Et]=a.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches);a.useEffect(()=>{if(typeof window>"u")return;const t=window.matchMedia("(max-width: 768px)"),n=i=>Et(i.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[]);const[Oe,X]=a.useState(null),R=a.useCallback(t=>{X(n=>n===t?null:t)},[]),Ze=en(),mt=tn(),[sn]=jn(),Be=a.useMemo(()=>{const t=new Map,n=[];for(const w of _){const A=b.getAreaForAgent(w.id);if(!Ut((A==null?void 0:A.id)??null))continue;if(!A||A.archived){n.push(w);continue}const E=t.get(A.id);E?E.push(w):t.set(A.id,[w])}const i=new Map,g=[];for(const w of mt.values()){let A=!1;for(const E of Ze.values())if(!E.archived&&Vt(E.id)&&b.isPositionInArea(w.position,E)){const z=i.get(E.id);z?z.push(w):i.set(E.id,[w]),A=!0;break}!A&&Ut(null)&&g.push(w)}const x=[];for(const[,w]of Ze){if(w.archived||!Vt(w.id))continue;const A=t.get(w.id),E=i.get(w.id)??[];(A&&A.length>0||E.length>0)&&x.push({area:w,agents:A??[],buildings:E})}(n.length>0||g.length>0)&&x.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:g});const C=x.filter(w=>w.area.id!=="__unassigned__"),k=x.filter(w=>w.area.id==="__unassigned__");let o=1,y=1;const $=new Map;if(C.length>1){let w=1/0,A=-1/0,E=1/0,z=-1/0;for(const O of C)w=Math.min(w,O.area.center.x),A=Math.max(A,O.area.center.x),E=Math.min(E,O.area.center.z),z=Math.max(z,O.area.center.z);const ft=A-w||1,ht=z-E||1;if(C.length<=4){o=C.length,y=1;const O=[...C].sort((B,Mt)=>B.area.center.x-Mt.area.center.x);for(let B=0;B<O.length;B++)$.set(O[B].area.id,{row:1,col:B+1})}else{const O=[...C].sort((j,D)=>j.area.center.x-D.area.center.x),B=[];for(let j=1;j<O.length;j++)B.push(O[j].area.center.x-O[j-1].area.center.x);const Mt=B.reduce((j,D)=>j+D,0)/B.length||1;let $t=1;for(const j of B)j>Mt*1.3&&$t++;o=Math.max(2,Math.min($t,C.length));const It=[...C].sort((j,D)=>j.area.center.z-D.area.center.z),gt=[];for(let j=1;j<It.length;j++)gt.push(It[j].area.center.z-It[j-1].area.center.z);const cn=gt.reduce((j,D)=>j+D,0)/gt.length||1;let zt=1;for(const j of gt)j>cn*1.3&&zt++;y=Math.max(2,Math.min(zt,C.length)),o=Math.max(o,Math.ceil(C.length/y)),y=Math.max(y,Math.ceil(C.length/o));const dn=ft/o,un=ht/y,Tt=new Set;for(const j of C){let D=Math.min(o-1,Math.max(0,Math.floor((j.area.center.x-w)/dn))),Fe=Math.min(y-1,Math.max(0,Math.floor((j.area.center.z-E)/un))),nt=`${Fe},${D}`,Ot=0;const pn=y*o;for(;Tt.has(nt)&&Ot<pn;)D++,D>=o&&(D=0,Fe=(Fe+1)%y),nt=`${Fe},${D}`,Ot++;Tt.has(nt)&&(Fe=y,D=0,nt=`${Fe},${D}`,y++),Tt.add(nt),$.set(j.area.id,{row:Fe+1,col:D+1})}}}const T=w=>{w.sort((A,E)=>{var ft,ht,O,B;const z=(((ft=A.position)==null?void 0:ft.z)??0)-(((ht=E.position)==null?void 0:ht.z)??0);return z!==0?z:(((O=A.position)==null?void 0:O.x)??0)-(((B=E.position)==null?void 0:B.x)??0)})};for(const w of C)T(w.agents);for(const w of k)T(w.agents);return{groups:[...C,...k],gridCols:o,gridRows:y,positions:$}},[_,Ze,mt,sn]),ln=a.useMemo(()=>{if(!ae)return[];const t=_.find(n=>n.id===ae.agentId);return t?[{id:"edit-agent",label:"Edit Agent",icon:e.jsx(p,{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(p,{name:"chat",size:14}),onClick:()=>u(t.id)},{id:"clone-agent",label:"Clone Agent",icon:e.jsx(p,{name:"clipboard",size:14}),onClick:()=>b.cloneAgent(t.id)},{id:"fork-agent",label:"Fork Agent (with history)",icon:e.jsx(p,{name:"git-branch",size:14}),onClick:()=>b.forkAgent(t.id)},{id:"delete-agent",label:"Delete Agent",icon:e.jsx(p,{name:"trash",size:14}),danger:!0,onClick:()=>{Me({agentId:t.id,name:t.name})}}]:[]},[ae,_,u]),rn=a.useMemo(()=>{var C;if(!f)return[];const t=mt.get(f.buildingId);if(!t)return[];const n=[],i=t.type==="server"||t.type==="docker"||t.type==="terminal",g=t.status==="running",x=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==="boss"?"View Boss Logs":t.type==="terminal"?"Open Terminal":t.type==="server"&&((C=t.pm2)!=null&&C.enabled)?"View PM2 Logs":"Open",icon:e.jsx(p,{name:t.type==="database"?"database":t.type==="folder"?"folder":t.type==="tests"?"flask":t.type==="terminal"?"terminal":"eye",size:14}),onClick:()=>Xe(t.id)}),i&&(g||n.push({id:"start",label:"Start",icon:e.jsx(p,{name:"play",size:14}),onClick:()=>b.sendBuildingCommand(t.id,"start")}),g&&(n.push({id:"restart",label:"Restart",icon:e.jsx(p,{name:"refresh",size:14}),onClick:()=>b.sendBuildingCommand(t.id,"restart")}),n.push({id:"stop",label:"Stop",icon:e.jsx(p,{name:"stop",size:14}),onClick:()=>b.sendBuildingCommand(t.id,"stop")}))),x&&t.subordinateBuildingIds&&t.subordinateBuildingIds.length>0&&(n.push({id:"start-all",label:"Start All Subordinates",icon:e.jsx(p,{name:"launch",size:14}),onClick:()=>{for(const k of t.subordinateBuildingIds)b.sendBuildingCommand(k,"start")}}),n.push({id:"stop-all",label:"Stop All Subordinates",icon:e.jsx(p,{name:"pause",size:14}),onClick:()=>{for(const k of t.subordinateBuildingIds)b.sendBuildingCommand(k,"stop")}}),n.push({id:"restart-all",label:"Restart All Subordinates",icon:e.jsx(p,{name:"restart",size:14}),onClick:()=>{for(const k of t.subordinateBuildingIds)b.sendBuildingCommand(k,"restart")}})),i&&n.push({id:"health-check",label:"Health Check",icon:e.jsx(p,{name:"health",size:14}),onClick:()=>b.sendBuildingCommand(t.id,"healthCheck")}),n.push({id:"divider-edit",label:"",divider:!0,onClick:()=>{}}),n.push({id:"edit",label:"Edit Building",icon:e.jsx(p,{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(p,{name:"copy",size:14}),onClick:()=>{b.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 k of t.urls)n.push({id:`url-${k.label}`,label:k.label,icon:e.jsx(p,{name:"link",size:14}),onClick:()=>window.open(k.url,"_blank","noopener,noreferrer")});return n.push({id:"divider-danger",label:"",divider:!0,onClick:()=>{}}),n.push({id:"delete",label:"Delete Building",icon:e.jsx(p,{name:"trash",size:14}),danger:!0,onClick:()=>b.deleteBuilding(t.id)}),n},[f,mt,Xe]),on=a.useCallback(t=>{const n=new Set(Be.groups.map(i=>i.area.id));n.delete(t),ze(n),requestAnimationFrame(()=>{const i=d.current;if(!i)return;const g=i.querySelector(`[data-area-id="${t}"]`);if(!g)return;const x=i.getBoundingClientRect(),k=g.getBoundingClientRect().top-x.top+i.scrollTop-8;i.scrollTo({top:Math.max(0,k),behavior:"smooth"})})},[Be]);return e.jsxs("div",{ref:Ie,className:`flat-view ${K?"flat-view--with-inspector":""} ${v?"flat-view--has-chat":""} ${ie?"flat-view--mobile-sidebar-open":""}`,style:(()=>{if(Ne===null&&Q===null)return;const t={};return Ne!==null&&(t["--flat-middle-width"]=`${Ne}px`),Q!==null&&(t["--flat-inspector-width"]=`${Q}px`),t})(),children:[ie&&e.jsx("div",{className:"flat-mobile-sidebar-backdrop",onClick:Ve,"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:P,title:"Create new agent",children:"+ Agent"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--boss",onClick:M,title:"Create new boss agent",children:"+ Boss"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--area",onClick:L,title:"Create new area",children:"+ Area"})]})}),e.jsx("div",{className:"flat-middle__content",children:e.jsx(Nn,{activeAgentId:St,onClose:ut,onSelectAgent:pt,collapsedAreas:Se,onToggleArea:Ke,agentListRef:d})})]}),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:Je,onPointerMove:Pe,onPointerUp:q,onPointerCancel:q,onDoubleClick:vt}),e.jsxs("div",{className:"flat-right",children:[e.jsxs("button",{type:"button",className:"flat-mobile-sidebar-toggle","aria-label":ie?"Close agents sidebar":"Open agents sidebar","aria-expanded":ie,onClick:lt,children:[e.jsx(p,{name:"list",size:18}),e.jsx("span",{className:"flat-mobile-sidebar-toggle__label",children:"Agents"})]}),v?e.jsx(va,{agentId:v,terminalViewMode:He,onTerminalViewModeChange:Ue,inspectorOpen:Ce,onToggleInspector:rt,onImageClick:De,onFileClick:Nt,onBashClick:ct,onViewMarkdown:kt,onRequestClearSubordinates:yt,onOpenBuilding:Xe,keyboard:ot,canNavigateBack:Qe,canNavigateForward:et,onNavigateBack:tt,onNavigateForward:fe,agentInfoOpen:We,onToggleAgentInfo:wt,onHeaderContextMenu:t=>{v&&_e({agentId:v,position:t})},onBuildingContextMenu:(t,n)=>{H({buildingId:t,position:n})}}):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.jsx(ma,{className:"flat-map__view-mode"})]}),e.jsx("div",{className:"flat-map__grid",style:{gridTemplateColumns:`repeat(${Be.gridCols}, 1fr)`},children:Be.groups.length===0?e.jsx("div",{className:"flat-map__empty",children:e.jsx("span",{children:"No areas or agents yet"})}):(()=>{var n;const t=he&&Oe?((n=Be.positions.get(Oe))==null?void 0:n.row)??null:null;return Be.groups.map(i=>{var k;const g=i.area.id,x=Be.positions.get(g),C=he&&Oe!==g;return he&&t!=null&&(x==null?void 0:x.row)===t&&g!==Oe?null:e.jsxs("div",{className:`flat-map-area-card${C?" flat-map-area-card--collapsed":""}`,style:{"--area-color":i.area.color,gridRow:x==null?void 0:x.row,gridColumn:x==null?void 0:x.col},onContextMenu:o=>{N&&(o.preventDefault(),o.stopPropagation(),N(g,{x:o.clientX,y:o.clientY}))},children:[((k=i.area.logo)==null?void 0:k.filename)&&e.jsx("img",{className:"flat-map-area-card__logo",src:ia(i.area.logo.filename),alt:"","aria-hidden":"true",onError:o=>{o.currentTarget.style.display="none"}}),e.jsxs("button",{type:"button",className:"flat-map-area-card__header",onClick:()=>he?R(g):on(g),title:he?C?`Expand ${i.area.name}`:`Collapse ${i.area.name}`:`Focus ${i.area.name} in left panel`,"aria-expanded":he?!C:void 0,children:[e.jsx("span",{className:"flat-map-area-card__color",style:{background:i.area.color}}),e.jsx("span",{className:"flat-map-area-card__name",children:i.area.name}),e.jsx("span",{className:"flat-map-area-card__count",children:i.agents.length}),he&&e.jsx(p,{name:C?"caret-down":"caret-up",size:11,className:"flat-map-area-card__caret"})]}),e.jsx("div",{className:"flat-map-area-card__agents",children:i.agents.map(o=>{const y=o.isBoss||o.class==="boss",$=y?At.get(o.id):void 0,T=kn(o),w=T.usedPercent>=80?"#ff4a4a":T.usedPercent>=60?"#ff9e4a":T.usedPercent>=40?"#ffd700":"#4aff9e",A=`Context: ${(T.totalTokens/1e3).toFixed(1)}k / ${(T.contextWindow/1e3).toFixed(1)}k (${T.usedPercent}% used, ${T.freePercent}% free)`,E=o.latestTodos&&o.latestTodos.length>0||$&&$.length>0;return e.jsx(yn,{todos:o.latestTodos,subordinates:$,position:"top",children:e.jsxs("button",{type:"button",className:`flat-map-agent-chip ${o.status}`,onClick:()=>u(o.id),onContextMenu:z=>{z.preventDefault(),z.stopPropagation(),_e({agentId:o.id,position:{x:z.clientX,y:z.clientY}})},title:E?void 0:`${y?"Boss · ":""}Open chat with ${o.name}
|
|
2
|
+
${A}`,children:[e.jsx(nn,{agent:o,size:16}),y&&e.jsx("span",{className:"flat-map-agent-chip__crown","aria-hidden":"true",children:e.jsx(p,{name:"crown",size:11,color:"#ffd700",weight:"fill"})}),e.jsx("span",{className:"flat-map-agent-chip__name",children:o.name}),e.jsx("img",{src:o.provider==="codex"?"/assets/codex.png":o.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:o.provider,className:"flat-map-agent-chip__provider-icon",title:o.provider==="codex"?"Codex Agent":o.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),e.jsx("span",{className:"flat-map-agent-chip__dot",style:{backgroundColor:an(o.status)}}),o.latestTodos&&o.latestTodos.length>0&&e.jsx(An,{todos:o.latestTodos,maxDots:6}),y&&$&&$.length>0&&e.jsx(Sn,{subordinates:$,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:`${T.usedPercent}%`,backgroundColor:w}})})]})},o.id)})}),i.area.directories.length>0&&e.jsx("div",{className:"flat-map-area-card__folders",role:"group","aria-label":`${i.area.name} folders`,children:i.area.directories.map(o=>{const y=o.split("/").filter(Boolean).pop()||o;return e.jsxs("button",{type:"button",className:"flat-map-folder-chip",onClick:$=>{$.stopPropagation(),b.openFileExplorerForAreaFolder(g,o)},title:`Open in file explorer: ${o}`,children:[e.jsx(p,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-map-folder-chip__name",children:y})]},o)})}),i.buildings.length>0&&e.jsx("div",{className:"flat-map-area-card__buildings",children:i.buildings.map(o=>{var $;const y=($=En[o.type])==null?void 0:$.color;return e.jsxs("button",{type:"button",className:`flat-map-building-chip flat-map-building-chip--${o.status}`,style:y?{"--building-type-color":y}:void 0,onClick:T=>{if(h){const w=T.currentTarget.getBoundingClientRect();h(o.id,{x:w.right,y:w.top+w.height/2})}else Xe(o.id)},onContextMenu:T=>{T.preventDefault(),T.stopPropagation(),H({buildingId:o.id,position:{x:T.clientX,y:T.clientY}})},title:`${o.name} · ${o.type} · ${o.status}`,children:[e.jsx(p,{name:Mn(o.type),size:12,color:y}),e.jsx("span",{className:"flat-map-building-chip__name",children:o.name}),e.jsx("span",{className:"flat-map-building-chip__dot",style:{backgroundColor:In(o.status)}})]},o.id)})})]},g)})})()})]})})]}),K&&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:ye,onPointerMove:Pe,onPointerUp:q,onPointerCancel:q,onDoubleClick:Ct}),Ye&&e.jsxs("aside",{className:`flat-inspector ${l?"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":Le==="agent",className:`flat-inspector__tab ${Le==="agent"?"flat-inspector__tab--active":""}`,onClick:()=>Ae("agent"),children:"Agent"}),e.jsx("button",{type:"button",role:"tab","aria-selected":Le==="tracking",className:`flat-inspector__tab ${Le==="tracking"?"flat-inspector__tab--active":""}`,onClick:()=>Ae("tracking"),children:"Tracking"})]}),e.jsx("button",{type:"button",className:"flat-inspector__close",onClick:ce,title:"Close inspector","aria-label":"Close inspector",children:"✕"})]}),e.jsx("div",{className:"flat-inspector__body",children:Le==="tracking"?e.jsx(Tn,{activeAgentId:v??"",onSelectAgent:t=>{u(t),window.innerWidth<=768&&ce()}}):(()=>{if(!v)return e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Select an agent to inspect"})});const t=_.find(n=>n.id===v);return t?e.jsx(Pn,{agent:t,onFocusAgent:n=>{u(n),window.innerWidth<=768&&ce()},onKillAgent:n=>b.killAgent(n)}):e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Agent not found"})})})()})]}),I&&e.jsx(Ln,{url:I.url,name:I.name,onClose:()=>W(null)}),U&&e.jsx(Dn,{state:U,onClose:()=>xe(null)}),e.jsx(Rn,{agent:v?_.find(t=>t.id===v)??null:null,content:Z,onClose:()=>be(null)}),Ee&&e.jsx($n,{action:"clear-subordinates",selectedAgentId:Ee.agentId,subordinateCount:Ee.count,onClose:()=>st(null),onClearHistory:()=>{}}),e.jsx(zn,{agent:v?_.find(t=>t.id===v)??null:null,isOpen:We&&!!v,onClose:it}),e.jsx(Xt,{isOpen:ae!==null,position:(ae==null?void 0:ae.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:ln,onClose:()=>_e(null)}),e.jsx(Xt,{isOpen:f!==null,position:(f==null?void 0:f.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:rn,onClose:()=>H(null)}),e.jsx(On,{isOpen:we!==null,title:G("common:confirm.removeAgentTitle"),message:G("common:confirm.removeAgentMessage",{name:(we==null?void 0:we.name)??""}),confirmLabel:G("common:buttons.remove"),cancelLabel:G("common:buttons.cancel"),variant:"danger",onConfirm:()=>{we&&b.removeAgentFromServer(we.agentId)},onClose:()=>Me(null)})]})}export{ya as FlatView};
|