tide-commander 1.134.2 → 1.136.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/assets/{BossLogsModal-DNQC-Ewi.js → BossLogsModal-B5wtQ9Fh.js} +1 -1
  2. package/dist/assets/{BossSpawnModal-DSpPdHfB.js → BossSpawnModal-B8twkNNt.js} +1 -1
  3. package/dist/assets/{ControlsModal-TPM0WTd7.js → ControlsModal-BKUVlO45.js} +1 -1
  4. package/dist/assets/{DockerLogsModal-BsEfK9sY.js → DockerLogsModal-Oa0WYexL.js} +1 -1
  5. package/dist/assets/{EmbeddedEditor-B7pzeHYJ.js → EmbeddedEditor-Cnkfr9vJ.js} +1 -1
  6. package/dist/assets/{GmailOAuthSetup-BD0lLD6-.js → GmailOAuthSetup-Cfsgqs5D.js} +1 -1
  7. package/dist/assets/{GoogleOAuthSetup-q_I-vMvg.js → GoogleOAuthSetup-BZCY7oIc.js} +1 -1
  8. package/dist/assets/{IframeModal-C0-b5Igy.js → IframeModal-BVaOFzOL.js} +1 -1
  9. package/dist/assets/{IntegrationsPanel-BPWcucBR.js → IntegrationsPanel-CdcwTSOY.js} +2 -2
  10. package/dist/assets/{LogViewerModal-D1puFD4z.js → LogViewerModal-U0o-ixDu.js} +1 -1
  11. package/dist/assets/{MonitoringModal-Dy3YmxW7.js → MonitoringModal-CdYBNEBK.js} +1 -1
  12. package/dist/assets/{PM2LogsModal-DFNTztfk.js → PM2LogsModal-cxSSfOTz.js} +1 -1
  13. package/dist/assets/{RestoreArchivedAreaModal-CokHqFKe.js → RestoreArchivedAreaModal-BkzbecLN.js} +1 -1
  14. package/dist/assets/{Scene2DCanvas-Dr1l-tVX.js → Scene2DCanvas-GGc__FVu.js} +1 -1
  15. package/dist/assets/{SceneManager-IcoT7Cdk.js → SceneManager-BWyie0tH.js} +1 -1
  16. package/dist/assets/{SkillsPanel-Cc1zvnfm.js → SkillsPanel-DS7QNt0-.js} +1 -1
  17. package/dist/assets/{SlackMultiInstanceSetup-Cjva8TJX.js → SlackMultiInstanceSetup-CjHaygiR.js} +1 -1
  18. package/dist/assets/{SpawnModal-DHKupuXe.js → SpawnModal-MWySBWkA.js} +1 -1
  19. package/dist/assets/{StatisticsModal-DZXDkn4d.js → StatisticsModal-D08htYhH.js} +1 -1
  20. package/dist/assets/{SubordinateAssignmentModal-DLJNIySK.js → SubordinateAssignmentModal-DULM1xpx.js} +1 -1
  21. package/dist/assets/{TriggerManagerPanel-Bd5ZGBaw.js → TriggerManagerPanel-nB6R7Nk4.js} +1 -1
  22. package/dist/assets/{WorkflowEditorPanel-D1YylR-A.js → WorkflowEditorPanel-CKgW8DhB.js} +1 -1
  23. package/dist/assets/{area-logos-C1EKS2S6.js → area-logos-CuU1qdkU.js} +1 -1
  24. package/dist/assets/{index-_wxXq7jG.js → index-8DzLSviG.js} +1 -1
  25. package/dist/assets/{index-0yPqh1QY.js → index-B6TRH1E2.js} +1 -1
  26. package/dist/assets/{index-7EfWB7v9.js → index-CLmNQzTF.js} +2 -2
  27. package/dist/assets/{index-E4hM-HPm.js → index-CQPpjjTd.js} +1 -1
  28. package/dist/assets/{index-IPKznDm8.js → index-CWYcGGCJ.js} +3 -3
  29. package/dist/assets/{index-BLrXnQWB.js → index-CWiGs6nn.js} +1 -1
  30. package/dist/assets/{index-BmUoFUZP.js → index-Cc_Ys4_9.js} +1 -1
  31. package/dist/assets/{index-C87bCtYJ.js → index-Csnk6THj.js} +1 -1
  32. package/dist/assets/{index-Ch70UsM8.js → index-ih8yuWhL.js} +1 -1
  33. package/dist/assets/{main-DhXGHPKx.js → main-CHE4wC7P.js} +113 -113
  34. package/dist/assets/main-DM0iS4EN.css +1 -0
  35. package/dist/assets/{web-CHTqiViU.js → web-C4yrL2Hp.js} +1 -1
  36. package/dist/assets/{web-g3yRdGTs.js → web-D1Ur_Mtd.js} +1 -1
  37. package/dist/assets/{web-CDTjrhUg.js → web-dmnfXY_q.js} +1 -1
  38. package/dist/index.html +2 -2
  39. package/dist/locales/en/terminal.json +13 -0
  40. package/dist/src/packages/server/claude/interactive/interactive-runner.js +8 -0
  41. package/dist/src/packages/server/claude/runner/recovery-store.js +102 -6
  42. package/dist/src/packages/server/claude/runner.js +30 -10
  43. package/dist/src/packages/server/data/index.js +1 -0
  44. package/dist/src/packages/server/services/auto-collapse-service.js +8 -2
  45. package/dist/src/packages/server/services/collapse-context.js +52 -12
  46. package/dist/src/packages/server/services/subagent-jsonl-watcher.js +112 -82
  47. package/dist/src/packages/server/websocket/handlers/agent-handler.js +3 -0
  48. package/dist/src/packages/server/websocket/listeners/runtime-listeners.js +40 -30
  49. package/package.json +1 -1
  50. package/dist/assets/main-rrlO1Py8.css +0 -1
@@ -1,4 +1,4 @@
1
- import{u as Ie,cw as oo,P as so,r as i,k as Ee,j as e,C as we,s as x,cx as ro,cy as to,cz as ao,G as Le,i as K,m as ze,aS as io,aw as lo,aT as co,cA as I,a6 as no,aX as Pe,I as yo,h as Me}from"./main-DhXGHPKx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const mo=[{value:"scout",labelKey:"tools:skills.classScout",descriptionKey:"tools:skills.classScoutDesc"},{value:"builder",labelKey:"tools:skills.classBuilder",descriptionKey:"tools:skills.classBuilderDesc"},{value:"debugger",labelKey:"tools:skills.classDebugger",descriptionKey:"tools:skills.classDebuggerDesc"},{value:"architect",labelKey:"tools:skills.classArchitect",descriptionKey:"tools:skills.classArchitectDesc"},{value:"warrior",labelKey:"tools:skills.classWarrior",descriptionKey:"tools:skills.classWarriorDesc"},{value:"support",labelKey:"tools:skills.classSupport",descriptionKey:"tools:skills.classSupportDesc"},{value:"boss",labelKey:"tools:skills.classBoss",descriptionKey:"tools:skills.classBossDesc"}],go=[{labelKey:"tools:skills.toolReadFiles",value:"Read"},{labelKey:"tools:skills.toolWriteFiles",value:"Write"},{labelKey:"tools:skills.toolEditFiles",value:"Edit"},{labelKey:"tools:skills.toolRunBash",value:"Bash"},{labelKey:"tools:skills.toolGitCommands",value:"Bash(git:*)"},{labelKey:"tools:skills.toolNpmCommands",value:"Bash(npm:*)"},{labelKey:"tools:skills.toolDockerCommands",value:"Bash(docker:*)"},{labelKey:"tools:skills.toolKubectlCommands",value:"Bash(kubectl:*)"},{labelKey:"tools:skills.toolSearchFiles",value:"Grep"},{labelKey:"tools:skills.toolGlobFiles",value:"Glob"},{labelKey:"tools:skills.toolWebFetch",value:"WebFetch"},{labelKey:"tools:skills.toolWebSearch",value:"WebSearch"}],po=`## Instructions
1
+ import{u as Ie,cw as oo,P as so,r as i,k as Ee,j as e,C as we,s as x,cx as ro,cy as to,cz as ao,G as Le,i as K,m as ze,aS as io,aw as lo,aT as co,cA as I,a6 as no,aX as Pe,I as yo,h as Me}from"./main-CHE4wC7P.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const mo=[{value:"scout",labelKey:"tools:skills.classScout",descriptionKey:"tools:skills.classScoutDesc"},{value:"builder",labelKey:"tools:skills.classBuilder",descriptionKey:"tools:skills.classBuilderDesc"},{value:"debugger",labelKey:"tools:skills.classDebugger",descriptionKey:"tools:skills.classDebuggerDesc"},{value:"architect",labelKey:"tools:skills.classArchitect",descriptionKey:"tools:skills.classArchitectDesc"},{value:"warrior",labelKey:"tools:skills.classWarrior",descriptionKey:"tools:skills.classWarriorDesc"},{value:"support",labelKey:"tools:skills.classSupport",descriptionKey:"tools:skills.classSupportDesc"},{value:"boss",labelKey:"tools:skills.classBoss",descriptionKey:"tools:skills.classBossDesc"}],go=[{labelKey:"tools:skills.toolReadFiles",value:"Read"},{labelKey:"tools:skills.toolWriteFiles",value:"Write"},{labelKey:"tools:skills.toolEditFiles",value:"Edit"},{labelKey:"tools:skills.toolRunBash",value:"Bash"},{labelKey:"tools:skills.toolGitCommands",value:"Bash(git:*)"},{labelKey:"tools:skills.toolNpmCommands",value:"Bash(npm:*)"},{labelKey:"tools:skills.toolDockerCommands",value:"Bash(docker:*)"},{labelKey:"tools:skills.toolKubectlCommands",value:"Bash(kubectl:*)"},{labelKey:"tools:skills.toolSearchFiles",value:"Grep"},{labelKey:"tools:skills.toolGlobFiles",value:"Glob"},{labelKey:"tools:skills.toolWebFetch",value:"WebFetch"},{labelKey:"tools:skills.toolWebSearch",value:"WebSearch"}],po=`## Instructions
2
2
 
3
3
  Describe step-by-step instructions for this skill here.
4
4
 
