tide-commander 1.76.2 → 1.77.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 (35) hide show
  1. package/dist/assets/{BossLogsModal-B41BvcEF.js → BossLogsModal-DadqfwM-.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-DUTcju8I.js → BossSpawnModal-BfBD2177.js} +1 -1
  3. package/dist/assets/{ControlsModal-DbiIdKPt.js → ControlsModal-C7k19rVV.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-5mrsMmlQ.js → DockerLogsModal-zerJaMSY.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-DirMT3E8.js → EmbeddedEditor-C_sbdn9e.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-CmGKGxui.js → GmailOAuthSetup-CWUAVZZM.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-CbWwCAK0.js → GoogleOAuthSetup-E7aWGuMy.js} +1 -1
  8. package/dist/assets/{IframeModal-Dboa4JXN.js → IframeModal-BNwvP8Po.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-DS28YNJo.js → IntegrationsPanel-CWQ5Uum4.js} +2 -2
  10. package/dist/assets/{LogViewerModal-UbrMLs2v.js → LogViewerModal-BCXMLdRH.js} +1 -1
  11. package/dist/assets/{MonitoringModal-B_XI1vTS.js → MonitoringModal-DK79sc5N.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-ChvPf5Uv.js → PM2LogsModal-Bh3w4epV.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-CEq_4zoQ.js → RestoreArchivedAreaModal-B-H5Skrp.js} +1 -1
  14. package/dist/assets/{Scene2DCanvas-DYDA_fv5.js → Scene2DCanvas-B9UN5ZKm.js} +1 -1
  15. package/dist/assets/{SceneManager-Be_I2Z9r.js → SceneManager-FjdQYco5.js} +1 -1
  16. package/dist/assets/{SkillsPanel-CNIkJScD.js → SkillsPanel-B9C8MwOF.js} +1 -1
  17. package/dist/assets/{SpawnModal-BXV32TQn.js → SpawnModal-D_LcFbP1.js} +1 -1
  18. package/dist/assets/{SubordinateAssignmentModal-DK3uJtBR.js → SubordinateAssignmentModal-BoanKhXq.js} +1 -1
  19. package/dist/assets/{TriggerManagerPanel-C8JheOOO.js → TriggerManagerPanel-Ck-tzKLv.js} +1 -1
  20. package/dist/assets/{WorkflowEditorPanel-DeLnt3ou.js → WorkflowEditorPanel-Bwvw_Vgj.js} +1 -1
  21. package/dist/assets/{index-C2QVwmIa.js → index-7isjCekP.js} +1 -1
  22. package/dist/assets/{index-D6ez6g4v.js → index-8lOgiTZV.js} +1 -1
  23. package/dist/assets/{index-C-HNvKyN.js → index-B5v0FpYR.js} +1 -1
  24. package/dist/assets/{index-BZFjiZW2.js → index-BAwissdJ.js} +1 -1
  25. package/dist/assets/{index-BR3DNqtn.js → index-BJJScfkg.js} +1 -1
  26. package/dist/assets/{index-DXjESpea.js → index-BKq2RkPI.js} +3 -3
  27. package/dist/assets/{index-B7BnOlMV.js → index-Baz89OXb.js} +2 -2
  28. package/dist/assets/index-DMa3VOph.js +2 -0
  29. package/dist/assets/{index-CymWdB1l.js → index-DvKJEzc1.js} +1 -1
  30. package/dist/assets/{main-BvvvhWnd.js → main-CiaEK7il.js} +89 -89
  31. package/dist/assets/{web-Dyi_JNTJ.js → web-BdPxI-ix.js} +1 -1
  32. package/dist/assets/{web-B-5bt6Uj.js → web-C1fk4YYO.js} +1 -1
  33. package/dist/index.html +1 -1
  34. package/package.json +1 -1
  35. package/dist/assets/index-DHlpIGVI.js +0 -2
