tide-commander 1.35.0 → 1.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{BossLogsModal-B_dgVF7L.js → BossLogsModal-B6meUM1T.js} +1 -1
- package/dist/assets/BossSpawnModal-DzWs1NNZ.js +1 -0
- package/dist/assets/{ControlsModal-WMTTqbca.js → ControlsModal-D2QDZ20h.js} +1 -1
- package/dist/assets/{DockerLogsModal-THzhLHch.js → DockerLogsModal-Bh1ghgFV.js} +1 -1
- package/dist/assets/{EmbeddedEditor-DWLKJYav.js → EmbeddedEditor-C4rKc9Ys.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-DN9ceaS6.js → GmailOAuthSetup-E5_WFtyX.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-bVST2EOB.js → GoogleOAuthSetup-B7NLxSSp.js} +1 -1
- package/dist/assets/{IframeModal-BELsjvgi.js → IframeModal-CGbINL-o.js} +1 -1
- package/dist/assets/{IntegrationsPanel-DwDr4BRt.js → IntegrationsPanel-DZmbjiXV.js} +2 -2
- package/dist/assets/{LogViewerModal-CMe04PO5.js → LogViewerModal-KI2L074n.js} +1 -1
- package/dist/assets/{MonitoringModal-CqSalNeY.js → MonitoringModal-CWqjvTra.js} +1 -1
- package/dist/assets/{PM2LogsModal-CCmCDxVt.js → PM2LogsModal-DRHybuUO.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-IfzPidIv.js → RestoreArchivedAreaModal-DjpKSz7P.js} +1 -1
- package/dist/assets/{SaveSnapshotModal-DUhrVD5l.js → SaveSnapshotModal-CWtf3rgg.js} +1 -1
- package/dist/assets/Scene2DCanvas-CSfRDtXw.js +1 -0
- package/dist/assets/SceneManager-Do4NpOsy.js +104 -0
- package/dist/assets/{SkillsPanel-CPFOI4Tl.js → SkillsPanel-BqZSNfNW.js} +3 -3
- package/dist/assets/{SnapshotManager-Cbu0tJBz.js → SnapshotManager-DyqyIhWz.js} +1 -1
- package/dist/assets/SpawnModal-CGFj_b9I.js +1 -0
- package/dist/assets/SubordinateAssignmentModal-DGFoupVt.js +1 -0
- package/dist/assets/{SupervisorPanel-BvX-dlk_.js → SupervisorPanel-B1PVopnm.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-RUVFmKmf.js → TriggerManagerPanel-CFez7_vm.js} +2 -2
- package/dist/assets/{WorkflowEditorPanel-CwZpEqzM.js → WorkflowEditorPanel-ClMl5U8g.js} +1 -1
- package/dist/assets/{index-DDPUtz8-.js → index-B4SUGrVB.js} +1 -1
- package/dist/assets/{index-CiD1Rwaq.js → index-BK3kI8Cb.js} +1 -1
- package/dist/assets/{index-BFguOWBW.js → index-Bf3KKyiV.js} +2 -2
- package/dist/assets/{index-D4nfDvz4.js → index-Bmu_CPsU.js} +3 -3
- package/dist/assets/index-CbzHGOPP.js +1 -0
- package/dist/assets/index-CpZt7iSV.js +1 -0
- package/dist/assets/{index-B-wV06cR.js → index-CxtzptPF.js} +5 -5
- package/dist/assets/{index-EH8IBvSU.js → index-D2_-BBP8.js} +3 -3
- package/dist/assets/main-C6uuUPJ0.css +1 -0
- package/dist/assets/main-CtGyoZXd.js +152 -0
- package/dist/assets/{web-D1vWYL8u.js → web-C2JUUvGB.js} +1 -1
- package/dist/assets/{web-DUq3Undh.js → web-D4EcUHSn.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/src/packages/server/routes/agents.js +209 -1
- package/dist/src/packages/server/routes/areas.js +25 -0
- package/dist/src/packages/server/routes/index.js +2 -0
- package/dist/src/packages/server/routes/workspaces.js +123 -0
- package/dist/src/packages/server/services/agent-service.js +87 -1
- package/dist/src/packages/server/services/area-layout-service.js +260 -0
- package/dist/src/packages/server/services/workspace-service.js +104 -0
- package/package.json +1 -1
- package/dist/assets/BossSpawnModal-CSO1bYxA.js +0 -1
- package/dist/assets/Scene2DCanvas-Bl5DUC7w.js +0 -1
- package/dist/assets/SceneManager-BGO9tiaI.js +0 -104
- package/dist/assets/SpawnModal-BqDbsYLY.js +0 -1
- package/dist/assets/SubordinateAssignmentModal-DOqkhL_L.js +0 -1
- package/dist/assets/camera-D_KeL_pz.js +0 -1
- package/dist/assets/index-C7gqY2AA.js +0 -1
- package/dist/assets/index-H0PzHVFw.js +0 -1
- package/dist/assets/main-Cjm0d8dZ.js +0 -152
- package/dist/assets/main-DqC9_fF4.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as g,a4 as te,a5 as pe,j as e,u as U,a6 as be,a7 as je,f as ie,s as j,a8 as Pe,v as Ee,w as K,a9 as z,aa as Le,Y as Fe,ab as Oe,V as ee,ac as $e,ad as _e,ae as De,af as Re,ag as G,ah as Be,ai as Ue,aj as ze,O as Ve,ak as ae,al as ne,am as Ke,a0 as qe,S as He}from"./main-CtGyoZXd.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const le="deivid11/tide-commander",Me=`https://api.github.com/repos/${le}/releases/latest`,Ge=`https://api.github.com/repos/${le}/releases?per_page=3`,Ye=3600*1e3,fe="app_update_dismissed_version",xe="1.36.0";function We(){var x,y;const[s,i]=g.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:xe}),n=((y=(x=te)==null?void 0:x.getPlatform)==null?void 0:y.call(x))==="android"||!1,o=r=>r.replace(/^v/,"").split(".").map(c=>parseInt(c,10)||0),d=(r,u)=>{const c=o(r),k=o(u),w=Math.max(c.length,k.length);for(let T=0;T<w;T++){const I=c[T]||0,F=k[T]||0;if(I>F)return 1;if(I<F)return-1}return 0},p=async r=>{var c,k;if(te&&pe&&((k=(c=te).isNativePlatform)==null?void 0:k.call(c))===!0){const w=await pe.get({url:r,headers:{Accept:"application/vnd.github.v3+json"}});return{data:w.data,status:w.status}}else{const w=await fetch(r,{headers:{Accept:"application/vnd.github.v3+json"}});return w.ok?{data:await w.json(),status:w.status}:{data:null,status:w.status}}},l=g.useCallback(async(r=!1)=>{i(u=>({...u,isChecking:!0,error:null}));try{const[u,c]=await Promise.all([p(Me),p(Ge)]);if(u.status!==200)throw new Error(`GitHub API error: ${u.status}`);const k=u.data,w=k.tag_name;let T=[];c.status===200&&c.data&&(T=c.data.map(S=>({version:S.tag_name,name:S.name,publishedAt:S.published_at,releaseUrl:S.html_url})));const I=localStorage.getItem(fe);if(!r&&I===w)return i(S=>({...S,isChecking:!1,updateAvailable:!1,recentReleases:T})),null;if(!(d(w,xe)>0))return i(S=>({...S,isChecking:!1,updateAvailable:!1,recentReleases:T})),null;const _=k.assets.find(S=>S.name.endsWith(".apk")&&S.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(S=>({...S,isChecking:!1,updateAvailable:!0,updateInfo:m,recentReleases:T})),m}catch(u){const c=u instanceof Error?u.message:"Failed to check for updates";return i(k=>({...k,isChecking:!1,error:c})),null}},[]),a=g.useCallback(async()=>{var r,u,c;if(!((r=s.updateInfo)!=null&&r.apkUrl)){(u=s.updateInfo)!=null&&u.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(T=>({...T,error:w}))}},[s.updateInfo,n]),f=g.useCallback(()=>{s.updateInfo&&localStorage.setItem(fe,s.updateInfo.version),i(r=>({...r,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),N=g.useCallback(()=>{var r;(r=s.updateInfo)!=null&&r.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${le}/releases`,"_blank")},[s.updateInfo]);return g.useEffect(()=>{if(!n)return;const r=setTimeout(()=>{l()},5e3),u=setInterval(()=>{l()},Ye);return()=>{clearTimeout(r),clearInterval(u)}},[n,l]),{...s,isAndroid:n,checkForUpdate:l,downloadAndInstall:a,dismissUpdate:f,openReleasePage:N}}const ve="tide-toolbox-collapse";function Je(s,i){try{const n=localStorage.getItem(`${ve}-${s}`);if(n!==null)return n==="true"}catch{}return i}function Ze(s,i){try{localStorage.setItem(`${ve}-${s}`,String(i))}catch{}}function O({title:s,storageKey:i,defaultOpen:n=!1,forceOpen:o=!1,children:d,headerExtra:p}){const[l,a]=g.useState(()=>i?Je(i,n):n),f=()=>{const x=!l;a(x),i&&Ze(i,x)},N=o||l;return e.jsxs("div",{className:`collapsible-section ${N?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:f,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[p,e.jsx("span",{className:"collapsible-arrow",children:N?"▼":"▶"})]})]}),N&&e.jsx("div",{className:"collapsible-content",children:d})]})}function Xe({area:s,isSelected:i,onClick:n,onDelete:o}){const{t:d}=U(["config","common"]),p=s.assignedAgentIds.length,l=s.type==="rectangle"?d("config:areas.rect"):d("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," ",p>0&&`• ${p} ${p>1?d("common:labels.agents").toLowerCase():d("common:labels.agent").toLowerCase()}`]})]}),e.jsx("button",{className:"area-delete-btn",onClick:o,title:d("config:areas.deleteArea"),children:"×"})]})}function Qe({building:s,isSelected:i,onClick:n,onEdit:o}){var f;const{t:d}=U(["config"]),p=be[s.type],l=((f=s.pm2Status)==null?void 0:f.ports)||[],a=(N,x)=>{N.stopPropagation(),window.open(`http://localhost:${x}`,"_blank")};return e.jsxs("div",{className:`building-item ${i?"selected":""}`,onClick:n,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:je[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:p.icon}),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,l.length>0&&e.jsx("span",{className:"building-ports",children:l.map(N=>e.jsxs("a",{href:`http://localhost:${N}`,className:"building-port-link",onClick:x=>a(x,N),title:`Open :${N}`,children:[":",N]},N))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:N=>{N.stopPropagation(),o()},title:d("config:buildings.editBuilding"),children:"⚙"})]})}function es({building:s,onClose:i,onOpenModal:n}){var x,y,r,u,c,k,w,T;const{t:o}=U(["config","common"]),{buildingLogs:d}=ie(),p=j.getBuildingLogs(s.id),l=be[s.type],a=Pe[s.style||"server-rack"],f=I=>{j.sendBuildingCommand(s.id,I)},N=I=>{window.open(I,"_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:l.icon}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:je[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:a.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:()=>f("start"),disabled:!((x=s.commands)!=null&&x.start)||s.status==="running",title:((y=s.commands)==null?void 0:y.start)||o("config:buildings.noStartCommand"),children:["▶ ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>f("stop"),disabled:!((r=s.commands)!=null&&r.stop)||s.status==="stopped",title:((u=s.commands)==null?void 0:u.stop)||o("config:buildings.noStopCommand"),children:["■ ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>f("restart"),disabled:!((c=s.commands)!=null&&c.restart),title:((k=s.commands)==null?void 0:k.restart)||o("config:buildings.noRestartCommand"),children:["⟳ ",o("common:buttons.retry")]}),e.jsx("button",{className:"building-editor-action-btn health",onClick:()=>f("healthCheck"),disabled:!((w=s.commands)!=null&&w.healthCheck),title:((T=s.commands)==null?void 0:T.healthCheck)||o("config:buildings.noHealthCheck"),children:"♥ 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((I,F)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>N(I.url),title:I.url,children:["🔗 ",I.label||I.url]},F))})]}),p.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:()=>j.clearBuildingLogs(s.id),title:o("common:buttons.clear"),children:o("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:p.slice(-5).map((I,F)=>e.jsx("div",{className:"building-editor-log-entry",children:I},F))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:n,children:["⚙ ",o("config:buildings.fullSettings")]})})]})}async function ss(s,i){const n=z(),o=await fetch(K(`/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 d=await o.json().catch(()=>({error:o.statusText}));throw new Error(d.error||`Upload failed: ${o.statusText}`)}return o.json()}async function ts(s){const i=z(),n=await fetch(K(`/api/areas/${s}/logo`),{method:"DELETE",headers:{...i?{Authorization:`Bearer ${i}`}:{}}});if(!n.ok)throw new Error(`Failed to delete logo: ${n.statusText}`)}function as(s){return Ee(K(`/api/areas/logos/${s}`))}const ns=[{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 os({area:s,onClose:i,onOpenFolder:n}){var R;const{t:o}=U(["config","common"]),[d,p]=g.useState(s.name),[l,a]=g.useState(s.prompt||""),[f,N]=g.useState(!1),[x,y]=g.useState(""),[r,u]=g.useState(!1),c=g.useRef(null);g.useEffect(()=>{p(s.name)},[s.id,s.name]),g.useEffect(()=>{a(s.prompt||"")},[s.id,s.prompt]);const k=h=>{const C=h.target.value;p(C),j.updateArea(s.id,{name:C})},w=h=>{j.updateArea(s.id,{color:h})},T=h=>{const C=h.target.value;a(C),j.updateArea(s.id,{prompt:C})},I=()=>{x.trim()&&(j.addDirectoryToArea(s.id,x.trim()),y(""),N(!1))},F=(h,C)=>{C.stopPropagation(),j.removeDirectoryFromArea(s.id,h)},_=()=>{j.bringAreaToFront(s.id)},m=()=>{j.sendAreaToBack(s.id)},S=g.useCallback(()=>{let h=2,C=2;s.type==="rectangle"&&s.width&&s.height?(h=s.width,C=s.height):s.type==="circle"&&s.radius&&(h=s.radius*1.414,C=s.radius*1.414);const L=Math.min(h,C)*.4;return{width:Math.round(L*10)/10,height:Math.round(L*10)/10}},[s.type,s.width,s.height,s.radius]),Q=async h=>{var L;const C=(L=h.target.files)==null?void 0:L[0];if(C){u(!0);try{const q=await ss(s.id,C),H=S();j.updateArea(s.id,{logo:{filename:q.filename,position:"center",width:H.width,height:H.height,keepAspectRatio:!0,opacity:.8}})}catch(q){console.error("Failed to upload logo:",q)}finally{u(!1),c.current&&(c.current.value="")}}},Y=async()=>{try{await ts(s.id),j.updateArea(s.id,{logo:void 0})}catch(h){console.error("Failed to remove logo:",h)}},W=h=>{s.logo&&j.updateArea(s.id,{logo:{...s.logo,position:h}})},J=h=>{if(!s.logo)return;const C=parseFloat(h.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const L=s.logo.height/s.logo.width;j.updateArea(s.id,{logo:{...s.logo,width:C,height:Math.round(C*L*10)/10}})}else j.updateArea(s.id,{logo:{...s.logo,width:C}})},b=h=>{if(!s.logo)return;const C=parseFloat(h.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const L=s.logo.width/s.logo.height;j.updateArea(s.id,{logo:{...s.logo,height:C,width:Math.round(C*L*10)/10}})}else j.updateArea(s.id,{logo:{...s.logo,height:C}})},E=()=>{s.logo&&j.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},P=h=>{s.logo&&j.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(h.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:d,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:Le.map(h=>e.jsx("div",{className:`color-swatch ${s.color===h?"selected":""}`,style:{backgroundColor:h},onClick:()=>w(h)},h))})]}),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:["↑ ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:m,title:o("config:areas.sendToBack"),children:["↓ ",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:as(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:Y,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var h;return(h=c.current)==null?void 0:h.click()},disabled:r,children:r?"...":"↻"})]}),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:ns.map(({key:h,labelKey:C})=>{var L;return e.jsx("button",{className:`area-logo-pos-btn ${((L=s.logo)==null?void 0:L.position)===h?"active":""}`,onClick:()=>W(h),children:o(`config:areas.${C}`)},h)})})]}),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:J,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:b,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:E}),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:P,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 h;return(h=c.current)==null?void 0:h.click()},disabled:r,children:r?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:c,type:"file",accept:"image/*",style:{display:"none"},onChange:Q})]})]}),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(h=>e.jsxs("div",{className:"area-folder-item",title:h,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("span",{className:"area-folder-path",children:h.split("/").pop()||h}),e.jsx("button",{className:"area-folder-remove",onClick:C=>F(h,C),title:o("config:areas.removeFolder"),children:"×"})]},h)),f?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(Fe,{value:x,onChange:y,onSubmit:I,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:I,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>N(!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:T,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 is(){const{t:s}=U(["config","common"]),i=Oe(),[n,o]=g.useState(!1),[d,p]=g.useState(null),[l,a]=g.useState({name:"",key:"",value:"",description:""}),f=()=>{o(!0),p(null),a({name:"",key:"",value:"",description:""})},N=c=>{p(c.id),o(!1),a({name:c.name,key:c.key,value:c.value,description:c.description||""})},x=()=>{o(!1),p(null),a({name:"",key:"",value:"",description:""})},y=()=>{!l.name.trim()||!l.key.trim()||(d?j.updateSecret(d,{name:l.name.trim(),key:l.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:l.value,description:l.description.trim()||void 0}):j.createSecret({name:l.name.trim(),key:l.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:l.value,description:l.description.trim()||void 0}),x())},r=c=>{confirm(s("config:secrets.deleteConfirm"))&&(j.deleteSecret(c),d===c&&x())},u=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 ${d===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:()=>u(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:()=>N(c),title:s("common:buttons.edit"),children:"✎"}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>r(c.id),title:s("common:buttons.delete"),children:"×"})]})]}),c.description&&e.jsx("div",{className:"secret-item-description",children:c.description})]},c.id))}),(n||d)&&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:x,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:y,disabled:!l.name.trim()||!l.key.trim(),children:s(d?"config:secrets.update":"common:buttons.add")})]})]}),!n&&!d&&e.jsx("button",{className:"secrets-add-btn",onClick:f,children:s("config:secrets.addSecret")})]})}function ls(){const{t:s}=U(["config","common"]),[i,n]=g.useState([]),[o,d]=g.useState(new Set),[p,l]=g.useState(new Set),[a,f]=g.useState(!1),[N,x]=g.useState(!1),[y,r]=g.useState(null),[u,c]=g.useState(null),[k,w]=g.useState(null);g.useEffect(()=>{ee(K("/api/config/categories")).then(b=>b.json()).then(b=>{const E=Array.isArray(b)?b:[];n(E),d(new Set(E.map(P=>P.id)))}).catch(b=>console.error("Failed to fetch config categories:",b))},[]);const T=b=>{d(E=>{const P=new Set(E);return P.has(b)?P.delete(b):P.add(b),P})},I=b=>{l(E=>{const P=new Set(E);return P.has(b)?P.delete(b):P.add(b),P})},F=()=>d(new Set(i.map(b=>b.id))),_=()=>d(new Set),m=()=>{u&&l(new Set(u.categories.map(b=>b.id)))},S=()=>l(new Set),Q=async()=>{var b;if(o.size!==0){f(!0),w(null);try{const E=Array.from(o).join(","),P=await ee(K(`/api/config/export?categories=${E}`));if(!P.ok)throw new Error("Export failed");const R=await P.blob(),h=window.URL.createObjectURL(R),C=document.createElement("a");C.href=h;const L=P.headers.get("Content-Disposition"),q=((b=L==null?void 0:L.match(/filename="(.+)"/))==null?void 0:b[1])||"tide-commander-config.zip";C.download=q,document.body.appendChild(C),C.click(),document.body.removeChild(C),window.URL.revokeObjectURL(h),w({type:"success",text:s("config:data.exportSuccess")})}catch(E){w({type:"error",text:E.message||"Export failed"})}finally{f(!1)}}},Y=async b=>{var P;const E=(P=b.target.files)==null?void 0:P[0];if(E){r(E),w(null),c(null),l(new Set);try{const R=await ee(K("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await E.arrayBuffer()});if(!R.ok){const L=await R.json();throw new Error(L.error||"Failed to preview config file")}const h=await R.json(),C=Array.isArray(h.categories)?h.categories:[];c({...h,categories:C}),l(new Set(C.map(L=>L.id)))}catch(R){w({type:"error",text:R.message||"Failed to read config file"}),r(null)}}},W=async()=>{if(!(!y||p.size===0)){x(!0),w(null);try{const b=Array.from(p).join(","),E=await ee(K(`/api/config/import?categories=${b}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await y.arrayBuffer()}),P=await E.json();if(!E.ok)throw new Error(P.error||"Import failed");w({type:"success",text:P.message||s("config:data.importSuccess")}),r(null),c(null),l(new Set)}catch(b){w({type:"error",text:b.message||"Import failed"})}finally{x(!1)}}},J=()=>{r(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:F,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(b=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(b.id),onChange:()=>T(b.id)}),e.jsx("span",{className:"data-category-name",children:b.name})]},b.id))}),e.jsx("button",{className:"data-action-btn export",onClick:Q,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?u?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(u.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:S,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:u.categories.map(b=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:p.has(b.id),onChange:()=>I(b.id)}),e.jsx("span",{className:"data-category-name",children:b.name}),b.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",b.fileCount," ",s("config:data.files"),")"]})]},b.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:J,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:W,disabled:N||p.size===0,children:N?s("config:data.importing"):s("config:data.importCount",{count:p.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:Y,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}function cs(){const[s,i]=g.useState(()=>$e()),n=o=>{i(o);const d=De(o);Re(d)};return e.jsx("div",{className:"theme-selector",children:e.jsx("div",{className:"theme-selector-grid",children:_e.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 rs(){const{t:s}=U(["config"]),{updateAvailable:i,updateInfo:n,recentReleases:o,isChecking:d,error:p,currentVersion:l,isAndroid:a,checkForUpdate:f,downloadAndInstall:N,openReleasePage:x}=We(),y=u=>u?`${(u/(1024*1024)).toFixed(1)} MB`:"",r=u=>new Date(u).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("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:x,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)]}),p&&e.jsx("div",{className:"about-update-error",children:p}),e.jsxs("div",{className:"about-update-actions",children:[e.jsx("button",{className:"about-update-btn changelog",onClick:x,children:s("config:about.changelog")}),a&&n.apkUrl?e.jsx("button",{className:"about-update-btn download",onClick:N,children:s("config:about.downloadAPK")}):e.jsx("button",{className:"about-update-btn download",onClick:x,children:s("config:about.viewRelease")})]})]}):e.jsxs("div",{className:"about-update-check",children:[e.jsx("span",{className:"about-update-status",children:s(d?"config:about.checkingUpdates":"config:about.upToDate")}),e.jsx("button",{className:"about-update-btn check",onClick:()=>f(!0),disabled:d,children:d?"...":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(u=>e.jsxs("a",{href:u.releaseUrl,target:"_blank",rel:"noopener noreferrer",className:`about-release-item ${u.version===`v${l}`||u.version===l?"current":""}`,children:[e.jsx("span",{className:"about-release-version",children:u.version}),e.jsx("span",{className:"about-release-date",children:r(u.publishedAt)})]},u.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("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 ds={gmail:"✉️",slack:"💬",jira:"📋","google-calendar":"📅",docx:"📄"};function ms({onOpenModal:s}){const[i,n]=g.useState([]),[o,d]=g.useState(!0),p=g.useCallback(async()=>{try{const l=await ee(K("/api/integrations"));if(!l.ok)return;const a=await l.json();n(a)}catch{}finally{d(!1)}},[]);return g.useEffect(()=>{p()},[p]),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=ds[l.id]||"🔌",f=!!l.status.error,N=l.status.connected,x=f?"#f38ba8":N?"#a6e3a1":"#fab387",y=f?"Error":N?"Connected":"Setup Required",r=f?"✗":N?"✓":"⚠";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:x,fontSize:11,fontWeight:500,whiteSpace:"nowrap"},children:[r," ",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:u=>{u.target.style.color="var(--text-primary, #cdd6f4)"},onMouseLeave:u=>{u.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 us(){const s=z(),i=await fetch(`${G()}/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 gs(s){const i=z(),n=await fetch(`${G()}/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 hs(){const s=z(),i=await fetch(`${G()}/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 ps(){const s=z(),i=await fetch(`${G()}/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 fs(s){const i=z(),n=await fetch(`${G()}/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 xs(){const s=z(),i=await fetch(`${G()}/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 bs(s){const i=z(),n=await fetch(`${G()}/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}`)}function js({isOpen:s,onClose:i}){const{t:n}=U(["config"]),[o,d]=g.useState(""),[p,l]=g.useState(""),[a,f]=g.useState(!0),[N,x]=g.useState(null),[y,r]=g.useState(null),[u,c]=g.useState(!1);g.useEffect(()=>{s&&k()},[s]);const k=async()=>{try{f(!0),x(null),r(null);const m=await us();d(m),l(m),c(!1)}catch(m){x(m instanceof Error?m.message:"Failed to load system prompt")}finally{f(!1)}},w=m=>{const S=m.target.value;d(S),c(S!==p),x(null),r(null)},T=async()=>{try{x(null),r(null),await gs(o),l(o),c(!1),r(n("config:systemPrompt.saved"))}catch(m){x(m instanceof Error?m.message:"Failed to save system prompt")}},I=async()=>{if(window.confirm(n("config:systemPrompt.confirmClear")))try{x(null),r(null),await hs(),d(""),l(""),c(!1),r(n("config:systemPrompt.cleared"))}catch(m){x(m instanceof Error?m.message:"Failed to clear system prompt")}},F=()=>{d(p),c(!1),x(null),r(null)},_=m=>{if(m.key==="Escape"){if(u&&!window.confirm("You have unsaved changes. Close anyway?")){m.preventDefault();return}i()}};return s?e.jsx(Be,{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("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")}),N&&e.jsxs("div",{className:"alert alert-error",children:[e.jsx("span",{className:"alert-icon",children:"⚠️"}),N]}),y&&e.jsxs("div",{className:"alert alert-success",children:[e.jsx("span",{className:"alert-icon",children:"✓"}),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:I,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:F,disabled:!u||a,children:n("config:systemPrompt.reset")}),e.jsx("button",{className:"btn btn-primary",onClick:T,disabled:!u||a,children:n("config:systemPrompt.save")})]})]})]})})}):null}const vs=[{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:"🌙"}],Ns=[{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:"🔴"}],ys=[{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:"👎"}],ks=[{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:"💜"}],ws=[{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"}],Ss=[{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"}],Cs={showTrees:"trees",showBushes:"bushes",showHouse:"house",showLamps:"lamps",showGrass:"grass",showClouds:"clouds"},As={none:"grass","pokemon-stadium":"pokemon"},Is={"emote-yes":"yes","emote-no":"no"},Ts={"":"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 X({options:s,value:i,onChange:n,iconOnly:o=!1}){return e.jsx("div",{className:"chip-selector",children:s.map(d=>e.jsxs("button",{className:`chip ${i===d.value?"active":""}`,onClick:()=>n(d.value),title:d.label,children:[e.jsx("span",{className:"chip-icon",children:d.icon}),!o&&e.jsx("span",{className:"chip-label",children:d.label})]},d.value))})}function v({text:s,query:i}){if(!i.trim())return e.jsx(e.Fragment,{children:s});const n=s.toLowerCase(),o=i.toLowerCase(),d=n.indexOf(o);if(d===-1)return e.jsx(e.Fragment,{children:s});const p=s.slice(0,d),l=s.slice(d,d+i.length),a=s.slice(d+i.length);return e.jsxs(e.Fragment,{children:[p,e.jsx("mark",{className:"search-highlight",children:l}),a]})}const Ps=[{id:"general",title:"General",keywords:["history","hide costs","grid","fps","power saving","performance","limit","editor","external editor","language","idioma","语言","vibration","haptic","intensity"]},{id:"agentNames",title:"Agent Names",keywords:["agent","names","custom","characters","rename"]},{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","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"]},{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"]}],oe=[{value:"auto",label:"Auto",icon:"🌐"},{value:"en",label:"English",icon:"🇺🇸"},{value:"zh-CN",label:"中文",icon:"🇨🇳"},{value:"es",label:"Español",icon:"🇪🇸"},{value:"hi",label:"हिन्दी",icon:"🇮🇳"},{value:"pt",label:"Português",icon:"🇧🇷"},{value:"ru",label:"Русский",icon:"🇷🇺"},{value:"ja",label:"日本語",icon:"🇯🇵"},{value:"de",label:"Deutsch",icon:"🇩🇪"},{value:"fr",label:"Français",icon:"🇫🇷"},{value:"it",label:"Italiano",icon:"🇮🇹"}];function Es({config:s,onChange:i,searchQuery:n="",onOpenIntegrationsModal:o,onOpenMonitoringModal:d,onOpenWorkflowEditor:p,onOpenTriggerManager:l}){var ge;const{t:a}=U(["config","common"]),f=ie(),[N,x]=g.useState(f.settings.historyLimit),[y,r]=g.useState(()=>Ue()),[u,c]=g.useState(!1),[k,w]=g.useState(()=>z()),[T,I]=g.useState(!1),[F,_]=g.useState(!1),[m,S]=g.useState(""),[Q,Y]=g.useState(!1),[W,J]=g.useState(""),[b,E]=g.useState(!1);g.useEffect(()=>{xs().then(J).catch(()=>{})},[]),g.useEffect(()=>{ps().then(t=>{t!==f.settings.experimentalEchoPrompt&&j.updateSettings({experimentalEchoPrompt:t})}).catch(()=>{})},[]),g.useEffect(()=>ze(t=>{r(t),c(!1)}),[]);const P=vs.map(t=>({...t,label:a(`config:time.${t.value}`)})),R=Ns.map(t=>({...t,label:a(`config:floor.${As[t.value]||t.value}`)})),h=ys.map(t=>({...t,label:a(`config:animation.${Is[t.value]||t.value}`)})),C=ks.map(t=>({...t,label:a(`config:colorMode.${t.value}`)})),L=ws.map(t=>({...t,label:a(`config:terrain.${Cs[t.key]}`)})),q=Ss.map(t=>({...t,label:a(`config:sky.${Ts[t.value??""]}`)})),H=n.trim()?Ps.filter(t=>{const D=n.toLowerCase();return t.title.toLowerCase().includes(D)||t.keywords.some(se=>se.toLowerCase().includes(D))}).map(t=>t.id):null,A=t=>H?H.includes(t):!0,V=f.settings.customAgentNames||[],Ne=V.length>0?V:Ve,ce=()=>{const t=m.trim();t&&!V.includes(t)&&(j.updateSettings({customAgentNames:[...V,t]}),S(""))},ye=t=>{j.updateSettings({customAgentNames:V.filter(D=>D!==t)})},ke=()=>{j.updateSettings({customAgentNames:[]})},we=t=>{r(t),c(!0)},re=()=>{Ke(y),c(!1),ne()},Se=t=>{w(t),I(!0)},de=()=>{qe(He.AUTH_TOKEN,k),I(!1),ne()},Ce=t=>{J(t),E(!0)},me=()=>{bs(W).catch(()=>{}),E(!1)},Z=t=>{i({...s,terrain:{...s.terrain,...t}})},M=t=>{i({...s,modelStyle:{...s.modelStyle,...t}})},ue=t=>{i({...s,animations:{...s.animations,...t}})},Ae=t=>{x(t),j.updateSettings({historyLimit:t})},Ie=t=>{const D=s.terrain[t];typeof D=="boolean"&&Z({[t]:!D})},$=n.trim().length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-section",children:[H&&H.length===0&&e.jsx("div",{className:"config-no-results",children:a("config:noResults",{query:n})}),A("general")&&e.jsxs(O,{title:a("config:sections.general"),storageKey:"general",defaultOpen:!0,forceOpen:$&&A("general"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.history"),query:n})}),e.jsx("input",{type:"number",className:"config-input config-input-sm",value:N,onChange:t=>Ae(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(v,{text:a("config:general.hideCosts"),query:n})}),e.jsx(B,{checked:f.settings.hideCost,onChange:t=>j.updateSettings({hideCost:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{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(v,{text:a("config:general.showFPS"),query:n})}),e.jsx(B,{checked:f.settings.showFPS,onChange:t=>j.updateSettings({showFPS:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{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(v,{text:a("config:general.powerSaving"),query:n})," ⚡"]}),e.jsx(B,{checked:f.settings.powerSaving,onChange:t=>j.updateSettings({powerSaving:t})})]}),e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.vibrationIntensity"),query:n})}),e.jsx("input",{type:"range",className:"config-slider",min:"0",max:"5",step:"1",value:f.settings.vibrationIntensity,onChange:t=>j.updateSettings({vibrationIntensity:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:f.settings.vibrationIntensity===0?a("config:vibrationValues.off"):f.settings.vibrationIntensity===1?a("config:vibrationValues.ultraLight"):f.settings.vibrationIntensity===2?a("config:vibrationValues.veryLight"):f.settings.vibrationIntensity===3?a("config:vibrationValues.light"):f.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(v,{text:a("config:general.externalEditor"),query:n})}),e.jsx("input",{type:"text",className:"config-input",placeholder:a("config:general.externalEditorPlaceholder"),value:f.settings.externalEditorCommand||"",onChange:t=>j.updateSettings({externalEditorCommand:t.target.value})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:general.language"),query:n})}),e.jsx(X,{options:oe,value:localStorage.getItem("tide-commander-language-mode")==="manual"?((ge=oe.find(t=>t.value!=="auto"&&ae.language.startsWith(t.value.split("-")[0])))==null?void 0:ge.value)||"en":"auto",onChange:t=>{var D;if(t==="auto"){localStorage.setItem("tide-commander-language-mode","auto");const se=navigator.language,Te=((D=oe.find(he=>he.value!=="auto"&&se.startsWith(he.value.split("-")[0])))==null?void 0:D.value)||"en";ae.changeLanguage(Te)}else localStorage.setItem("tide-commander-language-mode","manual"),ae.changeLanguage(t)}})]})]}),A("agentNames")&&e.jsx(O,{title:a("config:sections.agentNames"),storageKey:"agentNames",defaultOpen:!1,forceOpen:$&&A("agentNames"),children:e.jsxs("div",{className:"agent-names-section",children:[e.jsx("span",{className:"config-hint",children:V.length>0?a("config:agentNames.customConfigured",{count:V.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:m,onChange:t=>S(t.target.value),onKeyDown:t=>{t.key==="Enter"&&ce()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:ce,disabled:!m.trim(),title:a("config:agentNames.addName"),children:"+"})]}),e.jsx("div",{className:"agent-names-list",children:Ne.map((t,D)=>e.jsxs("div",{className:"agent-name-chip",children:[e.jsx("span",{className:"agent-name-text",children:t}),V.length>0&&e.jsx("button",{className:"agent-name-remove",onClick:()=>ye(t),title:a("common:buttons.remove"),children:"x"})]},`${t}-${D}`))}),V.length>0&&e.jsx("button",{className:"config-btn config-btn-link",onClick:ke,children:a("common:buttons.resetToDefaults")})]})}),A("appearance")&&e.jsx(O,{title:a("config:sections.appearance"),storageKey:"appearance",defaultOpen:!1,forceOpen:$&&A("appearance"),children:e.jsx(cs,{})}),A("connection")&&e.jsxs(O,{title:a("config:sections.connection"),storageKey:"connection",defaultOpen:!1,forceOpen:$&&A("connection"),children:[e.jsxs("div",{className:"config-row config-row-stacked",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{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:y,onChange:t=>we(t.target.value),placeholder:"http://localhost:5174",onKeyDown:t=>{t.key==="Enter"&&u&&re()}}),u&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:re,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(v,{text:a("config:connection.authToken"),query:n})}),e.jsxs("div",{className:"config-input-group",children:[e.jsx("input",{type:F?"text":"password",className:"config-input config-input-full",value:k,onChange:t=>Se(t.target.value),placeholder:a("config:connection.tokenPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&T&&de()}}),e.jsx("button",{className:"config-btn config-btn-sm",onClick:()=>_(!F),title:a(F?"config:connection.hideToken":"config:connection.showToken"),children:F?"🙈":"👁️"}),T&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:de,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(v,{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:W,onChange:t=>Ce(t.target.value),placeholder:a("config:connection.codexBinaryPathPlaceholder"),onKeyDown:t=>{t.key==="Enter"&&b&&me()}}),b&&e.jsx("button",{className:"config-btn config-btn-sm",onClick:me,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(v,{text:a("common:buttons.reconnect"),query:n})}),e.jsx("button",{className:"config-btn",onClick:()=>ne(),title:"Force reconnect to server",children:a("common:buttons.reconnect")})]})]}),A("scene")&&e.jsxs(O,{title:a("config:sections.scene"),storageKey:"scene",defaultOpen:!1,forceOpen:$&&A("scene"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{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(v,{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(v,{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(v,{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(v,{text:a("config:scene.time"),query:n})}),e.jsx(X,{options:P,value:s.timeMode,onChange:t=>i({...s,timeMode:t}),iconOnly:!0})]})]}),A("terrain")&&e.jsxs(O,{title:a("config:sections.terrain"),storageKey:"terrain",defaultOpen:!1,forceOpen:$&&A("terrain"),children:[e.jsx("div",{className:"terrain-icons",children:L.map(t=>e.jsx("button",{className:`terrain-icon-btn ${s.terrain[t.key]?"active":""}`,onClick:()=>Ie(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(v,{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=>Z({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(v,{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=>Z({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(v,{text:a("config:terrainSettings.floor"),query:n})}),e.jsx(X,{options:R,value:s.terrain.floorStyle,onChange:t=>Z({floorStyle:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:terrainSettings.sky"),query:n})}),e.jsx("div",{className:"sky-color-selector",children:q.map(t=>e.jsx("button",{className:`sky-color-btn ${s.terrain.skyColor===t.value?"active":""}`,onClick:()=>Z({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(v,{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=>Z({battlefieldSize:parseInt(t.target.value)})}),e.jsx("span",{className:"config-value",children:s.terrain.battlefieldSize})]})]}),A("modelStyle")&&e.jsxs(O,{title:a("config:sections.modelStyle"),storageKey:"modelStyle",defaultOpen:!1,forceOpen:$&&A("modelStyle"),children:[e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{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=>M({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(v,{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=>M({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(v,{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=>M({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(v,{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=>M({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(v,{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=>M({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(v,{text:a("config:modelStyleSettings.wireframe"),query:n})}),e.jsx(B,{checked:s.modelStyle.wireframe,onChange:t=>M({wireframe:t})})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:modelStyleSettings.colorMode"),query:n})}),e.jsx(X,{options:C,value:s.modelStyle.colorMode,onChange:t=>M({colorMode:t}),iconOnly:!0})]})]}),A("animations")&&e.jsxs(O,{title:a("config:sections.animations"),storageKey:"animations",defaultOpen:!1,forceOpen:$&&A("animations"),children:[e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:animationSettings.idle"),query:n})}),e.jsx(X,{options:h,value:s.animations.idleAnimation,onChange:t=>ue({idleAnimation:t}),iconOnly:!0})]}),e.jsxs("div",{className:"config-group",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:animationSettings.working"),query:n})}),e.jsx(X,{options:h,value:s.animations.workingAnimation,onChange:t=>ue({workingAnimation:t}),iconOnly:!0})]})]}),A("secrets")&&e.jsx(O,{title:a("config:sections.secrets"),storageKey:"secrets",defaultOpen:!1,forceOpen:$&&A("secrets"),children:e.jsx(is,{})}),A("systemPrompt")&&e.jsx(O,{title:a("config:sections.systemPrompt"),storageKey:"systemPrompt",defaultOpen:!1,forceOpen:$&&A("systemPrompt"),children:e.jsxs("div",{className:"config-row",children:[e.jsx("span",{className:"config-label",children:e.jsx(v,{text:a("config:systemPrompt.title"),query:n})}),e.jsx("button",{className:"config-button",onClick:()=>Y(!0),children:a("config:systemPrompt.editPrompt")})]})}),A("data")&&e.jsx(O,{title:a("config:sections.data"),storageKey:"data",defaultOpen:!1,forceOpen:$&&A("data"),children:e.jsx(ls,{})}),A("integrations")&&e.jsx(O,{title:"Integrations",storageKey:"integrations",defaultOpen:!1,forceOpen:$&&A("integrations"),children:e.jsx(ms,{onOpenModal:t=>o==null?void 0:o(t)})}),A("workflows")&&e.jsxs(O,{title:"Workflows",storageKey:"workflows",defaultOpen:!1,forceOpen:$&&A("workflows"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(v,{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:()=>p==null?void 0:p(),children:"Open Workflow Editor"})})]}),A("triggers")&&e.jsxs(O,{title:"Triggers",storageKey:"triggers",defaultOpen:!1,forceOpen:$&&A("triggers"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(v,{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(O,{title:"Monitoring",storageKey:"monitoring",defaultOpen:!1,forceOpen:$&&A("monitoring"),children:[e.jsx("div",{className:"config-row",children:e.jsx("span",{className:"config-label",children:e.jsx(v,{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:()=>d==null?void 0:d(),children:"Open Monitoring & Logs"})})]}),A("experimental")&&e.jsxs(O,{title:a("config:sections.experimental"),storageKey:"experimental",defaultOpen:!1,forceOpen:$&&A("experimental"),children:[e.jsxs("div",{className:"config-row",children:[e.jsxs("span",{className:"config-label",title:"Lightweight 2D top-down view for better performance",children:[e.jsx(v,{text:a("config:experimental.2dView"),query:n})," 🗺️"]}),e.jsx(B,{checked:f.settings.experimental2DView,onChange:t=>j.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(v,{text:a("config:experimental.voiceAssistant"),query:n})," 🎤"]}),e.jsx(B,{checked:f.settings.experimentalVoiceAssistant,onChange:t=>j.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(v,{text:a("config:experimental.tts"),query:n})," 🔊"]}),e.jsx(B,{checked:f.settings.experimentalTTS,onChange:t=>j.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(v,{text:a("config:experimental.echoPrompt"),query:n})}),e.jsx(B,{checked:f.settings.experimentalEchoPrompt,onChange:async t=>{j.updateSettings({experimentalEchoPrompt:t});try{await fs(t)}catch(D){console.error("Failed to sync echo prompt setting to server:",D)}}})]}),e.jsx("span",{className:"config-hint",children:a("config:experimental.hint")})]}),A("about")&&e.jsx(O,{title:a("config:sections.about"),storageKey:"about",defaultOpen:!1,forceOpen:$&&A("about"),children:e.jsx(rs,{})})]}),e.jsx(js,{isOpen:Q,onClose:()=>Y(!1)})]})}function _s({onConfigChange:s,onToolChange:i,config:n,isOpen:o,onClose:d,onOpenBuildingModal:p,onOpenAreaExplorer:l,onOpenIntegrationsModal:a,onOpenMonitoringModal:f,onOpenWorkflowEditor:N,onOpenTriggerManager:x}){const{t:y}=U(["config","common"]),r=ie(),u=Array.from(r.areas.values()),c=Array.from(r.buildings.values()),[k,w]=g.useState(""),T=g.useRef(null);if(g.useEffect(()=>{const m=S=>{S.key==="Escape"&&o&&d()};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[o,d]),g.useEffect(()=>{if(o&&T.current){const m=setTimeout(()=>{var S;(S=T.current)==null||S.focus()},50);return()=>clearTimeout(m)}},[o]),!o)return null;const I=m=>{const S=r.activeTool===m?null:m;i(S)},F=m=>{j.selectArea(r.selectedAreaId===m?null:m),i("select")},_=(m,S)=>{m.stopPropagation(),j.deleteArea(S)};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"toolbox-backdrop",onClick:d}),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:d,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:T,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(O,{title:y("config:areas.title",{count:u.length}),storageKey:"areas",children:[e.jsxs("div",{className:"tool-buttons",children:[e.jsx("button",{className:`tool-btn ${r.activeTool==="select"?"active":""}`,onClick:()=>I("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 ${r.activeTool==="rectangle"?"active":""}`,onClick:()=>I("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 ${r.activeTool==="circle"?"active":""}`,onClick:()=>I("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:u.length===0?e.jsx("div",{className:"areas-empty",children:y("config:areas.drawToCreate")}):u.map(m=>e.jsx(Xe,{area:m,isSelected:r.selectedAreaId===m.id,onClick:()=>F(m.id),onDelete:S=>_(S,m.id)},m.id))})]})}),r.selectedAreaId&&e.jsx(os,{area:r.areas.get(r.selectedAreaId),onClose:()=>j.selectArea(null),onOpenFolder:l}),e.jsx("div",{className:"toolbox-section toolbox-section-collapsible",children:e.jsx(O,{title:y("config:buildings.title",{count:c.length}),storageKey:"buildings",headerExtra:e.jsx("button",{className:"add-building-btn",onClick:m=>{m.stopPropagation(),p==null||p()},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(Qe,{building:m,isSelected:r.selectedBuildingIds.has(m.id),onClick:()=>{j.selectBuilding(r.selectedBuildingIds.has(m.id)?null:m.id)},onEdit:()=>p==null?void 0:p(m.id)},m.id))})})}),r.selectedBuildingIds.size===1&&(()=>{const m=Array.from(r.selectedBuildingIds)[0],S=r.buildings.get(m);return S?e.jsx(es,{building:S,onClose:()=>j.selectBuilding(null),onOpenModal:()=>p==null?void 0:p(m)}):null})(),e.jsx(Es,{config:n,onChange:s,searchQuery:k,onOpenIntegrationsModal:a,onOpenMonitoringModal:f,onOpenWorkflowEditor:N,onOpenTriggerManager:x})]})]})]})}export{_s as Toolbox};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a1 as se,H as ne,J as ie,I as re,b6 as ce,r as g,s as O,b7 as bt,z as pt,u as Mt,j as m}from"./main-CtGyoZXd.js";import"./modulepreload-polyfill-B5Qt9EMX.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function et(e){return Array.isArray?Array.isArray(e):zt(e)==="[object Array]"}function oe(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function ae(e){return e==null?"":oe(e)}function X(e){return typeof e=="string"}function Qt(e){return typeof e=="number"}function ue(e){return e===!0||e===!1||le(e)&&zt(e)=="[object Boolean]"}function Wt(e){return typeof e=="object"}function le(e){return Wt(e)&&e!==null}function H(e){return e!=null}function gt(e){return!e.trim().length}function zt(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const he="Incorrect 'index' type",de=e=>`Invalid value for key ${e}`,fe=e=>`Pattern length exceeds max of ${e}.`,me=e=>`Missing ${e} property in key`,pe=e=>`Property 'weight' in key '${e}' must be a positive integer`,Rt=Object.prototype.hasOwnProperty;class ge{constructor(t){this._keys=[],this._keyMap={};let s=0;t.forEach(n=>{let i=Vt(n);this._keys.push(i),this._keyMap[i.id]=i,s+=i.weight}),this._keys.forEach(n=>{n.weight/=s})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Vt(e){let t=null,s=null,n=null,i=1,c=null;if(X(e)||et(e))n=e,t=_t(e),s=yt(e);else{if(!Rt.call(e,"name"))throw new Error(me("name"));const o=e.name;if(n=o,Rt.call(e,"weight")&&(i=e.weight,i<=0))throw new Error(pe(o));t=_t(o),s=yt(o),c=e.getFn}return{path:t,id:s,weight:i,src:n,getFn:c}}function _t(e){return et(e)?e:e.split(".")}function yt(e){return et(e)?e.join("."):e}function ye(e,t){let s=[],n=!1;const i=(c,o,a)=>{if(H(c))if(!o[a])s.push(c);else{let u=o[a];const l=c[u];if(!H(l))return;if(a===o.length-1&&(X(l)||Qt(l)||ue(l)))s.push(ae(l));else if(et(l)){n=!0;for(let d=0,h=l.length;d<h;d+=1)i(l[d],o,a+1)}else o.length&&i(l,o,a+1)}};return i(e,X(t)?t.split("."):t,0),n?s:s[0]}const Ae={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},xe={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1},Ee={location:0,threshold:.6,distance:100},Ce={useExtendedSearch:!1,getFn:ye,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var p={...xe,...Ae,...Ee,...Ce};const Fe=/[^ ]+/g;function Me(e=1,t=3){const s=new Map,n=Math.pow(10,t);return{get(i){const c=i.match(Fe).length;if(s.has(c))return s.get(c);const o=1/Math.pow(c,.5*e),a=parseFloat(Math.round(o*n)/n);return s.set(c,a),a},clear(){s.clear()}}}class wt{constructor({getFn:t=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){this.norm=Me(s,3),this.getFn=t,this.isCreated=!1,this.setIndexRecords()}setSources(t=[]){this.docs=t}setIndexRecords(t=[]){this.records=t}setKeys(t=[]){this.keys=t,this._keysMap={},t.forEach((s,n)=>{this._keysMap[s.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,X(this.docs[0])?this.docs.forEach((t,s)=>{this._addString(t,s)}):this.docs.forEach((t,s)=>{this._addObject(t,s)}),this.norm.clear())}add(t){const s=this.size();X(t)?this._addString(t,s):this._addObject(t,s)}removeAt(t){this.records.splice(t,1);for(let s=t,n=this.size();s<n;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(t,s){return t[this._keysMap[s]]}size(){return this.records.length}_addString(t,s){if(!H(t)||gt(t))return;let n={v:t,i:s,n:this.norm.get(t)};this.records.push(n)}_addObject(t,s){let n={i:s,$:{}};this.keys.forEach((i,c)=>{let o=i.getFn?i.getFn(t):this.getFn(t,i.path);if(H(o)){if(et(o)){let a=[];const u=[{nestedArrIndex:-1,value:o}];for(;u.length;){const{nestedArrIndex:l,value:d}=u.pop();if(H(d))if(X(d)&&!gt(d)){let h={v:d,i:l,n:this.norm.get(d)};a.push(h)}else et(d)&&d.forEach((h,f)=>{u.push({nestedArrIndex:f,value:h})})}n.$[c]=a}else if(X(o)&&!gt(o)){let a={v:o,n:this.norm.get(o)};n.$[c]=a}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function Ut(e,t,{getFn:s=p.getFn,fieldNormWeight:n=p.fieldNormWeight}={}){const i=new wt({getFn:s,fieldNormWeight:n});return i.setKeys(e.map(Vt)),i.setSources(t),i.create(),i}function we(e,{getFn:t=p.getFn,fieldNormWeight:s=p.fieldNormWeight}={}){const{keys:n,records:i}=e,c=new wt({getFn:t,fieldNormWeight:s});return c.setKeys(n),c.setIndexRecords(i),c}function ht(e,{errors:t=0,currentLocation:s=0,expectedLocation:n=0,distance:i=p.distance,ignoreLocation:c=p.ignoreLocation}={}){const o=t/e.length;if(c)return o;const a=Math.abs(n-s);return i?o+a/i:a?1:o}function ve(e=[],t=p.minMatchCharLength){let s=[],n=-1,i=-1,c=0;for(let o=e.length;c<o;c+=1){let a=e[c];a&&n===-1?n=c:!a&&n!==-1&&(i=c-1,i-n+1>=t&&s.push([n,i]),n=-1)}return e[c-1]&&c-n>=t&&s.push([n,c-1]),s}const ot=32;function De(e,t,s,{location:n=p.location,distance:i=p.distance,threshold:c=p.threshold,findAllMatches:o=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,includeMatches:u=p.includeMatches,ignoreLocation:l=p.ignoreLocation}={}){if(t.length>ot)throw new Error(fe(ot));const d=t.length,h=e.length,f=Math.max(0,Math.min(n,h));let y=c,C=f;const k=a>1||u,D=k?Array(h):[];let b;for(;(b=e.indexOf(t,C))>-1;){let S=ht(t,{currentLocation:b,expectedLocation:f,distance:i,ignoreLocation:l});if(y=Math.min(S,y),C=b+d,k){let v=0;for(;v<d;)D[b+v]=1,v+=1}}C=-1;let N=[],z=1,Q=d+h;const at=1<<d-1;for(let S=0;S<d;S+=1){let v=0,j=Q;for(;v<j;)ht(t,{errors:S,currentLocation:f+j,expectedLocation:f,distance:i,ignoreLocation:l})<=y?v=j:Q=j,j=Math.floor((Q-v)/2+v);Q=j;let _=Math.max(1,f-j+1),W=o?h:Math.min(f+j,h)+d,K=Array(W+2);K[W+1]=(1<<S)-1;for(let T=W;T>=_;T-=1){let Z=T-1,ct=s[e.charAt(Z)];if(k&&(D[Z]=+!!ct),K[T]=(K[T+1]<<1|1)&ct,S&&(K[T]|=(N[T+1]|N[T])<<1|1|N[T+1]),K[T]&at&&(z=ht(t,{errors:S,currentLocation:Z,expectedLocation:f,distance:i,ignoreLocation:l}),z<=y)){if(y=z,C=Z,C<=f)break;_=Math.max(1,2*f-C)}}if(ht(t,{errors:S+1,currentLocation:f,expectedLocation:f,distance:i,ignoreLocation:l})>y)break;N=K}const st={isMatch:C>=0,score:Math.max(.001,z)};if(k){const S=ve(D,a);S.length?u&&(st.indices=S):st.isMatch=!1}return st}function Se(e){let t={};for(let s=0,n=e.length;s<n;s+=1){const i=e.charAt(s);t[i]=(t[i]||0)|1<<n-s-1}return t}const dt=String.prototype.normalize?(e=>e.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(e=>e);class Gt{constructor(t,{location:s=p.location,threshold:n=p.threshold,distance:i=p.distance,includeMatches:c=p.includeMatches,findAllMatches:o=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:d=p.ignoreLocation}={}){if(this.options={location:s,threshold:n,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:d},t=u?t:t.toLowerCase(),t=l?dt(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const h=(y,C)=>{this.chunks.push({pattern:y,alphabet:Se(y),startIndex:C})},f=this.pattern.length;if(f>ot){let y=0;const C=f%ot,k=f-C;for(;y<k;)h(this.pattern.substr(y,ot),y),y+=ot;if(C){const D=f-ot;h(this.pattern.substr(D),D)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:s,ignoreDiacritics:n,includeMatches:i}=this.options;if(t=s?t:t.toLowerCase(),t=n?dt(t):t,this.pattern===t){let k={isMatch:!0,score:0};return i&&(k.indices=[[0,t.length-1]]),k}const{location:c,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:d}=this.options;let h=[],f=0,y=!1;this.chunks.forEach(({pattern:k,alphabet:D,startIndex:b})=>{const{isMatch:N,score:z,indices:Q}=De(t,k,D,{location:c+b,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:i,ignoreLocation:d});N&&(y=!0),f+=z,N&&Q&&(h=[...h,...Q])});let C={isMatch:y,score:y?f/this.chunks.length:1};return y&&i&&(C.indices=h),C}}class rt{constructor(t){this.pattern=t}static isMultiMatch(t){return Lt(t,this.multiRegex)}static isSingleMatch(t){return Lt(t,this.singleRegex)}search(){}}function Lt(e,t){const s=e.match(t);return s?s[1]:null}class Be extends rt{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const s=t===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ie extends rt{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const n=t.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class ke extends rt{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const s=t.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class $e extends rt{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const s=!t.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}}class be extends rt{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const s=t.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Re extends rt{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const s=!t.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}}class Yt extends rt{constructor(t,{location:s=p.location,threshold:n=p.threshold,distance:i=p.distance,includeMatches:c=p.includeMatches,findAllMatches:o=p.findAllMatches,minMatchCharLength:a=p.minMatchCharLength,isCaseSensitive:u=p.isCaseSensitive,ignoreDiacritics:l=p.ignoreDiacritics,ignoreLocation:d=p.ignoreLocation}={}){super(t),this._bitapSearch=new Gt(t,{location:s,threshold:n,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:d})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class Jt extends rt{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let s=0,n;const i=[],c=this.pattern.length;for(;(n=t.indexOf(this.pattern,s))>-1;)s=n+c,i.push([n,s-1]);const o=!!i.length;return{isMatch:o,score:o?0:1,indices:i}}}const At=[Be,Jt,ke,$e,Re,be,Ie,Yt],Nt=At.length,_e=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Le="|";function Ne(e,t={}){return e.split(Le).map(s=>{let n=s.trim().split(_e).filter(c=>c&&!!c.trim()),i=[];for(let c=0,o=n.length;c<o;c+=1){const a=n[c];let u=!1,l=-1;for(;!u&&++l<Nt;){const d=At[l];let h=d.isMultiMatch(a);h&&(i.push(new d(h,t)),u=!0)}if(!u)for(l=-1;++l<Nt;){const d=At[l];let h=d.isSingleMatch(a);if(h){i.push(new d(h,t));break}}}return i})}const je=new Set([Yt.type,Jt.type]);class Te{constructor(t,{isCaseSensitive:s=p.isCaseSensitive,ignoreDiacritics:n=p.ignoreDiacritics,includeMatches:i=p.includeMatches,minMatchCharLength:c=p.minMatchCharLength,ignoreLocation:o=p.ignoreLocation,findAllMatches:a=p.findAllMatches,location:u=p.location,threshold:l=p.threshold,distance:d=p.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:n,includeMatches:i,minMatchCharLength:c,findAllMatches:a,ignoreLocation:o,location:u,threshold:l,distance:d},t=s?t:t.toLowerCase(),t=n?dt(t):t,this.pattern=t,this.query=Ne(this.pattern,this.options)}static condition(t,s){return s.useExtendedSearch}searchIn(t){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:n,isCaseSensitive:i,ignoreDiacritics:c}=this.options;t=i?t:t.toLowerCase(),t=c?dt(t):t;let o=0,a=[],u=0;for(let l=0,d=s.length;l<d;l+=1){const h=s[l];a.length=0,o=0;for(let f=0,y=h.length;f<y;f+=1){const C=h[f],{isMatch:k,indices:D,score:b}=C.search(t);if(k){if(o+=1,u+=b,n){const N=C.constructor.type;je.has(N)?a=[...a,...D]:a.push(D)}}else{u=0,o=0,a.length=0;break}}if(o){let f={isMatch:!0,score:u/o};return n&&(f.indices=a),f}}return{isMatch:!1,score:1}}}const xt=[];function Pe(...e){xt.push(...e)}function Et(e,t){for(let s=0,n=xt.length;s<n;s+=1){let i=xt[s];if(i.condition(e,t))return new i(e,t)}return new Gt(e,t)}const ft={AND:"$and",OR:"$or"},Ct={PATH:"$path",PATTERN:"$val"},Ft=e=>!!(e[ft.AND]||e[ft.OR]),Ke=e=>!!e[Ct.PATH],Oe=e=>!et(e)&&Wt(e)&&!Ft(e),jt=e=>({[ft.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Xt(e,t,{auto:s=!0}={}){const n=i=>{let c=Object.keys(i);const o=Ke(i);if(!o&&c.length>1&&!Ft(i))return n(jt(i));if(Oe(i)){const u=o?i[Ct.PATH]:c[0],l=o?i[Ct.PATTERN]:i[u];if(!X(l))throw new Error(de(u));const d={keyId:yt(u),pattern:l};return s&&(d.searcher=Et(l,t)),d}let a={children:[],operator:c[0]};return c.forEach(u=>{const l=i[u];et(l)&&l.forEach(d=>{a.children.push(n(d))})}),a};return Ft(e)||(e=jt(e)),n(e)}function He(e,{ignoreFieldNorm:t=p.ignoreFieldNorm}){e.forEach(s=>{let n=1;s.matches.forEach(({key:i,norm:c,score:o})=>{const a=i?i.weight:null;n*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(t?1:c))}),s.score=n})}function Qe(e,t){const s=e.matches;t.matches=[],H(s)&&s.forEach(n=>{if(!H(n.indices)||!n.indices.length)return;const{indices:i,value:c}=n;let o={indices:i,value:c};n.key&&(o.key=n.key.src),n.idx>-1&&(o.refIndex=n.idx),t.matches.push(o)})}function We(e,t){t.score=e.score}function ze(e,t,{includeMatches:s=p.includeMatches,includeScore:n=p.includeScore}={}){const i=[];return s&&i.push(Qe),n&&i.push(We),e.map(c=>{const{idx:o}=c,a={item:t[o],refIndex:o};return i.length&&i.forEach(u=>{u(c,a)}),a})}class G{constructor(t,s={},n){this.options={...p,...s},this.options.useExtendedSearch,this._keyStore=new ge(this.options.keys),this.setCollection(t,n)}setCollection(t,s){if(this._docs=t,s&&!(s instanceof wt))throw new Error(he);this._myIndex=s||Ut(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){H(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const s=[];for(let n=0,i=this._docs.length;n<i;n+=1){const c=this._docs[n];t(c,n)&&(this.removeAt(n),n-=1,i-=1,s.push(c))}return s}removeAt(t){this._docs.splice(t,1),this._myIndex.removeAt(t)}getIndex(){return this._myIndex}search(t,{limit:s=-1}={}){const{includeMatches:n,includeScore:i,shouldSort:c,sortFn:o,ignoreFieldNorm:a}=this.options;let u=X(t)?X(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return He(u,{ignoreFieldNorm:a}),c&&u.sort(o),Qt(s)&&s>-1&&(u=u.slice(0,s)),ze(u,this._docs,{includeMatches:n,includeScore:i})}_searchStringList(t){const s=Et(t,this.options),{records:n}=this._myIndex,i=[];return n.forEach(({v:c,i:o,n:a})=>{if(!H(c))return;const{isMatch:u,score:l,indices:d}=s.searchIn(c);u&&i.push({item:c,idx:o,matches:[{score:l,value:c,norm:a,indices:d}]})}),i}_searchLogical(t){const s=Xt(t,this.options),n=(a,u,l)=>{if(!a.children){const{keyId:h,searcher:f}=a,y=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(u,h),searcher:f});return y&&y.length?[{idx:l,item:u,matches:y}]:[]}const d=[];for(let h=0,f=a.children.length;h<f;h+=1){const y=a.children[h],C=n(y,u,l);if(C.length)d.push(...C);else if(a.operator===ft.AND)return[]}return d},i=this._myIndex.records,c={},o=[];return i.forEach(({$:a,i:u})=>{if(H(a)){let l=n(s,a,u);l.length&&(c[u]||(c[u]={idx:u,item:a,matches:[]},o.push(c[u])),l.forEach(({matches:d})=>{c[u].matches.push(...d)}))}}),o}_searchObjectList(t){const s=Et(t,this.options),{keys:n,records:i}=this._myIndex,c=[];return i.forEach(({$:o,i:a})=>{if(!H(o))return;let u=[];n.forEach((l,d)=>{u.push(...this._findMatches({key:l,value:o[d],searcher:s}))}),u.length&&c.push({idx:a,item:o,matches:u})}),c}_findMatches({key:t,value:s,searcher:n}){if(!H(s))return[];let i=[];if(et(s))s.forEach(({v:c,i:o,n:a})=>{if(!H(c))return;const{isMatch:u,score:l,indices:d}=n.searchIn(c);u&&i.push({score:l,key:t,value:c,idx:o,norm:a,indices:d})});else{const{v:c,n:o}=s,{isMatch:a,score:u,indices:l}=n.searchIn(c);a&&i.push({score:u,key:t,value:c,norm:o,indices:l})}return i}}G.version="7.1.0";G.createIndex=Ut;G.parseIndex=we;G.config=p;G.parseQuery=Xt;Pe(Te);const Tt={".ts":"📘",".tsx":"⚛️",".js":"📒",".jsx":"⚛️",".py":"🐍",".rs":"🦀",".go":"🔷",".md":"📝",".json":"📋",".yaml":"⚙️",".yml":"⚙️",".css":"🎨",".scss":"🎨",".html":"🌐",".sql":"🗃️",".sh":"💻",".env":"🔐",".toml":"⚙️",".lock":"🔒",default:"📄"};function Ve(e){var s;const t="."+((s=e.split(".").pop())==null?void 0:s.toLowerCase());return Tt[t]||Tt.default}function Pt(e){const t=se[e];return(t==null?void 0:t.icon)||"🤖"}function Zt(e){const t=Math.floor(e/1e3),s=Math.floor(t/60),n=Math.floor(s/60),i=Math.floor(n/24);return i>0?`${i}d ${n%24}h ago`:n>0?`${n}h ${s%60}m ago`:s>0?`${s}m ago`:"just now"}function Kt(e){const s=Date.now()-e;return Zt(s)}function Ot(e){switch(e){case"agent":return"Agent";case"command":return"Command";case"area":return"Area";case"activity":return"Activity";case"modified-file":return"Changed";case"building":return"Server";default:return e}}const Ht=["command","agent","building","area","modified-file","activity"];function Ue({isOpen:e,onClose:t,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:i,onOpenSupervisor:c,onOpenFileExplorer:o,onOpenPM2LogsModal:a,onOpenBossLogsModal:u,onOpenDatabasePanel:l,onOpenMonitoringModal:d}){const h=ne(),f=ie(),y=re(),C=ce(),k=g.useMemo(()=>{const r=O.getState().supervisor.agentHistories;let A="";for(const[F,M]of r)A+=`${F}:${M.length},`;return A},[h]),D=g.useRef(t);D.current=t;const b=g.useRef(s);b.current=s;const N=g.useRef(n);N.current=n;const z=g.useRef(i);z.current=i;const Q=g.useRef(c);Q.current=c;const at=g.useRef(o);at.current=o;const st=g.useRef(a);st.current=a;const S=g.useRef(u);S.current=u;const v=g.useRef(l);v.current=l;const j=g.useRef(d);j.current=d;const[_,W]=g.useState(""),[K,nt]=g.useState(0);g.useEffect(()=>{if(e){W(""),nt(0);const r=Array.from(h.values());for(const A of r)!O.hasHistoryBeenFetched(A.id)&&!O.isLoadingHistoryForAgent(A.id)&&O.requestAgentSupervisorHistory(A.id)}},[e,h]);const T=O.getShortcuts(),Z=g.useMemo(()=>{if(!e)return[];const r=T.find(F=>F.id==="spawn-agent"),A=T.find(F=>F.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:r?bt(r):"Alt+N",icon:"➕",action:()=>{D.current(),b.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:A?bt(A):"Ctrl+K",icon:"📊",action:()=>{D.current(),N.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:"⚙️",action:()=>{D.current(),z.current()}},{id:"cmd-supervisor",type:"command",title:"Supervisor Overview",subtitle:"View agent analysis",icon:"🎖️",action:()=>{D.current(),Q.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:"📊",action:()=>{var F;D.current(),(F=j.current)==null||F.call(j)}}]},[e,T]),ct=g.useMemo(()=>e?Array.from(h.values()).map(r=>{const A=O.getAgentSupervisorHistory(r.id),F=A.length>0?A[0]:null,M=A.map(x=>({text:`${x.analysis.statusDescription} ${x.analysis.recentWorkSummary}`,timestamp:x.timestamp})),$=(C||[]).filter(x=>x.agentId===r.id).map(x=>x.filePath),I=[...new Set($)],R=I.map(x=>x.split("/").pop()||x),B=[];r.lastAssignedTask&&B.push(r.lastAssignedTask);const Y=`${r.class} • ${r.status} • ${r.cwd}`;let J=`${r.name} ${Y}`,L,ut,E;for(const x of M)J+=` ${x.text}`;F&&(L=F.analysis.recentWorkSummary,ut=F.analysis.statusDescription,E=F.timestamp),R.length>0&&(J+=` ${R.join(" ")} ${I.join(" ")}`),B.length>0&&(J+=` ${B.join(" ")}`);const w=Date.now()-r.lastActivity;let U;return r.lastAssignedTask&&(r.lastAssignedTask.length>150?U=r.lastAssignedTask.slice(0,150)+"...":U=r.lastAssignedTask),{id:`agent-${r.id}`,type:"agent",title:r.name,subtitle:Y,lastUserInput:U,statusDescription:ut,activityText:L,matchedText:L,timeAway:w,lastStatusTime:E,icon:Pt(r.class),_searchText:J,_modifiedFiles:I,_userQueries:B,_historyEntries:M,action:()=>{D.current(),O.selectAgent(r.id)}}}):[],[e,h,k,C]),lt=g.useMemo(()=>e?Array.from(f.values()).map(r=>{var A;return{id:`area-${r.id}`,type:"area",title:r.name,subtitle:`${r.assignedAgentIds.length} agents • ${((A=r.directories)==null?void 0:A.length)||0} folders`,icon:"🗺️",action:()=>{D.current(),O.selectArea(r.id)}}}):[],[e,f]),mt=g.useMemo(()=>e?Array.from(y.values()).filter(r=>r.type==="server"||r.type==="boss"||r.type==="database").map(r=>{var R,B,Y,J;const A=r.status==="running"?"🟢":r.status==="stopped"?"🔴":"🟡",F=r.type==="boss"?"👑":r.type==="database"?"🗄️":"🖥️";let $=`${r.type==="boss"?"Boss":r.type==="database"?"Database":"Server"} • ${r.status}`;if(r.type==="database"&&((B=(R=r.database)==null?void 0:R.connections)!=null&&B.length)){const L=r.database.connections[0];$+=` • ${L.engine} @ ${L.host}`}else r.cwd&&($+=` • ${r.cwd}`);let I=`${r.name} ${r.type} ${r.status} ${r.cwd||""} ${((Y=r.pm2)==null?void 0:Y.name)||""}`;if(r.type==="database"&&((J=r.database)!=null&&J.connections))for(const L of r.database.connections)I+=` ${L.name} ${L.engine} ${L.host} ${L.database||""} mysql postgresql sql`;return{id:`building-${r.id}`,type:"building",title:r.name,subtitle:$,icon:`${A} ${F}`,_searchText:I,action:()=>{var L;D.current(),r.type==="boss"?S.current(r.id):r.type==="database"?v.current(r.id):(L=r.pm2)!=null&&L.enabled&&st.current(r.id)}}}):[],[e,y]),vt=g.useMemo(()=>{if(!e)return[];const r=C||[],A=new Set,F=[];for(const M of r){if(A.has(M.filePath))continue;A.add(M.filePath);const $=M.filePath.split("/").pop()||M.filePath,I=M.action==="created"?"Created":M.action==="modified"?"Modified":M.action==="deleted"?"Deleted":"Read";if(F.push({id:`modified-${M.filePath}-${M.timestamp}`,type:"modified-file",title:$,subtitle:`${I} by ${M.agentName} • ${M.filePath}`,matchedText:M.filePath,icon:M.action==="deleted"?"🗑️":Ve(M.filePath),action:()=>{D.current();const R=Array.from(O.getState().areas.values());for(const B of R)for(const Y of B.directories||[])if(M.filePath.startsWith(Y)){O.setFileViewerPath(M.filePath),at.current(B.id);return}O.selectAgent(M.agentId)}}),F.length>=50)break}return F},[e,C]),Dt=g.useMemo(()=>{if(!e)return[];const r=[],A=Array.from(h.values());for(const F of A){const M=O.getAgentSupervisorHistory(F.id);if(M.length>0){const $=M[0],I=$.analysis;r.push({id:`activity-${F.id}-${$.timestamp}`,type:"activity",title:F.name,subtitle:I.statusDescription,activityText:I.recentWorkSummary,matchedText:I.recentWorkSummary,icon:Pt(F.class),action:()=>{D.current(),O.selectAgent(F.id)}})}}return r},[e,h,k]),St=g.useMemo(()=>new G(ct,{keys:["title","subtitle","_searchText","activityText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ct]),Bt=g.useMemo(()=>new G(Z,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[Z]),It=g.useMemo(()=>new G(lt,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[lt]),kt=g.useMemo(()=>new G(vt,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[vt]),$t=g.useMemo(()=>new G(Dt,{keys:["title","subtitle","matchedText","activityText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Dt]),qt=g.useMemo(()=>new G(mt,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[mt]),V=g.useMemo(()=>{if(!_.trim()){const E=[];E.push(...mt);const w=[...ct].sort((x,P)=>{const q=x.timeAway??0,tt=P.timeAway??0;return q-tt});E.push(...w),E.push(...Z.slice(0,2)),E.push(...lt.slice(0,2));const U={};return Ht.forEach((x,P)=>{U[x]=P}),E.sort((x,P)=>(U[x.type]??999)-(U[P.type]??999)),E}const r=_.toLowerCase(),A=St.search(_).slice(0,8),F=Bt.search(_).slice(0,3),M=It.search(_).slice(0,2),$=kt.search(_).slice(0,3),I=$t.search(_).slice(0,3),R=qt.search(_).filter(E=>{const w=E.score??1;return`${E.item.title} ${E.item.subtitle||""} ${E.item._searchText||""}`.toLowerCase().includes(r)||w<=.2}).slice(0,4),B=[],Y=[],J=[];for(const E of A){const w={...E.item};if(w._modifiedFiles&&w._modifiedFiles.length>0){const x=w._modifiedFiles.filter(P=>{var it;const q=((it=P.split("/").pop())==null?void 0:it.toLowerCase())||"",tt=P.toLowerCase();return q.includes(r)||tt.includes(r)});x.length>0&&(w.matchedFiles=x)}if(w._userQueries&&w._userQueries.length>0){const x=w._userQueries.find(P=>P.toLowerCase().includes(r));if(x)if(x.length>200){const q=x.toLowerCase().indexOf(r),tt=Math.max(0,q-60),it=Math.min(x.length,q+r.length+100);w.matchedQuery=(tt>0?"...":"")+x.slice(tt,it)+(it<x.length?"...":"")}else w.matchedQuery=x}if(w._historyEntries&&w._historyEntries.length>0){const x=w._historyEntries.find(P=>P.text.toLowerCase().includes(r));if(x)if(x.text.length>250){const q=x.text.toLowerCase().indexOf(r),tt=Math.max(0,q-80),it=Math.min(x.text.length,q+r.length+120);w.matchedHistory={text:(tt>0?"...":"")+x.text.slice(tt,it)+(it<x.text.length?"...":""),timestamp:x.timestamp}}else w.matchedHistory=x}const U=w.title.toLowerCase();U===r||U.startsWith(r)?Y.push(w):J.push(w)}for(const E of Y)B.push(E);for(const E of R)B.push(E.item);for(const E of J)B.push(E);for(const E of F)B.push(E.item);for(const E of M)B.push(E.item);for(const E of $)B.push(E.item);const L=new Set(A.map(E=>E.item.id));for(const E of I){const w=E.item.id.replace("activity-","").split("-")[0];L.has(`agent-${w}`)||B.push(E.item)}const ut={};return Ht.forEach((E,w)=>{ut[E]=w}),B.sort((E,w)=>(ut[E.type]??999)-(ut[w.type]??999)),B},[_,St,Bt,It,kt,$t,Z,ct,lt]);g.useEffect(()=>{K>=V.length&&nt(Math.max(0,V.length-1))},[V.length,K]);const te=g.useCallback(r=>{if(r.altKey&&!r.ctrlKey&&!r.metaKey&&(r.key==="p"||r.key==="n"||r.key==="P"||r.key==="N")){r.preventDefault(),r.stopPropagation(),r.nativeEvent.stopImmediatePropagation();const A=r.key.toLowerCase();nt(A==="p"?F=>F>0?F-1:V.length-1:F=>F<V.length-1?F+1:0);return}switch(r.key){case"Escape":r.preventDefault(),D.current();break;case"ArrowUp":r.preventDefault(),nt(A=>A>0?A-1:V.length-1);break;case"ArrowDown":r.preventDefault(),nt(A=>A<V.length-1?A+1:0);break;case"Enter":r.preventDefault(),V[K]&&V[K].action();break}},[V,K]),ee=g.useCallback((r,A)=>{if(!A||!r)return r;const F=r.toLowerCase(),M=A.toLowerCase(),$=[];let I=0,R=F.indexOf(M),B=0;for(;R!==-1;)R>I&&$.push(r.slice(I,R)),$.push(pt.createElement("mark",{key:B++,className:"spotlight-highlight"},r.slice(R,R+A.length))),I=R+A.length,R=F.indexOf(M,I);return I<r.length&&$.push(r.slice(I)),$.length>0?pt.createElement(pt.Fragment,null,...$):r},[]);return{query:_,setQuery:W,selectedIndex:K,setSelectedIndex:nt,results:V,handleKeyDown:te,highlightMatch:ee}}const Ge=g.forwardRef(function({query:t,onQueryChange:s,onKeyDown:n,onResetSelection:i},c){const{t:o}=Mt(["common"]);return m.jsxs("div",{className:"spotlight-input-wrapper",children:[m.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),m.jsx("input",{ref:c,type:"text",className:"spotlight-input",placeholder:o("common:search.spotlightPlaceholder"),value:t,onChange:a=>{s(a.target.value),i()},onKeyDown:n,autoFocus:!0,spellCheck:!1}),m.jsxs("div",{className:"spotlight-input-hints",children:[m.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),m.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),m.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Ye=g.memo(function({result:t,isSelected:s,query:n,highlightMatch:i,onClick:c,onMouseEnter:o}){const a=t.activityText||t.statusDescription||t.matchedFiles&&t.matchedFiles.length>0||t.matchedQuery||t.matchedHistory;return m.jsxs("div",{className:`spotlight-item ${s?"selected":""} ${t.activityText?"has-activity":""}`,onClick:c,onMouseEnter:o,role:"option","aria-selected":s,children:[m.jsx("span",{className:"spotlight-item-icon","aria-hidden":"true",children:t.icon}),m.jsxs("div",{className:"spotlight-item-content",children:[m.jsxs("div",{className:"spotlight-item-header",children:[m.jsx("span",{className:"spotlight-item-title",children:i(t.title,n)}),m.jsx("span",{className:`spotlight-item-type ${t.type}`,"aria-label":Ot(t.type),children:Ot(t.type)})]}),t.subtitle&&m.jsx("span",{className:"spotlight-item-subtitle",children:i(t.subtitle,n)}),t.statusDescription&&m.jsx("span",{className:"spotlight-item-status",children:i(t.statusDescription,n)}),t.activityText&&m.jsx("span",{className:"spotlight-item-activity",children:i(t.activityText,n)}),a&&m.jsxs("div",{className:"spotlight-item-details",children:[t.matchedFiles&&t.matchedFiles.length>0&&m.jsx("span",{className:"spotlight-item-files",children:t.matchedFiles.map((u,l)=>m.jsxs("span",{className:"file-badge",children:[l>0&&m.jsx("span",{className:"file-separator",children:"•"}),i(u.split("/").pop()||u,n)]},u))}),t.matchedQuery&&m.jsx("span",{className:"spotlight-item-query",children:i(t.matchedQuery,n)}),t.matchedHistory&&m.jsxs("span",{className:"spotlight-item-history",children:[i(t.matchedHistory.text,n),m.jsx("span",{className:"spotlight-history-time",children:Kt(t.matchedHistory.timestamp)})]})]}),(t.timeAway!==void 0||t.lastStatusTime!==void 0)&&m.jsxs("span",{className:"spotlight-item-time",children:[t.timeAway!==void 0&&m.jsxs("span",{className:"spotlight-time-away",children:["Idle: ",Zt(t.timeAway)]}),t.lastStatusTime!==void 0&&m.jsxs("span",{className:"spotlight-status-time",children:["Updated ",Kt(t.lastStatusTime)]})]}),t.lastUserInput&&!t.matchedQuery&&m.jsxs("span",{className:"spotlight-item-last-input",children:['"',i(t.lastUserInput,n),'"']})]})]})}),Je=g.forwardRef(function({results:t,selectedIndex:s,query:n,highlightMatch:i,onSelectIndex:c},o){const{t:a}=Mt(["terminal"]),u=g.useRef(!1);g.useEffect(()=>{u.current=!1},[t]),g.useEffect(()=>{const h=typeof o=="function"?null:o==null?void 0:o.current;if(!h)return;const f=()=>{u.current=!0};return h.addEventListener("mousemove",f),()=>{h.removeEventListener("mousemove",f)}},[o,t]);const l={command:a("terminal:spotlight.categories.commands"),agent:a("terminal:spotlight.categories.agents"),building:a("terminal:spotlight.categories.infrastructure"),area:a("terminal:spotlight.categories.areas"),"modified-file":a("terminal:spotlight.categories.modifiedFiles"),activity:a("terminal:spotlight.categories.recentActivity")},d=g.useMemo(()=>{const h=[];let f=null,y=[];return t.forEach((C,k)=>{C.type!==f&&(f!==null&&y.length>0&&h.push([f,y]),f=C.type,y=[]),y.push({result:C,index:k})}),f!==null&&y.length>0&&h.push([f,y]),h},[t]);return g.useEffect(()=>{if(!o||typeof o=="function")return;const h=o.current;if(!h)return;const f=h.querySelector(".spotlight-item.selected");f&&f.scrollIntoView({block:"nearest",behavior:"smooth"})},[s,o]),t.length===0?m.jsx("div",{className:"spotlight-results",ref:o,children:m.jsx("div",{className:"spotlight-empty",children:a("terminal:spotlight.noResults")})}):m.jsx("div",{className:"spotlight-results",ref:o,children:d.map(([h,f])=>m.jsxs("div",{children:[d.length>1&&m.jsx("div",{className:"spotlight-category-header",children:l[h]||h}),f.map(({result:y,index:C})=>m.jsx(Ye,{result:y,isSelected:C===s,query:n,highlightMatch:i,onClick:()=>y.action(),onMouseEnter:()=>{u.current&&c(C)}},y.id))]},h))})}),Xe=g.memo(function(){const{t}=Mt(["terminal"]);return m.jsxs("div",{className:"spotlight-footer",children:[m.jsxs("div",{className:"spotlight-footer-left",children:[m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"↑"}),m.jsx("kbd",{children:"↓"})," ",m.jsx("kbd",{children:"Alt+N"}),m.jsx("kbd",{children:"Alt+P"})," ",t("terminal:spotlight.navigate")]}),m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"Enter"})," ",t("terminal:spotlight.select")]})]}),m.jsx("div",{className:"spotlight-footer-right",children:m.jsxs("span",{className:"spotlight-footer-hint",children:[m.jsx("kbd",{children:"Esc"})," ",t("common:buttons.close")]})})]})});function ss({isOpen:e,onClose:t,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:i,onOpenSupervisor:c,onOpenFileExplorer:o,onOpenPM2LogsModal:a,onOpenBossLogsModal:u,onOpenDatabasePanel:l,onOpenMonitoringModal:d}){const h=g.useRef(null),f=g.useRef(null),y=g.useRef(0),{query:C,setQuery:k,selectedIndex:D,setSelectedIndex:b,results:N,handleKeyDown:z,highlightMatch:Q}=Ue({isOpen:e,onClose:t,onOpenSpawnModal:s,onOpenCommanderView:n,onOpenToolbox:i,onOpenSupervisor:c,onOpenFileExplorer:o,onOpenPM2LogsModal:a,onOpenBossLogsModal:u,onOpenDatabasePanel:l,onOpenMonitoringModal:d});y.current=N.length,g.useEffect(()=>{e&&setTimeout(()=>{var S;(S=h.current)==null||S.focus()},50)},[e]),g.useEffect(()=>{if(!e)return;const S=v=>{if(v.key==="Escape"){v.preventDefault(),v.stopPropagation(),v.stopImmediatePropagation(),t();return}if(v.altKey&&!v.ctrlKey&&!v.metaKey&&(v.key==="n"||v.key==="p"||v.key==="N"||v.key==="P")){v.preventDefault(),v.stopPropagation(),v.stopImmediatePropagation();const j=v.key.toLowerCase(),_=y.current;b(j==="p"?W=>W>0?W-1:_-1:W=>W<_-1?W+1:0);return}};return window.addEventListener("keydown",S,{capture:!0}),()=>{window.removeEventListener("keydown",S,{capture:!0})}},[e,t]);const at=g.useCallback(S=>{S.target===S.currentTarget&&t()},[t]),st=g.useCallback(()=>{b(0)},[b]);return e?m.jsx("div",{className:"spotlight-overlay",onClick:at,children:m.jsxs("div",{className:"spotlight-modal",children:[m.jsx(Ge,{ref:h,query:C,onQueryChange:k,onKeyDown:z,onResetSelection:st}),m.jsx(Je,{ref:f,results:N,selectedIndex:D,query:C,highlightMatch:Q,onSelectIndex:b}),m.jsx(Xe,{})]})}):null}export{Tt as FILE_ICONS,ss as Spotlight,Xe as SpotlightFooter,Ge as SpotlightInput,Ye as SpotlightItem,Je as SpotlightResults,Zt as formatDuration,Kt as formatRelativeTime,Pt as getAgentIcon,Ve as getFileIconFromPath,Ot as getTypeLabel,Ue as useSpotlightSearch};
|