tide-commander 1.165.1 → 1.167.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/assets/{BossLogsModal-IqVqHwz-.js → BossLogsModal-CLmSG1H0.js} +1 -1
- package/dist/assets/BossSpawnModal-DZlB8KRy.js +1 -0
- package/dist/assets/ControlsModal-B1-STBnD.js +1 -0
- package/dist/assets/DockerLogsModal-CWnhsG_r.js +2 -0
- package/dist/assets/{EmbeddedEditor-BA9mX_Lg.js → EmbeddedEditor-5po-iz0Q.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-7nj6aLot.js → GmailOAuthSetup-BB10r44e.js} +1 -1
- package/dist/assets/GoogleOAuthSetup-CW_Ib5kq.js +270 -0
- package/dist/assets/{IframeModal-DkkCx6nq.js → IframeModal-CPt5x5fr.js} +1 -1
- package/dist/assets/IntegrationsPanel-CO-5iHtn.js +2 -0
- package/dist/assets/{LogViewerModal-DKYB8dHo.js → LogViewerModal-DicJq6l-.js} +1 -1
- package/dist/assets/{MonitoringModal-DOKMIa5U.js → MonitoringModal-B3nwcYZn.js} +1 -1
- package/dist/assets/{PM2LogsModal-XlbT9uoY.js → PM2LogsModal-Viw6fBjN.js} +2 -2
- package/dist/assets/RestoreArchivedAreaModal-BVH9wxhk.js +1 -0
- package/dist/assets/Scene2DCanvas-D6TCimYq.js +1 -0
- package/dist/assets/SceneManager-BdJs75zx.js +104 -0
- package/dist/assets/{SkillsPanel-BKjpKM1N.js → SkillsPanel-D1WonIBN.js} +1 -1
- package/dist/assets/{SlackMultiInstanceSetup-C0k60ioO.js → SlackMultiInstanceSetup-DSTZ5Hry.js} +1 -1
- package/dist/assets/SpawnModal-DUpIkQ08.js +1 -0
- package/dist/assets/StatisticsModal-BoDgM_8E.js +1 -0
- package/dist/assets/SubordinateAssignmentModal-LysAkNGy.js +1 -0
- package/dist/assets/{TriggerManagerPanel-RWrID12k.js → TriggerManagerPanel-BHxmBRvy.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-Ccwm4H5t.js → WorkflowEditorPanel-BHayKmMV.js} +1 -1
- package/dist/assets/abnfDiagram-VRR7QNED-DBZ5EpAj.js +1 -0
- package/dist/assets/arc-UCe2q9lp.js +1 -0
- package/dist/assets/architectureDiagram-ZJ3FMSHR-D5zOdUA8.js +36 -0
- package/dist/assets/{area-logos-DnrrrkFh.js → area-logos-4nlUPBxf.js} +1 -1
- package/dist/assets/blockDiagram-677ZJIJ3-7S-qZlh0.js +132 -0
- package/dist/assets/c4Diagram-LMCZKHZV-CgLv5SCO.js +10 -0
- package/dist/assets/channel-C59jtig-.js +1 -0
- package/dist/assets/chunk-2Q5K7J3B-J08qsAGr.js +1 -0
- package/dist/assets/chunk-32BRIVSS-Xy5D5wu7.js +1 -0
- package/dist/assets/chunk-5VM5RSS4-DqhmRB6E.js +15 -0
- package/dist/assets/chunk-EX3LRPZG-QE89_WgA.js +231 -0
- package/dist/assets/chunk-JWPE2WC7-YSc_ua_g.js +1 -0
- package/dist/assets/chunk-MOJQB5TN-CcH7NM7I.js +88 -0
- package/dist/assets/chunk-RYQCIY6F-CndQTJJ1.js +1 -0
- package/dist/assets/chunk-V7JOEXUC-Dauixo5p.js +206 -0
- package/dist/assets/chunk-VR4S4FIN-BBU6oFw0.js +1 -0
- package/dist/assets/chunk-XXDRQBXY-DXMolb4D.js +1 -0
- package/dist/assets/classDiagram-OUVF2IWQ-DHvVmqF9.js +1 -0
- package/dist/assets/classDiagram-v2-EOCWNBFH-DHvVmqF9.js +1 -0
- package/dist/assets/cose-bilkent-JH36ORCC-Dd9IB924.js +1 -0
- package/dist/assets/cynefin-VYW2F7L2-BQxwdSSb.js +178 -0
- package/dist/assets/cynefinDiagram-TSTJHNR4-BLnxgd0m.js +62 -0
- package/dist/assets/cytoscape.esm-DTSO7Bv0.js +331 -0
- package/dist/assets/dagre-VKFMJZFB-BZ7fXVWR.js +4 -0
- package/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/assets/diagram-FQU43EPY-BFQ1xjHE.js +3 -0
- package/dist/assets/diagram-G47NLZAW-sXsGErM6.js +24 -0
- package/dist/assets/diagram-NH7WQ7WH-D6SPifDp.js +24 -0
- package/dist/assets/diagram-OA4YK3LP-Mu16f_2g.js +30 -0
- package/dist/assets/diagram-WEI45ONY-3BTJg43I.js +41 -0
- package/dist/assets/ebnfDiagram-CCIWWBDH-BGl2hs1X.js +1 -0
- package/dist/assets/erDiagram-Q63AITRT-D03B1rgc.js +85 -0
- package/dist/assets/flowDiagram-23GEKE2U-BCaZJGGE.js +156 -0
- package/dist/assets/ganttDiagram-NO4QXBWP-DrTSQR9G.js +292 -0
- package/dist/assets/gitGraphDiagram-IHSO6WYX-BvrZLcji.js +106 -0
- package/dist/assets/graph-C9eacEi8.js +1 -0
- package/dist/assets/index-B7l8Nsf8.js +1 -0
- package/dist/assets/index-BK7LL53p.js +1 -0
- package/dist/assets/index-CJ6x10Zs.js +2 -0
- package/dist/assets/index-D6btqUwj.js +2 -0
- package/dist/assets/{index-D-MKKw7S.js → index-DAXUzeVz.js} +6 -6
- package/dist/assets/{index-Cjgy2CnG.js → index-DcD9tVKJ.js} +3 -3
- package/dist/assets/{index-DZ7i37eV.js → index-Dzup44Dy.js} +6 -6
- package/dist/assets/index-JEgWBCoB.js +1 -0
- package/dist/assets/index-J_xWyk3Q.js +1 -0
- package/dist/assets/infoDiagram-FWYZ7A6U-Bw9k-wkS.js +2 -0
- package/dist/assets/init-Gi6I4Gst.js +1 -0
- package/dist/assets/ishikawaDiagram-FXEZZL3T-C2oVKtw0.js +70 -0
- package/dist/assets/journeyDiagram-5HDEW3XC-pRpwSEa5.js +139 -0
- package/dist/assets/kanban-definition-HUTT4EX6-CYq_poR1.js +89 -0
- package/dist/assets/katex-C5jXJg4s.js +257 -0
- package/dist/assets/layout-DEXfKzaS.js +1 -0
- package/dist/assets/linear-DLT2RlFJ.js +1 -0
- package/dist/assets/{main-DIf9R6Jx.js → main-06kmV-SQ.js} +125 -125
- package/dist/assets/main-BzGnAbiA.css +1 -0
- package/dist/assets/map-Czzmt4hB.js +1 -0
- package/dist/assets/mermaid.core-DmOBz9SE.js +314 -0
- package/dist/assets/mindmap-definition-LN4V7U3C-DzucjpI_.js +96 -0
- package/dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/assets/pegDiagram-2B236MQR-CIf_bLf4.js +1 -0
- package/dist/assets/pieDiagram-ENE6RG2P-Dh9HXeSf.js +39 -0
- package/dist/assets/quadrantDiagram-ABIIQ3AL-B5hZRZ5w.js +7 -0
- package/dist/assets/railroadDiagram-RFXS5EU6-B1oWAO1u.js +1 -0
- package/dist/assets/requirementDiagram-TGXJPOKE-Cg7bjm4O.js +84 -0
- package/dist/assets/sankeyDiagram-HTMAVEWB-TLCrcbtk.js +40 -0
- package/dist/assets/sequenceDiagram-DBY2YBRQ-BD3b_psw.js +162 -0
- package/dist/assets/sizeCapture-X5ZJPWSS-D26nx1uQ.js +1 -0
- package/dist/assets/stateDiagram-2N3HPSRC-CIwRQUnK.js +1 -0
- package/dist/assets/stateDiagram-v2-6OUMAXLB-C5qcZ4o1.js +1 -0
- package/dist/assets/swimlanes-5IMT3BWC-DYbes851.js +2 -0
- package/dist/assets/swimlanesDiagram-G3AALYLV-Ke-NRRIa.js +8 -0
- package/dist/assets/timeline-definition-FHXFAJF6-Fr9U6JU6.js +120 -0
- package/dist/assets/{vendor-three-Chj50gSY.js → vendor-three-3OKhI9bz.js} +1 -1
- package/dist/assets/vennDiagram-L72KCM5P-Cns-KLq7.js +34 -0
- package/dist/assets/wardleyDiagram-EHGQE667-DHA7rD9Z.js +78 -0
- package/dist/assets/{web-DDxnPoTK.js → web-B7c8sthS.js} +1 -1
- package/dist/assets/{web-DhZ0XCan.js → web-C05qFIA-.js} +1 -1
- package/dist/assets/{web-Dlc8Nyra.js → web-Dja1kfLs.js} +1 -1
- package/dist/assets/xychartDiagram-FW5EYKEG-DCnL05Wq.js +7 -0
- package/dist/build-info.json +1 -1
- package/dist/index.html +3 -3
- package/dist/src/packages/server/claude/runner/watchdog.js +27 -0
- package/dist/src/packages/server/codex/app-server/codex-app-server-runner.js +34 -4
- package/dist/src/packages/server/data/builtin-skills/index.js +2 -0
- package/dist/src/packages/server/data/builtin-skills/mermaid-diagrams.js +76 -0
- package/dist/src/packages/server/integrations/gmail/gmail-client.js +73 -5
- package/dist/src/packages/server/integrations/gmail/gmail-routes.js +9 -4
- package/dist/src/packages/server/integrations/google-auth/token-health.js +196 -0
- package/dist/src/packages/server/integrations/google-calendar/calendar-client.js +61 -6
- package/dist/src/packages/server/integrations/google-calendar/calendar-routes.js +9 -4
- package/dist/src/packages/server/integrations/google-drive/drive-client.js +61 -6
- package/dist/src/packages/server/integrations/google-drive/drive-routes.js +9 -4
- package/dist/src/packages/server/opencode/server/opencode-server-process.js +102 -7
- package/dist/src/packages/server/opencode/server/opencode-server-runner.js +13 -0
- package/dist/src/packages/server/services/agent-service.js +7 -0
- package/dist/src/packages/server/services/runtime-events.js +1 -0
- package/package.json +2 -1
- package/dist/assets/BossSpawnModal-Dj9ayWfR.js +0 -1
- package/dist/assets/ControlsModal-ki85jvDA.js +0 -1
- package/dist/assets/DockerLogsModal-CeIuKlvk.js +0 -2
- package/dist/assets/GoogleOAuthSetup-Bh-Cy-dE.js +0 -236
- package/dist/assets/IntegrationsPanel-DHjpWEFF.js +0 -2
- package/dist/assets/RestoreArchivedAreaModal-Du1f8Urv.js +0 -1
- package/dist/assets/Scene2DCanvas-BTnpyyK6.js +0 -1
- package/dist/assets/SceneManager-owoMSHKT.js +0 -104
- package/dist/assets/SpawnModal-Cww_6dcz.js +0 -1
- package/dist/assets/StatisticsModal-Dl5loLLI.js +0 -1
- package/dist/assets/SubordinateAssignmentModal-DefQL38f.js +0 -1
- package/dist/assets/index-B5iakYkB.js +0 -1
- package/dist/assets/index-CbJ-R04c.js +0 -2
- package/dist/assets/index-CcHBNDP_.js +0 -2
- package/dist/assets/index-DG7HgtQn.js +0 -1
- package/dist/assets/index-Fcs4x2Vj.js +0 -1
- package/dist/assets/index-g0yAcpoy.js +0 -1
- package/dist/assets/main-Dnp-3iMX.css +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as ns,b5 as as,b6 as ts,b7 as ls,b8 as os,r as t,_ as De,S as oe,b9 as is,ba as ie,A as Ie,k as ce,i as cs,s as v,n as rs,j as e,bb as ds,a9 as _e,bc as x,bd as ps,be as re,I as de,aT as T,aR as H,bf as ms,bg as J,aS as pe,bh as me,bi as us,$ as hs}from"./main-DIf9R6Jx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function Le(d,j){const S=j.filter(C=>!d.has(C));return S.length===0?`${j[Math.floor(Math.random()*j.length)]}-${Date.now()%1e3}`:S[Math.floor(Math.random()*S.length)]}function gs({isOpen:d,onClose:j,onSpawnStart:S,onSpawnEnd:C,spawnPosition:$e,spawnAreaId:N}){const{t:n}=ns(["terminal","common"]),P=as(),p=ts(),ue=ls(),X=ue.length>0?ue:os,[m,b]=t.useState(""),[k,F]=t.useState(()=>De(oe.LAST_CWD)),[i,M]=t.useState("scout"),[he,I]=t.useState(!1),[Te,R]=t.useState(!1),[we,Y]=t.useState(!1),[xe,fe]=t.useState(""),[y,Q]=t.useState([]),[E,O]=t.useState(null),[Pe,ge]=t.useState(!1),[_,je]=t.useState(""),[h,Fe]=t.useState(""),[U,Re]=t.useState(!1),[z,Oe]=t.useState("bypass"),[o,G]=t.useState("claude"),[f,A]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[V,Z]=t.useState(new Set),[ee,Ne]=t.useState("claude-opus-4-8[1m]"),[se,be]=t.useState("xHigh"),[ne,Ue]=t.useState("gpt-5.6-luna"),[ae,ze]=t.useState("minimax/MiniMax-M1-80k"),[te,Ge]=t.useState(is),[ve,qe]=t.useState(""),[D,We]=t.useState(""),q=t.useRef(null),Se=t.useRef(!1),L=t.useCallback(()=>{window.__spawnModalAreaContext=null},[]),w=t.useMemo(()=>P.filter(s=>s.enabled),[P]),Be=["full-notifications","streaming-exec","task-label","report-task-to-boss","agent-tracking","agent-memory","send-message-to-agent"];t.useEffect(()=>{if(d&&!Se.current){if(w.length>0){const l=w.filter(r=>Be.includes(r.slug)).map(r=>r.id);l.length>0&&Z(new Set(l))}const a=De(oe.DEFAULT_AGENT_CLASS);if(a==="random"){const r=[...Object.keys(us),...p.map(u=>u.id)];M(r[Math.floor(Math.random()*r.length)])}else M(a||"scout")}Se.current=d},[d,w,p]);const Ce=t.useMemo(()=>{if(!D.trim())return w;const s=D.toLowerCase();return w.filter(a=>a.name.toLowerCase().includes(s)||a.description.toLowerCase().includes(s)||a.slug.toLowerCase().includes(s))},[w,D]),Ke=t.useCallback(s=>{Z(a=>{const l=new Set(a);return l.has(s)?l.delete(s):l.add(s),l})},[]);t.useMemo(()=>w.filter(s=>s.assignedAgentClasses.includes(i)),[w,i]);const He=t.useMemo(()=>{var a;const s=p.find(l=>l.id===i);return(a=s==null?void 0:s.defaultSkillIds)!=null&&a.length?P.filter(l=>s.defaultSkillIds.includes(l.id)):[]},[p,i,P]),ke=t.useMemo(()=>{if(!_.trim())return y;const s=_.toLowerCase();return y.filter(a=>a.sessionId.toLowerCase().includes(s)||a.projectPath.toLowerCase().includes(s)||a.firstMessage&&a.firstMessage.toLowerCase().includes(s))},[y,_]),W=t.useMemo(()=>{if(!h.trim())return p;const s=h.toLowerCase();return p.filter(a=>a.name.toLowerCase().includes(s)||a.description.toLowerCase().includes(s)||a.id.toLowerCase().includes(s))},[p,h]),B=t.useMemo(()=>{if(!h.trim())return ie;const s=h.toLowerCase();return ie.filter(a=>{const l=Ie[a.id];return a.name.toLowerCase().includes(s)||a.id.toLowerCase().includes(s)||l.description.toLowerCase().includes(s)})},[h]);t.useEffect(()=>{if(!d||!h.trim())return;const s=[...W.map(a=>a.id),...B.map(a=>a.id)];s.length===1&&s[0]!==i&&M(s[0])},[d,h,W,B,i]);const c=t.useMemo(()=>p.find(s=>s.id===i),[p,i]),Je=t.useMemo(()=>{if(c!=null&&c.model)return c.model},[c]),Xe=t.useMemo(()=>{if(c!=null&&c.customModelPath)return ce(`/api/custom-models/${c.id}`)},[c]),Ye=c==null?void 0:c.modelScale,Qe=t.useMemo(()=>c?"scout":i,[i,c]),K=t.useCallback(async s=>{ge(!0);try{const a=s?ce(`/api/agents/claude-sessions?cwd=${encodeURIComponent(s)}`):ce("/api/agents/claude-sessions"),r=await(await cs(a)).json();Q(r.sessions||[])}catch(a){console.error("Failed to fetch sessions:",a),Q([])}finally{ge(!1)}},[]);t.useEffect(()=>{d?K(k||void 0):(Q([]),O(null),je(""))},[d,K]),t.useEffect(()=>{if(!d)return;const s=setTimeout(()=>{K(k||void 0),O(null)},300);return()=>clearTimeout(s)},[k,d,K]),t.useEffect(()=>{if(!d||!N)return;const s=v.getState().areas.get(N);if(s!=null&&s.directories&&s.directories.length>0){F(s.directories[0]);return}const a=Array.from(v.getState().agents.values()).filter(g=>{var $;return(($=v.getAreaForAgent(g.id))==null?void 0:$.id)===N&&g.cwd});if(a.length===0)return;const l=new Map;for(const g of a)l.set(g.cwd,(l.get(g.cwd)||0)+1);let r="",u=0;for(const[g,$]of l)$>u&&(r=g,u=$);r&&F(r)},[d,N]),t.useEffect(()=>{if(d){const s=new Set(Array.from(v.getState().agents.values()).map(u=>u.name)),a=Le(s,X),l=p.find(u=>u.id===i),r=l?`${l.name} ${a}`:a;b(r),q.current&&(q.current.focus(),q.current.select())}},[d,X]),t.useEffect(()=>{if(!d)return;const s=p.find(a=>a.id===i);if(s){const a=p.find(l=>m.startsWith(l.name+" "));if(a){const l=m.substring(a.name.length+1);b(`${s.name} ${l}`)}else b(`${s.name} ${m}`)}else{const a=p.find(l=>m.startsWith(l.name+" "));if(a){const l=m.substring(a.name.length+1);b(l)}}},[i]),t.useEffect(()=>{i==="boss"&&Ne("claude-opus-4-8[1m]")},[i]);const Ve=()=>{var r;console.log("[SpawnModal] handleSpawn called"),R(!1);const s=E&&((r=y.find(u=>u.sessionId===E))==null?void 0:r.projectPath)||k;if(console.log("[SpawnModal] Effective CWD:",s),console.log("[SpawnModal] Agent name:",m),console.log("[SpawnModal] Agent class:",i),console.log("[SpawnModal] Permission mode:",z),console.log("[SpawnModal] Provider:",o),console.log("[SpawnModal] Use Chrome:",U),console.log("[SpawnModal] Session ID:",E||"none"),!s.trim()){console.error("[SpawnModal] Empty CWD, showing error"),R(!0);return}if(!m.trim()){console.log("[SpawnModal] Empty name, regenerating");const u=new Set(Array.from(v.getState().agents.values()).map(g=>g.name));b(Le(u,X));return}hs(oe.LAST_CWD,s),I(!0),S();const a=Array.from(V),l=ve.trim()||void 0;console.log("[SpawnModal] Calling store.spawnAgent with:",{name:m.trim(),class:i,cwd:s.trim(),sessionId:E||void 0,useChrome:o==="claude"?U:!1,permissionMode:z,provider:o,codexConfig:o==="codex"?f:void 0,codexModel:o==="codex"?ne:void 0,opencodeModel:o==="opencode"?ae:void 0,grokModel:o==="grok"?te:void 0,initialSkillIds:a,model:o==="claude"?ee:void 0,customInstructions:l?`${l.length} chars`:void 0,spawnAreaId:N||void 0}),window.__spawnModalAreaContext=N?{areaId:N}:null,v.spawnAgent(m.trim(),i,s.trim(),$e||void 0,E||void 0,o==="claude"?U:!1,z,a,o,o==="codex"?f:void 0,o==="codex"?ne:void 0,o==="claude"?ee:void 0,l,o==="claude"||o==="grok"?se:void 0,o==="opencode"?ae:void 0,o==="grok"?te:void 0)},Me=()=>{console.log("[SpawnModal] Agent creation successful"),I(!1),b(""),Z(new Set),L(),C(),j()},ye=()=>{console.error("[SpawnModal] Agent creation failed"),I(!1),R(!0),L(),C()},Ee=s=>{console.log("[SpawnModal] Directory not found:",s),I(!1),fe(s),Y(!0),C()},Ae=()=>{Y(!1),I(!0),S(),v.createDirectoryAndSpawn(xe,m.trim(),i)},le=()=>{Y(!1),fe(""),L()};t.useEffect(()=>(window.__spawnModalSuccess=Me,window.__spawnModalError=ye,window.__spawnModalDirNotFound=Ee,()=>{L(),delete window.__spawnModalSuccess,delete window.__spawnModalError,delete window.__spawnModalDirNotFound}),[m,i,Me,ye,Ee,L]);const{handleMouseDown:Ze,handleClick:es}=rs(j),ss=s=>{s.key==="Escape"&&j()};return!d&&!we?null:we?e.jsx("div",{className:"modal-overlay visible",onClick:le,onKeyDown:s=>{s.key==="Escape"&&le(),s.key==="Enter"&&Ae()},children:e.jsxs("div",{className:"modal confirm-modal",onClick:s=>s.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:n("terminal:spawn.directoryNotFound")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:n("terminal:spawn.directoryNotExist")}),e.jsx("code",{className:"confirm-modal-path",children:xe}),e.jsx("p",{children:n("terminal:spawn.wouldYouCreate")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:le,children:n("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:Ae,autoFocus:!0,children:n("terminal:spawn.createDirectory")})]})]})}):e.jsx("div",{className:`modal-overlay ${d?"visible":""}`,onMouseDown:Ze,onClick:es,onKeyDown:ss,children:e.jsxs("div",{className:"modal spawn-modal",children:[e.jsx("div",{className:"modal-header",children:n("terminal:spawn.deployTitle")}),e.jsxs("div",{className:"modal-body spawn-modal-body",children:[e.jsxs("div",{className:"spawn-section",children:[e.jsxs("div",{className:"spawn-section-header",children:[e.jsx("h4",{className:"spawn-section-title",children:n("terminal:spawn.agentClass")}),e.jsx("span",{className:"spawn-section-hint",children:(c==null?void 0:c.name)||i})]}),e.jsxs("div",{className:"spawn-top-section",children:[e.jsxs("div",{className:"spawn-preview-compact",children:[e.jsx(ds,{agentClass:Qe,modelFile:Je,customModelUrl:Xe,modelScale:Ye,width:110,height:130}),e.jsx("div",{className:"spawn-preview-label",children:(c==null?void 0:c.name)||i})]}),e.jsxs("div",{className:"spawn-class-section",children:[p.length+ie.length>6&&e.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:n("terminal:spawn.filterClasses"),value:h,onChange:s=>Fe(s.target.value)}),e.jsxs("div",{className:"class-selector-inline",children:[W.map(s=>e.jsxs("button",{className:`class-chip ${i===s.id?"selected":""}`,onClick:()=>M(s.id),title:s.description,children:[e.jsx(_e,{classId:s.id,size:18,className:"class-chip-icon"}),e.jsx("span",{className:"class-chip-name",children:s.name})]},s.id)),B.map(s=>{const a=Ie[s.id];return e.jsxs("button",{className:`class-chip ${i===s.id?"selected":""}`,onClick:()=>M(s.id),title:a.description,children:[e.jsx(_e,{classId:s.id,size:18,className:"class-chip-icon"}),e.jsx("span",{className:"class-chip-name",children:s.name})]},s.id)}),h&&W.length===0&&B.length===0&&e.jsx("div",{className:"class-search-empty",children:n("terminal:spawn.noClassesMatch",{query:h})})]})]})]}),e.jsxs("div",{className:"spawn-form-row",children:[e.jsxs("div",{className:"spawn-field",children:[e.jsx("label",{className:"spawn-label",children:n("common:labels.name")}),e.jsx("input",{ref:q,type:"text",className:"spawn-input",placeholder:n("terminal:spawn.agentNamePlaceholder"),value:m,onChange:s=>b(s.target.value)})]}),e.jsxs("div",{className:"spawn-field spawn-field-wide",children:[e.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.workingDir"),e.jsx(x,{text:n("terminal:spawn.helpWorkingDir"),title:n("terminal:spawn.workingDir"),position:"top",size:"sm"})]}),e.jsx(ps,{value:k,onChange:s=>{F(s),R(!1)},placeholder:n("terminal:spawn.workingDirPlaceholder"),className:`spawn-input ${Te?"error":""}`,directoriesOnly:!0})]})]})]}),e.jsxs("div",{className:"spawn-section",children:[e.jsx("div",{className:"spawn-section-header",children:e.jsx("h4",{className:"spawn-section-title",children:n("terminal:spawn.selectRuntime")})}),e.jsxs("div",{className:"spawn-form-row",children:[e.jsxs("div",{className:"spawn-field",children:[e.jsxs("label",{className:"spawn-label",children:[n("common:labels.runtime"),e.jsx(x,{text:n("terminal:spawn.helpRuntime"),title:n("terminal:spawn.runtimeTitle"),position:"top",size:"sm"})]}),e.jsxs("div",{className:"spawn-select-row",children:[e.jsxs("button",{className:`spawn-select-btn ${o==="claude"?"selected":""}`,onClick:()=>G("claude"),title:n("terminal:spawn.useClaudeCli"),children:[e.jsx("img",{src:"/assets/claude.ico",alt:"Claude",className:"spawn-provider-icon"}),e.jsx("span",{children:"Claude"})]}),e.jsxs("button",{className:`spawn-select-btn ${o==="codex"?"selected":""}`,onClick:()=>G("codex"),title:n("terminal:spawn.useCodexCli"),children:[e.jsx("img",{src:"/assets/codex.ico",alt:"Codex",className:"spawn-provider-icon"}),e.jsx("span",{children:"Codex"})]}),e.jsxs("button",{className:`spawn-select-btn spawn-select-btn--opencode ${o==="opencode"?"selected":""}`,onClick:()=>G("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[e.jsx("img",{src:"/assets/opencode.svg",alt:"OpenCode",className:"spawn-provider-icon"}),e.jsx("span",{children:"OpenCode"})]}),e.jsxs("button",{className:`spawn-select-btn spawn-select-btn--grok ${o==="grok"?"selected":""}`,onClick:()=>G("grok"),title:"Use Grok CLI (headless)",children:[e.jsx("img",{src:"/assets/grok.png",alt:"Grok",className:"spawn-provider-icon"}),e.jsx("span",{children:"Grok"})]})]})]}),e.jsxs("div",{className:"spawn-field",children:[e.jsxs("label",{className:"spawn-label",children:[n("common:labels.permissions"),e.jsx(x,{text:n("terminal:spawn.helpPermission"),title:n("terminal:spawn.permissionMode"),position:"top",size:"sm"})]}),e.jsx("div",{className:"spawn-select-row",children:Object.keys(re).map(s=>e.jsxs("button",{className:`spawn-select-btn ${z===s?"selected":""}`,onClick:()=>Oe(s),title:re[s].description,children:[e.jsx("span",{children:e.jsx(de,{name:s==="bypass"?"bolt":"lock",size:12})}),e.jsx("span",{children:re[s].label})]},s))})]})]}),e.jsx("div",{className:"spawn-form-row",children:e.jsxs("div",{className:"spawn-field",children:[e.jsxs("label",{className:"spawn-label",children:[n("common:labels.model"),e.jsx(x,{text:n("terminal:spawn.helpModel"),title:n("terminal:spawn.modelTitle"),position:"top",size:"sm"})]}),o==="claude"?e.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(T).filter(s=>!T[s].deprecated).map(s=>e.jsxs("button",{className:`spawn-select-btn ${ee===s?"selected":""}`,onClick:()=>Ne(s),title:T[s].description,children:[e.jsx("span",{children:T[s].icon}),e.jsx("span",{children:T[s].label})]},s))}):o==="codex"?e.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(H).map(s=>e.jsxs("button",{className:`spawn-select-btn ${ne===s?"selected":""}`,onClick:()=>Ue(s),title:H[s].description,children:[e.jsx("span",{children:H[s].icon}),e.jsx("span",{children:H[s].label})]},s))}):o==="opencode"?e.jsx(ms,{value:ae,onChange:ze,inputId:"spawn-opencode-model"}):o==="grok"?e.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(J).map(s=>e.jsxs("button",{className:`spawn-select-btn ${te===s?"selected":""}`,onClick:()=>Ge(s),title:J[s].description,children:[e.jsx("span",{children:J[s].icon}),e.jsx("span",{children:J[s].label})]},s))}):e.jsx("div",{className:"spawn-inline-hint",children:n("terminal:spawn.chooseCodexModel")})]})}),e.jsxs("div",{className:"spawn-form-row",children:[(o==="claude"||o==="grok")&&e.jsxs("div",{className:"spawn-field",children:[e.jsx("label",{className:"spawn-label",children:"Effort"}),e.jsxs("div",{className:"spawn-select-row spawn-select-row--effort",children:[e.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${se===void 0?"selected":""}`,onClick:()=>be(void 0),title:"Use default effort level",children:e.jsx("span",{children:"Default"})}),Object.keys(pe).map(s=>e.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${se===s?"selected":""}`,onClick:()=>be(s),title:pe[s].description,children:e.jsx("span",{children:pe[s].label})},s))]})]}),e.jsxs("div",{className:"spawn-field",children:[e.jsx("label",{className:"spawn-label",children:n("terminal:spawn.browser")}),e.jsxs("label",{className:"spawn-checkbox",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:s=>Re(s.target.checked),disabled:o!=="claude"}),e.jsxs("span",{children:[e.jsx(de,{name:"globe",size:12})," ",n("terminal:spawn.chromeBrowser")]}),e.jsx(x,{text:n(o==="claude"?"terminal:spawn.helpChrome":"terminal:spawn.helpChromeDisabled"),title:n("terminal:spawn.chromeBrowser"),position:"top",size:"sm"})]})]})]}),o==="codex"&&e.jsxs("div",{className:"codex-config-section",children:[e.jsx("div",{className:"codex-config-title",children:n("terminal:spawn.codex.configuration")}),e.jsxs("div",{className:"codex-config-options",children:[e.jsxs("div",{className:"codex-option-group",children:[e.jsxs("label",{className:"spawn-checkbox",children:[e.jsx("input",{type:"checkbox",checked:f.fullAuto!==!1,onChange:s=>A(a=>({...a,fullAuto:s.target.checked}))}),e.jsx("span",{children:n("terminal:spawn.codex.fullAuto")}),e.jsx(x,{text:n("terminal:spawn.helpFullAuto"),title:n("terminal:spawn.fullAutoTitle"),position:"top",size:"sm"})]}),e.jsxs("label",{className:"spawn-checkbox",children:[e.jsx("input",{type:"checkbox",checked:!!f.search,onChange:s=>A(a=>({...a,search:s.target.checked}))}),e.jsx("span",{children:n("terminal:spawn.codex.search")}),e.jsx(x,{text:n("terminal:spawn.helpSearch"),title:n("terminal:spawn.searchTitle"),position:"top",size:"sm"})]})]}),f.fullAuto===!1&&e.jsxs("div",{className:"codex-option-group",children:[e.jsx("div",{className:"codex-option-header",children:n("terminal:spawn.codex.restrictions")}),e.jsxs("select",{className:"spawn-input codex-select",value:f.sandbox||"workspace-write",onChange:s=>A(a=>({...a,sandbox:s.target.value})),children:[e.jsxs("option",{value:"read-only",children:["📖 ",n("terminal:spawn.codex.sandboxReadOnly")]}),e.jsxs("option",{value:"workspace-write",children:["✏️ ",n("terminal:spawn.codex.sandboxWorkspaceWrite")]}),e.jsxs("option",{value:"danger-full-access",children:["⚡ ",n("terminal:spawn.codex.sandboxDangerFullAccess")]})]}),e.jsxs("select",{className:"spawn-input codex-select",value:f.approvalMode||"on-request",onChange:s=>A(a=>({...a,approvalMode:s.target.value})),children:[e.jsxs("option",{value:"untrusted",children:["🔒 ",n("terminal:spawn.codex.approvalsUntrusted")]}),e.jsxs("option",{value:"on-failure",children:["⚠️ ",n("terminal:spawn.codex.approvalsOnFailure")]}),e.jsxs("option",{value:"on-request",children:["🤔 ",n("terminal:spawn.codex.approvalsOnRequest")]}),e.jsxs("option",{value:"never",children:["✅ ",n("terminal:spawn.codex.approvalsNever")]})]})]}),e.jsxs("div",{className:"codex-option-group",children:[e.jsx("div",{className:"codex-option-header",children:n("terminal:spawn.codex.profile")}),e.jsx("input",{type:"text",className:"spawn-input codex-profile-input",placeholder:n("terminal:spawn.codex.profilePlaceholder"),value:f.profile||"",onChange:s=>A(a=>({...a,profile:s.target.value||void 0}))})]}),e.jsxs("div",{className:"codex-option-group",children:[e.jsx("div",{className:"codex-option-header",children:n("terminal:spawn.codex.reasoningEffort")}),e.jsxs("select",{className:"spawn-input codex-select",value:f.reasoningEffort||"",onChange:s=>A(a=>({...a,reasoningEffort:s.target.value||void 0})),children:[e.jsx("option",{value:"",children:n("terminal:spawn.codex.reasoningEffortDefault")}),Object.keys(me).map(s=>e.jsxs("option",{value:s,children:[me[s].icon," ",me[s].label]},s))]})]})]})]})]}),w.length>0&&e.jsxs("div",{className:"spawn-section spawn-skills-section",children:[e.jsxs("div",{className:"spawn-section-header",children:[e.jsxs("h4",{className:"spawn-section-title",children:[n("terminal:spawn.skills"),e.jsx(x,{text:n("terminal:spawn.helpSkills"),title:n("terminal:spawn.skillsTitle"),position:"top",size:"sm"})]}),e.jsxs("span",{className:"spawn-section-hint",children:[V.size," selected · ",n("common:labels.optional")]})]}),w.length>6&&e.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:n("terminal:spawn.filterSkills"),value:D,onChange:s=>We(s.target.value)}),e.jsxs("div",{className:"spawn-skills-inline",children:[Ce.map(s=>{const a=V.has(s.id);return He.some(r=>r.id===s.id)?null:e.jsxs("button",{className:`spawn-skill-chip ${a?"selected":""}`,onClick:()=>Ke(s.id),title:s.description,children:[a&&e.jsx("span",{className:"spawn-skill-check",children:e.jsx(de,{name:"check",size:10})}),e.jsx("span",{children:s.name}),s.builtin&&e.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},s.id)}),D&&Ce.length===0&&e.jsx("div",{className:"skill-search-empty",children:n("terminal:spawn.noSkillsMatch",{query:D})})]})]}),e.jsxs("details",{className:"spawn-advanced",children:[e.jsxs("summary",{children:[n("terminal:spawn.customInstructions")," & ",n("terminal:spawn.linkSession")]}),e.jsxs("div",{className:"spawn-advanced-body",children:[e.jsxs("div",{className:"spawn-custom-instructions-section",children:[e.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.customInstructions")," ",e.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]}),e.jsx(x,{text:n("terminal:spawn.helpCustomInstructions"),title:n("terminal:spawn.customInstructions"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"spawn-input spawn-textarea",placeholder:n("terminal:spawn.customInstructionsPlaceholder"),value:ve,onChange:s=>qe(s.target.value),rows:3})]}),e.jsxs("div",{className:"spawn-sessions-section",children:[e.jsxs("label",{className:"spawn-label",children:[n("terminal:spawn.linkSession")," ",e.jsxs("span",{className:"spawn-label-hint",children:["(",n("common:labels.optional"),")"]}),e.jsx(x,{text:n("terminal:spawn.helpLinkSession"),title:n("terminal:spawn.linkSessionTitle"),position:"top",size:"sm"})]}),y.length>0&&e.jsx("input",{type:"text",className:"spawn-input session-search-input",placeholder:n("terminal:spawn.searchSessions"),value:_,onChange:s=>je(s.target.value)}),e.jsx("div",{className:"sessions-list",children:Pe?e.jsx("div",{className:"sessions-loading",children:n("terminal:spawn.loadingSessions")}):y.length===0?e.jsx("div",{className:"sessions-empty",children:n("terminal:spawn.noSessions")}):ke.length===0?e.jsx("div",{className:"sessions-empty",children:n("terminal:spawn.noSessionsMatch",{query:_})}):ke.map(s=>{const a=E===s.sessionId,l=Date.now()-new Date(s.lastModified).getTime(),r=l<6e4?n("common:time.justNow"):l<36e5?n("common:time.minutesAgo",{count:Math.floor(l/6e4)}):l<864e5?n("common:time.hoursAgo",{count:Math.floor(l/36e5)}):n("common:time.daysAgo",{count:Math.floor(l/864e5)});return e.jsxs("div",{className:`session-item ${a?"selected":""}`,onClick:()=>{a?O(null):(O(s.sessionId),F(s.projectPath))},children:[e.jsxs("div",{className:"session-item-header",children:[e.jsx("span",{className:"session-item-path",children:s.projectPath}),e.jsx("span",{className:"session-item-age",children:r})]}),e.jsx("div",{className:"session-item-preview",children:s.firstMessage||n("terminal:spawn.messagesCount",{count:s.messageCount})})]},s.sessionId)})})]})]})]})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:j,children:n("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:Ve,disabled:he,children:n(he?"common:buttons.deploying":"common:buttons2.deploy")})]})]})})}export{gs as SpawnModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as R,n as U,aq as j,da as B,db as F,j as t,bB as G,I,c9 as k}from"./main-DIf9R6Jx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const b=["#6ab8c8","#c89a5a","#9a80c0","#5cb88a","#c85a5a","#c87a9a","#c8c87a","#5a8fd4","#d45a5a","#8a6fbf"],P=14,w=720,C=260,p={top:16,right:20,bottom:42,left:64};function W(){const i=new Date;return i.setHours(0,0,0,0),i.getTime()}function $(i){if(!i)return"N/A";try{return new Date(i).toLocaleString()}catch{return"N/A"}}function q(i,s){if(i.length===0||s<=0)return"conic-gradient(rgba(50, 50, 62, 0.95) 0deg 360deg)";let a=0;return`conic-gradient(${i.map((h,l)=>{const c=a,n=h.tokens.total/s*360;return a+=n,`${b[l%b.length]} ${c.toFixed(2)}deg ${a.toFixed(2)}deg`}).join(", ")})`}function E(i){const[,s,a]=i.split("-");return!s||!a?i:`${s}/${a}`}function z(i){const s=(i==null?void 0:i.days)??[];if(s.length===0)return[];const a=new Map;for(const l of s)for(const c of l.agents){const n=a.get(c.agentId)??{agentName:c.agentName,total:0};n.total+=c.tokens.total,a.set(c.agentId,n)}const r={id:"general",name:"General",color:"#f1fa8c",values:s.map(l=>l.totalTokens),total:s.reduce((l,c)=>l+c.totalTokens,0),peak:Math.max(0,...s.map(l=>l.totalTokens)),isTotal:!0},h=[...a.entries()].sort((l,c)=>c[1].total-l[1].total).map(([l,c],n)=>({id:l,name:c.agentName,color:b[n%b.length],values:s.map(u=>{var d;return((d=u.agents.find(x=>x.agentId===l))==null?void 0:d.tokens.total)??0}),total:c.total,peak:Math.max(0,...s.map(u=>{var d;return((d=u.agents.find(x=>x.agentId===l))==null?void 0:d.tokens.total)??0}))}));return[r,...h].filter(l=>l.total>0)}function Y(i){if(i<=0)return 1;const s=10**Math.floor(Math.log10(i)),a=i/s;return(a<=1?1:a<=2?2:a<=5?5:10)*s}function H(i,s,a,r){const h=p.left,l=p.top,c=w-p.left-p.right,n=C-p.top-p.bottom,u=i<=1?h+c/2:h+s/(i-1)*c,d=l+n-a/r*n;return{x:u,y:d}}function X(i,s){return i.map((a,r)=>{const{x:h,y:l}=H(i.length,r,a,s);return`${h.toFixed(2)},${l.toFixed(2)}`}).join(" ")}function J(i,s=28){return i.length<=s?i:`${i.slice(0,s-1)}...`}function K({summary:i}){const[s,a]=j.useState(null),r=i.days,h=z(i),l=Math.max(1,...h.flatMap(e=>e.values)),c=Y(l),n=p.left,u=p.top,d=w-p.left-p.right,x=C-p.top-p.bottom,f=[0,.5,1],M=Math.max(1,Math.ceil(r.length/5)),v=190,y=86,g=s?Math.min(Math.max(s.x+12,8),w-v-8):0,_=s?Math.min(Math.max(s.y-y-10,8),C-y-8):0;return t.jsxs("div",{className:"statistics-line-chart",children:[t.jsxs("svg",{className:"statistics-line-chart__svg",viewBox:`0 0 ${w} ${C}`,role:"img","aria-label":"Daily Claude token usage by agent",preserveAspectRatio:"xMidYMid meet",onMouseLeave:()=>a(null),children:[f.map(e=>{const m=u+x-e*x;return t.jsxs("g",{children:[t.jsx("line",{className:"statistics-line-chart__grid",x1:n,y1:m,x2:n+d,y2:m}),t.jsx("text",{className:"statistics-line-chart__axis-label",x:n-10,y:m+4,textAnchor:"end",children:k(Math.round(c*e))})]},e)}),t.jsx("line",{className:"statistics-line-chart__axis",x1:n,y1:u,x2:n,y2:u+x}),t.jsx("line",{className:"statistics-line-chart__axis",x1:n,y1:u+x,x2:n+d,y2:u+x}),r.map((e,m)=>{if(m!==0&&m!==r.length-1&&m%M!==0)return null;const o=r.length<=1?n+d/2:n+m/(r.length-1)*d;return t.jsx("text",{className:"statistics-line-chart__axis-label",x:o,y:C-14,textAnchor:"middle",children:E(e.date)},e.date)}),h.map(e=>t.jsx("polyline",{className:e.isTotal?"statistics-line-chart__line statistics-line-chart__line--total":"statistics-line-chart__line",points:X(e.values,c),fill:"none",stroke:e.color,strokeWidth:e.isTotal?3:2,strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("title",{children:`${e.name}: ${e.peak.toLocaleString()} peak daily tokens`})},e.id)),h.map(e=>e.values.map((m,o)=>{var L,D,V,A;const{x:N,y:S}=H(r.length,o,m,c),T={id:`${e.id}-${(L=r[o])==null?void 0:L.date}`,date:((D=r[o])==null?void 0:D.date)??"",name:e.name,color:e.color,value:m,total:e.total,peak:e.peak,x:N,y:S};return t.jsxs("g",{children:[t.jsx("circle",{className:"statistics-line-chart__point",cx:N,cy:S,r:e.isTotal?3.4:2.6,fill:e.color}),t.jsx("circle",{className:"statistics-line-chart__point-hit",cx:N,cy:S,r:10,tabIndex:0,role:"button","aria-label":`${e.name} ${(V=r[o])==null?void 0:V.date}: ${m.toLocaleString()} tokens`,onMouseEnter:()=>a(T),onFocus:()=>a(T),onBlur:()=>a(null)})]},`${e.id}-${(A=r[o])==null?void 0:A.date}`)})),s&&t.jsxs("g",{className:"statistics-line-chart__tooltip",children:[t.jsx("line",{className:"statistics-line-chart__hover-line",x1:s.x,y1:u,x2:s.x,y2:u+x}),t.jsx("circle",{className:"statistics-line-chart__hover-point",cx:s.x,cy:s.y,r:5,fill:s.color}),t.jsx("rect",{className:"statistics-line-chart__tooltip-box",x:g,y:_,width:v,height:y,rx:6}),t.jsx("text",{className:"statistics-line-chart__tooltip-title",x:g+10,y:_+18,children:E(s.date)}),t.jsx("text",{className:"statistics-line-chart__tooltip-name",x:g+10,y:_+34,children:J(s.name)}),t.jsxs("text",{className:"statistics-line-chart__tooltip-value",x:g+10,y:_+52,children:["Daily: ",k(s.value)]}),t.jsxs("text",{className:"statistics-line-chart__tooltip-meta",x:g+10,y:_+68,children:["Peak: ",k(s.peak)]}),t.jsxs("text",{className:"statistics-line-chart__tooltip-meta",x:g+100,y:_+68,children:["Total: ",k(s.total)]})]})]}),t.jsx("div",{className:"statistics-line-chart__legend",children:h.map(e=>t.jsxs("div",{className:"statistics-line-chart__legend-item",title:`${e.name}: peak ${e.peak.toLocaleString()} daily tokens, ${e.total.toLocaleString()} period tokens`,children:[t.jsx("span",{className:"statistics-line-chart__legend-swatch",style:{backgroundColor:e.color}}),t.jsx("span",{children:e.name}),t.jsx("strong",{children:k(e.peak)})]},e.id))})]})}function tt({isOpen:i,onClose:s}){const{t:a}=R(["terminal","common"]),{handleMouseDown:r,handleClick:h}=U(s),[l,c]=j.useState(null),[n,u]=j.useState(null),[d,x]=j.useState(!1),[f,M]=j.useState(null),v=j.useMemo(()=>W(),[]),y=j.useCallback(async()=>{x(!0),M(null);try{const o=Date.now(),[N,S]=await Promise.all([B({since:v,until:o}),F({days:P,until:o})]);c(N),u(S)}catch(o){M((o==null?void 0:o.message)||"Error")}finally{x(!1)}},[v]);if(j.useEffect(()=>{i&&y()},[i,y]),!i)return null;const g=(l==null?void 0:l.entries)??[],_=(l==null?void 0:l.totalTokens)??0,e=q(g,_),m=((n==null?void 0:n.days)??[]).some(o=>o.totalTokens>0);return t.jsx(G,{children:t.jsx("div",{className:"modal-overlay visible",onMouseDown:r,onClick:h,children:t.jsxs("div",{className:"modal statistics-modal",children:[t.jsxs("div",{className:"modal-header statistics-modal__header",children:[t.jsxs("div",{className:"statistics-modal__title",children:[t.jsx("span",{className:"statistics-modal__icon",children:t.jsx(I,{name:"dashboard",size:15})}),t.jsx("span",{children:a("terminal:statistics.title",{defaultValue:"Statistics"})})]}),t.jsx("button",{className:"modal-close statistics-modal__close",onClick:s,title:a("common:buttons.close"),children:"×"})]}),t.jsxs("div",{className:"modal-body statistics-modal__body",children:[t.jsxs("section",{className:"statistics-panel",children:[t.jsxs("div",{className:"statistics-panel__header",children:[t.jsxs("div",{children:[t.jsx("h3",{children:a("terminal:statistics.usageByAgent",{defaultValue:"Claude usage today"})}),t.jsx("span",{className:"statistics-panel__subtitle",children:a("terminal:statistics.usageByAgentSubtitle",{defaultValue:"Input + cache creation + cache read + output tokens, deduped by Claude request id"})})]}),t.jsx("button",{type:"button",className:"statistics-panel__refresh",onClick:y,disabled:d,title:a("terminal:statistics.refresh",{defaultValue:"Refresh usage"}),children:t.jsx(I,{name:"refresh",size:14})})]}),d&&!l&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!d&&f&&t.jsx("div",{className:"statistics-panel__empty statistics-panel__empty--error",children:a("terminal:statistics.error",{defaultValue:"Failed to load usage: {{error}}",error:f})}),!f&&l&&g.length===0&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.empty",{defaultValue:"No Claude token usage found for today."})}),!f&&l&&g.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"statistics-panel__layout",children:[t.jsx("div",{className:"statistics-panel__chart-wrap",children:t.jsx("div",{className:"statistics-panel__pie",style:{background:e},role:"img","aria-label":a("terminal:statistics.pieLabel",{defaultValue:"Claude token usage by agent"}),children:t.jsxs("div",{className:"statistics-panel__pie-hole",children:[t.jsx("strong",{children:k(_)}),t.jsx("span",{children:a("terminal:statistics.total",{defaultValue:"total"})})]})})}),t.jsx("div",{className:"statistics-panel__list",children:g.map((o,N)=>t.jsxs("div",{className:"statistics-panel__row",title:`${o.agentName}: ${o.tokens.total.toLocaleString()} tokens`,children:[t.jsx("span",{className:"statistics-panel__swatch",style:{backgroundColor:b[N%b.length]}}),t.jsxs("div",{className:"statistics-panel__row-main",children:[t.jsx("div",{className:"statistics-panel__row-name",children:o.agentName}),t.jsxs("div",{className:"statistics-panel__row-meta",children:[o.requestCount.toLocaleString()," ",a("terminal:statistics.requests",{defaultValue:"requests"})," / ",o.percent,"%"]})]}),t.jsx("strong",{children:k(o.tokens.total)})]},o.agentId))})]}),t.jsx("div",{className:"statistics-panel__footnote",children:a("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:$(l.since),until:$(l.until)})})]})]}),t.jsxs("section",{className:"statistics-panel",children:[t.jsx("div",{className:"statistics-panel__header",children:t.jsxs("div",{children:[t.jsx("h3",{children:a("terminal:statistics.dailyUsage",{defaultValue:"Daily usage by agent"})}),t.jsx("span",{className:"statistics-panel__subtitle",children:a("terminal:statistics.dailyUsageSubtitle",{defaultValue:"General token usage by day plus one line for each Claude agent."})})]})}),d&&!n&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!d&&!f&&n&&!m&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.dailyEmpty",{defaultValue:"No Claude token usage found for recent days."})}),!f&&n&&m&&t.jsxs(t.Fragment,{children:[t.jsx(K,{summary:n}),t.jsx("div",{className:"statistics-panel__footnote",children:a("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:$(n.since),until:$(n.until)})})]})]})]})]})})})}export{tt as StatisticsModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as L,aC as $,ar as D,r as m,j as s,bj as N,a9 as S,I as g,s as J}from"./main-DIf9R6Jx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function M({isOpen:l,bossId:r,onClose:o}){var j;const{t:a}=L(["terminal","common"]),f=$(),n=D(r),[i,c]=m.useState(new Set),[u,b]=m.useState(!1),d=Array.from(f.values()).filter(e=>e.class!=="boss"&&(!e.bossId||e.bossId===r));m.useEffect(()=>{l&&n&&c(new Set(n.subordinateIds||[]))},[l,n]);const y=()=>{b(!0),J.assignSubordinates(r,Array.from(i)),setTimeout(()=>{b(!1),o()},300)},A=e=>{const t=new Set(i);t.has(e)?t.delete(e):t.add(e),c(t)},C=()=>{c(new Set(d.map(e=>e.id)))},p=()=>{c(new Set)},w=e=>{e.target===e.currentTarget&&o()},k=e=>{e.key==="Escape"&&o()};if(!l||!n)return null;const E=N.boss,h=((j=n.subordinateIds)==null?void 0:j.length)||0,I=i.size,x=JSON.stringify([...n.subordinateIds||[]].sort())!==JSON.stringify([...i].sort());return s.jsx("div",{className:`modal-overlay ${l?"visible":""}`,onClick:w,onKeyDown:k,children:s.jsxs("div",{className:"modal subordinate-assignment-modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("span",{className:"boss-header-icon",style:{color:E.color},children:s.jsx(S,{agent:n,size:22})}),a("terminal:team.manageTeam"),": ",n.name]}),s.jsxs("div",{className:"modal-body subordinate-assignment-body",children:[s.jsxs("div",{className:"subordinate-assignment-info",children:[s.jsx("p",{children:a("terminal:team.selectAgents")}),s.jsxs("div",{className:"subordinate-assignment-actions",children:[s.jsx("button",{className:"btn btn-small",onClick:C,children:a("common:buttons.selectAll")}),s.jsx("button",{className:"btn btn-small",onClick:p,children:a("common:buttons.clearAll")})]})]}),s.jsx("div",{className:"subordinates-list",children:d.length===0?s.jsx("div",{className:"subordinates-empty",children:a("terminal:team.noAgentsAvailable")}):d.map(e=>{var v;const t=i.has(e.id),T=N[e.class],z=(v=n.subordinateIds)==null?void 0:v.includes(e.id);return s.jsxs("div",{className:`subordinate-item ${t?"selected":""}`,onClick:()=>A(e.id),children:[s.jsx("div",{className:"subordinate-checkbox",children:t?s.jsx(g,{name:"check",size:12}):null}),s.jsx("div",{className:"subordinate-icon",style:{color:T.color},children:s.jsx(S,{agent:e,size:18})}),s.jsxs("div",{className:"subordinate-info",children:[s.jsx("div",{className:"subordinate-name",children:e.name}),s.jsx("div",{className:"subordinate-class",children:e.class})]}),s.jsx("div",{className:`subordinate-status status-${e.status}`,children:e.status}),z&&s.jsx("div",{className:"subordinate-badge",children:a("common:status.current")})]},e.id)})}),s.jsx("div",{className:"subordinate-assignment-summary",children:x?s.jsxs("span",{className:"summary-changed",children:[h," ",s.jsx(g,{name:"arrow-right",size:11})," ",I," ",a("terminal:team.subordinates").toLowerCase()]}):s.jsxs("span",{className:"summary-unchanged",children:[h," ",a("terminal:team.subordinates").toLowerCase()]})})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:o,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-boss",onClick:y,disabled:u||!x,children:a(u?"common:status.saving":"terminal:team.saveTeam")})]})]})})}export{M as SubordinateAssignmentModal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aq as ts,u as rs,aU as _s,aV as vs,aW as Is,j as s,I as U,a9 as $s,aX as Es,aY as Ds,aZ as Ms,a_ as Ls,r as o,ag as Xs,aC as Ss,m as Ps,a5 as Ys,Y as Rs,a$ as Gs,b0 as Us,b1 as Fs,b2 as Zs,b3 as Hs,s as M,b4 as Ws,t as G}from"./main-DIf9R6Jx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const bs=ts.memo(({agent:a,isSelected:z,isKeyboardFocused:F=!1,onSelect:L,onDoubleClick:r,onChat:g,onFocus:h,onKill:w,onDragStart:X})=>{const{t:x}=rs(["dashboard","common"]),S=_s().has(a.id),N=vs(a.status),Z=Is(a),j=Ls(Z),I=a.taskLabel?s.jsxs(s.Fragment,{children:[s.jsx(U,{name:"task",size:12})," ",a.taskLabel]}):a.currentTask||a.lastAssignedTask,m=a.status==="idle"&&a.lastActivity>0,[,H]=ts.useState(0);return ts.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>H(q=>q+1),15e3);return()=>window.clearInterval(b)},[m]),s.jsxs("div",{className:`dash-card dash-card--${N} ${z?"dash-card--selected":""} ${F?"dash-card--keyboard-focused":""}`,"data-agent-id":a.id,onClick:()=>L(a.id),onDoubleClick:b=>{b.stopPropagation(),r(a.id)},onDragStart:b=>{X==null||X(a),b.dataTransfer.effectAllowed="move"},draggable:!0,title:x("cards.doubleClickHint"),children:[s.jsxs("div",{className:"dash-card__row1",children:[s.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${N}`}),s.jsx("span",{className:"dash-card__name",children:a.name}),s.jsxs("span",{className:"dash-card__class",children:[s.jsx($s,{agent:a,size:14})," ",a.class]}),s.jsxs("span",{className:`dash-card__provider dash-card__provider--${a.provider}`,children:[s.jsx(U,{name:a.provider==="codex"||a.provider==="opencode"||a.provider==="grok"?"status-pending":"robot",size:11,weight:a.provider==="codex"||a.provider==="opencode"||a.provider==="grok"?"fill":"regular",color:a.provider==="codex"?"#a16207":a.provider==="opencode"?"#4ade80":a.provider==="grok"?"#6366f1":void 0})," ",a.provider]}),S&&s.jsx("span",{className:"dash-card__unseen-badge",title:"New output available - click to view",children:"!"})]}),s.jsxs("div",{className:"dash-card__row2",children:[s.jsx("span",{className:`dash-card__status dash-card__status--${N}`,children:S?"Unseen":a.status}),s.jsxs("div",{className:"dash-card__context",children:[s.jsx("div",{className:"dash-card__context-bar",children:s.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${j}`,style:{width:`${Z}%`}})}),s.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${j}`,children:[Z,"%"]})]})]}),s.jsxs("div",{className:"dash-card__row3",children:[s.jsxs("span",{className:"dash-card__workdir",title:a.cwd,children:[s.jsx(U,{name:"folder",size:11})," ",a.cwd.split("/").pop()||a.cwd]}),m&&s.jsxs("span",{className:"dash-card__idle-time",style:{color:Ms(a.lastActivity)},title:Ds(a.lastActivity),children:[s.jsx(U,{name:"status-waiting-input",size:10})," ",Es(a.lastActivity)]})]}),I&&s.jsx("div",{className:"dash-card__row4",children:s.jsx("span",{className:"dash-card__task",children:I})}),s.jsxs("div",{className:"dash-card__actions",children:[g&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:b=>{b.stopPropagation(),g(a.id)},title:x("cards.openTerminal"),children:x("cards.chat")}),w&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:b=>{b.stopPropagation(),w(a.id)},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});bs.displayName="AgentCard";const fs=({buildings:a,onSelectBuilding:z})=>{const{t:F}=rs(["dashboard"]),L=o.useMemo(()=>Array.from(a.values()).sort((r,g)=>r.name.localeCompare(g.name)),[a]);return s.jsxs("div",{className:"dashboard-view__buildings",children:[s.jsxs("div",{className:"dashboard-view__buildings-header",children:[s.jsx("span",{className:"dashboard-view__buildings-title",children:F("buildings.title")}),s.jsx("span",{className:"dashboard-view__buildings-count",children:L.length})]}),s.jsx("div",{className:"dashboard-view__buildings-row",children:L.map(r=>{const g=vs(r.status),h=Xs(r.type);return s.jsxs("button",{className:`dash-pill dash-pill--${g}`,onClick:()=>z==null?void 0:z(r.id),title:`${r.name} (${r.type}) - ${r.status}`,children:[s.jsx("span",{className:"dash-pill__icon",children:s.jsx(U,{name:h,size:14})}),s.jsx("span",{className:"dash-pill__name",children:r.name}),s.jsx("span",{className:`dash-pill__dot dash-pill__dot--${g}`})]},r.id)})})]})};fs.displayName="BuildingPills";function qs({onSelectAgent:a,onFocusAgent:z,onKillAgent:F,onSelectBuilding:L,onOpenTerminal:r,onFocusZone:g}){const{t:h}=rs(["dashboard","common"]),w=Ss(),X=Ps(),x=Ys(),ns=Rs(),S=_s(),[N,Z]=o.useState(""),[j,I]=o.useState("all"),[m,H]=o.useState("zone"),[b,q]=o.useState(new Set),[k,J]=o.useState(null),[ws,B]=o.useState(null),[P,Q]=o.useState(!1),[p,W]=o.useState(null),K=o.useMemo(()=>{const e=Array.from(w.values());return{total:e.length,working:e.filter(d=>d.status==="working"||d.status==="waiting"||d.status==="waiting_permission").length,idle:e.filter(d=>d.status==="idle").length,error:e.filter(d=>d.status==="error"||d.status==="offline"||d.status==="orphaned").length}},[w]),is=o.useMemo(()=>m==="zone"?Gs(w,x):m==="status"?Us(w,S):Fs(w),[w,x,m,S]),T=o.useMemo(()=>{const e=N.toLowerCase().trim(),d=is.map(l=>({...l,agents:l.agents.filter(_=>{if(j==="working"){if(_.status!=="working"&&_.status!=="waiting"&&_.status!=="waiting_permission")return!1}else if(j==="error"&&_.status!=="error"&&_.status!=="offline"&&_.status!=="orphaned")return!1;return!(e&&!_.name.toLowerCase().includes(e)&&!_.class.toLowerCase().includes(e))})}));return m==="zone"?d:d.filter(l=>l.agents.length>0)},[is,j,N,m]),O=o.useCallback(e=>e.area?`area:${e.area.id}`:`${m}:${e.label}`,[m]),ss=o.useMemo(()=>T.map(e=>({...e,sortedAgents:m==="status"?Zs(e.agents,{prioritizeRecentlyIdle:!0}):Hs(e.agents)})),[T,m]),C=o.useMemo(()=>{const e=[];return ss.forEach(d=>{const l=O(d);b.has(l)||e.push(...d.sortedAgents)}),e},[ss,b,O]),ps=o.useCallback(e=>{q(d=>{const l=new Set(d);return l.has(e)?l.delete(e):l.add(e),l})},[]),gs=o.useCallback(e=>{r==null||r(e)},[r]),xs=o.useCallback(e=>{a==null||a(e),Q(!0),W(e)},[a]),js=o.useCallback(e=>{r==null||r(e)},[r]),Ns=o.useCallback(e=>{J(e)},[]),ks=o.useCallback((e,d)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",B(d)},[]),Cs=o.useCallback(()=>{B(null)},[]),ys=o.useCallback(e=>{if(!k)return;if(e===null){const $=M.getState(),t=Array.from($.areas.values()).find(n=>n.assignedAgentIds.includes(k.id));t&&M.unassignAgentFromArea(k.id,t.id),J(null),B(null);return}const d=x.get(e);if(!d)return;const l=Array.from(w.values()),_=Ws(d,l,k.position);M.updateAgent({...k,position:{...k.position,x:_.x,z:_.z}}),M.assignAgentToArea(k.id,e),J(null),B(null)},[k,x,w]);return o.useEffect(()=>{if(C.length===0){Q(!1),W(null);return}P&&(!p||!C.some(e=>e.id===p))&&(W(C[0].id),a==null||a(C[0].id))},[C,P,p,a]),o.useEffect(()=>{const e=t=>t instanceof HTMLElement?t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||t.isContentEditable:!1,d=t=>t instanceof HTMLElement?!!t.closest(".guake-terminal")||t.classList.contains("guake-input")||t.classList.contains("agent-panel-input"):!1,l=t=>{const n=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(A=>A.dataset.agentId===t);n==null||n.scrollIntoView({block:"nearest",inline:"nearest"})},_=(t,n)=>{var os,cs,ls,us,hs,ms;const A=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(i=>{const u=i.dataset.agentId;if(!u)return null;const y=i.getBoundingClientRect();return{id:u,centerX:y.left+y.width/2,centerY:y.top+y.height/2,height:y.height}}).filter(i=>i!==null).sort((i,u)=>i.centerY-u.centerY||i.centerX-u.centerX);if(A.length===0)return t;const es=A.reduce((i,u)=>i+u.height,0)/A.length,as=Math.max(18,es*.6),f=[];for(const i of A){const u=f[f.length-1];if(!u){f.push([{id:i.id,centerX:i.centerX,centerY:i.centerY}]);continue}const y=u.reduce((As,zs)=>As+zs.centerY,0)/u.length;Math.abs(i.centerY-y)<=as?u.push({id:i.id,centerX:i.centerX,centerY:i.centerY}):f.push([{id:i.id,centerX:i.centerX,centerY:i.centerY}])}f.forEach(i=>i.sort((u,y)=>u.centerX-y.centerX));const Y=f.findIndex(i=>i.some(u=>u.id===t));if(Y===-1)return((cs=(os=f[0])==null?void 0:os[0])==null?void 0:cs.id)??t;const E=f[Y],v=E.findIndex(i=>i.id===t);if(v===-1)return((us=(ls=f[0])==null?void 0:ls[0])==null?void 0:us.id)??t;if(n==="left")return((hs=E[Math.max(0,v-1)])==null?void 0:hs.id)??t;if(n==="right")return((ms=E[Math.min(E.length-1,v+1)])==null?void 0:ms.id)??t;const V=n==="up"?Math.max(0,Y-1):Math.min(f.length-1,Y+1),c=f[V],R=E[v].centerX;let D=c[0],ds=Math.abs(D.centerX-R);for(const i of c){const u=Math.abs(i.centerX-R);u<ds&&(D=i,ds=u)}return(D==null?void 0:D.id)??t},$=t=>{const n=M.getShortcuts(),A=n.find(c=>c.id==="dashboard-selector-toggle"),es=n.find(c=>c.id==="dashboard-vim-left"),as=n.find(c=>c.id==="dashboard-vim-down"),f=n.find(c=>c.id==="dashboard-vim-up"),Y=n.find(c=>c.id==="dashboard-vim-right"),E=n.find(c=>c.id==="open-terminal"),v=M.getState();if(e(t.target))if(!v.terminalOpen&&d(t.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(G(t,A)){if(C.length===0)return;t.preventDefault(),t.stopPropagation(),Q(!0),W(c=>{const R=c&&C.some(D=>D.id===c)?c:C[0].id;return a==null||a(R),window.setTimeout(()=>l(R),0),R});return}const V=G(t,es)||t.key==="ArrowLeft"?"left":G(t,as)||t.key==="ArrowDown"?"down":G(t,f)||t.key==="ArrowUp"?"up":G(t,Y)||t.key==="ArrowRight"?"right":null;if(V&&P&&p){t.preventDefault(),t.stopPropagation();const c=_(p,V);c!==p&&(W(c),a==null||a(c),window.setTimeout(()=>l(c),0));return}if(G(t,E)){if(v.terminalOpen)return;if(P&&p&&v.agents.has(p)){t.preventDefault(),r==null||r(p);return}if(v.selectedAgentIds.size===1){t.preventDefault();const c=Array.from(v.selectedAgentIds)[0];r==null||r(c);return}if(v.lastSelectedAgentId&&v.agents.has(v.lastSelectedAgentId)){t.preventDefault(),r==null||r(v.lastSelectedAgentId);return}}};return document.addEventListener("keydown",$,!0),()=>document.removeEventListener("keydown",$,!0)},[C,P,p,r,a]),o.useEffect(()=>{const e=document.activeElement;e instanceof HTMLElement&&e.closest(".guake-terminal")&&!M.getState().terminalOpen&&e.blur()},[]),s.jsxs("div",{className:"dashboard-view",children:[s.jsxs("div",{className:"dashboard-view__topbar",children:[s.jsxs("div",{className:"dashboard-view__metrics",children:[s.jsxs("button",{className:`dashboard-view__metric-btn ${j==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.total}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:labels.agents")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${j==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("working"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.working}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.working")})]}),s.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.idle}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.idle")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${j==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("error"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.error}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.error")})]})]}),s.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:h("searchPlaceholder"),value:N,onChange:e=>Z(e.target.value)})]}),s.jsxs("div",{className:"dashboard-view__grouping",children:[s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>H("zone"),children:h("grouping.byZone")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>H("status"),children:h("grouping.byStatus")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>H("activity"),children:h("grouping.byActivity")})]}),s.jsxs("div",{className:"dashboard-view__content",children:[ss.map(e=>{const d=O(e),l=b.has(d),_=e.sortedAgents,$=e.agents.filter(n=>n.status==="working"||n.status==="waiting"||n.status==="waiting_permission").length,t=e.agents.filter(n=>S.has(n.id)).length;return s.jsxs("div",{className:`dashboard-view__zone ${ws===(e.area?e.area.id:null)&&k?"dashboard-view__zone--drag-over":""}`,onDragOver:n=>ks(n,e.area?e.area.id:null),onDragLeave:Cs,onDrop:()=>ys(e.area?e.area.id:null),children:[s.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>ps(d),children:[s.jsxs("div",{className:"dashboard-view__zone-left",children:[s.jsx("span",{className:`dashboard-view__zone-chevron ${l?"dashboard-view__zone-chevron--collapsed":""}`,children:s.jsx(U,{name:"caret-down",size:12})}),s.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:e.color}}),s.jsx("span",{className:"dashboard-view__zone-name",children:e.label}),s.jsxs("span",{className:"dashboard-view__zone-count",children:[h("agentCount",{count:e.agents.length}),$>0&&s.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",$," ",h("working")]}),t>0&&s.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",t," Unseen"]})]})]}),e.area&&g&&s.jsx("button",{className:"dashboard-view__zone-focus",onClick:n=>{n.stopPropagation(),g(e.area.id)},title:h("focusZone"),children:h("focusZone")})]}),!l&&s.jsx("div",{className:"dashboard-view__zone-grid",children:_.map(n=>s.jsx(bs,{agent:n,isSelected:ns.has(n.id),isKeyboardFocused:P&&p===n.id,onSelect:xs,onDoubleClick:gs,onChat:js,onFocus:z,onKill:F,onDragStart:Ns},n.id))})]},d)}),T.length===0&&s.jsx("div",{className:"dashboard-view__empty",children:N?h("noAgentsMatching",{search:N}):h("noAgentsSpawned")}),X.size>0&&s.jsx(fs,{buildings:X,onSelectBuilding:L})]})]})}export{qs as DashboardView};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as s,H as Aa,J as ea,K as ma,L as pa,j as e,M as fa,N as Ea,u as Kt,O as Ma,P as Ia,U as Ta,V as La,W as Pa,X as $a,Y as Ra,Z as ha,_ as ta,S as M,$ as aa,a0 as Yt,a1 as na,a2 as Mt,a3 as _e,a4 as Da,s as g,a5 as ga,m as xa,a6 as za,z as sa,B as ia,I as d,a7 as Oa,q as Ba,a8 as Fa,a9 as ba,aa as _a,ab as wa,ac as va,ad as Wa,ae as Ha,af as Ua,ag as Ga,ah as Va,ai as Xa,aj as qa,ak as Ya,al as Ka,am as Za,an as Ja,ao as Qa,ap as la,C as en,aq as tn,ar as ra,as as an,at as nn,au as sn,av as ln,aw as rn,ax as on,ay as cn,az as dn,aA as un,aB as mn,aC as pn,aD as fn,aE as hn,aF as gn,aG as xn,aH as it,aI as bn,aJ as _n,aK as wn,aL as vn,aM as gt,aN as jn,aO as Cn,aP as kn,aQ as Nn,aR as yn,aS as oa,aT as Sn}from"./main-DIf9R6Jx.js";import{g as An}from"./area-logos-DnrrrkFh.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function En(c){const r=s.useRef(c);r.current=c,s.useEffect(()=>{if(!Aa())return;let m=null,b=!1;return ea.addListener("backButton",()=>{r.current()==="exit"&&ea.exitApp()}).then(N=>{b?N.remove():m=N}),()=>{b=!0,m&&(m.remove(),m=null)}},[])}async function Mn(c){const r=ma(),m=await fetch(`${pa()}/api/agents/${c}/terminal`,{method:"POST",headers:{Authorization:`Bearer ${r}`}});if(!m.ok){const b=await m.json().catch(()=>({}));throw new Error((b==null?void 0:b.error)||`Failed to start terminal (${m.status})`)}return m.json()}async function In(c){const r=ma();await fetch(`${pa()}/api/agents/${c}/terminal`,{method:"DELETE",headers:{Authorization:`Bearer ${r}`}})}const xt=new Map;function Tn({agentId:c}){const[r,m]=s.useState(null),[b,N]=s.useState(null);return s.useEffect(()=>{let I=!1;const A=xt.get(c);return A&&(clearTimeout(A),xt.delete(c)),m(null),N(null),Mn(c).then(y=>{I||m(y.url)}).catch(y=>{I||N(y instanceof Error?y.message:"Failed to start terminal")}),()=>{I=!0;const y=xt.get(c);y&&clearTimeout(y),xt.set(c,setTimeout(()=>{xt.delete(c),In(c)},2500))}},[c]),b?e.jsx("div",{className:"flat-classic-terminal flat-classic-terminal--message",children:e.jsx("span",{children:b})}):r?e.jsx("div",{className:"flat-classic-terminal",children:e.jsx(fa,{terminalUrl:r,visible:!0})}):e.jsx("div",{className:"flat-classic-terminal flat-classic-terminal--message",children:e.jsx("span",{children:"Attaching to interactive session…"})})}const Gt=new Map,Ln=6e4;function ca(c){return Number.isFinite(c)?Math.abs(c)>=1e3?c.toLocaleString(void 0,{maximumFractionDigits:0}):c.toLocaleString(void 0,{maximumFractionDigits:2}):String(c)}function Pn(c,r){var N,I,A;const m=[];if(!c.rateLimits)return m;if(c.provider==="claude"){const y=c,K=[{key:"fiveHour",label:r("terminal:usage.currentSession"),window:y.rateLimits.fiveHour},{key:"sevenDay",label:r("terminal:usage.currentWeekAll"),window:y.rateLimits.sevenDay},{key:"sevenDayOpus",label:r("terminal:usage.currentWeekOpus"),window:y.rateLimits.sevenDayOpus},{key:"sevenDayFable",label:r("terminal:usage.currentWeekFable"),window:y.rateLimits.sevenDayFable}];for(const v of K)(v.window||v.key==="sevenDayFable")&&m.push(v);return m}const b=c;return(N=b.rateLimits)!=null&&N.weekly&&m.push({key:"weekly",label:r("terminal:usage.weeklyLimit"),window:b.rateLimits.weekly}),(I=b.rateLimits)!=null&&I.monthly&&m.push({key:"monthly",label:r("terminal:usage.monthlyLimit"),window:b.rateLimits.monthly}),(A=b.rateLimits)!=null&&A.onDemand&&m.push({key:"onDemand",label:r("terminal:usage.onDemandLimit"),window:b.rateLimits.onDemand}),m}function $n({agentId:c,contextSummary:r}){const{t:m}=Kt(["terminal","common"]),[b,N]=s.useState(()=>{var R;return((R=Gt.get(c))==null?void 0:R.snapshot)??null}),[I,A]=s.useState(!1),[y,K]=s.useState(null),v=s.useRef(0);s.useEffect(()=>{const R=Gt.get(c);if(R&&Date.now()-R.fetchedAt<Ln){N(R.snapshot);return}const re=++v.current;A(!0),K(null),Ma(c).then(T=>{re===v.current&&(Gt.set(c,{snapshot:T,fetchedAt:Date.now()}),N(T),A(!1))}).catch(T=>{re===v.current&&(K(T.message||"Failed to load plan limits"),A(!1))})},[c]);const H=b?Pn(b,m):[];return e.jsxs("div",{className:"plan-limits-tooltip",children:[r&&e.jsx("div",{className:"plan-limits-tooltip__context",children:r}),e.jsx("div",{className:"plan-limits-tooltip__title",children:m("terminal:usage.limits")}),I&&!b&&e.jsxs("div",{className:"plan-limits-tooltip__muted",children:[m("common:status.loading"),"…"]}),!I&&y&&!b&&e.jsx("div",{className:"plan-limits-tooltip__muted",children:m("terminal:usage.limitsError",{message:y})}),H.length>0?e.jsx("div",{className:"plan-limits-tooltip__gauges",children:H.map(({key:R,label:re,window:T})=>{const Ee=T?Math.max(0,Math.min(100,T.utilization)):0,oe=Ta(Ee),ce=T!=null&&typeof T.used=="number"&&typeof T.limit=="number"&&Number.isFinite(T.used)&&Number.isFinite(T.limit);return e.jsxs("div",{className:"plan-limits-tooltip__gauge",children:[e.jsxs("div",{className:"plan-limits-tooltip__gauge-head",children:[e.jsx("span",{className:"plan-limits-tooltip__gauge-label",children:re}),e.jsx("span",{className:"plan-limits-tooltip__gauge-percent",style:{color:oe},children:m("terminal:usage.percentUsed",{percent:Math.round(Ee)})})]}),e.jsx("div",{className:"plan-limits-tooltip__bar",children:e.jsx("div",{className:"plan-limits-tooltip__bar-fill",style:{width:`${Ee}%`,background:oe}})}),e.jsxs("div",{className:"plan-limits-tooltip__reset",children:[T&&m("terminal:usage.resets",{time:Ia(T.resetsAt)}),ce&&e.jsx("span",{style:{marginLeft:8},children:m("terminal:usage.creditsUsed",{used:ca(T.used),limit:ca(T.limit)})})]})]},R)})}):b&&!I&&e.jsx("div",{className:"plan-limits-tooltip__muted",children:b.rateLimitsError?m("terminal:usage.limitsError",{message:b.rateLimitsError}):b.cliHint})]})}function Rn({agentId:c,disabled:r,contextSummary:m,children:b}){return e.jsx(Ea,{position:"top",maxWidth:320,disabled:r,className:"plan-limits-tooltip-wrapper",triggerStyle:{display:"inline-flex",alignItems:"center"},content:e.jsx($n,{agentId:c,contextSummary:m}),children:b})}const Dn=s.memo(function({className:r=""}){const{t:m}=Kt(["common"]),[b,N]=La(),I=s.useRef(null),[A,y]=s.useState(null);s.useLayoutEffect(()=>{const v=I.current;if(!v)return;const H=v.querySelector(".view-mode-toggle__btn--active");H&&y({left:H.offsetLeft,width:H.offsetWidth})},[b]);const K=s.useCallback(v=>{if(v!==b){if(typeof window<"u"&&window.dispatchEvent(new CustomEvent("tide:viewmode-switch-pressed",{detail:{mode:v}})),v==="3d"){requestAnimationFrame(()=>N(v));return}N(v)}},[b,N]);return e.jsxs("div",{className:`view-mode-toggle ${r}`,ref:I,children:[A&&e.jsx("div",{className:"view-mode-toggle__indicator",style:{left:A.left,width:A.width}}),Pa.map(v=>e.jsxs("button",{className:`view-mode-toggle__btn ${b===v?"view-mode-toggle__btn--active":""}`,onClick:()=>K(v),title:m(`common:viewMode.descriptions.${v}`),children:[e.jsxs("span",{className:"view-mode-toggle__icon",children:[v==="2d"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]}),v==="3d"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),e.jsx("path",{d:"M2 17l10 5 10-5"}),e.jsx("path",{d:"M2 12l10 5 10-5"})]}),v==="flat"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1"})]}),v==="dashboard"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"9",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"5",rx:"1"}),e.jsx("rect",{x:"14",y:"12",width:"7",height:"9",rx:"1"}),e.jsx("rect",{x:"3",y:"16",width:"7",height:"5",rx:"1"})]})]}),e.jsx("span",{className:"view-mode-toggle__label",children:m(`common:viewMode.labels.${v}`)})]},v))]})}),It=3,Tt=280,da=320,Vt=240,ua=64,zn=["simple","chat","advanced"],On={simple:"Simple",chat:"Chat",advanced:"Advanced"},Bn={simple:"○",chat:"◐",advanced:"◉"},Fn={simple:"Simple view — clean messages only",chat:"Chat view — assistant replies (no tool calls)",advanced:"Advanced view — everything including tools"},Xt="flat-clear-context",ja="tide:flat-embedded-panels";function Ca(){try{const c=localStorage.getItem(ja),r=c?JSON.parse(c):{};return r&&typeof r=="object"?r:{}}catch{return{}}}function qt(c,r){try{const m=Ca();r?m[c]=r:delete m[c],localStorage.setItem(ja,JSON.stringify(m))}catch{}}function Wn(c){const r=c.split("/").filter(Boolean);return r.length===0?c:r.slice(-2).join("/")}function Hn(c){if(c.provider==="codex"){const I=c.codexModel||"gpt-5.6-luna",A=yn[I];return{model:(A==null?void 0:A.label)||I}}if(c.provider==="opencode")return{model:c.opencodeModel||"opencode"};if(c.provider==="grok"){const I=c.grokModel||"grok-4.5",A=c.effort,y=A?oa[A]:void 0;return{model:I,effort:y==null?void 0:y.label}}const r=c.model||"sonnet",m=Sn[r],b=c.effort,N=b?oa[b]:void 0;return{model:(m==null?void 0:m.label)||r,effort:N==null?void 0:N.label}}function Un(c,r){if(r.type==="rectangle"&&r.width&&r.height){const m=r.width/2,b=r.height/2;return c.x>=r.center.x-m&&c.x<=r.center.x+m&&c.z>=r.center.z-b&&c.z<=r.center.z+b}if(r.type==="circle"&&r.radius){const m=c.x-r.center.x,b=c.z-r.center.z;return m*m+b*b<=r.radius*r.radius}return!1}const Gn=tn.memo(function({agentId:r,terminalViewMode:m,onTerminalViewModeChange:b,inspectorOpen:N,onToggleInspector:I,onShowTaskBoard:A,onImageClick:y,onFileClick:K,onBashClick:v,onViewMarkdown:H,onRequestClearSubordinates:R,keyboard:re,canNavigateBack:T,canNavigateForward:Ee,onNavigateBack:oe,onNavigateForward:ce,agentInfoOpen:Oe,onToggleAgentInfo:bt,onHeaderContextMenu:we,onBuildingContextMenu:ve}){var Nt,yt;const p=ra(r),D=xa(),Me=an(),Ie=s.useRef(null),Ze=s.useRef(null),{displayedAgentId:Te,fadingOut:Lt}=nn(r),_t=ra(Te),Je=!!Me.interactiveMode&&((p==null?void 0:p.provider)??"claude")==="claude"&&!!(p!=null&&p.sessionId),[de,Qe]=s.useState(!1),[Be,ue]=s.useState(!1),$=s.useCallback(()=>ue(!1),[]);ha("flat-chat-actions",Be,$),s.useEffect(()=>{const a=()=>ue(o=>!o);return window.addEventListener("tide:toggle-chat-actions",a),()=>window.removeEventListener("tide:toggle-chat-actions",a)},[]),s.useEffect(()=>{Qe(!1),ue(!1)},[r]),s.useEffect(()=>{!Je&&de&&Qe(!1)},[Je,de]),s.useEffect(()=>{const a=Ze.current;if(!a)return;const o=u=>{u.button===3?(u.preventDefault(),u.stopPropagation(),oe()):u.button===4&&(u.preventDefault(),u.stopPropagation(),ce())},i=u=>{(u.button===3||u.button===4)&&u.preventDefault()};return a.addEventListener("mouseup",o),a.addEventListener("mousedown",i),()=>{a.removeEventListener("mouseup",o),a.removeEventListener("mousedown",i)}},[oe,ce]),s.useEffect(()=>{const a=Ze.current;if(!a)return;let o=0,i=0,u=0;const X=250,Q=600,L=80,st=1.5,ae=ne=>{let U=ne instanceof HTMLElement?ne:null;for(;U&&U!==a;){const St=window.getComputedStyle(U).overflowX;if((St==="auto"||St==="scroll")&&U.scrollWidth>U.clientWidth)return!0;U=U.parentElement}return!1},Ye=ne=>{const U=Date.now();if(U<u){ne.preventDefault();return}if(Math.abs(ne.deltaX)<=Math.abs(ne.deltaY)*st){o=0;return}if(ae(ne.target)){o=0;return}U-i>X&&(o=0),i=U,o+=ne.deltaX,o<=-L?(o=0,u=U+Q,ne.preventDefault(),oe()):o>=L&&(o=0,u=U+Q,ne.preventDefault(),ce())};return a.addEventListener("wheel",Ye,{passive:!1}),()=>a.removeEventListener("wheel",Ye)},[oe,ce]);const me=ga(),lt=s.useMemo(()=>{if(!p)return null;const a=new Set,o=[];for(const i of me.values())i.archived||i.directories.length===0||i.assignedAgentIds.includes(r)&&(a.add(i.id),o.push(i));for(const i of me.values())i.archived||i.directories.length===0||a.has(i.id)||Un({x:p.position.x,z:p.position.z},i)&&(a.add(i.id),o.push(i));return o.length===0?null:o.flatMap(i=>i.directories.filter(u=>u&&u.trim().length>0).map(u=>({areaId:i.id,areaName:i.name,dir:u})))},[p,r,me]),{branches:wt,fetchRemote:Fe,fetchingDirs:Le}=sn(lt),pe=s.useMemo(()=>{var i;const a=g.getAreaForAgent(r);if(!a)return[];const o=[];for(const u of D.values())u.type==="terminal"&&g.isPositionInArea(u.position,a)&&o.push({id:u.id,name:u.name,hasUrl:!!((i=u.terminalStatus)!=null&&i.url)});return o},[r,D]),je=s.useMemo(()=>{var i;const a=g.getAreaForAgent(r);if(!a)return[];const o=[];for(const u of D.values())u.type==="server"&&((i=u.pm2)!=null&&i.enabled)&&g.isPositionInArea(u.position,a)&&o.push({id:u.id,name:u.name});return o},[r,D]),Z=s.useMemo(()=>{const a=g.getAreaForAgent(r);if(!a)return[];const o=[];for(const i of D.values())i.type==="database"&&i.database&&g.isPositionInArea(i.position,a)&&o.push({id:i.id,name:i.name});return o},[r,D]),We=ln(),se=s.useMemo(()=>{const a=g.getAreaForAgent(r);if(!a)return[];const o=[];for(const i of D.values())if(i.type==="tests"&&g.isPositionInArea(i.position,a)){const u=!!i.folderPath&&We.some(X=>rn(X,i.folderPath));o.push({id:i.id,name:i.name,working:u})}return o},[r,D,We]),ie=s.useMemo(()=>{const a=g.getAreaForAgent(r);if(!a)return[];const o=[];for(const i of D.values())i.type==="http"&&g.isPositionInArea(i.position,a)&&o.push({id:i.id,name:i.name});return o},[r,D]),[,Pt]=s.useReducer(a=>a+1,0),Ce=((Nt=Ie.current)==null?void 0:Nt.search.searchMode)??!1,rt=s.useCallback(()=>{var a;(a=Ie.current)==null||a.search.toggleSearch(),Pt()},[]),Pe=on(),$e=Pe.isPending(Xt),[j,te]=s.useState(null),J=j?D.get(j.buildingId):null,[He,Re]=s.useState(""),[Ue,$t]=s.useState(()=>cn()),z=s.useMemo(()=>{var a;return((a=g.getAreaForAgent(r))==null?void 0:a.id)??null},[r,D]),Ge=s.useCallback((a,o)=>{Re(""),te(i=>{const u=(i==null?void 0:i.buildingId)===o?null:{type:a,buildingId:o};return z&&qt(z,u),u})},[z]),ke=s.useCallback(()=>{Re(""),te(null),z&&qt(z,null)},[z]);s.useEffect(()=>{if((j==null?void 0:j.type)!=="pm2-logs")return;const a=j.buildingId;return g.startLogStreaming(a,200),()=>g.stopLogStreaming(a)},[j]);const{height:Rt,onResizeStart:Dt}=dn(),{sidePanelWidth:zt,handleSidePanelResizeStart:ot}=un(),[w,vt]=s.useState(()=>Yt(M.GIT_PANEL_OPEN,!1)),[De,fe]=s.useState(()=>Yt(M.BUILDINGS_PANEL_OPEN,!1)),[O,Ve]=s.useState(!1),ct=s.useCallback(()=>{Ve(a=>{const o=!a;return o&&mn.setEnabled(!0),o})},[]),Ot=s.useCallback(()=>Ve(!1),[]),jt=s.useCallback(()=>{vt(a=>{const o=!a;return _e(M.GIT_PANEL_OPEN,o),o})},[]),Ct=s.useCallback(()=>{fe(a=>{const o=!a;return _e(M.BUILDINGS_PANEL_OPEN,o),o})},[]),Bt=s.useCallback(()=>{vt(!1),_e(M.GIT_PANEL_OPEN,!1)},[]),dt=s.useCallback(()=>{fe(!1),_e(M.BUILDINGS_PANEL_OPEN,!1)},[]),Xe=pn(),he=s.useMemo(()=>({terminal:pe,"pm2-logs":je,database:Z,tests:se,http:ie}),[pe,je,Z,se,ie]);s.useEffect(()=>{if(!j)return;he[j.type].some(o=>o.id===j.buildingId)||(Re(""),te(null))},[j,he]);const Ne=s.useRef(void 0);s.useEffect(()=>{var o;if(Ne.current===z)return;Ne.current=z;const a=z?Ca()[z]:void 0;Re(""),a&&((o=he[a.type])!=null&&o.some(i=>i.id===a.buildingId))?te(a):te(null)},[z,he]),s.useEffect(()=>{const a=o=>{var X;const i=o.detail;if(!(i!=null&&i.buildingId)||!(i!=null&&i.type)||!((X=he[i.type])!=null&&X.some(Q=>Q.id===i.buildingId)))return;i.handled=!0,Re("");const u={type:i.type,buildingId:i.buildingId};te(u),z&&qt(z,u)};return window.addEventListener("tide:dock-building-flat",a),()=>window.removeEventListener("tide:dock-building-flat",a)},[he,z]);const[qe,B]=s.useState(!1),ge=s.useRef(null);if(s.useEffect(()=>{if(!qe)return;const a=o=>{ge.current&&!ge.current.contains(o.target)&&B(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[qe]),!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 ye=p.contextStats,ut=!!ye,et=ye?ye.totalTokens:p.contextUsed||0,mt=ye?ye.contextWindow:p.contextLimit||(p.provider==="grok"?5e5:2e5),Ft=ye?ye.usedPercent:Math.round(et/mt*100),ze=Math.max(0,Math.min(100,Ft)),kt=Math.round(ze*10)/10,xe=Math.round((100-ze)*10)/10,tt=ze>=80?"#ff4a4a":ze>=60?"#ff9e4a":ze>=40?"#ffd700":"#4aff9e",at=(et/1e3).toFixed(1),pt=(mt/1e3).toFixed(1),be=p.cwd,ft=be?Wn(be):null,Se=((yt=p.subordinateIds)==null?void 0:yt.length)||0,nt=Se>0;return e.jsxs("div",{ref:Ze,className:`flat-terminal-wrapper ${w||De||O?"flat-terminal-wrapper--with-side-panel":""} ${Lt?"pane-fading-out":""}`,style:{"--guake-side-panel-width":`min(${zt}px, 70%)`},children:[e.jsxs("div",{className:"flat-terminal-wrapper__header",children:[e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__header-main ${Oe?"flat-terminal-wrapper__header-main--active":""}`,onClick:bt,onContextMenu:a=>{a.preventDefault(),a.stopPropagation(),we({x:a.clientX,y:a.clientY})},title:Oe?"Hide agent info":"Show agent info","aria-pressed":Oe,children:[e.jsx("span",{className:`flat-terminal-wrapper__header-avatar${p.status==="working"?" is-working":""}`,children:e.jsx(ba,{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:va(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:wa(p.provider,"/"),alt:p.provider,className:"flat-terminal-wrapper__header-provider-icon",title:_a(p.provider)}),(()=>{const{model:a,effort:o}=Hn(p);return e.jsxs("span",{className:"flat-terminal-wrapper__header-model-chip",title:o?`Model: ${a} · Effort: ${o}`:`Model: ${a}`,children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-name",children:a}),o&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-sep","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"flat-terminal-wrapper__header-model-effort",children:o})]})]})})()]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__header-meta",children:[e.jsxs("div",{className:"flat-terminal-wrapper__view-mode",role:"group","aria-label":"Message view mode",children:[zn.map(a=>e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${!de&&m===a?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>{Qe(!1),b(a)},title:Fn[a],"aria-pressed":!de&&m===a,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:Bn[a]}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:On[a]})]},a)),Je&&e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${de?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>Qe(a=>!a),title:"Classic TUI — attach to the live interactive claude session in a terminal","aria-pressed":de,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:e.jsx(d,{name:"terminal",size:13})}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:"Classic TUI"})]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__actions",role:"group","aria-label":"Terminal actions",children:[e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:oe,disabled:!T,title:"Back to previous agent","aria-label":"Back to previous agent",children:e.jsx(d,{name:"arrow-left",size:14})}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:ce,disabled:!Ee,title:"Forward to next agent","aria-label":"Forward to next agent",children:e.jsx(d,{name:"arrow-right",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${Ce?"flat-terminal-wrapper__action-btn--active":""}`,onClick:rt,title:Ce?"Close search":"Search messages","aria-pressed":Ce,children:e.jsx(d,{name:Ce?"cross":"search",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn flat-terminal-wrapper__action-btn--danger ${$e?"flat-terminal-wrapper__action-btn--confirm":""}`,onClick:()=>Pe.handleClick(Xt,()=>{var a;g.clearContext(r),(a=Ie.current)==null||a.historyLoader.clearHistory()}),title:$e?"Click again to confirm clear context":"Clear context",children:e.jsx(d,{name:$e?"question":"clear",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${w?"flat-terminal-wrapper__action-btn--active":""}`,onClick:jt,title:w?"Hide git panel":"Show git changes","aria-pressed":w,children:e.jsx(d,{name:"git-branch",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${De?"flat-terminal-wrapper__action-btn--active":""}`,onClick:Ct,title:De?"Hide buildings panel":"Show area buildings","aria-pressed":De,children:e.jsx(d,{name:"buildings",size:14})}),e.jsxs("div",{className:"flat-terminal-wrapper__more",ref:ge,children:[e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${qe?"flat-terminal-wrapper__action-btn--active":""}`,onClick:()=>B(a=>!a),title:"More actions","aria-expanded":qe,children:"⋮"}),qe&&e.jsxs("div",{className:"flat-terminal-wrapper__more-menu",role:"menu",children:[e.jsxs("button",{type:"button",role:"menuitem",className:`flat-terminal-wrapper__more-item ${O?"flat-terminal-wrapper__more-item--active":""}`,onClick:()=>{ct(),B(!1)},title:O?"Hide Debug Panel":"Show Debug Panel",children:[e.jsx(d,{name:"bug",size:14}),e.jsx("span",{children:O?"Hide Debug Panel":"Show Debug Panel"})]}),e.jsx("div",{className:"flat-terminal-wrapper__more-divider"}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item",onClick:()=>{g.collapseContext(r),B(!1)},disabled:p.status!=="idle",title:p.status!=="idle"?"Agent must be idle to collapse context":"Collapse context",children:[e.jsx(d,{name:"package",size:14}),e.jsx("span",{children:"Collapse context"})]}),nt&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{R(r,Se),B(!1)},children:[e.jsx(d,{name:"crown",size:14}),e.jsxs("span",{children:["Clear ",Se," subordinate",Se===1?"":"s"]})]}),e.jsx("div",{className:"flat-terminal-wrapper__more-divider"}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{g.killAgent(r),B(!1)},children:[e.jsx(d,{name:"cross",size:14}),e.jsx("span",{children:"Remove agent"})]})]})]})]}),e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__inspector-toggle ${N?"flat-terminal-wrapper__inspector-toggle--active":""}`,onClick:I,title:N?"Hide inspector panel":"Show inspector panel","aria-label":N?"Hide inspector panel":"Show inspector panel","aria-pressed":N,children:[e.jsx("span",{className:"flat-terminal-wrapper__inspector-icon","aria-hidden":"true",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"}),e.jsx("line",{x1:"10",y1:"2.5",x2:"10",y2:"13.5"})]})}),e.jsx("span",{className:"flat-terminal-wrapper__inspector-label",children:"Inspector"})]}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__close",onClick:()=>g.deselectAll(),title:"Close chat","aria-label":"Close chat",children:e.jsx(d,{name:"cross",size:14})})]})]}),Be&&e.jsxs("div",{className:"flat-chat-actions-sheet-root",role:"presentation",children:[e.jsx("div",{className:"flat-chat-actions-sheet__backdrop",onClick:$}),e.jsxs("div",{className:"flat-chat-actions-sheet",role:"menu","aria-label":"Chat actions",children:[e.jsx("div",{className:"flat-chat-actions-sheet__grabber","aria-hidden":"true"}),e.jsxs("div",{className:"flat-chat-actions-sheet__title-row",children:[e.jsx("span",{className:"flat-chat-actions-sheet__title",children:p.name}),e.jsx("button",{type:"button",className:"flat-chat-actions-sheet__done",onClick:$,children:"Done"})]}),e.jsxs("div",{className:"flat-chat-actions-sheet__grid",children:[e.jsxs("button",{type:"button",role:"menuitem",className:`flat-chat-actions-sheet__item ${Ce?"is-active":""}`,onClick:()=>{rt(),$()},children:[e.jsx(d,{name:Ce?"cross":"search",size:20}),e.jsx("span",{children:Ce?"Close search":"Search"})]}),e.jsxs("button",{type:"button",role:"menuitem",className:`flat-chat-actions-sheet__item ${w?"is-active":""}`,onClick:()=>{jt(),$()},children:[e.jsx(d,{name:"git-branch",size:20}),e.jsx("span",{children:"Git changes"})]}),e.jsxs("button",{type:"button",role:"menuitem",className:`flat-chat-actions-sheet__item ${De?"is-active":""}`,onClick:()=>{Ct(),$()},children:[e.jsx(d,{name:"buildings",size:20}),e.jsx("span",{children:"Buildings"})]}),e.jsxs("button",{type:"button",role:"menuitem",className:`flat-chat-actions-sheet__item ${O?"is-active":""}`,onClick:()=>{ct(),$()},children:[e.jsx(d,{name:"bug",size:20}),e.jsx("span",{children:"Debug"})]})]}),e.jsxs("div",{className:"flat-chat-actions-sheet__list",children:[e.jsxs("button",{type:"button",role:"menuitem",className:`flat-chat-actions-sheet__row flat-chat-actions-sheet__row--danger ${$e?"is-armed":""}`,onClick:()=>Pe.handleClick(Xt,()=>{var a;g.clearContext(r),(a=Ie.current)==null||a.historyLoader.clearHistory(),$()}),children:[e.jsx(d,{name:$e?"question":"clear",size:18}),e.jsx("span",{children:$e?"Tap again to confirm clear":"Clear context"})]}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-chat-actions-sheet__row",disabled:p.status!=="idle",onClick:()=>{g.collapseContext(r),$()},children:[e.jsx(d,{name:"package",size:18}),e.jsx("span",{children:"Collapse context"})]}),nt&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-chat-actions-sheet__row flat-chat-actions-sheet__row--danger",onClick:()=>{R(r,Se),$()},children:[e.jsx(d,{name:"crown",size:18}),e.jsxs("span",{children:["Clear ",Se," subordinate",Se===1?"":"s"]})]}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-chat-actions-sheet__row flat-chat-actions-sheet__row--danger",onClick:()=>{g.killAgent(r),$()},children:[e.jsx(d,{name:"cross",size:18}),e.jsx("span",{children:"Remove agent"})]})]})]})]}),e.jsx(fn,{agent:p,onClick:A}),de&&Je?e.jsx(Tn,{agentId:r}):Te&&_t?e.jsx(hn,{ref:Ie,agentId:Te,agent:_t,viewMode:m,isOpen:!0,onImageClick:y,onFileClick:K,onBashClick:v,onViewMarkdown:H,keyboard:re,hasModalOpen:!1},Te):null,j&&J&&(()=>{var X,Q;const a=j.type,o={terminal:"terminal","pm2-logs":"scroll",database:"hard-drives",tests:"flask",http:"globe"},i=a==="terminal"&&!((X=J.terminalStatus)!=null&&X.url),u=!i;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:Dt,role:"separator","aria-orientation":"horizontal","aria-label":"Resize embedded panel"}),e.jsxs("div",{className:"flat-bottom-panel",role:"region","aria-label":`${J.name} panel`,style:{height:Rt},children:[e.jsxs("div",{className:"flat-bottom-panel__header",children:[e.jsxs("span",{className:"flat-bottom-panel__title",children:[e.jsx(d,{name:o[a],size:12}),e.jsx("span",{children:J.name}),i&&e.jsx("span",{className:"flat-bottom-panel__muted",children:"(starting...)"})]}),e.jsxs("span",{className:"flat-bottom-panel__header-actions",children:[a==="pm2-logs"&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:"guake-bottom-terminal-filter",value:He,onChange:L=>Re(L.target.value),placeholder:"Filter logs","aria-label":`Filter logs for ${J.name}`,spellCheck:!1}),e.jsx("select",{className:"guake-bottom-terminal-retention",value:Ue===null?"unlimited":String(Ue),onChange:L=>{const st=L.target.value==="unlimited"?null:Number(L.target.value);$t(st),xn(st)},"aria-label":`Max log retention for ${J.name}`,children:gn.map(L=>e.jsx("option",{value:L===null?"unlimited":String(L),children:L===null?"Unlimited":`${L.toLocaleString()} lines`},L===null?"unlimited":L))}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>g.clearStreamingLogs(j.buildingId),title:"Clear logs",children:e.jsx(d,{name:"trash",size:12})}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>g.sendBuildingCommand(j.buildingId,"restart"),title:"Restart",children:e.jsx(d,{name:"restart",size:12})})]}),u&&e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>{ke(),it(j.buildingId)},title:"Maximize — open as modal","aria-label":"Open as modal",children:e.jsx(d,{name:"fullscreen",size:12})}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:ke,title:"Close panel","aria-label":"Close panel",children:e.jsx(d,{name:"cross",size:12})})]})]}),e.jsx("div",{className:"flat-bottom-panel__body",children:a==="terminal"?(Q=J.terminalStatus)!=null&&Q.url?e.jsx(fa,{terminalUrl:J.terminalStatus.url,visible:!0}):e.jsx("div",{className:"flat-bottom-panel__placeholder",children:"Starting terminal..."}):a==="pm2-logs"?e.jsx(bn,{buildingId:j.buildingId,filterText:He,maxRetention:Ue}):a==="database"?e.jsx(_n,{building:J}):a==="tests"?e.jsx("div",{className:"tests-panel-host",children:e.jsx(wn,{building:J,autoFocusSearch:!1})}):e.jsx("div",{className:"http-requests-panel-host",children:e.jsx(vn,{building:J,autoFocusSearch:!1})})})]})]})})(),e.jsxs("div",{className:"flat-terminal-wrapper__statusbar",role:"contentinfo",children:[p.isDetached&&e.jsxs("span",{className:"flat-terminal-wrapper__detached",title:"Reattaching session...",children:[e.jsx(d,{name:"refresh",size:12}),e.jsx("span",{children:"Reattaching"})]}),be&&ft&&e.jsxs("span",{className:"flat-terminal-wrapper__cwd",title:`Open in file explorer: ${be}`,"aria-label":`Open ${be} in file explorer`,role:"button",tabIndex:0,onClick:()=>g.openFileExplorer(be),onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),g.openFileExplorer(be))},children:[e.jsx("span",{className:"flat-terminal-wrapper__cwd-icon",children:e.jsx(d,{name:"folder",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__cwd-text",children:ft})]}),lt&<.map(({areaId:a,areaName:o,dir:i})=>{const u=wt.get(i),X=Le.has(i),Q=i.split("/").filter(Boolean).pop()||i;return e.jsxs("span",{className:"flat-terminal-wrapper__area-dir",title:`${o}: ${i}${u?` (${u.branch}${u.ahead?` ↑${u.ahead}`:""}${u.behind?` ↓${u.behind}`:""})`:""}`,onClick:()=>g.openFileExplorerForAreaFolder(a,i),children:[e.jsx(d,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-terminal-wrapper__area-dir-name",children:Q}),u&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flat-terminal-wrapper__area-dir-branch",children:[e.jsx(d,{name:"git-branch",size:10})," ",u.branch]}),u.ahead>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-ahead",title:`${u.ahead} ahead`,children:[e.jsx(d,{name:"arrow-up",size:9}),u.ahead]}),u.behind>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-behind",title:`${u.behind} behind`,children:[e.jsx(d,{name:"arrow-down",size:9}),u.behind]}),e.jsx("span",{className:`flat-terminal-wrapper__area-fetch ${X?"flat-terminal-wrapper__area-fetch--fetching":""}`,title:"Git fetch",onClick:L=>{L.stopPropagation(),Fe(i)},children:e.jsx(d,{name:X?"hourglass":"download",size:12})})]})]},`${a}:${i}`)}),e.jsx(Rn,{agentId:r,disabled:((p==null?void 0:p.provider)??"claude")!=="claude"&&((p==null?void 0:p.provider)??"claude")!=="grok",contextSummary:ut?`Context: ${at}k / ${pt}k tokens (${kt}% used)`:void 0,children:e.jsxs("span",{className:"flat-terminal-wrapper__context",tabIndex:0,role:"button",onClick:()=>g.setContextModalAgentId(r),onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),g.setContextModalAgentId(r))},title:((p==null?void 0:p.provider)??"claude")!=="claude"&&((p==null?void 0:p.provider)??"claude")!=="grok"?ut?`Context usage: ${at}k / ${pt}k tokens (${kt}% used). Click to view stats.`:"Click to fetch context stats":void 0,children:[e.jsx("span",{className:"flat-terminal-wrapper__context-icon",children:e.jsx(d,{name:"dashboard",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__context-label",children:"Ctx:"}),e.jsx("span",{className:"flat-terminal-wrapper__context-bar",children:e.jsx("span",{className:"flat-terminal-wrapper__context-bar-fill",style:{width:`${ze}%`,backgroundColor:tt}})}),e.jsxs("span",{className:"flat-terminal-wrapper__context-tokens",style:{color:tt},children:[at,"k/",pt,"k"]}),e.jsxs("span",{className:"flat-terminal-wrapper__context-free",children:["(",xe,"% free)"]}),!ut&&e.jsx("span",{className:"flat-terminal-wrapper__context-warning",title:"No context stats yet",children:e.jsx(d,{name:"warn",size:12})})]})}),e.jsx("div",{className:"flat-terminal-wrapper__statusbar-spacer","aria-hidden":"true"}),pe.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area terminals",children:pe.map(a=>{const o=(j==null?void 0:j.buildingId)===a.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${o?"flat-terminal-wrapper__building-btn--active":""} ${a.hasUrl?"":"flat-terminal-wrapper__building-btn--offline"}`,title:`${o?"Hide":"Show"} terminal: ${a.name}${a.hasUrl?"":" (starting...)"}`,onClick:()=>{if(o){ke();return}if(a.hasUrl&>(a.id)==="modal"){it(a.id);return}a.hasUrl||g.sendBuildingCommand(a.id,"start"),Ge("terminal",a.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),ve(a.id,{x:i.clientX,y:i.clientY})},children:e.jsx(d,{name:"terminal",size:14})},a.id)})}),je.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area PM2 logs",children:je.map(a=>{const o=(j==null?void 0:j.buildingId)===a.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${o?"flat-terminal-wrapper__building-btn--active":""}`,title:`${o?"Hide":"Show"} logs: ${a.name}`,onClick:()=>{o?ke():gt(a.id)==="modal"?it(a.id):Ge("pm2-logs",a.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),ve(a.id,{x:i.clientX,y:i.clientY})},children:e.jsx(d,{name:"scroll",size:14})},a.id)})}),Z.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area databases",children:Z.map(a=>{const o=(j==null?void 0:j.buildingId)===a.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${o?"flat-terminal-wrapper__building-btn--active":""}`,title:`${o?"Hide":"Show"} database: ${a.name}`,onClick:()=>{o?ke():gt(a.id)==="modal"?it(a.id):Ge("database",a.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),ve(a.id,{x:i.clientX,y:i.clientY})},children:e.jsx(d,{name:"hard-drives",size:14})},a.id)})}),se.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area tests",children:se.map(a=>{const o=(j==null?void 0:j.buildingId)===a.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${o?"flat-terminal-wrapper__building-btn--active":""} ${a.working?"flat-terminal-wrapper__building-btn--tests-working":""}`,title:a.working?`Running tests: ${a.name}`:`${o?"Hide":"Show"} tests: ${a.name}`,onClick:()=>{o?ke():gt(a.id)==="modal"?it(a.id):Ge("tests",a.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),ve(a.id,{x:i.clientX,y:i.clientY})},children:e.jsx(d,{name:"flask",size:14})},a.id)})}),ie.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area HTTP requests",children:ie.map(a=>{const o=(j==null?void 0:j.buildingId)===a.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${o?"flat-terminal-wrapper__building-btn--active":""}`,title:`${o?"Hide":"Show"} HTTP requests: ${a.name}`,onClick:()=>{o?ke():gt(a.id)==="modal"?it(a.id):Ge("http",a.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),ve(a.id,{x:i.clientX,y:i.clientY})},children:e.jsx(d,{name:"globe",size:14})},a.id)})}),e.jsx("div",{className:"flat-terminal-wrapper__theme",children:e.jsx(jn,{})})]}),w&&e.jsx(Cn,{agentId:r,agents:Xe,onClose:Bt,branchInfoMap:wt,fetchRemote:Fe,fetchingDirs:Le,onResizeStart:a=>ot(a,"right")}),De&&e.jsx(kn,{agentId:r,onClose:dt}),O&&e.jsx(Nn,{agentId:r,onClose:Ot})]})}),Vn={groups:[],gridCols:1,gridRows:1,positions:new Map};function Zn({onAgentClick:c,onBuildingClick:r,onBuildingDoubleClick:m,onBuildingPopup:b,onAreaContextMenu:N,onOpenSpawnModal:I,onOpenBossSpawnModal:A,onOpenAreaModal:y}){const{t:K}=Kt(["common"]),v=$a(),H=Ra(),[R,re]=s.useState(null),[T,Ee]=s.useState(null),[oe,ce]=s.useState(null);ha("flatview-image-modal",R!==null,()=>re(null));const[Oe,bt]=s.useState(null),[we,ve]=s.useState(null),[p,D]=s.useState(null),[Me,Ie]=s.useState(null),[Ze,Te]=s.useState(!1),Lt=s.useCallback(()=>{Te(t=>!t)},[]),_t=s.useCallback(()=>{Te(!1)},[]),[Je,de]=s.useState(()=>{const t=ta(M.VIEW_MODE);return t==="simple"||t==="chat"||t==="advanced"?t:"simple"}),Qe=s.useCallback(t=>{de(t),aa(M.VIEW_MODE,t)},[]);s.useEffect(()=>{const t=n=>{if(n.key!==M.VIEW_MODE)return;const l=n.newValue;(l==="simple"||l==="chat"||l==="advanced")&&de(l)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const[Be,ue]=s.useState(()=>Yt(M.FLAT_INSPECTOR_OPEN,!1)),[$,me]=s.useState(!1),lt=s.useCallback(()=>me(t=>!t),[]),wt=s.useCallback(()=>me(!1),[]);s.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-agents-drawer-state",{detail:{open:$}}))},[$]),s.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-inspector-state",{detail:{open:Be}}))},[Be]),s.useEffect(()=>{const t=()=>me(k=>!k),n=()=>{ue(k=>{const E=!k;return _e(M.FLAT_INSPECTOR_OPEN,E),E})},l=()=>{me(!1),ue(!1),_e(M.FLAT_INSPECTOR_OPEN,!1)},x=()=>me(!1),_=()=>{ue(!1),_e(M.FLAT_INSPECTOR_OPEN,!1)};return window.addEventListener("tide-toggle-flat-agents-drawer",t),window.addEventListener("tide-toggle-flat-inspector",n),window.addEventListener("tide-close-flat-side-views",l),window.addEventListener("tide-close-flat-agents-drawer-only",x),window.addEventListener("tide-close-flat-inspector-only",_),()=>{window.removeEventListener("tide-toggle-flat-agents-drawer",t),window.removeEventListener("tide-toggle-flat-inspector",n),window.removeEventListener("tide-close-flat-side-views",l),window.removeEventListener("tide-close-flat-agents-drawer-only",x),window.removeEventListener("tide-close-flat-inspector-only",_)}},[]);const Fe=s.useRef(null),Le=s.useRef(null),[pe,je]=s.useState(()=>{const t=na(M.FLAT_MIDDLE_WIDTH,0);return t>=Tt?t:null}),[Z,We]=s.useState(()=>{const t=na(M.FLAT_INSPECTOR_WIDTH,0);return t>=Vt?t:null}),se=s.useCallback(t=>{if(typeof window>"u")return t;const n=Z!==null?It+Z:0,l=window.innerWidth-ua-It-da-n;return Math.max(Tt,Math.min(Math.max(l,Tt),t))},[Z]),ie=s.useCallback(t=>{var _;if(typeof window>"u")return t;const n=(_=Fe.current)==null?void 0:_.querySelector(".flat-middle"),l=(n==null?void 0:n.getBoundingClientRect().width)??Tt,x=window.innerWidth-ua-l-It-da-It;return Math.max(Vt,Math.min(Math.max(x,Vt),t))},[]);s.useEffect(()=>{if(pe===null&&Z===null)return;const t=()=>{je(n=>{if(n===null)return n;const l=se(n);return l===n?n:l}),We(n=>{if(n===null)return n;const l=ie(n);return l===n?n:l})};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[pe,Z,se,ie]);const Pt=s.useCallback(t=>{var l;if(t.button!==0)return;const n=(l=Fe.current)==null?void 0:l.querySelector(".flat-middle");n&&(t.currentTarget.setPointerCapture(t.pointerId),Le.current={kind:"middle",startX:t.clientX,startWidth:n.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),Ce=s.useCallback(t=>{var l;if(t.button!==0)return;const n=(l=Fe.current)==null?void 0:l.querySelector(".flat-inspector");n&&(t.currentTarget.setPointerCapture(t.pointerId),Le.current={kind:"inspector",startX:t.clientX,startWidth:n.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),rt=s.useCallback(t=>{const n=Le.current;if(!n||t.pointerId!==n.pointerId)return;const l=t.clientX-n.startX;n.kind==="middle"?je(se(n.startWidth+l)):We(ie(n.startWidth-l))},[se,ie]),Pe=s.useCallback(t=>{const n=Le.current;if(!n||t.pointerId!==n.pointerId)return;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}if(Le.current=null,document.body.classList.remove("flat-splitter-dragging"),!(Math.abs(t.clientX-n.startX)>2))return;const x=t.clientX-n.startX;if(n.kind==="middle"){const _=se(n.startWidth+x);je(_),Mt(M.FLAT_MIDDLE_WIDTH,_)}else{const _=ie(n.startWidth-x);We(_),Mt(M.FLAT_INSPECTOR_WIDTH,_)}},[se,ie]),$e=s.useCallback(()=>{je(null),Mt(M.FLAT_MIDDLE_WIDTH,0)},[]),j=s.useCallback(()=>{We(null),Mt(M.FLAT_INSPECTOR_WIDTH,0)},[]),[te,J]=s.useState(()=>ta(M.FLAT_INSPECTOR_VIEW)==="tracking"?"tracking":"agent"),He=s.useCallback(t=>{J(t),aa(M.FLAT_INSPECTOR_VIEW,t)},[]),Re=s.useCallback(()=>{ue(t=>{const n=!t;return _e(M.FLAT_INSPECTOR_OPEN,n),n})},[]),Ue=s.useCallback(()=>{ue(!1),_e(M.FLAT_INSPECTOR_OPEN,!1)},[]),$t=s.useCallback(()=>{He("tracking"),ue(!0),_e(M.FLAT_INSPECTOR_OPEN,!0)},[He]),z=Da(),Ge=s.useCallback((t,n)=>{re({url:t,name:n})},[]),ke=s.useCallback((t,n)=>{Ee({command:t,output:n,isLive:!1})},[]),Rt=s.useCallback((t,n)=>{var _;const l=H.size>0?Array.from(H)[0]:null,x=l?(_=g.getState().agents.get(l))==null?void 0:_.cwd:void 0;g.setFileViewerPath(t,n,x)},[H]),Dt=s.useCallback(t=>{ce(t)},[]),zt=s.useCallback((t,n)=>{bt({agentId:t,count:n})},[]),ot=s.useCallback(t=>{m?m(t):r(t)},[r,m]),w=s.useMemo(()=>H.size>0?Array.from(H)[0]:null,[H]),vt=s.useCallback(t=>{w&&ve({agentId:w,position:t})},[w]),De=s.useCallback((t,n)=>{D({buildingId:t,position:n})},[]);s.useEffect(()=>{Te(!1)},[w]);const fe=s.useRef([]),O=s.useRef(-1),Ve=s.useRef(!1),ct=s.useRef(null),[Ot,jt]=s.useState(!1),[Ct,Bt]=s.useState(!1),dt=s.useRef(!1),Xe=s.useRef(null),he=s.useRef(!1),Ne=s.useMemo(()=>new Set(v.map(t=>t.id)),[v]),qe=s.useMemo(()=>{const t=new Map(v.map(l=>[l.id,l])),n=new Map;for(const l of v)if((l.isBoss||l.class==="boss")&&l.subordinateIds&&l.subordinateIds.length>0){const x=l.subordinateIds.map(_=>t.get(_)).filter(_=>_!==void 0);x.length>0&&n.set(l.id,x)}return n},[v]),B=s.useCallback(()=>{const t=fe.current,n=O.current;jt(n>0),Bt(n>=0&&n<t.length-1)},[]),ge=s.useCallback(t=>{const n=fe.current;if(n.length===0)return;let l=O.current+t;for(;l>=0&&l<n.length;){const x=n[l];if(Ne.has(x)){Ve.current=!0,O.current=l,B(),g.selectAgent(x);return}l+=t}},[Ne,B]),ye=s.useCallback(()=>ge(-1),[ge]),ut=s.useCallback(()=>ge(1),[ge]);En(s.useCallback(()=>{const t=fe.current,n=O.current;return t.length>0&&n>0?(ge(-1),"handled"):"exit"},[ge]));const et=s.useCallback((t,n)=>{if(typeof window>"u")return;const l=window.history.state,_={...typeof l=="object"&&l!==null?l:{},__flatAgentNav:{agentId:t}};n==="replace"?window.history.replaceState(_,"",window.location.href):window.history.pushState(_,"",window.location.href)},[]);s.useEffect(()=>{if(!w){dt.current=!1,Xe.current=null;return}if(!dt.current){et(w,"replace"),dt.current=!0,Xe.current=w;return}if(he.current){he.current=!1,Xe.current=w;return}Xe.current!==w&&(et(w,"push"),Xe.current=w)},[w,et]),s.useEffect(()=>{const t=n=>{var k,E;const l=(E=(k=n.state)==null?void 0:k.__flatAgentNav)==null?void 0:E.agentId;if(!l||typeof l!="string"||!Ne.has(l)||l===w)return;he.current=!0,Ve.current=!0;const x=fe.current,_=x.lastIndexOf(l);_>=0?O.current=_:(x.push(l),O.current=x.length-1),B(),g.selectAgent(l)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[Ne,w,B]),s.useEffect(()=>{if(!w){fe.current=[],O.current=-1,B();return}if(ct.current=w,Ve.current){Ve.current=!1,B();return}const t=fe.current,n=O.current;if(n>=0&&t[n]===w){B();return}const l=n<t.length-1?t.slice(0,n+1):t.slice();l.push(w),l.length>100&&l.shift(),fe.current=l,O.current=l.length-1,B()},[w,B]);const mt=s.useCallback(t=>{c(t),me(!1)},[c]),Ft=w??"",ze=s.useCallback(()=>{},[]),kt=s.useCallback(t=>{mt(t)},[mt]),xe=Be,[tt,at]=s.useState(xe),[pt,be]=s.useState(xe);s.useEffect(()=>{if(xe){at(!0);return}be(!1);const t=setTimeout(()=>at(!1),240);return()=>clearTimeout(t)},[xe]),s.useEffect(()=>{if(!tt||!xe)return;let t=0;const n=requestAnimationFrame(()=>{t=requestAnimationFrame(()=>be(!0))});return()=>{cancelAnimationFrame(n),cancelAnimationFrame(t)}},[tt,xe]);const ft=s.useRef(null);s.useEffect(()=>{if(w)return;const t=n=>{if(n.key!==" "&&n.key!=="Backspace")return;const l=n.target;if(l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.isContentEditable)return;const x=ct.current;!x||!Ne.has(x)||(n.preventDefault(),g.selectAgent(x))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[w,Ne]);const[Se,nt]=s.useState(new Set),Nt=s.useCallback(t=>{nt(n=>{const l=new Set(n);return l.has(t)?l.delete(t):l.add(t),l})},[]),yt=s.useCallback(t=>{nt(new Set(t))},[]),[a,o]=s.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches);s.useEffect(()=>{if(typeof window>"u")return;const t=window.matchMedia("(max-width: 768px)"),n=l=>o(l.matches);return t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[]);const[i,u]=s.useState(null),X=s.useCallback(t=>{u(n=>n===t?null:t)},[]),Q=ga(),L=xa(),[st]=za(),ae=s.useMemo(()=>{if(w)return Vn;const t=new Map,n=[];for(const h of v){const C=g.getAreaForAgent(h.id);if(!sa((C==null?void 0:C.id)??null))continue;if(!C||C.archived){n.push(h);continue}const P=t.get(C.id);P?P.push(h):t.set(C.id,[h])}const l=new Map,x=[];for(const h of L.values()){let C=!1;for(const P of Q.values())if(!P.archived&&ia(P.id)&&g.isPositionInArea(h.position,P)){const le=l.get(P.id);le?le.push(h):l.set(P.id,[h]),C=!0;break}!C&&sa(null)&&x.push(h)}const _=[];for(const[,h]of Q){if(h.archived||!ia(h.id))continue;const C=t.get(h.id),P=l.get(h.id)??[];(C&&C.length>0||P.length>0)&&_.push({area:h,agents:C??[],buildings:P})}(n.length>0||x.length>0)&&_.push({area:{id:"__unassigned__",name:"Unassigned",color:"#6272a4",center:{x:0,z:0},type:"circle",radius:0,directories:[],archived:!1,assignedAgentIds:[],zIndex:0},agents:n,buildings:x});const k=_.filter(h=>h.area.id!=="__unassigned__"),E=_.filter(h=>h.area.id==="__unassigned__");let G=1,F=1;const f=new Map;if(k.length>1){let h=1/0,C=-1/0,P=1/0,le=-1/0;for(const q of k)h=Math.min(h,q.area.center.x),C=Math.max(C,q.area.center.x),P=Math.min(P,q.area.center.z),le=Math.max(le,q.area.center.z);const Ae=C-h||1,At=le-P||1;if(k.length<=4){G=k.length,F=1;const q=[...k].sort((Y,Wt)=>Y.area.center.x-Wt.area.center.x);for(let Y=0;Y<q.length;Y++)f.set(q[Y].area.id,{row:1,col:Y+1})}else{const q=[...k].sort((S,W)=>S.area.center.x-W.area.center.x),Y=[];for(let S=1;S<q.length;S++)Y.push(q[S].area.center.x-q[S-1].area.center.x);const Wt=Y.reduce((S,W)=>S+W,0)/Y.length||1;let Zt=1;for(const S of Y)S>Wt*1.3&&Zt++;G=Math.max(2,Math.min(Zt,k.length));const Ht=[...k].sort((S,W)=>S.area.center.z-W.area.center.z),Et=[];for(let S=1;S<Ht.length;S++)Et.push(Ht[S].area.center.z-Ht[S-1].area.center.z);const ka=Et.reduce((S,W)=>S+W,0)/Et.length||1;let Jt=1;for(const S of Et)S>ka*1.3&&Jt++;F=Math.max(2,Math.min(Jt,k.length)),G=Math.max(G,Math.ceil(k.length/F)),F=Math.max(F,Math.ceil(k.length/G));const Na=Ae/G,ya=At/F,Ut=new Set;for(const S of k){let W=Math.min(G-1,Math.max(0,Math.floor((S.area.center.x-h)/Na))),Ke=Math.min(F-1,Math.max(0,Math.floor((S.area.center.z-P)/ya))),ht=`${Ke},${W}`,Qt=0;const Sa=F*G;for(;Ut.has(ht)&&Qt<Sa;)W++,W>=G&&(W=0,Ke=(Ke+1)%F),ht=`${Ke},${W}`,Qt++;Ut.has(ht)&&(Ke=F,W=0,ht=`${Ke},${W}`,F++),Ut.add(ht),f.set(S.area.id,{row:Ke+1,col:W+1})}}}const ee=h=>{h.sort((C,P)=>{var Ae,At,q,Y;const le=(((Ae=C.position)==null?void 0:Ae.z)??0)-(((At=P.position)==null?void 0:At.z)??0);return le!==0?le:(((q=C.position)==null?void 0:q.x)??0)-(((Y=P.position)==null?void 0:Y.x)??0)})};for(const h of k)ee(h.agents);for(const h of E)ee(h.agents);const V=[...k,...E].sort((h,C)=>h.area.name.localeCompare(C.area.name,void 0,{sensitivity:"base",numeric:!0})||h.area.id.localeCompare(C.area.id));return f.clear(),V.forEach((h,C)=>{f.set(h.area.id,{row:Math.floor(C/G)+1,col:C%G+1})}),F=Math.max(1,Math.ceil(V.length/G)),{groups:V,gridCols:G,gridRows:F,positions:f}},[v,Q,L,st,w]),Ye=s.useMemo(()=>{let t=0,n=0;for(const l of ae.groups)t+=l.agents.length,n+=l.agents.filter(x=>x.status==="working").length;return{areaCount:ae.groups.length,agentCount:t,workingCount:n}},[ae]),ne=s.useMemo(()=>{if(!we)return[];const t=v.find(n=>n.id===we.agentId);return t?[{id:"edit-agent",label:"Edit Agent",icon:e.jsx(d,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:open-agent-edit",{detail:{agentId:t.id}}))}},{id:"open-chat",label:"Open Chat",icon:e.jsx(d,{name:"chat",size:14}),onClick:()=>c(t.id)},{id:"clone-agent",label:"Clone Agent",icon:e.jsx(d,{name:"clipboard",size:14}),onClick:()=>g.cloneAgent(t.id)},{id:"fork-agent",label:"Fork Agent (with history)",icon:e.jsx(d,{name:"git-branch",size:14}),onClick:()=>g.forkAgent(t.id)},{id:"delete-agent",label:"Delete Agent",icon:e.jsx(d,{name:"trash",size:14}),danger:!0,onClick:()=>{Ie({agentId:t.id,name:t.name})}}]:[]},[we,v,c]),U=s.useMemo(()=>{var k;if(!p)return[];const t=L.get(p.buildingId);if(!t)return[];const n=[],l=t.type==="server"||t.type==="docker"||t.type==="terminal",x=t.status==="running",_=t.type==="boss";if(n.push({id:"open",label:t.type==="database"?"Open Database":t.type==="folder"?"Open Folder":t.type==="tests"?"Open Tests":t.type==="http"?"Open Requests":t.type==="boss"?"View Boss Logs":t.type==="terminal"?"Open Terminal":t.type==="server"&&((k=t.pm2)!=null&&k.enabled)?"View PM2 Logs":"Open",icon:e.jsx(d,{name:t.type==="database"?"database":t.type==="folder"?"folder":t.type==="tests"?"flask":t.type==="http"?"globe":t.type==="terminal"?"terminal":"eye",size:14}),onClick:()=>ot(t.id)}),l&&(x||n.push({id:"start",label:"Start",icon:e.jsx(d,{name:"play",size:14}),onClick:()=>g.sendBuildingCommand(t.id,"start")}),x&&(n.push({id:"restart",label:"Restart",icon:e.jsx(d,{name:"refresh",size:14}),onClick:()=>g.sendBuildingCommand(t.id,"restart")}),n.push({id:"stop",label:"Stop",icon:e.jsx(d,{name:"stop",size:14}),onClick:()=>g.sendBuildingCommand(t.id,"stop")}))),_&&t.subordinateBuildingIds&&t.subordinateBuildingIds.length>0&&(n.push({id:"start-all",label:"Start All Subordinates",icon:e.jsx(d,{name:"launch",size:14}),onClick:()=>{for(const E of t.subordinateBuildingIds)g.sendBuildingCommand(E,"start")}}),n.push({id:"stop-all",label:"Stop All Subordinates",icon:e.jsx(d,{name:"pause",size:14}),onClick:()=>{for(const E of t.subordinateBuildingIds)g.sendBuildingCommand(E,"stop")}}),n.push({id:"restart-all",label:"Restart All Subordinates",icon:e.jsx(d,{name:"restart",size:14}),onClick:()=>{for(const E of t.subordinateBuildingIds)g.sendBuildingCommand(E,"restart")}})),l&&n.push({id:"health-check",label:"Health Check",icon:e.jsx(d,{name:"health",size:14}),onClick:()=>g.sendBuildingCommand(t.id,"healthCheck")}),n.push({id:"divider-edit",label:"",divider:!0,onClick:()=>{}}),n.push({id:"edit",label:"Edit Building",icon:e.jsx(d,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:building-edit",{detail:{buildingId:t.id}}))}}),n.push({id:"clone",label:"Clone Building",icon:e.jsx(d,{name:"copy",size:14}),onClick:()=>{g.createBuilding({name:`${t.name} (Copy)`,type:t.type,style:t.style,color:t.color,scale:t.scale,position:{x:t.position.x+2,z:t.position.z+2},cwd:t.cwd,folderPath:t.folderPath,commands:t.commands,pm2:t.pm2,docker:t.docker,database:t.database,terminal:t.terminal,urls:t.urls,subordinateBuildingIds:t.subordinateBuildingIds})}}),t.urls&&t.urls.length>0)for(const E of t.urls)n.push({id:`url-${E.label}`,label:E.label,icon:e.jsx(d,{name:"link",size:14}),onClick:()=>window.open(E.url,"_blank","noopener,noreferrer")});return n.push({id:"divider-danger",label:"",divider:!0,onClick:()=>{}}),n.push({id:"delete",label:"Delete Building",icon:e.jsx(d,{name:"trash",size:14}),danger:!0,onClick:()=>g.deleteBuilding(t.id)}),n},[p,L,ot]),St=s.useCallback(t=>{nt(new Set([t])),requestAnimationFrame(()=>{const n=ft.current;if(!n)return;const l=n.querySelector(`[data-area-id="${t}"]`);if(!l)return;const x=n.getBoundingClientRect(),k=l.getBoundingClientRect().top-x.top+n.scrollTop-8;n.scrollTo({top:Math.max(0,k),behavior:"smooth"})})},[]);return e.jsxs("div",{ref:Fe,className:`flat-view ${xe?"flat-view--with-inspector":""} ${w?"flat-view--has-chat":""} ${$?"flat-view--mobile-sidebar-open":""}`,style:(()=>{if(pe===null&&Z===null)return;const t={};return pe!==null&&(t["--flat-middle-width"]=`${pe}px`),Z!==null&&(t["--flat-inspector-width"]=`${Z}px`),t})(),children:[$&&e.jsx("div",{className:"flat-mobile-sidebar-backdrop",onClick:wt,"aria-hidden":"true"}),e.jsxs("div",{className:"flat-middle",children:[e.jsx("div",{className:"flat-middle__header",children:e.jsxs("div",{className:"flat-middle__actions",children:[e.jsx("button",{className:"flat-cta-btn flat-cta-btn--agent",onClick:I,title:"Create new agent",children:"+ Agent"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--boss",onClick:A,title:"Create new boss agent",children:"+ Boss"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--area",onClick:y,title:"Create new area",children:"+ Area"})]})}),e.jsx("div",{className:"flat-middle__content",children:e.jsx(Oa,{activeAgentId:Ft,onClose:ze,onSelectAgent:kt,expandedAreas:Se,onToggleArea:Nt,onSetExpandedAreas:yt,agentListRef:ft})})]}),e.jsx("div",{className:"flat-splitter flat-splitter--middle",role:"separator","aria-orientation":"vertical","aria-label":"Resize agents panel",title:"Drag to resize · Double-click to reset",onPointerDown:Pt,onPointerMove:rt,onPointerUp:Pe,onPointerCancel:Pe,onDoubleClick:$e}),e.jsxs("div",{className:"flat-right",children:[e.jsxs("button",{type:"button",className:"flat-mobile-sidebar-toggle","aria-label":$?"Close agents sidebar":"Open agents sidebar","aria-expanded":$,onClick:lt,children:[e.jsx(d,{name:"list",size:18}),e.jsx("span",{className:"flat-mobile-sidebar-toggle__label",children:"Agents"})]}),w?e.jsx(Gn,{agentId:w,terminalViewMode:Je,onTerminalViewModeChange:Qe,inspectorOpen:Be,onToggleInspector:Re,onShowTaskBoard:$t,onImageClick:Ge,onFileClick:Rt,onBashClick:ke,onViewMarkdown:Dt,onRequestClearSubordinates:zt,keyboard:z,canNavigateBack:Ot,canNavigateForward:Ct,onNavigateBack:ye,onNavigateForward:ut,agentInfoOpen:Ze,onToggleAgentInfo:Lt,onHeaderContextMenu:vt,onBuildingContextMenu:De}):e.jsx("div",{className:"flat-chat flat-chat--empty",children:e.jsxs("div",{className:"flat-map",children:[e.jsxs("div",{className:"flat-map__header",children:[e.jsx("span",{className:"flat-map__title",children:"🗺️ Areas"}),e.jsx("span",{className:"flat-map__hint",children:"Click an area to focus it, or an agent to chat"}),e.jsxs("span",{className:"flat-map__stats",children:[e.jsxs("span",{children:[Ye.areaCount," areas"]}),e.jsxs("span",{children:[Ye.agentCount," agents"]}),Ye.workingCount>0&&e.jsxs("span",{className:"flat-map__stats-working",children:[e.jsx("span",{className:"flat-map__stats-dot","aria-hidden":"true"}),Ye.workingCount," working"]})]}),e.jsx(Dn,{className:"flat-map__view-mode"})]}),e.jsx("div",{className:"flat-map__grid",style:{gridTemplateColumns:a?"repeat(2, minmax(0, 1fr))":`repeat(${ae.gridCols}, 1fr)`},children:ae.groups.length===0?e.jsx("div",{className:"flat-map__empty",children:e.jsx("span",{children:"No areas or agents yet"})}):(a?[...ae.groups].sort((n,l)=>{const x=ae.positions.get(n.area.id),_=ae.positions.get(l.area.id);return!x&&!_?0:x?_?x.row-_.row||x.col-_.col:-1:1}):ae.groups).map(n=>{var F;const l=n.area.id,x=ae.positions.get(l),_=n.agents.filter(f=>f.status==="working").length,k=_>0,E=a&&i!==l,G=a&&!E;return e.jsxs("div",{className:`flat-map-area-card${k?" flat-map-area-card--working":""}${E?" flat-map-area-card--collapsed":""}${G?" flat-map-area-card--expanded":""}`,style:{"--area-color":n.area.color,gridRow:a||x==null?void 0:x.row,gridColumn:a||x==null?void 0:x.col},onContextMenu:f=>{N&&(f.preventDefault(),f.stopPropagation(),N(l,{x:f.clientX,y:f.clientY}))},children:[e.jsxs("button",{type:"button",className:"flat-map-area-card__header",onClick:()=>a?X(l):St(l),title:a?E?`Expand ${n.area.name}`:`Collapse ${n.area.name}`:`Focus ${n.area.name} in left panel`,"aria-expanded":a?!E:void 0,children:[e.jsx("span",{className:"flat-map-area-card__color",style:{background:n.area.color}}),((F=n.area.logo)==null?void 0:F.filename)&&e.jsx("img",{className:"flat-map-area-card__logo",src:An(n.area.logo.filename),alt:"","aria-hidden":"true",onError:f=>{f.currentTarget.style.display="none"}}),e.jsx("span",{className:"flat-map-area-card__name",children:n.area.name}),e.jsxs("span",{className:"flat-map-area-card__count",title:`${n.agents.length} agent${n.agents.length===1?"":"s"}`,"aria-label":`${n.agents.length} agent${n.agents.length===1?"":"s"}`,children:[e.jsx(d,{name:"users",size:10}),n.agents.length]}),k&&e.jsxs("span",{className:"flat-map-area-card__working",title:`${_} working agent${_===1?"":"s"}`,"aria-label":`${_} working agent${_===1?"":"s"}`,children:[e.jsxs("span",{className:"flat-map-area-card__working-bars","aria-hidden":"true",children:[e.jsx("i",{}),e.jsx("i",{}),e.jsx("i",{})]}),e.jsx("span",{className:"flat-map-area-card__working-count",children:_})]}),a&&e.jsx(d,{name:E?"caret-down":"caret-up",size:11,className:"flat-map-area-card__caret"})]}),e.jsx("div",{className:"flat-map-area-card__agents",children:n.agents.map(f=>{const ee=f.isBoss||f.class==="boss",V=ee?qe.get(f.id):void 0,h=Ba(f),C=h.usedPercent>=80?"#ff4a4a":h.usedPercent>=60?"#ff9e4a":h.usedPercent>=40?"#ffd700":"#4aff9e",P=`Context: ${(h.totalTokens/1e3).toFixed(1)}k / ${(h.contextWindow/1e3).toFixed(1)}k (${h.usedPercent}% used, ${h.freePercent}% free)`,le=f.latestTodos&&f.latestTodos.length>0||V&&V.length>0;return e.jsx(Fa,{todos:f.latestTodos,subordinates:V,position:"top",children:e.jsxs("button",{type:"button",className:`flat-map-agent-chip ${f.status}`,onClick:()=>c(f.id),onContextMenu:Ae=>{Ae.preventDefault(),Ae.stopPropagation(),ve({agentId:f.id,position:{x:Ae.clientX,y:Ae.clientY}})},title:le?void 0:`${ee?"Boss · ":""}Open chat with ${f.name}
|
|
2
|
-
${P}`,children:[e.jsx(ba,{agent:f,size:16}),ee&&e.jsx("span",{className:"flat-map-agent-chip__crown","aria-hidden":"true",children:e.jsx(d,{name:"crown",size:11,color:"#ffd700",weight:"fill"})}),e.jsx("span",{className:"flat-map-agent-chip__name",children:f.name}),e.jsx("img",{src:wa(f.provider,"/"),alt:f.provider,className:"flat-map-agent-chip__provider-icon",title:_a(f.provider)}),e.jsx("span",{className:"flat-map-agent-chip__dot",style:{backgroundColor:va(f.status)}}),f.latestTodos&&f.latestTodos.length>0&&e.jsx(Wa,{todos:f.latestTodos,maxDots:6}),ee&&V&&V.length>0&&e.jsx(Ha,{subordinates:V,maxDots:6}),e.jsx("span",{className:"flat-map-agent-chip__context-bar","aria-hidden":"true",children:e.jsx("span",{className:"flat-map-agent-chip__context-bar-fill",style:{width:`${h.usedPercent}%`,backgroundColor:C}})})]})},f.id)})}),n.area.directories.length>0&&e.jsx("div",{className:"flat-map-area-card__folders",role:"group","aria-label":`${n.area.name} folders`,children:n.area.directories.map(f=>{const ee=f.split("/").filter(Boolean).pop()||f;return e.jsxs("button",{type:"button",className:"flat-map-folder-chip",onClick:V=>{V.stopPropagation(),g.openFileExplorerForAreaFolder(l,f)},title:`Open in file explorer: ${f}`,children:[e.jsx(d,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-map-folder-chip__name",children:ee})]},f)})}),n.buildings.length>0&&e.jsx("div",{className:"flat-map-area-card__buildings",children:n.buildings.map(f=>{var V;const ee=(V=Ua[f.type])==null?void 0:V.color;return e.jsxs("button",{type:"button",className:`flat-map-building-chip flat-map-building-chip--${f.status}`,style:ee?{"--building-type-color":ee}:void 0,onClick:h=>{if(b){const C=h.currentTarget.getBoundingClientRect();b(f.id,{x:C.right,y:C.top+C.height/2})}else ot(f.id)},onContextMenu:h=>{h.preventDefault(),h.stopPropagation(),D({buildingId:f.id,position:{x:h.clientX,y:h.clientY}})},title:`${f.name} · ${f.type} · ${f.status}`,children:[e.jsx(d,{name:Ga(f.type),size:12,color:ee}),e.jsx("span",{className:"flat-map-building-chip__name",children:f.name}),e.jsx("span",{className:"flat-map-building-chip__dot",style:{backgroundColor:Va(f.status)}})]},f.id)})})]},l)})})]})})]}),xe&&e.jsx("div",{className:"flat-splitter flat-splitter--inspector",role:"separator","aria-orientation":"vertical","aria-label":"Resize inspector panel",title:"Drag to resize · Double-click to reset",onPointerDown:Ce,onPointerMove:rt,onPointerUp:Pe,onPointerCancel:Pe,onDoubleClick:j}),tt&&e.jsxs("aside",{className:`flat-inspector ${pt?"flat-inspector--open":"flat-inspector--closing"}`,"aria-label":"Inspector panel",children:[e.jsxs("div",{className:"flat-inspector__header",children:[e.jsxs("div",{className:"flat-inspector__tabs",role:"tablist","aria-label":"Inspector view",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":te==="agent",className:`flat-inspector__tab ${te==="agent"?"flat-inspector__tab--active":""}`,onClick:()=>He("agent"),children:"Agent"}),e.jsx("button",{type:"button",role:"tab","aria-selected":te==="tracking",className:`flat-inspector__tab ${te==="tracking"?"flat-inspector__tab--active":""}`,onClick:()=>He("tracking"),children:"Tracking"})]}),e.jsx("button",{type:"button",className:"flat-inspector__close",onClick:Ue,title:"Close inspector","aria-label":"Close inspector",children:"✕"})]}),e.jsx("div",{className:"flat-inspector__body",children:te==="tracking"?e.jsx(Xa,{activeAgentId:w??"",onSelectAgent:t=>{c(t),window.innerWidth<=768&&Ue()}}):(()=>{if(!w)return e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Select an agent to inspect"})});const t=v.find(n=>n.id===w);return t?e.jsx(qa,{agent:t,onFocusAgent:n=>{c(n),window.innerWidth<=768&&Ue()},onKillAgent:n=>g.killAgent(n)}):e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Agent not found"})})})()})]}),R&&e.jsx(Ya,{url:R.url,name:R.name,onClose:()=>re(null)}),T&&e.jsx(Ka,{state:T,onClose:()=>Ee(null)}),e.jsx(Za,{agent:w?v.find(t=>t.id===w)??null:null,content:oe,onClose:()=>ce(null)}),Oe&&e.jsx(Ja,{action:"clear-subordinates",selectedAgentId:Oe.agentId,subordinateCount:Oe.count,onClose:()=>bt(null),onClearHistory:()=>{}}),e.jsx(Qa,{agent:w?v.find(t=>t.id===w)??null:null,isOpen:Ze&&!!w,onClose:_t}),e.jsx(la,{isOpen:we!==null,position:(we==null?void 0:we.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:ne,onClose:()=>ve(null)}),e.jsx(la,{isOpen:p!==null,position:(p==null?void 0:p.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:U,onClose:()=>D(null)}),e.jsx(en,{isOpen:Me!==null,title:K("common:confirm.removeAgentTitle"),message:K("common:confirm.removeAgentMessage",{name:(Me==null?void 0:Me.name)??""}),confirmLabel:K("common:buttons.remove"),cancelLabel:K("common:buttons.cancel"),variant:"danger",onConfirm:()=>{Me&&g.removeAgentFromServer(Me.agentId)},onClose:()=>Ie(null)})]})}export{Zn as FlatView};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-DDxnPoTK.js","assets/main-DIf9R6Jx.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-Dnp-3iMX.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{dc as e,cf as o}from"./main-DIf9R6Jx.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-DDxnPoTK.js"),__vite__mapDeps([0,1,2,3,4])).then(r=>new r.HapticsWeb)});export{c as Haptics,i as ImpactStyle,t as NotificationType};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as At,k as yt,aC as Et,a5 as xt,m as Ct,cJ as Mt,cK as wt,aU as Ft,r as d,$ as St,S as pe,cL as vt,cM as fe,s as V,cN as Bt,j as f,I as ne,cO as Ve,cP as It,a9 as _t,cQ as Dt,cR as kt,cS as Ee,aq as Be,_ as Rt,v as nt,u as we,cT as Je}from"./main-DIf9R6Jx.js";import{cU as Ls,cV as $s,cW as js,cX as Ns,cY as Ps}from"./main-DIf9R6Jx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function re(t){return Array.isArray?Array.isArray(t):ct(t)==="[object Array]"}function bt(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Tt(t){return t==null?"":bt(t)}function Z(t){return typeof t=="string"}function rt(t){return typeof t=="number"}function Lt(t){return t===!0||t===!1||$t(t)&&ct(t)=="[object Boolean]"}function it(t){return typeof t=="object"}function $t(t){return it(t)&&t!==null}function Q(t){return t!=null}function Ie(t){return!t.trim().length}function ct(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const jt="Incorrect 'index' type",Nt=t=>`Invalid value for key ${t}`,Pt=t=>`Pattern length exceeds max of ${t}.`,Kt=t=>`Missing ${t} property in key`,Ot=t=>`Property 'weight' in key '${t}' must be a positive integer`,Xe=Object.prototype.hasOwnProperty;class zt{constructor(e){this._keys=[],this._keyMap={};let n=0;e.forEach(r=>{let i=ot(r);this._keys.push(i),this._keyMap[i.id]=i,n+=i.weight}),this._keys.forEach(r=>{r.weight/=n})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function ot(t){let e=null,n=null,r=null,i=1,c=null;if(Z(t)||re(t))r=t,e=qe(t),n=_e(t);else{if(!Xe.call(t,"name"))throw new Error(Kt("name"));const o=t.name;if(r=o,Xe.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(Ot(o));e=qe(o),n=_e(o),c=t.getFn}return{path:e,id:n,weight:i,src:r,getFn:c}}function qe(t){return re(t)?t:t.split(".")}function _e(t){return re(t)?t.join("."):t}function Qt(t,e){let n=[],r=!1;const i=(c,o,a)=>{if(Q(c))if(!o[a])n.push(c);else{let u=o[a];const l=c[u];if(!Q(l))return;if(a===o.length-1&&(Z(l)||rt(l)||Lt(l)))n.push(Tt(l));else if(re(l)){r=!0;for(let h=0,E=l.length;h<E;h+=1)i(l[h],o,a+1)}else o.length&&i(l,o,a+1)}};return i(t,Z(e)?e.split("."):e,0),r?n:n[0]}const Gt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Wt={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},Ut={location:0,threshold:.6,distance:100},Ht={useExtendedSearch:!1,getFn:Qt,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var y={...Wt,...Gt,...Ut,...Ht};const Yt=/[^ ]+/g;function Vt(t=1,e=3){const n=new Map,r=Math.pow(10,e);return{get(i){const c=i.match(Yt).length;if(n.has(c))return n.get(c);const o=1/Math.pow(c,.5*t),a=parseFloat(Math.round(o*r)/r);return n.set(c,a),a},clear(){n.clear()}}}class Le{constructor({getFn:e=y.getFn,fieldNormWeight:n=y.fieldNormWeight}={}){this.norm=Vt(n,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((n,r)=>{this._keysMap[n.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Z(this.docs[0])?this.docs.forEach((e,n)=>{this._addString(e,n)}):this.docs.forEach((e,n)=>{this._addObject(e,n)}),this.norm.clear())}add(e){const n=this.size();Z(e)?this._addString(e,n):this._addObject(e,n)}removeAt(e){this.records.splice(e,1);for(let n=e,r=this.size();n<r;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(e,n){return e[this._keysMap[n]]}size(){return this.records.length}_addString(e,n){if(!Q(e)||Ie(e))return;let r={v:e,i:n,n:this.norm.get(e)};this.records.push(r)}_addObject(e,n){let r={i:n,$:{}};this.keys.forEach((i,c)=>{let o=i.getFn?i.getFn(e):this.getFn(e,i.path);if(Q(o)){if(re(o)){let a=[];const u=[{nestedArrIndex:-1,value:o}];for(;u.length;){const{nestedArrIndex:l,value:h}=u.pop();if(Q(h))if(Z(h)&&!Ie(h)){let E={v:h,i:l,n:this.norm.get(h)};a.push(E)}else re(h)&&h.forEach((E,C)=>{u.push({nestedArrIndex:C,value:E})})}r.$[c]=a}else if(Z(o)&&!Ie(o)){let a={v:o,n:this.norm.get(o)};r.$[c]=a}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function at(t,e,{getFn:n=y.getFn,fieldNormWeight:r=y.fieldNormWeight}={}){const i=new Le({getFn:n,fieldNormWeight:r});return i.setKeys(t.map(ot)),i.setSources(e),i.create(),i}function Jt(t,{getFn:e=y.getFn,fieldNormWeight:n=y.fieldNormWeight}={}){const{keys:r,records:i}=t,c=new Le({getFn:e,fieldNormWeight:n});return c.setKeys(r),c.setIndexRecords(i),c}function xe(t,{errors:e=0,currentLocation:n=0,expectedLocation:r=0,distance:i=y.distance,ignoreLocation:c=y.ignoreLocation}={}){const o=e/t.length;if(c)return o;const a=Math.abs(r-n);return i?o+a/i:a?1:o}function Xt(t=[],e=y.minMatchCharLength){let n=[],r=-1,i=-1,c=0;for(let o=t.length;c<o;c+=1){let a=t[c];a&&r===-1?r=c:!a&&r!==-1&&(i=c-1,i-r+1>=e&&n.push([r,i]),r=-1)}return t[c-1]&&c-r>=e&&n.push([r,c-1]),n}const le=32;function qt(t,e,n,{location:r=y.location,distance:i=y.distance,threshold:c=y.threshold,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,includeMatches:u=y.includeMatches,ignoreLocation:l=y.ignoreLocation}={}){if(e.length>le)throw new Error(Pt(le));const h=e.length,E=t.length,C=Math.max(0,Math.min(r,E));let g=c,p=C;const S=a>1||u,F=S?Array(E):[];let T;for(;(T=t.indexOf(e,p))>-1;){let $=xe(e,{currentLocation:T,expectedLocation:C,distance:i,ignoreLocation:l});if(g=Math.min($,g),p=T+h,S){let N=0;for(;N<h;)F[T+N]=1,N+=1}}p=-1;let j=[],G=1,W=h+E;const oe=1<<h-1;for(let $=0;$<h;$+=1){let N=0,D=W;for(;N<D;)xe(e,{errors:$,currentLocation:C+D,expectedLocation:C,distance:i,ignoreLocation:l})<=g?N=D:W=D,D=Math.floor((W-N)/2+N);W=D;let ae=Math.max(1,C-D+1),U=o?E:Math.min(C+D,E)+h,v=Array(U+2);v[U+1]=(1<<$)-1;for(let R=U;R>=ae;R-=1){let X=R-1,O=n[t.charAt(X)];if(S&&(F[X]=+!!O),v[R]=(v[R+1]<<1|1)&O,$&&(v[R]|=(j[R+1]|j[R])<<1|1|j[R+1]),v[R]&oe&&(G=xe(e,{errors:$,currentLocation:X,expectedLocation:C,distance:i,ignoreLocation:l}),G<=g)){if(g=G,p=X,p<=C)break;ae=Math.max(1,2*C-p)}}if(xe(e,{errors:$+1,currentLocation:C,expectedLocation:C,distance:i,ignoreLocation:l})>g)break;j=v}const ie={isMatch:p>=0,score:Math.max(.001,G)};if(S){const $=Xt(F,a);$.length?u&&(ie.indices=$):ie.isMatch=!1}return ie}function Zt(t){let e={};for(let n=0,r=t.length;n<r;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<r-n-1}return e}const Ce=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class ut{constructor(e,{location:n=y.location,threshold:r=y.threshold,distance:i=y.distance,includeMatches:c=y.includeMatches,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,isCaseSensitive:u=y.isCaseSensitive,ignoreDiacritics:l=y.ignoreDiacritics,ignoreLocation:h=y.ignoreLocation}={}){if(this.options={location:n,threshold:r,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h},e=u?e:e.toLowerCase(),e=l?Ce(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const E=(g,p)=>{this.chunks.push({pattern:g,alphabet:Zt(g),startIndex:p})},C=this.pattern.length;if(C>le){let g=0;const p=C%le,S=C-p;for(;g<S;)E(this.pattern.substr(g,le),g),g+=le;if(p){const F=C-le;E(this.pattern.substr(F),F)}}else E(this.pattern,0)}searchIn(e){const{isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i}=this.options;if(e=n?e:e.toLowerCase(),e=r?Ce(e):e,this.pattern===e){let S={isMatch:!0,score:0};return i&&(S.indices=[[0,e.length-1]]),S}const{location:c,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:h}=this.options;let E=[],C=0,g=!1;this.chunks.forEach(({pattern:S,alphabet:F,startIndex:T})=>{const{isMatch:j,score:G,indices:W}=qt(e,S,F,{location:c+T,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:i,ignoreLocation:h});j&&(g=!0),C+=G,j&&W&&(E=[...E,...W])});let p={isMatch:g,score:g?C/this.chunks.length:1};return g&&i&&(p.indices=E),p}}class ce{constructor(e){this.pattern=e}static isMultiMatch(e){return Ze(e,this.multiRegex)}static isSingleMatch(e){return Ze(e,this.singleRegex)}search(){}}function Ze(t,e){const n=t.match(e);return n?n[1]:null}class es extends ce{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const n=e===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class ts extends ce{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const r=e.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class ss extends ce{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const n=e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class ns extends ce{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const n=!e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class rs extends ce{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const n=e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class is extends ce{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const n=!e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class lt extends ce{constructor(e,{location:n=y.location,threshold:r=y.threshold,distance:i=y.distance,includeMatches:c=y.includeMatches,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,isCaseSensitive:u=y.isCaseSensitive,ignoreDiacritics:l=y.ignoreDiacritics,ignoreLocation:h=y.ignoreLocation}={}){super(e),this._bitapSearch=new ut(e,{location:n,threshold:r,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ht extends ce{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let n=0,r;const i=[],c=this.pattern.length;for(;(r=e.indexOf(this.pattern,n))>-1;)n=r+c,i.push([r,n-1]);const o=!!i.length;return{isMatch:o,score:o?0:1,indices:i}}}const De=[es,ht,ss,ns,is,rs,ts,lt],et=De.length,cs=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,os="|";function as(t,e={}){return t.split(os).map(n=>{let r=n.trim().split(cs).filter(c=>c&&!!c.trim()),i=[];for(let c=0,o=r.length;c<o;c+=1){const a=r[c];let u=!1,l=-1;for(;!u&&++l<et;){const h=De[l];let E=h.isMultiMatch(a);E&&(i.push(new h(E,e)),u=!0)}if(!u)for(l=-1;++l<et;){const h=De[l];let E=h.isSingleMatch(a);if(E){i.push(new h(E,e));break}}}return i})}const us=new Set([lt.type,ht.type]);class ls{constructor(e,{isCaseSensitive:n=y.isCaseSensitive,ignoreDiacritics:r=y.ignoreDiacritics,includeMatches:i=y.includeMatches,minMatchCharLength:c=y.minMatchCharLength,ignoreLocation:o=y.ignoreLocation,findAllMatches:a=y.findAllMatches,location:u=y.location,threshold:l=y.threshold,distance:h=y.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i,minMatchCharLength:c,findAllMatches:a,ignoreLocation:o,location:u,threshold:l,distance:h},e=n?e:e.toLowerCase(),e=r?Ce(e):e,this.pattern=e,this.query=as(this.pattern,this.options)}static condition(e,n){return n.useExtendedSearch}searchIn(e){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:i,ignoreDiacritics:c}=this.options;e=i?e:e.toLowerCase(),e=c?Ce(e):e;let o=0,a=[],u=0;for(let l=0,h=n.length;l<h;l+=1){const E=n[l];a.length=0,o=0;for(let C=0,g=E.length;C<g;C+=1){const p=E[C],{isMatch:S,indices:F,score:T}=p.search(e);if(S){if(o+=1,u+=T,r){const j=p.constructor.type;us.has(j)?a=[...a,...F]:a.push(F)}}else{u=0,o=0,a.length=0;break}}if(o){let C={isMatch:!0,score:u/o};return r&&(C.indices=a),C}}return{isMatch:!1,score:1}}}const ke=[];function hs(...t){ke.push(...t)}function Re(t,e){for(let n=0,r=ke.length;n<r;n+=1){let i=ke[n];if(i.condition(t,e))return new i(t,e)}return new ut(t,e)}const Me={AND:"$and",OR:"$or"},be={PATH:"$path",PATTERN:"$val"},Te=t=>!!(t[Me.AND]||t[Me.OR]),ds=t=>!!t[be.PATH],fs=t=>!re(t)&&it(t)&&!Te(t),tt=t=>({[Me.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function dt(t,e,{auto:n=!0}={}){const r=i=>{let c=Object.keys(i);const o=ds(i);if(!o&&c.length>1&&!Te(i))return r(tt(i));if(fs(i)){const u=o?i[be.PATH]:c[0],l=o?i[be.PATTERN]:i[u];if(!Z(l))throw new Error(Nt(u));const h={keyId:_e(u),pattern:l};return n&&(h.searcher=Re(l,e)),h}let a={children:[],operator:c[0]};return c.forEach(u=>{const l=i[u];re(l)&&l.forEach(h=>{a.children.push(r(h))})}),a};return Te(t)||(t=tt(t)),r(t)}function gs(t,{ignoreFieldNorm:e=y.ignoreFieldNorm}){t.forEach(n=>{let r=1;n.matches.forEach(({key:i,norm:c,score:o})=>{const a=i?i.weight:null;r*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(e?1:c))}),n.score=r})}function ps(t,e){const n=t.matches;e.matches=[],Q(n)&&n.forEach(r=>{if(!Q(r.indices)||!r.indices.length)return;const{indices:i,value:c}=r;let o={indices:i,value:c};r.key&&(o.key=r.key.src),r.idx>-1&&(o.refIndex=r.idx),e.matches.push(o)})}function ms(t,e){e.score=t.score}function As(t,e,{includeMatches:n=y.includeMatches,includeScore:r=y.includeScore}={}){const i=[];return n&&i.push(ps),r&&i.push(ms),t.map(c=>{const{idx:o}=c,a={item:e[o],refIndex:o};return i.length&&i.forEach(u=>{u(c,a)}),a})}class q{constructor(e,n={},r){this.options={...y,...n},this.options.useExtendedSearch,this._keyStore=new zt(this.options.keys),this.setCollection(e,r)}setCollection(e,n){if(this._docs=e,n&&!(n instanceof Le))throw new Error(jt);this._myIndex=n||at(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){Q(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const n=[];for(let r=0,i=this._docs.length;r<i;r+=1){const c=this._docs[r];e(c,r)&&(this.removeAt(r),r-=1,i-=1,n.push(c))}return n}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:n=-1}={}){const{includeMatches:r,includeScore:i,shouldSort:c,sortFn:o,ignoreFieldNorm:a}=this.options;let u=Z(e)?Z(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return gs(u,{ignoreFieldNorm:a}),c&&u.sort(o),rt(n)&&n>-1&&(u=u.slice(0,n)),As(u,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e){const n=Re(e,this.options),{records:r}=this._myIndex,i=[];return r.forEach(({v:c,i:o,n:a})=>{if(!Q(c))return;const{isMatch:u,score:l,indices:h}=n.searchIn(c);u&&i.push({item:c,idx:o,matches:[{score:l,value:c,norm:a,indices:h}]})}),i}_searchLogical(e){const n=dt(e,this.options),r=(a,u,l)=>{if(!a.children){const{keyId:E,searcher:C}=a,g=this._findMatches({key:this._keyStore.get(E),value:this._myIndex.getValueForItemAtKeyId(u,E),searcher:C});return g&&g.length?[{idx:l,item:u,matches:g}]:[]}const h=[];for(let E=0,C=a.children.length;E<C;E+=1){const g=a.children[E],p=r(g,u,l);if(p.length)h.push(...p);else if(a.operator===Me.AND)return[]}return h},i=this._myIndex.records,c={},o=[];return i.forEach(({$:a,i:u})=>{if(Q(a)){let l=r(n,a,u);l.length&&(c[u]||(c[u]={idx:u,item:a,matches:[]},o.push(c[u])),l.forEach(({matches:h})=>{c[u].matches.push(...h)}))}}),o}_searchObjectList(e){const n=Re(e,this.options),{keys:r,records:i}=this._myIndex,c=[];return i.forEach(({$:o,i:a})=>{if(!Q(o))return;let u=[];r.forEach((l,h)=>{u.push(...this._findMatches({key:l,value:o[h],searcher:n}))}),u.length&&c.push({idx:a,item:o,matches:u})}),c}_findMatches({key:e,value:n,searcher:r}){if(!Q(n))return[];let i=[];if(re(n))n.forEach(({v:c,i:o,n:a})=>{if(!Q(c))return;const{isMatch:u,score:l,indices:h}=r.searchIn(c);u&&i.push({score:l,key:e,value:c,idx:o,norm:a,indices:h})});else{const{v:c,n:o}=n,{isMatch:a,score:u,indices:l}=r.searchIn(c);a&&i.push({score:u,key:e,value:c,norm:o,indices:l})}return i}}q.version="7.1.0";q.createIndex=at;q.parseIndex=Jt;q.config=y;q.parseQuery=dt;hs(ls);async function ys(t){const e=new URLSearchParams({q:t}),n=await At(yt(`/api/folders/search?${e.toString()}`));if(!n.ok){const i=await n.json().catch(()=>({}));throw new Error(i.error||`Failed to search folders: ${n.statusText}`)}const r=await n.json();return Array.isArray(r.folders)?r.folders:[]}const Es=["command","agent","building","area","folder","modified-file"],xs=2;function Cs(){const t=nt(pe.SPOTLIGHT_TAB,"all");return fe.includes(t)?t:"all"}function st(){return Rt(pe.SPOTLIGHT_QUERY,"")}function Ms(){const t=nt(pe.AOP_CONFIG,{});return t.sortMode==="name"||t.sortMode==="status"||t.sortMode==="recent"?t.sortMode:"recent"}function ws({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=Et(),E=xt(),C=Ct(),g=Mt(),p=wt(),S=Ft(),F=d.useRef(e);F.current=e;const T=d.useRef(n);T.current=n;const j=d.useRef(r);j.current=r;const G=d.useRef(i);G.current=i;const W=d.useRef(c);W.current=c;const oe=d.useRef(o);oe.current=o;const ie=d.useRef(a);ie.current=a;const $=d.useRef(u);$.current=u;const N=d.useRef(l);N.current=l;const[D,ae]=d.useState(st),[U,v]=d.useState(0),[M,R]=d.useState(Cs),[X,O]=d.useState([]),ft=d.useCallback(s=>{ae(s),St(pe.SPOTLIGHT_QUERY,s)},[]);d.useEffect(()=>{t&&(ae(st()),v(0))},[t]),d.useEffect(()=>{if(!t){O([]);return}const s=D.trim();if(s.length<xs){O([]);return}let m=!1;const w=setTimeout(()=>{ys(s).then(x=>{m||O(x)}).catch(()=>{m||O([])})},250);return()=>{m=!0,clearTimeout(w)}},[t,D]);const Fe=d.useCallback(s=>{R(s),vt(pe.SPOTLIGHT_TAB,s)},[]),$e=d.useRef(M);$e.current=M;const gt=d.useCallback(s=>{const m=fe.indexOf($e.current),w=fe[(m+s+fe.length)%fe.length];Fe(w)},[Fe]);d.useEffect(()=>{v(0)},[M]);const Se=V.getShortcuts(),ge=d.useMemo(()=>t?Bt():{},[t]),me=d.useMemo(()=>{if(!t)return[];const s=window.matchMedia("(pointer: coarse)").matches,m=Se.find(x=>x.id==="spawn-agent"),w=Se.find(x=>x.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:s?"":m?Ve(m):"Alt+N",icon:f.jsx(ne,{name:"plus",size:16}),action:()=>{F.current(),T.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:s?"":w!=null&&w.key?Ve(w):"Tab",icon:f.jsx(ne,{name:"dashboard",size:16}),action:()=>{F.current(),j.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:f.jsx(ne,{name:"gear",size:16}),action:()=>{F.current(),G.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:f.jsx(ne,{name:"chart-line",size:16}),action:()=>{var x;F.current(),(x=N.current)==null||x.call(N)}}]},[t,Se]),he=d.useMemo(()=>t?Array.from(h.values()).map(s=>{const m=(g||[]).filter(Y=>Y.agentId===s.id).map(Y=>Y.filePath),w=[...new Set(m)],x=w.map(Y=>Y.split("/").pop()||Y),B=[];s.lastAssignedTask&&B.push(s.lastAssignedTask);const L=`${s.class} • ${s.cwd}`;let k=`${s.name} ${s.class} ${s.status} ${s.cwd}`;s.taskLabel&&(k+=` ${s.taskLabel}`),x.length>0&&(k+=` ${x.join(" ")} ${w.join(" ")}`),B.length>0&&(k+=` ${B.join(" ")}`);const P=Date.now()-s.lastActivity;let H;return s.lastAssignedTask&&(s.lastAssignedTask.length>150?H=s.lastAssignedTask.slice(0,150)+"...":H=s.lastAssignedTask),{id:`agent-${s.id}`,type:"agent",title:s.name,subtitle:L,lastUserInput:H,timeAway:P,icon:f.jsx(_t,{agent:s,size:20}),_searchText:k,_modifiedFiles:w,_userQueries:B,_agentId:s.id,_lastActivity:s.lastActivity,_taskLabel:s.taskLabel,_status:s.status,action:()=>{F.current(),It(s.id),V.selectAgent(s.id),V.getState().viewMode!=="flat"&&V.requestTerminalExpand()}}}):[],[t,h,g]),Ae=d.useMemo(()=>t?Array.from(E.values()).map(s=>{var m;return{id:`area-${s.id}`,type:"area",title:s.name,subtitle:`${s.assignedAgentIds.length} agents • ${((m=s.directories)==null?void 0:m.length)||0} folders`,icon:f.jsx(ne,{name:"map",size:16}),action:()=>{F.current(),V.selectArea(s.id)}}}):[],[t,E]),je=d.useMemo(()=>{const s=new Map;for(const m of he)m._agentId&&s.set(m._agentId,m);return s},[he]),Ne=d.useMemo(()=>{const s=new Map;if(!t)return s;for(const m of h.values()){const w=V.getAreaForAgent(m.id);if(!w||w.archived)continue;const x=s.get(w.id);x?x.push(m):s.set(w.id,[m])}return s},[t,h,E]),Pe=d.useMemo(()=>{const s=new Map;for(const m of p)s.has(m.agentId)||s.set(m.agentId,m.timestamp);return s},[p]),ve=d.useMemo(()=>{if(!t)return[];const s=D.trim().toLowerCase(),m=Dt({sortMode:Ms(),agentsWithUnseenOutput:S,getLatestToolTimestamp:B=>Pe.get(B)}),w=Array.from(E.values()).filter(B=>!B.archived).filter(B=>s?B.name.toLowerCase().includes(s):!0).sort((B,L)=>B.name.localeCompare(L.name,void 0,{sensitivity:"base"})),x=[];for(const B of w){const k=(Ne.get(B.id)||[]).slice().sort(m).map(P=>je.get(P.id)).filter(P=>!!P);!s&&k.length===0||x.push({areaId:B.id,areaName:B.name,areaColor:B.color,agents:k})}return x},[t,D,E,Ne,je,S,Pe]),ye=d.useMemo(()=>t?Array.from(C.values()).filter(s=>s.type==="server"||s.type==="boss"||s.type==="database"||s.type==="tests").map(s=>{var P,H,Y,ue,ee;const m=s.status==="running"?"#4ade80":s.status==="stopped"?"#f87171":"#facc15",w=s.type==="boss"?"crown":s.type==="database"?"database":s.type==="tests"?"flask":"desktop",x=s.type==="boss"?"Boss":s.type==="database"?"Database":s.type==="tests"?"Tests":"Server";let B=`${x} • ${s.status}`;if(s.type==="database"&&((H=(P=s.database)==null?void 0:P.connections)!=null&&H.length)){const z=s.database.connections[0];B+=` • ${z.engine} @ ${z.host}`}else s.type==="tests"&&s.folderPath?B=`${x} • ${s.folderPath}`:s.cwd&&(B+=` • ${s.cwd}`);const L=((Y=s.pm2Status)==null?void 0:Y.ports)||[];let k=`${s.name} ${s.type} ${s.status} ${s.cwd||""} ${((ue=s.pm2)==null?void 0:ue.name)||""}`;if(s.type==="tests"&&(k+=` ${s.folderPath||""} tests junit maven`),L.length>0&&(k+=` ${L.join(" ")}`),s.type==="database"&&((ee=s.database)!=null&&ee.connections))for(const z of s.database.connections)k+=` ${z.name} ${z.engine} ${z.host} ${z.database||""} mysql postgresql sql`;return{id:`building-${s.id}`,type:"building",title:s.name,subtitle:B,_ports:L,icon:f.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[f.jsx(ne,{name:"status-pending",size:10,weight:"fill",color:m}),f.jsx(ne,{name:w,size:16})]}),_searchText:k,action:()=>{var z;F.current(),s.type==="boss"?ie.current(s.id):s.type==="database"?$.current(s.id):s.type==="tests"?V.openTestsBuilding(s.id):s.type==="http"?V.openHttpBuilding(s.id):(z=s.pm2)!=null&&z.enabled&&oe.current(s.id)}}}):[],[t,C]),Ke=d.useMemo(()=>{if(!t)return[];const s=g||[],m=new Set,w=[];for(const x of s){if(m.has(x.filePath))continue;m.add(x.filePath);const B=x.filePath.split("/").pop()||x.filePath,L=x.action==="created"?"Created":x.action==="modified"?"Modified":x.action==="deleted"?"Deleted":"Read";if(w.push({id:`modified-${x.filePath}-${x.timestamp}`,type:"modified-file",title:B,subtitle:`${L} by ${x.agentName} • ${x.filePath}`,matchedText:x.filePath,icon:x.action==="deleted"?f.jsx(ne,{name:"trash",size:16}):kt(x.filePath),action:()=>{F.current();const k=Array.from(V.getState().areas.values());for(const P of k)for(const H of P.directories||[])if(x.filePath.startsWith(H)){V.setFileViewerPath(x.filePath),W.current(P.id);return}V.selectAgent(x.agentId)}}),w.length>=50)break}return w},[t,g]),Oe=d.useMemo(()=>t?X.map(s=>{const m=s.isGitRepo&&s.gitBranch?`${s.path} • ${s.gitBranch}`:s.path;return{id:`folder-${s.path}`,type:"folder",title:s.name,subtitle:m,matchedText:s.path,icon:f.jsx(ne,{name:s.isGitRepo?"git-branch":"folder",size:16}),_searchText:`${s.name} ${s.path}`,_isGitRepo:s.isGitRepo,_gitBranch:s.gitBranch,action:()=>{F.current(),V.openFileExplorer(s.path)}}}):[],[t,X]),ze=d.useMemo(()=>new q(he,{keys:["title","subtitle","_searchText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[he]),Qe=d.useMemo(()=>new q(me,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[me]),Ge=d.useMemo(()=>new q(Ae,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[Ae]),We=d.useMemo(()=>new q(Ke,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Ke]),Ue=d.useMemo(()=>new q(ye,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ye]),de=d.useMemo(()=>{if(!D.trim()){const A=[];A.push(...ye);const I=[...he].sort((b,K)=>{const te=Ee(b._agentId,b._lastActivity,ge);return Ee(K._agentId,K._lastActivity,ge)-te});A.push(...I),A.push(...me.slice(0,2)),A.push(...Ae.slice(0,2));const _={};return Es.forEach((b,K)=>{_[b]=K}),A.sort((b,K)=>(_[b.type]??999)-(_[K.type]??999)),A}const s=D.trim().toLowerCase(),m=ze.search(D).slice(0,8),w=Qe.search(D).slice(0,3),x=Ge.search(D).slice(0,2),B=We.search(D).slice(0,3),L=Oe.slice(0,8),k=Ue.search(D).filter(A=>{const I=A.score??1;return`${A.item.title} ${A.item.subtitle||""} ${A.item._searchText||""}`.toLowerCase().includes(s)||I<=.2}).slice(0,4),P={agent:6,building:5,folder:4,command:3,area:2,"modified-file":1},H=A=>{if(!s)return 1;const I=A.title.toLowerCase();return I===s?6:I.startsWith(s)?5:I.split(/[^a-z0-9]+/i).includes(s)?4:I.includes(s)?3:`${A.subtitle||""} ${A._searchText||""} ${A.matchedText||""}`.toLowerCase().includes(s)?2:1},Y=(A,I)=>{const _=(1-Math.min(1,I??1))*4;return H(A)*100+(P[A.type]??0)*5+_},ue=new Map,ee=(A,I)=>{const _=ue.get(A.type),b={item:A,score:Y(A,I)};_?_.push(b):ue.set(A.type,[b])};for(const A of m){const I={...A.item};if(I._modifiedFiles&&I._modifiedFiles.length>0){const _=I._modifiedFiles.filter(b=>{var se;const K=((se=b.split("/").pop())==null?void 0:se.toLowerCase())||"",te=b.toLowerCase();return K.includes(s)||te.includes(s)});_.length>0&&(I.matchedFiles=_)}if(I._userQueries&&I._userQueries.length>0){const _=I._userQueries.find(b=>b.toLowerCase().includes(s));if(_)if(_.length>200){const K=_.toLowerCase().indexOf(s),te=Math.max(0,K-60),se=Math.min(_.length,K+s.length+100);I.matchedQuery=(te>0?"...":"")+_.slice(te,se)+(se<_.length?"...":"")}else I.matchedQuery=_}ee(I,A.score)}for(const A of k)ee(A.item,A.score);for(const A of w)ee(A.item,A.score);for(const A of x)ee(A.item,A.score);for(const A of B)ee(A.item,A.score);for(const A of L)ee(A,void 0);for(const[A,I]of ue)A==="agent"?I.sort((_,b)=>{const K=H(_.item),te=H(b.item);if(te!==K)return te-K;const se=Ee(_.item._agentId,_.item._lastActivity,ge),Ye=Ee(b.item._agentId,b.item._lastActivity,ge);return Ye!==se?Ye-se:b.score-_.score}):I.sort((_,b)=>b.score-_.score);const z=A=>A.reduce((I,_)=>Math.max(I,_.score),-1),He=[];return Array.from(ue.values()).sort((A,I)=>z(I)-z(A)).forEach(A=>{for(const I of A)He.push(I.item)}),He},[D,ze,Qe,Ge,We,Ue,me,he,Ae,ye,Oe,ge]),J=d.useMemo(()=>{switch(M){case"agents":return de.filter(s=>s.type==="agent");case"buildings":return de.filter(s=>s.type==="building");case"commands":return de.filter(s=>s.type==="command");case"folders":return de.filter(s=>s.type==="folder");case"areas":return ve.flatMap(s=>s.agents);case"all":default:return de}},[M,de,ve]);d.useEffect(()=>{U>=J.length&&v(Math.max(0,J.length-1))},[J.length,U]);const pt=d.useCallback(s=>{if(s.altKey&&!s.ctrlKey&&!s.metaKey&&(s.key==="p"||s.key==="n"||s.key==="P"||s.key==="N")){s.preventDefault(),s.stopPropagation(),s.nativeEvent.stopImmediatePropagation();const m=s.key.toLowerCase();v(m==="p"?w=>w>0?w-1:J.length-1:w=>w<J.length-1?w+1:0);return}switch(s.key){case"Escape":s.preventDefault(),F.current();break;case"ArrowUp":s.preventDefault(),v(m=>m>0?m-1:J.length-1);break;case"ArrowDown":s.preventDefault(),v(m=>m<J.length-1?m+1:0);break;case"Enter":s.preventDefault(),J[U]&&J[U].action();break}},[J,U]),mt=d.useCallback((s,m)=>{if(!m||!s)return s;const w=s.toLowerCase(),x=m.toLowerCase(),B=[];let L=0,k=w.indexOf(x),P=0;for(;k!==-1;)k>L&&B.push(s.slice(L,k)),B.push(Be.createElement("mark",{key:P++,className:"spotlight-highlight"},s.slice(k,k+m.length))),L=k+m.length,k=w.indexOf(x,L);return L<s.length&&B.push(s.slice(L)),B.length>0?Be.createElement(Be.Fragment,null,...B):s},[]);return{query:D,setQuery:ft,selectedIndex:U,setSelectedIndex:v,results:J,activeTab:M,setActiveTab:Fe,cycleTab:gt,areaSections:ve,handleKeyDown:pt,highlightMatch:mt}}const Fs=d.forwardRef(function({query:e,onQueryChange:n,onKeyDown:r,onResetSelection:i},c){const{t:o}=we(["common"]);return f.jsxs("div",{className:"spotlight-input-wrapper",children:[f.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),f.jsx("input",{ref:c,type:"text",className:"spotlight-input",placeholder:o("common:search.spotlightPlaceholder"),value:e,onChange:a=>{n(a.target.value),i()},onKeyDown:r,autoFocus:!0,spellCheck:!1}),f.jsxs("div",{className:"spotlight-input-hints",children:[f.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),f.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),f.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Ss=d.memo(function({activeTab:e,onSelect:n}){const{t:r}=we(["terminal"]);return f.jsxs("div",{className:"spotlight-tabs",role:"tablist","aria-label":r("terminal:spotlight.tabsLabel"),children:[fe.map(i=>f.jsx("button",{type:"button",role:"tab","aria-selected":i===e,tabIndex:-1,className:`spotlight-tab${i===e?" active":""}`,onClick:()=>n(i),children:r(`terminal:spotlight.tabs.${i}`)},i)),f.jsx("span",{className:"spotlight-tabs-hint",children:f.jsx("kbd",{children:"Tab"})})]})}),vs=d.forwardRef(function({results:e,selectedIndex:n,query:r,activeTab:i,areaSections:c,highlightMatch:o,onSelectIndex:a},u){const{t:l}=we(["terminal"]),h=d.useRef(!1);d.useEffect(()=>{h.current=!1},[e]),d.useEffect(()=>{const g=typeof u=="function"?null:u==null?void 0:u.current;if(!g)return;const p=()=>{h.current=!0};return g.addEventListener("mousemove",p),()=>{g.removeEventListener("mousemove",p)}},[u,e]);const E={command:l("terminal:spotlight.categories.commands"),agent:l("terminal:spotlight.categories.agents"),building:l("terminal:spotlight.categories.infrastructure"),area:l("terminal:spotlight.categories.areas"),folder:l("terminal:spotlight.categories.folders"),"modified-file":l("terminal:spotlight.categories.modifiedFiles")},C=d.useMemo(()=>{const g=[];let p=null,S=[];return e.forEach((F,T)=>{F.type!==p&&(p!==null&&S.length>0&&g.push([p,S]),p=F.type,S=[]),S.push({result:F,index:T})}),p!==null&&S.length>0&&g.push([p,S]),g},[e]);if(d.useEffect(()=>{if(!u||typeof u=="function")return;const g=u.current;if(!g)return;const p=g.querySelector(".spotlight-item.selected");p&&p.scrollIntoView({block:"nearest",behavior:"smooth"})},[n,u]),i==="areas"){if(c.length===0)return f.jsx("div",{className:"spotlight-results",ref:u,children:f.jsx("div",{className:"spotlight-empty",children:l("terminal:spotlight.noResults")})});let g=0;return f.jsx("div",{className:"spotlight-results",ref:u,children:c.map(p=>f.jsxs("div",{children:[f.jsxs("div",{className:"spotlight-category-header spotlight-area-section-header",children:[f.jsx("span",{className:"spotlight-area-dot",style:{background:p.areaColor},"aria-hidden":"true"}),f.jsx("span",{className:"spotlight-area-name",children:p.areaName}),f.jsx("span",{className:"spotlight-area-count",children:p.agents.length})]}),p.agents.length===0?f.jsx("div",{className:"spotlight-area-empty",children:l("terminal:spotlight.noAgentsInArea")}):p.agents.map(S=>{const F=g++;return f.jsx(Je,{result:S,isSelected:F===n,query:r,highlightMatch:o,onClick:()=>S.action(),onMouseEnter:()=>{h.current&&a(F)}},S.id)})]},p.areaId))})}return e.length===0?f.jsx("div",{className:"spotlight-results",ref:u,children:f.jsx("div",{className:"spotlight-empty",children:l("terminal:spotlight.noResults")})}):f.jsx("div",{className:"spotlight-results",ref:u,children:C.map(([g,p])=>f.jsxs("div",{children:[C.length>1&&f.jsx("div",{className:"spotlight-category-header",children:E[g]||g}),p.map(({result:S,index:F})=>f.jsx(Je,{result:S,isSelected:F===n,query:r,highlightMatch:o,onClick:()=>S.action(),onMouseEnter:()=>{h.current&&a(F)}},S.id))]},g))})}),Bs=d.memo(function(){const{t:e}=we(["terminal"]);return f.jsxs("div",{className:"spotlight-footer",children:[f.jsxs("div",{className:"spotlight-footer-left",children:[f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"↑"}),f.jsx("kbd",{children:"↓"})," ",f.jsx("kbd",{children:"Alt+N"}),f.jsx("kbd",{children:"Alt+P"})," ",e("terminal:spotlight.navigate")]}),f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Enter"})," ",e("terminal:spotlight.select")]}),f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Tab"})," ",e("terminal:spotlight.switchTabs")]})]}),f.jsx("div",{className:"spotlight-footer-right",children:f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Esc"})," ",e("common:buttons.close")]})})]})}),Is=768;function Rs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=d.useRef(null),E=d.useRef(null),C=d.useRef(null),g=d.useRef(0),{query:p,setQuery:S,selectedIndex:F,setSelectedIndex:T,results:j,activeTab:G,setActiveTab:W,cycleTab:oe,areaSections:ie,handleKeyDown:$,highlightMatch:N}=ws({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l});g.current=j.length;const D=d.useRef(oe);D.current=oe,d.useEffect(()=>{t&&setTimeout(()=>{var v,M;(v=h.current)==null||v.focus(),(M=h.current)==null||M.select()},50)},[t]),d.useEffect(()=>{if(!t)return;const v=window.visualViewport;if(!v||window.innerWidth>Is)return;const M=()=>{const R=E.current;R&&(R.style.height=`${v.height}px`,R.style.top=`${v.offsetTop}px`)};return M(),v.addEventListener("resize",M),v.addEventListener("scroll",M),()=>{v.removeEventListener("resize",M),v.removeEventListener("scroll",M);const R=E.current;R&&(R.style.height="",R.style.top="")}},[t]),d.useEffect(()=>{if(!t)return;const v=M=>{if(M.key==="Escape"){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),e();return}if(M.key==="Tab"){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),D.current(M.shiftKey?-1:1);return}if(M.altKey&&!M.ctrlKey&&!M.metaKey&&(M.key==="n"||M.key==="p"||M.key==="N"||M.key==="P")){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation();const R=M.key.toLowerCase(),X=g.current;T(R==="p"?O=>O>0?O-1:X-1:O=>O<X-1?O+1:0);return}};return window.addEventListener("keydown",v,{capture:!0}),()=>{window.removeEventListener("keydown",v,{capture:!0})}},[t,e]);const ae=d.useCallback(v=>{v.target===v.currentTarget&&e()},[e]),U=d.useCallback(()=>{T(0)},[T]);return t?f.jsx("div",{ref:E,className:"spotlight-overlay",onClick:ae,children:f.jsxs("div",{className:"spotlight-modal",children:[f.jsx(Fs,{ref:h,query:p,onQueryChange:S,onKeyDown:$,onResetSelection:U}),f.jsx(Ss,{activeTab:G,onSelect:W}),f.jsx(vs,{ref:C,results:j,selectedIndex:F,query:p,activeTab:G,areaSections:ie,highlightMatch:N,onSelectIndex:T}),f.jsx(Bs,{})]})}):null}export{Ls as FILE_ICON_NAMES,Rs as Spotlight,Bs as SpotlightFooter,Fs as SpotlightInput,Je as SpotlightItem,vs as SpotlightResults,$s as formatDuration,js as formatRelativeTime,Ns as getAgentIcon,kt as getFileIconFromPath,Ps as getTypeLabel,ws as useSpotlightSearch};
|