@@ -1 +1 @@
1
- import{c5 as a}from"./main-BvvvhWnd.js";import{ImpactStyle as i,NotificationType as r}from"./index-B7BnOlMV.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";class h extends a{constructor(){super(...arguments),this.selectionStarted=!1}async impact(t){const e=this.patternForImpact(t==null?void 0:t.style);this.vibrateWithPattern(e)}async notification(t){const e=this.patternForNotification(t==null?void 0:t.type);this.vibrateWithPattern(e)}async vibrate(t){const e=(t==null?void 0:t.duration)||300;this.vibrateWithPattern([e])}async selectionStart(){this.selectionStarted=!0}async selectionChanged(){this.selectionStarted&&this.vibrateWithPattern([70])}async selectionEnd(){this.selectionStarted=!1}patternForImpact(t=i.Heavy){return t===i.Medium?[43]:t===i.Light?[20]:[61]}patternForNotification(t=r.Success){return t===r.Warning?[30,40,30,50,60]:t===r.Error?[27,45,50]:[35,65,21]}vibrateWithPattern(t){if(navigator.vibrate)navigator.vibrate(t);else throw this.unavailable("Browser does not support the vibrate API")}}export{h as HapticsWeb};
1
+ import{c5 as a}from"./main-CiaEK7il.js";import{ImpactStyle as i,NotificationType as r}from"./index-Baz89OXb.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";class h extends a{constructor(){super(...arguments),this.selectionStarted=!1}async impact(t){const e=this.patternForImpact(t==null?void 0:t.style);this.vibrateWithPattern(e)}async notification(t){const e=this.patternForNotification(t==null?void 0:t.type);this.vibrateWithPattern(e)}async vibrate(t){const e=(t==null?void 0:t.duration)||300;this.vibrateWithPattern([e])}async selectionStart(){this.selectionStarted=!0}async selectionChanged(){this.selectionStarted&&this.vibrateWithPattern([70])}async selectionEnd(){this.selectionStarted=!1}patternForImpact(t=i.Heavy){return t===i.Medium?[43]:t===i.Light?[20]:[61]}patternForNotification(t=r.Success){return t===r.Warning?[30,40,30,50,60]:t===r.Error?[27,45,50]:[35,65,21]}vibrateWithPattern(t){if(navigator.vibrate)navigator.vibrate(t);else throw this.unavailable("Browser does not support the vibrate API")}}export{h as HapticsWeb};
@@ -1 +1 @@
1
- import{c5 as s}from"./main-BvvvhWnd.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";class l extends s{constructor(){super(...arguments),this.pending=[],this.deliveredNotifications=[],this.hasNotificationSupport=()=>{if(!("Notification"in window)||!Notification.requestPermission)return!1;if(Notification.permission!=="granted")try{new Notification("")}catch(i){if(i instanceof Error&&i.name==="TypeError")return!1}return!0}}async getDeliveredNotifications(){const i=[];for(const t of this.deliveredNotifications){const e={title:t.title,id:parseInt(t.tag),body:t.body};i.push(e)}return{notifications:i}}async removeDeliveredNotifications(i){for(const t of i.notifications){const e=this.deliveredNotifications.find(n=>n.tag===String(t.id));e==null||e.close(),this.deliveredNotifications=this.deliveredNotifications.filter(()=>!e)}}async removeAllDeliveredNotifications(){for(const i of this.deliveredNotifications)i.close();this.deliveredNotifications=[]}async createChannel(){throw this.unimplemented("Not implemented on web.")}async deleteChannel(){throw this.unimplemented("Not implemented on web.")}async listChannels(){throw this.unimplemented("Not implemented on web.")}async schedule(i){if(!this.hasNotificationSupport())throw this.unavailable("Notifications not supported in this browser.");for(const t of i.notifications)this.sendNotification(t);return{notifications:i.notifications.map(t=>({id:t.id}))}}async getPending(){return{notifications:this.pending}}async registerActionTypes(){throw this.unimplemented("Not implemented on web.")}async cancel(i){this.pending=this.pending.filter(t=>!i.notifications.find(e=>e.id===t.id))}async areEnabled(){const{display:i}=await this.checkPermissions();return{value:i==="granted"}}async changeExactNotificationSetting(){throw this.unimplemented("Not implemented on web.")}async checkExactNotificationSetting(){throw this.unimplemented("Not implemented on web.")}async requestPermissions(){if(!this.hasNotificationSupport())throw this.unavailable("Notifications not supported in this browser.");return{display:this.transformNotificationPermission(await Notification.requestPermission())}}async checkPermissions(){if(!this.hasNotificationSupport())throw this.unavailable("Notifications not supported in this browser.");return{display:this.transformNotificationPermission(Notification.permission)}}transformNotificationPermission(i){switch(i){case"granted":return"granted";case"denied":return"denied";default:return"prompt"}}sendPending(){var i;const t=[],e=new Date().getTime();for(const n of this.pending)!((i=n.schedule)===null||i===void 0)&&i.at&&n.schedule.at.getTime()<=e&&(this.buildNotification(n),t.push(n));this.pending=this.pending.filter(n=>!t.find(o=>o===n))}sendNotification(i){var t;if(!((t=i.schedule)===null||t===void 0)&&t.at){const e=i.schedule.at.getTime()-new Date().getTime();this.pending.push(i),setTimeout(()=>{this.sendPending()},e);return}this.buildNotification(i)}buildNotification(i){const t=new Notification(i.title,{body:i.body,tag:String(i.id)});return t.addEventListener("click",this.onClick.bind(this,i),!1),t.addEventListener("show",this.onShow.bind(this,i),!1),t.addEventListener("close",()=>{this.deliveredNotifications=this.deliveredNotifications.filter(()=>!this)},!1),this.deliveredNotifications.push(t),t}onClick(i){const t={actionId:"tap",notification:i};this.notifyListeners("localNotificationActionPerformed",t)}onShow(i){this.notifyListeners("localNotificationReceived",i)}}export{l as LocalNotificationsWeb};
1
+ import{c5 as s}from"./main-CiaEK7il.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";class l extends s{constructor(){super(...arguments),this.pending=[],this.deliveredNotifications=[],this.hasNotificationSupport=()=>{if(!("Notification"in window)||!Notification.requestPermission)return!1;if(Notification.permission!=="granted")try{new Notification("")}catch(i){if(i instanceof Error&&i.name==="TypeError")return!1}return!0}}async getDeliveredNotifications(){const i=[];for(const t of this.deliveredNotifications){const e={title:t.title,id:parseInt(t.tag),body:t.body};i.push(e)}return{notifications:i}}async removeDeliveredNotifications(i){for(const t of i.notifications){const e=this.deliveredNotifications.find(n=>n.tag===String(t.id));e==null||e.close(),this.deliveredNotifications=this.deliveredNotifications.filter(()=>!e)}}async removeAllDeliveredNotifications(){for(const i of this.deliveredNotifications)i.close();this.deliveredNotifications=[]}async createChannel(){throw this.unimplemented("Not implemented on web.")}async deleteChannel(){throw this.unimplemented("Not implemented on web.")}async listChannels(){throw this.unimplemented("Not implemented on web.")}async schedule(i){if(!this.hasNotificationSupport())throw this.unavailable("Notifications not supported in this browser.");for(const t of i.notifications)this.sendNotification(t);return{notifications:i.notifications.map(t=>({id:t.id}))}}async getPending(){return{notifications:this.pending}}async registerActionTypes(){throw this.unimplemented("Not implemented on web.")}async cancel(i){this.pending=this.pending.filter(t=>!i.notifications.find(e=>e.id===t.id))}async areEnabled(){const{display:i}=await this.checkPermissions();return{value:i==="granted"}}async changeExactNotificationSetting(){throw this.unimplemented("Not implemented on web.")}async checkExactNotificationSetting(){throw this.unimplemented("Not implemented on web.")}async requestPermissions(){if(!this.hasNotificationSupport())throw this.unavailable("Notifications not supported in this browser.");return{display:this.transformNotificationPermission(await Notification.requestPermission())}}async checkPermissions(){if(!this.hasNotificationSupport())throw this.unavailable("Notifications not supported in this browser.");return{display:this.transformNotificationPermission(Notification.permission)}}transformNotificationPermission(i){switch(i){case"granted":return"granted";case"denied":return"denied";default:return"prompt"}}sendPending(){var i;const t=[],e=new Date().getTime();for(const n of this.pending)!((i=n.schedule)===null||i===void 0)&&i.at&&n.schedule.at.getTime()<=e&&(this.buildNotification(n),t.push(n));this.pending=this.pending.filter(n=>!t.find(o=>o===n))}sendNotification(i){var t;if(!((t=i.schedule)===null||t===void 0)&&t.at){const e=i.schedule.at.getTime()-new Date().getTime();this.pending.push(i),setTimeout(()=>{this.sendPending()},e);return}this.buildNotification(i)}buildNotification(i){const t=new Notification(i.title,{body:i.body,tag:String(i.id)});return t.addEventListener("click",this.onClick.bind(this,i),!1),t.addEventListener("show",this.onShow.bind(this,i),!1),t.addEventListener("close",()=>{this.deliveredNotifications=this.deliveredNotifications.filter(()=>!this)},!1),this.deliveredNotifications.push(t),t}onClick(i){const t={actionId:"tap",notification:i};this.notifyListeners("localNotificationActionPerformed",t)}onShow(i){this.notifyListeners("localNotificationReceived",i)}}export{l as LocalNotificationsWeb};
package/dist/index.html CHANGED
@@ -22,7 +22,7 @@
22
22
  <link rel="icon" type="image/png" sizes="16x16" href="/assets/icons/favicon-16x16.png" />