@@ -1,2 +1,2 @@
1
- import{r as h,j as e,h as b,i as m}from"./main-DhXGHPKx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const C=["public_channel","private_channel","im","mpim"],z={public_channel:"Public channels",private_channel:"Private channels",im:"1:1 DMs",mpim:"Group DMs"};function M(t){const i=new Set;for(const a of(t||"").split(",")){const f=a.trim();C.includes(f)&&i.add(f)}return i}function $(t){return C.filter(i=>t.has(i)).join(",")}const s={container:{display:"flex",gap:16,minHeight:420},list:{width:200,flexShrink:0,background:"var(--surface-1, #181825)",borderRadius:8,border:"1px solid var(--border, #313244)",padding:8,display:"flex",flexDirection:"column",gap:4},listItem:t=>({padding:"8px 10px",borderRadius:6,cursor:"pointer",background:t?"rgba(137,180,250,0.15)":"transparent",border:t?"1px solid rgba(137,180,250,0.3)":"1px solid transparent",color:t?"#cdd6f4":"#a6adc8",fontSize:13}),label:{fontWeight:500},sub:{fontSize:11,color:"#6c7086",marginTop:2},addBtn:{marginTop:8,padding:"8px 10px",borderRadius:6,background:"transparent",color:"#89b4fa",border:"1px dashed rgba(137,180,250,0.4)",cursor:"pointer",fontSize:13},editor:{flex:1,display:"flex",flexDirection:"column",gap:12},field:{display:"flex",flexDirection:"column",gap:4},fieldLabel:{fontSize:12,fontWeight:500,color:"#a6adc8"},fieldDesc:{fontSize:11,color:"#6c7086"},input:{padding:"8px 10px",background:"var(--surface-0, #1e1e2e)",border:"1px solid var(--border, #313244)",borderRadius:6,color:"#cdd6f4",fontSize:13,fontFamily:"inherit"},badge:t=>{const a={socket:"#a6e3a1",polling:"#89b4fa",none:"#6c7086"}[t]??"#6c7086";return{display:"inline-block",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:500,background:`${a}26`,color:a,border:`1px solid ${a}55`}},rowGap:{display:"flex",gap:12},buttons:{display:"flex",gap:8,marginTop:12},btnPrimary:{padding:"8px 16px",background:"#89b4fa",color:"#1e1e2e",border:"none",borderRadius:6,cursor:"pointer",fontWeight:500,fontSize:13},btnSecondary:{padding:"8px 16px",background:"transparent",color:"#cdd6f4",border:"1px solid var(--border, #313244)",borderRadius:6,cursor:"pointer",fontSize:13},btnDanger:{padding:"8px 16px",background:"transparent",color:"#f38ba8",border:"1px solid rgba(243,139,168,0.4)",borderRadius:6,cursor:"pointer",fontSize:13},alert:t=>({padding:"8px 12px",borderRadius:6,fontSize:12,background:t==="error"?"rgba(243,139,168,0.15)":"rgba(166,227,161,0.15)",color:t==="error"?"#f38ba8":"#a6e3a1",border:`1px solid ${t==="error"?"rgba(243,139,168,0.3)":"rgba(166,227,161,0.3)"}`})},j="/api/slack/instances";async function N(){const t=await b(m(j));if(!t.ok)throw new Error(`HTTP ${t.status}`);return(await t.json()).instances}async function B(t){const i=await b(m(`${j}/${encodeURIComponent(t)}/values`));if(!i.ok)throw new Error(`HTTP ${i.status}`);return(await i.json()).values}async function K(t,i){const a=await b(m(j),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,label:i})});if(!a.ok){const f=await a.json().catch(()=>({}));throw new Error(f.error||`HTTP ${a.status}`)}}async function H(t,i){const a=await b(m(`${j}/${encodeURIComponent(t)}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!a.ok){const f=await a.json().catch(()=>({}));throw new Error(f.error||`HTTP ${a.status}`)}}async function W(t){const i=await b(m(`${j}/${encodeURIComponent(t)}`),{method:"DELETE"});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.error||`HTTP ${i.status}`)}}const V=({integration:t,onCancel:i})=>{const[a,f]=h.useState([]),[o,v]=h.useState("default"),[l,S]=h.useState(null),[T,_]=h.useState(null),[g,I]=h.useState(""),[D,A]=h.useState(!1),[L,E]=h.useState(!1),[w,x]=h.useState(null),y=h.useCallback(async()=>{try{const n=await N();f(n),!n.some(d=>d.id===o)&&n.length>0&&v(n[0].id)}catch(n){x({kind:"error",message:`Failed to load instances: ${n.message}`})}},[o]),k=h.useCallback(async()=>{if(o){A(!0);try{const n=await B(o);S(n),_(n);const r=a.find(d=>d.id===o);I((r==null?void 0:r.label)??o)}catch(n){x({kind:"error",message:`Failed to load instance: ${n.message}`})}finally{A(!1)}}},[o,a]);h.useEffect(()=>{y()},[y]),h.useEffect(()=>{k()},[k]);const P=async()=>{const n=window.prompt('Instance id (kebab-case, e.g. "personal", "team-bot"):');if(!n)return;const r=window.prompt("Display label:",n)||n;try{await K(n.trim(),r.trim()),await y(),v(n.trim()),x({kind:"success",message:`Created "${n}"`})}catch(d){x({kind:"error",message:d.message})}},O=async()=>{if(o!=="default"&&window.confirm(`Delete Slack instance "${o}"? This disconnects it and removes its config.`))try{await W(o),v("default"),await y(),x({kind:"success",message:"Instance deleted"})}catch(n){x({kind:"error",message:n.message})}},R=async()=>{if(!(!l||!T)){E(!0);try{const n={};Object.keys(l).forEach(p=>{const u=l[p];if(u!==T[p]){if((p==="SLACK_BOT_TOKEN"||p==="SLACK_APP_TOKEN")&&u==="********")return;n[p]=u}});const r=a.find(p=>p.id===o),d=r&&g.trim()&&g.trim()!==r.label;await H(o,{label:d?g.trim():void 0,values:Object.keys(n).length>0?n:void 0}),x({kind:"success",message:"Saved. Slack will reconnect with the new settings."}),await y(),await k()}catch(n){x({kind:"error",message:n.message})}finally{E(!1)}}},c=(n,r)=>{l&&S({...l,[n]:r})};return e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:12,fontSize:12,color:"#a6adc8"},children:"Add multiple Slack connections side-by-side. The default instance maps to your existing bot / token; add more for personal (xoxp-) tokens or additional workspaces."}),w&&e.jsx("div",{style:{...s.alert(w.kind),marginBottom:12},children:w.message}),e.jsxs("div",{style:s.container,children:[e.jsxs("div",{style:s.list,children:[a.map(n=>{var d,p,u;const r=((d=n.config)==null?void 0:d.currentMode)??"none";return e.jsxs("div",{style:s.listItem(n.id===o),onClick:()=>v(n.id),children:[e.jsx("div",{style:s.label,children:n.label}),e.jsxs("div",{style:s.sub,children:[e.jsx("span",{style:s.badge(r),children:r==="none"?"—":r}),(p=n.status)!=null&&p.connected?" • connected":(u=n.status)!=null&&u.error?" • error":" • idle"]})]},n.id)}),e.jsx("button",{type:"button",style:s.addBtn,onClick:P,children:"+ Add Instance"})]}),e.jsxs("div",{style:s.editor,children:[D&&e.jsx("div",{style:{color:"#6c7086",fontSize:13},children:"Loading…"}),!D&&l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:s.field,children:[e.jsx("span",{style:s.fieldLabel,children:"Display label"}),e.jsx("input",{type:"text",style:s.input,value:g,onChange:n=>I(n.target.value),disabled:!1}),e.jsxs("span",{style:s.fieldDesc,children:["Shown in the instance list. Id is fixed: ",e.jsx("code",{children:o})]})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:l.enabled,onChange:n=>c("enabled",n.target.checked)}),e.jsx("span",{style:s.fieldLabel,children:"Enabled"})]}),e.jsx("span",{style:s.fieldDesc,children:"Toggle off to disconnect this instance without deleting its config."})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:l.mirrorOwnMessages,onChange:n=>c("mirrorOwnMessages",n.target.checked)}),e.jsx("span",{style:s.fieldLabel,children:"Mirror messages I send too"})]}),e.jsxs("span",{style:s.fieldDesc,children:["Capture your outgoing messages alongside incoming ones (logged as ",e.jsx("code",{children:"direction:outbound"}),"). Recommended for personal (xoxp-) tokens. Triggers do not fire on your own messages — that would loop."]})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:l.reactOnTrigger,onChange:n=>c("reactOnTrigger",n.target.checked)}),e.jsx("span",{style:s.fieldLabel,children:"Auto-react with 👀 on trigger"})]}),e.jsxs("span",{style:s.fieldDesc,children:["When a Slack trigger fires on an incoming message, react with ",e.jsx("code",{children:":eyes:"}),' as an "I saw it, working on it" ack. Turn off for accounts where the reaction is noisy. The server env ',e.jsx("code",{children:"SLACK_REACT_ON_TRIGGER=false"})," still disables it across all instances."]})]}),e.jsxs("div",{style:s.field,children:[e.jsx("span",{style:s.fieldLabel,children:"Slack Token"}),e.jsx("input",{type:"password",style:s.input,placeholder:"xoxb-... or xoxp-...",value:l.SLACK_BOT_TOKEN,onChange:n=>c("SLACK_BOT_TOKEN",n.target.value)}),e.jsxs("span",{style:s.fieldDesc,children:["Bot token (xoxb-) → Socket Mode. User token (xoxp-) → Web API polling (~30-60s lag). Stored encrypted under a per-instance key; leave as ",e.jsx("code",{children:"********"})," to keep the existing token."]})]}),e.jsxs("div",{style:s.field,children:[e.jsx("span",{style:s.fieldLabel,children:"App Token (Socket Mode only)"}),e.jsx("input",{type:"password",style:s.input,placeholder:"xapp-...",value:l.SLACK_APP_TOKEN,onChange:n=>c("SLACK_APP_TOKEN",n.target.value)}),e.jsx("span",{style:s.fieldDesc,children:"Required for xoxb- only. Leave blank for xoxp- (polling mode)."})]}),e.jsxs("div",{style:s.rowGap,children:[e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Inbound Mode"}),e.jsxs("select",{style:s.input,value:l.authMode,onChange:n=>c("authMode",n.target.value),children:[e.jsx("option",{value:"auto",children:"Auto (from token prefix)"}),e.jsx("option",{value:"socket",children:"Socket Mode (xoxb-)"}),e.jsx("option",{value:"polling",children:"Polling (xoxp-)"})]})]}),e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Default Channel"}),e.jsx("input",{type:"text",style:s.input,placeholder:"C0123456789",value:l.defaultChannelId,onChange:n=>c("defaultChannelId",n.target.value)})]})]}),e.jsxs("div",{style:s.rowGap,children:[e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Polling Interval (s)"}),e.jsx("input",{type:"number",style:s.input,min:10,max:600,value:l.pollingIntervalSec,onChange:n=>c("pollingIntervalSec",Number(n.target.value))})]}),e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Concurrency"}),e.jsx("input",{type:"number",style:s.input,min:1,max:8,value:l.pollingConcurrency,onChange:n=>c("pollingConcurrency",Number(n.target.value))})]}),e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Backfill Cap (msgs)"}),e.jsx("input",{type:"number",style:s.input,min:1,max:1e3,value:l.pollingBackfillMessageCap,onChange:n=>c("pollingBackfillMessageCap",Number(n.target.value))})]}),e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Min ms between calls"}),e.jsx("input",{type:"number",style:s.input,min:0,max:1e4,value:l.pollingMinMsBetweenCalls,onChange:n=>c("pollingMinMsBetweenCalls",Number(n.target.value))}),e.jsx("span",{style:{...s.fieldDesc,fontSize:11},children:"Throttle. 1500 ≈ 40 req/min. Set 0 to disable."})]})]}),e.jsxs("div",{style:s.field,children:[e.jsx("span",{style:s.fieldLabel,children:"Channel Types (poll all of these)"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:12,marginTop:4},children:C.map(n=>{const d=M(l.pollingChannelTypes).has(n);return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",fontSize:13},children:[e.jsx("input",{type:"checkbox",checked:d,onChange:p=>{const u=new Set(M(l.pollingChannelTypes));p.target.checked?u.add(n):u.delete(n),c("pollingChannelTypes",$(u))}}),e.jsx("span",{children:z[n]})]},n)})}),e.jsx("span",{style:s.fieldDesc,children:"Determines which channel types are polled when the allowlist below is empty. Tick all four for full coverage. Heads-up: hundreds of channels at once can hit Slack's rate limit (~50 req/min) — use the allowlist to narrow down."})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:s.fieldLabel,children:"Channel Allowlist (optional)"}),l.pollingChannelAllowlist&&e.jsx("button",{type:"button",style:{...s.btnSecondary,padding:"4px 10px",fontSize:12},onClick:()=>c("pollingChannelAllowlist",""),title:"Clear the allowlist — fall back to polling all channels per the type checkboxes above.",children:"Include all (clear list)"})]}),e.jsx("textarea",{style:{...s.input,minHeight:60,fontFamily:"monospace",fontSize:12},placeholder:`C0123456789, G0987654321
1
+ import{r as h,j as e,h as b,i as m}from"./main-CHE4wC7P.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const C=["public_channel","private_channel","im","mpim"],z={public_channel:"Public channels",private_channel:"Private channels",im:"1:1 DMs",mpim:"Group DMs"};function M(t){const i=new Set;for(const a of(t||"").split(",")){const f=a.trim();C.includes(f)&&i.add(f)}return i}function $(t){return C.filter(i=>t.has(i)).join(",")}const s={container:{display:"flex",gap:16,minHeight:420},list:{width:200,flexShrink:0,background:"var(--surface-1, #181825)",borderRadius:8,border:"1px solid var(--border, #313244)",padding:8,display:"flex",flexDirection:"column",gap:4},listItem:t=>({padding:"8px 10px",borderRadius:6,cursor:"pointer",background:t?"rgba(137,180,250,0.15)":"transparent",border:t?"1px solid rgba(137,180,250,0.3)":"1px solid transparent",color:t?"#cdd6f4":"#a6adc8",fontSize:13}),label:{fontWeight:500},sub:{fontSize:11,color:"#6c7086",marginTop:2},addBtn:{marginTop:8,padding:"8px 10px",borderRadius:6,background:"transparent",color:"#89b4fa",border:"1px dashed rgba(137,180,250,0.4)",cursor:"pointer",fontSize:13},editor:{flex:1,display:"flex",flexDirection:"column",gap:12},field:{display:"flex",flexDirection:"column",gap:4},fieldLabel:{fontSize:12,fontWeight:500,color:"#a6adc8"},fieldDesc:{fontSize:11,color:"#6c7086"},input:{padding:"8px 10px",background:"var(--surface-0, #1e1e2e)",border:"1px solid var(--border, #313244)",borderRadius:6,color:"#cdd6f4",fontSize:13,fontFamily:"inherit"},badge:t=>{const a={socket:"#a6e3a1",polling:"#89b4fa",none:"#6c7086"}[t]??"#6c7086";return{display:"inline-block",padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:500,background:`${a}26`,color:a,border:`1px solid ${a}55`}},rowGap:{display:"flex",gap:12},buttons:{display:"flex",gap:8,marginTop:12},btnPrimary:{padding:"8px 16px",background:"#89b4fa",color:"#1e1e2e",border:"none",borderRadius:6,cursor:"pointer",fontWeight:500,fontSize:13},btnSecondary:{padding:"8px 16px",background:"transparent",color:"#cdd6f4",border:"1px solid var(--border, #313244)",borderRadius:6,cursor:"pointer",fontSize:13},btnDanger:{padding:"8px 16px",background:"transparent",color:"#f38ba8",border:"1px solid rgba(243,139,168,0.4)",borderRadius:6,cursor:"pointer",fontSize:13},alert:t=>({padding:"8px 12px",borderRadius:6,fontSize:12,background:t==="error"?"rgba(243,139,168,0.15)":"rgba(166,227,161,0.15)",color:t==="error"?"#f38ba8":"#a6e3a1",border:`1px solid ${t==="error"?"rgba(243,139,168,0.3)":"rgba(166,227,161,0.3)"}`})},j="/api/slack/instances";async function N(){const t=await b(m(j));if(!t.ok)throw new Error(`HTTP ${t.status}`);return(await t.json()).instances}async function B(t){const i=await b(m(`${j}/${encodeURIComponent(t)}/values`));if(!i.ok)throw new Error(`HTTP ${i.status}`);return(await i.json()).values}async function K(t,i){const a=await b(m(j),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,label:i})});if(!a.ok){const f=await a.json().catch(()=>({}));throw new Error(f.error||`HTTP ${a.status}`)}}async function H(t,i){const a=await b(m(`${j}/${encodeURIComponent(t)}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!a.ok){const f=await a.json().catch(()=>({}));throw new Error(f.error||`HTTP ${a.status}`)}}async function W(t){const i=await b(m(`${j}/${encodeURIComponent(t)}`),{method:"DELETE"});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.error||`HTTP ${i.status}`)}}const V=({integration:t,onCancel:i})=>{const[a,f]=h.useState([]),[o,v]=h.useState("default"),[l,S]=h.useState(null),[T,_]=h.useState(null),[g,I]=h.useState(""),[D,A]=h.useState(!1),[L,E]=h.useState(!1),[w,x]=h.useState(null),y=h.useCallback(async()=>{try{const n=await N();f(n),!n.some(d=>d.id===o)&&n.length>0&&v(n[0].id)}catch(n){x({kind:"error",message:`Failed to load instances: ${n.message}`})}},[o]),k=h.useCallback(async()=>{if(o){A(!0);try{const n=await B(o);S(n),_(n);const r=a.find(d=>d.id===o);I((r==null?void 0:r.label)??o)}catch(n){x({kind:"error",message:`Failed to load instance: ${n.message}`})}finally{A(!1)}}},[o,a]);h.useEffect(()=>{y()},[y]),h.useEffect(()=>{k()},[k]);const P=async()=>{const n=window.prompt('Instance id (kebab-case, e.g. "personal", "team-bot"):');if(!n)return;const r=window.prompt("Display label:",n)||n;try{await K(n.trim(),r.trim()),await y(),v(n.trim()),x({kind:"success",message:`Created "${n}"`})}catch(d){x({kind:"error",message:d.message})}},O=async()=>{if(o!=="default"&&window.confirm(`Delete Slack instance "${o}"? This disconnects it and removes its config.`))try{await W(o),v("default"),await y(),x({kind:"success",message:"Instance deleted"})}catch(n){x({kind:"error",message:n.message})}},R=async()=>{if(!(!l||!T)){E(!0);try{const n={};Object.keys(l).forEach(p=>{const u=l[p];if(u!==T[p]){if((p==="SLACK_BOT_TOKEN"||p==="SLACK_APP_TOKEN")&&u==="********")return;n[p]=u}});const r=a.find(p=>p.id===o),d=r&&g.trim()&&g.trim()!==r.label;await H(o,{label:d?g.trim():void 0,values:Object.keys(n).length>0?n:void 0}),x({kind:"success",message:"Saved. Slack will reconnect with the new settings."}),await y(),await k()}catch(n){x({kind:"error",message:n.message})}finally{E(!1)}}},c=(n,r)=>{l&&S({...l,[n]:r})};return e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:12,fontSize:12,color:"#a6adc8"},children:"Add multiple Slack connections side-by-side. The default instance maps to your existing bot / token; add more for personal (xoxp-) tokens or additional workspaces."}),w&&e.jsx("div",{style:{...s.alert(w.kind),marginBottom:12},children:w.message}),e.jsxs("div",{style:s.container,children:[e.jsxs("div",{style:s.list,children:[a.map(n=>{var d,p,u;const r=((d=n.config)==null?void 0:d.currentMode)??"none";return e.jsxs("div",{style:s.listItem(n.id===o),onClick:()=>v(n.id),children:[e.jsx("div",{style:s.label,children:n.label}),e.jsxs("div",{style:s.sub,children:[e.jsx("span",{style:s.badge(r),children:r==="none"?"—":r}),(p=n.status)!=null&&p.connected?" • connected":(u=n.status)!=null&&u.error?" • error":" • idle"]})]},n.id)}),e.jsx("button",{type:"button",style:s.addBtn,onClick:P,children:"+ Add Instance"})]}),e.jsxs("div",{style:s.editor,children:[D&&e.jsx("div",{style:{color:"#6c7086",fontSize:13},children:"Loading…"}),!D&&l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:s.field,children:[e.jsx("span",{style:s.fieldLabel,children:"Display label"}),e.jsx("input",{type:"text",style:s.input,value:g,onChange:n=>I(n.target.value),disabled:!1}),e.jsxs("span",{style:s.fieldDesc,children:["Shown in the instance list. Id is fixed: ",e.jsx("code",{children:o})]})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:l.enabled,onChange:n=>c("enabled",n.target.checked)}),e.jsx("span",{style:s.fieldLabel,children:"Enabled"})]}),e.jsx("span",{style:s.fieldDesc,children:"Toggle off to disconnect this instance without deleting its config."})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:l.mirrorOwnMessages,onChange:n=>c("mirrorOwnMessages",n.target.checked)}),e.jsx("span",{style:s.fieldLabel,children:"Mirror messages I send too"})]}),e.jsxs("span",{style:s.fieldDesc,children:["Capture your outgoing messages alongside incoming ones (logged as ",e.jsx("code",{children:"direction:outbound"}),"). Recommended for personal (xoxp-) tokens. Triggers do not fire on your own messages — that would loop."]})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:l.reactOnTrigger,onChange:n=>c("reactOnTrigger",n.target.checked)}),e.jsx("span",{style:s.fieldLabel,children:"Auto-react with 👀 on trigger"})]}),e.jsxs("span",{style:s.fieldDesc,children:["When a Slack trigger fires on an incoming message, react with ",e.jsx("code",{children:":eyes:"}),' as an "I saw it, working on it" ack. Turn off for accounts where the reaction is noisy. The server env ',e.jsx("code",{children:"SLACK_REACT_ON_TRIGGER=false"})," still disables it across all instances."]})]}),e.jsxs("div",{style:s.field,children:[e.jsx("span",{style:s.fieldLabel,children:"Slack Token"}),e.jsx("input",{type:"password",style:s.input,placeholder:"xoxb-... or xoxp-...",value:l.SLACK_BOT_TOKEN,onChange:n=>c("SLACK_BOT_TOKEN",n.target.value)}),e.jsxs("span",{style:s.fieldDesc,children:["Bot token (xoxb-) → Socket Mode. User token (xoxp-) → Web API polling (~30-60s lag). Stored encrypted under a per-instance key; leave as ",e.jsx("code",{children:"********"})," to keep the existing token."]})]}),e.jsxs("div",{style:s.field,children:[e.jsx("span",{style:s.fieldLabel,children:"App Token (Socket Mode only)"}),e.jsx("input",{type:"password",style:s.input,placeholder:"xapp-...",value:l.SLACK_APP_TOKEN,onChange:n=>c("SLACK_APP_TOKEN",n.target.value)}),e.jsx("span",{style:s.fieldDesc,children:"Required for xoxb- only. Leave blank for xoxp- (polling mode)."})]}),e.jsxs("div",{style:s.rowGap,children:[e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Inbound Mode"}),e.jsxs("select",{style:s.input,value:l.authMode,onChange:n=>c("authMode",n.target.value),children:[e.jsx("option",{value:"auto",children:"Auto (from token prefix)"}),e.jsx("option",{value:"socket",children:"Socket Mode (xoxb-)"}),e.jsx("option",{value:"polling",children:"Polling (xoxp-)"})]})]}),e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Default Channel"}),e.jsx("input",{type:"text",style:s.input,placeholder:"C0123456789",value:l.defaultChannelId,onChange:n=>c("defaultChannelId",n.target.value)})]})]}),e.jsxs("div",{style:s.rowGap,children:[e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Polling Interval (s)"}),e.jsx("input",{type:"number",style:s.input,min:10,max:600,value:l.pollingIntervalSec,onChange:n=>c("pollingIntervalSec",Number(n.target.value))})]}),e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Concurrency"}),e.jsx("input",{type:"number",style:s.input,min:1,max:8,value:l.pollingConcurrency,onChange:n=>c("pollingConcurrency",Number(n.target.value))})]}),e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Backfill Cap (msgs)"}),e.jsx("input",{type:"number",style:s.input,min:1,max:1e3,value:l.pollingBackfillMessageCap,onChange:n=>c("pollingBackfillMessageCap",Number(n.target.value))})]}),e.jsxs("div",{style:{...s.field,flex:1},children:[e.jsx("span",{style:s.fieldLabel,children:"Min ms between calls"}),e.jsx("input",{type:"number",style:s.input,min:0,max:1e4,value:l.pollingMinMsBetweenCalls,onChange:n=>c("pollingMinMsBetweenCalls",Number(n.target.value))}),e.jsx("span",{style:{...s.fieldDesc,fontSize:11},children:"Throttle. 1500 ≈ 40 req/min. Set 0 to disable."})]})]}),e.jsxs("div",{style:s.field,children:[e.jsx("span",{style:s.fieldLabel,children:"Channel Types (poll all of these)"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:12,marginTop:4},children:C.map(n=>{const d=M(l.pollingChannelTypes).has(n);return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer",fontSize:13},children:[e.jsx("input",{type:"checkbox",checked:d,onChange:p=>{const u=new Set(M(l.pollingChannelTypes));p.target.checked?u.add(n):u.delete(n),c("pollingChannelTypes",$(u))}}),e.jsx("span",{children:z[n]})]},n)})}),e.jsx("span",{style:s.fieldDesc,children:"Determines which channel types are polled when the allowlist below is empty. Tick all four for full coverage. Heads-up: hundreds of channels at once can hit Slack's rate limit (~50 req/min) — use the allowlist to narrow down."})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:s.fieldLabel,children:"Channel Allowlist (optional)"}),l.pollingChannelAllowlist&&e.jsx("button",{type:"button",style:{...s.btnSecondary,padding:"4px 10px",fontSize:12},onClick:()=>c("pollingChannelAllowlist",""),title:"Clear the allowlist — fall back to polling all channels per the type checkboxes above.",children:"Include all (clear list)"})]}),e.jsx("textarea",{style:{...s.input,minHeight:60,fontFamily:"monospace",fontSize:12},placeholder:`C0123456789, G0987654321
2
2
  C9999999999`,value:l.pollingChannelAllowlist,onChange:n=>c("pollingChannelAllowlist",n.target.value)}),e.jsx("span",{style:s.fieldDesc,children:'Comma- or newline-separated channel IDs. When set, polling restricts to these channels (plus DMs if "Always include DMs" is on). The Channel Types checkboxes above are ignored while an allowlist is active. Leave blank to fall back to polling all channels per the type checkboxes.'})]}),e.jsxs("div",{style:s.field,children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:l.pollingDmsAlways,onChange:n=>c("pollingDmsAlways",n.target.checked)}),e.jsx("span",{style:s.fieldLabel,children:"Always include DMs"})]}),e.jsx("span",{style:s.fieldDesc,children:"When the allowlist is set, still poll all 1:1 DMs (D-prefix). Default on. Turn off for strict allowlist-only mode."})]}),e.jsxs("div",{style:s.buttons,children:[e.jsx("button",{type:"button",style:s.btnPrimary,onClick:R,disabled:L,children:L?"Saving…":"Save & Reconnect"}),e.jsx("button",{type:"button",style:s.btnSecondary,onClick:i,children:"Close"}),o!=="default"&&e.jsx("button",{type:"button",style:{...s.btnDanger,marginLeft:"auto"},onClick:O,children:"Delete Instance"})]})]})]})]})]})};export{V as SlackMultiInstanceSetup,V as default};
@@ -1 +1 @@
1
- import{u as Qe,aS as es,aT as ss,aU as as,aV as ns,r as t,W as Ee,S as ne,aW as te,A as Ae,i as le,h as ts,s as S,k as ls,j as s,aX as os,a6 as De,aY as x,aZ as is,a_ as oe,I as ie,aE as T,aC as K,a$ as cs,aD as ce,b0 as re,b1 as rs,X as ds}from"./main-DhXGHPKx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function Ie(r,j){const b=j.filter(C=>!r.has(C));return b.length===0?`${j[Math.floor(Math.random()*j.length)]}-${Date.now()%1e3}`:b[Math.floor(Math.random()*b.length)]}function hs({isOpen:r,onClose:j,onSpawnStart:b,onSpawnEnd:C,spawnPosition:_e,spawnAreaId:N}){const{t:a}=Qe(["terminal","common"]),P=es(),p=ss(),de=as(),H=de.length>0?de:ns,[m,v]=t.useState(""),[M,F]=t.useState(()=>Ee(ne.LAST_CWD)),[i,k]=t.useState("scout"),[pe,I]=t.useState(!1),[Le,R]=t.useState(!1),[me,X]=t.useState(!1),[ue,he]=t.useState(""),[y,Y]=t.useState([]),[E,U]=t.useState(null),[$e,we]=t.useState(!1),[_,xe]=t.useState(""),[h,Te]=t.useState(""),[z,Pe]=t.useState(!1),[O,Fe]=t.useState("bypass"),[o,J]=t.useState("claude"),[f,A]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[fe,V]=t.useState(new Set),[Z,ge]=t.useState("claude-opus-4-8[1m]"),[Q,je]=t.useState("xHigh"),[ee,Re]=t.useState("gpt-5.3-codex"),[se,Ue]=t.useState("minimax/MiniMax-M1-80k"),[Ne,ze]=t.useState(""),[D,Oe]=t.useState(""),q=t.useRef(null),ve=t.useRef(!1),L=t.useCallback(()=>{window.__spawnModalAreaContext=null},[]),w=t.useMemo(()=>P.filter(e=>e.enabled),[P]),qe=["full-notifications","streaming-exec","task-label","report-task-to-boss","agent-tracking","agent-memory","send-message-to-agent"];t.useEffect(()=>{if(r&&!ve.current){if(w.length>0){const l=w.filter(c=>qe.includes(c.slug)).map(c=>c.id);l.length>0&&V(new Set(l))}const n=Ee(ne.DEFAULT_AGENT_CLASS);if(n==="random"){const c=[...Object.keys(rs),...p.map(u=>u.id)];k(c[Math.floor(Math.random()*c.length)])}else k(n||"scout")}ve.current=r},[r,w,p]);const Se=t.useMemo(()=>{if(!D.trim())return w;const e=D.toLowerCase();return w.filter(n=>n.name.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)||n.slug.toLowerCase().includes(e))},[w,D]),We=t.useCallback(e=>{V(n=>{const l=new Set(n);return l.has(e)?l.delete(e):l.add(e),l})},[]);t.useMemo(()=>w.filter(e=>e.assignedAgentClasses.includes(i)),[w,i]);const Ge=t.useMemo(()=>{var n;const e=p.find(l=>l.id===i);return(n=e==null?void 0:e.defaultSkillIds)!=null&&n.length?P.filter(l=>e.defaultSkillIds.includes(l.id)):[]},[p,i,P]),be=t.useMemo(()=>{if(!_.trim())return y;const e=_.toLowerCase();return y.filter(n=>n.sessionId.toLowerCase().includes(e)||n.projectPath.toLowerCase().includes(e)||n.firstMessage&&n.firstMessage.toLowerCase().includes(e))},[y,_]),W=t.useMemo(()=>{if(!h.trim())return p;const e=h.toLowerCase();return p.filter(n=>n.name.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)||n.id.toLowerCase().includes(e))},[p,h]),G=t.useMemo(()=>{if(!h.trim())return te;const e=h.toLowerCase();return te.filter(n=>{const l=Ae[n.id];return n.name.toLowerCase().includes(e)||n.id.toLowerCase().includes(e)||l.description.toLowerCase().includes(e)})},[h]);t.useEffect(()=>{if(!r||!h.trim())return;const e=[...W.map(n=>n.id),...G.map(n=>n.id)];e.length===1&&e[0]!==i&&k(e[0])},[r,h,W,G,i]);const d=t.useMemo(()=>p.find(e=>e.id===i),[p,i]),Be=t.useMemo(()=>{if(d!=null&&d.model)return d.model},[d]),Ke=t.useMemo(()=>{if(d!=null&&d.customModelPath)return le(`/api/custom-models/${d.id}`)},[d]),He=d==null?void 0:d.modelScale,Xe=t.useMemo(()=>d?"scout":i,[i,d]),B=t.useCallback(async e=>{we(!0);try{const n=e?le(`/api/agents/claude-sessions?cwd=${encodeURIComponent(e)}`):le("/api/agents/claude-sessions"),c=await(await ts(n)).json();Y(c.sessions||[])}catch(n){console.error("Failed to fetch sessions:",n),Y([])}finally{we(!1)}},[]);t.useEffect(()=>{r?B(M||void 0):(Y([]),U(null),xe(""))},[r,B]),t.useEffect(()=>{if(!r)return;const e=setTimeout(()=>{B(M||void 0),U(null)},300);return()=>clearTimeout(e)},[M,r,B]),t.useEffect(()=>{if(!r||!N)return;const e=S.getState().areas.get(N);if(e!=null&&e.directories&&e.directories.length>0){F(e.directories[0]);return}const n=Array.from(S.getState().agents.values()).filter(g=>{var $;return(($=S.getAreaForAgent(g.id))==null?void 0:$.id)===N&&g.cwd});if(n.length===0)return;const l=new Map;for(const g of n)l.set(g.cwd,(l.get(g.cwd)||0)+1);let c="",u=0;for(const[g,$]of l)$>u&&(c=g,u=$);c&&F(c)},[r,N]),t.useEffect(()=>{if(r){const e=new Set(Array.from(S.getState().agents.values()).map(u=>u.name)),n=Ie(e,H),l=p.find(u=>u.id===i),c=l?`${l.name} ${n}`:n;v(c),q.current&&(q.current.focus(),q.current.select())}},[r,H]),t.useEffect(()=>{if(!r)return;const e=p.find(n=>n.id===i);if(e){const n=p.find(l=>m.startsWith(l.name+" "));if(n){const l=m.substring(n.name.length+1);v(`${e.name} ${l}`)}else v(`${e.name} ${m}`)}else{const n=p.find(l=>m.startsWith(l.name+" "));if(n){const l=m.substring(n.name.length+1);v(l)}}},[i]),t.useEffect(()=>{i==="boss"&&ge("claude-opus-4-8[1m]")},[i]);const Ye=()=>{var c;console.log("[SpawnModal] handleSpawn called"),R(!1);const e=E&&((c=y.find(u=>u.sessionId===E))==null?void 0:c.projectPath)||M;if(console.log("[SpawnModal] Effective CWD:",e),console.log("[SpawnModal] Agent name:",m),console.log("[SpawnModal] Agent class:",i),console.log("[SpawnModal] Permission mode:",O),console.log("[SpawnModal] Provider:",o),console.log("[SpawnModal] Use Chrome:",z),console.log("[SpawnModal] Session ID:",E||"none"),!e.trim()){console.error("[SpawnModal] Empty CWD, showing error"),R(!0);return}if(!m.trim()){console.log("[SpawnModal] Empty name, regenerating");const u=new Set(Array.from(S.getState().agents.values()).map(g=>g.name));v(Ie(u,H));return}ds(ne.LAST_CWD,e),I(!0),b();const n=Array.from(fe),l=Ne.trim()||void 0;console.log("[SpawnModal] Calling store.spawnAgent with:",{name:m.trim(),class:i,cwd:e.trim(),sessionId:E||void 0,useChrome:o==="claude"?z:!1,permissionMode:O,provider:o,codexConfig:o==="codex"?f:void 0,codexModel:o==="codex"?ee:void 0,opencodeModel:o==="opencode"?se:void 0,initialSkillIds:n,model:o==="claude"?Z:void 0,customInstructions:l?`${l.length} chars`:void 0,spawnAreaId:N||void 0}),window.__spawnModalAreaContext=N?{areaId:N}:null,S.spawnAgent(m.trim(),i,e.trim(),_e||void 0,E||void 0,o==="claude"?z:!1,O,n,o,o==="codex"?f:void 0,o==="codex"?ee:void 0,o==="claude"?Z:void 0,l,o==="claude"?Q:void 0,o==="opencode"?se:void 0)},Ce=()=>{console.log("[SpawnModal] Agent creation successful"),I(!1),v(""),V(new Set),L(),C(),j()},Me=()=>{console.error("[SpawnModal] Agent creation failed"),I(!1),R(!0),L(),C()},ke=e=>{console.log("[SpawnModal] Directory not found:",e),I(!1),he(e),X(!0),C()},ye=()=>{X(!1),I(!0),b(),S.createDirectoryAndSpawn(ue,m.trim(),i)},ae=()=>{X(!1),he(""),L()};t.useEffect(()=>(window.__spawnModalSuccess=Ce,window.__spawnModalError=Me,window.__spawnModalDirNotFound=ke,()=>{L(),delete window.__spawnModalSuccess,delete window.__spawnModalError,delete window.__spawnModalDirNotFound}),[m,i,Ce,Me,ke,L]);const{handleMouseDown:Je,handleClick:Ve}=ls(j),Ze=e=>{e.key==="Escape"&&j()};return!r&&!me?null:me?s.jsx("div",{className:"modal-overlay visible",onClick:ae,onKeyDown:e=>{e.key==="Escape"&&ae(),e.key==="Enter"&&ye()},children:s.jsxs("div",{className:"modal confirm-modal",onClick:e=>e.stopPropagation(),children:[s.jsx("div",{className:"modal-header",children:a("terminal:spawn.directoryNotFound")}),s.jsxs("div",{className:"modal-body confirm-modal-body",children:[s.jsx("p",{children:a("terminal:spawn.directoryNotExist")}),s.jsx("code",{className:"confirm-modal-path",children:ue}),s.jsx("p",{children:a("terminal:spawn.wouldYouCreate")})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:ae,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:ye,autoFocus:!0,children:a("terminal:spawn.createDirectory")})]})]})}):s.jsx("div",{className:`modal-overlay ${r?"visible":""}`,onMouseDown:Je,onClick:Ve,onKeyDown:Ze,children:s.jsxs("div",{className:"modal spawn-modal",children:[s.jsx("div",{className:"modal-header",children:a("terminal:spawn.deployTitle")}),s.jsxs("div",{className:"modal-body spawn-modal-body",children:[s.jsxs("div",{className:"spawn-top-section",children:[s.jsx("div",{className:"spawn-preview-compact",children:s.jsx(os,{agentClass:Xe,modelFile:Be,customModelUrl:Ke,modelScale:He,width:100,height:120})}),s.jsxs("div",{className:"spawn-class-section",children:[s.jsx("div",{className:"spawn-class-label",children:a("terminal:spawn.agentClass")}),p.length+te.length>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:a("terminal:spawn.filterClasses"),value:h,onChange:e=>Te(e.target.value)}),s.jsxs("div",{className:"class-selector-inline",children:[W.map(e=>s.jsxs("button",{className:`class-chip ${i===e.id?"selected":""}`,onClick:()=>k(e.id),title:e.description,children:[s.jsx(De,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)),G.map(e=>{const n=Ae[e.id];return s.jsxs("button",{className:`class-chip ${i===e.id?"selected":""}`,onClick:()=>k(e.id),title:n.description,children:[s.jsx(De,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)}),h&&W.length===0&&G.length===0&&s.jsx("div",{className:"class-search-empty",children:a("terminal:spawn.noClassesMatch",{query:h})})]})]})]}),s.jsxs("div",{className:"spawn-form-section",children:[s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:a("common:labels.name")}),s.jsx("input",{ref:q,type:"text",className:"spawn-input",placeholder:a("terminal:spawn.agentNamePlaceholder"),value:m,onChange:e=>v(e.target.value)})]}),s.jsxs("div",{className:"spawn-field spawn-field-wide",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.workingDir"),s.jsx(x,{text:a("terminal:spawn.helpWorkingDir"),title:a("terminal:spawn.workingDir"),position:"top",size:"sm"})]}),s.jsx(is,{value:M,onChange:e=>{F(e),R(!1)},placeholder:a("terminal:spawn.workingDirPlaceholder"),className:`spawn-input ${Le?"error":""}`,directoriesOnly:!0})]})]}),s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.selectRuntime"),s.jsx(x,{text:a("terminal:spawn.helpRuntime"),title:a("terminal:spawn.runtimeTitle"),position:"top",size:"sm"})]}),s.jsxs("div",{className:"spawn-select-row",children:[s.jsxs("button",{className:`spawn-select-btn ${o==="claude"?"selected":""}`,onClick:()=>J("claude"),title:a("terminal:spawn.useClaudeCli"),children:[s.jsx("img",{src:"/assets/claude.ico",alt:"Claude",className:"spawn-provider-icon"}),s.jsx("span",{children:"Claude"})]}),s.jsxs("button",{className:`spawn-select-btn ${o==="codex"?"selected":""}`,onClick:()=>J("codex"),title:a("terminal:spawn.useCodexCli"),children:[s.jsx("img",{src:"/assets/codex.ico",alt:"Codex",className:"spawn-provider-icon"}),s.jsx("span",{children:"Codex"})]}),s.jsxs("button",{className:`spawn-select-btn spawn-select-btn--opencode ${o==="opencode"?"selected":""}`,onClick:()=>J("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[s.jsx("img",{src:"/assets/opencode.svg",alt:"OpenCode",className:"spawn-provider-icon"}),s.jsx("span",{children:"OpenCode"})]})]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("common:labels.permissions"),s.jsx(x,{text:a("terminal:spawn.helpPermission"),title:a("terminal:spawn.permissionMode"),position:"top",size:"sm"})]}),s.jsx("div",{className:"spawn-select-row",children:Object.keys(oe).map(e=>s.jsxs("button",{className:`spawn-select-btn ${O===e?"selected":""}`,onClick:()=>Fe(e),title:oe[e].description,children:[s.jsx("span",{children:s.jsx(ie,{name:e==="bypass"?"bolt":"lock",size:12})}),s.jsx("span",{children:oe[e].label})]},e))})]})]}),s.jsx("div",{className:"spawn-form-row",children:s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("common:labels.model"),s.jsx(x,{text:a("terminal:spawn.helpModel"),title:a("terminal:spawn.modelTitle"),position:"top",size:"sm"})]}),o==="claude"?s.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(T).filter(e=>!T[e].deprecated).map(e=>s.jsxs("button",{className:`spawn-select-btn ${Z===e?"selected":""}`,onClick:()=>ge(e),title:T[e].description,children:[s.jsx("span",{children:T[e].icon}),s.jsx("span",{children:T[e].label})]},e))}):o==="codex"?s.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(K).map(e=>s.jsxs("button",{className:`spawn-select-btn ${ee===e?"selected":""}`,onClick:()=>Re(e),title:K[e].description,children:[s.jsx("span",{children:K[e].icon}),s.jsx("span",{children:K[e].label})]},e))}):o==="opencode"?s.jsx(cs,{value:se,onChange:Ue,inputId:"spawn-opencode-model"}):s.jsx("div",{className:"spawn-inline-hint",children:a("terminal:spawn.chooseCodexModel")})]})}),s.jsxs("div",{className:"spawn-form-row",children:[o==="claude"&&s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:"Effort"}),s.jsxs("div",{className:"spawn-select-row spawn-select-row--effort",children:[s.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${Q===void 0?"selected":""}`,onClick:()=>je(void 0),title:"Use default effort level",children:s.jsx("span",{children:"Default"})}),Object.keys(ce).map(e=>s.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${Q===e?"selected":""}`,onClick:()=>je(e),title:ce[e].description,children:s.jsx("span",{children:ce[e].label})},e))]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:a("terminal:spawn.browser")}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:z,onChange:e=>Pe(e.target.checked),disabled:o!=="claude"}),s.jsxs("span",{children:[s.jsx(ie,{name:"globe",size:12})," ",a("terminal:spawn.chromeBrowser")]}),s.jsx(x,{text:a(o==="claude"?"terminal:spawn.helpChrome":"terminal:spawn.helpChromeDisabled"),title:a("terminal:spawn.chromeBrowser"),position:"top",size:"sm"})]})]})]}),o==="codex"&&s.jsxs("div",{className:"codex-config-section",children:[s.jsx("div",{className:"codex-config-title",children:a("terminal:spawn.codex.configuration")}),s.jsxs("div",{className:"codex-config-options",children:[s.jsxs("div",{className:"codex-option-group",children:[s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:f.fullAuto!==!1,onChange:e=>A(n=>({...n,fullAuto:e.target.checked}))}),s.jsx("span",{children:a("terminal:spawn.codex.fullAuto")}),s.jsx(x,{text:a("terminal:spawn.helpFullAuto"),title:a("terminal:spawn.fullAutoTitle"),position:"top",size:"sm"})]}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:!!f.search,onChange:e=>A(n=>({...n,search:e.target.checked}))}),s.jsx("span",{children:a("terminal:spawn.codex.search")}),s.jsx(x,{text:a("terminal:spawn.helpSearch"),title:a("terminal:spawn.searchTitle"),position:"top",size:"sm"})]})]}),f.fullAuto===!1&&s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.restrictions")}),s.jsxs("select",{className:"spawn-input codex-select",value:f.sandbox||"workspace-write",onChange:e=>A(n=>({...n,sandbox:e.target.value})),children:[s.jsxs("option",{value:"read-only",children:["📖 ",a("terminal:spawn.codex.sandboxReadOnly")]}),s.jsxs("option",{value:"workspace-write",children:["✏️ ",a("terminal:spawn.codex.sandboxWorkspaceWrite")]}),s.jsxs("option",{value:"danger-full-access",children:["⚡ ",a("terminal:spawn.codex.sandboxDangerFullAccess")]})]}),s.jsxs("select",{className:"spawn-input codex-select",value:f.approvalMode||"on-request",onChange:e=>A(n=>({...n,approvalMode:e.target.value})),children:[s.jsxs("option",{value:"untrusted",children:["🔒 ",a("terminal:spawn.codex.approvalsUntrusted")]}),s.jsxs("option",{value:"on-failure",children:["⚠️ ",a("terminal:spawn.codex.approvalsOnFailure")]}),s.jsxs("option",{value:"on-request",children:["🤔 ",a("terminal:spawn.codex.approvalsOnRequest")]}),s.jsxs("option",{value:"never",children:["✅ ",a("terminal:spawn.codex.approvalsNever")]})]})]}),s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.profile")}),s.jsx("input",{type:"text",className:"spawn-input codex-profile-input",placeholder:a("terminal:spawn.codex.profilePlaceholder"),value:f.profile||"",onChange:e=>A(n=>({...n,profile:e.target.value||void 0}))})]}),s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.reasoningEffort")}),s.jsxs("select",{className:"spawn-input codex-select",value:f.reasoningEffort||"",onChange:e=>A(n=>({...n,reasoningEffort:e.target.value||void 0})),children:[s.jsx("option",{value:"",children:a("terminal:spawn.codex.reasoningEffortDefault")}),Object.keys(re).map(e=>s.jsxs("option",{value:e,children:[re[e].icon," ",re[e].label]},e))]})]})]})]}),w.length>0&&s.jsxs("div",{className:"spawn-skills-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.skills")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpSkills"),title:a("terminal:spawn.skillsTitle"),position:"top",size:"sm"})]}),w.length>6&&s.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:a("terminal:spawn.filterSkills"),value:D,onChange:e=>Oe(e.target.value)}),s.jsxs("div",{className:"spawn-skills-inline",children:[Se.map(e=>{const n=fe.has(e.id);return Ge.some(c=>c.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${n?"selected":""}`,onClick:()=>We(e.id),title:e.description,children:[n&&s.jsx("span",{className:"spawn-skill-check",children:s.jsx(ie,{name:"check",size:10})}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),D&&Se.length===0&&s.jsx("div",{className:"skill-search-empty",children:a("terminal:spawn.noSkillsMatch",{query:D})})]})]}),s.jsxs("div",{className:"spawn-custom-instructions-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.customInstructions")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpCustomInstructions"),title:a("terminal:spawn.customInstructions"),position:"top",size:"sm"})]}),s.jsx("textarea",{className:"spawn-input spawn-textarea",placeholder:a("terminal:spawn.customInstructionsPlaceholder"),value:Ne,onChange:e=>ze(e.target.value),rows:3})]}),s.jsxs("div",{className:"spawn-sessions-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.linkSession")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpLinkSession"),title:a("terminal:spawn.linkSessionTitle"),position:"top",size:"sm"})]}),y.length>0&&s.jsx("input",{type:"text",className:"spawn-input session-search-input",placeholder:a("terminal:spawn.searchSessions"),value:_,onChange:e=>xe(e.target.value)}),s.jsx("div",{className:"sessions-list",children:$e?s.jsx("div",{className:"sessions-loading",children:a("terminal:spawn.loadingSessions")}):y.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessions")}):be.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessionsMatch",{query:_})}):be.map(e=>{const n=E===e.sessionId,l=Date.now()-new Date(e.lastModified).getTime(),c=l<6e4?a("common:time.justNow"):l<36e5?a("common:time.minutesAgo",{count:Math.floor(l/6e4)}):l<864e5?a("common:time.hoursAgo",{count:Math.floor(l/36e5)}):a("common:time.daysAgo",{count:Math.floor(l/864e5)});return s.jsxs("div",{className:`session-item ${n?"selected":""}`,onClick:()=>{n?U(null):(U(e.sessionId),F(e.projectPath))},children:[s.jsxs("div",{className:"session-item-header",children:[s.jsx("span",{className:"session-item-path",children:e.projectPath}),s.jsx("span",{className:"session-item-age",children:c})]}),s.jsx("div",{className:"session-item-preview",children:e.firstMessage||a("terminal:spawn.messagesCount",{count:e.messageCount})})]},e.sessionId)})})]})]})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:j,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:Ye,disabled:pe,children:a(pe?"common:buttons.deploying":"common:buttons2.deploy")})]})]})})}export{hs as SpawnModal};
1
+ import{u as Qe,aS as es,aT as ss,aU as as,aV as ns,r as t,W as Ee,S as ne,aW as te,A as Ae,i as le,h as ts,s as S,k as ls,j as s,aX as os,a6 as De,aY as x,aZ as is,a_ as oe,I as ie,aE as T,aC as K,a$ as cs,aD as ce,b0 as re,b1 as rs,X as ds}from"./main-CHE4wC7P.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function Ie(r,j){const b=j.filter(C=>!r.has(C));return b.length===0?`${j[Math.floor(Math.random()*j.length)]}-${Date.now()%1e3}`:b[Math.floor(Math.random()*b.length)]}function hs({isOpen:r,onClose:j,onSpawnStart:b,onSpawnEnd:C,spawnPosition:_e,spawnAreaId:N}){const{t:a}=Qe(["terminal","common"]),P=es(),p=ss(),de=as(),H=de.length>0?de:ns,[m,v]=t.useState(""),[M,F]=t.useState(()=>Ee(ne.LAST_CWD)),[i,k]=t.useState("scout"),[pe,I]=t.useState(!1),[Le,R]=t.useState(!1),[me,X]=t.useState(!1),[ue,he]=t.useState(""),[y,Y]=t.useState([]),[E,U]=t.useState(null),[$e,we]=t.useState(!1),[_,xe]=t.useState(""),[h,Te]=t.useState(""),[z,Pe]=t.useState(!1),[O,Fe]=t.useState("bypass"),[o,J]=t.useState("claude"),[f,A]=t.useState({fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[fe,V]=t.useState(new Set),[Z,ge]=t.useState("claude-opus-4-8[1m]"),[Q,je]=t.useState("xHigh"),[ee,Re]=t.useState("gpt-5.3-codex"),[se,Ue]=t.useState("minimax/MiniMax-M1-80k"),[Ne,ze]=t.useState(""),[D,Oe]=t.useState(""),q=t.useRef(null),ve=t.useRef(!1),L=t.useCallback(()=>{window.__spawnModalAreaContext=null},[]),w=t.useMemo(()=>P.filter(e=>e.enabled),[P]),qe=["full-notifications","streaming-exec","task-label","report-task-to-boss","agent-tracking","agent-memory","send-message-to-agent"];t.useEffect(()=>{if(r&&!ve.current){if(w.length>0){const l=w.filter(c=>qe.includes(c.slug)).map(c=>c.id);l.length>0&&V(new Set(l))}const n=Ee(ne.DEFAULT_AGENT_CLASS);if(n==="random"){const c=[...Object.keys(rs),...p.map(u=>u.id)];k(c[Math.floor(Math.random()*c.length)])}else k(n||"scout")}ve.current=r},[r,w,p]);const Se=t.useMemo(()=>{if(!D.trim())return w;const e=D.toLowerCase();return w.filter(n=>n.name.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)||n.slug.toLowerCase().includes(e))},[w,D]),We=t.useCallback(e=>{V(n=>{const l=new Set(n);return l.has(e)?l.delete(e):l.add(e),l})},[]);t.useMemo(()=>w.filter(e=>e.assignedAgentClasses.includes(i)),[w,i]);const Ge=t.useMemo(()=>{var n;const e=p.find(l=>l.id===i);return(n=e==null?void 0:e.defaultSkillIds)!=null&&n.length?P.filter(l=>e.defaultSkillIds.includes(l.id)):[]},[p,i,P]),be=t.useMemo(()=>{if(!_.trim())return y;const e=_.toLowerCase();return y.filter(n=>n.sessionId.toLowerCase().includes(e)||n.projectPath.toLowerCase().includes(e)||n.firstMessage&&n.firstMessage.toLowerCase().includes(e))},[y,_]),W=t.useMemo(()=>{if(!h.trim())return p;const e=h.toLowerCase();return p.filter(n=>n.name.toLowerCase().includes(e)||n.description.toLowerCase().includes(e)||n.id.toLowerCase().includes(e))},[p,h]),G=t.useMemo(()=>{if(!h.trim())return te;const e=h.toLowerCase();return te.filter(n=>{const l=Ae[n.id];return n.name.toLowerCase().includes(e)||n.id.toLowerCase().includes(e)||l.description.toLowerCase().includes(e)})},[h]);t.useEffect(()=>{if(!r||!h.trim())return;const e=[...W.map(n=>n.id),...G.map(n=>n.id)];e.length===1&&e[0]!==i&&k(e[0])},[r,h,W,G,i]);const d=t.useMemo(()=>p.find(e=>e.id===i),[p,i]),Be=t.useMemo(()=>{if(d!=null&&d.model)return d.model},[d]),Ke=t.useMemo(()=>{if(d!=null&&d.customModelPath)return le(`/api/custom-models/${d.id}`)},[d]),He=d==null?void 0:d.modelScale,Xe=t.useMemo(()=>d?"scout":i,[i,d]),B=t.useCallback(async e=>{we(!0);try{const n=e?le(`/api/agents/claude-sessions?cwd=${encodeURIComponent(e)}`):le("/api/agents/claude-sessions"),c=await(await ts(n)).json();Y(c.sessions||[])}catch(n){console.error("Failed to fetch sessions:",n),Y([])}finally{we(!1)}},[]);t.useEffect(()=>{r?B(M||void 0):(Y([]),U(null),xe(""))},[r,B]),t.useEffect(()=>{if(!r)return;const e=setTimeout(()=>{B(M||void 0),U(null)},300);return()=>clearTimeout(e)},[M,r,B]),t.useEffect(()=>{if(!r||!N)return;const e=S.getState().areas.get(N);if(e!=null&&e.directories&&e.directories.length>0){F(e.directories[0]);return}const n=Array.from(S.getState().agents.values()).filter(g=>{var $;return(($=S.getAreaForAgent(g.id))==null?void 0:$.id)===N&&g.cwd});if(n.length===0)return;const l=new Map;for(const g of n)l.set(g.cwd,(l.get(g.cwd)||0)+1);let c="",u=0;for(const[g,$]of l)$>u&&(c=g,u=$);c&&F(c)},[r,N]),t.useEffect(()=>{if(r){const e=new Set(Array.from(S.getState().agents.values()).map(u=>u.name)),n=Ie(e,H),l=p.find(u=>u.id===i),c=l?`${l.name} ${n}`:n;v(c),q.current&&(q.current.focus(),q.current.select())}},[r,H]),t.useEffect(()=>{if(!r)return;const e=p.find(n=>n.id===i);if(e){const n=p.find(l=>m.startsWith(l.name+" "));if(n){const l=m.substring(n.name.length+1);v(`${e.name} ${l}`)}else v(`${e.name} ${m}`)}else{const n=p.find(l=>m.startsWith(l.name+" "));if(n){const l=m.substring(n.name.length+1);v(l)}}},[i]),t.useEffect(()=>{i==="boss"&&ge("claude-opus-4-8[1m]")},[i]);const Ye=()=>{var c;console.log("[SpawnModal] handleSpawn called"),R(!1);const e=E&&((c=y.find(u=>u.sessionId===E))==null?void 0:c.projectPath)||M;if(console.log("[SpawnModal] Effective CWD:",e),console.log("[SpawnModal] Agent name:",m),console.log("[SpawnModal] Agent class:",i),console.log("[SpawnModal] Permission mode:",O),console.log("[SpawnModal] Provider:",o),console.log("[SpawnModal] Use Chrome:",z),console.log("[SpawnModal] Session ID:",E||"none"),!e.trim()){console.error("[SpawnModal] Empty CWD, showing error"),R(!0);return}if(!m.trim()){console.log("[SpawnModal] Empty name, regenerating");const u=new Set(Array.from(S.getState().agents.values()).map(g=>g.name));v(Ie(u,H));return}ds(ne.LAST_CWD,e),I(!0),b();const n=Array.from(fe),l=Ne.trim()||void 0;console.log("[SpawnModal] Calling store.spawnAgent with:",{name:m.trim(),class:i,cwd:e.trim(),sessionId:E||void 0,useChrome:o==="claude"?z:!1,permissionMode:O,provider:o,codexConfig:o==="codex"?f:void 0,codexModel:o==="codex"?ee:void 0,opencodeModel:o==="opencode"?se:void 0,initialSkillIds:n,model:o==="claude"?Z:void 0,customInstructions:l?`${l.length} chars`:void 0,spawnAreaId:N||void 0}),window.__spawnModalAreaContext=N?{areaId:N}:null,S.spawnAgent(m.trim(),i,e.trim(),_e||void 0,E||void 0,o==="claude"?z:!1,O,n,o,o==="codex"?f:void 0,o==="codex"?ee:void 0,o==="claude"?Z:void 0,l,o==="claude"?Q:void 0,o==="opencode"?se:void 0)},Ce=()=>{console.log("[SpawnModal] Agent creation successful"),I(!1),v(""),V(new Set),L(),C(),j()},Me=()=>{console.error("[SpawnModal] Agent creation failed"),I(!1),R(!0),L(),C()},ke=e=>{console.log("[SpawnModal] Directory not found:",e),I(!1),he(e),X(!0),C()},ye=()=>{X(!1),I(!0),b(),S.createDirectoryAndSpawn(ue,m.trim(),i)},ae=()=>{X(!1),he(""),L()};t.useEffect(()=>(window.__spawnModalSuccess=Ce,window.__spawnModalError=Me,window.__spawnModalDirNotFound=ke,()=>{L(),delete window.__spawnModalSuccess,delete window.__spawnModalError,delete window.__spawnModalDirNotFound}),[m,i,Ce,Me,ke,L]);const{handleMouseDown:Je,handleClick:Ve}=ls(j),Ze=e=>{e.key==="Escape"&&j()};return!r&&!me?null:me?s.jsx("div",{className:"modal-overlay visible",onClick:ae,onKeyDown:e=>{e.key==="Escape"&&ae(),e.key==="Enter"&&ye()},children:s.jsxs("div",{className:"modal confirm-modal",onClick:e=>e.stopPropagation(),children:[s.jsx("div",{className:"modal-header",children:a("terminal:spawn.directoryNotFound")}),s.jsxs("div",{className:"modal-body confirm-modal-body",children:[s.jsx("p",{children:a("terminal:spawn.directoryNotExist")}),s.jsx("code",{className:"confirm-modal-path",children:ue}),s.jsx("p",{children:a("terminal:spawn.wouldYouCreate")})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:ae,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:ye,autoFocus:!0,children:a("terminal:spawn.createDirectory")})]})]})}):s.jsx("div",{className:`modal-overlay ${r?"visible":""}`,onMouseDown:Je,onClick:Ve,onKeyDown:Ze,children:s.jsxs("div",{className:"modal spawn-modal",children:[s.jsx("div",{className:"modal-header",children:a("terminal:spawn.deployTitle")}),s.jsxs("div",{className:"modal-body spawn-modal-body",children:[s.jsxs("div",{className:"spawn-top-section",children:[s.jsx("div",{className:"spawn-preview-compact",children:s.jsx(os,{agentClass:Xe,modelFile:Be,customModelUrl:Ke,modelScale:He,width:100,height:120})}),s.jsxs("div",{className:"spawn-class-section",children:[s.jsx("div",{className:"spawn-class-label",children:a("terminal:spawn.agentClass")}),p.length+te.length>6&&s.jsx("input",{type:"text",className:"spawn-input class-search-input",placeholder:a("terminal:spawn.filterClasses"),value:h,onChange:e=>Te(e.target.value)}),s.jsxs("div",{className:"class-selector-inline",children:[W.map(e=>s.jsxs("button",{className:`class-chip ${i===e.id?"selected":""}`,onClick:()=>k(e.id),title:e.description,children:[s.jsx(De,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)),G.map(e=>{const n=Ae[e.id];return s.jsxs("button",{className:`class-chip ${i===e.id?"selected":""}`,onClick:()=>k(e.id),title:n.description,children:[s.jsx(De,{classId:e.id,size:18,className:"class-chip-icon"}),s.jsx("span",{className:"class-chip-name",children:e.name})]},e.id)}),h&&W.length===0&&G.length===0&&s.jsx("div",{className:"class-search-empty",children:a("terminal:spawn.noClassesMatch",{query:h})})]})]})]}),s.jsxs("div",{className:"spawn-form-section",children:[s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:a("common:labels.name")}),s.jsx("input",{ref:q,type:"text",className:"spawn-input",placeholder:a("terminal:spawn.agentNamePlaceholder"),value:m,onChange:e=>v(e.target.value)})]}),s.jsxs("div",{className:"spawn-field spawn-field-wide",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.workingDir"),s.jsx(x,{text:a("terminal:spawn.helpWorkingDir"),title:a("terminal:spawn.workingDir"),position:"top",size:"sm"})]}),s.jsx(is,{value:M,onChange:e=>{F(e),R(!1)},placeholder:a("terminal:spawn.workingDirPlaceholder"),className:`spawn-input ${Le?"error":""}`,directoriesOnly:!0})]})]}),s.jsxs("div",{className:"spawn-form-row",children:[s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.selectRuntime"),s.jsx(x,{text:a("terminal:spawn.helpRuntime"),title:a("terminal:spawn.runtimeTitle"),position:"top",size:"sm"})]}),s.jsxs("div",{className:"spawn-select-row",children:[s.jsxs("button",{className:`spawn-select-btn ${o==="claude"?"selected":""}`,onClick:()=>J("claude"),title:a("terminal:spawn.useClaudeCli"),children:[s.jsx("img",{src:"/assets/claude.ico",alt:"Claude",className:"spawn-provider-icon"}),s.jsx("span",{children:"Claude"})]}),s.jsxs("button",{className:`spawn-select-btn ${o==="codex"?"selected":""}`,onClick:()=>J("codex"),title:a("terminal:spawn.useCodexCli"),children:[s.jsx("img",{src:"/assets/codex.ico",alt:"Codex",className:"spawn-provider-icon"}),s.jsx("span",{children:"Codex"})]}),s.jsxs("button",{className:`spawn-select-btn spawn-select-btn--opencode ${o==="opencode"?"selected":""}`,onClick:()=>J("opencode"),title:"Use OpenCode CLI (multi-provider)",children:[s.jsx("img",{src:"/assets/opencode.svg",alt:"OpenCode",className:"spawn-provider-icon"}),s.jsx("span",{children:"OpenCode"})]})]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("common:labels.permissions"),s.jsx(x,{text:a("terminal:spawn.helpPermission"),title:a("terminal:spawn.permissionMode"),position:"top",size:"sm"})]}),s.jsx("div",{className:"spawn-select-row",children:Object.keys(oe).map(e=>s.jsxs("button",{className:`spawn-select-btn ${O===e?"selected":""}`,onClick:()=>Fe(e),title:oe[e].description,children:[s.jsx("span",{children:s.jsx(ie,{name:e==="bypass"?"bolt":"lock",size:12})}),s.jsx("span",{children:oe[e].label})]},e))})]})]}),s.jsx("div",{className:"spawn-form-row",children:s.jsxs("div",{className:"spawn-field",children:[s.jsxs("label",{className:"spawn-label",children:[a("common:labels.model"),s.jsx(x,{text:a("terminal:spawn.helpModel"),title:a("terminal:spawn.modelTitle"),position:"top",size:"sm"})]}),o==="claude"?s.jsx("div",{className:"spawn-select-row spawn-select-row--wrap",children:Object.keys(T).filter(e=>!T[e].deprecated).map(e=>s.jsxs("button",{className:`spawn-select-btn ${Z===e?"selected":""}`,onClick:()=>ge(e),title:T[e].description,children:[s.jsx("span",{children:T[e].icon}),s.jsx("span",{children:T[e].label})]},e))}):o==="codex"?s.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(K).map(e=>s.jsxs("button",{className:`spawn-select-btn ${ee===e?"selected":""}`,onClick:()=>Re(e),title:K[e].description,children:[s.jsx("span",{children:K[e].icon}),s.jsx("span",{children:K[e].label})]},e))}):o==="opencode"?s.jsx(cs,{value:se,onChange:Ue,inputId:"spawn-opencode-model"}):s.jsx("div",{className:"spawn-inline-hint",children:a("terminal:spawn.chooseCodexModel")})]})}),s.jsxs("div",{className:"spawn-form-row",children:[o==="claude"&&s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:"Effort"}),s.jsxs("div",{className:"spawn-select-row spawn-select-row--effort",children:[s.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${Q===void 0?"selected":""}`,onClick:()=>je(void 0),title:"Use default effort level",children:s.jsx("span",{children:"Default"})}),Object.keys(ce).map(e=>s.jsx("button",{className:`spawn-select-btn spawn-select-btn--compact ${Q===e?"selected":""}`,onClick:()=>je(e),title:ce[e].description,children:s.jsx("span",{children:ce[e].label})},e))]})]}),s.jsxs("div",{className:"spawn-field",children:[s.jsx("label",{className:"spawn-label",children:a("terminal:spawn.browser")}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:z,onChange:e=>Pe(e.target.checked),disabled:o!=="claude"}),s.jsxs("span",{children:[s.jsx(ie,{name:"globe",size:12})," ",a("terminal:spawn.chromeBrowser")]}),s.jsx(x,{text:a(o==="claude"?"terminal:spawn.helpChrome":"terminal:spawn.helpChromeDisabled"),title:a("terminal:spawn.chromeBrowser"),position:"top",size:"sm"})]})]})]}),o==="codex"&&s.jsxs("div",{className:"codex-config-section",children:[s.jsx("div",{className:"codex-config-title",children:a("terminal:spawn.codex.configuration")}),s.jsxs("div",{className:"codex-config-options",children:[s.jsxs("div",{className:"codex-option-group",children:[s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:f.fullAuto!==!1,onChange:e=>A(n=>({...n,fullAuto:e.target.checked}))}),s.jsx("span",{children:a("terminal:spawn.codex.fullAuto")}),s.jsx(x,{text:a("terminal:spawn.helpFullAuto"),title:a("terminal:spawn.fullAutoTitle"),position:"top",size:"sm"})]}),s.jsxs("label",{className:"spawn-checkbox",children:[s.jsx("input",{type:"checkbox",checked:!!f.search,onChange:e=>A(n=>({...n,search:e.target.checked}))}),s.jsx("span",{children:a("terminal:spawn.codex.search")}),s.jsx(x,{text:a("terminal:spawn.helpSearch"),title:a("terminal:spawn.searchTitle"),position:"top",size:"sm"})]})]}),f.fullAuto===!1&&s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.restrictions")}),s.jsxs("select",{className:"spawn-input codex-select",value:f.sandbox||"workspace-write",onChange:e=>A(n=>({...n,sandbox:e.target.value})),children:[s.jsxs("option",{value:"read-only",children:["📖 ",a("terminal:spawn.codex.sandboxReadOnly")]}),s.jsxs("option",{value:"workspace-write",children:["✏️ ",a("terminal:spawn.codex.sandboxWorkspaceWrite")]}),s.jsxs("option",{value:"danger-full-access",children:["⚡ ",a("terminal:spawn.codex.sandboxDangerFullAccess")]})]}),s.jsxs("select",{className:"spawn-input codex-select",value:f.approvalMode||"on-request",onChange:e=>A(n=>({...n,approvalMode:e.target.value})),children:[s.jsxs("option",{value:"untrusted",children:["🔒 ",a("terminal:spawn.codex.approvalsUntrusted")]}),s.jsxs("option",{value:"on-failure",children:["⚠️ ",a("terminal:spawn.codex.approvalsOnFailure")]}),s.jsxs("option",{value:"on-request",children:["🤔 ",a("terminal:spawn.codex.approvalsOnRequest")]}),s.jsxs("option",{value:"never",children:["✅ ",a("terminal:spawn.codex.approvalsNever")]})]})]}),s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.profile")}),s.jsx("input",{type:"text",className:"spawn-input codex-profile-input",placeholder:a("terminal:spawn.codex.profilePlaceholder"),value:f.profile||"",onChange:e=>A(n=>({...n,profile:e.target.value||void 0}))})]}),s.jsxs("div",{className:"codex-option-group",children:[s.jsx("div",{className:"codex-option-header",children:a("terminal:spawn.codex.reasoningEffort")}),s.jsxs("select",{className:"spawn-input codex-select",value:f.reasoningEffort||"",onChange:e=>A(n=>({...n,reasoningEffort:e.target.value||void 0})),children:[s.jsx("option",{value:"",children:a("terminal:spawn.codex.reasoningEffortDefault")}),Object.keys(re).map(e=>s.jsxs("option",{value:e,children:[re[e].icon," ",re[e].label]},e))]})]})]})]}),w.length>0&&s.jsxs("div",{className:"spawn-skills-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.skills")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpSkills"),title:a("terminal:spawn.skillsTitle"),position:"top",size:"sm"})]}),w.length>6&&s.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:a("terminal:spawn.filterSkills"),value:D,onChange:e=>Oe(e.target.value)}),s.jsxs("div",{className:"spawn-skills-inline",children:[Se.map(e=>{const n=fe.has(e.id);return Ge.some(c=>c.id===e.id)?null:s.jsxs("button",{className:`spawn-skill-chip ${n?"selected":""}`,onClick:()=>We(e.id),title:e.description,children:[n&&s.jsx("span",{className:"spawn-skill-check",children:s.jsx(ie,{name:"check",size:10})}),s.jsx("span",{children:e.name}),e.builtin&&s.jsx("span",{className:"spawn-skill-builtin",children:"TC"})]},e.id)}),D&&Se.length===0&&s.jsx("div",{className:"skill-search-empty",children:a("terminal:spawn.noSkillsMatch",{query:D})})]})]}),s.jsxs("div",{className:"spawn-custom-instructions-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.customInstructions")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpCustomInstructions"),title:a("terminal:spawn.customInstructions"),position:"top",size:"sm"})]}),s.jsx("textarea",{className:"spawn-input spawn-textarea",placeholder:a("terminal:spawn.customInstructionsPlaceholder"),value:Ne,onChange:e=>ze(e.target.value),rows:3})]}),s.jsxs("div",{className:"spawn-sessions-section",children:[s.jsxs("label",{className:"spawn-label",children:[a("terminal:spawn.linkSession")," ",s.jsxs("span",{className:"spawn-label-hint",children:["(",a("common:labels.optional"),")"]}),s.jsx(x,{text:a("terminal:spawn.helpLinkSession"),title:a("terminal:spawn.linkSessionTitle"),position:"top",size:"sm"})]}),y.length>0&&s.jsx("input",{type:"text",className:"spawn-input session-search-input",placeholder:a("terminal:spawn.searchSessions"),value:_,onChange:e=>xe(e.target.value)}),s.jsx("div",{className:"sessions-list",children:$e?s.jsx("div",{className:"sessions-loading",children:a("terminal:spawn.loadingSessions")}):y.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessions")}):be.length===0?s.jsx("div",{className:"sessions-empty",children:a("terminal:spawn.noSessionsMatch",{query:_})}):be.map(e=>{const n=E===e.sessionId,l=Date.now()-new Date(e.lastModified).getTime(),c=l<6e4?a("common:time.justNow"):l<36e5?a("common:time.minutesAgo",{count:Math.floor(l/6e4)}):l<864e5?a("common:time.hoursAgo",{count:Math.floor(l/36e5)}):a("common:time.daysAgo",{count:Math.floor(l/864e5)});return s.jsxs("div",{className:`session-item ${n?"selected":""}`,onClick:()=>{n?U(null):(U(e.sessionId),F(e.projectPath))},children:[s.jsxs("div",{className:"session-item-header",children:[s.jsx("span",{className:"session-item-path",children:e.projectPath}),s.jsx("span",{className:"session-item-age",children:c})]}),s.jsx("div",{className:"session-item-preview",children:e.firstMessage||a("terminal:spawn.messagesCount",{count:e.messageCount})})]},e.sessionId)})})]})]})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:j,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:Ye,disabled:pe,children:a(pe?"common:buttons.deploying":"common:buttons2.deploy")})]})]})})}export{hs as SpawnModal};
@@ -1 +1 @@
1
- import{u as F,k as R,al as j,cB as U,cC as B,j as t,be as G,I,bF as k}from"./main-DhXGHPKx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const b=["#6ab8c8","#c89a5a","#9a80c0","#5cb88a","#c85a5a","#c87a9a","#c8c87a","#5a8fd4","#d45a5a","#8a6fbf"],P=14,w=720,C=260,p={top:16,right:20,bottom:42,left:64};function W(){const i=new Date;return i.setHours(0,0,0,0),i.getTime()}function $(i){if(!i)return"N/A";try{return new Date(i).toLocaleString()}catch{return"N/A"}}function z(i,s){if(i.length===0||s<=0)return"conic-gradient(rgba(50, 50, 62, 0.95) 0deg 360deg)";let a=0;return`conic-gradient(${i.map((h,l)=>{const c=a,n=h.tokens.total/s*360;return a+=n,`${b[l%b.length]} ${c.toFixed(2)}deg ${a.toFixed(2)}deg`}).join(", ")})`}function E(i){const[,s,a]=i.split("-");return!s||!a?i:`${s}/${a}`}function q(i){const s=(i==null?void 0:i.days)??[];if(s.length===0)return[];const a=new Map;for(const l of s)for(const c of l.agents){const n=a.get(c.agentId)??{agentName:c.agentName,total:0};n.total+=c.tokens.total,a.set(c.agentId,n)}const r={id:"general",name:"General",color:"#f1fa8c",values:s.map(l=>l.totalTokens),total:s.reduce((l,c)=>l+c.totalTokens,0),peak:Math.max(0,...s.map(l=>l.totalTokens)),isTotal:!0},h=[...a.entries()].sort((l,c)=>c[1].total-l[1].total).map(([l,c],n)=>({id:l,name:c.agentName,color:b[n%b.length],values:s.map(u=>{var d;return((d=u.agents.find(x=>x.agentId===l))==null?void 0:d.tokens.total)??0}),total:c.total,peak:Math.max(0,...s.map(u=>{var d;return((d=u.agents.find(x=>x.agentId===l))==null?void 0:d.tokens.total)??0}))}));return[r,...h].filter(l=>l.total>0)}function Y(i){if(i<=0)return 1;const s=10**Math.floor(Math.log10(i)),a=i/s;return(a<=1?1:a<=2?2:a<=5?5:10)*s}function H(i,s,a,r){const h=p.left,l=p.top,c=w-p.left-p.right,n=C-p.top-p.bottom,u=i<=1?h+c/2:h+s/(i-1)*c,d=l+n-a/r*n;return{x:u,y:d}}function X(i,s){return i.map((a,r)=>{const{x:h,y:l}=H(i.length,r,a,s);return`${h.toFixed(2)},${l.toFixed(2)}`}).join(" ")}function J(i,s=28){return i.length<=s?i:`${i.slice(0,s-1)}...`}function K({summary:i}){const[s,a]=j.useState(null),r=i.days,h=q(i),l=Math.max(1,...h.flatMap(e=>e.values)),c=Y(l),n=p.left,u=p.top,d=w-p.left-p.right,x=C-p.top-p.bottom,f=[0,.5,1],M=Math.max(1,Math.ceil(r.length/5)),v=190,y=86,g=s?Math.min(Math.max(s.x+12,8),w-v-8):0,_=s?Math.min(Math.max(s.y-y-10,8),C-y-8):0;return t.jsxs("div",{className:"statistics-line-chart",children:[t.jsxs("svg",{className:"statistics-line-chart__svg",viewBox:`0 0 ${w} ${C}`,role:"img","aria-label":"Daily Claude token usage by agent",preserveAspectRatio:"xMidYMid meet",onMouseLeave:()=>a(null),children:[f.map(e=>{const m=u+x-e*x;return t.jsxs("g",{children:[t.jsx("line",{className:"statistics-line-chart__grid",x1:n,y1:m,x2:n+d,y2:m}),t.jsx("text",{className:"statistics-line-chart__axis-label",x:n-10,y:m+4,textAnchor:"end",children:k(Math.round(c*e))})]},e)}),t.jsx("line",{className:"statistics-line-chart__axis",x1:n,y1:u,x2:n,y2:u+x}),t.jsx("line",{className:"statistics-line-chart__axis",x1:n,y1:u+x,x2:n+d,y2:u+x}),r.map((e,m)=>{if(m!==0&&m!==r.length-1&&m%M!==0)return null;const o=r.length<=1?n+d/2:n+m/(r.length-1)*d;return t.jsx("text",{className:"statistics-line-chart__axis-label",x:o,y:C-14,textAnchor:"middle",children:E(e.date)},e.date)}),h.map(e=>t.jsx("polyline",{className:e.isTotal?"statistics-line-chart__line statistics-line-chart__line--total":"statistics-line-chart__line",points:X(e.values,c),fill:"none",stroke:e.color,strokeWidth:e.isTotal?3:2,strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("title",{children:`${e.name}: ${e.peak.toLocaleString()} peak daily tokens`})},e.id)),h.map(e=>e.values.map((m,o)=>{var L,D,V,A;const{x:N,y:S}=H(r.length,o,m,c),T={id:`${e.id}-${(L=r[o])==null?void 0:L.date}`,date:((D=r[o])==null?void 0:D.date)??"",name:e.name,color:e.color,value:m,total:e.total,peak:e.peak,x:N,y:S};return t.jsxs("g",{children:[t.jsx("circle",{className:"statistics-line-chart__point",cx:N,cy:S,r:e.isTotal?3.4:2.6,fill:e.color}),t.jsx("circle",{className:"statistics-line-chart__point-hit",cx:N,cy:S,r:10,tabIndex:0,role:"button","aria-label":`${e.name} ${(V=r[o])==null?void 0:V.date}: ${m.toLocaleString()} tokens`,onMouseEnter:()=>a(T),onFocus:()=>a(T),onBlur:()=>a(null)})]},`${e.id}-${(A=r[o])==null?void 0:A.date}`)})),s&&t.jsxs("g",{className:"statistics-line-chart__tooltip",children:[t.jsx("line",{className:"statistics-line-chart__hover-line",x1:s.x,y1:u,x2:s.x,y2:u+x}),t.jsx("circle",{className:"statistics-line-chart__hover-point",cx:s.x,cy:s.y,r:5,fill:s.color}),t.jsx("rect",{className:"statistics-line-chart__tooltip-box",x:g,y:_,width:v,height:y,rx:6}),t.jsx("text",{className:"statistics-line-chart__tooltip-title",x:g+10,y:_+18,children:E(s.date)}),t.jsx("text",{className:"statistics-line-chart__tooltip-name",x:g+10,y:_+34,children:J(s.name)}),t.jsxs("text",{className:"statistics-line-chart__tooltip-value",x:g+10,y:_+52,children:["Daily: ",k(s.value)]}),t.jsxs("text",{className:"statistics-line-chart__tooltip-meta",x:g+10,y:_+68,children:["Peak: ",k(s.peak)]}),t.jsxs("text",{className:"statistics-line-chart__tooltip-meta",x:g+100,y:_+68,children:["Total: ",k(s.total)]})]})]}),t.jsx("div",{className:"statistics-line-chart__legend",children:h.map(e=>t.jsxs("div",{className:"statistics-line-chart__legend-item",title:`${e.name}: peak ${e.peak.toLocaleString()} daily tokens, ${e.total.toLocaleString()} period tokens`,children:[t.jsx("span",{className:"statistics-line-chart__legend-swatch",style:{backgroundColor:e.color}}),t.jsx("span",{children:e.name}),t.jsx("strong",{children:k(e.peak)})]},e.id))})]})}function tt({isOpen:i,onClose:s}){const{t:a}=F(["terminal","common"]),{handleMouseDown:r,handleClick:h}=R(s),[l,c]=j.useState(null),[n,u]=j.useState(null),[d,x]=j.useState(!1),[f,M]=j.useState(null),v=j.useMemo(()=>W(),[]),y=j.useCallback(async()=>{x(!0),M(null);try{const o=Date.now(),[N,S]=await Promise.all([U({since:v,until:o}),B({days:P,until:o})]);c(N),u(S)}catch(o){M((o==null?void 0:o.message)||"Error")}finally{x(!1)}},[v]);if(j.useEffect(()=>{i&&y()},[i,y]),!i)return null;const g=(l==null?void 0:l.entries)??[],_=(l==null?void 0:l.totalTokens)??0,e=z(g,_),m=((n==null?void 0:n.days)??[]).some(o=>o.totalTokens>0);return t.jsx(G,{children:t.jsx("div",{className:"modal-overlay visible",onMouseDown:r,onClick:h,children:t.jsxs("div",{className:"modal statistics-modal",children:[t.jsxs("div",{className:"modal-header statistics-modal__header",children:[t.jsxs("div",{className:"statistics-modal__title",children:[t.jsx("span",{className:"statistics-modal__icon",children:t.jsx(I,{name:"dashboard",size:15})}),t.jsx("span",{children:a("terminal:statistics.title",{defaultValue:"Statistics"})})]}),t.jsx("button",{className:"modal-close statistics-modal__close",onClick:s,title:a("common:buttons.close"),children:"×"})]}),t.jsxs("div",{className:"modal-body statistics-modal__body",children:[t.jsxs("section",{className:"statistics-panel",children:[t.jsxs("div",{className:"statistics-panel__header",children:[t.jsxs("div",{children:[t.jsx("h3",{children:a("terminal:statistics.usageByAgent",{defaultValue:"Claude usage today"})}),t.jsx("span",{className:"statistics-panel__subtitle",children:a("terminal:statistics.usageByAgentSubtitle",{defaultValue:"Input + cache creation + cache read + output tokens, deduped by Claude request id"})})]}),t.jsx("button",{type:"button",className:"statistics-panel__refresh",onClick:y,disabled:d,title:a("terminal:statistics.refresh",{defaultValue:"Refresh usage"}),children:t.jsx(I,{name:"refresh",size:14})})]}),d&&!l&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!d&&f&&t.jsx("div",{className:"statistics-panel__empty statistics-panel__empty--error",children:a("terminal:statistics.error",{defaultValue:"Failed to load usage: {{error}}",error:f})}),!f&&l&&g.length===0&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.empty",{defaultValue:"No Claude token usage found for today."})}),!f&&l&&g.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"statistics-panel__layout",children:[t.jsx("div",{className:"statistics-panel__chart-wrap",children:t.jsx("div",{className:"statistics-panel__pie",style:{background:e},role:"img","aria-label":a("terminal:statistics.pieLabel",{defaultValue:"Claude token usage by agent"}),children:t.jsxs("div",{className:"statistics-panel__pie-hole",children:[t.jsx("strong",{children:k(_)}),t.jsx("span",{children:a("terminal:statistics.total",{defaultValue:"total"})})]})})}),t.jsx("div",{className:"statistics-panel__list",children:g.map((o,N)=>t.jsxs("div",{className:"statistics-panel__row",title:`${o.agentName}: ${o.tokens.total.toLocaleString()} tokens`,children:[t.jsx("span",{className:"statistics-panel__swatch",style:{backgroundColor:b[N%b.length]}}),t.jsxs("div",{className:"statistics-panel__row-main",children:[t.jsx("div",{className:"statistics-panel__row-name",children:o.agentName}),t.jsxs("div",{className:"statistics-panel__row-meta",children:[o.requestCount.toLocaleString()," ",a("terminal:statistics.requests",{defaultValue:"requests"})," / ",o.percent,"%"]})]}),t.jsx("strong",{children:k(o.tokens.total)})]},o.agentId))})]}),t.jsx("div",{className:"statistics-panel__footnote",children:a("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:$(l.since),until:$(l.until)})})]})]}),t.jsxs("section",{className:"statistics-panel",children:[t.jsx("div",{className:"statistics-panel__header",children:t.jsxs("div",{children:[t.jsx("h3",{children:a("terminal:statistics.dailyUsage",{defaultValue:"Daily usage by agent"})}),t.jsx("span",{className:"statistics-panel__subtitle",children:a("terminal:statistics.dailyUsageSubtitle",{defaultValue:"General token usage by day plus one line for each Claude agent."})})]})}),d&&!n&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!d&&!f&&n&&!m&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.dailyEmpty",{defaultValue:"No Claude token usage found for recent days."})}),!f&&n&&m&&t.jsxs(t.Fragment,{children:[t.jsx(K,{summary:n}),t.jsx("div",{className:"statistics-panel__footnote",children:a("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:$(n.since),until:$(n.until)})})]})]})]})]})})})}export{tt as StatisticsModal};
1
+ import{u as F,k as R,al as j,cB as U,cC as B,j as t,be as G,I,bF as k}from"./main-CHE4wC7P.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const b=["#6ab8c8","#c89a5a","#9a80c0","#5cb88a","#c85a5a","#c87a9a","#c8c87a","#5a8fd4","#d45a5a","#8a6fbf"],P=14,w=720,C=260,p={top:16,right:20,bottom:42,left:64};function W(){const i=new Date;return i.setHours(0,0,0,0),i.getTime()}function $(i){if(!i)return"N/A";try{return new Date(i).toLocaleString()}catch{return"N/A"}}function z(i,s){if(i.length===0||s<=0)return"conic-gradient(rgba(50, 50, 62, 0.95) 0deg 360deg)";let a=0;return`conic-gradient(${i.map((h,l)=>{const c=a,n=h.tokens.total/s*360;return a+=n,`${b[l%b.length]} ${c.toFixed(2)}deg ${a.toFixed(2)}deg`}).join(", ")})`}function E(i){const[,s,a]=i.split("-");return!s||!a?i:`${s}/${a}`}function q(i){const s=(i==null?void 0:i.days)??[];if(s.length===0)return[];const a=new Map;for(const l of s)for(const c of l.agents){const n=a.get(c.agentId)??{agentName:c.agentName,total:0};n.total+=c.tokens.total,a.set(c.agentId,n)}const r={id:"general",name:"General",color:"#f1fa8c",values:s.map(l=>l.totalTokens),total:s.reduce((l,c)=>l+c.totalTokens,0),peak:Math.max(0,...s.map(l=>l.totalTokens)),isTotal:!0},h=[...a.entries()].sort((l,c)=>c[1].total-l[1].total).map(([l,c],n)=>({id:l,name:c.agentName,color:b[n%b.length],values:s.map(u=>{var d;return((d=u.agents.find(x=>x.agentId===l))==null?void 0:d.tokens.total)??0}),total:c.total,peak:Math.max(0,...s.map(u=>{var d;return((d=u.agents.find(x=>x.agentId===l))==null?void 0:d.tokens.total)??0}))}));return[r,...h].filter(l=>l.total>0)}function Y(i){if(i<=0)return 1;const s=10**Math.floor(Math.log10(i)),a=i/s;return(a<=1?1:a<=2?2:a<=5?5:10)*s}function H(i,s,a,r){const h=p.left,l=p.top,c=w-p.left-p.right,n=C-p.top-p.bottom,u=i<=1?h+c/2:h+s/(i-1)*c,d=l+n-a/r*n;return{x:u,y:d}}function X(i,s){return i.map((a,r)=>{const{x:h,y:l}=H(i.length,r,a,s);return`${h.toFixed(2)},${l.toFixed(2)}`}).join(" ")}function J(i,s=28){return i.length<=s?i:`${i.slice(0,s-1)}...`}function K({summary:i}){const[s,a]=j.useState(null),r=i.days,h=q(i),l=Math.max(1,...h.flatMap(e=>e.values)),c=Y(l),n=p.left,u=p.top,d=w-p.left-p.right,x=C-p.top-p.bottom,f=[0,.5,1],M=Math.max(1,Math.ceil(r.length/5)),v=190,y=86,g=s?Math.min(Math.max(s.x+12,8),w-v-8):0,_=s?Math.min(Math.max(s.y-y-10,8),C-y-8):0;return t.jsxs("div",{className:"statistics-line-chart",children:[t.jsxs("svg",{className:"statistics-line-chart__svg",viewBox:`0 0 ${w} ${C}`,role:"img","aria-label":"Daily Claude token usage by agent",preserveAspectRatio:"xMidYMid meet",onMouseLeave:()=>a(null),children:[f.map(e=>{const m=u+x-e*x;return t.jsxs("g",{children:[t.jsx("line",{className:"statistics-line-chart__grid",x1:n,y1:m,x2:n+d,y2:m}),t.jsx("text",{className:"statistics-line-chart__axis-label",x:n-10,y:m+4,textAnchor:"end",children:k(Math.round(c*e))})]},e)}),t.jsx("line",{className:"statistics-line-chart__axis",x1:n,y1:u,x2:n,y2:u+x}),t.jsx("line",{className:"statistics-line-chart__axis",x1:n,y1:u+x,x2:n+d,y2:u+x}),r.map((e,m)=>{if(m!==0&&m!==r.length-1&&m%M!==0)return null;const o=r.length<=1?n+d/2:n+m/(r.length-1)*d;return t.jsx("text",{className:"statistics-line-chart__axis-label",x:o,y:C-14,textAnchor:"middle",children:E(e.date)},e.date)}),h.map(e=>t.jsx("polyline",{className:e.isTotal?"statistics-line-chart__line statistics-line-chart__line--total":"statistics-line-chart__line",points:X(e.values,c),fill:"none",stroke:e.color,strokeWidth:e.isTotal?3:2,strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("title",{children:`${e.name}: ${e.peak.toLocaleString()} peak daily tokens`})},e.id)),h.map(e=>e.values.map((m,o)=>{var L,D,V,A;const{x:N,y:S}=H(r.length,o,m,c),T={id:`${e.id}-${(L=r[o])==null?void 0:L.date}`,date:((D=r[o])==null?void 0:D.date)??"",name:e.name,color:e.color,value:m,total:e.total,peak:e.peak,x:N,y:S};return t.jsxs("g",{children:[t.jsx("circle",{className:"statistics-line-chart__point",cx:N,cy:S,r:e.isTotal?3.4:2.6,fill:e.color}),t.jsx("circle",{className:"statistics-line-chart__point-hit",cx:N,cy:S,r:10,tabIndex:0,role:"button","aria-label":`${e.name} ${(V=r[o])==null?void 0:V.date}: ${m.toLocaleString()} tokens`,onMouseEnter:()=>a(T),onFocus:()=>a(T),onBlur:()=>a(null)})]},`${e.id}-${(A=r[o])==null?void 0:A.date}`)})),s&&t.jsxs("g",{className:"statistics-line-chart__tooltip",children:[t.jsx("line",{className:"statistics-line-chart__hover-line",x1:s.x,y1:u,x2:s.x,y2:u+x}),t.jsx("circle",{className:"statistics-line-chart__hover-point",cx:s.x,cy:s.y,r:5,fill:s.color}),t.jsx("rect",{className:"statistics-line-chart__tooltip-box",x:g,y:_,width:v,height:y,rx:6}),t.jsx("text",{className:"statistics-line-chart__tooltip-title",x:g+10,y:_+18,children:E(s.date)}),t.jsx("text",{className:"statistics-line-chart__tooltip-name",x:g+10,y:_+34,children:J(s.name)}),t.jsxs("text",{className:"statistics-line-chart__tooltip-value",x:g+10,y:_+52,children:["Daily: ",k(s.value)]}),t.jsxs("text",{className:"statistics-line-chart__tooltip-meta",x:g+10,y:_+68,children:["Peak: ",k(s.peak)]}),t.jsxs("text",{className:"statistics-line-chart__tooltip-meta",x:g+100,y:_+68,children:["Total: ",k(s.total)]})]})]}),t.jsx("div",{className:"statistics-line-chart__legend",children:h.map(e=>t.jsxs("div",{className:"statistics-line-chart__legend-item",title:`${e.name}: peak ${e.peak.toLocaleString()} daily tokens, ${e.total.toLocaleString()} period tokens`,children:[t.jsx("span",{className:"statistics-line-chart__legend-swatch",style:{backgroundColor:e.color}}),t.jsx("span",{children:e.name}),t.jsx("strong",{children:k(e.peak)})]},e.id))})]})}function tt({isOpen:i,onClose:s}){const{t:a}=F(["terminal","common"]),{handleMouseDown:r,handleClick:h}=R(s),[l,c]=j.useState(null),[n,u]=j.useState(null),[d,x]=j.useState(!1),[f,M]=j.useState(null),v=j.useMemo(()=>W(),[]),y=j.useCallback(async()=>{x(!0),M(null);try{const o=Date.now(),[N,S]=await Promise.all([U({since:v,until:o}),B({days:P,until:o})]);c(N),u(S)}catch(o){M((o==null?void 0:o.message)||"Error")}finally{x(!1)}},[v]);if(j.useEffect(()=>{i&&y()},[i,y]),!i)return null;const g=(l==null?void 0:l.entries)??[],_=(l==null?void 0:l.totalTokens)??0,e=z(g,_),m=((n==null?void 0:n.days)??[]).some(o=>o.totalTokens>0);return t.jsx(G,{children:t.jsx("div",{className:"modal-overlay visible",onMouseDown:r,onClick:h,children:t.jsxs("div",{className:"modal statistics-modal",children:[t.jsxs("div",{className:"modal-header statistics-modal__header",children:[t.jsxs("div",{className:"statistics-modal__title",children:[t.jsx("span",{className:"statistics-modal__icon",children:t.jsx(I,{name:"dashboard",size:15})}),t.jsx("span",{children:a("terminal:statistics.title",{defaultValue:"Statistics"})})]}),t.jsx("button",{className:"modal-close statistics-modal__close",onClick:s,title:a("common:buttons.close"),children:"×"})]}),t.jsxs("div",{className:"modal-body statistics-modal__body",children:[t.jsxs("section",{className:"statistics-panel",children:[t.jsxs("div",{className:"statistics-panel__header",children:[t.jsxs("div",{children:[t.jsx("h3",{children:a("terminal:statistics.usageByAgent",{defaultValue:"Claude usage today"})}),t.jsx("span",{className:"statistics-panel__subtitle",children:a("terminal:statistics.usageByAgentSubtitle",{defaultValue:"Input + cache creation + cache read + output tokens, deduped by Claude request id"})})]}),t.jsx("button",{type:"button",className:"statistics-panel__refresh",onClick:y,disabled:d,title:a("terminal:statistics.refresh",{defaultValue:"Refresh usage"}),children:t.jsx(I,{name:"refresh",size:14})})]}),d&&!l&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!d&&f&&t.jsx("div",{className:"statistics-panel__empty statistics-panel__empty--error",children:a("terminal:statistics.error",{defaultValue:"Failed to load usage: {{error}}",error:f})}),!f&&l&&g.length===0&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.empty",{defaultValue:"No Claude token usage found for today."})}),!f&&l&&g.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"statistics-panel__layout",children:[t.jsx("div",{className:"statistics-panel__chart-wrap",children:t.jsx("div",{className:"statistics-panel__pie",style:{background:e},role:"img","aria-label":a("terminal:statistics.pieLabel",{defaultValue:"Claude token usage by agent"}),children:t.jsxs("div",{className:"statistics-panel__pie-hole",children:[t.jsx("strong",{children:k(_)}),t.jsx("span",{children:a("terminal:statistics.total",{defaultValue:"total"})})]})})}),t.jsx("div",{className:"statistics-panel__list",children:g.map((o,N)=>t.jsxs("div",{className:"statistics-panel__row",title:`${o.agentName}: ${o.tokens.total.toLocaleString()} tokens`,children:[t.jsx("span",{className:"statistics-panel__swatch",style:{backgroundColor:b[N%b.length]}}),t.jsxs("div",{className:"statistics-panel__row-main",children:[t.jsx("div",{className:"statistics-panel__row-name",children:o.agentName}),t.jsxs("div",{className:"statistics-panel__row-meta",children:[o.requestCount.toLocaleString()," ",a("terminal:statistics.requests",{defaultValue:"requests"})," / ",o.percent,"%"]})]}),t.jsx("strong",{children:k(o.tokens.total)})]},o.agentId))})]}),t.jsx("div",{className:"statistics-panel__footnote",children:a("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:$(l.since),until:$(l.until)})})]})]}),t.jsxs("section",{className:"statistics-panel",children:[t.jsx("div",{className:"statistics-panel__header",children:t.jsxs("div",{children:[t.jsx("h3",{children:a("terminal:statistics.dailyUsage",{defaultValue:"Daily usage by agent"})}),t.jsx("span",{className:"statistics-panel__subtitle",children:a("terminal:statistics.dailyUsageSubtitle",{defaultValue:"General token usage by day plus one line for each Claude agent."})})]})}),d&&!n&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.loading",{defaultValue:"Loading usage..."})}),!d&&!f&&n&&!m&&t.jsx("div",{className:"statistics-panel__empty",children:a("terminal:statistics.dailyEmpty",{defaultValue:"No Claude token usage found for recent days."})}),!f&&n&&m&&t.jsxs(t.Fragment,{children:[t.jsx(K,{summary:n}),t.jsx("div",{className:"statistics-panel__footnote",children:a("terminal:statistics.window",{defaultValue:"Window: {{since}} to {{until}}",since:$(n.since),until:$(n.until)})})]})]})]})]})})})}export{tt as StatisticsModal};
@@ -1 +1 @@
1
- import{u as L,aw as $,am as D,r as m,j as s,b2 as N,a6 as S,I as g,s as J}from"./main-DhXGHPKx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function M({isOpen:l,bossId:r,onClose:o}){var j;const{t:a}=L(["terminal","common"]),f=$(),n=D(r),[i,c]=m.useState(new Set),[u,b]=m.useState(!1),d=Array.from(f.values()).filter(e=>e.class!=="boss"&&(!e.bossId||e.bossId===r));m.useEffect(()=>{l&&n&&c(new Set(n.subordinateIds||[]))},[l,n]);const y=()=>{b(!0),J.assignSubordinates(r,Array.from(i)),setTimeout(()=>{b(!1),o()},300)},A=e=>{const t=new Set(i);t.has(e)?t.delete(e):t.add(e),c(t)},w=()=>{c(new Set(d.map(e=>e.id)))},C=()=>{c(new Set)},p=e=>{e.target===e.currentTarget&&o()},k=e=>{e.key==="Escape"&&o()};if(!l||!n)return null;const E=N.boss,h=((j=n.subordinateIds)==null?void 0:j.length)||0,I=i.size,x=JSON.stringify([...n.subordinateIds||[]].sort())!==JSON.stringify([...i].sort());return s.jsx("div",{className:`modal-overlay ${l?"visible":""}`,onClick:p,onKeyDown:k,children:s.jsxs("div",{className:"modal subordinate-assignment-modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("span",{className:"boss-header-icon",style:{color:E.color},children:s.jsx(S,{agent:n,size:22})}),a("terminal:team.manageTeam"),": ",n.name]}),s.jsxs("div",{className:"modal-body subordinate-assignment-body",children:[s.jsxs("div",{className:"subordinate-assignment-info",children:[s.jsx("p",{children:a("terminal:team.selectAgents")}),s.jsxs("div",{className:"subordinate-assignment-actions",children:[s.jsx("button",{className:"btn btn-small",onClick:w,children:a("common:buttons.selectAll")}),s.jsx("button",{className:"btn btn-small",onClick:C,children:a("common:buttons.clearAll")})]})]}),s.jsx("div",{className:"subordinates-list",children:d.length===0?s.jsx("div",{className:"subordinates-empty",children:a("terminal:team.noAgentsAvailable")}):d.map(e=>{var v;const t=i.has(e.id),T=N[e.class],z=(v=n.subordinateIds)==null?void 0:v.includes(e.id);return s.jsxs("div",{className:`subordinate-item ${t?"selected":""}`,onClick:()=>A(e.id),children:[s.jsx("div",{className:"subordinate-checkbox",children:t?s.jsx(g,{name:"check",size:12}):null}),s.jsx("div",{className:"subordinate-icon",style:{color:T.color},children:s.jsx(S,{agent:e,size:18})}),s.jsxs("div",{className:"subordinate-info",children:[s.jsx("div",{className:"subordinate-name",children:e.name}),s.jsx("div",{className:"subordinate-class",children:e.class})]}),s.jsx("div",{className:`subordinate-status status-${e.status}`,children:e.status}),z&&s.jsx("div",{className:"subordinate-badge",children:a("common:status.current")})]},e.id)})}),s.jsx("div",{className:"subordinate-assignment-summary",children:x?s.jsxs("span",{className:"summary-changed",children:[h," ",s.jsx(g,{name:"arrow-right",size:11})," ",I," ",a("terminal:team.subordinates").toLowerCase()]}):s.jsxs("span",{className:"summary-unchanged",children:[h," ",a("terminal:team.subordinates").toLowerCase()]})})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:o,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-boss",onClick:y,disabled:u||!x,children:a(u?"common:status.saving":"terminal:team.saveTeam")})]})]})})}export{M as SubordinateAssignmentModal};
1
+ import{u as L,aw as $,am as D,r as m,j as s,b2 as N,a6 as S,I as g,s as J}from"./main-CHE4wC7P.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function M({isOpen:l,bossId:r,onClose:o}){var j;const{t:a}=L(["terminal","common"]),f=$(),n=D(r),[i,c]=m.useState(new Set),[u,b]=m.useState(!1),d=Array.from(f.values()).filter(e=>e.class!=="boss"&&(!e.bossId||e.bossId===r));m.useEffect(()=>{l&&n&&c(new Set(n.subordinateIds||[]))},[l,n]);const y=()=>{b(!0),J.assignSubordinates(r,Array.from(i)),setTimeout(()=>{b(!1),o()},300)},A=e=>{const t=new Set(i);t.has(e)?t.delete(e):t.add(e),c(t)},w=()=>{c(new Set(d.map(e=>e.id)))},C=()=>{c(new Set)},p=e=>{e.target===e.currentTarget&&o()},k=e=>{e.key==="Escape"&&o()};if(!l||!n)return null;const E=N.boss,h=((j=n.subordinateIds)==null?void 0:j.length)||0,I=i.size,x=JSON.stringify([...n.subordinateIds||[]].sort())!==JSON.stringify([...i].sort());return s.jsx("div",{className:`modal-overlay ${l?"visible":""}`,onClick:p,onKeyDown:k,children:s.jsxs("div",{className:"modal subordinate-assignment-modal",children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("span",{className:"boss-header-icon",style:{color:E.color},children:s.jsx(S,{agent:n,size:22})}),a("terminal:team.manageTeam"),": ",n.name]}),s.jsxs("div",{className:"modal-body subordinate-assignment-body",children:[s.jsxs("div",{className:"subordinate-assignment-info",children:[s.jsx("p",{children:a("terminal:team.selectAgents")}),s.jsxs("div",{className:"subordinate-assignment-actions",children:[s.jsx("button",{className:"btn btn-small",onClick:w,children:a("common:buttons.selectAll")}),s.jsx("button",{className:"btn btn-small",onClick:C,children:a("common:buttons.clearAll")})]})]}),s.jsx("div",{className:"subordinates-list",children:d.length===0?s.jsx("div",{className:"subordinates-empty",children:a("terminal:team.noAgentsAvailable")}):d.map(e=>{var v;const t=i.has(e.id),T=N[e.class],z=(v=n.subordinateIds)==null?void 0:v.includes(e.id);return s.jsxs("div",{className:`subordinate-item ${t?"selected":""}`,onClick:()=>A(e.id),children:[s.jsx("div",{className:"subordinate-checkbox",children:t?s.jsx(g,{name:"check",size:12}):null}),s.jsx("div",{className:"subordinate-icon",style:{color:T.color},children:s.jsx(S,{agent:e,size:18})}),s.jsxs("div",{className:"subordinate-info",children:[s.jsx("div",{className:"subordinate-name",children:e.name}),s.jsx("div",{className:"subordinate-class",children:e.class})]}),s.jsx("div",{className:`subordinate-status status-${e.status}`,children:e.status}),z&&s.jsx("div",{className:"subordinate-badge",children:a("common:status.current")})]},e.id)})}),s.jsx("div",{className:"subordinate-assignment-summary",children:x?s.jsxs("span",{className:"summary-changed",children:[h," ",s.jsx(g,{name:"arrow-right",size:11})," ",I," ",a("terminal:team.subordinates").toLowerCase()]}):s.jsxs("span",{className:"summary-unchanged",children:[h," ",a("terminal:team.subordinates").toLowerCase()]})})]}),s.jsxs("div",{className:"modal-footer",children:[s.jsx("button",{className:"btn btn-secondary",onClick:o,children:a("common:buttons.cancel")}),s.jsx("button",{className:"btn btn-boss",onClick:y,disabled:u||!x,children:a(u?"common:status.saving":"terminal:team.saveTeam")})]})]})})}export{M as SubordinateAssignmentModal};
@@ -1,4 +1,4 @@
1
- import{aw as Me,r as o,h as v,i as b,j as e}from"./main-DhXGHPKx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ie=[{value:"webhook",label:"Webhook"},{value:"bitbucket",label:"Bitbucket"},{value:"cron",label:"Cron"},{value:"slack",label:"Slack"},{value:"email",label:"Email"},{value:"jira",label:"Jira"},{value:"whatsapp",label:"WhatsApp"}],Ae=[{value:"all",label:"All",icon:"◎"},{value:"webhook",label:"Webhook",icon:"🪝"},{value:"bitbucket",label:"Bitbucket",icon:"🪣"},{value:"cron",label:"Cron",icon:"⏰"},{value:"slack",label:"Slack",icon:"💬"},{value:"email",label:"Email",icon:"✉️"},{value:"jira",label:"Jira",icon:"🎫"},{value:"whatsapp",label:"WhatsApp",icon:"📱"}],Be=[{value:"pullrequest:created",label:"PR created"},{value:"pullrequest:updated",label:"PR updated"},{value:"pullrequest:approved",label:"PR approved"},{value:"pullrequest:unapproved",label:"PR unapproved"},{value:"pullrequest:fulfilled",label:"PR merged"},{value:"pullrequest:rejected",label:"PR declined"},{value:"pullrequest:comment_created",label:"PR comment created"}],Re=[{value:"structural",label:"Structural",desc:"Field-based matching (fast, free)"},{value:"llm",label:"LLM",desc:"Semantic matching via LLM (flexible, costs tokens)"},{value:"hybrid",label:"Hybrid",desc:"Structural pre-filter + LLM (recommended)"}],Fe=[{value:"structural",label:"Structural"},{value:"llm",label:"LLM"}];function Ee(w){if(!w)return"";const g=new Date(w);if(Number.isNaN(g.getTime()))return"";const m=j=>String(j).padStart(2,"0");return`${g.getFullYear()}-${m(g.getMonth()+1)}-${m(g.getDate())}T${m(g.getHours())}:${m(g.getMinutes())}`}const O=()=>({name:"",description:"",type:"webhook",agentId:"",promptTemplate:"",enabled:!0,matchMode:"structural",extractionMode:"structural",config:{method:"POST"}});function Pe({isOpen:w,onClose:g}){var Q,X,Z,ee,le,te,se,ae,ne,ie,re,oe,ce,de,pe,ue;const m=Me(),[j,xe]=o.useState([]),[S,A]=o.useState("list"),[n,k]=o.useState(O()),[h,R]=o.useState(!1),[L,D]=o.useState(!1),[P,y]=o.useState(null),[z,he]=o.useState([]),[T,ye]=o.useState(null),[F,be]=o.useState(`{
1
+ import{aw as Me,r as o,h as v,i as b,j as e}from"./main-CHE4wC7P.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ie=[{value:"webhook",label:"Webhook"},{value:"bitbucket",label:"Bitbucket"},{value:"cron",label:"Cron"},{value:"slack",label:"Slack"},{value:"email",label:"Email"},{value:"jira",label:"Jira"},{value:"whatsapp",label:"WhatsApp"}],Ae=[{value:"all",label:"All",icon:"◎"},{value:"webhook",label:"Webhook",icon:"🪝"},{value:"bitbucket",label:"Bitbucket",icon:"🪣"},{value:"cron",label:"Cron",icon:"⏰"},{value:"slack",label:"Slack",icon:"💬"},{value:"email",label:"Email",icon:"✉️"},{value:"jira",label:"Jira",icon:"🎫"},{value:"whatsapp",label:"WhatsApp",icon:"📱"}],Be=[{value:"pullrequest:created",label:"PR created"},{value:"pullrequest:updated",label:"PR updated"},{value:"pullrequest:approved",label:"PR approved"},{value:"pullrequest:unapproved",label:"PR unapproved"},{value:"pullrequest:fulfilled",label:"PR merged"},{value:"pullrequest:rejected",label:"PR declined"},{value:"pullrequest:comment_created",label:"PR comment created"}],Re=[{value:"structural",label:"Structural",desc:"Field-based matching (fast, free)"},{value:"llm",label:"LLM",desc:"Semantic matching via LLM (flexible, costs tokens)"},{value:"hybrid",label:"Hybrid",desc:"Structural pre-filter + LLM (recommended)"}],Fe=[{value:"structural",label:"Structural"},{value:"llm",label:"LLM"}];function Ee(w){if(!w)return"";const g=new Date(w);if(Number.isNaN(g.getTime()))return"";const m=j=>String(j).padStart(2,"0");return`${g.getFullYear()}-${m(g.getMonth()+1)}-${m(g.getDate())}T${m(g.getHours())}:${m(g.getMinutes())}`}const O=()=>({name:"",description:"",type:"webhook",agentId:"",promptTemplate:"",enabled:!0,matchMode:"structural",extractionMode:"structural",config:{method:"POST"}});function Pe({isOpen:w,onClose:g}){var Q,X,Z,ee,le,te,se,ae,ne,ie,re,oe,ce,de,pe,ue;const m=Me(),[j,xe]=o.useState([]),[S,A]=o.useState("list"),[n,k]=o.useState(O()),[h,R]=o.useState(!1),[L,D]=o.useState(!1),[P,y]=o.useState(null),[z,he]=o.useState([]),[T,ye]=o.useState(null),[F,be]=o.useState(`{
2
2
 
3
3
  }`),[u,M]=o.useState(null),[N,U]=o.useState(!1),[H,W]=o.useState([]),[I,ge]=o.useState("all"),[_,je]=o.useState([]),f=o.useCallback(async()=>{try{const t=await v(b("/api/triggers"));if(t.ok){const s=await t.json();xe(s)}}catch(t){console.error("Failed to load triggers:",t)}},[]),B=o.useCallback(async t=>{try{const s=await v(b(`/api/triggers/${t}/events?limit=20`));if(s.ok){const a=await s.json();he(a)}}catch(s){console.error("Failed to load trigger history:",s)}},[]),q=o.useCallback(async()=>{try{const t=await v(b("/api/slack/instances"));if(t.ok){const s=await t.json(),a=Array.isArray(s==null?void 0:s.instances)?s.instances:[];je(a.map(p=>({id:p.id,label:p.label||p.id})))}}catch(t){console.error("Failed to load Slack instances:",t)}},[]);o.useEffect(()=>{w&&(f(),q())},[w,f,q]),o.useEffect(()=>{T&&B(T)},[T,B]);const ve=o.useCallback(async()=>{D(!0),y(null);try{const t=h?b(`/api/triggers/${n.id}`):b("/api/triggers"),p=await v(t,{method:h?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!p.ok){const d=await p.json();throw new Error(d.error||"Failed to save trigger")}await f(),A("list"),k(O()),R(!1)}catch(t){y(t instanceof Error?t.message:"Save failed")}finally{D(!1)}},[n,h,f]),me=o.useCallback(async t=>{try{await v(b(`/api/triggers/${t}`),{method:"DELETE"}),await f()}catch(s){console.error("Failed to delete trigger:",s)}},[f]),fe=o.useCallback(async t=>{try{await v(b(`/api/triggers/${t.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!t.enabled})}),await f()}catch(s){console.error("Failed to toggle trigger:",s)}},[f]),ke=o.useCallback(async t=>{try{await v(b(`/api/triggers/${t}/fire`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({variables:{}})}),T===t&&await B(t)}catch(s){console.error("Failed to test fire trigger:",s)}},[T,B]),Ce=o.useCallback(async()=>{if(n.id){U(!0),M(null);try{let t;try{t=JSON.parse(F)}catch{M({structuralMatch:void 0,extractedVariables:{},wouldFire:!1}),y("Invalid JSON payload");return}const s=await v(b(`/api/triggers/${n.id}/test-match`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payload:t})});if(s.ok){const a=await s.json();M(a),y(null)}else{const a=await s.json();y(a.error||"Test match failed")}}catch(t){y(t instanceof Error?t.message:"Test match failed")}finally{U(!1)}}},[n.id,F]),we=o.useCallback(async t=>{var s;try{const a=await v(b("/api/triggers/validate-cron"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expression:t,timezone:((s=n.config)==null?void 0:s.timezone)||"UTC"})});if(a.ok){const p=await a.json();W(p.valid?p.nextFires:[])}}catch{W([])}},[n]),$=o.useCallback(t=>{t?(k({...t}),R(!0)):(k(O()),R(!1)),M(null),y(null),A("edit")},[]),x=o.useCallback((t,s)=>{k(a=>({...a,[t]:s}))},[]),r=o.useCallback((t,s)=>{k(a=>({...a,config:{...a.config,[t]:s}}))},[]),E=o.useCallback((t,s)=>{k(a=>({...a,llmMatch:{...a.llmMatch||{prompt:""},[t]:s}}))},[]),J=o.useCallback((t,s)=>{k(a=>({...a,llmExtract:{...a.llmExtract||{prompt:"",variables:[]},[t]:s}}))},[]),Se=o.useMemo(()=>Array.from(m.values()).map(t=>({id:t.id,name:t.name,class:t.class})),[m]),Te=o.useMemo(()=>{const t={all:j.length,webhook:0,bitbucket:0,cron:0,slack:0,email:0,jira:0,whatsapp:0};for(const s of j)s.type in t&&(t[s.type]+=1);return t},[j]),G=o.useMemo(()=>I==="all"?j:j.filter(t=>t.type===I),[j,I]),[K,V]=o.useState(null),Y=o.useCallback((t,s)=>{t&&navigator.clipboard.writeText(t).then(()=>{V(s),setTimeout(()=>V(a=>a===s?null:a),1500)},()=>y("Failed to copy to clipboard"))},[]);return w?e.jsx("div",{style:l.overlay,onClick:g,children:e.jsxs("div",{style:l.panel,onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{style:l.header,children:[e.jsx("h2",{style:l.title,children:S==="list"?"Triggers":h?"Edit Trigger":"New Trigger"}),e.jsxs("div",{style:l.headerActions,children:[S==="list"&&e.jsx("button",{style:l.addBtn,onClick:()=>$(),children:"+ New Trigger"}),S==="edit"&&e.jsx("button",{style:l.backBtn,onClick:()=>{A("list"),M(null),y(null)},children:"Back"}),e.jsx("button",{style:l.closeBtn,onClick:g,children:"X"})]})]}),P&&e.jsx("div",{style:l.error,children:P}),S==="list"&&e.jsxs("div",{style:l.content,children:[e.jsx("div",{style:l.tabBar,role:"tablist","aria-label":"Filter triggers by type",children:Ae.map(t=>{const s=Te[t.value],a=I===t.value;return e.jsxs("button",{role:"tab","aria-selected":a,onClick:()=>ge(t.value),style:{...l.tab,...a?l.tabActive:{}},title:`${t.label} (${s})`,children:[e.jsx("span",{style:l.tabIcon,children:t.icon}),e.jsx("span",{style:l.tabLabel,children:t.label}),e.jsx("span",{style:{...l.tabBadge,...a?l.tabBadgeActive:{}},children:s})]},t.value)})}),j.length===0?e.jsx("div",{style:l.empty,children:"No triggers configured. Create one to get started."}):G.length===0?e.jsxs("div",{style:l.empty,children:["No ",I," triggers configured yet."]}):G.map(t=>{var s;return e.jsxs("div",{style:{...l.triggerCard,borderLeftColor:t.status==="error"?"#e74c3c":t.enabled?"#2ecc71":"#95a5a6"},onClick:()=>{ye(t.id),$(t)},children:[e.jsxs("div",{style:l.cardHeader,children:[e.jsxs("div",{style:l.cardTitle,children:[e.jsx("span",{style:l.typeTag,children:t.type}),e.jsx("span",{children:t.name}),t.type==="cron"&&(()=>{const a=t.config||{};return a.runOnce?a.completedAt?e.jsx("span",{style:{...l.matchTag,color:"#a6e3a1"},children:"Once · completed"}):a.missedAt?e.jsx("span",{style:{...l.matchTag,color:"#f38ba8"},children:"Once · missed"}):e.jsx("span",{style:{...l.matchTag,color:"#f9e2af"},children:"Once · pending"}):e.jsx("span",{style:l.matchTag,children:"Recurring"})})(),t.matchMode!=="structural"&&e.jsx("span",{style:l.matchTag,children:t.matchMode})]}),e.jsxs("div",{style:l.cardActions,children:[e.jsx("button",{style:l.smallBtn,onClick:a=>{a.stopPropagation(),fe(t)},children:t.enabled?"Disable":"Enable"}),e.jsx("button",{style:l.smallBtn,onClick:a=>{a.stopPropagation(),ke(t.id)},children:"Test Fire"}),e.jsx("button",{style:{...l.smallBtn,color:"#e74c3c"},onClick:a=>{a.stopPropagation(),me(t.id)},children:"Delete"})]})]}),e.jsxs("div",{style:l.cardMeta,children:[e.jsxs("span",{children:["Agent: ",((s=m.get(t.agentId))==null?void 0:s.name)||t.agentId]}),e.jsxs("span",{children:["Fires: ",t.fireCount]}),t.lastFiredAt&&e.jsxs("span",{children:["Last: ",new Date(t.lastFiredAt).toLocaleString()]}),t.status==="error"&&t.lastError&&e.jsxs("span",{style:{color:"#e74c3c"},children:["Error: ",t.lastError]})]})]},t.id)})]}),S==="edit"&&e.jsx("div",{style:l.content,children:e.jsxs("div",{style:l.form,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Name"}),e.jsx("input",{style:l.input,value:n.name||"",onChange:t=>x("name",t.target.value),placeholder:"My Trigger"})]}),e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Description"}),e.jsx("input",{style:l.input,value:n.description||"",onChange:t=>x("description",t.target.value),placeholder:"Optional description"})]}),e.jsxs("div",{style:l.row,children:[e.jsxs("div",{style:l.field,children:[e.jsx("label",{style:l.label,children:"Type"}),e.jsx("select",{style:l.select,value:n.type||"webhook",onChange:t=>{const s=t.target.value;x("type",s),s==="webhook"?x("config",{method:"POST"}):s==="cron"?x("config",{expression:"0 9 * * MON-FRI",timezone:"UTC"}):s==="bitbucket"?x("config",{workspace:"",repoSlug:"",events:["pullrequest:created","pullrequest:updated"]}):x("config",{}),(n.promptTemplate??"").trim()||(s==="slack"?x("promptTemplate",`Slack message from {{slack.user}} in {{slack.channelName}}:
4
4
  {{slack.message}}
@@ -1,4 +1,4 @@
1
- import{r as x,h as M,i as P,j as e,aw as J}from"./main-DhXGHPKx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const H=[{id:"intake",name:"Intake",type:"action",description:"Gather CC details from the developer via Slack",action:{type:"agent_task",agentId:"",promptTemplate:`A developer has requested a new CC (Control de Cambios). Here is their message:
1
+ import{r as x,h as M,i as P,j as e,aw as J}from"./main-CHE4wC7P.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const H=[{id:"intake",name:"Intake",type:"action",description:"Gather CC details from the developer via Slack",action:{type:"agent_task",agentId:"",promptTemplate:`A developer has requested a new CC (Control de Cambios). Here is their message:
2
2
  {{trigger.slack.message}}
3
3
  From: {{trigger.slack.user}} (Slack ID: {{trigger.slack.userId}})
4
4
 
@@ -1 +1 @@
1
- import{m as i,i as r,G as n}from"./main-DhXGHPKx.js";async function p(e,o){const t=n(),a=await fetch(r(`/api/areas/${e}/logo`),{method:"POST",headers:{"Content-Type":o.type||"image/png","X-Filename":encodeURIComponent(o.name),...t?{Authorization:`Bearer ${t}`}:{}},body:o});if(!a.ok){const s=await a.json().catch(()=>({error:a.statusText}));throw new Error(s.error||`Upload failed: ${a.statusText}`)}return a.json()}async function d(e){const o=n(),t=await fetch(r(`/api/areas/${e}/logo`),{method:"DELETE",headers:{...o?{Authorization:`Bearer ${o}`}:{}}});if(!t.ok)throw new Error(`Failed to delete logo: ${t.statusText}`)}function u(e){return i(r(`/api/areas/logos/${e}`))}export{d,u as g,p as u};
1
+ import{m as i,i as r,G as n}from"./main-CHE4wC7P.js";async function p(e,o){const t=n(),a=await fetch(r(`/api/areas/${e}/logo`),{method:"POST",headers:{"Content-Type":o.type||"image/png","X-Filename":encodeURIComponent(o.name),...t?{Authorization:`Bearer ${t}`}:{}},body:o});if(!a.ok){const s=await a.json().catch(()=>({error:a.statusText}));throw new Error(s.error||`Upload failed: ${a.statusText}`)}return a.json()}async function d(e){const o=n(),t=await fetch(r(`/api/areas/${e}/logo`),{method:"DELETE",headers:{...o?{Authorization:`Bearer ${o}`}:{}}});if(!t.ok)throw new Error(`Failed to delete logo: ${t.statusText}`)}function u(e){return i(r(`/api/areas/logos/${e}`))}export{d,u as g,p as u};
@@ -1 +1 @@
1
- import{h as At,i as yt,aw as Et,a1 as xt,a2 as Ct,c9 as Mt,ca as Ft,aF as wt,r as d,X as St,S as me,cb as vt,cc as fe,s as J,cd as Bt,j as f,I as ne,ce as Ve,cf as It,a6 as _t,cg as Dt,ch as kt,ci as Ee,al as Be,W as Rt,p as nt,u as Fe,cj as Je}from"./main-DhXGHPKx.js";import{ck as Ls,cl as $s,cm as js,cn as Ns,co as Ps}from"./main-DhXGHPKx.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function re(t){return Array.isArray?Array.isArray(t):it(t)==="[object Array]"}function bt(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Tt(t){return t==null?"":bt(t)}function q(t){return typeof t=="string"}function rt(t){return typeof t=="number"}function Lt(t){return t===!0||t===!1||$t(t)&&it(t)=="[object Boolean]"}function ct(t){return typeof t=="object"}function $t(t){return ct(t)&&t!==null}function G(t){return t!=null}function Ie(t){return!t.trim().length}function it(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 c=ot(r);this._keys.push(c),this._keyMap[c.id]=c,n+=c.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,c=1,i=null;if(q(t)||re(t))r=t,e=Ze(t),n=_e(t);else{if(!Xe.call(t,"name"))throw new Error(Kt("name"));const o=t.name;if(r=o,Xe.call(t,"weight")&&(c=t.weight,c<=0))throw new Error(Ot(o));e=Ze(o),n=_e(o),i=t.getFn}return{path:e,id:n,weight:c,src:r,getFn:i}}function Ze(t){return re(t)?t:t.split(".")}function _e(t){return re(t)?t.join("."):t}function Gt(t,e){let n=[],r=!1;const c=(i,o,a)=>{if(G(i))if(!o[a])n.push(i);else{let u=o[a];const l=i[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)c(l[h],o,a+1)}else o.length&&c(l,o,a+1)}};return c(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(c){const i=c.match(Yt).length;if(n.has(i))return n.get(i);const o=1/Math.pow(i,.5*t),a=parseFloat(Math.round(o*r)/r);return n.set(i,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)||Ie(e))return;let r={v:e,i:n,n:this.norm.get(e)};this.records.push(r)}_addObject(e,n){let r={i:n,$:{}};this.keys.forEach((c,i)=>{let o=c.getFn?c.getFn(e):this.getFn(e,c.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)&&!Ie(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.$[i]=a}else if(q(o)&&!Ie(o)){let a={v:o,n:this.norm.get(o)};r.$[i]=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 c=new Le({getFn:n,fieldNormWeight:r});return c.setKeys(t.map(ot)),c.setSources(e),c.create(),c}function Jt(t,{getFn:e=y.getFn,fieldNormWeight:n=y.fieldNormWeight}={}){const{keys:r,records:c}=t,i=new Le({getFn:e,fieldNormWeight:n});return i.setKeys(r),i.setIndexRecords(c),i}function xe(t,{errors:e=0,currentLocation:n=0,expectedLocation:r=0,distance:c=y.distance,ignoreLocation:i=y.ignoreLocation}={}){const o=e/t.length;if(i)return o;const a=Math.abs(r-n);return c?o+a/c:a?1:o}function Xt(t=[],e=y.minMatchCharLength){let n=[],r=-1,c=-1,i=0;for(let o=t.length;i<o;i+=1){let a=t[i];a&&r===-1?r=i:!a&&r!==-1&&(c=i-1,c-r+1>=e&&n.push([r,c]),r=-1)}return t[i-1]&&i-r>=e&&n.push([r,i-1]),n}const le=32;function Zt(t,e,n,{location:r=y.location,distance:c=y.distance,threshold:i=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=i,m=x;const S=a>1||u,w=S?Array(E):[];let T;for(;(T=t.indexOf(e,m))>-1;){let $=xe(e,{currentLocation:T,expectedLocation:x,distance:c,ignoreLocation:l});if(g=Math.min($,g),m=T+h,S){let N=0;for(;N<h;)w[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,D=W;for(;N<D;)xe(e,{errors:$,currentLocation:x+D,expectedLocation:x,distance:c,ignoreLocation:l})<=g?N=D:W=D,D=Math.floor((W-N)/2+N);W=D;let ae=Math.max(1,x-D+1),H=o?E:Math.min(x+D,E)+h,v=Array(H+2);v[H+1]=(1<<$)-1;for(let R=H;R>=ae;R-=1){let X=R-1,O=n[t.charAt(X)];if(S&&(w[X]=+!!O),v[R]=(v[R+1]<<1|1)&O,$&&(v[R]|=(j[R+1]|j[R])<<1|1|j[R+1]),v[R]&oe&&(Q=xe(e,{errors:$,currentLocation:X,expectedLocation:x,distance:c,ignoreLocation:l}),Q<=g)){if(g=Q,m=X,m<=x)break;ae=Math.max(1,2*x-m)}}if(xe(e,{errors:$+1,currentLocation:x,expectedLocation:x,distance:c,ignoreLocation:l})>g)break;j=v}const ce={isMatch:m>=0,score:Math.max(.001,Q)};if(S){const $=Xt(w,a);$.length?u&&(ce.indices=$):ce.isMatch=!1}return ce}function qt(t){let e={};for(let n=0,r=t.length;n<r;n+=1){const c=t.charAt(n);e[c]=(e[c]||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:c=y.distance,includeMatches:i=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:c,includeMatches:i,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 w=x-le;E(this.pattern.substr(w),w)}}else E(this.pattern,0)}searchIn(e){const{isCaseSensitive:n,ignoreDiacritics:r,includeMatches:c}=this.options;if(e=n?e:e.toLowerCase(),e=r?Ce(e):e,this.pattern===e){let S={isMatch:!0,score:0};return c&&(S.indices=[[0,e.length-1]]),S}const{location:i,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:h}=this.options;let E=[],x=0,g=!1;this.chunks.forEach(({pattern:S,alphabet:w,startIndex:T})=>{const{isMatch:j,score:Q,indices:W}=Zt(e,S,w,{location:i+T,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:c,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&&c&&(m.indices=E),m}}class ie{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 ie{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 ie{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 ie{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 ie{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 ie{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 cs extends ie{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 ie{constructor(e,{location:n=y.location,threshold:r=y.threshold,distance:c=y.distance,includeMatches:i=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:c,includeMatches:i,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 ie{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let n=0,r;const c=[],i=this.pattern.length;for(;(r=e.indexOf(this.pattern,n))>-1;)n=r+i,c.push([r,n-1]);const o=!!c.length;return{isMatch:o,score:o?0:1,indices:c}}}const De=[es,ht,ss,ns,cs,rs,ts,lt],et=De.length,is=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,os="|";function as(t,e={}){return t.split(os).map(n=>{let r=n.trim().split(is).filter(i=>i&&!!i.trim()),c=[];for(let i=0,o=r.length;i<o;i+=1){const a=r[i];let u=!1,l=-1;for(;!u&&++l<et;){const h=De[l];let E=h.isMultiMatch(a);E&&(c.push(new h(E,e)),u=!0)}if(!u)for(l=-1;++l<et;){const h=De[l];let E=h.isSingleMatch(a);if(E){c.push(new h(E,e));break}}}return c})}const us=new Set([lt.type,ht.type]);class ls{constructor(e,{isCaseSensitive:n=y.isCaseSensitive,ignoreDiacritics:r=y.ignoreDiacritics,includeMatches:c=y.includeMatches,minMatchCharLength:i=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:c,minMatchCharLength:i,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:c,ignoreDiacritics:i}=this.options;e=c?e:e.toLowerCase(),e=i?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:w,score:T}=m.search(e);if(S){if(o+=1,u+=T,r){const j=m.constructor.type;us.has(j)?a=[...a,...w]:a.push(w)}}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 ke=[];function hs(...t){ke.push(...t)}function Re(t,e){for(let n=0,r=ke.length;n<r;n+=1){let c=ke[n];if(c.condition(t,e))return new c(t,e)}return new ut(t,e)}const Me={AND:"$and",OR:"$or"},be={PATH:"$path",PATTERN:"$val"},Te=t=>!!(t[Me.AND]||t[Me.OR]),ds=t=>!!t[be.PATH],fs=t=>!re(t)&&ct(t)&&!Te(t),tt=t=>({[Me.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function dt(t,e,{auto:n=!0}={}){const r=c=>{let i=Object.keys(c);const o=ds(c);if(!o&&i.length>1&&!Te(c))return r(tt(c));if(fs(c)){const u=o?c[be.PATH]:i[0],l=o?c[be.PATTERN]:c[u];if(!q(l))throw new Error(Nt(u));const h={keyId:_e(u),pattern:l};return n&&(h.searcher=Re(l,e)),h}let a={children:[],operator:i[0]};return i.forEach(u=>{const l=c[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:c,norm:i,score:o})=>{const a=c?c.weight:null;r*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(e?1:i))}),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:c,value:i}=r;let o={indices:c,value:i};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 c=[];return n&&c.push(ms),r&&c.push(ps),t.map(i=>{const{idx:o}=i,a={item:e[o],refIndex:o};return c.length&&c.forEach(u=>{u(i,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,c=this._docs.length;r<c;r+=1){const i=this._docs[r];e(i,r)&&(this.removeAt(r),r-=1,c-=1,n.push(i))}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:c,shouldSort:i,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}),i&&u.sort(o),rt(n)&&n>-1&&(u=u.slice(0,n)),As(u,this._docs,{includeMatches:r,includeScore:c})}_searchStringList(e){const n=Re(e,this.options),{records:r}=this._myIndex,c=[];return r.forEach(({v:i,i:o,n:a})=>{if(!G(i))return;const{isMatch:u,score:l,indices:h}=n.searchIn(i);u&&c.push({item:i,idx:o,matches:[{score:l,value:i,norm:a,indices:h}]})}),c}_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},c=this._myIndex.records,i={},o=[];return c.forEach(({$:a,i:u})=>{if(G(a)){let l=r(n,a,u);l.length&&(i[u]||(i[u]={idx:u,item:a,matches:[]},o.push(i[u])),l.forEach(({matches:h})=>{i[u].matches.push(...h)}))}}),o}_searchObjectList(e){const n=Re(e,this.options),{keys:r,records:c}=this._myIndex,i=[];return c.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&&i.push({idx:a,item:o,matches:u})}),i}_findMatches({key:e,value:n,searcher:r}){if(!G(n))return[];let c=[];if(re(n))n.forEach(({v:i,i:o,n:a})=>{if(!G(i))return;const{isMatch:u,score:l,indices:h}=r.searchIn(i);u&&c.push({score:l,key:e,value:i,idx:o,norm:a,indices:h})});else{const{v:i,n:o}=n,{isMatch:a,score:u,indices:l}=r.searchIn(i);a&&c.push({score:u,key:e,value:i,norm:o,indices:l})}return c}}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 c=await n.json().catch(()=>({}));throw new Error(c.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:c,onOpenFileExplorer:i,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=Et(),E=xt(),x=Ct(),g=Mt(),m=Ft(),S=wt(),w=d.useRef(e);w.current=e;const T=d.useRef(n);T.current=n;const j=d.useRef(r);j.current=r;const Q=d.useRef(c);Q.current=c;const W=d.useRef(i);W.current=i;const oe=d.useRef(o);oe.current=o;const ce=d.useRef(a);ce.current=a;const $=d.useRef(u);$.current=u;const N=d.useRef(l);N.current=l;const[D,ae]=d.useState(st),[H,v]=d.useState(0),[M,R]=d.useState(Cs),[X,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=D.trim();if(s.length<xs){O([]);return}let p=!1;const C=setTimeout(()=>{ys(s).then(F=>{p||O(F)}).catch(()=>{p||O([])})},250);return()=>{p=!0,clearTimeout(C)}},[t,D]);const we=d.useCallback(s=>{R(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=J.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:()=>{w.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:()=>{w.current(),j.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:f.jsx(ne,{name:"gear",size:16}),action:()=>{w.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;w.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)],F=C.map(Y=>Y.split("/").pop()||Y),B=[];s.lastAssignedTask&&B.push(s.lastAssignedTask);const L=`${s.class} • ${s.cwd}`;let k=`${s.name} ${s.class} ${s.status} ${s.cwd}`;s.taskLabel&&(k+=` ${s.taskLabel}`),F.length>0&&(k+=` ${F.join(" ")} ${C.join(" ")}`),B.length>0&&(k+=` ${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(_t,{agent:s,size:20}),_searchText:k,_modifiedFiles:C,_userQueries:B,_agentId:s.id,_lastActivity:s.lastActivity,_taskLabel:s.taskLabel,_status:s.status,action:()=>{w.current(),It(s.id),J.selectAgent(s.id),J.getState().viewMode!=="flat"&&J.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:()=>{w.current(),J.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=J.getAreaForAgent(p.id);if(!C||C.archived)continue;const F=s.get(C.id);F?F.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=D.trim().toLowerCase(),p=Dt({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"})),F=[];for(const B of C){const k=(Ne.get(B.id)||[]).slice().sort(p).map(P=>je.get(P.id)).filter(P=>!!P);!s&&k.length===0||F.push({areaId:B.id,areaName:B.name,areaColor:B.color,agents:k})}return F},[t,D,E,Ne,je,S,Pe]),ye=d.useMemo(()=>t?Array.from(x.values()).filter(s=>s.type==="server"||s.type==="boss"||s.type==="database"||s.type==="tests").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":s.type==="tests"?"flask":"desktop",F=s.type==="boss"?"Boss":s.type==="database"?"Database":s.type==="tests"?"Tests":"Server";let B=`${F} • ${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.type==="tests"&&s.folderPath?B=`${F} • ${s.folderPath}`:s.cwd&&(B+=` • ${s.cwd}`);const L=((Y=s.pm2Status)==null?void 0:Y.ports)||[];let k=`${s.name} ${s.type} ${s.status} ${s.cwd||""} ${((ue=s.pm2)==null?void 0:ue.name)||""}`;if(s.type==="tests"&&(k+=` ${s.folderPath||""} tests junit maven`),L.length>0&&(k+=` ${L.join(" ")}`),s.type==="database"&&((ee=s.database)!=null&&ee.connections))for(const z of s.database.connections)k+=` ${z.name} ${z.engine} ${z.host} ${z.database||""} mysql postgresql sql`;return{id:`building-${s.id}`,type:"building",title:s.name,subtitle:B,_ports:L,icon:f.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[f.jsx(ne,{name:"status-pending",size:10,weight:"fill",color:p}),f.jsx(ne,{name:C,size:16})]}),_searchText:k,action:()=>{var z;w.current(),s.type==="boss"?ce.current(s.id):s.type==="database"?$.current(s.id):s.type==="tests"?J.openTestsBuilding(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 F of s){if(p.has(F.filePath))continue;p.add(F.filePath);const B=F.filePath.split("/").pop()||F.filePath,L=F.action==="created"?"Created":F.action==="modified"?"Modified":F.action==="deleted"?"Deleted":"Read";if(C.push({id:`modified-${F.filePath}-${F.timestamp}`,type:"modified-file",title:B,subtitle:`${L} by ${F.agentName} • ${F.filePath}`,matchedText:F.filePath,icon:F.action==="deleted"?f.jsx(ne,{name:"trash",size:16}):kt(F.filePath),action:()=>{w.current();const k=Array.from(J.getState().areas.values());for(const P of k)for(const U of P.directories||[])if(F.filePath.startsWith(U)){J.setFileViewerPath(F.filePath),W.current(P.id);return}J.selectAgent(F.agentId)}}),C.length>=50)break}return C},[t,g]),Oe=d.useMemo(()=>t?X.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:()=>{w.current(),J.openFileExplorer(s.path)}}}):[],[t,X]),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(!D.trim()){const A=[];A.push(...ye);const I=[...he].sort((b,K)=>{const te=Ee(b._agentId,b._lastActivity,ge);return Ee(K._agentId,K._lastActivity,ge)-te});A.push(...I),A.push(...pe.slice(0,2)),A.push(...Ae.slice(0,2));const _={};return Es.forEach((b,K)=>{_[b]=K}),A.sort((b,K)=>(_[b.type]??999)-(_[K.type]??999)),A}const s=D.trim().toLowerCase(),p=ze.search(D).slice(0,8),C=Ge.search(D).slice(0,3),F=Qe.search(D).slice(0,2),B=We.search(D).slice(0,3),L=Oe.slice(0,8),k=He.search(D).filter(A=>{const I=A.score??1;return`${A.item.title} ${A.item.subtitle||""} ${A.item._searchText||""}`.toLowerCase().includes(s)||I<=.2}).slice(0,4),P={agent:6,building:5,folder:4,command:3,area:2,"modified-file":1},U=A=>{if(!s)return 1;const I=A.title.toLowerCase();return I===s?6:I.startsWith(s)?5:I.split(/[^a-z0-9]+/i).includes(s)?4:I.includes(s)?3:`${A.subtitle||""} ${A._searchText||""} ${A.matchedText||""}`.toLowerCase().includes(s)?2:1},Y=(A,I)=>{const _=(1-Math.min(1,I??1))*4;return U(A)*100+(P[A.type]??0)*5+_},ue=new Map,ee=(A,I)=>{const _=ue.get(A.type),b={item:A,score:Y(A,I)};_?_.push(b):ue.set(A.type,[b])};for(const A of p){const I={...A.item};if(I._modifiedFiles&&I._modifiedFiles.length>0){const _=I._modifiedFiles.filter(b=>{var se;const K=((se=b.split("/").pop())==null?void 0:se.toLowerCase())||"",te=b.toLowerCase();return K.includes(s)||te.includes(s)});_.length>0&&(I.matchedFiles=_)}if(I._userQueries&&I._userQueries.length>0){const _=I._userQueries.find(b=>b.toLowerCase().includes(s));if(_)if(_.length>200){const K=_.toLowerCase().indexOf(s),te=Math.max(0,K-60),se=Math.min(_.length,K+s.length+100);I.matchedQuery=(te>0?"...":"")+_.slice(te,se)+(se<_.length?"...":"")}else I.matchedQuery=_}ee(I,A.score)}for(const A of k)ee(A.item,A.score);for(const A of C)ee(A.item,A.score);for(const A of F)ee(A.item,A.score);for(const A of B)ee(A.item,A.score);for(const A of L)ee(A,void 0);for(const[A,I]of ue)A==="agent"?I.sort((_,b)=>{const K=U(_.item),te=U(b.item);if(te!==K)return te-K;const se=Ee(_.item._agentId,_.item._lastActivity,ge),Ye=Ee(b.item._agentId,b.item._lastActivity,ge);return Ye!==se?Ye-se:b.score-_.score}):I.sort((_,b)=>b.score-_.score);const z=A=>A.reduce((I,_)=>Math.max(I,_.score),-1),Ue=[];return Array.from(ue.values()).sort((A,I)=>z(I)-z(A)).forEach(A=>{for(const I of A)Ue.push(I.item)}),Ue},[D,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(),w.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(),F=p.toLowerCase(),B=[];let L=0,k=C.indexOf(F),P=0;for(;k!==-1;)k>L&&B.push(s.slice(L,k)),B.push(Be.createElement("mark",{key:P++,className:"spotlight-highlight"},s.slice(k,k+p.length))),L=k+p.length,k=C.indexOf(F,L);return L<s.length&&B.push(s.slice(L)),B.length>0?Be.createElement(Be.Fragment,null,...B):s},[]);return{query:D,setQuery:ft,selectedIndex: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:c},i){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:i,type:"text",className:"spotlight-input",placeholder:o("common:search.spotlightPlaceholder"),value:e,onChange:a=>{n(a.target.value),c()},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(c=>f.jsx("button",{type:"button",role:"tab","aria-selected":c===e,tabIndex:-1,className:`spotlight-tab${c===e?" active":""}`,onClick:()=>n(c),children:r(`terminal:spotlight.tabs.${c}`)},c)),f.jsx("span",{className:"spotlight-tabs-hint",children:f.jsx("kbd",{children:"Tab"})})]})}),vs=d.forwardRef(function({results:e,selectedIndex:n,query:r,activeTab:c,areaSections:i,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((w,T)=>{w.type!==m&&(m!==null&&S.length>0&&g.push([m,S]),m=w.type,S=[]),S.push({result:w,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]),c==="areas"){if(i.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:i.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 w=g++;return f.jsx(Je,{result:S,isSelected:w===n,query:r,highlightMatch:o,onClick:()=>S.action(),onMouseEnter:()=>{h.current&&a(w)}},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:w})=>f.jsx(Je,{result:S,isSelected:w===n,query:r,highlightMatch:o,onClick:()=>S.action(),onMouseEnter:()=>{h.current&&a(w)}},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")]})})]})}),Is=768;function Rs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:c,onOpenFileExplorer:i,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:w,setSelectedIndex:T,results:j,activeTab:Q,setActiveTab:W,cycleTab:oe,areaSections:ce,handleKeyDown:$,highlightMatch:N}=Fs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:c,onOpenFileExplorer:i,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l});g.current=j.length;const D=d.useRef(oe);D.current=oe,d.useEffect(()=>{t&&setTimeout(()=>{var v,M;(v=h.current)==null||v.focus(),(M=h.current)==null||M.select()},50)},[t]),d.useEffect(()=>{if(!t)return;const v=window.visualViewport;if(!v||window.innerWidth>Is)return;const M=()=>{const R=E.current;R&&(R.style.height=`${v.height}px`,R.style.top=`${v.offsetTop}px`)};return M(),v.addEventListener("resize",M),v.addEventListener("scroll",M),()=>{v.removeEventListener("resize",M),v.removeEventListener("scroll",M);const R=E.current;R&&(R.style.height="",R.style.top="")}},[t]),d.useEffect(()=>{if(!t)return;const v=M=>{if(M.key==="Escape"){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),e();return}if(M.key==="Tab"){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),D.current(M.shiftKey?-1:1);return}if(M.altKey&&!M.ctrlKey&&!M.metaKey&&(M.key==="n"||M.key==="p"||M.key==="N"||M.key==="P")){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation();const R=M.key.toLowerCase(),X=g.current;T(R==="p"?O=>O>0?O-1:X-1:O=>O<X-1?O+1:0);return}};return window.addEventListener("keydown",v,{capture:!0}),()=>{window.removeEventListener("keydown",v,{capture:!0})}},[t,e]);const ae=d.useCallback(v=>{v.target===v.currentTarget&&e()},[e]),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:w,query:m,activeTab:Q,areaSections:ce,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,kt as getFileIconFromPath,Ps as getTypeLabel,Fs as useSpotlightSearch};
1
+ import{h as At,i as yt,aw as Et,a1 as xt,a2 as Ct,c9 as Mt,ca as Ft,aF as wt,r as d,X as St,S as me,cb as vt,cc as fe,s as J,cd as Bt,j as f,I as ne,ce as Ve,cf as It,a6 as _t,cg as Dt,ch as kt,ci as Ee,al as Be,W as Rt,p as nt,u as Fe,cj as Je}from"./main-CHE4wC7P.js";import{ck as Ls,cl as $s,cm as js,cn as Ns,co as Ps}from"./main-CHE4wC7P.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function re(t){return Array.isArray?Array.isArray(t):it(t)==="[object Array]"}function bt(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Tt(t){return t==null?"":bt(t)}function q(t){return typeof t=="string"}function rt(t){return typeof t=="number"}function Lt(t){return t===!0||t===!1||$t(t)&&it(t)=="[object Boolean]"}function ct(t){return typeof t=="object"}function $t(t){return ct(t)&&t!==null}function G(t){return t!=null}function Ie(t){return!t.trim().length}function it(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 c=ot(r);this._keys.push(c),this._keyMap[c.id]=c,n+=c.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,c=1,i=null;if(q(t)||re(t))r=t,e=Ze(t),n=_e(t);else{if(!Xe.call(t,"name"))throw new Error(Kt("name"));const o=t.name;if(r=o,Xe.call(t,"weight")&&(c=t.weight,c<=0))throw new Error(Ot(o));e=Ze(o),n=_e(o),i=t.getFn}return{path:e,id:n,weight:c,src:r,getFn:i}}function Ze(t){return re(t)?t:t.split(".")}function _e(t){return re(t)?t.join("."):t}function Gt(t,e){let n=[],r=!1;const c=(i,o,a)=>{if(G(i))if(!o[a])n.push(i);else{let u=o[a];const l=i[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)c(l[h],o,a+1)}else o.length&&c(l,o,a+1)}};return c(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(c){const i=c.match(Yt).length;if(n.has(i))return n.get(i);const o=1/Math.pow(i,.5*t),a=parseFloat(Math.round(o*r)/r);return n.set(i,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)||Ie(e))return;let r={v:e,i:n,n:this.norm.get(e)};this.records.push(r)}_addObject(e,n){let r={i:n,$:{}};this.keys.forEach((c,i)=>{let o=c.getFn?c.getFn(e):this.getFn(e,c.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)&&!Ie(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.$[i]=a}else if(q(o)&&!Ie(o)){let a={v:o,n:this.norm.get(o)};r.$[i]=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 c=new Le({getFn:n,fieldNormWeight:r});return c.setKeys(t.map(ot)),c.setSources(e),c.create(),c}function Jt(t,{getFn:e=y.getFn,fieldNormWeight:n=y.fieldNormWeight}={}){const{keys:r,records:c}=t,i=new Le({getFn:e,fieldNormWeight:n});return i.setKeys(r),i.setIndexRecords(c),i}function xe(t,{errors:e=0,currentLocation:n=0,expectedLocation:r=0,distance:c=y.distance,ignoreLocation:i=y.ignoreLocation}={}){const o=e/t.length;if(i)return o;const a=Math.abs(r-n);return c?o+a/c:a?1:o}function Xt(t=[],e=y.minMatchCharLength){let n=[],r=-1,c=-1,i=0;for(let o=t.length;i<o;i+=1){let a=t[i];a&&r===-1?r=i:!a&&r!==-1&&(c=i-1,c-r+1>=e&&n.push([r,c]),r=-1)}return t[i-1]&&i-r>=e&&n.push([r,i-1]),n}const le=32;function Zt(t,e,n,{location:r=y.location,distance:c=y.distance,threshold:i=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=i,m=x;const S=a>1||u,w=S?Array(E):[];let T;for(;(T=t.indexOf(e,m))>-1;){let $=xe(e,{currentLocation:T,expectedLocation:x,distance:c,ignoreLocation:l});if(g=Math.min($,g),m=T+h,S){let N=0;for(;N<h;)w[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,D=W;for(;N<D;)xe(e,{errors:$,currentLocation:x+D,expectedLocation:x,distance:c,ignoreLocation:l})<=g?N=D:W=D,D=Math.floor((W-N)/2+N);W=D;let ae=Math.max(1,x-D+1),H=o?E:Math.min(x+D,E)+h,v=Array(H+2);v[H+1]=(1<<$)-1;for(let R=H;R>=ae;R-=1){let X=R-1,O=n[t.charAt(X)];if(S&&(w[X]=+!!O),v[R]=(v[R+1]<<1|1)&O,$&&(v[R]|=(j[R+1]|j[R])<<1|1|j[R+1]),v[R]&oe&&(Q=xe(e,{errors:$,currentLocation:X,expectedLocation:x,distance:c,ignoreLocation:l}),Q<=g)){if(g=Q,m=X,m<=x)break;ae=Math.max(1,2*x-m)}}if(xe(e,{errors:$+1,currentLocation:x,expectedLocation:x,distance:c,ignoreLocation:l})>g)break;j=v}const ce={isMatch:m>=0,score:Math.max(.001,Q)};if(S){const $=Xt(w,a);$.length?u&&(ce.indices=$):ce.isMatch=!1}return ce}function qt(t){let e={};for(let n=0,r=t.length;n<r;n+=1){const c=t.charAt(n);e[c]=(e[c]||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:c=y.distance,includeMatches:i=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:c,includeMatches:i,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 w=x-le;E(this.pattern.substr(w),w)}}else E(this.pattern,0)}searchIn(e){const{isCaseSensitive:n,ignoreDiacritics:r,includeMatches:c}=this.options;if(e=n?e:e.toLowerCase(),e=r?Ce(e):e,this.pattern===e){let S={isMatch:!0,score:0};return c&&(S.indices=[[0,e.length-1]]),S}const{location:i,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,ignoreLocation:h}=this.options;let E=[],x=0,g=!1;this.chunks.forEach(({pattern:S,alphabet:w,startIndex:T})=>{const{isMatch:j,score:Q,indices:W}=Zt(e,S,w,{location:i+T,distance:o,threshold:a,findAllMatches:u,minMatchCharLength:l,includeMatches:c,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&&c&&(m.indices=E),m}}class ie{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 ie{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 ie{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 ie{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 ie{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 ie{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 cs extends ie{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 ie{constructor(e,{location:n=y.location,threshold:r=y.threshold,distance:c=y.distance,includeMatches:i=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:c,includeMatches:i,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 ie{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let n=0,r;const c=[],i=this.pattern.length;for(;(r=e.indexOf(this.pattern,n))>-1;)n=r+i,c.push([r,n-1]);const o=!!c.length;return{isMatch:o,score:o?0:1,indices:c}}}const De=[es,ht,ss,ns,cs,rs,ts,lt],et=De.length,is=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,os="|";function as(t,e={}){return t.split(os).map(n=>{let r=n.trim().split(is).filter(i=>i&&!!i.trim()),c=[];for(let i=0,o=r.length;i<o;i+=1){const a=r[i];let u=!1,l=-1;for(;!u&&++l<et;){const h=De[l];let E=h.isMultiMatch(a);E&&(c.push(new h(E,e)),u=!0)}if(!u)for(l=-1;++l<et;){const h=De[l];let E=h.isSingleMatch(a);if(E){c.push(new h(E,e));break}}}return c})}const us=new Set([lt.type,ht.type]);class ls{constructor(e,{isCaseSensitive:n=y.isCaseSensitive,ignoreDiacritics:r=y.ignoreDiacritics,includeMatches:c=y.includeMatches,minMatchCharLength:i=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:c,minMatchCharLength:i,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:c,ignoreDiacritics:i}=this.options;e=c?e:e.toLowerCase(),e=i?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:w,score:T}=m.search(e);if(S){if(o+=1,u+=T,r){const j=m.constructor.type;us.has(j)?a=[...a,...w]:a.push(w)}}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 ke=[];function hs(...t){ke.push(...t)}function Re(t,e){for(let n=0,r=ke.length;n<r;n+=1){let c=ke[n];if(c.condition(t,e))return new c(t,e)}return new ut(t,e)}const Me={AND:"$and",OR:"$or"},be={PATH:"$path",PATTERN:"$val"},Te=t=>!!(t[Me.AND]||t[Me.OR]),ds=t=>!!t[be.PATH],fs=t=>!re(t)&&ct(t)&&!Te(t),tt=t=>({[Me.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function dt(t,e,{auto:n=!0}={}){const r=c=>{let i=Object.keys(c);const o=ds(c);if(!o&&i.length>1&&!Te(c))return r(tt(c));if(fs(c)){const u=o?c[be.PATH]:i[0],l=o?c[be.PATTERN]:c[u];if(!q(l))throw new Error(Nt(u));const h={keyId:_e(u),pattern:l};return n&&(h.searcher=Re(l,e)),h}let a={children:[],operator:i[0]};return i.forEach(u=>{const l=c[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:c,norm:i,score:o})=>{const a=c?c.weight:null;r*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(e?1:i))}),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:c,value:i}=r;let o={indices:c,value:i};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 c=[];return n&&c.push(ms),r&&c.push(ps),t.map(i=>{const{idx:o}=i,a={item:e[o],refIndex:o};return c.length&&c.forEach(u=>{u(i,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,c=this._docs.length;r<c;r+=1){const i=this._docs[r];e(i,r)&&(this.removeAt(r),r-=1,c-=1,n.push(i))}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:c,shouldSort:i,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}),i&&u.sort(o),rt(n)&&n>-1&&(u=u.slice(0,n)),As(u,this._docs,{includeMatches:r,includeScore:c})}_searchStringList(e){const n=Re(e,this.options),{records:r}=this._myIndex,c=[];return r.forEach(({v:i,i:o,n:a})=>{if(!G(i))return;const{isMatch:u,score:l,indices:h}=n.searchIn(i);u&&c.push({item:i,idx:o,matches:[{score:l,value:i,norm:a,indices:h}]})}),c}_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},c=this._myIndex.records,i={},o=[];return c.forEach(({$:a,i:u})=>{if(G(a)){let l=r(n,a,u);l.length&&(i[u]||(i[u]={idx:u,item:a,matches:[]},o.push(i[u])),l.forEach(({matches:h})=>{i[u].matches.push(...h)}))}}),o}_searchObjectList(e){const n=Re(e,this.options),{keys:r,records:c}=this._myIndex,i=[];return c.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&&i.push({idx:a,item:o,matches:u})}),i}_findMatches({key:e,value:n,searcher:r}){if(!G(n))return[];let c=[];if(re(n))n.forEach(({v:i,i:o,n:a})=>{if(!G(i))return;const{isMatch:u,score:l,indices:h}=r.searchIn(i);u&&c.push({score:l,key:e,value:i,idx:o,norm:a,indices:h})});else{const{v:i,n:o}=n,{isMatch:a,score:u,indices:l}=r.searchIn(i);a&&c.push({score:u,key:e,value:i,norm:o,indices:l})}return c}}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 c=await n.json().catch(()=>({}));throw new Error(c.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:c,onOpenFileExplorer:i,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l}){const h=Et(),E=xt(),x=Ct(),g=Mt(),m=Ft(),S=wt(),w=d.useRef(e);w.current=e;const T=d.useRef(n);T.current=n;const j=d.useRef(r);j.current=r;const Q=d.useRef(c);Q.current=c;const W=d.useRef(i);W.current=i;const oe=d.useRef(o);oe.current=o;const ce=d.useRef(a);ce.current=a;const $=d.useRef(u);$.current=u;const N=d.useRef(l);N.current=l;const[D,ae]=d.useState(st),[H,v]=d.useState(0),[M,R]=d.useState(Cs),[X,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=D.trim();if(s.length<xs){O([]);return}let p=!1;const C=setTimeout(()=>{ys(s).then(F=>{p||O(F)}).catch(()=>{p||O([])})},250);return()=>{p=!0,clearTimeout(C)}},[t,D]);const we=d.useCallback(s=>{R(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=J.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:()=>{w.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:()=>{w.current(),j.current()}},{id:"cmd-settings",type:"command",title:"Settings & Tools",subtitle:"Configure Tide Commander",icon:f.jsx(ne,{name:"gear",size:16}),action:()=>{w.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;w.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)],F=C.map(Y=>Y.split("/").pop()||Y),B=[];s.lastAssignedTask&&B.push(s.lastAssignedTask);const L=`${s.class} • ${s.cwd}`;let k=`${s.name} ${s.class} ${s.status} ${s.cwd}`;s.taskLabel&&(k+=` ${s.taskLabel}`),F.length>0&&(k+=` ${F.join(" ")} ${C.join(" ")}`),B.length>0&&(k+=` ${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(_t,{agent:s,size:20}),_searchText:k,_modifiedFiles:C,_userQueries:B,_agentId:s.id,_lastActivity:s.lastActivity,_taskLabel:s.taskLabel,_status:s.status,action:()=>{w.current(),It(s.id),J.selectAgent(s.id),J.getState().viewMode!=="flat"&&J.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:()=>{w.current(),J.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=J.getAreaForAgent(p.id);if(!C||C.archived)continue;const F=s.get(C.id);F?F.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=D.trim().toLowerCase(),p=Dt({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"})),F=[];for(const B of C){const k=(Ne.get(B.id)||[]).slice().sort(p).map(P=>je.get(P.id)).filter(P=>!!P);!s&&k.length===0||F.push({areaId:B.id,areaName:B.name,areaColor:B.color,agents:k})}return F},[t,D,E,Ne,je,S,Pe]),ye=d.useMemo(()=>t?Array.from(x.values()).filter(s=>s.type==="server"||s.type==="boss"||s.type==="database"||s.type==="tests").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":s.type==="tests"?"flask":"desktop",F=s.type==="boss"?"Boss":s.type==="database"?"Database":s.type==="tests"?"Tests":"Server";let B=`${F} • ${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.type==="tests"&&s.folderPath?B=`${F} • ${s.folderPath}`:s.cwd&&(B+=` • ${s.cwd}`);const L=((Y=s.pm2Status)==null?void 0:Y.ports)||[];let k=`${s.name} ${s.type} ${s.status} ${s.cwd||""} ${((ue=s.pm2)==null?void 0:ue.name)||""}`;if(s.type==="tests"&&(k+=` ${s.folderPath||""} tests junit maven`),L.length>0&&(k+=` ${L.join(" ")}`),s.type==="database"&&((ee=s.database)!=null&&ee.connections))for(const z of s.database.connections)k+=` ${z.name} ${z.engine} ${z.host} ${z.database||""} mysql postgresql sql`;return{id:`building-${s.id}`,type:"building",title:s.name,subtitle:B,_ports:L,icon:f.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[f.jsx(ne,{name:"status-pending",size:10,weight:"fill",color:p}),f.jsx(ne,{name:C,size:16})]}),_searchText:k,action:()=>{var z;w.current(),s.type==="boss"?ce.current(s.id):s.type==="database"?$.current(s.id):s.type==="tests"?J.openTestsBuilding(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 F of s){if(p.has(F.filePath))continue;p.add(F.filePath);const B=F.filePath.split("/").pop()||F.filePath,L=F.action==="created"?"Created":F.action==="modified"?"Modified":F.action==="deleted"?"Deleted":"Read";if(C.push({id:`modified-${F.filePath}-${F.timestamp}`,type:"modified-file",title:B,subtitle:`${L} by ${F.agentName} • ${F.filePath}`,matchedText:F.filePath,icon:F.action==="deleted"?f.jsx(ne,{name:"trash",size:16}):kt(F.filePath),action:()=>{w.current();const k=Array.from(J.getState().areas.values());for(const P of k)for(const U of P.directories||[])if(F.filePath.startsWith(U)){J.setFileViewerPath(F.filePath),W.current(P.id);return}J.selectAgent(F.agentId)}}),C.length>=50)break}return C},[t,g]),Oe=d.useMemo(()=>t?X.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:()=>{w.current(),J.openFileExplorer(s.path)}}}):[],[t,X]),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(!D.trim()){const A=[];A.push(...ye);const I=[...he].sort((b,K)=>{const te=Ee(b._agentId,b._lastActivity,ge);return Ee(K._agentId,K._lastActivity,ge)-te});A.push(...I),A.push(...pe.slice(0,2)),A.push(...Ae.slice(0,2));const _={};return Es.forEach((b,K)=>{_[b]=K}),A.sort((b,K)=>(_[b.type]??999)-(_[K.type]??999)),A}const s=D.trim().toLowerCase(),p=ze.search(D).slice(0,8),C=Ge.search(D).slice(0,3),F=Qe.search(D).slice(0,2),B=We.search(D).slice(0,3),L=Oe.slice(0,8),k=He.search(D).filter(A=>{const I=A.score??1;return`${A.item.title} ${A.item.subtitle||""} ${A.item._searchText||""}`.toLowerCase().includes(s)||I<=.2}).slice(0,4),P={agent:6,building:5,folder:4,command:3,area:2,"modified-file":1},U=A=>{if(!s)return 1;const I=A.title.toLowerCase();return I===s?6:I.startsWith(s)?5:I.split(/[^a-z0-9]+/i).includes(s)?4:I.includes(s)?3:`${A.subtitle||""} ${A._searchText||""} ${A.matchedText||""}`.toLowerCase().includes(s)?2:1},Y=(A,I)=>{const _=(1-Math.min(1,I??1))*4;return U(A)*100+(P[A.type]??0)*5+_},ue=new Map,ee=(A,I)=>{const _=ue.get(A.type),b={item:A,score:Y(A,I)};_?_.push(b):ue.set(A.type,[b])};for(const A of p){const I={...A.item};if(I._modifiedFiles&&I._modifiedFiles.length>0){const _=I._modifiedFiles.filter(b=>{var se;const K=((se=b.split("/").pop())==null?void 0:se.toLowerCase())||"",te=b.toLowerCase();return K.includes(s)||te.includes(s)});_.length>0&&(I.matchedFiles=_)}if(I._userQueries&&I._userQueries.length>0){const _=I._userQueries.find(b=>b.toLowerCase().includes(s));if(_)if(_.length>200){const K=_.toLowerCase().indexOf(s),te=Math.max(0,K-60),se=Math.min(_.length,K+s.length+100);I.matchedQuery=(te>0?"...":"")+_.slice(te,se)+(se<_.length?"...":"")}else I.matchedQuery=_}ee(I,A.score)}for(const A of k)ee(A.item,A.score);for(const A of C)ee(A.item,A.score);for(const A of F)ee(A.item,A.score);for(const A of B)ee(A.item,A.score);for(const A of L)ee(A,void 0);for(const[A,I]of ue)A==="agent"?I.sort((_,b)=>{const K=U(_.item),te=U(b.item);if(te!==K)return te-K;const se=Ee(_.item._agentId,_.item._lastActivity,ge),Ye=Ee(b.item._agentId,b.item._lastActivity,ge);return Ye!==se?Ye-se:b.score-_.score}):I.sort((_,b)=>b.score-_.score);const z=A=>A.reduce((I,_)=>Math.max(I,_.score),-1),Ue=[];return Array.from(ue.values()).sort((A,I)=>z(I)-z(A)).forEach(A=>{for(const I of A)Ue.push(I.item)}),Ue},[D,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(),w.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(),F=p.toLowerCase(),B=[];let L=0,k=C.indexOf(F),P=0;for(;k!==-1;)k>L&&B.push(s.slice(L,k)),B.push(Be.createElement("mark",{key:P++,className:"spotlight-highlight"},s.slice(k,k+p.length))),L=k+p.length,k=C.indexOf(F,L);return L<s.length&&B.push(s.slice(L)),B.length>0?Be.createElement(Be.Fragment,null,...B):s},[]);return{query:D,setQuery:ft,selectedIndex: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:c},i){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:i,type:"text",className:"spotlight-input",placeholder:o("common:search.spotlightPlaceholder"),value:e,onChange:a=>{n(a.target.value),c()},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(c=>f.jsx("button",{type:"button",role:"tab","aria-selected":c===e,tabIndex:-1,className:`spotlight-tab${c===e?" active":""}`,onClick:()=>n(c),children:r(`terminal:spotlight.tabs.${c}`)},c)),f.jsx("span",{className:"spotlight-tabs-hint",children:f.jsx("kbd",{children:"Tab"})})]})}),vs=d.forwardRef(function({results:e,selectedIndex:n,query:r,activeTab:c,areaSections:i,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((w,T)=>{w.type!==m&&(m!==null&&S.length>0&&g.push([m,S]),m=w.type,S=[]),S.push({result:w,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]),c==="areas"){if(i.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:i.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 w=g++;return f.jsx(Je,{result:S,isSelected:w===n,query:r,highlightMatch:o,onClick:()=>S.action(),onMouseEnter:()=>{h.current&&a(w)}},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:w})=>f.jsx(Je,{result:S,isSelected:w===n,query:r,highlightMatch:o,onClick:()=>S.action(),onMouseEnter:()=>{h.current&&a(w)}},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")]})})]})}),Is=768;function Rs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:c,onOpenFileExplorer:i,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:w,setSelectedIndex:T,results:j,activeTab:Q,setActiveTab:W,cycleTab:oe,areaSections:ce,handleKeyDown:$,highlightMatch:N}=Fs({isOpen:t,onClose:e,onOpenSpawnModal:n,onOpenCommanderView:r,onOpenToolbox:c,onOpenFileExplorer:i,onOpenPM2LogsModal:o,onOpenBossLogsModal:a,onOpenDatabasePanel:u,onOpenMonitoringModal:l});g.current=j.length;const D=d.useRef(oe);D.current=oe,d.useEffect(()=>{t&&setTimeout(()=>{var v,M;(v=h.current)==null||v.focus(),(M=h.current)==null||M.select()},50)},[t]),d.useEffect(()=>{if(!t)return;const v=window.visualViewport;if(!v||window.innerWidth>Is)return;const M=()=>{const R=E.current;R&&(R.style.height=`${v.height}px`,R.style.top=`${v.offsetTop}px`)};return M(),v.addEventListener("resize",M),v.addEventListener("scroll",M),()=>{v.removeEventListener("resize",M),v.removeEventListener("scroll",M);const R=E.current;R&&(R.style.height="",R.style.top="")}},[t]),d.useEffect(()=>{if(!t)return;const v=M=>{if(M.key==="Escape"){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),e();return}if(M.key==="Tab"){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation(),D.current(M.shiftKey?-1:1);return}if(M.altKey&&!M.ctrlKey&&!M.metaKey&&(M.key==="n"||M.key==="p"||M.key==="N"||M.key==="P")){M.preventDefault(),M.stopPropagation(),M.stopImmediatePropagation();const R=M.key.toLowerCase(),X=g.current;T(R==="p"?O=>O>0?O-1:X-1:O=>O<X-1?O+1:0);return}};return window.addEventListener("keydown",v,{capture:!0}),()=>{window.removeEventListener("keydown",v,{capture:!0})}},[t,e]);const ae=d.useCallback(v=>{v.target===v.currentTarget&&e()},[e]),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:w,query:m,activeTab:Q,areaSections:ce,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,kt as getFileIconFromPath,Ps as getTypeLabel,Fs as useSpotlightSearch};