@grackle-ai/web 0.91.4 → 0.92.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-gigL5i5c.js","assets/dagview-tHPW3Rz3.js","assets/grpc-CbbuZL-C.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
2
- import{r as QS,a as eT,b as y,j as o,d as Z0,H as K0,P as Y0,i as tT,B as nT,c as sT,C as aT,M as iT,e as oT}from"./dagview-tHPW3Rz3.js";import{c as rT,a as lT,G as cT,f as dT,M as uT,A as o_,D as r_,W as fT,O as pT,b as mT,C as ol,d as hT,e as l_,w as gT,t as vT,p as Nc,g as yT,R as Ar,S as J0}from"./grpc-CbbuZL-C.js";import{v as bT,r as _T,t as Cc,i as xT,f as kT,M as pd,a as md}from"./markdown-Yr3vTPLR.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const u of d.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function i(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function r(c){if(c.ep)return;c.ep=!0;const d=i(c);fetch(c.href,d)}})();var Bf={exports:{}},Dr={},zf={exports:{}},Uf={};/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-DTOJmEHK.js","assets/dagview-tHPW3Rz3.js","assets/grpc-DuXB9y79.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
2
+ import{r as QS,a as eT,b as y,j as o,d as Z0,H as K0,P as Y0,i as tT,B as nT,c as sT,C as aT,M as iT,e as oT}from"./dagview-tHPW3Rz3.js";import{c as rT,a as lT,G as cT,f as dT,M as uT,A as o_,D as r_,W as fT,O as pT,b as mT,C as ol,d as hT,e as l_,w as gT,t as vT,p as Nc,g as yT,R as Ar,S as J0}from"./grpc-DuXB9y79.js";import{v as bT,r as _T,t as Cc,i as xT,f as kT,M as pd,a as md}from"./markdown-Yr3vTPLR.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const u of d.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function i(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function r(c){if(c.ep)return;c.ep=!0;const d=i(c);fetch(c.href,d)}})();var Bf={exports:{}},Dr={},zf={exports:{}},Uf={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
5
5
  *
