tide-commander 1.83.0 → 1.84.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/assets/{BossLogsModal-Bgg8MqNZ.js → BossLogsModal-C8zRzuFy.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-SQNEPxH1.js → BossSpawnModal-CeA6mhN7.js} +1 -1
  3. package/dist/assets/{ControlsModal-ImEPi76l.js → ControlsModal-CP6NB4EV.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-Cs3jjehG.js → DockerLogsModal-DEgQJ1ZA.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-Cg3lq_Cv.js → EmbeddedEditor-CKvksEzA.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-1Gh5-yZt.js → GmailOAuthSetup-DdRol00s.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-DmXPQyOR.js → GoogleOAuthSetup-CGV5agAn.js} +1 -1
  8. package/dist/assets/{IframeModal-BEItm7bf.js → IframeModal-hQ9wpT90.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-epI8eaV_.js → IntegrationsPanel-0DPPoL2y.js} +2 -2
  10. package/dist/assets/{LogViewerModal-B4ryb52t.js → LogViewerModal-DGVR_WfJ.js} +1 -1
  11. package/dist/assets/{MonitoringModal-CzUjqD5Y.js → MonitoringModal-FzeLMdzo.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-Ex9G2Mly.js → PM2LogsModal-UqeZ-Z-C.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-DIsamY35.js → RestoreArchivedAreaModal-Dk3oNX5d.js} +1 -1
  14. package/dist/assets/{Scene2DCanvas-B5VdT-R2.js → Scene2DCanvas-BLYWui_s.js} +1 -1
  15. package/dist/assets/{SceneManager-CgkTa3Uf.js → SceneManager-Bo_ImHGE.js} +1 -1
  16. package/dist/assets/{SkillsPanel-DXxAlZbz.js → SkillsPanel-D448Eb0f.js} +1 -1
  17. package/dist/assets/{SpawnModal-_1Af5rTQ.js → SpawnModal-BMlp3ZUn.js} +1 -1
  18. package/dist/assets/{SubordinateAssignmentModal-CZ1p4KxH.js → SubordinateAssignmentModal-WdKcjuF8.js} +1 -1
  19. package/dist/assets/{TriggerManagerPanel-DnOvAQq6.js → TriggerManagerPanel-DAQz-77a.js} +1 -1
  20. package/dist/assets/{WorkflowEditorPanel-Dr896thl.js → WorkflowEditorPanel-j4Ios7kX.js} +1 -1
  21. package/dist/assets/index-BR9_mEVJ.css +1 -0
  22. package/dist/assets/index-BdGz_GAe.css +1 -0
  23. package/dist/assets/index-C8qENpYZ.js +1 -0
  24. package/dist/assets/{index-CkhtIUBY.js → index-CDxPahrR.js} +1 -1
  25. package/dist/assets/index-CQ-mkqhz.js +1 -0
  26. package/dist/assets/{index-DVqDWfDB.js → index-Cbf25fjE.js} +2 -2
  27. package/dist/assets/{index-DvRrAd9Y.js → index-Ce_6e5Xj.js} +1 -1
  28. package/dist/assets/index-CkoqkFEg.js +2 -0
  29. package/dist/assets/{index-C70mj1bd.js → index-RyuR5SvS.js} +1 -1
  30. package/dist/assets/{index-CgPa_6TH.js → index-blYiJWLh.js} +1 -1
  31. package/dist/assets/{index-OYmdvKdM.js → index-voJf2Goi.js} +3 -3
  32. package/dist/assets/main-CFu_SP_0.css +1 -0
  33. package/dist/assets/{main-CHfGSVnw.js → main-CPwivjwQ.js} +87 -87
  34. package/dist/assets/{web-rv0WAVTk.js → web-DrIhSNal.js} +1 -1
  35. package/dist/assets/{web-D1aYcbd6.js → web-DsEKGJbn.js} +1 -1
  36. package/dist/index.html +3 -3
  37. package/dist/locales/en/common.json +5 -1
  38. package/dist/locales/en/config.json +61 -0
  39. package/dist/src/packages/server/integrations/whatsapp/whatsapp-notification-publisher.js +48 -0
  40. package/dist/src/packages/server/integrations/whatsapp/whatsapp-routes.js +43 -0
  41. package/dist/src/packages/server/routes/notifications.js +12 -0
  42. package/dist/src/packages/server/services/agent-service.js +10 -0
  43. package/dist/src/packages/server/services/index.js +1 -0
  44. package/dist/src/packages/server/services/whatsapp-notification-config-service.js +120 -0
  45. package/dist/src/packages/server/websocket/handlers/notification-handler.js +12 -0
  46. package/package.json +1 -1
  47. package/dist/assets/index-B0Q9DUzT.css +0 -1
  48. package/dist/assets/index-CFb36m7S.css +0 -1
  49. package/dist/assets/index-CoUtzDXD.js +0 -2
  50. package/dist/assets/index-DCHHa29_.js +0 -1
  51. package/dist/assets/index-ave_XgRW.js +0 -1
  52. package/dist/assets/main-DmmvYoEs.css +0 -1
