tide-commander 1.93.0 → 1.94.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/assets/{BossLogsModal-CgILsm9V.js → BossLogsModal-b4O2O00j.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-BdGy2pC2.js → BossSpawnModal--Cn40tMQ.js} +1 -1
  3. package/dist/assets/{ControlsModal-hFIzwgt7.js → ControlsModal-SNJ95Qn9.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-CDX9xVzn.js → DockerLogsModal-DOkOsLaK.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-2DZTiy_9.js → EmbeddedEditor-BKLJKK3B.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-Cq1DpIPF.js → GmailOAuthSetup-B8ao6401.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-B1UOVYlZ.js → GoogleOAuthSetup-By-gup6S.js} +1 -1
  8. package/dist/assets/{IframeModal-GZkqd6O6.js → IframeModal-KzrFyAG0.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-CBN_0nAs.js → IntegrationsPanel-CXMEldir.js} +2 -2
  10. package/dist/assets/{LogViewerModal-BrZrAYvt.js → LogViewerModal-C70SfK7U.js} +1 -1
  11. package/dist/assets/{MonitoringModal-bIVunlhs.js → MonitoringModal-CbZtFYh9.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-Crs7Q2LK.js → PM2LogsModal-C8mo6Tqu.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-9thnHbZ3.js → RestoreArchivedAreaModal-BUB-mruP.js} +1 -1
  14. package/dist/assets/{Scene2DCanvas-Bj7JLtW8.js → Scene2DCanvas-zinDgDAK.js} +1 -1
  15. package/dist/assets/{SceneManager-C-ItjZnd.js → SceneManager-CAxi1UHT.js} +1 -1
  16. package/dist/assets/{SkillsPanel-pTORcpQL.js → SkillsPanel-Bh_J9suc.js} +1 -1
  17. package/dist/assets/{SlackMultiInstanceSetup-FXuMr1vo.js → SlackMultiInstanceSetup-DZSpM5ew.js} +1 -1
  18. package/dist/assets/{SpawnModal-D3Pgos07.js → SpawnModal-BrcKWjDs.js} +1 -1
  19. package/dist/assets/{SubordinateAssignmentModal-6au3Tv5w.js → SubordinateAssignmentModal-CBqmszjc.js} +1 -1
  20. package/dist/assets/{TriggerManagerPanel-DletkqtL.js → TriggerManagerPanel-BD7VnHYc.js} +1 -1
  21. package/dist/assets/{WorkflowEditorPanel-DMu9KdjB.js → WorkflowEditorPanel-DE9448gZ.js} +1 -1
  22. package/dist/assets/{index-CQYizqu9.js → index-B4VnKOHB.js} +1 -1
  23. package/dist/assets/{index-_OjecyuG.js → index-BkZ422b_.js} +1 -1
  24. package/dist/assets/{index-Hl0I9IIt.js → index-C7EieXis.js} +1 -1
  25. package/dist/assets/{index-BPox4QjF.js → index-Cbk6B5BY.js} +1 -1
  26. package/dist/assets/{index-DIsb3aYA.js → index-CpLZo6IM.js} +1 -1
  27. package/dist/assets/{index-ZZtcJoNU.js → index-DPvgEcBT.js} +3 -3
  28. package/dist/assets/index-DelPL0HI.js +2 -0
  29. package/dist/assets/{index-mEu7CM6i.js → index-Dk2THz0j.js} +2 -2
  30. package/dist/assets/{index-BGatvpcF.js → index-DuDcnBNX.js} +1 -1
  31. package/dist/assets/{main-BUO6--48.js → main-CteALl_G.js} +4 -4
  32. package/dist/assets/{web-BbNfUMzK.js → web-BZa7rL0p.js} +1 -1
  33. package/dist/assets/{web-bKiHKTT6.js → web-CGYGq80f.js} +1 -1
  34. package/dist/assets/{web-CQsQBSkQ.js → web-DtevCxzm.js} +1 -1
  35. package/dist/index.html +1 -1
  36. package/package.json +1 -1
  37. package/dist/assets/index-DAsi0YrR.js +0 -2
