tide-commander 1.124.0 → 1.125.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-vnY84OW6.js → BossLogsModal-CnPJyLDo.js} +1 -1
- package/dist/assets/{BossSpawnModal-DK4o1B1G.js → BossSpawnModal-CH9Lcs0s.js} +1 -1
- package/dist/assets/{ControlsModal-DIIrhjP-.js → ControlsModal-B5ij8JXe.js} +1 -1
- package/dist/assets/{DockerLogsModal-DAYsel5x.js → DockerLogsModal-4o_CayDQ.js} +1 -1
- package/dist/assets/{EmbeddedEditor-BfgWyhqC.js → EmbeddedEditor-DMtVC8_B.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-BIniQATp.js → GmailOAuthSetup-BZTi6c8Z.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-CiFr1rM6.js → GoogleOAuthSetup-C9IndpE9.js} +1 -1
- package/dist/assets/{IframeModal-BKUjRc7t.js → IframeModal-B8tqUr1a.js} +1 -1
- package/dist/assets/{IntegrationsPanel-CkCh7SK_.js → IntegrationsPanel-C3HpRO16.js} +2 -2
- package/dist/assets/{LogViewerModal-DzeTs0So.js → LogViewerModal-BX32bw0D.js} +1 -1
- package/dist/assets/{MonitoringModal-DIOoegb2.js → MonitoringModal-CjkvH0MB.js} +1 -1
- package/dist/assets/{PM2LogsModal-O1D3lCxi.js → PM2LogsModal-6AnAL2_W.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-DjTFA30U.js → RestoreArchivedAreaModal-D3hwlL6h.js} +1 -1
- package/dist/assets/{Scene2DCanvas-Ciy_QFtt.js → Scene2DCanvas-CKnp12cg.js} +1 -1
- package/dist/assets/{SceneManager-DW1i0KI_.js → SceneManager-Q6togXKI.js} +1 -1
- package/dist/assets/{SkillsPanel-Dhf4aEpR.js → SkillsPanel-CvecGgVV.js} +1 -1
- package/dist/assets/{SlackMultiInstanceSetup-BIqMtoyG.js → SlackMultiInstanceSetup-BbRE3IhN.js} +1 -1
- package/dist/assets/{SpawnModal-BPLVKMLo.js → SpawnModal-CgoxbD16.js} +1 -1
- package/dist/assets/{StatisticsModal-BedfZQEy.js → StatisticsModal-BA_fSj-V.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-ucii3933.js → SubordinateAssignmentModal-BvMliz7f.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-B8-QU-To.js → TriggerManagerPanel-k2VmPkQU.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-B9CGF-98.js → WorkflowEditorPanel-BXmVeDYM.js} +1 -1
- package/dist/assets/{area-logos-DWkLpq_i.js → area-logos-DS6Od-VT.js} +1 -1
- package/dist/assets/{index-BgasKIX3.js → index-0ZzclERE.js} +1 -1
- package/dist/assets/{index-g2dBTanH.js → index-BGW1Qhh2.js} +1 -1
- package/dist/assets/{index-Bq7tUYOE.js → index-BVHlOHGE.js} +3 -3
- package/dist/assets/{index-zxNMbnTB.js → index-C2pGCMnS.js} +1 -1
- package/dist/assets/{index-Djlp4Keg.js → index-D51FYH2I.js} +1 -1
- package/dist/assets/{index-CeT1jXmk.js → index-De5FHXxj.js} +2 -2
- package/dist/assets/{index-zdN0nqTN.js → index-DjXBnTiZ.js} +1 -1
- package/dist/assets/{index-BS620FNd.js → index-DoKoumY4.js} +1 -1
- package/dist/assets/{index-CdifOSey.js → index-zhn31J4U.js} +1 -1
- package/dist/assets/{main-Vvtxh0xs.js → main-DWrvyMds.js} +62 -62
- package/dist/assets/{web-DRH7TXsp.js → web-BMnbjPrS.js} +1 -1
- package/dist/assets/{web-DKxBFW76.js → web-CVpy62v4.js} +1 -1
- package/dist/assets/{web-DJFpB9D2.js → web-y_u3FOwd.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/src/packages/server/data/index.js +3 -0
- package/dist/src/packages/server/index.js +3 -1
- package/dist/src/packages/server/services/auto-collapse-service.js +133 -0
- package/dist/src/packages/server/services/index.js +1 -0
- package/dist/src/packages/server/websocket/handlers/agent-handler.js +9 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as l,b1 as Re,b2 as Ye,j as e,I as L,u as Y,b3 as as,ab as ns,f as Ve,s as T,b4 as hs,b5 as ms,aW as gs,b6 as fs,C as he,G as oe,H as Z,h as je,i as ke,m as xs,b7 as bs,b8 as js,b9 as vs,ba as ws,P as Ns,bb as Se,a6 as ys,bc as is,bd as ks,be as Be,bf as Ss,bg as Cs,bh as As,bi as Ts,bj as _s,bk as Is,bl as Es,aQ as Ps,W as Ls,S as ye,bm as $s,bn as Ds,aS as Fs,bo as Ue,X as Ee,a_ as Os,bp as ze,bq as Rs}from"./main-Vvtxh0xs.js";import{g as Us,d as zs,u as Ms}from"./area-logos-DWkLpq_i.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ke="deivid11/tide-commander",Bs=`https://api.github.com/repos/${Ke}/releases/latest`,Vs=`https://api.github.com/repos/${Ke}/releases?per_page=3`,Ks=3600*1e3,Je="app_update_dismissed_version",Ze="1.124.0";function Hs(){var y,C;const[s,i]=l.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:Ze}),t=((C=(y=Re)==null?void 0:y.getPlatform)==null?void 0:C.call(y))==="android"||!1,o=u=>u.replace(/^v/,"").split(".").map(g=>parseInt(g,10)||0),d=(u,p)=>{const g=o(u),v=o(p),j=Math.max(g.length,v.length);for(let m=0;m<j;m++){const k=g[m]||0,$=v[m]||0;if(k>$)return 1;if(k<$)return-1}return 0},r=async u=>{var g,v;if(Re&&Ye&&((v=(g=Re).isNativePlatform)==null?void 0:v.call(g))===!0){const j=await Ye.get({url:u,headers:{Accept:"application/vnd.github.v3+json"}});return{data:j.data,status:j.status}}else{const j=await fetch(u,{headers:{Accept:"application/vnd.github.v3+json"}});return j.ok?{data:await j.json(),status:j.status}:{data:null,status:j.status}}},c=l.useCallback(async(u=!1)=>{i(p=>({...p,isChecking:!0,error:null}));try{const[p,g]=await Promise.all([r(Bs),r(Vs)]);if(p.status!==200)throw new Error(`GitHub API error: ${p.status}`);const v=p.data,j=v.tag_name;let m=[];g.status===200&&g.data&&(m=g.data.map(w=>({version:w.tag_name,name:w.name,publishedAt:w.published_at,releaseUrl:w.html_url})));const k=localStorage.getItem(Je);if(!u&&k===j)return i(w=>({...w,isChecking:!1,updateAvailable:!1,recentReleases:m})),null;if(!(d(j,Ze)>0))return i(w=>({...w,isChecking:!1,updateAvailable:!1,recentReleases:m})),null;const I=v.assets.find(w=>w.name.endsWith(".apk")&&w.content_type==="application/vnd.android.package-archive"),V={version:j,name:v.name,changelog:v.body,releaseUrl:v.html_url,apkUrl:(I==null?void 0:I.browser_download_url)||null,apkSize:(I==null?void 0:I.size)||null,publishedAt:v.published_at};return i(w=>({...w,isChecking:!1,updateAvailable:!0,updateInfo:V,recentReleases:m})),V}catch(p){const g=p instanceof Error?p.message:"Failed to check for updates";return i(v=>({...v,isChecking:!1,error:g})),null}},[]),f=l.useCallback(async()=>{var u,p,g;if(!((u=s.updateInfo)!=null&&u.apkUrl)){(p=s.updateInfo)!=null&&p.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!t){(g=s.updateInfo)!=null&&g.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),i(v=>({...v,error:null}))}catch(v){const j=v instanceof Error?v.message:"Failed to open download";i(m=>({...m,error:j}))}},[s.updateInfo,t]),a=l.useCallback(()=>{s.updateInfo&&localStorage.setItem(Je,s.updateInfo.version),i(u=>({...u,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),x=l.useCallback(()=>{var u;(u=s.updateInfo)!=null&&u.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${Ke}/releases`,"_blank")},[s.updateInfo]);return l.useEffect(()=>{if(!t)return;const u=setTimeout(()=>{c()},5e3),p=setInterval(()=>{c()},Ks);return()=>{clearTimeout(u),clearInterval(p)}},[t,c]),{...s,isAndroid:t,checkForUpdate:c,downloadAndInstall:f,dismissUpdate:a,openReleasePage:x}}const os="tide-toolbox-collapse";function Ws(s,i){try{const t=localStorage.getItem(`${os}-${s}`);if(t!==null)return t==="true"}catch{}return i}function qs(s,i){try{localStorage.setItem(`${os}-${s}`,String(i))}catch{}}function K({title:s,storageKey:i,defaultOpen:t=!1,forceOpen:o=!1,children:d,headerExtra:r}){const[c,f]=l.useState(()=>i?Ws(i,t):t),a=()=>{const y=!c;f(y),i&&qs(i,y)},x=o||c;return e.jsxs("div",{className:`collapsible-section ${x?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:a,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[r,e.jsx("span",{className:"collapsible-arrow",children:e.jsx(L,{name:x?"caret-down":"caret-right",size:10})})]})]}),x&&e.jsx("div",{className:"collapsible-content",children:d})]})}function Gs({area:s,isSelected:i,onClick:t,onDelete:o}){const{t:d}=Y(["config","common"]),r=s.assignedAgentIds.length,c=s.type==="rectangle"?d("config:areas.rect"):d("config:areas.circle");return e.jsxs("div",{className:`area-item ${i?"selected":""}`,onClick:t,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:[c," ",r>0&&`• ${r} ${r>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 Ys({building:s,isSelected:i,onClick:t,onEdit:o}){var f;const{t:d}=Y(["config"]),r=((f=s.pm2Status)==null?void 0:f.ports)||[],c=(a,x)=>{a.stopPropagation(),window.open(`http://${window.location.hostname}:${x}`,"_blank")};return e.jsxs("div",{className:`building-item ${i?"selected":""}`,onClick:t,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:as[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx(L,{name:ns(s.type),size:16})}),e.jsxs("div",{className:"building-info",children:[e.jsx("div",{className:"building-name",children:s.name}),e.jsxs("div",{className:"building-meta",children:[s.type,r.length>0&&e.jsx("span",{className:"building-ports",children:r.map(a=>e.jsxs("a",{href:`http://${window.location.hostname}:${a}`,className:"building-port-link",onClick:x=>c(x,a),title:`Open :${a}`,children:[":",a]},a))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:a=>{a.stopPropagation(),o()},title:d("config:buildings.editBuilding"),children:e.jsx(L,{name:"gear",size:14})})]})}function Js({building:s,onClose:i,onOpenModal:t}){var x,y,C,u,p,g,v,j;const{t:o}=Y(["config","common"]),{buildingLogs:d}=Ve(),r=T.getBuildingLogs(s.id),c=hs[s.style||"server-rack"],f=m=>{T.sendBuildingCommand(s.id,m)},a=m=>{window.open(m,"_blank")};return e.jsxs("div",{className:"building-editor",children:[e.jsxs("div",{className:"building-editor-header",children:[e.jsxs("div",{className:"building-editor-title-row",children:[e.jsx("span",{className:"building-editor-icon",children:e.jsx(L,{name:ns(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:as[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:c.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:[e.jsx(L,{name:"play",size:12})," ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>f("stop"),disabled:!((C=s.commands)!=null&&C.stop)||s.status==="stopped",title:((u=s.commands)==null?void 0:u.stop)||o("config:buildings.noStopCommand"),children:[e.jsx(L,{name:"stop",size:12,weight:"fill"})," ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>f("restart"),disabled:!((p=s.commands)!=null&&p.restart),title:((g=s.commands)==null?void 0:g.restart)||o("config:buildings.noRestartCommand"),children:[e.jsx(L,{name:"refresh",size:12})," ",o("common:buttons.retry")]}),e.jsxs("button",{className:"building-editor-action-btn health",onClick:()=>f("healthCheck"),disabled:!((v=s.commands)!=null&&v.healthCheck),title:((j=s.commands)==null?void 0:j.healthCheck)||o("config:buildings.noHealthCheck"),children:[e.jsx(L,{name:"heart",size:12})," Health"]})]})]}),s.urls&&s.urls.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((m,k)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>a(m.url),title:m.url,children:[e.jsx(L,{name:"link",size:12})," ",m.label||m.url]},k))})]}),r.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:()=>T.clearBuildingLogs(s.id),title:o("common:buttons.clear"),children:o("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:r.slice(-5).map((m,k)=>e.jsx("div",{className:"building-editor-log-entry",children:m},k))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:t,children:[e.jsx(L,{name:"gear",size:12})," ",o("config:buildings.fullSettings")]})})]})}const Zs=[{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 Xs({area:s,onClose:i,onOpenFolder:t}){var Q;const{t:o}=Y(["config","common"]),[d,r]=l.useState(s.name),[c,f]=l.useState(s.prompt||""),[a,x]=l.useState(!1),[y,C]=l.useState(""),[u,p]=l.useState(!1),g=l.useRef(null);l.useEffect(()=>{r(s.name)},[s.id,s.name]),l.useEffect(()=>{f(s.prompt||"")},[s.id,s.prompt]);const v=N=>{const D=N.target.value;r(D),T.updateArea(s.id,{name:D})},j=N=>{T.updateArea(s.id,{color:N})},m=N=>{const D=N.target.value;f(D),T.updateArea(s.id,{prompt:D})},k=()=>{y.trim()&&(T.addDirectoryToArea(s.id,y.trim()),C(""),x(!1))},$=(N,D)=>{D.stopPropagation(),T.removeDirectoryFromArea(s.id,N)},I=()=>{T.bringAreaToFront(s.id)},V=()=>{T.sendAreaToBack(s.id)},w=l.useCallback(()=>{let N=2,D=2;s.type==="rectangle"&&s.width&&s.height?(N=s.width,D=s.height):s.type==="circle"&&s.radius&&(N=s.radius*1.414,D=s.radius*1.414);const B=Math.min(N,D)*.4;return{width:Math.round(B*10)/10,height:Math.round(B*10)/10}},[s.type,s.width,s.height,s.radius]),O=async N=>{var B;const D=(B=N.target.files)==null?void 0:B[0];if(D){p(!0);try{const h=await Ms(s.id,D),E=w();T.updateArea(s.id,{logo:{filename:h.filename,position:"center",width:E.width,height:E.height,keepAspectRatio:!0,opacity:.8}})}catch(h){console.error("Failed to upload logo:",h)}finally{p(!1),g.current&&(g.current.value="")}}},z=async()=>{try{await zs(s.id),T.updateArea(s.id,{logo:void 0})}catch(N){console.error("Failed to remove logo:",N)}},H=N=>{s.logo&&T.updateArea(s.id,{logo:{...s.logo,position:N}})},S=N=>{if(!s.logo)return;const D=parseFloat(N.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const B=s.logo.height/s.logo.width;T.updateArea(s.id,{logo:{...s.logo,width:D,height:Math.round(D*B*10)/10}})}else T.updateArea(s.id,{logo:{...s.logo,width:D}})},R=N=>{if(!s.logo)return;const D=parseFloat(N.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const B=s.logo.width/s.logo.height;T.updateArea(s.id,{logo:{...s.logo,height:D,width:Math.round(D*B*10)/10}})}else T.updateArea(s.id,{logo:{...s.logo,height:D}})},W=()=>{s.logo&&T.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},J=N=>{s.logo&&T.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(N.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:v,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:ms.map(N=>e.jsx("button",{type:"button",className:`color-swatch ${s.color===N?"selected":""}`,style:{backgroundColor:N},onClick:()=>j(N),"aria-label":`Set area color ${N}`,"aria-pressed":s.color===N,title:N},N))})]}),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:I,title:o("config:areas.bringToFront"),children:[e.jsx(L,{name:"arrow-up",size:12})," ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:V,title:o("config:areas.sendToBack"),children:[e.jsx(L,{name:"arrow-down",size:12})," ",o("config:areas.back")]})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.logo")}),e.jsxs("div",{className:"area-logo-section",children:[(Q=s.logo)!=null&&Q.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:Us(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:z,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var N;return(N=g.current)==null?void 0:N.click()},disabled:u,children:u?"...":e.jsx(L,{name:"refresh",size:12})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:Zs.map(({key:N,labelKey:D})=>{var B;return e.jsx("button",{className:`area-logo-pos-btn ${((B=s.logo)==null?void 0:B.position)===N?"active":""}`,onClick:()=>H(N),children:o(`config:areas.${D}`)},N)})})]}),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:S,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:R,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:W}),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:J,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 N;return(N=g.current)==null?void 0:N.click()},disabled:u,children:u?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:g,type:"file",accept:"image/*",style:{display:"none"},onChange:O})]})]}),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(N=>e.jsxs("div",{className:"area-folder-item",title:N,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>t==null?void 0:t(s.id),title:o("config:areas.openFolder"),children:e.jsx(L,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:N.split("/").pop()||N}),e.jsx("button",{className:"area-folder-remove",onClick:D=>$(N,D),title:o("config:areas.removeFolder"),children:"×"})]},N)),a?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(gs,{value:y,onChange:C,onSubmit:k,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:k,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>x(!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:c,onChange:m,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 Qs(){const{t:s}=Y(["config","common"]),i=fs(),[t,o]=l.useState(!1),[d,r]=l.useState(null),[c,f]=l.useState({name:"",key:"",value:"",description:""}),[a,x]=l.useState(null),y=()=>{o(!0),r(null),f({name:"",key:"",value:"",description:""})},C=m=>{r(m.id),o(!1),f({name:m.name,key:m.key,value:m.value,description:m.description||""})},u=()=>{o(!1),r(null),f({name:"",key:"",value:"",description:""})},p=()=>{!c.name.trim()||!c.key.trim()||(d?T.updateSecret(d,{name:c.name.trim(),key:c.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:c.value,description:c.description.trim()||void 0}):T.createSecret({name:c.name.trim(),key:c.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:c.value,description:c.description.trim()||void 0}),u())},g=m=>{x(m)},v=()=>{a&&(T.deleteSecret(a),d===a&&u())},j=m=>{navigator.clipboard.writeText(`{{${m}}}`)};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&&!t?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):i.map(m=>e.jsxs("div",{className:`secret-item ${d===m.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:m.name}),e.jsx("code",{className:"secret-item-key",onClick:()=>j(m.key),title:s("config:secrets.copyPlaceholder"),children:`{{${m.key}}}`})]}),e.jsxs("div",{className:"secret-item-actions",children:[e.jsx("button",{className:"secret-item-btn edit",onClick:()=>C(m),title:s("common:buttons.edit"),children:e.jsx(L,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>g(m.id),title:s("common:buttons.delete"),children:"×"})]})]}),m.description&&e.jsx("div",{className:"secret-item-description",children:m.description})]},m.id))}),(t||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:c.name,onChange:m=>f({...c,name:m.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:c.key,onChange:m=>f({...c,key:m.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${c.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:c.value,onChange:m=>f({...c,value:m.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:c.description,onChange:m=>f({...c,description:m.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:u,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:p,disabled:!c.name.trim()||!c.key.trim(),children:s(d?"config:secrets.update":"common:buttons.add")})]})]}),!t&&!d&&e.jsx("button",{className:"secrets-add-btn",onClick:y,children:s("config:secrets.addSecret")}),e.jsx(he,{isOpen:a!==null,title:s("common:buttons.delete"),message:s("config:secrets.deleteConfirm"),confirmLabel:s("common:buttons.delete"),cancelLabel:s("common:buttons.cancel"),variant:"danger",onConfirm:v,onClose:()=>x(null)})]})}async function et(){const s=oe(),i=await fetch(`${Z()}/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 st(s){const i=oe(),t=await fetch(`${Z()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!t.ok)throw new Error(`Failed to update echo prompt setting: ${t.statusText}`)}async function tt(){const s=oe(),i=await fetch(`${Z()}/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 at(s){const i=oe(),t=await fetch(`${Z()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({path:s})});if(!t.ok)throw new Error(`Failed to update codex binary path: ${t.statusText}`)}async function nt(){const s=oe(),i=await fetch(`${Z()}/api/agents/system-settings/tmux-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch tmux mode setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function it(s){const i=oe(),t=await fetch(`${Z()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!t.ok)throw new Error(`Failed to update tmux mode setting: ${t.statusText}`)}async function ot(){const s=oe(),i=await fetch(`${Z()}/api/agents/system-settings/interactive-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch interactive mode setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function lt(s){const i=oe(),t=await fetch(`${Z()}/api/agents/system-settings/interactive-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!t.ok)throw new Error(`Failed to update interactive mode setting: ${t.statusText}`)}async function ct(){const s=oe(),i=await fetch(`${Z()}/api/agents/system-settings/backup`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch backup status: ${i.statusText}`);return i.json()}async function rt(s){const i=oe(),t=await fetch(`${Z()}/api/agents/system-settings/backup`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!t.ok){const o=await t.json().catch(()=>({}));throw new Error(o.error||`Failed to update backup setting: ${t.statusText}`)}return t.json()}function dt({checked:s,onChange:i,disabled:t}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,disabled:t,onChange:o=>i(o.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function ut(){const{t:s}=Y(["config","common"]),[i,t]=l.useState([]),[o,d]=l.useState(new Set),[r,c]=l.useState(new Set),[f,a]=l.useState(!1),[x,y]=l.useState(!1),[C,u]=l.useState(null),[p,g]=l.useState(null),[v,j]=l.useState(null),[m,k]=l.useState(null),[$,I]=l.useState(!1),[V,w]=l.useState(null);l.useEffect(()=>{je(ke("/api/config/categories")).then(h=>h.json()).then(h=>{const E=Array.isArray(h)?h:[];t(E),d(new Set(E.map(F=>F.id)))}).catch(h=>console.error("Failed to fetch config categories:",h))},[]),l.useEffect(()=>{ct().then(k).catch(h=>{console.error("Failed to fetch backup status:",h),w(h.message||"Failed to fetch backup status")})},[]);const O=async h=>{if(!$){I(!0),w(null);try{const E=await rt(h);k(E)}catch(E){w(E.message||"Failed to update backup setting")}finally{I(!1)}}},z=h=>{d(E=>{const F=new Set(E);return F.has(h)?F.delete(h):F.add(h),F})},H=h=>{c(E=>{const F=new Set(E);return F.has(h)?F.delete(h):F.add(h),F})},S=()=>d(new Set(i.map(h=>h.id))),R=()=>d(new Set),W=()=>{p&&c(new Set(p.categories.map(h=>h.id)))},J=()=>c(new Set),Q=async()=>{var h;if(o.size!==0){a(!0),j(null);try{const E=Array.from(o).join(","),F=await je(ke(`/api/config/export?categories=${E}`));if(!F.ok)throw new Error("Export failed");const ee=await F.blob(),se=window.URL.createObjectURL(ee),X=document.createElement("a");X.href=se;const A=F.headers.get("Content-Disposition"),q=((h=A==null?void 0:A.match(/filename="(.+)"/))==null?void 0:h[1])||"tide-commander-config.zip";X.download=q,document.body.appendChild(X),X.click(),document.body.removeChild(X),window.URL.revokeObjectURL(se),j({type:"success",text:s("config:data.exportSuccess")})}catch(E){j({type:"error",text:E.message||"Export failed"})}finally{a(!1)}}},N=async h=>{var F;const E=(F=h.target.files)==null?void 0:F[0];if(E){u(E),j(null),g(null),c(new Set);try{const ee=await je(ke("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await E.arrayBuffer()});if(!ee.ok){const A=await ee.json();throw new Error(A.error||"Failed to preview config file")}const se=await ee.json(),X=Array.isArray(se.categories)?se.categories:[];g({...se,categories:X}),c(new Set(X.map(A=>A.id)))}catch(ee){j({type:"error",text:ee.message||"Failed to read config file"}),u(null)}}},D=async()=>{if(!(!C||r.size===0)){y(!0),j(null);try{const h=Array.from(r).join(","),E=await je(ke(`/api/config/import?categories=${h}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await C.arrayBuffer()}),F=await E.json();if(!E.ok)throw new Error(F.error||"Import failed");j({type:"success",text:F.message||s("config:data.importSuccess")}),u(null),g(null),c(new Set)}catch(h){j({type:"error",text:h.message||"Import failed"})}finally{y(!1)}}},B=()=>{u(null),g(null),c(new Set),j(null)};return e.jsxs("div",{className:"data-section",children:[v&&e.jsx("div",{className:`data-message data-message-${v.type}`,children:v.text}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:"Hourly Backups"}),e.jsx(dt,{checked:!!(m!=null&&m.enabled),disabled:$||!m,onChange:O})]}),e.jsxs("div",{className:"data-backup-info",children:[m?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Saves a compressed snapshot of your data every hour to"," ",e.jsx("code",{children:m.backupDir}),". Identical snapshots are skipped. Keeps the 8 newest plus one from each of the 2 most recent prior days."]}),!m.scriptExists&&e.jsxs("div",{style:{marginTop:6,color:"var(--dracula-red, #ff5555)"},children:["Backup script not found at ",e.jsx("code",{children:m.scriptPath})]}),m.lastRunAt&&e.jsxs("div",{style:{marginTop:6},children:["Last run: ",new Date(m.lastRunAt).toLocaleString(),m.lastRunOk===!0&&" — ok",m.lastRunOk===!1&&m.lastRunError&&e.jsxs("span",{style:{color:"var(--dracula-red, #ff5555)"},children:[" — ",m.lastRunError]})]})]}):e.jsx("div",{children:"Loading backup status…"}),V&&e.jsx("div",{className:"data-message data-message-error",style:{marginTop:6},children:V})]})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:s("config:data.exportData")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:S,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:R,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:i.map(h=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(h.id),onChange:()=>z(h.id)}),e.jsx("span",{className:"data-category-name",children:h.name})]},h.id))}),e.jsx("button",{className:"data-action-btn export",onClick:Q,disabled:f||o.size===0,children:f?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")})}),C?p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:C.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(p.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:W,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:J,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:p.categories.map(h=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:r.has(h.id),onChange:()=>H(h.id)}),e.jsx("span",{className:"data-category-name",children:h.name}),h.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",h.fileCount," ",s("config:data.files"),")"]})]},h.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:B,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:D,disabled:x||r.size===0,children:x?s("config:data.importing"):s("config:data.importCount",{count:r.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:N,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}async function pt(){const s=await je(`${Z()}/api/system/install-info`);if(!s.ok)throw new Error(`Failed to fetch install info: ${s.statusText}`);return s.json()}function ht(s,i){const t=new AbortController;return(async()=>{try{const o=await fetch(xs(`${Z()}/api/system/self-update`),{method:"POST",signal:t.signal,headers:{Accept:"text/event-stream"}});if(!o.ok||!o.body){const f=await o.text().catch(()=>"");let a=null;try{a=JSON.parse(f)}catch{}const x=a&&typeof a=="object"&&"error"in a&&typeof a.error=="string"?a.error:`Self-update failed: ${o.status} ${o.statusText}`;s({type:"error",message:x}),i(new Error(x));return}const d=o.body.getReader(),r=new TextDecoder("utf-8");let c="";for(;;){const{value:f,done:a}=await d.read();if(a)break;c+=r.decode(f,{stream:!0});let x=c.indexOf(`
|
|
1
|
+
import{r as l,b1 as Re,b2 as Ye,j as e,I as L,u as Y,b3 as as,ab as ns,f as Ve,s as T,b4 as hs,b5 as ms,aW as gs,b6 as fs,C as he,G as oe,H as Z,h as je,i as ke,m as xs,b7 as bs,b8 as js,b9 as vs,ba as ws,P as Ns,bb as Se,a6 as ys,bc as is,bd as ks,be as Be,bf as Ss,bg as Cs,bh as As,bi as Ts,bj as _s,bk as Is,bl as Es,aQ as Ps,W as Ls,S as ye,bm as $s,bn as Ds,aS as Fs,bo as Ue,X as Ee,a_ as Os,bp as ze,bq as Rs}from"./main-DWrvyMds.js";import{g as Us,d as zs,u as Ms}from"./area-logos-DS6Od-VT.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ke="deivid11/tide-commander",Bs=`https://api.github.com/repos/${Ke}/releases/latest`,Vs=`https://api.github.com/repos/${Ke}/releases?per_page=3`,Ks=3600*1e3,Je="app_update_dismissed_version",Ze="1.125.0";function Hs(){var y,C;const[s,i]=l.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:Ze}),t=((C=(y=Re)==null?void 0:y.getPlatform)==null?void 0:C.call(y))==="android"||!1,o=u=>u.replace(/^v/,"").split(".").map(g=>parseInt(g,10)||0),d=(u,p)=>{const g=o(u),v=o(p),j=Math.max(g.length,v.length);for(let m=0;m<j;m++){const k=g[m]||0,$=v[m]||0;if(k>$)return 1;if(k<$)return-1}return 0},r=async u=>{var g,v;if(Re&&Ye&&((v=(g=Re).isNativePlatform)==null?void 0:v.call(g))===!0){const j=await Ye.get({url:u,headers:{Accept:"application/vnd.github.v3+json"}});return{data:j.data,status:j.status}}else{const j=await fetch(u,{headers:{Accept:"application/vnd.github.v3+json"}});return j.ok?{data:await j.json(),status:j.status}:{data:null,status:j.status}}},c=l.useCallback(async(u=!1)=>{i(p=>({...p,isChecking:!0,error:null}));try{const[p,g]=await Promise.all([r(Bs),r(Vs)]);if(p.status!==200)throw new Error(`GitHub API error: ${p.status}`);const v=p.data,j=v.tag_name;let m=[];g.status===200&&g.data&&(m=g.data.map(w=>({version:w.tag_name,name:w.name,publishedAt:w.published_at,releaseUrl:w.html_url})));const k=localStorage.getItem(Je);if(!u&&k===j)return i(w=>({...w,isChecking:!1,updateAvailable:!1,recentReleases:m})),null;if(!(d(j,Ze)>0))return i(w=>({...w,isChecking:!1,updateAvailable:!1,recentReleases:m})),null;const I=v.assets.find(w=>w.name.endsWith(".apk")&&w.content_type==="application/vnd.android.package-archive"),V={version:j,name:v.name,changelog:v.body,releaseUrl:v.html_url,apkUrl:(I==null?void 0:I.browser_download_url)||null,apkSize:(I==null?void 0:I.size)||null,publishedAt:v.published_at};return i(w=>({...w,isChecking:!1,updateAvailable:!0,updateInfo:V,recentReleases:m})),V}catch(p){const g=p instanceof Error?p.message:"Failed to check for updates";return i(v=>({...v,isChecking:!1,error:g})),null}},[]),f=l.useCallback(async()=>{var u,p,g;if(!((u=s.updateInfo)!=null&&u.apkUrl)){(p=s.updateInfo)!=null&&p.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!t){(g=s.updateInfo)!=null&&g.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),i(v=>({...v,error:null}))}catch(v){const j=v instanceof Error?v.message:"Failed to open download";i(m=>({...m,error:j}))}},[s.updateInfo,t]),a=l.useCallback(()=>{s.updateInfo&&localStorage.setItem(Je,s.updateInfo.version),i(u=>({...u,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),x=l.useCallback(()=>{var u;(u=s.updateInfo)!=null&&u.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${Ke}/releases`,"_blank")},[s.updateInfo]);return l.useEffect(()=>{if(!t)return;const u=setTimeout(()=>{c()},5e3),p=setInterval(()=>{c()},Ks);return()=>{clearTimeout(u),clearInterval(p)}},[t,c]),{...s,isAndroid:t,checkForUpdate:c,downloadAndInstall:f,dismissUpdate:a,openReleasePage:x}}const os="tide-toolbox-collapse";function Ws(s,i){try{const t=localStorage.getItem(`${os}-${s}`);if(t!==null)return t==="true"}catch{}return i}function qs(s,i){try{localStorage.setItem(`${os}-${s}`,String(i))}catch{}}function K({title:s,storageKey:i,defaultOpen:t=!1,forceOpen:o=!1,children:d,headerExtra:r}){const[c,f]=l.useState(()=>i?Ws(i,t):t),a=()=>{const y=!c;f(y),i&&qs(i,y)},x=o||c;return e.jsxs("div",{className:`collapsible-section ${x?"open":"collapsed"}`,children:[e.jsxs("button",{className:"collapsible-header",onClick:a,children:[e.jsx("span",{className:"collapsible-title",children:s}),e.jsxs("span",{className:"collapsible-header-right",children:[r,e.jsx("span",{className:"collapsible-arrow",children:e.jsx(L,{name:x?"caret-down":"caret-right",size:10})})]})]}),x&&e.jsx("div",{className:"collapsible-content",children:d})]})}function Gs({area:s,isSelected:i,onClick:t,onDelete:o}){const{t:d}=Y(["config","common"]),r=s.assignedAgentIds.length,c=s.type==="rectangle"?d("config:areas.rect"):d("config:areas.circle");return e.jsxs("div",{className:`area-item ${i?"selected":""}`,onClick:t,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:[c," ",r>0&&`• ${r} ${r>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 Ys({building:s,isSelected:i,onClick:t,onEdit:o}){var f;const{t:d}=Y(["config"]),r=((f=s.pm2Status)==null?void 0:f.ports)||[],c=(a,x)=>{a.stopPropagation(),window.open(`http://${window.location.hostname}:${x}`,"_blank")};return e.jsxs("div",{className:`building-item ${i?"selected":""}`,onClick:t,children:[e.jsx("div",{className:"building-status-dot",style:{backgroundColor:as[s.status]},title:s.status}),e.jsx("div",{className:"building-icon",children:e.jsx(L,{name:ns(s.type),size:16})}),e.jsxs("div",{className:"building-info",children:[e.jsx("div",{className:"building-name",children:s.name}),e.jsxs("div",{className:"building-meta",children:[s.type,r.length>0&&e.jsx("span",{className:"building-ports",children:r.map(a=>e.jsxs("a",{href:`http://${window.location.hostname}:${a}`,className:"building-port-link",onClick:x=>c(x,a),title:`Open :${a}`,children:[":",a]},a))})]})]}),e.jsx("button",{className:"building-edit-btn",onClick:a=>{a.stopPropagation(),o()},title:d("config:buildings.editBuilding"),children:e.jsx(L,{name:"gear",size:14})})]})}function Js({building:s,onClose:i,onOpenModal:t}){var x,y,C,u,p,g,v,j;const{t:o}=Y(["config","common"]),{buildingLogs:d}=Ve(),r=T.getBuildingLogs(s.id),c=hs[s.style||"server-rack"],f=m=>{T.sendBuildingCommand(s.id,m)},a=m=>{window.open(m,"_blank")};return e.jsxs("div",{className:"building-editor",children:[e.jsxs("div",{className:"building-editor-header",children:[e.jsxs("div",{className:"building-editor-title-row",children:[e.jsx("span",{className:"building-editor-icon",children:e.jsx(L,{name:ns(s.type),size:18})}),e.jsx("span",{className:"building-editor-title",children:s.name}),e.jsx("span",{className:"building-editor-status",style:{backgroundColor:as[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:c.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:[e.jsx(L,{name:"play",size:12})," ",o("common:buttons.start")]}),e.jsxs("button",{className:"building-editor-action-btn stop",onClick:()=>f("stop"),disabled:!((C=s.commands)!=null&&C.stop)||s.status==="stopped",title:((u=s.commands)==null?void 0:u.stop)||o("config:buildings.noStopCommand"),children:[e.jsx(L,{name:"stop",size:12,weight:"fill"})," ",o("common:buttons.stop")]}),e.jsxs("button",{className:"building-editor-action-btn restart",onClick:()=>f("restart"),disabled:!((p=s.commands)!=null&&p.restart),title:((g=s.commands)==null?void 0:g.restart)||o("config:buildings.noRestartCommand"),children:[e.jsx(L,{name:"refresh",size:12})," ",o("common:buttons.retry")]}),e.jsxs("button",{className:"building-editor-action-btn health",onClick:()=>f("healthCheck"),disabled:!((v=s.commands)!=null&&v.healthCheck),title:((j=s.commands)==null?void 0:j.healthCheck)||o("config:buildings.noHealthCheck"),children:[e.jsx(L,{name:"heart",size:12})," Health"]})]})]}),s.urls&&s.urls.length>0&&e.jsxs("div",{className:"building-editor-section",children:[e.jsx("div",{className:"building-editor-section-title",children:o("config:buildings.links")}),e.jsx("div",{className:"building-editor-links",children:s.urls.map((m,k)=>e.jsxs("button",{className:"building-editor-link",onClick:()=>a(m.url),title:m.url,children:[e.jsx(L,{name:"link",size:12})," ",m.label||m.url]},k))})]}),r.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:()=>T.clearBuildingLogs(s.id),title:o("common:buttons.clear"),children:o("common:buttons.clear")})]}),e.jsx("div",{className:"building-editor-logs",children:r.slice(-5).map((m,k)=>e.jsx("div",{className:"building-editor-log-entry",children:m},k))})]}),e.jsx("div",{className:"building-editor-footer",children:e.jsxs("button",{className:"building-editor-edit-btn",onClick:t,children:[e.jsx(L,{name:"gear",size:12})," ",o("config:buildings.fullSettings")]})})]})}const Zs=[{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 Xs({area:s,onClose:i,onOpenFolder:t}){var Q;const{t:o}=Y(["config","common"]),[d,r]=l.useState(s.name),[c,f]=l.useState(s.prompt||""),[a,x]=l.useState(!1),[y,C]=l.useState(""),[u,p]=l.useState(!1),g=l.useRef(null);l.useEffect(()=>{r(s.name)},[s.id,s.name]),l.useEffect(()=>{f(s.prompt||"")},[s.id,s.prompt]);const v=N=>{const D=N.target.value;r(D),T.updateArea(s.id,{name:D})},j=N=>{T.updateArea(s.id,{color:N})},m=N=>{const D=N.target.value;f(D),T.updateArea(s.id,{prompt:D})},k=()=>{y.trim()&&(T.addDirectoryToArea(s.id,y.trim()),C(""),x(!1))},$=(N,D)=>{D.stopPropagation(),T.removeDirectoryFromArea(s.id,N)},I=()=>{T.bringAreaToFront(s.id)},V=()=>{T.sendAreaToBack(s.id)},w=l.useCallback(()=>{let N=2,D=2;s.type==="rectangle"&&s.width&&s.height?(N=s.width,D=s.height):s.type==="circle"&&s.radius&&(N=s.radius*1.414,D=s.radius*1.414);const B=Math.min(N,D)*.4;return{width:Math.round(B*10)/10,height:Math.round(B*10)/10}},[s.type,s.width,s.height,s.radius]),O=async N=>{var B;const D=(B=N.target.files)==null?void 0:B[0];if(D){p(!0);try{const h=await Ms(s.id,D),E=w();T.updateArea(s.id,{logo:{filename:h.filename,position:"center",width:E.width,height:E.height,keepAspectRatio:!0,opacity:.8}})}catch(h){console.error("Failed to upload logo:",h)}finally{p(!1),g.current&&(g.current.value="")}}},z=async()=>{try{await zs(s.id),T.updateArea(s.id,{logo:void 0})}catch(N){console.error("Failed to remove logo:",N)}},H=N=>{s.logo&&T.updateArea(s.id,{logo:{...s.logo,position:N}})},S=N=>{if(!s.logo)return;const D=parseFloat(N.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.width>0){const B=s.logo.height/s.logo.width;T.updateArea(s.id,{logo:{...s.logo,width:D,height:Math.round(D*B*10)/10}})}else T.updateArea(s.id,{logo:{...s.logo,width:D}})},R=N=>{if(!s.logo)return;const D=parseFloat(N.target.value)||.1;if(s.logo.keepAspectRatio&&s.logo.height>0){const B=s.logo.width/s.logo.height;T.updateArea(s.id,{logo:{...s.logo,height:D,width:Math.round(D*B*10)/10}})}else T.updateArea(s.id,{logo:{...s.logo,height:D}})},W=()=>{s.logo&&T.updateArea(s.id,{logo:{...s.logo,keepAspectRatio:!s.logo.keepAspectRatio}})},J=N=>{s.logo&&T.updateArea(s.id,{logo:{...s.logo,opacity:parseFloat(N.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:v,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:ms.map(N=>e.jsx("button",{type:"button",className:`color-swatch ${s.color===N?"selected":""}`,style:{backgroundColor:N},onClick:()=>j(N),"aria-label":`Set area color ${N}`,"aria-pressed":s.color===N,title:N},N))})]}),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:I,title:o("config:areas.bringToFront"),children:[e.jsx(L,{name:"arrow-up",size:12})," ",o("config:areas.front")]}),e.jsxs("button",{className:"area-layer-btn",onClick:V,title:o("config:areas.sendToBack"),children:[e.jsx(L,{name:"arrow-down",size:12})," ",o("config:areas.back")]})]})]}),e.jsxs("div",{className:"area-editor-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"area-editor-label",style:{marginBottom:6},children:o("config:areas.logo")}),e.jsxs("div",{className:"area-logo-section",children:[(Q=s.logo)!=null&&Q.filename?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"area-logo-preview",children:[e.jsx("img",{src:Us(s.logo.filename),alt:"Logo",className:"area-logo-thumbnail"}),e.jsx("button",{className:"area-logo-remove-btn",onClick:z,children:o("config:areas.removeLogo")}),e.jsx("button",{className:"area-logo-replace-btn",onClick:()=>{var N;return(N=g.current)==null?void 0:N.click()},disabled:u,children:u?"...":e.jsx(L,{name:"refresh",size:12})})]}),e.jsxs("div",{className:"area-logo-config-row",children:[e.jsx("span",{className:"area-logo-config-label",children:o("config:areas.logoPosition")}),e.jsx("div",{className:"area-logo-position-row",children:Zs.map(({key:N,labelKey:D})=>{var B;return e.jsx("button",{className:`area-logo-pos-btn ${((B=s.logo)==null?void 0:B.position)===N?"active":""}`,onClick:()=>H(N),children:o(`config:areas.${D}`)},N)})})]}),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:S,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:R,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:W}),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:J,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 N;return(N=g.current)==null?void 0:N.click()},disabled:u,children:u?"...":o("config:areas.uploadLogo")}),e.jsx("input",{ref:g,type:"file",accept:"image/*",style:{display:"none"},onChange:O})]})]}),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(N=>e.jsxs("div",{className:"area-folder-item",title:N,children:[e.jsx("span",{className:"area-folder-icon clickable",onClick:()=>t==null?void 0:t(s.id),title:o("config:areas.openFolder"),children:e.jsx(L,{name:"folder",size:14})}),e.jsx("span",{className:"area-folder-path",children:N.split("/").pop()||N}),e.jsx("button",{className:"area-folder-remove",onClick:D=>$(N,D),title:o("config:areas.removeFolder"),children:"×"})]},N)),a?e.jsxs("div",{className:"area-add-folder-inline",children:[e.jsx(gs,{value:y,onChange:C,onSubmit:k,placeholder:o("config:areas.folderPlaceholder"),className:"area-add-folder-input",directoriesOnly:!0,autoFocus:!0}),e.jsx("button",{className:"area-add-folder-confirm",onClick:k,children:"+"})]}):e.jsx("button",{className:"area-add-folder-btn",onClick:()=>x(!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:c,onChange:m,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 Qs(){const{t:s}=Y(["config","common"]),i=fs(),[t,o]=l.useState(!1),[d,r]=l.useState(null),[c,f]=l.useState({name:"",key:"",value:"",description:""}),[a,x]=l.useState(null),y=()=>{o(!0),r(null),f({name:"",key:"",value:"",description:""})},C=m=>{r(m.id),o(!1),f({name:m.name,key:m.key,value:m.value,description:m.description||""})},u=()=>{o(!1),r(null),f({name:"",key:"",value:"",description:""})},p=()=>{!c.name.trim()||!c.key.trim()||(d?T.updateSecret(d,{name:c.name.trim(),key:c.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:c.value,description:c.description.trim()||void 0}):T.createSecret({name:c.name.trim(),key:c.key.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_"),value:c.value,description:c.description.trim()||void 0}),u())},g=m=>{x(m)},v=()=>{a&&(T.deleteSecret(a),d===a&&u())},j=m=>{navigator.clipboard.writeText(`{{${m}}}`)};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&&!t?e.jsx("div",{className:"secrets-empty",children:s("config:secrets.noSecrets")}):i.map(m=>e.jsxs("div",{className:`secret-item ${d===m.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:m.name}),e.jsx("code",{className:"secret-item-key",onClick:()=>j(m.key),title:s("config:secrets.copyPlaceholder"),children:`{{${m.key}}}`})]}),e.jsxs("div",{className:"secret-item-actions",children:[e.jsx("button",{className:"secret-item-btn edit",onClick:()=>C(m),title:s("common:buttons.edit"),children:e.jsx(L,{name:"edit",size:12})}),e.jsx("button",{className:"secret-item-btn delete",onClick:()=>g(m.id),title:s("common:buttons.delete"),children:"×"})]})]}),m.description&&e.jsx("div",{className:"secret-item-description",children:m.description})]},m.id))}),(t||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:c.name,onChange:m=>f({...c,name:m.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:c.key,onChange:m=>f({...c,key:m.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")})}),e.jsx("span",{className:"secret-form-hint",children:s("config:secrets.usedAs",{placeholder:`{{${c.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:c.value,onChange:m=>f({...c,value:m.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:c.description,onChange:m=>f({...c,description:m.target.value})})]}),e.jsxs("div",{className:"secret-form-actions",children:[e.jsx("button",{className:"secret-form-btn cancel",onClick:u,children:s("common:buttons.cancel")}),e.jsx("button",{className:"secret-form-btn save",onClick:p,disabled:!c.name.trim()||!c.key.trim(),children:s(d?"config:secrets.update":"common:buttons.add")})]})]}),!t&&!d&&e.jsx("button",{className:"secrets-add-btn",onClick:y,children:s("config:secrets.addSecret")}),e.jsx(he,{isOpen:a!==null,title:s("common:buttons.delete"),message:s("config:secrets.deleteConfirm"),confirmLabel:s("common:buttons.delete"),cancelLabel:s("common:buttons.cancel"),variant:"danger",onConfirm:v,onClose:()=>x(null)})]})}async function et(){const s=oe(),i=await fetch(`${Z()}/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 st(s){const i=oe(),t=await fetch(`${Z()}/api/agents/system-settings/echo-prompt`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!t.ok)throw new Error(`Failed to update echo prompt setting: ${t.statusText}`)}async function tt(){const s=oe(),i=await fetch(`${Z()}/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 at(s){const i=oe(),t=await fetch(`${Z()}/api/agents/system-settings/codex-binary`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({path:s})});if(!t.ok)throw new Error(`Failed to update codex binary path: ${t.statusText}`)}async function nt(){const s=oe(),i=await fetch(`${Z()}/api/agents/system-settings/tmux-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch tmux mode setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function it(s){const i=oe(),t=await fetch(`${Z()}/api/agents/system-settings/tmux-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!t.ok)throw new Error(`Failed to update tmux mode setting: ${t.statusText}`)}async function ot(){const s=oe(),i=await fetch(`${Z()}/api/agents/system-settings/interactive-mode`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch interactive mode setting: ${i.statusText}`);return(await i.json()).enabled||!1}async function lt(s){const i=oe(),t=await fetch(`${Z()}/api/agents/system-settings/interactive-mode`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!t.ok)throw new Error(`Failed to update interactive mode setting: ${t.statusText}`)}async function ct(){const s=oe(),i=await fetch(`${Z()}/api/agents/system-settings/backup`,{headers:{Authorization:`Bearer ${s}`}});if(!i.ok)throw new Error(`Failed to fetch backup status: ${i.statusText}`);return i.json()}async function rt(s){const i=oe(),t=await fetch(`${Z()}/api/agents/system-settings/backup`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({enabled:s})});if(!t.ok){const o=await t.json().catch(()=>({}));throw new Error(o.error||`Failed to update backup setting: ${t.statusText}`)}return t.json()}function dt({checked:s,onChange:i,disabled:t}){return e.jsxs("label",{className:"config-toggle",children:[e.jsx("input",{type:"checkbox",className:"config-toggle-input",checked:s,disabled:t,onChange:o=>i(o.target.checked)}),e.jsx("span",{className:"config-toggle-track",children:e.jsx("span",{className:"config-toggle-thumb"})})]})}function ut(){const{t:s}=Y(["config","common"]),[i,t]=l.useState([]),[o,d]=l.useState(new Set),[r,c]=l.useState(new Set),[f,a]=l.useState(!1),[x,y]=l.useState(!1),[C,u]=l.useState(null),[p,g]=l.useState(null),[v,j]=l.useState(null),[m,k]=l.useState(null),[$,I]=l.useState(!1),[V,w]=l.useState(null);l.useEffect(()=>{je(ke("/api/config/categories")).then(h=>h.json()).then(h=>{const E=Array.isArray(h)?h:[];t(E),d(new Set(E.map(F=>F.id)))}).catch(h=>console.error("Failed to fetch config categories:",h))},[]),l.useEffect(()=>{ct().then(k).catch(h=>{console.error("Failed to fetch backup status:",h),w(h.message||"Failed to fetch backup status")})},[]);const O=async h=>{if(!$){I(!0),w(null);try{const E=await rt(h);k(E)}catch(E){w(E.message||"Failed to update backup setting")}finally{I(!1)}}},z=h=>{d(E=>{const F=new Set(E);return F.has(h)?F.delete(h):F.add(h),F})},H=h=>{c(E=>{const F=new Set(E);return F.has(h)?F.delete(h):F.add(h),F})},S=()=>d(new Set(i.map(h=>h.id))),R=()=>d(new Set),W=()=>{p&&c(new Set(p.categories.map(h=>h.id)))},J=()=>c(new Set),Q=async()=>{var h;if(o.size!==0){a(!0),j(null);try{const E=Array.from(o).join(","),F=await je(ke(`/api/config/export?categories=${E}`));if(!F.ok)throw new Error("Export failed");const ee=await F.blob(),se=window.URL.createObjectURL(ee),X=document.createElement("a");X.href=se;const A=F.headers.get("Content-Disposition"),q=((h=A==null?void 0:A.match(/filename="(.+)"/))==null?void 0:h[1])||"tide-commander-config.zip";X.download=q,document.body.appendChild(X),X.click(),document.body.removeChild(X),window.URL.revokeObjectURL(se),j({type:"success",text:s("config:data.exportSuccess")})}catch(E){j({type:"error",text:E.message||"Export failed"})}finally{a(!1)}}},N=async h=>{var F;const E=(F=h.target.files)==null?void 0:F[0];if(E){u(E),j(null),g(null),c(new Set);try{const ee=await je(ke("/api/config/preview"),{method:"POST",headers:{"Content-Type":"application/zip"},body:await E.arrayBuffer()});if(!ee.ok){const A=await ee.json();throw new Error(A.error||"Failed to preview config file")}const se=await ee.json(),X=Array.isArray(se.categories)?se.categories:[];g({...se,categories:X}),c(new Set(X.map(A=>A.id)))}catch(ee){j({type:"error",text:ee.message||"Failed to read config file"}),u(null)}}},D=async()=>{if(!(!C||r.size===0)){y(!0),j(null);try{const h=Array.from(r).join(","),E=await je(ke(`/api/config/import?categories=${h}`),{method:"POST",headers:{"Content-Type":"application/zip"},body:await C.arrayBuffer()}),F=await E.json();if(!E.ok)throw new Error(F.error||"Import failed");j({type:"success",text:F.message||s("config:data.importSuccess")}),u(null),g(null),c(new Set)}catch(h){j({type:"error",text:h.message||"Import failed"})}finally{y(!1)}}},B=()=>{u(null),g(null),c(new Set),j(null)};return e.jsxs("div",{className:"data-section",children:[v&&e.jsx("div",{className:`data-message data-message-${v.type}`,children:v.text}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:"Hourly Backups"}),e.jsx(dt,{checked:!!(m!=null&&m.enabled),disabled:$||!m,onChange:O})]}),e.jsxs("div",{className:"data-backup-info",children:[m?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Saves a compressed snapshot of your data every hour to"," ",e.jsx("code",{children:m.backupDir}),". Identical snapshots are skipped. Keeps the 8 newest plus one from each of the 2 most recent prior days."]}),!m.scriptExists&&e.jsxs("div",{style:{marginTop:6,color:"var(--dracula-red, #ff5555)"},children:["Backup script not found at ",e.jsx("code",{children:m.scriptPath})]}),m.lastRunAt&&e.jsxs("div",{style:{marginTop:6},children:["Last run: ",new Date(m.lastRunAt).toLocaleString(),m.lastRunOk===!0&&" — ok",m.lastRunOk===!1&&m.lastRunError&&e.jsxs("span",{style:{color:"var(--dracula-red, #ff5555)"},children:[" — ",m.lastRunError]})]})]}):e.jsx("div",{children:"Loading backup status…"}),V&&e.jsx("div",{className:"data-message data-message-error",style:{marginTop:6},children:V})]})]}),e.jsxs("div",{className:"data-subsection",children:[e.jsxs("div",{className:"data-subsection-header",children:[e.jsx("span",{className:"data-subsection-title",children:s("config:data.exportData")}),e.jsxs("div",{className:"data-select-controls",children:[e.jsx("button",{className:"data-select-btn",onClick:S,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:R,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:i.map(h=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:o.has(h.id),onChange:()=>z(h.id)}),e.jsx("span",{className:"data-category-name",children:h.name})]},h.id))}),e.jsx("button",{className:"data-action-btn export",onClick:Q,disabled:f||o.size===0,children:f?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")})}),C?p?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-import-info",children:[e.jsx("div",{className:"data-import-file",children:C.name}),e.jsxs("div",{className:"data-import-date",children:[s("config:data.exported"),": ",new Date(p.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:W,children:s("common:labels.all")}),e.jsx("button",{className:"data-select-btn",onClick:J,children:s("common:labels.none")})]})]}),e.jsx("div",{className:"data-category-list",children:p.categories.map(h=>e.jsxs("label",{className:"data-category-item",children:[e.jsx("input",{type:"checkbox",checked:r.has(h.id),onChange:()=>H(h.id)}),e.jsx("span",{className:"data-category-name",children:h.name}),h.fileCount&&e.jsxs("span",{className:"data-category-count",children:["(",h.fileCount," ",s("config:data.files"),")"]})]},h.id))}),e.jsxs("div",{className:"data-import-actions",children:[e.jsx("button",{className:"data-action-btn cancel",onClick:B,children:s("common:buttons.cancel")}),e.jsx("button",{className:"data-action-btn import",onClick:D,disabled:x||r.size===0,children:x?s("config:data.importing"):s("config:data.importCount",{count:r.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:N,style:{display:"none"}}),e.jsx("span",{className:"data-file-input-label",children:s("config:data.selectFile")})]})]})]})}async function pt(){const s=await je(`${Z()}/api/system/install-info`);if(!s.ok)throw new Error(`Failed to fetch install info: ${s.statusText}`);return s.json()}function ht(s,i){const t=new AbortController;return(async()=>{try{const o=await fetch(xs(`${Z()}/api/system/self-update`),{method:"POST",signal:t.signal,headers:{Accept:"text/event-stream"}});if(!o.ok||!o.body){const f=await o.text().catch(()=>"");let a=null;try{a=JSON.parse(f)}catch{}const x=a&&typeof a=="object"&&"error"in a&&typeof a.error=="string"?a.error:`Self-update failed: ${o.status} ${o.statusText}`;s({type:"error",message:x}),i(new Error(x));return}const d=o.body.getReader(),r=new TextDecoder("utf-8");let c="";for(;;){const{value:f,done:a}=await d.read();if(a)break;c+=r.decode(f,{stream:!0});let x=c.indexOf(`
|
|
2
2
|
|
|
3
3
|
`);for(;x!==-1;){const y=c.slice(0,x);c=c.slice(x+2);const C=y.split(`
|
|
4
4
|
`);let u="message",p="";for(const g of C)g.startsWith(":")||(g.startsWith("event:")?u=g.slice(6).trim():g.startsWith("data:")&&(p+=(p?`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-
|
|
2
|
-
import{cw as e,bI as o}from"./main-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-y_u3FOwd.js","assets/main-DWrvyMds.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-D5FMJNlX.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{cw as e,bI as o}from"./main-DWrvyMds.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";var i;(function(r){r.Heavy="HEAVY",r.Medium="MEDIUM",r.Light="LIGHT"})(i||(i={}));var t;(function(r){r.Success="SUCCESS",r.Warning="WARNING",r.Error="ERROR"})(t||(t={}));const c=e("Haptics",{web:()=>o(()=>import("./web-y_u3FOwd.js"),__vite__mapDeps([0,1,2,3,4])).then(r=>new r.HapticsWeb)});export{c as Haptics,i as ImpactStyle,t as NotificationType};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as At,i as yt,at as Et,a1 as xt,a2 as Ct,c2 as Mt,c3 as Ft,aC as wt,r as d,X as St,S as me,c4 as vt,c5 as fe,s as X,c6 as Bt,j as f,I as ne,c7 as Ve,c8 as bt,a6 as It,c9 as _t,ca as Dt,cb as Ee,al as Be,W as Rt,p as nt,u as Fe,cc as Je}from"./main-Vvtxh0xs.js";import{cd as Ls,ce as $s,cf as js,cg as Ns,ch as Ps}from"./main-Vvtxh0xs.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function re(t){return Array.isArray?Array.isArray(t):ct(t)==="[object Array]"}function kt(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Tt(t){return t==null?"":kt(t)}function q(t){return typeof t=="string"}function rt(t){return typeof t=="number"}function Lt(t){return t===!0||t===!1||$t(t)&&ct(t)=="[object Boolean]"}function it(t){return typeof t=="object"}function $t(t){return it(t)&&t!==null}function G(t){return t!=null}function be(t){return!t.trim().length}function ct(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const jt="Incorrect 'index' type",Nt=t=>`Invalid value for key ${t}`,Pt=t=>`Pattern length exceeds max of ${t}.`,Kt=t=>`Missing ${t} property in key`,Ot=t=>`Property 'weight' in key '${t}' must be a positive integer`,Xe=Object.prototype.hasOwnProperty;class zt{constructor(e){this._keys=[],this._keyMap={};let n=0;e.forEach(r=>{let i=ot(r);this._keys.push(i),this._keyMap[i.id]=i,n+=i.weight}),this._keys.forEach(r=>{r.weight/=n})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function ot(t){let e=null,n=null,r=null,i=1,c=null;if(q(t)||re(t))r=t,e=Ze(t),n=Ie(t);else{if(!Xe.call(t,"name"))throw new Error(Kt("name"));const o=t.name;if(r=o,Xe.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(Ot(o));e=Ze(o),n=Ie(o),c=t.getFn}return{path:e,id:n,weight:i,src:r,getFn:c}}function Ze(t){return re(t)?t:t.split(".")}function Ie(t){return re(t)?t.join("."):t}function Gt(t,e){let n=[],r=!1;const i=(c,o,a)=>{if(G(c))if(!o[a])n.push(c);else{let u=o[a];const l=c[u];if(!G(l))return;if(a===o.length-1&&(q(l)||rt(l)||Lt(l)))n.push(Tt(l));else if(re(l)){r=!0;for(let h=0,E=l.length;h<E;h+=1)i(l[h],o,a+1)}else o.length&&i(l,o,a+1)}};return i(t,q(e)?e.split("."):e,0),r?n:n[0]}const Qt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Wt={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},Ht={location:0,threshold:.6,distance:100},Ut={useExtendedSearch:!1,getFn:Gt,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var y={...Wt,...Qt,...Ht,...Ut};const Yt=/[^ ]+/g;function Vt(t=1,e=3){const n=new Map,r=Math.pow(10,e);return{get(i){const c=i.match(Yt).length;if(n.has(c))return n.get(c);const o=1/Math.pow(c,.5*t),a=parseFloat(Math.round(o*r)/r);return n.set(c,a),a},clear(){n.clear()}}}class Le{constructor({getFn:e=y.getFn,fieldNormWeight:n=y.fieldNormWeight}={}){this.norm=Vt(n,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((n,r)=>{this._keysMap[n.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,q(this.docs[0])?this.docs.forEach((e,n)=>{this._addString(e,n)}):this.docs.forEach((e,n)=>{this._addObject(e,n)}),this.norm.clear())}add(e){const n=this.size();q(e)?this._addString(e,n):this._addObject(e,n)}removeAt(e){this.records.splice(e,1);for(let n=e,r=this.size();n<r;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(e,n){return e[this._keysMap[n]]}size(){return this.records.length}_addString(e,n){if(!G(e)||be(e))return;let r={v:e,i:n,n:this.norm.get(e)};this.records.push(r)}_addObject(e,n){let r={i:n,$:{}};this.keys.forEach((i,c)=>{let o=i.getFn?i.getFn(e):this.getFn(e,i.path);if(G(o)){if(re(o)){let a=[];const u=[{nestedArrIndex:-1,value:o}];for(;u.length;){const{nestedArrIndex:l,value:h}=u.pop();if(G(h))if(q(h)&&!be(h)){let E={v:h,i:l,n:this.norm.get(h)};a.push(E)}else re(h)&&h.forEach((E,x)=>{u.push({nestedArrIndex:x,value:E})})}r.$[c]=a}else if(q(o)&&!be(o)){let a={v:o,n:this.norm.get(o)};r.$[c]=a}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function at(t,e,{getFn:n=y.getFn,fieldNormWeight:r=y.fieldNormWeight}={}){const i=new Le({getFn:n,fieldNormWeight:r});return i.setKeys(t.map(ot)),i.setSources(e),i.create(),i}function Jt(t,{getFn:e=y.getFn,fieldNormWeight:n=y.fieldNormWeight}={}){const{keys:r,records:i}=t,c=new Le({getFn:e,fieldNormWeight:n});return c.setKeys(r),c.setIndexRecords(i),c}function xe(t,{errors:e=0,currentLocation:n=0,expectedLocation:r=0,distance:i=y.distance,ignoreLocation:c=y.ignoreLocation}={}){const o=e/t.length;if(c)return o;const a=Math.abs(r-n);return i?o+a/i:a?1:o}function Xt(t=[],e=y.minMatchCharLength){let n=[],r=-1,i=-1,c=0;for(let o=t.length;c<o;c+=1){let a=t[c];a&&r===-1?r=c:!a&&r!==-1&&(i=c-1,i-r+1>=e&&n.push([r,i]),r=-1)}return t[c-1]&&c-r>=e&&n.push([r,c-1]),n}const le=32;function Zt(t,e,n,{location:r=y.location,distance:i=y.distance,threshold:c=y.threshold,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,includeMatches:u=y.includeMatches,ignoreLocation:l=y.ignoreLocation}={}){if(e.length>le)throw new Error(Pt(le));const h=e.length,E=t.length,x=Math.max(0,Math.min(r,E));let g=c,m=x;const S=a>1||u,F=S?Array(E):[];let T;for(;(T=t.indexOf(e,m))>-1;){let $=xe(e,{currentLocation:T,expectedLocation:x,distance:i,ignoreLocation:l});if(g=Math.min($,g),m=T+h,S){let N=0;for(;N<h;)F[T+N]=1,N+=1}}m=-1;let j=[],Q=1,W=h+E;const oe=1<<h-1;for(let $=0;$<h;$+=1){let N=0,_=W;for(;N<_;)xe(e,{errors:$,currentLocation:x+_,expectedLocation:x,distance:i,ignoreLocation:l})<=g?N=_:W=_,_=Math.floor((W-N)/2+N);W=_;let ae=Math.max(1,x-_+1),H=o?E:Math.min(x+_,E)+h,v=Array(H+2);v[H+1]=(1<<$)-1;for(let D=H;D>=ae;D-=1){let J=D-1,O=n[t.charAt(J)];if(S&&(F[J]=+!!O),v[D]=(v[D+1]<<1|1)&O,$&&(v[D]|=(j[D+1]|j[D])<<1|1|j[D+1]),v[D]&oe&&(Q=xe(e,{errors:$,currentLocation:J,expectedLocation:x,distance:i,ignoreLocation:l}),Q<=g)){if(g=Q,m=J,m<=x)break;ae=Math.max(1,2*x-m)}}if(xe(e,{errors:$+1,currentLocation:x,expectedLocation:x,distance:i,ignoreLocation:l})>g)break;j=v}const ie={isMatch:m>=0,score:Math.max(.001,Q)};if(S){const $=Xt(F,a);$.length?u&&(ie.indices=$):ie.isMatch=!1}return ie}function qt(t){let e={};for(let n=0,r=t.length;n<r;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<r-n-1}return e}const Ce=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class ut{constructor(e,{location:n=y.location,threshold:r=y.threshold,distance:i=y.distance,includeMatches:c=y.includeMatches,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,isCaseSensitive:u=y.isCaseSensitive,ignoreDiacritics:l=y.ignoreDiacritics,ignoreLocation:h=y.ignoreLocation}={}){if(this.options={location:n,threshold:r,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h},e=u?e:e.toLowerCase(),e=l?Ce(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const E=(g,m)=>{this.chunks.push({pattern:g,alphabet:qt(g),startIndex:m})},x=this.pattern.length;if(x>le){let g=0;const m=x%le,S=x-m;for(;g<S;)E(this.pattern.substr(g,le),g),g+=le;if(m){const F=x-le;E(this.pattern.substr(F),F)}}else E(this.pattern,0)}searchIn(e){const{isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i}=this.options;if(e=n?e:e.toLowerCase(),e=r?Ce(e):e,this.pattern===e){let S={isMatch:!0,score:0};return i&&(S.indices=[[0,e.length-1]]),S}const{location:c,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:h}=this.options;let E=[],x=0,g=!1;this.chunks.forEach(({pattern:S,alphabet:F,startIndex:T})=>{const{isMatch:j,score:Q,indices:W}=Zt(e,S,F,{location:c+T,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:i,ignoreLocation:h});j&&(g=!0),x+=Q,j&&W&&(E=[...E,...W])});let m={isMatch:g,score:g?x/this.chunks.length:1};return g&&i&&(m.indices=E),m}}class ce{constructor(e){this.pattern=e}static isMultiMatch(e){return qe(e,this.multiRegex)}static isSingleMatch(e){return qe(e,this.singleRegex)}search(){}}function qe(t,e){const n=t.match(e);return n?n[1]:null}class es extends ce{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const n=e===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class ts extends ce{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const r=e.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class ss extends ce{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const n=e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class ns extends ce{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const n=!e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class rs extends ce{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const n=e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class is extends ce{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const n=!e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class lt extends ce{constructor(e,{location:n=y.location,threshold:r=y.threshold,distance:i=y.distance,includeMatches:c=y.includeMatches,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,isCaseSensitive:u=y.isCaseSensitive,ignoreDiacritics:l=y.ignoreDiacritics,ignoreLocation:h=y.ignoreLocation}={}){super(e),this._bitapSearch=new ut(e,{location:n,threshold:r,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ht extends ce{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let n=0,r;const i=[],c=this.pattern.length;for(;(r=e.indexOf(this.pattern,n))>-1;)n=r+c,i.push([r,n-1]);const o=!!i.length;return{isMatch:o,score:o?0:1,indices:i}}}const _e=[es,ht,ss,ns,is,rs,ts,lt],et=_e.length,cs=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,os="|";function as(t,e={}){return t.split(os).map(n=>{let r=n.trim().split(cs).filter(c=>c&&!!c.trim()),i=[];for(let c=0,o=r.length;c<o;c+=1){const a=r[c];let u=!1,l=-1;for(;!u&&++l<et;){const h=_e[l];let E=h.isMultiMatch(a);E&&(i.push(new h(E,e)),u=!0)}if(!u)for(l=-1;++l<et;){const h=_e[l];let E=h.isSingleMatch(a);if(E){i.push(new h(E,e));break}}}return i})}const us=new Set([lt.type,ht.type]);class ls{constructor(e,{isCaseSensitive:n=y.isCaseSensitive,ignoreDiacritics:r=y.ignoreDiacritics,includeMatches:i=y.includeMatches,minMatchCharLength:c=y.minMatchCharLength,ignoreLocation:o=y.ignoreLocation,findAllMatches:a=y.findAllMatches,location:u=y.location,threshold:l=y.threshold,distance:h=y.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i,minMatchCharLength:c,findAllMatches:a,ignoreLocation:o,location:u,threshold:l,distance:h},e=n?e:e.toLowerCase(),e=r?Ce(e):e,this.pattern=e,this.query=as(this.pattern,this.options)}static condition(e,n){return n.useExtendedSearch}searchIn(e){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:i,ignoreDiacritics:c}=this.options;e=i?e:e.toLowerCase(),e=c?Ce(e):e;let o=0,a=[],u=0;for(let l=0,h=n.length;l<h;l+=1){const E=n[l];a.length=0,o=0;for(let x=0,g=E.length;x<g;x+=1){const m=E[x],{isMatch:S,indices:F,score:T}=m.search(e);if(S){if(o+=1,u+=T,r){const j=m.constructor.type;us.has(j)?a=[...a,...F]:a.push(F)}}else{u=0,o=0,a.length=0;break}}if(o){let x={isMatch:!0,score:u/o};return r&&(x.indices=a),x}}return{isMatch:!1,score:1}}}const De=[];function hs(...t){De.push(...t)}function Re(t,e){for(let n=0,r=De.length;n<r;n+=1){let i=De[n];if(i.condition(t,e))return new i(t,e)}return new ut(t,e)}const Me={AND:"$and",OR:"$or"},ke={PATH:"$path",PATTERN:"$val"},Te=t=>!!(t[Me.AND]||t[Me.OR]),ds=t=>!!t[ke.PATH],fs=t=>!re(t)&&it(t)&&!Te(t),tt=t=>({[Me.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function dt(t,e,{auto:n=!0}={}){const r=i=>{let c=Object.keys(i);const o=ds(i);if(!o&&c.length>1&&!Te(i))return r(tt(i));if(fs(i)){const u=o?i[ke.PATH]:c[0],l=o?i[ke.PATTERN]:i[u];if(!q(l))throw new Error(Nt(u));const h={keyId:Ie(u),pattern:l};return n&&(h.searcher=Re(l,e)),h}let a={children:[],operator:c[0]};return c.forEach(u=>{const l=i[u];re(l)&&l.forEach(h=>{a.children.push(r(h))})}),a};return Te(t)||(t=tt(t)),r(t)}function gs(t,{ignoreFieldNorm:e=y.ignoreFieldNorm}){t.forEach(n=>{let r=1;n.matches.forEach(({key:i,norm:c,score:o})=>{const a=i?i.weight:null;r*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(e?1:c))}),n.score=r})}function ms(t,e){const n=t.matches;e.matches=[],G(n)&&n.forEach(r=>{if(!G(r.indices)||!r.indices.length)return;const{indices:i,value:c}=r;let o={indices:i,value:c};r.key&&(o.key=r.key.src),r.idx>-1&&(o.refIndex=r.idx),e.matches.push(o)})}function ps(t,e){e.score=t.score}function As(t,e,{includeMatches:n=y.includeMatches,includeScore:r=y.includeScore}={}){const i=[];return n&&i.push(ms),r&&i.push(ps),t.map(c=>{const{idx:o}=c,a={item:e[o],refIndex:o};return i.length&&i.forEach(u=>{u(c,a)}),a})}class Z{constructor(e,n={},r){this.options={...y,...n},this.options.useExtendedSearch,this._keyStore=new zt(this.options.keys),this.setCollection(e,r)}setCollection(e,n){if(this._docs=e,n&&!(n instanceof Le))throw new Error(jt);this._myIndex=n||at(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){G(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const n=[];for(let r=0,i=this._docs.length;r<i;r+=1){const c=this._docs[r];e(c,r)&&(this.removeAt(r),r-=1,i-=1,n.push(c))}return n}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:n=-1}={}){const{includeMatches:r,includeScore:i,shouldSort:c,sortFn:o,ignoreFieldNorm:a}=this.options;let u=q(e)?q(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return gs(u,{ignoreFieldNorm:a}),c&&u.sort(o),rt(n)&&n>-1&&(u=u.slice(0,n)),As(u,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e){const n=Re(e,this.options),{records:r}=this._myIndex,i=[];return r.forEach(({v:c,i:o,n:a})=>{if(!G(c))return;const{isMatch:u,score:l,indices:h}=n.searchIn(c);u&&i.push({item:c,idx:o,matches:[{score:l,value:c,norm:a,indices:h}]})}),i}_searchLogical(e){const n=dt(e,this.options),r=(a,u,l)=>{if(!a.children){const{keyId:E,searcher:x}=a,g=this._findMatches({key:this._keyStore.get(E),value:this._myIndex.getValueForItemAtKeyId(u,E),searcher:x});return g&&g.length?[{idx:l,item:u,matches:g}]:[]}const h=[];for(let E=0,x=a.children.length;E<x;E+=1){const g=a.children[E],m=r(g,u,l);if(m.length)h.push(...m);else if(a.operator===Me.AND)return[]}return h},i=this._myIndex.records,c={},o=[];return i.forEach(({$:a,i:u})=>{if(G(a)){let l=r(n,a,u);l.length&&(c[u]||(c[u]={idx:u,item:a,matches:[]},o.push(c[u])),l.forEach(({matches:h})=>{c[u].matches.push(...h)}))}}),o}_searchObjectList(e){const n=Re(e,this.options),{keys:r,records:i}=this._myIndex,c=[];return i.forEach(({$:o,i:a})=>{if(!G(o))return;let u=[];r.forEach((l,h)=>{u.push(...this._findMatches({key:l,value:o[h],searcher:n}))}),u.length&&c.push({idx:a,item:o,matches:u})}),c}_findMatches({key:e,value:n,searcher:r}){if(!G(n))return[];let i=[];if(re(n))n.forEach(({v:c,i:o,n:a})=>{if(!G(c))return;const{isMatch:u,score:l,indices:h}=r.searchIn(c);u&&i.push({score:l,key:e,value:c,idx:o,norm:a,indices:h})});else{const{v:c,n:o}=n,{isMatch:a,score:u,indices:l}=r.searchIn(c);a&&i.push({score:u,key:e,value:c,norm:o,indices:l})}return i}}Z.version="7.1.0";Z.createIndex=at;Z.parseIndex=Jt;Z.config=y;Z.parseQuery=dt;hs(ls);async function ys(t){const e=new URLSearchParams({q:t}),n=await At(yt(`/api/folders/search?${e.toString()}`));if(!n.ok){const i=await n.json().catch(()=>({}));throw new Error(i.error||`Failed to search folders: ${n.statusText}`)}const r=await n.json();return Array.isArray(r.folders)?r.folders:[]}const Es=["command","agent","building","area","folder","modified-file"],xs=2;function Cs(){const t=nt(me.SPOTLIGHT_TAB,"all");return fe.includes(t)?t:"all"}function st(){return Rt(me.SPOTLIGHT_QUERY,"")}function Ms(){const t=nt(me.AOP_CONFIG,{});return t.sortMode==="name"||t.sortMode==="status"||t.sortMode==="recent"?t.sortMode:"recent"}function Fs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=Et(),E=xt(),x=Ct(),g=Mt(),m=Ft(),S=wt(),F=d.useRef(e);F.current=e;const T=d.useRef(n);T.current=n;const j=d.useRef(r);j.current=r;const Q=d.useRef(i);Q.current=i;const W=d.useRef(c);W.current=c;const oe=d.useRef(o);oe.current=o;const ie=d.useRef(a);ie.current=a;const $=d.useRef(u);$.current=u;const N=d.useRef(l);N.current=l;const[_,ae]=d.useState(st),[H,v]=d.useState(0),[M,D]=d.useState(Cs),[J,O]=d.useState([]),ft=d.useCallback(s=>{ae(s),St(me.SPOTLIGHT_QUERY,s)},[]);d.useEffect(()=>{t&&(ae(st()),v(0))},[t]),d.useEffect(()=>{if(!t){O([]);return}const s=_.trim();if(s.length<xs){O([]);return}let p=!1;const C=setTimeout(()=>{ys(s).then(w=>{p||O(w)}).catch(()=>{p||O([])})},250);return()=>{p=!0,clearTimeout(C)}},[t,_]);const we=d.useCallback(s=>{D(s),vt(me.SPOTLIGHT_TAB,s)},[]),$e=d.useRef(M);$e.current=M;const gt=d.useCallback(s=>{const p=fe.indexOf($e.current),C=fe[(p+s+fe.length)%fe.length];we(C)},[we]);d.useEffect(()=>{v(0)},[M]);const Se=X.getShortcuts(),ge=d.useMemo(()=>t?Bt():{},[t]),pe=d.useMemo(()=>{if(!t)return[];const s=Se.find(C=>C.id==="spawn-agent"),p=Se.find(C=>C.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:s?Ve(s):"Alt+N",icon:f.jsx(ne,{name:"plus",size:16}),action:()=>{F.current(),T.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:p?Ve(p):"Ctrl+K",icon:f.jsx(ne,{name:"dashboard",size:16}),action:()=>{F.current(),j.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:f.jsx(ne,{name:"gear",size:16}),action:()=>{F.current(),Q.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:f.jsx(ne,{name:"chart-line",size:16}),action:()=>{var C;F.current(),(C=N.current)==null||C.call(N)}}]},[t,Se]),he=d.useMemo(()=>t?Array.from(h.values()).map(s=>{const p=(g||[]).filter(Y=>Y.agentId===s.id).map(Y=>Y.filePath),C=[...new Set(p)],w=C.map(Y=>Y.split("/").pop()||Y),b=[];s.lastAssignedTask&&b.push(s.lastAssignedTask);const L=`${s.class} • ${s.cwd}`;let R=`${s.name} ${s.class} ${s.status} ${s.cwd}`;s.taskLabel&&(R+=` ${s.taskLabel}`),w.length>0&&(R+=` ${w.join(" ")} ${C.join(" ")}`),b.length>0&&(R+=` ${b.join(" ")}`);const P=Date.now()-s.lastActivity;let U;return s.lastAssignedTask&&(s.lastAssignedTask.length>150?U=s.lastAssignedTask.slice(0,150)+"...":U=s.lastAssignedTask),{id:`agent-${s.id}`,type:"agent",title:s.name,subtitle:L,lastUserInput:U,timeAway:P,icon:f.jsx(It,{agent:s,size:20}),_searchText:R,_modifiedFiles:C,_userQueries:b,_agentId:s.id,_lastActivity:s.lastActivity,_taskLabel:s.taskLabel,_status:s.status,action:()=>{F.current(),bt(s.id),X.selectAgent(s.id),X.getState().viewMode!=="flat"&&X.requestTerminalExpand()}}}):[],[t,h,g]),Ae=d.useMemo(()=>t?Array.from(E.values()).map(s=>{var p;return{id:`area-${s.id}`,type:"area",title:s.name,subtitle:`${s.assignedAgentIds.length} agents • ${((p=s.directories)==null?void 0:p.length)||0} folders`,icon:f.jsx(ne,{name:"map",size:16}),action:()=>{F.current(),X.selectArea(s.id)}}}):[],[t,E]),je=d.useMemo(()=>{const s=new Map;for(const p of he)p._agentId&&s.set(p._agentId,p);return s},[he]),Ne=d.useMemo(()=>{const s=new Map;if(!t)return s;for(const p of h.values()){const C=X.getAreaForAgent(p.id);if(!C||C.archived)continue;const w=s.get(C.id);w?w.push(p):s.set(C.id,[p])}return s},[t,h,E]),Pe=d.useMemo(()=>{const s=new Map;for(const p of m)s.has(p.agentId)||s.set(p.agentId,p.timestamp);return s},[m]),ve=d.useMemo(()=>{if(!t)return[];const s=_.trim().toLowerCase(),p=_t({sortMode:Ms(),agentsWithUnseenOutput:S,getLatestToolTimestamp:b=>Pe.get(b)}),C=Array.from(E.values()).filter(b=>!b.archived).filter(b=>s?b.name.toLowerCase().includes(s):!0).sort((b,L)=>b.name.localeCompare(L.name,void 0,{sensitivity:"base"})),w=[];for(const b of C){const R=(Ne.get(b.id)||[]).slice().sort(p).map(P=>je.get(P.id)).filter(P=>!!P);!s&&R.length===0||w.push({areaId:b.id,areaName:b.name,areaColor:b.color,agents:R})}return w},[t,_,E,Ne,je,S,Pe]),ye=d.useMemo(()=>t?Array.from(x.values()).filter(s=>s.type==="server"||s.type==="boss"||s.type==="database").map(s=>{var P,U,Y,ue,ee;const p=s.status==="running"?"#4ade80":s.status==="stopped"?"#f87171":"#facc15",C=s.type==="boss"?"crown":s.type==="database"?"database":"desktop";let b=`${s.type==="boss"?"Boss":s.type==="database"?"Database":"Server"} • ${s.status}`;if(s.type==="database"&&((U=(P=s.database)==null?void 0:P.connections)!=null&&U.length)){const z=s.database.connections[0];b+=` • ${z.engine} @ ${z.host}`}else s.cwd&&(b+=` • ${s.cwd}`);const L=((Y=s.pm2Status)==null?void 0:Y.ports)||[];let R=`${s.name} ${s.type} ${s.status} ${s.cwd||""} ${((ue=s.pm2)==null?void 0:ue.name)||""}`;if(L.length>0&&(R+=` ${L.join(" ")}`),s.type==="database"&&((ee=s.database)!=null&&ee.connections))for(const z of s.database.connections)R+=` ${z.name} ${z.engine} ${z.host} ${z.database||""} mysql postgresql sql`;return{id:`building-${s.id}`,type:"building",title:s.name,subtitle:b,_ports:L,icon:f.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[f.jsx(ne,{name:"status-pending",size:10,weight:"fill",color:p}),f.jsx(ne,{name:C,size:16})]}),_searchText:R,action:()=>{var z;F.current(),s.type==="boss"?ie.current(s.id):s.type==="database"?$.current(s.id):(z=s.pm2)!=null&&z.enabled&&oe.current(s.id)}}}):[],[t,x]),Ke=d.useMemo(()=>{if(!t)return[];const s=g||[],p=new Set,C=[];for(const w of s){if(p.has(w.filePath))continue;p.add(w.filePath);const b=w.filePath.split("/").pop()||w.filePath,L=w.action==="created"?"Created":w.action==="modified"?"Modified":w.action==="deleted"?"Deleted":"Read";if(C.push({id:`modified-${w.filePath}-${w.timestamp}`,type:"modified-file",title:b,subtitle:`${L} by ${w.agentName} • ${w.filePath}`,matchedText:w.filePath,icon:w.action==="deleted"?f.jsx(ne,{name:"trash",size:16}):Dt(w.filePath),action:()=>{F.current();const R=Array.from(X.getState().areas.values());for(const P of R)for(const U of P.directories||[])if(w.filePath.startsWith(U)){X.setFileViewerPath(w.filePath),W.current(P.id);return}X.selectAgent(w.agentId)}}),C.length>=50)break}return C},[t,g]),Oe=d.useMemo(()=>t?J.map(s=>{const p=s.isGitRepo&&s.gitBranch?`${s.path} • ${s.gitBranch}`:s.path;return{id:`folder-${s.path}`,type:"folder",title:s.name,subtitle:p,matchedText:s.path,icon:f.jsx(ne,{name:s.isGitRepo?"git-branch":"folder",size:16}),_searchText:`${s.name} ${s.path}`,_isGitRepo:s.isGitRepo,_gitBranch:s.gitBranch,action:()=>{F.current(),X.openFileExplorer(s.path)}}}):[],[t,J]),ze=d.useMemo(()=>new Z(he,{keys:["title","subtitle","_searchText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[he]),Ge=d.useMemo(()=>new Z(pe,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[pe]),Qe=d.useMemo(()=>new Z(Ae,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[Ae]),We=d.useMemo(()=>new Z(Ke,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Ke]),He=d.useMemo(()=>new Z(ye,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ye]),de=d.useMemo(()=>{if(!_.trim()){const A=[];A.push(...ye);const B=[...he].sort((k,K)=>{const te=Ee(k._agentId,k._lastActivity,ge);return Ee(K._agentId,K._lastActivity,ge)-te});A.push(...B),A.push(...pe.slice(0,2)),A.push(...Ae.slice(0,2));const I={};return Es.forEach((k,K)=>{I[k]=K}),A.sort((k,K)=>(I[k.type]??999)-(I[K.type]??999)),A}const s=_.trim().toLowerCase(),p=ze.search(_).slice(0,8),C=Ge.search(_).slice(0,3),w=Qe.search(_).slice(0,2),b=We.search(_).slice(0,3),L=Oe.slice(0,8),R=He.search(_).filter(A=>{const B=A.score??1;return`${A.item.title} ${A.item.subtitle||""} ${A.item._searchText||""}`.toLowerCase().includes(s)||B<=.2}).slice(0,4),P={agent:6,building:5,folder:4,command:3,area:2,"modified-file":1},U=A=>{if(!s)return 1;const B=A.title.toLowerCase();return B===s?6:B.startsWith(s)?5:B.split(/[^a-z0-9]+/i).includes(s)?4:B.includes(s)?3:`${A.subtitle||""} ${A._searchText||""} ${A.matchedText||""}`.toLowerCase().includes(s)?2:1},Y=(A,B)=>{const I=(1-Math.min(1,B??1))*4;return U(A)*100+(P[A.type]??0)*5+I},ue=new Map,ee=(A,B)=>{const I=ue.get(A.type),k={item:A,score:Y(A,B)};I?I.push(k):ue.set(A.type,[k])};for(const A of p){const B={...A.item};if(B._modifiedFiles&&B._modifiedFiles.length>0){const I=B._modifiedFiles.filter(k=>{var se;const K=((se=k.split("/").pop())==null?void 0:se.toLowerCase())||"",te=k.toLowerCase();return K.includes(s)||te.includes(s)});I.length>0&&(B.matchedFiles=I)}if(B._userQueries&&B._userQueries.length>0){const I=B._userQueries.find(k=>k.toLowerCase().includes(s));if(I)if(I.length>200){const K=I.toLowerCase().indexOf(s),te=Math.max(0,K-60),se=Math.min(I.length,K+s.length+100);B.matchedQuery=(te>0?"...":"")+I.slice(te,se)+(se<I.length?"...":"")}else B.matchedQuery=I}ee(B,A.score)}for(const A of R)ee(A.item,A.score);for(const A of C)ee(A.item,A.score);for(const A of w)ee(A.item,A.score);for(const A of b)ee(A.item,A.score);for(const A of L)ee(A,void 0);for(const[A,B]of ue)A==="agent"?B.sort((I,k)=>{const K=U(I.item),te=U(k.item);if(te!==K)return te-K;const se=Ee(I.item._agentId,I.item._lastActivity,ge),Ye=Ee(k.item._agentId,k.item._lastActivity,ge);return Ye!==se?Ye-se:k.score-I.score}):B.sort((I,k)=>k.score-I.score);const z=A=>A.reduce((B,I)=>Math.max(B,I.score),-1),Ue=[];return Array.from(ue.values()).sort((A,B)=>z(B)-z(A)).forEach(A=>{for(const B of A)Ue.push(B.item)}),Ue},[_,ze,Ge,Qe,We,He,pe,he,Ae,ye,Oe,ge]),V=d.useMemo(()=>{switch(M){case"agents":return de.filter(s=>s.type==="agent");case"buildings":return de.filter(s=>s.type==="building");case"commands":return de.filter(s=>s.type==="command");case"folders":return de.filter(s=>s.type==="folder");case"areas":return ve.flatMap(s=>s.agents);case"all":default:return de}},[M,de,ve]);d.useEffect(()=>{H>=V.length&&v(Math.max(0,V.length-1))},[V.length,H]);const mt=d.useCallback(s=>{if(s.altKey&&!s.ctrlKey&&!s.metaKey&&(s.key==="p"||s.key==="n"||s.key==="P"||s.key==="N")){s.preventDefault(),s.stopPropagation(),s.nativeEvent.stopImmediatePropagation();const p=s.key.toLowerCase();v(p==="p"?C=>C>0?C-1:V.length-1:C=>C<V.length-1?C+1:0);return}switch(s.key){case"Escape":s.preventDefault(),F.current();break;case"ArrowUp":s.preventDefault(),v(p=>p>0?p-1:V.length-1);break;case"ArrowDown":s.preventDefault(),v(p=>p<V.length-1?p+1:0);break;case"Enter":s.preventDefault(),V[H]&&V[H].action();break}},[V,H]),pt=d.useCallback((s,p)=>{if(!p||!s)return s;const C=s.toLowerCase(),w=p.toLowerCase(),b=[];let L=0,R=C.indexOf(w),P=0;for(;R!==-1;)R>L&&b.push(s.slice(L,R)),b.push(Be.createElement("mark",{key:P++,className:"spotlight-highlight"},s.slice(R,R+p.length))),L=R+p.length,R=C.indexOf(w,L);return L<s.length&&b.push(s.slice(L)),b.length>0?Be.createElement(Be.Fragment,null,...b):s},[]);return{query:_,setQuery:ft,selectedIndex:H,setSelectedIndex:v,results:V,activeTab:M,setActiveTab:we,cycleTab:gt,areaSections:ve,handleKeyDown:mt,highlightMatch:pt}}const ws=d.forwardRef(function({query:e,onQueryChange:n,onKeyDown:r,onResetSelection:i},c){const{t:o}=Fe(["common"]);return f.jsxs("div",{className:"spotlight-input-wrapper",children:[f.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),f.jsx("input",{ref:c,type:"text",className:"spotlight-input",placeholder:o("common:search.spotlightPlaceholder"),value:e,onChange:a=>{n(a.target.value),i()},onKeyDown:r,autoFocus:!0,spellCheck:!1}),f.jsxs("div",{className:"spotlight-input-hints",children:[f.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),f.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),f.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Ss=d.memo(function({activeTab:e,onSelect:n}){const{t:r}=Fe(["terminal"]);return f.jsxs("div",{className:"spotlight-tabs",role:"tablist","aria-label":r("terminal:spotlight.tabsLabel"),children:[fe.map(i=>f.jsx("button",{type:"button",role:"tab","aria-selected":i===e,tabIndex:-1,className:`spotlight-tab${i===e?" active":""}`,onClick:()=>n(i),children:r(`terminal:spotlight.tabs.${i}`)},i)),f.jsx("span",{className:"spotlight-tabs-hint",children:f.jsx("kbd",{children:"Tab"})})]})}),vs=d.forwardRef(function({results:e,selectedIndex:n,query:r,activeTab:i,areaSections:c,highlightMatch:o,onSelectIndex:a},u){const{t:l}=Fe(["terminal"]),h=d.useRef(!1);d.useEffect(()=>{h.current=!1},[e]),d.useEffect(()=>{const g=typeof u=="function"?null:u==null?void 0:u.current;if(!g)return;const m=()=>{h.current=!0};return g.addEventListener("mousemove",m),()=>{g.removeEventListener("mousemove",m)}},[u,e]);const E={command:l("terminal:spotlight.categories.commands"),agent:l("terminal:spotlight.categories.agents"),building:l("terminal:spotlight.categories.infrastructure"),area:l("terminal:spotlight.categories.areas"),folder:l("terminal:spotlight.categories.folders"),"modified-file":l("terminal:spotlight.categories.modifiedFiles")},x=d.useMemo(()=>{const g=[];let m=null,S=[];return e.forEach((F,T)=>{F.type!==m&&(m!==null&&S.length>0&&g.push([m,S]),m=F.type,S=[]),S.push({result:F,index:T})}),m!==null&&S.length>0&&g.push([m,S]),g},[e]);if(d.useEffect(()=>{if(!u||typeof u=="function")return;const g=u.current;if(!g)return;const m=g.querySelector(".spotlight-item.selected");m&&m.scrollIntoView({block:"nearest",behavior:"smooth"})},[n,u]),i==="areas"){if(c.length===0)return f.jsx("div",{className:"spotlight-results",ref:u,children:f.jsx("div",{className:"spotlight-empty",children:l("terminal:spotlight.noResults")})});let g=0;return f.jsx("div",{className:"spotlight-results",ref:u,children:c.map(m=>f.jsxs("div",{children:[f.jsxs("div",{className:"spotlight-category-header spotlight-area-section-header",children:[f.jsx("span",{className:"spotlight-area-dot",style:{background:m.areaColor},"aria-hidden":"true"}),f.jsx("span",{className:"spotlight-area-name",children:m.areaName}),f.jsx("span",{className:"spotlight-area-count",children:m.agents.length})]}),m.agents.length===0?f.jsx("div",{className:"spotlight-area-empty",children:l("terminal:spotlight.noAgentsInArea")}):m.agents.map(S=>{const F=g++;return f.jsx(Je,{result:S,isSelected:F===n,query:r,highlightMatch:o,onClick:()=>S.action(),onMouseEnter:()=>{h.current&&a(F)}},S.id)})]},m.areaId))})}return e.length===0?f.jsx("div",{className:"spotlight-results",ref:u,children:f.jsx("div",{className:"spotlight-empty",children:l("terminal:spotlight.noResults")})}):f.jsx("div",{className:"spotlight-results",ref:u,children:x.map(([g,m])=>f.jsxs("div",{children:[x.length>1&&f.jsx("div",{className:"spotlight-category-header",children:E[g]||g}),m.map(({result:S,index:F})=>f.jsx(Je,{result:S,isSelected:F===n,query:r,highlightMatch:o,onClick:()=>S.action(),onMouseEnter:()=>{h.current&&a(F)}},S.id))]},g))})}),Bs=d.memo(function(){const{t:e}=Fe(["terminal"]);return f.jsxs("div",{className:"spotlight-footer",children:[f.jsxs("div",{className:"spotlight-footer-left",children:[f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"↑"}),f.jsx("kbd",{children:"↓"})," ",f.jsx("kbd",{children:"Alt+N"}),f.jsx("kbd",{children:"Alt+P"})," ",e("terminal:spotlight.navigate")]}),f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Enter"})," ",e("terminal:spotlight.select")]}),f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Tab"})," ",e("terminal:spotlight.switchTabs")]})]}),f.jsx("div",{className:"spotlight-footer-right",children:f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Esc"})," ",e("common:buttons.close")]})})]})}),bs=768;function Rs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=d.useRef(null),E=d.useRef(null),x=d.useRef(null),g=d.useRef(0),{query:m,setQuery:S,selectedIndex:F,setSelectedIndex:T,results:j,activeTab:Q,setActiveTab:W,cycleTab:oe,areaSections:ie,handleKeyDown:$,highlightMatch:N}=Fs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l});g.current=j.length;const _=d.useRef(oe);_.current=oe,d.useEffect(()=>{t&&setTimeout(()=>{var v,M;(v=h.current)==null||v.focus(),(M=h.current)==null||M.select()},50)},[t]),d.useEffect(()=>{if(!t)return;const v=window.visualViewport;if(!v||window.innerWidth>bs)return;const M=()=>{const D=E.current;D&&(D.style.height=`${v.height}px`,D.style.top=`${v.offsetTop}px`)};return M(),v.addEventListener("resize",M),v.addEventListener("scroll",M),()=>{v.removeEventListener("resize",M),v.removeEventListener("scroll",M);const D=E.current;D&&(D.style.height="",D.style.top="")}},[t]),d.useEffect(()=>{if(!t)return;const v=M=>{if(M.key==="Escape"){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),e();return}if(M.key==="Tab"){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),_.current(M.shiftKey?-1:1);return}if(M.altKey&&!M.ctrlKey&&!M.metaKey&&(M.key==="n"||M.key==="p"||M.key==="N"||M.key==="P")){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation();const D=M.key.toLowerCase(),J=g.current;T(D==="p"?O=>O>0?O-1:J-1:O=>O<J-1?O+1:0);return}};return window.addEventListener("keydown",v,{capture:!0}),()=>{window.removeEventListener("keydown",v,{capture:!0})}},[t,e]);const ae=d.useCallback(v=>{v.target===v.currentTarget&&e()},[e]),H=d.useCallback(()=>{T(0)},[T]);return t?f.jsx("div",{ref:E,className:"spotlight-overlay",onClick:ae,children:f.jsxs("div",{className:"spotlight-modal",children:[f.jsx(ws,{ref:h,query:m,onQueryChange:S,onKeyDown:$,onResetSelection:H}),f.jsx(Ss,{activeTab:Q,onSelect:W}),f.jsx(vs,{ref:x,results:j,selectedIndex:F,query:m,activeTab:Q,areaSections:ie,highlightMatch:N,onSelectIndex:T}),f.jsx(Bs,{})]})}):null}export{Ls as FILE_ICON_NAMES,Rs as Spotlight,Bs as SpotlightFooter,ws as SpotlightInput,Je as SpotlightItem,vs as SpotlightResults,$s as formatDuration,js as formatRelativeTime,Ns as getAgentIcon,Dt as getFileIconFromPath,Ps as getTypeLabel,Fs as useSpotlightSearch};
|
|
1
|
+
import{h as At,i as yt,at as Et,a1 as xt,a2 as Ct,c2 as Mt,c3 as Ft,aC as wt,r as d,X as St,S as me,c4 as vt,c5 as fe,s as X,c6 as Bt,j as f,I as ne,c7 as Ve,c8 as bt,a6 as It,c9 as _t,ca as Dt,cb as Ee,al as Be,W as Rt,p as nt,u as Fe,cc as Je}from"./main-DWrvyMds.js";import{cd as Ls,ce as $s,cf as js,cg as Ns,ch as Ps}from"./main-DWrvyMds.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function re(t){return Array.isArray?Array.isArray(t):ct(t)==="[object Array]"}function kt(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Tt(t){return t==null?"":kt(t)}function q(t){return typeof t=="string"}function rt(t){return typeof t=="number"}function Lt(t){return t===!0||t===!1||$t(t)&&ct(t)=="[object Boolean]"}function it(t){return typeof t=="object"}function $t(t){return it(t)&&t!==null}function G(t){return t!=null}function be(t){return!t.trim().length}function ct(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const jt="Incorrect 'index' type",Nt=t=>`Invalid value for key ${t}`,Pt=t=>`Pattern length exceeds max of ${t}.`,Kt=t=>`Missing ${t} property in key`,Ot=t=>`Property 'weight' in key '${t}' must be a positive integer`,Xe=Object.prototype.hasOwnProperty;class zt{constructor(e){this._keys=[],this._keyMap={};let n=0;e.forEach(r=>{let i=ot(r);this._keys.push(i),this._keyMap[i.id]=i,n+=i.weight}),this._keys.forEach(r=>{r.weight/=n})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function ot(t){let e=null,n=null,r=null,i=1,c=null;if(q(t)||re(t))r=t,e=Ze(t),n=Ie(t);else{if(!Xe.call(t,"name"))throw new Error(Kt("name"));const o=t.name;if(r=o,Xe.call(t,"weight")&&(i=t.weight,i<=0))throw new Error(Ot(o));e=Ze(o),n=Ie(o),c=t.getFn}return{path:e,id:n,weight:i,src:r,getFn:c}}function Ze(t){return re(t)?t:t.split(".")}function Ie(t){return re(t)?t.join("."):t}function Gt(t,e){let n=[],r=!1;const i=(c,o,a)=>{if(G(c))if(!o[a])n.push(c);else{let u=o[a];const l=c[u];if(!G(l))return;if(a===o.length-1&&(q(l)||rt(l)||Lt(l)))n.push(Tt(l));else if(re(l)){r=!0;for(let h=0,E=l.length;h<E;h+=1)i(l[h],o,a+1)}else o.length&&i(l,o,a+1)}};return i(t,q(e)?e.split("."):e,0),r?n:n[0]}const Qt={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Wt={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,e)=>t.score===e.score?t.idx<e.idx?-1:1:t.score<e.score?-1:1},Ht={location:0,threshold:.6,distance:100},Ut={useExtendedSearch:!1,getFn:Gt,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var y={...Wt,...Qt,...Ht,...Ut};const Yt=/[^ ]+/g;function Vt(t=1,e=3){const n=new Map,r=Math.pow(10,e);return{get(i){const c=i.match(Yt).length;if(n.has(c))return n.get(c);const o=1/Math.pow(c,.5*t),a=parseFloat(Math.round(o*r)/r);return n.set(c,a),a},clear(){n.clear()}}}class Le{constructor({getFn:e=y.getFn,fieldNormWeight:n=y.fieldNormWeight}={}){this.norm=Vt(n,3),this.getFn=e,this.isCreated=!1,this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((n,r)=>{this._keysMap[n.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,q(this.docs[0])?this.docs.forEach((e,n)=>{this._addString(e,n)}):this.docs.forEach((e,n)=>{this._addObject(e,n)}),this.norm.clear())}add(e){const n=this.size();q(e)?this._addString(e,n):this._addObject(e,n)}removeAt(e){this.records.splice(e,1);for(let n=e,r=this.size();n<r;n+=1)this.records[n].i-=1}getValueForItemAtKeyId(e,n){return e[this._keysMap[n]]}size(){return this.records.length}_addString(e,n){if(!G(e)||be(e))return;let r={v:e,i:n,n:this.norm.get(e)};this.records.push(r)}_addObject(e,n){let r={i:n,$:{}};this.keys.forEach((i,c)=>{let o=i.getFn?i.getFn(e):this.getFn(e,i.path);if(G(o)){if(re(o)){let a=[];const u=[{nestedArrIndex:-1,value:o}];for(;u.length;){const{nestedArrIndex:l,value:h}=u.pop();if(G(h))if(q(h)&&!be(h)){let E={v:h,i:l,n:this.norm.get(h)};a.push(E)}else re(h)&&h.forEach((E,x)=>{u.push({nestedArrIndex:x,value:E})})}r.$[c]=a}else if(q(o)&&!be(o)){let a={v:o,n:this.norm.get(o)};r.$[c]=a}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function at(t,e,{getFn:n=y.getFn,fieldNormWeight:r=y.fieldNormWeight}={}){const i=new Le({getFn:n,fieldNormWeight:r});return i.setKeys(t.map(ot)),i.setSources(e),i.create(),i}function Jt(t,{getFn:e=y.getFn,fieldNormWeight:n=y.fieldNormWeight}={}){const{keys:r,records:i}=t,c=new Le({getFn:e,fieldNormWeight:n});return c.setKeys(r),c.setIndexRecords(i),c}function xe(t,{errors:e=0,currentLocation:n=0,expectedLocation:r=0,distance:i=y.distance,ignoreLocation:c=y.ignoreLocation}={}){const o=e/t.length;if(c)return o;const a=Math.abs(r-n);return i?o+a/i:a?1:o}function Xt(t=[],e=y.minMatchCharLength){let n=[],r=-1,i=-1,c=0;for(let o=t.length;c<o;c+=1){let a=t[c];a&&r===-1?r=c:!a&&r!==-1&&(i=c-1,i-r+1>=e&&n.push([r,i]),r=-1)}return t[c-1]&&c-r>=e&&n.push([r,c-1]),n}const le=32;function Zt(t,e,n,{location:r=y.location,distance:i=y.distance,threshold:c=y.threshold,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,includeMatches:u=y.includeMatches,ignoreLocation:l=y.ignoreLocation}={}){if(e.length>le)throw new Error(Pt(le));const h=e.length,E=t.length,x=Math.max(0,Math.min(r,E));let g=c,m=x;const S=a>1||u,F=S?Array(E):[];let T;for(;(T=t.indexOf(e,m))>-1;){let $=xe(e,{currentLocation:T,expectedLocation:x,distance:i,ignoreLocation:l});if(g=Math.min($,g),m=T+h,S){let N=0;for(;N<h;)F[T+N]=1,N+=1}}m=-1;let j=[],Q=1,W=h+E;const oe=1<<h-1;for(let $=0;$<h;$+=1){let N=0,_=W;for(;N<_;)xe(e,{errors:$,currentLocation:x+_,expectedLocation:x,distance:i,ignoreLocation:l})<=g?N=_:W=_,_=Math.floor((W-N)/2+N);W=_;let ae=Math.max(1,x-_+1),H=o?E:Math.min(x+_,E)+h,v=Array(H+2);v[H+1]=(1<<$)-1;for(let D=H;D>=ae;D-=1){let J=D-1,O=n[t.charAt(J)];if(S&&(F[J]=+!!O),v[D]=(v[D+1]<<1|1)&O,$&&(v[D]|=(j[D+1]|j[D])<<1|1|j[D+1]),v[D]&oe&&(Q=xe(e,{errors:$,currentLocation:J,expectedLocation:x,distance:i,ignoreLocation:l}),Q<=g)){if(g=Q,m=J,m<=x)break;ae=Math.max(1,2*x-m)}}if(xe(e,{errors:$+1,currentLocation:x,expectedLocation:x,distance:i,ignoreLocation:l})>g)break;j=v}const ie={isMatch:m>=0,score:Math.max(.001,Q)};if(S){const $=Xt(F,a);$.length?u&&(ie.indices=$):ie.isMatch=!1}return ie}function qt(t){let e={};for(let n=0,r=t.length;n<r;n+=1){const i=t.charAt(n);e[i]=(e[i]||0)|1<<r-n-1}return e}const Ce=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class ut{constructor(e,{location:n=y.location,threshold:r=y.threshold,distance:i=y.distance,includeMatches:c=y.includeMatches,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,isCaseSensitive:u=y.isCaseSensitive,ignoreDiacritics:l=y.ignoreDiacritics,ignoreLocation:h=y.ignoreLocation}={}){if(this.options={location:n,threshold:r,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h},e=u?e:e.toLowerCase(),e=l?Ce(e):e,this.pattern=e,this.chunks=[],!this.pattern.length)return;const E=(g,m)=>{this.chunks.push({pattern:g,alphabet:qt(g),startIndex:m})},x=this.pattern.length;if(x>le){let g=0;const m=x%le,S=x-m;for(;g<S;)E(this.pattern.substr(g,le),g),g+=le;if(m){const F=x-le;E(this.pattern.substr(F),F)}}else E(this.pattern,0)}searchIn(e){const{isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i}=this.options;if(e=n?e:e.toLowerCase(),e=r?Ce(e):e,this.pattern===e){let S={isMatch:!0,score:0};return i&&(S.indices=[[0,e.length-1]]),S}const{location:c,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:h}=this.options;let E=[],x=0,g=!1;this.chunks.forEach(({pattern:S,alphabet:F,startIndex:T})=>{const{isMatch:j,score:Q,indices:W}=Zt(e,S,F,{location:c+T,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:i,ignoreLocation:h});j&&(g=!0),x+=Q,j&&W&&(E=[...E,...W])});let m={isMatch:g,score:g?x/this.chunks.length:1};return g&&i&&(m.indices=E),m}}class ce{constructor(e){this.pattern=e}static isMultiMatch(e){return qe(e,this.multiRegex)}static isSingleMatch(e){return qe(e,this.singleRegex)}search(){}}function qe(t,e){const n=t.match(e);return n?n[1]:null}class es extends ce{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const n=e===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class ts extends ce{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const r=e.indexOf(this.pattern)===-1;return{isMatch:r,score:r?0:1,indices:[0,e.length-1]}}}class ss extends ce{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const n=e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class ns extends ce{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const n=!e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class rs extends ce{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const n=e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class is extends ce{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const n=!e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class lt extends ce{constructor(e,{location:n=y.location,threshold:r=y.threshold,distance:i=y.distance,includeMatches:c=y.includeMatches,findAllMatches:o=y.findAllMatches,minMatchCharLength:a=y.minMatchCharLength,isCaseSensitive:u=y.isCaseSensitive,ignoreDiacritics:l=y.ignoreDiacritics,ignoreLocation:h=y.ignoreLocation}={}){super(e),this._bitapSearch=new ut(e,{location:n,threshold:r,distance:i,includeMatches:c,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:u,ignoreDiacritics:l,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ht extends ce{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let n=0,r;const i=[],c=this.pattern.length;for(;(r=e.indexOf(this.pattern,n))>-1;)n=r+c,i.push([r,n-1]);const o=!!i.length;return{isMatch:o,score:o?0:1,indices:i}}}const _e=[es,ht,ss,ns,is,rs,ts,lt],et=_e.length,cs=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,os="|";function as(t,e={}){return t.split(os).map(n=>{let r=n.trim().split(cs).filter(c=>c&&!!c.trim()),i=[];for(let c=0,o=r.length;c<o;c+=1){const a=r[c];let u=!1,l=-1;for(;!u&&++l<et;){const h=_e[l];let E=h.isMultiMatch(a);E&&(i.push(new h(E,e)),u=!0)}if(!u)for(l=-1;++l<et;){const h=_e[l];let E=h.isSingleMatch(a);if(E){i.push(new h(E,e));break}}}return i})}const us=new Set([lt.type,ht.type]);class ls{constructor(e,{isCaseSensitive:n=y.isCaseSensitive,ignoreDiacritics:r=y.ignoreDiacritics,includeMatches:i=y.includeMatches,minMatchCharLength:c=y.minMatchCharLength,ignoreLocation:o=y.ignoreLocation,findAllMatches:a=y.findAllMatches,location:u=y.location,threshold:l=y.threshold,distance:h=y.distance}={}){this.query=null,this.options={isCaseSensitive:n,ignoreDiacritics:r,includeMatches:i,minMatchCharLength:c,findAllMatches:a,ignoreLocation:o,location:u,threshold:l,distance:h},e=n?e:e.toLowerCase(),e=r?Ce(e):e,this.pattern=e,this.query=as(this.pattern,this.options)}static condition(e,n){return n.useExtendedSearch}searchIn(e){const n=this.query;if(!n)return{isMatch:!1,score:1};const{includeMatches:r,isCaseSensitive:i,ignoreDiacritics:c}=this.options;e=i?e:e.toLowerCase(),e=c?Ce(e):e;let o=0,a=[],u=0;for(let l=0,h=n.length;l<h;l+=1){const E=n[l];a.length=0,o=0;for(let x=0,g=E.length;x<g;x+=1){const m=E[x],{isMatch:S,indices:F,score:T}=m.search(e);if(S){if(o+=1,u+=T,r){const j=m.constructor.type;us.has(j)?a=[...a,...F]:a.push(F)}}else{u=0,o=0,a.length=0;break}}if(o){let x={isMatch:!0,score:u/o};return r&&(x.indices=a),x}}return{isMatch:!1,score:1}}}const De=[];function hs(...t){De.push(...t)}function Re(t,e){for(let n=0,r=De.length;n<r;n+=1){let i=De[n];if(i.condition(t,e))return new i(t,e)}return new ut(t,e)}const Me={AND:"$and",OR:"$or"},ke={PATH:"$path",PATTERN:"$val"},Te=t=>!!(t[Me.AND]||t[Me.OR]),ds=t=>!!t[ke.PATH],fs=t=>!re(t)&&it(t)&&!Te(t),tt=t=>({[Me.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function dt(t,e,{auto:n=!0}={}){const r=i=>{let c=Object.keys(i);const o=ds(i);if(!o&&c.length>1&&!Te(i))return r(tt(i));if(fs(i)){const u=o?i[ke.PATH]:c[0],l=o?i[ke.PATTERN]:i[u];if(!q(l))throw new Error(Nt(u));const h={keyId:Ie(u),pattern:l};return n&&(h.searcher=Re(l,e)),h}let a={children:[],operator:c[0]};return c.forEach(u=>{const l=i[u];re(l)&&l.forEach(h=>{a.children.push(r(h))})}),a};return Te(t)||(t=tt(t)),r(t)}function gs(t,{ignoreFieldNorm:e=y.ignoreFieldNorm}){t.forEach(n=>{let r=1;n.matches.forEach(({key:i,norm:c,score:o})=>{const a=i?i.weight:null;r*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(e?1:c))}),n.score=r})}function ms(t,e){const n=t.matches;e.matches=[],G(n)&&n.forEach(r=>{if(!G(r.indices)||!r.indices.length)return;const{indices:i,value:c}=r;let o={indices:i,value:c};r.key&&(o.key=r.key.src),r.idx>-1&&(o.refIndex=r.idx),e.matches.push(o)})}function ps(t,e){e.score=t.score}function As(t,e,{includeMatches:n=y.includeMatches,includeScore:r=y.includeScore}={}){const i=[];return n&&i.push(ms),r&&i.push(ps),t.map(c=>{const{idx:o}=c,a={item:e[o],refIndex:o};return i.length&&i.forEach(u=>{u(c,a)}),a})}class Z{constructor(e,n={},r){this.options={...y,...n},this.options.useExtendedSearch,this._keyStore=new zt(this.options.keys),this.setCollection(e,r)}setCollection(e,n){if(this._docs=e,n&&!(n instanceof Le))throw new Error(jt);this._myIndex=n||at(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){G(e)&&(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const n=[];for(let r=0,i=this._docs.length;r<i;r+=1){const c=this._docs[r];e(c,r)&&(this.removeAt(r),r-=1,i-=1,n.push(c))}return n}removeAt(e){this._docs.splice(e,1),this._myIndex.removeAt(e)}getIndex(){return this._myIndex}search(e,{limit:n=-1}={}){const{includeMatches:r,includeScore:i,shouldSort:c,sortFn:o,ignoreFieldNorm:a}=this.options;let u=q(e)?q(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return gs(u,{ignoreFieldNorm:a}),c&&u.sort(o),rt(n)&&n>-1&&(u=u.slice(0,n)),As(u,this._docs,{includeMatches:r,includeScore:i})}_searchStringList(e){const n=Re(e,this.options),{records:r}=this._myIndex,i=[];return r.forEach(({v:c,i:o,n:a})=>{if(!G(c))return;const{isMatch:u,score:l,indices:h}=n.searchIn(c);u&&i.push({item:c,idx:o,matches:[{score:l,value:c,norm:a,indices:h}]})}),i}_searchLogical(e){const n=dt(e,this.options),r=(a,u,l)=>{if(!a.children){const{keyId:E,searcher:x}=a,g=this._findMatches({key:this._keyStore.get(E),value:this._myIndex.getValueForItemAtKeyId(u,E),searcher:x});return g&&g.length?[{idx:l,item:u,matches:g}]:[]}const h=[];for(let E=0,x=a.children.length;E<x;E+=1){const g=a.children[E],m=r(g,u,l);if(m.length)h.push(...m);else if(a.operator===Me.AND)return[]}return h},i=this._myIndex.records,c={},o=[];return i.forEach(({$:a,i:u})=>{if(G(a)){let l=r(n,a,u);l.length&&(c[u]||(c[u]={idx:u,item:a,matches:[]},o.push(c[u])),l.forEach(({matches:h})=>{c[u].matches.push(...h)}))}}),o}_searchObjectList(e){const n=Re(e,this.options),{keys:r,records:i}=this._myIndex,c=[];return i.forEach(({$:o,i:a})=>{if(!G(o))return;let u=[];r.forEach((l,h)=>{u.push(...this._findMatches({key:l,value:o[h],searcher:n}))}),u.length&&c.push({idx:a,item:o,matches:u})}),c}_findMatches({key:e,value:n,searcher:r}){if(!G(n))return[];let i=[];if(re(n))n.forEach(({v:c,i:o,n:a})=>{if(!G(c))return;const{isMatch:u,score:l,indices:h}=r.searchIn(c);u&&i.push({score:l,key:e,value:c,idx:o,norm:a,indices:h})});else{const{v:c,n:o}=n,{isMatch:a,score:u,indices:l}=r.searchIn(c);a&&i.push({score:u,key:e,value:c,norm:o,indices:l})}return i}}Z.version="7.1.0";Z.createIndex=at;Z.parseIndex=Jt;Z.config=y;Z.parseQuery=dt;hs(ls);async function ys(t){const e=new URLSearchParams({q:t}),n=await At(yt(`/api/folders/search?${e.toString()}`));if(!n.ok){const i=await n.json().catch(()=>({}));throw new Error(i.error||`Failed to search folders: ${n.statusText}`)}const r=await n.json();return Array.isArray(r.folders)?r.folders:[]}const Es=["command","agent","building","area","folder","modified-file"],xs=2;function Cs(){const t=nt(me.SPOTLIGHT_TAB,"all");return fe.includes(t)?t:"all"}function st(){return Rt(me.SPOTLIGHT_QUERY,"")}function Ms(){const t=nt(me.AOP_CONFIG,{});return t.sortMode==="name"||t.sortMode==="status"||t.sortMode==="recent"?t.sortMode:"recent"}function Fs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=Et(),E=xt(),x=Ct(),g=Mt(),m=Ft(),S=wt(),F=d.useRef(e);F.current=e;const T=d.useRef(n);T.current=n;const j=d.useRef(r);j.current=r;const Q=d.useRef(i);Q.current=i;const W=d.useRef(c);W.current=c;const oe=d.useRef(o);oe.current=o;const ie=d.useRef(a);ie.current=a;const $=d.useRef(u);$.current=u;const N=d.useRef(l);N.current=l;const[_,ae]=d.useState(st),[H,v]=d.useState(0),[M,D]=d.useState(Cs),[J,O]=d.useState([]),ft=d.useCallback(s=>{ae(s),St(me.SPOTLIGHT_QUERY,s)},[]);d.useEffect(()=>{t&&(ae(st()),v(0))},[t]),d.useEffect(()=>{if(!t){O([]);return}const s=_.trim();if(s.length<xs){O([]);return}let p=!1;const C=setTimeout(()=>{ys(s).then(w=>{p||O(w)}).catch(()=>{p||O([])})},250);return()=>{p=!0,clearTimeout(C)}},[t,_]);const we=d.useCallback(s=>{D(s),vt(me.SPOTLIGHT_TAB,s)},[]),$e=d.useRef(M);$e.current=M;const gt=d.useCallback(s=>{const p=fe.indexOf($e.current),C=fe[(p+s+fe.length)%fe.length];we(C)},[we]);d.useEffect(()=>{v(0)},[M]);const Se=X.getShortcuts(),ge=d.useMemo(()=>t?Bt():{},[t]),pe=d.useMemo(()=>{if(!t)return[];const s=Se.find(C=>C.id==="spawn-agent"),p=Se.find(C=>C.id==="toggle-commander");return[{id:"cmd-spawn",type:"command",title:"Spawn New Agent",subtitle:s?Ve(s):"Alt+N",icon:f.jsx(ne,{name:"plus",size:16}),action:()=>{F.current(),T.current()}},{id:"cmd-commander",type:"command",title:"Commander View",subtitle:p?Ve(p):"Ctrl+K",icon:f.jsx(ne,{name:"dashboard",size:16}),action:()=>{F.current(),j.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:f.jsx(ne,{name:"gear",size:16}),action:()=>{F.current(),Q.current()}},{id:"cmd-monitoring",type:"command",title:"Monitoring & Logs",subtitle:"Triggers, workflows, events",icon:f.jsx(ne,{name:"chart-line",size:16}),action:()=>{var C;F.current(),(C=N.current)==null||C.call(N)}}]},[t,Se]),he=d.useMemo(()=>t?Array.from(h.values()).map(s=>{const p=(g||[]).filter(Y=>Y.agentId===s.id).map(Y=>Y.filePath),C=[...new Set(p)],w=C.map(Y=>Y.split("/").pop()||Y),b=[];s.lastAssignedTask&&b.push(s.lastAssignedTask);const L=`${s.class} • ${s.cwd}`;let R=`${s.name} ${s.class} ${s.status} ${s.cwd}`;s.taskLabel&&(R+=` ${s.taskLabel}`),w.length>0&&(R+=` ${w.join(" ")} ${C.join(" ")}`),b.length>0&&(R+=` ${b.join(" ")}`);const P=Date.now()-s.lastActivity;let U;return s.lastAssignedTask&&(s.lastAssignedTask.length>150?U=s.lastAssignedTask.slice(0,150)+"...":U=s.lastAssignedTask),{id:`agent-${s.id}`,type:"agent",title:s.name,subtitle:L,lastUserInput:U,timeAway:P,icon:f.jsx(It,{agent:s,size:20}),_searchText:R,_modifiedFiles:C,_userQueries:b,_agentId:s.id,_lastActivity:s.lastActivity,_taskLabel:s.taskLabel,_status:s.status,action:()=>{F.current(),bt(s.id),X.selectAgent(s.id),X.getState().viewMode!=="flat"&&X.requestTerminalExpand()}}}):[],[t,h,g]),Ae=d.useMemo(()=>t?Array.from(E.values()).map(s=>{var p;return{id:`area-${s.id}`,type:"area",title:s.name,subtitle:`${s.assignedAgentIds.length} agents • ${((p=s.directories)==null?void 0:p.length)||0} folders`,icon:f.jsx(ne,{name:"map",size:16}),action:()=>{F.current(),X.selectArea(s.id)}}}):[],[t,E]),je=d.useMemo(()=>{const s=new Map;for(const p of he)p._agentId&&s.set(p._agentId,p);return s},[he]),Ne=d.useMemo(()=>{const s=new Map;if(!t)return s;for(const p of h.values()){const C=X.getAreaForAgent(p.id);if(!C||C.archived)continue;const w=s.get(C.id);w?w.push(p):s.set(C.id,[p])}return s},[t,h,E]),Pe=d.useMemo(()=>{const s=new Map;for(const p of m)s.has(p.agentId)||s.set(p.agentId,p.timestamp);return s},[m]),ve=d.useMemo(()=>{if(!t)return[];const s=_.trim().toLowerCase(),p=_t({sortMode:Ms(),agentsWithUnseenOutput:S,getLatestToolTimestamp:b=>Pe.get(b)}),C=Array.from(E.values()).filter(b=>!b.archived).filter(b=>s?b.name.toLowerCase().includes(s):!0).sort((b,L)=>b.name.localeCompare(L.name,void 0,{sensitivity:"base"})),w=[];for(const b of C){const R=(Ne.get(b.id)||[]).slice().sort(p).map(P=>je.get(P.id)).filter(P=>!!P);!s&&R.length===0||w.push({areaId:b.id,areaName:b.name,areaColor:b.color,agents:R})}return w},[t,_,E,Ne,je,S,Pe]),ye=d.useMemo(()=>t?Array.from(x.values()).filter(s=>s.type==="server"||s.type==="boss"||s.type==="database").map(s=>{var P,U,Y,ue,ee;const p=s.status==="running"?"#4ade80":s.status==="stopped"?"#f87171":"#facc15",C=s.type==="boss"?"crown":s.type==="database"?"database":"desktop";let b=`${s.type==="boss"?"Boss":s.type==="database"?"Database":"Server"} • ${s.status}`;if(s.type==="database"&&((U=(P=s.database)==null?void 0:P.connections)!=null&&U.length)){const z=s.database.connections[0];b+=` • ${z.engine} @ ${z.host}`}else s.cwd&&(b+=` • ${s.cwd}`);const L=((Y=s.pm2Status)==null?void 0:Y.ports)||[];let R=`${s.name} ${s.type} ${s.status} ${s.cwd||""} ${((ue=s.pm2)==null?void 0:ue.name)||""}`;if(L.length>0&&(R+=` ${L.join(" ")}`),s.type==="database"&&((ee=s.database)!=null&&ee.connections))for(const z of s.database.connections)R+=` ${z.name} ${z.engine} ${z.host} ${z.database||""} mysql postgresql sql`;return{id:`building-${s.id}`,type:"building",title:s.name,subtitle:b,_ports:L,icon:f.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[f.jsx(ne,{name:"status-pending",size:10,weight:"fill",color:p}),f.jsx(ne,{name:C,size:16})]}),_searchText:R,action:()=>{var z;F.current(),s.type==="boss"?ie.current(s.id):s.type==="database"?$.current(s.id):(z=s.pm2)!=null&&z.enabled&&oe.current(s.id)}}}):[],[t,x]),Ke=d.useMemo(()=>{if(!t)return[];const s=g||[],p=new Set,C=[];for(const w of s){if(p.has(w.filePath))continue;p.add(w.filePath);const b=w.filePath.split("/").pop()||w.filePath,L=w.action==="created"?"Created":w.action==="modified"?"Modified":w.action==="deleted"?"Deleted":"Read";if(C.push({id:`modified-${w.filePath}-${w.timestamp}`,type:"modified-file",title:b,subtitle:`${L} by ${w.agentName} • ${w.filePath}`,matchedText:w.filePath,icon:w.action==="deleted"?f.jsx(ne,{name:"trash",size:16}):Dt(w.filePath),action:()=>{F.current();const R=Array.from(X.getState().areas.values());for(const P of R)for(const U of P.directories||[])if(w.filePath.startsWith(U)){X.setFileViewerPath(w.filePath),W.current(P.id);return}X.selectAgent(w.agentId)}}),C.length>=50)break}return C},[t,g]),Oe=d.useMemo(()=>t?J.map(s=>{const p=s.isGitRepo&&s.gitBranch?`${s.path} • ${s.gitBranch}`:s.path;return{id:`folder-${s.path}`,type:"folder",title:s.name,subtitle:p,matchedText:s.path,icon:f.jsx(ne,{name:s.isGitRepo?"git-branch":"folder",size:16}),_searchText:`${s.name} ${s.path}`,_isGitRepo:s.isGitRepo,_gitBranch:s.gitBranch,action:()=>{F.current(),X.openFileExplorer(s.path)}}}):[],[t,J]),ze=d.useMemo(()=>new Z(he,{keys:["title","subtitle","_searchText","lastUserInput"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[he]),Ge=d.useMemo(()=>new Z(pe,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[pe]),Qe=d.useMemo(()=>new Z(Ae,{keys:["title","subtitle"],threshold:.4,includeScore:!0,includeMatches:!0}),[Ae]),We=d.useMemo(()=>new Z(Ke,{keys:["title","subtitle","matchedText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[Ke]),He=d.useMemo(()=>new Z(ye,{keys:["title","subtitle","_searchText"],threshold:.4,ignoreLocation:!0,includeScore:!0,includeMatches:!0}),[ye]),de=d.useMemo(()=>{if(!_.trim()){const A=[];A.push(...ye);const B=[...he].sort((k,K)=>{const te=Ee(k._agentId,k._lastActivity,ge);return Ee(K._agentId,K._lastActivity,ge)-te});A.push(...B),A.push(...pe.slice(0,2)),A.push(...Ae.slice(0,2));const I={};return Es.forEach((k,K)=>{I[k]=K}),A.sort((k,K)=>(I[k.type]??999)-(I[K.type]??999)),A}const s=_.trim().toLowerCase(),p=ze.search(_).slice(0,8),C=Ge.search(_).slice(0,3),w=Qe.search(_).slice(0,2),b=We.search(_).slice(0,3),L=Oe.slice(0,8),R=He.search(_).filter(A=>{const B=A.score??1;return`${A.item.title} ${A.item.subtitle||""} ${A.item._searchText||""}`.toLowerCase().includes(s)||B<=.2}).slice(0,4),P={agent:6,building:5,folder:4,command:3,area:2,"modified-file":1},U=A=>{if(!s)return 1;const B=A.title.toLowerCase();return B===s?6:B.startsWith(s)?5:B.split(/[^a-z0-9]+/i).includes(s)?4:B.includes(s)?3:`${A.subtitle||""} ${A._searchText||""} ${A.matchedText||""}`.toLowerCase().includes(s)?2:1},Y=(A,B)=>{const I=(1-Math.min(1,B??1))*4;return U(A)*100+(P[A.type]??0)*5+I},ue=new Map,ee=(A,B)=>{const I=ue.get(A.type),k={item:A,score:Y(A,B)};I?I.push(k):ue.set(A.type,[k])};for(const A of p){const B={...A.item};if(B._modifiedFiles&&B._modifiedFiles.length>0){const I=B._modifiedFiles.filter(k=>{var se;const K=((se=k.split("/").pop())==null?void 0:se.toLowerCase())||"",te=k.toLowerCase();return K.includes(s)||te.includes(s)});I.length>0&&(B.matchedFiles=I)}if(B._userQueries&&B._userQueries.length>0){const I=B._userQueries.find(k=>k.toLowerCase().includes(s));if(I)if(I.length>200){const K=I.toLowerCase().indexOf(s),te=Math.max(0,K-60),se=Math.min(I.length,K+s.length+100);B.matchedQuery=(te>0?"...":"")+I.slice(te,se)+(se<I.length?"...":"")}else B.matchedQuery=I}ee(B,A.score)}for(const A of R)ee(A.item,A.score);for(const A of C)ee(A.item,A.score);for(const A of w)ee(A.item,A.score);for(const A of b)ee(A.item,A.score);for(const A of L)ee(A,void 0);for(const[A,B]of ue)A==="agent"?B.sort((I,k)=>{const K=U(I.item),te=U(k.item);if(te!==K)return te-K;const se=Ee(I.item._agentId,I.item._lastActivity,ge),Ye=Ee(k.item._agentId,k.item._lastActivity,ge);return Ye!==se?Ye-se:k.score-I.score}):B.sort((I,k)=>k.score-I.score);const z=A=>A.reduce((B,I)=>Math.max(B,I.score),-1),Ue=[];return Array.from(ue.values()).sort((A,B)=>z(B)-z(A)).forEach(A=>{for(const B of A)Ue.push(B.item)}),Ue},[_,ze,Ge,Qe,We,He,pe,he,Ae,ye,Oe,ge]),V=d.useMemo(()=>{switch(M){case"agents":return de.filter(s=>s.type==="agent");case"buildings":return de.filter(s=>s.type==="building");case"commands":return de.filter(s=>s.type==="command");case"folders":return de.filter(s=>s.type==="folder");case"areas":return ve.flatMap(s=>s.agents);case"all":default:return de}},[M,de,ve]);d.useEffect(()=>{H>=V.length&&v(Math.max(0,V.length-1))},[V.length,H]);const mt=d.useCallback(s=>{if(s.altKey&&!s.ctrlKey&&!s.metaKey&&(s.key==="p"||s.key==="n"||s.key==="P"||s.key==="N")){s.preventDefault(),s.stopPropagation(),s.nativeEvent.stopImmediatePropagation();const p=s.key.toLowerCase();v(p==="p"?C=>C>0?C-1:V.length-1:C=>C<V.length-1?C+1:0);return}switch(s.key){case"Escape":s.preventDefault(),F.current();break;case"ArrowUp":s.preventDefault(),v(p=>p>0?p-1:V.length-1);break;case"ArrowDown":s.preventDefault(),v(p=>p<V.length-1?p+1:0);break;case"Enter":s.preventDefault(),V[H]&&V[H].action();break}},[V,H]),pt=d.useCallback((s,p)=>{if(!p||!s)return s;const C=s.toLowerCase(),w=p.toLowerCase(),b=[];let L=0,R=C.indexOf(w),P=0;for(;R!==-1;)R>L&&b.push(s.slice(L,R)),b.push(Be.createElement("mark",{key:P++,className:"spotlight-highlight"},s.slice(R,R+p.length))),L=R+p.length,R=C.indexOf(w,L);return L<s.length&&b.push(s.slice(L)),b.length>0?Be.createElement(Be.Fragment,null,...b):s},[]);return{query:_,setQuery:ft,selectedIndex:H,setSelectedIndex:v,results:V,activeTab:M,setActiveTab:we,cycleTab:gt,areaSections:ve,handleKeyDown:mt,highlightMatch:pt}}const ws=d.forwardRef(function({query:e,onQueryChange:n,onKeyDown:r,onResetSelection:i},c){const{t:o}=Fe(["common"]);return f.jsxs("div",{className:"spotlight-input-wrapper",children:[f.jsx("span",{className:"spotlight-search-icon",children:"⌘"}),f.jsx("input",{ref:c,type:"text",className:"spotlight-input",placeholder:o("common:search.spotlightPlaceholder"),value:e,onChange:a=>{n(a.target.value),i()},onKeyDown:r,autoFocus:!0,spellCheck:!1}),f.jsxs("div",{className:"spotlight-input-hints",children:[f.jsx("span",{className:"spotlight-shortcut-hint",children:"↑↓"}),f.jsx("span",{className:"spotlight-shortcut-hint",children:"Enter"}),f.jsx("span",{className:"spotlight-shortcut-hint",children:"Esc"})]})]})}),Ss=d.memo(function({activeTab:e,onSelect:n}){const{t:r}=Fe(["terminal"]);return f.jsxs("div",{className:"spotlight-tabs",role:"tablist","aria-label":r("terminal:spotlight.tabsLabel"),children:[fe.map(i=>f.jsx("button",{type:"button",role:"tab","aria-selected":i===e,tabIndex:-1,className:`spotlight-tab${i===e?" active":""}`,onClick:()=>n(i),children:r(`terminal:spotlight.tabs.${i}`)},i)),f.jsx("span",{className:"spotlight-tabs-hint",children:f.jsx("kbd",{children:"Tab"})})]})}),vs=d.forwardRef(function({results:e,selectedIndex:n,query:r,activeTab:i,areaSections:c,highlightMatch:o,onSelectIndex:a},u){const{t:l}=Fe(["terminal"]),h=d.useRef(!1);d.useEffect(()=>{h.current=!1},[e]),d.useEffect(()=>{const g=typeof u=="function"?null:u==null?void 0:u.current;if(!g)return;const m=()=>{h.current=!0};return g.addEventListener("mousemove",m),()=>{g.removeEventListener("mousemove",m)}},[u,e]);const E={command:l("terminal:spotlight.categories.commands"),agent:l("terminal:spotlight.categories.agents"),building:l("terminal:spotlight.categories.infrastructure"),area:l("terminal:spotlight.categories.areas"),folder:l("terminal:spotlight.categories.folders"),"modified-file":l("terminal:spotlight.categories.modifiedFiles")},x=d.useMemo(()=>{const g=[];let m=null,S=[];return e.forEach((F,T)=>{F.type!==m&&(m!==null&&S.length>0&&g.push([m,S]),m=F.type,S=[]),S.push({result:F,index:T})}),m!==null&&S.length>0&&g.push([m,S]),g},[e]);if(d.useEffect(()=>{if(!u||typeof u=="function")return;const g=u.current;if(!g)return;const m=g.querySelector(".spotlight-item.selected");m&&m.scrollIntoView({block:"nearest",behavior:"smooth"})},[n,u]),i==="areas"){if(c.length===0)return f.jsx("div",{className:"spotlight-results",ref:u,children:f.jsx("div",{className:"spotlight-empty",children:l("terminal:spotlight.noResults")})});let g=0;return f.jsx("div",{className:"spotlight-results",ref:u,children:c.map(m=>f.jsxs("div",{children:[f.jsxs("div",{className:"spotlight-category-header spotlight-area-section-header",children:[f.jsx("span",{className:"spotlight-area-dot",style:{background:m.areaColor},"aria-hidden":"true"}),f.jsx("span",{className:"spotlight-area-name",children:m.areaName}),f.jsx("span",{className:"spotlight-area-count",children:m.agents.length})]}),m.agents.length===0?f.jsx("div",{className:"spotlight-area-empty",children:l("terminal:spotlight.noAgentsInArea")}):m.agents.map(S=>{const F=g++;return f.jsx(Je,{result:S,isSelected:F===n,query:r,highlightMatch:o,onClick:()=>S.action(),onMouseEnter:()=>{h.current&&a(F)}},S.id)})]},m.areaId))})}return e.length===0?f.jsx("div",{className:"spotlight-results",ref:u,children:f.jsx("div",{className:"spotlight-empty",children:l("terminal:spotlight.noResults")})}):f.jsx("div",{className:"spotlight-results",ref:u,children:x.map(([g,m])=>f.jsxs("div",{children:[x.length>1&&f.jsx("div",{className:"spotlight-category-header",children:E[g]||g}),m.map(({result:S,index:F})=>f.jsx(Je,{result:S,isSelected:F===n,query:r,highlightMatch:o,onClick:()=>S.action(),onMouseEnter:()=>{h.current&&a(F)}},S.id))]},g))})}),Bs=d.memo(function(){const{t:e}=Fe(["terminal"]);return f.jsxs("div",{className:"spotlight-footer",children:[f.jsxs("div",{className:"spotlight-footer-left",children:[f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"↑"}),f.jsx("kbd",{children:"↓"})," ",f.jsx("kbd",{children:"Alt+N"}),f.jsx("kbd",{children:"Alt+P"})," ",e("terminal:spotlight.navigate")]}),f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Enter"})," ",e("terminal:spotlight.select")]}),f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Tab"})," ",e("terminal:spotlight.switchTabs")]})]}),f.jsx("div",{className:"spotlight-footer-right",children:f.jsxs("span",{className:"spotlight-footer-hint",children:[f.jsx("kbd",{children:"Esc"})," ",e("common:buttons.close")]})})]})}),bs=768;function Rs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=d.useRef(null),E=d.useRef(null),x=d.useRef(null),g=d.useRef(0),{query:m,setQuery:S,selectedIndex:F,setSelectedIndex:T,results:j,activeTab:Q,setActiveTab:W,cycleTab:oe,areaSections:ie,handleKeyDown:$,highlightMatch:N}=Fs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:i,onOpenFileExplorer:c,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l});g.current=j.length;const _=d.useRef(oe);_.current=oe,d.useEffect(()=>{t&&setTimeout(()=>{var v,M;(v=h.current)==null||v.focus(),(M=h.current)==null||M.select()},50)},[t]),d.useEffect(()=>{if(!t)return;const v=window.visualViewport;if(!v||window.innerWidth>bs)return;const M=()=>{const D=E.current;D&&(D.style.height=`${v.height}px`,D.style.top=`${v.offsetTop}px`)};return M(),v.addEventListener("resize",M),v.addEventListener("scroll",M),()=>{v.removeEventListener("resize",M),v.removeEventListener("scroll",M);const D=E.current;D&&(D.style.height="",D.style.top="")}},[t]),d.useEffect(()=>{if(!t)return;const v=M=>{if(M.key==="Escape"){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),e();return}if(M.key==="Tab"){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),_.current(M.shiftKey?-1:1);return}if(M.altKey&&!M.ctrlKey&&!M.metaKey&&(M.key==="n"||M.key==="p"||M.key==="N"||M.key==="P")){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation();const D=M.key.toLowerCase(),J=g.current;T(D==="p"?O=>O>0?O-1:J-1:O=>O<J-1?O+1:0);return}};return window.addEventListener("keydown",v,{capture:!0}),()=>{window.removeEventListener("keydown",v,{capture:!0})}},[t,e]);const ae=d.useCallback(v=>{v.target===v.currentTarget&&e()},[e]),H=d.useCallback(()=>{T(0)},[T]);return t?f.jsx("div",{ref:E,className:"spotlight-overlay",onClick:ae,children:f.jsxs("div",{className:"spotlight-modal",children:[f.jsx(ws,{ref:h,query:m,onQueryChange:S,onKeyDown:$,onResetSelection:H}),f.jsx(Ss,{activeTab:Q,onSelect:W}),f.jsx(vs,{ref:x,results:j,selectedIndex:F,query:m,activeTab:Q,areaSections:ie,highlightMatch:N,onSelectIndex:T}),f.jsx(Bs,{})]})}):null}export{Ls as FILE_ICON_NAMES,Rs as Spotlight,Bs as SpotlightFooter,ws as SpotlightInput,Je as SpotlightItem,vs as SpotlightResults,$s as formatDuration,js as formatRelativeTime,Ns as getAgentIcon,Dt as getFileIconFromPath,Ps as getTypeLabel,Fs as useSpotlightSearch};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{bv as Oe,r as t,s as I,i as ye,bw as Ee,h as _e,j as e,I as z,u as fe,bx as ze,by as Pe,bz as Be,bA as Ue,n as We,bB as Ke,bC as De,bD as Ve,af as Ge,ag as qe,ah as Ye,b0 as Je,W as Me,S as oe,aW as Xe,aT as Qe,a6 as Ze,X as Ie,at as et,a1 as tt,bE as st,o as X,bF as nt}from"./main-
|
|
1
|
+
import{bv as Oe,r as t,s as I,i as ye,bw as Ee,h as _e,j as e,I as z,u as fe,bx as ze,by as Pe,bz as Be,bA as Ue,n as We,bB as Ke,bC as De,bD as Ve,af as Ge,ag as qe,ah as Ye,b0 as Je,W as Me,S as oe,aW as Xe,aT as Qe,a6 as Ze,X as Ie,at as et,a1 as tt,bE as st,o as X,bF as nt}from"./main-DWrvyMds.js";import{FileExplorerPanel as at}from"./index-BVHlOHGE.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ne={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,me=3,ot={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ct=12e4;function rt(s){return s.trim().replace(/\r\n/g,`
|
|
2
2
|
`)}function $e(s,a){return`${s}:${rt(a)}`}function it(s,a,l,f){if(s.uuid&&a.has(s.uuid))return!1;if(s.uuid)return!0;const p=s.isUserPrompt?"user":"assistant",d=$e(p,s.text),M=s.timestamp||0,A=l.get(d);return A!==void 0&&Math.abs(M-A)<=ct?!1:M>f}function dt({isOpen:s,agents:a}){const l=Oe(),[f,p]=t.useState(new Map),d=t.useRef(new Set);t.useRef(a);const M=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),A=t.useMemo(()=>Array.from(a.values()).map(j=>`${j.id}:${j.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{s||(d.current.clear(),p(new Map))},[s]),t.useEffect(()=>{if(!s)return;const j=new Set(Array.from(a.keys()));for(const i of d.current)j.has(i)||d.current.delete(i);let h=null;l>0&&(h=I.preserveOutputs(),d.current.clear());const v=async(i,C,F=0)=>{if(d.current.add(i.id),F>0&&await new Promise(x=>setTimeout(x,F)),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),k}),!i.sessionId){C&&C.length>0&&I.mergeOutputsWithHistory(i.id,[],C),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),k});return}try{const k=await(await _e(ye(`/api/agents/${i.id}/history?limit=${Ee}&offset=0`))).json(),T=k.messages||[],K=T.length>0?Math.max(...T.map(w=>w.timestamp?new Date(w.timestamp).getTime():0)):0,Y=new Set(T.map(w=>w.uuid).filter(w=>!!w)),V=new Map;for(const w of T){if(w.type!=="user"&&w.type!=="assistant")continue;const c=$e(w.type,w.content),L=w.timestamp?new Date(w.timestamp).getTime():0,W=V.get(c)??0;L>W&&V.set(c,L)}const G=I.getOutputs(i.id),U=(C&&C.length>0?[...C,...G]:G).filter(w=>it(w,Y,V,K));I.clearOutputs(i.id);for(const w of U)I.addOutput(i.id,w);p(w=>{const c=new Map(w);return c.set(i.id,{agentId:i.id,messages:T,loading:!1,hasMore:k.hasMore||!1,totalCount:k.totalCount||0}),c})}catch(x){if(console.error(`Failed to load history for ${i.name}:`,x),C&&C.length>0){I.clearOutputs(i.id);for(const k of C)I.addOutput(i.id,k)}p(k=>{const T=new Map(k);return T.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),T})}},u=l>0?500:0,D=Array.from(a.values());for(const i of D)if(!d.current.has(i.id)){const C=h==null?void 0:h.get(i.id);v(i,C,u)}},[s,M,A,l]);const R=t.useRef(a),N=t.useRef(f);R.current=a,N.current=f;const b=t.useCallback(async j=>{const h=R.current.get(j),v=N.current.get(j);if(!(h!=null&&h.sessionId)||!v||!v.hasMore)return;const u=v.messages.length;try{const i=await(await fetch(ye(`/api/agents/${j}/history?limit=${Ee}&offset=${u}`))).json();i.messages&&i.messages.length>0&&p(C=>{const F=new Map(C),x=C.get(j);return x&&F.set(j,{...x,messages:[...i.messages,...x.messages],hasMore:i.hasMore||!1}),F})}catch(D){console.error(`Failed to load more history for agent ${j}:`,D)}},[]),E=t.useCallback(j=>{d.current.delete(j),p(h=>{const v=new Map(h),u=h.get(j);return u&&v.set(j,{...u,messages:[],hasMore:!1,totalCount:0,loading:!1}),v})},[]);return{histories:f,loadMoreHistory:b,clearAgentHistory:E}}function ut({command:s,onCommandChange:a,useTextarea:l,forceTextarea:f,onForceTextarea:p,onSend:d,canSend:M,attachedFiles:A,onAddFile:R,onRemoveFile:N,uploadFile:b,onAddPastedText:E,placeholder:j="Message...",className:h="",compact:v=!1,inputRef:u}){const D=t.useRef(null),i=t.useRef(null),C=t.useRef(l);t.useEffect(()=>{if(l&&!C.current&&i.current){const c=i.current;c.focus(),c.selectionStart=c.selectionEnd=c.value.length}C.current=l},[l]),t.useEffect(()=>{const c=i.current;if(!c||!l)return;c.style.height="auto";const L=v?120:180,W=Math.min(c.scrollHeight,L);c.style.height=`${W}px`},[s,l,v]);const F=t.useCallback(async c=>{const L=c.clipboardData.items;for(const _ of L)if(_.type.startsWith("image/")){c.preventDefault();const $=_.getAsFile();if($){const H=await b($);H&&R(H)}return}const W=c.clipboardData.files;if(W.length>0){c.preventDefault();for(const _ of W){const $=await b(_);$&&R($)}return}const B=c.clipboardData.getData("text"),te=(B.match(/\n/g)||[]).length+1;if(te>5){c.preventDefault();const $=`[Pasted text #${E(B)} +${te} lines]`,H=c.target,se=H.selectionStart||0,ae=H.selectionEnd||0,ne=s.slice(0,se)+$+s.slice(ae);a(ne),l||p(!0)}},[s,a,l,p,b,R,E]),x=t.useCallback(async c=>{const L=c.target.files;if(L){for(const W of L){const B=await b(W);B&&R(B)}D.current&&(D.current.value="")}},[b,R]),k=t.useCallback(c=>{if(c.key==="Enter"&&c.shiftKey){l||(c.preventDefault(),p(!0));return}c.key==="Enter"&&(c.preventDefault(),d())},[l,p,d]),T=t.useCallback(c=>{},[]),K=t.useCallback(c=>{c.button===1&&(c.preventDefault(),c.stopPropagation())},[]),Y=t.useCallback(c=>{i.current=c,u==null||u(c)},[u]),V=v?"agent-panel-input":"guake-input",G=v?"agent-panel-input-container":"guake-input-container",Q=v?"agent-panel-attach-btn":"guake-attach-btn",U=v?"agent-panel-send-btn":"",w=l?v?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[A.length>0&&e.jsx("div",{className:v?"agent-panel-attachments":"guake-attachments",children:A.map(c=>e.jsxs("div",{className:`${v?"agent-panel-attachment":"guake-attachment"} ${c.isImage?"is-image":""}`,children:[e.jsx("span",{className:v?"agent-panel-attachment-icon":"guake-attachment-icon",children:e.jsx(z,{name:c.isImage?"file":"paperclip",size:12})}),e.jsx("span",{className:v?"agent-panel-attachment-name":"guake-attachment-name",title:c.path,children:c.name}),!v&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(c.size/1024),"KB)"]}),e.jsx("button",{className:v?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>N(c.id),title:"Remove",children:"×"})]},c.id))}),e.jsxs("div",{className:`${V} ${w} ${h}`,children:[e.jsx("input",{ref:D,type:"file",multiple:!0,onChange:x,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:G,onAuxClick:K,children:[e.jsx("button",{className:Q,onClick:()=>{var c;return(c=D.current)==null?void 0:c.click()},title:"Attach file (or paste image)",children:e.jsx(z,{name:"paperclip",size:14})}),l?e.jsx("textarea",{ref:Y,placeholder:j,value:s,onChange:c=>a(c.target.value),onKeyDown:k,onPaste:F,onMouseDown:T}):e.jsx("input",{ref:u,type:"text",placeholder:j,value:s,onChange:c=>a(c.target.value),onKeyDown:k,onPaste:F,onMouseDown:T}),e.jsx("button",{className:U,onClick:d,disabled:!M,title:"Send",children:e.jsx(z,{name:"send",size:14})})]})]})]})}function mt(s){const a=Math.floor(s/1e3),l=Math.floor(a/60),f=a%60;return`${l}:${f.toString().padStart(2,"0")}`}const ft=t.memo(function({agentId:a,isWorking:l,timestamp:f}){const{t:p}=fe(["terminal"]),[d,M]=t.useState(0);return t.useEffect(()=>{if(!l||!f){M(0);return}M(Date.now()-f);const A=setInterval(()=>{M(Date.now()-f)},1e3);return()=>clearInterval(A)},[l,f]),l?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:mt(d)}),e.jsxs("button",{className:"guake-stop-btn",onClick:()=>I.stopAgent(a),title:p("terminal:input.stopOperation"),children:[e.jsx("span",{className:"stop-icon",children:e.jsx(z,{name:"stop",size:12,weight:"fill"})}),e.jsx("span",{className:"stop-label",children:p("terminal:input.stop")})]})]}):null});function pt({agent:s,history:a,outputs:l,isExpanded:f,isFocused:p,advancedView:d,onExpand:M,onFocus:A,inputRef:R,onLoadMore:N,onClearHistory:b}){const{t:E}=fe(["terminal","common"]),j=ze(s.id),h=t.useRef(null),[v,u]=t.useState(!1),D=t.useRef(0),i=t.useRef(!1),[C,F]=t.useState(!0),[x,k]=t.useState(!1),[T,K]=t.useState(null),[Y,V]=t.useState(null),[G,Q]=t.useState(null);Pe(`commander-image-modal-${s.id}`,T!==null,()=>K(null));const{command:U,setCommand:w,forceTextarea:c,setForceTextarea:L,useTextarea:W,setPastedTexts:B,incrementPastedCount:te,resetPastedCount:_,attachedFiles:$,setAttachedFiles:H,removeAttachedFile:se,uploadFile:ae,expandPastedTexts:ne}=Be({selectedAgentId:s.id}),le=U.trim().length>0||$.length>0,n=Ue({outputs:l,viewMode:d?"advanced":"simple"}),o=t.useMemo(()=>{const S=We(s);return{usedPercent:S.usedPercent,freePercent:S.freePercent,hasData:!!s.contextStats,totalTokens:S.totalTokens,contextWindow:S.contextWindow}},[s.contextStats,s.contextUsed,s.contextLimit]),g=t.useCallback(()=>{!v&&(a!=null&&a.hasMore)&&N&&(u(!0),D.current=h.current?h.current.scrollHeight-h.current.scrollTop:0,N())},[v,a==null?void 0:a.hasMore,N]);t.useEffect(()=>{v&&a&&!a.loading&&u(!1)},[a,v]);const m=t.useCallback(()=>{i.current=!0,F(!1)},[]),P=t.useRef(f),Z=t.useRef(p);t.useEffect(()=>{(f&&!P.current||p&&!Z.current)&&(i.current=!1,F(!0),k(!0)),P.current=f,Z.current=p},[f,p]);const ee=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{ee.current&&!(a!=null&&a.loading)&&(i.current=!1,F(!0),k(!0)),ee.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{if(!x)return;const S=h.current;if(!S)return;const y=performance.now();let O=0,ue=-1,ke;const Re=()=>{const{scrollTop:Fe,scrollHeight:Se,clientHeight:Le}=S,He=Se-Fe-Le<=2;if(Math.abs(Se-ue)<=1&&He?O+=1:O=0,ue=Se,O>=3){k(!1);return}if(performance.now()-y>5e3){k(!1);return}ke=requestAnimationFrame(Re)};return ke=requestAnimationFrame(Re),()=>cancelAnimationFrame(ke)},[x]),t.useEffect(()=>{i.current||F(!0)},[n.length]);const q=t.useCallback(()=>!1,[]),ie=t.useCallback(S=>{const y=te();return B(O=>new Map(O).set(y,S)),y},[te,B]),he=t.useCallback(S=>{H(y=>[...y,S])},[H]),xe=t.useCallback(()=>{if(!le)return;if(U.trim()==="/clear"&&$.length===0){I.clearContext(s.id),b(),w(""),L(!1),B(new Map),H([]),_();return}let S=ne(U.trim());if($.length>0){const y=$.map(O=>O.isImage?`[Image: ${O.path}]`:`[File: ${O.path}]`).join(`
|
|
3
3
|
`);S=S?`${S}
|
|
4
4
|
|