@@ -1,2 +0,0 @@
1
- import{u as Xt,z as Ut,B as qt,r as n,E as Nt,S as j,G as kt,H as wt,J as It,K as st,L as Ae,M as Kt,s as f,N as Pt,O as zt,P as Yt,v as At,w as St,j as e,I as u,U as Zt,m as Jt,V as Qt,W as Dt,X as Rt,Y as ea,Z as ta,_ as aa,$ as na,a0 as sa,a1 as la,a2 as ra,a3 as ia,a4 as oa,a5 as ca,a6 as yt,C as da,a7 as ua,a8 as pa,a9 as ma,aa as fa,ab as ha,ac as ga,ad as ba,ae as xa,af as _a,ag as wa,ah as Ca,ai as ja,aj as va,ak as Na,al as ka,am as Ia}from"./main-CHfGSVnw.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const lt=3,rt=280,Mt=320,_t=240,Et=64,Aa=["simple","chat","advanced"],Sa={simple:"Simple",chat:"Chat",advanced:"Advanced"},ya={simple:"○",chat:"◐",advanced:"◉"},Ma={simple:"Simple view — clean messages only",chat:"Chat view — assistant replies (no tool calls)",advanced:"Advanced view — everything including tools"},Tt="flat-clear-context";function Ea(_){const d=_.split("/").filter(Boolean);return d.length===0?_:d.slice(-2).join("/")}function Ta(_){if(_.provider==="codex"){const he=_.codexModel||"gpt-5.3-codex",ne=Na[he];return{model:(ne==null?void 0:ne.label)||he}}if(_.provider==="opencode")return{model:_.opencodeModel||"opencode"};const d=_.model||"sonnet",N=Ia[d],E=_.effort,B=E?ka[E]:void 0;return{model:(N==null?void 0:N.label)||d,effort:B==null?void 0:B.label}}function Pa(_,d){if(d.type==="rectangle"&&d.width&&d.height){const N=d.width/2,E=d.height/2;return _.x>=d.center.x-N&&_.x<=d.center.x+N&&_.z>=d.center.z-E&&_.z<=d.center.z+E}if(d.type==="circle"&&d.radius){const N=_.x-d.center.x,E=_.z-d.center.z;return N*N+E*E<=d.radius*d.radius}return!1}const za=ua.memo(function({agentId:d,terminalViewMode:N,onTerminalViewModeChange:E,inspectorOpen:B,onToggleInspector:he,onImageClick:ne,onFileClick:ge,onBashClick:T,onViewMarkdown:Se,onRequestClearSubordinates:ye,onOpenBuilding:Me,keyboard:We,canNavigateBack:He,canNavigateForward:Ee,onNavigateBack:Y,onNavigateForward:P,agentInfoOpen:be,onToggleAgentInfo:G}){var te,ve,q,Qe;const h=pa(d),A=zt(),se=n.useRef(null),xe=n.useRef(null);n.useEffect(()=>{const s=xe.current;if(!s)return;const i=o=>{o.button===3?(o.preventDefault(),o.stopPropagation(),Y()):o.button===4&&(o.preventDefault(),o.stopPropagation(),P())},c=o=>{(o.button===3||o.button===4)&&o.preventDefault()};return s.addEventListener("mouseup",i),s.addEventListener("mousedown",c),()=>{s.removeEventListener("mouseup",i),s.removeEventListener("mousedown",c)}},[Y,P]),n.useEffect(()=>{const s=xe.current;if(!s)return;let i=0,c=0,o=0;const ae=250,pe=600,Ne=80,mt=1.5,ft=D=>{let I=D instanceof HTMLElement?D:null;for(;I&&I!==s;){const Oe=window.getComputedStyle(I).overflowX;if((Oe==="auto"||Oe==="scroll")&&I.scrollWidth>I.clientWidth)return!0;I=I.parentElement}return!1},ke=D=>{const I=Date.now();if(I<o){D.preventDefault();return}if(Math.abs(D.deltaX)<=Math.abs(D.deltaY)*mt){i=0;return}if(ft(D.target)){i=0;return}I-c>ae&&(i=0),c=I,i+=D.deltaX,i<=-Ne?(i=0,o=I+pe,D.preventDefault(),Y()):i>=Ne&&(i=0,o=I+pe,D.preventDefault(),P())};return s.addEventListener("wheel",ke,{passive:!1}),()=>s.removeEventListener("wheel",ke)},[Y,P]);const le=Pt(),Te=n.useMemo(()=>{if(!h)return null;const s=new Set,i=[];for(const c of le.values())c.archived||c.directories.length===0||c.assignedAgentIds.includes(d)&&(s.add(c.id),i.push(c));for(const c of le.values())c.archived||c.directories.length===0||s.has(c.id)||Pa({x:h.position.x,z:h.position.z},c)&&(s.add(c.id),i.push(c));return i.length===0?null:i.flatMap(c=>c.directories.filter(o=>o&&o.trim().length>0).map(o=>({areaId:c.id,areaName:c.name,dir:o})))},[h,d,le]),{branches:Ge,fetchRemote:Ve,fetchingDirs:Pe}=ma(Te),_e=n.useMemo(()=>{var c;const s=f.getAreaForAgent(d);if(!s)return[];const i=[];for(const o of A.values())o.type==="terminal"&&f.isPositionInArea(o.position,s)&&i.push({id:o.id,name:o.name,hasUrl:!!((c=o.terminalStatus)!=null&&c.url)});return i},[d,A]),ze=n.useMemo(()=>{var c;const s=f.getAreaForAgent(d);if(!s)return[];const i=[];for(const o of A.values())o.type==="server"&&((c=o.pm2)!=null&&c.enabled)&&f.isPositionInArea(o.position,s)&&i.push({id:o.id,name:o.name});return i},[d,A]),De=n.useMemo(()=>{const s=f.getAreaForAgent(d);if(!s)return[];const i=[];for(const c of A.values())c.type==="database"&&c.database&&f.isPositionInArea(c.position,s)&&i.push({id:c.id,name:c.name});return i},[d,A]),[,we]=n.useReducer(s=>s+1,0),Z=((te=se.current)==null?void 0:te.search.searchMode)??!1,it=n.useCallback(()=>{var s;(s=se.current)==null||s.search.toggleSearch(),we()},[]),Xe=fa(),J=Xe.isPending(Tt),[R,F]=n.useState(null),O=R?A.get(R):null,{height:W,onResizeStart:Ce}=ha(),[L,V]=n.useState(()=>wt(j.GIT_PANEL_OPEN,!1)),[re,Ue]=n.useState(()=>wt(j.BUILDINGS_PANEL_OPEN,!1)),[Q,ie]=n.useState(!1),ot=n.useCallback(()=>{ie(s=>{const i=!s;return i&&ga.setEnabled(!0),i})},[]),ct=n.useCallback(()=>ie(!1),[]),oe=n.useCallback(()=>{V(s=>{const i=!s;return Ae(j.GIT_PANEL_OPEN,i),i})},[]),dt=n.useCallback(()=>{Ue(s=>{const i=!s;return Ae(j.BUILDINGS_PANEL_OPEN,i),i})},[]),qe=n.useCallback(()=>{V(!1),Ae(j.GIT_PANEL_OPEN,!1)},[]),ut=n.useCallback(()=>{Ue(!1),Ae(j.BUILDINGS_PANEL_OPEN,!1)},[]),pt=ba();n.useEffect(()=>{if(!R)return;_e.some(i=>i.id===R)||F(null)},[R,_e]);const[ce,ee]=n.useState(!1),Re=n.useRef(null);if(n.useEffect(()=>{if(!ce)return;const s=i=>{Re.current&&!Re.current.contains(i.target)&&ee(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[ce]),!h)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 X=h.contextStats,Ke=!!X,Ye=X?X.totalTokens:h.contextUsed||0,de=X?X.contextWindow:h.contextLimit||2e5,g=X?X.usedPercent:Math.round(Ye/de*100),z=Math.max(0,Math.min(100,g)),H=Math.max(0,100-z),ue=z>=80?"#ff4a4a":z>=60?"#ff9e4a":z>=40?"#ffd700":"#4aff9e",Le=(Ye/1e3).toFixed(1),Ze=(de/1e3).toFixed(1),U=h.cwd,Je=U?Ea(U):null,je=((ve=h.subordinateIds)==null?void 0:ve.length)||0,$e=je>0;return e.jsxs("div",{ref:xe,className:`flat-terminal-wrapper ${L||re||Q?"flat-terminal-wrapper--with-side-panel":""}`,children:[e.jsxs("div",{className:"flat-terminal-wrapper__header",children:[e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__header-main ${be?"flat-terminal-wrapper__header-main--active":""}`,onClick:G,title:be?"Hide agent info":"Show agent info","aria-pressed":be,children:[e.jsx(Dt,{agent:h,size:28}),e.jsxs("span",{className:"flat-terminal-wrapper__header-info",children:[e.jsx("span",{className:"flat-terminal-wrapper__header-name",children:h.name}),e.jsx("span",{className:"flat-terminal-wrapper__header-status",style:{color:Rt(h.status)},children:h.status})]}),h.taskLabel&&e.jsxs("span",{className:"flat-terminal-wrapper__header-task",title:h.taskLabel,children:["📋 ",h.taskLabel]}),e.jsxs("span",{className:"flat-terminal-wrapper__header-model",children:[e.jsx("img",{src:h.provider==="codex"?"/assets/codex.png":h.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:h.provider,className:"flat-terminal-wrapper__header-provider-icon",title:h.provider==="codex"?"Codex Agent":h.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),(()=>{const{model:s,effort:i}=Ta(h);return e.jsxs("span",{className:"flat-terminal-wrapper__header-model-chip",title:i?`Model: ${s} · Effort: ${i}`:`Model: ${s}`,children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-name",children:s}),i&&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:i})]})]})})()]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__header-meta",children:[e.jsx("div",{className:"flat-terminal-wrapper__view-mode",role:"group","aria-label":"Message view mode",children:Aa.map(s=>e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn ${N===s?"flat-terminal-wrapper__view-mode-btn--active":""}`,onClick:()=>E(s),title:Ma[s],"aria-pressed":N===s,children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:ya[s]}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:Sa[s]})]},s))}),e.jsxs("div",{className:"flat-terminal-wrapper__actions",role:"group","aria-label":"Terminal actions",children:[e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:Y,disabled:!He,title:"Back to previous agent","aria-label":"Back to previous agent",children:e.jsx(u,{name:"arrow-left",size:14})}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:P,disabled:!Ee,title:"Forward to next agent","aria-label":"Forward to next agent",children:e.jsx(u,{name:"arrow-right",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${Z?"flat-terminal-wrapper__action-btn--active":""}`,onClick:it,title:Z?"Close search":"Search messages","aria-pressed":Z,children:e.jsx(u,{name:Z?"cross":"search",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn flat-terminal-wrapper__action-btn--danger ${J?"flat-terminal-wrapper__action-btn--confirm":""}`,onClick:()=>Xe.handleClick(Tt,()=>{var s;f.clearContext(d),(s=se.current)==null||s.historyLoader.clearHistory()}),title:J?"Click again to confirm clear context":"Clear context",children:e.jsx(u,{name:J?"question":"clear",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${L?"flat-terminal-wrapper__action-btn--active":""}`,onClick:oe,title:L?"Hide git panel":"Show git changes","aria-pressed":L,children:e.jsx(u,{name:"git-branch",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${re?"flat-terminal-wrapper__action-btn--active":""}`,onClick:dt,title:re?"Hide buildings panel":"Show area buildings","aria-pressed":re,children:e.jsx(u,{name:"buildings",size:14})}),e.jsxs("div",{className:"flat-terminal-wrapper__more",ref:Re,children:[e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${ce?"flat-terminal-wrapper__action-btn--active":""}`,onClick:()=>ee(s=>!s),title:"More actions","aria-expanded":ce,children:"⋮"}),ce&&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 ${Q?"flat-terminal-wrapper__more-item--active":""}`,onClick:()=>{ot(),ee(!1)},title:Q?"Hide Debug Panel":"Show Debug Panel",children:[e.jsx(u,{name:"bug",size:14}),e.jsx("span",{children:Q?"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:()=>{f.collapseContext(d),ee(!1)},disabled:h.status!=="idle",title:h.status!=="idle"?"Agent must be idle to collapse context":"Collapse context",children:[e.jsx(u,{name:"package",size:14}),e.jsx("span",{children:"Collapse context"})]}),$e&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{ye(d,je),ee(!1)},children:[e.jsx(u,{name:"crown",size:14}),e.jsxs("span",{children:["Clear ",je," subordinate",je===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:()=>{f.killAgent(d),ee(!1)},children:[e.jsx(u,{name:"cross",size:14}),e.jsx("span",{children:"Remove agent"})]})]})]})]}),e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__inspector-toggle ${B?"flat-terminal-wrapper__inspector-toggle--active":""}`,onClick:he,title:B?"Hide inspector panel":"Show inspector panel","aria-label":B?"Hide inspector panel":"Show inspector panel","aria-pressed":B,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:()=>f.deselectAll(),title:"Close chat","aria-label":"Close chat",children:e.jsx(u,{name:"cross",size:14})})]})]}),e.jsx(xa,{ref:se,agentId:d,agent:h,viewMode:N,isOpen:!0,onImageClick:ne,onFileClick:ge,onBashClick:T,onViewMarkdown:Se,keyboard:We,hasModalOpen:!1}),O&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:Ce,role:"separator","aria-orientation":"horizontal","aria-label":"Resize embedded terminal"}),e.jsxs("div",{className:"flat-bottom-panel",role:"region","aria-label":`Embedded terminal: ${O.name}`,style:{height:W},children:[e.jsxs("div",{className:"flat-bottom-panel__header",children:[e.jsxs("span",{className:"flat-bottom-panel__title",children:[e.jsx(u,{name:"terminal",size:12}),e.jsx("span",{children:O.name}),!((q=O.terminalStatus)!=null&&q.url)&&e.jsx("span",{className:"flat-bottom-panel__muted",children:"(starting...)"})]}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>F(null),title:"Close embedded terminal","aria-label":"Close embedded terminal",children:e.jsx(u,{name:"cross",size:12})})]}),e.jsx("div",{className:"flat-bottom-panel__body",children:(Qe=O.terminalStatus)!=null&&Qe.url?e.jsx(_a,{terminalUrl:O.terminalStatus.url,visible:!0}):e.jsx("div",{className:"flat-bottom-panel__placeholder",children:"Starting terminal..."})})]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__statusbar",role:"contentinfo",children:[h.isDetached&&e.jsxs("span",{className:"flat-terminal-wrapper__detached",title:"Reattaching session...",children:[e.jsx(u,{name:"refresh",size:12}),e.jsx("span",{children:"Reattaching"})]}),U&&Je&&e.jsxs("span",{className:"flat-terminal-wrapper__cwd",title:`Open in file explorer: ${U}`,"aria-label":`Open ${U} in file explorer`,role:"button",tabIndex:0,onClick:()=>f.openFileExplorer(U),onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),f.openFileExplorer(U))},children:[e.jsx("span",{className:"flat-terminal-wrapper__cwd-icon",children:e.jsx(u,{name:"folder",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__cwd-text",children:Je})]}),Te&&Te.map(({areaId:s,areaName:i,dir:c})=>{const o=Ge.get(c),ae=Pe.has(c),pe=c.split("/").filter(Boolean).pop()||c;return e.jsxs("span",{className:"flat-terminal-wrapper__area-dir",title:`${i}: ${c}${o?` (${o.branch}${o.ahead?` ↑${o.ahead}`:""}${o.behind?` ↓${o.behind}`:""})`:""}`,onClick:()=>f.openFileExplorerForAreaFolder(s,c),children:[e.jsx(u,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-terminal-wrapper__area-dir-name",children:pe}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flat-terminal-wrapper__area-dir-branch",children:[e.jsx(u,{name:"git-branch",size:10})," ",o.branch]}),o.ahead>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-ahead",title:`${o.ahead} ahead`,children:[e.jsx(u,{name:"arrow-up",size:9}),o.ahead]}),o.behind>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-behind",title:`${o.behind} behind`,children:[e.jsx(u,{name:"arrow-down",size:9}),o.behind]}),e.jsx("span",{className:`flat-terminal-wrapper__area-fetch ${ae?"flat-terminal-wrapper__area-fetch--fetching":""}`,title:"Git fetch",onClick:Ne=>{Ne.stopPropagation(),Ve(c)},children:e.jsx(u,{name:ae?"hourglass":"download",size:12})})]})]},`${s}:${c}`)}),e.jsxs("span",{className:"flat-terminal-wrapper__context",onClick:()=>f.setContextModalAgentId(d),title:Ke?`Context usage: ${Le}k / ${Ze}k tokens (${z}% used). Click to view stats.`:"Click to fetch context stats",children:[e.jsx("span",{className:"flat-terminal-wrapper__context-icon",children:e.jsx(u,{name:"dashboard",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__context-label",children:"Ctx:"}),e.jsx("span",{className:"flat-terminal-wrapper__context-bar",children:e.jsx("span",{className:"flat-terminal-wrapper__context-bar-fill",style:{width:`${z}%`,backgroundColor:ue}})}),e.jsxs("span",{className:"flat-terminal-wrapper__context-tokens",style:{color:ue},children:[Le,"k/",Ze,"k"]}),e.jsxs("span",{className:"flat-terminal-wrapper__context-free",children:["(",H,"% free)"]}),!Ke&&e.jsx("span",{className:"flat-terminal-wrapper__context-warning",title:"No context stats yet",children:e.jsx(u,{name:"warn",size:12})})]}),e.jsx("div",{className:"flat-terminal-wrapper__statusbar-spacer","aria-hidden":"true"}),_e.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area terminals",children:_e.map(s=>{const i=R===s.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${i?"flat-terminal-wrapper__building-btn--active":""} ${s.hasUrl?"":"flat-terminal-wrapper__building-btn--offline"}`,title:`${i?"Hide":"Show"} terminal: ${s.name}${s.hasUrl?"":" (starting...)"}`,onClick:()=>{if(i){F(null);return}s.hasUrl||f.sendBuildingCommand(s.id,"start"),F(s.id)},children:e.jsx(u,{name:"terminal",size:14})},s.id)})}),ze.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area PM2 logs",children:ze.map(s=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open logs: ${s.name}`,onClick:()=>Me(s.id),children:e.jsx(u,{name:"scroll",size:14})},s.id))}),De.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area databases",children:De.map(s=>e.jsx("button",{type:"button",className:"flat-terminal-wrapper__building-btn",title:`Open database: ${s.name}`,onClick:()=>Me(s.id),children:e.jsx(u,{name:"hard-drives",size:14})},s.id))}),e.jsx("div",{className:"flat-terminal-wrapper__theme",children:e.jsx(wa,{})})]}),L&&e.jsx(Ca,{agentId:d,agents:pt,onClose:qe,branchInfoMap:Ge,fetchRemote:Ve,fetchingDirs:Pe}),re&&e.jsx(ja,{agentId:d,onClose:ut}),Q&&e.jsx(va,{agentId:d,onClose:ct})]})});function $a({onAgentClick:_,onBuildingClick:d,onBuildingDoubleClick:N,onBuildingPopup:E,onOpenSpawnModal:B,onOpenBossSpawnModal:he,onOpenAreaModal:ne}){const{t:ge}=Xt(["common"]),T=Ut(),Se=qt(),[ye,Me]=n.useState(null),[We,He]=n.useState(null),[Ee,Y]=n.useState(null),[P,be]=n.useState(null),[G,h]=n.useState(null),[A,se]=n.useState(null),[xe,le]=n.useState(!1),Te=n.useCallback(()=>{le(t=>!t)},[]),Ge=n.useCallback(()=>{le(!1)},[]),[Ve,Pe]=n.useState(()=>{const t=Nt(j.VIEW_MODE);return t==="simple"||t==="chat"||t==="advanced"?t:"simple"}),_e=n.useCallback(t=>{Pe(t),kt(j.VIEW_MODE,t)},[]);n.useEffect(()=>{const t=a=>{if(a.key!==j.VIEW_MODE)return;const l=a.newValue;(l==="simple"||l==="chat"||l==="advanced")&&Pe(l)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const[ze,De]=n.useState(()=>wt(j.FLAT_INSPECTOR_OPEN,!1)),[we,Z]=n.useState(!1),it=n.useCallback(()=>Z(t=>!t),[]),Xe=n.useCallback(()=>Z(!1),[]),J=n.useRef(null),R=n.useRef(null),[F,O]=n.useState(()=>{const t=It(j.FLAT_MIDDLE_WIDTH,0);return t>=rt?t:null}),[W,Ce]=n.useState(()=>{const t=It(j.FLAT_INSPECTOR_WIDTH,0);return t>=_t?t:null}),L=n.useCallback(t=>{if(typeof window>"u")return t;const a=W!==null?lt+W:0,l=window.innerWidth-Et-lt-Mt-a;return Math.max(rt,Math.min(Math.max(l,rt),t))},[W]),V=n.useCallback(t=>{var p;if(typeof window>"u")return t;const a=(p=J.current)==null?void 0:p.querySelector(".flat-middle"),l=(a==null?void 0:a.getBoundingClientRect().width)??rt,r=window.innerWidth-Et-l-lt-Mt-lt;return Math.max(_t,Math.min(Math.max(r,_t),t))},[]);n.useEffect(()=>{if(F===null&&W===null)return;const t=()=>{O(a=>{if(a===null)return a;const l=L(a);return l===a?a:l}),Ce(a=>{if(a===null)return a;const l=V(a);return l===a?a:l})};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[F,W,L,V]);const re=n.useCallback(t=>{var l;if(t.button!==0)return;const a=(l=J.current)==null?void 0:l.querySelector(".flat-middle");a&&(t.currentTarget.setPointerCapture(t.pointerId),R.current={kind:"middle",startX:t.clientX,startWidth:a.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),Ue=n.useCallback(t=>{var l;if(t.button!==0)return;const a=(l=J.current)==null?void 0:l.querySelector(".flat-inspector");a&&(t.currentTarget.setPointerCapture(t.pointerId),R.current={kind:"inspector",startX:t.clientX,startWidth:a.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),Q=n.useCallback(t=>{const a=R.current;if(!a||t.pointerId!==a.pointerId)return;const l=t.clientX-a.startX;a.kind==="middle"?O(L(a.startWidth+l)):Ce(V(a.startWidth-l))},[L,V]),ie=n.useCallback(t=>{const a=R.current;if(!a||t.pointerId!==a.pointerId)return;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}if(R.current=null,document.body.classList.remove("flat-splitter-dragging"),!(Math.abs(t.clientX-a.startX)>2))return;const r=t.clientX-a.startX;if(a.kind==="middle"){const p=L(a.startWidth+r);O(p),st(j.FLAT_MIDDLE_WIDTH,p)}else{const p=V(a.startWidth-r);Ce(p),st(j.FLAT_INSPECTOR_WIDTH,p)}},[L,V]),ot=n.useCallback(()=>{O(null),st(j.FLAT_MIDDLE_WIDTH,0)},[]),ct=n.useCallback(()=>{Ce(null),st(j.FLAT_INSPECTOR_WIDTH,0)},[]),[oe,dt]=n.useState(()=>Nt(j.FLAT_INSPECTOR_VIEW)==="tracking"?"tracking":"agent"),qe=n.useCallback(t=>{dt(t),kt(j.FLAT_INSPECTOR_VIEW,t)},[]),ut=n.useCallback(()=>{De(t=>{const a=!t;return Ae(j.FLAT_INSPECTOR_OPEN,a),a})},[]),pt=n.useCallback(()=>{De(!1),Ae(j.FLAT_INSPECTOR_OPEN,!1)},[]),ce=Kt(),ee=n.useCallback((t,a)=>{Me({url:t,name:a})},[]),Re=n.useCallback((t,a)=>{He({command:t,output:a,isLive:!1})},[]),X=n.useCallback((t,a)=>{f.setFileViewerPath(t,a)},[]),Ke=n.useCallback(t=>{},[]),Ye=n.useCallback((t,a)=>{Y({agentId:t,count:a})},[]),de=n.useCallback(t=>{N?N(t):d(t)},[d,N]),g=n.useMemo(()=>Se.size>0?Array.from(Se)[0]:null,[Se]);n.useEffect(()=>{le(!1)},[g]);const z=n.useRef([]),H=n.useRef(-1),ue=n.useRef(!1),Le=n.useRef(null),[Ze,U]=n.useState(!1),[Je,je]=n.useState(!1),$e=n.useRef(!1),te=n.useRef(null),ve=n.useRef(!1),q=n.useMemo(()=>new Set(T.map(t=>t.id)),[T]),Qe=n.useMemo(()=>{const t=new Map(T.map(l=>[l.id,l])),a=new Map;for(const l of T)if((l.isBoss||l.class==="boss")&&l.subordinateIds&&l.subordinateIds.length>0){const r=l.subordinateIds.map(p=>t.get(p)).filter(p=>p!==void 0);r.length>0&&a.set(l.id,r)}return a},[T]),s=n.useCallback(()=>{const t=z.current,a=H.current;U(a>0),je(a>=0&&a<t.length-1)},[]),i=n.useCallback(t=>{const a=z.current;if(a.length===0)return;let l=H.current+t;for(;l>=0&&l<a.length;){const r=a[l];if(q.has(r)){ue.current=!0,H.current=l,s(),f.selectAgent(r);return}l+=t}},[q,s]),c=n.useCallback(()=>i(-1),[i]),o=n.useCallback(()=>i(1),[i]),ae=n.useCallback((t,a)=>{if(typeof window>"u")return;const l=window.history.state,p={...typeof l=="object"&&l!==null?l:{},__flatAgentNav:{agentId:t}};a==="replace"?window.history.replaceState(p,"",window.location.href):window.history.pushState(p,"",window.location.href)},[]);n.useEffect(()=>{if(!g){$e.current=!1,te.current=null;return}if(!$e.current){ae(g,"replace"),$e.current=!0,te.current=g;return}if(ve.current){ve.current=!1,te.current=g;return}te.current!==g&&(ae(g,"push"),te.current=g)},[g,ae]),n.useEffect(()=>{const t=a=>{var m,x;const l=(x=(m=a.state)==null?void 0:m.__flatAgentNav)==null?void 0:x.agentId;if(!l||typeof l!="string"||!q.has(l)||l===g)return;ve.current=!0,ue.current=!0;const r=z.current,p=r.lastIndexOf(l);p>=0?H.current=p:(r.push(l),H.current=r.length-1),s(),f.selectAgent(l)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[q,g,s]),n.useEffect(()=>{if(!g){z.current=[],H.current=-1,s();return}if(Le.current=g,ue.current){ue.current=!1,s();return}const t=z.current,a=H.current;if(a>=0&&t[a]===g){s();return}const l=a<t.length-1?t.slice(0,a+1):t.slice();l.push(g),l.length>100&&l.shift(),z.current=l,H.current=l.length-1,s()},[g,s]);const pe=n.useCallback(t=>{_(t),Z(!1)},[_]),Ne=g??"",mt=n.useCallback(()=>{},[]),ft=n.useCallback(t=>{pe(t)},[pe]),ke=ze,D=n.useRef(null);n.useEffect(()=>{if(g)return;const t=a=>{if(a.key!==" "&&a.key!=="Backspace")return;const l=a.target;if(l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.isContentEditable)return;const r=Le.current;!r||!q.has(r)||(a.preventDefault(),f.selectAgent(r))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[g,q]);const[I,Oe]=n.useState(new Set),Lt=n.useCallback(t=>{Oe(a=>{const l=new Set(a);return l.has(t)?l.delete(t):l.add(t),l})},[]),ht=Pt(),et=zt(),[$t]=Yt(),Ie=n.useMemo(()=>{const t=new Map,a=[];for(const b of T){const C=f.getAreaForAgent(b.id);if(!At((C==null?void 0:C.id)??null))continue;if(!C||C.archived){a.push(b);continue}const v=t.get(C.id);v?v.push(b):t.set(C.id,[b])}const l=new Map,r=[];for(const b of et.values()){let C=!1;for(const v of ht.values())if(!v.archived&&St(v.id)&&f.isPositionInArea(b.position,v)){const K=l.get(v.id);K?K.push(b):l.set(v.id,[b]),C=!0;break}!C&&At(null)&&r.push(b)}const p=[];for(const[,b]of ht){if(b.archived||!St(b.id))continue;const C=t.get(b.id),v=l.get(b.id)??[];(C&&C.length>0||v.length>0)&&p.push({area:b,agents:C??[],buildings:v})}(a.length>0||r.length>0)&&p.push({area:{id:"__unassigned__",name:"Unassigned",color:"#6272a4",center:{x:0,z:0},type:"circle",radius:0,directories:[],archived:!1,assignedAgentIds:[],zIndex:0},agents:a,buildings:r});const m=p.filter(b=>b.area.id!=="__unassigned__"),x=p.filter(b=>b.area.id==="__unassigned__");let $=1,S=1;const Be=new Map;if(m.length>1){let b=1/0,C=-1/0,v=1/0,K=-1/0;for(const y of m)b=Math.min(b,y.area.center.x),C=Math.max(C,y.area.center.x),v=Math.min(v,y.area.center.z),K=Math.max(K,y.area.center.z);const tt=C-b||1,at=K-v||1;if(m.length<=4){$=m.length,S=1;const y=[...m].sort((M,gt)=>M.area.center.x-gt.area.center.x);for(let M=0;M<y.length;M++)Be.set(y[M].area.id,{row:1,col:M+1})}else{const y=[...m].sort((w,k)=>w.area.center.x-k.area.center.x),M=[];for(let w=1;w<y.length;w++)M.push(y[w].area.center.x-y[w-1].area.center.x);const gt=M.reduce((w,k)=>w+k,0)/M.length||1;let Ct=1;for(const w of M)w>gt*1.3&&Ct++;$=Math.max(2,Math.min(Ct,m.length));const bt=[...m].sort((w,k)=>w.area.center.z-k.area.center.z),nt=[];for(let w=1;w<bt.length;w++)nt.push(bt[w].area.center.z-bt[w-1].area.center.z);const Wt=nt.reduce((w,k)=>w+k,0)/nt.length||1;let jt=1;for(const w of nt)w>Wt*1.3&&jt++;S=Math.max(2,Math.min(jt,m.length)),$=Math.max($,Math.ceil(m.length/S)),S=Math.max(S,Math.ceil(m.length/$));const Ht=tt/$,Gt=at/S,xt=new Set;for(const w of m){let k=Math.min($-1,Math.max(0,Math.floor((w.area.center.x-b)/Ht))),fe=Math.min(S-1,Math.max(0,Math.floor((w.area.center.z-v)/Gt))),Fe=`${fe},${k}`,vt=0;const Vt=S*$;for(;xt.has(Fe)&&vt<Vt;)k++,k>=$&&(k=0,fe=(fe+1)%S),Fe=`${fe},${k}`,vt++;xt.has(Fe)&&(fe=S,k=0,Fe=`${fe},${k}`,S++),xt.add(Fe),Be.set(w.area.id,{row:fe+1,col:k+1})}}}const me=b=>{b.sort((C,v)=>{var tt,at,y,M;const K=(((tt=C.position)==null?void 0:tt.z)??0)-(((at=v.position)==null?void 0:at.z)??0);return K!==0?K:(((y=C.position)==null?void 0:y.x)??0)-(((M=v.position)==null?void 0:M.x)??0)})};for(const b of m)me(b.agents);for(const b of x)me(b.agents);return{groups:[...m,...x],gridCols:$,gridRows:S,positions:Be}},[T,ht,et,$t]),Ot=n.useMemo(()=>{if(!P)return[];const t=T.find(a=>a.id===P.agentId);return t?[{id:"edit-agent",label:"Edit Agent",icon:e.jsx(u,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:open-agent-edit",{detail:{agentId:t.id}}))}},{id:"open-chat",label:"Open Chat",icon:e.jsx(u,{name:"chat",size:14}),onClick:()=>_(t.id)},{id:"delete-agent",label:"Delete Agent",icon:e.jsx(u,{name:"trash",size:14}),danger:!0,onClick:()=>{se({agentId:t.id,name:t.name})}}]:[]},[P,T,_]),Bt=n.useMemo(()=>{var m;if(!G)return[];const t=et.get(G.buildingId);if(!t)return[];const a=[],l=t.type==="server"||t.type==="docker"||t.type==="terminal",r=t.status==="running",p=t.type==="boss";if(a.push({id:"open",label:t.type==="database"?"Open Database":t.type==="folder"?"Open Folder":t.type==="boss"?"View Boss Logs":t.type==="terminal"?"Open Terminal":t.type==="server"&&((m=t.pm2)!=null&&m.enabled)?"View PM2 Logs":"Open",icon:e.jsx(u,{name:t.type==="database"?"database":t.type==="folder"?"folder":t.type==="terminal"?"terminal":"eye",size:14}),onClick:()=>de(t.id)}),l&&(r||a.push({id:"start",label:"Start",icon:e.jsx(u,{name:"play",size:14}),onClick:()=>f.sendBuildingCommand(t.id,"start")}),r&&(a.push({id:"restart",label:"Restart",icon:e.jsx(u,{name:"refresh",size:14}),onClick:()=>f.sendBuildingCommand(t.id,"restart")}),a.push({id:"stop",label:"Stop",icon:e.jsx(u,{name:"stop",size:14}),onClick:()=>f.sendBuildingCommand(t.id,"stop")}))),p&&t.subordinateBuildingIds&&t.subordinateBuildingIds.length>0&&(a.push({id:"start-all",label:"Start All Subordinates",icon:e.jsx(u,{name:"launch",size:14}),onClick:()=>{for(const x of t.subordinateBuildingIds)f.sendBuildingCommand(x,"start")}}),a.push({id:"stop-all",label:"Stop All Subordinates",icon:e.jsx(u,{name:"pause",size:14}),onClick:()=>{for(const x of t.subordinateBuildingIds)f.sendBuildingCommand(x,"stop")}}),a.push({id:"restart-all",label:"Restart All Subordinates",icon:e.jsx(u,{name:"restart",size:14}),onClick:()=>{for(const x of t.subordinateBuildingIds)f.sendBuildingCommand(x,"restart")}})),l&&a.push({id:"health-check",label:"Health Check",icon:e.jsx(u,{name:"health",size:14}),onClick:()=>f.sendBuildingCommand(t.id,"healthCheck")}),a.push({id:"divider-edit",label:"",divider:!0,onClick:()=>{}}),a.push({id:"edit",label:"Edit Building",icon:e.jsx(u,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:building-edit",{detail:{buildingId:t.id}}))}}),a.push({id:"clone",label:"Clone Building",icon:e.jsx(u,{name:"copy",size:14}),onClick:()=>{f.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 x of t.urls)a.push({id:`url-${x.label}`,label:x.label,icon:e.jsx(u,{name:"link",size:14}),onClick:()=>window.open(x.url,"_blank","noopener,noreferrer")});return a.push({id:"divider-danger",label:"",divider:!0,onClick:()=>{}}),a.push({id:"delete",label:"Delete Building",icon:e.jsx(u,{name:"trash",size:14}),danger:!0,onClick:()=>f.deleteBuilding(t.id)}),a},[G,et,de]),Ft=n.useCallback(t=>{const a=new Set(Ie.groups.map(l=>l.area.id));a.delete(t),Oe(a),requestAnimationFrame(()=>{const l=D.current;if(!l)return;const r=l.querySelector(`[data-area-id="${t}"]`);if(!r)return;const p=l.getBoundingClientRect(),x=r.getBoundingClientRect().top-p.top+l.scrollTop-8;l.scrollTo({top:Math.max(0,x),behavior:"smooth"})})},[Ie]);return e.jsxs("div",{ref:J,className:`flat-view ${ke?"flat-view--with-inspector":""} ${g?"flat-view--has-chat":""} ${we?"flat-view--mobile-sidebar-open":""}`,style:(()=>{if(F===null&&W===null)return;const t={};return F!==null&&(t["--flat-middle-width"]=`${F}px`),W!==null&&(t["--flat-inspector-width"]=`${W}px`),t})(),children:[we&&e.jsx("div",{className:"flat-mobile-sidebar-backdrop",onClick:Xe,"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:B,title:"Create new agent",children:"+ Agent"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--boss",onClick:he,title:"Create new boss agent",children:"+ Boss"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--area",onClick:ne,title:"Create new area",children:"+ Area"})]})}),e.jsx("div",{className:"flat-middle__content",children:e.jsx(Zt,{activeAgentId:Ne,onClose:mt,onSelectAgent:ft,collapsedAreas:I,onToggleArea:Lt,agentListRef:D})})]}),e.jsx("div",{className:"flat-splitter flat-splitter--middle",role:"separator","aria-orientation":"vertical","aria-label":"Resize agents panel",title:"Drag to resize · Double-click to reset",onPointerDown:re,onPointerMove:Q,onPointerUp:ie,onPointerCancel:ie,onDoubleClick:ot}),e.jsxs("div",{className:"flat-right",children:[e.jsxs("button",{type:"button",className:"flat-mobile-sidebar-toggle","aria-label":we?"Close agents sidebar":"Open agents sidebar","aria-expanded":we,onClick:it,children:[e.jsx(u,{name:"list",size:18}),e.jsx("span",{className:"flat-mobile-sidebar-toggle__label",children:"Agents"})]}),g?e.jsx(za,{agentId:g,terminalViewMode:Ve,onTerminalViewModeChange:_e,inspectorOpen:ze,onToggleInspector:ut,onImageClick:ee,onFileClick:X,onBashClick:Re,onViewMarkdown:Ke,onRequestClearSubordinates:Ye,onOpenBuilding:de,keyboard:ce,canNavigateBack:Ze,canNavigateForward:Je,onNavigateBack:c,onNavigateForward:o,agentInfoOpen:xe,onToggleAgentInfo:Te}):e.jsx("div",{className:"flat-chat flat-chat--empty",children:e.jsxs("div",{className:"flat-map",children:[e.jsxs("div",{className:"flat-map__header",children:[e.jsx("span",{className:"flat-map__title",children:"🗺️ Areas"}),e.jsx("span",{className:"flat-map__hint",children:"Click an area to focus it, or an agent to chat"})]}),e.jsx("div",{className:"flat-map__grid",style:{gridTemplateColumns:`repeat(${Ie.gridCols}, 1fr)`},children:Ie.groups.length===0?e.jsx("div",{className:"flat-map__empty",children:e.jsx("span",{children:"No areas or agents yet"})}):Ie.groups.map(t=>{const a=t.area.id,l=Ie.positions.get(a);return e.jsxs("div",{className:"flat-map-area-card",style:{"--area-color":t.area.color,gridRow:l==null?void 0:l.row,gridColumn:l==null?void 0:l.col},children:[e.jsxs("button",{type:"button",className:"flat-map-area-card__header",onClick:()=>Ft(a),title:`Focus ${t.area.name} in left panel`,children:[e.jsx("span",{className:"flat-map-area-card__color",style:{background:t.area.color}}),e.jsx("span",{className:"flat-map-area-card__name",children:t.area.name}),e.jsx("span",{className:"flat-map-area-card__count",children:t.agents.length})]}),e.jsx("div",{className:"flat-map-area-card__agents",children:t.agents.map(r=>{const p=r.isBoss||r.class==="boss",m=p?Qe.get(r.id):void 0,x=Jt(r),$=x.usedPercent>=80?"#ff4a4a":x.usedPercent>=60?"#ff9e4a":x.usedPercent>=40?"#ffd700":"#4aff9e",S=`Context: ${(x.totalTokens/1e3).toFixed(1)}k / ${(x.contextWindow/1e3).toFixed(1)}k (${x.usedPercent}% used, ${x.freePercent}% free)`,Be=r.latestTodos&&r.latestTodos.length>0||m&&m.length>0;return e.jsx(Qt,{todos:r.latestTodos,subordinates:m,position:"top",children:e.jsxs("button",{type:"button",className:`flat-map-agent-chip ${r.status}`,onClick:()=>_(r.id),onContextMenu:me=>{me.preventDefault(),me.stopPropagation(),be({agentId:r.id,position:{x:me.clientX,y:me.clientY}})},title:Be?void 0:`${p?"Boss · ":""}Open chat with ${r.name}
2
- ${S}`,children:[e.jsx(Dt,{agent:r,size:16}),p&&e.jsx("span",{className:"flat-map-agent-chip__crown","aria-hidden":"true",children:e.jsx(u,{name:"crown",size:11,color:"#ffd700",weight:"fill"})}),e.jsx("span",{className:"flat-map-agent-chip__name",children:r.name}),e.jsx("img",{src:r.provider==="codex"?"/assets/codex.png":r.provider==="opencode"?"/assets/opencode.png":"/assets/claude.png",alt:r.provider,className:"flat-map-agent-chip__provider-icon",title:r.provider==="codex"?"Codex Agent":r.provider==="opencode"?"OpenCode Agent":"Claude Agent"}),e.jsx("span",{className:"flat-map-agent-chip__dot",style:{backgroundColor:Rt(r.status)}}),r.latestTodos&&r.latestTodos.length>0&&e.jsx(ea,{todos:r.latestTodos,maxDots:6}),p&&m&&m.length>0&&e.jsx(ta,{subordinates:m,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:`${x.usedPercent}%`,backgroundColor:$}})})]})},r.id)})}),t.buildings.length>0&&e.jsx("div",{className:"flat-map-area-card__buildings",children:t.buildings.map(r=>e.jsxs("button",{type:"button",className:`flat-map-building-chip flat-map-building-chip--${r.status}`,onClick:p=>{if(E){const m=p.currentTarget.getBoundingClientRect();E(r.id,{x:m.right,y:m.top+m.height/2})}else de(r.id)},onContextMenu:p=>{p.preventDefault(),p.stopPropagation(),h({buildingId:r.id,position:{x:p.clientX,y:p.clientY}})},title:`${r.name} · ${r.type} · ${r.status}`,children:[e.jsx(u,{name:aa(r.type),size:12}),e.jsx("span",{className:"flat-map-building-chip__name",children:r.name}),e.jsx("span",{className:"flat-map-building-chip__dot",style:{backgroundColor:na(r.status)}})]},r.id))})]},a)})})]})})]}),ke&&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:Ue,onPointerMove:Q,onPointerUp:ie,onPointerCancel:ie,onDoubleClick:ct}),ke&&e.jsxs("aside",{className:"flat-inspector","aria-label":"Inspector panel",children:[e.jsxs("div",{className:"flat-inspector__header",children:[e.jsxs("div",{className:"flat-inspector__tabs",role:"tablist","aria-label":"Inspector view",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":oe==="agent",className:`flat-inspector__tab ${oe==="agent"?"flat-inspector__tab--active":""}`,onClick:()=>qe("agent"),children:"Agent"}),e.jsx("button",{type:"button",role:"tab","aria-selected":oe==="tracking",className:`flat-inspector__tab ${oe==="tracking"?"flat-inspector__tab--active":""}`,onClick:()=>qe("tracking"),children:"Tracking"})]}),e.jsx("button",{type:"button",className:"flat-inspector__close",onClick:pt,title:"Close inspector","aria-label":"Close inspector",children:"✕"})]}),e.jsx("div",{className:"flat-inspector__body",children:oe==="tracking"?e.jsx(sa,{activeAgentId:g??"",onSelectAgent:t=>_(t)}):(()=>{if(!g)return e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Select an agent to inspect"})});const t=T.find(a=>a.id===g);return t?e.jsx(la,{agent:t,onFocusAgent:a=>_(a),onKillAgent:a=>f.killAgent(a)}):e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Agent not found"})})})()})]}),ye&&e.jsx(ra,{url:ye.url,name:ye.name,onClose:()=>Me(null)}),We&&e.jsx(ia,{state:We,onClose:()=>He(null)}),Ee&&e.jsx(oa,{action:"clear-subordinates",selectedAgentId:Ee.agentId,subordinateCount:Ee.count,onClose:()=>Y(null),onClearHistory:()=>{}}),e.jsx(ca,{agent:g?T.find(t=>t.id===g)??null:null,isOpen:xe&&!!g,onClose:Ge}),e.jsx(yt,{isOpen:P!==null,position:(P==null?void 0:P.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:Ot,onClose:()=>be(null)}),e.jsx(yt,{isOpen:G!==null,position:(G==null?void 0:G.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:Bt,onClose:()=>h(null)}),e.jsx(da,{isOpen:A!==null,title:ge("common:confirm.removeAgentTitle"),message:ge("common:confirm.removeAgentMessage",{name:(A==null?void 0:A.name)??""}),confirmLabel:ge("common:buttons.remove"),cancelLabel:ge("common:buttons.cancel"),variant:"danger",onConfirm:()=>{A&&f.removeAgentFromServer(A.agentId)},onClose:()=>se(null)})]})}export{$a as FlatView};
@@ -1 +0,0 @@
1
- import{r as c,aP as Pe,aQ as ze,j as e,I as L,u as se,aR as Ve,_ as qe,f as De,s as k,aS as Ge,k as He,l as re,aT as W,aU as Ye,aI as Je,aV as Ze,C as fe,aW as ae,aF as Ne,aX as Xe,aY as Qe,aZ as es,a_ as ss,a$ as Me,b0 as as,b1 as ts,b2 as _e,b3 as ns,b4 as os,b5 as is,b6 as ls,b7 as cs,b8 as rs,b9 as ds,aB as ms,E as us,S as ye,ba as ps,bb as gs,aD as hs,bc as Le,G as Ae,aM as fs,bd as Fe,be as xs}from"./main-CHfGSVnw.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const $e="deivid11/tide-commander",bs=`https://api.github.com/repos/${$e}/releases/latest`,js=`https://api.github.com/repos/${$e}/releases?per_page=3`,vs=3600*1e3,Ue="app_update_dismissed_version",Re="1.83.0";function ys(){var y,S;const[s,i]=c.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:Re}),a=((S=(y=Pe)==null?void 0:y.getPlatform)==null?void 0:S.call(y))==="android"||!1,o=u=>u.replace(/^v/,"").split(".").map(p=>parseInt(p,10)||0),m=(u,h)=>{const p=o(u),N=o(h),x=Math.max(p.length,N.length);for(let r=0;r<x;r++){const F=p[r]||0,R=N[r]||0;if(F>R)return 1;if(F<R)return-1}return 0},f=async u=>{var p,N;if(Pe&&ze&&((N=(p=Pe).isNativePlatform)==null?void 0:N.call(p))===!0){const x=await ze.get({url:u,headers:{Accept:"application/vnd.github.v3+json"}});return{data:x.data,status:x.status}}else{const x=await fetch(u,{headers:{Accept:"application/vnd.github.v3+json"}});return x.ok?{data:await x.json(),status:x.status}:{data:null,status:x.status}}},d=c.useCallback(async(u=!1)=>{i(h=>({...h,isChecking:!0,error:null}));try{const[h,p]=await Promise.all([f(bs),f(js)]);if(h.status!==200)throw new Error(`GitHub API error: ${h.status}`);const N=h.data,x=N.tag_name;let r=[];p.status===200&&p.data&&(r=p.data.map(C=>({version:C.tag_name,name:C.name,publishedAt:C.published_at,releaseUrl:C.html_url})));const F=localStorage.getItem(Ue);if(!u&&F===x)return i(C=>({...C,isChecking:!1,updateAvailable:!1,recentReleases:r})),null;if(!(m(x,Re)>0))return i(C=>({...C,isChecking:!1,updateAvailable:!1,recentReleases:r})),null;const $=N.assets.find(C=>C.name.endsWith(".apk")&&C.content_type==="application/vnd.android.package-archive"),v={version:x,name:N.name,changelog:N.body,releaseUrl:N.html_url,apkUrl:($==null?void 0:$.browser_download_url)||null,apkSize:($==null?void 0:$.size)||null,publishedAt:N.published_at};return i(C=>({...C,isChecking:!1,updateAvailable:!0,updateInfo:v,recentReleases:r})),v}catch(h){const p=h instanceof Error?h.message:"Failed to check for updates";return i(N=>({...N,isChecking:!1,error:p})),null}},[]),n=c.useCallback(async()=>{var u,h,p;if(!((u=s.updateInfo)!=null&&u.apkUrl)){(h=s.updateInfo)!=null&&h.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!a){(p=s.updateInfo)!=null&&p.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),i(N=>({...N,error:null}))}catch(N){const x=N instanceof Error?N.message:"Failed to open download";i(r=>({...r,error:x}))}},[s.updateInfo,a]),g=c.useCallback(()=>{s.updateInfo&&localStorage.setItem(Ue,s.updateInfo.version),i(u=>({...u,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),T=c.useCallback(()=>{var u;(u=s.updateInfo)!=null&&u.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${$e}/releases`,"_blank")},[s.updateInfo]);return c.useEffect(()=>{if(!a)return;const u=setTimeout(()=>{d()},5e3),h=setInterval(()=>{d()},vs);return()=>{clearTimeout(u),clearInterval(h)}},[a,d]),{...s,isAndroid:a,checkForUpdate:d,downloadAndInstall:n,dismissUpdate:g,openReleasePage:T}}const We="tide-toolbox-collapse";function Ns(s,i){try{const a=localStorage.getItem(`${We}-${s}`);if(a!==null)return a==="true"}catch{}return i}function ws(s,i){try{localStorage.setItem(`${We}-${s}`,String(i))}catch{}}function U({title:s,storageKey:i,defaultOpen:a=!1,forceOpen:o=!1,children:m,headerExtra:f}){const[d,n]=c.useState(()=>i?Ns(i,a):a),g=()=>{const y=!d;n(y),i&&ws(i,y)},T=o||d;return e.jsxs("div",{className:`collapsible-section ${T?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:g,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[f,e.jsx("span",{className:"collapsible-arrow",children:e.jsx(L,{name:T?"caret-down":"caret-right",size:10})})]})]}),T&&e.jsx("div",{className:"collapsible-content",children:m})]})}function ks({area:s,isSelected:i,onClick:a,onDelete:o}){const{t:m}=se(["config","common"]),f=s.assignedAgentIds.length,d=s.type==="rectangle"?m("config:areas.rect"):m("config:areas.circle");return e.jsxs("div",{className:`area-item ${i?"selected":""}`,onClick:a,children:[e.jsx("div",{className:"area-color-dot",style:{backgroundColor:s.color}}),e.jsxs("div",{className:"area-info",children:[e.jsx("div",{className:"area-name",children:s.name}),e.jsxs("div",{className:"area-meta",children:[d," ",f>0&&`• ${f} ${f>1?m("common:labels.agents").toLowerCase():m("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:o,title:m("config:areas.deleteArea"),children:"×"})]})}function Ss({building:s,isSelected:i,onClick:a,onEdit:o}){var n;const{t:m}=se(["config"]),f=((n=s.pm2Status)==null?void 0:n.ports)||[],d=(g,T)=>{g.stopPropagation(),window.open(`http://${window.location.hostname}:${T}`,"_blank")};return e.jsxs("div",{className:`building-item ${i?"selected":""}`,onClick:a,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:Ve[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx(L,{name:qe(s.type),size:16})}),e.jsxs("div",{className:"building-info",children:[e.jsx("div",{className:"building-name",children:s.name}),e.jsxs("div",{className:"building-meta",children:[s.type,f.length>0&&e.jsx("span",{className:"building-ports",children:f.map(g=>e.jsxs("a",{href:`http://${window.location.hostname}:${g}`,className:"building-port-link",onClick:T=>d(T,g),title:`Open :${g}`,children:[":",g]},g))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:g=>{g.stopPropagation(),o()},title:m("config:buildings.editBuilding"),children:e.jsx(L,{name:"gear",size:14})})]})}function Cs({building:s,onClose:i,onOpenModal:a}){var T,y,S,u,h,p,N,x;const{t:o}=se(["config","common"]),{buildingLogs:m}=De(),f=k.getBuildingLogs(s.id),d=Ge[s.style||"server-rack"],n=r=>{k.sendBuildingCommand(s.id,r)},g=r=>{window.open(r,"_blank")};return e.jsxs("div",{className:"building-editor",children:[e.jsxs("div",{className:"building-editor-header",children:[e.jsxs("div",{className:"building-editor-title-row",children:[e.jsx("span",{className:"building-editor-icon",children:e.jsx(L,{name:qe(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:Ve[s.status]},children:s.status})]}),e.jsx("button",{className:"building-editor-close",onClick:i,children:"×"})]}),e.jsx("div",{className:"building-editor-section",children:e.jsxs("div",{className:"building-editor-info-grid",children:[e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("common:labels.type")}),e.jsx("span",{className:"building-editor-info-value",children:s.type})]}),e.jsxs("div",{className:"building-editor-info-item",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.style")}),e.jsx("span",{className:"building-editor-info-value",children:d.label})]}),s.cwd&&e.jsxs("div",{className:"building-editor-info-item building-editor-info-wide",children:[e.jsx("span",{className:"building-editor-info-label",children:o("config:buildings.directory")}),e.jsx("span",{className:"building-editor-info-value building-editor-cwd",title:s.cwd,children:s.cwd.split("/").pop()||s.cwd})]})]})}),s.type==="server"&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.actions")}),e.jsxs("div",{className:"building-editor-actions",children:[e.jsxs("button",{className:"building-editor-action-btn start",onClick:()=>n("start"),disabled:!((T=s.commands)!=null&&T.start)||s.status==="running",title:((y=s.commands)==null?void 0:y.start)||o("config:buildings.noStartCommand"),children:[e.jsx(L,{name:"play",size:12})," ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>n("stop"),disabled:!((S=s.commands)!=null&&S.stop)||s.status==="stopped",title:((u=s.commands)==null?void 0:u.stop)||o("config:buildings.noStopCommand"),children:[e.jsx(L,{name:"stop",size:12,weight:"fill"})," ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>n("restart"),disabled:!((h=s.commands)!=null&&h.restart),title:((p=s.commands)==null?void 0:p.restart)||o("config:buildings.noRestartCommand"),children:[e.jsx(L,{name:"refresh",size:12})," ",o("common:buttons.retry")]}),e.jsxs("button",{className:"building-editor-action-btn health",onClick:()=>n("healthCheck"),disabled:!((N=s.commands)!=null&&N.healthCheck),title:((x=s.commands)==null?void 0:x.healthCheck)||o("config:buildings.noHealthCheck"),children:[e.jsx(L,{name:"heart",size:12})," Health"]})]})]}),s.urls&&s.urls.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((r,F)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>g(r.url),title:r.url,children:[e.jsx(L,{name:"link",size:12})," ",r.label||r.url]},F))})]}),f.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsxs("div",{className:"building-editor-section-title",children:[o("config:buildings.recentLogs"),e.jsx("button",{className:"building-editor-clear-logs",onClick:()=>k.clearBuildingLogs(s.id),title:o("common:buttons.clear"),children:o("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:f.slice(-5).map((r,F)=>e.jsx("div",{className:"building-editor-log-entry",children:r},F))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:a,children:[e.jsx(L,{name:"gear",size:12})," ",o("config:buildings.fullSettings")]})})]})}async function As(s,i){const a=W(),o=await fetch(re(`/api/areas/${s}/logo`),{method:"POST",headers:{"Content-Type":i.type||"image/png","X-Filename":encodeURIComponent(i.name),...a?{Authorization:`Bearer ${a}`}:{}},body:i});if(!o.ok){const m=await o.json().catch(()=>({error:o.statusText}));throw new Error(m.error||`Upload failed: ${o.statusText}`)}return o.json()}async function Ts(s){const i=W(),a=await fetch(re(`/api/areas/${s}/logo`),{method:"DELETE",headers:{...i?{Authorization:`Bearer ${i}`}:{}}});if(!a.ok)throw new Error(`Failed to delete logo: ${a.statusText}`)}function Is(s){return He(re(`/api/areas/logos/${s}`))}const Es=[{key:"center",labelKey:"posCenter"},{key:"top-left",labelKey:"posTopLeft"},{key:"top-right",labelKey:"posTopRight"},{key:"bottom-left",labelKey:"posBottomLeft"},{key:"bottom-right",labelKey:"posBottomRight"}];function Ps({area:s,onClose:i,onOpenFolder:a}){var ne;const{t:o}=se(["config","common"]),[m,f]=c.useState(s.name),[d,n]=c.useState(s.prompt||""),[g,T]=c.useState(!1),[y,S]=c.useState(""),[u,h]=c.useState(!1),p=c.useRef(null);c.useEffect(()=>{f(s.name)},[s.id,s.name]),c.useEffect(()=>{n(s.prompt||"")},[s.id,s.prompt]);const N=b=>{const E=b.target.value;f(E),k.updateArea(s.id,{name:E})},x=b=>{k.updateArea(s.id,{color:b})},r=b=>{const E=b.target.value;n(E),k.updateArea(s.id,{prompt:E})},F=()=>{y.trim()&&(k.addDirectoryToArea(s.id,y.trim()),S(""),T(!1))},R=(b,E)=>{E.stopPropagation(),k.removeDirectoryFromArea(s.id,b)},$=()=>{k.bringAreaToFront(s.id)},v=()=>{k.sendAreaToBack(s.id)},C=c.useCallback(()=>{let b=2,E=2;s.type==="rectangle"&&s.width&&s.height?(b=s.width,E=s.height):s.type==="circle"&&s.radius&&(b=s.radius*1.414,E=s.radius*1.414);const z=Math.min(b,E)*.4;return{width:Math.round(z*10)/10,height:Math.round(z*10)/10}},[s.type,s.width,s.height,s.radius]),M=async b=>{var z;const E=(z=b.target.files)==null?void 0:z[0];if(E){h(!0);try{const j=await As(s.id,E),P=C();k.updateArea(s.id,{logo:{filename:j.filename,position:"center",width:P.width,height:P.height,keepAspectRatio:!0,opacity:.8}})}catch(j){console.error("Failed to upload logo:",j)}finally{h(!1),p.current&&(p.current.value="")}}},K=async()=>{try{await Ts(s.id),k.updateArea(s.id,{logo:void 0})}catch(b){console.error("Failed to remove logo:",b)}},G=b=>{s.logo&&k.updateArea(s.id,{logo:{...s.logo,position:b}})},V=b=>{if(!s.logo)return;const E=parseFloat(b.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const z=s.logo.height/s.logo.width;k.updateArea(s.id,{logo:{...s.logo,width:E,height:Math.round(E*z*10)/10}})}else k.updateArea(s.id,{logo:{...s.logo,width:E}})},O=b=>{if(!s.logo)return;const E=parseFloat(b.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const z=s.logo.width/s.logo.height;k.updateArea(s.id,{logo:{...s.logo,height:E,width:Math.round(E*z*10)/10}})}else k.updateArea(s.id,{logo:{...s.logo,height:E}})},q=()=>{s.logo&&k.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},ee=b=>{s.logo&&k.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(b.target.value)}})};return e.jsxs("div",{className:"area-editor",children:[e.jsxs("div",{className:"area-editor-header",children:[e.jsx("span",{className:"area-editor-title",children:o("config:areas.editArea")}),e.jsx("button",{className:"area-editor-close",onClick:i,children:"×"})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("common:labels.name")}),e.jsx("input",{type:"text",className:"area-editor-input",value:m,onChange:N,placeholder:o("config:areas.areaName")})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.color")}),e.jsx("div",{className:"color-picker-row",children:Ye.map(b=>e.jsx("div",{className:`color-swatch ${s.color===b?"selected":""}`,style:{backgroundColor:b},onClick:()=>x(b)},b))})]}),e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.layer")}),e.jsxs("div",{className:"area-layer-buttons",children:[e.jsxs("button",{className:"area-layer-btn",onClick:$,title:o("config:areas.bringToFront"),children:[e.jsx(L,{name:"arrow-up",size:12})," ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:v,title:o("config:areas.sendToBack"),children:[e.jsx(L,{name:"arrow-down",size:12})," ",o("config:areas.back")]})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.logo")}),e.jsxs("div",{className:"area-logo-section",children:[(ne=s.logo)!=null&&ne.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:Is(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:K,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var b;return(b=p.current)==null?void 0:b.click()},disabled:u,children:u?"...":e.jsx(L,{name:"refresh",size:12})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:Es.map(({key:b,labelKey:E})=>{var z;return e.jsx("button",{className:`area-logo-pos-btn ${((z=s.logo)==null?void 0:z.position)===b?"active":""}`,onClick:()=>G(b),children:o(`config:areas.${E}`)},b)})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoSize")}),e.jsxs("div",{className:"area-logo-size-row",children:[e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoWidth")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.width,onChange:V,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-size-field",children:[e.jsx("span",{children:o("config:areas.logoHeight")}),e.jsx("input",{type:"number",className:"area-logo-size-input",value:s.logo.height,onChange:O,min:.1,step:.1})]}),e.jsxs("label",{className:"area-logo-aspect-label",title:o("config:areas.keepAspectRatio"),children:[e.jsx("input",{type:"checkbox",checked:s.logo.keepAspectRatio,onChange:q}),o("config:areas.keepAspectRatio")]})]})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoOpacity")}),e.jsxs("div",{className:"area-logo-opacity-row",children:[e.jsx("input",{type:"range",min:0,max:1,step:.05,value:s.logo.opacity??.8,onChange:ee,className:"area-logo-opacity-slider"}),e.jsxs("span",{className:"area-logo-opacity-value",children:[Math.round((s.logo.opacity??.8)*100),"%"]})]})]})]}):e.jsx("button",{className:"area-logo-upload-btn",onClick:()=>{var b;return(b=p.current)==null?void 0:b.click()},disabled:u,children:u?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:p,type:"file",accept:"image/*",style:{display:"none"},onChange:M})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.folders",{count:s.directories.length})}),e.jsxs("div",{className:"area-folders-list",children:[s.directories.map(b=>e.jsxs("div",{className:"area-folder-item",title:b,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>a==null?void 0:a(s.id),title:o("config:areas.openFolder"),children:e.jsx(L,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:b.split("/").pop()||b}),e.jsx("button",{className:"area-folder-remove",onClick:E=>R(b,E),title:o("config:areas.removeFolder"),children:"×"})]},b)),g?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(Je,{value:y,onChange:S,onSubmit:F,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:F,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>T(!0),children:o("config:areas.addFolder")})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.prompt","Prompt")}),e.jsx("textarea",{className:"area-editor-input",value:d,onChange:r,placeholder:o("config:areas.promptPlaceholder","System prompt for agents in this area..."),rows:4,style:{resize:"vertical",fontFamily:"monospace",fontSize:12}}),e.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4},children:o("config:areas.promptHint","This prompt is injected into agents assigned to this area. Takes effect on next context refresh.")})]}),s.assignedAgentIds.length>0&&e.jsxs("div",{className:"area-editor-row",children:[e.jsx("div",{className:"area-editor-label",children:o("config:areas.assignedAgents",{count:s.assignedAgentIds.length})}),e.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:o("config:areas.rightClickUnassign")})]})]})}function Ls(){const{t:s}=se(["config","common"]),i=Ze(),[a,o]=c.useState(!1),[m,f]=c.useState(null),[d,n]=c.useState({name:"",key:"",value:"",description:""}),[g,T]=c.useState(null),y=()=>{o(!0),f(null),n({name:"",key:"",value:"",description:""})},S=r=>{f(r.id),o(!1),n({name:r.name,key:r.key,value:r.value,description:r.description||""})},u=()=>{o(!1),f(null),n({name:"",key:"",value:"",description:""})},h=()=>{!d.name.trim()||!d.key.trim()||(m?k.updateSecret(m,{name:d.name.trim(),key:d.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:d.value,description:d.description.trim()||void 0}):k.createSecret({name:d.name.trim(),key:d.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:d.value,description:d.description.trim()||void 0}),u())},p=r=>{T(r)},N=()=>{g&&(k.deleteSecret(g),m===g&&u())},x=r=>{navigator.clipboard.writeText(`{{${r}}}`)};return e.jsxs("div",{className:"secrets-section",children:[e.jsx("div",{className:"secrets-description",children:s("config:secrets.description",{placeholder:"{{KEY}}"})}),e.jsx("div",{className:"secrets-list",children:i.length===0&&!a?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):i.map(r=>e.jsxs("div",{className:`secret-item ${m===r.id?"editing":""}`,children:[e.jsxs("div",{className:"secret-item-header",children:[e.jsxs("div",{className:"secret-item-info",children:[e.jsx("span",{className:"secret-item-name",children:r.name}),e.jsx("code",{className:"secret-item-key",onClick:()=>x(r.key),title:s("config:secrets.copyPlaceholder"),children:`{{${r.key}}}`})]}),e.jsxs("div",{className:"secret-item-actions",children:[e.jsx("button",{className:"secret-item-btn edit",onClick:()=>S(r),title:s("common:buttons.edit"),children:e.jsx(L,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>p(r.id),title:s("common:buttons.delete"),children:"×"})]})]}),r.description&&e.jsx("div",{className:"secret-item-description",children:r.description})]},r.id))}),(a||m)&&e.jsxs("div",{className:"secret-form",children:[e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.name")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.namePlaceholder"),value:d.name,onChange:r=>n({...d,name:r.target.value}),autoFocus:!0})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:"Key"}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.keyPlaceholder"),value:d.key,onChange:r=>n({...d,key:r.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${d.key||"KEY"}}}`})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("config:secrets.secretValue")}),e.jsx("input",{type:"password",className:"secret-form-input",placeholder:s("config:secrets.valuePlaceholder"),value:d.value,onChange:r=>n({...d,value:r.target.value})})]}),e.jsxs("div",{className:"secret-form-row",children:[e.jsx("label",{className:"secret-form-label",children:s("common:labels.description")}),e.jsx("input",{type:"text",className:"secret-form-input",placeholder:s("config:secrets.descriptionPlaceholder"),value:d.description,onChange:r=>n({...d,description:r.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:u,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:h,disabled:!d.name.trim()||!d.key.trim(),children:s(m?"config:secrets.update":"common:buttons.add")})]})]}),!a&&!m&&e.jsx("button",{className:"secrets-add-btn",onClick:y,children:s("config:secrets.addSecret")}),e.jsx(fe,{isOpen:g!==null,title:s("common:buttons.delete"),message:s("config:secrets.deleteConfirm"),confirmLabel:s("common:buttons.delete"),cancelLabel:s("common:buttons.cancel"),variant:"danger",onConfirm:N,onClose:()=>T(null)})]})}async function Fs(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch system prompt: ${i.statusText}`);return(await i.json()).prompt||""}async function Os(s){const i=W(),a=await fetch(`${ae()}/api/agents/system-settings/prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({prompt:s})});if(!a.ok)throw new Error(`Failed to update system prompt: ${a.statusText}`)}async function Ds(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/prompt`,{method:"DELETE",headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to clear system prompt: ${i.statusText}`)}async function $s(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/echo-prompt`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch echo prompt setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function zs(s){const i=W(),a=await fetch(`${ae()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!a.ok)throw new Error(`Failed to update echo prompt setting: ${a.statusText}`)}async function _s(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/codex-binary`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch codex binary path: ${i.statusText}`);return(await i.json()).path||""}async function Us(s){const i=W(),a=await fetch(`${ae()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({path:s})});if(!a.ok)throw new Error(`Failed to update codex binary path: ${a.statusText}`)}async function Rs(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/tmux-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch tmux mode setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function Bs(s){const i=W(),a=await fetch(`${ae()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!a.ok)throw new Error(`Failed to update tmux mode setting: ${a.statusText}`)}async function Ks(){const s=W(),i=await fetch(`${ae()}/api/agents/system-settings/backup`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch backup status: ${i.statusText}`);return i.json()}async function Vs(s){const i=W(),a=await fetch(`${ae()}/api/agents/system-settings/backup`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.error||`Failed to update backup setting: ${a.statusText}`)}return a.json()}function qs({checked:s,onChange:i,disabled:a}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,disabled:a,onChange:o=>i(o.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function Ms(){const{t:s}=se(["config","common"]),[i,a]=c.useState([]),[o,m]=c.useState(new Set),[f,d]=c.useState(new Set),[n,g]=c.useState(!1),[T,y]=c.useState(!1),[S,u]=c.useState(null),[h,p]=c.useState(null),[N,x]=c.useState(null),[r,F]=c.useState(null),[R,$]=c.useState(!1),[v,C]=c.useState(null);c.useEffect(()=>{Ne(re("/api/config/categories")).then(j=>j.json()).then(j=>{const P=Array.isArray(j)?j:[];a(P),m(new Set(P.map(D=>D.id)))}).catch(j=>console.error("Failed to fetch config categories:",j))},[]),c.useEffect(()=>{Ks().then(F).catch(j=>{console.error("Failed to fetch backup status:",j),C(j.message||"Failed to fetch backup status")})},[]);const M=async j=>{if(!R){$(!0),C(null);try{const P=await Vs(j);F(P)}catch(P){C(P.message||"Failed to update backup setting")}finally{$(!1)}}},K=j=>{m(P=>{const D=new Set(P);return D.has(j)?D.delete(j):D.add(j),D})},G=j=>{d(P=>{const D=new Set(P);return D.has(j)?D.delete(j):D.add(j),D})},V=()=>m(new Set(i.map(j=>j.id))),O=()=>m(new Set),q=()=>{h&&d(new Set(h.categories.map(j=>j.id)))},ee=()=>d(new Set),ne=async()=>{var j;if(o.size!==0){g(!0),x(null);try{const P=Array.from(o).join(","),D=await Ne(re(`/api/config/export?categories=${P}`));if(!D.ok)throw new Error("Export failed");const Y=await D.blob(),J=window.URL.createObjectURL(Y),Z=document.createElement("a");Z.href=J;const H=D.headers.get("Content-Disposition"),xe=((j=H==null?void 0:H.match(/filename="(.+)"/))==null?void 0:j[1])||"tide-commander-config.zip";Z.download=xe,document.body.appendChild(Z),Z.click(),document.body.removeChild(Z),window.URL.revokeObjectURL(J),x({type:"success",text:s("config:data.exportSuccess")})}catch(P){x({type:"error",text:P.message||"Export failed"})}finally{g(!1)}}},b=async j=>{var D;const P=(D=j.target.files)==null?void 0:D[0];if(P){u(P),x(null),p(null),d(new Set);try{const Y=await Ne(re("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await P.arrayBuffer()});if(!Y.ok){const H=await Y.json();throw new Error(H.error||"Failed to preview config file")}const J=await Y.json(),Z=Array.isArray(J.categories)?J.categories:[];p({...J,categories:Z}),d(new Set(Z.map(H=>H.id)))}catch(Y){x({type:"error",text:Y.message||"Failed to read config file"}),u(null)}}},E=async()=>{if(!(!S||f.size===0)){y(!0),x(null);try{const j=Array.from(f).join(","),P=await Ne(re(`/api/config/import?categories=${j}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await S.arrayBuffer()}),D=await P.json();if(!P.ok)throw new Error(D.error||"Import failed");x({type:"success",text:D.message||s("config:data.importSuccess")}),u(null),p(null),d(new Set)}catch(j){x({type:"error",text:j.message||"Import failed"})}finally{y(!1)}}},z=()=>{u(null),p(null),d(new Set),x(null)};return e.jsxs("div",{className:"data-section",children:[N&&e.jsx("div",{className:`data-message data-message-${N.type}`,children:N.text}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:"Hourly Backups"}),e.jsx(qs,{checked:!!(r!=null&&r.enabled),disabled:R||!r,onChange:M})]}),e.jsxs("div",{className:"data-backup-info",children:[r?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Saves a compressed snapshot of your data every hour to"," ",e.jsx("code",{children:r.backupDir}),". Identical snapshots are skipped. Keeps the 8 newest plus one from each of the 2 most recent prior days."]}),!r.scriptExists&&e.jsxs("div",{style:{marginTop:6,color:"var(--dracula-red, #ff5555)"},children:["Backup script not found at ",e.jsx("code",{children:r.scriptPath})]}),r.lastRunAt&&e.jsxs("div",{style:{marginTop:6},children:["Last run: ",new Date(r.lastRunAt).toLocaleString(),r.lastRunOk===!0&&" — ok",r.lastRunOk===!1&&r.lastRunError&&e.jsxs("span",{style:{color:"var(--dracula-red, #ff5555)"},children:[" — ",r.lastRunError]})]})]}):e.jsx("div",{children:"Loading backup status…"}),v&&e.jsx("div",{className:"data-message data-message-error",style:{marginTop:6},children:v})]})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:s("config:data.exportData")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:V,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:O,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:i.map(j=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(j.id),onChange:()=>K(j.id)}),e.jsx("span",{className:"data-category-name",children:j.name})]},j.id))}),e.jsx("button",{className:"data-action-btn export",onClick:ne,disabled:n||o.size===0,children:n?s("config:data.exporting"):s("config:data.exportCount",{count:o.size})})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsx("div",{className:"data-subsection-header",children:e.jsx("span",{className:"data-subsection-title",children:s("config:data.importData")})}),S?h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:S.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(h.exportedAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-subtitle",children:s("config:data.selectToImport")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:q,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:ee,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:h.categories.map(j=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:f.has(j.id),onChange:()=>G(j.id)}),e.jsx("span",{className:"data-category-name",children:j.name}),j.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",j.fileCount," ",s("config:data.files"),")"]})]},j.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:z,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:E,disabled:T||f.size===0,children:T?s("config:data.importing"):s("config:data.importCount",{count:f.size})})]})]}):e.jsx("div",{className:"data-loading",children:s("config:data.readingFile")}):e.jsxs("label",{className:"data-file-input",children:[e.jsx("input",{type:"file",accept:".zip",onChange:b,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}function Ws(){const[s,i]=c.useState(()=>Xe()),a=o=>{i(o);const m=es(o);ss(m)};return e.jsx("div",{className:"theme-selector",children:e.jsx("div",{className:"theme-selector-grid",children:Qe.map(o=>e.jsxs("button",{className:`theme-option ${s===o.id?"active":""}`,onClick:()=>a(o.id),title:o.description,children:[e.jsx("div",{className:"theme-preview",children:e.jsxs("div",{className:"theme-preview-bg",style:{backgroundColor:o.colors.bgPrimary},children:[e.jsx("div",{className:"theme-preview-accent",style:{backgroundColor:o.colors.accentBlue}}),e.jsx("div",{className:"theme-preview-claude",style:{backgroundColor:o.colors.accentClaude}})]})}),e.jsx("span",{className:"theme-name",children:o.name})]},o.id))})})}function Gs(){const{t:s}=se(["config"]),{updateAvailable:i,updateInfo:a,recentReleases:o,isChecking:m,error:f,currentVersion:d,isAndroid:n,checkForUpdate:g,downloadAndInstall:T,openReleasePage:y}=ys(),S=h=>h?`${(h/(1024*1024)).toFixed(1)} MB`:"",u=h=>new Date(h).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"});return e.jsxs("div",{className:"about-section",children:[e.jsxs("div",{className:"about-logo",children:[e.jsx("span",{className:"about-logo-icon",children:e.jsx(L,{name:"waves",size:24})}),e.jsx("span",{className:"about-logo-text",children:"Tide Commander"})]}),e.jsxs("div",{className:"about-version",children:[e.jsx("span",{className:"about-version-label",children:s("config:about.version")}),e.jsxs("div",{className:"about-version-info",children:[e.jsx("span",{className:"about-version-value",children:d}),i&&a?e.jsx("span",{className:"about-version-update-badge",onClick:y,title:`Update available: ${a.version}`,children:a.version}):e.jsxs("a",{href:"https://github.com/deivid11/tide-commander/releases",target:"_blank",rel:"noopener noreferrer",className:"about-version-status",children:["(",s("config:about.updated"),")"]})]})]}),e.jsxs("div",{className:"about-update",children:[i&&a?e.jsxs("div",{className:"about-update-available",children:[e.jsxs("div",{className:"about-update-header",children:[e.jsx("span",{className:"about-update-badge",children:s("config:about.updateAvailable")}),e.jsx("span",{className:"about-update-version",children:a.version})]}),a.apkSize&&e.jsxs("div",{className:"about-update-size",children:[s("config:about.sizeLabel"),": ",S(a.apkSize)]}),f&&e.jsx("div",{className:"about-update-error",children:f}),e.jsxs("div",{className:"about-update-actions",children:[e.jsx("button",{className:"about-update-btn changelog",onClick:y,children:s("config:about.changelog")}),n&&a.apkUrl?e.jsx("button",{className:"about-update-btn download",onClick:T,children:s("config:about.downloadAPK")}):e.jsx("button",{className:"about-update-btn download",onClick:y,children:s("config:about.viewRelease")})]})]}):e.jsxs("div",{className:"about-update-check",children:[e.jsx("span",{className:"about-update-status",children:s(m?"config:about.checkingUpdates":"config:about.upToDate")}),e.jsx("button",{className:"about-update-btn check",onClick:()=>g(!0),disabled:m,children:m?"...":s("config:about.check")})]}),o.length>0&&e.jsxs("div",{className:"about-releases",children:[e.jsx("div",{className:"about-releases-title",children:s("config:about.recentReleases")}),e.jsx("div",{className:"about-releases-list",children:o.map(h=>e.jsxs("a",{href:h.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:`about-release-item ${h.version===`v${d}`||h.version===d?"current":""}`,children:[e.jsx("span",{className:"about-release-version",children:h.version}),e.jsx("span",{className:"about-release-date",children:u(h.publishedAt)})]},h.version))})]})]}),e.jsx("div",{className:"about-description",children:s("config:about.tagline")}),e.jsxs("div",{className:"about-principles",children:[e.jsx("div",{className:"about-principles-title",children:s("config:about.corePrinciples")}),e.jsxs("ul",{className:"about-principles-list",children:[e.jsx("li",{children:s("config:about.principle1")}),e.jsx("li",{children:s("config:about.principle2")}),e.jsx("li",{children:s("config:about.principle3")}),e.jsx("li",{children:s("config:about.principle4")})]})]}),e.jsx("div",{className:"about-links",children:e.jsxs("a",{href:"https://github.com/deivid11/tide-commander",target:"_blank",rel:"noopener noreferrer",className:"about-link",children:[e.jsx("span",{className:"about-link-icon",children:e.jsx(L,{name:"package",size:14})}),e.jsx("span",{children:s("config:about.repository")})]})}),e.jsxs("div",{className:"about-credits",children:[e.jsx("div",{className:"about-credits-title",children:s("config:about.specialThanks")}),e.jsxs("div",{className:"about-credit-item",children:[e.jsx("a",{href:"https://kenney.nl",target:"_blank",rel:"noopener noreferrer",className:"about-credit-link",children:"Kenney.nl"}),e.jsx("span",{className:"about-credit-desc",children:s("config:about.kenneyCredit")})]}),e.jsxs("div",{className:"about-credit-item",children:[e.jsx("a",{href:"https://claude.ai/code",target:"_blank",rel:"noopener noreferrer",className:"about-credit-link",children:"Claude Code"}),e.jsx("span",{className:"about-credit-desc",children:s("config:about.claudeCodeCredit")})]})]})]})}const Hs={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅",docx:"📄"};function Ys({onOpenModal:s}){const[i,a]=c.useState([]),[o,m]=c.useState(!0),f=c.useCallback(async()=>{try{const d=await Ne(re("/api/integrations"));if(!d.ok)return;const n=await d.json();a(n)}catch{}finally{m(!1)}},[]);return c.useEffect(()=>{f()},[f]),o?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"Loading..."}):i.length===0?e.jsx("div",{style:{color:"var(--text-secondary, #a6adc8)",fontSize:12,padding:"4px 0"},children:"No integrations available."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[i.map(d=>{const n=Hs[d.id]||"🔌",g=!!d.status.error,T=d.status.connected,y=g?"#f38ba8":T?"#a6e3a1":"#fab387",S=g?"Error":T?"Connected":"Setup Required",u=g?"✗":T?"✓":"⚠";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:6,background:"var(--surface-1, #181825)",border:"1px solid var(--border, #313244)",fontSize:13},children:[e.jsx("span",{style:{fontSize:15,flexShrink:0},children:n}),e.jsx("span",{style:{flex:1,color:"var(--text-primary, #cdd6f4)",fontWeight:500},children:d.name}),e.jsxs("span",{style:{color:y,fontSize:11,fontWeight:500,whiteSpace:"nowrap"},children:[u," ",S]}),e.jsx("button",{onClick:()=>s(d.id),title:`Configure ${d.name}`,style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",fontSize:14,color:"var(--text-secondary, #a6adc8)",borderRadius:4,flexShrink:0},onMouseEnter:h=>{h.target.style.color="var(--text-primary, #cdd6f4)"},onMouseLeave:h=>{h.target.style.color="var(--text-secondary, #a6adc8)"},children:"⚙️"})]},d.id)}),e.jsx("button",{onClick:()=>s(),style:{background:"none",border:"1px dashed var(--border, #313244)",borderRadius:6,padding:"6px 8px",cursor:"pointer",color:"var(--text-secondary, #a6adc8)",fontSize:12,textAlign:"center",marginTop:2},onMouseEnter:d=>{d.target.style.borderColor="var(--accent, #89b4fa)",d.target.style.color="var(--accent, #89b4fa)"},onMouseLeave:d=>{d.target.style.borderColor="var(--border, #313244)",d.target.style.color="var(--text-secondary, #a6adc8)"},children:"Manage All Integrations"})]})}function Js({isOpen:s,onClose:i}){const{t:a}=se(["config"]),[o,m]=c.useState(""),[f,d]=c.useState(""),[n,g]=c.useState(!0),[T,y]=c.useState(null),[S,u]=c.useState(null),[h,p]=c.useState(!1),[N,x]=c.useState(!1),[r,F]=c.useState(!1);c.useEffect(()=>{s&&R()},[s]);const R=async()=>{try{g(!0),y(null),u(null);const O=await Fs();m(O),d(O),p(!1)}catch(O){y(O instanceof Error?O.message:"Failed to load system prompt")}finally{g(!1)}},$=O=>{const q=O.target.value;m(q),p(q!==f),y(null),u(null)},v=async()=>{try{y(null),u(null),await Os(o),d(o),p(!1),u(a("config:systemPrompt.saved"))}catch(O){y(O instanceof Error?O.message:"Failed to save system prompt")}},C=()=>{x(!0)},M=async()=>{try{y(null),u(null),await Ds(),m(""),d(""),p(!1),u(a("config:systemPrompt.cleared"))}catch(O){y(O instanceof Error?O.message:"Failed to clear system prompt")}},K=()=>{m(f),p(!1),y(null),u(null)},G=()=>{if(h){F(!0);return}i()},V=O=>{O.key==="Escape"&&(O.preventDefault(),G())};return s?e.jsxs(Me,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:G,children:e.jsxs("div",{className:"system-prompt-modal",onClick:O=>O.stopPropagation(),onKeyDown:V,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:a("config:systemPrompt.title")}),e.jsx("button",{className:"modal-close",onClick:G,"aria-label":"Close",children:e.jsx(L,{name:"close",size:16})})]}),e.jsx("div",{className:"modal-body",children:n?e.jsxs("div",{className:"loading-state",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:"Loading system prompt..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"modal-description",children:a("config:systemPrompt.description")}),T&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"warn",size:14})}),T]}),S&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"check",size:14})}),S]}),e.jsxs("div",{className:"editor-wrapper",children:[e.jsxs("div",{className:"editor-header",children:[e.jsx("label",{htmlFor:"prompt-input",className:"editor-label",children:a("config:systemPrompt.editPrompt")}),e.jsxs("span",{className:"char-count",children:[o.length," ",a("config:systemPrompt.characters")]})]}),e.jsx("textarea",{id:"prompt-input",className:"prompt-editor",value:o,onChange:$,placeholder:a("config:systemPrompt.placeholder"),rows:18,autoFocus:!0}),e.jsx("div",{className:"editor-hint",children:a("config:systemPrompt.hint")})]})]})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("div",{className:"footer-buttons-left",children:e.jsx("button",{className:"btn btn-danger",onClick:C,disabled:!o||n,children:a("config:systemPrompt.clear")})}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:G,children:"Close"}),e.jsx("button",{className:"btn btn-secondary",onClick:K,disabled:!h||n,children:a("config:systemPrompt.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:v,disabled:!h||n,children:a("config:systemPrompt.save")})]})]})]})}),e.jsx(fe,{isOpen:N,title:a("config:systemPrompt.clear"),message:a("config:systemPrompt.confirmClear"),confirmLabel:a("config:systemPrompt.clear"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{M()},onClose:()=>x(!1)}),e.jsx(fe,{isOpen:r,title:"Unsaved Changes",message:"You have unsaved changes. Close anyway?",confirmLabel:"Close anyway",cancelLabel:"Keep editing",variant:"danger",onConfirm:i,onClose:()=>F(!1)})]}):null}const Be={enabled:!1,baseUrl:"",defaultSessionId:"",webhookVerifyToken:"",showIncomingToasts:!0},Zs=2500,Xs=12e4;function Ke(s){return{enabled:s.enabled??!1,baseUrl:s.baseUrl??"",defaultSessionId:s.defaultSessionId??"",webhookVerifyToken:s.webhookVerifyToken??"",showIncomingToasts:s.showIncomingToasts??!0}}function Qs(s,i){return s.enabled===i.enabled&&s.baseUrl===i.baseUrl&&s.defaultSessionId===i.defaultSessionId&&s.webhookVerifyToken===i.webhookVerifyToken&&s.showIncomingToasts===i.showIncomingToasts}function ea({isOpen:s,onClose:i}){const{t:a}=se(["config"]),[o,m]=c.useState(Be),[f,d]=c.useState(Be),[n,g]=c.useState(!1),[T,y]=c.useState([]),[S,u]=c.useState(!0),[h,p]=c.useState(null),[N,x]=c.useState(null),[r,F]=c.useState(""),[R,$]=c.useState(!1),[v,C]=c.useState(""),[M,K]=c.useState(null),[G,V]=c.useState(null),[O,q]=c.useState(null),ee=c.useRef(null),ne=c.useRef(0),[b,E]=c.useState(""),[z,j]=c.useState(""),[P,D]=c.useState(null),[Y,J]=c.useState(!1),[Z,H]=c.useState(!1),[xe,de]=c.useState(!1),[A,X]=c.useState(!1),[pe,ge]=c.useState(null),be=!Qs(o,f),te=c.useCallback(()=>{ee.current&&(clearTimeout(ee.current),ee.current=null)},[]),je=c.useCallback(async()=>{try{u(!0),p(null),x(null);const[l,I]=await Promise.all([as(),ts()]),B=Ke(l);if(m(B),d(B),g(!!I.configured),I.configured)try{const ce=await _e();y(Array.isArray(ce)?ce:[])}catch{y([])}else y([])}catch(l){p(l instanceof Error?l.message:a("config:whatsapp.errors.loadFailed"))}finally{u(!1)}},[a]),me=c.useCallback(async()=>{try{const l=await _e();y(Array.isArray(l)?l:[])}catch{}},[]);c.useEffect(()=>(s?je():(te(),K(null),V(null),q(null),F(""),$(!1),D(null)),()=>{te()}),[s,je,te]);const le=(l,I)=>{m(B=>({...B,[l]:I})),p(null),x(null)},Te=async()=>{try{p(null),x(null);const l=await cs({enabled:o.enabled,baseUrl:o.baseUrl.trim(),defaultSessionId:o.defaultSessionId.trim(),webhookVerifyToken:o.webhookVerifyToken,showIncomingToasts:o.showIncomingToasts});window.dispatchEvent(new CustomEvent("tide:whatsapp-config-updated"));const I=Ke(l);m(I),d(I),x(a("config:whatsapp.saved"))}catch(l){p(l instanceof Error?l.message:a("config:whatsapp.errors.saveFailed"))}},Ie=()=>{m(f),p(null),x(null)},ue=()=>{if(be){H(!0);return}i()},Ee=l=>{l.key==="Escape"&&(l.preventDefault(),ue())},we=async()=>{const l=r.trim();if(l)try{p(null),x(null),await os(l),F(""),$(!1),g(!0),x(a("config:whatsapp.apiKeySaved"))}catch(I){p(I instanceof Error?I.message:a("config:whatsapp.errors.apiKeySaveFailed"))}},oe=()=>{de(!0)},ie=async()=>{try{p(null),x(null),await rs(),g(!1),x(a("config:whatsapp.apiKeyCleared"))}catch(l){p(l instanceof Error?l.message:a("config:whatsapp.errors.apiKeyClearFailed"))}},ve=c.useCallback(async l=>{if(Date.now()>ne.current){q(a("config:whatsapp.pairingTimeout")),K(null),V(null),te(),me();return}try{const I=await ns(l);if(I.status&&["connected","paired","open","ready"].includes(I.status.toLowerCase())){q(a("config:whatsapp.pairingSuccess")),K(null),V(null),te(),me();return}const ce=I.qrUrl??I.qr??null;ce&&V(ce)}catch(I){q(I instanceof Error?I.message:a("config:whatsapp.errors.qrFetchFailed"))}ee.current=setTimeout(()=>{ve(l)},Zs)},[me,te,a]),ke=async()=>{const l=v.trim();if(l)try{p(null),x(null),q(null),V(null),te(),await is(l),C(""),K(l),ne.current=Date.now()+Xs,ve(l),me()}catch(I){p(I instanceof Error?I.message:a("config:whatsapp.errors.sessionCreateFailed"))}},Se=()=>{te(),K(null),V(null),q(null)},_=l=>{ge(l),X(!0)},Ce=async()=>{if(pe)try{p(null),x(null),await ds(pe),M===pe&&Se(),me(),x(a("config:whatsapp.sessionDeleted"))}catch(l){p(l instanceof Error?l.message:a("config:whatsapp.errors.sessionDeleteFailed"))}finally{ge(null)}},t=async()=>{const l=b.trim(),I=z.trim();if(!(!l||!I))try{J(!0),D(null);const B=o.defaultSessionId.trim()||void 0;await ls(l,I,B),D({kind:"success",text:a("config:whatsapp.testSent")})}catch(B){D({kind:"error",text:B instanceof Error?B.message:a("config:whatsapp.errors.testSendFailed")})}finally{J(!1)}};return s?e.jsxs(Me,{children:[e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:ue,children:e.jsxs("div",{className:"whatsapp-config-modal",onClick:l=>l.stopPropagation(),onKeyDown:Ee,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:a("config:whatsapp.title")}),e.jsx("button",{className:"modal-close",onClick:ue,"aria-label":"Close",children:e.jsx(L,{name:"close",size:16})})]}),e.jsx("div",{className:"modal-body",children:S?e.jsxs("div",{className:"loading-state",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:a("config:whatsapp.loading")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"modal-description",children:a("config:whatsapp.description")}),h&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"warn",size:14})}),h]}),N&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:"check",size:14})}),N]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:a("config:whatsapp.sections.general")}),e.jsxs("div",{className:"wa-field wa-field-row",children:[e.jsx("label",{htmlFor:"wa-enabled",className:"wa-label",children:a("config:whatsapp.enabled")}),e.jsxs("label",{className:"wa-toggle",children:[e.jsx("input",{id:"wa-enabled",type:"checkbox",checked:o.enabled,onChange:l=>le("enabled",l.target.checked)}),e.jsx("span",{className:"wa-toggle-track",children:e.jsx("span",{className:"wa-toggle-thumb"})})]})]}),e.jsxs("div",{className:"wa-field wa-field-row",children:[e.jsx("label",{htmlFor:"wa-show-toasts",className:"wa-label",children:a("config:whatsapp.showIncomingToasts")}),e.jsxs("label",{className:"wa-toggle",children:[e.jsx("input",{id:"wa-show-toasts",type:"checkbox",checked:o.showIncomingToasts,onChange:l=>le("showIncomingToasts",l.target.checked)}),e.jsx("span",{className:"wa-toggle-track",children:e.jsx("span",{className:"wa-toggle-thumb"})})]})]}),e.jsx("span",{className:"wa-hint",children:a("config:whatsapp.showIncomingToastsHelp")}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-base-url",className:"wa-label",children:a("config:whatsapp.baseUrl")}),e.jsx("input",{id:"wa-base-url",type:"text",className:"wa-input",placeholder:"http://localhost:3007",value:o.baseUrl,onChange:l=>le("baseUrl",l.target.value)})]}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-default-session",className:"wa-label",children:a("config:whatsapp.defaultSessionId")}),e.jsx("input",{id:"wa-default-session",type:"text",className:"wa-input",placeholder:a("config:whatsapp.defaultSessionIdPlaceholder"),value:o.defaultSessionId,onChange:l=>le("defaultSessionId",l.target.value)})]}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-webhook-token",className:"wa-label",children:a("config:whatsapp.webhookVerifyToken")}),e.jsx("input",{id:"wa-webhook-token",type:"text",className:"wa-input",placeholder:a("config:whatsapp.webhookVerifyTokenPlaceholder"),value:o.webhookVerifyToken,onChange:l=>le("webhookVerifyToken",l.target.value)})]})]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:a("config:whatsapp.sections.apiKey")}),e.jsx("div",{className:"wa-key-status",children:n?e.jsxs("span",{className:"wa-status wa-status-ok",children:[e.jsx(L,{name:"check",size:12})," ",a("config:whatsapp.configured")]}):e.jsxs("span",{className:"wa-status wa-status-warn",children:[e.jsx(L,{name:"warn",size:12})," ",a("config:whatsapp.notConfigured")]})}),e.jsxs("div",{className:"wa-field wa-field-inline",children:[e.jsx("input",{type:R?"text":"password",className:"wa-input",placeholder:a("config:whatsapp.apiKeyPlaceholder"),value:r,onChange:l=>F(l.target.value)}),e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>$(l=>!l),title:a(R?"config:whatsapp.hideKey":"config:whatsapp.showKey"),children:e.jsx(L,{name:R?"eye-closed":"eye",size:14})}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:we,disabled:!r.trim(),children:a("config:whatsapp.saveKey")}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:oe,disabled:!n,children:a("config:whatsapp.clearKey")})]}),e.jsx("span",{className:"wa-hint",children:a("config:whatsapp.apiKeyHint")})]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:a("config:whatsapp.sections.sessions")}),e.jsx("div",{className:"wa-sessions-list",children:!Array.isArray(T)||T.length===0?e.jsx("div",{className:"wa-empty",children:a("config:whatsapp.noSessions")}):T.map(l=>e.jsxs("div",{className:"wa-session-row",children:[e.jsxs("div",{className:"wa-session-info",children:[e.jsx("span",{className:"wa-session-id",children:l.id}),e.jsx("span",{className:`wa-session-status status-${(l.status??"unknown").toLowerCase()}`,children:l.status||"—"}),l.pairedNumber&&e.jsx("span",{className:"wa-session-paired",children:l.pairedNumber})]}),e.jsx("button",{type:"button",className:"btn btn-danger btn-sm",onClick:()=>_(l.id),children:a("config:whatsapp.deleteSession")})]},l.id))}),e.jsxs("div",{className:"wa-field wa-field-inline",children:[e.jsx("input",{type:"text",className:"wa-input",placeholder:a("config:whatsapp.addSessionPlaceholder"),value:v,onChange:l=>C(l.target.value),onKeyDown:l=>{l.key==="Enter"&&ke()}}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:ke,disabled:!v.trim()||M!==null,children:a("config:whatsapp.addSession")})]}),M&&e.jsxs("div",{className:"wa-qr-panel",children:[e.jsxs("div",{className:"wa-qr-header",children:[e.jsx("span",{children:a("config:whatsapp.qrPrompt",{id:M})}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Se,children:a("config:whatsapp.cancelPairing")})]}),G?e.jsx("div",{className:"wa-qr-image",children:e.jsx("img",{src:G,alt:"WhatsApp pairing QR code"})}):e.jsxs("div",{className:"wa-qr-loading",children:[e.jsx("div",{className:"spinner"}),e.jsx("p",{children:a("config:whatsapp.waitingForQr")})]})]}),O&&!M&&e.jsx("div",{className:"wa-pairing-message",children:O})]}),e.jsxs("section",{className:"wa-section",children:[e.jsx("h3",{className:"wa-section-title",children:a("config:whatsapp.sections.testMessage")}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-test-to",className:"wa-label",children:a("config:whatsapp.testTo")}),e.jsx("input",{id:"wa-test-to",type:"text",className:"wa-input",placeholder:a("config:whatsapp.testToPlaceholder"),value:b,onChange:l=>E(l.target.value)})]}),e.jsxs("div",{className:"wa-field",children:[e.jsx("label",{htmlFor:"wa-test-message",className:"wa-label",children:a("config:whatsapp.testMessageBody")}),e.jsx("textarea",{id:"wa-test-message",className:"wa-textarea",rows:4,placeholder:a("config:whatsapp.testMessageBodyPlaceholder"),value:z,onChange:l=>j(l.target.value)})]}),e.jsx("div",{className:"wa-field-inline wa-field-end",children:e.jsx("button",{type:"button",className:"btn btn-primary",onClick:t,disabled:!b.trim()||!z.trim()||Y,children:a(Y?"config:whatsapp.sending":"config:whatsapp.sendTest")})}),P&&e.jsxs("div",{className:`alert ${P.kind==="success"?"alert-success":"alert-error"}`,children:[e.jsx("span",{className:"alert-icon",children:e.jsx(L,{name:P.kind==="success"?"check":"warn",size:14})}),P.text]})]})]})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("div",{className:"footer-buttons-left"}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:ue,children:a("config:whatsapp.close")}),e.jsx("button",{className:"btn btn-secondary",onClick:Ie,disabled:!be||S,children:a("config:whatsapp.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:Te,disabled:!be||S,children:a("config:whatsapp.save")})]})]})]})}),e.jsx(fe,{isOpen:Z,title:a("config:whatsapp.unsavedTitle"),message:a("config:whatsapp.unsavedMessage"),confirmLabel:a("config:whatsapp.closeAnyway"),cancelLabel:a("config:whatsapp.keepEditing"),variant:"danger",onConfirm:()=>{H(!1),i()},onClose:()=>H(!1)}),e.jsx(fe,{isOpen:xe,title:a("config:whatsapp.clearKey"),message:a("config:whatsapp.confirmClearKey"),confirmLabel:a("config:whatsapp.clearKey"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{ie()},onClose:()=>de(!1)}),e.jsx(fe,{isOpen:A,title:a("config:whatsapp.deleteSession"),message:a("config:whatsapp.confirmDeleteSession",{id:pe??""}),confirmLabel:a("config:whatsapp.deleteSession"),cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{Ce()},onClose:()=>{X(!1),ge(null)}})]}):null}const sa=[{value:"auto",label:"Auto",icon:"🕐"},{value:"dawn",label:"Dawn",icon:"🌅"},{value:"day",label:"Day",icon:"☀️"},{value:"dusk",label:"Dusk",icon:"🌇"},{value:"night",label:"Night",icon:"🌙"}],aa=[{value:"none",label:"Grass",icon:"🌱"},{value:"concrete",label:"Concrete",icon:"🏗️"},{value:"galactic",label:"Galactic",icon:"🌌"},{value:"metal",label:"Metal",icon:"⚙️"},{value:"hex",label:"Hex",icon:"⬡"},{value:"circuit",label:"Circuit",icon:"🔌"},{value:"pokemon-stadium",label:"Pokemon",icon:"🔴"}],ta=[{value:"static",label:"Static",icon:"🧍"},{value:"idle",label:"Idle",icon:"🚶"},{value:"walk",label:"Walk",icon:"🚶‍♂️"},{value:"sprint",label:"Sprint",icon:"🏃"},{value:"jump",label:"Jump",icon:"⬆️"},{value:"fall",label:"Fall",icon:"⬇️"},{value:"crouch",label:"Crouch",icon:"🧎"},{value:"sit",label:"Sit",icon:"🪑"},{value:"die",label:"Die",icon:"💀"},{value:"emote-yes",label:"Yes",icon:"👍"},{value:"emote-no",label:"No",icon:"👎"}],na=[{value:"normal",label:"Normal",icon:"🎨"},{value:"bw",label:"B&W",icon:"⬛"},{value:"sepia",label:"Sepia",icon:"🟤"},{value:"cool",label:"Cool",icon:"❄️"},{value:"warm",label:"Warm",icon:"🔥"},{value:"neon",label:"Neon",icon:"💜"}],oa=[{key:"showTrees",icon:"🌳",label:"Trees"},{key:"showBushes",icon:"🌿",label:"Bushes"},{key:"showHouse",icon:"🏠",label:"House"},{key:"showLamps",icon:"💡",label:"Lamps"},{key:"showGrass",icon:"🟩",label:"Grass"},{key:"showClouds",icon:"☁️",label:"Clouds"}],ia=[{value:null,label:"Auto",color:"linear-gradient(135deg, #4a90d9 0%, #0a1a2a 100%)"},{value:"#4a90d9",label:"Day Blue",color:"#4a90d9"},{value:"#0a1a2a",label:"Night",color:"#0a1a2a"},{value:"#ff6b35",label:"Sunset",color:"#ff6b35"},{value:"#1a0a2e",label:"Purple",color:"#1a0a2e"},{value:"#2d5a27",label:"Matrix",color:"#2d5a27"},{value:"#8b0000",label:"Blood",color:"#8b0000"},{value:"#000000",label:"Void",color:"#000000"}],la={showTrees:"trees",showBushes:"bushes",showHouse:"house",showLamps:"lamps",showGrass:"grass",showClouds:"clouds"},ca={none:"grass","pokemon-stadium":"pokemon"},ra={"emote-yes":"yes","emote-no":"no"},da={"":"auto","#4a90d9":"dayBlue","#0a1a2a":"night","#ff6b35":"sunset","#1a0a2e":"purple","#2d5a27":"matrix","#8b0000":"blood","#000000":"void"};function Q({checked:s,onChange:i}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,onChange:a=>i(a.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function he({options:s,value:i,onChange:a,iconOnly:o=!1}){return e.jsx("div",{className:"chip-selector",children:s.map(m=>e.jsxs("button",{className:`chip ${i===m.value?"active":""}`,onClick:()=>a(m.value),title:m.label,children:[e.jsx("span",{className:"chip-icon",children:m.icon}),!o&&e.jsx("span",{className:"chip-label",children:m.label})]},m.value))})}function w({text:s,query:i}){if(!i.trim())return e.jsx(e.Fragment,{children:s});const a=s.toLowerCase(),o=i.toLowerCase(),m=a.indexOf(o);if(m===-1)return e.jsx(e.Fragment,{children:s});const f=s.slice(0,m),d=s.slice(m,m+i.length),n=s.slice(m+i.length);return e.jsxs(e.Fragment,{children:[f,e.jsx("mark",{className:"search-highlight",children:d}),n]})}const ma=[{id:"general",title:"General",keywords:["history","hide costs","grid","fps","power saving","performance","limit","editor","external editor","language","idioma","语言","vibration","haptic","intensity","tab title","tmux","process persistence"]},{id:"agentNames",title:"Agent Names",keywords:["agent","names","custom","characters","rename"]},{id:"defaultClass",title:"Default Spawn Class",keywords:["default","class","spawn","agent","scout","builder","random"]},{id:"appearance",title:"Appearance",keywords:["theme","appearance","color","dark","light","style","look"]},{id:"connection",title:"Connection",keywords:["backend","url","auth","token","reconnect","server","api","connect","codex","opencode","binary","path"]},{id:"scene",title:"Scene",keywords:["character","size","indicator","scale","time","dawn","day","dusk","night","auto"]},{id:"terrain",title:"Terrain",keywords:["trees","bushes","house","lamps","grass","clouds","fog","brightness","floor","sky","color","environment","battlefield","size","grid","simple","minimal","dark","clean"]},{id:"modelStyle",title:"Agent Model Style",keywords:["saturation","roughness","metalness","glow","emissive","reflections","wireframe","color mode","material","shader"]},{id:"animations",title:"Animations",keywords:["idle","working","animation","walk","run","sprint","jump","sit","crouch"]},{id:"secrets",title:"Secrets",keywords:["secrets","api","key","password","credentials","env","environment"]},{id:"systemPrompt",title:"System Prompt",keywords:["system","prompt","global","instructions","ai","agent","rules","guidelines"]},{id:"whatsapp",title:"WhatsApp Integration",keywords:["whatsapp","message","sms","integration","notification","baileys"]},{id:"data",title:"Data",keywords:["export","import","backup","restore","save","load","json"]},{id:"integrations",title:"Integrations",keywords:["integrations","plugins","gmail","slack","jira","calendar","docx","email","config","setup"]},{id:"workflows",title:"Workflows",keywords:["workflow","automation","state machine","editor","actions","transitions","pipeline"]},{id:"triggers",title:"Triggers",keywords:["trigger","event","webhook","cron","slack","email","jira","matching","fire"]},{id:"monitoring",title:"Monitoring",keywords:["monitoring","logs","triggers","events","history","workflow","traces","audit","timeline"]},{id:"experimental",title:"Experimental",keywords:["experimental","2d","view","voice","assistant","speech","tts","text to speech","echo","prompt","duplicate"]},{id:"about",title:"About",keywords:["about","version","update","credits","github","releases"]}],Oe=[{value:"auto",label:"Auto",icon:"🌐"},{value:"en",label:"English",icon:"🇺🇸"},{value:"zh-CN",label:"中文",icon:"🇨🇳"},{value:"es",label:"Español",icon:"🇪🇸"},{value:"hi",label:"हिन्दी",icon:"🇮🇳"},{value:"pt",label:"Português",icon:"🇧🇷"},{value:"ru",label:"Русский",icon:"🇷🇺"},{value:"ja",label:"日本語",icon:"🇯🇵"},{value:"de",label:"Deutsch",icon:"🇩🇪"},{value:"fr",label:"Français",icon:"🇫🇷"},{value:"it",label:"Italiano",icon:"🇮🇹"}];function ua({config:s,onChange:i,searchQuery:a="",onOpenIntegrationsModal:o,onOpenMonitoringModal:m,onOpenWorkflowEditor:f,onOpenTriggerManager:d}){var Ce;const{t:n}=se(["config","common"]),g=De(),T=ms(),[y,S]=c.useState(()=>us(ye.DEFAULT_AGENT_CLASS)||"scout"),[u,h]=c.useState(g.settings.historyLimit),[p,N]=c.useState(()=>ps()),[x,r]=c.useState(!1),[F,R]=c.useState(""),[$,v]=c.useState(()=>W()),[C,M]=c.useState(!1),[K,G]=c.useState(!1),[V,O]=c.useState(""),[q,ee]=c.useState(!1),[ne,b]=c.useState(!1),[E,z]=c.useState(""),[j,P]=c.useState(!1);c.useEffect(()=>{_s().then(z).catch(()=>{})},[]),c.useEffect(()=>{$s().then(t=>{t!==g.settings.experimentalEchoPrompt&&k.updateSettings({experimentalEchoPrompt:t})}).catch(()=>{})},[]),c.useEffect(()=>{Rs().then(t=>{t!==g.settings.tmuxMode&&k.updateSettings({tmuxMode:t})}).catch(()=>{})},[]),c.useEffect(()=>gs(t=>{N(t),r(!1)}),[]);const D=sa.map(t=>({...t,label:n(`config:time.${t.value}`)})),Y=aa.map(t=>({...t,label:n(`config:floor.${ca[t.value]||t.value}`)})),J=ta.map(t=>({...t,label:n(`config:animation.${ra[t.value]||t.value}`)})),Z=na.map(t=>({...t,label:n(`config:colorMode.${t.value}`)})),H=oa.map(t=>({...t,label:n(`config:terrain.${la[t.key]}`)})),xe=ia.map(t=>({...t,label:n(`config:sky.${da[t.value??""]}`)})),de=a.trim()?ma.filter(t=>{const l=a.toLowerCase();return t.title.toLowerCase().includes(l)||t.keywords.some(I=>I.toLowerCase().includes(l))}).map(t=>t.id):null,A=t=>de?de.includes(t):!0,X=g.settings.customAgentNames||[],pe=X.length>0?X:hs,ge=()=>{const t=V.trim();t&&!X.includes(t)&&(k.updateSettings({customAgentNames:[...X,t]}),O(""))},be=t=>{k.updateSettings({customAgentNames:X.filter(l=>l!==t)})},te=()=>{k.updateSettings({customAgentNames:[]})},je=()=>{const t=F.trim();if(t){if(p.includes(t)){R("");return}N([...p,t]),r(!0),R("")}},me=t=>{N(p.filter((l,I)=>I!==t)),r(!0)},le=(t,l)=>{const I=t+l;if(I<0||I>=p.length)return;const B=p.slice();[B[t],B[I]]=[B[I],B[t]],N(B),r(!0)},Te=()=>{xs(p),r(!1),Fe()},Ie=t=>{v(t),M(!0)},ue=()=>{Ae(ye.AUTH_TOKEN,$),M(!1),Fe()},Ee=t=>{z(t),P(!0)},we=()=>{Us(E).catch(()=>{}),P(!1)},oe=t=>{i({...s,terrain:{...s.terrain,...t}})},ie=t=>{i({...s,modelStyle:{...s.modelStyle,...t}})},ve=t=>{i({...s,animations:{...s.animations,...t}})},ke=t=>{h(t),k.updateSettings({historyLimit:t})},Se=t=>{const l=s.terrain[t];typeof l=="boolean"&&oe({[t]:!l})},_=a.trim().length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-section",children:[de&&de.length===0&&e.jsx("div",{className:"config-no-results",children:n("config:noResults",{query:a})}),A("general")&&e.jsxs(U,{title:n("config:sections.general"),storageKey:"general",defaultOpen:!0,forceOpen:_&&A("general"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.history"),query:a})}),e.jsx("input",{type:"number",className:"config-input config-input-sm",value:u,onChange:t=>ke(parseInt(t.target.value)||100),min:50,max:2e3,step:50})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.hideCosts"),query:a})}),e.jsx(Q,{checked:g.settings.hideCost,onChange:t=>k.updateSettings({hideCost:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.grid"),query:a})}),e.jsx(Q,{checked:s.gridVisible,onChange:t=>i({...s,gridVisible:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.showFPS"),query:a})}),e.jsx(Q,{checked:g.settings.showFPS,onChange:t=>k.updateSettings({showFPS:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.fpsLimit"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"120",step:"10",value:s.fpsLimit,onChange:t=>i({...s,fpsLimit:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.fpsLimit===0?"∞":s.fpsLimit})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Experimental: Reduce FPS when idle to save power",children:[e.jsx(w,{text:n("config:general.powerSaving"),query:a})," ",e.jsx(L,{name:"bolt",size:12})]}),e.jsx(Q,{checked:g.settings.powerSaving,onChange:t=>k.updateSettings({powerSaving:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:"Wrap agent processes in tmux sessions so they survive server restarts (requires tmux installed)",children:e.jsx(w,{text:n("config:general.tmuxMode"),query:a})}),e.jsx(Q,{checked:g.settings.tmuxMode,onChange:async t=>{k.updateSettings({tmuxMode:t});try{await Bs(t)}catch(l){console.error("Failed to sync tmux mode setting to server:",l)}}})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.vibrationIntensity"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"5",step:"1",value:g.settings.vibrationIntensity,onChange:t=>k.updateSettings({vibrationIntensity:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:g.settings.vibrationIntensity===0?n("config:vibrationValues.off"):g.settings.vibrationIntensity===1?n("config:vibrationValues.ultraLight"):g.settings.vibrationIntensity===2?n("config:vibrationValues.veryLight"):g.settings.vibrationIntensity===3?n("config:vibrationValues.light"):g.settings.vibrationIntensity===4?n("config:vibrationValues.medium"):n("config:vibrationValues.heavy")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.externalEditor"),query:a})}),e.jsx("input",{type:"text",className:"config-input",placeholder:n("config:general.externalEditorPlaceholder"),value:g.settings.externalEditorCommand||"",onChange:t=>k.updateSettings({externalEditorCommand:t.target.value})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.tabTitle"),query:a})}),e.jsx("input",{type:"text",className:"config-input",placeholder:n("config:general.tabTitlePlaceholder"),value:g.settings.tabTitle||"",onChange:t=>k.updateSettings({tabTitle:t.target.value})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:general.language"),query:a})}),e.jsx(he,{options:Oe,value:localStorage.getItem("tide-commander-language-mode")==="manual"?((Ce=Oe.find(t=>t.value!=="auto"&&Le.language.startsWith(t.value.split("-")[0])))==null?void 0:Ce.value)||"en":"auto",onChange:t=>{var l;if(t==="auto"){localStorage.setItem("tide-commander-language-mode","auto");const I=navigator.language,B=((l=Oe.find(ce=>ce.value!=="auto"&&I.startsWith(ce.value.split("-")[0])))==null?void 0:l.value)||"en";Le.changeLanguage(B)}else localStorage.setItem("tide-commander-language-mode","manual"),Le.changeLanguage(t)}})]})]}),A("agentNames")&&e.jsx(U,{title:n("config:sections.agentNames"),storageKey:"agentNames",defaultOpen:!1,forceOpen:_&&A("agentNames"),children:e.jsxs("div",{className:"agent-names-section",children:[e.jsx("span",{className:"config-hint",children:X.length>0?n("config:agentNames.customConfigured",{count:X.length}):n("config:agentNames.usingDefaults")}),e.jsxs("div",{className:"agent-names-input-row",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",placeholder:n("config:agentNames.addPlaceholder"),value:V,onChange:t=>O(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ge()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:ge,disabled:!V.trim(),title:n("config:agentNames.addName"),children:"+"})]}),e.jsx("div",{className:"agent-names-list",children:pe.map((t,l)=>e.jsxs("div",{className:"agent-name-chip",children:[e.jsx("span",{className:"agent-name-text",children:t}),X.length>0&&e.jsx("button",{className:"agent-name-remove",onClick:()=>be(t),title:n("common:buttons.remove"),children:"x"})]},`${t}-${l}`))}),X.length>0&&e.jsx("button",{className:"config-btn config-btn-link",onClick:te,children:n("common:buttons.resetToDefaults")})]})}),A("defaultClass")&&e.jsx(U,{title:"Default Spawn Class",storageKey:"defaultClass",defaultOpen:!1,forceOpen:_&&A("defaultClass"),children:e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-hint",children:'Class pre-selected when the spawn modal opens. "Random" picks a different class each time.'}),e.jsxs("div",{className:"agent-names-list",style:{flexWrap:"wrap",gap:"6px",marginTop:"8px"},children:[e.jsx("div",{className:`agent-name-chip${y==="random"?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{S("random"),Ae(ye.DEFAULT_AGENT_CLASS,"random")},children:e.jsx("span",{className:"agent-name-text",children:"🎲 Random"})}),Object.entries(fs).map(([t,l])=>e.jsx("div",{className:`agent-name-chip${y===t?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{S(t),Ae(ye.DEFAULT_AGENT_CLASS,t)},children:e.jsxs("span",{className:"agent-name-text",children:[l.icon," ",t.charAt(0).toUpperCase()+t.slice(1)]})},t)),T.map(t=>e.jsx("div",{className:`agent-name-chip${y===t.id?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{S(t.id),Ae(ye.DEFAULT_AGENT_CLASS,t.id)},children:e.jsxs("span",{className:"agent-name-text",children:[t.icon," ",t.name]})},t.id))]})]})}),A("appearance")&&e.jsx(U,{title:n("config:sections.appearance"),storageKey:"appearance",defaultOpen:!1,forceOpen:_&&A("appearance"),children:e.jsx(Ws,{})}),A("connection")&&e.jsxs(U,{title:n("config:sections.connection"),storageKey:"connection",defaultOpen:!1,forceOpen:_&&A("connection"),children:[e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:connection.backendUrl"),query:a})}),e.jsx("div",{className:"backend-urls-list",children:p.map((t,l)=>e.jsxs("div",{className:"backend-url-row",children:[e.jsx("span",{className:"backend-url-priority",title:n("config:connection.priorityLabel",{defaultValue:"Priority"}),children:l+1}),e.jsx("span",{className:"backend-url-text",title:t,children:t}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>le(l,-1),disabled:l===0,title:n("config:connection.moveUp",{defaultValue:"Move up"}),children:"↑"}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>le(l,1),disabled:l===p.length-1,title:n("config:connection.moveDown",{defaultValue:"Move down"}),children:"↓"}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>me(l),title:n("common:buttons.remove"),children:"x"})]},`${t}-${l}`))}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:F,onChange:t=>R(t.target.value),placeholder:n("config:connection.addUrlPlaceholder",{defaultValue:"http://host:port"}),onKeyDown:t=>{t.key==="Enter"&&je()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:je,disabled:!F.trim(),title:n("config:connection.addUrl",{defaultValue:"Add URL"}),children:"+"}),x&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:Te,title:n("config:connection.saveAndReconnect"),children:n("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:n("config:connection.urlsHint",{defaultValue:"Tried in order on connect; the first reachable host wins. Leave empty for auto-detect."})})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:connection.authToken"),query:a})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:K?"text":"password",className:"config-input config-input-full",value:$,onChange:t=>Ie(t.target.value),placeholder:n("config:connection.tokenPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&C&&ue()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>G(!K),title:n(K?"config:connection.hideToken":"config:connection.showToken"),children:e.jsx(L,{name:K?"eye-closed":"eye",size:14})}),C&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:ue,title:n("config:connection.saveAndReconnect"),children:n("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:n("config:connection.tokenRequired")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:connection.codexBinaryPath"),query:a})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:E,onChange:t=>Ee(t.target.value),placeholder:n("config:connection.codexBinaryPathPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&j&&we()}}),j&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:we,children:n("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:n("config:connection.codexBinaryPathHint")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("common:buttons.reconnect"),query:a})}),e.jsx("button",{className:"config-btn",onClick:()=>Fe(),title:"Force reconnect to server",children:n("common:buttons.reconnect")})]})]}),A("scene")&&e.jsxs(U,{title:n("config:sections.scene"),storageKey:"scene",defaultOpen:!1,forceOpen:_&&A("scene"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:scene.characterSize"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"3.0",step:"0.1",value:s.characterScale,onChange:t=>i({...s,characterScale:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.characterScale.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:scene.scale2d",{defaultValue:"2D Scale"}),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale2d,onChange:t=>i({...s,scale2d:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.scale2d.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:scene.scale3d",{defaultValue:"3D Scale"}),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.3",max:"2.0",step:"0.1",value:s.scale3d,onChange:t=>i({...s,scale3d:parseFloat(t.target.value)})}),e.jsxs("span",{className:"config-value",children:[s.scale3d.toFixed(1),"x"]})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:scene.show2DTaskLabels",{defaultValue:"Show 2D task labels"}),query:a})}),e.jsx(Q,{checked:s.show2DTaskLabels,onChange:t=>i({...s,show2DTaskLabels:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:scene.time"),query:a})}),e.jsx(he,{options:D,value:s.timeMode,onChange:t=>i({...s,timeMode:t}),iconOnly:!0})]})]}),A("terrain")&&e.jsxs(U,{title:n("config:sections.terrain"),storageKey:"terrain",defaultOpen:!1,forceOpen:_&&A("terrain"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.simpleMode",{defaultValue:"Simple Mode"}),query:a})}),e.jsx(Q,{checked:s.terrain.simpleMode??!1,onChange:t=>oe({simpleMode:t})})]}),e.jsx("div",{className:"terrain-icons",style:{opacity:s.terrain.simpleMode?.4:1,pointerEvents:s.terrain.simpleMode?"none":"auto"},children:H.map(t=>e.jsx("button",{className:`terrain-icon-btn ${s.terrain[t.key]?"active":""}`,onClick:()=>Se(t.key),title:t.label,children:t.icon},t.key))}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.fog"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.terrain.fogDensity,onChange:t=>oe({fogDensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.fogDensity===0?n("config:fogValues.off"):s.terrain.fogDensity<=1?n("config:fogValues.low"):n("config:fogValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.brightness"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.2",max:"2",step:"0.1",value:s.terrain.brightness,onChange:t=>oe({brightness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.brightness<=.5?n("config:brightnessValues.dark"):s.terrain.brightness<=1.2?n("config:brightnessValues.normal"):n("config:brightnessValues.bright")})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.floor"),query:a})}),e.jsx(he,{options:Y,value:s.terrain.floorStyle,onChange:t=>oe({floorStyle:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.sky"),query:a})}),e.jsx("div",{className:"sky-color-selector",children:xe.map(t=>e.jsx("button",{className:`sky-color-btn ${s.terrain.skyColor===t.value?"active":""}`,onClick:()=>oe({skyColor:t.value}),title:t.label,style:{background:t.color}},t.value??"auto"))})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:terrainSettings.battlefieldSize"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"30",max:"200",step:"10",value:s.terrain.battlefieldSize,onChange:t=>oe({battlefieldSize:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.battlefieldSize})]})]}),A("modelStyle")&&e.jsxs(U,{title:n("config:sections.modelStyle"),storageKey:"modelStyle",defaultOpen:!1,forceOpen:_&&A("modelStyle"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.saturation"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.modelStyle.saturation,onChange:t=>ie({saturation:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.saturation<=.3?n("config:saturationValues.gray"):s.modelStyle.saturation<=1.2?n("config:saturationValues.normal"):n("config:saturationValues.vivid")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.roughness"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.roughness,onChange:t=>ie({roughness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.roughness<0?n("config:roughnessValues.auto"):s.modelStyle.roughness<=.3?n("config:roughnessValues.glossy"):s.modelStyle.roughness<=.7?n("config:roughnessValues.normal"):n("config:roughnessValues.matte")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.metalness"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.metalness,onChange:t=>ie({metalness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.metalness<0?n("config:metalnessValues.auto"):s.modelStyle.metalness<=.3?n("config:metalnessValues.plastic"):s.modelStyle.metalness<=.7?n("config:metalnessValues.mixed"):n("config:metalnessValues.metal")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.glow"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"1",step:"0.05",value:s.modelStyle.emissiveBoost,onChange:t=>ie({emissiveBoost:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.emissiveBoost<=.1?n("config:glowValues.off"):s.modelStyle.emissiveBoost<=.4?n("config:glowValues.low"):s.modelStyle.emissiveBoost<=.7?n("config:glowValues.med"):n("config:glowValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.reflections"),query:a})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"2",step:"0.1",value:s.modelStyle.envMapIntensity,onChange:t=>ie({envMapIntensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.envMapIntensity<0?n("config:reflectionValues.auto"):s.modelStyle.envMapIntensity<=.3?n("config:reflectionValues.low"):s.modelStyle.envMapIntensity<=1?n("config:reflectionValues.normal"):n("config:reflectionValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.wireframe"),query:a})}),e.jsx(Q,{checked:s.modelStyle.wireframe,onChange:t=>ie({wireframe:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:modelStyleSettings.colorMode"),query:a})}),e.jsx(he,{options:Z,value:s.modelStyle.colorMode,onChange:t=>ie({colorMode:t}),iconOnly:!0})]})]}),A("animations")&&e.jsxs(U,{title:n("config:sections.animations"),storageKey:"animations",defaultOpen:!1,forceOpen:_&&A("animations"),children:[e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:animationSettings.idle"),query:a})}),e.jsx(he,{options:J,value:s.animations.idleAnimation,onChange:t=>ve({idleAnimation:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:animationSettings.working"),query:a})}),e.jsx(he,{options:J,value:s.animations.workingAnimation,onChange:t=>ve({workingAnimation:t}),iconOnly:!0})]})]}),A("secrets")&&e.jsx(U,{title:n("config:sections.secrets"),storageKey:"secrets",defaultOpen:!1,forceOpen:_&&A("secrets"),children:e.jsx(Ls,{})}),A("systemPrompt")&&e.jsx(U,{title:n("config:sections.systemPrompt"),storageKey:"systemPrompt",defaultOpen:!1,forceOpen:_&&A("systemPrompt"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:systemPrompt.title"),query:a})}),e.jsx("button",{className:"config-button",onClick:()=>ee(!0),children:n("config:systemPrompt.editPrompt")})]})}),A("whatsapp")&&e.jsx(U,{title:n("config:sections.whatsapp"),storageKey:"whatsapp",defaultOpen:!1,forceOpen:_&&A("whatsapp"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(w,{text:n("config:whatsapp.title"),query:a})}),e.jsx("button",{className:"config-button",onClick:()=>b(!0),children:n("config:whatsapp.editConfig")})]})}),A("data")&&e.jsx(U,{title:n("config:sections.data"),storageKey:"data",defaultOpen:!1,forceOpen:_&&A("data"),children:e.jsx(Ms,{})}),A("integrations")&&e.jsx(U,{title:"Integrations",storageKey:"integrations",defaultOpen:!1,forceOpen:_&&A("integrations"),children:e.jsx(Ys,{onOpenModal:t=>o==null?void 0:o(t)})}),A("workflows")&&e.jsxs(U,{title:"Workflows",storageKey:"workflows",defaultOpen:!1,forceOpen:_&&A("workflows"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(w,{text:"Create and manage automated workflow pipelines with visual state machine editor",query:a})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>f==null?void 0:f(),children:"Open Workflow Editor"})})]}),A("triggers")&&e.jsxs(U,{title:"Triggers",storageKey:"triggers",defaultOpen:!1,forceOpen:_&&A("triggers"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(w,{text:"Create and manage event-driven triggers that fire agents with templates",query:a})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>d==null?void 0:d(),children:"Open Trigger Manager"})})]}),A("monitoring")&&e.jsxs(U,{title:"Monitoring",storageKey:"monitoring",defaultOpen:!1,forceOpen:_&&A("monitoring"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(w,{text:"View event logs, trigger history, workflow traces, and system stats",query:a})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>m==null?void 0:m(),children:"Open Monitoring & Logs"})})]}),A("experimental")&&e.jsxs(U,{title:n("config:sections.experimental"),storageKey:"experimental",defaultOpen:!1,forceOpen:_&&A("experimental"),children:[e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Lightweight 2D top-down view for better performance",children:[e.jsx(w,{text:n("config:experimental.2dView"),query:a})," ",e.jsx(L,{name:"map",size:12})]}),e.jsx(Q,{checked:g.settings.experimental2DView,onChange:t=>k.updateSettings({experimental2DView:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Voice assistant for hands-free agent control",children:[e.jsx(w,{text:n("config:experimental.voiceAssistant"),query:a})," ",e.jsx(L,{name:"microphone",size:12})]}),e.jsx(Q,{checked:g.settings.experimentalVoiceAssistant,onChange:t=>k.updateSettings({experimentalVoiceAssistant:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Text-to-speech for reading agent responses",children:[e.jsx(w,{text:n("config:experimental.tts"),query:a})," ",e.jsx(L,{name:"speaker-on",size:12})]}),e.jsx(Q,{checked:g.settings.experimentalTTS,onChange:t=>k.updateSettings({experimentalTTS:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",title:"Duplicate system prompt for improved LLM attention coverage. Increases input token usage.",children:e.jsx(w,{text:n("config:experimental.echoPrompt"),query:a})}),e.jsx(Q,{checked:g.settings.experimentalEchoPrompt,onChange:async t=>{k.updateSettings({experimentalEchoPrompt:t});try{await zs(t)}catch(l){console.error("Failed to sync echo prompt setting to server:",l)}}})]}),e.jsx("span",{className:"config-hint",children:n("config:experimental.hint")})]}),A("about")&&e.jsx(U,{title:n("config:sections.about"),storageKey:"about",defaultOpen:!1,forceOpen:_&&A("about"),children:e.jsx(Gs,{})})]}),e.jsx(Js,{isOpen:q,onClose:()=>ee(!1)}),e.jsx(ea,{isOpen:ne,onClose:()=>b(!1)})]})}function fa({onConfigChange:s,onToolChange:i,config:a,isOpen:o,onClose:m,onOpenBuildingModal:f,onOpenAreaExplorer:d,onOpenIntegrationsModal:n,onOpenMonitoringModal:g,onOpenWorkflowEditor:T,onOpenTriggerManager:y}){const{t:S}=se(["config","common"]),u=De(),h=Array.from(u.areas.values()),p=Array.from(u.buildings.values()),[N,x]=c.useState(""),r=c.useRef(null);if(c.useEffect(()=>{const v=C=>{C.key==="Escape"&&o&&m()};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[o,m]),c.useEffect(()=>{if(o&&r.current){const v=setTimeout(()=>{var C;(C=r.current)==null||C.focus()},50);return()=>clearTimeout(v)}},[o]),!o)return null;const F=v=>{const C=u.activeTool===v?null:v;i(C)},R=v=>{k.selectArea(u.selectedAreaId===v?null:v),i("select")},$=(v,C)=>{v.stopPropagation(),k.deleteArea(C)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"toolbox-backdrop",onClick:m}),e.jsxs("aside",{className:"toolbox",children:[e.jsxs("div",{className:"toolbox-header",children:[e.jsx("span",{children:S("config:title")}),e.jsx("button",{className:"toolbox-close-btn",onClick:m,title:S("common:buttons.close"),children:"×"})]}),e.jsxs("div",{className:"toolbox-search",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"})]}),e.jsx("input",{ref:r,type:"text",placeholder:S("config:searchPlaceholder"),value:N,onChange:v=>x(v.target.value),className:"toolbox-search-input"}),N&&e.jsx("button",{className:"toolbox-search-clear",onClick:()=>x(""),children:"×"})]}),e.jsxs("div",{className:"toolbox-content",children:[e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsxs(U,{title:S("config:areas.title",{count:h.length}),storageKey:"areas",children:[e.jsxs("div",{className:"tool-buttons",children:[e.jsx("button",{className:`tool-btn ${u.activeTool==="select"?"active":""}`,onClick:()=>F("select"),title:S("config:tools.select"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"})})})}),e.jsx("button",{className:`tool-btn ${u.activeTool==="rectangle"?"active":""}`,onClick:()=>F("rectangle"),title:S("config:tools.rectangle"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",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("button",{className:`tool-btn ${u.activeTool==="circle"?"active":""}`,onClick:()=>F("circle"),title:S("config:tools.circle"),children:e.jsx("span",{children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("circle",{cx:"12",cy:"12",r:"9"})})})})]}),e.jsx("div",{className:"areas-list",children:h.length===0?e.jsx("div",{className:"areas-empty",children:S("config:areas.drawToCreate")}):h.map(v=>e.jsx(ks,{area:v,isSelected:u.selectedAreaId===v.id,onClick:()=>R(v.id),onDelete:C=>$(C,v.id)},v.id))})]})}),u.selectedAreaId&&e.jsx(Ps,{area:u.areas.get(u.selectedAreaId),onClose:()=>k.selectArea(null),onOpenFolder:d}),e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsx(U,{title:S("config:buildings.title",{count:p.length}),storageKey:"buildings",headerExtra:e.jsx("button",{className:"add-building-btn",onClick:v=>{v.stopPropagation(),f==null||f()},title:S("config:buildings.addBuilding"),children:"+"}),children:e.jsx("div",{className:"buildings-list",children:p.length===0?e.jsx("div",{className:"buildings-empty",children:S("config:buildings.clickToAdd")}):p.map(v=>e.jsx(Ss,{building:v,isSelected:u.selectedBuildingIds.has(v.id),onClick:()=>{k.selectBuilding(u.selectedBuildingIds.has(v.id)?null:v.id)},onEdit:()=>f==null?void 0:f(v.id)},v.id))})})}),u.selectedBuildingIds.size===1&&(()=>{const v=Array.from(u.selectedBuildingIds)[0],C=u.buildings.get(v);return C?e.jsx(Cs,{building:C,onClose:()=>k.selectBuilding(null),onOpenModal:()=>f==null?void 0:f(v)}):null})(),e.jsx(ua,{config:a,onChange:s,searchQuery:N,onOpenIntegrationsModal:n,onOpenMonitoringModal:g,onOpenWorkflowEditor:T,onOpenTriggerManager:y})]})]})]})}export{fa as Toolbox};
@@ -1 +0,0 @@
1
- import{j as f,I as H,ad as He,N as Je,O as Xe,bT as Ze,r as A,s as se,bU as be,a7 as fe,u as Ce}from"./main-CHfGSVnw.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function q(t){return Array.isArray?Array.isArray(t):Pe(t)==="[object Array]"}function qe(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function et(t){return t==null?"":qe(t)}function X(t){return typeof t=="string"}function $e(t){return typeof t=="number"}function tt(t){return t===!0||t===!1||st(t)&&Pe(t)=="[object Boolean]"}function Te(t){return typeof t=="object"}function st(t){return Te(t)&&t!==null}function O(t){return t!=null}function me(t){return!t.trim().length}function Pe(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const nt="Incorrect 'index' type",rt=t=>`Invalid value for key ${t}`,it=t=>`Pattern length exceeds max of ${t}.`,ct=t=>`Missing ${t} property in key`,ot=t=>`Property 'weight' in key '${t}' must be a positive integer`,ve=Object.prototype.hasOwnProperty;class at{constructor(e){this._keys=[],this._keyMap={};let s=0;e.forEach(n=>{let r=Ke(n);this._keys.push(r),this._keyMap[r.id]=r,s+=r.weight}),this._keys.forEach(n=>{n.weight/=s})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Ke(t){let e=null,s=null,n=null,r=1,i=null;if(X(t)||q(t))n=t,e=Se(t),s=pe(t);else{if(!ve.call(t,"name"))throw new Error(ct("name"));const c=t.name;if(n=c,ve.call(t,"weight")&&(r=t.weight,r<=0))throw new Error(ot(c));e=Se(c),s=pe(c),i=t.getFn}return{path:e,id:s,weight:r,src:n,getFn:i}}function Se(t){return q(t)?t:t.split(".")}function pe(t){return q(t)?t.join("."):t}function ut(t,e){let s=[],n=!1;const r=(i,c,a)=>{if(O(i))if(!c[a])s.push(i);else{let u=c[a];const l=i[u];if(!O(l))return;if(a===c.length-1&&(X(l)||$e(l)||tt(l)))s.push(et(l));else if(q(l)){n=!0;for(let h=0,d=l.length;h<d;h+=1)r(l[h],c,a+1)}else c.length&&r(l,c,a+1)}};return r(t,X(e)?e.split("."):e,0),n?s:s[0]}const lt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},ht={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},dt={location:0,threshold:.6,distance:100},ft={useExtendedSearch:!1,getFn:ut,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var p={...ht,...lt,...dt,...ft};const mt=/[^ ]+/g;function pt(t=1,e=3){const s=new Map,n=Math.pow(10,e);return{get(r){const i=r.match(mt).length;if(s.has(i))return s.get(i);const c=1/Math.pow(i,.5*t),a=parseFloat(Math.round(c*n)/n);return s.set(i,a),a},clear(){s.clear()}}}class we{constructor({getFn:e=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){this.norm=pt(s,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((s,n)=>{this._keysMap[s.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,X(this.docs[0])?this.docs.forEach((e,s)=>{this._addString(e,s)}):this.docs.forEach((e,s)=>{this._addObject(e,s)}),this.norm.clear())}add(e){const s=this.size();X(e)?this._addString(e,s):this._addObject(e,s)}removeAt(e){this.records.splice(e,1);for(let s=e,n=this.size();s<n;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(e,s){return e[this._keysMap[s]]}size(){return this.records.length}_addString(e,s){if(!O(e)||me(e))return;let n={v:e,i:s,n:this.norm.get(e)};this.records.push(n)}_addObject(e,s){let n={i:s,$:{}};this.keys.forEach((r,i)=>{let c=r.getFn?r.getFn(e):this.getFn(e,r.path);if(O(c)){if(q(c)){let a=[];const u=[{nestedArrIndex:-1,value:c}];for(;u.length;){const{nestedArrIndex:l,value:h}=u.pop();if(O(h))if(X(h)&&!me(h)){let d={v:h,i:l,n:this.norm.get(h)};a.push(d)}else q(h)&&h.forEach((d,m)=>{u.push({nestedArrIndex:m,value:d})})}n.$[i]=a}else if(X(c)&&!me(c)){let a={v:c,n:this.norm.get(c)};n.$[i]=a}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Oe(t,e,{getFn:s=p.getFn,fieldNormWeight:n=p.fieldNormWeight}={}){const r=new we({getFn:s,fieldNormWeight:n});return r.setKeys(t.map(Ke)),r.setSources(e),r.create(),r}function gt(t,{getFn:e=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){const{keys:n,records:r}=t,i=new we({getFn:e,fieldNormWeight:s});return i.setKeys(n),i.setIndexRecords(r),i}function le(t,{errors:e=0,currentLocation:s=0,expectedLocation:n=0,distance:r=p.distance,ignoreLocation:i=p.ignoreLocation}={}){const c=e/t.length;if(i)return c;const a=Math.abs(n-s);return r?c+a/r:a?1:c}function At(t=[],e=p.minMatchCharLength){let s=[],n=-1,r=-1,i=0;for(let c=t.length;i<c;i+=1){let a=t[i];a&&n===-1?n=i:!a&&n!==-1&&(r=i-1,r-n+1>=e&&s.push([n,r]),n=-1)}return t[i-1]&&i-n>=e&&s.push([n,i-1]),s}const ne=32;function yt(t,e,s,{location:n=p.location,distance:r=p.distance,threshold:i=p.threshold,findAllMatches:c=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,includeMatches:u=p.includeMatches,ignoreLocation:l=p.ignoreLocation}={}){if(e.length>ne)throw new Error(it(ne));const h=e.length,d=t.length,m=Math.max(0,Math.min(n,d));let g=i,y=m;const b=a>1||u,k=b?Array(d):[];let S;for(;(S=t.indexOf(e,y))>-1;){let x=le(e,{currentLocation:S,expectedLocation:m,distance:r,ignoreLocation:l});if(g=Math.min(x,g),y=S+h,b){let E=0;for(;E<h;)k[S+E]=1,E+=1}}y=-1;let _=[],W=1,z=h+d;const re=1<<h-1;for(let x=0;x<h;x+=1){let E=0,I=z;for(;E<I;)le(e,{errors:x,currentLocation:m+I,expectedLocation:m,distance:r,ignoreLocation:l})<=g?E=I:z=I,I=Math.floor((z-E)/2+E);z=I;let $=Math.max(1,m-I+1),T=c?d:Math.min(m+I,d)+h,V=Array(T+2);V[T+1]=(1<<x)-1;for(let N=T;N>=$;N-=1){let Z=N-1,ae=s[t.charAt(Z)];if(b&&(k[Z]=+!!ae),V[N]=(V[N+1]<<1|1)&ae,x&&(V[N]|=(_[N+1]|_[N])<<1|1|_[N+1]),V[N]&re&&(W=le(e,{errors:x,currentLocation:Z,expectedLocation:m,distance:r,ignoreLocation:l}),W<=g)){if(g=W,y=Z,y<=m)break;$=Math.max(1,2*m-y)}}if(le(e,{errors:x+1,currentLocation:m,expectedLocation:m,distance:r,ignoreLocation:l})>g)break;_=V}const G={isMatch:y>=0,score:Math.max(.001,W)};if(b){const x=At(k,a);x.length?u&&(G.indices=x):G.isMatch=!1}return G}function xt(t){let e={};for(let s=0,n=t.length;s<n;s+=1){const r=t.charAt(s);e[r]=(e[r]||0)|1<<n-s-1}return e}const he=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 ze{constructor(e,{location:s=p.location,threshold:n=p.threshold,distance:r=p.distance,includeMatches:i=p.includeMatches,findAllMatches:c=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:h=p.ignoreLocation}={}){if(this.options={location:s,threshold:n,distance:r,includeMatches:i,findAllMatches:c,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h},e=u?e:e.toLowerCase(),e=l?he(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const d=(g,y)=>{this.chunks.push({pattern:g,alphabet:xt(g),startIndex:y})},m=this.pattern.length;if(m>ne){let g=0;const y=m%ne,b=m-y;for(;g<b;)d(this.pattern.substr(g,ne),g),g+=ne;if(y){const k=m-ne;d(this.pattern.substr(k),k)}}else d(this.pattern,0)}searchIn(e){const{isCaseSensitive:s,ignoreDiacritics:n,includeMatches:r}=this.options;if(e=s?e:e.toLowerCase(),e=n?he(e):e,this.pattern===e){let b={isMatch:!0,score:0};return r&&(b.indices=[[0,e.length-1]]),b}const{location:i,distance:c,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:h}=this.options;let d=[],m=0,g=!1;this.chunks.forEach(({pattern:b,alphabet:k,startIndex:S})=>{const{isMatch:_,score:W,indices:z}=yt(e,b,k,{location:i+S,distance:c,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:r,ignoreLocation:h});_&&(g=!0),m+=W,_&&z&&(d=[...d,...z])});let y={isMatch:g,score:g?m/this.chunks.length:1};return g&&r&&(y.indices=d),y}}class ee{constructor(e){this.pattern=e}static isMultiMatch(e){return ke(e,this.multiRegex)}static isSingleMatch(e){return ke(e,this.singleRegex)}search(){}}function ke(t,e){const s=t.match(e);return s?s[1]:null}class Et extends ee{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const s=e===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ct extends ee{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class wt extends ee{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const s=e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ft extends ee{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const s=!e.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class Mt extends ee{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const s=e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class It extends ee{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const s=!e.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,e.length-1]}}}class Qe extends ee{constructor(e,{location:s=p.location,threshold:n=p.threshold,distance:r=p.distance,includeMatches:i=p.includeMatches,findAllMatches:c=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:h=p.ignoreLocation}={}){super(e),this._bitapSearch=new ze(e,{location:s,threshold:n,distance:r,includeMatches:i,findAllMatches:c,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 We extends ee{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let s=0,n;const r=[],i=this.pattern.length;for(;(n=e.indexOf(this.pattern,s))>-1;)s=n+i,r.push([n,s-1]);const c=!!r.length;return{isMatch:c,score:c?0:1,indices:r}}}const ge=[Et,We,wt,Ft,It,Mt,Ct,Qe],Ne=ge.length,Dt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Bt="|";function bt(t,e={}){return t.split(Bt).map(s=>{let n=s.trim().split(Dt).filter(i=>i&&!!i.trim()),r=[];for(let i=0,c=n.length;i<c;i+=1){const a=n[i];let u=!1,l=-1;for(;!u&&++l<Ne;){const h=ge[l];let d=h.isMultiMatch(a);d&&(r.push(new h(d,e)),u=!0)}if(!u)for(l=-1;++l<Ne;){const h=ge[l];let d=h.isSingleMatch(a);if(d){r.push(new h(d,e));break}}}return r})}const vt=new Set([Qe.type,We.type]);class St{constructor(e,{isCaseSensitive:s=p.isCaseSensitive,ignoreDiacritics:n=p.ignoreDiacritics,includeMatches:r=p.includeMatches,minMatchCharLength:i=p.minMatchCharLength,ignoreLocation:c=p.ignoreLocation,findAllMatches:a=p.findAllMatches,location:u=p.location,threshold:l=p.threshold,distance:h=p.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:n,includeMatches:r,minMatchCharLength:i,findAllMatches:a,ignoreLocation:c,location:u,threshold:l,distance:h},e=s?e:e.toLowerCase(),e=n?he(e):e,this.pattern=e,this.query=bt(this.pattern,this.options)}static condition(e,s){return s.useExtendedSearch}searchIn(e){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:r,ignoreDiacritics:i}=this.options;e=r?e:e.toLowerCase(),e=i?he(e):e;let c=0,a=[],u=0;for(let l=0,h=s.length;l<h;l+=1){const d=s[l];a.length=0,c=0;for(let m=0,g=d.length;m<g;m+=1){const y=d[m],{isMatch:b,indices:k,score:S}=y.search(e);if(b){if(c+=1,u+=S,n){const _=y.constructor.type;vt.has(_)?a=[...a,...k]:a.push(k)}}else{u=0,c=0,a.length=0;break}}if(c){let m={isMatch:!0,score:u/c};return n&&(m.indices=a),m}}return{isMatch:!1,score:1}}}const Ae=[];function kt(...t){Ae.push(...t)}function ye(t,e){for(let s=0,n=Ae.length;s<n;s+=1){let r=Ae[s];if(r.condition(t,e))return new r(t,e)}return new ze(t,e)}const de={AND:"$and",OR:"$or"},xe={PATH:"$path",PATTERN:"$val"},Ee=t=>!!(t[de.AND]||t[de.OR]),Nt=t=>!!t[xe.PATH],jt=t=>!q(t)&&Te(t)&&!Ee(t),je=t=>({[de.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function Ve(t,e,{auto:s=!0}={}){const n=r=>{let i=Object.keys(r);const c=Nt(r);if(!c&&i.length>1&&!Ee(r))return n(je(r));if(jt(r)){const u=c?r[xe.PATH]:i[0],l=c?r[xe.PATTERN]:r[u];if(!X(l))throw new Error(rt(u));const h={keyId:pe(u),pattern:l};return s&&(h.searcher=ye(l,e)),h}let a={children:[],operator:i[0]};return i.forEach(u=>{const l=r[u];q(l)&&l.forEach(h=>{a.children.push(n(h))})}),a};return Ee(t)||(t=je(t)),n(t)}function Rt(t,{ignoreFieldNorm:e=p.ignoreFieldNorm}){t.forEach(s=>{let n=1;s.matches.forEach(({key:r,norm:i,score:c})=>{const a=r?r.weight:null;n*=Math.pow(c===0&&a?Number.EPSILON:c,(a||1)*(e?1:i))}),s.score=n})}function _t(t,e){const s=t.matches;e.matches=[],O(s)&&s.forEach(n=>{if(!O(n.indices)||!n.indices.length)return;const{indices:r,value:i}=n;let c={indices:r,value:i};n.key&&(c.key=n.key.src),n.idx>-1&&(c.refIndex=n.idx),e.matches.push(c)})}function Lt(t,e){e.score=t.score}function $t(t,e,{includeMatches:s=p.includeMatches,includeScore:n=p.includeScore}={}){const r=[];return s&&r.push(_t),n&&r.push(Lt),t.map(i=>{const{idx:c}=i,a={item:e[c],refIndex:c};return r.length&&r.forEach(u=>{u(i,a)}),a})}class J{constructor(e,s={},n){this.options={...p,...s},this.options.useExtendedSearch,this._keyStore=new at(this.options.keys),this.setCollection(e,n)}setCollection(e,s){if(this._docs=e,s&&!(s instanceof we))throw new Error(nt);this._myIndex=s||Oe(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){O(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const s=[];for(let n=0,r=this._docs.length;n<r;n+=1){const i=this._docs[n];e(i,n)&&(this.removeAt(n),n-=1,r-=1,s.push(i))}return s}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:s=-1}={}){const{includeMatches:n,includeScore:r,shouldSort:i,sortFn:c,ignoreFieldNorm:a}=this.options;let u=X(e)?X(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return Rt(u,{ignoreFieldNorm:a}),i&&u.sort(c),$e(s)&&s>-1&&(u=u.slice(0,s)),$t(u,this._docs,{includeMatches:n,includeScore:r})}_searchStringList(e){const s=ye(e,this.options),{records:n}=this._myIndex,r=[];return n.forEach(({v:i,i:c,n:a})=>{if(!O(i))return;const{isMatch:u,score:l,indices:h}=s.searchIn(i);u&&r.push({item:i,idx:c,matches:[{score:l,value:i,norm:a,indices:h}]})}),r}_searchLogical(e){const s=Ve(e,this.options),n=(a,u,l)=>{if(!a.children){const{keyId:d,searcher:m}=a,g=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(u,d),searcher:m});return g&&g.length?[{idx:l,item:u,matches:g}]:[]}const h=[];for(let d=0,m=a.children.length;d<m;d+=1){const g=a.children[d],y=n(g,u,l);if(y.length)h.push(...y);else if(a.operator===de.AND)return[]}return h},r=this._myIndex.records,i={},c=[];return r.forEach(({$:a,i:u})=>{if(O(a)){let l=n(s,a,u);l.length&&(i[u]||(i[u]={idx:u,item:a,matches:[]},c.push(i[u])),l.forEach(({matches:h})=>{i[u].matches.push(...h)}))}}),c}_searchObjectList(e){const s=ye(e,this.options),{keys:n,records:r}=this._myIndex,i=[];return r.forEach(({$:c,i:a})=>{if(!O(c))return;let u=[];n.forEach((l,h)=>{u.push(...this._findMatches({key:l,value:c[h],searcher:s}))}),u.length&&i.push({idx:a,item:c,matches:u})}),i}_findMatches({key:e,value:s,searcher:n}){if(!O(s))return[];let r=[];if(q(s))s.forEach(({v:i,i:c,n:a})=>{if(!O(i))return;const{isMatch:u,score:l,indices:h}=n.searchIn(i);u&&r.push({score:l,key:e,value:i,idx:c,norm:a,indices:h})});else{const{v:i,n:c}=s,{isMatch:a,score:u,indices:l}=n.searchIn(i);a&&r.push({score:u,key:e,value:i,norm:c,indices:l})}return r}}J.version="7.1.0";J.createIndex=Oe;J.parseIndex=gt;J.config=p;J.parseQuery=Ve;kt(St);const Re={".ts":"file-code",".tsx":"atom",".js":"file-code",".jsx":"atom",".py":"file-code",".rs":"file-code",".go":"file-code",".md":"file-text",".json":"clipboard",".yaml":"gear",".yml":"gear",".css":"palette",".scss":"palette",".html":"globe",".sql":"database",".sh":"terminal",".env":"lock",".toml":"gear",".lock":"lock",default:"file-text"};function Tt(t){switch(t){case"scout":return"class-scout";case"builder":return"class-builder";case"debugger":return"class-debugger";case"architect":return"class-architect";case"warrior":return"class-warrior";case"support":return"class-support";case"boss":return"class-boss";default:return"class-default"}}function Pt(t,e=16){var r;const s="."+(((r=t.split(".").pop())==null?void 0:r.toLowerCase())??""),n=Re[s]||Re.default;return f.jsx(H,{name:n,size:e})}function Kt(t,e=16){return f.jsx(H,{name:Tt(t),size:e,weight:"fill"})}function Ue(t){const e=Math.floor(t/1e3),s=Math.floor(e/60),n=Math.floor(s/60),r=Math.floor(n/24);return r>0?`${r}d ${n%24}h ago`:n>0?`${n}h ${s%60}m ago`:s>0?`${s}m ago`:"just now"}function Jt(t){const s=Date.now()-t;return Ue(s)}function _e(t){switch(t){case"agent":return"Agent";case"command":return"Command";case"area":return"Area";case"modified-file":return"Changed";case"building":return"Server";default:return t}}const Le=["command","agent","building","area","modified-file"];function Ot({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=He(),d=Je(),m=Xe(),g=Ze(),y=A.useRef(e);y.current=e;const b=A.useRef(s);b.current=s;const k=A.useRef(n);k.current=n;const S=A.useRef(r);S.current=r;const _=A.useRef(i);_.current=i;const W=A.useRef(c);W.current=c;const z=A.useRef(a);z.current=a;const re=A.useRef(u);re.current=u;const G=A.useRef(l);G.current=l;const[x,E]=A.useState(""),[I,$]=A.useState(0);A.useEffect(()=>{t&&(E(""),$(0))},[t]);const T=se.getShortcuts(),V=A.useMemo(()=>{if(!t)return[];const o=T.find(F=>F.id==="spawn-agent"),w=T.find(F=>F.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:o?be(o):"Alt+N",icon:f.jsx(H,{name:"plus",size:16}),action:()=>{y.current(),b.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:w?be(w):"Ctrl+K",icon:f.jsx(H,{name:"dashboard",size:16}),action:()=>{y.current(),k.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:f.jsx(H,{name:"gear",size:16}),action:()=>{y.current(),S.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:f.jsx(H,{name:"chart-line",size:16}),action:()=>{var F;y.current(),(F=G.current)==null||F.call(G)}}]},[t,T]),oe=A.useMemo(()=>t?Array.from(h.values()).map(o=>{const w=(g||[]).filter(K=>K.agentId===o.id).map(K=>K.filePath),F=[...new Set(w)],M=F.map(K=>K.split("/").pop()||K),v=[];o.lastAssignedTask&&v.push(o.lastAssignedTask);const j=`${o.class} • ${o.status} • ${o.cwd}`;let D=`${o.name} ${j}`;M.length>0&&(D+=` ${M.join(" ")} ${F.join(" ")}`),v.length>0&&(D+=` ${v.join(" ")}`);const P=Date.now()-o.lastActivity;let Q;return o.lastAssignedTask&&(o.lastAssignedTask.length>150?Q=o.lastAssignedTask.slice(0,150)+"...":Q=o.lastAssignedTask),{id:`agent-${o.id}`,type:"agent",title:o.name,subtitle:j,lastUserInput:Q,timeAway:P,icon:Kt(o.class),_searchText:D,_modifiedFiles:F,_userQueries:v,action:()=>{y.current(),se.selectAgent(o.id),se.requestTerminalExpand()}}}):[],[t,h,g]),N=A.useMemo(()=>t?Array.from(d.values()).map(o=>{var w;return{id:`area-${o.id}`,type:"area",title:o.name,subtitle:`${o.assignedAgentIds.length} agents • ${((w=o.directories)==null?void 0:w.length)||0} folders`,icon:f.jsx(H,{name:"map",size:16}),action:()=>{y.current(),se.selectArea(o.id)}}}):[],[t,d]),Z=A.useMemo(()=>t?Array.from(m.values()).filter(o=>o.type==="server"||o.type==="boss"||o.type==="database").map(o=>{var D,P,Q,K;const w=o.status==="running"?"#4ade80":o.status==="stopped"?"#f87171":"#facc15",F=o.type==="boss"?"crown":o.type==="database"?"database":"desktop";let v=`${o.type==="boss"?"Boss":o.type==="database"?"Database":"Server"} • ${o.status}`;if(o.type==="database"&&((P=(D=o.database)==null?void 0:D.connections)!=null&&P.length)){const L=o.database.connections[0];v+=` • ${L.engine} @ ${L.host}`}else o.cwd&&(v+=` • ${o.cwd}`);let j=`${o.name} ${o.type} ${o.status} ${o.cwd||""} ${((Q=o.pm2)==null?void 0:Q.name)||""}`;if(o.type==="database"&&((K=o.database)!=null&&K.connections))for(const L of o.database.connections)j+=` ${L.name} ${L.engine} ${L.host} ${L.database||""} mysql postgresql sql`;return{id:`building-${o.id}`,type:"building",title:o.name,subtitle:v,icon:f.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[f.jsx(H,{name:"status-pending",size:10,weight:"fill",color:w}),f.jsx(H,{name:F,size:16})]}),_searchText:j,action:()=>{var L;y.current(),o.type==="boss"?z.current(o.id):o.type==="database"?re.current(o.id):(L=o.pm2)!=null&&L.enabled&&W.current(o.id)}}}):[],[t,m]),ae=A.useMemo(()=>{if(!t)return[];const o=g||[],w=new Set,F=[];for(const M of o){if(w.has(M.filePath))continue;w.add(M.filePath);const v=M.filePath.split("/").pop()||M.filePath,j=M.action==="created"?"Created":M.action==="modified"?"Modified":M.action==="deleted"?"Deleted":"Read";if(F.push({id:`modified-${M.filePath}-${M.timestamp}`,type:"modified-file",title:v,subtitle:`${j} by ${M.agentName} • ${M.filePath}`,matchedText:M.filePath,icon:M.action==="deleted"?f.jsx(H,{name:"trash",size:16}):Pt(M.filePath),action:()=>{y.current();const D=Array.from(se.getState().areas.values());for(const P of D)for(const Q of P.directories||[])if(M.filePath.startsWith(Q)){se.setFileViewerPath(M.filePath),_.current(P.id);return}se.selectAgent(M.agentId)}}),F.length>=50)break}return F},[t,g]),Fe=A.useMemo(()=>new J(oe,{keys:["title","subtitle","_searchText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[oe]),Me=A.useMemo(()=>new J(V,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[V]),Ie=A.useMemo(()=>new J(N,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[N]),De=A.useMemo(()=>new J(ae,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ae]),Be=A.useMemo(()=>new J(Z,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Z]),U=A.useMemo(()=>{if(!x.trim()){const C=[];C.push(...Z);const B=[...oe].sort((R,Y)=>{const ie=R.timeAway??0,ce=Y.timeAway??0;return ie-ce});C.push(...B),C.push(...V.slice(0,2)),C.push(...N.slice(0,2));const te={};return Le.forEach((R,Y)=>{te[R]=Y}),C.sort((R,Y)=>(te[R.type]??999)-(te[Y.type]??999)),C}const o=x.toLowerCase(),w=Fe.search(x).slice(0,8),F=Me.search(x).slice(0,3),M=Ie.search(x).slice(0,2),v=De.search(x).slice(0,3),j=Be.search(x).filter(C=>{const B=C.score??1;return`${C.item.title} ${C.item.subtitle||""} ${C.item._searchText||""}`.toLowerCase().includes(o)||B<=.2}).slice(0,4),D=[],P=[],Q=[];for(const C of w){const B={...C.item};if(B._modifiedFiles&&B._modifiedFiles.length>0){const R=B._modifiedFiles.filter(Y=>{var ue;const ie=((ue=Y.split("/").pop())==null?void 0:ue.toLowerCase())||"",ce=Y.toLowerCase();return ie.includes(o)||ce.includes(o)});R.length>0&&(B.matchedFiles=R)}if(B._userQueries&&B._userQueries.length>0){const R=B._userQueries.find(Y=>Y.toLowerCase().includes(o));if(R)if(R.length>200){const ie=R.toLowerCase().indexOf(o),ce=Math.max(0,ie-60),ue=Math.min(R.length,ie+o.length+100);B.matchedQuery=(ce>0?"...":"")+R.slice(ce,ue)+(ue<R.length?"...":"")}else B.matchedQuery=R}const te=B.title.toLowerCase();te===o||te.startsWith(o)?P.push(B):Q.push(B)}const K=(C,B)=>(C.timeAway??Number.POSITIVE_INFINITY)-(B.timeAway??Number.POSITIVE_INFINITY);P.sort(K),Q.sort(K);for(const C of P)D.push(C);for(const C of j)D.push(C.item);for(const C of Q)D.push(C);for(const C of F)D.push(C.item);for(const C of M)D.push(C.item);for(const C of v)D.push(C.item);const L={};return Le.forEach((C,B)=>{L[C]=B}),D.sort((C,B)=>(L[C.type]??999)-(L[B.type]??999)),D},[x,Fe,Me,Ie,De,Be,V,oe,N,Z]);A.useEffect(()=>{I>=U.length&&$(Math.max(0,U.length-1))},[U.length,I]);const Ye=A.useCallback(o=>{if(o.altKey&&!o.ctrlKey&&!o.metaKey&&(o.key==="p"||o.key==="n"||o.key==="P"||o.key==="N")){o.preventDefault(),o.stopPropagation(),o.nativeEvent.stopImmediatePropagation();const w=o.key.toLowerCase();$(w==="p"?F=>F>0?F-1:U.length-1:F=>F<U.length-1?F+1:0);return}switch(o.key){case"Escape":o.preventDefault(),y.current();break;case"ArrowUp":o.preventDefault(),$(w=>w>0?w-1:U.length-1);break;case"ArrowDown":o.preventDefault(),$(w=>w<U.length-1?w+1:0);break;case"Enter":o.preventDefault(),U[I]&&U[I].action();break}},[U,I]),Ge=A.useCallback((o,w)=>{if(!w||!o)return o;const F=o.toLowerCase(),M=w.toLowerCase(),v=[];let j=0,D=F.indexOf(M),P=0;for(;D!==-1;)D>j&&v.push(o.slice(j,D)),v.push(fe.createElement("mark",{key:P++,className:"spotlight-highlight"},o.slice(D,D+w.length))),j=D+w.length,D=F.indexOf(M,j);return j<o.length&&v.push(o.slice(j)),v.length>0?fe.createElement(fe.Fragment,null,...v):o},[]);return{query:x,setQuery:E,selectedIndex:I,setSelectedIndex:$,results:U,handleKeyDown:Ye,highlightMatch:Ge}}const zt=A.forwardRef(function({query:e,onQueryChange:s,onKeyDown:n,onResetSelection:r},i){const{t:c}=Ce(["common"]);return f.jsxs("div",{className:"spotlight-input-wrapper",children:[f.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),f.jsx("input",{ref:i,type:"text",className:"spotlight-input",placeholder:c("common:search.spotlightPlaceholder"),value:e,onChange:a=>{s(a.target.value),r()},onKeyDown:n,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"})]})]})}),Qt=A.memo(function({result:e,isSelected:s,query:n,highlightMatch:r,onClick:i,onMouseEnter:c}){const a=e.activityText||e.matchedFiles&&e.matchedFiles.length>0||e.matchedQuery;return f.jsxs("div",{className:`spotlight-item ${s?"selected":""} ${e.activityText?"has-activity":""}`,onClick:i,onMouseEnter:c,role:"option","aria-selected":s,children:[f.jsx("span",{className:"spotlight-item-icon","aria-hidden":"true",children:e.icon}),f.jsxs("div",{className:"spotlight-item-content",children:[f.jsxs("div",{className:"spotlight-item-header",children:[f.jsx("span",{className:"spotlight-item-title",children:r(e.title,n)}),f.jsx("span",{className:`spotlight-item-type ${e.type}`,"aria-label":_e(e.type),children:_e(e.type)})]}),e.subtitle&&f.jsx("span",{className:"spotlight-item-subtitle",children:r(e.subtitle,n)}),e.activityText&&f.jsx("span",{className:"spotlight-item-activity",children:r(e.activityText,n)}),a&&f.jsxs("div",{className:"spotlight-item-details",children:[e.matchedFiles&&e.matchedFiles.length>0&&f.jsx("span",{className:"spotlight-item-files",children:e.matchedFiles.map((u,l)=>f.jsxs("span",{className:"file-badge",children:[l>0&&f.jsx("span",{className:"file-separator",children:"•"}),r(u.split("/").pop()||u,n)]},u))}),e.matchedQuery&&f.jsx("span",{className:"spotlight-item-query",children:r(e.matchedQuery,n)})]}),e.timeAway!==void 0&&f.jsx("span",{className:"spotlight-item-time",children:f.jsxs("span",{className:"spotlight-time-away",children:["Idle: ",Ue(e.timeAway)]})}),e.lastUserInput&&!e.matchedQuery&&f.jsxs("span",{className:"spotlight-item-last-input",children:['"',r(e.lastUserInput,n),'"']})]})]})}),Wt=A.forwardRef(function({results:e,selectedIndex:s,query:n,highlightMatch:r,onSelectIndex:i},c){const{t:a}=Ce(["terminal"]),u=A.useRef(!1);A.useEffect(()=>{u.current=!1},[e]),A.useEffect(()=>{const d=typeof c=="function"?null:c==null?void 0:c.current;if(!d)return;const m=()=>{u.current=!0};return d.addEventListener("mousemove",m),()=>{d.removeEventListener("mousemove",m)}},[c,e]);const l={command:a("terminal:spotlight.categories.commands"),agent:a("terminal:spotlight.categories.agents"),building:a("terminal:spotlight.categories.infrastructure"),area:a("terminal:spotlight.categories.areas"),"modified-file":a("terminal:spotlight.categories.modifiedFiles")},h=A.useMemo(()=>{const d=[];let m=null,g=[];return e.forEach((y,b)=>{y.type!==m&&(m!==null&&g.length>0&&d.push([m,g]),m=y.type,g=[]),g.push({result:y,index:b})}),m!==null&&g.length>0&&d.push([m,g]),d},[e]);return A.useEffect(()=>{if(!c||typeof c=="function")return;const d=c.current;if(!d)return;const m=d.querySelector(".spotlight-item.selected");m&&m.scrollIntoView({block:"nearest",behavior:"smooth"})},[s,c]),e.length===0?f.jsx("div",{className:"spotlight-results",ref:c,children:f.jsx("div",{className:"spotlight-empty",children:a("terminal:spotlight.noResults")})}):f.jsx("div",{className:"spotlight-results",ref:c,children:h.map(([d,m])=>f.jsxs("div",{children:[h.length>1&&f.jsx("div",{className:"spotlight-category-header",children:l[d]||d}),m.map(({result:g,index:y})=>f.jsx(Qt,{result:g,isSelected:y===s,query:n,highlightMatch:r,onClick:()=>g.action(),onMouseEnter:()=>{u.current&&i(y)}},g.id))]},d))})}),Vt=A.memo(function(){const{t:e}=Ce(["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.jsx("div",{className:"spotlight-footer-right",children:f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Esc"})," ",e("common:buttons.close")]})})]})}),Ut=768;function Xt({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=A.useRef(null),d=A.useRef(null),m=A.useRef(null),g=A.useRef(0),{query:y,setQuery:b,selectedIndex:k,setSelectedIndex:S,results:_,handleKeyDown:W,highlightMatch:z}=Ot({isOpen:t,onClose:e,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:r,onOpenFileExplorer:i,onOpenPM2LogsModal:c,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l});g.current=_.length,A.useEffect(()=>{t&&setTimeout(()=>{var x;(x=h.current)==null||x.focus()},50)},[t]),A.useEffect(()=>{if(!t)return;const x=window.visualViewport;if(!x||window.innerWidth>Ut)return;const E=()=>{const I=d.current;I&&(I.style.height=`${x.height}px`,I.style.top=`${x.offsetTop}px`)};return E(),x.addEventListener("resize",E),x.addEventListener("scroll",E),()=>{x.removeEventListener("resize",E),x.removeEventListener("scroll",E);const I=d.current;I&&(I.style.height="",I.style.top="")}},[t]),A.useEffect(()=>{if(!t)return;const x=E=>{if(E.key==="Escape"){E.preventDefault(),E.stopPropagation(),E.stopImmediatePropagation(),e();return}if(E.altKey&&!E.ctrlKey&&!E.metaKey&&(E.key==="n"||E.key==="p"||E.key==="N"||E.key==="P")){E.preventDefault(),E.stopPropagation(),E.stopImmediatePropagation();const I=E.key.toLowerCase(),$=g.current;S(I==="p"?T=>T>0?T-1:$-1:T=>T<$-1?T+1:0);return}};return window.addEventListener("keydown",x,{capture:!0}),()=>{window.removeEventListener("keydown",x,{capture:!0})}},[t,e]);const re=A.useCallback(x=>{x.target===x.currentTarget&&e()},[e]),G=A.useCallback(()=>{S(0)},[S]);return t?f.jsx("div",{ref:d,className:"spotlight-overlay",onClick:re,children:f.jsxs("div",{className:"spotlight-modal",children:[f.jsx(zt,{ref:h,query:y,onQueryChange:b,onKeyDown:W,onResetSelection:G}),f.jsx(Wt,{ref:m,results:_,selectedIndex:k,query:y,highlightMatch:z,onSelectIndex:S}),f.jsx(Vt,{})]})}):null}export{Re as FILE_ICON_NAMES,Xt as Spotlight,Vt as SpotlightFooter,zt as SpotlightInput,Qt as SpotlightItem,Wt as SpotlightResults,Ue as formatDuration,Jt as formatRelativeTime,Kt as getAgentIcon,Pt as getFileIconFromPath,_e as getTypeLabel,Ot as useSpotlightSearch};