@@ -0,0 +1,2 @@
1
+ import{r as a,z as sn,B as St,u as Bt,E as ln,j as e,V as rn,G as on,H as cn,J as Mt,S as y,K as Tt,L as Nt,M as Pt,N as dt,O as se,P as dn,s as x,U as Ft,W as Wt,X as un,v as Lt,w as Rt,I as u,Y as pn,m as mn,Z as fn,_ as Ht,$ as Vt,a0 as hn,a1 as gn,a2 as xn,a3 as bn,a4 as _n,a5 as wn,a6 as vn,a7 as Cn,a8 as jn,a9 as Nn,aa as Dt,C as kn,ab as yn,ac as An,ad as In,ae as En,af as Sn,ag as Mn,ah as Tn,ai as Pn,aj as Ln,ak as Rn,al as Dn,am as zn,an as On,ao as $n,ap as Bn,aq as Fn}from"./main-CteALl_G.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function Wn(w){const c=a.useRef(w);c.current=w,a.useEffect(()=>{if(!sn())return;let v=null,I=!1;return St.addListener("backButton",()=>{c.current()==="exit"&&St.exitApp()}).then(E=>{I?E.remove():v=E}),()=>{I=!0,v&&(v.remove(),v=null)}},[])}const Hn=a.memo(function({className:c=""}){const{t:v}=Bt(["common"]),[I,E]=ln(),Y=a.useRef(null),[F,Re]=a.useState(null);a.useLayoutEffect(()=>{const f=Y.current;if(!f)return;const K=f.querySelector(".view-mode-toggle__btn--active");K&&Re({left:K.offsetLeft,width:K.offsetWidth})},[I]);const ie=a.useCallback(f=>{if(f!==I){if(typeof window<"u"&&window.dispatchEvent(new CustomEvent("tide:viewmode-switch-pressed",{detail:{mode:f}})),f==="3d"){requestAnimationFrame(()=>E(f));return}E(f)}},[I,E]);return e.jsxs("div",{className:`view-mode-toggle ${c}`,ref:Y,children:[F&&e.jsx("div",{className:"view-mode-toggle__indicator",style:{left:F.left,width:F.width}}),rn.map(f=>e.jsxs("button",{className:`view-mode-toggle__btn ${I===f?"view-mode-toggle__btn--active":""}`,onClick:()=>ie(f),title:v(`common:viewMode.descriptions.${f}`),children:[e.jsxs("span",{className:"view-mode-toggle__icon",children:[f==="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"})]}),f==="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"})]}),f==="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"})]}),f==="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:v(`common:viewMode.labels.${f}`)})]},f))]})}),ut=3,pt=280,zt=320,jt=240,Ot=64,Vn=["simple","chat","advanced"],Xn={simple:"Simple",chat:"Chat",advanced:"Advanced"},Gn={simple:"○",chat:"◐",advanced:"◉"},Un={simple:"Simple view — clean messages only",chat:"Chat view — assistant replies (no tool calls)",advanced:"Advanced view — everything including tools"},$t="flat-clear-context";function qn(w){const c=w.split("/").filter(Boolean);return c.length===0?w:c.slice(-2).join("/")}function Yn(w){if(w.provider==="codex"){const Y=w.codexModel||"gpt-5.3-codex",F=$n[Y];return{model:(F==null?void 0:F.label)||Y}}if(w.provider==="opencode")return{model:w.opencodeModel||"opencode"};const c=w.model||"sonnet",v=Fn[c],I=w.effort,E=I?Bn[I]:void 0;return{model:(v==null?void 0:v.label)||c,effort:E==null?void 0:E.label}}function Kn(w,c){if(c.type==="rectangle"&&c.width&&c.height){const v=c.width/2,I=c.height/2;return w.x>=c.center.x-v&&w.x<=c.center.x+v&&w.z>=c.center.z-I&&w.z<=c.center.z+I}if(c.type==="circle"&&c.radius){const v=w.x-c.center.x,I=w.z-c.center.z;return v*v+I*I<=c.radius*c.radius}return!1}const Zn=yn.memo(function({agentId:c,terminalViewMode:v,onTerminalViewModeChange:I,inspectorOpen:E,onToggleInspector:Y,onImageClick:F,onFileClick:Re,onBashClick:ie,onViewMarkdown:f,onRequestClearSubordinates:K,onOpenBuilding:ye,keyboard:Ve,canNavigateBack:Xe,canNavigateForward:Ge,onNavigateBack:Z,onNavigateForward:le,agentInfoOpen:W,onToggleAgentInfo:De,onHeaderContextMenu:J}){var Me,ne,at,$;const b=An(c),T=Wt(),me=a.useRef(null),Ae=a.useRef(null);a.useEffect(()=>{const i=Ae.current;if(!i)return;const r=o=>{o.button===3?(o.preventDefault(),o.stopPropagation(),Z()):o.button===4&&(o.preventDefault(),o.stopPropagation(),le())},d=o=>{(o.button===3||o.button===4)&&o.preventDefault()};return i.addEventListener("mouseup",r),i.addEventListener("mousedown",d),()=>{i.removeEventListener("mouseup",r),i.removeEventListener("mousedown",d)}},[Z,le]),a.useEffect(()=>{const i=Ae.current;if(!i)return;let r=0,d=0,o=0;const Ce=250,Te=600,Pe=80,bt=1.5,q=D=>{let M=D instanceof HTMLElement?D:null;for(;M&&M!==i;){const We=window.getComputedStyle(M).overflowX;if((We==="auto"||We==="scroll")&&M.scrollWidth>M.clientWidth)return!0;M=M.parentElement}return!1},Le=D=>{const M=Date.now();if(M<o){D.preventDefault();return}if(Math.abs(D.deltaX)<=Math.abs(D.deltaY)*bt){r=0;return}if(q(D.target)){r=0;return}M-d>Ce&&(r=0),d=M,r+=D.deltaX,r<=-Pe?(r=0,o=M+Te,D.preventDefault(),Z()):r>=Pe&&(r=0,o=M+Te,D.preventDefault(),le())};return i.addEventListener("wheel",Le,{passive:!1}),()=>i.removeEventListener("wheel",Le)},[Z,le]);const fe=Ft(),ze=a.useMemo(()=>{if(!b)return null;const i=new Set,r=[];for(const d of fe.values())d.archived||d.directories.length===0||d.assignedAgentIds.includes(c)&&(i.add(d.id),r.push(d));for(const d of fe.values())d.archived||d.directories.length===0||i.has(d.id)||Kn({x:b.position.x,z:b.position.z},d)&&(i.add(d.id),r.push(d));return r.length===0?null:r.flatMap(d=>d.directories.filter(o=>o&&o.trim().length>0).map(o=>({areaId:d.id,areaName:d.name,dir:o})))},[b,c,fe]),{branches:Ue,fetchRemote:qe,fetchingDirs:Oe}=In(ze),Ie=a.useMemo(()=>{var d;const i=x.getAreaForAgent(c);if(!i)return[];const r=[];for(const o of T.values())o.type==="terminal"&&x.isPositionInArea(o.position,i)&&r.push({id:o.id,name:o.name,hasUrl:!!((d=o.terminalStatus)!=null&&d.url)});return r},[c,T]),he=a.useMemo(()=>{var d;const i=x.getAreaForAgent(c);if(!i)return[];const r=[];for(const o of T.values())o.type==="server"&&((d=o.pm2)!=null&&d.enabled)&&x.isPositionInArea(o.position,i)&&r.push({id:o.id,name:o.name});return r},[c,T]),re=a.useMemo(()=>{const i=x.getAreaForAgent(c);if(!i)return[];const r=[];for(const d of T.values())d.type==="database"&&d.database&&x.isPositionInArea(d.position,i)&&r.push({id:d.id,name:d.name});return r},[c,T]),[,oe]=a.useReducer(i=>i+1,0),H=((Me=me.current)==null?void 0:Me.search.searchMode)??!1,mt=a.useCallback(()=>{var i;(i=me.current)==null||i.search.toggleSearch(),oe()},[]),Ye=En(),ce=Ye.isPending($t),[z,G]=a.useState(null),V=z?T.get(z):null,{height:U,onResizeStart:Ee}=Sn(),[O,Q]=a.useState(()=>Nt(y.GIT_PANEL_OPEN,!1)),[ge,Ke]=a.useState(()=>Nt(y.BUILDINGS_PANEL_OPEN,!1)),[de,xe]=a.useState(!1),ft=a.useCallback(()=>{xe(i=>{const r=!i;return r&&Mn.setEnabled(!0),r})},[]),ht=a.useCallback(()=>xe(!1),[]),be=a.useCallback(()=>{Q(i=>{const r=!i;return se(y.GIT_PANEL_OPEN,r),r})},[]),gt=a.useCallback(()=>{Ke(i=>{const r=!i;return se(y.BUILDINGS_PANEL_OPEN,r),r})},[]),Ze=a.useCallback(()=>{Q(!1),se(y.GIT_PANEL_OPEN,!1)},[]),xt=a.useCallback(()=>{Ke(!1),se(y.BUILDINGS_PANEL_OPEN,!1)},[]),$e=Tn();a.useEffect(()=>{if(!z)return;Ie.some(r=>r.id===z)||G(null)},[z,Ie]);const[_e,ue]=a.useState(!1),Be=a.useRef(null);if(a.useEffect(()=>{if(!_e)return;const i=r=>{Be.current&&!Be.current.contains(r.target)&&ue(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[_e]),!b)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 ee=b.contextStats,Je=!!ee,Qe=ee?ee.totalTokens:b.contextUsed||0,we=ee?ee.contextWindow:b.contextLimit||2e5,h=ee?ee.usedPercent:Math.round(Qe/we*100),P=Math.max(0,Math.min(100,h)),X=Math.round(P*10)/10,Se=Math.round((100-P)*10)/10,Fe=P>=80?"#ff4a4a":P>=60?"#ff9e4a":P>=40?"#ffd700":"#4aff9e",et=(Qe/1e3).toFixed(1),tt=(we/1e3).toFixed(1),te=b.cwd,nt=te?qn(te):null,pe=((ne=b.subordinateIds)==null?void 0:ne.length)||0,ve=pe>0;return e.jsxs("div",{ref:Ae,className:`flat-terminal-wrapper ${O||ge||de?"flat-terminal-wrapper--with-side-panel":""}`,children:[e.jsxs("div",{className:"flat-terminal-wrapper__header",children:[e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__header-main ${W?"flat-terminal-wrapper__header-main--active":""}`,onClick:De,onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),J({x:i.clientX,y:i.clientY})},title:W?"Hide agent info":"Show agent info","aria-pressed":W,children:[e.jsx(Ht,{agent:b,size:28}),e.jsxs("span",{className:"flat-terminal-wrapper__header-info",children:[e.jsx("span",{className:"flat-terminal-wrapper__header-name",children:b.name}),e.jsx("span",{className:"flat-terminal-wrapper__header-status",style:{color:Vt(b.status)},children:b.status})]}),b.taskLabel&&e.jsxs("span",{className:"flat-terminal-wrapper__header-task",title:b.taskLabel,children:["📋 ",b.taskLabel]}),e.jsxs("span",{className:"flat-terminal-wrapper__header-model",children:[e.jsx("img",{src:b.provider==="codex"?"/assets/codex.png":b.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:b.provider,className:"flat-terminal-wrapper__header-provider-icon",title:b.provider==="codex"?"Codex Agent":b.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),(()=>{const{model:i,effort:r}=Yn(b);return e.jsxs("span",{className:"flat-terminal-wrapper__header-model-chip",title:r?`Model: ${i} · Effort: ${r}`:`Model: ${i}`,children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-name",children:i}),r&&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:r})]})]})})()]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__header-meta",children:[e.jsx("div",{className:"flat-terminal-wrapper__view-mode",role:"group","aria-label":"Message view mode",children:Vn.map(i=>e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${v===i?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>I(i),title:Un[i],"aria-pressed":v===i,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:Gn[i]}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:Xn[i]})]},i))}),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:!Xe,title:"Back to previous agent","aria-label":"Back to previous agent",children:e.jsx(u,{name:"arrow-left",size:14})}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:le,disabled:!Ge,title:"Forward to next agent","aria-label":"Forward to next agent",children:e.jsx(u,{name:"arrow-right",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${H?"flat-terminal-wrapper__action-btn--active":""}`,onClick:mt,title:H?"Close search":"Search messages","aria-pressed":H,children:e.jsx(u,{name:H?"cross":"search",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn flat-terminal-wrapper__action-btn--danger ${ce?"flat-terminal-wrapper__action-btn--confirm":""}`,onClick:()=>Ye.handleClick($t,()=>{var i;x.clearContext(c),(i=me.current)==null||i.historyLoader.clearHistory()}),title:ce?"Click again to confirm clear context":"Clear context",children:e.jsx(u,{name:ce?"question":"clear",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${O?"flat-terminal-wrapper__action-btn--active":""}`,onClick:be,title:O?"Hide git panel":"Show git changes","aria-pressed":O,children:e.jsx(u,{name:"git-branch",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${ge?"flat-terminal-wrapper__action-btn--active":""}`,onClick:gt,title:ge?"Hide buildings panel":"Show area buildings","aria-pressed":ge,children:e.jsx(u,{name:"buildings",size:14})}),e.jsxs("div",{className:"flat-terminal-wrapper__more",ref:Be,children:[e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${_e?"flat-terminal-wrapper__action-btn--active":""}`,onClick:()=>ue(i=>!i),title:"More actions","aria-expanded":_e,children:"⋮"}),_e&&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:()=>{ft(),ue(!1)},title:de?"Hide Debug Panel":"Show Debug Panel",children:[e.jsx(u,{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:()=>{x.collapseContext(c),ue(!1)},disabled:b.status!=="idle",title:b.status!=="idle"?"Agent must be idle to collapse context":"Collapse context",children:[e.jsx(u,{name:"package",size:14}),e.jsx("span",{children:"Collapse context"})]}),ve&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{K(c,pe),ue(!1)},children:[e.jsx(u,{name:"crown",size:14}),e.jsxs("span",{children:["Clear ",pe," subordinate",pe===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:()=>{x.killAgent(c),ue(!1)},children:[e.jsx(u,{name:"cross",size:14}),e.jsx("span",{children:"Remove agent"})]})]})]})]}),e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__inspector-toggle ${E?"flat-terminal-wrapper__inspector-toggle--active":""}`,onClick:Y,title:E?"Hide inspector panel":"Show inspector panel","aria-label":E?"Hide inspector panel":"Show inspector panel","aria-pressed":E,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:()=>x.deselectAll(),title:"Close chat","aria-label":"Close chat",children:e.jsx(u,{name:"cross",size:14})})]})]}),e.jsx(Pn,{ref:me,agentId:c,agent:b,viewMode:v,isOpen:!0,onImageClick:F,onFileClick:Re,onBashClick:ie,onViewMarkdown:f,keyboard:Ve,hasModalOpen:!1}),V&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:Ee,role:"separator","aria-orientation":"horizontal","aria-label":"Resize embedded terminal"}),e.jsxs("div",{className:"flat-bottom-panel",role:"region","aria-label":`Embedded terminal: ${V.name}`,style:{height:U},children:[e.jsxs("div",{className:"flat-bottom-panel__header",children:[e.jsxs("span",{className:"flat-bottom-panel__title",children:[e.jsx(u,{name:"terminal",size:12}),e.jsx("span",{children:V.name}),!((at=V.terminalStatus)!=null&&at.url)&&e.jsx("span",{className:"flat-bottom-panel__muted",children:"(starting...)"})]}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>G(null),title:"Close embedded terminal","aria-label":"Close embedded terminal",children:e.jsx(u,{name:"cross",size:12})})]}),e.jsx("div",{className:"flat-bottom-panel__body",children:($=V.terminalStatus)!=null&&$.url?e.jsx(Ln,{terminalUrl:V.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:[b.isDetached&&e.jsxs("span",{className:"flat-terminal-wrapper__detached",title:"Reattaching session...",children:[e.jsx(u,{name:"refresh",size:12}),e.jsx("span",{children:"Reattaching"})]}),te&&nt&&e.jsxs("span",{className:"flat-terminal-wrapper__cwd",title:`Open in file explorer: ${te}`,"aria-label":`Open ${te} in file explorer`,role:"button",tabIndex:0,onClick:()=>x.openFileExplorer(te),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),x.openFileExplorer(te))},children:[e.jsx("span",{className:"flat-terminal-wrapper__cwd-icon",children:e.jsx(u,{name:"folder",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__cwd-text",children:nt})]}),ze&&ze.map(({areaId:i,areaName:r,dir:d})=>{const o=Ue.get(d),Ce=Oe.has(d),Te=d.split("/").filter(Boolean).pop()||d;return e.jsxs("span",{className:"flat-terminal-wrapper__area-dir",title:`${r}: ${d}${o?` (${o.branch}${o.ahead?` ↑${o.ahead}`:""}${o.behind?` ↓${o.behind}`:""})`:""}`,onClick:()=>x.openFileExplorerForAreaFolder(i,d),children:[e.jsx(u,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-terminal-wrapper__area-dir-name",children:Te}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flat-terminal-wrapper__area-dir-branch",children:[e.jsx(u,{name:"git-branch",size:10})," ",o.branch]}),o.ahead>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-ahead",title:`${o.ahead} ahead`,children:[e.jsx(u,{name:"arrow-up",size:9}),o.ahead]}),o.behind>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-behind",title:`${o.behind} behind`,children:[e.jsx(u,{name:"arrow-down",size:9}),o.behind]}),e.jsx("span",{className:`flat-terminal-wrapper__area-fetch ${Ce?"flat-terminal-wrapper__area-fetch--fetching":""}`,title:"Git fetch",onClick:Pe=>{Pe.stopPropagation(),qe(d)},children:e.jsx(u,{name:Ce?"hourglass":"download",size:12})})]})]},`${i}:${d}`)}),e.jsxs("span",{className:"flat-terminal-wrapper__context",onClick:()=>x.setContextModalAgentId(c),title:Je?`Context usage: ${et}k / ${tt}k tokens (${X}% used). Click to view stats.`:"Click to fetch context stats",children:[e.jsx("span",{className:"flat-terminal-wrapper__context-icon",children:e.jsx(u,{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:`${P}%`,backgroundColor:Fe}})}),e.jsxs("span",{className:"flat-terminal-wrapper__context-tokens",style:{color:Fe},children:[et,"k/",tt,"k"]}),e.jsxs("span",{className:"flat-terminal-wrapper__context-free",children:["(",Se,"% free)"]}),!Je&&e.jsx("span",{className:"flat-terminal-wrapper__context-warning",title:"No context stats yet",children:e.jsx(u,{name:"warn",size:12})})]}),e.jsx("div",{className:"flat-terminal-wrapper__statusbar-spacer","aria-hidden":"true"}),Ie.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area terminals",children:Ie.map(i=>{const r=z===i.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${r?"flat-terminal-wrapper__building-btn--active":""} ${i.hasUrl?"":"flat-terminal-wrapper__building-btn--offline"}`,title:`${r?"Hide":"Show"} terminal: ${i.name}${i.hasUrl?"":" (starting...)"}`,onClick:()=>{if(r){G(null);return}i.hasUrl||x.sendBuildingCommand(i.id,"start"),G(i.id)},children:e.jsx(u,{name:"terminal",size:14})},i.id)})}),he.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area PM2 logs",children:he.map(i=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open logs: ${i.name}`,onClick:()=>ye(i.id),children:e.jsx(u,{name:"scroll",size:14})},i.id))}),re.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area databases",children:re.map(i=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open database: ${i.name}`,onClick:()=>ye(i.id),children:e.jsx(u,{name:"hard-drives",size:14})},i.id))}),e.jsx("div",{className:"flat-terminal-wrapper__theme",children:e.jsx(Rn,{})})]}),O&&e.jsx(Dn,{agentId:c,agents:$e,onClose:Ze,branchInfoMap:Ue,fetchRemote:qe,fetchingDirs:Oe}),ge&&e.jsx(zn,{agentId:c,onClose:xt}),de&&e.jsx(On,{agentId:c,onClose:ht})]})});function ta({onAgentClick:w,onBuildingClick:c,onBuildingDoubleClick:v,onBuildingPopup:I,onAreaContextMenu:E,onOpenSpawnModal:Y,onOpenBossSpawnModal:F,onOpenAreaModal:Re}){const{t:ie}=Bt(["common"]),f=on(),K=cn(),[ye,Ve]=a.useState(null),[Xe,Ge]=a.useState(null),[Z,le]=a.useState(null),[W,De]=a.useState(null),[J,b]=a.useState(null),[T,me]=a.useState(null),[Ae,fe]=a.useState(!1),ze=a.useCallback(()=>{fe(t=>!t)},[]),Ue=a.useCallback(()=>{fe(!1)},[]),[qe,Oe]=a.useState(()=>{const t=Mt(y.VIEW_MODE);return t==="simple"||t==="chat"||t==="advanced"?t:"simple"}),Ie=a.useCallback(t=>{Oe(t),Tt(y.VIEW_MODE,t)},[]);a.useEffect(()=>{const t=n=>{if(n.key!==y.VIEW_MODE)return;const s=n.newValue;(s==="simple"||s==="chat"||s==="advanced")&&Oe(s)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const[he,re]=a.useState(()=>Nt(y.FLAT_INSPECTOR_OPEN,!1)),[oe,H]=a.useState(!1),mt=a.useCallback(()=>H(t=>!t),[]),Ye=a.useCallback(()=>H(!1),[]);a.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-agents-drawer-state",{detail:{open:oe}}))},[oe]),a.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-inspector-state",{detail:{open:he}}))},[he]),a.useEffect(()=>{const t=()=>H(_=>!_),n=()=>{re(_=>{const l=!_;return se(y.FLAT_INSPECTOR_OPEN,l),l})},s=()=>{H(!1),re(!1),se(y.FLAT_INSPECTOR_OPEN,!1)},p=()=>H(!1),m=()=>{re(!1),se(y.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",s),window.addEventListener("tide-close-flat-agents-drawer-only",p),window.addEventListener("tide-close-flat-inspector-only",m),()=>{window.removeEventListener("tide-toggle-flat-agents-drawer",t),window.removeEventListener("tide-toggle-flat-inspector",n),window.removeEventListener("tide-close-flat-side-views",s),window.removeEventListener("tide-close-flat-agents-drawer-only",p),window.removeEventListener("tide-close-flat-inspector-only",m)}},[]);const ce=a.useRef(null),z=a.useRef(null),[G,V]=a.useState(()=>{const t=Pt(y.FLAT_MIDDLE_WIDTH,0);return t>=pt?t:null}),[U,Ee]=a.useState(()=>{const t=Pt(y.FLAT_INSPECTOR_WIDTH,0);return t>=jt?t:null}),O=a.useCallback(t=>{if(typeof window>"u")return t;const n=U!==null?ut+U:0,s=window.innerWidth-Ot-ut-zt-n;return Math.max(pt,Math.min(Math.max(s,pt),t))},[U]),Q=a.useCallback(t=>{var m;if(typeof window>"u")return t;const n=(m=ce.current)==null?void 0:m.querySelector(".flat-middle"),s=(n==null?void 0:n.getBoundingClientRect().width)??pt,p=window.innerWidth-Ot-s-ut-zt-ut;return Math.max(jt,Math.min(Math.max(p,jt),t))},[]);a.useEffect(()=>{if(G===null&&U===null)return;const t=()=>{V(n=>{if(n===null)return n;const s=O(n);return s===n?n:s}),Ee(n=>{if(n===null)return n;const s=Q(n);return s===n?n:s})};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[G,U,O,Q]);const ge=a.useCallback(t=>{var s;if(t.button!==0)return;const n=(s=ce.current)==null?void 0:s.querySelector(".flat-middle");n&&(t.currentTarget.setPointerCapture(t.pointerId),z.current={kind:"middle",startX:t.clientX,startWidth:n.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),Ke=a.useCallback(t=>{var s;if(t.button!==0)return;const n=(s=ce.current)==null?void 0:s.querySelector(".flat-inspector");n&&(t.currentTarget.setPointerCapture(t.pointerId),z.current={kind:"inspector",startX:t.clientX,startWidth:n.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),de=a.useCallback(t=>{const n=z.current;if(!n||t.pointerId!==n.pointerId)return;const s=t.clientX-n.startX;n.kind==="middle"?V(O(n.startWidth+s)):Ee(Q(n.startWidth-s))},[O,Q]),xe=a.useCallback(t=>{const n=z.current;if(!n||t.pointerId!==n.pointerId)return;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}if(z.current=null,document.body.classList.remove("flat-splitter-dragging"),!(Math.abs(t.clientX-n.startX)>2))return;const p=t.clientX-n.startX;if(n.kind==="middle"){const m=O(n.startWidth+p);V(m),dt(y.FLAT_MIDDLE_WIDTH,m)}else{const m=Q(n.startWidth-p);Ee(m),dt(y.FLAT_INSPECTOR_WIDTH,m)}},[O,Q]),ft=a.useCallback(()=>{V(null),dt(y.FLAT_MIDDLE_WIDTH,0)},[]),ht=a.useCallback(()=>{Ee(null),dt(y.FLAT_INSPECTOR_WIDTH,0)},[]),[be,gt]=a.useState(()=>Mt(y.FLAT_INSPECTOR_VIEW)==="tracking"?"tracking":"agent"),Ze=a.useCallback(t=>{gt(t),Tt(y.FLAT_INSPECTOR_VIEW,t)},[]),xt=a.useCallback(()=>{re(t=>{const n=!t;return se(y.FLAT_INSPECTOR_OPEN,n),n})},[]),$e=a.useCallback(()=>{re(!1),se(y.FLAT_INSPECTOR_OPEN,!1)},[]),_e=dn(),ue=a.useCallback((t,n)=>{Ve({url:t,name:n})},[]),Be=a.useCallback((t,n)=>{Ge({command:t,output:n,isLive:!1})},[]),ee=a.useCallback((t,n)=>{x.setFileViewerPath(t,n)},[]),Je=a.useCallback(t=>{},[]),Qe=a.useCallback((t,n)=>{le({agentId:t,count:n})},[]),we=a.useCallback(t=>{v?v(t):c(t)},[c,v]),h=a.useMemo(()=>K.size>0?Array.from(K)[0]:null,[K]);a.useEffect(()=>{fe(!1)},[h]);const P=a.useRef([]),X=a.useRef(-1),Se=a.useRef(!1),Fe=a.useRef(null),[et,tt]=a.useState(!1),[te,nt]=a.useState(!1),pe=a.useRef(!1),ve=a.useRef(null),Me=a.useRef(!1),ne=a.useMemo(()=>new Set(f.map(t=>t.id)),[f]),at=a.useMemo(()=>{const t=new Map(f.map(s=>[s.id,s])),n=new Map;for(const s of f)if((s.isBoss||s.class==="boss")&&s.subordinateIds&&s.subordinateIds.length>0){const p=s.subordinateIds.map(m=>t.get(m)).filter(m=>m!==void 0);p.length>0&&n.set(s.id,p)}return n},[f]),$=a.useCallback(()=>{const t=P.current,n=X.current;tt(n>0),nt(n>=0&&n<t.length-1)},[]),i=a.useCallback(t=>{const n=P.current;if(n.length===0)return;let s=X.current+t;for(;s>=0&&s<n.length;){const p=n[s];if(ne.has(p)){Se.current=!0,X.current=s,$(),x.selectAgent(p);return}s+=t}},[ne,$]),r=a.useCallback(()=>i(-1),[i]),d=a.useCallback(()=>i(1),[i]);Wn(a.useCallback(()=>{const t=P.current,n=X.current;return t.length>0&&n>0?(i(-1),"handled"):"exit"},[i]));const o=a.useCallback((t,n)=>{if(typeof window>"u")return;const s=window.history.state,m={...typeof s=="object"&&s!==null?s:{},__flatAgentNav:{agentId:t}};n==="replace"?window.history.replaceState(m,"",window.location.href):window.history.pushState(m,"",window.location.href)},[]);a.useEffect(()=>{if(!h){pe.current=!1,ve.current=null;return}if(!pe.current){o(h,"replace"),pe.current=!0,ve.current=h;return}if(Me.current){Me.current=!1,ve.current=h;return}ve.current!==h&&(o(h,"push"),ve.current=h)},[h,o]),a.useEffect(()=>{const t=n=>{var _,l;const s=(l=(_=n.state)==null?void 0:_.__flatAgentNav)==null?void 0:l.agentId;if(!s||typeof s!="string"||!ne.has(s)||s===h)return;Me.current=!0,Se.current=!0;const p=P.current,m=p.lastIndexOf(s);m>=0?X.current=m:(p.push(s),X.current=p.length-1),$(),x.selectAgent(s)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[ne,h,$]),a.useEffect(()=>{if(!h){P.current=[],X.current=-1,$();return}if(Fe.current=h,Se.current){Se.current=!1,$();return}const t=P.current,n=X.current;if(n>=0&&t[n]===h){$();return}const s=n<t.length-1?t.slice(0,n+1):t.slice();s.push(h),s.length>100&&s.shift(),P.current=s,X.current=s.length-1,$()},[h,$]);const Ce=a.useCallback(t=>{w(t),H(!1)},[w]),Te=h??"",Pe=a.useCallback(()=>{},[]),bt=a.useCallback(t=>{Ce(t)},[Ce]),q=he,[Le,D]=a.useState(q),[M,We]=a.useState(q);a.useEffect(()=>{if(q){D(!0);return}We(!1);const t=setTimeout(()=>D(!1),240);return()=>clearTimeout(t)},[q]),a.useEffect(()=>{if(!Le||!q)return;let t=0;const n=requestAnimationFrame(()=>{t=requestAnimationFrame(()=>We(!0))});return()=>{cancelAnimationFrame(n),cancelAnimationFrame(t)}},[Le,q]);const kt=a.useRef(null);a.useEffect(()=>{if(h)return;const t=n=>{if(n.key!==" "&&n.key!=="Backspace")return;const s=n.target;if(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)return;const p=Fe.current;!p||!ne.has(p)||(n.preventDefault(),x.selectAgent(p))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[h,ne]);const[Xt,yt]=a.useState(new Set),Gt=a.useCallback(t=>{yt(n=>{const s=new Set(n);return s.has(t)?s.delete(t):s.add(t),s})},[]),[je,Ut]=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=s=>Ut(s.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[]);const[st,qt]=a.useState(null),Yt=a.useCallback(t=>{qt(n=>n===t?null:t)},[]),_t=Ft(),it=Wt(),[Kt]=un(),Ne=a.useMemo(()=>{const t=new Map,n=[];for(const g of f){const k=x.getAreaForAgent(g.id);if(!Lt((k==null?void 0:k.id)??null))continue;if(!k||k.archived){n.push(g);continue}const j=t.get(k.id);j?j.push(g):t.set(k.id,[g])}const s=new Map,p=[];for(const g of it.values()){let k=!1;for(const j of _t.values())if(!j.archived&&Rt(j.id)&&x.isPositionInArea(g.position,j)){const ae=s.get(j.id);ae?ae.push(g):s.set(j.id,[g]),k=!0;break}!k&&Lt(null)&&p.push(g)}const m=[];for(const[,g]of _t){if(g.archived||!Rt(g.id))continue;const k=t.get(g.id),j=s.get(g.id)??[];(k&&k.length>0||j.length>0)&&m.push({area:g,agents:k??[],buildings:j})}(n.length>0||p.length>0)&&m.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:p});const _=m.filter(g=>g.area.id!=="__unassigned__"),l=m.filter(g=>g.area.id==="__unassigned__");let A=1,N=1;const B=new Map;if(_.length>1){let g=1/0,k=-1/0,j=1/0,ae=-1/0;for(const L of _)g=Math.min(g,L.area.center.x),k=Math.max(k,L.area.center.x),j=Math.min(j,L.area.center.z),ae=Math.max(ae,L.area.center.z);const rt=k-g||1,ot=ae-j||1;if(_.length<=4){A=_.length,N=1;const L=[..._].sort((R,wt)=>R.area.center.x-wt.area.center.x);for(let R=0;R<L.length;R++)B.set(L[R].area.id,{row:1,col:R+1})}else{const L=[..._].sort((C,S)=>C.area.center.x-S.area.center.x),R=[];for(let C=1;C<L.length;C++)R.push(L[C].area.center.x-L[C-1].area.center.x);const wt=R.reduce((C,S)=>C+S,0)/R.length||1;let At=1;for(const C of R)C>wt*1.3&&At++;A=Math.max(2,Math.min(At,_.length));const vt=[..._].sort((C,S)=>C.area.center.z-S.area.center.z),ct=[];for(let C=1;C<vt.length;C++)ct.push(vt[C].area.center.z-vt[C-1].area.center.z);const en=ct.reduce((C,S)=>C+S,0)/ct.length||1;let It=1;for(const C of ct)C>en*1.3&&It++;N=Math.max(2,Math.min(It,_.length)),A=Math.max(A,Math.ceil(_.length/N)),N=Math.max(N,Math.ceil(_.length/A));const tn=rt/A,nn=ot/N,Ct=new Set;for(const C of _){let S=Math.min(A-1,Math.max(0,Math.floor((C.area.center.x-g)/tn))),ke=Math.min(N-1,Math.max(0,Math.floor((C.area.center.z-j)/nn))),He=`${ke},${S}`,Et=0;const an=N*A;for(;Ct.has(He)&&Et<an;)S++,S>=A&&(S=0,ke=(ke+1)%N),He=`${ke},${S}`,Et++;Ct.has(He)&&(ke=N,S=0,He=`${ke},${S}`,N++),Ct.add(He),B.set(C.area.id,{row:ke+1,col:S+1})}}}const lt=g=>{g.sort((k,j)=>{var rt,ot,L,R;const ae=(((rt=k.position)==null?void 0:rt.z)??0)-(((ot=j.position)==null?void 0:ot.z)??0);return ae!==0?ae:(((L=k.position)==null?void 0:L.x)??0)-(((R=j.position)==null?void 0:R.x)??0)})};for(const g of _)lt(g.agents);for(const g of l)lt(g.agents);return{groups:[..._,...l],gridCols:A,gridRows:N,positions:B}},[f,_t,it,Kt]),Zt=a.useMemo(()=>{if(!W)return[];const t=f.find(n=>n.id===W.agentId);return t?[{id:"edit-agent",label:"Edit Agent",icon:e.jsx(u,{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(u,{name:"chat",size:14}),onClick:()=>w(t.id)},{id:"delete-agent",label:"Delete Agent",icon:e.jsx(u,{name:"trash",size:14}),danger:!0,onClick:()=>{me({agentId:t.id,name:t.name})}}]:[]},[W,f,w]),Jt=a.useMemo(()=>{var _;if(!J)return[];const t=it.get(J.buildingId);if(!t)return[];const n=[],s=t.type==="server"||t.type==="docker"||t.type==="terminal",p=t.status==="running",m=t.type==="boss";if(n.push({id:"open",label:t.type==="database"?"Open Database":t.type==="folder"?"Open Folder":t.type==="boss"?"View Boss Logs":t.type==="terminal"?"Open Terminal":t.type==="server"&&((_=t.pm2)!=null&&_.enabled)?"View PM2 Logs":"Open",icon:e.jsx(u,{name:t.type==="database"?"database":t.type==="folder"?"folder":t.type==="terminal"?"terminal":"eye",size:14}),onClick:()=>we(t.id)}),s&&(p||n.push({id:"start",label:"Start",icon:e.jsx(u,{name:"play",size:14}),onClick:()=>x.sendBuildingCommand(t.id,"start")}),p&&(n.push({id:"restart",label:"Restart",icon:e.jsx(u,{name:"refresh",size:14}),onClick:()=>x.sendBuildingCommand(t.id,"restart")}),n.push({id:"stop",label:"Stop",icon:e.jsx(u,{name:"stop",size:14}),onClick:()=>x.sendBuildingCommand(t.id,"stop")}))),m&&t.subordinateBuildingIds&&t.subordinateBuildingIds.length>0&&(n.push({id:"start-all",label:"Start All Subordinates",icon:e.jsx(u,{name:"launch",size:14}),onClick:()=>{for(const l of t.subordinateBuildingIds)x.sendBuildingCommand(l,"start")}}),n.push({id:"stop-all",label:"Stop All Subordinates",icon:e.jsx(u,{name:"pause",size:14}),onClick:()=>{for(const l of t.subordinateBuildingIds)x.sendBuildingCommand(l,"stop")}}),n.push({id:"restart-all",label:"Restart All Subordinates",icon:e.jsx(u,{name:"restart",size:14}),onClick:()=>{for(const l of t.subordinateBuildingIds)x.sendBuildingCommand(l,"restart")}})),s&&n.push({id:"health-check",label:"Health Check",icon:e.jsx(u,{name:"health",size:14}),onClick:()=>x.sendBuildingCommand(t.id,"healthCheck")}),n.push({id:"divider-edit",label:"",divider:!0,onClick:()=>{}}),n.push({id:"edit",label:"Edit Building",icon:e.jsx(u,{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(u,{name:"copy",size:14}),onClick:()=>{x.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 l of t.urls)n.push({id:`url-${l.label}`,label:l.label,icon:e.jsx(u,{name:"link",size:14}),onClick:()=>window.open(l.url,"_blank","noopener,noreferrer")});return n.push({id:"divider-danger",label:"",divider:!0,onClick:()=>{}}),n.push({id:"delete",label:"Delete Building",icon:e.jsx(u,{name:"trash",size:14}),danger:!0,onClick:()=>x.deleteBuilding(t.id)}),n},[J,it,we]),Qt=a.useCallback(t=>{const n=new Set(Ne.groups.map(s=>s.area.id));n.delete(t),yt(n),requestAnimationFrame(()=>{const s=kt.current;if(!s)return;const p=s.querySelector(`[data-area-id="${t}"]`);if(!p)return;const m=s.getBoundingClientRect(),l=p.getBoundingClientRect().top-m.top+s.scrollTop-8;s.scrollTo({top:Math.max(0,l),behavior:"smooth"})})},[Ne]);return e.jsxs("div",{ref:ce,className:`flat-view ${q?"flat-view--with-inspector":""} ${h?"flat-view--has-chat":""} ${oe?"flat-view--mobile-sidebar-open":""}`,style:(()=>{if(G===null&&U===null)return;const t={};return G!==null&&(t["--flat-middle-width"]=`${G}px`),U!==null&&(t["--flat-inspector-width"]=`${U}px`),t})(),children:[oe&&e.jsx("div",{className:"flat-mobile-sidebar-backdrop",onClick:Ye,"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:Y,title:"Create new agent",children:"+ Agent"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--boss",onClick:F,title:"Create new boss agent",children:"+ Boss"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--area",onClick:Re,title:"Create new area",children:"+ Area"})]})}),e.jsx("div",{className:"flat-middle__content",children:e.jsx(pn,{activeAgentId:Te,onClose:Pe,onSelectAgent:bt,collapsedAreas:Xt,onToggleArea:Gt,agentListRef:kt})})]}),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:ge,onPointerMove:de,onPointerUp:xe,onPointerCancel:xe,onDoubleClick:ft}),e.jsxs("div",{className:"flat-right",children:[e.jsxs("button",{type:"button",className:"flat-mobile-sidebar-toggle","aria-label":oe?"Close agents sidebar":"Open agents sidebar","aria-expanded":oe,onClick:mt,children:[e.jsx(u,{name:"list",size:18}),e.jsx("span",{className:"flat-mobile-sidebar-toggle__label",children:"Agents"})]}),h?e.jsx(Zn,{agentId:h,terminalViewMode:qe,onTerminalViewModeChange:Ie,inspectorOpen:he,onToggleInspector:xt,onImageClick:ue,onFileClick:ee,onBashClick:Be,onViewMarkdown:Je,onRequestClearSubordinates:Qe,onOpenBuilding:we,keyboard:_e,canNavigateBack:et,canNavigateForward:te,onNavigateBack:r,onNavigateForward:d,agentInfoOpen:Ae,onToggleAgentInfo:ze,onHeaderContextMenu:t=>{h&&De({agentId:h,position:t})}}):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(Hn,{className:"flat-map__view-mode"})]}),e.jsx("div",{className:"flat-map__grid",style:{gridTemplateColumns:`repeat(${Ne.gridCols}, 1fr)`},children:Ne.groups.length===0?e.jsx("div",{className:"flat-map__empty",children:e.jsx("span",{children:"No areas or agents yet"})}):(()=>{var n;const t=je&&st?((n=Ne.positions.get(st))==null?void 0:n.row)??null:null;return Ne.groups.map(s=>{const p=s.area.id,m=Ne.positions.get(p),_=je&&st!==p;return je&&t!=null&&(m==null?void 0:m.row)===t&&p!==st?null:e.jsxs("div",{className:`flat-map-area-card${_?" flat-map-area-card--collapsed":""}`,style:{"--area-color":s.area.color,gridRow:m==null?void 0:m.row,gridColumn:m==null?void 0:m.col},onContextMenu:l=>{E&&(l.preventDefault(),l.stopPropagation(),E(p,{x:l.clientX,y:l.clientY}))},children:[e.jsxs("button",{type:"button",className:"flat-map-area-card__header",onClick:()=>je?Yt(p):Qt(p),title:je?_?`Expand ${s.area.name}`:`Collapse ${s.area.name}`:`Focus ${s.area.name} in left panel`,"aria-expanded":je?!_:void 0,children:[e.jsx("span",{className:"flat-map-area-card__color",style:{background:s.area.color}}),e.jsx("span",{className:"flat-map-area-card__name",children:s.area.name}),e.jsx("span",{className:"flat-map-area-card__count",children:s.agents.length}),je&&e.jsx(u,{name:_?"caret-down":"caret-up",size:11,className:"flat-map-area-card__caret"})]}),e.jsx("div",{className:"flat-map-area-card__agents",children:s.agents.map(l=>{const A=l.isBoss||l.class==="boss",N=A?at.get(l.id):void 0,B=mn(l),lt=B.usedPercent>=80?"#ff4a4a":B.usedPercent>=60?"#ff9e4a":B.usedPercent>=40?"#ffd700":"#4aff9e",g=`Context: ${(B.totalTokens/1e3).toFixed(1)}k / ${(B.contextWindow/1e3).toFixed(1)}k (${B.usedPercent}% used, ${B.freePercent}% free)`,k=l.latestTodos&&l.latestTodos.length>0||N&&N.length>0;return e.jsx(fn,{todos:l.latestTodos,subordinates:N,position:"top",children:e.jsxs("button",{type:"button",className:`flat-map-agent-chip ${l.status}`,onClick:()=>w(l.id),onContextMenu:j=>{j.preventDefault(),j.stopPropagation(),De({agentId:l.id,position:{x:j.clientX,y:j.clientY}})},title:k?void 0:`${A?"Boss · ":""}Open chat with ${l.name}
2
+ ${g}`,children:[e.jsx(Ht,{agent:l,size:16}),A&&e.jsx("span",{className:"flat-map-agent-chip__crown","aria-hidden":"true",children:e.jsx(u,{name:"crown",size:11,color:"#ffd700",weight:"fill"})}),e.jsx("span",{className:"flat-map-agent-chip__name",children:l.name}),e.jsx("img",{src:l.provider==="codex"?"/assets/codex.png":l.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:l.provider,className:"flat-map-agent-chip__provider-icon",title:l.provider==="codex"?"Codex Agent":l.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),e.jsx("span",{className:"flat-map-agent-chip__dot",style:{backgroundColor:Vt(l.status)}}),l.latestTodos&&l.latestTodos.length>0&&e.jsx(hn,{todos:l.latestTodos,maxDots:6}),A&&N&&N.length>0&&e.jsx(gn,{subordinates:N,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:`${B.usedPercent}%`,backgroundColor:lt}})})]})},l.id)})}),s.buildings.length>0&&e.jsx("div",{className:"flat-map-area-card__buildings",children:s.buildings.map(l=>e.jsxs("button",{type:"button",className:`flat-map-building-chip flat-map-building-chip--${l.status}`,onClick:A=>{if(I){const N=A.currentTarget.getBoundingClientRect();I(l.id,{x:N.right,y:N.top+N.height/2})}else we(l.id)},onContextMenu:A=>{A.preventDefault(),A.stopPropagation(),b({buildingId:l.id,position:{x:A.clientX,y:A.clientY}})},title:`${l.name} · ${l.type} · ${l.status}`,children:[e.jsx(u,{name:xn(l.type),size:12}),e.jsx("span",{className:"flat-map-building-chip__name",children:l.name}),e.jsx("span",{className:"flat-map-building-chip__dot",style:{backgroundColor:bn(l.status)}})]},l.id))})]},p)})})()})]})})]}),q&&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:Ke,onPointerMove:de,onPointerUp:xe,onPointerCancel:xe,onDoubleClick:ht}),Le&&e.jsxs("aside",{className:`flat-inspector ${M?"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":be==="agent",className:`flat-inspector__tab ${be==="agent"?"flat-inspector__tab--active":""}`,onClick:()=>Ze("agent"),children:"Agent"}),e.jsx("button",{type:"button",role:"tab","aria-selected":be==="tracking",className:`flat-inspector__tab ${be==="tracking"?"flat-inspector__tab--active":""}`,onClick:()=>Ze("tracking"),children:"Tracking"})]}),e.jsx("button",{type:"button",className:"flat-inspector__close",onClick:$e,title:"Close inspector","aria-label":"Close inspector",children:"✕"})]}),e.jsx("div",{className:"flat-inspector__body",children:be==="tracking"?e.jsx(_n,{activeAgentId:h??"",onSelectAgent:t=>{w(t),window.innerWidth<=768&&$e()}}):(()=>{if(!h)return e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Select an agent to inspect"})});const t=f.find(n=>n.id===h);return t?e.jsx(wn,{agent:t,onFocusAgent:n=>{w(n),window.innerWidth<=768&&$e()},onKillAgent:n=>x.killAgent(n)}):e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Agent not found"})})})()})]}),ye&&e.jsx(vn,{url:ye.url,name:ye.name,onClose:()=>Ve(null)}),Xe&&e.jsx(Cn,{state:Xe,onClose:()=>Ge(null)}),Z&&e.jsx(jn,{action:"clear-subordinates",selectedAgentId:Z.agentId,subordinateCount:Z.count,onClose:()=>le(null),onClearHistory:()=>{}}),e.jsx(Nn,{agent:h?f.find(t=>t.id===h)??null:null,isOpen:Ae&&!!h,onClose:Ue}),e.jsx(Dt,{isOpen:W!==null,position:(W==null?void 0:W.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:Zt,onClose:()=>De(null)}),e.jsx(Dt,{isOpen:J!==null,position:(J==null?void 0:J.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:Jt,onClose:()=>b(null)}),e.jsx(kn,{isOpen:T!==null,title:ie("common:confirm.removeAgentTitle"),message:ie("common:confirm.removeAgentMessage",{name:(T==null?void 0:T.name)??""}),confirmLabel:ie("common:buttons.remove"),cancelLabel:ie("common:buttons.cancel"),variant:"danger",onConfirm:()=>{T&&x.removeAgentFromServer(T.agentId)},onClose:()=>me(null)})]})}export{ta as FlatView};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-bKiHKTT6.js","assets/main-BUO6--48.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-BfT_95fk.css"])))=>i.map(i=>d[i]);
2
- import{c9 as e,bC as o}from"./main-BUO6--48.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";var i;(function(r){r.Heavy="HEAVY",r.Medium="MEDIUM",r.Light="LIGHT"})(i||(i={}));var t;(function(r){r.Success="SUCCESS",r.Warning="WARNING",r.Error="ERROR"})(t||(t={}));const c=e("Haptics",{web:()=>o(()=>import("./web-bKiHKTT6.js"),__vite__mapDeps([0,1,2,3,4])).then(r=>new r.HapticsWeb)});export{c as Haptics,i as ImpactStyle,t as NotificationType};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-CGYGq80f.js","assets/main-CteALl_G.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-BfT_95fk.css"])))=>i.map(i=>d[i]);
2
+ import{c9 as e,bC as o}from"./main-CteALl_G.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";var i;(function(r){r.Heavy="HEAVY",r.Medium="MEDIUM",r.Light="LIGHT"})(i||(i={}));var t;(function(r){r.Success="SUCCESS",r.Warning="WARNING",r.Error="ERROR"})(t||(t={}));const c=e("Haptics",{web:()=>o(()=>import("./web-CGYGq80f.js"),__vite__mapDeps([0,1,2,3,4])).then(r=>new r.HapticsWeb)});export{c as Haptics,i as ImpactStyle,t as NotificationType};
@@ -1,4 +1,4 @@
1
- import{bg as ta,u as B,j as e,aL as j,bj as Ms,bk as Fs,aM as Ue,s as D,bl as $s,r as d,D as Z,I as F,a2 as Us,aV as Ve,f as na,bm as la,J as ia,S as oa,h as ra,bn as Ks,aW as He}from"./main-BUO6--48.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 ma(o){return ta.t(o)}function qe(o){if(o===0)return"0 B";const p=1024,u=["B","KB","MB","GB"],x=Math.floor(Math.log(o)/Math.log(p));return parseFloat((o/Math.pow(p,x)).toFixed(1))+" "+u[x]}function da(o){const u=Date.now()-o,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 Vs(o){const p=[],u=/\x1B\[([0-9;]*)m/g;let x=0,n=null,y;for(;(y=u.exec(o))!==null;){if(y.index>x){const g=o.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<o.length){const C=o.slice(x);n?p.push(e.jsx("span",{style:{color:n},children:C},p.length)):p.push(C)}return p.length>0?p:[o]}function ua({buildingName:o,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:o})}),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:o,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:o,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:o,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:r}){var N;const{t:i}=B(["terminal","common"]);return o?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:o})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Arguments"),e.jsx(j,{text:i("terminal:building.helpPm2Arguments"),title:i("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:x,onChange:b=>n(b.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Interpreter"),e.jsx(j,{text:i("terminal:building.helpPm2Interpreter"),title:i("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:y,onChange:b=>C(b.target.value),children:Object.keys(Ms).map(b=>e.jsx("option",{value:b,children:Ms[b].label},b))})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2InterpArgs"),e.jsx(j,{text:i("terminal:building.helpPm2InterpArgs"),title:i("terminal:building.pm2InterpArgs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:b=>v(b.target.value),placeholder:"-jar (for Java)"})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Environment"),e.jsx(j,{text:i("terminal:building.helpPm2Environment"),title:i("terminal:building.pm2Environment"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:s,onChange:b=>h(b.target.value),placeholder:`KEY=value
1
+ import{bg as ta,u as B,j as e,aL as j,bj as Ms,bk as Fs,aM as Ue,s as D,bl as $s,r as d,D as Z,I as F,a2 as Us,aV as Ve,f as na,bm as la,J as ia,S as oa,h as ra,bn as Ks,aW as He}from"./main-CteALl_G.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 ma(o){return ta.t(o)}function qe(o){if(o===0)return"0 B";const p=1024,u=["B","KB","MB","GB"],x=Math.floor(Math.log(o)/Math.log(p));return parseFloat((o/Math.pow(p,x)).toFixed(1))+" "+u[x]}function da(o){const u=Date.now()-o,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 Vs(o){const p=[],u=/\x1B\[([0-9;]*)m/g;let x=0,n=null,y;for(;(y=u.exec(o))!==null;){if(y.index>x){const g=o.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<o.length){const C=o.slice(x);n?p.push(e.jsx("span",{style:{color:n},children:C},p.length)):p.push(C)}return p.length>0?p:[o]}function ua({buildingName:o,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:o})}),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:o,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:o,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:o,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:r}){var N;const{t:i}=B(["terminal","common"]);return o?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:o})]}),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
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:qe(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:da(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:c,setSelectedExistingContainer:E,dockerContainersList:V,isEditMode:q,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(Ue,{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:c,onChange:l=>E(l.target.value),required:o==="existing",children:[e.jsx("option",{value:"",children:"Select a container..."}),V.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:"↻"})]})]}),V.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."}),c&&e.jsx("div",{className:"docker-existing-info",children:(()=>{const l=V.find(S=>S.name===c);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
4
4
  DATABASE_URL=postgres://...