tide-commander 1.61.0 → 1.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/assets/{BossLogsModal-3Yl1x6no.js → BossLogsModal-Cc26KWtF.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-CtdUSVOe.js → BossSpawnModal-79zixDGu.js} +1 -1
  3. package/dist/assets/{ControlsModal-Do75CTjK.js → ControlsModal-sIxaSPTd.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-BUNEvAKq.js → DockerLogsModal-RAIqQDHy.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-kZoAvzXy.js → EmbeddedEditor-SYtH65mY.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-Cx86RH8z.js → GmailOAuthSetup-DK2GlEv1.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-a4Uka8Dj.js → GoogleOAuthSetup-CprVeTSW.js} +1 -1
  8. package/dist/assets/{IframeModal-COU7VIXR.js → IframeModal-pzXWPx2i.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-BxoRYAOT.js → IntegrationsPanel-BzPNGPs-.js} +2 -2
  10. package/dist/assets/{LogViewerModal-B6gpzoR_.js → LogViewerModal-oqzbJ5iy.js} +1 -1
  11. package/dist/assets/{MonitoringModal-D8gY_Y_E.js → MonitoringModal-DadiFtmu.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-Bh_OSEfy.js → PM2LogsModal-C4hQRREX.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal--x_2h_PC.js → RestoreArchivedAreaModal-fHOJ9ZwM.js} +1 -1
  14. package/dist/assets/{Scene2DCanvas-D6JaWQir.js → Scene2DCanvas-BeHXBqTf.js} +1 -1
  15. package/dist/assets/{SceneManager-D0G3RRXw.js → SceneManager-B6E_cAYg.js} +1 -1
  16. package/dist/assets/{SkillsPanel-CMpEehte.js → SkillsPanel-B3-ni6t4.js} +1 -1
  17. package/dist/assets/{SpawnModal-B93jS-vZ.js → SpawnModal-00Lv0ZQy.js} +1 -1
  18. package/dist/assets/{SubordinateAssignmentModal-D6ljPU9_.js → SubordinateAssignmentModal-DVgwAkbS.js} +1 -1
  19. package/dist/assets/{TriggerManagerPanel-B10Fkz8b.js → TriggerManagerPanel-GUPU3sup.js} +1 -1
  20. package/dist/assets/{WorkflowEditorPanel-Dq6DsTap.js → WorkflowEditorPanel-CP26YA9V.js} +1 -1
  21. package/dist/assets/{index-DOFVfDi8.js → index-B9SzB9ov.js} +1 -1
  22. package/dist/assets/{index-CL0Zct3v.js → index-BS2yVyno.js} +2 -2
  23. package/dist/assets/{index-DqrbW5Zz.js → index-C7PPAB37.js} +1 -1
  24. package/dist/assets/index-D8tCoR93.js +51 -0
  25. package/dist/assets/{index-DifcRV30.js → index-DKziSiqq.js} +1 -1
  26. package/dist/assets/{index-C-IICy0l.js → index-DLkUpBdu.js} +1 -1
  27. package/dist/assets/{index-DiR8ltu-.js → index-DwJ7OcGh.js} +1 -1
  28. package/dist/assets/{index-B9PsO-nV.js → index-alq8vlxv.js} +1 -1
  29. package/dist/assets/{main-C0P7G341.js → main-DxFgIntP.js} +79 -79
  30. package/dist/assets/main-a5zo94fK.css +1 -0
  31. package/dist/assets/prism-asciidoc-D4osZMJ_.js +1 -0
  32. package/dist/assets/prism-awk-DiEVnfT5.js +1 -0
  33. package/dist/assets/prism-batch-CpZc0oiP.js +1 -0
  34. package/dist/assets/prism-cmake-2k54r3W4.js +1 -0
  35. package/dist/assets/prism-cobol-CImV5aEJ.js +1 -0
  36. package/dist/assets/prism-d-D6VTrqzz.js +1 -0
  37. package/dist/assets/prism-dart-MjriiaMt.js +1 -0
  38. package/dist/assets/prism-elm-CMrT16V5.js +1 -0
  39. package/dist/assets/prism-fortran-BsL8VIqV.js +1 -0
  40. package/dist/assets/prism-fsharp-rcW17Fsa.js +1 -0
  41. package/dist/assets/prism-hcl-C92OCP0l.js +1 -0
  42. package/dist/assets/prism-java-CK6tws4L.js +1 -0
  43. package/dist/assets/prism-julia-C2uswDes.js +1 -0
  44. package/dist/assets/prism-latex-Ct-fIE8d.js +1 -0
  45. package/dist/assets/prism-less-B2VBxBo8.js +1 -0
  46. package/dist/assets/prism-markup-templating-Ct1xsyfA.js +1 -0
  47. package/dist/assets/prism-nasm-D2DqwrUR.js +1 -0
  48. package/dist/assets/prism-nix-CMuMbGbY.js +1 -0
  49. package/dist/assets/prism-objectivec-B5ZTBh2_.js +1 -0
  50. package/dist/assets/prism-ocaml-DUzM3pbH.js +1 -0
  51. package/dist/assets/prism-pascal-DLd6CmKt.js +1 -0
  52. package/dist/assets/prism-php-Dt9698bA.js +1 -0
  53. package/dist/assets/prism-properties-BuDLw1wS.js +1 -0
  54. package/dist/assets/prism-protobuf-DiQ_z8B5.js +1 -0
  55. package/dist/assets/prism-rescript-BrV2LXur.js +1 -0
  56. package/dist/assets/prism-rest-Cv9ZKW_h.js +1 -0
  57. package/dist/assets/prism-sass-COF7ESLM.js +1 -0
  58. package/dist/assets/prism-solidity-ByIPMHdY.js +1 -0
  59. package/dist/assets/prism-stylus-Eax_o2yj.js +1 -0
  60. package/dist/assets/prism-tcl-kQv6vxnu.js +1 -0
  61. package/dist/assets/prism-visual-basic-BiTqmF9b.js +1 -0
  62. package/dist/assets/prism-wasm-B8bdMNge.js +1 -0
  63. package/dist/assets/prism-zig-CN7ohWT3.js +1 -0
  64. package/dist/assets/{web-EXuokvBQ.js → web-BGvcteqx.js} +1 -1
  65. package/dist/assets/{web-CCSQWj8_.js → web-DBp9A4mr.js} +1 -1
  66. package/dist/index.html +2 -2
  67. package/dist/locales/en/terminal.json +5 -1
  68. package/dist/src/packages/server/routes/agents.js +20 -2
  69. package/package.json +1 -1
  70. package/dist/assets/index-BjEqS8Jp.js +0 -49
  71. package/dist/assets/main-Bl1gp3Xq.css +0 -1