23
23
  <link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/apple-touch-icon.png" />
24
24
  <title>Tide Commander</title>
25
- <script type="module" crossorigin src="/assets/main-BvvvhWnd.js"></script>
25
+ <script type="module" crossorigin src="/assets/main-CiaEK7il.js"></script>
26
26
  <link rel="modulepreload" crossorigin href="/assets/vendor-react--Eh9ivFN.js">
27
27
  <link rel="modulepreload" crossorigin href="/assets/vendor-three-Chj50gSY.js">
28
28
  <link rel="stylesheet" crossorigin href="/assets/main-Co2mNETL.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tide-commander",
3
- "version": "1.76.2",
3
+ "version": "1.77.0",
4
4
  "description": "Visual multi-agent orchestrator and manager for Claude Code with 3D/2D interface",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,2 +0,0 @@
1
- import{u as Et,z as yt,B as Pt,r as n,E as ht,S as w,G as gt,H as dt,J as xt,K as Xe,L as pe,M as Dt,s as C,N as Ct,O as Rt,v as zt,w as Lt,j as e,I as u,P as $t,m as Ot,U as Ft,V as jt,W as Nt,X as Bt,Y as Wt,Z as Ht,_ as Gt,$ as Vt,a0 as Ut,a1 as Xt,a2 as qt,a3 as Kt,C as Yt,a4 as Zt,a5 as Jt,a6 as Qt,a7 as ea,a8 as ta,a9 as aa,aa as na,ab as sa,ac as la,ad as ra,ae as ia,af as oa,ag as ca,ah as da,ai as pa,aj as ua,ak as ma}from"./main-BvvvhWnd.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const qe=3,Ke=280,_t=320,ct=240,bt=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"},wt="flat-clear-context";function _a(f){const c=f.split("/").filter(Boolean);return c.length===0?f:c.slice(-2).join("/")}function ba(f){if(f.provider==="codex"){const ne=f.codexModel||"gpt-5.3-codex",R=pa[ne];return{model:(R==null?void 0:R.label)||ne}}if(f.provider==="opencode")return{model:f.opencodeModel||"opencode"};const c=f.model||"sonnet",N=ma[c],T=f.effort,D=T?ua[T]:void 0;return{model:(N==null?void 0:N.label)||c,effort:D==null?void 0:D.label}}function wa(f,c){if(c.type==="rectangle"&&c.width&&c.height){const N=c.width/2,T=c.height/2;return f.x>=c.center.x-N&&f.x<=c.center.x+N&&f.z>=c.center.z-T&&f.z<=c.center.z+T}if(c.type==="circle"&&c.radius){const N=f.x-c.center.x,T=f.z-c.center.z;return N*N+T*T<=c.radius*c.radius}return!1}const Ca=Zt.memo(function({agentId:c,terminalViewMode:N,onTerminalViewModeChange:T,inspectorOpen:D,onToggleInspector:ne,onImageClick:R,onFileClick:S,onBashClick:ue,onViewMarkdown:me,onRequestClearSubordinates:ke,onOpenBuilding:fe,keyboard:Ae,canNavigateBack:he,canNavigateForward:Ie,onNavigateBack:y,onNavigateForward:se,agentInfoOpen:z,onToggleAgentInfo:Se}){var $e,Oe,je,Fe;const p=Jt(c),P=Qt(),le=n.useRef(null),Me=n.useRef(null);n.useEffect(()=>{const l=Me.current;if(!l)return;const d=i=>{i.button===3?(i.preventDefault(),i.stopPropagation(),y()):i.button===4&&(i.preventDefault(),i.stopPropagation(),se())},o=i=>{(i.button===3||i.button===4)&&i.preventDefault()};return l.addEventListener("mouseup",d),l.addEventListener("mousedown",o),()=>{l.removeEventListener("mouseup",d),l.removeEventListener("mousedown",o)}},[y,se]);const ge=Ct(),re=n.useMemo(()=>{if(!p)return null;const l=new Set,d=[];for(const o of ge.values())o.archived||o.directories.length===0||o.assignedAgentIds.includes(c)&&(l.add(o.id),d.push(o));for(const o of ge.values())o.archived||o.directories.length===0||l.has(o.id)||wa({x:p.position.x,z:p.position.z},o)&&(l.add(o.id),d.push(o));return d.length===0?null:d.flatMap(o=>o.directories.filter(i=>i&&i.trim().length>0).map(i=>({areaId:o.id,areaName:o.name,dir:i})))},[p,c,ge]),{branches:Te,fetchRemote:xe,fetchingDirs:_e}=ea(re),F=n.useMemo(()=>{var o;const l=C.getAreaForAgent(c);if(!l)return[];const d=[];for(const i of P.values())i.type==="terminal"&&C.isPositionInArea(i.position,l)&&d.push({id:i.id,name:i.name,hasUrl:!!((o=i.terminalStatus)!=null&&o.url)});return d},[c,P]),ie=n.useMemo(()=>{var o;const l=C.getAreaForAgent(c);if(!l)return[];const d=[];for(const i of P.values())i.type==="server"&&((o=i.pm2)!=null&&o.enabled)&&C.isPositionInArea(i.position,l)&&d.push({id:i.id,name:i.name});return d},[c,P]),Ee=n.useMemo(()=>{const l=C.getAreaForAgent(c);if(!l)return[];const d=[];for(const o of P.values())o.type==="database"&&o.database&&C.isPositionInArea(o.position,l)&&d.push({id:o.id,name:o.name});return d},[c,P]),[,Ye]=n.useReducer(l=>l+1,0),B=(($e=le.current)==null?void 0:$e.search.searchMode)??!1,J=n.useCallback(()=>{var l;(l=le.current)==null||l.search.toggleSearch(),Ye()},[]),U=ta(),X=U.isPending(wt),[k,W]=n.useState(null),M=k?P.get(k):null,{height:q,onResizeStart:Ze}=aa(),[Q,be]=n.useState(()=>dt(w.GIT_PANEL_OPEN,!1)),[L,ye]=n.useState(()=>dt(w.BUILDINGS_PANEL_OPEN,!1)),[ee,K]=n.useState(!1),Je=n.useCallback(()=>{K(l=>{const d=!l;return d&&na.setEnabled(!0),d})},[]),Pe=n.useCallback(()=>K(!1),[]),Qe=n.useCallback(()=>{be(l=>{const d=!l;return pe(w.GIT_PANEL_OPEN,d),d})},[]),et=n.useCallback(()=>{ye(l=>{const d=!l;return pe(w.BUILDINGS_PANEL_OPEN,d),d})},[]),tt=n.useCallback(()=>{be(!1),pe(w.GIT_PANEL_OPEN,!1)},[]),at=n.useCallback(()=>{ye(!1),pe(w.BUILDINGS_PANEL_OPEN,!1)},[]),nt=sa();n.useEffect(()=>{if(!k)return;F.some(d=>d.id===k)||W(null)},[k,F]);const[te,Y]=n.useState(!1),we=n.useRef(null);if(n.useEffect(()=>{if(!te)return;const l=d=>{we.current&&!we.current.contains(d.target)&&Y(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[te]),!p)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 H=p.contextStats,b=!!H,Z=H?H.totalTokens:p.contextUsed||0,G=H?H.contextWindow:p.contextLimit||2e5,Ce=H?H.usedPercent:Math.round(Z/G*100),V=Math.max(0,Math.min(100,Ce)),st=Math.max(0,100-V),De=V>=80?"#ff4a4a":V>=60?"#ff9e4a":V>=40?"#ffd700":"#4aff9e",Re=(Z/1e3).toFixed(1),ze=(G/1e3).toFixed(1),$=p.cwd,Le=$?_a($):null,E=((Oe=p.subordinateIds)==null?void 0:Oe.length)||0,oe=E>0;return e.jsxs("div",{ref:Me,className:`flat-terminal-wrapper ${Q||L||ee?"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 ${z?"flat-terminal-wrapper__header-main--active":""}`,onClick:Se,title:z?"Hide agent info":"Show agent info","aria-pressed":z,children:[e.jsx(jt,{agent:p,size:28}),e.jsxs("span",{className:"flat-terminal-wrapper__header-info",children:[e.jsx("span",{className:"flat-terminal-wrapper__header-name",children:p.name}),e.jsx("span",{className:"flat-terminal-wrapper__header-status",style:{color:Nt(p.status)},children:p.status})]}),p.taskLabel&&e.jsxs("span",{className:"flat-terminal-wrapper__header-task",title:p.taskLabel,children:["📋 ",p.taskLabel]}),e.jsxs("span",{className:"flat-terminal-wrapper__header-model",children:[e.jsx("img",{src:p.provider==="codex"?"/assets/codex.png":p.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:p.provider,className:"flat-terminal-wrapper__header-provider-icon",title:p.provider==="codex"?"Codex Agent":p.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),(()=>{const{model:l,effort:d}=ba(p);return e.jsxs("span",{className:"flat-terminal-wrapper__header-model-chip",title:d?`Model: ${l} · Effort: ${d}`:`Model: ${l}`,children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-name",children:l}),d&&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:d})]})]})})()]})]}),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:fa.map(l=>e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${N===l?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>T(l),title:xa[l],"aria-pressed":N===l,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:ga[l]}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:ha[l]})]},l))}),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:y,disabled:!he,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:se,disabled:!Ie,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 ${B?"flat-terminal-wrapper__action-btn--active":""}`,onClick:J,title:B?"Close search":"Search messages","aria-pressed":B,children:e.jsx(u,{name:B?"cross":"search",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn flat-terminal-wrapper__action-btn--danger ${X?"flat-terminal-wrapper__action-btn--confirm":""}`,onClick:()=>U.handleClick(wt,()=>{var l;C.clearContext(c),(l=le.current)==null||l.historyLoader.clearHistory()}),title:X?"Click again to confirm clear context":"Clear context",children:e.jsx(u,{name:X?"question":"clear",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${Q?"flat-terminal-wrapper__action-btn--active":""}`,onClick:Qe,title:Q?"Hide git panel":"Show git changes","aria-pressed":Q,children:e.jsx(u,{name:"git-branch",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${L?"flat-terminal-wrapper__action-btn--active":""}`,onClick:et,title:L?"Hide buildings panel":"Show area buildings","aria-pressed":L,children:e.jsx(u,{name:"buildings",size:14})}),e.jsxs("div",{className:"flat-terminal-wrapper__more",ref:we,children:[e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${te?"flat-terminal-wrapper__action-btn--active":""}`,onClick:()=>Y(l=>!l),title:"More actions","aria-expanded":te,children:"⋮"}),te&&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 ${ee?"flat-terminal-wrapper__more-item--active":""}`,onClick:()=>{Je(),Y(!1)},title:ee?"Hide Debug Panel":"Show Debug Panel",children:[e.jsx(u,{name:"bug",size:14}),e.jsx("span",{children:ee?"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:()=>{C.collapseContext(c),Y(!1)},disabled:p.status!=="idle",title:p.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"})]}),oe&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{ke(c,E),Y(!1)},children:[e.jsx(u,{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:()=>{C.killAgent(c),Y(!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 ${D?"flat-terminal-wrapper__inspector-toggle--active":""}`,onClick:ne,title:D?"Hide inspector panel":"Show inspector panel","aria-label":D?"Hide inspector panel":"Show inspector panel","aria-pressed":D,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:()=>C.deselectAll(),title:"Close chat","aria-label":"Close chat",children:e.jsx(u,{name:"cross",size:14})})]})]}),e.jsx(la,{ref:le,agentId:c,agent:p,viewMode:N,isOpen:!0,onImageClick:R,onFileClick:S,onBashClick:ue,onViewMarkdown:me,keyboard:Ae,hasModalOpen:!1}),M&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:Ze,role:"separator","aria-orientation":"horizontal","aria-label":"Resize embedded terminal"}),e.jsxs("div",{className:"flat-bottom-panel",role:"region","aria-label":`Embedded terminal: ${M.name}`,style:{height:q},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:M.name}),!((je=M.terminalStatus)!=null&&je.url)&&e.jsx("span",{className:"flat-bottom-panel__muted",children:"(starting...)"})]}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>W(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:(Fe=M.terminalStatus)!=null&&Fe.url?e.jsx(ra,{terminalUrl:M.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:[p.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"})]}),$&&Le&&e.jsxs("span",{className:"flat-terminal-wrapper__cwd",title:$,onClick:()=>C.setFileViewerPath($),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:Le})]}),re&&re.map(({areaId:l,areaName:d,dir:o})=>{const i=Te.get(o),Be=_e.has(o),We=o.split("/").filter(Boolean).pop()||o;return e.jsxs("span",{className:"flat-terminal-wrapper__area-dir",title:`${d}: ${o}${i?` (${i.branch}${i.ahead?` ↑${i.ahead}`:""}${i.behind?` ↓${i.behind}`:""})`:""}`,onClick:()=>C.openFileExplorerForAreaFolder(l,o),children:[e.jsx(u,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-terminal-wrapper__area-dir-name",children:We}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flat-terminal-wrapper__area-dir-branch",children:[e.jsx(u,{name:"git-branch",size:10})," ",i.branch]}),i.ahead>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-ahead",title:`${i.ahead} ahead`,children:[e.jsx(u,{name:"arrow-up",size:9}),i.ahead]}),i.behind>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-behind",title:`${i.behind} behind`,children:[e.jsx(u,{name:"arrow-down",size:9}),i.behind]}),e.jsx("span",{className:`flat-terminal-wrapper__area-fetch ${Be?"flat-terminal-wrapper__area-fetch--fetching":""}`,title:"Git fetch",onClick:lt=>{lt.stopPropagation(),xe(o)},children:e.jsx(u,{name:Be?"hourglass":"download",size:12})})]})]},`${l}:${o}`)}),e.jsxs("span",{className:"flat-terminal-wrapper__context",onClick:()=>C.setContextModalAgentId(c),title:b?`Context usage: ${Re}k / ${ze}k tokens (${V}% 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:`${V}%`,backgroundColor:De}})}),e.jsxs("span",{className:"flat-terminal-wrapper__context-tokens",style:{color:De},children:[Re,"k/",ze,"k"]}),e.jsxs("span",{className:"flat-terminal-wrapper__context-free",children:["(",st,"% free)"]}),!b&&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"}),F.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area terminals",children:F.map(l=>{const d=k===l.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${d?"flat-terminal-wrapper__building-btn--active":""} ${l.hasUrl?"":"flat-terminal-wrapper__building-btn--offline"}`,title:`${d?"Hide":"Show"} terminal: ${l.name}${l.hasUrl?"":" (starting...)"}`,onClick:()=>{if(d){W(null);return}l.hasUrl||C.sendBuildingCommand(l.id,"start"),W(l.id)},children:e.jsx(u,{name:"terminal",size:14})},l.id)})}),ie.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area PM2 logs",children:ie.map(l=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open logs: ${l.name}`,onClick:()=>fe(l.id),children:e.jsx(u,{name:"scroll",size:14})},l.id))}),Ee.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area databases",children:Ee.map(l=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open database: ${l.name}`,onClick:()=>fe(l.id),children:e.jsx(u,{name:"hard-drives",size:14})},l.id))}),e.jsx("div",{className:"flat-terminal-wrapper__theme",children:e.jsx(ia,{})})]}),Q&&e.jsx(oa,{agentId:c,agents:nt,onClose:tt,branchInfoMap:Te,fetchRemote:xe,fetchingDirs:_e}),L&&e.jsx(ca,{agentId:c,onClose:at}),ee&&e.jsx(da,{agentId:c,onClose:Pe})]})});function ka({onAgentClick:f,onBuildingClick:c,onBuildingDoubleClick:N,onOpenSpawnModal:T,onOpenBossSpawnModal:D,onOpenAreaModal:ne}){const{t:R}=Et(["common"]),S=yt(),ue=Pt(),[me,ke]=n.useState(null),[fe,Ae]=n.useState(null),[he,Ie]=n.useState(null),[y,se]=n.useState(null),[z,Se]=n.useState(null),[p,P]=n.useState(!1),le=n.useCallback(()=>{P(t=>!t)},[]),Me=n.useCallback(()=>{P(!1)},[]),[ge,re]=n.useState(()=>{const t=ht(w.VIEW_MODE);return t==="simple"||t==="chat"||t==="advanced"?t:"simple"}),Te=n.useCallback(t=>{re(t),gt(w.VIEW_MODE,t)},[]);n.useEffect(()=>{const t=a=>{if(a.key!==w.VIEW_MODE)return;const s=a.newValue;(s==="simple"||s==="chat"||s==="advanced")&&re(s)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const[xe,_e]=n.useState(()=>dt(w.FLAT_INSPECTOR_OPEN,!1)),[F,ie]=n.useState(!1),Ee=n.useCallback(()=>ie(t=>!t),[]),Ye=n.useCallback(()=>ie(!1),[]),B=n.useRef(null),J=n.useRef(null),[U,X]=n.useState(()=>{const t=xt(w.FLAT_MIDDLE_WIDTH,0);return t>=Ke?t:null}),[k,W]=n.useState(()=>{const t=xt(w.FLAT_INSPECTOR_WIDTH,0);return t>=ct?t:null}),M=n.useCallback(t=>{if(typeof window>"u")return t;const a=k!==null?qe+k:0,s=window.innerWidth-bt-qe-_t-a;return Math.max(Ke,Math.min(Math.max(s,Ke),t))},[k]),q=n.useCallback(t=>{var _;if(typeof window>"u")return t;const a=(_=B.current)==null?void 0:_.querySelector(".flat-middle"),s=(a==null?void 0:a.getBoundingClientRect().width)??Ke,r=window.innerWidth-bt-s-qe-_t-qe;return Math.max(ct,Math.min(Math.max(r,ct),t))},[]);n.useEffect(()=>{if(U===null&&k===null)return;const t=()=>{X(a=>{if(a===null)return a;const s=M(a);return s===a?a:s}),W(a=>{if(a===null)return a;const s=q(a);return s===a?a:s})};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[U,k,M,q]);const Ze=n.useCallback(t=>{var s;if(t.button!==0)return;const a=(s=B.current)==null?void 0:s.querySelector(".flat-middle");a&&(t.currentTarget.setPointerCapture(t.pointerId),J.current={kind:"middle",startX:t.clientX,startWidth:a.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),Q=n.useCallback(t=>{var s;if(t.button!==0)return;const a=(s=B.current)==null?void 0:s.querySelector(".flat-inspector");a&&(t.currentTarget.setPointerCapture(t.pointerId),J.current={kind:"inspector",startX:t.clientX,startWidth:a.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),be=n.useCallback(t=>{const a=J.current;if(!a||t.pointerId!==a.pointerId)return;const s=t.clientX-a.startX;a.kind==="middle"?X(M(a.startWidth+s)):W(q(a.startWidth-s))},[M,q]),L=n.useCallback(t=>{const a=J.current;if(!a||t.pointerId!==a.pointerId)return;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}if(J.current=null,document.body.classList.remove("flat-splitter-dragging"),!(Math.abs(t.clientX-a.startX)>2))return;const r=t.clientX-a.startX;if(a.kind==="middle"){const _=M(a.startWidth+r);X(_),Xe(w.FLAT_MIDDLE_WIDTH,_)}else{const _=q(a.startWidth-r);W(_),Xe(w.FLAT_INSPECTOR_WIDTH,_)}},[M,q]),ye=n.useCallback(()=>{X(null),Xe(w.FLAT_MIDDLE_WIDTH,0)},[]),ee=n.useCallback(()=>{W(null),Xe(w.FLAT_INSPECTOR_WIDTH,0)},[]),[K,Je]=n.useState(()=>ht(w.FLAT_INSPECTOR_VIEW)==="tracking"?"tracking":"agent"),Pe=n.useCallback(t=>{Je(t),gt(w.FLAT_INSPECTOR_VIEW,t)},[]),Qe=n.useCallback(()=>{_e(t=>{const a=!t;return pe(w.FLAT_INSPECTOR_OPEN,a),a})},[]),et=n.useCallback(()=>{_e(!1),pe(w.FLAT_INSPECTOR_OPEN,!1)},[]),tt=Dt(),at=n.useCallback((t,a)=>{ke({url:t,name:a})},[]),nt=n.useCallback((t,a)=>{Ae({command:t,output:a,isLive:!1})},[]),te=n.useCallback((t,a)=>{C.setFileViewerPath(t,a)},[]),Y=n.useCallback(t=>{},[]),we=n.useCallback((t,a)=>{Ie({agentId:t,count:a})},[]),H=n.useCallback(t=>{N?N(t):c(t)},[c,N]),b=n.useMemo(()=>ue.size>0?Array.from(ue)[0]:null,[ue]);n.useEffect(()=>{P(!1)},[b]);const Z=n.useRef([]),G=n.useRef(-1),Ce=n.useRef(!1),V=n.useRef(null),[st,De]=n.useState(!1),[Re,ze]=n.useState(!1),$=n.useMemo(()=>new Set(S.map(t=>t.id)),[S]),Le=n.useMemo(()=>{const t=new Map(S.map(s=>[s.id,s])),a=new Map;for(const s of S)if((s.isBoss||s.class==="boss")&&s.subordinateIds&&s.subordinateIds.length>0){const r=s.subordinateIds.map(_=>t.get(_)).filter(_=>_!==void 0);r.length>0&&a.set(s.id,r)}return a},[S]),E=n.useCallback(()=>{const t=Z.current,a=G.current;De(a>0),ze(a>=0&&a<t.length-1)},[]),oe=n.useCallback(t=>{const a=Z.current;if(a.length===0)return;let s=G.current+t;for(;s>=0&&s<a.length;){const r=a[s];if($.has(r)){Ce.current=!0,G.current=s,E(),C.selectAgent(r);return}s+=t}},[$,E]),$e=n.useCallback(()=>oe(-1),[oe]),Oe=n.useCallback(()=>oe(1),[oe]);n.useEffect(()=>{if(!b){Z.current=[],G.current=-1,E();return}if(V.current=b,Ce.current){Ce.current=!1,E();return}const t=Z.current,a=G.current;if(a>=0&&t[a]===b){E();return}const s=a<t.length-1?t.slice(0,a+1):t.slice();s.push(b),s.length>100&&s.shift(),Z.current=s,G.current=s.length-1,E()},[b,E]);const je=n.useCallback(t=>{f(t),ie(!1)},[f]),Fe=b??"",l=n.useCallback(()=>{},[]),d=n.useCallback(t=>{je(t)},[je]),o=xe,i=n.useRef(null);n.useEffect(()=>{if(b)return;const t=a=>{if(a.key!==" "&&a.key!=="Backspace")return;const s=a.target;if(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)return;const r=V.current;!r||!$.has(r)||(a.preventDefault(),C.selectAgent(r))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[b,$]);const[Be,We]=n.useState(new Set),lt=n.useCallback(t=>{We(a=>{const s=new Set(a);return s.has(t)?s.delete(t):s.add(t),s})},[]),pt=Ct(),[vt]=Rt(),ce=n.useMemo(()=>{const t=new Map,a=[];for(const m of S){const x=C.getAreaForAgent(m.id);if(!zt((x==null?void 0:x.id)??null))continue;if(!x||x.archived){a.push(m);continue}const O=t.get(x.id);O?O.push(m):t.set(x.id,[m])}const s=[];for(const[,m]of pt){if(m.archived||!Lt(m.id))continue;const x=t.get(m.id);x&&x.length>0&&s.push({area:m,agents:x})}a.length>0&&s.push({area:{id:"__unassigned__",name:"Unassigned",color:"#6272a4",center:{x:0,z:0},type:"circle",radius:0,directories:[],archived:!1,assignedAgentIds:[],zIndex:0},agents:a});const r=s.filter(m=>m.area.id!=="__unassigned__"),_=s.filter(m=>m.area.id==="__unassigned__");let j=1,g=1;const Ne=new Map;if(r.length>1){let m=1/0,x=-1/0,O=1/0,de=-1/0;for(const A of r)m=Math.min(m,A.area.center.x),x=Math.max(x,A.area.center.x),O=Math.min(O,A.area.center.z),de=Math.max(de,A.area.center.z);const Ge=x-m||1,Ve=de-O||1;if(r.length<=4){j=r.length,g=1;const A=[...r].sort((I,rt)=>I.area.center.x-rt.area.center.x);for(let I=0;I<A.length;I++)Ne.set(A[I].area.id,{row:1,col:I+1})}else{const A=[...r].sort((h,v)=>h.area.center.x-v.area.center.x),I=[];for(let h=1;h<A.length;h++)I.push(A[h].area.center.x-A[h-1].area.center.x);const rt=I.reduce((h,v)=>h+v,0)/I.length||1;let ut=1;for(const h of I)h>rt*1.3&&ut++;j=Math.max(2,Math.min(ut,r.length));const it=[...r].sort((h,v)=>h.area.center.z-v.area.center.z),Ue=[];for(let h=1;h<it.length;h++)Ue.push(it[h].area.center.z-it[h-1].area.center.z);const It=Ue.reduce((h,v)=>h+v,0)/Ue.length||1;let mt=1;for(const h of Ue)h>It*1.3&&mt++;g=Math.max(2,Math.min(mt,r.length)),j=Math.max(j,Math.ceil(r.length/g)),g=Math.max(g,Math.ceil(r.length/j));const St=Ge/j,Mt=Ve/g,ot=new Set;for(const h of r){let v=Math.min(j-1,Math.max(0,Math.floor((h.area.center.x-m)/St))),ae=Math.min(g-1,Math.max(0,Math.floor((h.area.center.z-O)/Mt))),ve=`${ae},${v}`,ft=0;const Tt=g*j;for(;ot.has(ve)&&ft<Tt;)v++,v>=j&&(v=0,ae=(ae+1)%g),ve=`${ae},${v}`,ft++;ot.has(ve)&&(ae=g,v=0,ve=`${ae},${v}`,g++),ot.add(ve),Ne.set(h.area.id,{row:ae+1,col:v+1})}}}const He=m=>{m.sort((x,O)=>{var Ge,Ve,A,I;const de=(((Ge=x.position)==null?void 0:Ge.z)??0)-(((Ve=O.position)==null?void 0:Ve.z)??0);return de!==0?de:(((A=x.position)==null?void 0:A.x)??0)-(((I=O.position)==null?void 0:I.x)??0)})};for(const m of r)He(m.agents);for(const m of _)He(m.agents);return{groups:[...r,..._],gridCols:j,gridRows:g,positions:Ne}},[S,pt,vt]),kt=n.useMemo(()=>{if(!y)return[];const t=S.find(a=>a.id===y.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:()=>f(t.id)},{id:"delete-agent",label:"Delete Agent",icon:e.jsx(u,{name:"trash",size:14}),danger:!0,onClick:()=>{Se({agentId:t.id,name:t.name})}}]:[]},[y,S,f]),At=n.useCallback(t=>{const a=new Set(ce.groups.map(s=>s.area.id));a.delete(t),We(a),requestAnimationFrame(()=>{const s=i.current;if(!s)return;const r=s.querySelector(`[data-area-id="${t}"]`);if(!r)return;const _=s.getBoundingClientRect(),g=r.getBoundingClientRect().top-_.top+s.scrollTop-8;s.scrollTo({top:Math.max(0,g),behavior:"smooth"})})},[ce]);return e.jsxs("div",{ref:B,className:`flat-view ${o?"flat-view--with-inspector":""} ${b?"flat-view--has-chat":""} ${F?"flat-view--mobile-sidebar-open":""}`,style:(()=>{if(U===null&&k===null)return;const t={};return U!==null&&(t["--flat-middle-width"]=`${U}px`),k!==null&&(t["--flat-inspector-width"]=`${k}px`),t})(),children:[F&&e.jsx("div",{className:"flat-mobile-sidebar-backdrop",onClick:Ye,"aria-hidden":"true"}),e.jsxs("div",{className:"flat-middle",children:[e.jsxs("div",{className:"flat-middle__header",children:[e.jsx("h2",{className:"flat-middle__title",children:"👥 Agents"}),e.jsxs("div",{className:"flat-middle__actions",children:[e.jsx("button",{className:"flat-cta-btn flat-cta-btn--agent",onClick:T,title:"Create new agent",children:"+ Agent"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--boss",onClick:D,title:"Create new boss agent",children:"+ Boss"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--area",onClick:ne,title:"Create new area",children:"+ Area"})]})]}),e.jsx("div",{className:"flat-middle__content",children:e.jsx($t,{activeAgentId:Fe,onClose:l,onSelectAgent:d,collapsedAreas:Be,onToggleArea:lt,agentListRef:i})})]}),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:Ze,onPointerMove:be,onPointerUp:L,onPointerCancel:L,onDoubleClick:ye}),e.jsxs("div",{className:"flat-right",children:[e.jsxs("button",{type:"button",className:"flat-mobile-sidebar-toggle","aria-label":F?"Close agents sidebar":"Open agents sidebar","aria-expanded":F,onClick:Ee,children:[e.jsx(u,{name:"list",size:18}),e.jsx("span",{className:"flat-mobile-sidebar-toggle__label",children:"Agents"})]}),b?e.jsx(Ca,{agentId:b,terminalViewMode:ge,onTerminalViewModeChange:Te,inspectorOpen:xe,onToggleInspector:Qe,onImageClick:at,onFileClick:te,onBashClick:nt,onViewMarkdown:Y,onRequestClearSubordinates:we,onOpenBuilding:H,keyboard:tt,canNavigateBack:st,canNavigateForward:Re,onNavigateBack:$e,onNavigateForward:Oe,agentInfoOpen:p,onToggleAgentInfo:le}):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("div",{className:"flat-map__grid",style:{gridTemplateColumns:`repeat(${ce.gridCols}, 1fr)`},children:ce.groups.length===0?e.jsx("div",{className:"flat-map__empty",children:e.jsx("span",{children:"No areas or agents yet"})}):ce.groups.map(t=>{const a=t.area.id,s=ce.positions.get(a);return e.jsxs("div",{className:"flat-map-area-card",style:{"--area-color":t.area.color,gridRow:s==null?void 0:s.row,gridColumn:s==null?void 0:s.col},children:[e.jsxs("button",{type:"button",className:"flat-map-area-card__header",onClick:()=>At(a),title:`Focus ${t.area.name} in left panel`,children:[e.jsx("span",{className:"flat-map-area-card__color",style:{background:t.area.color}}),e.jsx("span",{className:"flat-map-area-card__name",children:t.area.name}),e.jsx("span",{className:"flat-map-area-card__count",children:t.agents.length})]}),e.jsx("div",{className:"flat-map-area-card__agents",children:t.agents.map(r=>{const _=r.isBoss||r.class==="boss",j=_?Le.get(r.id):void 0,g=Ot(r),Ne=g.usedPercent>=80?"#ff4a4a":g.usedPercent>=60?"#ff9e4a":g.usedPercent>=40?"#ffd700":"#4aff9e",He=`Context: ${(g.totalTokens/1e3).toFixed(1)}k / ${(g.contextWindow/1e3).toFixed(1)}k (${g.usedPercent}% used, ${g.freePercent}% free)`,m=r.latestTodos&&r.latestTodos.length>0||j&&j.length>0;return e.jsx(Ft,{todos:r.latestTodos,subordinates:j,position:"top",children:e.jsxs("button",{type:"button",className:`flat-map-agent-chip ${r.status}`,onClick:()=>f(r.id),onContextMenu:x=>{x.preventDefault(),x.stopPropagation(),se({agentId:r.id,position:{x:x.clientX,y:x.clientY}})},title:m?void 0:`${_?"Boss · ":""}Open chat with ${r.name}
2
- ${He}`,children:[e.jsx(jt,{agent:r,size:16}),_&&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:r.name}),e.jsx("img",{src:r.provider==="codex"?"/assets/codex.png":r.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:r.provider,className:"flat-map-agent-chip__provider-icon",title:r.provider==="codex"?"Codex Agent":r.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),e.jsx("span",{className:"flat-map-agent-chip__dot",style:{backgroundColor:Nt(r.status)}}),r.latestTodos&&r.latestTodos.length>0&&e.jsx(Bt,{todos:r.latestTodos,maxDots:6}),_&&j&&j.length>0&&e.jsx(Wt,{subordinates:j,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:`${g.usedPercent}%`,backgroundColor:Ne}})})]})},r.id)})})]},a)})})]})})]}),o&&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:Q,onPointerMove:be,onPointerUp:L,onPointerCancel:L,onDoubleClick:ee}),o&&e.jsxs("aside",{className:"flat-inspector","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":K==="agent",className:`flat-inspector__tab ${K==="agent"?"flat-inspector__tab--active":""}`,onClick:()=>Pe("agent"),children:"Agent"}),e.jsx("button",{type:"button",role:"tab","aria-selected":K==="tracking",className:`flat-inspector__tab ${K==="tracking"?"flat-inspector__tab--active":""}`,onClick:()=>Pe("tracking"),children:"Tracking"})]}),e.jsx("button",{type:"button",className:"flat-inspector__close",onClick:et,title:"Close inspector","aria-label":"Close inspector",children:"✕"})]}),e.jsx("div",{className:"flat-inspector__body",children:K==="tracking"?e.jsx(Ht,{activeAgentId:b??"",onSelectAgent:t=>f(t)}):(()=>{if(!b)return e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Select an agent to inspect"})});const t=S.find(a=>a.id===b);return t?e.jsx(Gt,{agent:t,onFocusAgent:a=>f(a),onKillAgent:a=>C.killAgent(a)}):e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Agent not found"})})})()})]}),me&&e.jsx(Vt,{url:me.url,name:me.name,onClose:()=>ke(null)}),fe&&e.jsx(Ut,{state:fe,onClose:()=>Ae(null)}),he&&e.jsx(Xt,{action:"clear-subordinates",selectedAgentId:he.agentId,subordinateCount:he.count,onClose:()=>Ie(null),onClearHistory:()=>{}}),e.jsx(qt,{agent:b?S.find(t=>t.id===b)??null:null,isOpen:p&&!!b,onClose:Me}),e.jsx(Kt,{isOpen:y!==null,position:(y==null?void 0:y.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:kt,onClose:()=>se(null)}),e.jsx(Yt,{isOpen:z!==null,title:R("common:confirm.removeAgentTitle"),message:R("common:confirm.removeAgentMessage",{name:(z==null?void 0:z.name)??""}),confirmLabel:R("common:buttons.remove"),cancelLabel:R("common:buttons.cancel"),variant:"danger",onConfirm:()=>{z&&C.removeAgentFromServer(z.agentId)},onClose:()=>Se(null)})]})}export{ka as FlatView};