@@ -271,7 +271,7 @@ ${JSON.stringify(u,void 0,2)}
271
271
  \`\`\``):s.push(`${m} (${c}):`);break}case"error":{s.push(`**Error** (${c}):
272
272
  ${r.content}`);break}}}return s.join(`
273
273
 
274
- `)}function X4({events:t,formatForClipboard:s}){const[i,r]=y.useState(!1),[c,d]=y.useState(new Set),u=y.useRef(void 0),p=y.useMemo(()=>c.size,[c]),m=y.useCallback(k=>{r(!0),k!==void 0?(d(new Set([k])),u.current=k):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((k,w)=>{if(w&&u.current!==void 0){const N=Math.min(u.current,k),T=Math.max(u.current,k);d(C=>{const D=new Set(C);for(let L=N;L<=T;L++)L<t.length&&il(t[L])&&D.add(L);return D})}else d(N=>{const T=new Set(N);return T.has(k)?T.delete(k):T.add(k),T.size===0?(r(!1),u.current=void 0):u.current=k,T})},[t]),b=y.useCallback(()=>{const k=new Set;for(let w=0;w<t.length;w++)il(t[w])&&k.add(w);d(k)},[t]),_=y.useCallback(()=>{d(new Set)},[]),S=y.useCallback(async()=>{const w=[...c].sort((T,C)=>T-C).filter(T=>T<t.length).map(T=>t[T]);if(w.length===0)return!1;const N=s(w);try{return await navigator.clipboard.writeText(N),!0}catch{return!1}},[c,t,s]);return{isSelecting:i,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:_,copySelected:S}}const Q4="_wrapper_1cdza_1",e6="_scrollContainer_1cdza_9",t6="_selectingPadding_1cdza_16",n6="_toolbar_1cdza_20",s6="_directionToggle_1cdza_27",a6="_scrollToAnchor_1cdza_65",i6="_scrollToAnchorBottom_1cdza_89",o6="_scrollToAnchorTop_1cdza_93",r6="_eventOverflowWarning_1cdza_97",Ys={wrapper:Q4,scrollContainer:e6,selectingPadding:t6,toolbar:n6,directionToggle:s6,scrollToAnchor:a6,scrollToAnchorBottom:i6,scrollToAnchorTop:o6,eventOverflowWarning:r6};function l6(t){const s=new Date(t.timestamp).toLocaleTimeString();switch(t.eventType){case"text":case"output":return`Select message from assistant at ${s}`;case"user_input":return`Select message from user at ${s}`;case"tool_result":case"tool_use":return`Select tool event at ${s}`;case"error":return`Select error at ${s}`;default:return`Select event at ${s}`}}const h1="grackle-stream-direction";function c6(){try{return localStorage.getItem(h1)==="reversed"}catch{return!1}}function d6({eventsDropped:t}){return t<=0?o.jsx(o.Fragment,{}):o.jsxs("div",{className:Ys.eventOverflowWarning,role:"alert",children:[o.jsx(am,{size:en,"aria-hidden":"true"})," ",t.toLocaleString()," older event",t===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function Jm({events:t,eventsDropped:s,emptyState:i,onShowToast:r}){const c=y.useRef(null),[d,u]=y.useState(c6),p=KM(),m=X4({events:t,formatForClipboard:W4}),g=y.useMemo(()=>t.filter(il).length,[t]),v=y.useMemo(()=>d?[...t].reverse():t,[t,d]),{isAtAnchor:b,scrollToAnchor:_}=K4({scrollRef:c,contentLength:t.length,isReversed:d,paused:m.isSelecting}),S=()=>{const T=!d;u(T);try{localStorage.setItem(h1,T?"reversed":"default")}catch{}};y.useEffect(()=>{if(!m.isSelecting)return;const T=C=>{C.key==="Escape"&&m.cancelSelection()};return window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T)}},[m.isSelecting,m.cancelSelection]);const k=y.useCallback(async()=>{await m.copySelected()&&(r==null||r(`Copied ${m.selectedCount} message${m.selectedCount===1?"":"s"} to clipboard`,"success"))},[m,r]),w=p?0:.2,N=d?-8:8;return o.jsxs("div",{className:Ys.wrapper,children:[o.jsx("div",{className:Ys.toolbar,children:o.jsx(Oo,{text:d?"Showing newest first":"Showing oldest first",children:o.jsx("button",{className:Ys.directionToggle,onClick:S,"aria-label":d?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:d?o.jsx(ay,{size:en,"aria-hidden":"true"}):o.jsx(iy,{size:en,"aria-hidden":"true"})})})}),o.jsxs("div",{ref:c,className:`${Ys.scrollContainer} ${m.isSelecting?Ys.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&i,o.jsx(d6,{eventsDropped:s}),o.jsx(ps,{initial:!1,children:v.map((T,C)=>{const D=d?t.length-1-C:C;return o.jsx(Rt.div,{initial:{opacity:0,y:N},animate:{opacity:1,y:0},transition:{duration:w,ease:"easeOut"},children:o.jsx(B4,{copyText:J4(T),isContentBearing:il(T),isSelecting:m.isSelecting,isSelected:m.selectedIndices.has(D),checkboxLabel:l6(T),onSelect:()=>{m.enterSelectionMode(D)},onToggle:L=>{m.toggleEvent(D,L)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:o.jsx(kA,{event:T,toolUseCtx:T.toolUseCtx,settled:T.settled})})},`${T.sessionId}-${T.timestamp}-${D}`)})})]}),o.jsx(ps,{children:m.isSelecting&&o.jsx(G4,{selectedCount:m.selectedCount,totalSelectable:g,onSelectAll:m.selectAll,onDeselectAll:m.deselectAll,onCopy:()=>{k().catch(()=>{})},onCancel:m.cancelSelection})}),o.jsx(ps,{children:!b&&o.jsxs(Rt.button,{className:`${Ys.scrollToAnchor} ${d?Ys.scrollToAnchorTop:Ys.scrollToAnchorBottom}`,onClick:_,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[d?o.jsx(iy,{size:en,"aria-hidden":"true"}):o.jsx(ay,{size:en,"aria-hidden":"true"})," New events"]})})]})}function Wm(t){const{value:s,onSave:i,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[b,_]=y.useState(""),S=y.useRef(!1),k=d===c,w=y.useCallback(O=>{v(O),_("")},[]),N=y.useCallback(()=>{_("")},[]),T=y.useCallback(()=>{S.current=!1,u==null||u(null),v(""),_("")},[u]),C=y.useCallback(()=>{const O=m?g.trim():g;if(r){const $=r(g);if($){_($);return}}const z=m?s.trim():s;if(O===z){T();return}i(O),T()},[g,s,m,r,i,T]),D=y.useCallback(()=>{S.current=!0,u==null||u(c),v(s),_("")},[c,s,u]),L=y.useCallback(O=>{if(S.current){S.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(O=>{O.key==="Escape"?T():O.key==="Enter"&&p&&C()},[T,p,C]),I=(()=>{if(!k)return!1;const O=m?s.trim():s;return(m?g.trim():g)!==O})();return y.useEffect(()=>{!k&&(g!==""||b!=="")&&(v(""),_(""))},[k,g,b]),{isEditing:k,draft:g,error:b,isDirty:I,startEdit:D,cancelEdit:T,save:C,setDraft:w,clearError:N,handleBlur:L,handleKeyDown:E,ignoreInitialBlurRef:S}}const u6="_editFieldWrapper_yuzty_1",f6="_editInput_yuzty_10",p6="_editTextarea_yuzty_42",m6="_editSelect_yuzty_78",h6="_editError_yuzty_111",g6="_editInputInvalid_yuzty_118",v6="_editHint_yuzty_123",y6="_unsavedDot_yuzty_132",b6="_metaValueClickable_yuzty_140",_6="_editButton_yuzty_159",x6="_metaPlaceholder_yuzty_175",k6="_worktreeToggle_yuzty_180",et={editFieldWrapper:u6,editInput:f6,editTextarea:p6,editSelect:m6,editError:h6,editInputInvalid:g6,editHint:v6,unsavedDot:y6,metaValueClickable:b6,editButton:_6,metaPlaceholder:x6,worktreeToggle:k6};function ln(t){const{value:s,onSave:i,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:b,ariaLabel:_,"data-testid":S}=t,k=y.useRef(null),w=Wm({value:s,onSave:i,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(w.isEditing){const T=window.setTimeout(()=>{var C;(C=k.current)==null||C.focus()},0);return()=>window.clearTimeout(T)}},[w.isEditing]),c==="create"){const T=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return o.jsxs("div",{className:et.editFieldWrapper,children:[o.jsx("input",{className:`${et.editInput} ${C?et.editInputInvalid:""}`,value:s,onChange:T,maxLength:b,placeholder:v,"aria-label":_,"data-testid":S?`${S}-input`:void 0}),C&&o.jsx("span",{className:et.editError,"data-testid":"edit-error",children:C})]})}if(w.isEditing)return o.jsxs("div",{className:et.editFieldWrapper,children:[o.jsx("input",{ref:k,className:`${et.editInput} ${w.error?et.editInputInvalid:""}`,value:w.draft,onChange:T=>w.setDraft(T.target.value),onBlur:w.handleBlur,onKeyDown:w.handleKeyDown,maxLength:b,placeholder:v,"aria-label":_,"data-testid":S?`${S}-input`:void 0}),w.isDirty&&o.jsx("span",{className:et.unsavedDot,title:"Unsaved changes"}),w.error&&o.jsx("span",{className:et.editError,"data-testid":"edit-error",children:w.error}),o.jsx("span",{className:et.editHint,children:"Enter to save · Esc to cancel"})]});const N=g==null?void 0:g(s);return o.jsxs("span",{role:"button",tabIndex:0,className:et.metaValueClickable,onClick:()=>w.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),w.startEdit())},title:"Click to edit","aria-label":_,"data-testid":S?`${S}-button`:void 0,children:[N!==void 0?N:s?o.jsx("span",{children:s}):o.jsx("span",{className:et.metaPlaceholder,children:v||"None"}),o.jsx("span",{className:et.editButton,"aria-hidden":"true",children:"✏️"})]})}function Wp(t){const{value:s,onSave:i,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=t,S=y.useRef(null),k=Wm({value:s,onSave:i,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(k.isEditing){const N=window.setTimeout(()=>{var T;(T=S.current)==null||T.focus()},0);return()=>window.clearTimeout(N)}},[k.isEditing]),c==="create"){const N=C=>{m==null||m(C.target.value)},T=r==null?void 0:r(s);return o.jsxs("div",{className:et.editFieldWrapper,children:[o.jsx("textarea",{className:`${et.editTextarea} ${T?et.editInputInvalid:""}`,value:s,onChange:N,placeholder:v,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),T&&o.jsx("span",{className:et.editError,"data-testid":"edit-error",children:T})]})}if(k.isEditing)return o.jsxs("div",{className:et.editFieldWrapper,children:[o.jsx("textarea",{ref:S,className:`${et.editTextarea} ${k.error?et.editInputInvalid:""}`,value:k.draft,onChange:N=>k.setDraft(N.target.value),onBlur:k.handleBlur,onKeyDown:k.handleKeyDown,title:b,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),k.isDirty&&o.jsx("span",{className:et.unsavedDot,title:"Unsaved changes"}),k.error&&o.jsx("span",{className:et.editError,"data-testid":"edit-error",children:k.error}),o.jsx("span",{className:et.editHint,children:"Tab to save · Esc to cancel"})]});const w=g==null?void 0:g(s);return o.jsxs("span",{role:"button",tabIndex:0,className:et.metaValueClickable,onClick:()=>k.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),k.startEdit())},title:"Click to edit","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[w!==void 0?w:s?o.jsx("span",{children:s}):o.jsx("span",{className:et.metaPlaceholder,children:v||"None"}),o.jsx("span",{className:et.editButton,"aria-hidden":"true",children:"✏️"})]})}function cd(t){var D;const{value:s,onSave:i,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=t,S=y.useRef(null),k=Wm({value:s,onSave:i,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(k.isEditing){const L=window.setTimeout(()=>{var E;(E=S.current)==null||E.focus()},0);return()=>window.clearTimeout(L)}},[k.isEditing]);const w=y.useCallback(L=>{const E=L.target.value;k.ignoreInitialBlurRef.current=!1,E!==s&&i(E),k.cancelEdit()},[s,i,k]),N=y.useCallback(L=>{if(k.ignoreInitialBlurRef.current){k.ignoreInitialBlurRef.current=!1;return}L.relatedTarget instanceof HTMLElement&&L.relatedTarget.dataset.editAction===d||k.cancelEdit()},[d,k]);if(r==="create")return o.jsx("select",{className:et.editSelect,value:s,onChange:L=>m==null?void 0:m(L.target.value),"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(L=>o.jsx("option",{value:L.value,children:L.label},L.value))});if(k.isEditing)return o.jsx("select",{ref:S,className:et.editSelect,value:k.draft,onChange:w,onBlur:N,title:b,"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(L=>o.jsx("option",{value:L.value,children:L.label},L.value))});const T=g==null?void 0:g(s),C=(D=c.find(L=>L.value===s))==null?void 0:D.label;return o.jsxs("button",{type:"button",className:et.metaValueClickable,onClick:()=>k.startEdit(),title:"Click to change","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[T!==void 0?T:C?o.jsx("span",{children:C}):o.jsx("span",{className:et.metaPlaceholder,children:v||"None"}),o.jsx("span",{className:et.editButton,"aria-hidden":"true",children:"✏️"})]})}function S6(t){const{checked:s,onChange:i,label:r,ariaLabel:c,"data-testid":d}=t;return o.jsxs("label",{className:et.worktreeToggle,"data-testid":d,children:[o.jsx("input",{type:"checkbox",checked:s,onChange:u=>i(u.target.checked),"aria-label":c}),o.jsx("span",{children:r})]})}const T6="_envRow_1e1r5_1",w6="_envDot_1e1r5_7",j6="_envDotGreen_1e1r5_14",N6="_envDotYellow_1e1r5_18",C6="_envDotRed_1e1r5_22",E6="_envDotGray_1e1r5_26",Co={envRow:T6,envDot:w6,envDotGreen:j6,envDotYellow:N6,envDotRed:C6,envDotGray:E6};function A6(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?Co.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?Co.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?Co.envDotRed:Co.envDotGray}function D6(t){const{value:s,onSave:i,environments:r,allowNone:c=!1,fieldId:d="environment",activeFieldId:u,onActivate:p,placeholder:m="No environment",ariaLabel:g="Environment","data-testid":v}=t,b=r.find(k=>k.id===s),_=[...c?[{value:"",label:"None"}]:[],...r.map(k=>({value:k.id,label:k.displayName}))],S=()=>{if(b)return o.jsxs("span",{className:Co.envRow,children:[o.jsx("span",{className:`${Co.envDot} ${A6(b.status)}`}),b.displayName]})};return o.jsx(cd,{value:s,onSave:i,options:_,fieldId:d,activeFieldId:u,onActivate:p,renderDisplay:S,placeholder:m,ariaLabel:g,"data-testid":v})}const R6="_nav_1snmp_1",M6="_searchForm_1snmp_8",I6="_searchInput_1snmp_15",O6="_searchButton_1snmp_33",L6="_clearButton_1snmp_68",B6="_workspaceSelect_1snmp_85",z6="_listHeader_1snmp_99",U6="_nodeList_1snmp_108",$6="_nodeItem_1snmp_116",P6="_indicator_1snmp_129",H6="_label_1snmp_136",V6="_badge_1snmp_145",Yn={nav:R6,searchForm:M6,searchInput:I6,searchButton:O6,clearButton:L6,workspaceSelect:B6,listHeader:z6,nodeList:U6,nodeItem:$6,indicator:P6,label:H6,badge:V6};function q6({nodes:t,workspaces:s,loading:i,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(k=>{k.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=y.useCallback(()=>{g(""),d()},[d]),_=y.useCallback(k=>{u(k)},[u]),S=y.useCallback(k=>{g(""),p(k)},[p]);return o.jsxs("div",{className:Yn.nav,"data-testid":"knowledge-nav",children:[o.jsxs("form",{className:Yn.searchForm,onSubmit:v,children:[o.jsx("input",{className:Yn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:k=>{g(k.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),o.jsx("button",{type:"submit",className:Yn.searchButton,disabled:i,children:"Go"})]}),r&&o.jsx("button",{type:"button",className:Yn.clearButton,onClick:b,children:"Clear search"}),o.jsxs("select",{className:Yn.workspaceSelect,onChange:k=>{S(k.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[o.jsx("option",{value:"",children:"All workspaces"}),s.map(k=>o.jsx("option",{value:k.id,children:k.name},k.id))]}),o.jsxs("div",{className:Yn.listHeader,children:["Nodes (",t.length,")"]}),o.jsx("ul",{className:Yn.nodeList,children:t.map(k=>o.jsxs("li",{className:Yn.nodeItem,onClick:()=>{_(k.id)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),_(k.id))},role:"button",tabIndex:0,children:[o.jsx("span",{className:Yn.indicator,style:{backgroundColor:k.kind==="reference"?"#4A9EFF":k.category==="decision"?"#22C55E":k.category==="concept"?"#A855F7":k.category==="snippet"?"#6B7280":"#EAB308"}}),o.jsx("span",{className:Yn.label,children:k.label}),o.jsx("span",{className:Yn.badge,children:k.kind==="reference"?k.sourceType:k.category})]},k.id))})]})}const G6="_container_1mq5u_1",F6="_hamburger_1mq5u_33",Z6="_brand_1mq5u_49",K6="_brandLogo_1mq5u_68",Y6="_info_1mq5u_75",J6="_connectionLabel_1mq5u_90",W6="_connectionDot_1mq5u_103",X6="_connected_1mq5u_106",Q6="_disconnected_1mq5u_110",Zs={container:G6,hamburger:F6,brand:Z6,brandLogo:K6,info:Y6,connectionLabel:J6,connectionDot:W6,connected:X6,disconnected:Q6};function e5({connected:t,environments:s,sessions:i,onToggleSidebar:r,sidebarOpen:c}){const d=xt(),u=s.length,p=s.filter(g=>g.status==="connected").length,m=i.filter(g=>["running","idle"].includes(g.status)).length;return o.jsxs("div",{className:Zs.container,children:[r&&o.jsx("button",{type:"button",className:Zs.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:o.jsx(M2,{size:Bt,"aria-hidden":"true"})}),o.jsx(Oo,{text:"Home",placement:"bottom",children:o.jsxs("button",{type:"button",className:Zs.brand,onClick:()=>d(Ti),"data-testid":"statusbar-brand",children:[o.jsx("img",{src:"/icon-192x192.png",alt:"",className:Zs.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),o.jsxs("div",{className:Zs.info,children:[o.jsxs("span",{"aria-label":t?"Connected":"Disconnected",children:[o.jsx("span",{className:`${Zs.connectionDot} ${t?Zs.connected:Zs.disconnected}`,"aria-hidden":"true",children:o.jsx(Ba,{size:im,fill:"currentColor"})})," ",o.jsx("span",{className:Zs.connectionLabel,"aria-hidden":"true",children:t?"Connected":"Disconnected"})]}),o.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),o.jsxs("span",{children:[m," active"]})]})]})}const t5="_nav_13gkc_1",n5="_tab_13gkc_35",s5="_tabIcon_13gkc_68",a5="_tabLabel_13gkc_79",i5="_tabActive_13gkc_84",Lr={nav:t5,tab:n5,tabIcon:s5,tabLabel:a5,tabActive:i5},gi=[{view:"dashboard",label:"Dashboard",icon:o.jsx(_2,{size:Bt}),route:Ti,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:o.jsx(O2,{size:Bt}),route:sN,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:o.jsx(r2,{size:Bt}),route:aN,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:o.jsx(B2,{size:Bt}),route:Ao,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:o.jsx(t2,{size:Bt}),route:I_,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:o.jsx(f_,{size:Bt}),route:bd,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:o.jsx(F2,{size:Bt}),route:Qj,testId:"sidebar-tab-settings"}];function o5(t){return t===Ti||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(I_)?"knowledge":t.startsWith(bd)?"findings":t.startsWith(Eo)?"settings":"tasks"}function r5(){const t=Zt(),s=xt(),i=y.useRef(null),r=o5(t.pathname),c=y.useCallback(u=>{s(u.route)},[s]),d=y.useCallback(u=>{var b,_;const p=(b=i.current)==null?void 0:b.querySelectorAll('[role="tab"]');if(!p)return;const m=Array.from(p).findIndex(S=>S===document.activeElement),g=m>=0?m:gi.findIndex(S=>S.view===r);let v=g;if(u.key==="ArrowRight"||u.key==="j"||u.key==="J")u.preventDefault(),v=(g+1)%gi.length;else if(u.key==="ArrowLeft"||u.key==="k"||u.key==="K")u.preventDefault(),v=(g-1+gi.length)%gi.length;else if(u.key==="Home")u.preventDefault(),v=0;else if(u.key==="End")u.preventDefault(),v=gi.length-1;else return;s(gi[v].route),(_=p[v])==null||_.focus()},[r,s]);return o.jsx("nav",{className:Lr.nav,ref:i,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:d,"data-testid":"sidebar-nav",children:gi.map(u=>{const p=u.view===r;return o.jsx(Oo,{text:u.label,placement:"bottom",children:o.jsxs("button",{role:"tab",type:"button","aria-selected":p,tabIndex:p?0:-1,className:`${Lr.tab} ${p?Lr.tabActive:""}`,onClick:()=>c(u),"data-testid":u.testId,"aria-label":u.label,children:[o.jsx("span",{className:Lr.tabIcon,"aria-hidden":"true",children:u.icon}),o.jsx("span",{className:Lr.tabLabel,children:u.label})]})},u.view)})})}const l5="_container_pi6ii_1",c5="_content_pi6ii_66",zb={container:l5,content:c5},d5=320,g1=220,v1=600,y1="grackle-sidebar-width";function u5(){try{const t=localStorage.getItem(y1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=g1&&s<=v1)return s}}catch{}return d5}function f5(t){try{localStorage.setItem(y1,String(t))}catch{}}function p5({content:t}){const[s]=y.useState(u5),i=y.useRef(null);if(y.useEffect(()=>{const r=i.current;if(!r)return;const c=new ResizeObserver(d=>{for(const u of d){const p=u.borderBoxSize[0];if(p){const m=Math.round(p.inlineSize);m>=g1&&m<=v1&&f5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return o.jsx("div",{className:zb.container,ref:i,"data-testid":"sidebar",style:{width:s},children:o.jsx("div",{className:zb.content,children:t})})}const m5="_bar_tnfsh_1",h5="_btnPrimary_tnfsh_32",g5="_statusText_tnfsh_85",v5="_statusCompleted_tnfsh_90",y5="_statusFailed_tnfsh_94",b5="_statusBlocked_tnfsh_98",_5="_hintText_tnfsh_103",Tt={bar:m5,btnPrimary:h5,statusText:g5,statusCompleted:v5,statusFailed:y5,statusBlocked:b5,hintText:_5};function x5({sessions:t,tasks:s,environments:i}){const r=xt(),c=Zt(),d=At("/sessions/:sessionId"),u=At("/tasks/:taskId"),p=At("/tasks/:taskId/stream"),m=At("/tasks/:taskId/findings"),g=At("/tasks/:taskId/edit"),v=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),b=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),_=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),S=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),k=At("/sessions/new"),w=At("/environments/:environmentId/workspaces/:workspaceId"),N=At("/tasks/new"),T=At("/chat"),C=At("/"),D=At("/settings/*"),L=d==null?void 0:d.params.sessionId,E=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(m==null?void 0:m.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId)??(_==null?void 0:_.params.taskId)??(S==null?void 0:S.params.taskId),I=v??b??_??S,O=(I==null?void 0:I.params.environmentId)??(w==null?void 0:w.params.environmentId),z=c.pathname.startsWith("/environments")&&!w&&!I,$=!!T,X=!!k,te=!!w&&!v&&!b&&!_&&!S,P=!!N;if(!!C&&!X&&!te&&!P||!!D||(!!g||!!S)||P||z||X)return o.jsx(o.Fragment,{});if($)return i.find(F=>F.adapterType==="local"&&F.status==="connected")?o.jsx(o.Fragment,{}):o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Add a local environment to start chatting"})});if(te)return o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Select a task or click + to create one"})});if(E){const A=s.find(pe=>pe.id===E);if(!A)return o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Loading..."})});const F=new Map(s.map(pe=>[pe.id,pe])),oe=A.dependsOn.some(pe=>{const de=F.get(pe);return de!==void 0&&de.status!=="complete"});if(A.status==="not_started"){const pe=oe?A.dependsOn.map(de=>F.get(de)).filter(de=>de&&de.status!=="complete").map(de=>de.title):[];return o.jsx("div",{className:Tt.bar,children:oe?o.jsxs("span",{className:Tt.statusBlocked,children:["Blocked by: ",pe.join(", ")]}):o.jsx("span",{className:Tt.hintText,children:"Use the buttons above to start or manage this task"})})}if(A.status==="working"||A.status==="paused"){const pe=A.latestSessionId||void 0,de=pe?t.find(ke=>ke.id===pe):void 0;return de&&de.status!=="stopped"?o.jsx(o.Fragment,{}):o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Waiting for agent..."})})}if(A.status==="complete")return o.jsxs("div",{className:Tt.bar,children:[o.jsx("span",{className:`${Tt.statusText} ${Tt.statusCompleted}`,children:"Task completed"}),o.jsx("button",{onClick:()=>r(Ci(A.workspaceId,void 0,O)),className:Tt.btnPrimary,children:"+ New Task"})]});if(A.status==="failed")return o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:`${Tt.statusText} ${Tt.statusFailed}`,children:"Task failed"})})}if(L){const A=t.find(pe=>pe.id===L),F=(A==null?void 0:A.status)==="stopped";if(A!==void 0&&!F)return o.jsx(o.Fragment,{});if(F)return o.jsxs("div",{className:Tt.bar,children:[o.jsxs("span",{className:`${Tt.statusText} ${Tt.hintText}`,children:["Session ",A.endReason||A.status]}),o.jsx("button",{onClick:()=>r(D_(A.environmentId)),className:Tt.btnPrimary,children:"+ New Chat"})]})}return o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Loading..."})})}const k5="_nav_14i94_1",S5="_tab_14i94_24",T5="_tabActive_14i94_62",w5="_tabLabel_14i94_75",j5="_statusDot_14i94_81",N5="_pulse_14i94_87",C5="_addButton_14i94_99",E5="_empty_14i94_132",Aa={nav:k5,tab:S5,tabActive:T5,tabLabel:w5,statusDot:j5,pulse:N5,addButton:C5,empty:E5},A5={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function D5({environments:t}){const s=xt(),i=y.useRef(null),r=At("/environments/:environmentId"),c=At("/environments/:environmentId/edit"),d=At("/environments/:environmentId/workspaces/:workspaceId"),u=At("/environments/:environmentId/workspaces/:workspaceId/*"),p=(r==null?void 0:r.params.environmentId)??(c==null?void 0:c.params.environmentId)??(d==null?void 0:d.params.environmentId)??(u==null?void 0:u.params.environmentId),m=p==="new"?void 0:p,g=y.useCallback(_=>{s(Si(_))},[s]),v=y.useCallback(_=>{var T;const S=(T=i.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),w=k>=0?k:t.findIndex(C=>C.id===m);let N=w;if(_.key==="ArrowDown"||_.key==="j"||_.key==="J")_.preventDefault(),N=(w+1)%S.length;else if(_.key==="ArrowUp"||_.key==="k"||_.key==="K")_.preventDefault(),N=(w-1+S.length)%S.length;else if(_.key==="Home")_.preventDefault(),N=0;else if(_.key==="End")_.preventDefault(),N=S.length-1;else return;N<t.length&&s(Si(t[N].id)),S[N].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return o.jsxs("div",{className:Aa.nav,"data-testid":"environment-nav",children:[o.jsx("nav",{ref:i,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(_=>{const S=_.id===m,k=_.id===b,w=A5[_.status]||"var(--text-tertiary)",N=_.status==="connected";return o.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${Aa.tab} ${S?Aa.tabActive:""}`,onClick:()=>g(_.id),"data-testid":"env-nav-item",children:[o.jsx("span",{className:`${Aa.statusDot} ${N?Aa.pulse:""}`,style:{color:w},"aria-hidden":"true",children:o.jsx(Ba,{size:im,fill:"currentColor"})}),o.jsx("span",{className:Aa.tabLabel,title:_.displayName||_.id,children:_.displayName||_.id})]},_.id)})}),o.jsx("button",{type:"button",className:Aa.addButton,onClick:()=>s(Wj),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&o.jsx("div",{className:Aa.empty,children:"No environments yet."})]})}function Xm(t){const s=new Date(t),i=new Date,r=i.getTime()-s.getTime(),c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return"just now";if(d<60)return`${d}m ago`;if(u<24)return`${u}h ago`;if(p===1)return"yesterday";if(p<7)return`${p} days ago`;const m=s.getFullYear()===i.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const Ub={architecture:{text:"var(--accent-blue)",bg:"var(--accent-blue-dim)"},api:{text:"var(--accent-green)",bg:"var(--accent-green-dim)"},bug:{text:"var(--accent-red)",bg:"var(--accent-red-dim)"},decision:{text:"var(--accent-yellow)",bg:"var(--accent-yellow-dim)"},dependency:{text:"var(--accent-purple)",bg:"var(--accent-purple-dim)"},pattern:{text:"var(--accent-cyan)",bg:"var(--accent-cyan-dim)"},general:{text:"var(--text-secondary)",bg:"var(--bg-elevated)"}};function dd(t){return Ub[t]||Ub.general}const R5="_nav_dlm8m_1",M5="_categoryPills_dlm8m_24",I5="_categoryPill_dlm8m_24",O5="_tab_dlm8m_42",L5="_tabActive_dlm8m_80",B5="_tabContent_dlm8m_93",z5="_tabLabel_dlm8m_100",U5="_tabMeta_dlm8m_106",$5="_categoryDot_dlm8m_111",P5="_empty_dlm8m_118",_s={nav:R5,categoryPills:M5,categoryPill:I5,tab:O5,tabActive:L5,tabContent:B5,tabLabel:z5,tabMeta:U5,categoryDot:$5,empty:P5};function H5({findings:t,workspaceId:s,environmentId:i}){const r=xt(),c=y.useRef(null),d=At("/findings/:findingId"),u=At("/environments/:environmentId/workspaces/:workspaceId/findings/:findingId"),p=(d==null?void 0:d.params.findingId)??(u==null?void 0:u.params.findingId),m=y.useMemo(()=>{const _=new Set(t.map(S=>S.category).filter(Boolean));return Array.from(_).sort()},[t]),g=y.useCallback(_=>{r(Rp(_,s,i))},[r,s,i]),v=y.useCallback(_=>{var T;const S=(T=c.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),w=k>=0?k:t.findIndex(C=>C.id===p);let N=w;if(_.key==="ArrowDown"||_.key==="j"||_.key==="J")_.preventDefault(),N=(w+1)%S.length;else if(_.key==="ArrowUp"||_.key==="k"||_.key==="K")_.preventDefault(),N=(w-1+S.length)%S.length;else if(_.key==="Home")_.preventDefault(),N=0;else if(_.key==="End")_.preventDefault(),N=S.length-1;else return;N<t.length&&r(Rp(t[N].id,s,i)),S[N].focus()},[p,t,r,s,i]),b=p??(t.length>0?t[0].id:void 0);return o.jsxs("div",{className:_s.nav,"data-testid":"findings-nav",children:[m.length>1&&o.jsx("div",{className:_s.categoryPills,"data-testid":"findings-nav-categories",children:m.map(_=>o.jsx("span",{className:_s.categoryPill,style:{color:dd(_).text},children:_},_))}),o.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(_=>{const S=_.id===p,k=_.id===b;return o.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${_s.tab} ${S?_s.tabActive:""}`,onClick:()=>g(_.id),"data-testid":"finding-nav-item",children:[o.jsx("span",{className:_s.categoryDot,style:{color:dd(_.category).text},"aria-hidden":"true",children:o.jsx(Ba,{size:im,fill:"currentColor"})}),o.jsxs("span",{className:_s.tabContent,children:[o.jsx("span",{className:_s.tabLabel,title:_.title,children:_.title}),o.jsx("span",{className:_s.tabMeta,title:_.createdAt,children:Xm(_.createdAt)})]})]},_.id)})}),t.length===0&&o.jsx("div",{className:_s.empty,children:"No findings yet. Agents will post discoveries here."})]})}function V5(t){if(t.length===0)return[];const s=[...t].sort((r,c)=>r[0]-c[0]),i=[[s[0][0],s[0][1]]];for(let r=1;r<s.length;r++){const c=i[i.length-1],[d,u]=s[r];d<=c[1]+1?c[1]=Math.max(c[1],u):i.push([d,u])}return i}function b1({text:t,indices:s,highlightClass:i}){if(!s||s.length===0)return o.jsx(o.Fragment,{children:t});const r=V5(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(o.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(o.jsx("mark",{className:i,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(o.jsx("span",{children:t.slice(d)},`p${d}`)),o.jsx(o.Fragment,{children:c})}function q5(t){const s=new Map(t.map(r=>[r.id,{...r,children:[]}])),i=[];for(const r of s.values())r.parentTaskId&&s.has(r.parentTaskId)?s.get(r.parentTaskId).children.push(r):i.push(r);for(const r of s.values())r.children.sort((c,d)=>c.sortOrder-d.sortOrder);return i.sort((r,c)=>r.sortOrder-c.sortOrder)}function G5(t,s){const i=new Map;for(const d of t){const p=d.dependsOn.length>0&&d.dependsOn.some(g=>s.get(g)!=="complete")?"blocked":d.status,m=i.get(p);m?m.push(d):i.set(p,[d])}const r=[],c=new Set;for(const d of tw){c.add(d);const u=i.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=za(d);r.push({status:d,label:p.label,style:p,tasks:u})}}for(const[d,u]of i)if(!c.has(d)&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=za(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const F5="_container_z4i38_1",Z5="_header_z4i38_5",K5="_headerActions_z4i38_17",Y5="_searchInput_z4i38_23",J5="_searchHighlight_z4i38_56",W5="_groupToggle_z4i38_62",X5="_groupToggleActive_z4i38_89",Q5="_addButton_z4i38_93",eI="_taskRow_z4i38_120",tI="_selected_z4i38_140",nI="_expandArrow_z4i38_150",sI="_expanded_z4i38_157",aI="_leafSpacer_z4i38_161",iI="_taskStatusIcon_z4i38_166",oI="_taskTitle_z4i38_170",rI="_workspaceBadge_z4i38_177",lI="_childCountBadge_z4i38_195",cI="_dependencyBadge_z4i38_208",dI="_blockedBadge_z4i38_220",uI="_addChildButton_z4i38_225",fI="_emptyState_z4i38_268",pI="_statusGroupHeader_z4i38_275",mI="_statusGroupIcon_z4i38_294",hI="_statusGroupLabel_z4i38_298",gI="_statusGroupCount_z4i38_303",Fe={container:F5,header:Z5,headerActions:K5,searchInput:Y5,searchHighlight:J5,groupToggle:W5,groupToggleActive:X5,addButton:Q5,taskRow:eI,selected:tI,expandArrow:nI,expanded:sI,leafSpacer:aI,taskStatusIcon:iI,taskTitle:oI,workspaceBadge:rI,childCountBadge:lI,dependencyBadge:cI,blockedBadge:dI,addChildButton:uI,emptyState:fI,statusGroupHeader:pI,statusGroupIcon:mI,statusGroupLabel:hI,statusGroupCount:gI},vI=[{name:"title",weight:2},{name:"description",weight:1}],_1=16,yI=16,x1="grackle-task-group-by-status";function $b(){try{return localStorage.getItem(x1)==="true"}catch{return!1}}function bI(t){try{localStorage.setItem(x1,String(t))}catch{}}function _I({group:t,isExpanded:s,onToggle:i,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return o.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[o.jsxs("div",{className:Fe.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:i,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),i())},children:[o.jsx("span",{className:`${Fe.expandArrow} ${s?Fe.expanded:""}`,"aria-hidden":"true",children:o.jsx(sa,{size:it})}),o.jsx("span",{className:Fe.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),o.jsx("span",{className:Fe.statusGroupLabel,children:t.label}),o.jsx("span",{className:Fe.statusGroupCount,children:t.tasks.length})]}),o.jsx(ps,{children:s&&o.jsx(Rt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},style:{overflow:"hidden"},children:t.tasks.map(p=>{const m=za(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return o.jsxs("div",{onClick:()=>c(In(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(In(p.id)))},className:`${Fe.taskRow} ${g?Fe.selected:""}`,style:{"--task-indent":`${_1}px`},"data-task-id":p.id,children:[o.jsx("span",{className:Fe.leafSpacer}),o.jsx("span",{className:Fe.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${rl(p.status)}`,children:m.icon}),o.jsx("span",{className:Fe.taskTitle,title:p.title,children:o.jsx(b1,{text:p.title,indices:d.get(p.id),highlightClass:Fe.searchHighlight})}),v&&o.jsx("span",{className:Fe.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function k1({node:t,depth:s,expandedTasks:i,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=za(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),b=i.has(t.id),_=t.children.length>0,S=c===t.id,k=_1+s*yI,N=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{onClick:()=>d(In(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:T=>{T.currentTarget===T.target&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(In(t.id)))},className:`${Fe.taskRow} ${S?Fe.selected:""}`,style:{"--task-indent":`${k}px`},"data-task-id":t.id,children:[_&&o.jsx("span",{className:`${Fe.expandArrow} ${b?Fe.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:T=>{T.stopPropagation(),r(t.id)},onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),T.stopPropagation(),r(t.id))},children:o.jsx(sa,{size:it,"aria-hidden":"true"})}),!_&&o.jsx("span",{className:Fe.leafSpacer}),o.jsx("span",{className:Fe.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${rl(t.status)}`,children:g.icon}),o.jsx("span",{className:Fe.taskTitle,title:t.title,children:o.jsx(b1,{text:t.title,indices:p.get(t.id),highlightClass:Fe.searchHighlight})}),N&&o.jsx("span",{className:Fe.workspaceBadge,title:N,children:N}),_&&o.jsxs("span",{className:Fe.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&o.jsx("span",{className:`${Fe.dependencyBadge} ${v?Fe.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<uT&&o.jsx(Oo,{text:"Add child task",children:o.jsx("button",{onClick:T=>{T.stopPropagation(),d(Ci(t.workspaceId,t.id))},"aria-label":"Add child task",className:Fe.addChildButton,children:"+"})})]}),o.jsx(ps,{children:_&&b&&o.jsx(Rt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:t.children.map(T=>o.jsx(k1,{node:T,depth:s+1,expandedTasks:i,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function xI({workspaces:t,tasks:s}){const i=xt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState($b),[g,v]=y.useState($b),[b,_]=y.useState(new Map),S=At("/tasks/:taskId/*"),k=(S==null?void 0:S.params.taskId)!=="new"?S==null?void 0:S.params.taskId:void 0,w=y.useMemo(()=>new Map(s.map(K=>[K.id,K.status])),[s]),N=y.useMemo(()=>new Map(t.map(K=>[K.id,K.name])),[t]),T=()=>{const K=!p;bI(K),m(K),K&&(v(!0),_(new Map))},C=K=>{_(re=>{const A=new Map(re),F=A.has(K)?A.get(K):g;return A.set(K,!F),A})},D=K=>b.has(K)?b.get(K):g,L=K=>{c(re=>{const A=new Set(re);return A.has(K)?(A.delete(K),u(F=>new Set(F).add(K))):(A.add(K),u(F=>{const oe=new Set(F);return oe.delete(K),oe})),A})};y.useEffect(()=>{const K=new Set(s.filter(re=>re.parentTaskId).map(re=>re.parentTaskId));K.size>0&&c(re=>{const A=new Set(re);for(const F of K)d.has(F)||A.add(F);return A})},[s,d]);const[E,I]=y.useState(""),{directMatchTaskIds:O,treeMatchTaskIds:z,titleHighlights:$}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const K=dT(s,E,vI),re=new Set(K.map(pe=>pe.item.id)),A=new Map;for(const pe of K){const de=pe.matches.find(Oe=>Oe.key==="title");de&&A.set(pe.item.id,de.indices)}const F=new Set(re),oe=new Map(s.map(pe=>[pe.id,pe]));for(const pe of[...re]){let de=oe.get(pe);for(;de!=null&&de.parentTaskId;)F.add(de.parentTaskId),de=oe.get(de.parentTaskId)}return{directMatchTaskIds:re,treeMatchTaskIds:F,titleHighlights:A}},[E,s]),X=O!==null,te=X?p?O:z:null,P=te?s.filter(K=>te.has(K.id)):s,ae=p?[]:q5(P);return o.jsxs("div",{className:Fe.container,children:[o.jsxs("div",{className:Fe.header,children:[o.jsx("span",{children:"Tasks"}),o.jsxs("div",{className:Fe.headerActions,children:[o.jsx(Oo,{text:p?"Switch to tree view":"Group tasks by status",children:o.jsx("button",{className:`${Fe.groupToggle} ${p?Fe.groupToggleActive:""}`,onClick:T,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:o.jsx(E2,{size:en})})}),o.jsx(Oo,{text:"New task",children:o.jsx("button",{className:Fe.addButton,onClick:()=>i(Ci()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&o.jsx("input",{type:"text",value:E,onChange:K=>I(K.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Fe.searchInput,"data-testid":"sidebar-search"}),p?G5(P,w).map(K=>o.jsx(_I,{group:K,isExpanded:D(K.status),onToggle:()=>C(K.status),selectedTaskId:k,navigate:i,titleHighlights:$,workspaceNames:N},K.status)):ae.map(K=>o.jsx(k1,{node:K,depth:0,expandedTasks:r,toggleTask:L,selectedTaskId:k,navigate:i,taskStatusById:w,titleHighlights:$,workspaceNames:N},K.id)),P.length===0&&!X&&o.jsx("div",{className:Fe.emptyState,children:"No tasks yet. Click + to create one."}),P.length===0&&X&&o.jsx("div",{className:Fe.emptyState,children:"No matching tasks"})]})}const kI="_toast_ed2dk_1",SI="_success_ed2dk_18",TI="_icon_ed2dk_22",wI="_error_ed2dk_25",jI="_warning_ed2dk_32",NI="_info_ed2dk_38",CI="_message_ed2dk_53",EI="_close_ed2dk_60",Br={toast:kI,success:SI,icon:TI,error:wI,warning:jI,info:NI,message:CI,close:EI},AI={success:o.jsx(ji,{size:Bt}),error:o.jsx(Pa,{size:Bt}),warning:o.jsx(am,{size:Bt}),info:o.jsx(sm,{size:Bt})};function DI({toast:t,onDismiss:s}){return y.useEffect(()=>{const i=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(i)},[t.id,t.duration,s]),o.jsxs(Rt.div,{className:`${Br.toast} ${Br[t.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[o.jsx("span",{className:Br.icon,"aria-hidden":"true",children:AI[t.variant]}),o.jsx("span",{className:Br.message,children:t.message}),o.jsx("button",{type:"button",className:Br.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:o.jsx(Pa,{size:en,"aria-hidden":"true"})})]})}const RI="_container_qqse2_1",MI={container:RI};function II({toasts:t,onDismiss:s}){return o.jsx("div",{className:MI.container,"data-testid":"toast-container",children:o.jsx(ps,{children:t.map(i=>o.jsx(DI,{toast:i,onDismiss:s},i.id))})})}const OI="_callout_e5awm_1",LI="_success_e5awm_11",BI="_icon_e5awm_15",zI="_error_e5awm_18",UI="_warning_e5awm_25",$I="_info_e5awm_32",PI="_content_e5awm_48",HI="_close_e5awm_53",zr={callout:OI,success:LI,icon:BI,error:zI,warning:UI,info:$I,content:PI,close:HI},VI={success:o.jsx(ji,{size:Bt}),error:o.jsx(Pa,{size:Bt}),warning:o.jsx(am,{size:Bt}),info:o.jsx(sm,{size:Bt})};function qI({variant:t="info",children:s,dismissible:i=!1,className:r}){const[c,d]=y.useState(!1);return o.jsx(o.Fragment,{children:!c&&o.jsxs("div",{className:[zr.callout,zr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[o.jsx("span",{className:zr.icon,"aria-hidden":"true",children:VI[t]}),o.jsx("span",{className:zr.content,children:s}),i&&o.jsx("button",{type:"button",className:zr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:o.jsx(Pa,{size:en,"aria-hidden":"true"})})]})})}function GI({currentVersion:t,latestVersion:s,updateAvailable:i,isDocker:r}){if(!i)return o.jsx(o.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return o.jsx("div",{"data-testid":"update-banner",children:o.jsxs(qI,{variant:"info",dismissible:!0,children:[o.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",o.jsx("code",{children:c})]})})}const FI="_container_de44x_1",ZI="_emptyState_de44x_8",KI="_card_de44x_14",YI="_cardClickable_de44x_34",JI="_cardHeader_de44x_42",WI="_categoryBadge_de44x_54",XI="_findingTitle_de44x_62",QI="_findingDate_de44x_68",eO="_findingContent_de44x_80",tO="_tags_de44x_86",nO="_tag_de44x_86",cs={container:FI,emptyState:ZI,card:KI,cardClickable:YI,cardHeader:JI,categoryBadge:WI,findingTitle:XI,findingDate:QI,findingContent:eO,tags:tO,tag:nO};function S1({findings:t,onFindingClick:s}){return t.length===0?o.jsx("div",{className:cs.emptyState,children:"No findings yet. Agents will post discoveries here."}):o.jsx("div",{className:cs.container,children:t.map((i,r)=>{const c=dd(i.category),d=s?Rt.button:Rt.div;return o.jsxs(d,{type:s?"button":void 0,className:`${cs.card} ${s?cs.cardClickable:""}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:r*.05,duration:.2},onClick:s?()=>{s(i.id)}:void 0,children:[o.jsxs("div",{className:cs.cardHeader,children:[o.jsx("span",{className:cs.categoryBadge,style:{background:c.bg,color:c.text},children:i.category}),o.jsx("span",{className:cs.findingTitle,children:i.title}),o.jsx("span",{className:cs.findingDate,title:i.createdAt,children:Xm(i.createdAt)})]}),o.jsx("div",{className:cs.findingContent,children:i.content.length>300?i.content.slice(0,300)+"...":i.content}),i.tags.length>0&&o.jsx("div",{className:cs.tags,children:i.tags.map(u=>o.jsx("span",{className:cs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},i.id)})})}const sO="_section_1ingb_14",aO="_sectionTitle_1ingb_26",iO="_sectionDescription_1ingb_35",oO="_tokenList_1ingb_48",rO="_tokenRow_1ingb_55",lO="_tokenBadge_1ingb_68",cO="_tokenName_1ingb_83",dO="_tokenTarget_1ingb_90",uO="_deleteButton_1ingb_99",fO="_addForm_1ingb_113",pO="_formRow_1ingb_119",mO="_input_1ingb_125",hO="_select_1ingb_155",gO="_addButton_1ingb_187",vO="_emptyStateInfo_1ingb_221",yO="_themeOptions_1ingb_229",bO="_themeOption_1ingb_229",_O="_themeOptionSelected_1ingb_254",xO="_themeOptionHeader_1ingb_259",kO="_themeOptionLabel_1ingb_266",SO="_themeOptionDesc_1ingb_273",TO="_variantToggle_1ingb_279",wO="_variantButton_1ingb_286",jO="_variantActive_1ingb_305",NO="_themeSwatches_1ingb_311",CO="_themeSwatch_1ingb_311",EO="_systemToggle_1ingb_325",AO="_systemToggleHint_1ingb_341",DO="_themeActive_1ingb_348",RO="_aboutGrid_1ingb_354",MO="_aboutItem_1ingb_360",IO="_aboutLabel_1ingb_373",OO="_aboutValue_1ingb_379",LO="_aboutDot_1ingb_387",BO="_aboutDotConnected_1ingb_394",zO="_aboutDotDisconnected_1ingb_398",ge={section:sO,sectionTitle:aO,sectionDescription:iO,tokenList:oO,tokenRow:rO,tokenBadge:lO,tokenName:cO,tokenTarget:dO,deleteButton:uO,addForm:fO,formRow:pO,input:mO,select:hO,addButton:gO,emptyStateInfo:vO,themeOptions:yO,themeOption:bO,themeOptionSelected:_O,themeOptionHeader:xO,themeOptionLabel:kO,themeOptionDesc:SO,variantToggle:TO,variantButton:wO,variantActive:jO,themeSwatches:NO,themeSwatch:CO,systemToggle:EO,systemToggleHint:AO,themeActive:DO,aboutGrid:RO,aboutItem:MO,aboutLabel:IO,aboutValue:OO,aboutDot:LO,aboutDotConnected:BO,aboutDotDisconnected:zO},UO=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function $O({tokens:t,onSetToken:s,onDeleteToken:i,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,b]=y.useState(""),[_,S]=y.useState(null),k=T=>{if(T.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),b("")},w=T=>{S(T)},N=()=>{_&&(i(_),r==null||r("Token deleted","info")),S(null)};return o.jsxs(o.Fragment,{children:[o.jsx(wi,{isOpen:_!==null,title:"Delete Token?",description:_?`"${_}" will be permanently removed.`:void 0,onConfirm:N,onCancel:()=>S(null)}),o.jsxs("section",{className:ge.section,children:[o.jsx("h3",{className:ge.sectionTitle,children:"Tokens"}),o.jsx("p",{className:ge.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?o.jsx("div",{className:ge.emptyStateInfo,children:"Add your first API token to enable service integrations."}):o.jsx("div",{className:ge.tokenList,children:t.map(T=>o.jsxs("div",{className:ge.tokenRow,children:[o.jsx("span",{className:ge.tokenBadge,children:T.tokenType}),o.jsx("span",{className:ge.tokenName,children:T.name}),o.jsx("span",{className:ge.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),o.jsx("button",{className:ge.deleteButton,onClick:()=>w(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:o.jsx(Pa,{size:en,"aria-hidden":"true"})})]},T.name))}),o.jsxs("form",{className:ge.addForm,onSubmit:k,children:[o.jsxs("div",{className:ge.formRow,children:[o.jsx("input",{className:ge.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),o.jsx("input",{className:ge.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),o.jsxs("div",{className:ge.formRow,children:[o.jsx("select",{className:ge.select,value:m,onChange:T=>g(T.target.value),children:UO.map(T=>o.jsx("option",{value:T.value,children:T.label},T.value))}),o.jsx("input",{className:ge.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:T=>b(T.target.value)}),o.jsx("button",{className:ge.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const jd=[{id:"grackle",label:"Grackle",description:"The default Grackle theme — iridescent purple on clean dark.",swatches:["#0e1218","#8b5cf6","#60a5fa","#e5e7eb","#34d399"],variantLightId:"grackle-light",variantDarkId:"grackle-dark"},{id:"grackle-light",label:"Grackle Light",description:"Light Grackle variant.",hidden:!0},{id:"grackle-dark",label:"Grackle Dark",description:"Dark Grackle variant.",hidden:!0},{id:"glass",label:"Glassmorphism",description:"Dark frosted-glass aesthetic with backdrop blur effects.",swatches:["#0a0c14","#4ecca3","#70a1ff","#e2e8f0","#a855f7"]},{id:"matrix",label:"Matrix",description:"Phosphor-green CRT terminal with scanlines and glow.",swatches:["#050505","#00ff41","#00bfff","#33ff77","#ffb000"]},{id:"brutalist",label:"Neubrutalism",description:"Thick borders, raw colors, bold type — ugly on purpose.",swatches:["#f5f0e8","#ff5757","#5ce1e6","#1a1a1a","#ffde59"],variantLightId:"brutalist-light",variantDarkId:"brutalist-dark"},{id:"brutalist-light",label:"Neubrutalism Light",description:"Light neubrutalism variant.",hidden:!0},{id:"brutalist-dark",label:"Neubrutalism Dark",description:"Dark neubrutalism variant.",hidden:!0},{id:"monokai",label:"Monokai",description:"Classic warm editor palette — pink, green, and purple.",swatches:["#272822","#f92672","#a6e22e","#f8f8f2","#ae81ff"],variantLightId:"monokai-light",variantDarkId:"monokai-dark"},{id:"monokai-dark",label:"Monokai Dark",description:"Dark Monokai variant.",hidden:!0},{id:"monokai-light",label:"Monokai Light",description:"Light Monokai variant.",hidden:!0},{id:"ubuntu",label:"Ubuntu",description:"Aubergine terminal with the GNOME Tango palette.",swatches:["#300a24","#8ae234","#ef2929","#eeeeec","#fce94f"]},{id:"sandstone",label:"Sandstone",description:"Warm terracotta accent on dark brown, in the style of Claude Code.",swatches:["#1a1815","#C15F3C","#6b8afd","#e8e6e3","#a78bfa"]},{id:"verdigris",label:"Verdigris",description:"Teal accent on charcoal, in the style of ChatGPT.",swatches:["#141414","#00a67e","#3b82f6","#ececec","#ab68ff"]},{id:"primer",label:"Primer",description:"Blue accent on ink-dark grey, in the style of GitHub.",swatches:["#0d1117","#58a6ff","#3fb950","#c9d1d9","#bc8cff"]}],T1=new Set(jd.map(t=>t.id)),Pb="grackle";function Xp(t){return jd.find(s=>s.id===t)}function PO({themeId:t,resolvedThemeId:s,onSetTheme:i,preferSystem:r,onSetPreferSystem:c}){return o.jsxs("section",{className:ge.section,children:[o.jsx("h3",{className:ge.sectionTitle,children:"Appearance"}),o.jsx("p",{className:ge.sectionDescription,children:"Choose how Grackle looks across the app."}),o.jsx("div",{className:ge.themeOptions,children:jd.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?t===d.id||t===d.variantLightId||t===d.variantDarkId:t===d.id,m=u&&s===d.variantLightId;return o.jsxs("button",{type:"button",className:`${ge.themeOption} ${p?ge.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>i(d.id),children:[o.jsxs("span",{className:ge.themeOptionHeader,children:[o.jsxs("span",{children:[o.jsx("span",{className:ge.themeOptionLabel,children:d.label}),o.jsx("span",{className:ge.themeOptionDesc,children:d.description})]}),u&&o.jsxs("span",{className:ge.variantToggle,children:[o.jsx("span",{role:"button",tabIndex:0,className:`${ge.variantButton} ${p&&m?ge.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),i(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),i(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),o.jsx("span",{role:"button",tabIndex:0,className:`${ge.variantButton} ${p&&!m?ge.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),i(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),i(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&o.jsx("span",{className:ge.themeSwatches,children:d.swatches.map((g,v)=>o.jsx("span",{className:ge.themeSwatch,style:{background:g}},v))})]},d.id)})}),o.jsxs("label",{className:ge.systemToggle,children:[o.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),o.jsx("span",{children:"Match system light/dark preference"})]}),o.jsx("p",{className:ge.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),o.jsxs("p",{className:ge.themeActive,children:["Active theme: ",o.jsx("strong",{children:s})]})]})}function HO({connected:t,environments:s,sessions:i}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=i.filter(u=>["running","idle"].includes(u.status)).length;return o.jsxs("section",{className:ge.section,"data-testid":"about-panel",children:[o.jsx("h3",{className:ge.sectionTitle,children:"About"}),o.jsx("p",{className:ge.sectionDescription,children:"Connection status and application information."}),o.jsxs("div",{className:ge.aboutGrid,children:[o.jsxs("div",{className:ge.aboutItem,children:[o.jsx("span",{className:ge.aboutLabel,children:"Connection"}),o.jsxs("span",{className:ge.aboutValue,children:[o.jsx("span",{className:`${ge.aboutDot} ${t?ge.aboutDotConnected:ge.aboutDotDisconnected}`}),t?"Connected":"Disconnected"]})]}),o.jsxs("div",{className:ge.aboutItem,children:[o.jsx("span",{className:ge.aboutLabel,children:"Environments"}),o.jsxs("span",{className:ge.aboutValue,children:[r,"/",c," connected"]})]}),o.jsxs("div",{className:ge.aboutItem,children:[o.jsx("span",{className:ge.aboutLabel,children:"Active Sessions"}),o.jsx("span",{className:ge.aboutValue,children:d})]}),o.jsxs("div",{className:ge.aboutItem,children:[o.jsx("span",{className:ge.aboutLabel,children:"Version"}),o.jsx("span",{className:ge.aboutValue,children:"0.91.3"})]})]})]})}const VO="_container_cddyd_1",qO="_header_cddyd_8",GO="_headerTitle_cddyd_35",FO="_badge_cddyd_44",ZO="_headerActions_cddyd_54",KO="_body_cddyd_61",YO="_formContent_cddyd_73",JO="_section_cddyd_85",WO="_label_cddyd_91",XO="_titleInput_cddyd_98",QO="_descriptionTextarea_cddyd_131",eL="_parentContext_cddyd_167",tL="_parentLabel_cddyd_175",nL="_parentName_cddyd_182",sL="_personaSelect_cddyd_186",aL="_depList_cddyd_220",iL="_depItem_cddyd_226",oL="_depItemSelected_cddyd_248",rL="_noDeps_cddyd_252",lL="_btnPrimary_cddyd_258",cL="_btnGhost_cddyd_289",Qe={container:VO,header:qO,headerTitle:GO,badge:FO,headerActions:ZO,body:KO,formContent:YO,section:JO,label:WO,titleInput:XO,descriptionTextarea:QO,parentContext:eL,parentLabel:tL,parentName:nL,personaSelect:sL,depList:aL,depItem:iL,depItemSelected:oL,noDeps:rL,btnPrimary:lL,btnGhost:cL};function w1({mode:t,taskId:s,workspaceId:i,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:b}){const _=xt(),S=t==="edit",k=S&&s?d.find(me=>me.id===s):void 0,w=S?(k==null?void 0:k.workspaceId)??"":i??"",[N,T]=y.useState(w),C=w||N,D=u.find(me=>me.id===C),L=c??(D==null?void 0:D.environmentId),E=!S&&!i,I=S?(k==null?void 0:k.parentTaskId)??"":r??"",O=I?d.find(me=>me.id===I):void 0,[z,$]=y.useState((k==null?void 0:k.title)??""),[X,te]=y.useState((k==null?void 0:k.description)??""),[P,ae]=y.useState((k==null?void 0:k.dependsOn)??[]),[K,re]=y.useState((k==null?void 0:k.defaultPersonaId)??""),[A,F]=y.useState((k==null?void 0:k.canDecompose)??!1),[oe,pe]=y.useState(!1),de=y.useRef(!1);y.useEffect(()=>{S&&k&&!de.current&&(de.current=!0,$(k.title),te(k.description),ae(k.dependsOn),re(k.defaultPersonaId),F(k.canDecompose))},[S,k]);const Oe=d.filter(me=>me.workspaceId===C&&(!S||me.id!==s)&&me.id!==I),ke=z.trim().length>0&&(!S||k!==void 0)&&C.length>0,Ce=me=>{ae(Be=>Be.includes(me)?Be.filter(mt=>mt!==me):[...Be,me])},ze=()=>{!ke||oe||S&&k===void 0||(S&&s?(g(s,z.trim(),X,P,K),b==null||b("Task updated","success"),v?v():_(In(s,void 0,C,L),{replace:!0})):(pe(!0),m(C,z.trim(),X,P.length>0?P:void 0,I||void 0,K,A,()=>{b==null||b("Task created","success"),_(i?ki(i,L):"/tasks",{replace:!0})},me=>{b==null||b(me,"error"),pe(!1)})))},ue=()=>{if(v){v();return}_(S&&s?In(s,void 0,C,L):i?ki(i,L):"/tasks")},_e=S?"edit task":I?"child task":"new task";return o.jsxs("div",{className:Qe.container,children:[o.jsxs("div",{className:Qe.header,children:[o.jsxs("div",{className:Qe.headerTitle,children:[o.jsx("span",{className:Qe.badge,children:_e}),O&&o.jsxs("span",{className:Qe.parentContext,children:[o.jsx("span",{className:Qe.parentLabel,children:"Child of"}),o.jsx("span",{className:Qe.parentName,children:O.title})]})]}),o.jsxs("div",{className:Qe.headerActions,children:[o.jsx("button",{onClick:ze,disabled:!ke||oe,className:Qe.btnPrimary,"data-testid":"task-edit-save",children:oe?"Creating…":S?"Save Changes":"Create"}),o.jsx("button",{onClick:ue,className:Qe.btnGhost,children:"Cancel"})]})]}),o.jsx("div",{className:Qe.body,children:o.jsxs("div",{className:Qe.formContent,children:[E&&o.jsxs("div",{className:Qe.section,children:[o.jsx("label",{className:Qe.label,htmlFor:"task-edit-workspace",children:"Workspace"}),o.jsxs("select",{id:"task-edit-workspace",value:N,onChange:me=>T(me.target.value),className:Qe.personaSelect,"data-testid":"task-edit-workspace",children:[o.jsx("option",{value:"",children:"Select a workspace..."}),u.map(me=>o.jsx("option",{value:me.id,children:me.name},me.id))]})]}),o.jsxs("div",{className:Qe.section,children:[o.jsx("label",{className:Qe.label,htmlFor:"task-edit-title",children:"Title"}),o.jsx("input",{id:"task-edit-title",type:"text",value:z,onChange:me=>$(me.target.value),placeholder:"Task title...",autoFocus:!0,className:Qe.titleInput,"data-testid":"task-edit-title",onKeyDown:me=>{me.key==="Enter"&&ke&&ze()}})]}),o.jsxs("div",{className:Qe.section,children:[o.jsx("label",{className:Qe.label,htmlFor:"task-edit-description",children:"Description"}),o.jsx("textarea",{id:"task-edit-description",value:X,onChange:me=>te(me.target.value),placeholder:"Describe the task... (markdown supported)",className:Qe.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),o.jsxs("div",{className:Qe.section,children:[o.jsx("label",{className:Qe.label,htmlFor:"task-edit-persona",children:"Default Persona"}),o.jsxs("select",{id:"task-edit-persona",value:K,onChange:me=>re(me.target.value),className:Qe.personaSelect,"data-testid":"task-edit-persona",children:[o.jsx("option",{value:"",children:"(Inherit)"}),p.map(me=>o.jsx("option",{value:me.id,children:me.name},me.id))]})]}),!S&&o.jsx("div",{className:Qe.section,children:o.jsxs("label",{className:Qe.depItem,"data-testid":"task-edit-can-decompose",children:[o.jsx("input",{type:"checkbox",checked:A,onChange:me=>F(me.target.checked)}),"Can spawn subtasks"]})}),o.jsxs("div",{className:Qe.section,children:[o.jsx("div",{className:Qe.label,children:"Dependencies"}),Oe.length===0?o.jsx("div",{className:Qe.noDeps,children:"No other tasks in this workspace"}):o.jsx("div",{className:Qe.depList,children:Oe.map(me=>{const Be=P.includes(me.id);return o.jsxs("label",{className:`${Qe.depItem} ${Be?Qe.depItemSelected:""}`,"data-testid":`dep-option-${me.id}`,children:[o.jsx("input",{type:"checkbox",checked:Be,onChange:()=>Ce(me.id)}),me.title,o.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",me.status,")"]})]},me.id)})})]})]})})]})}const dL="_actionButtons_1rjka_1",uL="_btnPrimary_1rjka_8",fL="_btnDanger_1rjka_39",pL="_btnGhost_1rjka_78",Ft={actionButtons:dL,btnPrimary:uL,btnDanger:fL,btnGhost:pL};function mL({task:t,sessionId:s,isBlocked:i,onStart:r,onResume:c,onStop:d,onPause:u,onDelete:p,onEdit:m}){if(t.status==="not_started")return i?o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{onClick:m,className:Ft.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Ft.btnPrimary,children:"Start"}),o.jsx("button",{onClick:m,className:Ft.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{onClick:d,className:Ft.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),o.jsx("button",{onClick:u,disabled:!s,className:Ft.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{onClick:d,className:Ft.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),o.jsx("button",{onClick:c,className:Ft.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return o.jsx("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{onClick:r,className:Ft.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const hL="_workpadSection_y8nj9_1",gL="_workpadLabel_y8nj9_9",vL="_workpadStatus_y8nj9_17",yL="_workpadSummary_y8nj9_23",bL="_workpadExtra_y8nj9_29",Da={workpadSection:hL,workpadLabel:gL,workpadStatus:vL,workpadSummary:yL,workpadExtra:bL};function _L({workpad:t}){if(!t)return;let s;try{const i=JSON.parse(t);if(i==null||typeof i!="object"||Array.isArray(i))return;s=i}catch{return o.jsxs("div",{className:Da.workpadSection,"data-testid":"workpad-panel",children:[o.jsx("div",{className:Da.workpadLabel,children:"Workpad"}),o.jsx("div",{className:Da.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return o.jsxs("div",{className:Da.workpadSection,"data-testid":"workpad-panel",children:[o.jsx("div",{className:Da.workpadLabel,children:"Workpad"}),s.status&&o.jsx("div",{className:Da.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&o.jsx("div",{className:Da.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&o.jsx("div",{className:Da.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const xL="_overviewDashboard_r05qm_1",kL="_overviewHero_r05qm_7",SL="_statusBadge_r05qm_14",TL="_statusPending_r05qm_26",wL="_statusAssigned_r05qm_31",jL="_statusInProgress_r05qm_36",NL="_statusReview_r05qm_41",CL="_statusDone_r05qm_46",EL="_statusFailed_r05qm_51",AL="_statusWaitingInput_r05qm_56",DL="_overviewBranchPill_r05qm_61",RL="_branchLink_r05qm_76",ML="_overviewSection_r05qm_87",IL="_overviewLabel_r05qm_93",OL="_overviewValue_r05qm_100",LL="_overviewMuted_r05qm_105",BL="_overviewMarkdown_r05qm_111",zL="_envRow_r05qm_180",UL="_envDot_r05qm_186",$L="_envDotGreen_r05qm_193",PL="_envDotYellow_r05qm_197",HL="_envDotRed_r05qm_201",VL="_envDotGray_r05qm_205",qL="_depList_r05qm_209",GL="_depItem_r05qm_215",FL="_depBlocked_r05qm_222",ZL="_depDone_r05qm_226",KL="_timeline_r05qm_230",YL="_timelineRow_r05qm_236",JL="_timelineKey_r05qm_243",WL="_timelineValue_r05qm_249",XL="_timelineDelta_r05qm_253",QL="_reviewNotes_r05qm_264",ye={overviewDashboard:xL,overviewHero:kL,statusBadge:SL,statusPending:TL,statusAssigned:wL,statusInProgress:jL,statusReview:NL,statusDone:CL,statusFailed:EL,statusWaitingInput:AL,overviewBranchPill:DL,branchLink:RL,overviewSection:ML,overviewLabel:IL,overviewValue:OL,overviewMuted:LL,overviewMarkdown:BL,envRow:zL,envDot:UL,envDotGreen:$L,envDotYellow:PL,envDotRed:HL,envDotGray:VL,depList:qL,depItem:GL,depBlocked:FL,depDone:ZL,timeline:KL,timelineRow:YL,timelineKey:JL,timelineValue:WL,timelineDelta:XL,reviewNotes:QL};function Lc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function vp(t,s){if(!t||!s)return;const i=new Date(s).getTime()-new Date(t).getTime();if(isNaN(i)||i<0)return;const r=Math.floor(i/6e4),c=Math.floor(i%6e4/1e3);if(r===0)return`${c}s`;const d=Math.floor(r/60),u=r%60;return d===0?`${r}m ${c}s`:`${d}h ${u}m`}function Hb(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?ye.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?ye.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?ye.envDotRed:ye.envDotGray}function eB({status:t}){const s=za(t),i=ew(t);return o.jsx("span",{className:`${ye.statusBadge} ${ye[i]??ye.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function tB({task:t,tasksById:s,environments:i,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?i.find(k=>k.id===g):void 0,b=r.find(k=>k.id===t.workspaceId),_=i.find(k=>k.id===d),S=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return o.jsxs("div",{className:ye.overviewDashboard,"data-testid":"task-overview-panel",children:[o.jsxs("div",{className:ye.overviewHero,children:[o.jsx(eB,{status:t.status}),t.branch&&o.jsx("span",{className:ye.overviewBranchPill,"data-testid":"task-overview-branch",children:S?o.jsxs("a",{href:S,target:"_blank",rel:"noreferrer noopener",className:ye.branchLink,children:["🔗"," ",t.branch]}):o.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-description",children:[o.jsx("div",{className:ye.overviewLabel,children:"Description"}),o.jsx("div",{className:ye.overviewMarkdown,children:o.jsx(pd,{remarkPlugins:[md],children:t.description})})]}),t.workpad&&o.jsx(_L,{workpad:t.workpad}),o.jsxs("div",{className:ye.overviewSection,children:[o.jsx("div",{className:ye.overviewLabel,children:"Environment"}),g&&v?o.jsxs("div",{className:ye.envRow,"data-testid":"task-overview-environment",children:[o.jsx("span",{className:`${ye.envDot} ${Hb(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),o.jsx("span",{className:ye.overviewValue,children:v.displayName})]}):_?o.jsxs("div",{className:ye.envRow,"data-testid":"task-overview-environment",children:[o.jsx("span",{className:`${ye.envDot} ${Hb(_.status)}`,title:_.status,"aria-label":`Status: ${_.status}`,role:"img"}),o.jsx("span",{className:ye.overviewValue,children:_.displayName}),o.jsx("span",{className:ye.overviewMuted,children:"(workspace default)"})]}):o.jsx("div",{className:ye.overviewMuted,children:"Set in workspace settings"})]}),o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-dependencies",children:[o.jsx("div",{className:ye.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?o.jsx("div",{className:ye.overviewMuted,children:"None"}):o.jsx("div",{className:ye.depList,children:t.dependsOn.map(k=>{const w=s.get(k),N=(w==null?void 0:w.status)==="complete";return o.jsxs("div",{className:`${ye.depItem} ${N?ye.depDone:ye.depBlocked}`,children:[o.jsx("span",{children:N?"✓":"○"}),o.jsx("span",{children:(w==null?void 0:w.title)??k})]},k)})})]}),o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-timeline",children:[o.jsx("div",{className:ye.overviewLabel,children:"Timeline"}),o.jsxs("div",{className:ye.timeline,children:[t.createdAt&&o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Created"}),o.jsx("span",{className:ye.timelineValue,children:Lc(t.createdAt)})]}),t.assignedAt&&(()=>{const k=vp(t.createdAt,t.assignedAt);return o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Assigned"}),o.jsx("span",{className:ye.timelineValue,children:Lc(t.assignedAt)}),k!==void 0&&o.jsx("span",{className:ye.timelineDelta,children:k})]})})(),t.startedAt&&(()=>{const k=vp(t.assignedAt??t.createdAt,t.startedAt);return o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Started"}),o.jsx("span",{className:ye.timelineValue,children:Lc(t.startedAt)}),k!==void 0&&o.jsx("span",{className:ye.timelineDelta,children:k})]})})(),t.completedAt&&(()=>{const k=vp(t.startedAt,t.completedAt);return o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Completed"}),o.jsx("span",{className:ye.timelineValue,children:Lc(t.completedAt)}),k!==void 0&&o.jsx("span",{className:ye.timelineDelta,children:k})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&o.jsx("div",{className:ye.overviewMuted,children:"No timing data"})]})]}),u&&u.costUsd>0&&o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-usage",children:[o.jsx("div",{className:ye.overviewLabel,children:"Usage"}),o.jsxs("div",{className:ye.timeline,children:[o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Cost"}),o.jsx("span",{className:ye.timelineValue,children:Do(u.costUsd)}),o.jsxs("span",{className:ye.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costUsd>u.costUsd&&o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Total (incl. subtasks)"}),o.jsx("span",{className:ye.timelineValue,children:Do(p.costUsd)}),o.jsxs("span",{className:ye.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),t.reviewNotes&&o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-review-notes",children:[o.jsx("div",{className:ye.overviewLabel,children:"Review Notes"}),o.jsx("div",{className:ye.reviewNotes,children:t.reviewNotes})]})]})}const nB="_container_legrg_1",sB="_header_legrg_8",aB="_headerTitle_legrg_35",iB="_badge_legrg_44",oB="_headerActions_legrg_54",rB="_body_legrg_61",lB="_formContent_legrg_73",cB="_section_legrg_85",dB="_label_legrg_91",uB="_nameInput_legrg_98",fB="_fieldInput_legrg_131",pB="_adapterSelect_legrg_164",mB="_readOnlyValue_legrg_198",hB="_codespaceSection_legrg_204",gB="_codespaceActions_legrg_210",vB="_creatingHint_legrg_216",yB="_errorHint_legrg_222",bB="_btnPrimary_legrg_235",_B="_btnGhost_legrg_266",ie={container:nB,header:sB,headerTitle:aB,badge:iB,headerActions:oB,body:rB,formContent:lB,section:cB,label:dB,nameInput:uB,fieldInput:fB,adapterSelect:pB,readOnlyValue:mB,codespaceSection:hB,codespaceActions:gB,creatingHint:vB,errorHint:yB,btnPrimary:bB,btnGhost:_B},Yc=1,Jc=65535;function yp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=Yc&&s<=Jc}function bp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function xB({codespaceName:t,onCodespaceNameChange:s,envName:i,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[b,_]=y.useState(""),[S,k]=y.useState("");return g==="create"?o.jsxs("div",{className:ie.codespaceSection,children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Repository"}),o.jsx("input",{type:"text",value:b,onChange:w=>_(w.target.value),placeholder:"owner/repo",className:ie.fieldInput,"data-testid":"env-codespace-repo"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Machine Type"}),o.jsx("input",{type:"text",value:S,onChange:w=>k(w.target.value),placeholder:"Machine type (optional)...",className:ie.fieldInput,"data-testid":"env-codespace-machine"})]}),o.jsxs("div",{className:ie.codespaceActions,children:[o.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),S.trim()||void 0),v("pick"),_(""),k(""))},disabled:!b.trim(),className:ie.btnPrimary,children:"Create"}),o.jsx("button",{onClick:()=>{v("pick"),_(""),k("")},className:ie.btnGhost,children:"Cancel"})]})]}):o.jsx("div",{className:ie.codespaceSection,children:o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Codespace"}),!u&&o.jsxs("select",{value:t,onChange:w=>{w.target.value==="__create__"?(v("create"),s("")):(s(w.target.value),w.target.value&&!i.trim()&&r(w.target.value))},disabled:p,className:ie.adapterSelect,"data-testid":"env-codespace-select",children:[o.jsx("option",{value:"",children:"Select a codespace..."}),c.map(w=>o.jsxs("option",{value:w.name,children:[w.name," (",w.repository,") — ",w.state]},w.name)),o.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&o.jsx("span",{className:ie.creatingHint,children:"Creating codespace..."}),u&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:ie.errorHint,children:u}),o.jsx("input",{type:"text",value:t,onChange:w=>s(w.target.value),placeholder:"Or enter codespace name manually...",className:ie.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&o.jsx("span",{className:ie.errorHint,children:d})]})})}function j1({mode:t,environmentId:s,environments:i,onAddEnvironment:r,onUpdateEnvironment:c,onListCodespaces:d,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v,onShowToast:b}){const _=xt(),S=t==="edit",k=S&&s?i.find(ue=>ue.id===s):void 0,[w,N]=y.useState(""),[T,C]=y.useState("local"),[D,L]=y.useState(""),[E,I]=y.useState(""),[O,z]=y.useState(""),[$,X]=y.useState(""),[te,P]=y.useState(""),[ae,K]=y.useState(""),[re,A]=y.useState(""),[F,oe]=y.useState(null),pe=y.useCallback(()=>{const ue={};if(T==="local"){if(D.trim()&&(ue.host=D.trim()),E.trim()){const _e=Number(E);Number.isInteger(_e)&&(ue.port=_e)}}else if(T==="ssh"){if(ue.host=D.trim(),O.trim()&&(ue.user=O.trim()),E.trim()){const _e=Number(E);Number.isInteger(_e)&&(ue.sshPort=_e)}$.trim()&&(ue.identityFile=$.trim())}else T==="docker"?(te.trim()&&(ue.image=te.trim()),ae.trim()&&(ue.repo=ae.trim())):T==="codespace"&&(ue.codespaceName=re.trim());return ue},[T,D,E,O,$,te,ae,re]),de=()=>!(!w.trim()||T==="ssh"&&!D.trim()||T==="codespace"&&!re.trim()||(T==="local"||T==="ssh")&&!yp(E)),Oe=()=>{de()&&(r(w.trim(),T,pe()),b==null||b("Environment added successfully","success"),_(Ao,{replace:!0}))},ke=()=>{_(s?Si(s):Ao)},Ce=y.useCallback((ue,_e)=>{if(!k||!s)return;const me=bp(k.adapterConfig),Be=_e.trim();Be?me[ue]=Be:delete me[ue],c(s,{adapterConfig:me})},[k,s,c]),ze=y.useCallback((ue,_e)=>{if(!k||!s)return;const me=bp(k.adapterConfig);if(_e.trim()){const Be=Number(_e);Number.isInteger(Be)&&Be>=Yc&&Be<=Jc&&(me[ue]=Be)}else delete me[ue];c(s,{adapterConfig:me})},[k,s,c]);if(S){if(!k)return o.jsxs("div",{className:ie.container,children:[o.jsxs("div",{className:ie.header,children:[o.jsx("div",{className:ie.headerTitle,children:o.jsx("span",{className:ie.badge,children:"edit environment"})}),o.jsx("div",{className:ie.headerActions,children:o.jsx("button",{onClick:ke,className:ie.btnGhost,children:"Back"})})]}),o.jsx("div",{className:ie.body,children:o.jsx("div",{className:ie.formContent,children:o.jsx("span",{className:ie.readOnlyValue,children:"Environment not found"})})})]});const ue=bp(k.adapterConfig);return o.jsxs("div",{className:ie.container,"data-testid":"env-edit-panel",children:[o.jsxs("div",{className:ie.header,children:[o.jsx("div",{className:ie.headerTitle,children:o.jsx("span",{className:ie.badge,children:"edit environment"})}),o.jsx("div",{className:ie.headerActions,children:o.jsx("button",{onClick:ke,className:ie.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),o.jsx("div",{className:ie.body,children:o.jsxs("div",{className:ie.formContent,children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Name"}),o.jsx(ln,{value:k.displayName,onSave:_e=>{s&&c(s,{displayName:_e})},validate:_e=>_e.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:F,onActivate:oe,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Adapter Type"}),o.jsx("span",{className:ie.readOnlyValue,"data-testid":"env-edit-adapter-type",children:k.adapterType})]}),k.adapterType==="local"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Host"}),o.jsx(ln,{value:String(ue.host??""),onSave:_e=>Ce("host",_e),mode:"edit",fieldId:"host",activeFieldId:F,onActivate:oe,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Port"}),o.jsx(ln,{value:String(ue.port??""),onSave:_e=>ze("port",_e),validate:_e=>yp(_e)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:F,onActivate:oe,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),k.adapterType==="ssh"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Host"}),o.jsx(ln,{value:String(ue.host??""),onSave:_e=>Ce("host",_e),validate:_e=>_e.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:F,onActivate:oe,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"User"}),o.jsx(ln,{value:String(ue.user??""),onSave:_e=>Ce("user",_e),mode:"edit",fieldId:"user",activeFieldId:F,onActivate:oe,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"SSH Port"}),o.jsx(ln,{value:String(ue.sshPort??""),onSave:_e=>ze("sshPort",_e),validate:_e=>yp(_e)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:F,onActivate:oe,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Identity File"}),o.jsx(ln,{value:String(ue.identityFile??""),onSave:_e=>Ce("identityFile",_e),mode:"edit",fieldId:"identityFile",activeFieldId:F,onActivate:oe,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),k.adapterType==="docker"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Image"}),o.jsx(ln,{value:String(ue.image??""),onSave:_e=>Ce("image",_e),mode:"edit",fieldId:"image",activeFieldId:F,onActivate:oe,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Repo"}),o.jsx(ln,{value:String(ue.repo??""),onSave:_e=>Ce("repo",_e),mode:"edit",fieldId:"repo",activeFieldId:F,onActivate:oe,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),k.adapterType==="codespace"&&o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Codespace Name"}),o.jsx(ln,{value:String(ue.codespaceName??""),onSave:_e=>Ce("codespaceName",_e),validate:_e=>_e.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:F,onActivate:oe,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return o.jsxs("div",{className:ie.container,"data-testid":"env-create-panel",children:[o.jsxs("div",{className:ie.header,children:[o.jsx("div",{className:ie.headerTitle,children:o.jsx("span",{className:ie.badge,children:"new environment"})}),o.jsxs("div",{className:ie.headerActions,children:[o.jsx("button",{onClick:Oe,disabled:!de(),className:ie.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),o.jsx("button",{onClick:ke,className:ie.btnGhost,children:"Cancel"})]})]}),o.jsx("div",{className:ie.body,children:o.jsxs("div",{className:ie.formContent,children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-name",children:"Name"}),o.jsx("input",{id:"env-create-name",type:"text",value:w,onChange:ue=>N(ue.target.value),placeholder:"Environment name...",autoFocus:!0,className:ie.nameInput,"data-testid":"env-create-name",onKeyDown:ue=>{ue.key==="Enter"&&de()&&Oe()}})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),o.jsxs("select",{id:"env-create-adapter",value:T,onChange:ue=>{C(ue.target.value),ue.target.value==="codespace"&&d()},className:ie.adapterSelect,"data-testid":"env-create-adapter",children:[o.jsx("option",{value:"local",children:"local"}),o.jsx("option",{value:"ssh",children:"ssh"}),o.jsx("option",{value:"docker",children:"docker"}),o.jsx("option",{value:"codespace",children:"codespace"})]})]}),T==="local"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-host",children:"Host"}),o.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:ue=>L(ue.target.value),placeholder:"Host (optional)...",className:ie.fieldInput,"data-testid":"env-create-host"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-port",children:"Port"}),o.jsx("input",{id:"env-create-port",type:"number",min:Yc,max:Jc,value:E,onChange:ue=>I(ue.target.value),placeholder:"Port (optional)...",className:ie.fieldInput,"data-testid":"env-create-port"})]})]}),T==="ssh"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-host",children:"Host"}),o.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:ue=>L(ue.target.value),placeholder:"Host (required)...",className:ie.fieldInput,"data-testid":"env-create-host"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-user",children:"User"}),o.jsx("input",{id:"env-create-user",type:"text",value:O,onChange:ue=>z(ue.target.value),placeholder:"User (optional)...",className:ie.fieldInput,"data-testid":"env-create-user"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-port",children:"SSH Port"}),o.jsx("input",{id:"env-create-port",type:"number",min:Yc,max:Jc,value:E,onChange:ue=>I(ue.target.value),placeholder:"SSH port (optional)...",className:ie.fieldInput,"data-testid":"env-create-port"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-identity",children:"Identity File"}),o.jsx("input",{id:"env-create-identity",type:"text",value:$,onChange:ue=>X(ue.target.value),placeholder:"Identity file (optional)...",className:ie.fieldInput,"data-testid":"env-create-identity"})]})]}),T==="docker"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-image",children:"Image"}),o.jsx("input",{id:"env-create-image",type:"text",value:te,onChange:ue=>P(ue.target.value),placeholder:"Image (optional)...",className:ie.fieldInput,"data-testid":"env-create-image"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-repo",children:"Repo"}),o.jsx("input",{id:"env-create-repo",type:"text",value:ae,onChange:ue=>K(ue.target.value),placeholder:"Repo (optional)...",className:ie.fieldInput,"data-testid":"env-create-repo"})]})]}),T==="codespace"&&o.jsx(xB,{codespaceName:re,onCodespaceNameChange:A,envName:w,onEnvNameChange:N,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v})]})})]})}const kB="_group_1iprv_1",SB="_groupTitle_1iprv_8",TB="_shortcutList_1iprv_17",wB="_shortcutRow_1iprv_23",jB="_keys_1iprv_36",NB="_kbd_1iprv_43",CB="_description_1iprv_60",vi={group:kB,groupTitle:SB,shortcutList:TB,shortcutRow:wB,keys:jB,kbd:NB,description:CB},EB=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"},{keys:["3"],description:"Switch to Findings tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Chat",shortcuts:[{keys:["Enter"],description:"Send message (when input is focused)"}]}];function AB(){return o.jsxs("section",{className:ge.section,"data-testid":"keyboard-shortcuts-panel",children:[o.jsx("h3",{className:ge.sectionTitle,children:"Keyboard Shortcuts"}),o.jsx("p",{className:ge.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),EB.map(t=>o.jsxs("div",{className:vi.group,children:[o.jsx("h4",{className:vi.groupTitle,children:t.title}),o.jsx("div",{className:vi.shortcutList,children:t.shortcuts.map(s=>o.jsxs("div",{className:vi.shortcutRow,children:[o.jsx("span",{className:vi.keys,children:s.keys.map(i=>o.jsx("kbd",{className:vi.kbd,children:i},i))}),o.jsx("span",{className:vi.description,children:s.description})]},s.description))})]},t.title))]})}const DB=[{key:"claude",label:"Claude",description:"Forward Claude credentials for AI agent access.",options:[{value:"off",label:"Off"},{value:"subscription",label:"Subscription"},{value:"api_key",label:"API Key"}]},{key:"github",label:"GitHub",description:"Forward GITHUB_TOKEN and GH_TOKEN for git operations.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"copilot",label:"Copilot",description:"Forward Copilot tokens (COPILOT_GITHUB_TOKEN, CLI config).",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"codex",label:"Codex",description:"Forward OPENAI_API_KEY for Codex/OpenAI access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"goose",label:"Goose",description:"Forward Goose config and API keys for Goose agent access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]}];function RB({credentialProviders:t,onUpdateCredentialProviders:s}){const i=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return o.jsxs("section",{className:ge.section,children:[o.jsx("h3",{className:ge.sectionTitle,children:"Credential Providers"}),o.jsx("p",{className:ge.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),o.jsx("div",{className:ge.tokenList,children:DB.map(r=>o.jsxs("div",{className:ge.tokenRow,children:[o.jsx("span",{className:ge.tokenName,children:r.label}),o.jsx("span",{className:ge.tokenTarget,children:r.description}),o.jsx("select",{className:ge.select,value:t[r.key],onChange:c=>i(r.key,c.target.value),children:r.options.map(c=>o.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const MB="_container_10efq_1",IB="_header_10efq_7",OB="_list_10efq_105",LB="_card_10efq_111",BB="_cardHeader_10efq_125",zB="_cardTitle_10efq_135",UB="_defaultBadge_10efq_141",$B="_cardActions_10efq_155",PB="_description_10efq_160",HB="_meta_10efq_166",VB="_empty_10efq_212",qB="_typeBadge_10efq_362",Jn={container:MB,header:IB,list:OB,card:LB,cardHeader:BB,cardTitle:zB,defaultBadge:UB,cardActions:$B,description:PB,meta:HB,empty:VB,typeBadge:qB};function GB({personas:t,appDefaultPersonaId:s,onDeletePersona:i,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await i(v),p(null)};return o.jsxs("div",{className:Jn.container,children:[o.jsxs("div",{className:Jn.header,children:[o.jsx("h2",{children:"Personas"}),o.jsx(Js,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?o.jsx("p",{className:Jn.empty,children:"No personas yet. Create one to get started."}):o.jsx("div",{className:Jn.list,children:t.map(v=>{const b=s===v.id,_=v.type==="script";return o.jsxs("div",{className:Jn.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),d(v.id))},children:[o.jsxs("div",{className:Jn.cardHeader,children:[o.jsxs("span",{className:Jn.cardTitle,children:[o.jsx("strong",{children:v.name}),o.jsx("span",{className:Jn.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:_?"Script":"Agent"}),b&&o.jsx("span",{className:Jn.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),o.jsxs("div",{className:Jn.cardActions,onClick:S=>S.stopPropagation(),children:[!b&&o.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>{r(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),o.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),o.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&o.jsx("p",{className:Jn.description,children:v.description}),o.jsxs("div",{className:Jn.meta,children:[v.runtime&&o.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&o.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&o.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),o.jsx(wi,{isOpen:u!==null,title:"Delete Persona?",description:`"${(m==null?void 0:m.name)??""}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const FB="_container_uy08i_1",ZB="_header_uy08i_7",KB="_count_uy08i_13",YB="_presets_uy08i_18",JB="_presetButton_uy08i_24",WB="_filterInput_uy08i_41",XB="_groups_uy08i_53",QB="_group_uy08i_53",e8="_groupHeader_uy08i_68",t8="_groupName_uy08i_77",n8="_groupCount_uy08i_81",s8="_toolList_uy08i_87",a8="_toolItem_uy08i_95",i8="_toolName_uy08i_103",mn={container:FB,header:ZB,count:KB,presets:YB,presetButton:JB,filterInput:WB,groups:XB,group:QB,groupHeader:e8,groupName:t8,groupCount:n8,toolList:s8,toolItem:a8,toolName:i8},o8=(()=>{const t=new Map;for(const s of o_){const i=s==="get_version_status"?"version":s.split("_")[0];t.has(i)||t.set(i,[]),t.get(i).push(s)}return[...t.entries()].sort(([s],[i])=>s.localeCompare(i)).map(([s,i])=>({group:s,tools:i.sort()}))})(),r8=[{name:"default",label:"Default",tools:r_},{name:"worker",label:"Worker",tools:fT},{name:"orchestrator",label:"Orchestrator",tools:pT},{name:"admin",label:"Admin",tools:mT}];function Vb({selectedTools:t,onChange:s,disabled:i}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.useCallback(v=>{if(i)return;const b=new Set(d);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[d,s,i]),p=y.useCallback((v,b)=>{if(i)return;const _=new Set(d);for(const S of v)b?_.delete(S):_.add(S);s([..._].sort())},[d,s,i]),m=y.useCallback(v=>{i||s([...v].sort())},[s,i]),g=r.toLowerCase();return o.jsxs("div",{className:mn.container,"data-testid":"mcp-tool-selector",children:[o.jsx("div",{className:mn.header,children:o.jsx("span",{className:mn.count,children:t.length===0?`Using default (${r_.length} tools)`:`${t.length} of ${o_.size} tools selected`})}),o.jsxs("div",{className:mn.presets,"data-testid":"mcp-tool-presets",children:[r8.map(v=>o.jsx("button",{type:"button",className:mn.presetButton,disabled:i,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),o.jsx("button",{type:"button",className:mn.presetButton,disabled:i,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),o.jsx("input",{type:"text",className:mn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:i,"data-testid":"mcp-tool-filter"}),o.jsx("div",{className:mn.groups,children:o8.map(({group:v,tools:b})=>{const _=g?b.filter(k=>k.toLowerCase().includes(g)):b;if(_.length===0)return null;const S=_.every(k=>d.has(k));return o.jsxs("div",{className:mn.group,"data-testid":`tool-group-${v}`,children:[o.jsxs("label",{className:mn.groupHeader,children:[o.jsx("input",{type:"checkbox",checked:S,onChange:()=>p(_,S),disabled:i,"data-testid":`group-toggle-${v}`}),o.jsx("span",{className:mn.groupName,children:v}),o.jsxs("span",{className:mn.groupCount,children:["(",_.filter(k=>d.has(k)).length,"/",_.length,")"]})]}),o.jsx("div",{className:mn.toolList,children:_.map(k=>o.jsxs("label",{className:mn.toolItem,children:[o.jsx("input",{type:"checkbox",checked:d.has(k),onChange:()=>u(k),disabled:i,"data-testid":`tool-${k}`}),o.jsx("span",{className:mn.toolName,children:k})]},k))})]},v)})})]})}const l8="_nav_1bhou_1",c8="_tab_1bhou_24",d8="_tabIcon_1bhou_62",u8="_tabActive_1bhou_68",Bc={nav:l8,tab:c8,tabIcon:d8,tabActive:u8},Ks=[{path:"credentials",label:"Credentials",icon:o.jsx(S2,{size:Bt})},{path:"personas",label:"Personas",icon:o.jsx(W2,{size:Bt})},{path:"appearance",label:"Appearance",icon:o.jsx(U2,{size:Bt})},{path:"shortcuts",label:"Shortcuts",icon:o.jsx(w2,{size:Bt})},{path:"about",label:"About",icon:o.jsx(sm,{size:Bt})}];function f8(){var u;const t=Zt(),s=xt(),i=y.useRef(null),r=((u=Ks.find(p=>{const m=`${Eo}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??Ks[0].path,c=y.useCallback(p=>{s(`${Eo}/${p}`)},[s]),d=y.useCallback(p=>{var S,k;const m=(S=i.current)==null?void 0:S.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(w=>w===document.activeElement),v=g>=0?g:Ks.findIndex(w=>w.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%Ks.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+Ks.length)%Ks.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=Ks.length-1;else return;const _=Ks[b].path;s(`${Eo}/${_}`),(k=m[b])==null||k.focus()},[r,s]);return o.jsx("nav",{className:Bc.nav,ref:i,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:Ks.map(p=>{const m=p.path===r;return o.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Bc.tab} ${m?Bc.tabActive:""}`,onClick:()=>c(p.path),children:[o.jsx("span",{className:Bc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}function p8({tasks:t,taskStatusById:s,sessionStatusByTaskId:i}){const r=new Map;for(const d of t)if(d.parentTaskId){const u=r.get(d.parentTaskId);u?u.push(d):r.set(d.parentTaskId,[d])}const c=new Map(oy.map(d=>[d,[]]));for(const d of t){const u=rl(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(k=>s.get(k)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(k=>k.status==="complete").length;let b;if(u==="paused"&&i){const k=i.get(d.id);k==="idle"?b="Needs input":k==="completed"&&(b="Ready to complete")}const _={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},S=c.get(u);S?S.push(_):c.get("not_started").push(_)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return oy.map(d=>{const u=za(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const m8="_boardContainer_1c4y1_1",h8="_column_1c4y1_17",g8="_columnHeader_1c4y1_34",v8="_columnIcon_1c4y1_47",y8="_columnLabel_1c4y1_52",b8="_columnCount_1c4y1_57",_8="_cardList_1c4y1_67",x8="_emptyPlaceholder_1c4y1_76",k8="_card_1c4y1_67",S8="_cardHeader_1c4y1_107",T8="_cardStatusIcon_1c4y1_113",w8="_cardTitle_1c4y1_119",j8="_cardBadges_1c4y1_127",N8="_badge_1c4y1_134",C8="_blockedBadge_1c4y1_146",E8="_childBadge_1c4y1_151",A8="_depBadge_1c4y1_155",D8="_parentBadge_1c4y1_159",R8="_pausedSubBadge_1c4y1_166",M8="_personaBadge_1c4y1_170",I8="_envBadge_1c4y1_174",O8="_emptyCta_1c4y1_178",L8="_ctaButton_1c4y1_188",B8="_ctaDescription_1c4y1_204",nt={boardContainer:m8,column:h8,columnHeader:g8,columnIcon:v8,columnLabel:y8,columnCount:b8,cardList:_8,emptyPlaceholder:x8,card:k8,cardHeader:S8,cardStatusIcon:T8,cardTitle:w8,cardBadges:j8,badge:N8,blockedBadge:C8,childBadge:E8,depBadge:A8,parentBadge:D8,pausedSubBadge:R8,personaBadge:M8,envBadge:I8,emptyCta:O8,ctaButton:L8,ctaDescription:B8};function z8({workspaceId:t,environmentId:s,tasks:i,sessions:r,personas:c,environments:d}){const u=xt(),p=y.useMemo(()=>i.filter(_=>_.workspaceId===t),[i,t]),m=y.useMemo(()=>new Map(i.map(_=>[_.id,_.status])),[i]),g=y.useMemo(()=>new Map(p.map(_=>[_.id,_])),[p]),v=y.useMemo(()=>{const _=new Map(r.map(C=>[C.id,C])),S=new Map(c.map(C=>[C.id,C])),k=new Map(d.map(C=>[C.id,C])),w=new Map,N=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const D=_.get(C.latestSessionId);if(D){if(w.set(C.id,D.endReason||D.status),D.personaId){const L=S.get(D.personaId);L&&N.set(C.id,L.name)}if(D.environmentId){const L=k.get(D.environmentId);L&&T.set(C.id,L.displayName)}}}return{sessionStatusByTaskId:w,personaNameByTaskId:N,environmentNameByTaskId:T}},[p,r,c,d]),b=y.useMemo(()=>p8({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?o.jsxs("div",{className:nt.emptyCta,"data-testid":"board-empty-cta",children:[o.jsx("button",{className:nt.ctaButton,onClick:()=>u(Ci(t,void 0,s)),children:"Create Task"}),o.jsx("div",{className:nt.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):o.jsx("div",{className:nt.boardContainer,"data-testid":"board-container",children:b.map(_=>o.jsxs("section",{className:nt.column,"data-testid":`board-column-${_.status}`,"aria-label":`${_.label}, ${_.tasks.length} ${_.tasks.length===1?"task":"tasks"}`,children:[o.jsxs("div",{className:nt.columnHeader,children:[o.jsx("span",{className:nt.columnIcon,style:{color:_.style.color},children:_.style.icon}),o.jsx("span",{className:nt.columnLabel,children:_.label}),o.jsx("span",{className:nt.columnCount,"data-testid":`board-count-${_.status}`,children:_.tasks.length})]}),o.jsx("div",{className:nt.cardList,children:_.tasks.length===0?o.jsx("div",{className:nt.emptyPlaceholder,children:"No tasks"}):o.jsx(ps,{mode:"popLayout",children:_.tasks.map(S=>o.jsx(Rt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:o.jsx(U8,{boardTask:S,tasksById:g,personaName:v.personaNameByTaskId.get(S.task.id),envName:v.environmentNameByTaskId.get(S.task.id),onClick:()=>u(In(S.task.id,void 0,t,s))})},S.task.id))})})]},_.status))})}function U8({boardTask:t,tasksById:s,personaName:i,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=za(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return o.jsxs("div",{className:nt.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c())},children:[o.jsxs("div",{className:nt.cardHeader,children:[o.jsx("span",{className:nt.cardStatusIcon,style:{color:v.color},children:v.icon}),o.jsx("span",{className:nt.cardTitle,children:d.title})]}),o.jsxs("div",{className:nt.cardBadges,children:[b&&o.jsx("span",{className:`${nt.badge} ${nt.parentBadge}`,title:b.title,children:b.title}),p>0&&o.jsxs("span",{className:`${nt.badge} ${nt.childBadge}`,children:[m,"/",p]}),u&&o.jsx("span",{className:`${nt.badge} ${nt.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&o.jsx("span",{className:`${nt.badge} ${nt.depBadge}`,children:"dep"}),g&&o.jsx("span",{className:`${nt.badge} ${nt.pausedSubBadge}`,children:g}),i&&o.jsx("span",{className:`${nt.badge} ${nt.personaBadge}`,children:i}),r&&o.jsx("span",{className:`${nt.badge} ${nt.envBadge}`,children:r})]})]})}const $8="_formContent_ymnez_1",P8="_section_ymnez_13",H8="_label_ymnez_19",V8="_titleInput_ymnez_26",q8="_descriptionTextarea_ymnez_58",G8="_selectField_ymnez_94",F8="_checkboxRow_ymnez_128",Z8="_checkboxLabel_ymnez_141",K8="_fieldError_ymnez_146",yt={formContent:$8,section:P8,label:H8,titleInput:V8,descriptionTextarea:q8,selectField:G8,checkboxRow:F8,checkboxLabel:Z8,fieldError:K8};function Y8(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.environmentId)??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const J8=100;function W8({values:t,onChange:s,environments:i,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return o.jsxs("div",{className:yt.formContent,children:[o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-name",children:"Name"}),o.jsx("input",{id:"ws-name",className:yt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:J8,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&o.jsx("span",{className:yt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-description",children:"Description"}),o.jsx("textarea",{id:"ws-description",className:yt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-repo",children:"Repository URL"}),o.jsx("input",{id:"ws-repo",className:yt.titleInput,type:"text",value:t.repoUrl,onChange:m=>p("repoUrl",m.target.value),placeholder:"https://github.com/org/repo",disabled:d,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&o.jsx("span",{className:yt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-environment",children:"Environment"}),o.jsxs("select",{id:"ws-environment",className:yt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[o.jsx("option",{value:"",children:"Select environment…"}),i.map(m=>o.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&o.jsx("span",{className:yt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-persona",children:"Default Persona"}),o.jsxs("select",{id:"ws-persona",className:yt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[o.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>o.jsx("option",{value:m.id,children:m.name},m.id))]})]}),o.jsx("div",{className:yt.section,children:o.jsxs("label",{className:yt.checkboxRow,children:[o.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),o.jsx("span",{className:yt.checkboxLabel,children:"Enable worktree isolation"})]})}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-workdir",children:"Working Directory"}),o.jsx("input",{id:"ws-workdir",className:yt.titleInput,type:"text",value:t.workingDirectory,onChange:m=>p("workingDirectory",m.target.value),placeholder:"Default (server default)",disabled:d,"data-testid":"workspace-form-workdir"})]})]})}const N1=y.createContext(void 0),X8=4e3;function Q8({children:t}){const[s,i]=y.useState([]),r=y.useRef(0),c=y.useCallback(u=>{i(p=>p.filter(m=>m.id!==u))},[]),d=y.useCallback((u,p="info",m=X8)=>{const g=`toast-${++r.current}`;i(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return o.jsx(N1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function Tn(){const t=y.useContext(N1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const Qp="grackle-theme",C1="grackle-prefer-system",E1="(prefers-color-scheme: dark)";let Vr=[],Wc;function _p(){Wc=void 0;for(const t of Vr)t()}function em(){return typeof window>"u"?!1:window.matchMedia(E1).matches}function Yr(){if(typeof localStorage>"u")return Pb;try{const t=localStorage.getItem(Qp);if(t!==null&&T1.has(t))return t}catch{}return Pb}function ud(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(C1)==="true"}catch{return!1}}function tm(t){return jd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function A1(t,s){const i=Xp(t);if(i!=null&&i.variantDarkId)return s&&i.variantLightId?em()?i.variantDarkId:i.variantLightId:i.variantDarkId;if(i!=null&&i.hidden&&s){const r=tm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return em()?r.variantDarkId:r.variantLightId}return t}function ko(t,s,i=!1){i&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=A1(t,s),i&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&ko(Yr(),ud());function ez(){return Wc===void 0&&(Wc={themeId:Yr(),systemDark:em(),preferSystem:ud()}),Wc}function tz(t){return Vr=[...Vr,t],()=>{Vr=Vr.filter(s=>s!==t)}}function nz(){const t=y.useSyncExternalStore(tz,ez),{themeId:s,preferSystem:i}=t,r=A1(s,i),c=y.useCallback(u=>{if(T1.has(u)){try{localStorage.setItem(Qp,u)}catch{}ko(u,ud(),!0),_p()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(C1,u?"true":"false")}catch{}if(u){const p=Yr(),m=Xp(p);if(m!=null&&m.hidden){const g=tm(p);if(g)try{localStorage.setItem(Qp,g.id)}catch{}}}ko(Yr(),u,!0),_p()},[]);return y.useEffect(()=>{ko(s,i)},[s,i]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(E1),p=()=>{const m=Yr(),g=ud();if(g){const v=Xp(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&ko(m,g),v!=null&&v.hidden){const b=tm(m);b!=null&&b.variantDarkId&&b.variantLightId&&ko(m,g)}}_p()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:i,setPreferSystem:d}}const D1=y.createContext(void 0);function sz({children:t}){const s=nz();return o.jsx(D1.Provider,{value:s,children:t})}function R1(){const t=y.useContext(D1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const M1=y.createContext(void 0),I1=y.createContext(void 0);function az({children:t}){const[s,i]=y.useState(void 0),r=y.useCallback(c=>{i(c)},[]);return o.jsx(I1.Provider,{value:r,children:o.jsx(M1.Provider,{value:s,children:t})})}function iz(){return y.useContext(M1)}function oz(){const t=y.useContext(I1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const Qm=y.createContext(void 0);function ut(){const t=y.useContext(Qm);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function O1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function L1(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function rz(t){return O1(t)&&typeof t.sessionId=="string"&&typeof t.eventType=="string"&&typeof t.timestamp=="string"&&typeof t.content=="string"&&(t.raw===void 0||typeof t.raw=="string")}const lz=new Set(["off","subscription","api_key"]),zc=new Set(["off","on"]);function cz(t){return O1(t)&&lz.has(t.claude)&&zc.has(t.github)&&zc.has(t.copilot)&&zc.has(t.codex)&&zc.has(t.goose)}function B1(t){switch(t){case"waiting_input":return"idle";case"completed":return"stopped";case"killed":return"stopped";case"failed":return"stopped";case"interrupted":return"stopped";case"terminated":return"stopped";default:return t}}function z1(t){switch(t){case"completed":return"completed";case"killed":return"killed";case"failed":return"interrupted";case"interrupted":return"interrupted";case"terminated":return"terminated";default:return}}const xo=5e3;function dz(t,s){const i=[];let r=t;const c=new Set;for(;r&&s.has(r)&&!c.has(r);){c.add(r);const d=s.get(r);i.unshift(d),r=d.parentTaskId||void 0}return i}const na={label:"Home",url:Ti};function uz(t){return t?[na,{label:"Settings",url:Eo},{label:t,url:void 0}]:[na,{label:"Settings",url:void 0}]}const eh={label:"Environments",url:Ao};function fz(){return[na,{label:"Environments",url:void 0}]}function pz(){return[na,{label:"New Chat",url:void 0}]}function mz(t){return[na,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function hz(t,s,i,r){const c=i.find(u=>u.id===t),d=r.find(u=>u.id===s);return[na,eh,{label:(d==null?void 0:d.displayName)??"Environment",url:Si(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function gz(t,s,i,r,c){const d=dz(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?i.find(S=>S.id===p):void 0,g=s??(m==null?void 0:m.environmentId),v=g?r.find(S=>S.id===g):void 0,b=[na];v&&g&&(b.push(eh),b.push({label:v.displayName,url:Si(g)})),m&&g&&b.push({label:m.name,url:ki(m.id,g)});for(let S=0;S<d.length-1;S++)b.push({label:d[S].title,url:In(d[S].id,void 0,p,g)});const _=d[d.length-1];return b.push({label:(_==null?void 0:_.title)??t,url:void 0}),b}const vz={label:"Findings",url:bd};function yz(){return[na,{label:"Findings",url:void 0}]}function U1(t,s,i,r,c){const d=[na];if(s&&i){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===i);d.push(eh),p&&d.push({label:p.displayName,url:Si(i)}),u&&d.push({label:u.name,url:ki(s,i)}),d.push({label:"Findings",url:iN(s,i)})}else d.push(vz);return d.push({label:t,url:void 0}),d}function th(t){const s=[];for(const i of t){const r=s[s.length-1];i.eventType==="text"&&(r==null?void 0:r.eventType)==="text"?s[s.length-1]={...r,content:r.content+i.content}:s.push(i)}return s}function Uc(t){if(typeof t.id=="string")return t.id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const i=t.item;if(i&&typeof i.id=="string")return i.id}function bz(t){if(typeof t.tool_use_id=="string")return t.tool_use_id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const i=t.item;if(i&&typeof i.id=="string")return i.id}function nh(t){const s=new Map;for(const v of t)if(v.raw)try{s.set(v,JSON.parse(v.raw))}catch{}const i=new Map;for(const v of t){if(v.eventType!=="tool_use")continue;const b=s.get(v),_=b?Uc(b):void 0;if(_)try{const S=JSON.parse(v.content);i.set(_,{tool:S.tool,args:S.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,b)=>{if(v.eventType!=="tool_result")return v;const _=s.get(v),S=_?bz(_):void 0;if(!S)return v;const k=i.get(S);if(!k)return v;r.add(S),c.add(b);let w;const N=v.content.trim();if(N.startsWith("{"))try{const T=JSON.parse(N);typeof T.detailedContent=="string"&&(w=T.detailedContent)}catch{}return{...v,toolUseCtx:{...k,detailedResult:w}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const b=s.get(d[v]),_=b?Uc(b):void 0;_&&r.has(_)||u.push(v)}const p=[];for(let v=0;v<d.length;v++)d[v].eventType!=="tool_result"||c.has(v)||p.push(v);let m=0;for(const v of u){for(;m<p.length&&p[m]<v;)m++;if(m>=p.length)break;const b=p[m];if(b!==v+1)continue;const _=d[v],S=d[b];let k;try{const w=JSON.parse(_.content);k={tool:w.tool,args:w.args}}catch{}if(k){let w;const N=S.content.trim();if(N.startsWith("{"))try{const D=JSON.parse(N);typeof D.detailedContent=="string"&&(w=D.detailedContent)}catch{}d[b]={...S,toolUseCtx:{...k,detailedResult:w}},c.add(b);const T=s.get(_),C=T?Uc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(_,{...T??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const b=s.get(v);if(!b)return!0;const _=Uc(b);if(_&&r.has(_))return!1;const S=b.__seqId;return!(S&&r.has(S))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let b=!1;for(let _=v+1;_<g.length;_++)if(g[_].eventType!=="tool_use"){b=!0;break}b&&(g[v]={...g[v],settled:!0})}return g}function _z(t,s,i){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=$1(s),d=s.filter(m=>nm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||nm(m,c)).length,p=i.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function $1(t){const s=new Map;for(const i of t)s.set(i.id,i.status);return s}function nm(t,s){return t.dependsOn.some(i=>s.get(i)!=="complete")}function xz(t,s){var u;const i=new Map;for(const p of s)i.set(p.id,p);const r=$1(t),c=[];for(const p of t){const m=p.workspaceId?((u=i.get(p.workspaceId))==null?void 0:u.name)??"Unknown":"Unknown";p.status==="failed"?c.push({task:p,reason:"failed",workspaceName:m}):nm(p,r)?c.push({task:p,reason:"blocked",workspaceName:m}):p.status==="paused"&&c.push({task:p,reason:"paused",workspaceName:m})}const d={failed:0,blocked:1,paused:2};return c.sort((p,m)=>(d[p.reason]??3)-(d[m.reason]??3)),c}function kz(t,s){const i=new Map;for(const r of s)i.set(r.id,r);return t.filter(r=>r.status==="running"||r.status==="idle"||r.status==="waiting").map(r=>{var c;return{session:r,environmentName:((c=i.get(r.environmentId))==null?void 0:c.displayName)??"Unknown"}})}function Sz(t,s,i){const r=new Map;for(const c of s){if(!c.workspaceId)continue;let d=r.get(c.workspaceId);d||(d={totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0},r.set(c.workspaceId,d)),d.totalTasks+=1,c.status==="complete"?d.completedTasks+=1:c.status==="working"?d.workingTasks+=1:c.status==="failed"&&(d.failedTasks+=1)}return t.map(c=>{const d=r.get(c.id)??{totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0};return{workspace:c,totalTasks:d.totalTasks,completedTasks:d.completedTasks,workingTasks:d.workingTasks,failedTasks:d.failedTasks}})}const ks=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
274
+ `)}function X4({events:t,formatForClipboard:s}){const[i,r]=y.useState(!1),[c,d]=y.useState(new Set),u=y.useRef(void 0),p=y.useMemo(()=>c.size,[c]),m=y.useCallback(k=>{r(!0),k!==void 0?(d(new Set([k])),u.current=k):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((k,w)=>{if(w&&u.current!==void 0){const N=Math.min(u.current,k),T=Math.max(u.current,k);d(C=>{const D=new Set(C);for(let L=N;L<=T;L++)L<t.length&&il(t[L])&&D.add(L);return D})}else d(N=>{const T=new Set(N);return T.has(k)?T.delete(k):T.add(k),T.size===0?(r(!1),u.current=void 0):u.current=k,T})},[t]),b=y.useCallback(()=>{const k=new Set;for(let w=0;w<t.length;w++)il(t[w])&&k.add(w);d(k)},[t]),_=y.useCallback(()=>{d(new Set)},[]),S=y.useCallback(async()=>{const w=[...c].sort((T,C)=>T-C).filter(T=>T<t.length).map(T=>t[T]);if(w.length===0)return!1;const N=s(w);try{return await navigator.clipboard.writeText(N),!0}catch{return!1}},[c,t,s]);return{isSelecting:i,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:_,copySelected:S}}const Q4="_wrapper_1cdza_1",e6="_scrollContainer_1cdza_9",t6="_selectingPadding_1cdza_16",n6="_toolbar_1cdza_20",s6="_directionToggle_1cdza_27",a6="_scrollToAnchor_1cdza_65",i6="_scrollToAnchorBottom_1cdza_89",o6="_scrollToAnchorTop_1cdza_93",r6="_eventOverflowWarning_1cdza_97",Ys={wrapper:Q4,scrollContainer:e6,selectingPadding:t6,toolbar:n6,directionToggle:s6,scrollToAnchor:a6,scrollToAnchorBottom:i6,scrollToAnchorTop:o6,eventOverflowWarning:r6};function l6(t){const s=new Date(t.timestamp).toLocaleTimeString();switch(t.eventType){case"text":case"output":return`Select message from assistant at ${s}`;case"user_input":return`Select message from user at ${s}`;case"tool_result":case"tool_use":return`Select tool event at ${s}`;case"error":return`Select error at ${s}`;default:return`Select event at ${s}`}}const h1="grackle-stream-direction";function c6(){try{return localStorage.getItem(h1)==="reversed"}catch{return!1}}function d6({eventsDropped:t}){return t<=0?o.jsx(o.Fragment,{}):o.jsxs("div",{className:Ys.eventOverflowWarning,role:"alert",children:[o.jsx(am,{size:en,"aria-hidden":"true"})," ",t.toLocaleString()," older event",t===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function Jm({events:t,eventsDropped:s,emptyState:i,onShowToast:r}){const c=y.useRef(null),[d,u]=y.useState(c6),p=KM(),m=X4({events:t,formatForClipboard:W4}),g=y.useMemo(()=>t.filter(il).length,[t]),v=y.useMemo(()=>d?[...t].reverse():t,[t,d]),{isAtAnchor:b,scrollToAnchor:_}=K4({scrollRef:c,contentLength:t.length,isReversed:d,paused:m.isSelecting}),S=()=>{const T=!d;u(T);try{localStorage.setItem(h1,T?"reversed":"default")}catch{}};y.useEffect(()=>{if(!m.isSelecting)return;const T=C=>{C.key==="Escape"&&m.cancelSelection()};return window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T)}},[m.isSelecting,m.cancelSelection]);const k=y.useCallback(async()=>{await m.copySelected()&&(r==null||r(`Copied ${m.selectedCount} message${m.selectedCount===1?"":"s"} to clipboard`,"success"))},[m,r]),w=p?0:.2,N=d?-8:8;return o.jsxs("div",{className:Ys.wrapper,children:[o.jsx("div",{className:Ys.toolbar,children:o.jsx(Oo,{text:d?"Showing newest first":"Showing oldest first",children:o.jsx("button",{className:Ys.directionToggle,onClick:S,"aria-label":d?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:d?o.jsx(ay,{size:en,"aria-hidden":"true"}):o.jsx(iy,{size:en,"aria-hidden":"true"})})})}),o.jsxs("div",{ref:c,className:`${Ys.scrollContainer} ${m.isSelecting?Ys.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&i,o.jsx(d6,{eventsDropped:s}),o.jsx(ps,{initial:!1,children:v.map((T,C)=>{const D=d?t.length-1-C:C;return o.jsx(Rt.div,{initial:{opacity:0,y:N},animate:{opacity:1,y:0},transition:{duration:w,ease:"easeOut"},children:o.jsx(B4,{copyText:J4(T),isContentBearing:il(T),isSelecting:m.isSelecting,isSelected:m.selectedIndices.has(D),checkboxLabel:l6(T),onSelect:()=>{m.enterSelectionMode(D)},onToggle:L=>{m.toggleEvent(D,L)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:o.jsx(kA,{event:T,toolUseCtx:T.toolUseCtx,settled:T.settled})})},`${T.sessionId}-${T.timestamp}-${D}`)})})]}),o.jsx(ps,{children:m.isSelecting&&o.jsx(G4,{selectedCount:m.selectedCount,totalSelectable:g,onSelectAll:m.selectAll,onDeselectAll:m.deselectAll,onCopy:()=>{k().catch(()=>{})},onCancel:m.cancelSelection})}),o.jsx(ps,{children:!b&&o.jsxs(Rt.button,{className:`${Ys.scrollToAnchor} ${d?Ys.scrollToAnchorTop:Ys.scrollToAnchorBottom}`,onClick:_,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[d?o.jsx(iy,{size:en,"aria-hidden":"true"}):o.jsx(ay,{size:en,"aria-hidden":"true"})," New events"]})})]})}function Wm(t){const{value:s,onSave:i,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[b,_]=y.useState(""),S=y.useRef(!1),k=d===c,w=y.useCallback(O=>{v(O),_("")},[]),N=y.useCallback(()=>{_("")},[]),T=y.useCallback(()=>{S.current=!1,u==null||u(null),v(""),_("")},[u]),C=y.useCallback(()=>{const O=m?g.trim():g;if(r){const $=r(g);if($){_($);return}}const z=m?s.trim():s;if(O===z){T();return}i(O),T()},[g,s,m,r,i,T]),D=y.useCallback(()=>{S.current=!0,u==null||u(c),v(s),_("")},[c,s,u]),L=y.useCallback(O=>{if(S.current){S.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(O=>{O.key==="Escape"?T():O.key==="Enter"&&p&&C()},[T,p,C]),I=(()=>{if(!k)return!1;const O=m?s.trim():s;return(m?g.trim():g)!==O})();return y.useEffect(()=>{!k&&(g!==""||b!=="")&&(v(""),_(""))},[k,g,b]),{isEditing:k,draft:g,error:b,isDirty:I,startEdit:D,cancelEdit:T,save:C,setDraft:w,clearError:N,handleBlur:L,handleKeyDown:E,ignoreInitialBlurRef:S}}const u6="_editFieldWrapper_yuzty_1",f6="_editInput_yuzty_10",p6="_editTextarea_yuzty_42",m6="_editSelect_yuzty_78",h6="_editError_yuzty_111",g6="_editInputInvalid_yuzty_118",v6="_editHint_yuzty_123",y6="_unsavedDot_yuzty_132",b6="_metaValueClickable_yuzty_140",_6="_editButton_yuzty_159",x6="_metaPlaceholder_yuzty_175",k6="_worktreeToggle_yuzty_180",et={editFieldWrapper:u6,editInput:f6,editTextarea:p6,editSelect:m6,editError:h6,editInputInvalid:g6,editHint:v6,unsavedDot:y6,metaValueClickable:b6,editButton:_6,metaPlaceholder:x6,worktreeToggle:k6};function ln(t){const{value:s,onSave:i,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:b,ariaLabel:_,"data-testid":S}=t,k=y.useRef(null),w=Wm({value:s,onSave:i,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(w.isEditing){const T=window.setTimeout(()=>{var C;(C=k.current)==null||C.focus()},0);return()=>window.clearTimeout(T)}},[w.isEditing]),c==="create"){const T=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return o.jsxs("div",{className:et.editFieldWrapper,children:[o.jsx("input",{className:`${et.editInput} ${C?et.editInputInvalid:""}`,value:s,onChange:T,maxLength:b,placeholder:v,"aria-label":_,"data-testid":S?`${S}-input`:void 0}),C&&o.jsx("span",{className:et.editError,"data-testid":"edit-error",children:C})]})}if(w.isEditing)return o.jsxs("div",{className:et.editFieldWrapper,children:[o.jsx("input",{ref:k,className:`${et.editInput} ${w.error?et.editInputInvalid:""}`,value:w.draft,onChange:T=>w.setDraft(T.target.value),onBlur:w.handleBlur,onKeyDown:w.handleKeyDown,maxLength:b,placeholder:v,"aria-label":_,"data-testid":S?`${S}-input`:void 0}),w.isDirty&&o.jsx("span",{className:et.unsavedDot,title:"Unsaved changes"}),w.error&&o.jsx("span",{className:et.editError,"data-testid":"edit-error",children:w.error}),o.jsx("span",{className:et.editHint,children:"Enter to save · Esc to cancel"})]});const N=g==null?void 0:g(s);return o.jsxs("span",{role:"button",tabIndex:0,className:et.metaValueClickable,onClick:()=>w.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),w.startEdit())},title:"Click to edit","aria-label":_,"data-testid":S?`${S}-button`:void 0,children:[N!==void 0?N:s?o.jsx("span",{children:s}):o.jsx("span",{className:et.metaPlaceholder,children:v||"None"}),o.jsx("span",{className:et.editButton,"aria-hidden":"true",children:"✏️"})]})}function Wp(t){const{value:s,onSave:i,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=t,S=y.useRef(null),k=Wm({value:s,onSave:i,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(k.isEditing){const N=window.setTimeout(()=>{var T;(T=S.current)==null||T.focus()},0);return()=>window.clearTimeout(N)}},[k.isEditing]),c==="create"){const N=C=>{m==null||m(C.target.value)},T=r==null?void 0:r(s);return o.jsxs("div",{className:et.editFieldWrapper,children:[o.jsx("textarea",{className:`${et.editTextarea} ${T?et.editInputInvalid:""}`,value:s,onChange:N,placeholder:v,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),T&&o.jsx("span",{className:et.editError,"data-testid":"edit-error",children:T})]})}if(k.isEditing)return o.jsxs("div",{className:et.editFieldWrapper,children:[o.jsx("textarea",{ref:S,className:`${et.editTextarea} ${k.error?et.editInputInvalid:""}`,value:k.draft,onChange:N=>k.setDraft(N.target.value),onBlur:k.handleBlur,onKeyDown:k.handleKeyDown,title:b,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),k.isDirty&&o.jsx("span",{className:et.unsavedDot,title:"Unsaved changes"}),k.error&&o.jsx("span",{className:et.editError,"data-testid":"edit-error",children:k.error}),o.jsx("span",{className:et.editHint,children:"Tab to save · Esc to cancel"})]});const w=g==null?void 0:g(s);return o.jsxs("span",{role:"button",tabIndex:0,className:et.metaValueClickable,onClick:()=>k.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),k.startEdit())},title:"Click to edit","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[w!==void 0?w:s?o.jsx("span",{children:s}):o.jsx("span",{className:et.metaPlaceholder,children:v||"None"}),o.jsx("span",{className:et.editButton,"aria-hidden":"true",children:"✏️"})]})}function cd(t){var D;const{value:s,onSave:i,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=t,S=y.useRef(null),k=Wm({value:s,onSave:i,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(k.isEditing){const L=window.setTimeout(()=>{var E;(E=S.current)==null||E.focus()},0);return()=>window.clearTimeout(L)}},[k.isEditing]);const w=y.useCallback(L=>{const E=L.target.value;k.ignoreInitialBlurRef.current=!1,E!==s&&i(E),k.cancelEdit()},[s,i,k]),N=y.useCallback(L=>{if(k.ignoreInitialBlurRef.current){k.ignoreInitialBlurRef.current=!1;return}L.relatedTarget instanceof HTMLElement&&L.relatedTarget.dataset.editAction===d||k.cancelEdit()},[d,k]);if(r==="create")return o.jsx("select",{className:et.editSelect,value:s,onChange:L=>m==null?void 0:m(L.target.value),"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(L=>o.jsx("option",{value:L.value,children:L.label},L.value))});if(k.isEditing)return o.jsx("select",{ref:S,className:et.editSelect,value:k.draft,onChange:w,onBlur:N,title:b,"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(L=>o.jsx("option",{value:L.value,children:L.label},L.value))});const T=g==null?void 0:g(s),C=(D=c.find(L=>L.value===s))==null?void 0:D.label;return o.jsxs("button",{type:"button",className:et.metaValueClickable,onClick:()=>k.startEdit(),title:"Click to change","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[T!==void 0?T:C?o.jsx("span",{children:C}):o.jsx("span",{className:et.metaPlaceholder,children:v||"None"}),o.jsx("span",{className:et.editButton,"aria-hidden":"true",children:"✏️"})]})}function S6(t){const{checked:s,onChange:i,label:r,ariaLabel:c,"data-testid":d}=t;return o.jsxs("label",{className:et.worktreeToggle,"data-testid":d,children:[o.jsx("input",{type:"checkbox",checked:s,onChange:u=>i(u.target.checked),"aria-label":c}),o.jsx("span",{children:r})]})}const T6="_envRow_1e1r5_1",w6="_envDot_1e1r5_7",j6="_envDotGreen_1e1r5_14",N6="_envDotYellow_1e1r5_18",C6="_envDotRed_1e1r5_22",E6="_envDotGray_1e1r5_26",Co={envRow:T6,envDot:w6,envDotGreen:j6,envDotYellow:N6,envDotRed:C6,envDotGray:E6};function A6(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?Co.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?Co.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?Co.envDotRed:Co.envDotGray}function D6(t){const{value:s,onSave:i,environments:r,allowNone:c=!1,fieldId:d="environment",activeFieldId:u,onActivate:p,placeholder:m="No environment",ariaLabel:g="Environment","data-testid":v}=t,b=r.find(k=>k.id===s),_=[...c?[{value:"",label:"None"}]:[],...r.map(k=>({value:k.id,label:k.displayName}))],S=()=>{if(b)return o.jsxs("span",{className:Co.envRow,children:[o.jsx("span",{className:`${Co.envDot} ${A6(b.status)}`}),b.displayName]})};return o.jsx(cd,{value:s,onSave:i,options:_,fieldId:d,activeFieldId:u,onActivate:p,renderDisplay:S,placeholder:m,ariaLabel:g,"data-testid":v})}const R6="_nav_1snmp_1",M6="_searchForm_1snmp_8",I6="_searchInput_1snmp_15",O6="_searchButton_1snmp_33",L6="_clearButton_1snmp_68",B6="_workspaceSelect_1snmp_85",z6="_listHeader_1snmp_99",U6="_nodeList_1snmp_108",$6="_nodeItem_1snmp_116",P6="_indicator_1snmp_129",H6="_label_1snmp_136",V6="_badge_1snmp_145",Yn={nav:R6,searchForm:M6,searchInput:I6,searchButton:O6,clearButton:L6,workspaceSelect:B6,listHeader:z6,nodeList:U6,nodeItem:$6,indicator:P6,label:H6,badge:V6};function q6({nodes:t,workspaces:s,loading:i,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(k=>{k.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=y.useCallback(()=>{g(""),d()},[d]),_=y.useCallback(k=>{u(k)},[u]),S=y.useCallback(k=>{g(""),p(k)},[p]);return o.jsxs("div",{className:Yn.nav,"data-testid":"knowledge-nav",children:[o.jsxs("form",{className:Yn.searchForm,onSubmit:v,children:[o.jsx("input",{className:Yn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:k=>{g(k.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),o.jsx("button",{type:"submit",className:Yn.searchButton,disabled:i,children:"Go"})]}),r&&o.jsx("button",{type:"button",className:Yn.clearButton,onClick:b,children:"Clear search"}),o.jsxs("select",{className:Yn.workspaceSelect,onChange:k=>{S(k.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[o.jsx("option",{value:"",children:"All workspaces"}),s.map(k=>o.jsx("option",{value:k.id,children:k.name},k.id))]}),o.jsxs("div",{className:Yn.listHeader,children:["Nodes (",t.length,")"]}),o.jsx("ul",{className:Yn.nodeList,children:t.map(k=>o.jsxs("li",{className:Yn.nodeItem,onClick:()=>{_(k.id)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),_(k.id))},role:"button",tabIndex:0,children:[o.jsx("span",{className:Yn.indicator,style:{backgroundColor:k.kind==="reference"?"#4A9EFF":k.category==="decision"?"#22C55E":k.category==="concept"?"#A855F7":k.category==="snippet"?"#6B7280":"#EAB308"}}),o.jsx("span",{className:Yn.label,children:k.label}),o.jsx("span",{className:Yn.badge,children:k.kind==="reference"?k.sourceType:k.category})]},k.id))})]})}const G6="_container_1mq5u_1",F6="_hamburger_1mq5u_33",Z6="_brand_1mq5u_49",K6="_brandLogo_1mq5u_68",Y6="_info_1mq5u_75",J6="_connectionLabel_1mq5u_90",W6="_connectionDot_1mq5u_103",X6="_connected_1mq5u_106",Q6="_disconnected_1mq5u_110",Zs={container:G6,hamburger:F6,brand:Z6,brandLogo:K6,info:Y6,connectionLabel:J6,connectionDot:W6,connected:X6,disconnected:Q6};function e5({connected:t,environments:s,sessions:i,onToggleSidebar:r,sidebarOpen:c}){const d=xt(),u=s.length,p=s.filter(g=>g.status==="connected").length,m=i.filter(g=>["running","idle"].includes(g.status)).length;return o.jsxs("div",{className:Zs.container,children:[r&&o.jsx("button",{type:"button",className:Zs.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:o.jsx(M2,{size:Bt,"aria-hidden":"true"})}),o.jsx(Oo,{text:"Home",placement:"bottom",children:o.jsxs("button",{type:"button",className:Zs.brand,onClick:()=>d(Ti),"data-testid":"statusbar-brand",children:[o.jsx("img",{src:"/icon-192x192.png",alt:"",className:Zs.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),o.jsxs("div",{className:Zs.info,children:[o.jsxs("span",{"aria-label":t?"Connected":"Disconnected",children:[o.jsx("span",{className:`${Zs.connectionDot} ${t?Zs.connected:Zs.disconnected}`,"aria-hidden":"true",children:o.jsx(Ba,{size:im,fill:"currentColor"})})," ",o.jsx("span",{className:Zs.connectionLabel,"aria-hidden":"true",children:t?"Connected":"Disconnected"})]}),o.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),o.jsxs("span",{children:[m," active"]})]})]})}const t5="_nav_13gkc_1",n5="_tab_13gkc_35",s5="_tabIcon_13gkc_68",a5="_tabLabel_13gkc_79",i5="_tabActive_13gkc_84",Lr={nav:t5,tab:n5,tabIcon:s5,tabLabel:a5,tabActive:i5},gi=[{view:"dashboard",label:"Dashboard",icon:o.jsx(_2,{size:Bt}),route:Ti,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:o.jsx(O2,{size:Bt}),route:sN,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:o.jsx(r2,{size:Bt}),route:aN,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:o.jsx(B2,{size:Bt}),route:Ao,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:o.jsx(t2,{size:Bt}),route:I_,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:o.jsx(f_,{size:Bt}),route:bd,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:o.jsx(F2,{size:Bt}),route:Qj,testId:"sidebar-tab-settings"}];function o5(t){return t===Ti||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(I_)?"knowledge":t.startsWith(bd)?"findings":t.startsWith(Eo)?"settings":"tasks"}function r5(){const t=Zt(),s=xt(),i=y.useRef(null),r=o5(t.pathname),c=y.useCallback(u=>{s(u.route)},[s]),d=y.useCallback(u=>{var b,_;const p=(b=i.current)==null?void 0:b.querySelectorAll('[role="tab"]');if(!p)return;const m=Array.from(p).findIndex(S=>S===document.activeElement),g=m>=0?m:gi.findIndex(S=>S.view===r);let v=g;if(u.key==="ArrowRight"||u.key==="j"||u.key==="J")u.preventDefault(),v=(g+1)%gi.length;else if(u.key==="ArrowLeft"||u.key==="k"||u.key==="K")u.preventDefault(),v=(g-1+gi.length)%gi.length;else if(u.key==="Home")u.preventDefault(),v=0;else if(u.key==="End")u.preventDefault(),v=gi.length-1;else return;s(gi[v].route),(_=p[v])==null||_.focus()},[r,s]);return o.jsx("nav",{className:Lr.nav,ref:i,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:d,"data-testid":"sidebar-nav",children:gi.map(u=>{const p=u.view===r;return o.jsx(Oo,{text:u.label,placement:"bottom",children:o.jsxs("button",{role:"tab",type:"button","aria-selected":p,tabIndex:p?0:-1,className:`${Lr.tab} ${p?Lr.tabActive:""}`,onClick:()=>c(u),"data-testid":u.testId,"aria-label":u.label,children:[o.jsx("span",{className:Lr.tabIcon,"aria-hidden":"true",children:u.icon}),o.jsx("span",{className:Lr.tabLabel,children:u.label})]})},u.view)})})}const l5="_container_pi6ii_1",c5="_content_pi6ii_66",zb={container:l5,content:c5},d5=320,g1=220,v1=600,y1="grackle-sidebar-width";function u5(){try{const t=localStorage.getItem(y1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=g1&&s<=v1)return s}}catch{}return d5}function f5(t){try{localStorage.setItem(y1,String(t))}catch{}}function p5({content:t}){const[s]=y.useState(u5),i=y.useRef(null);if(y.useEffect(()=>{const r=i.current;if(!r)return;const c=new ResizeObserver(d=>{for(const u of d){const p=u.borderBoxSize[0];if(p){const m=Math.round(p.inlineSize);m>=g1&&m<=v1&&f5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return o.jsx("div",{className:zb.container,ref:i,"data-testid":"sidebar",style:{width:s},children:o.jsx("div",{className:zb.content,children:t})})}const m5="_bar_tnfsh_1",h5="_btnPrimary_tnfsh_32",g5="_statusText_tnfsh_85",v5="_statusCompleted_tnfsh_90",y5="_statusFailed_tnfsh_94",b5="_statusBlocked_tnfsh_98",_5="_hintText_tnfsh_103",Tt={bar:m5,btnPrimary:h5,statusText:g5,statusCompleted:v5,statusFailed:y5,statusBlocked:b5,hintText:_5};function x5({sessions:t,tasks:s,environments:i}){const r=xt(),c=Zt(),d=At("/sessions/:sessionId"),u=At("/tasks/:taskId"),p=At("/tasks/:taskId/stream"),m=At("/tasks/:taskId/findings"),g=At("/tasks/:taskId/edit"),v=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),b=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),_=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),S=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),k=At("/sessions/new"),w=At("/environments/:environmentId/workspaces/:workspaceId"),N=At("/tasks/new"),T=At("/chat"),C=At("/"),D=At("/settings/*"),L=d==null?void 0:d.params.sessionId,E=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(m==null?void 0:m.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId)??(_==null?void 0:_.params.taskId)??(S==null?void 0:S.params.taskId),I=v??b??_??S,O=(I==null?void 0:I.params.environmentId)??(w==null?void 0:w.params.environmentId),z=c.pathname.startsWith("/environments")&&!w&&!I,$=!!T,X=!!k,te=!!w&&!v&&!b&&!_&&!S,P=!!N;if(!!C&&!X&&!te&&!P||!!D||(!!g||!!S)||P||z||X)return o.jsx(o.Fragment,{});if($)return i.find(F=>F.adapterType==="local"&&F.status==="connected")?o.jsx(o.Fragment,{}):o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Add a local environment to start chatting"})});if(te)return o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Select a task or click + to create one"})});if(E){const A=s.find(pe=>pe.id===E);if(!A)return o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Loading..."})});const F=new Map(s.map(pe=>[pe.id,pe])),oe=A.dependsOn.some(pe=>{const de=F.get(pe);return de!==void 0&&de.status!=="complete"});if(A.status==="not_started"){const pe=oe?A.dependsOn.map(de=>F.get(de)).filter(de=>de&&de.status!=="complete").map(de=>de.title):[];return o.jsx("div",{className:Tt.bar,children:oe?o.jsxs("span",{className:Tt.statusBlocked,children:["Blocked by: ",pe.join(", ")]}):o.jsx("span",{className:Tt.hintText,children:"Use the buttons above to start or manage this task"})})}if(A.status==="working"||A.status==="paused"){const pe=A.latestSessionId||void 0,de=pe?t.find(ke=>ke.id===pe):void 0;return de&&de.status!=="stopped"?o.jsx(o.Fragment,{}):o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Waiting for agent..."})})}if(A.status==="complete")return o.jsxs("div",{className:Tt.bar,children:[o.jsx("span",{className:`${Tt.statusText} ${Tt.statusCompleted}`,children:"Task completed"}),o.jsx("button",{onClick:()=>r(Ci(A.workspaceId,void 0,O)),className:Tt.btnPrimary,children:"+ New Task"})]});if(A.status==="failed")return o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:`${Tt.statusText} ${Tt.statusFailed}`,children:"Task failed"})})}if(L){const A=t.find(pe=>pe.id===L),F=(A==null?void 0:A.status)==="stopped";if(A!==void 0&&!F)return o.jsx(o.Fragment,{});if(F)return o.jsxs("div",{className:Tt.bar,children:[o.jsxs("span",{className:`${Tt.statusText} ${Tt.hintText}`,children:["Session ",A.endReason||A.status]}),o.jsx("button",{onClick:()=>r(D_(A.environmentId)),className:Tt.btnPrimary,children:"+ New Chat"})]})}return o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Loading..."})})}const k5="_nav_14i94_1",S5="_tab_14i94_24",T5="_tabActive_14i94_62",w5="_tabLabel_14i94_75",j5="_statusDot_14i94_81",N5="_pulse_14i94_87",C5="_addButton_14i94_99",E5="_empty_14i94_132",Aa={nav:k5,tab:S5,tabActive:T5,tabLabel:w5,statusDot:j5,pulse:N5,addButton:C5,empty:E5},A5={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function D5({environments:t}){const s=xt(),i=y.useRef(null),r=At("/environments/:environmentId"),c=At("/environments/:environmentId/edit"),d=At("/environments/:environmentId/workspaces/:workspaceId"),u=At("/environments/:environmentId/workspaces/:workspaceId/*"),p=(r==null?void 0:r.params.environmentId)??(c==null?void 0:c.params.environmentId)??(d==null?void 0:d.params.environmentId)??(u==null?void 0:u.params.environmentId),m=p==="new"?void 0:p,g=y.useCallback(_=>{s(Si(_))},[s]),v=y.useCallback(_=>{var T;const S=(T=i.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),w=k>=0?k:t.findIndex(C=>C.id===m);let N=w;if(_.key==="ArrowDown"||_.key==="j"||_.key==="J")_.preventDefault(),N=(w+1)%S.length;else if(_.key==="ArrowUp"||_.key==="k"||_.key==="K")_.preventDefault(),N=(w-1+S.length)%S.length;else if(_.key==="Home")_.preventDefault(),N=0;else if(_.key==="End")_.preventDefault(),N=S.length-1;else return;N<t.length&&s(Si(t[N].id)),S[N].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return o.jsxs("div",{className:Aa.nav,"data-testid":"environment-nav",children:[o.jsx("nav",{ref:i,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(_=>{const S=_.id===m,k=_.id===b,w=A5[_.status]||"var(--text-tertiary)",N=_.status==="connected";return o.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${Aa.tab} ${S?Aa.tabActive:""}`,onClick:()=>g(_.id),"data-testid":"env-nav-item",children:[o.jsx("span",{className:`${Aa.statusDot} ${N?Aa.pulse:""}`,style:{color:w},"aria-hidden":"true",children:o.jsx(Ba,{size:im,fill:"currentColor"})}),o.jsx("span",{className:Aa.tabLabel,title:_.displayName||_.id,children:_.displayName||_.id})]},_.id)})}),o.jsx("button",{type:"button",className:Aa.addButton,onClick:()=>s(Wj),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&o.jsx("div",{className:Aa.empty,children:"No environments yet."})]})}function Xm(t){const s=new Date(t),i=new Date,r=i.getTime()-s.getTime(),c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return"just now";if(d<60)return`${d}m ago`;if(u<24)return`${u}h ago`;if(p===1)return"yesterday";if(p<7)return`${p} days ago`;const m=s.getFullYear()===i.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const Ub={architecture:{text:"var(--accent-blue)",bg:"var(--accent-blue-dim)"},api:{text:"var(--accent-green)",bg:"var(--accent-green-dim)"},bug:{text:"var(--accent-red)",bg:"var(--accent-red-dim)"},decision:{text:"var(--accent-yellow)",bg:"var(--accent-yellow-dim)"},dependency:{text:"var(--accent-purple)",bg:"var(--accent-purple-dim)"},pattern:{text:"var(--accent-cyan)",bg:"var(--accent-cyan-dim)"},general:{text:"var(--text-secondary)",bg:"var(--bg-elevated)"}};function dd(t){return Ub[t]||Ub.general}const R5="_nav_dlm8m_1",M5="_categoryPills_dlm8m_24",I5="_categoryPill_dlm8m_24",O5="_tab_dlm8m_42",L5="_tabActive_dlm8m_80",B5="_tabContent_dlm8m_93",z5="_tabLabel_dlm8m_100",U5="_tabMeta_dlm8m_106",$5="_categoryDot_dlm8m_111",P5="_empty_dlm8m_118",_s={nav:R5,categoryPills:M5,categoryPill:I5,tab:O5,tabActive:L5,tabContent:B5,tabLabel:z5,tabMeta:U5,categoryDot:$5,empty:P5};function H5({findings:t,workspaceId:s,environmentId:i}){const r=xt(),c=y.useRef(null),d=At("/findings/:findingId"),u=At("/environments/:environmentId/workspaces/:workspaceId/findings/:findingId"),p=(d==null?void 0:d.params.findingId)??(u==null?void 0:u.params.findingId),m=y.useMemo(()=>{const _=new Set(t.map(S=>S.category).filter(Boolean));return Array.from(_).sort()},[t]),g=y.useCallback(_=>{r(Rp(_,s,i))},[r,s,i]),v=y.useCallback(_=>{var T;const S=(T=c.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),w=k>=0?k:t.findIndex(C=>C.id===p);let N=w;if(_.key==="ArrowDown"||_.key==="j"||_.key==="J")_.preventDefault(),N=(w+1)%S.length;else if(_.key==="ArrowUp"||_.key==="k"||_.key==="K")_.preventDefault(),N=(w-1+S.length)%S.length;else if(_.key==="Home")_.preventDefault(),N=0;else if(_.key==="End")_.preventDefault(),N=S.length-1;else return;N<t.length&&r(Rp(t[N].id,s,i)),S[N].focus()},[p,t,r,s,i]),b=p??(t.length>0?t[0].id:void 0);return o.jsxs("div",{className:_s.nav,"data-testid":"findings-nav",children:[m.length>1&&o.jsx("div",{className:_s.categoryPills,"data-testid":"findings-nav-categories",children:m.map(_=>o.jsx("span",{className:_s.categoryPill,style:{color:dd(_).text},children:_},_))}),o.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(_=>{const S=_.id===p,k=_.id===b;return o.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${_s.tab} ${S?_s.tabActive:""}`,onClick:()=>g(_.id),"data-testid":"finding-nav-item",children:[o.jsx("span",{className:_s.categoryDot,style:{color:dd(_.category).text},"aria-hidden":"true",children:o.jsx(Ba,{size:im,fill:"currentColor"})}),o.jsxs("span",{className:_s.tabContent,children:[o.jsx("span",{className:_s.tabLabel,title:_.title,children:_.title}),o.jsx("span",{className:_s.tabMeta,title:_.createdAt,children:Xm(_.createdAt)})]})]},_.id)})}),t.length===0&&o.jsx("div",{className:_s.empty,children:"No findings yet. Agents will post discoveries here."})]})}function V5(t){if(t.length===0)return[];const s=[...t].sort((r,c)=>r[0]-c[0]),i=[[s[0][0],s[0][1]]];for(let r=1;r<s.length;r++){const c=i[i.length-1],[d,u]=s[r];d<=c[1]+1?c[1]=Math.max(c[1],u):i.push([d,u])}return i}function b1({text:t,indices:s,highlightClass:i}){if(!s||s.length===0)return o.jsx(o.Fragment,{children:t});const r=V5(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(o.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(o.jsx("mark",{className:i,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(o.jsx("span",{children:t.slice(d)},`p${d}`)),o.jsx(o.Fragment,{children:c})}function q5(t){const s=new Map(t.map(r=>[r.id,{...r,children:[]}])),i=[];for(const r of s.values())r.parentTaskId&&s.has(r.parentTaskId)?s.get(r.parentTaskId).children.push(r):i.push(r);for(const r of s.values())r.children.sort((c,d)=>c.sortOrder-d.sortOrder);return i.sort((r,c)=>r.sortOrder-c.sortOrder)}function G5(t,s){const i=new Map;for(const d of t){const p=d.dependsOn.length>0&&d.dependsOn.some(g=>s.get(g)!=="complete")?"blocked":d.status,m=i.get(p);m?m.push(d):i.set(p,[d])}const r=[],c=new Set;for(const d of tw){c.add(d);const u=i.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=za(d);r.push({status:d,label:p.label,style:p,tasks:u})}}for(const[d,u]of i)if(!c.has(d)&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=za(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const F5="_container_z4i38_1",Z5="_header_z4i38_5",K5="_headerActions_z4i38_17",Y5="_searchInput_z4i38_23",J5="_searchHighlight_z4i38_56",W5="_groupToggle_z4i38_62",X5="_groupToggleActive_z4i38_89",Q5="_addButton_z4i38_93",eI="_taskRow_z4i38_120",tI="_selected_z4i38_140",nI="_expandArrow_z4i38_150",sI="_expanded_z4i38_157",aI="_leafSpacer_z4i38_161",iI="_taskStatusIcon_z4i38_166",oI="_taskTitle_z4i38_170",rI="_workspaceBadge_z4i38_177",lI="_childCountBadge_z4i38_195",cI="_dependencyBadge_z4i38_208",dI="_blockedBadge_z4i38_220",uI="_addChildButton_z4i38_225",fI="_emptyState_z4i38_268",pI="_statusGroupHeader_z4i38_275",mI="_statusGroupIcon_z4i38_294",hI="_statusGroupLabel_z4i38_298",gI="_statusGroupCount_z4i38_303",Fe={container:F5,header:Z5,headerActions:K5,searchInput:Y5,searchHighlight:J5,groupToggle:W5,groupToggleActive:X5,addButton:Q5,taskRow:eI,selected:tI,expandArrow:nI,expanded:sI,leafSpacer:aI,taskStatusIcon:iI,taskTitle:oI,workspaceBadge:rI,childCountBadge:lI,dependencyBadge:cI,blockedBadge:dI,addChildButton:uI,emptyState:fI,statusGroupHeader:pI,statusGroupIcon:mI,statusGroupLabel:hI,statusGroupCount:gI},vI=[{name:"title",weight:2},{name:"description",weight:1}],_1=16,yI=16,x1="grackle-task-group-by-status";function $b(){try{return localStorage.getItem(x1)==="true"}catch{return!1}}function bI(t){try{localStorage.setItem(x1,String(t))}catch{}}function _I({group:t,isExpanded:s,onToggle:i,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return o.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[o.jsxs("div",{className:Fe.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:i,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),i())},children:[o.jsx("span",{className:`${Fe.expandArrow} ${s?Fe.expanded:""}`,"aria-hidden":"true",children:o.jsx(sa,{size:it})}),o.jsx("span",{className:Fe.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),o.jsx("span",{className:Fe.statusGroupLabel,children:t.label}),o.jsx("span",{className:Fe.statusGroupCount,children:t.tasks.length})]}),o.jsx(ps,{children:s&&o.jsx(Rt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},style:{overflow:"hidden"},children:t.tasks.map(p=>{const m=za(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return o.jsxs("div",{onClick:()=>c(In(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(In(p.id)))},className:`${Fe.taskRow} ${g?Fe.selected:""}`,style:{"--task-indent":`${_1}px`},"data-task-id":p.id,children:[o.jsx("span",{className:Fe.leafSpacer}),o.jsx("span",{className:Fe.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${rl(p.status)}`,children:m.icon}),o.jsx("span",{className:Fe.taskTitle,title:p.title,children:o.jsx(b1,{text:p.title,indices:d.get(p.id),highlightClass:Fe.searchHighlight})}),v&&o.jsx("span",{className:Fe.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function k1({node:t,depth:s,expandedTasks:i,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=za(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),b=i.has(t.id),_=t.children.length>0,S=c===t.id,k=_1+s*yI,N=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{onClick:()=>d(In(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:T=>{T.currentTarget===T.target&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(In(t.id)))},className:`${Fe.taskRow} ${S?Fe.selected:""}`,style:{"--task-indent":`${k}px`},"data-task-id":t.id,children:[_&&o.jsx("span",{className:`${Fe.expandArrow} ${b?Fe.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:T=>{T.stopPropagation(),r(t.id)},onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),T.stopPropagation(),r(t.id))},children:o.jsx(sa,{size:it,"aria-hidden":"true"})}),!_&&o.jsx("span",{className:Fe.leafSpacer}),o.jsx("span",{className:Fe.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${rl(t.status)}`,children:g.icon}),o.jsx("span",{className:Fe.taskTitle,title:t.title,children:o.jsx(b1,{text:t.title,indices:p.get(t.id),highlightClass:Fe.searchHighlight})}),N&&o.jsx("span",{className:Fe.workspaceBadge,title:N,children:N}),_&&o.jsxs("span",{className:Fe.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&o.jsx("span",{className:`${Fe.dependencyBadge} ${v?Fe.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<uT&&o.jsx(Oo,{text:"Add child task",children:o.jsx("button",{onClick:T=>{T.stopPropagation(),d(Ci(t.workspaceId,t.id))},"aria-label":"Add child task",className:Fe.addChildButton,children:"+"})})]}),o.jsx(ps,{children:_&&b&&o.jsx(Rt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:t.children.map(T=>o.jsx(k1,{node:T,depth:s+1,expandedTasks:i,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function xI({workspaces:t,tasks:s}){const i=xt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState($b),[g,v]=y.useState($b),[b,_]=y.useState(new Map),S=At("/tasks/:taskId/*"),k=(S==null?void 0:S.params.taskId)!=="new"?S==null?void 0:S.params.taskId:void 0,w=y.useMemo(()=>new Map(s.map(K=>[K.id,K.status])),[s]),N=y.useMemo(()=>new Map(t.map(K=>[K.id,K.name])),[t]),T=()=>{const K=!p;bI(K),m(K),K&&(v(!0),_(new Map))},C=K=>{_(re=>{const A=new Map(re),F=A.has(K)?A.get(K):g;return A.set(K,!F),A})},D=K=>b.has(K)?b.get(K):g,L=K=>{c(re=>{const A=new Set(re);return A.has(K)?(A.delete(K),u(F=>new Set(F).add(K))):(A.add(K),u(F=>{const oe=new Set(F);return oe.delete(K),oe})),A})};y.useEffect(()=>{const K=new Set(s.filter(re=>re.parentTaskId).map(re=>re.parentTaskId));K.size>0&&c(re=>{const A=new Set(re);for(const F of K)d.has(F)||A.add(F);return A})},[s,d]);const[E,I]=y.useState(""),{directMatchTaskIds:O,treeMatchTaskIds:z,titleHighlights:$}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const K=dT(s,E,vI),re=new Set(K.map(pe=>pe.item.id)),A=new Map;for(const pe of K){const de=pe.matches.find(Oe=>Oe.key==="title");de&&A.set(pe.item.id,de.indices)}const F=new Set(re),oe=new Map(s.map(pe=>[pe.id,pe]));for(const pe of[...re]){let de=oe.get(pe);for(;de!=null&&de.parentTaskId;)F.add(de.parentTaskId),de=oe.get(de.parentTaskId)}return{directMatchTaskIds:re,treeMatchTaskIds:F,titleHighlights:A}},[E,s]),X=O!==null,te=X?p?O:z:null,P=te?s.filter(K=>te.has(K.id)):s,ae=p?[]:q5(P);return o.jsxs("div",{className:Fe.container,children:[o.jsxs("div",{className:Fe.header,children:[o.jsx("span",{children:"Tasks"}),o.jsxs("div",{className:Fe.headerActions,children:[o.jsx(Oo,{text:p?"Switch to tree view":"Group tasks by status",children:o.jsx("button",{className:`${Fe.groupToggle} ${p?Fe.groupToggleActive:""}`,onClick:T,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:o.jsx(E2,{size:en})})}),o.jsx(Oo,{text:"New task",children:o.jsx("button",{className:Fe.addButton,onClick:()=>i(Ci()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&o.jsx("input",{type:"text",value:E,onChange:K=>I(K.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Fe.searchInput,"data-testid":"sidebar-search"}),p?G5(P,w).map(K=>o.jsx(_I,{group:K,isExpanded:D(K.status),onToggle:()=>C(K.status),selectedTaskId:k,navigate:i,titleHighlights:$,workspaceNames:N},K.status)):ae.map(K=>o.jsx(k1,{node:K,depth:0,expandedTasks:r,toggleTask:L,selectedTaskId:k,navigate:i,taskStatusById:w,titleHighlights:$,workspaceNames:N},K.id)),P.length===0&&!X&&o.jsx("div",{className:Fe.emptyState,children:"No tasks yet. Click + to create one."}),P.length===0&&X&&o.jsx("div",{className:Fe.emptyState,children:"No matching tasks"})]})}const kI="_toast_ed2dk_1",SI="_success_ed2dk_18",TI="_icon_ed2dk_22",wI="_error_ed2dk_25",jI="_warning_ed2dk_32",NI="_info_ed2dk_38",CI="_message_ed2dk_53",EI="_close_ed2dk_60",Br={toast:kI,success:SI,icon:TI,error:wI,warning:jI,info:NI,message:CI,close:EI},AI={success:o.jsx(ji,{size:Bt}),error:o.jsx(Pa,{size:Bt}),warning:o.jsx(am,{size:Bt}),info:o.jsx(sm,{size:Bt})};function DI({toast:t,onDismiss:s}){return y.useEffect(()=>{const i=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(i)},[t.id,t.duration,s]),o.jsxs(Rt.div,{className:`${Br.toast} ${Br[t.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[o.jsx("span",{className:Br.icon,"aria-hidden":"true",children:AI[t.variant]}),o.jsx("span",{className:Br.message,children:t.message}),o.jsx("button",{type:"button",className:Br.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:o.jsx(Pa,{size:en,"aria-hidden":"true"})})]})}const RI="_container_qqse2_1",MI={container:RI};function II({toasts:t,onDismiss:s}){return o.jsx("div",{className:MI.container,"data-testid":"toast-container",children:o.jsx(ps,{children:t.map(i=>o.jsx(DI,{toast:i,onDismiss:s},i.id))})})}const OI="_callout_e5awm_1",LI="_success_e5awm_11",BI="_icon_e5awm_15",zI="_error_e5awm_18",UI="_warning_e5awm_25",$I="_info_e5awm_32",PI="_content_e5awm_48",HI="_close_e5awm_53",zr={callout:OI,success:LI,icon:BI,error:zI,warning:UI,info:$I,content:PI,close:HI},VI={success:o.jsx(ji,{size:Bt}),error:o.jsx(Pa,{size:Bt}),warning:o.jsx(am,{size:Bt}),info:o.jsx(sm,{size:Bt})};function qI({variant:t="info",children:s,dismissible:i=!1,className:r}){const[c,d]=y.useState(!1);return o.jsx(o.Fragment,{children:!c&&o.jsxs("div",{className:[zr.callout,zr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[o.jsx("span",{className:zr.icon,"aria-hidden":"true",children:VI[t]}),o.jsx("span",{className:zr.content,children:s}),i&&o.jsx("button",{type:"button",className:zr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:o.jsx(Pa,{size:en,"aria-hidden":"true"})})]})})}function GI({currentVersion:t,latestVersion:s,updateAvailable:i,isDocker:r}){if(!i)return o.jsx(o.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return o.jsx("div",{"data-testid":"update-banner",children:o.jsxs(qI,{variant:"info",dismissible:!0,children:[o.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",o.jsx("code",{children:c})]})})}const FI="_container_de44x_1",ZI="_emptyState_de44x_8",KI="_card_de44x_14",YI="_cardClickable_de44x_34",JI="_cardHeader_de44x_42",WI="_categoryBadge_de44x_54",XI="_findingTitle_de44x_62",QI="_findingDate_de44x_68",eO="_findingContent_de44x_80",tO="_tags_de44x_86",nO="_tag_de44x_86",cs={container:FI,emptyState:ZI,card:KI,cardClickable:YI,cardHeader:JI,categoryBadge:WI,findingTitle:XI,findingDate:QI,findingContent:eO,tags:tO,tag:nO};function S1({findings:t,onFindingClick:s}){return t.length===0?o.jsx("div",{className:cs.emptyState,children:"No findings yet. Agents will post discoveries here."}):o.jsx("div",{className:cs.container,children:t.map((i,r)=>{const c=dd(i.category),d=s?Rt.button:Rt.div;return o.jsxs(d,{type:s?"button":void 0,className:`${cs.card} ${s?cs.cardClickable:""}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:r*.05,duration:.2},onClick:s?()=>{s(i.id)}:void 0,children:[o.jsxs("div",{className:cs.cardHeader,children:[o.jsx("span",{className:cs.categoryBadge,style:{background:c.bg,color:c.text},children:i.category}),o.jsx("span",{className:cs.findingTitle,children:i.title}),o.jsx("span",{className:cs.findingDate,title:i.createdAt,children:Xm(i.createdAt)})]}),o.jsx("div",{className:cs.findingContent,children:i.content.length>300?i.content.slice(0,300)+"...":i.content}),i.tags.length>0&&o.jsx("div",{className:cs.tags,children:i.tags.map(u=>o.jsx("span",{className:cs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},i.id)})})}const sO="_section_1ingb_14",aO="_sectionTitle_1ingb_26",iO="_sectionDescription_1ingb_35",oO="_tokenList_1ingb_48",rO="_tokenRow_1ingb_55",lO="_tokenBadge_1ingb_68",cO="_tokenName_1ingb_83",dO="_tokenTarget_1ingb_90",uO="_deleteButton_1ingb_99",fO="_addForm_1ingb_113",pO="_formRow_1ingb_119",mO="_input_1ingb_125",hO="_select_1ingb_155",gO="_addButton_1ingb_187",vO="_emptyStateInfo_1ingb_221",yO="_themeOptions_1ingb_229",bO="_themeOption_1ingb_229",_O="_themeOptionSelected_1ingb_254",xO="_themeOptionHeader_1ingb_259",kO="_themeOptionLabel_1ingb_266",SO="_themeOptionDesc_1ingb_273",TO="_variantToggle_1ingb_279",wO="_variantButton_1ingb_286",jO="_variantActive_1ingb_305",NO="_themeSwatches_1ingb_311",CO="_themeSwatch_1ingb_311",EO="_systemToggle_1ingb_325",AO="_systemToggleHint_1ingb_341",DO="_themeActive_1ingb_348",RO="_aboutGrid_1ingb_354",MO="_aboutItem_1ingb_360",IO="_aboutLabel_1ingb_373",OO="_aboutValue_1ingb_379",LO="_aboutDot_1ingb_387",BO="_aboutDotConnected_1ingb_394",zO="_aboutDotDisconnected_1ingb_398",ge={section:sO,sectionTitle:aO,sectionDescription:iO,tokenList:oO,tokenRow:rO,tokenBadge:lO,tokenName:cO,tokenTarget:dO,deleteButton:uO,addForm:fO,formRow:pO,input:mO,select:hO,addButton:gO,emptyStateInfo:vO,themeOptions:yO,themeOption:bO,themeOptionSelected:_O,themeOptionHeader:xO,themeOptionLabel:kO,themeOptionDesc:SO,variantToggle:TO,variantButton:wO,variantActive:jO,themeSwatches:NO,themeSwatch:CO,systemToggle:EO,systemToggleHint:AO,themeActive:DO,aboutGrid:RO,aboutItem:MO,aboutLabel:IO,aboutValue:OO,aboutDot:LO,aboutDotConnected:BO,aboutDotDisconnected:zO},UO=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function $O({tokens:t,onSetToken:s,onDeleteToken:i,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,b]=y.useState(""),[_,S]=y.useState(null),k=T=>{if(T.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),b("")},w=T=>{S(T)},N=()=>{_&&(i(_),r==null||r("Token deleted","info")),S(null)};return o.jsxs(o.Fragment,{children:[o.jsx(wi,{isOpen:_!==null,title:"Delete Token?",description:_?`"${_}" will be permanently removed.`:void 0,onConfirm:N,onCancel:()=>S(null)}),o.jsxs("section",{className:ge.section,children:[o.jsx("h3",{className:ge.sectionTitle,children:"Tokens"}),o.jsx("p",{className:ge.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?o.jsx("div",{className:ge.emptyStateInfo,children:"Add your first API token to enable service integrations."}):o.jsx("div",{className:ge.tokenList,children:t.map(T=>o.jsxs("div",{className:ge.tokenRow,children:[o.jsx("span",{className:ge.tokenBadge,children:T.tokenType}),o.jsx("span",{className:ge.tokenName,children:T.name}),o.jsx("span",{className:ge.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),o.jsx("button",{className:ge.deleteButton,onClick:()=>w(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:o.jsx(Pa,{size:en,"aria-hidden":"true"})})]},T.name))}),o.jsxs("form",{className:ge.addForm,onSubmit:k,children:[o.jsxs("div",{className:ge.formRow,children:[o.jsx("input",{className:ge.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),o.jsx("input",{className:ge.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),o.jsxs("div",{className:ge.formRow,children:[o.jsx("select",{className:ge.select,value:m,onChange:T=>g(T.target.value),children:UO.map(T=>o.jsx("option",{value:T.value,children:T.label},T.value))}),o.jsx("input",{className:ge.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:T=>b(T.target.value)}),o.jsx("button",{className:ge.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const jd=[{id:"grackle",label:"Grackle",description:"The default Grackle theme — iridescent purple on clean dark.",swatches:["#0e1218","#8b5cf6","#60a5fa","#e5e7eb","#34d399"],variantLightId:"grackle-light",variantDarkId:"grackle-dark"},{id:"grackle-light",label:"Grackle Light",description:"Light Grackle variant.",hidden:!0},{id:"grackle-dark",label:"Grackle Dark",description:"Dark Grackle variant.",hidden:!0},{id:"glass",label:"Glassmorphism",description:"Dark frosted-glass aesthetic with backdrop blur effects.",swatches:["#0a0c14","#4ecca3","#70a1ff","#e2e8f0","#a855f7"]},{id:"matrix",label:"Matrix",description:"Phosphor-green CRT terminal with scanlines and glow.",swatches:["#050505","#00ff41","#00bfff","#33ff77","#ffb000"]},{id:"brutalist",label:"Neubrutalism",description:"Thick borders, raw colors, bold type — ugly on purpose.",swatches:["#f5f0e8","#ff5757","#5ce1e6","#1a1a1a","#ffde59"],variantLightId:"brutalist-light",variantDarkId:"brutalist-dark"},{id:"brutalist-light",label:"Neubrutalism Light",description:"Light neubrutalism variant.",hidden:!0},{id:"brutalist-dark",label:"Neubrutalism Dark",description:"Dark neubrutalism variant.",hidden:!0},{id:"monokai",label:"Monokai",description:"Classic warm editor palette — pink, green, and purple.",swatches:["#272822","#f92672","#a6e22e","#f8f8f2","#ae81ff"],variantLightId:"monokai-light",variantDarkId:"monokai-dark"},{id:"monokai-dark",label:"Monokai Dark",description:"Dark Monokai variant.",hidden:!0},{id:"monokai-light",label:"Monokai Light",description:"Light Monokai variant.",hidden:!0},{id:"ubuntu",label:"Ubuntu",description:"Aubergine terminal with the GNOME Tango palette.",swatches:["#300a24","#8ae234","#ef2929","#eeeeec","#fce94f"]},{id:"sandstone",label:"Sandstone",description:"Warm terracotta accent on dark brown, in the style of Claude Code.",swatches:["#1a1815","#C15F3C","#6b8afd","#e8e6e3","#a78bfa"]},{id:"verdigris",label:"Verdigris",description:"Teal accent on charcoal, in the style of ChatGPT.",swatches:["#141414","#00a67e","#3b82f6","#ececec","#ab68ff"]},{id:"primer",label:"Primer",description:"Blue accent on ink-dark grey, in the style of GitHub.",swatches:["#0d1117","#58a6ff","#3fb950","#c9d1d9","#bc8cff"]}],T1=new Set(jd.map(t=>t.id)),Pb="grackle";function Xp(t){return jd.find(s=>s.id===t)}function PO({themeId:t,resolvedThemeId:s,onSetTheme:i,preferSystem:r,onSetPreferSystem:c}){return o.jsxs("section",{className:ge.section,children:[o.jsx("h3",{className:ge.sectionTitle,children:"Appearance"}),o.jsx("p",{className:ge.sectionDescription,children:"Choose how Grackle looks across the app."}),o.jsx("div",{className:ge.themeOptions,children:jd.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?t===d.id||t===d.variantLightId||t===d.variantDarkId:t===d.id,m=u&&s===d.variantLightId;return o.jsxs("button",{type:"button",className:`${ge.themeOption} ${p?ge.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>i(d.id),children:[o.jsxs("span",{className:ge.themeOptionHeader,children:[o.jsxs("span",{children:[o.jsx("span",{className:ge.themeOptionLabel,children:d.label}),o.jsx("span",{className:ge.themeOptionDesc,children:d.description})]}),u&&o.jsxs("span",{className:ge.variantToggle,children:[o.jsx("span",{role:"button",tabIndex:0,className:`${ge.variantButton} ${p&&m?ge.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),i(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),i(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),o.jsx("span",{role:"button",tabIndex:0,className:`${ge.variantButton} ${p&&!m?ge.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),i(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),i(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&o.jsx("span",{className:ge.themeSwatches,children:d.swatches.map((g,v)=>o.jsx("span",{className:ge.themeSwatch,style:{background:g}},v))})]},d.id)})}),o.jsxs("label",{className:ge.systemToggle,children:[o.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),o.jsx("span",{children:"Match system light/dark preference"})]}),o.jsx("p",{className:ge.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),o.jsxs("p",{className:ge.themeActive,children:["Active theme: ",o.jsx("strong",{children:s})]})]})}function HO({connected:t,environments:s,sessions:i}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=i.filter(u=>["running","idle"].includes(u.status)).length;return o.jsxs("section",{className:ge.section,"data-testid":"about-panel",children:[o.jsx("h3",{className:ge.sectionTitle,children:"About"}),o.jsx("p",{className:ge.sectionDescription,children:"Connection status and application information."}),o.jsxs("div",{className:ge.aboutGrid,children:[o.jsxs("div",{className:ge.aboutItem,children:[o.jsx("span",{className:ge.aboutLabel,children:"Connection"}),o.jsxs("span",{className:ge.aboutValue,children:[o.jsx("span",{className:`${ge.aboutDot} ${t?ge.aboutDotConnected:ge.aboutDotDisconnected}`}),t?"Connected":"Disconnected"]})]}),o.jsxs("div",{className:ge.aboutItem,children:[o.jsx("span",{className:ge.aboutLabel,children:"Environments"}),o.jsxs("span",{className:ge.aboutValue,children:[r,"/",c," connected"]})]}),o.jsxs("div",{className:ge.aboutItem,children:[o.jsx("span",{className:ge.aboutLabel,children:"Active Sessions"}),o.jsx("span",{className:ge.aboutValue,children:d})]}),o.jsxs("div",{className:ge.aboutItem,children:[o.jsx("span",{className:ge.aboutLabel,children:"Version"}),o.jsx("span",{className:ge.aboutValue,children:"0.92.0"})]})]})]})}const VO="_container_cddyd_1",qO="_header_cddyd_8",GO="_headerTitle_cddyd_35",FO="_badge_cddyd_44",ZO="_headerActions_cddyd_54",KO="_body_cddyd_61",YO="_formContent_cddyd_73",JO="_section_cddyd_85",WO="_label_cddyd_91",XO="_titleInput_cddyd_98",QO="_descriptionTextarea_cddyd_131",eL="_parentContext_cddyd_167",tL="_parentLabel_cddyd_175",nL="_parentName_cddyd_182",sL="_personaSelect_cddyd_186",aL="_depList_cddyd_220",iL="_depItem_cddyd_226",oL="_depItemSelected_cddyd_248",rL="_noDeps_cddyd_252",lL="_btnPrimary_cddyd_258",cL="_btnGhost_cddyd_289",Qe={container:VO,header:qO,headerTitle:GO,badge:FO,headerActions:ZO,body:KO,formContent:YO,section:JO,label:WO,titleInput:XO,descriptionTextarea:QO,parentContext:eL,parentLabel:tL,parentName:nL,personaSelect:sL,depList:aL,depItem:iL,depItemSelected:oL,noDeps:rL,btnPrimary:lL,btnGhost:cL};function w1({mode:t,taskId:s,workspaceId:i,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:b}){const _=xt(),S=t==="edit",k=S&&s?d.find(me=>me.id===s):void 0,w=S?(k==null?void 0:k.workspaceId)??"":i??"",[N,T]=y.useState(w),C=w||N,D=u.find(me=>me.id===C),L=c??(D==null?void 0:D.environmentId),E=!S&&!i,I=S?(k==null?void 0:k.parentTaskId)??"":r??"",O=I?d.find(me=>me.id===I):void 0,[z,$]=y.useState((k==null?void 0:k.title)??""),[X,te]=y.useState((k==null?void 0:k.description)??""),[P,ae]=y.useState((k==null?void 0:k.dependsOn)??[]),[K,re]=y.useState((k==null?void 0:k.defaultPersonaId)??""),[A,F]=y.useState((k==null?void 0:k.canDecompose)??!1),[oe,pe]=y.useState(!1),de=y.useRef(!1);y.useEffect(()=>{S&&k&&!de.current&&(de.current=!0,$(k.title),te(k.description),ae(k.dependsOn),re(k.defaultPersonaId),F(k.canDecompose))},[S,k]);const Oe=d.filter(me=>me.workspaceId===C&&(!S||me.id!==s)&&me.id!==I),ke=z.trim().length>0&&(!S||k!==void 0)&&C.length>0,Ce=me=>{ae(Be=>Be.includes(me)?Be.filter(mt=>mt!==me):[...Be,me])},ze=()=>{!ke||oe||S&&k===void 0||(S&&s?(g(s,z.trim(),X,P,K),b==null||b("Task updated","success"),v?v():_(In(s,void 0,C,L),{replace:!0})):(pe(!0),m(C,z.trim(),X,P.length>0?P:void 0,I||void 0,K,A,()=>{b==null||b("Task created","success"),_(i?ki(i,L):"/tasks",{replace:!0})},me=>{b==null||b(me,"error"),pe(!1)})))},ue=()=>{if(v){v();return}_(S&&s?In(s,void 0,C,L):i?ki(i,L):"/tasks")},_e=S?"edit task":I?"child task":"new task";return o.jsxs("div",{className:Qe.container,children:[o.jsxs("div",{className:Qe.header,children:[o.jsxs("div",{className:Qe.headerTitle,children:[o.jsx("span",{className:Qe.badge,children:_e}),O&&o.jsxs("span",{className:Qe.parentContext,children:[o.jsx("span",{className:Qe.parentLabel,children:"Child of"}),o.jsx("span",{className:Qe.parentName,children:O.title})]})]}),o.jsxs("div",{className:Qe.headerActions,children:[o.jsx("button",{onClick:ze,disabled:!ke||oe,className:Qe.btnPrimary,"data-testid":"task-edit-save",children:oe?"Creating…":S?"Save Changes":"Create"}),o.jsx("button",{onClick:ue,className:Qe.btnGhost,children:"Cancel"})]})]}),o.jsx("div",{className:Qe.body,children:o.jsxs("div",{className:Qe.formContent,children:[E&&o.jsxs("div",{className:Qe.section,children:[o.jsx("label",{className:Qe.label,htmlFor:"task-edit-workspace",children:"Workspace"}),o.jsxs("select",{id:"task-edit-workspace",value:N,onChange:me=>T(me.target.value),className:Qe.personaSelect,"data-testid":"task-edit-workspace",children:[o.jsx("option",{value:"",children:"Select a workspace..."}),u.map(me=>o.jsx("option",{value:me.id,children:me.name},me.id))]})]}),o.jsxs("div",{className:Qe.section,children:[o.jsx("label",{className:Qe.label,htmlFor:"task-edit-title",children:"Title"}),o.jsx("input",{id:"task-edit-title",type:"text",value:z,onChange:me=>$(me.target.value),placeholder:"Task title...",autoFocus:!0,className:Qe.titleInput,"data-testid":"task-edit-title",onKeyDown:me=>{me.key==="Enter"&&ke&&ze()}})]}),o.jsxs("div",{className:Qe.section,children:[o.jsx("label",{className:Qe.label,htmlFor:"task-edit-description",children:"Description"}),o.jsx("textarea",{id:"task-edit-description",value:X,onChange:me=>te(me.target.value),placeholder:"Describe the task... (markdown supported)",className:Qe.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),o.jsxs("div",{className:Qe.section,children:[o.jsx("label",{className:Qe.label,htmlFor:"task-edit-persona",children:"Default Persona"}),o.jsxs("select",{id:"task-edit-persona",value:K,onChange:me=>re(me.target.value),className:Qe.personaSelect,"data-testid":"task-edit-persona",children:[o.jsx("option",{value:"",children:"(Inherit)"}),p.map(me=>o.jsx("option",{value:me.id,children:me.name},me.id))]})]}),!S&&o.jsx("div",{className:Qe.section,children:o.jsxs("label",{className:Qe.depItem,"data-testid":"task-edit-can-decompose",children:[o.jsx("input",{type:"checkbox",checked:A,onChange:me=>F(me.target.checked)}),"Can spawn subtasks"]})}),o.jsxs("div",{className:Qe.section,children:[o.jsx("div",{className:Qe.label,children:"Dependencies"}),Oe.length===0?o.jsx("div",{className:Qe.noDeps,children:"No other tasks in this workspace"}):o.jsx("div",{className:Qe.depList,children:Oe.map(me=>{const Be=P.includes(me.id);return o.jsxs("label",{className:`${Qe.depItem} ${Be?Qe.depItemSelected:""}`,"data-testid":`dep-option-${me.id}`,children:[o.jsx("input",{type:"checkbox",checked:Be,onChange:()=>Ce(me.id)}),me.title,o.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",me.status,")"]})]},me.id)})})]})]})})]})}const dL="_actionButtons_1rjka_1",uL="_btnPrimary_1rjka_8",fL="_btnDanger_1rjka_39",pL="_btnGhost_1rjka_78",Ft={actionButtons:dL,btnPrimary:uL,btnDanger:fL,btnGhost:pL};function mL({task:t,sessionId:s,isBlocked:i,onStart:r,onResume:c,onStop:d,onPause:u,onDelete:p,onEdit:m}){if(t.status==="not_started")return i?o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{onClick:m,className:Ft.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Ft.btnPrimary,children:"Start"}),o.jsx("button",{onClick:m,className:Ft.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{onClick:d,className:Ft.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),o.jsx("button",{onClick:u,disabled:!s,className:Ft.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{onClick:d,className:Ft.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),o.jsx("button",{onClick:c,className:Ft.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return o.jsx("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{onClick:r,className:Ft.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const hL="_workpadSection_y8nj9_1",gL="_workpadLabel_y8nj9_9",vL="_workpadStatus_y8nj9_17",yL="_workpadSummary_y8nj9_23",bL="_workpadExtra_y8nj9_29",Da={workpadSection:hL,workpadLabel:gL,workpadStatus:vL,workpadSummary:yL,workpadExtra:bL};function _L({workpad:t}){if(!t)return;let s;try{const i=JSON.parse(t);if(i==null||typeof i!="object"||Array.isArray(i))return;s=i}catch{return o.jsxs("div",{className:Da.workpadSection,"data-testid":"workpad-panel",children:[o.jsx("div",{className:Da.workpadLabel,children:"Workpad"}),o.jsx("div",{className:Da.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return o.jsxs("div",{className:Da.workpadSection,"data-testid":"workpad-panel",children:[o.jsx("div",{className:Da.workpadLabel,children:"Workpad"}),s.status&&o.jsx("div",{className:Da.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&o.jsx("div",{className:Da.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&o.jsx("div",{className:Da.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const xL="_overviewDashboard_r05qm_1",kL="_overviewHero_r05qm_7",SL="_statusBadge_r05qm_14",TL="_statusPending_r05qm_26",wL="_statusAssigned_r05qm_31",jL="_statusInProgress_r05qm_36",NL="_statusReview_r05qm_41",CL="_statusDone_r05qm_46",EL="_statusFailed_r05qm_51",AL="_statusWaitingInput_r05qm_56",DL="_overviewBranchPill_r05qm_61",RL="_branchLink_r05qm_76",ML="_overviewSection_r05qm_87",IL="_overviewLabel_r05qm_93",OL="_overviewValue_r05qm_100",LL="_overviewMuted_r05qm_105",BL="_overviewMarkdown_r05qm_111",zL="_envRow_r05qm_180",UL="_envDot_r05qm_186",$L="_envDotGreen_r05qm_193",PL="_envDotYellow_r05qm_197",HL="_envDotRed_r05qm_201",VL="_envDotGray_r05qm_205",qL="_depList_r05qm_209",GL="_depItem_r05qm_215",FL="_depBlocked_r05qm_222",ZL="_depDone_r05qm_226",KL="_timeline_r05qm_230",YL="_timelineRow_r05qm_236",JL="_timelineKey_r05qm_243",WL="_timelineValue_r05qm_249",XL="_timelineDelta_r05qm_253",QL="_reviewNotes_r05qm_264",ye={overviewDashboard:xL,overviewHero:kL,statusBadge:SL,statusPending:TL,statusAssigned:wL,statusInProgress:jL,statusReview:NL,statusDone:CL,statusFailed:EL,statusWaitingInput:AL,overviewBranchPill:DL,branchLink:RL,overviewSection:ML,overviewLabel:IL,overviewValue:OL,overviewMuted:LL,overviewMarkdown:BL,envRow:zL,envDot:UL,envDotGreen:$L,envDotYellow:PL,envDotRed:HL,envDotGray:VL,depList:qL,depItem:GL,depBlocked:FL,depDone:ZL,timeline:KL,timelineRow:YL,timelineKey:JL,timelineValue:WL,timelineDelta:XL,reviewNotes:QL};function Lc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function vp(t,s){if(!t||!s)return;const i=new Date(s).getTime()-new Date(t).getTime();if(isNaN(i)||i<0)return;const r=Math.floor(i/6e4),c=Math.floor(i%6e4/1e3);if(r===0)return`${c}s`;const d=Math.floor(r/60),u=r%60;return d===0?`${r}m ${c}s`:`${d}h ${u}m`}function Hb(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?ye.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?ye.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?ye.envDotRed:ye.envDotGray}function eB({status:t}){const s=za(t),i=ew(t);return o.jsx("span",{className:`${ye.statusBadge} ${ye[i]??ye.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function tB({task:t,tasksById:s,environments:i,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?i.find(k=>k.id===g):void 0,b=r.find(k=>k.id===t.workspaceId),_=i.find(k=>k.id===d),S=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return o.jsxs("div",{className:ye.overviewDashboard,"data-testid":"task-overview-panel",children:[o.jsxs("div",{className:ye.overviewHero,children:[o.jsx(eB,{status:t.status}),t.branch&&o.jsx("span",{className:ye.overviewBranchPill,"data-testid":"task-overview-branch",children:S?o.jsxs("a",{href:S,target:"_blank",rel:"noreferrer noopener",className:ye.branchLink,children:["🔗"," ",t.branch]}):o.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-description",children:[o.jsx("div",{className:ye.overviewLabel,children:"Description"}),o.jsx("div",{className:ye.overviewMarkdown,children:o.jsx(pd,{remarkPlugins:[md],children:t.description})})]}),t.workpad&&o.jsx(_L,{workpad:t.workpad}),o.jsxs("div",{className:ye.overviewSection,children:[o.jsx("div",{className:ye.overviewLabel,children:"Environment"}),g&&v?o.jsxs("div",{className:ye.envRow,"data-testid":"task-overview-environment",children:[o.jsx("span",{className:`${ye.envDot} ${Hb(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),o.jsx("span",{className:ye.overviewValue,children:v.displayName})]}):_?o.jsxs("div",{className:ye.envRow,"data-testid":"task-overview-environment",children:[o.jsx("span",{className:`${ye.envDot} ${Hb(_.status)}`,title:_.status,"aria-label":`Status: ${_.status}`,role:"img"}),o.jsx("span",{className:ye.overviewValue,children:_.displayName}),o.jsx("span",{className:ye.overviewMuted,children:"(workspace default)"})]}):o.jsx("div",{className:ye.overviewMuted,children:"Set in workspace settings"})]}),o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-dependencies",children:[o.jsx("div",{className:ye.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?o.jsx("div",{className:ye.overviewMuted,children:"None"}):o.jsx("div",{className:ye.depList,children:t.dependsOn.map(k=>{const w=s.get(k),N=(w==null?void 0:w.status)==="complete";return o.jsxs("div",{className:`${ye.depItem} ${N?ye.depDone:ye.depBlocked}`,children:[o.jsx("span",{children:N?"✓":"○"}),o.jsx("span",{children:(w==null?void 0:w.title)??k})]},k)})})]}),o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-timeline",children:[o.jsx("div",{className:ye.overviewLabel,children:"Timeline"}),o.jsxs("div",{className:ye.timeline,children:[t.createdAt&&o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Created"}),o.jsx("span",{className:ye.timelineValue,children:Lc(t.createdAt)})]}),t.assignedAt&&(()=>{const k=vp(t.createdAt,t.assignedAt);return o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Assigned"}),o.jsx("span",{className:ye.timelineValue,children:Lc(t.assignedAt)}),k!==void 0&&o.jsx("span",{className:ye.timelineDelta,children:k})]})})(),t.startedAt&&(()=>{const k=vp(t.assignedAt??t.createdAt,t.startedAt);return o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Started"}),o.jsx("span",{className:ye.timelineValue,children:Lc(t.startedAt)}),k!==void 0&&o.jsx("span",{className:ye.timelineDelta,children:k})]})})(),t.completedAt&&(()=>{const k=vp(t.startedAt,t.completedAt);return o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Completed"}),o.jsx("span",{className:ye.timelineValue,children:Lc(t.completedAt)}),k!==void 0&&o.jsx("span",{className:ye.timelineDelta,children:k})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&o.jsx("div",{className:ye.overviewMuted,children:"No timing data"})]})]}),u&&u.costUsd>0&&o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-usage",children:[o.jsx("div",{className:ye.overviewLabel,children:"Usage"}),o.jsxs("div",{className:ye.timeline,children:[o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Cost"}),o.jsx("span",{className:ye.timelineValue,children:Do(u.costUsd)}),o.jsxs("span",{className:ye.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costUsd>u.costUsd&&o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Total (incl. subtasks)"}),o.jsx("span",{className:ye.timelineValue,children:Do(p.costUsd)}),o.jsxs("span",{className:ye.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),t.reviewNotes&&o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-review-notes",children:[o.jsx("div",{className:ye.overviewLabel,children:"Review Notes"}),o.jsx("div",{className:ye.reviewNotes,children:t.reviewNotes})]})]})}const nB="_container_legrg_1",sB="_header_legrg_8",aB="_headerTitle_legrg_35",iB="_badge_legrg_44",oB="_headerActions_legrg_54",rB="_body_legrg_61",lB="_formContent_legrg_73",cB="_section_legrg_85",dB="_label_legrg_91",uB="_nameInput_legrg_98",fB="_fieldInput_legrg_131",pB="_adapterSelect_legrg_164",mB="_readOnlyValue_legrg_198",hB="_codespaceSection_legrg_204",gB="_codespaceActions_legrg_210",vB="_creatingHint_legrg_216",yB="_errorHint_legrg_222",bB="_btnPrimary_legrg_235",_B="_btnGhost_legrg_266",ie={container:nB,header:sB,headerTitle:aB,badge:iB,headerActions:oB,body:rB,formContent:lB,section:cB,label:dB,nameInput:uB,fieldInput:fB,adapterSelect:pB,readOnlyValue:mB,codespaceSection:hB,codespaceActions:gB,creatingHint:vB,errorHint:yB,btnPrimary:bB,btnGhost:_B},Yc=1,Jc=65535;function yp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=Yc&&s<=Jc}function bp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function xB({codespaceName:t,onCodespaceNameChange:s,envName:i,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[b,_]=y.useState(""),[S,k]=y.useState("");return g==="create"?o.jsxs("div",{className:ie.codespaceSection,children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Repository"}),o.jsx("input",{type:"text",value:b,onChange:w=>_(w.target.value),placeholder:"owner/repo",className:ie.fieldInput,"data-testid":"env-codespace-repo"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Machine Type"}),o.jsx("input",{type:"text",value:S,onChange:w=>k(w.target.value),placeholder:"Machine type (optional)...",className:ie.fieldInput,"data-testid":"env-codespace-machine"})]}),o.jsxs("div",{className:ie.codespaceActions,children:[o.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),S.trim()||void 0),v("pick"),_(""),k(""))},disabled:!b.trim(),className:ie.btnPrimary,children:"Create"}),o.jsx("button",{onClick:()=>{v("pick"),_(""),k("")},className:ie.btnGhost,children:"Cancel"})]})]}):o.jsx("div",{className:ie.codespaceSection,children:o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Codespace"}),!u&&o.jsxs("select",{value:t,onChange:w=>{w.target.value==="__create__"?(v("create"),s("")):(s(w.target.value),w.target.value&&!i.trim()&&r(w.target.value))},disabled:p,className:ie.adapterSelect,"data-testid":"env-codespace-select",children:[o.jsx("option",{value:"",children:"Select a codespace..."}),c.map(w=>o.jsxs("option",{value:w.name,children:[w.name," (",w.repository,") — ",w.state]},w.name)),o.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&o.jsx("span",{className:ie.creatingHint,children:"Creating codespace..."}),u&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:ie.errorHint,children:u}),o.jsx("input",{type:"text",value:t,onChange:w=>s(w.target.value),placeholder:"Or enter codespace name manually...",className:ie.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&o.jsx("span",{className:ie.errorHint,children:d})]})})}function j1({mode:t,environmentId:s,environments:i,onAddEnvironment:r,onUpdateEnvironment:c,onListCodespaces:d,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v,onShowToast:b}){const _=xt(),S=t==="edit",k=S&&s?i.find(ue=>ue.id===s):void 0,[w,N]=y.useState(""),[T,C]=y.useState("local"),[D,L]=y.useState(""),[E,I]=y.useState(""),[O,z]=y.useState(""),[$,X]=y.useState(""),[te,P]=y.useState(""),[ae,K]=y.useState(""),[re,A]=y.useState(""),[F,oe]=y.useState(null),pe=y.useCallback(()=>{const ue={};if(T==="local"){if(D.trim()&&(ue.host=D.trim()),E.trim()){const _e=Number(E);Number.isInteger(_e)&&(ue.port=_e)}}else if(T==="ssh"){if(ue.host=D.trim(),O.trim()&&(ue.user=O.trim()),E.trim()){const _e=Number(E);Number.isInteger(_e)&&(ue.sshPort=_e)}$.trim()&&(ue.identityFile=$.trim())}else T==="docker"?(te.trim()&&(ue.image=te.trim()),ae.trim()&&(ue.repo=ae.trim())):T==="codespace"&&(ue.codespaceName=re.trim());return ue},[T,D,E,O,$,te,ae,re]),de=()=>!(!w.trim()||T==="ssh"&&!D.trim()||T==="codespace"&&!re.trim()||(T==="local"||T==="ssh")&&!yp(E)),Oe=()=>{de()&&(r(w.trim(),T,pe()),b==null||b("Environment added successfully","success"),_(Ao,{replace:!0}))},ke=()=>{_(s?Si(s):Ao)},Ce=y.useCallback((ue,_e)=>{if(!k||!s)return;const me=bp(k.adapterConfig),Be=_e.trim();Be?me[ue]=Be:delete me[ue],c(s,{adapterConfig:me})},[k,s,c]),ze=y.useCallback((ue,_e)=>{if(!k||!s)return;const me=bp(k.adapterConfig);if(_e.trim()){const Be=Number(_e);Number.isInteger(Be)&&Be>=Yc&&Be<=Jc&&(me[ue]=Be)}else delete me[ue];c(s,{adapterConfig:me})},[k,s,c]);if(S){if(!k)return o.jsxs("div",{className:ie.container,children:[o.jsxs("div",{className:ie.header,children:[o.jsx("div",{className:ie.headerTitle,children:o.jsx("span",{className:ie.badge,children:"edit environment"})}),o.jsx("div",{className:ie.headerActions,children:o.jsx("button",{onClick:ke,className:ie.btnGhost,children:"Back"})})]}),o.jsx("div",{className:ie.body,children:o.jsx("div",{className:ie.formContent,children:o.jsx("span",{className:ie.readOnlyValue,children:"Environment not found"})})})]});const ue=bp(k.adapterConfig);return o.jsxs("div",{className:ie.container,"data-testid":"env-edit-panel",children:[o.jsxs("div",{className:ie.header,children:[o.jsx("div",{className:ie.headerTitle,children:o.jsx("span",{className:ie.badge,children:"edit environment"})}),o.jsx("div",{className:ie.headerActions,children:o.jsx("button",{onClick:ke,className:ie.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),o.jsx("div",{className:ie.body,children:o.jsxs("div",{className:ie.formContent,children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Name"}),o.jsx(ln,{value:k.displayName,onSave:_e=>{s&&c(s,{displayName:_e})},validate:_e=>_e.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:F,onActivate:oe,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Adapter Type"}),o.jsx("span",{className:ie.readOnlyValue,"data-testid":"env-edit-adapter-type",children:k.adapterType})]}),k.adapterType==="local"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Host"}),o.jsx(ln,{value:String(ue.host??""),onSave:_e=>Ce("host",_e),mode:"edit",fieldId:"host",activeFieldId:F,onActivate:oe,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Port"}),o.jsx(ln,{value:String(ue.port??""),onSave:_e=>ze("port",_e),validate:_e=>yp(_e)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:F,onActivate:oe,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),k.adapterType==="ssh"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Host"}),o.jsx(ln,{value:String(ue.host??""),onSave:_e=>Ce("host",_e),validate:_e=>_e.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:F,onActivate:oe,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"User"}),o.jsx(ln,{value:String(ue.user??""),onSave:_e=>Ce("user",_e),mode:"edit",fieldId:"user",activeFieldId:F,onActivate:oe,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"SSH Port"}),o.jsx(ln,{value:String(ue.sshPort??""),onSave:_e=>ze("sshPort",_e),validate:_e=>yp(_e)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:F,onActivate:oe,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Identity File"}),o.jsx(ln,{value:String(ue.identityFile??""),onSave:_e=>Ce("identityFile",_e),mode:"edit",fieldId:"identityFile",activeFieldId:F,onActivate:oe,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),k.adapterType==="docker"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Image"}),o.jsx(ln,{value:String(ue.image??""),onSave:_e=>Ce("image",_e),mode:"edit",fieldId:"image",activeFieldId:F,onActivate:oe,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Repo"}),o.jsx(ln,{value:String(ue.repo??""),onSave:_e=>Ce("repo",_e),mode:"edit",fieldId:"repo",activeFieldId:F,onActivate:oe,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),k.adapterType==="codespace"&&o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Codespace Name"}),o.jsx(ln,{value:String(ue.codespaceName??""),onSave:_e=>Ce("codespaceName",_e),validate:_e=>_e.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:F,onActivate:oe,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return o.jsxs("div",{className:ie.container,"data-testid":"env-create-panel",children:[o.jsxs("div",{className:ie.header,children:[o.jsx("div",{className:ie.headerTitle,children:o.jsx("span",{className:ie.badge,children:"new environment"})}),o.jsxs("div",{className:ie.headerActions,children:[o.jsx("button",{onClick:Oe,disabled:!de(),className:ie.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),o.jsx("button",{onClick:ke,className:ie.btnGhost,children:"Cancel"})]})]}),o.jsx("div",{className:ie.body,children:o.jsxs("div",{className:ie.formContent,children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-name",children:"Name"}),o.jsx("input",{id:"env-create-name",type:"text",value:w,onChange:ue=>N(ue.target.value),placeholder:"Environment name...",autoFocus:!0,className:ie.nameInput,"data-testid":"env-create-name",onKeyDown:ue=>{ue.key==="Enter"&&de()&&Oe()}})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),o.jsxs("select",{id:"env-create-adapter",value:T,onChange:ue=>{C(ue.target.value),ue.target.value==="codespace"&&d()},className:ie.adapterSelect,"data-testid":"env-create-adapter",children:[o.jsx("option",{value:"local",children:"local"}),o.jsx("option",{value:"ssh",children:"ssh"}),o.jsx("option",{value:"docker",children:"docker"}),o.jsx("option",{value:"codespace",children:"codespace"})]})]}),T==="local"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-host",children:"Host"}),o.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:ue=>L(ue.target.value),placeholder:"Host (optional)...",className:ie.fieldInput,"data-testid":"env-create-host"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-port",children:"Port"}),o.jsx("input",{id:"env-create-port",type:"number",min:Yc,max:Jc,value:E,onChange:ue=>I(ue.target.value),placeholder:"Port (optional)...",className:ie.fieldInput,"data-testid":"env-create-port"})]})]}),T==="ssh"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-host",children:"Host"}),o.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:ue=>L(ue.target.value),placeholder:"Host (required)...",className:ie.fieldInput,"data-testid":"env-create-host"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-user",children:"User"}),o.jsx("input",{id:"env-create-user",type:"text",value:O,onChange:ue=>z(ue.target.value),placeholder:"User (optional)...",className:ie.fieldInput,"data-testid":"env-create-user"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-port",children:"SSH Port"}),o.jsx("input",{id:"env-create-port",type:"number",min:Yc,max:Jc,value:E,onChange:ue=>I(ue.target.value),placeholder:"SSH port (optional)...",className:ie.fieldInput,"data-testid":"env-create-port"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-identity",children:"Identity File"}),o.jsx("input",{id:"env-create-identity",type:"text",value:$,onChange:ue=>X(ue.target.value),placeholder:"Identity file (optional)...",className:ie.fieldInput,"data-testid":"env-create-identity"})]})]}),T==="docker"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-image",children:"Image"}),o.jsx("input",{id:"env-create-image",type:"text",value:te,onChange:ue=>P(ue.target.value),placeholder:"Image (optional)...",className:ie.fieldInput,"data-testid":"env-create-image"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-repo",children:"Repo"}),o.jsx("input",{id:"env-create-repo",type:"text",value:ae,onChange:ue=>K(ue.target.value),placeholder:"Repo (optional)...",className:ie.fieldInput,"data-testid":"env-create-repo"})]})]}),T==="codespace"&&o.jsx(xB,{codespaceName:re,onCodespaceNameChange:A,envName:w,onEnvNameChange:N,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v})]})})]})}const kB="_group_1iprv_1",SB="_groupTitle_1iprv_8",TB="_shortcutList_1iprv_17",wB="_shortcutRow_1iprv_23",jB="_keys_1iprv_36",NB="_kbd_1iprv_43",CB="_description_1iprv_60",vi={group:kB,groupTitle:SB,shortcutList:TB,shortcutRow:wB,keys:jB,kbd:NB,description:CB},EB=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"},{keys:["3"],description:"Switch to Findings tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Chat",shortcuts:[{keys:["Enter"],description:"Send message (when input is focused)"}]}];function AB(){return o.jsxs("section",{className:ge.section,"data-testid":"keyboard-shortcuts-panel",children:[o.jsx("h3",{className:ge.sectionTitle,children:"Keyboard Shortcuts"}),o.jsx("p",{className:ge.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),EB.map(t=>o.jsxs("div",{className:vi.group,children:[o.jsx("h4",{className:vi.groupTitle,children:t.title}),o.jsx("div",{className:vi.shortcutList,children:t.shortcuts.map(s=>o.jsxs("div",{className:vi.shortcutRow,children:[o.jsx("span",{className:vi.keys,children:s.keys.map(i=>o.jsx("kbd",{className:vi.kbd,children:i},i))}),o.jsx("span",{className:vi.description,children:s.description})]},s.description))})]},t.title))]})}const DB=[{key:"claude",label:"Claude",description:"Forward Claude credentials for AI agent access.",options:[{value:"off",label:"Off"},{value:"subscription",label:"Subscription"},{value:"api_key",label:"API Key"}]},{key:"github",label:"GitHub",description:"Forward GITHUB_TOKEN and GH_TOKEN for git operations.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"copilot",label:"Copilot",description:"Forward Copilot tokens (COPILOT_GITHUB_TOKEN, CLI config).",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"codex",label:"Codex",description:"Forward OPENAI_API_KEY for Codex/OpenAI access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"goose",label:"Goose",description:"Forward Goose config and API keys for Goose agent access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]}];function RB({credentialProviders:t,onUpdateCredentialProviders:s}){const i=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return o.jsxs("section",{className:ge.section,children:[o.jsx("h3",{className:ge.sectionTitle,children:"Credential Providers"}),o.jsx("p",{className:ge.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),o.jsx("div",{className:ge.tokenList,children:DB.map(r=>o.jsxs("div",{className:ge.tokenRow,children:[o.jsx("span",{className:ge.tokenName,children:r.label}),o.jsx("span",{className:ge.tokenTarget,children:r.description}),o.jsx("select",{className:ge.select,value:t[r.key],onChange:c=>i(r.key,c.target.value),children:r.options.map(c=>o.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const MB="_container_10efq_1",IB="_header_10efq_7",OB="_list_10efq_105",LB="_card_10efq_111",BB="_cardHeader_10efq_125",zB="_cardTitle_10efq_135",UB="_defaultBadge_10efq_141",$B="_cardActions_10efq_155",PB="_description_10efq_160",HB="_meta_10efq_166",VB="_empty_10efq_212",qB="_typeBadge_10efq_362",Jn={container:MB,header:IB,list:OB,card:LB,cardHeader:BB,cardTitle:zB,defaultBadge:UB,cardActions:$B,description:PB,meta:HB,empty:VB,typeBadge:qB};function GB({personas:t,appDefaultPersonaId:s,onDeletePersona:i,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await i(v),p(null)};return o.jsxs("div",{className:Jn.container,children:[o.jsxs("div",{className:Jn.header,children:[o.jsx("h2",{children:"Personas"}),o.jsx(Js,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?o.jsx("p",{className:Jn.empty,children:"No personas yet. Create one to get started."}):o.jsx("div",{className:Jn.list,children:t.map(v=>{const b=s===v.id,_=v.type==="script";return o.jsxs("div",{className:Jn.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),d(v.id))},children:[o.jsxs("div",{className:Jn.cardHeader,children:[o.jsxs("span",{className:Jn.cardTitle,children:[o.jsx("strong",{children:v.name}),o.jsx("span",{className:Jn.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:_?"Script":"Agent"}),b&&o.jsx("span",{className:Jn.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),o.jsxs("div",{className:Jn.cardActions,onClick:S=>S.stopPropagation(),children:[!b&&o.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>{r(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),o.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),o.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&o.jsx("p",{className:Jn.description,children:v.description}),o.jsxs("div",{className:Jn.meta,children:[v.runtime&&o.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&o.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&o.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),o.jsx(wi,{isOpen:u!==null,title:"Delete Persona?",description:`"${(m==null?void 0:m.name)??""}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const FB="_container_uy08i_1",ZB="_header_uy08i_7",KB="_count_uy08i_13",YB="_presets_uy08i_18",JB="_presetButton_uy08i_24",WB="_filterInput_uy08i_41",XB="_groups_uy08i_53",QB="_group_uy08i_53",e8="_groupHeader_uy08i_68",t8="_groupName_uy08i_77",n8="_groupCount_uy08i_81",s8="_toolList_uy08i_87",a8="_toolItem_uy08i_95",i8="_toolName_uy08i_103",mn={container:FB,header:ZB,count:KB,presets:YB,presetButton:JB,filterInput:WB,groups:XB,group:QB,groupHeader:e8,groupName:t8,groupCount:n8,toolList:s8,toolItem:a8,toolName:i8},o8=(()=>{const t=new Map;for(const s of o_){const i=s==="get_version_status"?"version":s.split("_")[0];t.has(i)||t.set(i,[]),t.get(i).push(s)}return[...t.entries()].sort(([s],[i])=>s.localeCompare(i)).map(([s,i])=>({group:s,tools:i.sort()}))})(),r8=[{name:"default",label:"Default",tools:r_},{name:"worker",label:"Worker",tools:fT},{name:"orchestrator",label:"Orchestrator",tools:pT},{name:"admin",label:"Admin",tools:mT}];function Vb({selectedTools:t,onChange:s,disabled:i}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.useCallback(v=>{if(i)return;const b=new Set(d);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[d,s,i]),p=y.useCallback((v,b)=>{if(i)return;const _=new Set(d);for(const S of v)b?_.delete(S):_.add(S);s([..._].sort())},[d,s,i]),m=y.useCallback(v=>{i||s([...v].sort())},[s,i]),g=r.toLowerCase();return o.jsxs("div",{className:mn.container,"data-testid":"mcp-tool-selector",children:[o.jsx("div",{className:mn.header,children:o.jsx("span",{className:mn.count,children:t.length===0?`Using default (${r_.length} tools)`:`${t.length} of ${o_.size} tools selected`})}),o.jsxs("div",{className:mn.presets,"data-testid":"mcp-tool-presets",children:[r8.map(v=>o.jsx("button",{type:"button",className:mn.presetButton,disabled:i,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),o.jsx("button",{type:"button",className:mn.presetButton,disabled:i,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),o.jsx("input",{type:"text",className:mn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:i,"data-testid":"mcp-tool-filter"}),o.jsx("div",{className:mn.groups,children:o8.map(({group:v,tools:b})=>{const _=g?b.filter(k=>k.toLowerCase().includes(g)):b;if(_.length===0)return null;const S=_.every(k=>d.has(k));return o.jsxs("div",{className:mn.group,"data-testid":`tool-group-${v}`,children:[o.jsxs("label",{className:mn.groupHeader,children:[o.jsx("input",{type:"checkbox",checked:S,onChange:()=>p(_,S),disabled:i,"data-testid":`group-toggle-${v}`}),o.jsx("span",{className:mn.groupName,children:v}),o.jsxs("span",{className:mn.groupCount,children:["(",_.filter(k=>d.has(k)).length,"/",_.length,")"]})]}),o.jsx("div",{className:mn.toolList,children:_.map(k=>o.jsxs("label",{className:mn.toolItem,children:[o.jsx("input",{type:"checkbox",checked:d.has(k),onChange:()=>u(k),disabled:i,"data-testid":`tool-${k}`}),o.jsx("span",{className:mn.toolName,children:k})]},k))})]},v)})})]})}const l8="_nav_1bhou_1",c8="_tab_1bhou_24",d8="_tabIcon_1bhou_62",u8="_tabActive_1bhou_68",Bc={nav:l8,tab:c8,tabIcon:d8,tabActive:u8},Ks=[{path:"credentials",label:"Credentials",icon:o.jsx(S2,{size:Bt})},{path:"personas",label:"Personas",icon:o.jsx(W2,{size:Bt})},{path:"appearance",label:"Appearance",icon:o.jsx(U2,{size:Bt})},{path:"shortcuts",label:"Shortcuts",icon:o.jsx(w2,{size:Bt})},{path:"about",label:"About",icon:o.jsx(sm,{size:Bt})}];function f8(){var u;const t=Zt(),s=xt(),i=y.useRef(null),r=((u=Ks.find(p=>{const m=`${Eo}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??Ks[0].path,c=y.useCallback(p=>{s(`${Eo}/${p}`)},[s]),d=y.useCallback(p=>{var S,k;const m=(S=i.current)==null?void 0:S.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(w=>w===document.activeElement),v=g>=0?g:Ks.findIndex(w=>w.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%Ks.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+Ks.length)%Ks.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=Ks.length-1;else return;const _=Ks[b].path;s(`${Eo}/${_}`),(k=m[b])==null||k.focus()},[r,s]);return o.jsx("nav",{className:Bc.nav,ref:i,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:Ks.map(p=>{const m=p.path===r;return o.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Bc.tab} ${m?Bc.tabActive:""}`,onClick:()=>c(p.path),children:[o.jsx("span",{className:Bc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}function p8({tasks:t,taskStatusById:s,sessionStatusByTaskId:i}){const r=new Map;for(const d of t)if(d.parentTaskId){const u=r.get(d.parentTaskId);u?u.push(d):r.set(d.parentTaskId,[d])}const c=new Map(oy.map(d=>[d,[]]));for(const d of t){const u=rl(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(k=>s.get(k)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(k=>k.status==="complete").length;let b;if(u==="paused"&&i){const k=i.get(d.id);k==="idle"?b="Needs input":k==="completed"&&(b="Ready to complete")}const _={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},S=c.get(u);S?S.push(_):c.get("not_started").push(_)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return oy.map(d=>{const u=za(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const m8="_boardContainer_1c4y1_1",h8="_column_1c4y1_17",g8="_columnHeader_1c4y1_34",v8="_columnIcon_1c4y1_47",y8="_columnLabel_1c4y1_52",b8="_columnCount_1c4y1_57",_8="_cardList_1c4y1_67",x8="_emptyPlaceholder_1c4y1_76",k8="_card_1c4y1_67",S8="_cardHeader_1c4y1_107",T8="_cardStatusIcon_1c4y1_113",w8="_cardTitle_1c4y1_119",j8="_cardBadges_1c4y1_127",N8="_badge_1c4y1_134",C8="_blockedBadge_1c4y1_146",E8="_childBadge_1c4y1_151",A8="_depBadge_1c4y1_155",D8="_parentBadge_1c4y1_159",R8="_pausedSubBadge_1c4y1_166",M8="_personaBadge_1c4y1_170",I8="_envBadge_1c4y1_174",O8="_emptyCta_1c4y1_178",L8="_ctaButton_1c4y1_188",B8="_ctaDescription_1c4y1_204",nt={boardContainer:m8,column:h8,columnHeader:g8,columnIcon:v8,columnLabel:y8,columnCount:b8,cardList:_8,emptyPlaceholder:x8,card:k8,cardHeader:S8,cardStatusIcon:T8,cardTitle:w8,cardBadges:j8,badge:N8,blockedBadge:C8,childBadge:E8,depBadge:A8,parentBadge:D8,pausedSubBadge:R8,personaBadge:M8,envBadge:I8,emptyCta:O8,ctaButton:L8,ctaDescription:B8};function z8({workspaceId:t,environmentId:s,tasks:i,sessions:r,personas:c,environments:d}){const u=xt(),p=y.useMemo(()=>i.filter(_=>_.workspaceId===t),[i,t]),m=y.useMemo(()=>new Map(i.map(_=>[_.id,_.status])),[i]),g=y.useMemo(()=>new Map(p.map(_=>[_.id,_])),[p]),v=y.useMemo(()=>{const _=new Map(r.map(C=>[C.id,C])),S=new Map(c.map(C=>[C.id,C])),k=new Map(d.map(C=>[C.id,C])),w=new Map,N=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const D=_.get(C.latestSessionId);if(D){if(w.set(C.id,D.endReason||D.status),D.personaId){const L=S.get(D.personaId);L&&N.set(C.id,L.name)}if(D.environmentId){const L=k.get(D.environmentId);L&&T.set(C.id,L.displayName)}}}return{sessionStatusByTaskId:w,personaNameByTaskId:N,environmentNameByTaskId:T}},[p,r,c,d]),b=y.useMemo(()=>p8({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?o.jsxs("div",{className:nt.emptyCta,"data-testid":"board-empty-cta",children:[o.jsx("button",{className:nt.ctaButton,onClick:()=>u(Ci(t,void 0,s)),children:"Create Task"}),o.jsx("div",{className:nt.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):o.jsx("div",{className:nt.boardContainer,"data-testid":"board-container",children:b.map(_=>o.jsxs("section",{className:nt.column,"data-testid":`board-column-${_.status}`,"aria-label":`${_.label}, ${_.tasks.length} ${_.tasks.length===1?"task":"tasks"}`,children:[o.jsxs("div",{className:nt.columnHeader,children:[o.jsx("span",{className:nt.columnIcon,style:{color:_.style.color},children:_.style.icon}),o.jsx("span",{className:nt.columnLabel,children:_.label}),o.jsx("span",{className:nt.columnCount,"data-testid":`board-count-${_.status}`,children:_.tasks.length})]}),o.jsx("div",{className:nt.cardList,children:_.tasks.length===0?o.jsx("div",{className:nt.emptyPlaceholder,children:"No tasks"}):o.jsx(ps,{mode:"popLayout",children:_.tasks.map(S=>o.jsx(Rt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:o.jsx(U8,{boardTask:S,tasksById:g,personaName:v.personaNameByTaskId.get(S.task.id),envName:v.environmentNameByTaskId.get(S.task.id),onClick:()=>u(In(S.task.id,void 0,t,s))})},S.task.id))})})]},_.status))})}function U8({boardTask:t,tasksById:s,personaName:i,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=za(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return o.jsxs("div",{className:nt.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c())},children:[o.jsxs("div",{className:nt.cardHeader,children:[o.jsx("span",{className:nt.cardStatusIcon,style:{color:v.color},children:v.icon}),o.jsx("span",{className:nt.cardTitle,children:d.title})]}),o.jsxs("div",{className:nt.cardBadges,children:[b&&o.jsx("span",{className:`${nt.badge} ${nt.parentBadge}`,title:b.title,children:b.title}),p>0&&o.jsxs("span",{className:`${nt.badge} ${nt.childBadge}`,children:[m,"/",p]}),u&&o.jsx("span",{className:`${nt.badge} ${nt.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&o.jsx("span",{className:`${nt.badge} ${nt.depBadge}`,children:"dep"}),g&&o.jsx("span",{className:`${nt.badge} ${nt.pausedSubBadge}`,children:g}),i&&o.jsx("span",{className:`${nt.badge} ${nt.personaBadge}`,children:i}),r&&o.jsx("span",{className:`${nt.badge} ${nt.envBadge}`,children:r})]})]})}const $8="_formContent_ymnez_1",P8="_section_ymnez_13",H8="_label_ymnez_19",V8="_titleInput_ymnez_26",q8="_descriptionTextarea_ymnez_58",G8="_selectField_ymnez_94",F8="_checkboxRow_ymnez_128",Z8="_checkboxLabel_ymnez_141",K8="_fieldError_ymnez_146",yt={formContent:$8,section:P8,label:H8,titleInput:V8,descriptionTextarea:q8,selectField:G8,checkboxRow:F8,checkboxLabel:Z8,fieldError:K8};function Y8(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.environmentId)??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const J8=100;function W8({values:t,onChange:s,environments:i,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return o.jsxs("div",{className:yt.formContent,children:[o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-name",children:"Name"}),o.jsx("input",{id:"ws-name",className:yt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:J8,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&o.jsx("span",{className:yt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-description",children:"Description"}),o.jsx("textarea",{id:"ws-description",className:yt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-repo",children:"Repository URL"}),o.jsx("input",{id:"ws-repo",className:yt.titleInput,type:"text",value:t.repoUrl,onChange:m=>p("repoUrl",m.target.value),placeholder:"https://github.com/org/repo",disabled:d,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&o.jsx("span",{className:yt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-environment",children:"Environment"}),o.jsxs("select",{id:"ws-environment",className:yt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[o.jsx("option",{value:"",children:"Select environment…"}),i.map(m=>o.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&o.jsx("span",{className:yt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-persona",children:"Default Persona"}),o.jsxs("select",{id:"ws-persona",className:yt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[o.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>o.jsx("option",{value:m.id,children:m.name},m.id))]})]}),o.jsx("div",{className:yt.section,children:o.jsxs("label",{className:yt.checkboxRow,children:[o.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),o.jsx("span",{className:yt.checkboxLabel,children:"Enable worktree isolation"})]})}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-workdir",children:"Working Directory"}),o.jsx("input",{id:"ws-workdir",className:yt.titleInput,type:"text",value:t.workingDirectory,onChange:m=>p("workingDirectory",m.target.value),placeholder:"Default (server default)",disabled:d,"data-testid":"workspace-form-workdir"})]})]})}const N1=y.createContext(void 0),X8=4e3;function Q8({children:t}){const[s,i]=y.useState([]),r=y.useRef(0),c=y.useCallback(u=>{i(p=>p.filter(m=>m.id!==u))},[]),d=y.useCallback((u,p="info",m=X8)=>{const g=`toast-${++r.current}`;i(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return o.jsx(N1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function Tn(){const t=y.useContext(N1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const Qp="grackle-theme",C1="grackle-prefer-system",E1="(prefers-color-scheme: dark)";let Vr=[],Wc;function _p(){Wc=void 0;for(const t of Vr)t()}function em(){return typeof window>"u"?!1:window.matchMedia(E1).matches}function Yr(){if(typeof localStorage>"u")return Pb;try{const t=localStorage.getItem(Qp);if(t!==null&&T1.has(t))return t}catch{}return Pb}function ud(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(C1)==="true"}catch{return!1}}function tm(t){return jd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function A1(t,s){const i=Xp(t);if(i!=null&&i.variantDarkId)return s&&i.variantLightId?em()?i.variantDarkId:i.variantLightId:i.variantDarkId;if(i!=null&&i.hidden&&s){const r=tm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return em()?r.variantDarkId:r.variantLightId}return t}function ko(t,s,i=!1){i&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=A1(t,s),i&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&ko(Yr(),ud());function ez(){return Wc===void 0&&(Wc={themeId:Yr(),systemDark:em(),preferSystem:ud()}),Wc}function tz(t){return Vr=[...Vr,t],()=>{Vr=Vr.filter(s=>s!==t)}}function nz(){const t=y.useSyncExternalStore(tz,ez),{themeId:s,preferSystem:i}=t,r=A1(s,i),c=y.useCallback(u=>{if(T1.has(u)){try{localStorage.setItem(Qp,u)}catch{}ko(u,ud(),!0),_p()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(C1,u?"true":"false")}catch{}if(u){const p=Yr(),m=Xp(p);if(m!=null&&m.hidden){const g=tm(p);if(g)try{localStorage.setItem(Qp,g.id)}catch{}}}ko(Yr(),u,!0),_p()},[]);return y.useEffect(()=>{ko(s,i)},[s,i]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(E1),p=()=>{const m=Yr(),g=ud();if(g){const v=Xp(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&ko(m,g),v!=null&&v.hidden){const b=tm(m);b!=null&&b.variantDarkId&&b.variantLightId&&ko(m,g)}}_p()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:i,setPreferSystem:d}}const D1=y.createContext(void 0);function sz({children:t}){const s=nz();return o.jsx(D1.Provider,{value:s,children:t})}function R1(){const t=y.useContext(D1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const M1=y.createContext(void 0),I1=y.createContext(void 0);function az({children:t}){const[s,i]=y.useState(void 0),r=y.useCallback(c=>{i(c)},[]);return o.jsx(I1.Provider,{value:r,children:o.jsx(M1.Provider,{value:s,children:t})})}function iz(){return y.useContext(M1)}function oz(){const t=y.useContext(I1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const Qm=y.createContext(void 0);function ut(){const t=y.useContext(Qm);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function O1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function L1(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function rz(t){return O1(t)&&typeof t.sessionId=="string"&&typeof t.eventType=="string"&&typeof t.timestamp=="string"&&typeof t.content=="string"&&(t.raw===void 0||typeof t.raw=="string")}const lz=new Set(["off","subscription","api_key"]),zc=new Set(["off","on"]);function cz(t){return O1(t)&&lz.has(t.claude)&&zc.has(t.github)&&zc.has(t.copilot)&&zc.has(t.codex)&&zc.has(t.goose)}function B1(t){switch(t){case"waiting_input":return"idle";case"completed":return"stopped";case"killed":return"stopped";case"failed":return"stopped";case"interrupted":return"stopped";case"terminated":return"stopped";default:return t}}function z1(t){switch(t){case"completed":return"completed";case"killed":return"killed";case"failed":return"interrupted";case"interrupted":return"interrupted";case"terminated":return"terminated";default:return}}const xo=5e3;function dz(t,s){const i=[];let r=t;const c=new Set;for(;r&&s.has(r)&&!c.has(r);){c.add(r);const d=s.get(r);i.unshift(d),r=d.parentTaskId||void 0}return i}const na={label:"Home",url:Ti};function uz(t){return t?[na,{label:"Settings",url:Eo},{label:t,url:void 0}]:[na,{label:"Settings",url:void 0}]}const eh={label:"Environments",url:Ao};function fz(){return[na,{label:"Environments",url:void 0}]}function pz(){return[na,{label:"New Chat",url:void 0}]}function mz(t){return[na,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function hz(t,s,i,r){const c=i.find(u=>u.id===t),d=r.find(u=>u.id===s);return[na,eh,{label:(d==null?void 0:d.displayName)??"Environment",url:Si(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function gz(t,s,i,r,c){const d=dz(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?i.find(S=>S.id===p):void 0,g=s??(m==null?void 0:m.environmentId),v=g?r.find(S=>S.id===g):void 0,b=[na];v&&g&&(b.push(eh),b.push({label:v.displayName,url:Si(g)})),m&&g&&b.push({label:m.name,url:ki(m.id,g)});for(let S=0;S<d.length-1;S++)b.push({label:d[S].title,url:In(d[S].id,void 0,p,g)});const _=d[d.length-1];return b.push({label:(_==null?void 0:_.title)??t,url:void 0}),b}const vz={label:"Findings",url:bd};function yz(){return[na,{label:"Findings",url:void 0}]}function U1(t,s,i,r,c){const d=[na];if(s&&i){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===i);d.push(eh),p&&d.push({label:p.displayName,url:Si(i)}),u&&d.push({label:u.name,url:ki(s,i)}),d.push({label:"Findings",url:iN(s,i)})}else d.push(vz);return d.push({label:t,url:void 0}),d}function th(t){const s=[];for(const i of t){const r=s[s.length-1];i.eventType==="text"&&(r==null?void 0:r.eventType)==="text"?s[s.length-1]={...r,content:r.content+i.content}:s.push(i)}return s}function Uc(t){if(typeof t.id=="string")return t.id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const i=t.item;if(i&&typeof i.id=="string")return i.id}function bz(t){if(typeof t.tool_use_id=="string")return t.tool_use_id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const i=t.item;if(i&&typeof i.id=="string")return i.id}function nh(t){const s=new Map;for(const v of t)if(v.raw)try{s.set(v,JSON.parse(v.raw))}catch{}const i=new Map;for(const v of t){if(v.eventType!=="tool_use")continue;const b=s.get(v),_=b?Uc(b):void 0;if(_)try{const S=JSON.parse(v.content);i.set(_,{tool:S.tool,args:S.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,b)=>{if(v.eventType!=="tool_result")return v;const _=s.get(v),S=_?bz(_):void 0;if(!S)return v;const k=i.get(S);if(!k)return v;r.add(S),c.add(b);let w;const N=v.content.trim();if(N.startsWith("{"))try{const T=JSON.parse(N);typeof T.detailedContent=="string"&&(w=T.detailedContent)}catch{}return{...v,toolUseCtx:{...k,detailedResult:w}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const b=s.get(d[v]),_=b?Uc(b):void 0;_&&r.has(_)||u.push(v)}const p=[];for(let v=0;v<d.length;v++)d[v].eventType!=="tool_result"||c.has(v)||p.push(v);let m=0;for(const v of u){for(;m<p.length&&p[m]<v;)m++;if(m>=p.length)break;const b=p[m];if(b!==v+1)continue;const _=d[v],S=d[b];let k;try{const w=JSON.parse(_.content);k={tool:w.tool,args:w.args}}catch{}if(k){let w;const N=S.content.trim();if(N.startsWith("{"))try{const D=JSON.parse(N);typeof D.detailedContent=="string"&&(w=D.detailedContent)}catch{}d[b]={...S,toolUseCtx:{...k,detailedResult:w}},c.add(b);const T=s.get(_),C=T?Uc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(_,{...T??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const b=s.get(v);if(!b)return!0;const _=Uc(b);if(_&&r.has(_))return!1;const S=b.__seqId;return!(S&&r.has(S))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let b=!1;for(let _=v+1;_<g.length;_++)if(g[_].eventType!=="tool_use"){b=!0;break}b&&(g[v]={...g[v],settled:!0})}return g}function _z(t,s,i){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=$1(s),d=s.filter(m=>nm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||nm(m,c)).length,p=i.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function $1(t){const s=new Map;for(const i of t)s.set(i.id,i.status);return s}function nm(t,s){return t.dependsOn.some(i=>s.get(i)!=="complete")}function xz(t,s){var u;const i=new Map;for(const p of s)i.set(p.id,p);const r=$1(t),c=[];for(const p of t){const m=p.workspaceId?((u=i.get(p.workspaceId))==null?void 0:u.name)??"Unknown":"Unknown";p.status==="failed"?c.push({task:p,reason:"failed",workspaceName:m}):nm(p,r)?c.push({task:p,reason:"blocked",workspaceName:m}):p.status==="paused"&&c.push({task:p,reason:"paused",workspaceName:m})}const d={failed:0,blocked:1,paused:2};return c.sort((p,m)=>(d[p.reason]??3)-(d[m.reason]??3)),c}function kz(t,s){const i=new Map;for(const r of s)i.set(r.id,r);return t.filter(r=>r.status==="running"||r.status==="idle"||r.status==="waiting").map(r=>{var c;return{session:r,environmentName:((c=i.get(r.environmentId))==null?void 0:c.displayName)??"Unknown"}})}function Sz(t,s,i){const r=new Map;for(const c of s){if(!c.workspaceId)continue;let d=r.get(c.workspaceId);d||(d={totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0},r.set(c.workspaceId,d)),d.totalTasks+=1,c.status==="complete"?d.completedTasks+=1:c.status==="working"?d.workingTasks+=1:c.status==="failed"&&(d.failedTasks+=1)}return t.map(c=>{const d=r.get(c.id)??{totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0};return{workspace:c,totalTasks:d.totalTasks,completedTasks:d.completedTasks,workingTasks:d.workingTasks,failedTasks:d.failedTasks}})}const ks=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
275
275
  export function verifyToken(req: Request, res: Response, next: NextFunction): void {
276
276
  const header = req.headers.authorization;
277
277
  if (!header?.startsWith("Bearer ")) {
@@ -712,4 +712,4 @@ const grackle = await host.mcpServer({
712
712
  url: env.vars.GRACKLE_MCP_URL,
713
713
  });
714
714
 
715
- $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),I==="agent"&&o.jsxs("div",{children:[o.jsx("label",{children:"Allowed MCP Tools"}),o.jsx(Vb,{selectedTools:X,onChange:se=>{te(se),me(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,se),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!Ce&&!ke&&o.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,o.jsx(wi,{isOpen:P,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:_e,onCancel:()=>ae(!1)})]})}function v9(){const{themeId:t,resolvedThemeId:s,setTheme:i,preferSystem:r,setPreferSystem:c}=R1();return o.jsx(PO,{themeId:t,resolvedThemeId:s,onSetTheme:i,preferSystem:r,onSetPreferSystem:c})}function y9(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let i=!1;return(async()=>{try{const c=await we.getVersionStatus({});i||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{i=!0}},[]),t}function b9(){const{connected:t,environments:{environments:s},sessions:{sessions:i}}=ut(),r=y9();return o.jsxs(o.Fragment,{children:[r&&o.jsx(GI,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),o.jsx(HO,{connected:t,environments:s,sessions:i})]})}function _9(){return o.jsx(AB,{})}const n_=Ci();function x9(){const t=xt();return Qs({key:"?"},()=>{t(tN)}),Qs({key:"n"},()=>{t(n_)}),Qs({key:"N"},()=>{t(n_)}),o.jsx(o.Fragment,{})}function ml(t){const s=oz();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function k9(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=ut(),i=y.useMemo(()=>o.jsx(xI,{workspaces:t,tasks:s}),[t,s]);return ml(i),o.jsx(Ha,{})}function S9(){const{environments:{environments:t}}=ut(),s=y.useMemo(()=>o.jsx(D5,{environments:t}),[t]);return ml(s),o.jsx(Ha,{})}function T9(){const t=y.useMemo(()=>o.jsx(f8,{}),[]);return ml(t),o.jsx(Ha,{})}function w9(){const{findings:{findings:t,loadFindings:s,loadAllFindings:i}}=ut(),{workspaceId:r,environmentId:c}=ms();y.useEffect(()=>{r?s(r).catch(()=>{}):i().catch(()=>{})},[r,s,i]);const d=y.useMemo(()=>o.jsx(H5,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return ml(d),o.jsx(Ha,{})}function j9(){const{knowledge:t,workspaces:{workspaces:s}}=ut(),i=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>o.jsx(q6,{nodes:t.graphData.nodes,workspaces:s,loading:t.loading,searchQuery:t.searchQuery,onSearch:i,onClearSearch:r,onSelectNode:c,onWorkspaceChange:d}),[t,s,i,r,c,d]);return ml(u),o.jsx(Ha,{})}const N9="_container_ce571_1",C9="_title_ce571_6",fd={container:N9,title:C9};function E9(){return o.jsxs("div",{className:fd.container,"aria-hidden":"true",children:[o.jsx("h1",{className:fd.title,children:"Findings"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>o.jsx(ld,{lines:3},s))})]})}function s_(){const{environmentId:t,workspaceId:s}=ms(),{findings:{findings:i,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=ut(),p=xt();y.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=y.useCallback(v=>{p(Rp(v,s,t))},[p,s,t]);if(r)return o.jsx(E9,{});const g=s&&t?U1("Findings",s,t,d,u).slice(0,-1):yz();return o.jsxs("div",{className:fd.container,"data-testid":"findings-list-page",children:[o.jsx(js,{segments:g}),o.jsx("h1",{className:fd.title,children:"Findings"}),o.jsx(S1,{findings:i,onFindingClick:m})]})}const A9="_container_1wwpb_1",D9="_notFound_1wwpb_6",R9="_header_1wwpb_12",M9="_categoryBadge_1wwpb_19",I9="_title_1wwpb_28",O9="_content_1wwpb_35",L9="_tags_1wwpb_77",B9="_tag_1wwpb_77",z9="_meta_1wwpb_92",U9="_metaTimestamp_1wwpb_100",$9="_metaLink_1wwpb_105",hn={container:A9,notFound:D9,header:R9,categoryBadge:M9,title:I9,content:O9,tags:L9,tag:B9,meta:z9,metaTimestamp:U9,metaLink:$9};function a_(){const{findingId:t,environmentId:s,workspaceId:i}=ms(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=ut(),m=xt();if(y.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return o.jsx("div",{className:hn.container,"data-testid":"finding-detail-page",children:o.jsx("div",{className:hn.notFound,children:"Loading..."})});if(!r)return o.jsx("div",{className:hn.container,"data-testid":"finding-detail-page",children:o.jsx("div",{className:hn.notFound,children:"Finding not found."})});const g=U1(r.title,i,s,u,p),v=dd(r.category);return o.jsxs("div",{className:hn.container,"data-testid":"finding-detail-page",children:[o.jsx(js,{segments:g}),o.jsxs("div",{className:hn.header,children:[o.jsx("span",{className:hn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),o.jsx("h1",{className:hn.title,children:r.title})]}),r.content&&o.jsx("div",{className:hn.content,children:o.jsx(pd,{remarkPlugins:[md],children:r.content})}),r.tags.length>0&&o.jsx("div",{className:hn.tags,children:r.tags.map(b=>o.jsx("span",{className:hn.tag,children:b},b))}),o.jsxs("div",{className:hn.meta,children:[o.jsx("span",{className:hn.metaTimestamp,title:r.createdAt,children:Xm(r.createdAt)}),r.taskId&&o.jsx("button",{type:"button",className:hn.metaLink,onClick:()=>{m(In(r.taskId))},children:"View Task"}),r.sessionId&&o.jsx("button",{type:"button",className:hn.metaLink,onClick:()=>{m(mm(r.sessionId))},children:"View Session"})]})]})}const P9="_wizard_1260s_1",H9="_container_1260s_10",V9="_stepContent_1260s_19",q9="_logoArea_1260s_28",G9="_logoImage_1260s_32",F9="_heading_1260s_41",Z9="_tagline_1260s_49",K9="_subtitle_1260s_56",Y9="_featureList_1260s_64",J9="_runtimeGrid_1260s_89",W9="_runtimeCard_1260s_101",X9="_runtimeName_1260s_133",Q9="_runtimeDescription_1260s_139",eP="_buttonRow_1260s_144",tP="_primaryButton_1260s_151",nP="_ghostButton_1260s_185",sP="_dots_1260s_213",aP="_dot_1260s_213",pt={wizard:P9,container:H9,stepContent:V9,logoArea:q9,logoImage:G9,heading:F9,tagline:Z9,subtitle:K9,featureList:Y9,runtimeGrid:J9,runtimeCard:W9,runtimeName:X9,runtimeDescription:Q9,buttonRow:eP,primaryButton:tP,ghostButton:nP,dots:sP,dot:aP};function iP({onNext:t}){return o.jsxs("div",{className:pt.stepContent,"data-testid":"setup-welcome",children:[o.jsx("div",{className:pt.logoArea,children:o.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:pt.logoImage})}),o.jsx("h1",{className:pt.heading,children:"Welcome to Grackle"}),o.jsx("p",{className:pt.tagline,children:"Multi-agent orchestration for software teams"}),o.jsx("button",{type:"button",className:pt.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function oP({onNext:t,onBack:s}){return o.jsxs("div",{className:pt.stepContent,"data-testid":"setup-about",children:[o.jsx("h2",{className:pt.heading,children:"What is Grackle?"}),o.jsxs("ul",{className:pt.featureList,children:[o.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),o.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),o.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),o.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),o.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),o.jsxs("div",{className:pt.buttonRow,children:[o.jsx("button",{type:"button",className:pt.ghostButton,onClick:s,children:"Back"}),o.jsx("button",{type:"button",className:pt.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const rP=[{id:"claude-code",name:"Claude Code",description:"Anthropic's agentic coding tool"},{id:"copilot",name:"Copilot Coding Agent",description:"GitHub's AI pair programmer"},{id:"codex",name:"Codex CLI",description:"OpenAI's coding agent"},{id:"goose",name:"Goose",description:"Block's open-source AI coding agent"}];function lP({currentRuntime:t,onFinish:s,onBack:i,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),o.jsxs("div",{className:pt.stepContent,"data-testid":"setup-runtime",children:[o.jsx("h2",{className:pt.heading,children:"Choose Your Runtime"}),o.jsx("p",{className:pt.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),o.jsx("div",{className:pt.runtimeGrid,children:rP.map(u=>o.jsxs("button",{type:"button",className:pt.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[o.jsx("span",{className:pt.runtimeName,children:u.name}),o.jsx("span",{className:pt.runtimeDescription,children:u.description})]},u.id))}),o.jsxs("div",{className:pt.buttonRow,children:[o.jsx("button",{type:"button",className:pt.ghostButton,onClick:i,children:"Back"}),o.jsx("button",{type:"button",className:pt.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-finish",children:"Finish"})]})]})}const cP=3,i_={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function dP(){const{personas:{personas:t,updatePersona:s},completeOnboarding:i,onboardingCompleted:r}=ut(),{showToast:c}=Tn(),d=xt(),[u,p]=y.useState(0),[m,g]=y.useState(!1),v=t.find(_=>_.id==="claude-code"),b=y.useCallback(_=>{g(!0);const S=[];if(v&&_!==v.runtime){const w=i_[_]??"sonnet";S.push(s(v.id,void 0,void 0,void 0,_,w))}const k=t.find(w=>w.id===J0);if(k&&_!==k.runtime){const w=i_[_]??"sonnet";S.push(s(J0,void 0,void 0,void 0,_,w))}Promise.all(S).then(()=>i()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),g(!1)})},[v,t,s,i,d,c]);return r===!0?o.jsx(fs,{to:"/",replace:!0}):o.jsx("div",{className:pt.wizard,"data-testid":"setup-wizard",children:o.jsxs("div",{className:pt.container,children:[o.jsx(ps,{mode:"wait",children:o.jsxs(Rt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&o.jsx(iP,{onNext:()=>p(1)}),u===1&&o.jsx(oP,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&o.jsx(lP,{currentRuntime:(v==null?void 0:v.runtime)??"claude-code",onFinish:b,onBack:()=>p(1),finishDisabled:!v||m})]},u)}),o.jsx("div",{className:pt.dots,children:Array.from({length:cP},(_,S)=>o.jsx("span",{className:pt.dot,"data-active":S===u},S))})]})})}const uP="_root_zndgp_1",fP="_body_zndgp_7",pP="_main_zndgp_19",mP="_sidebarWrapper_zndgp_26",hP="_overlay_zndgp_51",qr={root:uP,body:fP,main:pP,sidebarWrapper:mP,overlay:hP},gP=y.lazy(()=>AT(()=>import("./KnowledgePage-gigL5i5c.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),P1=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function vP(){const{connected:t,environments:{environments:s},sessions:{sessions:i},tasks:{tasks:r}}=ut(),{toasts:c,dismissToast:d}=Tn(),u=Zt(),p=iz(),m=p!==void 0,[g,v]=y.useState(!1),b=y.useCallback(()=>v(_=>!_),[]);return y.useEffect(()=>{v(!1)},[u.pathname]),y.useEffect(()=>{if(!g)return;const _=S=>{S.key==="Escape"&&v(!1)};return document.addEventListener("keydown",_),()=>{document.removeEventListener("keydown",_)}},[g]),o.jsxs(o.Fragment,{children:[o.jsx(e5,{connected:t,environments:s,sessions:i,onToggleSidebar:m?b:void 0,sidebarOpen:g}),o.jsx(r5,{}),o.jsxs("div",{className:qr.body,children:[m&&o.jsx("div",{className:qr.sidebarWrapper,"data-sidebar-open":g,children:o.jsx(p5,{content:p})}),m&&g&&o.jsx("div",{className:qr.overlay,"data-testid":"drawer-overlay",onClick:()=>v(!1)}),o.jsxs("div",{className:qr.main,children:[o.jsx(Ha,{}),o.jsx(x5,{sessions:i,tasks:r,environments:s})]})]}),o.jsx(II,{toasts:c,onDismiss:d}),o.jsx(x9,{})]})}function yP(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:i,clearOperationError:r},tasks:{tasks:c},connected:d,onboardingCompleted:u}=ut(),{showToast:p}=Tn();a7(s,p),c7(c,p),i7(i,r,p);const m=xt(),g=Zt();return y.useEffect(()=>{t&&!g.pathname.includes("/tasks/")&&m(mm(t),{replace:!0})},[t,m,g.pathname]),d&&u===!1?o.jsx(fs,{to:"/setup",replace:!0}):o.jsx(az,{children:o.jsxs("div",{className:qr.root,children:[P1&&o.jsx(DN,{}),o.jsx(vP,{})]})})}function Np(){const{workspaceId:t}=ms(),{workspaces:{workspaces:s}}=ut(),i=Zt(),r=s.find(m=>m.id===t);if(!(r!=null&&r.environmentId))return s.length===0?void 0:o.jsx(fs,{to:"/environments",replace:!0});const c=encodeURIComponent(t),d=`/workspaces/${c}`,u=i.pathname.startsWith(d)?i.pathname.slice(d.length):"",p=`/environments/${encodeURIComponent(r.environmentId)}/workspaces/${c}${u}${i.search}${i.hash}`;return o.jsx(fs,{to:p,replace:!0})}function bP(){return o.jsxs(gj,{children:[o.jsx(Ne,{path:"setup",element:o.jsx(dP,{})}),o.jsxs(Ne,{element:o.jsx(yP,{}),children:[o.jsx(Ne,{index:!0,element:o.jsx(VU,{})}),o.jsx(Ne,{path:"chat",element:o.jsx(QU,{})}),o.jsx(Ne,{path:"sessions/new",element:o.jsx(e$,{})}),o.jsx(Ne,{path:"sessions/:sessionId",element:o.jsx(a$,{})}),o.jsx(Ne,{element:o.jsx(j9,{}),children:o.jsx(Ne,{path:"knowledge",element:o.jsx(y.Suspense,{fallback:o.jsx(p1,{}),children:o.jsx(gP,{})})})}),o.jsxs(Ne,{element:o.jsx(k9,{}),children:[o.jsx(Ne,{path:"tasks",element:o.jsx(PU,{})}),o.jsx(Ne,{path:"tasks/new",element:o.jsx(Xb,{})}),o.jsx(Ne,{path:"tasks/:taskId",element:o.jsx(Ia,{})}),o.jsx(Ne,{path:"tasks/:taskId/edit",element:o.jsx(Ia,{})}),o.jsx(Ne,{path:"tasks/:taskId/stream",element:o.jsx(Ia,{})}),o.jsx(Ne,{path:"tasks/:taskId/findings",element:o.jsx(Ia,{})})]}),o.jsxs(Ne,{element:o.jsx(w9,{}),children:[o.jsx(Ne,{path:"findings",element:o.jsx(s_,{})}),o.jsx(Ne,{path:"findings/:findingId",element:o.jsx(a_,{})}),o.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:o.jsx(s_,{})}),o.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:o.jsx(a_,{})})]}),o.jsxs(Ne,{element:o.jsx(S9,{}),children:[o.jsx(Ne,{path:"workspaces",element:o.jsx(fs,{to:"/environments",replace:!0})}),o.jsx(Ne,{path:"workspaces/new",element:o.jsx(b$,{})}),o.jsx(Ne,{path:"workspaces/:workspaceId",element:o.jsx(Np,{})}),o.jsx(Ne,{path:"workspaces/:workspaceId/tasks/:taskId",element:o.jsx(Np,{})}),o.jsx(Ne,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:o.jsx(Np,{})}),o.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId",element:o.jsx(l$,{})}),o.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:o.jsx(Xb,{})}),o.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:o.jsx(Ia,{})}),o.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:o.jsx(Ia,{})}),o.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:o.jsx(Ia,{})}),o.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:o.jsx(Ia,{})}),o.jsxs(Ne,{path:"environments",element:o.jsx(j$,{}),children:[o.jsx(Ne,{index:!0,element:o.jsx(HU,{})}),o.jsx(Ne,{path:"new",element:o.jsx(x$,{})}),o.jsx(Ne,{path:":environmentId",element:o.jsx(t9,{})}),o.jsx(Ne,{path:":environmentId/edit",element:o.jsx(k$,{})})]})]}),o.jsx(Ne,{element:o.jsx(T9,{}),children:o.jsxs(Ne,{path:"settings",element:o.jsx(a9,{}),children:[o.jsx(Ne,{index:!0,element:o.jsx(fs,{to:"credentials",replace:!0})}),o.jsx(Ne,{path:"environments",element:o.jsx(fs,{to:"/environments",replace:!0})}),o.jsx(Ne,{path:"credentials",element:o.jsx(i9,{})}),o.jsx(Ne,{path:"tokens",element:o.jsx(fs,{to:"../credentials",replace:!0})}),o.jsx(Ne,{path:"personas",element:o.jsx(o9,{})}),o.jsx(Ne,{path:"personas/new",element:o.jsx(t_,{})}),o.jsx(Ne,{path:"personas/:personaId",element:o.jsx(t_,{})}),o.jsx(Ne,{path:"appearance",element:o.jsx(v9,{})}),o.jsx(Ne,{path:"shortcuts",element:o.jsx(_9,{})}),o.jsx(Ne,{path:"about",element:o.jsx(b9,{})})]})}),o.jsx(Ne,{path:"*",element:o.jsx(fs,{to:"/",replace:!0})})]})]})}const _P=1e4;function xP(){const{onboardingCompleted:t}=ut(),[s,i]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>i(!0),_P);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return o.jsx(ps,{mode:"wait",children:r?o.jsx(Rt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:o.jsx(p1,{})},"splash"):o.jsx(Rt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:o.jsx(Pj,{basename:"/".replace(/\/$/,""),children:o.jsx(bP,{})})},"app")})}function kP(){const t=P1?Mz:s7;return o.jsx(sz,{children:o.jsx(Q8,{children:o.jsx(t,{children:o.jsx(xP,{})})})})}NT.createRoot(document.getElementById("root")).render(o.jsx(y.StrictMode,{children:o.jsx(kP,{})}));export{js as B,I_ as K,ut as a,Rp as f,mm as s,In as t,xt as u};
715
+ $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),I==="agent"&&o.jsxs("div",{children:[o.jsx("label",{children:"Allowed MCP Tools"}),o.jsx(Vb,{selectedTools:X,onChange:se=>{te(se),me(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,se),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!Ce&&!ke&&o.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,o.jsx(wi,{isOpen:P,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:_e,onCancel:()=>ae(!1)})]})}function v9(){const{themeId:t,resolvedThemeId:s,setTheme:i,preferSystem:r,setPreferSystem:c}=R1();return o.jsx(PO,{themeId:t,resolvedThemeId:s,onSetTheme:i,preferSystem:r,onSetPreferSystem:c})}function y9(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let i=!1;return(async()=>{try{const c=await we.getVersionStatus({});i||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{i=!0}},[]),t}function b9(){const{connected:t,environments:{environments:s},sessions:{sessions:i}}=ut(),r=y9();return o.jsxs(o.Fragment,{children:[r&&o.jsx(GI,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),o.jsx(HO,{connected:t,environments:s,sessions:i})]})}function _9(){return o.jsx(AB,{})}const n_=Ci();function x9(){const t=xt();return Qs({key:"?"},()=>{t(tN)}),Qs({key:"n"},()=>{t(n_)}),Qs({key:"N"},()=>{t(n_)}),o.jsx(o.Fragment,{})}function ml(t){const s=oz();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function k9(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=ut(),i=y.useMemo(()=>o.jsx(xI,{workspaces:t,tasks:s}),[t,s]);return ml(i),o.jsx(Ha,{})}function S9(){const{environments:{environments:t}}=ut(),s=y.useMemo(()=>o.jsx(D5,{environments:t}),[t]);return ml(s),o.jsx(Ha,{})}function T9(){const t=y.useMemo(()=>o.jsx(f8,{}),[]);return ml(t),o.jsx(Ha,{})}function w9(){const{findings:{findings:t,loadFindings:s,loadAllFindings:i}}=ut(),{workspaceId:r,environmentId:c}=ms();y.useEffect(()=>{r?s(r).catch(()=>{}):i().catch(()=>{})},[r,s,i]);const d=y.useMemo(()=>o.jsx(H5,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return ml(d),o.jsx(Ha,{})}function j9(){const{knowledge:t,workspaces:{workspaces:s}}=ut(),i=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>o.jsx(q6,{nodes:t.graphData.nodes,workspaces:s,loading:t.loading,searchQuery:t.searchQuery,onSearch:i,onClearSearch:r,onSelectNode:c,onWorkspaceChange:d}),[t,s,i,r,c,d]);return ml(u),o.jsx(Ha,{})}const N9="_container_ce571_1",C9="_title_ce571_6",fd={container:N9,title:C9};function E9(){return o.jsxs("div",{className:fd.container,"aria-hidden":"true",children:[o.jsx("h1",{className:fd.title,children:"Findings"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>o.jsx(ld,{lines:3},s))})]})}function s_(){const{environmentId:t,workspaceId:s}=ms(),{findings:{findings:i,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=ut(),p=xt();y.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=y.useCallback(v=>{p(Rp(v,s,t))},[p,s,t]);if(r)return o.jsx(E9,{});const g=s&&t?U1("Findings",s,t,d,u).slice(0,-1):yz();return o.jsxs("div",{className:fd.container,"data-testid":"findings-list-page",children:[o.jsx(js,{segments:g}),o.jsx("h1",{className:fd.title,children:"Findings"}),o.jsx(S1,{findings:i,onFindingClick:m})]})}const A9="_container_1wwpb_1",D9="_notFound_1wwpb_6",R9="_header_1wwpb_12",M9="_categoryBadge_1wwpb_19",I9="_title_1wwpb_28",O9="_content_1wwpb_35",L9="_tags_1wwpb_77",B9="_tag_1wwpb_77",z9="_meta_1wwpb_92",U9="_metaTimestamp_1wwpb_100",$9="_metaLink_1wwpb_105",hn={container:A9,notFound:D9,header:R9,categoryBadge:M9,title:I9,content:O9,tags:L9,tag:B9,meta:z9,metaTimestamp:U9,metaLink:$9};function a_(){const{findingId:t,environmentId:s,workspaceId:i}=ms(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=ut(),m=xt();if(y.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return o.jsx("div",{className:hn.container,"data-testid":"finding-detail-page",children:o.jsx("div",{className:hn.notFound,children:"Loading..."})});if(!r)return o.jsx("div",{className:hn.container,"data-testid":"finding-detail-page",children:o.jsx("div",{className:hn.notFound,children:"Finding not found."})});const g=U1(r.title,i,s,u,p),v=dd(r.category);return o.jsxs("div",{className:hn.container,"data-testid":"finding-detail-page",children:[o.jsx(js,{segments:g}),o.jsxs("div",{className:hn.header,children:[o.jsx("span",{className:hn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),o.jsx("h1",{className:hn.title,children:r.title})]}),r.content&&o.jsx("div",{className:hn.content,children:o.jsx(pd,{remarkPlugins:[md],children:r.content})}),r.tags.length>0&&o.jsx("div",{className:hn.tags,children:r.tags.map(b=>o.jsx("span",{className:hn.tag,children:b},b))}),o.jsxs("div",{className:hn.meta,children:[o.jsx("span",{className:hn.metaTimestamp,title:r.createdAt,children:Xm(r.createdAt)}),r.taskId&&o.jsx("button",{type:"button",className:hn.metaLink,onClick:()=>{m(In(r.taskId))},children:"View Task"}),r.sessionId&&o.jsx("button",{type:"button",className:hn.metaLink,onClick:()=>{m(mm(r.sessionId))},children:"View Session"})]})]})}const P9="_wizard_1260s_1",H9="_container_1260s_10",V9="_stepContent_1260s_19",q9="_logoArea_1260s_28",G9="_logoImage_1260s_32",F9="_heading_1260s_41",Z9="_tagline_1260s_49",K9="_subtitle_1260s_56",Y9="_featureList_1260s_64",J9="_runtimeGrid_1260s_89",W9="_runtimeCard_1260s_101",X9="_runtimeName_1260s_133",Q9="_runtimeDescription_1260s_139",eP="_buttonRow_1260s_144",tP="_primaryButton_1260s_151",nP="_ghostButton_1260s_185",sP="_dots_1260s_213",aP="_dot_1260s_213",pt={wizard:P9,container:H9,stepContent:V9,logoArea:q9,logoImage:G9,heading:F9,tagline:Z9,subtitle:K9,featureList:Y9,runtimeGrid:J9,runtimeCard:W9,runtimeName:X9,runtimeDescription:Q9,buttonRow:eP,primaryButton:tP,ghostButton:nP,dots:sP,dot:aP};function iP({onNext:t}){return o.jsxs("div",{className:pt.stepContent,"data-testid":"setup-welcome",children:[o.jsx("div",{className:pt.logoArea,children:o.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:pt.logoImage})}),o.jsx("h1",{className:pt.heading,children:"Welcome to Grackle"}),o.jsx("p",{className:pt.tagline,children:"Multi-agent orchestration for software teams"}),o.jsx("button",{type:"button",className:pt.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function oP({onNext:t,onBack:s}){return o.jsxs("div",{className:pt.stepContent,"data-testid":"setup-about",children:[o.jsx("h2",{className:pt.heading,children:"What is Grackle?"}),o.jsxs("ul",{className:pt.featureList,children:[o.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),o.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),o.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),o.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),o.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),o.jsxs("div",{className:pt.buttonRow,children:[o.jsx("button",{type:"button",className:pt.ghostButton,onClick:s,children:"Back"}),o.jsx("button",{type:"button",className:pt.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const rP=[{id:"claude-code",name:"Claude Code",description:"Anthropic's agentic coding tool"},{id:"copilot",name:"Copilot Coding Agent",description:"GitHub's AI pair programmer"},{id:"codex",name:"Codex CLI",description:"OpenAI's coding agent"},{id:"goose",name:"Goose",description:"Block's open-source AI coding agent"}];function lP({currentRuntime:t,onFinish:s,onBack:i,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),o.jsxs("div",{className:pt.stepContent,"data-testid":"setup-runtime",children:[o.jsx("h2",{className:pt.heading,children:"Choose Your Runtime"}),o.jsx("p",{className:pt.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),o.jsx("div",{className:pt.runtimeGrid,children:rP.map(u=>o.jsxs("button",{type:"button",className:pt.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[o.jsx("span",{className:pt.runtimeName,children:u.name}),o.jsx("span",{className:pt.runtimeDescription,children:u.description})]},u.id))}),o.jsxs("div",{className:pt.buttonRow,children:[o.jsx("button",{type:"button",className:pt.ghostButton,onClick:i,children:"Back"}),o.jsx("button",{type:"button",className:pt.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-finish",children:"Finish"})]})]})}const cP=3,i_={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function dP(){const{personas:{personas:t,updatePersona:s},completeOnboarding:i,onboardingCompleted:r}=ut(),{showToast:c}=Tn(),d=xt(),[u,p]=y.useState(0),[m,g]=y.useState(!1),v=t.find(_=>_.id==="claude-code"),b=y.useCallback(_=>{g(!0);const S=[];if(v&&_!==v.runtime){const w=i_[_]??"sonnet";S.push(s(v.id,void 0,void 0,void 0,_,w))}const k=t.find(w=>w.id===J0);if(k&&_!==k.runtime){const w=i_[_]??"sonnet";S.push(s(J0,void 0,void 0,void 0,_,w))}Promise.all(S).then(()=>i()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),g(!1)})},[v,t,s,i,d,c]);return r===!0?o.jsx(fs,{to:"/",replace:!0}):o.jsx("div",{className:pt.wizard,"data-testid":"setup-wizard",children:o.jsxs("div",{className:pt.container,children:[o.jsx(ps,{mode:"wait",children:o.jsxs(Rt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&o.jsx(iP,{onNext:()=>p(1)}),u===1&&o.jsx(oP,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&o.jsx(lP,{currentRuntime:(v==null?void 0:v.runtime)??"claude-code",onFinish:b,onBack:()=>p(1),finishDisabled:!v||m})]},u)}),o.jsx("div",{className:pt.dots,children:Array.from({length:cP},(_,S)=>o.jsx("span",{className:pt.dot,"data-active":S===u},S))})]})})}const uP="_root_zndgp_1",fP="_body_zndgp_7",pP="_main_zndgp_19",mP="_sidebarWrapper_zndgp_26",hP="_overlay_zndgp_51",qr={root:uP,body:fP,main:pP,sidebarWrapper:mP,overlay:hP},gP=y.lazy(()=>AT(()=>import("./KnowledgePage-DTOJmEHK.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),P1=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function vP(){const{connected:t,environments:{environments:s},sessions:{sessions:i},tasks:{tasks:r}}=ut(),{toasts:c,dismissToast:d}=Tn(),u=Zt(),p=iz(),m=p!==void 0,[g,v]=y.useState(!1),b=y.useCallback(()=>v(_=>!_),[]);return y.useEffect(()=>{v(!1)},[u.pathname]),y.useEffect(()=>{if(!g)return;const _=S=>{S.key==="Escape"&&v(!1)};return document.addEventListener("keydown",_),()=>{document.removeEventListener("keydown",_)}},[g]),o.jsxs(o.Fragment,{children:[o.jsx(e5,{connected:t,environments:s,sessions:i,onToggleSidebar:m?b:void 0,sidebarOpen:g}),o.jsx(r5,{}),o.jsxs("div",{className:qr.body,children:[m&&o.jsx("div",{className:qr.sidebarWrapper,"data-sidebar-open":g,children:o.jsx(p5,{content:p})}),m&&g&&o.jsx("div",{className:qr.overlay,"data-testid":"drawer-overlay",onClick:()=>v(!1)}),o.jsxs("div",{className:qr.main,children:[o.jsx(Ha,{}),o.jsx(x5,{sessions:i,tasks:r,environments:s})]})]}),o.jsx(II,{toasts:c,onDismiss:d}),o.jsx(x9,{})]})}function yP(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:i,clearOperationError:r},tasks:{tasks:c},connected:d,onboardingCompleted:u}=ut(),{showToast:p}=Tn();a7(s,p),c7(c,p),i7(i,r,p);const m=xt(),g=Zt();return y.useEffect(()=>{t&&!g.pathname.includes("/tasks/")&&m(mm(t),{replace:!0})},[t,m,g.pathname]),d&&u===!1?o.jsx(fs,{to:"/setup",replace:!0}):o.jsx(az,{children:o.jsxs("div",{className:qr.root,children:[P1&&o.jsx(DN,{}),o.jsx(vP,{})]})})}function Np(){const{workspaceId:t}=ms(),{workspaces:{workspaces:s}}=ut(),i=Zt(),r=s.find(m=>m.id===t);if(!(r!=null&&r.environmentId))return s.length===0?void 0:o.jsx(fs,{to:"/environments",replace:!0});const c=encodeURIComponent(t),d=`/workspaces/${c}`,u=i.pathname.startsWith(d)?i.pathname.slice(d.length):"",p=`/environments/${encodeURIComponent(r.environmentId)}/workspaces/${c}${u}${i.search}${i.hash}`;return o.jsx(fs,{to:p,replace:!0})}function bP(){return o.jsxs(gj,{children:[o.jsx(Ne,{path:"setup",element:o.jsx(dP,{})}),o.jsxs(Ne,{element:o.jsx(yP,{}),children:[o.jsx(Ne,{index:!0,element:o.jsx(VU,{})}),o.jsx(Ne,{path:"chat",element:o.jsx(QU,{})}),o.jsx(Ne,{path:"sessions/new",element:o.jsx(e$,{})}),o.jsx(Ne,{path:"sessions/:sessionId",element:o.jsx(a$,{})}),o.jsx(Ne,{element:o.jsx(j9,{}),children:o.jsx(Ne,{path:"knowledge",element:o.jsx(y.Suspense,{fallback:o.jsx(p1,{}),children:o.jsx(gP,{})})})}),o.jsxs(Ne,{element:o.jsx(k9,{}),children:[o.jsx(Ne,{path:"tasks",element:o.jsx(PU,{})}),o.jsx(Ne,{path:"tasks/new",element:o.jsx(Xb,{})}),o.jsx(Ne,{path:"tasks/:taskId",element:o.jsx(Ia,{})}),o.jsx(Ne,{path:"tasks/:taskId/edit",element:o.jsx(Ia,{})}),o.jsx(Ne,{path:"tasks/:taskId/stream",element:o.jsx(Ia,{})}),o.jsx(Ne,{path:"tasks/:taskId/findings",element:o.jsx(Ia,{})})]}),o.jsxs(Ne,{element:o.jsx(w9,{}),children:[o.jsx(Ne,{path:"findings",element:o.jsx(s_,{})}),o.jsx(Ne,{path:"findings/:findingId",element:o.jsx(a_,{})}),o.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:o.jsx(s_,{})}),o.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:o.jsx(a_,{})})]}),o.jsxs(Ne,{element:o.jsx(S9,{}),children:[o.jsx(Ne,{path:"workspaces",element:o.jsx(fs,{to:"/environments",replace:!0})}),o.jsx(Ne,{path:"workspaces/new",element:o.jsx(b$,{})}),o.jsx(Ne,{path:"workspaces/:workspaceId",element:o.jsx(Np,{})}),o.jsx(Ne,{path:"workspaces/:workspaceId/tasks/:taskId",element:o.jsx(Np,{})}),o.jsx(Ne,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:o.jsx(Np,{})}),o.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId",element:o.jsx(l$,{})}),o.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:o.jsx(Xb,{})}),o.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:o.jsx(Ia,{})}),o.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:o.jsx(Ia,{})}),o.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:o.jsx(Ia,{})}),o.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:o.jsx(Ia,{})}),o.jsxs(Ne,{path:"environments",element:o.jsx(j$,{}),children:[o.jsx(Ne,{index:!0,element:o.jsx(HU,{})}),o.jsx(Ne,{path:"new",element:o.jsx(x$,{})}),o.jsx(Ne,{path:":environmentId",element:o.jsx(t9,{})}),o.jsx(Ne,{path:":environmentId/edit",element:o.jsx(k$,{})})]})]}),o.jsx(Ne,{element:o.jsx(T9,{}),children:o.jsxs(Ne,{path:"settings",element:o.jsx(a9,{}),children:[o.jsx(Ne,{index:!0,element:o.jsx(fs,{to:"credentials",replace:!0})}),o.jsx(Ne,{path:"environments",element:o.jsx(fs,{to:"/environments",replace:!0})}),o.jsx(Ne,{path:"credentials",element:o.jsx(i9,{})}),o.jsx(Ne,{path:"tokens",element:o.jsx(fs,{to:"../credentials",replace:!0})}),o.jsx(Ne,{path:"personas",element:o.jsx(o9,{})}),o.jsx(Ne,{path:"personas/new",element:o.jsx(t_,{})}),o.jsx(Ne,{path:"personas/:personaId",element:o.jsx(t_,{})}),o.jsx(Ne,{path:"appearance",element:o.jsx(v9,{})}),o.jsx(Ne,{path:"shortcuts",element:o.jsx(_9,{})}),o.jsx(Ne,{path:"about",element:o.jsx(b9,{})})]})}),o.jsx(Ne,{path:"*",element:o.jsx(fs,{to:"/",replace:!0})})]})]})}const _P=1e4;function xP(){const{onboardingCompleted:t}=ut(),[s,i]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>i(!0),_P);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return o.jsx(ps,{mode:"wait",children:r?o.jsx(Rt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:o.jsx(p1,{})},"splash"):o.jsx(Rt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:o.jsx(Pj,{basename:"/".replace(/\/$/,""),children:o.jsx(bP,{})})},"app")})}function kP(){const t=P1?Mz:s7;return o.jsx(sz,{children:o.jsx(Q8,{children:o.jsx(t,{children:o.jsx(xP,{})})})})}NT.createRoot(document.getElementById("root")).render(o.jsx(y.StrictMode,{children:o.jsx(kP,{})}));export{js as B,I_ as K,ut as a,Rp as f,mm as s,In as t,xt as u};