@@ -1 +1 @@
1
- import{r as u,ai as ie,aj as je,j as e,I as E,u as V,ak as ye,M as we,f as de,s as b,al as Oe,k as _e,l as G,am as U,an as De,a8 as Re,ao as Be,a5 as se,ap as Ue,aq as Ve,ar as qe,as as Ke,at as K,au as Me,a0 as Ge,a3 as He,S as ee,av as We,aw as Ye,a2 as Je,ax as le,ae as ne,ad as Ze,ay as ce,az as Xe}from"./main-C0P7G341.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const me="deivid11/tide-commander",Qe=`https://api.github.com/repos/${me}/releases/latest`,es=`https://api.github.com/repos/${me}/releases?per_page=3`,ss=3600*1e3,ve="app_update_dismissed_version",Ne="1.61.0";function ts(){var v,y;const[s,i]=u.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:Ne}),n=((y=(v=ie)==null?void 0:v.getPlatform)==null?void 0:y.call(v))==="android"||!1,o=d=>d.replace(/^v/,"").split(".").map(c=>parseInt(c,10)||0),r=(d,g)=>{const c=o(d),k=o(g),w=Math.max(c.length,k.length);for(let C=0;C<w;C++){const P=c[C]||0,D=k[C]||0;if(P>D)return 1;if(P<D)return-1}return 0},f=async d=>{var c,k;if(ie&&je&&((k=(c=ie).isNativePlatform)==null?void 0:k.call(c))===!0){const w=await je.get({url:d,headers:{Accept:"application/vnd.github.v3+json"}});return{data:w.data,status:w.status}}else{const w=await fetch(d,{headers:{Accept:"application/vnd.github.v3+json"}});return w.ok?{data:await w.json(),status:w.status}:{data:null,status:w.status}}},l=u.useCallback(async(d=!1)=>{i(g=>({...g,isChecking:!0,error:null}));try{const[g,c]=await Promise.all([f(Qe),f(es)]);if(g.status!==200)throw new Error(`GitHub API error: ${g.status}`);const k=g.data,w=k.tag_name;let C=[];c.status===200&&c.data&&(C=c.data.map(N=>({version:N.tag_name,name:N.name,publishedAt:N.published_at,releaseUrl:N.html_url})));const P=localStorage.getItem(ve);if(!d&&P===w)return i(N=>({...N,isChecking:!1,updateAvailable:!1,recentReleases:C})),null;if(!(r(w,Ne)>0))return i(N=>({...N,isChecking:!1,updateAvailable:!1,recentReleases:C})),null;const _=k.assets.find(N=>N.name.endsWith(".apk")&&N.content_type==="application/vnd.android.package-archive"),m={version:w,name:k.name,changelog:k.body,releaseUrl:k.html_url,apkUrl:(_==null?void 0:_.browser_download_url)||null,apkSize:(_==null?void 0:_.size)||null,publishedAt:k.published_at};return i(N=>({...N,isChecking:!1,updateAvailable:!0,updateInfo:m,recentReleases:C})),m}catch(g){const c=g instanceof Error?g.message:"Failed to check for updates";return i(k=>({...k,isChecking:!1,error:c})),null}},[]),a=u.useCallback(async()=>{var d,g,c;if(!((d=s.updateInfo)!=null&&d.apkUrl)){(g=s.updateInfo)!=null&&g.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!n){(c=s.updateInfo)!=null&&c.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),i(k=>({...k,error:null}))}catch(k){const w=k instanceof Error?k.message:"Failed to open download";i(C=>({...C,error:w}))}},[s.updateInfo,n]),h=u.useCallback(()=>{s.updateInfo&&localStorage.setItem(ve,s.updateInfo.version),i(d=>({...d,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),T=u.useCallback(()=>{var d;(d=s.updateInfo)!=null&&d.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${me}/releases`,"_blank")},[s.updateInfo]);return u.useEffect(()=>{if(!n)return;const d=setTimeout(()=>{l()},5e3),g=setInterval(()=>{l()},ss);return()=>{clearTimeout(d),clearInterval(g)}},[n,l]),{...s,isAndroid:n,checkForUpdate:l,downloadAndInstall:a,dismissUpdate:h,openReleasePage:T}}const ke="tide-toolbox-collapse";function as(s,i){try{const n=localStorage.getItem(`${ke}-${s}`);if(n!==null)return n==="true"}catch{}return i}function ns(s,i){try{localStorage.setItem(`${ke}-${s}`,String(i))}catch{}}function $({title:s,storageKey:i,defaultOpen:n=!1,forceOpen:o=!1,children:r,headerExtra:f}){const[l,a]=u.useState(()=>i?as(i,n):n),h=()=>{const v=!l;a(v),i&&ns(i,v)},T=o||l;return e.jsxs("div",{className:`collapsible-section ${T?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:h,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(E,{name:T?"caret-down":"caret-right",size:10})})]})]}),T&&e.jsx("div",{className:"collapsible-content",children:r})]})}function os({area:s,isSelected:i,onClick:n,onDelete:o}){const{t:r}=V(["config","common"]),f=s.assignedAgentIds.length,l=s.type==="rectangle"?r("config:areas.rect"):r("config:areas.circle");return e.jsxs("div",{className:`area-item ${i?"selected":""}`,onClick:n,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:[l," ",f>0&&`• ${f} ${f>1?r("common:labels.agents").toLowerCase():r("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:o,title:r("config:areas.deleteArea"),children:"×"})]})}function is({building:s,isSelected:i,onClick:n,onEdit:o}){var a;const{t:r}=V(["config"]),f=((a=s.pm2Status)==null?void 0:a.ports)||[],l=(h,T)=>{h.stopPropagation(),window.open(`http://localhost:${T}`,"_blank")};return e.jsxs("div",{className:`building-item ${i?"selected":""}`,onClick:n,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:ye[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx(E,{name:we(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(h=>e.jsxs("a",{href:`http://localhost:${h}`,className:"building-port-link",onClick:T=>l(T,h),title:`Open :${h}`,children:[":",h]},h))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:h=>{h.stopPropagation(),o()},title:r("config:buildings.editBuilding"),children:e.jsx(E,{name:"gear",size:14})})]})}function ls({building:s,onClose:i,onOpenModal:n}){var T,v,y,d,g,c,k,w;const{t:o}=V(["config","common"]),{buildingLogs:r}=de(),f=b.getBuildingLogs(s.id),l=Oe[s.style||"server-rack"],a=C=>{b.sendBuildingCommand(s.id,C)},h=C=>{window.open(C,"_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(E,{name:we(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:ye[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:l.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:()=>a("start"),disabled:!((T=s.commands)!=null&&T.start)||s.status==="running",title:((v=s.commands)==null?void 0:v.start)||o("config:buildings.noStartCommand"),children:[e.jsx(E,{name:"play",size:12})," ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>a("stop"),disabled:!((y=s.commands)!=null&&y.stop)||s.status==="stopped",title:((d=s.commands)==null?void 0:d.stop)||o("config:buildings.noStopCommand"),children:[e.jsx(E,{name:"stop",size:12,weight:"fill"})," ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>a("restart"),disabled:!((g=s.commands)!=null&&g.restart),title:((c=s.commands)==null?void 0:c.restart)||o("config:buildings.noRestartCommand"),children:[e.jsx(E,{name:"refresh",size:12})," ",o("common:buttons.retry")]}),e.jsxs("button",{className:"building-editor-action-btn health",onClick:()=>a("healthCheck"),disabled:!((k=s.commands)!=null&&k.healthCheck),title:((w=s.commands)==null?void 0:w.healthCheck)||o("config:buildings.noHealthCheck"),children:[e.jsx(E,{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((C,P)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>h(C.url),title:C.url,children:[e.jsx(E,{name:"link",size:12})," ",C.label||C.url]},P))})]}),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:()=>b.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((C,P)=>e.jsx("div",{className:"building-editor-log-entry",children:C},P))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:n,children:[e.jsx(E,{name:"gear",size:12})," ",o("config:buildings.fullSettings")]})})]})}async function cs(s,i){const n=U(),o=await fetch(G(`/api/areas/${s}/logo`),{method:"POST",headers:{"Content-Type":i.type||"image/png","X-Filename":encodeURIComponent(i.name),...n?{Authorization:`Bearer ${n}`}:{}},body:i});if(!o.ok){const r=await o.json().catch(()=>({error:o.statusText}));throw new Error(r.error||`Upload failed: ${o.statusText}`)}return o.json()}async function rs(s){const i=U(),n=await fetch(G(`/api/areas/${s}/logo`),{method:"DELETE",headers:{...i?{Authorization:`Bearer ${i}`}:{}}});if(!n.ok)throw new Error(`Failed to delete logo: ${n.statusText}`)}function ds(s){return _e(G(`/api/areas/logos/${s}`))}const ms=[{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 us({area:s,onClose:i,onOpenFolder:n}){var R;const{t:o}=V(["config","common"]),[r,f]=u.useState(s.name),[l,a]=u.useState(s.prompt||""),[h,T]=u.useState(!1),[v,y]=u.useState(""),[d,g]=u.useState(!1),c=u.useRef(null);u.useEffect(()=>{f(s.name)},[s.id,s.name]),u.useEffect(()=>{a(s.prompt||"")},[s.id,s.prompt]);const k=p=>{const S=p.target.value;f(S),b.updateArea(s.id,{name:S})},w=p=>{b.updateArea(s.id,{color:p})},C=p=>{const S=p.target.value;a(S),b.updateArea(s.id,{prompt:S})},P=()=>{v.trim()&&(b.addDirectoryToArea(s.id,v.trim()),y(""),T(!1))},D=(p,S)=>{S.stopPropagation(),b.removeDirectoryFromArea(s.id,p)},_=()=>{b.bringAreaToFront(s.id)},m=()=>{b.sendAreaToBack(s.id)},N=u.useCallback(()=>{let p=2,S=2;s.type==="rectangle"&&s.width&&s.height?(p=s.width,S=s.height):s.type==="circle"&&s.radius&&(p=s.radius*1.414,S=s.radius*1.414);const F=Math.min(p,S)*.4;return{width:Math.round(F*10)/10,height:Math.round(F*10)/10}},[s.type,s.width,s.height,s.radius]),X=async p=>{var F;const S=(F=p.target.files)==null?void 0:F[0];if(S){g(!0);try{const M=await cs(s.id,S),te=N();b.updateArea(s.id,{logo:{filename:M.filename,position:"center",width:te.width,height:te.height,keepAspectRatio:!0,opacity:.8}})}catch(M){console.error("Failed to upload logo:",M)}finally{g(!1),c.current&&(c.current.value="")}}},H=async()=>{try{await rs(s.id),b.updateArea(s.id,{logo:void 0})}catch(p){console.error("Failed to remove logo:",p)}},J=p=>{s.logo&&b.updateArea(s.id,{logo:{...s.logo,position:p}})},Q=p=>{if(!s.logo)return;const S=parseFloat(p.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const F=s.logo.height/s.logo.width;b.updateArea(s.id,{logo:{...s.logo,width:S,height:Math.round(S*F*10)/10}})}else b.updateArea(s.id,{logo:{...s.logo,width:S}})},x=p=>{if(!s.logo)return;const S=parseFloat(p.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const F=s.logo.width/s.logo.height;b.updateArea(s.id,{logo:{...s.logo,height:S,width:Math.round(S*F*10)/10}})}else b.updateArea(s.id,{logo:{...s.logo,height:S}})},L=()=>{s.logo&&b.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},I=p=>{s.logo&&b.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(p.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:r,onChange:k,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:De.map(p=>e.jsx("div",{className:`color-swatch ${s.color===p?"selected":""}`,style:{backgroundColor:p},onClick:()=>w(p)},p))})]}),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(E,{name:"arrow-up",size:12})," ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:m,title:o("config:areas.sendToBack"),children:[e.jsx(E,{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:[(R=s.logo)!=null&&R.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:ds(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:H,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var p;return(p=c.current)==null?void 0:p.click()},disabled:d,children:d?"...":e.jsx(E,{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:ms.map(({key:p,labelKey:S})=>{var F;return e.jsx("button",{className:`area-logo-pos-btn ${((F=s.logo)==null?void 0:F.position)===p?"active":""}`,onClick:()=>J(p),children:o(`config:areas.${S}`)},p)})})]}),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:Q,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:x,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:L}),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:I,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 p;return(p=c.current)==null?void 0:p.click()},disabled:d,children:d?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:c,type:"file",accept:"image/*",style:{display:"none"},onChange:X})]})]}),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(p=>e.jsxs("div",{className:"area-folder-item",title:p,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>n==null?void 0:n(s.id),title:o("config:areas.openFolder"),children:e.jsx(E,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:p.split("/").pop()||p}),e.jsx("button",{className:"area-folder-remove",onClick:S=>D(p,S),title:o("config:areas.removeFolder"),children:"×"})]},p)),h?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(Re,{value:v,onChange:y,onSubmit:P,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:P,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:l,onChange:C,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 gs(){const{t:s}=V(["config","common"]),i=Be(),[n,o]=u.useState(!1),[r,f]=u.useState(null),[l,a]=u.useState({name:"",key:"",value:"",description:""}),h=()=>{o(!0),f(null),a({name:"",key:"",value:"",description:""})},T=c=>{f(c.id),o(!1),a({name:c.name,key:c.key,value:c.value,description:c.description||""})},v=()=>{o(!1),f(null),a({name:"",key:"",value:"",description:""})},y=()=>{!l.name.trim()||!l.key.trim()||(r?b.updateSecret(r,{name:l.name.trim(),key:l.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:l.value,description:l.description.trim()||void 0}):b.createSecret({name:l.name.trim(),key:l.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:l.value,description:l.description.trim()||void 0}),v())},d=c=>{confirm(s("config:secrets.deleteConfirm"))&&(b.deleteSecret(c),r===c&&v())},g=c=>{navigator.clipboard.writeText(`{{${c}}}`)};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&&!n?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):i.map(c=>e.jsxs("div",{className:`secret-item ${r===c.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:c.name}),e.jsx("code",{className:"secret-item-key",onClick:()=>g(c.key),title:s("config:secrets.copyPlaceholder"),children:`{{${c.key}}}`})]}),e.jsxs("div",{className:"secret-item-actions",children:[e.jsx("button",{className:"secret-item-btn edit",onClick:()=>T(c),title:s("common:buttons.edit"),children:e.jsx(E,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>d(c.id),title:s("common:buttons.delete"),children:"×"})]})]}),c.description&&e.jsx("div",{className:"secret-item-description",children:c.description})]},c.id))}),(n||r)&&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:l.name,onChange:c=>a({...l,name:c.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:l.key,onChange:c=>a({...l,key:c.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${l.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:l.value,onChange:c=>a({...l,value:c.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:l.description,onChange:c=>a({...l,description:c.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:v,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:y,disabled:!l.name.trim()||!l.key.trim(),children:s(r?"config:secrets.update":"common:buttons.add")})]})]}),!n&&!r&&e.jsx("button",{className:"secrets-add-btn",onClick:h,children:s("config:secrets.addSecret")})]})}function hs(){const{t:s}=V(["config","common"]),[i,n]=u.useState([]),[o,r]=u.useState(new Set),[f,l]=u.useState(new Set),[a,h]=u.useState(!1),[T,v]=u.useState(!1),[y,d]=u.useState(null),[g,c]=u.useState(null),[k,w]=u.useState(null);u.useEffect(()=>{se(G("/api/config/categories")).then(x=>x.json()).then(x=>{const L=Array.isArray(x)?x:[];n(L),r(new Set(L.map(I=>I.id)))}).catch(x=>console.error("Failed to fetch config categories:",x))},[]);const C=x=>{r(L=>{const I=new Set(L);return I.has(x)?I.delete(x):I.add(x),I})},P=x=>{l(L=>{const I=new Set(L);return I.has(x)?I.delete(x):I.add(x),I})},D=()=>r(new Set(i.map(x=>x.id))),_=()=>r(new Set),m=()=>{g&&l(new Set(g.categories.map(x=>x.id)))},N=()=>l(new Set),X=async()=>{var x;if(o.size!==0){h(!0),w(null);try{const L=Array.from(o).join(","),I=await se(G(`/api/config/export?categories=${L}`));if(!I.ok)throw new Error("Export failed");const R=await I.blob(),p=window.URL.createObjectURL(R),S=document.createElement("a");S.href=p;const F=I.headers.get("Content-Disposition"),M=((x=F==null?void 0:F.match(/filename="(.+)"/))==null?void 0:x[1])||"tide-commander-config.zip";S.download=M,document.body.appendChild(S),S.click(),document.body.removeChild(S),window.URL.revokeObjectURL(p),w({type:"success",text:s("config:data.exportSuccess")})}catch(L){w({type:"error",text:L.message||"Export failed"})}finally{h(!1)}}},H=async x=>{var I;const L=(I=x.target.files)==null?void 0:I[0];if(L){d(L),w(null),c(null),l(new Set);try{const R=await se(G("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await L.arrayBuffer()});if(!R.ok){const F=await R.json();throw new Error(F.error||"Failed to preview config file")}const p=await R.json(),S=Array.isArray(p.categories)?p.categories:[];c({...p,categories:S}),l(new Set(S.map(F=>F.id)))}catch(R){w({type:"error",text:R.message||"Failed to read config file"}),d(null)}}},J=async()=>{if(!(!y||f.size===0)){v(!0),w(null);try{const x=Array.from(f).join(","),L=await se(G(`/api/config/import?categories=${x}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await y.arrayBuffer()}),I=await L.json();if(!L.ok)throw new Error(I.error||"Import failed");w({type:"success",text:I.message||s("config:data.importSuccess")}),d(null),c(null),l(new Set)}catch(x){w({type:"error",text:x.message||"Import failed"})}finally{v(!1)}}},Q=()=>{d(null),c(null),l(new Set),w(null)};return e.jsxs("div",{className:"data-section",children:[k&&e.jsx("div",{className:`data-message data-message-${k.type}`,children:k.text}),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:D,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:_,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:i.map(x=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(x.id),onChange:()=>C(x.id)}),e.jsx("span",{className:"data-category-name",children:x.name})]},x.id))}),e.jsx("button",{className:"data-action-btn export",onClick:X,disabled:a||o.size===0,children:a?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")})}),y?g?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:y.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(g.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:m,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:N,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:g.categories.map(x=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:f.has(x.id),onChange:()=>P(x.id)}),e.jsx("span",{className:"data-category-name",children:x.name}),x.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",x.fileCount," ",s("config:data.files"),")"]})]},x.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:Q,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:J,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:H,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}function ps(){const[s,i]=u.useState(()=>Ue()),n=o=>{i(o);const r=qe(o);Ke(r)};return e.jsx("div",{className:"theme-selector",children:e.jsx("div",{className:"theme-selector-grid",children:Ve.map(o=>e.jsxs("button",{className:`theme-option ${s===o.id?"active":""}`,onClick:()=>n(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 fs(){const{t:s}=V(["config"]),{updateAvailable:i,updateInfo:n,recentReleases:o,isChecking:r,error:f,currentVersion:l,isAndroid:a,checkForUpdate:h,downloadAndInstall:T,openReleasePage:v}=ts(),y=g=>g?`${(g/(1024*1024)).toFixed(1)} MB`:"",d=g=>new Date(g).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(E,{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:l}),i&&n?e.jsx("span",{className:"about-version-update-badge",onClick:v,title:`Update available: ${n.version}`,children:n.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&&n?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:n.version})]}),n.apkSize&&e.jsxs("div",{className:"about-update-size",children:[s("config:about.sizeLabel"),": ",y(n.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:v,children:s("config:about.changelog")}),a&&n.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:v,children:s("config:about.viewRelease")})]})]}):e.jsxs("div",{className:"about-update-check",children:[e.jsx("span",{className:"about-update-status",children:s(r?"config:about.checkingUpdates":"config:about.upToDate")}),e.jsx("button",{className:"about-update-btn check",onClick:()=>h(!0),disabled:r,children:r?"...":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(g=>e.jsxs("a",{href:g.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:`about-release-item ${g.version===`v${l}`||g.version===l?"current":""}`,children:[e.jsx("span",{className:"about-release-version",children:g.version}),e.jsx("span",{className:"about-release-date",children:d(g.publishedAt)})]},g.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(E,{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 xs={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅",docx:"📄"};function bs({onOpenModal:s}){const[i,n]=u.useState([]),[o,r]=u.useState(!0),f=u.useCallback(async()=>{try{const l=await se(G("/api/integrations"));if(!l.ok)return;const a=await l.json();n(a)}catch{}finally{r(!1)}},[]);return u.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(l=>{const a=xs[l.id]||"🔌",h=!!l.status.error,T=l.status.connected,v=h?"#f38ba8":T?"#a6e3a1":"#fab387",y=h?"Error":T?"Connected":"Setup Required",d=h?"✗":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:a}),e.jsx("span",{style:{flex:1,color:"var(--text-primary, #cdd6f4)",fontWeight:500},children:l.name}),e.jsxs("span",{style:{color:v,fontSize:11,fontWeight:500,whiteSpace:"nowrap"},children:[d," ",y]}),e.jsx("button",{onClick:()=>s(l.id),title:`Configure ${l.name}`,style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",fontSize:14,color:"var(--text-secondary, #a6adc8)",borderRadius:4,flexShrink:0},onMouseEnter:g=>{g.target.style.color="var(--text-primary, #cdd6f4)"},onMouseLeave:g=>{g.target.style.color="var(--text-secondary, #a6adc8)"},children:"⚙️"})]},l.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:l=>{l.target.style.borderColor="var(--accent, #89b4fa)",l.target.style.color="var(--accent, #89b4fa)"},onMouseLeave:l=>{l.target.style.borderColor="var(--border, #313244)",l.target.style.color="var(--text-secondary, #a6adc8)"},children:"Manage All Integrations"})]})}async function js(){const s=U(),i=await fetch(`${K()}/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 vs(s){const i=U(),n=await fetch(`${K()}/api/agents/system-settings/prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({prompt:s})});if(!n.ok)throw new Error(`Failed to update system prompt: ${n.statusText}`)}async function Ns(){const s=U(),i=await fetch(`${K()}/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 ys(){const s=U(),i=await fetch(`${K()}/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 ws(s){const i=U(),n=await fetch(`${K()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!n.ok)throw new Error(`Failed to update echo prompt setting: ${n.statusText}`)}async function ks(){const s=U(),i=await fetch(`${K()}/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 Ss(s){const i=U(),n=await fetch(`${K()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({path:s})});if(!n.ok)throw new Error(`Failed to update codex binary path: ${n.statusText}`)}async function Cs(){const s=U(),i=await fetch(`${K()}/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 As(s){const i=U(),n=await fetch(`${K()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!n.ok)throw new Error(`Failed to update tmux mode setting: ${n.statusText}`)}function Ts({isOpen:s,onClose:i}){const{t:n}=V(["config"]),[o,r]=u.useState(""),[f,l]=u.useState(""),[a,h]=u.useState(!0),[T,v]=u.useState(null),[y,d]=u.useState(null),[g,c]=u.useState(!1);u.useEffect(()=>{s&&k()},[s]);const k=async()=>{try{h(!0),v(null),d(null);const m=await js();r(m),l(m),c(!1)}catch(m){v(m instanceof Error?m.message:"Failed to load system prompt")}finally{h(!1)}},w=m=>{const N=m.target.value;r(N),c(N!==f),v(null),d(null)},C=async()=>{try{v(null),d(null),await vs(o),l(o),c(!1),d(n("config:systemPrompt.saved"))}catch(m){v(m instanceof Error?m.message:"Failed to save system prompt")}},P=async()=>{if(window.confirm(n("config:systemPrompt.confirmClear")))try{v(null),d(null),await Ns(),r(""),l(""),c(!1),d(n("config:systemPrompt.cleared"))}catch(m){v(m instanceof Error?m.message:"Failed to clear system prompt")}},D=()=>{r(f),c(!1),v(null),d(null)},_=m=>{if(m.key==="Escape"){if(g&&!window.confirm("You have unsaved changes. Close anyway?")){m.preventDefault();return}i()}};return s?e.jsx(Me,{children:e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:i,children:e.jsxs("div",{className:"system-prompt-modal",onClick:m=>m.stopPropagation(),onKeyDown:_,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:n("config:systemPrompt.title")}),e.jsx("button",{className:"modal-close",onClick:i,"aria-label":"Close",children:e.jsx(E,{name:"close",size:16})})]}),e.jsx("div",{className:"modal-body",children:a?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:n("config:systemPrompt.description")}),T&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(E,{name:"warn",size:14})}),T]}),y&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(E,{name:"check",size:14})}),y]}),e.jsxs("div",{className:"editor-wrapper",children:[e.jsxs("div",{className:"editor-header",children:[e.jsx("label",{htmlFor:"prompt-input",className:"editor-label",children:n("config:systemPrompt.editPrompt")}),e.jsxs("span",{className:"char-count",children:[o.length," ",n("config:systemPrompt.characters")]})]}),e.jsx("textarea",{id:"prompt-input",className:"prompt-editor",value:o,onChange:w,placeholder:n("config:systemPrompt.placeholder"),rows:18,autoFocus:!0}),e.jsx("div",{className:"editor-hint",children:n("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:P,disabled:!o||a,children:n("config:systemPrompt.clear")})}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:i,children:"Close"}),e.jsx("button",{className:"btn btn-secondary",onClick:D,disabled:!g||a,children:n("config:systemPrompt.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:C,disabled:!g||a,children:n("config:systemPrompt.save")})]})]})]})})}):null}const Is=[{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:"🌙"}],Es=[{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:"🔴"}],Ps=[{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:"👎"}],Ls=[{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:"💜"}],Fs=[{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"}],$s=[{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"}],zs={showTrees:"trees",showBushes:"bushes",showHouse:"house",showLamps:"lamps",showGrass:"grass",showClouds:"clouds"},Os={none:"grass","pokemon-stadium":"pokemon"},_s={"emote-yes":"yes","emote-no":"no"},Ds={"":"auto","#4a90d9":"dayBlue","#0a1a2a":"night","#ff6b35":"sunset","#1a0a2e":"purple","#2d5a27":"matrix","#8b0000":"blood","#000000":"void"};function B({checked:s,onChange:i}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,onChange:n=>i(n.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function Z({options:s,value:i,onChange:n,iconOnly:o=!1}){return e.jsx("div",{className:"chip-selector",children:s.map(r=>e.jsxs("button",{className:`chip ${i===r.value?"active":""}`,onClick:()=>n(r.value),title:r.label,children:[e.jsx("span",{className:"chip-icon",children:r.icon}),!o&&e.jsx("span",{className:"chip-label",children:r.label})]},r.value))})}function j({text:s,query:i}){if(!i.trim())return e.jsx(e.Fragment,{children:s});const n=s.toLowerCase(),o=i.toLowerCase(),r=n.indexOf(o);if(r===-1)return e.jsx(e.Fragment,{children:s});const f=s.slice(0,r),l=s.slice(r,r+i.length),a=s.slice(r+i.length);return e.jsxs(e.Fragment,{children:[f,e.jsx("mark",{className:"search-highlight",children:l}),a]})}const Rs=[{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:"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"]}],re=[{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 Bs({config:s,onChange:i,searchQuery:n="",onOpenIntegrationsModal:o,onOpenMonitoringModal:r,onOpenWorkflowEditor:f,onOpenTriggerManager:l}){var xe;const{t:a}=V(["config","common"]),h=de(),T=Ge(),[v,y]=u.useState(()=>He(ee.DEFAULT_AGENT_CLASS)||"scout"),[d,g]=u.useState(h.settings.historyLimit),[c,k]=u.useState(()=>We()),[w,C]=u.useState(!1),[P,D]=u.useState(()=>U()),[_,m]=u.useState(!1),[N,X]=u.useState(!1),[H,J]=u.useState(""),[Q,x]=u.useState(!1),[L,I]=u.useState(""),[R,p]=u.useState(!1);u.useEffect(()=>{ks().then(I).catch(()=>{})},[]),u.useEffect(()=>{ys().then(t=>{t!==h.settings.experimentalEchoPrompt&&b.updateSettings({experimentalEchoPrompt:t})}).catch(()=>{})},[]),u.useEffect(()=>{Cs().then(t=>{t!==h.settings.tmuxMode&&b.updateSettings({tmuxMode:t})}).catch(()=>{})},[]),u.useEffect(()=>Ye(t=>{k(t),C(!1)}),[]);const S=Is.map(t=>({...t,label:a(`config:time.${t.value}`)})),F=Es.map(t=>({...t,label:a(`config:floor.${Os[t.value]||t.value}`)})),M=Ps.map(t=>({...t,label:a(`config:animation.${_s[t.value]||t.value}`)})),te=Ls.map(t=>({...t,label:a(`config:colorMode.${t.value}`)})),Se=Fs.map(t=>({...t,label:a(`config:terrain.${zs[t.key]}`)})),Ce=$s.map(t=>({...t,label:a(`config:sky.${Ds[t.value??""]}`)})),ae=n.trim()?Rs.filter(t=>{const O=n.toLowerCase();return t.title.toLowerCase().includes(O)||t.keywords.some(oe=>oe.toLowerCase().includes(O))}).map(t=>t.id):null,A=t=>ae?ae.includes(t):!0,q=h.settings.customAgentNames||[],Ae=q.length>0?q:Je,ue=()=>{const t=H.trim();t&&!q.includes(t)&&(b.updateSettings({customAgentNames:[...q,t]}),J(""))},Te=t=>{b.updateSettings({customAgentNames:q.filter(O=>O!==t)})},Ie=()=>{b.updateSettings({customAgentNames:[]})},Ee=t=>{k(t),C(!0)},ge=()=>{Xe(c),C(!1),ce()},Pe=t=>{D(t),m(!0)},he=()=>{ne(ee.AUTH_TOKEN,P),m(!1),ce()},Le=t=>{I(t),p(!0)},pe=()=>{Ss(L).catch(()=>{}),p(!1)},W=t=>{i({...s,terrain:{...s.terrain,...t}})},Y=t=>{i({...s,modelStyle:{...s.modelStyle,...t}})},fe=t=>{i({...s,animations:{...s.animations,...t}})},Fe=t=>{g(t),b.updateSettings({historyLimit:t})},$e=t=>{const O=s.terrain[t];typeof O=="boolean"&&W({[t]:!O})},z=n.trim().length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-section",children:[ae&&ae.length===0&&e.jsx("div",{className:"config-no-results",children:a("config:noResults",{query:n})}),A("general")&&e.jsxs($,{title:a("config:sections.general"),storageKey:"general",defaultOpen:!0,forceOpen:z&&A("general"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:general.history"),query:n})}),e.jsx("input",{type:"number",className:"config-input config-input-sm",value:d,onChange:t=>Fe(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(j,{text:a("config:general.hideCosts"),query:n})}),e.jsx(B,{checked:h.settings.hideCost,onChange:t=>b.updateSettings({hideCost:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:general.grid"),query:n})}),e.jsx(B,{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(j,{text:a("config:general.showFPS"),query:n})}),e.jsx(B,{checked:h.settings.showFPS,onChange:t=>b.updateSettings({showFPS:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:general.fpsLimit"),query:n})}),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(j,{text:a("config:general.powerSaving"),query:n})," ",e.jsx(E,{name:"bolt",size:12})]}),e.jsx(B,{checked:h.settings.powerSaving,onChange:t=>b.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(j,{text:a("config:general.tmuxMode"),query:n})}),e.jsx(B,{checked:h.settings.tmuxMode,onChange:async t=>{b.updateSettings({tmuxMode:t});try{await As(t)}catch(O){console.error("Failed to sync tmux mode setting to server:",O)}}})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:general.vibrationIntensity"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"5",step:"1",value:h.settings.vibrationIntensity,onChange:t=>b.updateSettings({vibrationIntensity:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:h.settings.vibrationIntensity===0?a("config:vibrationValues.off"):h.settings.vibrationIntensity===1?a("config:vibrationValues.ultraLight"):h.settings.vibrationIntensity===2?a("config:vibrationValues.veryLight"):h.settings.vibrationIntensity===3?a("config:vibrationValues.light"):h.settings.vibrationIntensity===4?a("config:vibrationValues.medium"):a("config:vibrationValues.heavy")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:general.externalEditor"),query:n})}),e.jsx("input",{type:"text",className:"config-input",placeholder:a("config:general.externalEditorPlaceholder"),value:h.settings.externalEditorCommand||"",onChange:t=>b.updateSettings({externalEditorCommand:t.target.value})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:general.tabTitle"),query:n})}),e.jsx("input",{type:"text",className:"config-input",placeholder:a("config:general.tabTitlePlaceholder"),value:h.settings.tabTitle||"",onChange:t=>b.updateSettings({tabTitle:t.target.value})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:general.language"),query:n})}),e.jsx(Z,{options:re,value:localStorage.getItem("tide-commander-language-mode")==="manual"?((xe=re.find(t=>t.value!=="auto"&&le.language.startsWith(t.value.split("-")[0])))==null?void 0:xe.value)||"en":"auto",onChange:t=>{var O;if(t==="auto"){localStorage.setItem("tide-commander-language-mode","auto");const oe=navigator.language,ze=((O=re.find(be=>be.value!=="auto"&&oe.startsWith(be.value.split("-")[0])))==null?void 0:O.value)||"en";le.changeLanguage(ze)}else localStorage.setItem("tide-commander-language-mode","manual"),le.changeLanguage(t)}})]})]}),A("agentNames")&&e.jsx($,{title:a("config:sections.agentNames"),storageKey:"agentNames",defaultOpen:!1,forceOpen:z&&A("agentNames"),children:e.jsxs("div",{className:"agent-names-section",children:[e.jsx("span",{className:"config-hint",children:q.length>0?a("config:agentNames.customConfigured",{count:q.length}):a("config:agentNames.usingDefaults")}),e.jsxs("div",{className:"agent-names-input-row",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",placeholder:a("config:agentNames.addPlaceholder"),value:H,onChange:t=>J(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ue()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:ue,disabled:!H.trim(),title:a("config:agentNames.addName"),children:"+"})]}),e.jsx("div",{className:"agent-names-list",children:Ae.map((t,O)=>e.jsxs("div",{className:"agent-name-chip",children:[e.jsx("span",{className:"agent-name-text",children:t}),q.length>0&&e.jsx("button",{className:"agent-name-remove",onClick:()=>Te(t),title:a("common:buttons.remove"),children:"x"})]},`${t}-${O}`))}),q.length>0&&e.jsx("button",{className:"config-btn config-btn-link",onClick:Ie,children:a("common:buttons.resetToDefaults")})]})}),A("defaultClass")&&e.jsx($,{title:"Default Spawn Class",storageKey:"defaultClass",defaultOpen:!1,forceOpen:z&&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${v==="random"?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{y("random"),ne(ee.DEFAULT_AGENT_CLASS,"random")},children:e.jsx("span",{className:"agent-name-text",children:"🎲 Random"})}),Object.entries(Ze).map(([t,O])=>e.jsx("div",{className:`agent-name-chip${v===t?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{y(t),ne(ee.DEFAULT_AGENT_CLASS,t)},children:e.jsxs("span",{className:"agent-name-text",children:[O.icon," ",t.charAt(0).toUpperCase()+t.slice(1)]})},t)),T.map(t=>e.jsx("div",{className:`agent-name-chip${v===t.id?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{y(t.id),ne(ee.DEFAULT_AGENT_CLASS,t.id)},children:e.jsxs("span",{className:"agent-name-text",children:[t.icon," ",t.name]})},t.id))]})]})}),A("appearance")&&e.jsx($,{title:a("config:sections.appearance"),storageKey:"appearance",defaultOpen:!1,forceOpen:z&&A("appearance"),children:e.jsx(ps,{})}),A("connection")&&e.jsxs($,{title:a("config:sections.connection"),storageKey:"connection",defaultOpen:!1,forceOpen:z&&A("connection"),children:[e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:connection.backendUrl"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:c,onChange:t=>Ee(t.target.value),placeholder:"http://localhost:5174",onKeyDown:t=>{t.key==="Enter"&&w&&ge()}}),w&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:ge,title:a("config:connection.saveAndReconnect"),children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.autoDetectHint")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:connection.authToken"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:N?"text":"password",className:"config-input config-input-full",value:P,onChange:t=>Pe(t.target.value),placeholder:a("config:connection.tokenPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&_&&he()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>X(!N),title:a(N?"config:connection.hideToken":"config:connection.showToken"),children:e.jsx(E,{name:N?"eye-closed":"eye",size:14})}),_&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:he,title:a("config:connection.saveAndReconnect"),children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.tokenRequired")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:connection.codexBinaryPath"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:L,onChange:t=>Le(t.target.value),placeholder:a("config:connection.codexBinaryPathPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&R&&pe()}}),R&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:pe,children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.codexBinaryPathHint")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("common:buttons.reconnect"),query:n})}),e.jsx("button",{className:"config-btn",onClick:()=>ce(),title:"Force reconnect to server",children:a("common:buttons.reconnect")})]})]}),A("scene")&&e.jsxs($,{title:a("config:sections.scene"),storageKey:"scene",defaultOpen:!1,forceOpen:z&&A("scene"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:scene.characterSize"),query:n})}),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(j,{text:a("config:scene.scale2d",{defaultValue:"2D Scale"}),query:n})}),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(j,{text:a("config:scene.scale3d",{defaultValue:"3D Scale"}),query:n})}),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(j,{text:a("config:scene.show2DTaskLabels",{defaultValue:"Show 2D task labels"}),query:n})}),e.jsx(B,{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(j,{text:a("config:scene.time"),query:n})}),e.jsx(Z,{options:S,value:s.timeMode,onChange:t=>i({...s,timeMode:t}),iconOnly:!0})]})]}),A("terrain")&&e.jsxs($,{title:a("config:sections.terrain"),storageKey:"terrain",defaultOpen:!1,forceOpen:z&&A("terrain"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:terrainSettings.simpleMode",{defaultValue:"Simple Mode"}),query:n})}),e.jsx(B,{checked:s.terrain.simpleMode??!1,onChange:t=>W({simpleMode:t})})]}),e.jsx("div",{className:"terrain-icons",style:{opacity:s.terrain.simpleMode?.4:1,pointerEvents:s.terrain.simpleMode?"none":"auto"},children:Se.map(t=>e.jsx("button",{className:`terrain-icon-btn ${s.terrain[t.key]?"active":""}`,onClick:()=>$e(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(j,{text:a("config:terrainSettings.fog"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.terrain.fogDensity,onChange:t=>W({fogDensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.fogDensity===0?a("config:fogValues.off"):s.terrain.fogDensity<=1?a("config:fogValues.low"):a("config:fogValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:terrainSettings.brightness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.2",max:"2",step:"0.1",value:s.terrain.brightness,onChange:t=>W({brightness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.brightness<=.5?a("config:brightnessValues.dark"):s.terrain.brightness<=1.2?a("config:brightnessValues.normal"):a("config:brightnessValues.bright")})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:terrainSettings.floor"),query:n})}),e.jsx(Z,{options:F,value:s.terrain.floorStyle,onChange:t=>W({floorStyle:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:terrainSettings.sky"),query:n})}),e.jsx("div",{className:"sky-color-selector",children:Ce.map(t=>e.jsx("button",{className:`sky-color-btn ${s.terrain.skyColor===t.value?"active":""}`,onClick:()=>W({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(j,{text:a("config:terrainSettings.battlefieldSize"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"30",max:"200",step:"10",value:s.terrain.battlefieldSize,onChange:t=>W({battlefieldSize:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.battlefieldSize})]})]}),A("modelStyle")&&e.jsxs($,{title:a("config:sections.modelStyle"),storageKey:"modelStyle",defaultOpen:!1,forceOpen:z&&A("modelStyle"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:modelStyleSettings.saturation"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.modelStyle.saturation,onChange:t=>Y({saturation:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.saturation<=.3?a("config:saturationValues.gray"):s.modelStyle.saturation<=1.2?a("config:saturationValues.normal"):a("config:saturationValues.vivid")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:modelStyleSettings.roughness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.roughness,onChange:t=>Y({roughness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.roughness<0?a("config:roughnessValues.auto"):s.modelStyle.roughness<=.3?a("config:roughnessValues.glossy"):s.modelStyle.roughness<=.7?a("config:roughnessValues.normal"):a("config:roughnessValues.matte")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:modelStyleSettings.metalness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.metalness,onChange:t=>Y({metalness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.metalness<0?a("config:metalnessValues.auto"):s.modelStyle.metalness<=.3?a("config:metalnessValues.plastic"):s.modelStyle.metalness<=.7?a("config:metalnessValues.mixed"):a("config:metalnessValues.metal")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:modelStyleSettings.glow"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"1",step:"0.05",value:s.modelStyle.emissiveBoost,onChange:t=>Y({emissiveBoost:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.emissiveBoost<=.1?a("config:glowValues.off"):s.modelStyle.emissiveBoost<=.4?a("config:glowValues.low"):s.modelStyle.emissiveBoost<=.7?a("config:glowValues.med"):a("config:glowValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:modelStyleSettings.reflections"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"2",step:"0.1",value:s.modelStyle.envMapIntensity,onChange:t=>Y({envMapIntensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.envMapIntensity<0?a("config:reflectionValues.auto"):s.modelStyle.envMapIntensity<=.3?a("config:reflectionValues.low"):s.modelStyle.envMapIntensity<=1?a("config:reflectionValues.normal"):a("config:reflectionValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:modelStyleSettings.wireframe"),query:n})}),e.jsx(B,{checked:s.modelStyle.wireframe,onChange:t=>Y({wireframe:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:modelStyleSettings.colorMode"),query:n})}),e.jsx(Z,{options:te,value:s.modelStyle.colorMode,onChange:t=>Y({colorMode:t}),iconOnly:!0})]})]}),A("animations")&&e.jsxs($,{title:a("config:sections.animations"),storageKey:"animations",defaultOpen:!1,forceOpen:z&&A("animations"),children:[e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:animationSettings.idle"),query:n})}),e.jsx(Z,{options:M,value:s.animations.idleAnimation,onChange:t=>fe({idleAnimation:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:animationSettings.working"),query:n})}),e.jsx(Z,{options:M,value:s.animations.workingAnimation,onChange:t=>fe({workingAnimation:t}),iconOnly:!0})]})]}),A("secrets")&&e.jsx($,{title:a("config:sections.secrets"),storageKey:"secrets",defaultOpen:!1,forceOpen:z&&A("secrets"),children:e.jsx(gs,{})}),A("systemPrompt")&&e.jsx($,{title:a("config:sections.systemPrompt"),storageKey:"systemPrompt",defaultOpen:!1,forceOpen:z&&A("systemPrompt"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:systemPrompt.title"),query:n})}),e.jsx("button",{className:"config-button",onClick:()=>x(!0),children:a("config:systemPrompt.editPrompt")})]})}),A("data")&&e.jsx($,{title:a("config:sections.data"),storageKey:"data",defaultOpen:!1,forceOpen:z&&A("data"),children:e.jsx(hs,{})}),A("integrations")&&e.jsx($,{title:"Integrations",storageKey:"integrations",defaultOpen:!1,forceOpen:z&&A("integrations"),children:e.jsx(bs,{onOpenModal:t=>o==null?void 0:o(t)})}),A("workflows")&&e.jsxs($,{title:"Workflows",storageKey:"workflows",defaultOpen:!1,forceOpen:z&&A("workflows"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(j,{text:"Create and manage automated workflow pipelines with visual state machine editor",query:n})})}),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($,{title:"Triggers",storageKey:"triggers",defaultOpen:!1,forceOpen:z&&A("triggers"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(j,{text:"Create and manage event-driven triggers that fire agents with templates",query:n})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>l==null?void 0:l(),children:"Open Trigger Manager"})})]}),A("monitoring")&&e.jsxs($,{title:"Monitoring",storageKey:"monitoring",defaultOpen:!1,forceOpen:z&&A("monitoring"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(j,{text:"View event logs, trigger history, workflow traces, and system stats",query:n})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>r==null?void 0:r(),children:"Open Monitoring & Logs"})})]}),A("experimental")&&e.jsxs($,{title:a("config:sections.experimental"),storageKey:"experimental",defaultOpen:!1,forceOpen:z&&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(j,{text:a("config:experimental.2dView"),query:n})," ",e.jsx(E,{name:"map",size:12})]}),e.jsx(B,{checked:h.settings.experimental2DView,onChange:t=>b.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(j,{text:a("config:experimental.voiceAssistant"),query:n})," ",e.jsx(E,{name:"microphone",size:12})]}),e.jsx(B,{checked:h.settings.experimentalVoiceAssistant,onChange:t=>b.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(j,{text:a("config:experimental.tts"),query:n})," ",e.jsx(E,{name:"speaker-on",size:12})]}),e.jsx(B,{checked:h.settings.experimentalTTS,onChange:t=>b.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(j,{text:a("config:experimental.echoPrompt"),query:n})}),e.jsx(B,{checked:h.settings.experimentalEchoPrompt,onChange:async t=>{b.updateSettings({experimentalEchoPrompt:t});try{await ws(t)}catch(O){console.error("Failed to sync echo prompt setting to server:",O)}}})]}),e.jsx("span",{className:"config-hint",children:a("config:experimental.hint")})]}),A("about")&&e.jsx($,{title:a("config:sections.about"),storageKey:"about",defaultOpen:!1,forceOpen:z&&A("about"),children:e.jsx(fs,{})})]}),e.jsx(Ts,{isOpen:Q,onClose:()=>x(!1)})]})}function Ks({onConfigChange:s,onToolChange:i,config:n,isOpen:o,onClose:r,onOpenBuildingModal:f,onOpenAreaExplorer:l,onOpenIntegrationsModal:a,onOpenMonitoringModal:h,onOpenWorkflowEditor:T,onOpenTriggerManager:v}){const{t:y}=V(["config","common"]),d=de(),g=Array.from(d.areas.values()),c=Array.from(d.buildings.values()),[k,w]=u.useState(""),C=u.useRef(null);if(u.useEffect(()=>{const m=N=>{N.key==="Escape"&&o&&r()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[o,r]),u.useEffect(()=>{if(o&&C.current){const m=setTimeout(()=>{var N;(N=C.current)==null||N.focus()},50);return()=>clearTimeout(m)}},[o]),!o)return null;const P=m=>{const N=d.activeTool===m?null:m;i(N)},D=m=>{b.selectArea(d.selectedAreaId===m?null:m),i("select")},_=(m,N)=>{m.stopPropagation(),b.deleteArea(N)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"toolbox-backdrop",onClick:r}),e.jsxs("aside",{className:"toolbox",children:[e.jsxs("div",{className:"toolbox-header",children:[e.jsx("span",{children:y("config:title")}),e.jsx("button",{className:"toolbox-close-btn",onClick:r,title:y("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:C,type:"text",placeholder:y("config:searchPlaceholder"),value:k,onChange:m=>w(m.target.value),className:"toolbox-search-input"}),k&&e.jsx("button",{className:"toolbox-search-clear",onClick:()=>w(""),children:"×"})]}),e.jsxs("div",{className:"toolbox-content",children:[e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsxs($,{title:y("config:areas.title",{count:g.length}),storageKey:"areas",children:[e.jsxs("div",{className:"tool-buttons",children:[e.jsx("button",{className:`tool-btn ${d.activeTool==="select"?"active":""}`,onClick:()=>P("select"),title:y("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 ${d.activeTool==="rectangle"?"active":""}`,onClick:()=>P("rectangle"),title:y("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 ${d.activeTool==="circle"?"active":""}`,onClick:()=>P("circle"),title:y("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:g.length===0?e.jsx("div",{className:"areas-empty",children:y("config:areas.drawToCreate")}):g.map(m=>e.jsx(os,{area:m,isSelected:d.selectedAreaId===m.id,onClick:()=>D(m.id),onDelete:N=>_(N,m.id)},m.id))})]})}),d.selectedAreaId&&e.jsx(us,{area:d.areas.get(d.selectedAreaId),onClose:()=>b.selectArea(null),onOpenFolder:l}),e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsx($,{title:y("config:buildings.title",{count:c.length}),storageKey:"buildings",headerExtra:e.jsx("button",{className:"add-building-btn",onClick:m=>{m.stopPropagation(),f==null||f()},title:y("config:buildings.addBuilding"),children:"+"}),children:e.jsx("div",{className:"buildings-list",children:c.length===0?e.jsx("div",{className:"buildings-empty",children:y("config:buildings.clickToAdd")}):c.map(m=>e.jsx(is,{building:m,isSelected:d.selectedBuildingIds.has(m.id),onClick:()=>{b.selectBuilding(d.selectedBuildingIds.has(m.id)?null:m.id)},onEdit:()=>f==null?void 0:f(m.id)},m.id))})})}),d.selectedBuildingIds.size===1&&(()=>{const m=Array.from(d.selectedBuildingIds)[0],N=d.buildings.get(m);return N?e.jsx(ls,{building:N,onClose:()=>b.selectBuilding(null),onOpenModal:()=>f==null?void 0:f(m)}):null})(),e.jsx(Bs,{config:n,onChange:s,searchQuery:k,onOpenIntegrationsModal:a,onOpenMonitoringModal:h,onOpenWorkflowEditor:T,onOpenTriggerManager:v})]})]})]})}export{Ks as Toolbox};
1
+ import{r as u,ai as ie,aj as je,j as e,I as E,u as V,ak as ye,M as we,f as de,s as b,al as Oe,k as _e,l as G,am as U,an as De,a8 as Re,ao as Be,a5 as se,ap as Ue,aq as Ve,ar as qe,as as Ke,at as K,au as Me,a0 as Ge,a3 as He,S as ee,av as We,aw as Ye,a2 as Je,ax as le,ae as ne,ad as Ze,ay as ce,az as Xe}from"./main-DxFgIntP.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const me="deivid11/tide-commander",Qe=`https://api.github.com/repos/${me}/releases/latest`,es=`https://api.github.com/repos/${me}/releases?per_page=3`,ss=3600*1e3,ve="app_update_dismissed_version",Ne="1.62.0";function ts(){var v,y;const[s,i]=u.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:Ne}),n=((y=(v=ie)==null?void 0:v.getPlatform)==null?void 0:y.call(v))==="android"||!1,o=d=>d.replace(/^v/,"").split(".").map(c=>parseInt(c,10)||0),r=(d,g)=>{const c=o(d),k=o(g),w=Math.max(c.length,k.length);for(let C=0;C<w;C++){const P=c[C]||0,D=k[C]||0;if(P>D)return 1;if(P<D)return-1}return 0},f=async d=>{var c,k;if(ie&&je&&((k=(c=ie).isNativePlatform)==null?void 0:k.call(c))===!0){const w=await je.get({url:d,headers:{Accept:"application/vnd.github.v3+json"}});return{data:w.data,status:w.status}}else{const w=await fetch(d,{headers:{Accept:"application/vnd.github.v3+json"}});return w.ok?{data:await w.json(),status:w.status}:{data:null,status:w.status}}},l=u.useCallback(async(d=!1)=>{i(g=>({...g,isChecking:!0,error:null}));try{const[g,c]=await Promise.all([f(Qe),f(es)]);if(g.status!==200)throw new Error(`GitHub API error: ${g.status}`);const k=g.data,w=k.tag_name;let C=[];c.status===200&&c.data&&(C=c.data.map(N=>({version:N.tag_name,name:N.name,publishedAt:N.published_at,releaseUrl:N.html_url})));const P=localStorage.getItem(ve);if(!d&&P===w)return i(N=>({...N,isChecking:!1,updateAvailable:!1,recentReleases:C})),null;if(!(r(w,Ne)>0))return i(N=>({...N,isChecking:!1,updateAvailable:!1,recentReleases:C})),null;const _=k.assets.find(N=>N.name.endsWith(".apk")&&N.content_type==="application/vnd.android.package-archive"),m={version:w,name:k.name,changelog:k.body,releaseUrl:k.html_url,apkUrl:(_==null?void 0:_.browser_download_url)||null,apkSize:(_==null?void 0:_.size)||null,publishedAt:k.published_at};return i(N=>({...N,isChecking:!1,updateAvailable:!0,updateInfo:m,recentReleases:C})),m}catch(g){const c=g instanceof Error?g.message:"Failed to check for updates";return i(k=>({...k,isChecking:!1,error:c})),null}},[]),a=u.useCallback(async()=>{var d,g,c;if(!((d=s.updateInfo)!=null&&d.apkUrl)){(g=s.updateInfo)!=null&&g.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!n){(c=s.updateInfo)!=null&&c.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),i(k=>({...k,error:null}))}catch(k){const w=k instanceof Error?k.message:"Failed to open download";i(C=>({...C,error:w}))}},[s.updateInfo,n]),h=u.useCallback(()=>{s.updateInfo&&localStorage.setItem(ve,s.updateInfo.version),i(d=>({...d,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),T=u.useCallback(()=>{var d;(d=s.updateInfo)!=null&&d.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${me}/releases`,"_blank")},[s.updateInfo]);return u.useEffect(()=>{if(!n)return;const d=setTimeout(()=>{l()},5e3),g=setInterval(()=>{l()},ss);return()=>{clearTimeout(d),clearInterval(g)}},[n,l]),{...s,isAndroid:n,checkForUpdate:l,downloadAndInstall:a,dismissUpdate:h,openReleasePage:T}}const ke="tide-toolbox-collapse";function as(s,i){try{const n=localStorage.getItem(`${ke}-${s}`);if(n!==null)return n==="true"}catch{}return i}function ns(s,i){try{localStorage.setItem(`${ke}-${s}`,String(i))}catch{}}function $({title:s,storageKey:i,defaultOpen:n=!1,forceOpen:o=!1,children:r,headerExtra:f}){const[l,a]=u.useState(()=>i?as(i,n):n),h=()=>{const v=!l;a(v),i&&ns(i,v)},T=o||l;return e.jsxs("div",{className:`collapsible-section ${T?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:h,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(E,{name:T?"caret-down":"caret-right",size:10})})]})]}),T&&e.jsx("div",{className:"collapsible-content",children:r})]})}function os({area:s,isSelected:i,onClick:n,onDelete:o}){const{t:r}=V(["config","common"]),f=s.assignedAgentIds.length,l=s.type==="rectangle"?r("config:areas.rect"):r("config:areas.circle");return e.jsxs("div",{className:`area-item ${i?"selected":""}`,onClick:n,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:[l," ",f>0&&`• ${f} ${f>1?r("common:labels.agents").toLowerCase():r("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:o,title:r("config:areas.deleteArea"),children:"×"})]})}function is({building:s,isSelected:i,onClick:n,onEdit:o}){var a;const{t:r}=V(["config"]),f=((a=s.pm2Status)==null?void 0:a.ports)||[],l=(h,T)=>{h.stopPropagation(),window.open(`http://localhost:${T}`,"_blank")};return e.jsxs("div",{className:`building-item ${i?"selected":""}`,onClick:n,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:ye[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx(E,{name:we(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(h=>e.jsxs("a",{href:`http://localhost:${h}`,className:"building-port-link",onClick:T=>l(T,h),title:`Open :${h}`,children:[":",h]},h))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:h=>{h.stopPropagation(),o()},title:r("config:buildings.editBuilding"),children:e.jsx(E,{name:"gear",size:14})})]})}function ls({building:s,onClose:i,onOpenModal:n}){var T,v,y,d,g,c,k,w;const{t:o}=V(["config","common"]),{buildingLogs:r}=de(),f=b.getBuildingLogs(s.id),l=Oe[s.style||"server-rack"],a=C=>{b.sendBuildingCommand(s.id,C)},h=C=>{window.open(C,"_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(E,{name:we(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:ye[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:l.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:()=>a("start"),disabled:!((T=s.commands)!=null&&T.start)||s.status==="running",title:((v=s.commands)==null?void 0:v.start)||o("config:buildings.noStartCommand"),children:[e.jsx(E,{name:"play",size:12})," ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>a("stop"),disabled:!((y=s.commands)!=null&&y.stop)||s.status==="stopped",title:((d=s.commands)==null?void 0:d.stop)||o("config:buildings.noStopCommand"),children:[e.jsx(E,{name:"stop",size:12,weight:"fill"})," ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>a("restart"),disabled:!((g=s.commands)!=null&&g.restart),title:((c=s.commands)==null?void 0:c.restart)||o("config:buildings.noRestartCommand"),children:[e.jsx(E,{name:"refresh",size:12})," ",o("common:buttons.retry")]}),e.jsxs("button",{className:"building-editor-action-btn health",onClick:()=>a("healthCheck"),disabled:!((k=s.commands)!=null&&k.healthCheck),title:((w=s.commands)==null?void 0:w.healthCheck)||o("config:buildings.noHealthCheck"),children:[e.jsx(E,{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((C,P)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>h(C.url),title:C.url,children:[e.jsx(E,{name:"link",size:12})," ",C.label||C.url]},P))})]}),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:()=>b.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((C,P)=>e.jsx("div",{className:"building-editor-log-entry",children:C},P))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:n,children:[e.jsx(E,{name:"gear",size:12})," ",o("config:buildings.fullSettings")]})})]})}async function cs(s,i){const n=U(),o=await fetch(G(`/api/areas/${s}/logo`),{method:"POST",headers:{"Content-Type":i.type||"image/png","X-Filename":encodeURIComponent(i.name),...n?{Authorization:`Bearer ${n}`}:{}},body:i});if(!o.ok){const r=await o.json().catch(()=>({error:o.statusText}));throw new Error(r.error||`Upload failed: ${o.statusText}`)}return o.json()}async function rs(s){const i=U(),n=await fetch(G(`/api/areas/${s}/logo`),{method:"DELETE",headers:{...i?{Authorization:`Bearer ${i}`}:{}}});if(!n.ok)throw new Error(`Failed to delete logo: ${n.statusText}`)}function ds(s){return _e(G(`/api/areas/logos/${s}`))}const ms=[{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 us({area:s,onClose:i,onOpenFolder:n}){var R;const{t:o}=V(["config","common"]),[r,f]=u.useState(s.name),[l,a]=u.useState(s.prompt||""),[h,T]=u.useState(!1),[v,y]=u.useState(""),[d,g]=u.useState(!1),c=u.useRef(null);u.useEffect(()=>{f(s.name)},[s.id,s.name]),u.useEffect(()=>{a(s.prompt||"")},[s.id,s.prompt]);const k=p=>{const S=p.target.value;f(S),b.updateArea(s.id,{name:S})},w=p=>{b.updateArea(s.id,{color:p})},C=p=>{const S=p.target.value;a(S),b.updateArea(s.id,{prompt:S})},P=()=>{v.trim()&&(b.addDirectoryToArea(s.id,v.trim()),y(""),T(!1))},D=(p,S)=>{S.stopPropagation(),b.removeDirectoryFromArea(s.id,p)},_=()=>{b.bringAreaToFront(s.id)},m=()=>{b.sendAreaToBack(s.id)},N=u.useCallback(()=>{let p=2,S=2;s.type==="rectangle"&&s.width&&s.height?(p=s.width,S=s.height):s.type==="circle"&&s.radius&&(p=s.radius*1.414,S=s.radius*1.414);const F=Math.min(p,S)*.4;return{width:Math.round(F*10)/10,height:Math.round(F*10)/10}},[s.type,s.width,s.height,s.radius]),X=async p=>{var F;const S=(F=p.target.files)==null?void 0:F[0];if(S){g(!0);try{const M=await cs(s.id,S),te=N();b.updateArea(s.id,{logo:{filename:M.filename,position:"center",width:te.width,height:te.height,keepAspectRatio:!0,opacity:.8}})}catch(M){console.error("Failed to upload logo:",M)}finally{g(!1),c.current&&(c.current.value="")}}},H=async()=>{try{await rs(s.id),b.updateArea(s.id,{logo:void 0})}catch(p){console.error("Failed to remove logo:",p)}},J=p=>{s.logo&&b.updateArea(s.id,{logo:{...s.logo,position:p}})},Q=p=>{if(!s.logo)return;const S=parseFloat(p.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const F=s.logo.height/s.logo.width;b.updateArea(s.id,{logo:{...s.logo,width:S,height:Math.round(S*F*10)/10}})}else b.updateArea(s.id,{logo:{...s.logo,width:S}})},x=p=>{if(!s.logo)return;const S=parseFloat(p.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const F=s.logo.width/s.logo.height;b.updateArea(s.id,{logo:{...s.logo,height:S,width:Math.round(S*F*10)/10}})}else b.updateArea(s.id,{logo:{...s.logo,height:S}})},L=()=>{s.logo&&b.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},I=p=>{s.logo&&b.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(p.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:r,onChange:k,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:De.map(p=>e.jsx("div",{className:`color-swatch ${s.color===p?"selected":""}`,style:{backgroundColor:p},onClick:()=>w(p)},p))})]}),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(E,{name:"arrow-up",size:12})," ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:m,title:o("config:areas.sendToBack"),children:[e.jsx(E,{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:[(R=s.logo)!=null&&R.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:ds(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:H,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var p;return(p=c.current)==null?void 0:p.click()},disabled:d,children:d?"...":e.jsx(E,{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:ms.map(({key:p,labelKey:S})=>{var F;return e.jsx("button",{className:`area-logo-pos-btn ${((F=s.logo)==null?void 0:F.position)===p?"active":""}`,onClick:()=>J(p),children:o(`config:areas.${S}`)},p)})})]}),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:Q,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:x,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:L}),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:I,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 p;return(p=c.current)==null?void 0:p.click()},disabled:d,children:d?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:c,type:"file",accept:"image/*",style:{display:"none"},onChange:X})]})]}),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(p=>e.jsxs("div",{className:"area-folder-item",title:p,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>n==null?void 0:n(s.id),title:o("config:areas.openFolder"),children:e.jsx(E,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:p.split("/").pop()||p}),e.jsx("button",{className:"area-folder-remove",onClick:S=>D(p,S),title:o("config:areas.removeFolder"),children:"×"})]},p)),h?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(Re,{value:v,onChange:y,onSubmit:P,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:P,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:l,onChange:C,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 gs(){const{t:s}=V(["config","common"]),i=Be(),[n,o]=u.useState(!1),[r,f]=u.useState(null),[l,a]=u.useState({name:"",key:"",value:"",description:""}),h=()=>{o(!0),f(null),a({name:"",key:"",value:"",description:""})},T=c=>{f(c.id),o(!1),a({name:c.name,key:c.key,value:c.value,description:c.description||""})},v=()=>{o(!1),f(null),a({name:"",key:"",value:"",description:""})},y=()=>{!l.name.trim()||!l.key.trim()||(r?b.updateSecret(r,{name:l.name.trim(),key:l.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:l.value,description:l.description.trim()||void 0}):b.createSecret({name:l.name.trim(),key:l.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:l.value,description:l.description.trim()||void 0}),v())},d=c=>{confirm(s("config:secrets.deleteConfirm"))&&(b.deleteSecret(c),r===c&&v())},g=c=>{navigator.clipboard.writeText(`{{${c}}}`)};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&&!n?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):i.map(c=>e.jsxs("div",{className:`secret-item ${r===c.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:c.name}),e.jsx("code",{className:"secret-item-key",onClick:()=>g(c.key),title:s("config:secrets.copyPlaceholder"),children:`{{${c.key}}}`})]}),e.jsxs("div",{className:"secret-item-actions",children:[e.jsx("button",{className:"secret-item-btn edit",onClick:()=>T(c),title:s("common:buttons.edit"),children:e.jsx(E,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>d(c.id),title:s("common:buttons.delete"),children:"×"})]})]}),c.description&&e.jsx("div",{className:"secret-item-description",children:c.description})]},c.id))}),(n||r)&&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:l.name,onChange:c=>a({...l,name:c.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:l.key,onChange:c=>a({...l,key:c.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${l.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:l.value,onChange:c=>a({...l,value:c.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:l.description,onChange:c=>a({...l,description:c.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:v,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:y,disabled:!l.name.trim()||!l.key.trim(),children:s(r?"config:secrets.update":"common:buttons.add")})]})]}),!n&&!r&&e.jsx("button",{className:"secrets-add-btn",onClick:h,children:s("config:secrets.addSecret")})]})}function hs(){const{t:s}=V(["config","common"]),[i,n]=u.useState([]),[o,r]=u.useState(new Set),[f,l]=u.useState(new Set),[a,h]=u.useState(!1),[T,v]=u.useState(!1),[y,d]=u.useState(null),[g,c]=u.useState(null),[k,w]=u.useState(null);u.useEffect(()=>{se(G("/api/config/categories")).then(x=>x.json()).then(x=>{const L=Array.isArray(x)?x:[];n(L),r(new Set(L.map(I=>I.id)))}).catch(x=>console.error("Failed to fetch config categories:",x))},[]);const C=x=>{r(L=>{const I=new Set(L);return I.has(x)?I.delete(x):I.add(x),I})},P=x=>{l(L=>{const I=new Set(L);return I.has(x)?I.delete(x):I.add(x),I})},D=()=>r(new Set(i.map(x=>x.id))),_=()=>r(new Set),m=()=>{g&&l(new Set(g.categories.map(x=>x.id)))},N=()=>l(new Set),X=async()=>{var x;if(o.size!==0){h(!0),w(null);try{const L=Array.from(o).join(","),I=await se(G(`/api/config/export?categories=${L}`));if(!I.ok)throw new Error("Export failed");const R=await I.blob(),p=window.URL.createObjectURL(R),S=document.createElement("a");S.href=p;const F=I.headers.get("Content-Disposition"),M=((x=F==null?void 0:F.match(/filename="(.+)"/))==null?void 0:x[1])||"tide-commander-config.zip";S.download=M,document.body.appendChild(S),S.click(),document.body.removeChild(S),window.URL.revokeObjectURL(p),w({type:"success",text:s("config:data.exportSuccess")})}catch(L){w({type:"error",text:L.message||"Export failed"})}finally{h(!1)}}},H=async x=>{var I;const L=(I=x.target.files)==null?void 0:I[0];if(L){d(L),w(null),c(null),l(new Set);try{const R=await se(G("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await L.arrayBuffer()});if(!R.ok){const F=await R.json();throw new Error(F.error||"Failed to preview config file")}const p=await R.json(),S=Array.isArray(p.categories)?p.categories:[];c({...p,categories:S}),l(new Set(S.map(F=>F.id)))}catch(R){w({type:"error",text:R.message||"Failed to read config file"}),d(null)}}},J=async()=>{if(!(!y||f.size===0)){v(!0),w(null);try{const x=Array.from(f).join(","),L=await se(G(`/api/config/import?categories=${x}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await y.arrayBuffer()}),I=await L.json();if(!L.ok)throw new Error(I.error||"Import failed");w({type:"success",text:I.message||s("config:data.importSuccess")}),d(null),c(null),l(new Set)}catch(x){w({type:"error",text:x.message||"Import failed"})}finally{v(!1)}}},Q=()=>{d(null),c(null),l(new Set),w(null)};return e.jsxs("div",{className:"data-section",children:[k&&e.jsx("div",{className:`data-message data-message-${k.type}`,children:k.text}),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:D,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:_,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:i.map(x=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(x.id),onChange:()=>C(x.id)}),e.jsx("span",{className:"data-category-name",children:x.name})]},x.id))}),e.jsx("button",{className:"data-action-btn export",onClick:X,disabled:a||o.size===0,children:a?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")})}),y?g?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:y.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(g.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:m,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:N,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:g.categories.map(x=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:f.has(x.id),onChange:()=>P(x.id)}),e.jsx("span",{className:"data-category-name",children:x.name}),x.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",x.fileCount," ",s("config:data.files"),")"]})]},x.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:Q,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:J,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:H,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}function ps(){const[s,i]=u.useState(()=>Ue()),n=o=>{i(o);const r=qe(o);Ke(r)};return e.jsx("div",{className:"theme-selector",children:e.jsx("div",{className:"theme-selector-grid",children:Ve.map(o=>e.jsxs("button",{className:`theme-option ${s===o.id?"active":""}`,onClick:()=>n(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 fs(){const{t:s}=V(["config"]),{updateAvailable:i,updateInfo:n,recentReleases:o,isChecking:r,error:f,currentVersion:l,isAndroid:a,checkForUpdate:h,downloadAndInstall:T,openReleasePage:v}=ts(),y=g=>g?`${(g/(1024*1024)).toFixed(1)} MB`:"",d=g=>new Date(g).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(E,{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:l}),i&&n?e.jsx("span",{className:"about-version-update-badge",onClick:v,title:`Update available: ${n.version}`,children:n.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&&n?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:n.version})]}),n.apkSize&&e.jsxs("div",{className:"about-update-size",children:[s("config:about.sizeLabel"),": ",y(n.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:v,children:s("config:about.changelog")}),a&&n.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:v,children:s("config:about.viewRelease")})]})]}):e.jsxs("div",{className:"about-update-check",children:[e.jsx("span",{className:"about-update-status",children:s(r?"config:about.checkingUpdates":"config:about.upToDate")}),e.jsx("button",{className:"about-update-btn check",onClick:()=>h(!0),disabled:r,children:r?"...":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(g=>e.jsxs("a",{href:g.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:`about-release-item ${g.version===`v${l}`||g.version===l?"current":""}`,children:[e.jsx("span",{className:"about-release-version",children:g.version}),e.jsx("span",{className:"about-release-date",children:d(g.publishedAt)})]},g.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(E,{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 xs={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅",docx:"📄"};function bs({onOpenModal:s}){const[i,n]=u.useState([]),[o,r]=u.useState(!0),f=u.useCallback(async()=>{try{const l=await se(G("/api/integrations"));if(!l.ok)return;const a=await l.json();n(a)}catch{}finally{r(!1)}},[]);return u.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(l=>{const a=xs[l.id]||"🔌",h=!!l.status.error,T=l.status.connected,v=h?"#f38ba8":T?"#a6e3a1":"#fab387",y=h?"Error":T?"Connected":"Setup Required",d=h?"✗":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:a}),e.jsx("span",{style:{flex:1,color:"var(--text-primary, #cdd6f4)",fontWeight:500},children:l.name}),e.jsxs("span",{style:{color:v,fontSize:11,fontWeight:500,whiteSpace:"nowrap"},children:[d," ",y]}),e.jsx("button",{onClick:()=>s(l.id),title:`Configure ${l.name}`,style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",fontSize:14,color:"var(--text-secondary, #a6adc8)",borderRadius:4,flexShrink:0},onMouseEnter:g=>{g.target.style.color="var(--text-primary, #cdd6f4)"},onMouseLeave:g=>{g.target.style.color="var(--text-secondary, #a6adc8)"},children:"⚙️"})]},l.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:l=>{l.target.style.borderColor="var(--accent, #89b4fa)",l.target.style.color="var(--accent, #89b4fa)"},onMouseLeave:l=>{l.target.style.borderColor="var(--border, #313244)",l.target.style.color="var(--text-secondary, #a6adc8)"},children:"Manage All Integrations"})]})}async function js(){const s=U(),i=await fetch(`${K()}/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 vs(s){const i=U(),n=await fetch(`${K()}/api/agents/system-settings/prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({prompt:s})});if(!n.ok)throw new Error(`Failed to update system prompt: ${n.statusText}`)}async function Ns(){const s=U(),i=await fetch(`${K()}/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 ys(){const s=U(),i=await fetch(`${K()}/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 ws(s){const i=U(),n=await fetch(`${K()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!n.ok)throw new Error(`Failed to update echo prompt setting: ${n.statusText}`)}async function ks(){const s=U(),i=await fetch(`${K()}/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 Ss(s){const i=U(),n=await fetch(`${K()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({path:s})});if(!n.ok)throw new Error(`Failed to update codex binary path: ${n.statusText}`)}async function Cs(){const s=U(),i=await fetch(`${K()}/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 As(s){const i=U(),n=await fetch(`${K()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!n.ok)throw new Error(`Failed to update tmux mode setting: ${n.statusText}`)}function Ts({isOpen:s,onClose:i}){const{t:n}=V(["config"]),[o,r]=u.useState(""),[f,l]=u.useState(""),[a,h]=u.useState(!0),[T,v]=u.useState(null),[y,d]=u.useState(null),[g,c]=u.useState(!1);u.useEffect(()=>{s&&k()},[s]);const k=async()=>{try{h(!0),v(null),d(null);const m=await js();r(m),l(m),c(!1)}catch(m){v(m instanceof Error?m.message:"Failed to load system prompt")}finally{h(!1)}},w=m=>{const N=m.target.value;r(N),c(N!==f),v(null),d(null)},C=async()=>{try{v(null),d(null),await vs(o),l(o),c(!1),d(n("config:systemPrompt.saved"))}catch(m){v(m instanceof Error?m.message:"Failed to save system prompt")}},P=async()=>{if(window.confirm(n("config:systemPrompt.confirmClear")))try{v(null),d(null),await Ns(),r(""),l(""),c(!1),d(n("config:systemPrompt.cleared"))}catch(m){v(m instanceof Error?m.message:"Failed to clear system prompt")}},D=()=>{r(f),c(!1),v(null),d(null)},_=m=>{if(m.key==="Escape"){if(g&&!window.confirm("You have unsaved changes. Close anyway?")){m.preventDefault();return}i()}};return s?e.jsx(Me,{children:e.jsx("div",{className:`modal-overlay ${s?"visible":""}`,onClick:i,children:e.jsxs("div",{className:"system-prompt-modal",onClick:m=>m.stopPropagation(),onKeyDown:_,children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h2",{children:n("config:systemPrompt.title")}),e.jsx("button",{className:"modal-close",onClick:i,"aria-label":"Close",children:e.jsx(E,{name:"close",size:16})})]}),e.jsx("div",{className:"modal-body",children:a?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:n("config:systemPrompt.description")}),T&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(E,{name:"warn",size:14})}),T]}),y&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:e.jsx(E,{name:"check",size:14})}),y]}),e.jsxs("div",{className:"editor-wrapper",children:[e.jsxs("div",{className:"editor-header",children:[e.jsx("label",{htmlFor:"prompt-input",className:"editor-label",children:n("config:systemPrompt.editPrompt")}),e.jsxs("span",{className:"char-count",children:[o.length," ",n("config:systemPrompt.characters")]})]}),e.jsx("textarea",{id:"prompt-input",className:"prompt-editor",value:o,onChange:w,placeholder:n("config:systemPrompt.placeholder"),rows:18,autoFocus:!0}),e.jsx("div",{className:"editor-hint",children:n("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:P,disabled:!o||a,children:n("config:systemPrompt.clear")})}),e.jsxs("div",{className:"footer-buttons-right",children:[e.jsx("button",{className:"btn btn-secondary",onClick:i,children:"Close"}),e.jsx("button",{className:"btn btn-secondary",onClick:D,disabled:!g||a,children:n("config:systemPrompt.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:C,disabled:!g||a,children:n("config:systemPrompt.save")})]})]})]})})}):null}const Is=[{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:"🌙"}],Es=[{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:"🔴"}],Ps=[{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:"👎"}],Ls=[{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:"💜"}],Fs=[{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"}],$s=[{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"}],zs={showTrees:"trees",showBushes:"bushes",showHouse:"house",showLamps:"lamps",showGrass:"grass",showClouds:"clouds"},Os={none:"grass","pokemon-stadium":"pokemon"},_s={"emote-yes":"yes","emote-no":"no"},Ds={"":"auto","#4a90d9":"dayBlue","#0a1a2a":"night","#ff6b35":"sunset","#1a0a2e":"purple","#2d5a27":"matrix","#8b0000":"blood","#000000":"void"};function B({checked:s,onChange:i}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,onChange:n=>i(n.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function Z({options:s,value:i,onChange:n,iconOnly:o=!1}){return e.jsx("div",{className:"chip-selector",children:s.map(r=>e.jsxs("button",{className:`chip ${i===r.value?"active":""}`,onClick:()=>n(r.value),title:r.label,children:[e.jsx("span",{className:"chip-icon",children:r.icon}),!o&&e.jsx("span",{className:"chip-label",children:r.label})]},r.value))})}function j({text:s,query:i}){if(!i.trim())return e.jsx(e.Fragment,{children:s});const n=s.toLowerCase(),o=i.toLowerCase(),r=n.indexOf(o);if(r===-1)return e.jsx(e.Fragment,{children:s});const f=s.slice(0,r),l=s.slice(r,r+i.length),a=s.slice(r+i.length);return e.jsxs(e.Fragment,{children:[f,e.jsx("mark",{className:"search-highlight",children:l}),a]})}const Rs=[{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:"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"]}],re=[{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 Bs({config:s,onChange:i,searchQuery:n="",onOpenIntegrationsModal:o,onOpenMonitoringModal:r,onOpenWorkflowEditor:f,onOpenTriggerManager:l}){var xe;const{t:a}=V(["config","common"]),h=de(),T=Ge(),[v,y]=u.useState(()=>He(ee.DEFAULT_AGENT_CLASS)||"scout"),[d,g]=u.useState(h.settings.historyLimit),[c,k]=u.useState(()=>We()),[w,C]=u.useState(!1),[P,D]=u.useState(()=>U()),[_,m]=u.useState(!1),[N,X]=u.useState(!1),[H,J]=u.useState(""),[Q,x]=u.useState(!1),[L,I]=u.useState(""),[R,p]=u.useState(!1);u.useEffect(()=>{ks().then(I).catch(()=>{})},[]),u.useEffect(()=>{ys().then(t=>{t!==h.settings.experimentalEchoPrompt&&b.updateSettings({experimentalEchoPrompt:t})}).catch(()=>{})},[]),u.useEffect(()=>{Cs().then(t=>{t!==h.settings.tmuxMode&&b.updateSettings({tmuxMode:t})}).catch(()=>{})},[]),u.useEffect(()=>Ye(t=>{k(t),C(!1)}),[]);const S=Is.map(t=>({...t,label:a(`config:time.${t.value}`)})),F=Es.map(t=>({...t,label:a(`config:floor.${Os[t.value]||t.value}`)})),M=Ps.map(t=>({...t,label:a(`config:animation.${_s[t.value]||t.value}`)})),te=Ls.map(t=>({...t,label:a(`config:colorMode.${t.value}`)})),Se=Fs.map(t=>({...t,label:a(`config:terrain.${zs[t.key]}`)})),Ce=$s.map(t=>({...t,label:a(`config:sky.${Ds[t.value??""]}`)})),ae=n.trim()?Rs.filter(t=>{const O=n.toLowerCase();return t.title.toLowerCase().includes(O)||t.keywords.some(oe=>oe.toLowerCase().includes(O))}).map(t=>t.id):null,A=t=>ae?ae.includes(t):!0,q=h.settings.customAgentNames||[],Ae=q.length>0?q:Je,ue=()=>{const t=H.trim();t&&!q.includes(t)&&(b.updateSettings({customAgentNames:[...q,t]}),J(""))},Te=t=>{b.updateSettings({customAgentNames:q.filter(O=>O!==t)})},Ie=()=>{b.updateSettings({customAgentNames:[]})},Ee=t=>{k(t),C(!0)},ge=()=>{Xe(c),C(!1),ce()},Pe=t=>{D(t),m(!0)},he=()=>{ne(ee.AUTH_TOKEN,P),m(!1),ce()},Le=t=>{I(t),p(!0)},pe=()=>{Ss(L).catch(()=>{}),p(!1)},W=t=>{i({...s,terrain:{...s.terrain,...t}})},Y=t=>{i({...s,modelStyle:{...s.modelStyle,...t}})},fe=t=>{i({...s,animations:{...s.animations,...t}})},Fe=t=>{g(t),b.updateSettings({historyLimit:t})},$e=t=>{const O=s.terrain[t];typeof O=="boolean"&&W({[t]:!O})},z=n.trim().length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-section",children:[ae&&ae.length===0&&e.jsx("div",{className:"config-no-results",children:a("config:noResults",{query:n})}),A("general")&&e.jsxs($,{title:a("config:sections.general"),storageKey:"general",defaultOpen:!0,forceOpen:z&&A("general"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:general.history"),query:n})}),e.jsx("input",{type:"number",className:"config-input config-input-sm",value:d,onChange:t=>Fe(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(j,{text:a("config:general.hideCosts"),query:n})}),e.jsx(B,{checked:h.settings.hideCost,onChange:t=>b.updateSettings({hideCost:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:general.grid"),query:n})}),e.jsx(B,{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(j,{text:a("config:general.showFPS"),query:n})}),e.jsx(B,{checked:h.settings.showFPS,onChange:t=>b.updateSettings({showFPS:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:general.fpsLimit"),query:n})}),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(j,{text:a("config:general.powerSaving"),query:n})," ",e.jsx(E,{name:"bolt",size:12})]}),e.jsx(B,{checked:h.settings.powerSaving,onChange:t=>b.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(j,{text:a("config:general.tmuxMode"),query:n})}),e.jsx(B,{checked:h.settings.tmuxMode,onChange:async t=>{b.updateSettings({tmuxMode:t});try{await As(t)}catch(O){console.error("Failed to sync tmux mode setting to server:",O)}}})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:general.vibrationIntensity"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"5",step:"1",value:h.settings.vibrationIntensity,onChange:t=>b.updateSettings({vibrationIntensity:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:h.settings.vibrationIntensity===0?a("config:vibrationValues.off"):h.settings.vibrationIntensity===1?a("config:vibrationValues.ultraLight"):h.settings.vibrationIntensity===2?a("config:vibrationValues.veryLight"):h.settings.vibrationIntensity===3?a("config:vibrationValues.light"):h.settings.vibrationIntensity===4?a("config:vibrationValues.medium"):a("config:vibrationValues.heavy")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:general.externalEditor"),query:n})}),e.jsx("input",{type:"text",className:"config-input",placeholder:a("config:general.externalEditorPlaceholder"),value:h.settings.externalEditorCommand||"",onChange:t=>b.updateSettings({externalEditorCommand:t.target.value})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:general.tabTitle"),query:n})}),e.jsx("input",{type:"text",className:"config-input",placeholder:a("config:general.tabTitlePlaceholder"),value:h.settings.tabTitle||"",onChange:t=>b.updateSettings({tabTitle:t.target.value})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:general.language"),query:n})}),e.jsx(Z,{options:re,value:localStorage.getItem("tide-commander-language-mode")==="manual"?((xe=re.find(t=>t.value!=="auto"&&le.language.startsWith(t.value.split("-")[0])))==null?void 0:xe.value)||"en":"auto",onChange:t=>{var O;if(t==="auto"){localStorage.setItem("tide-commander-language-mode","auto");const oe=navigator.language,ze=((O=re.find(be=>be.value!=="auto"&&oe.startsWith(be.value.split("-")[0])))==null?void 0:O.value)||"en";le.changeLanguage(ze)}else localStorage.setItem("tide-commander-language-mode","manual"),le.changeLanguage(t)}})]})]}),A("agentNames")&&e.jsx($,{title:a("config:sections.agentNames"),storageKey:"agentNames",defaultOpen:!1,forceOpen:z&&A("agentNames"),children:e.jsxs("div",{className:"agent-names-section",children:[e.jsx("span",{className:"config-hint",children:q.length>0?a("config:agentNames.customConfigured",{count:q.length}):a("config:agentNames.usingDefaults")}),e.jsxs("div",{className:"agent-names-input-row",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",placeholder:a("config:agentNames.addPlaceholder"),value:H,onChange:t=>J(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ue()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:ue,disabled:!H.trim(),title:a("config:agentNames.addName"),children:"+"})]}),e.jsx("div",{className:"agent-names-list",children:Ae.map((t,O)=>e.jsxs("div",{className:"agent-name-chip",children:[e.jsx("span",{className:"agent-name-text",children:t}),q.length>0&&e.jsx("button",{className:"agent-name-remove",onClick:()=>Te(t),title:a("common:buttons.remove"),children:"x"})]},`${t}-${O}`))}),q.length>0&&e.jsx("button",{className:"config-btn config-btn-link",onClick:Ie,children:a("common:buttons.resetToDefaults")})]})}),A("defaultClass")&&e.jsx($,{title:"Default Spawn Class",storageKey:"defaultClass",defaultOpen:!1,forceOpen:z&&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${v==="random"?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{y("random"),ne(ee.DEFAULT_AGENT_CLASS,"random")},children:e.jsx("span",{className:"agent-name-text",children:"🎲 Random"})}),Object.entries(Ze).map(([t,O])=>e.jsx("div",{className:`agent-name-chip${v===t?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{y(t),ne(ee.DEFAULT_AGENT_CLASS,t)},children:e.jsxs("span",{className:"agent-name-text",children:[O.icon," ",t.charAt(0).toUpperCase()+t.slice(1)]})},t)),T.map(t=>e.jsx("div",{className:`agent-name-chip${v===t.id?" agent-name-chip--selected":""}`,style:{cursor:"pointer",userSelect:"none"},onClick:()=>{y(t.id),ne(ee.DEFAULT_AGENT_CLASS,t.id)},children:e.jsxs("span",{className:"agent-name-text",children:[t.icon," ",t.name]})},t.id))]})]})}),A("appearance")&&e.jsx($,{title:a("config:sections.appearance"),storageKey:"appearance",defaultOpen:!1,forceOpen:z&&A("appearance"),children:e.jsx(ps,{})}),A("connection")&&e.jsxs($,{title:a("config:sections.connection"),storageKey:"connection",defaultOpen:!1,forceOpen:z&&A("connection"),children:[e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:connection.backendUrl"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:c,onChange:t=>Ee(t.target.value),placeholder:"http://localhost:5174",onKeyDown:t=>{t.key==="Enter"&&w&&ge()}}),w&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:ge,title:a("config:connection.saveAndReconnect"),children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.autoDetectHint")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:connection.authToken"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:N?"text":"password",className:"config-input config-input-full",value:P,onChange:t=>Pe(t.target.value),placeholder:a("config:connection.tokenPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&_&&he()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>X(!N),title:a(N?"config:connection.hideToken":"config:connection.showToken"),children:e.jsx(E,{name:N?"eye-closed":"eye",size:14})}),_&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:he,title:a("config:connection.saveAndReconnect"),children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.tokenRequired")})]}),e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:connection.codexBinaryPath"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:"text",className:"config-input config-input-full",value:L,onChange:t=>Le(t.target.value),placeholder:a("config:connection.codexBinaryPathPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&R&&pe()}}),R&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:pe,children:a("common:buttons.apply")})]}),e.jsx("span",{className:"config-hint",children:a("config:connection.codexBinaryPathHint")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("common:buttons.reconnect"),query:n})}),e.jsx("button",{className:"config-btn",onClick:()=>ce(),title:"Force reconnect to server",children:a("common:buttons.reconnect")})]})]}),A("scene")&&e.jsxs($,{title:a("config:sections.scene"),storageKey:"scene",defaultOpen:!1,forceOpen:z&&A("scene"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:scene.characterSize"),query:n})}),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(j,{text:a("config:scene.scale2d",{defaultValue:"2D Scale"}),query:n})}),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(j,{text:a("config:scene.scale3d",{defaultValue:"3D Scale"}),query:n})}),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(j,{text:a("config:scene.show2DTaskLabels",{defaultValue:"Show 2D task labels"}),query:n})}),e.jsx(B,{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(j,{text:a("config:scene.time"),query:n})}),e.jsx(Z,{options:S,value:s.timeMode,onChange:t=>i({...s,timeMode:t}),iconOnly:!0})]})]}),A("terrain")&&e.jsxs($,{title:a("config:sections.terrain"),storageKey:"terrain",defaultOpen:!1,forceOpen:z&&A("terrain"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:terrainSettings.simpleMode",{defaultValue:"Simple Mode"}),query:n})}),e.jsx(B,{checked:s.terrain.simpleMode??!1,onChange:t=>W({simpleMode:t})})]}),e.jsx("div",{className:"terrain-icons",style:{opacity:s.terrain.simpleMode?.4:1,pointerEvents:s.terrain.simpleMode?"none":"auto"},children:Se.map(t=>e.jsx("button",{className:`terrain-icon-btn ${s.terrain[t.key]?"active":""}`,onClick:()=>$e(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(j,{text:a("config:terrainSettings.fog"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.terrain.fogDensity,onChange:t=>W({fogDensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.fogDensity===0?a("config:fogValues.off"):s.terrain.fogDensity<=1?a("config:fogValues.low"):a("config:fogValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:terrainSettings.brightness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0.2",max:"2",step:"0.1",value:s.terrain.brightness,onChange:t=>W({brightness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.brightness<=.5?a("config:brightnessValues.dark"):s.terrain.brightness<=1.2?a("config:brightnessValues.normal"):a("config:brightnessValues.bright")})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:terrainSettings.floor"),query:n})}),e.jsx(Z,{options:F,value:s.terrain.floorStyle,onChange:t=>W({floorStyle:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:terrainSettings.sky"),query:n})}),e.jsx("div",{className:"sky-color-selector",children:Ce.map(t=>e.jsx("button",{className:`sky-color-btn ${s.terrain.skyColor===t.value?"active":""}`,onClick:()=>W({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(j,{text:a("config:terrainSettings.battlefieldSize"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"30",max:"200",step:"10",value:s.terrain.battlefieldSize,onChange:t=>W({battlefieldSize:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.battlefieldSize})]})]}),A("modelStyle")&&e.jsxs($,{title:a("config:sections.modelStyle"),storageKey:"modelStyle",defaultOpen:!1,forceOpen:z&&A("modelStyle"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:modelStyleSettings.saturation"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"2",step:"0.1",value:s.modelStyle.saturation,onChange:t=>Y({saturation:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.saturation<=.3?a("config:saturationValues.gray"):s.modelStyle.saturation<=1.2?a("config:saturationValues.normal"):a("config:saturationValues.vivid")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:modelStyleSettings.roughness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.roughness,onChange:t=>Y({roughness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.roughness<0?a("config:roughnessValues.auto"):s.modelStyle.roughness<=.3?a("config:roughnessValues.glossy"):s.modelStyle.roughness<=.7?a("config:roughnessValues.normal"):a("config:roughnessValues.matte")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:modelStyleSettings.metalness"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"1",step:"0.1",value:s.modelStyle.metalness,onChange:t=>Y({metalness:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.metalness<0?a("config:metalnessValues.auto"):s.modelStyle.metalness<=.3?a("config:metalnessValues.plastic"):s.modelStyle.metalness<=.7?a("config:metalnessValues.mixed"):a("config:metalnessValues.metal")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:modelStyleSettings.glow"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"1",step:"0.05",value:s.modelStyle.emissiveBoost,onChange:t=>Y({emissiveBoost:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.emissiveBoost<=.1?a("config:glowValues.off"):s.modelStyle.emissiveBoost<=.4?a("config:glowValues.low"):s.modelStyle.emissiveBoost<=.7?a("config:glowValues.med"):a("config:glowValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:modelStyleSettings.reflections"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"-1",max:"2",step:"0.1",value:s.modelStyle.envMapIntensity,onChange:t=>Y({envMapIntensity:parseFloat(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.modelStyle.envMapIntensity<0?a("config:reflectionValues.auto"):s.modelStyle.envMapIntensity<=.3?a("config:reflectionValues.low"):s.modelStyle.envMapIntensity<=1?a("config:reflectionValues.normal"):a("config:reflectionValues.high")})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:modelStyleSettings.wireframe"),query:n})}),e.jsx(B,{checked:s.modelStyle.wireframe,onChange:t=>Y({wireframe:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:modelStyleSettings.colorMode"),query:n})}),e.jsx(Z,{options:te,value:s.modelStyle.colorMode,onChange:t=>Y({colorMode:t}),iconOnly:!0})]})]}),A("animations")&&e.jsxs($,{title:a("config:sections.animations"),storageKey:"animations",defaultOpen:!1,forceOpen:z&&A("animations"),children:[e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:animationSettings.idle"),query:n})}),e.jsx(Z,{options:M,value:s.animations.idleAnimation,onChange:t=>fe({idleAnimation:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:animationSettings.working"),query:n})}),e.jsx(Z,{options:M,value:s.animations.workingAnimation,onChange:t=>fe({workingAnimation:t}),iconOnly:!0})]})]}),A("secrets")&&e.jsx($,{title:a("config:sections.secrets"),storageKey:"secrets",defaultOpen:!1,forceOpen:z&&A("secrets"),children:e.jsx(gs,{})}),A("systemPrompt")&&e.jsx($,{title:a("config:sections.systemPrompt"),storageKey:"systemPrompt",defaultOpen:!1,forceOpen:z&&A("systemPrompt"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(j,{text:a("config:systemPrompt.title"),query:n})}),e.jsx("button",{className:"config-button",onClick:()=>x(!0),children:a("config:systemPrompt.editPrompt")})]})}),A("data")&&e.jsx($,{title:a("config:sections.data"),storageKey:"data",defaultOpen:!1,forceOpen:z&&A("data"),children:e.jsx(hs,{})}),A("integrations")&&e.jsx($,{title:"Integrations",storageKey:"integrations",defaultOpen:!1,forceOpen:z&&A("integrations"),children:e.jsx(bs,{onOpenModal:t=>o==null?void 0:o(t)})}),A("workflows")&&e.jsxs($,{title:"Workflows",storageKey:"workflows",defaultOpen:!1,forceOpen:z&&A("workflows"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(j,{text:"Create and manage automated workflow pipelines with visual state machine editor",query:n})})}),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($,{title:"Triggers",storageKey:"triggers",defaultOpen:!1,forceOpen:z&&A("triggers"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(j,{text:"Create and manage event-driven triggers that fire agents with templates",query:n})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>l==null?void 0:l(),children:"Open Trigger Manager"})})]}),A("monitoring")&&e.jsxs($,{title:"Monitoring",storageKey:"monitoring",defaultOpen:!1,forceOpen:z&&A("monitoring"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(j,{text:"View event logs, trigger history, workflow traces, and system stats",query:n})})}),e.jsx("div",{className:"config-row",children:e.jsx("button",{className:"config-button",onClick:()=>r==null?void 0:r(),children:"Open Monitoring & Logs"})})]}),A("experimental")&&e.jsxs($,{title:a("config:sections.experimental"),storageKey:"experimental",defaultOpen:!1,forceOpen:z&&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(j,{text:a("config:experimental.2dView"),query:n})," ",e.jsx(E,{name:"map",size:12})]}),e.jsx(B,{checked:h.settings.experimental2DView,onChange:t=>b.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(j,{text:a("config:experimental.voiceAssistant"),query:n})," ",e.jsx(E,{name:"microphone",size:12})]}),e.jsx(B,{checked:h.settings.experimentalVoiceAssistant,onChange:t=>b.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(j,{text:a("config:experimental.tts"),query:n})," ",e.jsx(E,{name:"speaker-on",size:12})]}),e.jsx(B,{checked:h.settings.experimentalTTS,onChange:t=>b.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(j,{text:a("config:experimental.echoPrompt"),query:n})}),e.jsx(B,{checked:h.settings.experimentalEchoPrompt,onChange:async t=>{b.updateSettings({experimentalEchoPrompt:t});try{await ws(t)}catch(O){console.error("Failed to sync echo prompt setting to server:",O)}}})]}),e.jsx("span",{className:"config-hint",children:a("config:experimental.hint")})]}),A("about")&&e.jsx($,{title:a("config:sections.about"),storageKey:"about",defaultOpen:!1,forceOpen:z&&A("about"),children:e.jsx(fs,{})})]}),e.jsx(Ts,{isOpen:Q,onClose:()=>x(!1)})]})}function Ks({onConfigChange:s,onToolChange:i,config:n,isOpen:o,onClose:r,onOpenBuildingModal:f,onOpenAreaExplorer:l,onOpenIntegrationsModal:a,onOpenMonitoringModal:h,onOpenWorkflowEditor:T,onOpenTriggerManager:v}){const{t:y}=V(["config","common"]),d=de(),g=Array.from(d.areas.values()),c=Array.from(d.buildings.values()),[k,w]=u.useState(""),C=u.useRef(null);if(u.useEffect(()=>{const m=N=>{N.key==="Escape"&&o&&r()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[o,r]),u.useEffect(()=>{if(o&&C.current){const m=setTimeout(()=>{var N;(N=C.current)==null||N.focus()},50);return()=>clearTimeout(m)}},[o]),!o)return null;const P=m=>{const N=d.activeTool===m?null:m;i(N)},D=m=>{b.selectArea(d.selectedAreaId===m?null:m),i("select")},_=(m,N)=>{m.stopPropagation(),b.deleteArea(N)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"toolbox-backdrop",onClick:r}),e.jsxs("aside",{className:"toolbox",children:[e.jsxs("div",{className:"toolbox-header",children:[e.jsx("span",{children:y("config:title")}),e.jsx("button",{className:"toolbox-close-btn",onClick:r,title:y("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:C,type:"text",placeholder:y("config:searchPlaceholder"),value:k,onChange:m=>w(m.target.value),className:"toolbox-search-input"}),k&&e.jsx("button",{className:"toolbox-search-clear",onClick:()=>w(""),children:"×"})]}),e.jsxs("div",{className:"toolbox-content",children:[e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsxs($,{title:y("config:areas.title",{count:g.length}),storageKey:"areas",children:[e.jsxs("div",{className:"tool-buttons",children:[e.jsx("button",{className:`tool-btn ${d.activeTool==="select"?"active":""}`,onClick:()=>P("select"),title:y("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 ${d.activeTool==="rectangle"?"active":""}`,onClick:()=>P("rectangle"),title:y("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 ${d.activeTool==="circle"?"active":""}`,onClick:()=>P("circle"),title:y("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:g.length===0?e.jsx("div",{className:"areas-empty",children:y("config:areas.drawToCreate")}):g.map(m=>e.jsx(os,{area:m,isSelected:d.selectedAreaId===m.id,onClick:()=>D(m.id),onDelete:N=>_(N,m.id)},m.id))})]})}),d.selectedAreaId&&e.jsx(us,{area:d.areas.get(d.selectedAreaId),onClose:()=>b.selectArea(null),onOpenFolder:l}),e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsx($,{title:y("config:buildings.title",{count:c.length}),storageKey:"buildings",headerExtra:e.jsx("button",{className:"add-building-btn",onClick:m=>{m.stopPropagation(),f==null||f()},title:y("config:buildings.addBuilding"),children:"+"}),children:e.jsx("div",{className:"buildings-list",children:c.length===0?e.jsx("div",{className:"buildings-empty",children:y("config:buildings.clickToAdd")}):c.map(m=>e.jsx(is,{building:m,isSelected:d.selectedBuildingIds.has(m.id),onClick:()=>{b.selectBuilding(d.selectedBuildingIds.has(m.id)?null:m.id)},onEdit:()=>f==null?void 0:f(m.id)},m.id))})})}),d.selectedBuildingIds.size===1&&(()=>{const m=Array.from(d.selectedBuildingIds)[0],N=d.buildings.get(m);return N?e.jsx(ls,{building:N,onClose:()=>b.selectBuilding(null),onOpenModal:()=>f==null?void 0:f(m)}):null})(),e.jsx(Bs,{config:n,onChange:s,searchQuery:k,onOpenIntegrationsModal:a,onOpenMonitoringModal:h,onOpenWorkflowEditor:T,onOpenTriggerManager:v})]})]})]})}export{Ks as Toolbox};
@@ -1 +1 @@
1
- import{z as ts,u as as,B as vs,C as bs,E as zs,j as s,I as F,G as Is,H as Es,J as $s,K as Ds,L as Ms,r as c,M as Ls,N as Xs,O as Ps,P as Ss,U as Ys,V as Rs,W as Gs,X as Us,Y as ms,Z as _s,s as M,_ as Fs,n as U}from"./main-C0P7G341.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const fs=ts.memo(({agent:t,isSelected:A,isKeyboardFocused:L=!1,onSelect:X,onDoubleClick:n,onChat:g,onFocus:h,onKill:w,onDragStart:P})=>{const{t:x}=as(["dashboard","common"]),S=vs().has(t.id),N=bs(t.status),H=zs(t),j=Ms(H),I=t.taskLabel?s.jsxs(s.Fragment,{children:[s.jsx(F,{name:"task",size:12})," ",t.taskLabel]}):t.currentTask||t.lastAssignedTask,m=t.status==="idle"&&t.lastActivity>0,[,Z]=ts.useState(0);return ts.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>Z(J=>J+1),15e3);return()=>window.clearInterval(b)},[m]),s.jsxs("div",{className:`dash-card dash-card--${N} ${A?"dash-card--selected":""} ${L?"dash-card--keyboard-focused":""}`,"data-agent-id":t.id,onClick:X,onDoubleClick:b=>{b.stopPropagation(),n()},onDragStart:b=>{P==null||P(t),b.dataTransfer.effectAllowed="move"},draggable:!0,title:x("cards.doubleClickHint"),children:[s.jsxs("div",{className:"dash-card__row1",children:[s.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${N}`}),s.jsx("span",{className:"dash-card__name",children:t.name}),s.jsxs("span",{className:"dash-card__class",children:[s.jsx(Is,{agent:t,size:14})," ",t.class]}),s.jsxs("span",{className:`dash-card__provider dash-card__provider--${t.provider}`,children:[s.jsx(F,{name:t.provider==="codex"||t.provider==="opencode"?"status-pending":"robot",size:11,weight:t.provider==="codex"||t.provider==="opencode"?"fill":"regular",color:t.provider==="codex"?"#a16207":t.provider==="opencode"?"#4ade80":void 0})," ",t.provider]}),S&&s.jsx("span",{className:"dash-card__unseen-badge",title:"New output available - click to view",children:"!"})]}),s.jsxs("div",{className:"dash-card__row2",children:[s.jsx("span",{className:`dash-card__status dash-card__status--${N}`,children:S?"Unseen":t.status}),s.jsxs("div",{className:"dash-card__context",children:[s.jsx("div",{className:"dash-card__context-bar",children:s.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${j}`,style:{width:`${H}%`}})}),s.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${j}`,children:[H,"%"]})]})]}),s.jsxs("div",{className:"dash-card__row3",children:[s.jsxs("span",{className:"dash-card__workdir",title:t.cwd,children:[s.jsx(F,{name:"folder",size:11})," ",t.cwd.split("/").pop()||t.cwd]}),m&&s.jsxs("span",{className:"dash-card__idle-time",style:{color:Ds(t.lastActivity)},title:$s(t.lastActivity),children:[s.jsx(F,{name:"status-waiting-input",size:10})," ",Es(t.lastActivity)]})]}),I&&s.jsx("div",{className:"dash-card__row4",children:s.jsx("span",{className:"dash-card__task",children:I})}),s.jsxs("div",{className:"dash-card__actions",children:[g&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:b=>{b.stopPropagation(),g()},title:x("cards.openTerminal"),children:x("cards.chat")}),w&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:b=>{b.stopPropagation(),w()},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});fs.displayName="AgentCard";const ws=({buildings:t,onSelectBuilding:A})=>{const{t:L}=as(["dashboard"]),X=c.useMemo(()=>Array.from(t.values()).sort((n,g)=>n.name.localeCompare(g.name)),[t]);return s.jsxs("div",{className:"dashboard-view__buildings",children:[s.jsxs("div",{className:"dashboard-view__buildings-header",children:[s.jsx("span",{className:"dashboard-view__buildings-title",children:L("buildings.title")}),s.jsx("span",{className:"dashboard-view__buildings-count",children:X.length})]}),s.jsx("div",{className:"dashboard-view__buildings-row",children:X.map(n=>{const g=bs(n.status),h=Ls(n.type);return s.jsxs("button",{className:`dash-pill dash-pill--${g}`,onClick:()=>A==null?void 0:A(n.id),title:`${n.name} (${n.type}) - ${n.status}`,children:[s.jsx("span",{className:"dash-pill__icon",children:s.jsx(F,{name:h,size:14})}),s.jsx("span",{className:"dash-pill__name",children:n.name}),s.jsx("span",{className:`dash-pill__dot dash-pill__dot--${g}`})]},n.id)})})]})};ws.displayName="BuildingPills";function Ws({onSelectAgent:t,onFocusAgent:A,onKillAgent:L,onSelectBuilding:X,onOpenTerminal:n,onFocusZone:g}){const{t:h}=as(["dashboard","common"]),w=Xs(),P=Ps(),x=Ss(),rs=Ys(),S=vs(),[N,H]=c.useState(""),[j,I]=c.useState("all"),[m,Z]=c.useState("zone"),[b,J]=c.useState(new Set),[k,T]=c.useState(null),[ps,W]=c.useState(null),[Y,Q]=c.useState(!1),[p,B]=c.useState(null),K=c.useMemo(()=>{const e=Array.from(w.values());return{total:e.length,working:e.filter(i=>i.status==="working"||i.status==="waiting"||i.status==="waiting_permission").length,idle:e.filter(i=>i.status==="idle").length,error:e.filter(i=>i.status==="error"||i.status==="offline"||i.status==="orphaned").length}},[w]),ns=c.useMemo(()=>m==="zone"?Rs(w,x):m==="status"?Gs(w,S):Us(w),[w,x,m,S]),V=c.useMemo(()=>{const e=N.toLowerCase().trim(),i=ns.map(l=>({...l,agents:l.agents.filter(_=>{if(j==="working"){if(_.status!=="working"&&_.status!=="waiting"&&_.status!=="waiting_permission")return!1}else if(j==="error"&&_.status!=="error"&&_.status!=="offline"&&_.status!=="orphaned")return!1;return!(e&&!_.name.toLowerCase().includes(e)&&!_.class.toLowerCase().includes(e))})}));return m==="zone"?i:i.filter(l=>l.agents.length>0)},[ns,j,N,m]),O=c.useCallback(e=>e.area?`area:${e.area.id}`:`${m}:${e.label}`,[m]),C=c.useMemo(()=>{const e=[];return V.forEach(i=>{const l=O(i);if(b.has(l))return;const _=m==="status"?ms(i.agents,{prioritizeRecentlyIdle:!0}):_s(i.agents);e.push(..._)}),e},[V,b,m,O]),gs=c.useCallback(e=>{J(i=>{const l=new Set(i);return l.has(e)?l.delete(e):l.add(e),l})},[]),xs=c.useCallback(e=>{n==null||n(e)},[n]),js=c.useCallback(e=>{T(e)},[]),Ns=c.useCallback((e,i)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",W(i)},[]),ks=c.useCallback(()=>{W(null)},[]),Cs=c.useCallback(e=>{if(!k)return;if(e===null){const E=M.getState(),a=Array.from(E.areas.values()).find(r=>r.assignedAgentIds.includes(k.id));a&&M.unassignAgentFromArea(k.id,a.id),T(null),W(null);return}const i=x.get(e);if(!i)return;const l=Array.from(w.values()),_=Fs(i,l,k.position);M.updateAgent({...k,position:{...k.position,x:_.x,z:_.z}}),M.assignAgentToArea(k.id,e),T(null),W(null)},[k,x,w]);return c.useEffect(()=>{if(C.length===0){Q(!1),B(null);return}Y&&(!p||!C.some(e=>e.id===p))&&(B(C[0].id),t==null||t(C[0].id))},[C,Y,p,t]),c.useEffect(()=>{const e=a=>a instanceof HTMLElement?a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.tagName==="SELECT"||a.isContentEditable:!1,i=a=>a instanceof HTMLElement?!!a.closest(".guake-terminal")||a.classList.contains("guake-input")||a.classList.contains("agent-panel-input"):!1,l=a=>{const r=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(z=>z.dataset.agentId===a);r==null||r.scrollIntoView({block:"nearest",inline:"nearest"})},_=(a,r)=>{var ds,os,cs,ls,us,hs;const z=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(d=>{const u=d.dataset.agentId;if(!u)return null;const y=d.getBoundingClientRect();return{id:u,centerX:y.left+y.width/2,centerY:y.top+y.height/2,height:y.height}}).filter(d=>d!==null).sort((d,u)=>d.centerY-u.centerY||d.centerX-u.centerX);if(z.length===0)return a;const ss=z.reduce((d,u)=>d+u.height,0)/z.length,es=Math.max(18,ss*.6),f=[];for(const d of z){const u=f[f.length-1];if(!u){f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}]);continue}const y=u.reduce((ys,As)=>ys+As.centerY,0)/u.length;Math.abs(d.centerY-y)<=es?u.push({id:d.id,centerX:d.centerX,centerY:d.centerY}):f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}])}f.forEach(d=>d.sort((u,y)=>u.centerX-y.centerX));const R=f.findIndex(d=>d.some(u=>u.id===a));if(R===-1)return((os=(ds=f[0])==null?void 0:ds[0])==null?void 0:os.id)??a;const $=f[R],v=$.findIndex(d=>d.id===a);if(v===-1)return((ls=(cs=f[0])==null?void 0:cs[0])==null?void 0:ls.id)??a;if(r==="left")return((us=$[Math.max(0,v-1)])==null?void 0:us.id)??a;if(r==="right")return((hs=$[Math.min($.length-1,v+1)])==null?void 0:hs.id)??a;const q=r==="up"?Math.max(0,R-1):Math.min(f.length-1,R+1),o=f[q],G=$[v].centerX;let D=o[0],is=Math.abs(D.centerX-G);for(const d of o){const u=Math.abs(d.centerX-G);u<is&&(D=d,is=u)}return(D==null?void 0:D.id)??a},E=a=>{const r=M.getShortcuts(),z=r.find(o=>o.id==="dashboard-selector-toggle"),ss=r.find(o=>o.id==="dashboard-vim-left"),es=r.find(o=>o.id==="dashboard-vim-down"),f=r.find(o=>o.id==="dashboard-vim-up"),R=r.find(o=>o.id==="dashboard-vim-right"),$=r.find(o=>o.id==="open-terminal"),v=M.getState();if(e(a.target))if(!v.terminalOpen&&i(a.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(U(a,z)){if(C.length===0)return;a.preventDefault(),a.stopPropagation(),Q(!0),B(o=>{const G=o&&C.some(D=>D.id===o)?o:C[0].id;return t==null||t(G),window.setTimeout(()=>l(G),0),G});return}const q=U(a,ss)||a.key==="ArrowLeft"?"left":U(a,es)||a.key==="ArrowDown"?"down":U(a,f)||a.key==="ArrowUp"?"up":U(a,R)||a.key==="ArrowRight"?"right":null;if(q&&Y&&p){a.preventDefault(),a.stopPropagation();const o=_(p,q);o!==p&&(B(o),t==null||t(o),window.setTimeout(()=>l(o),0));return}if(U(a,$)){if(v.terminalOpen)return;if(Y&&p&&v.agents.has(p)){a.preventDefault(),n==null||n(p);return}if(v.selectedAgentIds.size===1){a.preventDefault();const o=Array.from(v.selectedAgentIds)[0];n==null||n(o);return}if(v.lastSelectedAgentId&&v.agents.has(v.lastSelectedAgentId)){a.preventDefault(),n==null||n(v.lastSelectedAgentId);return}}};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[C,Y,p,n,t]),c.useEffect(()=>{const e=document.activeElement;e instanceof HTMLElement&&e.closest(".guake-terminal")&&!M.getState().terminalOpen&&e.blur()},[]),s.jsxs("div",{className:"dashboard-view",children:[s.jsxs("div",{className:"dashboard-view__topbar",children:[s.jsxs("div",{className:"dashboard-view__metrics",children:[s.jsxs("button",{className:`dashboard-view__metric-btn ${j==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.total}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:labels.agents")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${j==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("working"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.working}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.working")})]}),s.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.idle}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.idle")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${j==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("error"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.error}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.error")})]})]}),s.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:h("searchPlaceholder"),value:N,onChange:e=>H(e.target.value)})]}),s.jsxs("div",{className:"dashboard-view__grouping",children:[s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("zone"),children:h("grouping.byZone")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("status"),children:h("grouping.byStatus")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("activity"),children:h("grouping.byActivity")})]}),s.jsxs("div",{className:"dashboard-view__content",children:[V.map(e=>{const i=O(e),l=b.has(i),_=m==="status"?ms(e.agents,{prioritizeRecentlyIdle:!0}):_s(e.agents),E=e.agents.filter(r=>r.status==="working"||r.status==="waiting"||r.status==="waiting_permission").length,a=e.agents.filter(r=>S.has(r.id)).length;return s.jsxs("div",{className:`dashboard-view__zone ${ps===(e.area?e.area.id:null)&&k?"dashboard-view__zone--drag-over":""}`,onDragOver:r=>Ns(r,e.area?e.area.id:null),onDragLeave:ks,onDrop:()=>Cs(e.area?e.area.id:null),children:[s.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>gs(i),children:[s.jsxs("div",{className:"dashboard-view__zone-left",children:[s.jsx("span",{className:`dashboard-view__zone-chevron ${l?"dashboard-view__zone-chevron--collapsed":""}`,children:s.jsx(F,{name:"caret-down",size:12})}),s.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:e.color}}),s.jsx("span",{className:"dashboard-view__zone-name",children:e.label}),s.jsxs("span",{className:"dashboard-view__zone-count",children:[h("agentCount",{count:e.agents.length}),E>0&&s.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",E," ",h("working")]}),a>0&&s.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",a," Unseen"]})]})]}),e.area&&g&&s.jsx("button",{className:"dashboard-view__zone-focus",onClick:r=>{r.stopPropagation(),g(e.area.id)},title:h("focusZone"),children:h("focusZone")})]}),!l&&s.jsx("div",{className:"dashboard-view__zone-grid",children:_.map(r=>s.jsx(fs,{agent:r,isSelected:rs.has(r.id),isKeyboardFocused:Y&&p===r.id,onSelect:()=>{t==null||t(r.id),Q(!0),B(r.id)},onDoubleClick:()=>xs(r.id),onChat:()=>n==null?void 0:n(r.id),onFocus:A?()=>A(r.id):void 0,onKill:L?()=>L(r.id):void 0,onDragStart:js},r.id))})]},i)}),V.length===0&&s.jsx("div",{className:"dashboard-view__empty",children:N?h("noAgentsMatching",{search:N}):h("noAgentsSpawned")}),P.size>0&&s.jsx(ws,{buildings:P,onSelectBuilding:X})]})]})}export{Ws as DashboardView};
1
+ import{z as ts,u as as,B as vs,C as bs,E as zs,j as s,I as F,G as Is,H as Es,J as $s,K as Ds,L as Ms,r as c,M as Ls,N as Xs,O as Ps,P as Ss,U as Ys,V as Rs,W as Gs,X as Us,Y as ms,Z as _s,s as M,_ as Fs,n as U}from"./main-DxFgIntP.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const fs=ts.memo(({agent:t,isSelected:A,isKeyboardFocused:L=!1,onSelect:X,onDoubleClick:n,onChat:g,onFocus:h,onKill:w,onDragStart:P})=>{const{t:x}=as(["dashboard","common"]),S=vs().has(t.id),N=bs(t.status),H=zs(t),j=Ms(H),I=t.taskLabel?s.jsxs(s.Fragment,{children:[s.jsx(F,{name:"task",size:12})," ",t.taskLabel]}):t.currentTask||t.lastAssignedTask,m=t.status==="idle"&&t.lastActivity>0,[,Z]=ts.useState(0);return ts.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>Z(J=>J+1),15e3);return()=>window.clearInterval(b)},[m]),s.jsxs("div",{className:`dash-card dash-card--${N} ${A?"dash-card--selected":""} ${L?"dash-card--keyboard-focused":""}`,"data-agent-id":t.id,onClick:X,onDoubleClick:b=>{b.stopPropagation(),n()},onDragStart:b=>{P==null||P(t),b.dataTransfer.effectAllowed="move"},draggable:!0,title:x("cards.doubleClickHint"),children:[s.jsxs("div",{className:"dash-card__row1",children:[s.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${N}`}),s.jsx("span",{className:"dash-card__name",children:t.name}),s.jsxs("span",{className:"dash-card__class",children:[s.jsx(Is,{agent:t,size:14})," ",t.class]}),s.jsxs("span",{className:`dash-card__provider dash-card__provider--${t.provider}`,children:[s.jsx(F,{name:t.provider==="codex"||t.provider==="opencode"?"status-pending":"robot",size:11,weight:t.provider==="codex"||t.provider==="opencode"?"fill":"regular",color:t.provider==="codex"?"#a16207":t.provider==="opencode"?"#4ade80":void 0})," ",t.provider]}),S&&s.jsx("span",{className:"dash-card__unseen-badge",title:"New output available - click to view",children:"!"})]}),s.jsxs("div",{className:"dash-card__row2",children:[s.jsx("span",{className:`dash-card__status dash-card__status--${N}`,children:S?"Unseen":t.status}),s.jsxs("div",{className:"dash-card__context",children:[s.jsx("div",{className:"dash-card__context-bar",children:s.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${j}`,style:{width:`${H}%`}})}),s.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${j}`,children:[H,"%"]})]})]}),s.jsxs("div",{className:"dash-card__row3",children:[s.jsxs("span",{className:"dash-card__workdir",title:t.cwd,children:[s.jsx(F,{name:"folder",size:11})," ",t.cwd.split("/").pop()||t.cwd]}),m&&s.jsxs("span",{className:"dash-card__idle-time",style:{color:Ds(t.lastActivity)},title:$s(t.lastActivity),children:[s.jsx(F,{name:"status-waiting-input",size:10})," ",Es(t.lastActivity)]})]}),I&&s.jsx("div",{className:"dash-card__row4",children:s.jsx("span",{className:"dash-card__task",children:I})}),s.jsxs("div",{className:"dash-card__actions",children:[g&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:b=>{b.stopPropagation(),g()},title:x("cards.openTerminal"),children:x("cards.chat")}),w&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:b=>{b.stopPropagation(),w()},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});fs.displayName="AgentCard";const ws=({buildings:t,onSelectBuilding:A})=>{const{t:L}=as(["dashboard"]),X=c.useMemo(()=>Array.from(t.values()).sort((n,g)=>n.name.localeCompare(g.name)),[t]);return s.jsxs("div",{className:"dashboard-view__buildings",children:[s.jsxs("div",{className:"dashboard-view__buildings-header",children:[s.jsx("span",{className:"dashboard-view__buildings-title",children:L("buildings.title")}),s.jsx("span",{className:"dashboard-view__buildings-count",children:X.length})]}),s.jsx("div",{className:"dashboard-view__buildings-row",children:X.map(n=>{const g=bs(n.status),h=Ls(n.type);return s.jsxs("button",{className:`dash-pill dash-pill--${g}`,onClick:()=>A==null?void 0:A(n.id),title:`${n.name} (${n.type}) - ${n.status}`,children:[s.jsx("span",{className:"dash-pill__icon",children:s.jsx(F,{name:h,size:14})}),s.jsx("span",{className:"dash-pill__name",children:n.name}),s.jsx("span",{className:`dash-pill__dot dash-pill__dot--${g}`})]},n.id)})})]})};ws.displayName="BuildingPills";function Ws({onSelectAgent:t,onFocusAgent:A,onKillAgent:L,onSelectBuilding:X,onOpenTerminal:n,onFocusZone:g}){const{t:h}=as(["dashboard","common"]),w=Xs(),P=Ps(),x=Ss(),rs=Ys(),S=vs(),[N,H]=c.useState(""),[j,I]=c.useState("all"),[m,Z]=c.useState("zone"),[b,J]=c.useState(new Set),[k,T]=c.useState(null),[ps,W]=c.useState(null),[Y,Q]=c.useState(!1),[p,B]=c.useState(null),K=c.useMemo(()=>{const e=Array.from(w.values());return{total:e.length,working:e.filter(i=>i.status==="working"||i.status==="waiting"||i.status==="waiting_permission").length,idle:e.filter(i=>i.status==="idle").length,error:e.filter(i=>i.status==="error"||i.status==="offline"||i.status==="orphaned").length}},[w]),ns=c.useMemo(()=>m==="zone"?Rs(w,x):m==="status"?Gs(w,S):Us(w),[w,x,m,S]),V=c.useMemo(()=>{const e=N.toLowerCase().trim(),i=ns.map(l=>({...l,agents:l.agents.filter(_=>{if(j==="working"){if(_.status!=="working"&&_.status!=="waiting"&&_.status!=="waiting_permission")return!1}else if(j==="error"&&_.status!=="error"&&_.status!=="offline"&&_.status!=="orphaned")return!1;return!(e&&!_.name.toLowerCase().includes(e)&&!_.class.toLowerCase().includes(e))})}));return m==="zone"?i:i.filter(l=>l.agents.length>0)},[ns,j,N,m]),O=c.useCallback(e=>e.area?`area:${e.area.id}`:`${m}:${e.label}`,[m]),C=c.useMemo(()=>{const e=[];return V.forEach(i=>{const l=O(i);if(b.has(l))return;const _=m==="status"?ms(i.agents,{prioritizeRecentlyIdle:!0}):_s(i.agents);e.push(..._)}),e},[V,b,m,O]),gs=c.useCallback(e=>{J(i=>{const l=new Set(i);return l.has(e)?l.delete(e):l.add(e),l})},[]),xs=c.useCallback(e=>{n==null||n(e)},[n]),js=c.useCallback(e=>{T(e)},[]),Ns=c.useCallback((e,i)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",W(i)},[]),ks=c.useCallback(()=>{W(null)},[]),Cs=c.useCallback(e=>{if(!k)return;if(e===null){const E=M.getState(),a=Array.from(E.areas.values()).find(r=>r.assignedAgentIds.includes(k.id));a&&M.unassignAgentFromArea(k.id,a.id),T(null),W(null);return}const i=x.get(e);if(!i)return;const l=Array.from(w.values()),_=Fs(i,l,k.position);M.updateAgent({...k,position:{...k.position,x:_.x,z:_.z}}),M.assignAgentToArea(k.id,e),T(null),W(null)},[k,x,w]);return c.useEffect(()=>{if(C.length===0){Q(!1),B(null);return}Y&&(!p||!C.some(e=>e.id===p))&&(B(C[0].id),t==null||t(C[0].id))},[C,Y,p,t]),c.useEffect(()=>{const e=a=>a instanceof HTMLElement?a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.tagName==="SELECT"||a.isContentEditable:!1,i=a=>a instanceof HTMLElement?!!a.closest(".guake-terminal")||a.classList.contains("guake-input")||a.classList.contains("agent-panel-input"):!1,l=a=>{const r=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(z=>z.dataset.agentId===a);r==null||r.scrollIntoView({block:"nearest",inline:"nearest"})},_=(a,r)=>{var ds,os,cs,ls,us,hs;const z=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(d=>{const u=d.dataset.agentId;if(!u)return null;const y=d.getBoundingClientRect();return{id:u,centerX:y.left+y.width/2,centerY:y.top+y.height/2,height:y.height}}).filter(d=>d!==null).sort((d,u)=>d.centerY-u.centerY||d.centerX-u.centerX);if(z.length===0)return a;const ss=z.reduce((d,u)=>d+u.height,0)/z.length,es=Math.max(18,ss*.6),f=[];for(const d of z){const u=f[f.length-1];if(!u){f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}]);continue}const y=u.reduce((ys,As)=>ys+As.centerY,0)/u.length;Math.abs(d.centerY-y)<=es?u.push({id:d.id,centerX:d.centerX,centerY:d.centerY}):f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}])}f.forEach(d=>d.sort((u,y)=>u.centerX-y.centerX));const R=f.findIndex(d=>d.some(u=>u.id===a));if(R===-1)return((os=(ds=f[0])==null?void 0:ds[0])==null?void 0:os.id)??a;const $=f[R],v=$.findIndex(d=>d.id===a);if(v===-1)return((ls=(cs=f[0])==null?void 0:cs[0])==null?void 0:ls.id)??a;if(r==="left")return((us=$[Math.max(0,v-1)])==null?void 0:us.id)??a;if(r==="right")return((hs=$[Math.min($.length-1,v+1)])==null?void 0:hs.id)??a;const q=r==="up"?Math.max(0,R-1):Math.min(f.length-1,R+1),o=f[q],G=$[v].centerX;let D=o[0],is=Math.abs(D.centerX-G);for(const d of o){const u=Math.abs(d.centerX-G);u<is&&(D=d,is=u)}return(D==null?void 0:D.id)??a},E=a=>{const r=M.getShortcuts(),z=r.find(o=>o.id==="dashboard-selector-toggle"),ss=r.find(o=>o.id==="dashboard-vim-left"),es=r.find(o=>o.id==="dashboard-vim-down"),f=r.find(o=>o.id==="dashboard-vim-up"),R=r.find(o=>o.id==="dashboard-vim-right"),$=r.find(o=>o.id==="open-terminal"),v=M.getState();if(e(a.target))if(!v.terminalOpen&&i(a.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(U(a,z)){if(C.length===0)return;a.preventDefault(),a.stopPropagation(),Q(!0),B(o=>{const G=o&&C.some(D=>D.id===o)?o:C[0].id;return t==null||t(G),window.setTimeout(()=>l(G),0),G});return}const q=U(a,ss)||a.key==="ArrowLeft"?"left":U(a,es)||a.key==="ArrowDown"?"down":U(a,f)||a.key==="ArrowUp"?"up":U(a,R)||a.key==="ArrowRight"?"right":null;if(q&&Y&&p){a.preventDefault(),a.stopPropagation();const o=_(p,q);o!==p&&(B(o),t==null||t(o),window.setTimeout(()=>l(o),0));return}if(U(a,$)){if(v.terminalOpen)return;if(Y&&p&&v.agents.has(p)){a.preventDefault(),n==null||n(p);return}if(v.selectedAgentIds.size===1){a.preventDefault();const o=Array.from(v.selectedAgentIds)[0];n==null||n(o);return}if(v.lastSelectedAgentId&&v.agents.has(v.lastSelectedAgentId)){a.preventDefault(),n==null||n(v.lastSelectedAgentId);return}}};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[C,Y,p,n,t]),c.useEffect(()=>{const e=document.activeElement;e instanceof HTMLElement&&e.closest(".guake-terminal")&&!M.getState().terminalOpen&&e.blur()},[]),s.jsxs("div",{className:"dashboard-view",children:[s.jsxs("div",{className:"dashboard-view__topbar",children:[s.jsxs("div",{className:"dashboard-view__metrics",children:[s.jsxs("button",{className:`dashboard-view__metric-btn ${j==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.total}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:labels.agents")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${j==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("working"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.working}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.working")})]}),s.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.idle}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.idle")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${j==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("error"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:K.error}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.error")})]})]}),s.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:h("searchPlaceholder"),value:N,onChange:e=>H(e.target.value)})]}),s.jsxs("div",{className:"dashboard-view__grouping",children:[s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("zone"),children:h("grouping.byZone")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("status"),children:h("grouping.byStatus")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("activity"),children:h("grouping.byActivity")})]}),s.jsxs("div",{className:"dashboard-view__content",children:[V.map(e=>{const i=O(e),l=b.has(i),_=m==="status"?ms(e.agents,{prioritizeRecentlyIdle:!0}):_s(e.agents),E=e.agents.filter(r=>r.status==="working"||r.status==="waiting"||r.status==="waiting_permission").length,a=e.agents.filter(r=>S.has(r.id)).length;return s.jsxs("div",{className:`dashboard-view__zone ${ps===(e.area?e.area.id:null)&&k?"dashboard-view__zone--drag-over":""}`,onDragOver:r=>Ns(r,e.area?e.area.id:null),onDragLeave:ks,onDrop:()=>Cs(e.area?e.area.id:null),children:[s.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>gs(i),children:[s.jsxs("div",{className:"dashboard-view__zone-left",children:[s.jsx("span",{className:`dashboard-view__zone-chevron ${l?"dashboard-view__zone-chevron--collapsed":""}`,children:s.jsx(F,{name:"caret-down",size:12})}),s.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:e.color}}),s.jsx("span",{className:"dashboard-view__zone-name",children:e.label}),s.jsxs("span",{className:"dashboard-view__zone-count",children:[h("agentCount",{count:e.agents.length}),E>0&&s.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",E," ",h("working")]}),a>0&&s.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",a," Unseen"]})]})]}),e.area&&g&&s.jsx("button",{className:"dashboard-view__zone-focus",onClick:r=>{r.stopPropagation(),g(e.area.id)},title:h("focusZone"),children:h("focusZone")})]}),!l&&s.jsx("div",{className:"dashboard-view__zone-grid",children:_.map(r=>s.jsx(fs,{agent:r,isSelected:rs.has(r.id),isKeyboardFocused:Y&&p===r.id,onSelect:()=>{t==null||t(r.id),Q(!0),B(r.id)},onDoubleClick:()=>xs(r.id),onChat:()=>n==null?void 0:n(r.id),onFocus:A?()=>A(r.id):void 0,onKill:L?()=>L(r.id):void 0,onDragStart:js},r.id))})]},i)}),V.length===0&&s.jsx("div",{className:"dashboard-view__empty",children:N?h("noAgentsMatching",{search:N}):h("noAgentsSpawned")}),P.size>0&&s.jsx(ws,{buildings:P,onSelectBuilding:X})]})]})}export{Ws as DashboardView};