@grackle-ai/web 0.102.0 → 0.103.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-xY8zG7iT.js","assets/dagview-tHPW3Rz3.js","assets/grpc-DY0rnrKC.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
2
- import{r as vT,a as yT,b as x,j as i,d as ry,H as ly,P as cy,i as bT,B as xT,c as _T,C as kT,M as ST,e as TT}from"./dagview-tHPW3Rz3.js";import{c as jT,a as Sd,G as wT,b as NT,d as CT,e as ET,f as AT,M as DT,A as kx,D as Sx,W as RT,O as MT,g as IT,C as Ei,h as Tx,i as jx,w as OT,t as BT,p as Oc,j as LT,R as Lr,S as dy}from"./grpc-DY0rnrKC.js";import{v as zT,r as $T,t as Bc,i as UT,f as PT,M as Td,a as jd}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 o(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=o(c);fetch(c.href,d)}})();var Kf={exports:{}},zr={},Yf={exports:{}},Jf={};/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-UWFPbEn4.js","assets/dagview-tHPW3Rz3.js","assets/grpc-BAFIlDeq.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
2
+ import{r as vT,a as yT,b as x,j as i,d as ry,H as ly,P as cy,i as bT,B as xT,c as _T,C as kT,M as ST,e as TT}from"./dagview-tHPW3Rz3.js";import{c as jT,a as Sd,G as wT,b as NT,d as CT,e as ET,f as AT,M as DT,A as kx,D as Sx,W as RT,O as MT,g as IT,C as Ei,h as Tx,i as jx,w as OT,t as BT,p as Oc,j as LT,R as Lr,S as dy}from"./grpc-BAFIlDeq.js";import{v as zT,r as $T,t as Bc,i as UT,f as PT,M as Td,a as jd}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 o(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=o(c);fetch(c.href,d)}})();var Kf={exports:{}},zr={},Yf={exports:{}},Jf={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
5
5
  *
@@ -276,7 +276,7 @@ ${JSON.stringify(u,void 0,2)}
276
276
  \`\`\``):s.push(`${m} (${c}):`);break}case"error":{s.push(`**Error** (${c}):
277
277
  ${r.content}`);break}}}return s.join(`
278
278
 
279
- `)}function b6({events:t,formatForClipboard:s}){const[o,r]=x.useState(!1),[c,d]=x.useState(new Set),u=x.useRef(void 0),p=x.useMemo(()=>c.size,[c]),m=x.useCallback(k=>{r(!0),k!==void 0?(d(new Set([k])),u.current=k):(d(new Set),u.current=void 0)},[]),g=x.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=x.useCallback((k,j)=>{if(j&&u.current!==void 0){const N=Math.min(u.current,k),T=Math.max(u.current,k);d(C=>{const A=new Set(C);for(let I=N;I<=T;I++)I<t.length&&fl(t[I])&&A.add(I);return A})}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=x.useCallback(()=>{const k=new Set;for(let j=0;j<t.length;j++)fl(t[j])&&k.add(j);d(k)},[t]),y=x.useCallback(()=>{d(new Set)},[]),S=x.useCallback(async()=>{const j=[...c].sort((T,C)=>T-C).filter(T=>T<t.length).map(T=>t[T]);if(j.length===0)return!1;const N=s(j);try{return await navigator.clipboard.writeText(N),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:y,copySelected:S}}const x6="_wrapper_1cdza_1",_6="_scrollContainer_1cdza_9",k6="_selectingPadding_1cdza_16",S6="_toolbar_1cdza_20",T6="_directionToggle_1cdza_27",j6="_scrollToAnchor_1cdza_65",w6="_scrollToAnchorBottom_1cdza_89",N6="_scrollToAnchorTop_1cdza_93",C6="_eventOverflowWarning_1cdza_97",Qs={wrapper:x6,scrollContainer:_6,selectingPadding:k6,toolbar:S6,directionToggle:T6,scrollToAnchor:j6,scrollToAnchorBottom:w6,scrollToAnchorTop:N6,eventOverflowWarning:C6};function E6(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 R1="grackle-stream-direction";function A6(){try{return localStorage.getItem(R1)==="reversed"}catch{return!1}}function D6({eventsDropped:t}){return t<=0?i.jsx(i.Fragment,{}):i.jsxs("div",{className:Qs.eventOverflowWarning,role:"alert",children:[i.jsx(ym,{size:nn,"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 dh({events:t,eventsDropped:s,emptyState:o,onShowToast:r}){const c=x.useRef(null),[d,u]=x.useState(A6),p=h3(),m=b6({events:t,formatForClipboard:y6}),g=x.useMemo(()=>t.filter(fl).length,[t]),v=x.useMemo(()=>d?[...t].reverse():t,[t,d]),{isAtAnchor:b,scrollToAnchor:y}=h6({scrollRef:c,contentLength:t.length,isReversed:d,paused:m.isSelecting}),S=()=>{const T=!d;u(T);try{localStorage.setItem(R1,T?"reversed":"default")}catch{}};x.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=x.useCallback(async()=>{await m.copySelected()&&(r==null||r(`Copied ${m.selectedCount} message${m.selectedCount===1?"":"s"} to clipboard`,"success"))},[m,r]),j=p?0:.2,N=d?-8:8;return i.jsxs("div",{className:Qs.wrapper,children:[i.jsx("div",{className:Qs.toolbar,children:i.jsx($o,{text:d?"Showing newest first":"Showing oldest first",children:i.jsx("button",{className:Qs.directionToggle,onClick:S,"aria-label":d?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:d?i.jsx(yy,{size:nn,"aria-hidden":"true"}):i.jsx(by,{size:nn,"aria-hidden":"true"})})})}),i.jsxs("div",{ref:c,className:`${Qs.scrollContainer} ${m.isSelecting?Qs.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,i.jsx(D6,{eventsDropped:s}),i.jsx(gs,{initial:!1,children:v.map((T,C)=>{const A=d?t.length-1-C:C;return i.jsx(Mt.div,{initial:{opacity:0,y:N},animate:{opacity:1,y:0},transition:{duration:j,ease:"easeOut"},children:i.jsx(a6,{copyText:v6(T),isContentBearing:fl(T),isSelecting:m.isSelecting,isSelected:m.selectedIndices.has(A),checkboxLabel:E6(T),onSelect:()=>{m.enterSelectionMode(A)},onToggle:I=>{m.toggleEvent(A,I)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:i.jsx(VA,{event:T,toolUseCtx:T.toolUseCtx,settled:T.settled})})},`${T.sessionId}-${T.timestamp}-${A}`)})})]}),i.jsx(gs,{children:m.isSelecting&&i.jsx(f6,{selectedCount:m.selectedCount,totalSelectable:g,onSelectAll:m.selectAll,onDeselectAll:m.deselectAll,onCopy:()=>{k().catch(()=>{})},onCancel:m.cancelSelection})}),i.jsx(gs,{children:!b&&i.jsxs(Mt.button,{className:`${Qs.scrollToAnchor} ${d?Qs.scrollToAnchorTop:Qs.scrollToAnchorBottom}`,onClick:y,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?i.jsx(by,{size:nn,"aria-hidden":"true"}):i.jsx(yy,{size:nn,"aria-hidden":"true"})," New events"]})})]})}function uh(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=x.useState(""),[b,y]=x.useState(""),S=x.useRef(!1),k=d===c,j=x.useCallback(P=>{v(P),y("")},[]),N=x.useCallback(()=>{y("")},[]),T=x.useCallback(()=>{S.current=!1,u==null||u(null),v(""),y("")},[u]),C=x.useCallback(()=>{const P=m?g.trim():g;if(r){const z=r(g);if(z){y(z);return}}const O=m?s.trim():s;if(P===O){T();return}o(P),T()},[g,s,m,r,o,T]),A=x.useCallback(()=>{S.current=!0,u==null||u(c),v(s),y("")},[c,s,u]),I=x.useCallback(P=>{if(S.current){S.current=!1;return}P.relatedTarget instanceof HTMLElement&&P.relatedTarget.dataset.editAction===c||C()},[c,C]),E=x.useCallback(P=>{P.key==="Escape"?T():P.key==="Enter"&&p&&C()},[T,p,C]),D=(()=>{if(!k)return!1;const P=m?s.trim():s;return(m?g.trim():g)!==P})();return x.useEffect(()=>{!k&&(g!==""||b!=="")&&(v(""),y(""))},[k,g,b]),{isEditing:k,draft:g,error:b,isDirty:D,startEdit:A,cancelEdit:T,save:C,setDraft:j,clearError:N,handleBlur:I,handleKeyDown:E,ignoreInitialBlurRef:S}}const R6="_editFieldWrapper_yuzty_1",M6="_editInput_yuzty_10",I6="_editTextarea_yuzty_42",O6="_editSelect_yuzty_78",B6="_editError_yuzty_111",L6="_editInputInvalid_yuzty_118",z6="_editHint_yuzty_123",$6="_unsavedDot_yuzty_132",U6="_metaValueClickable_yuzty_140",P6="_editButton_yuzty_159",H6="_metaPlaceholder_yuzty_175",V6="_worktreeToggle_yuzty_180",st={editFieldWrapper:R6,editInput:M6,editTextarea:I6,editSelect:O6,editError:B6,editInputInvalid:L6,editHint:z6,unsavedDot:$6,metaValueClickable:U6,editButton:P6,metaPlaceholder:H6,worktreeToggle:V6};function Ft(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:b,ariaLabel:y,"data-testid":S}=t,k=x.useRef(null),j=uh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(x.useEffect(()=>{if(j.isEditing){const T=window.setTimeout(()=>{var C;(C=k.current)==null||C.focus()},0);return()=>window.clearTimeout(T)}},[j.isEditing]),c==="create"){const T=A=>{m==null||m(A.target.value)},C=r==null?void 0:r(s);return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("input",{className:`${st.editInput} ${C?st.editInputInvalid:""}`,value:s,onChange:T,maxLength:b,placeholder:v,"aria-label":y,"data-testid":S?`${S}-input`:void 0}),C&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("input",{ref:k,className:`${st.editInput} ${j.error?st.editInputInvalid:""}`,value:j.draft,onChange:T=>j.setDraft(T.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:b,placeholder:v,"aria-label":y,"data-testid":S?`${S}-input`:void 0}),j.isDirty&&i.jsx("span",{className:st.unsavedDot,title:"Unsaved changes"}),j.error&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:j.error}),i.jsx("span",{className:st.editHint,children:"Enter to save · Esc to cancel"})]});const N=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:st.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":y,"data-testid":S?`${S}-button`:void 0,children:[N!==void 0?N:s?i.jsx("span",{children:s}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function dm(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":y}=t,S=x.useRef(null),k=uh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(x.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 i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("textarea",{className:`${st.editTextarea} ${T?st.editInputInvalid:""}`,value:s,onChange:N,placeholder:v,"aria-label":b,"data-testid":y?`${y}-input`:void 0}),T&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:T})]})}if(k.isEditing)return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("textarea",{ref:S,className:`${st.editTextarea} ${k.error?st.editInputInvalid:""}`,value:k.draft,onChange:N=>k.setDraft(N.target.value),onBlur:k.handleBlur,onKeyDown:k.handleKeyDown,title:b,"aria-label":b,"data-testid":y?`${y}-input`:void 0}),k.isDirty&&i.jsx("span",{className:st.unsavedDot,title:"Unsaved changes"}),k.error&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:k.error}),i.jsx("span",{className:st.editHint,children:"Tab to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:st.metaValueClickable,onClick:()=>k.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),k.startEdit())},title:"Click to edit","aria-label":b,"data-testid":y?`${y}-button`:void 0,children:[j!==void 0?j:s?i.jsx("span",{children:s}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function Uo(t){var A;const{value:s,onSave:o,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":y}=t,S=x.useRef(null),k=uh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});x.useEffect(()=>{if(k.isEditing){const I=window.setTimeout(()=>{var E;(E=S.current)==null||E.focus()},0);return()=>window.clearTimeout(I)}},[k.isEditing]);const j=x.useCallback(I=>{const E=I.target.value;k.ignoreInitialBlurRef.current=!1,E!==s&&o(E),k.cancelEdit()},[s,o,k]),N=x.useCallback(I=>{if(k.ignoreInitialBlurRef.current){k.ignoreInitialBlurRef.current=!1;return}I.relatedTarget instanceof HTMLElement&&I.relatedTarget.dataset.editAction===d||k.cancelEdit()},[d,k]);if(r==="create")return i.jsx("select",{className:st.editSelect,value:s,onChange:I=>m==null?void 0:m(I.target.value),"aria-label":b,"data-testid":y?`${y}-select`:void 0,children:c.map(I=>i.jsx("option",{value:I.value,children:I.label},I.value))});if(k.isEditing)return i.jsx("select",{ref:S,className:st.editSelect,value:k.draft,onChange:j,onBlur:N,title:b,"aria-label":b,"data-testid":y?`${y}-select`:void 0,children:c.map(I=>i.jsx("option",{value:I.value,children:I.label},I.value))});const T=g==null?void 0:g(s),C=(A=c.find(I=>I.value===s))==null?void 0:A.label;return i.jsxs("button",{type:"button",className:st.metaValueClickable,onClick:()=>k.startEdit(),title:"Click to change","aria-label":b,"data-testid":y?`${y}-button`:void 0,children:[T!==void 0?T:C?i.jsx("span",{children:C}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function q6(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return i.jsxs("label",{className:st.worktreeToggle,"data-testid":d,children:[i.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),i.jsx("span",{children:r})]})}const G6="_envRow_1e1r5_1",F6="_envDot_1e1r5_7",Z6="_envDotGreen_1e1r5_14",K6="_envDotYellow_1e1r5_18",Y6="_envDotRed_1e1r5_22",J6="_envDotGray_1e1r5_26",Mo={envRow:G6,envDot:F6,envDotGreen:Z6,envDotYellow:K6,envDotRed:Y6,envDotGray:J6};function W6(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?Mo.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?Mo.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?Mo.envDotRed:Mo.envDotGray}function X6(t){const{value:s,onSave:o,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),y=[...c?[{value:"",label:"None"}]:[],...r.map(k=>({value:k.id,label:k.displayName}))],S=()=>{if(b)return i.jsxs("span",{className:Mo.envRow,children:[i.jsx("span",{className:`${Mo.envDot} ${W6(b.status)}`}),b.displayName]})};return i.jsx(Uo,{value:s,onSave:o,options:y,fieldId:d,activeFieldId:u,onActivate:p,renderDisplay:S,placeholder:m,ariaLabel:g,"data-testid":v})}const Q6="_nav_1snmp_1",eI="_searchForm_1snmp_8",tI="_searchInput_1snmp_15",nI="_searchButton_1snmp_33",sI="_clearButton_1snmp_68",aI="_workspaceSelect_1snmp_85",iI="_listHeader_1snmp_99",oI="_nodeList_1snmp_108",rI="_nodeItem_1snmp_116",lI="_indicator_1snmp_129",cI="_label_1snmp_136",dI="_badge_1snmp_145",Wn={nav:Q6,searchForm:eI,searchInput:tI,searchButton:nI,clearButton:sI,workspaceSelect:aI,listHeader:iI,nodeList:oI,nodeItem:rI,indicator:lI,label:cI,badge:dI};function uI({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=x.useState(""),v=x.useCallback(k=>{k.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=x.useCallback(()=>{g(""),d()},[d]),y=x.useCallback(k=>{u(k)},[u]),S=x.useCallback(k=>{g(""),p(k)},[p]);return i.jsxs("div",{className:Wn.nav,"data-testid":"knowledge-nav",children:[i.jsxs("form",{className:Wn.searchForm,onSubmit:v,children:[i.jsx("input",{className:Wn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:k=>{g(k.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),i.jsx("button",{type:"submit",className:Wn.searchButton,disabled:o,children:"Go"})]}),r&&i.jsx("button",{type:"button",className:Wn.clearButton,onClick:b,children:"Clear search"}),i.jsxs("select",{className:Wn.workspaceSelect,onChange:k=>{S(k.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[i.jsx("option",{value:"",children:"All workspaces"}),s.map(k=>i.jsx("option",{value:k.id,children:k.name},k.id))]}),i.jsxs("div",{className:Wn.listHeader,children:["Nodes (",t.length,")"]}),i.jsx("ul",{className:Wn.nodeList,children:t.map(k=>i.jsxs("li",{className:Wn.nodeItem,onClick:()=>{y(k.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),y(k.id))},role:"button",tabIndex:0,children:[i.jsx("span",{className:Wn.indicator,style:{backgroundColor:k.kind==="reference"?"#4A9EFF":k.category==="decision"?"#22C55E":k.category==="concept"?"#A855F7":k.category==="snippet"?"#6B7280":"#EAB308"}}),i.jsx("span",{className:Wn.label,children:k.label}),i.jsx("span",{className:Wn.badge,children:k.kind==="reference"?k.sourceType:k.category})]},k.id))})]})}const fI="_container_1mq5u_1",pI="_hamburger_1mq5u_33",mI="_brand_1mq5u_49",hI="_brandLogo_1mq5u_68",gI="_info_1mq5u_75",vI="_connectionLabel_1mq5u_90",yI="_connectionDot_1mq5u_103",bI="_connected_1mq5u_106",xI="_disconnected_1mq5u_110",Ws={container:fI,hamburger:pI,brand:mI,brandLogo:hI,info:gI,connectionLabel:vI,connectionDot:yI,connected:bI,disconnected:xI};function _I({connected:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=mt(),u=s.length,p=s.filter(g=>g.status==="connected").length,m=o.filter(g=>["running","idle"].includes(g.status)).length;return i.jsxs("div",{className:Ws.container,children:[r&&i.jsx("button",{type:"button",className:Ws.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:i.jsx(Q2,{size:Rt,"aria-hidden":"true"})}),i.jsx($o,{text:"Home",placement:"bottom",children:i.jsxs("button",{type:"button",className:Ws.brand,onClick:()=>d(Di),"data-testid":"statusbar-brand",children:[i.jsx("img",{src:"/icon-192x192.png",alt:"",className:Ws.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),i.jsxs("div",{className:Ws.info,children:[i.jsxs("span",{"aria-label":t?"Connected":"Disconnected",children:[i.jsx("span",{className:`${Ws.connectionDot} ${t?Ws.connected:Ws.disconnected}`,"aria-hidden":"true",children:i.jsx(Va,{size:bm,fill:"currentColor"})})," ",i.jsx("span",{className:Ws.connectionLabel,"aria-hidden":"true",children:t?"Connected":"Disconnected"})]}),i.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),i.jsxs("span",{children:[m," active"]})]})]})}const kI="_nav_13gkc_1",SI="_tab_13gkc_35",TI="_tabIcon_13gkc_68",jI="_tabLabel_13gkc_79",wI="_tabActive_13gkc_84",Vr={nav:kI,tab:SI,tabIcon:TI,tabLabel:jI,tabActive:wI},id=[{view:"dashboard",label:"Dashboard",icon:i.jsx(U2,{size:Rt}),route:Di,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:i.jsx(tj,{size:Rt}),route:TN,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:i.jsx(N2,{size:Rt}),route:jN,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:i.jsx(sj,{size:Rt}),route:Io,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:i.jsx(b2,{size:Rt}),route:Xx,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:i.jsx(Ex,{size:Rt}),route:Dd,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:i.jsx(fj,{size:Rt}),route:bN,testId:"sidebar-tab-settings"}];function NI(t){return t===Di||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(Xx)?"knowledge":t.startsWith(Dd)?"findings":t.startsWith(Ni)?"settings":"tasks"}function CI({tabs:t=id}){const s=Yt(),o=mt(),r=x.useRef(null),c=NI(s.pathname),d=x.useCallback(p=>{o(p.route)},[o]),u=x.useCallback(p=>{var y,S;const m=(y=r.current)==null?void 0:y.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(k=>k===document.activeElement),v=g>=0?g:t.findIndex(k=>k.view===c);let b=v;if(p.key==="ArrowRight"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%t.length;else if(p.key==="ArrowLeft"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+t.length)%t.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=t.length-1;else return;o(t[b].route),(S=m[b])==null||S.focus()},[c,o,t]);return i.jsx("nav",{className:Vr.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:u,"data-testid":"sidebar-nav",children:t.map(p=>{const m=p.view===c;return i.jsx($o,{text:p.label,placement:"bottom",children:i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Vr.tab} ${m?Vr.tabActive:""}`,onClick:()=>d(p),"data-testid":p.testId,"aria-label":p.label,children:[i.jsx("span",{className:Vr.tabIcon,"aria-hidden":"true",children:p.icon}),i.jsx("span",{className:Vr.tabLabel,children:p.label})]})},p.view)})})}const EI="_container_pi6ii_1",AI="_content_pi6ii_66",Xb={container:EI,content:AI},DI=320,M1=220,I1=600,O1="grackle-sidebar-width";function RI(){try{const t=localStorage.getItem(O1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=M1&&s<=I1)return s}}catch{}return DI}function MI(t){try{localStorage.setItem(O1,String(t))}catch{}}function II({content:t}){const[s]=x.useState(RI),o=x.useRef(null);if(x.useEffect(()=>{const r=o.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>=M1&&m<=I1&&MI(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return i.jsx("div",{className:Xb.container,ref:o,"data-testid":"sidebar",style:{width:s},children:i.jsx("div",{className:Xb.content,children:t})})}const OI="_bar_tnfsh_1",BI="_btnPrimary_tnfsh_32",LI="_statusText_tnfsh_85",zI="_statusCompleted_tnfsh_90",$I="_statusFailed_tnfsh_94",UI="_statusBlocked_tnfsh_98",PI="_hintText_tnfsh_103",jt={bar:OI,btnPrimary:BI,statusText:LI,statusCompleted:zI,statusFailed:$I,statusBlocked:UI,hintText:PI};function HI({sessions:t,tasks:s,environments:o}){const r=mt(),c=Yt(),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"),y=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),S=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),k=At("/sessions/new"),j=At("/environments/:environmentId/workspaces/:workspaceId"),N=At("/tasks/new"),T=At("/chat"),C=At("/"),A=At("/settings/*"),I=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)??(y==null?void 0:y.params.taskId)??(S==null?void 0:S.params.taskId),D=v??b??y??S,P=(D==null?void 0:D.params.environmentId)??(j==null?void 0:j.params.environmentId),O=c.pathname.startsWith("/environments")&&!j&&!D,z=!!T,Q=!!k,$=!!j&&!v&&!b&&!y&&!S,J=!!N;if(!!C&&!Q&&!$&&!J||!!A||(!!g||!!S)||J||O||Q)return i.jsx(i.Fragment,{});if(z)return o.find(F=>F.adapterType==="local"&&F.status==="connected")?i.jsx(i.Fragment,{}):i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Add a local environment to start chatting"})});if($)return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Select a task or click + to create one"})});if(E){const B=s.find(de=>de.id===E);if(!B)return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Loading..."})});const F=new Map(s.map(de=>[de.id,de])),Z=B.dependsOn.some(de=>{const W=F.get(de);return W!==void 0&&W.status!=="complete"});if(B.status==="not_started"){const de=Z?B.dependsOn.map(W=>F.get(W)).filter(W=>W&&W.status!=="complete").map(W=>W.title):[];return i.jsx("div",{className:jt.bar,children:Z?i.jsxs("span",{className:jt.statusBlocked,children:["Blocked by: ",de.join(", ")]}):i.jsx("span",{className:jt.hintText,children:"Use the buttons above to start or manage this task"})})}if(B.status==="working"||B.status==="paused"){const de=B.latestSessionId||void 0,W=de?t.find(ue=>ue.id===de):void 0;return W&&W.status!=="stopped"?i.jsx(i.Fragment,{}):i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Waiting for agent..."})})}if(B.status==="complete")return i.jsxs("div",{className:jt.bar,children:[i.jsx("span",{className:`${jt.statusText} ${jt.statusCompleted}`,children:"Task completed"}),i.jsx("button",{onClick:()=>r(Ii(B.workspaceId,void 0,P)),className:jt.btnPrimary,children:"+ New Task"})]});if(B.status==="failed")return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:`${jt.statusText} ${jt.statusFailed}`,children:"Task failed"})})}if(I){const B=t.find(de=>de.id===I),F=(B==null?void 0:B.status)==="stopped";if(B!==void 0&&!F)return i.jsx(i.Fragment,{});if(F)return i.jsxs("div",{className:jt.bar,children:[i.jsxs("span",{className:`${jt.statusText} ${jt.hintText}`,children:["Session ",B.endReason||B.status]}),i.jsx("button",{onClick:()=>r(Kx(B.environmentId)),className:jt.btnPrimary,children:"+ New Chat"})]})}return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Loading..."})})}const VI="_nav_14i94_1",qI="_tab_14i94_24",GI="_tabActive_14i94_62",FI="_tabLabel_14i94_75",ZI="_statusDot_14i94_81",KI="_pulse_14i94_87",YI="_addButton_14i94_99",JI="_empty_14i94_132",Ba={nav:VI,tab:qI,tabActive:GI,tabLabel:FI,statusDot:ZI,pulse:KI,addButton:YI,empty:JI},WI={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function XI({environments:t}){const s=mt(),o=x.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=x.useCallback(y=>{s(Ai(y))},[s]),v=x.useCallback(y=>{var T;const S=(T=o.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),j=k>=0?k:t.findIndex(C=>C.id===m);let N=j;if(y.key==="ArrowDown"||y.key==="j"||y.key==="J")y.preventDefault(),N=(j+1)%S.length;else if(y.key==="ArrowUp"||y.key==="k"||y.key==="K")y.preventDefault(),N=(j-1+S.length)%S.length;else if(y.key==="Home")y.preventDefault(),N=0;else if(y.key==="End")y.preventDefault(),N=S.length-1;else return;N<t.length&&s(Ai(t[N].id)),S[N].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:Ba.nav,"data-testid":"environment-nav",children:[i.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(y=>{const S=y.id===m,k=y.id===b,j=WI[y.status]||"var(--text-tertiary)",N=y.status==="connected";return i.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${Ba.tab} ${S?Ba.tabActive:""}`,onClick:()=>g(y.id),"data-testid":"env-nav-item",children:[i.jsx("span",{className:`${Ba.statusDot} ${N?Ba.pulse:""}`,style:{color:j},"aria-hidden":"true",children:i.jsx(Va,{size:bm,fill:"currentColor"})}),i.jsx("span",{className:Ba.tabLabel,title:y.displayName||y.id,children:y.displayName||y.id})]},y.id)})}),i.jsx("button",{type:"button",className:Ba.addButton,onClick:()=>s(vN),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&i.jsx("div",{className:Ba.empty,children:"No environments yet."})]})}function Po(t){const s=new Date(t),o=new Date,r=o.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()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}function B1(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return"—";const o=new Date,r=s.getTime()-o.getTime();if(r<=0)return"overdue";const c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return`in ${c}s`;if(d<60)return`in ${d}m`;if(u<24)return`in ${u}h`;if(p<7)return`in ${p} day${p===1?"":"s"}`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const Qb={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 xd(t){return Qb[t]||Qb.general}const QI="_nav_dlm8m_1",e5="_categoryPills_dlm8m_24",t5="_categoryPill_dlm8m_24",n5="_tab_dlm8m_42",s5="_tabActive_dlm8m_80",a5="_tabContent_dlm8m_93",i5="_tabLabel_dlm8m_100",o5="_tabMeta_dlm8m_106",r5="_categoryDot_dlm8m_111",l5="_empty_dlm8m_118",js={nav:QI,categoryPills:e5,categoryPill:t5,tab:n5,tabActive:s5,tabContent:a5,tabLabel:i5,tabMeta:o5,categoryDot:r5,empty:l5};function c5({findings:t,workspaceId:s,environmentId:o}){const r=mt(),c=x.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=x.useMemo(()=>{const y=new Set(t.map(S=>S.category).filter(Boolean));return Array.from(y).sort()},[t]),g=x.useCallback(y=>{r(Gp(y,s,o))},[r,s,o]),v=x.useCallback(y=>{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),j=k>=0?k:t.findIndex(C=>C.id===p);let N=j;if(y.key==="ArrowDown"||y.key==="j"||y.key==="J")y.preventDefault(),N=(j+1)%S.length;else if(y.key==="ArrowUp"||y.key==="k"||y.key==="K")y.preventDefault(),N=(j-1+S.length)%S.length;else if(y.key==="Home")y.preventDefault(),N=0;else if(y.key==="End")y.preventDefault(),N=S.length-1;else return;N<t.length&&r(Gp(t[N].id,s,o)),S[N].focus()},[p,t,r,s,o]),b=p??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:js.nav,"data-testid":"findings-nav",children:[m.length>1&&i.jsx("div",{className:js.categoryPills,"data-testid":"findings-nav-categories",children:m.map(y=>i.jsx("span",{className:js.categoryPill,style:{color:xd(y).text},children:y},y))}),i.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(y=>{const S=y.id===p,k=y.id===b;return i.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${js.tab} ${S?js.tabActive:""}`,onClick:()=>g(y.id),"data-testid":"finding-nav-item",children:[i.jsx("span",{className:js.categoryDot,style:{color:xd(y.category).text},"aria-hidden":"true",children:i.jsx(Va,{size:bm,fill:"currentColor"})}),i.jsxs("span",{className:js.tabContent,children:[i.jsx("span",{className:js.tabLabel,title:y.title,children:y.title}),i.jsx("span",{className:js.tabMeta,title:y.createdAt,children:Po(y.createdAt)})]})]},y.id)})}),t.length===0&&i.jsx("div",{className:js.empty,children:"No findings yet. Agents will post discoveries here."})]})}function d5(t){if(t.length===0)return[];const s=[...t].sort((r,c)=>r[0]-c[0]),o=[[s[0][0],s[0][1]]];for(let r=1;r<s.length;r++){const c=o[o.length-1],[d,u]=s[r];d<=c[1]+1?c[1]=Math.max(c[1],u):o.push([d,u])}return o}function L1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return i.jsx(i.Fragment,{children:t});const r=d5(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(i.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(i.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(i.jsx("span",{children:t.slice(d)},`p${d}`)),i.jsx(i.Fragment,{children:c})}function u5(t){const s=new Map(t.map(r=>[r.id,{...r,children:[]}])),o=[];for(const r of s.values())r.parentTaskId&&s.has(r.parentTaskId)?s.get(r.parentTaskId).children.push(r):o.push(r);for(const r of s.values())r.children.sort((c,d)=>c.sortOrder-d.sortOrder);return o.sort((r,c)=>r.sortOrder-c.sortOrder)}function f5(t,s){const o=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=o.get(p);m?m.push(d):o.set(p,[d])}const r=[],c=new Set;for(const d of _j){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=qa(d);r.push({status:d,label:p.label,style:p,tasks:u})}}for(const[d,u]of o)if(!c.has(d)&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=qa(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const p5="_container_z4i38_1",m5="_header_z4i38_5",h5="_headerActions_z4i38_17",g5="_searchInput_z4i38_23",v5="_searchHighlight_z4i38_56",y5="_groupToggle_z4i38_62",b5="_groupToggleActive_z4i38_89",x5="_addButton_z4i38_93",_5="_taskRow_z4i38_120",k5="_selected_z4i38_140",S5="_expandArrow_z4i38_150",T5="_expanded_z4i38_157",j5="_leafSpacer_z4i38_161",w5="_taskStatusIcon_z4i38_166",N5="_taskTitle_z4i38_170",C5="_workspaceBadge_z4i38_177",E5="_childCountBadge_z4i38_195",A5="_dependencyBadge_z4i38_208",D5="_blockedBadge_z4i38_220",R5="_addChildButton_z4i38_225",M5="_emptyState_z4i38_268",I5="_statusGroupHeader_z4i38_275",O5="_statusGroupIcon_z4i38_294",B5="_statusGroupLabel_z4i38_298",L5="_statusGroupCount_z4i38_303",Fe={container:p5,header:m5,headerActions:h5,searchInput:g5,searchHighlight:v5,groupToggle:y5,groupToggleActive:b5,addButton:x5,taskRow:_5,selected:k5,expandArrow:S5,expanded:T5,leafSpacer:j5,taskStatusIcon:w5,taskTitle:N5,workspaceBadge:C5,childCountBadge:E5,dependencyBadge:A5,blockedBadge:D5,addChildButton:R5,emptyState:M5,statusGroupHeader:I5,statusGroupIcon:O5,statusGroupLabel:B5,statusGroupCount:L5},z5=[{name:"title",weight:2},{name:"description",weight:1}],z1=16,$5=16,$1="grackle-task-group-by-status";function ex(){try{return localStorage.getItem($1)==="true"}catch{return!1}}function U5(t){try{localStorage.setItem($1,String(t))}catch{}}function P5({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return i.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[i.jsxs("div",{className:Fe.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[i.jsx("span",{className:`${Fe.expandArrow} ${s?Fe.expanded:""}`,"aria-hidden":"true",children:i.jsx(ra,{size:ct})}),i.jsx("span",{className:Fe.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),i.jsx("span",{className:Fe.statusGroupLabel,children:t.label}),i.jsx("span",{className:Fe.statusGroupCount,children:t.tasks.length})]}),i.jsx(gs,{children:s&&i.jsx(Mt.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=qa(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return i.jsxs("div",{onClick:()=>c(On(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(On(p.id)))},className:`${Fe.taskRow} ${g?Fe.selected:""}`,style:{"--task-indent":`${z1}px`},"data-task-id":p.id,children:[i.jsx("span",{className:Fe.leafSpacer}),i.jsx("span",{className:Fe.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${pl(p.status)}`,children:m.icon}),i.jsx("span",{className:Fe.taskTitle,title:p.title,children:i.jsx(L1,{text:p.title,indices:d.get(p.id),highlightClass:Fe.searchHighlight})}),v&&i.jsx("span",{className:Fe.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function U1({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=qa(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),b=o.has(t.id),y=t.children.length>0,S=c===t.id,k=z1+s*$5,N=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{onClick:()=>d(On(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:T=>{T.currentTarget===T.target&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(On(t.id)))},className:`${Fe.taskRow} ${S?Fe.selected:""}`,style:{"--task-indent":`${k}px`},"data-task-id":t.id,children:[y&&i.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:i.jsx(ra,{size:ct,"aria-hidden":"true"})}),!y&&i.jsx("span",{className:Fe.leafSpacer}),i.jsx("span",{className:Fe.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${pl(t.status)}`,children:g.icon}),i.jsx("span",{className:Fe.taskTitle,title:t.title,children:i.jsx(L1,{text:t.title,indices:p.get(t.id),highlightClass:Fe.searchHighlight})}),N&&i.jsx("span",{className:Fe.workspaceBadge,title:N,children:N}),y&&i.jsxs("span",{className:Fe.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&i.jsx("span",{className:`${Fe.dependencyBadge} ${v?Fe.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<DT&&i.jsx($o,{text:"Add child task",children:i.jsx("button",{onClick:T=>{T.stopPropagation(),d(Ii(t.workspaceId,t.id))},"aria-label":"Add child task",className:Fe.addChildButton,children:"+"})})]}),i.jsx(gs,{children:y&&b&&i.jsx(Mt.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=>i.jsx(U1,{node:T,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function H5({workspaces:t,tasks:s}){const o=mt(),[r,c]=x.useState(new Set),[d,u]=x.useState(new Set),[p,m]=x.useState(ex),[g,v]=x.useState(ex),[b,y]=x.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,j=x.useMemo(()=>new Map(s.map(te=>[te.id,te.status])),[s]),N=x.useMemo(()=>new Map(t.map(te=>[te.id,te.name])),[t]),T=()=>{const te=!p;U5(te),m(te),te&&(v(!0),y(new Map))},C=te=>{y(X=>{const B=new Map(X),F=B.has(te)?B.get(te):g;return B.set(te,!F),B})},A=te=>b.has(te)?b.get(te):g,I=te=>{c(X=>{const B=new Set(X);return B.has(te)?(B.delete(te),u(F=>new Set(F).add(te))):(B.add(te),u(F=>{const Z=new Set(F);return Z.delete(te),Z})),B})};x.useEffect(()=>{const te=new Set(s.filter(X=>X.parentTaskId).map(X=>X.parentTaskId));te.size>0&&c(X=>{const B=new Set(X);for(const F of te)d.has(F)||B.add(F);return B})},[s,d]);const[E,D]=x.useState(""),{directMatchTaskIds:P,treeMatchTaskIds:O,titleHighlights:z}=x.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const te=AT(s,E,z5),X=new Set(te.map(de=>de.item.id)),B=new Map;for(const de of te){const W=de.matches.find(ee=>ee.key==="title");W&&B.set(de.item.id,W.indices)}const F=new Set(X),Z=new Map(s.map(de=>[de.id,de]));for(const de of[...X]){let W=Z.get(de);for(;W!=null&&W.parentTaskId;)F.add(W.parentTaskId),W=Z.get(W.parentTaskId)}return{directMatchTaskIds:X,treeMatchTaskIds:F,titleHighlights:B}},[E,s]),Q=P!==null,$=Q?p?P:O:null,J=$?s.filter(te=>$.has(te.id)):s,me=p?[]:u5(J);return i.jsxs("div",{className:Fe.container,children:[i.jsxs("div",{className:Fe.header,children:[i.jsx("span",{children:"Tasks"}),i.jsxs("div",{className:Fe.headerActions,children:[i.jsx($o,{text:p?"Switch to tree view":"Group tasks by status",children:i.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:i.jsx(Y2,{size:nn})})}),i.jsx($o,{text:"New task",children:i.jsx("button",{className:Fe.addButton,onClick:()=>o(Ii()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&i.jsx("input",{type:"text",value:E,onChange:te=>D(te.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Fe.searchInput,"data-testid":"sidebar-search"}),p?f5(J,j).map(te=>i.jsx(P5,{group:te,isExpanded:A(te.status),onToggle:()=>C(te.status),selectedTaskId:k,navigate:o,titleHighlights:z,workspaceNames:N},te.status)):me.map(te=>i.jsx(U1,{node:te,depth:0,expandedTasks:r,toggleTask:I,selectedTaskId:k,navigate:o,taskStatusById:j,titleHighlights:z,workspaceNames:N},te.id)),J.length===0&&!Q&&i.jsx("div",{className:Fe.emptyState,children:"No tasks yet. Click + to create one."}),J.length===0&&Q&&i.jsx("div",{className:Fe.emptyState,children:"No matching tasks"})]})}const V5="_toast_ed2dk_1",q5="_success_ed2dk_18",G5="_icon_ed2dk_22",F5="_error_ed2dk_25",Z5="_warning_ed2dk_32",K5="_info_ed2dk_38",Y5="_message_ed2dk_53",J5="_close_ed2dk_60",qr={toast:V5,success:q5,icon:G5,error:F5,warning:Z5,info:K5,message:Y5,close:J5},W5={success:i.jsx(Ri,{size:Rt}),error:i.jsx(Ka,{size:Rt}),warning:i.jsx(ym,{size:Rt}),info:i.jsx(vm,{size:Rt})};function X5({toast:t,onDismiss:s}){return x.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),i.jsxs(Mt.div,{className:`${qr.toast} ${qr[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:[i.jsx("span",{className:qr.icon,"aria-hidden":"true",children:W5[t.variant]}),i.jsx("span",{className:qr.message,children:t.message}),i.jsx("button",{type:"button",className:qr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:i.jsx(Ka,{size:nn,"aria-hidden":"true"})})]})}const Q5="_container_qqse2_1",eO={container:Q5};function tO({toasts:t,onDismiss:s}){return i.jsx("div",{className:eO.container,"data-testid":"toast-container",children:i.jsx(gs,{children:t.map(o=>i.jsx(X5,{toast:o,onDismiss:s},o.id))})})}const nO="_callout_e5awm_1",sO="_success_e5awm_11",aO="_icon_e5awm_15",iO="_error_e5awm_18",oO="_warning_e5awm_25",rO="_info_e5awm_32",lO="_content_e5awm_48",cO="_close_e5awm_53",Gr={callout:nO,success:sO,icon:aO,error:iO,warning:oO,info:rO,content:lO,close:cO},dO={success:i.jsx(Ri,{size:Rt}),error:i.jsx(Ka,{size:Rt}),warning:i.jsx(ym,{size:Rt}),info:i.jsx(vm,{size:Rt})};function uO({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=x.useState(!1);return i.jsx(i.Fragment,{children:!c&&i.jsxs("div",{className:[Gr.callout,Gr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[i.jsx("span",{className:Gr.icon,"aria-hidden":"true",children:dO[t]}),i.jsx("span",{className:Gr.content,children:s}),o&&i.jsx("button",{type:"button",className:Gr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:i.jsx(Ka,{size:nn,"aria-hidden":"true"})})]})})}function fO({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return i.jsx(i.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return i.jsx("div",{"data-testid":"update-banner",children:i.jsxs(uO,{variant:"info",dismissible:!0,children:[i.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",i.jsx("code",{children:c})]})})}const pO="_container_de44x_1",mO="_emptyState_de44x_8",hO="_card_de44x_14",gO="_cardClickable_de44x_34",vO="_cardHeader_de44x_42",yO="_categoryBadge_de44x_54",bO="_findingTitle_de44x_62",xO="_findingDate_de44x_68",_O="_findingContent_de44x_80",kO="_tags_de44x_86",SO="_tag_de44x_86",fs={container:pO,emptyState:mO,card:hO,cardClickable:gO,cardHeader:vO,categoryBadge:yO,findingTitle:bO,findingDate:xO,findingContent:_O,tags:kO,tag:SO};function P1({findings:t,onFindingClick:s}){return t.length===0?i.jsx("div",{className:fs.emptyState,children:"No findings yet. Agents will post discoveries here."}):i.jsx("div",{className:fs.container,children:t.map((o,r)=>{const c=xd(o.category),d=s?Mt.button:Mt.div;return i.jsxs(d,{type:s?"button":void 0,className:`${fs.card} ${s?fs.cardClickable:""}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:r*.05,duration:.2},onClick:s?()=>{s(o.id)}:void 0,children:[i.jsxs("div",{className:fs.cardHeader,children:[i.jsx("span",{className:fs.categoryBadge,style:{background:c.bg,color:c.text},children:o.category}),i.jsx("span",{className:fs.findingTitle,children:o.title}),i.jsx("span",{className:fs.findingDate,title:o.createdAt,children:Po(o.createdAt)})]}),i.jsx("div",{className:fs.findingContent,children:o.content.length>300?o.content.slice(0,300)+"...":o.content}),o.tags.length>0&&i.jsx("div",{className:fs.tags,children:o.tags.map(u=>i.jsx("span",{className:fs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},o.id)})})}const TO="_section_1ingb_14",jO="_sectionTitle_1ingb_26",wO="_sectionDescription_1ingb_35",NO="_tokenList_1ingb_48",CO="_tokenRow_1ingb_55",EO="_tokenBadge_1ingb_68",AO="_tokenName_1ingb_83",DO="_tokenTarget_1ingb_90",RO="_deleteButton_1ingb_99",MO="_addForm_1ingb_113",IO="_formRow_1ingb_119",OO="_input_1ingb_125",BO="_select_1ingb_155",LO="_addButton_1ingb_187",zO="_emptyStateInfo_1ingb_221",$O="_themeOptions_1ingb_229",UO="_themeOption_1ingb_229",PO="_themeOptionSelected_1ingb_254",HO="_themeOptionHeader_1ingb_259",VO="_themeOptionLabel_1ingb_266",qO="_themeOptionDesc_1ingb_273",GO="_variantToggle_1ingb_279",FO="_variantButton_1ingb_286",ZO="_variantActive_1ingb_305",KO="_themeSwatches_1ingb_311",YO="_themeSwatch_1ingb_311",JO="_systemToggle_1ingb_325",WO="_systemToggleHint_1ingb_341",XO="_themeActive_1ingb_348",QO="_aboutGrid_1ingb_354",eB="_aboutItem_1ingb_360",tB="_aboutLabel_1ingb_373",nB="_aboutValue_1ingb_379",sB="_aboutDot_1ingb_387",aB="_aboutDotConnected_1ingb_394",iB="_aboutDotDisconnected_1ingb_398",ye={section:TO,sectionTitle:jO,sectionDescription:wO,tokenList:NO,tokenRow:CO,tokenBadge:EO,tokenName:AO,tokenTarget:DO,deleteButton:RO,addForm:MO,formRow:IO,input:OO,select:BO,addButton:LO,emptyStateInfo:zO,themeOptions:$O,themeOption:UO,themeOptionSelected:PO,themeOptionHeader:HO,themeOptionLabel:VO,themeOptionDesc:qO,variantToggle:GO,variantButton:FO,variantActive:ZO,themeSwatches:KO,themeSwatch:YO,systemToggle:JO,systemToggleHint:WO,themeActive:XO,aboutGrid:QO,aboutItem:eB,aboutLabel:tB,aboutValue:nB,aboutDot:sB,aboutDotConnected:aB,aboutDotDisconnected:iB},oB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function rB({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=x.useState(""),[u,p]=x.useState(""),[m,g]=x.useState("env_var"),[v,b]=x.useState(""),[y,S]=x.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("")},j=T=>{S(T)},N=()=>{y&&(o(y),r==null||r("Token deleted","info")),S(null)};return i.jsxs(i.Fragment,{children:[i.jsx(ia,{isOpen:y!==null,title:"Delete Token?",description:y?`"${y}" will be permanently removed.`:void 0,onConfirm:N,onCancel:()=>S(null)}),i.jsxs("section",{className:ye.section,children:[i.jsx("h3",{className:ye.sectionTitle,children:"Tokens"}),i.jsx("p",{className:ye.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?i.jsx("div",{className:ye.emptyStateInfo,children:"Add your first API token to enable service integrations."}):i.jsx("div",{className:ye.tokenList,children:t.map(T=>i.jsxs("div",{className:ye.tokenRow,children:[i.jsx("span",{className:ye.tokenBadge,children:T.tokenType}),i.jsx("span",{className:ye.tokenName,children:T.name}),i.jsx("span",{className:ye.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),i.jsx("button",{className:ye.deleteButton,onClick:()=>j(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:i.jsx(Ka,{size:nn,"aria-hidden":"true"})})]},T.name))}),i.jsxs("form",{className:ye.addForm,onSubmit:k,children:[i.jsxs("div",{className:ye.formRow,children:[i.jsx("input",{className:ye.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),i.jsx("input",{className:ye.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),i.jsxs("div",{className:ye.formRow,children:[i.jsx("select",{className:ye.select,value:m,onChange:T=>g(T.target.value),children:oB.map(T=>i.jsx("option",{value:T.value,children:T.label},T.value))}),i.jsx("input",{className:ye.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)}),i.jsx("button",{className:ye.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const zd=[{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"]}],H1=new Set(zd.map(t=>t.id)),tx="grackle";function um(t){return zd.find(s=>s.id===t)}function lB({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return i.jsxs("section",{className:ye.section,children:[i.jsx("h3",{className:ye.sectionTitle,children:"Appearance"}),i.jsx("p",{className:ye.sectionDescription,children:"Choose how Grackle looks across the app."}),i.jsx("div",{className:ye.themeOptions,children:zd.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 i.jsxs("button",{type:"button",className:`${ye.themeOption} ${p?ye.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[i.jsxs("span",{className:ye.themeOptionHeader,children:[i.jsxs("span",{children:[i.jsx("span",{className:ye.themeOptionLabel,children:d.label}),i.jsx("span",{className:ye.themeOptionDesc,children:d.description})]}),u&&i.jsxs("span",{className:ye.variantToggle,children:[i.jsx("span",{role:"button",tabIndex:0,className:`${ye.variantButton} ${p&&m?ye.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),i.jsx("span",{role:"button",tabIndex:0,className:`${ye.variantButton} ${p&&!m?ye.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&i.jsx("span",{className:ye.themeSwatches,children:d.swatches.map((g,v)=>i.jsx("span",{className:ye.themeSwatch,style:{background:g}},v))})]},d.id)})}),i.jsxs("label",{className:ye.systemToggle,children:[i.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),i.jsx("span",{children:"Match system light/dark preference"})]}),i.jsx("p",{className:ye.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),i.jsxs("p",{className:ye.themeActive,children:["Active theme: ",i.jsx("strong",{children:s})]})]})}function cB({connected:t,environments:s,sessions:o}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=o.filter(u=>["running","idle"].includes(u.status)).length;return i.jsxs("section",{className:ye.section,"data-testid":"about-panel",children:[i.jsx("h3",{className:ye.sectionTitle,children:"About"}),i.jsx("p",{className:ye.sectionDescription,children:"Connection status and application information."}),i.jsxs("div",{className:ye.aboutGrid,children:[i.jsxs("div",{className:ye.aboutItem,children:[i.jsx("span",{className:ye.aboutLabel,children:"Connection"}),i.jsxs("span",{className:ye.aboutValue,children:[i.jsx("span",{className:`${ye.aboutDot} ${t?ye.aboutDotConnected:ye.aboutDotDisconnected}`}),t?"Connected":"Disconnected"]})]}),i.jsxs("div",{className:ye.aboutItem,children:[i.jsx("span",{className:ye.aboutLabel,children:"Environments"}),i.jsxs("span",{className:ye.aboutValue,children:[r,"/",c," connected"]})]}),i.jsxs("div",{className:ye.aboutItem,children:[i.jsx("span",{className:ye.aboutLabel,children:"Active Sessions"}),i.jsx("span",{className:ye.aboutValue,children:d})]}),i.jsxs("div",{className:ye.aboutItem,children:[i.jsx("span",{className:ye.aboutLabel,children:"Version"}),i.jsx("span",{className:ye.aboutValue,children:"0.101.0"})]})]})]})}const dB="_container_cddyd_1",uB="_header_cddyd_8",fB="_headerTitle_cddyd_35",pB="_badge_cddyd_44",mB="_headerActions_cddyd_54",hB="_body_cddyd_61",gB="_formContent_cddyd_73",vB="_section_cddyd_85",yB="_label_cddyd_91",bB="_titleInput_cddyd_98",xB="_descriptionTextarea_cddyd_131",_B="_parentContext_cddyd_167",kB="_parentLabel_cddyd_175",SB="_parentName_cddyd_182",TB="_personaSelect_cddyd_186",jB="_depList_cddyd_220",wB="_depItem_cddyd_226",NB="_depItemSelected_cddyd_248",CB="_noDeps_cddyd_252",EB="_btnPrimary_cddyd_258",AB="_btnGhost_cddyd_289",nt={container:dB,header:uB,headerTitle:fB,badge:pB,headerActions:mB,body:hB,formContent:gB,section:vB,label:yB,titleInput:bB,descriptionTextarea:xB,parentContext:_B,parentLabel:kB,parentName:SB,personaSelect:TB,depList:jB,depItem:wB,depItemSelected:NB,noDeps:CB,btnPrimary:EB,btnGhost:AB};function V1({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:b}){const y=mt(),S=t==="edit",k=S&&s?d.find(xe=>xe.id===s):void 0,j=S?(k==null?void 0:k.workspaceId)??"":o??"",[N,T]=x.useState(j),C=j||N,A=u.find(xe=>xe.id===C),I=c??(A==null?void 0:A.environmentId),E=!S&&!o,D=S?(k==null?void 0:k.parentTaskId)??"":r??"",P=D?d.find(xe=>xe.id===D):void 0,[O,z]=x.useState((k==null?void 0:k.title)??""),[Q,$]=x.useState((k==null?void 0:k.description)??""),[J,me]=x.useState((k==null?void 0:k.dependsOn)??[]),[te,X]=x.useState((k==null?void 0:k.defaultPersonaId)??""),[B,F]=x.useState((k==null?void 0:k.canDecompose)??!1),[Z,de]=x.useState(!1),W=x.useRef(!1);x.useEffect(()=>{S&&k&&!W.current&&(W.current=!0,z(k.title),$(k.description),me(k.dependsOn),X(k.defaultPersonaId),F(k.canDecompose))},[S,k]);const ee=d.filter(xe=>xe.workspaceId===C&&(!S||xe.id!==s)&&xe.id!==D),ue=O.trim().length>0&&(!S||k!==void 0)&&C.length>0,Ce=xe=>{me(Be=>Be.includes(xe)?Be.filter(It=>It!==xe):[...Be,xe])},Pe=()=>{!ue||Z||S&&k===void 0||(S&&s?(g(s,O.trim(),Q,J,te),b==null||b("Task updated","success"),v?v():y(On(s,void 0,C,I),{replace:!0})):(de(!0),m(C,O.trim(),Q,J.length>0?J:void 0,D||void 0,te,B,()=>{b==null||b("Task created","success"),y(o?Ga(o,I):"/tasks",{replace:!0})},xe=>{b==null||b(xe,"error"),de(!1)})))},ge=()=>{if(v){v();return}y(S&&s?On(s,void 0,C,I):o?Ga(o,I):"/tasks")},Se=S?"edit task":D?"child task":"new task";return i.jsxs("div",{className:nt.container,children:[i.jsxs("div",{className:nt.header,children:[i.jsxs("div",{className:nt.headerTitle,children:[i.jsx("span",{className:nt.badge,children:Se}),P&&i.jsxs("span",{className:nt.parentContext,children:[i.jsx("span",{className:nt.parentLabel,children:"Child of"}),i.jsx("span",{className:nt.parentName,children:P.title})]})]}),i.jsxs("div",{className:nt.headerActions,children:[i.jsx("button",{onClick:Pe,disabled:!ue||Z,className:nt.btnPrimary,"data-testid":"task-edit-save",children:Z?"Creating…":S?"Save Changes":"Create"}),i.jsx("button",{onClick:ge,className:nt.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:nt.body,children:i.jsxs("div",{className:nt.formContent,children:[E&&i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-workspace",children:"Workspace"}),i.jsxs("select",{id:"task-edit-workspace",value:N,onChange:xe=>T(xe.target.value),className:nt.personaSelect,"data-testid":"task-edit-workspace",children:[i.jsx("option",{value:"",children:"Select a workspace..."}),u.map(xe=>i.jsx("option",{value:xe.id,children:xe.name},xe.id))]})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-title",children:"Title"}),i.jsx("input",{id:"task-edit-title",type:"text",value:O,onChange:xe=>z(xe.target.value),placeholder:"Task title...",autoFocus:!0,className:nt.titleInput,"data-testid":"task-edit-title",onKeyDown:xe=>{xe.key==="Enter"&&ue&&Pe()}})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-description",children:"Description"}),i.jsx("textarea",{id:"task-edit-description",value:Q,onChange:xe=>$(xe.target.value),placeholder:"Describe the task... (markdown supported)",className:nt.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-persona",children:"Default Persona"}),i.jsxs("select",{id:"task-edit-persona",value:te,onChange:xe=>X(xe.target.value),className:nt.personaSelect,"data-testid":"task-edit-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),p.map(xe=>i.jsx("option",{value:xe.id,children:xe.name},xe.id))]})]}),!S&&i.jsx("div",{className:nt.section,children:i.jsxs("label",{className:nt.depItem,"data-testid":"task-edit-can-decompose",children:[i.jsx("input",{type:"checkbox",checked:B,onChange:xe=>F(xe.target.checked)}),"Can spawn subtasks"]})}),i.jsxs("div",{className:nt.section,children:[i.jsx("div",{className:nt.label,children:"Dependencies"}),ee.length===0?i.jsx("div",{className:nt.noDeps,children:"No other tasks in this workspace"}):i.jsx("div",{className:nt.depList,children:ee.map(xe=>{const Be=J.includes(xe.id);return i.jsxs("label",{className:`${nt.depItem} ${Be?nt.depItemSelected:""}`,"data-testid":`dep-option-${xe.id}`,children:[i.jsx("input",{type:"checkbox",checked:Be,onChange:()=>Ce(xe.id)}),xe.title,i.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",xe.status,")"]})]},xe.id)})})]})]})})]})}const DB="_actionButtons_1rjka_1",RB="_btnPrimary_1rjka_8",MB="_btnDanger_1rjka_39",IB="_btnGhost_1rjka_78",Kt={actionButtons:DB,btnPrimary:RB,btnDanger:MB,btnGhost:IB};function OB({task:t,sessionId:s,isBlocked:o,onStart:r,onResume:c,onStop:d,onPause:u,onDelete:p,onEdit:m}){if(t.status==="not_started")return o?i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:m,className:Kt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Kt.btnPrimary,children:"Start"}),i.jsx("button",{onClick:m,className:Kt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Kt.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:u,disabled:!s,className:Kt.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Kt.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:c,className:Kt.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return i.jsx("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:r,className:Kt.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const BB="_workpadSection_y8nj9_1",LB="_workpadLabel_y8nj9_9",zB="_workpadStatus_y8nj9_17",$B="_workpadSummary_y8nj9_23",UB="_workpadExtra_y8nj9_29",La={workpadSection:BB,workpadLabel:LB,workpadStatus:zB,workpadSummary:$B,workpadExtra:UB};function PB({workpad:t}){if(!t)return;let s;try{const o=JSON.parse(t);if(o==null||typeof o!="object"||Array.isArray(o))return;s=o}catch{return i.jsxs("div",{className:La.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:La.workpadLabel,children:"Workpad"}),i.jsx("div",{className:La.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return i.jsxs("div",{className:La.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:La.workpadLabel,children:"Workpad"}),s.status&&i.jsx("div",{className:La.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&i.jsx("div",{className:La.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&i.jsx("div",{className:La.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const HB="_overviewDashboard_r05qm_1",VB="_overviewHero_r05qm_7",qB="_statusBadge_r05qm_14",GB="_statusPending_r05qm_26",FB="_statusAssigned_r05qm_31",ZB="_statusInProgress_r05qm_36",KB="_statusReview_r05qm_41",YB="_statusDone_r05qm_46",JB="_statusFailed_r05qm_51",WB="_statusWaitingInput_r05qm_56",XB="_overviewBranchPill_r05qm_61",QB="_branchLink_r05qm_76",eL="_overviewSection_r05qm_87",tL="_overviewLabel_r05qm_93",nL="_overviewValue_r05qm_100",sL="_overviewMuted_r05qm_105",aL="_overviewMarkdown_r05qm_111",iL="_envRow_r05qm_180",oL="_envDot_r05qm_186",rL="_envDotGreen_r05qm_193",lL="_envDotYellow_r05qm_197",cL="_envDotRed_r05qm_201",dL="_envDotGray_r05qm_205",uL="_depList_r05qm_209",fL="_depItem_r05qm_215",pL="_depBlocked_r05qm_222",mL="_depDone_r05qm_226",hL="_timeline_r05qm_230",gL="_timelineRow_r05qm_236",vL="_timelineKey_r05qm_243",yL="_timelineValue_r05qm_249",bL="_timelineDelta_r05qm_253",xL="_reviewNotes_r05qm_264",ve={overviewDashboard:HB,overviewHero:VB,statusBadge:qB,statusPending:GB,statusAssigned:FB,statusInProgress:ZB,statusReview:KB,statusDone:YB,statusFailed:JB,statusWaitingInput:WB,overviewBranchPill:XB,branchLink:QB,overviewSection:eL,overviewLabel:tL,overviewValue:nL,overviewMuted:sL,overviewMarkdown:aL,envRow:iL,envDot:oL,envDotGreen:rL,envDotYellow:lL,envDotRed:cL,envDotGray:dL,depList:uL,depItem:fL,depBlocked:pL,depDone:mL,timeline:hL,timelineRow:gL,timelineKey:vL,timelineValue:yL,timelineDelta:bL,reviewNotes:xL};function Fc(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 Ep(t,s){if(!t||!s)return;const o=new Date(s).getTime()-new Date(t).getTime();if(isNaN(o)||o<0)return;const r=Math.floor(o/6e4),c=Math.floor(o%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 nx(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?ve.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?ve.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?ve.envDotRed:ve.envDotGray}function _L({status:t}){const s=qa(t),o=xj(t);return i.jsx("span",{className:`${ve.statusBadge} ${ve[o]??ve.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function kL({task:t,tasksById:s,environments:o,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?o.find(k=>k.id===g):void 0,b=r.find(k=>k.id===t.workspaceId),y=o.find(k=>k.id===d),S=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return i.jsxs("div",{className:ve.overviewDashboard,"data-testid":"task-overview-panel",children:[i.jsxs("div",{className:ve.overviewHero,children:[i.jsx(_L,{status:t.status}),t.branch&&i.jsx("span",{className:ve.overviewBranchPill,"data-testid":"task-overview-branch",children:S?i.jsxs("a",{href:S,target:"_blank",rel:"noreferrer noopener",className:ve.branchLink,children:["🔗"," ",t.branch]}):i.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-description",children:[i.jsx("div",{className:ve.overviewLabel,children:"Description"}),i.jsx("div",{className:ve.overviewMarkdown,children:i.jsx(Td,{remarkPlugins:[jd],children:t.description})})]}),t.workpad&&i.jsx(PB,{workpad:t.workpad}),i.jsxs("div",{className:ve.overviewSection,children:[i.jsx("div",{className:ve.overviewLabel,children:"Environment"}),g&&v?i.jsxs("div",{className:ve.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${ve.envDot} ${nx(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),i.jsx("span",{className:ve.overviewValue,children:v.displayName})]}):y?i.jsxs("div",{className:ve.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${ve.envDot} ${nx(y.status)}`,title:y.status,"aria-label":`Status: ${y.status}`,role:"img"}),i.jsx("span",{className:ve.overviewValue,children:y.displayName}),i.jsx("span",{className:ve.overviewMuted,children:"(workspace default)"})]}):i.jsx("div",{className:ve.overviewMuted,children:"Set in workspace settings"})]}),i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-dependencies",children:[i.jsx("div",{className:ve.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?i.jsx("div",{className:ve.overviewMuted,children:"None"}):i.jsx("div",{className:ve.depList,children:t.dependsOn.map(k=>{const j=s.get(k),N=(j==null?void 0:j.status)==="complete";return i.jsxs("div",{className:`${ve.depItem} ${N?ve.depDone:ve.depBlocked}`,children:[i.jsx("span",{children:N?"✓":"○"}),i.jsx("span",{children:(j==null?void 0:j.title)??k})]},k)})})]}),i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-timeline",children:[i.jsx("div",{className:ve.overviewLabel,children:"Timeline"}),i.jsxs("div",{className:ve.timeline,children:[t.createdAt&&i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Created"}),i.jsx("span",{className:ve.timelineValue,children:Fc(t.createdAt)})]}),t.assignedAt&&(()=>{const k=Ep(t.createdAt,t.assignedAt);return i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Assigned"}),i.jsx("span",{className:ve.timelineValue,children:Fc(t.assignedAt)}),k!==void 0&&i.jsx("span",{className:ve.timelineDelta,children:k})]})})(),t.startedAt&&(()=>{const k=Ep(t.assignedAt??t.createdAt,t.startedAt);return i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Started"}),i.jsx("span",{className:ve.timelineValue,children:Fc(t.startedAt)}),k!==void 0&&i.jsx("span",{className:ve.timelineDelta,children:k})]})})(),t.completedAt&&(()=>{const k=Ep(t.startedAt,t.completedAt);return i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Completed"}),i.jsx("span",{className:ve.timelineValue,children:Fc(t.completedAt)}),k!==void 0&&i.jsx("span",{className:ve.timelineDelta,children:k})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&i.jsx("div",{className:ve.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-usage",children:[i.jsx("div",{className:ve.overviewLabel,children:"Usage"}),i.jsxs("div",{className:ve.timeline,children:[i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Cost"}),i.jsx("span",{className:ve.timelineValue,children:Ns(u.costMillicents)}),i.jsxs("span",{className:ve.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Total (incl. subtasks)"}),i.jsx("span",{className:ve.timelineValue,children:Ns(p.costMillicents)}),i.jsxs("span",{className:ve.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-budget",children:[i.jsx("div",{className:ve.overviewLabel,children:"Budget"}),i.jsxs("div",{className:ve.timeline,children:[t.tokenBudget>0&&i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Tokens"}),i.jsxs("span",{className:ve.timelineValue,children:[Oo(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",Oo(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Cost"}),i.jsxs("span",{className:ve.timelineValue,children:[Ns((u==null?void 0:u.costMillicents)??0)," / ",Ns(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-review-notes",children:[i.jsx("div",{className:ve.overviewLabel,children:"Review Notes"}),i.jsx("div",{className:ve.reviewNotes,children:t.reviewNotes})]})]})}const SL="_container_legrg_1",TL="_header_legrg_8",jL="_headerTitle_legrg_35",wL="_badge_legrg_44",NL="_headerActions_legrg_54",CL="_body_legrg_61",EL="_formContent_legrg_73",AL="_section_legrg_85",DL="_label_legrg_91",RL="_nameInput_legrg_98",ML="_fieldInput_legrg_131",IL="_adapterSelect_legrg_164",OL="_readOnlyValue_legrg_198",BL="_codespaceSection_legrg_204",LL="_codespaceActions_legrg_210",zL="_creatingHint_legrg_216",$L="_errorHint_legrg_222",UL="_btnPrimary_legrg_235",PL="_btnGhost_legrg_266",ce={container:SL,header:TL,headerTitle:jL,badge:wL,headerActions:NL,body:CL,formContent:EL,section:AL,label:DL,nameInput:RL,fieldInput:ML,adapterSelect:IL,readOnlyValue:OL,codespaceSection:BL,codespaceActions:LL,creatingHint:zL,errorHint:$L,btnPrimary:UL,btnGhost:PL},od=1,rd=65535;function Ap(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=od&&s<=rd}function Dp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function HL({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=x.useState("pick"),[b,y]=x.useState(""),[S,k]=x.useState("");return g==="create"?i.jsxs("div",{className:ce.codespaceSection,children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Repository"}),i.jsx("input",{type:"text",value:b,onChange:j=>y(j.target.value),placeholder:"owner/repo",className:ce.fieldInput,"data-testid":"env-codespace-repo"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Machine Type"}),i.jsx("input",{type:"text",value:S,onChange:j=>k(j.target.value),placeholder:"Machine type (optional)...",className:ce.fieldInput,"data-testid":"env-codespace-machine"})]}),i.jsxs("div",{className:ce.codespaceActions,children:[i.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),S.trim()||void 0),v("pick"),y(""),k(""))},disabled:!b.trim(),className:ce.btnPrimary,children:"Create"}),i.jsx("button",{onClick:()=>{v("pick"),y(""),k("")},className:ce.btnGhost,children:"Cancel"})]})]}):i.jsx("div",{className:ce.codespaceSection,children:i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Codespace"}),!u&&i.jsxs("select",{value:t,onChange:j=>{j.target.value==="__create__"?(v("create"),s("")):(s(j.target.value),j.target.value&&!o.trim()&&r(j.target.value))},disabled:p,className:ce.adapterSelect,"data-testid":"env-codespace-select",children:[i.jsx("option",{value:"",children:"Select a codespace..."}),c.map(j=>i.jsxs("option",{value:j.name,children:[j.name," (",j.repository,") — ",j.state]},j.name)),i.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&i.jsx("span",{className:ce.creatingHint,children:"Creating codespace..."}),u&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:ce.errorHint,children:u}),i.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:ce.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&i.jsx("span",{className:ce.errorHint,children:d})]})})}function q1({mode:t,environmentId:s,environments:o,onAddEnvironment:r,onUpdateEnvironment:c,onListCodespaces:d,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v,onShowToast:b}){const y=mt(),S=t==="edit",k=S&&s?o.find(ge=>ge.id===s):void 0,[j,N]=x.useState(""),[T,C]=x.useState("local"),[A,I]=x.useState(""),[E,D]=x.useState(""),[P,O]=x.useState(""),[z,Q]=x.useState(""),[$,J]=x.useState(""),[me,te]=x.useState(""),[X,B]=x.useState(""),[F,Z]=x.useState(null),de=x.useCallback(()=>{const ge={};if(T==="local"){if(A.trim()&&(ge.host=A.trim()),E.trim()){const Se=Number(E);Number.isInteger(Se)&&(ge.port=Se)}}else if(T==="ssh"){if(ge.host=A.trim(),P.trim()&&(ge.user=P.trim()),E.trim()){const Se=Number(E);Number.isInteger(Se)&&(ge.sshPort=Se)}z.trim()&&(ge.identityFile=z.trim())}else T==="docker"?($.trim()&&(ge.image=$.trim()),me.trim()&&(ge.repo=me.trim())):T==="codespace"&&(ge.codespaceName=X.trim());return ge},[T,A,E,P,z,$,me,X]),W=()=>!(!j.trim()||T==="ssh"&&!A.trim()||T==="codespace"&&!X.trim()||(T==="local"||T==="ssh")&&!Ap(E)),ee=()=>{W()&&(r(j.trim(),T,de()),b==null||b("Environment added successfully","success"),y(Io,{replace:!0}))},ue=()=>{y(s?Ai(s):Io)},Ce=x.useCallback((ge,Se)=>{if(!k||!s)return;const xe=Dp(k.adapterConfig),Be=Se.trim();Be?xe[ge]=Be:delete xe[ge],c(s,{adapterConfig:xe})},[k,s,c]),Pe=x.useCallback((ge,Se)=>{if(!k||!s)return;const xe=Dp(k.adapterConfig);if(Se.trim()){const Be=Number(Se);Number.isInteger(Be)&&Be>=od&&Be<=rd&&(xe[ge]=Be)}else delete xe[ge];c(s,{adapterConfig:xe})},[k,s,c]);if(S){if(!k)return i.jsxs("div",{className:ce.container,children:[i.jsxs("div",{className:ce.header,children:[i.jsx("div",{className:ce.headerTitle,children:i.jsx("span",{className:ce.badge,children:"edit environment"})}),i.jsx("div",{className:ce.headerActions,children:i.jsx("button",{onClick:ue,className:ce.btnGhost,children:"Back"})})]}),i.jsx("div",{className:ce.body,children:i.jsx("div",{className:ce.formContent,children:i.jsx("span",{className:ce.readOnlyValue,children:"Environment not found"})})})]});const ge=Dp(k.adapterConfig);return i.jsxs("div",{className:ce.container,"data-testid":"env-edit-panel",children:[i.jsxs("div",{className:ce.header,children:[i.jsx("div",{className:ce.headerTitle,children:i.jsx("span",{className:ce.badge,children:"edit environment"})}),i.jsx("div",{className:ce.headerActions,children:i.jsx("button",{onClick:ue,className:ce.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),i.jsx("div",{className:ce.body,children:i.jsxs("div",{className:ce.formContent,children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Name"}),i.jsx(Ft,{value:k.displayName,onSave:Se=>{s&&c(s,{displayName:Se})},validate:Se=>Se.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:F,onActivate:Z,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Adapter Type"}),i.jsx("span",{className:ce.readOnlyValue,"data-testid":"env-edit-adapter-type",children:k.adapterType})]}),k.adapterType==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Host"}),i.jsx(Ft,{value:String(ge.host??""),onSave:Se=>Ce("host",Se),mode:"edit",fieldId:"host",activeFieldId:F,onActivate:Z,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Port"}),i.jsx(Ft,{value:String(ge.port??""),onSave:Se=>Pe("port",Se),validate:Se=>Ap(Se)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:F,onActivate:Z,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),k.adapterType==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Host"}),i.jsx(Ft,{value:String(ge.host??""),onSave:Se=>Ce("host",Se),validate:Se=>Se.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:F,onActivate:Z,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"User"}),i.jsx(Ft,{value:String(ge.user??""),onSave:Se=>Ce("user",Se),mode:"edit",fieldId:"user",activeFieldId:F,onActivate:Z,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"SSH Port"}),i.jsx(Ft,{value:String(ge.sshPort??""),onSave:Se=>Pe("sshPort",Se),validate:Se=>Ap(Se)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:F,onActivate:Z,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Identity File"}),i.jsx(Ft,{value:String(ge.identityFile??""),onSave:Se=>Ce("identityFile",Se),mode:"edit",fieldId:"identityFile",activeFieldId:F,onActivate:Z,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),k.adapterType==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Image"}),i.jsx(Ft,{value:String(ge.image??""),onSave:Se=>Ce("image",Se),mode:"edit",fieldId:"image",activeFieldId:F,onActivate:Z,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Repo"}),i.jsx(Ft,{value:String(ge.repo??""),onSave:Se=>Ce("repo",Se),mode:"edit",fieldId:"repo",activeFieldId:F,onActivate:Z,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),k.adapterType==="codespace"&&i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Codespace Name"}),i.jsx(Ft,{value:String(ge.codespaceName??""),onSave:Se=>Ce("codespaceName",Se),validate:Se=>Se.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:F,onActivate:Z,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return i.jsxs("div",{className:ce.container,"data-testid":"env-create-panel",children:[i.jsxs("div",{className:ce.header,children:[i.jsx("div",{className:ce.headerTitle,children:i.jsx("span",{className:ce.badge,children:"new environment"})}),i.jsxs("div",{className:ce.headerActions,children:[i.jsx("button",{onClick:ee,disabled:!W(),className:ce.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),i.jsx("button",{onClick:ue,className:ce.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:ce.body,children:i.jsxs("div",{className:ce.formContent,children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-name",children:"Name"}),i.jsx("input",{id:"env-create-name",type:"text",value:j,onChange:ge=>N(ge.target.value),placeholder:"Environment name...",autoFocus:!0,className:ce.nameInput,"data-testid":"env-create-name",onKeyDown:ge=>{ge.key==="Enter"&&W()&&ee()}})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),i.jsxs("select",{id:"env-create-adapter",value:T,onChange:ge=>{C(ge.target.value),ge.target.value==="codespace"&&d()},className:ce.adapterSelect,"data-testid":"env-create-adapter",children:[i.jsx("option",{value:"local",children:"local"}),i.jsx("option",{value:"ssh",children:"ssh"}),i.jsx("option",{value:"docker",children:"docker"}),i.jsx("option",{value:"codespace",children:"codespace"})]})]}),T==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:A,onChange:ge=>I(ge.target.value),placeholder:"Host (optional)...",className:ce.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-port",children:"Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:od,max:rd,value:E,onChange:ge=>D(ge.target.value),placeholder:"Port (optional)...",className:ce.fieldInput,"data-testid":"env-create-port"})]})]}),T==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:A,onChange:ge=>I(ge.target.value),placeholder:"Host (required)...",className:ce.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-user",children:"User"}),i.jsx("input",{id:"env-create-user",type:"text",value:P,onChange:ge=>O(ge.target.value),placeholder:"User (optional)...",className:ce.fieldInput,"data-testid":"env-create-user"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-port",children:"SSH Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:od,max:rd,value:E,onChange:ge=>D(ge.target.value),placeholder:"SSH port (optional)...",className:ce.fieldInput,"data-testid":"env-create-port"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-identity",children:"Identity File"}),i.jsx("input",{id:"env-create-identity",type:"text",value:z,onChange:ge=>Q(ge.target.value),placeholder:"Identity file (optional)...",className:ce.fieldInput,"data-testid":"env-create-identity"})]})]}),T==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-image",children:"Image"}),i.jsx("input",{id:"env-create-image",type:"text",value:$,onChange:ge=>J(ge.target.value),placeholder:"Image (optional)...",className:ce.fieldInput,"data-testid":"env-create-image"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-repo",children:"Repo"}),i.jsx("input",{id:"env-create-repo",type:"text",value:me,onChange:ge=>te(ge.target.value),placeholder:"Repo (optional)...",className:ce.fieldInput,"data-testid":"env-create-repo"})]})]}),T==="codespace"&&i.jsx(HL,{codespaceName:X,onCodespaceNameChange:B,envName:j,onEnvNameChange:N,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v})]})})]})}const VL="_group_1iprv_1",qL="_groupTitle_1iprv_8",GL="_shortcutList_1iprv_17",FL="_shortcutRow_1iprv_23",ZL="_keys_1iprv_36",KL="_kbd_1iprv_43",YL="_description_1iprv_60",Si={group:VL,groupTitle:qL,shortcutList:GL,shortcutRow:FL,keys:ZL,kbd:KL,description:YL},JL=[{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 WL(){return i.jsxs("section",{className:ye.section,"data-testid":"keyboard-shortcuts-panel",children:[i.jsx("h3",{className:ye.sectionTitle,children:"Keyboard Shortcuts"}),i.jsx("p",{className:ye.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),JL.map(t=>i.jsxs("div",{className:Si.group,children:[i.jsx("h4",{className:Si.groupTitle,children:t.title}),i.jsx("div",{className:Si.shortcutList,children:t.shortcuts.map(s=>i.jsxs("div",{className:Si.shortcutRow,children:[i.jsx("span",{className:Si.keys,children:s.keys.map(o=>i.jsx("kbd",{className:Si.kbd,children:o},o))}),i.jsx("span",{className:Si.description,children:s.description})]},s.description))})]},t.title))]})}const XL=[{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 QL({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return i.jsxs("section",{className:ye.section,children:[i.jsx("h3",{className:ye.sectionTitle,children:"Credential Providers"}),i.jsx("p",{className:ye.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),i.jsx("div",{className:ye.tokenList,children:XL.map(r=>i.jsxs("div",{className:ye.tokenRow,children:[i.jsx("span",{className:ye.tokenName,children:r.label}),i.jsx("span",{className:ye.tokenTarget,children:r.description}),i.jsx("select",{className:ye.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>i.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const e8="_container_10efq_1",t8="_header_10efq_7",n8="_list_10efq_105",s8="_card_10efq_111",a8="_cardHeader_10efq_125",i8="_cardTitle_10efq_135",o8="_defaultBadge_10efq_141",r8="_cardActions_10efq_155",l8="_description_10efq_160",c8="_meta_10efq_166",d8="_empty_10efq_212",u8="_typeBadge_10efq_362",Xn={container:e8,header:t8,list:n8,card:s8,cardHeader:a8,cardTitle:i8,defaultBadge:o8,cardActions:r8,description:l8,meta:c8,empty:d8,typeBadge:u8};function f8({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=x.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return i.jsxs("div",{className:Xn.container,children:[i.jsxs("div",{className:Xn.header,children:[i.jsx("h2",{children:"Personas"}),i.jsx(tn,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?i.jsx("p",{className:Xn.empty,children:"No personas yet. Create one to get started."}):i.jsx("div",{className:Xn.list,children:t.map(v=>{const b=s===v.id,y=v.type==="script";return i.jsxs("div",{className:Xn.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:[i.jsxs("div",{className:Xn.cardHeader,children:[i.jsxs("span",{className:Xn.cardTitle,children:[i.jsx("strong",{children:v.name}),i.jsx("span",{className:Xn.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:y?"Script":"Agent"}),b&&i.jsx("span",{className:Xn.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),i.jsxs("div",{className:Xn.cardActions,onClick:S=>S.stopPropagation(),children:[!b&&i.jsx(tn,{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"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&i.jsx("p",{className:Xn.description,children:v.description}),i.jsxs("div",{className:Xn.meta,children:[v.runtime&&i.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&i.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&i.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),i.jsx(ia,{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 p8="_container_uy08i_1",m8="_header_uy08i_7",h8="_count_uy08i_13",g8="_presets_uy08i_18",v8="_presetButton_uy08i_24",y8="_filterInput_uy08i_41",b8="_groups_uy08i_53",x8="_group_uy08i_53",_8="_groupHeader_uy08i_68",k8="_groupName_uy08i_77",S8="_groupCount_uy08i_81",T8="_toolList_uy08i_87",j8="_toolItem_uy08i_95",w8="_toolName_uy08i_103",gn={container:p8,header:m8,count:h8,presets:g8,presetButton:v8,filterInput:y8,groups:b8,group:x8,groupHeader:_8,groupName:k8,groupCount:S8,toolList:T8,toolItem:j8,toolName:w8},N8=(()=>{const t=new Map;for(const s of kx){const o=s==="get_version_status"?"version":s.split("_")[0];t.has(o)||t.set(o,[]),t.get(o).push(s)}return[...t.entries()].sort(([s],[o])=>s.localeCompare(o)).map(([s,o])=>({group:s,tools:o.sort()}))})(),C8=[{name:"default",label:"Default",tools:Sx},{name:"worker",label:"Worker",tools:RT},{name:"orchestrator",label:"Orchestrator",tools:MT},{name:"admin",label:"Admin",tools:IT}];function sx({selectedTools:t,onChange:s,disabled:o}){const[r,c]=x.useState(""),d=x.useMemo(()=>new Set(t),[t]),u=x.useCallback(v=>{if(o)return;const b=new Set(d);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[d,s,o]),p=x.useCallback((v,b)=>{if(o)return;const y=new Set(d);for(const S of v)b?y.delete(S):y.add(S);s([...y].sort())},[d,s,o]),m=x.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return i.jsxs("div",{className:gn.container,"data-testid":"mcp-tool-selector",children:[i.jsx("div",{className:gn.header,children:i.jsx("span",{className:gn.count,children:t.length===0?`Using default (${Sx.length} tools)`:`${t.length} of ${kx.size} tools selected`})}),i.jsxs("div",{className:gn.presets,"data-testid":"mcp-tool-presets",children:[C8.map(v=>i.jsx("button",{type:"button",className:gn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),i.jsx("button",{type:"button",className:gn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),i.jsx("input",{type:"text",className:gn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),i.jsx("div",{className:gn.groups,children:N8.map(({group:v,tools:b})=>{const y=g?b.filter(k=>k.toLowerCase().includes(g)):b;if(y.length===0)return null;const S=y.every(k=>d.has(k));return i.jsxs("div",{className:gn.group,"data-testid":`tool-group-${v}`,children:[i.jsxs("label",{className:gn.groupHeader,children:[i.jsx("input",{type:"checkbox",checked:S,onChange:()=>p(y,S),disabled:o,"data-testid":`group-toggle-${v}`}),i.jsx("span",{className:gn.groupName,children:v}),i.jsxs("span",{className:gn.groupCount,children:["(",y.filter(k=>d.has(k)).length,"/",y.length,")"]})]}),i.jsx("div",{className:gn.toolList,children:y.map(k=>i.jsxs("label",{className:gn.toolItem,children:[i.jsx("input",{type:"checkbox",checked:d.has(k),onChange:()=>u(k),disabled:o,"data-testid":`tool-${k}`}),i.jsx("span",{className:gn.toolName,children:k})]},k))})]},v)})})]})}const E8="_container_1gfuq_1",A8="_header_1gfuq_7",D8="_list_1gfuq_19",R8="_card_1gfuq_25",M8="_cardHeader_1gfuq_40",I8="_cardTitle_1gfuq_46",O8="_statusBadge_1gfuq_56",B8="_enabled_1gfuq_68",L8="_disabled_1gfuq_71",z8="_cardActions_1gfuq_75",$8="_cardMeta_1gfuq_80",U8="_empty_1gfuq_98",Qn={container:E8,header:A8,list:D8,card:R8,cardHeader:M8,cardTitle:I8,statusBadge:O8,enabled:B8,disabled:L8,cardActions:z8,cardMeta:$8,empty:U8};function P8({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=x.useState(null),m=u?t.find(y=>y.id===u):void 0,g=async y=>{await o(y),p(null)},v=x.useMemo(()=>{const y=new Map;for(const S of s)y.set(S.id,S.name);return y},[s]),b=y=>v.get(y)??y;return i.jsxs("div",{className:Qn.container,children:[i.jsxs("div",{className:Qn.header,children:[i.jsx("h2",{children:"Schedules"}),i.jsx(tn,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?i.jsx("p",{className:Qn.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):i.jsx("div",{className:Qn.list,children:t.map(y=>i.jsxs("div",{className:Qn.card,"data-testid":`schedule-card-${y.id}`,onClick:()=>d(y.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),d(y.id))},children:[i.jsxs("div",{className:Qn.cardHeader,children:[i.jsxs("span",{className:Qn.cardTitle,children:[i.jsx("strong",{children:y.title}),i.jsx("span",{className:`${Qn.statusBadge} ${y.enabled?Qn.enabled:Qn.disabled}`,"data-testid":`schedule-status-badge-${y.id}`,children:y.enabled?"Enabled":"Disabled"})]}),i.jsxs("div",{className:Qn.cardActions,onClick:S=>S.stopPropagation(),children:[i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(y.id,{enabled:!y.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${y.id}`,title:y.enabled?"Disable schedule":"Enable schedule",children:y.enabled?"Disable":"Enable"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>d(y.id),"data-testid":`schedule-edit-${y.id}`,children:"Edit"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>p(y.id),"data-testid":`schedule-delete-${y.id}`,children:"Delete"})]})]}),i.jsxs("div",{className:Qn.cardMeta,children:[i.jsx("span",{"data-testid":`schedule-expression-${y.id}`,children:y.scheduleExpression}),y.personaId&&i.jsxs("span",{"data-testid":`schedule-persona-${y.id}`,children:["Persona: ",b(y.personaId)]}),i.jsxs("span",{"data-testid":`schedule-last-run-${y.id}`,children:["Last run: ",y.lastRunAt?Po(y.lastRunAt):"Never"]}),y.enabled&&y.nextRunAt?i.jsxs("span",{"data-testid":`schedule-next-run-${y.id}`,children:["Next run: ",B1(y.nextRunAt)]}):null,y.runCount>0&&i.jsxs("span",{"data-testid":`schedule-run-count-${y.id}`,children:["Runs: ",y.runCount]})]})]},y.id))}),i.jsx(ia,{isOpen:u!==null,title:"Delete Schedule?",description:`"${(m==null?void 0:m.title)??""}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const H8="_nav_1bhou_1",V8="_tab_1bhou_24",q8="_tabIcon_1bhou_62",G8="_tabActive_1bhou_68",Zc={nav:H8,tab:V8,tabIcon:q8,tabActive:G8},Xs=[{path:"credentials",label:"Credentials",icon:i.jsx(V2,{size:Rt})},{path:"personas",label:"Personas",icon:i.jsx(vj,{size:Rt})},{path:"schedules",label:"Schedules",icon:i.jsx(_2,{size:Rt})},{path:"appearance",label:"Appearance",icon:i.jsx(ij,{size:Rt})},{path:"shortcuts",label:"Shortcuts",icon:i.jsx(G2,{size:Rt})},{path:"about",label:"About",icon:i.jsx(vm,{size:Rt})}];function F8(){var u;const t=Yt(),s=mt(),o=x.useRef(null),r=((u=Xs.find(p=>{const m=`${Ni}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??Xs[0].path,c=x.useCallback(p=>{s(`${Ni}/${p}`)},[s]),d=x.useCallback(p=>{var S,k;const m=(S=o.current)==null?void 0:S.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:Xs.findIndex(j=>j.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%Xs.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+Xs.length)%Xs.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=Xs.length-1;else return;const y=Xs[b].path;s(`${Ni}/${y}`),(k=m[b])==null||k.focus()},[r,s]);return i.jsx("nav",{className:Zc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:Xs.map(p=>{const m=p.path===r;return i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Zc.tab} ${m?Zc.tabActive:""}`,onClick:()=>c(p.path),children:[i.jsx("span",{className:Zc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}function Z8({tasks:t,taskStatusById:s,sessionStatusByTaskId:o}){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(xy.map(d=>[d,[]]));for(const d of t){const u=pl(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"&&o){const k=o.get(d.id);k==="idle"?b="Needs input":k==="completed"&&(b="Ready to complete")}const y={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},S=c.get(u);S?S.push(y):c.get("not_started").push(y)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return xy.map(d=>{const u=qa(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const K8="_boardContainer_1c4y1_1",Y8="_column_1c4y1_17",J8="_columnHeader_1c4y1_34",W8="_columnIcon_1c4y1_47",X8="_columnLabel_1c4y1_52",Q8="_columnCount_1c4y1_57",e7="_cardList_1c4y1_67",t7="_emptyPlaceholder_1c4y1_76",n7="_card_1c4y1_67",s7="_cardHeader_1c4y1_107",a7="_cardStatusIcon_1c4y1_113",i7="_cardTitle_1c4y1_119",o7="_cardBadges_1c4y1_127",r7="_badge_1c4y1_134",l7="_blockedBadge_1c4y1_146",c7="_childBadge_1c4y1_151",d7="_depBadge_1c4y1_155",u7="_parentBadge_1c4y1_159",f7="_pausedSubBadge_1c4y1_166",p7="_personaBadge_1c4y1_170",m7="_envBadge_1c4y1_174",h7="_emptyCta_1c4y1_178",g7="_ctaButton_1c4y1_188",v7="_ctaDescription_1c4y1_204",it={boardContainer:K8,column:Y8,columnHeader:J8,columnIcon:W8,columnLabel:X8,columnCount:Q8,cardList:e7,emptyPlaceholder:t7,card:n7,cardHeader:s7,cardStatusIcon:a7,cardTitle:i7,cardBadges:o7,badge:r7,blockedBadge:l7,childBadge:c7,depBadge:d7,parentBadge:u7,pausedSubBadge:f7,personaBadge:p7,envBadge:m7,emptyCta:h7,ctaButton:g7,ctaDescription:v7};function y7({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=mt(),p=x.useMemo(()=>o.filter(y=>y.workspaceId===t),[o,t]),m=x.useMemo(()=>new Map(o.map(y=>[y.id,y.status])),[o]),g=x.useMemo(()=>new Map(p.map(y=>[y.id,y])),[p]),v=x.useMemo(()=>{const y=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])),j=new Map,N=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const A=y.get(C.latestSessionId);if(A){if(j.set(C.id,A.endReason||A.status),A.personaId){const I=S.get(A.personaId);I&&N.set(C.id,I.name)}if(A.environmentId){const I=k.get(A.environmentId);I&&T.set(C.id,I.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:N,environmentNameByTaskId:T}},[p,r,c,d]),b=x.useMemo(()=>Z8({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?i.jsxs("div",{className:it.emptyCta,"data-testid":"board-empty-cta",children:[i.jsx("button",{className:it.ctaButton,onClick:()=>u(Ii(t,void 0,s)),children:"Create Task"}),i.jsx("div",{className:it.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):i.jsx("div",{className:it.boardContainer,"data-testid":"board-container",children:b.map(y=>i.jsxs("section",{className:it.column,"data-testid":`board-column-${y.status}`,"aria-label":`${y.label}, ${y.tasks.length} ${y.tasks.length===1?"task":"tasks"}`,children:[i.jsxs("div",{className:it.columnHeader,children:[i.jsx("span",{className:it.columnIcon,style:{color:y.style.color},children:y.style.icon}),i.jsx("span",{className:it.columnLabel,children:y.label}),i.jsx("span",{className:it.columnCount,"data-testid":`board-count-${y.status}`,children:y.tasks.length})]}),i.jsx("div",{className:it.cardList,children:y.tasks.length===0?i.jsx("div",{className:it.emptyPlaceholder,children:"No tasks"}):i.jsx(gs,{mode:"popLayout",children:y.tasks.map(S=>i.jsx(Mt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:i.jsx(b7,{boardTask:S,tasksById:g,personaName:v.personaNameByTaskId.get(S.task.id),envName:v.environmentNameByTaskId.get(S.task.id),onClick:()=>u(On(S.task.id,void 0,t,s))})},S.task.id))})})]},y.status))})}function b7({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=qa(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return i.jsxs("div",{className:it.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),c())},children:[i.jsxs("div",{className:it.cardHeader,children:[i.jsx("span",{className:it.cardStatusIcon,style:{color:v.color},children:v.icon}),i.jsx("span",{className:it.cardTitle,children:d.title})]}),i.jsxs("div",{className:it.cardBadges,children:[b&&i.jsx("span",{className:`${it.badge} ${it.parentBadge}`,title:b.title,children:b.title}),p>0&&i.jsxs("span",{className:`${it.badge} ${it.childBadge}`,children:[m,"/",p]}),u&&i.jsx("span",{className:`${it.badge} ${it.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&i.jsx("span",{className:`${it.badge} ${it.depBadge}`,children:"dep"}),g&&i.jsx("span",{className:`${it.badge} ${it.pausedSubBadge}`,children:g}),o&&i.jsx("span",{className:`${it.badge} ${it.personaBadge}`,children:o}),r&&i.jsx("span",{className:`${it.badge} ${it.envBadge}`,children:r})]})]})}const x7="_formContent_ymnez_1",_7="_section_ymnez_13",k7="_label_ymnez_19",S7="_titleInput_ymnez_26",T7="_descriptionTextarea_ymnez_58",j7="_selectField_ymnez_94",w7="_checkboxRow_ymnez_128",N7="_checkboxLabel_ymnez_141",C7="_fieldError_ymnez_146",xt={formContent:x7,section:_7,label:k7,titleInput:S7,descriptionTextarea:T7,selectField:j7,checkboxRow:w7,checkboxLabel:N7,fieldError:C7};function E7(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 A7=100;function D7({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return i.jsxs("div",{className:xt.formContent,children:[i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-name",children:"Name"}),i.jsx("input",{id:"ws-name",className:xt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:A7,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-description",children:"Description"}),i.jsx("textarea",{id:"ws-description",className:xt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-repo",children:"Repository URL"}),i.jsx("input",{id:"ws-repo",className:xt.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)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-environment",children:"Environment"}),i.jsxs("select",{id:"ws-environment",className:xt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[i.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>i.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-persona",children:"Default Persona"}),i.jsxs("select",{id:"ws-persona",className:xt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>i.jsx("option",{value:m.id,children:m.name},m.id))]})]}),i.jsx("div",{className:xt.section,children:i.jsxs("label",{className:xt.checkboxRow,children:[i.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),i.jsx("span",{className:xt.checkboxLabel,children:"Enable worktree isolation"})]})}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-workdir",children:"Working Directory"}),i.jsx("input",{id:"ws-workdir",className:xt.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 G1=x.createContext(void 0),R7=4e3;function M7({children:t}){const[s,o]=x.useState([]),r=x.useRef(0),c=x.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=x.useCallback((u,p="info",m=R7)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return i.jsx(G1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function pn(){const t=x.useContext(G1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const fm="grackle-theme",F1="grackle-prefer-system",Z1="(prefers-color-scheme: dark)";let Jr=[],ld;function Rp(){ld=void 0;for(const t of Jr)t()}function pm(){return typeof window>"u"?!1:window.matchMedia(Z1).matches}function nl(){if(typeof localStorage>"u")return tx;try{const t=localStorage.getItem(fm);if(t!==null&&H1.has(t))return t}catch{}return tx}function _d(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(F1)==="true"}catch{return!1}}function mm(t){return zd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function K1(t,s){const o=um(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?pm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=mm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return pm()?r.variantDarkId:r.variantLightId}return t}function No(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=K1(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&No(nl(),_d());function I7(){return ld===void 0&&(ld={themeId:nl(),systemDark:pm(),preferSystem:_d()}),ld}function O7(t){return Jr=[...Jr,t],()=>{Jr=Jr.filter(s=>s!==t)}}function B7(){const t=x.useSyncExternalStore(O7,I7),{themeId:s,preferSystem:o}=t,r=K1(s,o),c=x.useCallback(u=>{if(H1.has(u)){try{localStorage.setItem(fm,u)}catch{}No(u,_d(),!0),Rp()}},[]),d=x.useCallback(u=>{try{localStorage.setItem(F1,u?"true":"false")}catch{}if(u){const p=nl(),m=um(p);if(m!=null&&m.hidden){const g=mm(p);if(g)try{localStorage.setItem(fm,g.id)}catch{}}}No(nl(),u,!0),Rp()},[]);return x.useEffect(()=>{No(s,o)},[s,o]),x.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(Z1),p=()=>{const m=nl(),g=_d();if(g){const v=um(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&No(m,g),v!=null&&v.hidden){const b=mm(m);b!=null&&b.variantDarkId&&b.variantLightId&&No(m,g)}}Rp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const Y1=x.createContext(void 0);function L7({children:t}){const s=B7();return i.jsx(Y1.Provider,{value:s,children:t})}function J1(){const t=x.useContext(Y1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const W1=x.createContext(void 0),X1=x.createContext(void 0);function z7({children:t}){const[s,o]=x.useState(void 0),r=x.useCallback(c=>{o(c)},[]);return i.jsx(X1.Provider,{value:r,children:i.jsx(W1.Provider,{value:s,children:t})})}function $7(){return x.useContext(W1)}function U7(){const t=x.useContext(X1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const fh=x.createContext(void 0);function dt(){const t=x.useContext(fh);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function Q1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ek(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function P7(t){return Q1(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 H7=new Set(["off","subscription","api_key"]),Kc=new Set(["off","on"]);function V7(t){return Q1(t)&&H7.has(t.claude)&&Kc.has(t.github)&&Kc.has(t.copilot)&&Kc.has(t.codex)&&Kc.has(t.goose)}function tk(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 nk(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 wo=5e3;function q7(t,s){const o=[];let r=t;const c=new Set;for(;r&&s.has(r)&&!c.has(r);){c.add(r);const d=s.get(r);o.unshift(d),r=d.parentTaskId||void 0}return o}const oa={label:"Home",url:Di};function G7(t){return t?[oa,{label:"Settings",url:Ni},{label:t,url:void 0}]:[oa,{label:"Settings",url:void 0}]}const ph={label:"Environments",url:Io};function F7(){return[oa,{label:"Environments",url:void 0}]}function Z7(){return[oa,{label:"New Chat",url:void 0}]}function K7(t){return[oa,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function Y7(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[oa,ph,{label:(d==null?void 0:d.displayName)??"Environment",url:Ai(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function J7(t,s,o,r,c){const d=q7(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.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=[oa];v&&g&&(b.push(ph),b.push({label:v.displayName,url:Ai(g)})),m&&g&&b.push({label:m.name,url:Ga(m.id,g)});for(let S=0;S<d.length-1;S++)b.push({label:d[S].title,url:On(d[S].id,void 0,p,g)});const y=d[d.length-1];return b.push({label:(y==null?void 0:y.title)??t,url:void 0}),b}const W7={label:"Findings",url:Dd};function X7(){return[oa,{label:"Findings",url:void 0}]}function sk(t,s,o,r,c){const d=[oa];if(s&&o){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===o);d.push(ph),p&&d.push({label:p.displayName,url:Ai(o)}),u&&d.push({label:u.name,url:Ga(s,o)}),d.push({label:"Findings",url:wN(s,o)})}else d.push(W7);return d.push({label:t,url:void 0}),d}function mh(t){const s=[];for(const o of t){const r=s[s.length-1];o.eventType==="text"&&(r==null?void 0:r.eventType)==="text"?s[s.length-1]={...r,content:r.content+o.content}:s.push(o)}return s}function Yc(t){if(typeof t.id=="string")return t.id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function Q7(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 o=t.item;if(o&&typeof o.id=="string")return o.id}function hh(t){const s=new Map;for(const v of t)if(v.raw)try{s.set(v,JSON.parse(v.raw))}catch{}const o=new Map;for(const v of t){if(v.eventType!=="tool_use")continue;const b=s.get(v),y=b?Yc(b):void 0;if(y)try{const S=JSON.parse(v.content);o.set(y,{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 y=s.get(v),S=y?Q7(y):void 0;if(!S)return v;const k=o.get(S);if(!k)return v;r.add(S),c.add(b);let j;const N=v.content.trim();if(N.startsWith("{"))try{const T=JSON.parse(N);typeof T.detailedContent=="string"&&(j=T.detailedContent)}catch{}return{...v,toolUseCtx:{...k,detailedResult:j}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const b=s.get(d[v]),y=b?Yc(b):void 0;y&&r.has(y)||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 y=d[v],S=d[b];let k;try{const j=JSON.parse(y.content);k={tool:j.tool,args:j.args}}catch{}if(k){let j;const N=S.content.trim();if(N.startsWith("{"))try{const A=JSON.parse(N);typeof A.detailedContent=="string"&&(j=A.detailedContent)}catch{}d[b]={...S,toolUseCtx:{...k,detailedResult:j}},c.add(b);const T=s.get(y),C=T?Yc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(y,{...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 y=Yc(b);if(y&&r.has(y))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 y=v+1;y<g.length;y++)if(g[y].eventType!=="tool_use"){b=!0;break}b&&(g[v]={...g[v],settled:!0})}return g}function ez(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=ak(s),d=s.filter(m=>hm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||hm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function ak(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function hm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function tz(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=ak(t),c=[];for(const p of t){const m=p.workspaceId?((u=o.get(p.workspaceId))==null?void 0:u.name)??"Unknown":"Unknown";p.status==="failed"?c.push({task:p,reason:"failed",workspaceName:m}):hm(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 nz(t,s){const o=new Map;for(const r of s)o.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=o.get(r.environmentId))==null?void 0:c.displayName)??"Unknown"}})}function sz(t,s,o){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 ws=[{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
279
+ `)}function b6({events:t,formatForClipboard:s}){const[o,r]=x.useState(!1),[c,d]=x.useState(new Set),u=x.useRef(void 0),p=x.useMemo(()=>c.size,[c]),m=x.useCallback(k=>{r(!0),k!==void 0?(d(new Set([k])),u.current=k):(d(new Set),u.current=void 0)},[]),g=x.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=x.useCallback((k,j)=>{if(j&&u.current!==void 0){const N=Math.min(u.current,k),T=Math.max(u.current,k);d(C=>{const A=new Set(C);for(let I=N;I<=T;I++)I<t.length&&fl(t[I])&&A.add(I);return A})}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=x.useCallback(()=>{const k=new Set;for(let j=0;j<t.length;j++)fl(t[j])&&k.add(j);d(k)},[t]),y=x.useCallback(()=>{d(new Set)},[]),S=x.useCallback(async()=>{const j=[...c].sort((T,C)=>T-C).filter(T=>T<t.length).map(T=>t[T]);if(j.length===0)return!1;const N=s(j);try{return await navigator.clipboard.writeText(N),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:y,copySelected:S}}const x6="_wrapper_1cdza_1",_6="_scrollContainer_1cdza_9",k6="_selectingPadding_1cdza_16",S6="_toolbar_1cdza_20",T6="_directionToggle_1cdza_27",j6="_scrollToAnchor_1cdza_65",w6="_scrollToAnchorBottom_1cdza_89",N6="_scrollToAnchorTop_1cdza_93",C6="_eventOverflowWarning_1cdza_97",Qs={wrapper:x6,scrollContainer:_6,selectingPadding:k6,toolbar:S6,directionToggle:T6,scrollToAnchor:j6,scrollToAnchorBottom:w6,scrollToAnchorTop:N6,eventOverflowWarning:C6};function E6(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 R1="grackle-stream-direction";function A6(){try{return localStorage.getItem(R1)==="reversed"}catch{return!1}}function D6({eventsDropped:t}){return t<=0?i.jsx(i.Fragment,{}):i.jsxs("div",{className:Qs.eventOverflowWarning,role:"alert",children:[i.jsx(ym,{size:nn,"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 dh({events:t,eventsDropped:s,emptyState:o,onShowToast:r}){const c=x.useRef(null),[d,u]=x.useState(A6),p=h3(),m=b6({events:t,formatForClipboard:y6}),g=x.useMemo(()=>t.filter(fl).length,[t]),v=x.useMemo(()=>d?[...t].reverse():t,[t,d]),{isAtAnchor:b,scrollToAnchor:y}=h6({scrollRef:c,contentLength:t.length,isReversed:d,paused:m.isSelecting}),S=()=>{const T=!d;u(T);try{localStorage.setItem(R1,T?"reversed":"default")}catch{}};x.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=x.useCallback(async()=>{await m.copySelected()&&(r==null||r(`Copied ${m.selectedCount} message${m.selectedCount===1?"":"s"} to clipboard`,"success"))},[m,r]),j=p?0:.2,N=d?-8:8;return i.jsxs("div",{className:Qs.wrapper,children:[i.jsx("div",{className:Qs.toolbar,children:i.jsx($o,{text:d?"Showing newest first":"Showing oldest first",children:i.jsx("button",{className:Qs.directionToggle,onClick:S,"aria-label":d?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:d?i.jsx(yy,{size:nn,"aria-hidden":"true"}):i.jsx(by,{size:nn,"aria-hidden":"true"})})})}),i.jsxs("div",{ref:c,className:`${Qs.scrollContainer} ${m.isSelecting?Qs.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,i.jsx(D6,{eventsDropped:s}),i.jsx(gs,{initial:!1,children:v.map((T,C)=>{const A=d?t.length-1-C:C;return i.jsx(Mt.div,{initial:{opacity:0,y:N},animate:{opacity:1,y:0},transition:{duration:j,ease:"easeOut"},children:i.jsx(a6,{copyText:v6(T),isContentBearing:fl(T),isSelecting:m.isSelecting,isSelected:m.selectedIndices.has(A),checkboxLabel:E6(T),onSelect:()=>{m.enterSelectionMode(A)},onToggle:I=>{m.toggleEvent(A,I)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:i.jsx(VA,{event:T,toolUseCtx:T.toolUseCtx,settled:T.settled})})},`${T.sessionId}-${T.timestamp}-${A}`)})})]}),i.jsx(gs,{children:m.isSelecting&&i.jsx(f6,{selectedCount:m.selectedCount,totalSelectable:g,onSelectAll:m.selectAll,onDeselectAll:m.deselectAll,onCopy:()=>{k().catch(()=>{})},onCancel:m.cancelSelection})}),i.jsx(gs,{children:!b&&i.jsxs(Mt.button,{className:`${Qs.scrollToAnchor} ${d?Qs.scrollToAnchorTop:Qs.scrollToAnchorBottom}`,onClick:y,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?i.jsx(by,{size:nn,"aria-hidden":"true"}):i.jsx(yy,{size:nn,"aria-hidden":"true"})," New events"]})})]})}function uh(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=x.useState(""),[b,y]=x.useState(""),S=x.useRef(!1),k=d===c,j=x.useCallback(P=>{v(P),y("")},[]),N=x.useCallback(()=>{y("")},[]),T=x.useCallback(()=>{S.current=!1,u==null||u(null),v(""),y("")},[u]),C=x.useCallback(()=>{const P=m?g.trim():g;if(r){const z=r(g);if(z){y(z);return}}const O=m?s.trim():s;if(P===O){T();return}o(P),T()},[g,s,m,r,o,T]),A=x.useCallback(()=>{S.current=!0,u==null||u(c),v(s),y("")},[c,s,u]),I=x.useCallback(P=>{if(S.current){S.current=!1;return}P.relatedTarget instanceof HTMLElement&&P.relatedTarget.dataset.editAction===c||C()},[c,C]),E=x.useCallback(P=>{P.key==="Escape"?T():P.key==="Enter"&&p&&C()},[T,p,C]),D=(()=>{if(!k)return!1;const P=m?s.trim():s;return(m?g.trim():g)!==P})();return x.useEffect(()=>{!k&&(g!==""||b!=="")&&(v(""),y(""))},[k,g,b]),{isEditing:k,draft:g,error:b,isDirty:D,startEdit:A,cancelEdit:T,save:C,setDraft:j,clearError:N,handleBlur:I,handleKeyDown:E,ignoreInitialBlurRef:S}}const R6="_editFieldWrapper_yuzty_1",M6="_editInput_yuzty_10",I6="_editTextarea_yuzty_42",O6="_editSelect_yuzty_78",B6="_editError_yuzty_111",L6="_editInputInvalid_yuzty_118",z6="_editHint_yuzty_123",$6="_unsavedDot_yuzty_132",U6="_metaValueClickable_yuzty_140",P6="_editButton_yuzty_159",H6="_metaPlaceholder_yuzty_175",V6="_worktreeToggle_yuzty_180",st={editFieldWrapper:R6,editInput:M6,editTextarea:I6,editSelect:O6,editError:B6,editInputInvalid:L6,editHint:z6,unsavedDot:$6,metaValueClickable:U6,editButton:P6,metaPlaceholder:H6,worktreeToggle:V6};function Ft(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:b,ariaLabel:y,"data-testid":S}=t,k=x.useRef(null),j=uh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(x.useEffect(()=>{if(j.isEditing){const T=window.setTimeout(()=>{var C;(C=k.current)==null||C.focus()},0);return()=>window.clearTimeout(T)}},[j.isEditing]),c==="create"){const T=A=>{m==null||m(A.target.value)},C=r==null?void 0:r(s);return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("input",{className:`${st.editInput} ${C?st.editInputInvalid:""}`,value:s,onChange:T,maxLength:b,placeholder:v,"aria-label":y,"data-testid":S?`${S}-input`:void 0}),C&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("input",{ref:k,className:`${st.editInput} ${j.error?st.editInputInvalid:""}`,value:j.draft,onChange:T=>j.setDraft(T.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:b,placeholder:v,"aria-label":y,"data-testid":S?`${S}-input`:void 0}),j.isDirty&&i.jsx("span",{className:st.unsavedDot,title:"Unsaved changes"}),j.error&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:j.error}),i.jsx("span",{className:st.editHint,children:"Enter to save · Esc to cancel"})]});const N=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:st.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":y,"data-testid":S?`${S}-button`:void 0,children:[N!==void 0?N:s?i.jsx("span",{children:s}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function dm(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":y}=t,S=x.useRef(null),k=uh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(x.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 i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("textarea",{className:`${st.editTextarea} ${T?st.editInputInvalid:""}`,value:s,onChange:N,placeholder:v,"aria-label":b,"data-testid":y?`${y}-input`:void 0}),T&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:T})]})}if(k.isEditing)return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("textarea",{ref:S,className:`${st.editTextarea} ${k.error?st.editInputInvalid:""}`,value:k.draft,onChange:N=>k.setDraft(N.target.value),onBlur:k.handleBlur,onKeyDown:k.handleKeyDown,title:b,"aria-label":b,"data-testid":y?`${y}-input`:void 0}),k.isDirty&&i.jsx("span",{className:st.unsavedDot,title:"Unsaved changes"}),k.error&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:k.error}),i.jsx("span",{className:st.editHint,children:"Tab to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:st.metaValueClickable,onClick:()=>k.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),k.startEdit())},title:"Click to edit","aria-label":b,"data-testid":y?`${y}-button`:void 0,children:[j!==void 0?j:s?i.jsx("span",{children:s}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function Uo(t){var A;const{value:s,onSave:o,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":y}=t,S=x.useRef(null),k=uh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});x.useEffect(()=>{if(k.isEditing){const I=window.setTimeout(()=>{var E;(E=S.current)==null||E.focus()},0);return()=>window.clearTimeout(I)}},[k.isEditing]);const j=x.useCallback(I=>{const E=I.target.value;k.ignoreInitialBlurRef.current=!1,E!==s&&o(E),k.cancelEdit()},[s,o,k]),N=x.useCallback(I=>{if(k.ignoreInitialBlurRef.current){k.ignoreInitialBlurRef.current=!1;return}I.relatedTarget instanceof HTMLElement&&I.relatedTarget.dataset.editAction===d||k.cancelEdit()},[d,k]);if(r==="create")return i.jsx("select",{className:st.editSelect,value:s,onChange:I=>m==null?void 0:m(I.target.value),"aria-label":b,"data-testid":y?`${y}-select`:void 0,children:c.map(I=>i.jsx("option",{value:I.value,children:I.label},I.value))});if(k.isEditing)return i.jsx("select",{ref:S,className:st.editSelect,value:k.draft,onChange:j,onBlur:N,title:b,"aria-label":b,"data-testid":y?`${y}-select`:void 0,children:c.map(I=>i.jsx("option",{value:I.value,children:I.label},I.value))});const T=g==null?void 0:g(s),C=(A=c.find(I=>I.value===s))==null?void 0:A.label;return i.jsxs("button",{type:"button",className:st.metaValueClickable,onClick:()=>k.startEdit(),title:"Click to change","aria-label":b,"data-testid":y?`${y}-button`:void 0,children:[T!==void 0?T:C?i.jsx("span",{children:C}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function q6(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return i.jsxs("label",{className:st.worktreeToggle,"data-testid":d,children:[i.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),i.jsx("span",{children:r})]})}const G6="_envRow_1e1r5_1",F6="_envDot_1e1r5_7",Z6="_envDotGreen_1e1r5_14",K6="_envDotYellow_1e1r5_18",Y6="_envDotRed_1e1r5_22",J6="_envDotGray_1e1r5_26",Mo={envRow:G6,envDot:F6,envDotGreen:Z6,envDotYellow:K6,envDotRed:Y6,envDotGray:J6};function W6(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?Mo.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?Mo.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?Mo.envDotRed:Mo.envDotGray}function X6(t){const{value:s,onSave:o,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),y=[...c?[{value:"",label:"None"}]:[],...r.map(k=>({value:k.id,label:k.displayName}))],S=()=>{if(b)return i.jsxs("span",{className:Mo.envRow,children:[i.jsx("span",{className:`${Mo.envDot} ${W6(b.status)}`}),b.displayName]})};return i.jsx(Uo,{value:s,onSave:o,options:y,fieldId:d,activeFieldId:u,onActivate:p,renderDisplay:S,placeholder:m,ariaLabel:g,"data-testid":v})}const Q6="_nav_1snmp_1",eI="_searchForm_1snmp_8",tI="_searchInput_1snmp_15",nI="_searchButton_1snmp_33",sI="_clearButton_1snmp_68",aI="_workspaceSelect_1snmp_85",iI="_listHeader_1snmp_99",oI="_nodeList_1snmp_108",rI="_nodeItem_1snmp_116",lI="_indicator_1snmp_129",cI="_label_1snmp_136",dI="_badge_1snmp_145",Wn={nav:Q6,searchForm:eI,searchInput:tI,searchButton:nI,clearButton:sI,workspaceSelect:aI,listHeader:iI,nodeList:oI,nodeItem:rI,indicator:lI,label:cI,badge:dI};function uI({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=x.useState(""),v=x.useCallback(k=>{k.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=x.useCallback(()=>{g(""),d()},[d]),y=x.useCallback(k=>{u(k)},[u]),S=x.useCallback(k=>{g(""),p(k)},[p]);return i.jsxs("div",{className:Wn.nav,"data-testid":"knowledge-nav",children:[i.jsxs("form",{className:Wn.searchForm,onSubmit:v,children:[i.jsx("input",{className:Wn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:k=>{g(k.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),i.jsx("button",{type:"submit",className:Wn.searchButton,disabled:o,children:"Go"})]}),r&&i.jsx("button",{type:"button",className:Wn.clearButton,onClick:b,children:"Clear search"}),i.jsxs("select",{className:Wn.workspaceSelect,onChange:k=>{S(k.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[i.jsx("option",{value:"",children:"All workspaces"}),s.map(k=>i.jsx("option",{value:k.id,children:k.name},k.id))]}),i.jsxs("div",{className:Wn.listHeader,children:["Nodes (",t.length,")"]}),i.jsx("ul",{className:Wn.nodeList,children:t.map(k=>i.jsxs("li",{className:Wn.nodeItem,onClick:()=>{y(k.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),y(k.id))},role:"button",tabIndex:0,children:[i.jsx("span",{className:Wn.indicator,style:{backgroundColor:k.kind==="reference"?"#4A9EFF":k.category==="decision"?"#22C55E":k.category==="concept"?"#A855F7":k.category==="snippet"?"#6B7280":"#EAB308"}}),i.jsx("span",{className:Wn.label,children:k.label}),i.jsx("span",{className:Wn.badge,children:k.kind==="reference"?k.sourceType:k.category})]},k.id))})]})}const fI="_container_1mq5u_1",pI="_hamburger_1mq5u_33",mI="_brand_1mq5u_49",hI="_brandLogo_1mq5u_68",gI="_info_1mq5u_75",vI="_connectionLabel_1mq5u_90",yI="_connectionDot_1mq5u_103",bI="_connected_1mq5u_106",xI="_disconnected_1mq5u_110",Ws={container:fI,hamburger:pI,brand:mI,brandLogo:hI,info:gI,connectionLabel:vI,connectionDot:yI,connected:bI,disconnected:xI};function _I({connected:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=mt(),u=s.length,p=s.filter(g=>g.status==="connected").length,m=o.filter(g=>["running","idle"].includes(g.status)).length;return i.jsxs("div",{className:Ws.container,children:[r&&i.jsx("button",{type:"button",className:Ws.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:i.jsx(Q2,{size:Rt,"aria-hidden":"true"})}),i.jsx($o,{text:"Home",placement:"bottom",children:i.jsxs("button",{type:"button",className:Ws.brand,onClick:()=>d(Di),"data-testid":"statusbar-brand",children:[i.jsx("img",{src:"/icon-192x192.png",alt:"",className:Ws.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),i.jsxs("div",{className:Ws.info,children:[i.jsxs("span",{"aria-label":t?"Connected":"Disconnected",children:[i.jsx("span",{className:`${Ws.connectionDot} ${t?Ws.connected:Ws.disconnected}`,"aria-hidden":"true",children:i.jsx(Va,{size:bm,fill:"currentColor"})})," ",i.jsx("span",{className:Ws.connectionLabel,"aria-hidden":"true",children:t?"Connected":"Disconnected"})]}),i.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),i.jsxs("span",{children:[m," active"]})]})]})}const kI="_nav_13gkc_1",SI="_tab_13gkc_35",TI="_tabIcon_13gkc_68",jI="_tabLabel_13gkc_79",wI="_tabActive_13gkc_84",Vr={nav:kI,tab:SI,tabIcon:TI,tabLabel:jI,tabActive:wI},id=[{view:"dashboard",label:"Dashboard",icon:i.jsx(U2,{size:Rt}),route:Di,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:i.jsx(tj,{size:Rt}),route:TN,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:i.jsx(N2,{size:Rt}),route:jN,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:i.jsx(sj,{size:Rt}),route:Io,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:i.jsx(b2,{size:Rt}),route:Xx,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:i.jsx(Ex,{size:Rt}),route:Dd,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:i.jsx(fj,{size:Rt}),route:bN,testId:"sidebar-tab-settings"}];function NI(t){return t===Di||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(Xx)?"knowledge":t.startsWith(Dd)?"findings":t.startsWith(Ni)?"settings":"tasks"}function CI({tabs:t=id}){const s=Yt(),o=mt(),r=x.useRef(null),c=NI(s.pathname),d=x.useCallback(p=>{o(p.route)},[o]),u=x.useCallback(p=>{var y,S;const m=(y=r.current)==null?void 0:y.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(k=>k===document.activeElement),v=g>=0?g:t.findIndex(k=>k.view===c);let b=v;if(p.key==="ArrowRight"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%t.length;else if(p.key==="ArrowLeft"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+t.length)%t.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=t.length-1;else return;o(t[b].route),(S=m[b])==null||S.focus()},[c,o,t]);return i.jsx("nav",{className:Vr.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:u,"data-testid":"sidebar-nav",children:t.map(p=>{const m=p.view===c;return i.jsx($o,{text:p.label,placement:"bottom",children:i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Vr.tab} ${m?Vr.tabActive:""}`,onClick:()=>d(p),"data-testid":p.testId,"aria-label":p.label,children:[i.jsx("span",{className:Vr.tabIcon,"aria-hidden":"true",children:p.icon}),i.jsx("span",{className:Vr.tabLabel,children:p.label})]})},p.view)})})}const EI="_container_pi6ii_1",AI="_content_pi6ii_66",Xb={container:EI,content:AI},DI=320,M1=220,I1=600,O1="grackle-sidebar-width";function RI(){try{const t=localStorage.getItem(O1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=M1&&s<=I1)return s}}catch{}return DI}function MI(t){try{localStorage.setItem(O1,String(t))}catch{}}function II({content:t}){const[s]=x.useState(RI),o=x.useRef(null);if(x.useEffect(()=>{const r=o.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>=M1&&m<=I1&&MI(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return i.jsx("div",{className:Xb.container,ref:o,"data-testid":"sidebar",style:{width:s},children:i.jsx("div",{className:Xb.content,children:t})})}const OI="_bar_tnfsh_1",BI="_btnPrimary_tnfsh_32",LI="_statusText_tnfsh_85",zI="_statusCompleted_tnfsh_90",$I="_statusFailed_tnfsh_94",UI="_statusBlocked_tnfsh_98",PI="_hintText_tnfsh_103",jt={bar:OI,btnPrimary:BI,statusText:LI,statusCompleted:zI,statusFailed:$I,statusBlocked:UI,hintText:PI};function HI({sessions:t,tasks:s,environments:o}){const r=mt(),c=Yt(),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"),y=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),S=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),k=At("/sessions/new"),j=At("/environments/:environmentId/workspaces/:workspaceId"),N=At("/tasks/new"),T=At("/chat"),C=At("/"),A=At("/settings/*"),I=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)??(y==null?void 0:y.params.taskId)??(S==null?void 0:S.params.taskId),D=v??b??y??S,P=(D==null?void 0:D.params.environmentId)??(j==null?void 0:j.params.environmentId),O=c.pathname.startsWith("/environments")&&!j&&!D,z=!!T,Q=!!k,$=!!j&&!v&&!b&&!y&&!S,J=!!N;if(!!C&&!Q&&!$&&!J||!!A||(!!g||!!S)||J||O||Q)return i.jsx(i.Fragment,{});if(z)return o.find(F=>F.adapterType==="local"&&F.status==="connected")?i.jsx(i.Fragment,{}):i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Add a local environment to start chatting"})});if($)return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Select a task or click + to create one"})});if(E){const B=s.find(de=>de.id===E);if(!B)return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Loading..."})});const F=new Map(s.map(de=>[de.id,de])),Z=B.dependsOn.some(de=>{const W=F.get(de);return W!==void 0&&W.status!=="complete"});if(B.status==="not_started"){const de=Z?B.dependsOn.map(W=>F.get(W)).filter(W=>W&&W.status!=="complete").map(W=>W.title):[];return i.jsx("div",{className:jt.bar,children:Z?i.jsxs("span",{className:jt.statusBlocked,children:["Blocked by: ",de.join(", ")]}):i.jsx("span",{className:jt.hintText,children:"Use the buttons above to start or manage this task"})})}if(B.status==="working"||B.status==="paused"){const de=B.latestSessionId||void 0,W=de?t.find(ue=>ue.id===de):void 0;return W&&W.status!=="stopped"?i.jsx(i.Fragment,{}):i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Waiting for agent..."})})}if(B.status==="complete")return i.jsxs("div",{className:jt.bar,children:[i.jsx("span",{className:`${jt.statusText} ${jt.statusCompleted}`,children:"Task completed"}),i.jsx("button",{onClick:()=>r(Ii(B.workspaceId,void 0,P)),className:jt.btnPrimary,children:"+ New Task"})]});if(B.status==="failed")return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:`${jt.statusText} ${jt.statusFailed}`,children:"Task failed"})})}if(I){const B=t.find(de=>de.id===I),F=(B==null?void 0:B.status)==="stopped";if(B!==void 0&&!F)return i.jsx(i.Fragment,{});if(F)return i.jsxs("div",{className:jt.bar,children:[i.jsxs("span",{className:`${jt.statusText} ${jt.hintText}`,children:["Session ",B.endReason||B.status]}),i.jsx("button",{onClick:()=>r(Kx(B.environmentId)),className:jt.btnPrimary,children:"+ New Chat"})]})}return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Loading..."})})}const VI="_nav_14i94_1",qI="_tab_14i94_24",GI="_tabActive_14i94_62",FI="_tabLabel_14i94_75",ZI="_statusDot_14i94_81",KI="_pulse_14i94_87",YI="_addButton_14i94_99",JI="_empty_14i94_132",Ba={nav:VI,tab:qI,tabActive:GI,tabLabel:FI,statusDot:ZI,pulse:KI,addButton:YI,empty:JI},WI={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function XI({environments:t}){const s=mt(),o=x.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=x.useCallback(y=>{s(Ai(y))},[s]),v=x.useCallback(y=>{var T;const S=(T=o.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),j=k>=0?k:t.findIndex(C=>C.id===m);let N=j;if(y.key==="ArrowDown"||y.key==="j"||y.key==="J")y.preventDefault(),N=(j+1)%S.length;else if(y.key==="ArrowUp"||y.key==="k"||y.key==="K")y.preventDefault(),N=(j-1+S.length)%S.length;else if(y.key==="Home")y.preventDefault(),N=0;else if(y.key==="End")y.preventDefault(),N=S.length-1;else return;N<t.length&&s(Ai(t[N].id)),S[N].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:Ba.nav,"data-testid":"environment-nav",children:[i.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(y=>{const S=y.id===m,k=y.id===b,j=WI[y.status]||"var(--text-tertiary)",N=y.status==="connected";return i.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${Ba.tab} ${S?Ba.tabActive:""}`,onClick:()=>g(y.id),"data-testid":"env-nav-item",children:[i.jsx("span",{className:`${Ba.statusDot} ${N?Ba.pulse:""}`,style:{color:j},"aria-hidden":"true",children:i.jsx(Va,{size:bm,fill:"currentColor"})}),i.jsx("span",{className:Ba.tabLabel,title:y.displayName||y.id,children:y.displayName||y.id})]},y.id)})}),i.jsx("button",{type:"button",className:Ba.addButton,onClick:()=>s(vN),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&i.jsx("div",{className:Ba.empty,children:"No environments yet."})]})}function Po(t){const s=new Date(t),o=new Date,r=o.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()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}function B1(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return"—";const o=new Date,r=s.getTime()-o.getTime();if(r<=0)return"overdue";const c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return`in ${c}s`;if(d<60)return`in ${d}m`;if(u<24)return`in ${u}h`;if(p<7)return`in ${p} day${p===1?"":"s"}`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const Qb={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 xd(t){return Qb[t]||Qb.general}const QI="_nav_dlm8m_1",e5="_categoryPills_dlm8m_24",t5="_categoryPill_dlm8m_24",n5="_tab_dlm8m_42",s5="_tabActive_dlm8m_80",a5="_tabContent_dlm8m_93",i5="_tabLabel_dlm8m_100",o5="_tabMeta_dlm8m_106",r5="_categoryDot_dlm8m_111",l5="_empty_dlm8m_118",js={nav:QI,categoryPills:e5,categoryPill:t5,tab:n5,tabActive:s5,tabContent:a5,tabLabel:i5,tabMeta:o5,categoryDot:r5,empty:l5};function c5({findings:t,workspaceId:s,environmentId:o}){const r=mt(),c=x.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=x.useMemo(()=>{const y=new Set(t.map(S=>S.category).filter(Boolean));return Array.from(y).sort()},[t]),g=x.useCallback(y=>{r(Gp(y,s,o))},[r,s,o]),v=x.useCallback(y=>{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),j=k>=0?k:t.findIndex(C=>C.id===p);let N=j;if(y.key==="ArrowDown"||y.key==="j"||y.key==="J")y.preventDefault(),N=(j+1)%S.length;else if(y.key==="ArrowUp"||y.key==="k"||y.key==="K")y.preventDefault(),N=(j-1+S.length)%S.length;else if(y.key==="Home")y.preventDefault(),N=0;else if(y.key==="End")y.preventDefault(),N=S.length-1;else return;N<t.length&&r(Gp(t[N].id,s,o)),S[N].focus()},[p,t,r,s,o]),b=p??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:js.nav,"data-testid":"findings-nav",children:[m.length>1&&i.jsx("div",{className:js.categoryPills,"data-testid":"findings-nav-categories",children:m.map(y=>i.jsx("span",{className:js.categoryPill,style:{color:xd(y).text},children:y},y))}),i.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(y=>{const S=y.id===p,k=y.id===b;return i.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${js.tab} ${S?js.tabActive:""}`,onClick:()=>g(y.id),"data-testid":"finding-nav-item",children:[i.jsx("span",{className:js.categoryDot,style:{color:xd(y.category).text},"aria-hidden":"true",children:i.jsx(Va,{size:bm,fill:"currentColor"})}),i.jsxs("span",{className:js.tabContent,children:[i.jsx("span",{className:js.tabLabel,title:y.title,children:y.title}),i.jsx("span",{className:js.tabMeta,title:y.createdAt,children:Po(y.createdAt)})]})]},y.id)})}),t.length===0&&i.jsx("div",{className:js.empty,children:"No findings yet. Agents will post discoveries here."})]})}function d5(t){if(t.length===0)return[];const s=[...t].sort((r,c)=>r[0]-c[0]),o=[[s[0][0],s[0][1]]];for(let r=1;r<s.length;r++){const c=o[o.length-1],[d,u]=s[r];d<=c[1]+1?c[1]=Math.max(c[1],u):o.push([d,u])}return o}function L1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return i.jsx(i.Fragment,{children:t});const r=d5(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(i.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(i.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(i.jsx("span",{children:t.slice(d)},`p${d}`)),i.jsx(i.Fragment,{children:c})}function u5(t){const s=new Map(t.map(r=>[r.id,{...r,children:[]}])),o=[];for(const r of s.values())r.parentTaskId&&s.has(r.parentTaskId)?s.get(r.parentTaskId).children.push(r):o.push(r);for(const r of s.values())r.children.sort((c,d)=>c.sortOrder-d.sortOrder);return o.sort((r,c)=>r.sortOrder-c.sortOrder)}function f5(t,s){const o=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=o.get(p);m?m.push(d):o.set(p,[d])}const r=[],c=new Set;for(const d of _j){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=qa(d);r.push({status:d,label:p.label,style:p,tasks:u})}}for(const[d,u]of o)if(!c.has(d)&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=qa(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const p5="_container_z4i38_1",m5="_header_z4i38_5",h5="_headerActions_z4i38_17",g5="_searchInput_z4i38_23",v5="_searchHighlight_z4i38_56",y5="_groupToggle_z4i38_62",b5="_groupToggleActive_z4i38_89",x5="_addButton_z4i38_93",_5="_taskRow_z4i38_120",k5="_selected_z4i38_140",S5="_expandArrow_z4i38_150",T5="_expanded_z4i38_157",j5="_leafSpacer_z4i38_161",w5="_taskStatusIcon_z4i38_166",N5="_taskTitle_z4i38_170",C5="_workspaceBadge_z4i38_177",E5="_childCountBadge_z4i38_195",A5="_dependencyBadge_z4i38_208",D5="_blockedBadge_z4i38_220",R5="_addChildButton_z4i38_225",M5="_emptyState_z4i38_268",I5="_statusGroupHeader_z4i38_275",O5="_statusGroupIcon_z4i38_294",B5="_statusGroupLabel_z4i38_298",L5="_statusGroupCount_z4i38_303",Fe={container:p5,header:m5,headerActions:h5,searchInput:g5,searchHighlight:v5,groupToggle:y5,groupToggleActive:b5,addButton:x5,taskRow:_5,selected:k5,expandArrow:S5,expanded:T5,leafSpacer:j5,taskStatusIcon:w5,taskTitle:N5,workspaceBadge:C5,childCountBadge:E5,dependencyBadge:A5,blockedBadge:D5,addChildButton:R5,emptyState:M5,statusGroupHeader:I5,statusGroupIcon:O5,statusGroupLabel:B5,statusGroupCount:L5},z5=[{name:"title",weight:2},{name:"description",weight:1}],z1=16,$5=16,$1="grackle-task-group-by-status";function ex(){try{return localStorage.getItem($1)==="true"}catch{return!1}}function U5(t){try{localStorage.setItem($1,String(t))}catch{}}function P5({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return i.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[i.jsxs("div",{className:Fe.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[i.jsx("span",{className:`${Fe.expandArrow} ${s?Fe.expanded:""}`,"aria-hidden":"true",children:i.jsx(ra,{size:ct})}),i.jsx("span",{className:Fe.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),i.jsx("span",{className:Fe.statusGroupLabel,children:t.label}),i.jsx("span",{className:Fe.statusGroupCount,children:t.tasks.length})]}),i.jsx(gs,{children:s&&i.jsx(Mt.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=qa(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return i.jsxs("div",{onClick:()=>c(On(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(On(p.id)))},className:`${Fe.taskRow} ${g?Fe.selected:""}`,style:{"--task-indent":`${z1}px`},"data-task-id":p.id,children:[i.jsx("span",{className:Fe.leafSpacer}),i.jsx("span",{className:Fe.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${pl(p.status)}`,children:m.icon}),i.jsx("span",{className:Fe.taskTitle,title:p.title,children:i.jsx(L1,{text:p.title,indices:d.get(p.id),highlightClass:Fe.searchHighlight})}),v&&i.jsx("span",{className:Fe.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function U1({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=qa(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),b=o.has(t.id),y=t.children.length>0,S=c===t.id,k=z1+s*$5,N=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{onClick:()=>d(On(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:T=>{T.currentTarget===T.target&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(On(t.id)))},className:`${Fe.taskRow} ${S?Fe.selected:""}`,style:{"--task-indent":`${k}px`},"data-task-id":t.id,children:[y&&i.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:i.jsx(ra,{size:ct,"aria-hidden":"true"})}),!y&&i.jsx("span",{className:Fe.leafSpacer}),i.jsx("span",{className:Fe.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${pl(t.status)}`,children:g.icon}),i.jsx("span",{className:Fe.taskTitle,title:t.title,children:i.jsx(L1,{text:t.title,indices:p.get(t.id),highlightClass:Fe.searchHighlight})}),N&&i.jsx("span",{className:Fe.workspaceBadge,title:N,children:N}),y&&i.jsxs("span",{className:Fe.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&i.jsx("span",{className:`${Fe.dependencyBadge} ${v?Fe.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<DT&&i.jsx($o,{text:"Add child task",children:i.jsx("button",{onClick:T=>{T.stopPropagation(),d(Ii(t.workspaceId,t.id))},"aria-label":"Add child task",className:Fe.addChildButton,children:"+"})})]}),i.jsx(gs,{children:y&&b&&i.jsx(Mt.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=>i.jsx(U1,{node:T,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function H5({workspaces:t,tasks:s}){const o=mt(),[r,c]=x.useState(new Set),[d,u]=x.useState(new Set),[p,m]=x.useState(ex),[g,v]=x.useState(ex),[b,y]=x.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,j=x.useMemo(()=>new Map(s.map(te=>[te.id,te.status])),[s]),N=x.useMemo(()=>new Map(t.map(te=>[te.id,te.name])),[t]),T=()=>{const te=!p;U5(te),m(te),te&&(v(!0),y(new Map))},C=te=>{y(X=>{const B=new Map(X),F=B.has(te)?B.get(te):g;return B.set(te,!F),B})},A=te=>b.has(te)?b.get(te):g,I=te=>{c(X=>{const B=new Set(X);return B.has(te)?(B.delete(te),u(F=>new Set(F).add(te))):(B.add(te),u(F=>{const Z=new Set(F);return Z.delete(te),Z})),B})};x.useEffect(()=>{const te=new Set(s.filter(X=>X.parentTaskId).map(X=>X.parentTaskId));te.size>0&&c(X=>{const B=new Set(X);for(const F of te)d.has(F)||B.add(F);return B})},[s,d]);const[E,D]=x.useState(""),{directMatchTaskIds:P,treeMatchTaskIds:O,titleHighlights:z}=x.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const te=AT(s,E,z5),X=new Set(te.map(de=>de.item.id)),B=new Map;for(const de of te){const W=de.matches.find(ee=>ee.key==="title");W&&B.set(de.item.id,W.indices)}const F=new Set(X),Z=new Map(s.map(de=>[de.id,de]));for(const de of[...X]){let W=Z.get(de);for(;W!=null&&W.parentTaskId;)F.add(W.parentTaskId),W=Z.get(W.parentTaskId)}return{directMatchTaskIds:X,treeMatchTaskIds:F,titleHighlights:B}},[E,s]),Q=P!==null,$=Q?p?P:O:null,J=$?s.filter(te=>$.has(te.id)):s,me=p?[]:u5(J);return i.jsxs("div",{className:Fe.container,children:[i.jsxs("div",{className:Fe.header,children:[i.jsx("span",{children:"Tasks"}),i.jsxs("div",{className:Fe.headerActions,children:[i.jsx($o,{text:p?"Switch to tree view":"Group tasks by status",children:i.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:i.jsx(Y2,{size:nn})})}),i.jsx($o,{text:"New task",children:i.jsx("button",{className:Fe.addButton,onClick:()=>o(Ii()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&i.jsx("input",{type:"text",value:E,onChange:te=>D(te.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Fe.searchInput,"data-testid":"sidebar-search"}),p?f5(J,j).map(te=>i.jsx(P5,{group:te,isExpanded:A(te.status),onToggle:()=>C(te.status),selectedTaskId:k,navigate:o,titleHighlights:z,workspaceNames:N},te.status)):me.map(te=>i.jsx(U1,{node:te,depth:0,expandedTasks:r,toggleTask:I,selectedTaskId:k,navigate:o,taskStatusById:j,titleHighlights:z,workspaceNames:N},te.id)),J.length===0&&!Q&&i.jsx("div",{className:Fe.emptyState,children:"No tasks yet. Click + to create one."}),J.length===0&&Q&&i.jsx("div",{className:Fe.emptyState,children:"No matching tasks"})]})}const V5="_toast_ed2dk_1",q5="_success_ed2dk_18",G5="_icon_ed2dk_22",F5="_error_ed2dk_25",Z5="_warning_ed2dk_32",K5="_info_ed2dk_38",Y5="_message_ed2dk_53",J5="_close_ed2dk_60",qr={toast:V5,success:q5,icon:G5,error:F5,warning:Z5,info:K5,message:Y5,close:J5},W5={success:i.jsx(Ri,{size:Rt}),error:i.jsx(Ka,{size:Rt}),warning:i.jsx(ym,{size:Rt}),info:i.jsx(vm,{size:Rt})};function X5({toast:t,onDismiss:s}){return x.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),i.jsxs(Mt.div,{className:`${qr.toast} ${qr[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:[i.jsx("span",{className:qr.icon,"aria-hidden":"true",children:W5[t.variant]}),i.jsx("span",{className:qr.message,children:t.message}),i.jsx("button",{type:"button",className:qr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:i.jsx(Ka,{size:nn,"aria-hidden":"true"})})]})}const Q5="_container_qqse2_1",eO={container:Q5};function tO({toasts:t,onDismiss:s}){return i.jsx("div",{className:eO.container,"data-testid":"toast-container",children:i.jsx(gs,{children:t.map(o=>i.jsx(X5,{toast:o,onDismiss:s},o.id))})})}const nO="_callout_e5awm_1",sO="_success_e5awm_11",aO="_icon_e5awm_15",iO="_error_e5awm_18",oO="_warning_e5awm_25",rO="_info_e5awm_32",lO="_content_e5awm_48",cO="_close_e5awm_53",Gr={callout:nO,success:sO,icon:aO,error:iO,warning:oO,info:rO,content:lO,close:cO},dO={success:i.jsx(Ri,{size:Rt}),error:i.jsx(Ka,{size:Rt}),warning:i.jsx(ym,{size:Rt}),info:i.jsx(vm,{size:Rt})};function uO({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=x.useState(!1);return i.jsx(i.Fragment,{children:!c&&i.jsxs("div",{className:[Gr.callout,Gr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[i.jsx("span",{className:Gr.icon,"aria-hidden":"true",children:dO[t]}),i.jsx("span",{className:Gr.content,children:s}),o&&i.jsx("button",{type:"button",className:Gr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:i.jsx(Ka,{size:nn,"aria-hidden":"true"})})]})})}function fO({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return i.jsx(i.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return i.jsx("div",{"data-testid":"update-banner",children:i.jsxs(uO,{variant:"info",dismissible:!0,children:[i.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",i.jsx("code",{children:c})]})})}const pO="_container_de44x_1",mO="_emptyState_de44x_8",hO="_card_de44x_14",gO="_cardClickable_de44x_34",vO="_cardHeader_de44x_42",yO="_categoryBadge_de44x_54",bO="_findingTitle_de44x_62",xO="_findingDate_de44x_68",_O="_findingContent_de44x_80",kO="_tags_de44x_86",SO="_tag_de44x_86",fs={container:pO,emptyState:mO,card:hO,cardClickable:gO,cardHeader:vO,categoryBadge:yO,findingTitle:bO,findingDate:xO,findingContent:_O,tags:kO,tag:SO};function P1({findings:t,onFindingClick:s}){return t.length===0?i.jsx("div",{className:fs.emptyState,children:"No findings yet. Agents will post discoveries here."}):i.jsx("div",{className:fs.container,children:t.map((o,r)=>{const c=xd(o.category),d=s?Mt.button:Mt.div;return i.jsxs(d,{type:s?"button":void 0,className:`${fs.card} ${s?fs.cardClickable:""}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:r*.05,duration:.2},onClick:s?()=>{s(o.id)}:void 0,children:[i.jsxs("div",{className:fs.cardHeader,children:[i.jsx("span",{className:fs.categoryBadge,style:{background:c.bg,color:c.text},children:o.category}),i.jsx("span",{className:fs.findingTitle,children:o.title}),i.jsx("span",{className:fs.findingDate,title:o.createdAt,children:Po(o.createdAt)})]}),i.jsx("div",{className:fs.findingContent,children:o.content.length>300?o.content.slice(0,300)+"...":o.content}),o.tags.length>0&&i.jsx("div",{className:fs.tags,children:o.tags.map(u=>i.jsx("span",{className:fs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},o.id)})})}const TO="_section_1ingb_14",jO="_sectionTitle_1ingb_26",wO="_sectionDescription_1ingb_35",NO="_tokenList_1ingb_48",CO="_tokenRow_1ingb_55",EO="_tokenBadge_1ingb_68",AO="_tokenName_1ingb_83",DO="_tokenTarget_1ingb_90",RO="_deleteButton_1ingb_99",MO="_addForm_1ingb_113",IO="_formRow_1ingb_119",OO="_input_1ingb_125",BO="_select_1ingb_155",LO="_addButton_1ingb_187",zO="_emptyStateInfo_1ingb_221",$O="_themeOptions_1ingb_229",UO="_themeOption_1ingb_229",PO="_themeOptionSelected_1ingb_254",HO="_themeOptionHeader_1ingb_259",VO="_themeOptionLabel_1ingb_266",qO="_themeOptionDesc_1ingb_273",GO="_variantToggle_1ingb_279",FO="_variantButton_1ingb_286",ZO="_variantActive_1ingb_305",KO="_themeSwatches_1ingb_311",YO="_themeSwatch_1ingb_311",JO="_systemToggle_1ingb_325",WO="_systemToggleHint_1ingb_341",XO="_themeActive_1ingb_348",QO="_aboutGrid_1ingb_354",eB="_aboutItem_1ingb_360",tB="_aboutLabel_1ingb_373",nB="_aboutValue_1ingb_379",sB="_aboutDot_1ingb_387",aB="_aboutDotConnected_1ingb_394",iB="_aboutDotDisconnected_1ingb_398",ye={section:TO,sectionTitle:jO,sectionDescription:wO,tokenList:NO,tokenRow:CO,tokenBadge:EO,tokenName:AO,tokenTarget:DO,deleteButton:RO,addForm:MO,formRow:IO,input:OO,select:BO,addButton:LO,emptyStateInfo:zO,themeOptions:$O,themeOption:UO,themeOptionSelected:PO,themeOptionHeader:HO,themeOptionLabel:VO,themeOptionDesc:qO,variantToggle:GO,variantButton:FO,variantActive:ZO,themeSwatches:KO,themeSwatch:YO,systemToggle:JO,systemToggleHint:WO,themeActive:XO,aboutGrid:QO,aboutItem:eB,aboutLabel:tB,aboutValue:nB,aboutDot:sB,aboutDotConnected:aB,aboutDotDisconnected:iB},oB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function rB({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=x.useState(""),[u,p]=x.useState(""),[m,g]=x.useState("env_var"),[v,b]=x.useState(""),[y,S]=x.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("")},j=T=>{S(T)},N=()=>{y&&(o(y),r==null||r("Token deleted","info")),S(null)};return i.jsxs(i.Fragment,{children:[i.jsx(ia,{isOpen:y!==null,title:"Delete Token?",description:y?`"${y}" will be permanently removed.`:void 0,onConfirm:N,onCancel:()=>S(null)}),i.jsxs("section",{className:ye.section,children:[i.jsx("h3",{className:ye.sectionTitle,children:"Tokens"}),i.jsx("p",{className:ye.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?i.jsx("div",{className:ye.emptyStateInfo,children:"Add your first API token to enable service integrations."}):i.jsx("div",{className:ye.tokenList,children:t.map(T=>i.jsxs("div",{className:ye.tokenRow,children:[i.jsx("span",{className:ye.tokenBadge,children:T.tokenType}),i.jsx("span",{className:ye.tokenName,children:T.name}),i.jsx("span",{className:ye.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),i.jsx("button",{className:ye.deleteButton,onClick:()=>j(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:i.jsx(Ka,{size:nn,"aria-hidden":"true"})})]},T.name))}),i.jsxs("form",{className:ye.addForm,onSubmit:k,children:[i.jsxs("div",{className:ye.formRow,children:[i.jsx("input",{className:ye.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),i.jsx("input",{className:ye.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),i.jsxs("div",{className:ye.formRow,children:[i.jsx("select",{className:ye.select,value:m,onChange:T=>g(T.target.value),children:oB.map(T=>i.jsx("option",{value:T.value,children:T.label},T.value))}),i.jsx("input",{className:ye.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)}),i.jsx("button",{className:ye.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const zd=[{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"]}],H1=new Set(zd.map(t=>t.id)),tx="grackle";function um(t){return zd.find(s=>s.id===t)}function lB({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return i.jsxs("section",{className:ye.section,children:[i.jsx("h3",{className:ye.sectionTitle,children:"Appearance"}),i.jsx("p",{className:ye.sectionDescription,children:"Choose how Grackle looks across the app."}),i.jsx("div",{className:ye.themeOptions,children:zd.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 i.jsxs("button",{type:"button",className:`${ye.themeOption} ${p?ye.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[i.jsxs("span",{className:ye.themeOptionHeader,children:[i.jsxs("span",{children:[i.jsx("span",{className:ye.themeOptionLabel,children:d.label}),i.jsx("span",{className:ye.themeOptionDesc,children:d.description})]}),u&&i.jsxs("span",{className:ye.variantToggle,children:[i.jsx("span",{role:"button",tabIndex:0,className:`${ye.variantButton} ${p&&m?ye.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),i.jsx("span",{role:"button",tabIndex:0,className:`${ye.variantButton} ${p&&!m?ye.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&i.jsx("span",{className:ye.themeSwatches,children:d.swatches.map((g,v)=>i.jsx("span",{className:ye.themeSwatch,style:{background:g}},v))})]},d.id)})}),i.jsxs("label",{className:ye.systemToggle,children:[i.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),i.jsx("span",{children:"Match system light/dark preference"})]}),i.jsx("p",{className:ye.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),i.jsxs("p",{className:ye.themeActive,children:["Active theme: ",i.jsx("strong",{children:s})]})]})}function cB({connected:t,environments:s,sessions:o}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=o.filter(u=>["running","idle"].includes(u.status)).length;return i.jsxs("section",{className:ye.section,"data-testid":"about-panel",children:[i.jsx("h3",{className:ye.sectionTitle,children:"About"}),i.jsx("p",{className:ye.sectionDescription,children:"Connection status and application information."}),i.jsxs("div",{className:ye.aboutGrid,children:[i.jsxs("div",{className:ye.aboutItem,children:[i.jsx("span",{className:ye.aboutLabel,children:"Connection"}),i.jsxs("span",{className:ye.aboutValue,children:[i.jsx("span",{className:`${ye.aboutDot} ${t?ye.aboutDotConnected:ye.aboutDotDisconnected}`}),t?"Connected":"Disconnected"]})]}),i.jsxs("div",{className:ye.aboutItem,children:[i.jsx("span",{className:ye.aboutLabel,children:"Environments"}),i.jsxs("span",{className:ye.aboutValue,children:[r,"/",c," connected"]})]}),i.jsxs("div",{className:ye.aboutItem,children:[i.jsx("span",{className:ye.aboutLabel,children:"Active Sessions"}),i.jsx("span",{className:ye.aboutValue,children:d})]}),i.jsxs("div",{className:ye.aboutItem,children:[i.jsx("span",{className:ye.aboutLabel,children:"Version"}),i.jsx("span",{className:ye.aboutValue,children:"0.102.0"})]})]})]})}const dB="_container_cddyd_1",uB="_header_cddyd_8",fB="_headerTitle_cddyd_35",pB="_badge_cddyd_44",mB="_headerActions_cddyd_54",hB="_body_cddyd_61",gB="_formContent_cddyd_73",vB="_section_cddyd_85",yB="_label_cddyd_91",bB="_titleInput_cddyd_98",xB="_descriptionTextarea_cddyd_131",_B="_parentContext_cddyd_167",kB="_parentLabel_cddyd_175",SB="_parentName_cddyd_182",TB="_personaSelect_cddyd_186",jB="_depList_cddyd_220",wB="_depItem_cddyd_226",NB="_depItemSelected_cddyd_248",CB="_noDeps_cddyd_252",EB="_btnPrimary_cddyd_258",AB="_btnGhost_cddyd_289",nt={container:dB,header:uB,headerTitle:fB,badge:pB,headerActions:mB,body:hB,formContent:gB,section:vB,label:yB,titleInput:bB,descriptionTextarea:xB,parentContext:_B,parentLabel:kB,parentName:SB,personaSelect:TB,depList:jB,depItem:wB,depItemSelected:NB,noDeps:CB,btnPrimary:EB,btnGhost:AB};function V1({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:b}){const y=mt(),S=t==="edit",k=S&&s?d.find(xe=>xe.id===s):void 0,j=S?(k==null?void 0:k.workspaceId)??"":o??"",[N,T]=x.useState(j),C=j||N,A=u.find(xe=>xe.id===C),I=c??(A==null?void 0:A.environmentId),E=!S&&!o,D=S?(k==null?void 0:k.parentTaskId)??"":r??"",P=D?d.find(xe=>xe.id===D):void 0,[O,z]=x.useState((k==null?void 0:k.title)??""),[Q,$]=x.useState((k==null?void 0:k.description)??""),[J,me]=x.useState((k==null?void 0:k.dependsOn)??[]),[te,X]=x.useState((k==null?void 0:k.defaultPersonaId)??""),[B,F]=x.useState((k==null?void 0:k.canDecompose)??!1),[Z,de]=x.useState(!1),W=x.useRef(!1);x.useEffect(()=>{S&&k&&!W.current&&(W.current=!0,z(k.title),$(k.description),me(k.dependsOn),X(k.defaultPersonaId),F(k.canDecompose))},[S,k]);const ee=d.filter(xe=>xe.workspaceId===C&&(!S||xe.id!==s)&&xe.id!==D),ue=O.trim().length>0&&(!S||k!==void 0)&&C.length>0,Ce=xe=>{me(Be=>Be.includes(xe)?Be.filter(It=>It!==xe):[...Be,xe])},Pe=()=>{!ue||Z||S&&k===void 0||(S&&s?(g(s,O.trim(),Q,J,te),b==null||b("Task updated","success"),v?v():y(On(s,void 0,C,I),{replace:!0})):(de(!0),m(C,O.trim(),Q,J.length>0?J:void 0,D||void 0,te,B,()=>{b==null||b("Task created","success"),y(o?Ga(o,I):"/tasks",{replace:!0})},xe=>{b==null||b(xe,"error"),de(!1)})))},ge=()=>{if(v){v();return}y(S&&s?On(s,void 0,C,I):o?Ga(o,I):"/tasks")},Se=S?"edit task":D?"child task":"new task";return i.jsxs("div",{className:nt.container,children:[i.jsxs("div",{className:nt.header,children:[i.jsxs("div",{className:nt.headerTitle,children:[i.jsx("span",{className:nt.badge,children:Se}),P&&i.jsxs("span",{className:nt.parentContext,children:[i.jsx("span",{className:nt.parentLabel,children:"Child of"}),i.jsx("span",{className:nt.parentName,children:P.title})]})]}),i.jsxs("div",{className:nt.headerActions,children:[i.jsx("button",{onClick:Pe,disabled:!ue||Z,className:nt.btnPrimary,"data-testid":"task-edit-save",children:Z?"Creating…":S?"Save Changes":"Create"}),i.jsx("button",{onClick:ge,className:nt.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:nt.body,children:i.jsxs("div",{className:nt.formContent,children:[E&&i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-workspace",children:"Workspace"}),i.jsxs("select",{id:"task-edit-workspace",value:N,onChange:xe=>T(xe.target.value),className:nt.personaSelect,"data-testid":"task-edit-workspace",children:[i.jsx("option",{value:"",children:"Select a workspace..."}),u.map(xe=>i.jsx("option",{value:xe.id,children:xe.name},xe.id))]})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-title",children:"Title"}),i.jsx("input",{id:"task-edit-title",type:"text",value:O,onChange:xe=>z(xe.target.value),placeholder:"Task title...",autoFocus:!0,className:nt.titleInput,"data-testid":"task-edit-title",onKeyDown:xe=>{xe.key==="Enter"&&ue&&Pe()}})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-description",children:"Description"}),i.jsx("textarea",{id:"task-edit-description",value:Q,onChange:xe=>$(xe.target.value),placeholder:"Describe the task... (markdown supported)",className:nt.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-persona",children:"Default Persona"}),i.jsxs("select",{id:"task-edit-persona",value:te,onChange:xe=>X(xe.target.value),className:nt.personaSelect,"data-testid":"task-edit-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),p.map(xe=>i.jsx("option",{value:xe.id,children:xe.name},xe.id))]})]}),!S&&i.jsx("div",{className:nt.section,children:i.jsxs("label",{className:nt.depItem,"data-testid":"task-edit-can-decompose",children:[i.jsx("input",{type:"checkbox",checked:B,onChange:xe=>F(xe.target.checked)}),"Can spawn subtasks"]})}),i.jsxs("div",{className:nt.section,children:[i.jsx("div",{className:nt.label,children:"Dependencies"}),ee.length===0?i.jsx("div",{className:nt.noDeps,children:"No other tasks in this workspace"}):i.jsx("div",{className:nt.depList,children:ee.map(xe=>{const Be=J.includes(xe.id);return i.jsxs("label",{className:`${nt.depItem} ${Be?nt.depItemSelected:""}`,"data-testid":`dep-option-${xe.id}`,children:[i.jsx("input",{type:"checkbox",checked:Be,onChange:()=>Ce(xe.id)}),xe.title,i.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",xe.status,")"]})]},xe.id)})})]})]})})]})}const DB="_actionButtons_1rjka_1",RB="_btnPrimary_1rjka_8",MB="_btnDanger_1rjka_39",IB="_btnGhost_1rjka_78",Kt={actionButtons:DB,btnPrimary:RB,btnDanger:MB,btnGhost:IB};function OB({task:t,sessionId:s,isBlocked:o,onStart:r,onResume:c,onStop:d,onPause:u,onDelete:p,onEdit:m}){if(t.status==="not_started")return o?i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:m,className:Kt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Kt.btnPrimary,children:"Start"}),i.jsx("button",{onClick:m,className:Kt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Kt.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:u,disabled:!s,className:Kt.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Kt.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:c,className:Kt.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return i.jsx("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:r,className:Kt.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const BB="_workpadSection_y8nj9_1",LB="_workpadLabel_y8nj9_9",zB="_workpadStatus_y8nj9_17",$B="_workpadSummary_y8nj9_23",UB="_workpadExtra_y8nj9_29",La={workpadSection:BB,workpadLabel:LB,workpadStatus:zB,workpadSummary:$B,workpadExtra:UB};function PB({workpad:t}){if(!t)return;let s;try{const o=JSON.parse(t);if(o==null||typeof o!="object"||Array.isArray(o))return;s=o}catch{return i.jsxs("div",{className:La.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:La.workpadLabel,children:"Workpad"}),i.jsx("div",{className:La.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return i.jsxs("div",{className:La.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:La.workpadLabel,children:"Workpad"}),s.status&&i.jsx("div",{className:La.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&i.jsx("div",{className:La.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&i.jsx("div",{className:La.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const HB="_overviewDashboard_r05qm_1",VB="_overviewHero_r05qm_7",qB="_statusBadge_r05qm_14",GB="_statusPending_r05qm_26",FB="_statusAssigned_r05qm_31",ZB="_statusInProgress_r05qm_36",KB="_statusReview_r05qm_41",YB="_statusDone_r05qm_46",JB="_statusFailed_r05qm_51",WB="_statusWaitingInput_r05qm_56",XB="_overviewBranchPill_r05qm_61",QB="_branchLink_r05qm_76",eL="_overviewSection_r05qm_87",tL="_overviewLabel_r05qm_93",nL="_overviewValue_r05qm_100",sL="_overviewMuted_r05qm_105",aL="_overviewMarkdown_r05qm_111",iL="_envRow_r05qm_180",oL="_envDot_r05qm_186",rL="_envDotGreen_r05qm_193",lL="_envDotYellow_r05qm_197",cL="_envDotRed_r05qm_201",dL="_envDotGray_r05qm_205",uL="_depList_r05qm_209",fL="_depItem_r05qm_215",pL="_depBlocked_r05qm_222",mL="_depDone_r05qm_226",hL="_timeline_r05qm_230",gL="_timelineRow_r05qm_236",vL="_timelineKey_r05qm_243",yL="_timelineValue_r05qm_249",bL="_timelineDelta_r05qm_253",xL="_reviewNotes_r05qm_264",ve={overviewDashboard:HB,overviewHero:VB,statusBadge:qB,statusPending:GB,statusAssigned:FB,statusInProgress:ZB,statusReview:KB,statusDone:YB,statusFailed:JB,statusWaitingInput:WB,overviewBranchPill:XB,branchLink:QB,overviewSection:eL,overviewLabel:tL,overviewValue:nL,overviewMuted:sL,overviewMarkdown:aL,envRow:iL,envDot:oL,envDotGreen:rL,envDotYellow:lL,envDotRed:cL,envDotGray:dL,depList:uL,depItem:fL,depBlocked:pL,depDone:mL,timeline:hL,timelineRow:gL,timelineKey:vL,timelineValue:yL,timelineDelta:bL,reviewNotes:xL};function Fc(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 Ep(t,s){if(!t||!s)return;const o=new Date(s).getTime()-new Date(t).getTime();if(isNaN(o)||o<0)return;const r=Math.floor(o/6e4),c=Math.floor(o%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 nx(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?ve.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?ve.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?ve.envDotRed:ve.envDotGray}function _L({status:t}){const s=qa(t),o=xj(t);return i.jsx("span",{className:`${ve.statusBadge} ${ve[o]??ve.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function kL({task:t,tasksById:s,environments:o,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?o.find(k=>k.id===g):void 0,b=r.find(k=>k.id===t.workspaceId),y=o.find(k=>k.id===d),S=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return i.jsxs("div",{className:ve.overviewDashboard,"data-testid":"task-overview-panel",children:[i.jsxs("div",{className:ve.overviewHero,children:[i.jsx(_L,{status:t.status}),t.branch&&i.jsx("span",{className:ve.overviewBranchPill,"data-testid":"task-overview-branch",children:S?i.jsxs("a",{href:S,target:"_blank",rel:"noreferrer noopener",className:ve.branchLink,children:["🔗"," ",t.branch]}):i.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-description",children:[i.jsx("div",{className:ve.overviewLabel,children:"Description"}),i.jsx("div",{className:ve.overviewMarkdown,children:i.jsx(Td,{remarkPlugins:[jd],children:t.description})})]}),t.workpad&&i.jsx(PB,{workpad:t.workpad}),i.jsxs("div",{className:ve.overviewSection,children:[i.jsx("div",{className:ve.overviewLabel,children:"Environment"}),g&&v?i.jsxs("div",{className:ve.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${ve.envDot} ${nx(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),i.jsx("span",{className:ve.overviewValue,children:v.displayName})]}):y?i.jsxs("div",{className:ve.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${ve.envDot} ${nx(y.status)}`,title:y.status,"aria-label":`Status: ${y.status}`,role:"img"}),i.jsx("span",{className:ve.overviewValue,children:y.displayName}),i.jsx("span",{className:ve.overviewMuted,children:"(workspace default)"})]}):i.jsx("div",{className:ve.overviewMuted,children:"Set in workspace settings"})]}),i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-dependencies",children:[i.jsx("div",{className:ve.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?i.jsx("div",{className:ve.overviewMuted,children:"None"}):i.jsx("div",{className:ve.depList,children:t.dependsOn.map(k=>{const j=s.get(k),N=(j==null?void 0:j.status)==="complete";return i.jsxs("div",{className:`${ve.depItem} ${N?ve.depDone:ve.depBlocked}`,children:[i.jsx("span",{children:N?"✓":"○"}),i.jsx("span",{children:(j==null?void 0:j.title)??k})]},k)})})]}),i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-timeline",children:[i.jsx("div",{className:ve.overviewLabel,children:"Timeline"}),i.jsxs("div",{className:ve.timeline,children:[t.createdAt&&i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Created"}),i.jsx("span",{className:ve.timelineValue,children:Fc(t.createdAt)})]}),t.assignedAt&&(()=>{const k=Ep(t.createdAt,t.assignedAt);return i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Assigned"}),i.jsx("span",{className:ve.timelineValue,children:Fc(t.assignedAt)}),k!==void 0&&i.jsx("span",{className:ve.timelineDelta,children:k})]})})(),t.startedAt&&(()=>{const k=Ep(t.assignedAt??t.createdAt,t.startedAt);return i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Started"}),i.jsx("span",{className:ve.timelineValue,children:Fc(t.startedAt)}),k!==void 0&&i.jsx("span",{className:ve.timelineDelta,children:k})]})})(),t.completedAt&&(()=>{const k=Ep(t.startedAt,t.completedAt);return i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Completed"}),i.jsx("span",{className:ve.timelineValue,children:Fc(t.completedAt)}),k!==void 0&&i.jsx("span",{className:ve.timelineDelta,children:k})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&i.jsx("div",{className:ve.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-usage",children:[i.jsx("div",{className:ve.overviewLabel,children:"Usage"}),i.jsxs("div",{className:ve.timeline,children:[i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Cost"}),i.jsx("span",{className:ve.timelineValue,children:Ns(u.costMillicents)}),i.jsxs("span",{className:ve.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Total (incl. subtasks)"}),i.jsx("span",{className:ve.timelineValue,children:Ns(p.costMillicents)}),i.jsxs("span",{className:ve.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-budget",children:[i.jsx("div",{className:ve.overviewLabel,children:"Budget"}),i.jsxs("div",{className:ve.timeline,children:[t.tokenBudget>0&&i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Tokens"}),i.jsxs("span",{className:ve.timelineValue,children:[Oo(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",Oo(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&i.jsxs("div",{className:ve.timelineRow,children:[i.jsx("span",{className:ve.timelineKey,children:"Cost"}),i.jsxs("span",{className:ve.timelineValue,children:[Ns((u==null?void 0:u.costMillicents)??0)," / ",Ns(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&i.jsxs("div",{className:ve.overviewSection,"data-testid":"task-overview-review-notes",children:[i.jsx("div",{className:ve.overviewLabel,children:"Review Notes"}),i.jsx("div",{className:ve.reviewNotes,children:t.reviewNotes})]})]})}const SL="_container_legrg_1",TL="_header_legrg_8",jL="_headerTitle_legrg_35",wL="_badge_legrg_44",NL="_headerActions_legrg_54",CL="_body_legrg_61",EL="_formContent_legrg_73",AL="_section_legrg_85",DL="_label_legrg_91",RL="_nameInput_legrg_98",ML="_fieldInput_legrg_131",IL="_adapterSelect_legrg_164",OL="_readOnlyValue_legrg_198",BL="_codespaceSection_legrg_204",LL="_codespaceActions_legrg_210",zL="_creatingHint_legrg_216",$L="_errorHint_legrg_222",UL="_btnPrimary_legrg_235",PL="_btnGhost_legrg_266",ce={container:SL,header:TL,headerTitle:jL,badge:wL,headerActions:NL,body:CL,formContent:EL,section:AL,label:DL,nameInput:RL,fieldInput:ML,adapterSelect:IL,readOnlyValue:OL,codespaceSection:BL,codespaceActions:LL,creatingHint:zL,errorHint:$L,btnPrimary:UL,btnGhost:PL},od=1,rd=65535;function Ap(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=od&&s<=rd}function Dp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function HL({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=x.useState("pick"),[b,y]=x.useState(""),[S,k]=x.useState("");return g==="create"?i.jsxs("div",{className:ce.codespaceSection,children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Repository"}),i.jsx("input",{type:"text",value:b,onChange:j=>y(j.target.value),placeholder:"owner/repo",className:ce.fieldInput,"data-testid":"env-codespace-repo"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Machine Type"}),i.jsx("input",{type:"text",value:S,onChange:j=>k(j.target.value),placeholder:"Machine type (optional)...",className:ce.fieldInput,"data-testid":"env-codespace-machine"})]}),i.jsxs("div",{className:ce.codespaceActions,children:[i.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),S.trim()||void 0),v("pick"),y(""),k(""))},disabled:!b.trim(),className:ce.btnPrimary,children:"Create"}),i.jsx("button",{onClick:()=>{v("pick"),y(""),k("")},className:ce.btnGhost,children:"Cancel"})]})]}):i.jsx("div",{className:ce.codespaceSection,children:i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Codespace"}),!u&&i.jsxs("select",{value:t,onChange:j=>{j.target.value==="__create__"?(v("create"),s("")):(s(j.target.value),j.target.value&&!o.trim()&&r(j.target.value))},disabled:p,className:ce.adapterSelect,"data-testid":"env-codespace-select",children:[i.jsx("option",{value:"",children:"Select a codespace..."}),c.map(j=>i.jsxs("option",{value:j.name,children:[j.name," (",j.repository,") — ",j.state]},j.name)),i.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&i.jsx("span",{className:ce.creatingHint,children:"Creating codespace..."}),u&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:ce.errorHint,children:u}),i.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:ce.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&i.jsx("span",{className:ce.errorHint,children:d})]})})}function q1({mode:t,environmentId:s,environments:o,onAddEnvironment:r,onUpdateEnvironment:c,onListCodespaces:d,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v,onShowToast:b}){const y=mt(),S=t==="edit",k=S&&s?o.find(ge=>ge.id===s):void 0,[j,N]=x.useState(""),[T,C]=x.useState("local"),[A,I]=x.useState(""),[E,D]=x.useState(""),[P,O]=x.useState(""),[z,Q]=x.useState(""),[$,J]=x.useState(""),[me,te]=x.useState(""),[X,B]=x.useState(""),[F,Z]=x.useState(null),de=x.useCallback(()=>{const ge={};if(T==="local"){if(A.trim()&&(ge.host=A.trim()),E.trim()){const Se=Number(E);Number.isInteger(Se)&&(ge.port=Se)}}else if(T==="ssh"){if(ge.host=A.trim(),P.trim()&&(ge.user=P.trim()),E.trim()){const Se=Number(E);Number.isInteger(Se)&&(ge.sshPort=Se)}z.trim()&&(ge.identityFile=z.trim())}else T==="docker"?($.trim()&&(ge.image=$.trim()),me.trim()&&(ge.repo=me.trim())):T==="codespace"&&(ge.codespaceName=X.trim());return ge},[T,A,E,P,z,$,me,X]),W=()=>!(!j.trim()||T==="ssh"&&!A.trim()||T==="codespace"&&!X.trim()||(T==="local"||T==="ssh")&&!Ap(E)),ee=()=>{W()&&(r(j.trim(),T,de()),b==null||b("Environment added successfully","success"),y(Io,{replace:!0}))},ue=()=>{y(s?Ai(s):Io)},Ce=x.useCallback((ge,Se)=>{if(!k||!s)return;const xe=Dp(k.adapterConfig),Be=Se.trim();Be?xe[ge]=Be:delete xe[ge],c(s,{adapterConfig:xe})},[k,s,c]),Pe=x.useCallback((ge,Se)=>{if(!k||!s)return;const xe=Dp(k.adapterConfig);if(Se.trim()){const Be=Number(Se);Number.isInteger(Be)&&Be>=od&&Be<=rd&&(xe[ge]=Be)}else delete xe[ge];c(s,{adapterConfig:xe})},[k,s,c]);if(S){if(!k)return i.jsxs("div",{className:ce.container,children:[i.jsxs("div",{className:ce.header,children:[i.jsx("div",{className:ce.headerTitle,children:i.jsx("span",{className:ce.badge,children:"edit environment"})}),i.jsx("div",{className:ce.headerActions,children:i.jsx("button",{onClick:ue,className:ce.btnGhost,children:"Back"})})]}),i.jsx("div",{className:ce.body,children:i.jsx("div",{className:ce.formContent,children:i.jsx("span",{className:ce.readOnlyValue,children:"Environment not found"})})})]});const ge=Dp(k.adapterConfig);return i.jsxs("div",{className:ce.container,"data-testid":"env-edit-panel",children:[i.jsxs("div",{className:ce.header,children:[i.jsx("div",{className:ce.headerTitle,children:i.jsx("span",{className:ce.badge,children:"edit environment"})}),i.jsx("div",{className:ce.headerActions,children:i.jsx("button",{onClick:ue,className:ce.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),i.jsx("div",{className:ce.body,children:i.jsxs("div",{className:ce.formContent,children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Name"}),i.jsx(Ft,{value:k.displayName,onSave:Se=>{s&&c(s,{displayName:Se})},validate:Se=>Se.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:F,onActivate:Z,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Adapter Type"}),i.jsx("span",{className:ce.readOnlyValue,"data-testid":"env-edit-adapter-type",children:k.adapterType})]}),k.adapterType==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Host"}),i.jsx(Ft,{value:String(ge.host??""),onSave:Se=>Ce("host",Se),mode:"edit",fieldId:"host",activeFieldId:F,onActivate:Z,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Port"}),i.jsx(Ft,{value:String(ge.port??""),onSave:Se=>Pe("port",Se),validate:Se=>Ap(Se)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:F,onActivate:Z,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),k.adapterType==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Host"}),i.jsx(Ft,{value:String(ge.host??""),onSave:Se=>Ce("host",Se),validate:Se=>Se.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:F,onActivate:Z,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"User"}),i.jsx(Ft,{value:String(ge.user??""),onSave:Se=>Ce("user",Se),mode:"edit",fieldId:"user",activeFieldId:F,onActivate:Z,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"SSH Port"}),i.jsx(Ft,{value:String(ge.sshPort??""),onSave:Se=>Pe("sshPort",Se),validate:Se=>Ap(Se)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:F,onActivate:Z,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Identity File"}),i.jsx(Ft,{value:String(ge.identityFile??""),onSave:Se=>Ce("identityFile",Se),mode:"edit",fieldId:"identityFile",activeFieldId:F,onActivate:Z,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),k.adapterType==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Image"}),i.jsx(Ft,{value:String(ge.image??""),onSave:Se=>Ce("image",Se),mode:"edit",fieldId:"image",activeFieldId:F,onActivate:Z,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Repo"}),i.jsx(Ft,{value:String(ge.repo??""),onSave:Se=>Ce("repo",Se),mode:"edit",fieldId:"repo",activeFieldId:F,onActivate:Z,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),k.adapterType==="codespace"&&i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Codespace Name"}),i.jsx(Ft,{value:String(ge.codespaceName??""),onSave:Se=>Ce("codespaceName",Se),validate:Se=>Se.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:F,onActivate:Z,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return i.jsxs("div",{className:ce.container,"data-testid":"env-create-panel",children:[i.jsxs("div",{className:ce.header,children:[i.jsx("div",{className:ce.headerTitle,children:i.jsx("span",{className:ce.badge,children:"new environment"})}),i.jsxs("div",{className:ce.headerActions,children:[i.jsx("button",{onClick:ee,disabled:!W(),className:ce.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),i.jsx("button",{onClick:ue,className:ce.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:ce.body,children:i.jsxs("div",{className:ce.formContent,children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-name",children:"Name"}),i.jsx("input",{id:"env-create-name",type:"text",value:j,onChange:ge=>N(ge.target.value),placeholder:"Environment name...",autoFocus:!0,className:ce.nameInput,"data-testid":"env-create-name",onKeyDown:ge=>{ge.key==="Enter"&&W()&&ee()}})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),i.jsxs("select",{id:"env-create-adapter",value:T,onChange:ge=>{C(ge.target.value),ge.target.value==="codespace"&&d()},className:ce.adapterSelect,"data-testid":"env-create-adapter",children:[i.jsx("option",{value:"local",children:"local"}),i.jsx("option",{value:"ssh",children:"ssh"}),i.jsx("option",{value:"docker",children:"docker"}),i.jsx("option",{value:"codespace",children:"codespace"})]})]}),T==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:A,onChange:ge=>I(ge.target.value),placeholder:"Host (optional)...",className:ce.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-port",children:"Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:od,max:rd,value:E,onChange:ge=>D(ge.target.value),placeholder:"Port (optional)...",className:ce.fieldInput,"data-testid":"env-create-port"})]})]}),T==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:A,onChange:ge=>I(ge.target.value),placeholder:"Host (required)...",className:ce.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-user",children:"User"}),i.jsx("input",{id:"env-create-user",type:"text",value:P,onChange:ge=>O(ge.target.value),placeholder:"User (optional)...",className:ce.fieldInput,"data-testid":"env-create-user"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-port",children:"SSH Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:od,max:rd,value:E,onChange:ge=>D(ge.target.value),placeholder:"SSH port (optional)...",className:ce.fieldInput,"data-testid":"env-create-port"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-identity",children:"Identity File"}),i.jsx("input",{id:"env-create-identity",type:"text",value:z,onChange:ge=>Q(ge.target.value),placeholder:"Identity file (optional)...",className:ce.fieldInput,"data-testid":"env-create-identity"})]})]}),T==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-image",children:"Image"}),i.jsx("input",{id:"env-create-image",type:"text",value:$,onChange:ge=>J(ge.target.value),placeholder:"Image (optional)...",className:ce.fieldInput,"data-testid":"env-create-image"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-repo",children:"Repo"}),i.jsx("input",{id:"env-create-repo",type:"text",value:me,onChange:ge=>te(ge.target.value),placeholder:"Repo (optional)...",className:ce.fieldInput,"data-testid":"env-create-repo"})]})]}),T==="codespace"&&i.jsx(HL,{codespaceName:X,onCodespaceNameChange:B,envName:j,onEnvNameChange:N,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v})]})})]})}const VL="_group_1iprv_1",qL="_groupTitle_1iprv_8",GL="_shortcutList_1iprv_17",FL="_shortcutRow_1iprv_23",ZL="_keys_1iprv_36",KL="_kbd_1iprv_43",YL="_description_1iprv_60",Si={group:VL,groupTitle:qL,shortcutList:GL,shortcutRow:FL,keys:ZL,kbd:KL,description:YL},JL=[{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 WL(){return i.jsxs("section",{className:ye.section,"data-testid":"keyboard-shortcuts-panel",children:[i.jsx("h3",{className:ye.sectionTitle,children:"Keyboard Shortcuts"}),i.jsx("p",{className:ye.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),JL.map(t=>i.jsxs("div",{className:Si.group,children:[i.jsx("h4",{className:Si.groupTitle,children:t.title}),i.jsx("div",{className:Si.shortcutList,children:t.shortcuts.map(s=>i.jsxs("div",{className:Si.shortcutRow,children:[i.jsx("span",{className:Si.keys,children:s.keys.map(o=>i.jsx("kbd",{className:Si.kbd,children:o},o))}),i.jsx("span",{className:Si.description,children:s.description})]},s.description))})]},t.title))]})}const XL=[{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 QL({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return i.jsxs("section",{className:ye.section,children:[i.jsx("h3",{className:ye.sectionTitle,children:"Credential Providers"}),i.jsx("p",{className:ye.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),i.jsx("div",{className:ye.tokenList,children:XL.map(r=>i.jsxs("div",{className:ye.tokenRow,children:[i.jsx("span",{className:ye.tokenName,children:r.label}),i.jsx("span",{className:ye.tokenTarget,children:r.description}),i.jsx("select",{className:ye.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>i.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const e8="_container_10efq_1",t8="_header_10efq_7",n8="_list_10efq_105",s8="_card_10efq_111",a8="_cardHeader_10efq_125",i8="_cardTitle_10efq_135",o8="_defaultBadge_10efq_141",r8="_cardActions_10efq_155",l8="_description_10efq_160",c8="_meta_10efq_166",d8="_empty_10efq_212",u8="_typeBadge_10efq_362",Xn={container:e8,header:t8,list:n8,card:s8,cardHeader:a8,cardTitle:i8,defaultBadge:o8,cardActions:r8,description:l8,meta:c8,empty:d8,typeBadge:u8};function f8({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=x.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return i.jsxs("div",{className:Xn.container,children:[i.jsxs("div",{className:Xn.header,children:[i.jsx("h2",{children:"Personas"}),i.jsx(tn,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?i.jsx("p",{className:Xn.empty,children:"No personas yet. Create one to get started."}):i.jsx("div",{className:Xn.list,children:t.map(v=>{const b=s===v.id,y=v.type==="script";return i.jsxs("div",{className:Xn.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:[i.jsxs("div",{className:Xn.cardHeader,children:[i.jsxs("span",{className:Xn.cardTitle,children:[i.jsx("strong",{children:v.name}),i.jsx("span",{className:Xn.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:y?"Script":"Agent"}),b&&i.jsx("span",{className:Xn.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),i.jsxs("div",{className:Xn.cardActions,onClick:S=>S.stopPropagation(),children:[!b&&i.jsx(tn,{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"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&i.jsx("p",{className:Xn.description,children:v.description}),i.jsxs("div",{className:Xn.meta,children:[v.runtime&&i.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&i.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&i.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),i.jsx(ia,{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 p8="_container_uy08i_1",m8="_header_uy08i_7",h8="_count_uy08i_13",g8="_presets_uy08i_18",v8="_presetButton_uy08i_24",y8="_filterInput_uy08i_41",b8="_groups_uy08i_53",x8="_group_uy08i_53",_8="_groupHeader_uy08i_68",k8="_groupName_uy08i_77",S8="_groupCount_uy08i_81",T8="_toolList_uy08i_87",j8="_toolItem_uy08i_95",w8="_toolName_uy08i_103",gn={container:p8,header:m8,count:h8,presets:g8,presetButton:v8,filterInput:y8,groups:b8,group:x8,groupHeader:_8,groupName:k8,groupCount:S8,toolList:T8,toolItem:j8,toolName:w8},N8=(()=>{const t=new Map;for(const s of kx){const o=s==="get_version_status"?"version":s.split("_")[0];t.has(o)||t.set(o,[]),t.get(o).push(s)}return[...t.entries()].sort(([s],[o])=>s.localeCompare(o)).map(([s,o])=>({group:s,tools:o.sort()}))})(),C8=[{name:"default",label:"Default",tools:Sx},{name:"worker",label:"Worker",tools:RT},{name:"orchestrator",label:"Orchestrator",tools:MT},{name:"admin",label:"Admin",tools:IT}];function sx({selectedTools:t,onChange:s,disabled:o}){const[r,c]=x.useState(""),d=x.useMemo(()=>new Set(t),[t]),u=x.useCallback(v=>{if(o)return;const b=new Set(d);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[d,s,o]),p=x.useCallback((v,b)=>{if(o)return;const y=new Set(d);for(const S of v)b?y.delete(S):y.add(S);s([...y].sort())},[d,s,o]),m=x.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return i.jsxs("div",{className:gn.container,"data-testid":"mcp-tool-selector",children:[i.jsx("div",{className:gn.header,children:i.jsx("span",{className:gn.count,children:t.length===0?`Using default (${Sx.length} tools)`:`${t.length} of ${kx.size} tools selected`})}),i.jsxs("div",{className:gn.presets,"data-testid":"mcp-tool-presets",children:[C8.map(v=>i.jsx("button",{type:"button",className:gn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),i.jsx("button",{type:"button",className:gn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),i.jsx("input",{type:"text",className:gn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),i.jsx("div",{className:gn.groups,children:N8.map(({group:v,tools:b})=>{const y=g?b.filter(k=>k.toLowerCase().includes(g)):b;if(y.length===0)return null;const S=y.every(k=>d.has(k));return i.jsxs("div",{className:gn.group,"data-testid":`tool-group-${v}`,children:[i.jsxs("label",{className:gn.groupHeader,children:[i.jsx("input",{type:"checkbox",checked:S,onChange:()=>p(y,S),disabled:o,"data-testid":`group-toggle-${v}`}),i.jsx("span",{className:gn.groupName,children:v}),i.jsxs("span",{className:gn.groupCount,children:["(",y.filter(k=>d.has(k)).length,"/",y.length,")"]})]}),i.jsx("div",{className:gn.toolList,children:y.map(k=>i.jsxs("label",{className:gn.toolItem,children:[i.jsx("input",{type:"checkbox",checked:d.has(k),onChange:()=>u(k),disabled:o,"data-testid":`tool-${k}`}),i.jsx("span",{className:gn.toolName,children:k})]},k))})]},v)})})]})}const E8="_container_1gfuq_1",A8="_header_1gfuq_7",D8="_list_1gfuq_19",R8="_card_1gfuq_25",M8="_cardHeader_1gfuq_40",I8="_cardTitle_1gfuq_46",O8="_statusBadge_1gfuq_56",B8="_enabled_1gfuq_68",L8="_disabled_1gfuq_71",z8="_cardActions_1gfuq_75",$8="_cardMeta_1gfuq_80",U8="_empty_1gfuq_98",Qn={container:E8,header:A8,list:D8,card:R8,cardHeader:M8,cardTitle:I8,statusBadge:O8,enabled:B8,disabled:L8,cardActions:z8,cardMeta:$8,empty:U8};function P8({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=x.useState(null),m=u?t.find(y=>y.id===u):void 0,g=async y=>{await o(y),p(null)},v=x.useMemo(()=>{const y=new Map;for(const S of s)y.set(S.id,S.name);return y},[s]),b=y=>v.get(y)??y;return i.jsxs("div",{className:Qn.container,children:[i.jsxs("div",{className:Qn.header,children:[i.jsx("h2",{children:"Schedules"}),i.jsx(tn,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?i.jsx("p",{className:Qn.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):i.jsx("div",{className:Qn.list,children:t.map(y=>i.jsxs("div",{className:Qn.card,"data-testid":`schedule-card-${y.id}`,onClick:()=>d(y.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),d(y.id))},children:[i.jsxs("div",{className:Qn.cardHeader,children:[i.jsxs("span",{className:Qn.cardTitle,children:[i.jsx("strong",{children:y.title}),i.jsx("span",{className:`${Qn.statusBadge} ${y.enabled?Qn.enabled:Qn.disabled}`,"data-testid":`schedule-status-badge-${y.id}`,children:y.enabled?"Enabled":"Disabled"})]}),i.jsxs("div",{className:Qn.cardActions,onClick:S=>S.stopPropagation(),children:[i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(y.id,{enabled:!y.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${y.id}`,title:y.enabled?"Disable schedule":"Enable schedule",children:y.enabled?"Disable":"Enable"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>d(y.id),"data-testid":`schedule-edit-${y.id}`,children:"Edit"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>p(y.id),"data-testid":`schedule-delete-${y.id}`,children:"Delete"})]})]}),i.jsxs("div",{className:Qn.cardMeta,children:[i.jsx("span",{"data-testid":`schedule-expression-${y.id}`,children:y.scheduleExpression}),y.personaId&&i.jsxs("span",{"data-testid":`schedule-persona-${y.id}`,children:["Persona: ",b(y.personaId)]}),i.jsxs("span",{"data-testid":`schedule-last-run-${y.id}`,children:["Last run: ",y.lastRunAt?Po(y.lastRunAt):"Never"]}),y.enabled&&y.nextRunAt?i.jsxs("span",{"data-testid":`schedule-next-run-${y.id}`,children:["Next run: ",B1(y.nextRunAt)]}):null,y.runCount>0&&i.jsxs("span",{"data-testid":`schedule-run-count-${y.id}`,children:["Runs: ",y.runCount]})]})]},y.id))}),i.jsx(ia,{isOpen:u!==null,title:"Delete Schedule?",description:`"${(m==null?void 0:m.title)??""}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const H8="_nav_1bhou_1",V8="_tab_1bhou_24",q8="_tabIcon_1bhou_62",G8="_tabActive_1bhou_68",Zc={nav:H8,tab:V8,tabIcon:q8,tabActive:G8},Xs=[{path:"credentials",label:"Credentials",icon:i.jsx(V2,{size:Rt})},{path:"personas",label:"Personas",icon:i.jsx(vj,{size:Rt})},{path:"schedules",label:"Schedules",icon:i.jsx(_2,{size:Rt})},{path:"appearance",label:"Appearance",icon:i.jsx(ij,{size:Rt})},{path:"shortcuts",label:"Shortcuts",icon:i.jsx(G2,{size:Rt})},{path:"about",label:"About",icon:i.jsx(vm,{size:Rt})}];function F8(){var u;const t=Yt(),s=mt(),o=x.useRef(null),r=((u=Xs.find(p=>{const m=`${Ni}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??Xs[0].path,c=x.useCallback(p=>{s(`${Ni}/${p}`)},[s]),d=x.useCallback(p=>{var S,k;const m=(S=o.current)==null?void 0:S.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:Xs.findIndex(j=>j.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%Xs.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+Xs.length)%Xs.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=Xs.length-1;else return;const y=Xs[b].path;s(`${Ni}/${y}`),(k=m[b])==null||k.focus()},[r,s]);return i.jsx("nav",{className:Zc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:Xs.map(p=>{const m=p.path===r;return i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Zc.tab} ${m?Zc.tabActive:""}`,onClick:()=>c(p.path),children:[i.jsx("span",{className:Zc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}function Z8({tasks:t,taskStatusById:s,sessionStatusByTaskId:o}){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(xy.map(d=>[d,[]]));for(const d of t){const u=pl(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"&&o){const k=o.get(d.id);k==="idle"?b="Needs input":k==="completed"&&(b="Ready to complete")}const y={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},S=c.get(u);S?S.push(y):c.get("not_started").push(y)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return xy.map(d=>{const u=qa(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const K8="_boardContainer_1c4y1_1",Y8="_column_1c4y1_17",J8="_columnHeader_1c4y1_34",W8="_columnIcon_1c4y1_47",X8="_columnLabel_1c4y1_52",Q8="_columnCount_1c4y1_57",e7="_cardList_1c4y1_67",t7="_emptyPlaceholder_1c4y1_76",n7="_card_1c4y1_67",s7="_cardHeader_1c4y1_107",a7="_cardStatusIcon_1c4y1_113",i7="_cardTitle_1c4y1_119",o7="_cardBadges_1c4y1_127",r7="_badge_1c4y1_134",l7="_blockedBadge_1c4y1_146",c7="_childBadge_1c4y1_151",d7="_depBadge_1c4y1_155",u7="_parentBadge_1c4y1_159",f7="_pausedSubBadge_1c4y1_166",p7="_personaBadge_1c4y1_170",m7="_envBadge_1c4y1_174",h7="_emptyCta_1c4y1_178",g7="_ctaButton_1c4y1_188",v7="_ctaDescription_1c4y1_204",it={boardContainer:K8,column:Y8,columnHeader:J8,columnIcon:W8,columnLabel:X8,columnCount:Q8,cardList:e7,emptyPlaceholder:t7,card:n7,cardHeader:s7,cardStatusIcon:a7,cardTitle:i7,cardBadges:o7,badge:r7,blockedBadge:l7,childBadge:c7,depBadge:d7,parentBadge:u7,pausedSubBadge:f7,personaBadge:p7,envBadge:m7,emptyCta:h7,ctaButton:g7,ctaDescription:v7};function y7({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=mt(),p=x.useMemo(()=>o.filter(y=>y.workspaceId===t),[o,t]),m=x.useMemo(()=>new Map(o.map(y=>[y.id,y.status])),[o]),g=x.useMemo(()=>new Map(p.map(y=>[y.id,y])),[p]),v=x.useMemo(()=>{const y=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])),j=new Map,N=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const A=y.get(C.latestSessionId);if(A){if(j.set(C.id,A.endReason||A.status),A.personaId){const I=S.get(A.personaId);I&&N.set(C.id,I.name)}if(A.environmentId){const I=k.get(A.environmentId);I&&T.set(C.id,I.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:N,environmentNameByTaskId:T}},[p,r,c,d]),b=x.useMemo(()=>Z8({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?i.jsxs("div",{className:it.emptyCta,"data-testid":"board-empty-cta",children:[i.jsx("button",{className:it.ctaButton,onClick:()=>u(Ii(t,void 0,s)),children:"Create Task"}),i.jsx("div",{className:it.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):i.jsx("div",{className:it.boardContainer,"data-testid":"board-container",children:b.map(y=>i.jsxs("section",{className:it.column,"data-testid":`board-column-${y.status}`,"aria-label":`${y.label}, ${y.tasks.length} ${y.tasks.length===1?"task":"tasks"}`,children:[i.jsxs("div",{className:it.columnHeader,children:[i.jsx("span",{className:it.columnIcon,style:{color:y.style.color},children:y.style.icon}),i.jsx("span",{className:it.columnLabel,children:y.label}),i.jsx("span",{className:it.columnCount,"data-testid":`board-count-${y.status}`,children:y.tasks.length})]}),i.jsx("div",{className:it.cardList,children:y.tasks.length===0?i.jsx("div",{className:it.emptyPlaceholder,children:"No tasks"}):i.jsx(gs,{mode:"popLayout",children:y.tasks.map(S=>i.jsx(Mt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:i.jsx(b7,{boardTask:S,tasksById:g,personaName:v.personaNameByTaskId.get(S.task.id),envName:v.environmentNameByTaskId.get(S.task.id),onClick:()=>u(On(S.task.id,void 0,t,s))})},S.task.id))})})]},y.status))})}function b7({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=qa(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return i.jsxs("div",{className:it.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),c())},children:[i.jsxs("div",{className:it.cardHeader,children:[i.jsx("span",{className:it.cardStatusIcon,style:{color:v.color},children:v.icon}),i.jsx("span",{className:it.cardTitle,children:d.title})]}),i.jsxs("div",{className:it.cardBadges,children:[b&&i.jsx("span",{className:`${it.badge} ${it.parentBadge}`,title:b.title,children:b.title}),p>0&&i.jsxs("span",{className:`${it.badge} ${it.childBadge}`,children:[m,"/",p]}),u&&i.jsx("span",{className:`${it.badge} ${it.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&i.jsx("span",{className:`${it.badge} ${it.depBadge}`,children:"dep"}),g&&i.jsx("span",{className:`${it.badge} ${it.pausedSubBadge}`,children:g}),o&&i.jsx("span",{className:`${it.badge} ${it.personaBadge}`,children:o}),r&&i.jsx("span",{className:`${it.badge} ${it.envBadge}`,children:r})]})]})}const x7="_formContent_ymnez_1",_7="_section_ymnez_13",k7="_label_ymnez_19",S7="_titleInput_ymnez_26",T7="_descriptionTextarea_ymnez_58",j7="_selectField_ymnez_94",w7="_checkboxRow_ymnez_128",N7="_checkboxLabel_ymnez_141",C7="_fieldError_ymnez_146",xt={formContent:x7,section:_7,label:k7,titleInput:S7,descriptionTextarea:T7,selectField:j7,checkboxRow:w7,checkboxLabel:N7,fieldError:C7};function E7(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 A7=100;function D7({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return i.jsxs("div",{className:xt.formContent,children:[i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-name",children:"Name"}),i.jsx("input",{id:"ws-name",className:xt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:A7,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-description",children:"Description"}),i.jsx("textarea",{id:"ws-description",className:xt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-repo",children:"Repository URL"}),i.jsx("input",{id:"ws-repo",className:xt.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)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-environment",children:"Environment"}),i.jsxs("select",{id:"ws-environment",className:xt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[i.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>i.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-persona",children:"Default Persona"}),i.jsxs("select",{id:"ws-persona",className:xt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>i.jsx("option",{value:m.id,children:m.name},m.id))]})]}),i.jsx("div",{className:xt.section,children:i.jsxs("label",{className:xt.checkboxRow,children:[i.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),i.jsx("span",{className:xt.checkboxLabel,children:"Enable worktree isolation"})]})}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-workdir",children:"Working Directory"}),i.jsx("input",{id:"ws-workdir",className:xt.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 G1=x.createContext(void 0),R7=4e3;function M7({children:t}){const[s,o]=x.useState([]),r=x.useRef(0),c=x.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=x.useCallback((u,p="info",m=R7)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return i.jsx(G1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function pn(){const t=x.useContext(G1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const fm="grackle-theme",F1="grackle-prefer-system",Z1="(prefers-color-scheme: dark)";let Jr=[],ld;function Rp(){ld=void 0;for(const t of Jr)t()}function pm(){return typeof window>"u"?!1:window.matchMedia(Z1).matches}function nl(){if(typeof localStorage>"u")return tx;try{const t=localStorage.getItem(fm);if(t!==null&&H1.has(t))return t}catch{}return tx}function _d(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(F1)==="true"}catch{return!1}}function mm(t){return zd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function K1(t,s){const o=um(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?pm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=mm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return pm()?r.variantDarkId:r.variantLightId}return t}function No(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=K1(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&No(nl(),_d());function I7(){return ld===void 0&&(ld={themeId:nl(),systemDark:pm(),preferSystem:_d()}),ld}function O7(t){return Jr=[...Jr,t],()=>{Jr=Jr.filter(s=>s!==t)}}function B7(){const t=x.useSyncExternalStore(O7,I7),{themeId:s,preferSystem:o}=t,r=K1(s,o),c=x.useCallback(u=>{if(H1.has(u)){try{localStorage.setItem(fm,u)}catch{}No(u,_d(),!0),Rp()}},[]),d=x.useCallback(u=>{try{localStorage.setItem(F1,u?"true":"false")}catch{}if(u){const p=nl(),m=um(p);if(m!=null&&m.hidden){const g=mm(p);if(g)try{localStorage.setItem(fm,g.id)}catch{}}}No(nl(),u,!0),Rp()},[]);return x.useEffect(()=>{No(s,o)},[s,o]),x.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(Z1),p=()=>{const m=nl(),g=_d();if(g){const v=um(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&No(m,g),v!=null&&v.hidden){const b=mm(m);b!=null&&b.variantDarkId&&b.variantLightId&&No(m,g)}}Rp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const Y1=x.createContext(void 0);function L7({children:t}){const s=B7();return i.jsx(Y1.Provider,{value:s,children:t})}function J1(){const t=x.useContext(Y1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const W1=x.createContext(void 0),X1=x.createContext(void 0);function z7({children:t}){const[s,o]=x.useState(void 0),r=x.useCallback(c=>{o(c)},[]);return i.jsx(X1.Provider,{value:r,children:i.jsx(W1.Provider,{value:s,children:t})})}function $7(){return x.useContext(W1)}function U7(){const t=x.useContext(X1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const fh=x.createContext(void 0);function dt(){const t=x.useContext(fh);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function Q1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ek(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function P7(t){return Q1(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 H7=new Set(["off","subscription","api_key"]),Kc=new Set(["off","on"]);function V7(t){return Q1(t)&&H7.has(t.claude)&&Kc.has(t.github)&&Kc.has(t.copilot)&&Kc.has(t.codex)&&Kc.has(t.goose)}function tk(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 nk(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 wo=5e3;function q7(t,s){const o=[];let r=t;const c=new Set;for(;r&&s.has(r)&&!c.has(r);){c.add(r);const d=s.get(r);o.unshift(d),r=d.parentTaskId||void 0}return o}const oa={label:"Home",url:Di};function G7(t){return t?[oa,{label:"Settings",url:Ni},{label:t,url:void 0}]:[oa,{label:"Settings",url:void 0}]}const ph={label:"Environments",url:Io};function F7(){return[oa,{label:"Environments",url:void 0}]}function Z7(){return[oa,{label:"New Chat",url:void 0}]}function K7(t){return[oa,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function Y7(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[oa,ph,{label:(d==null?void 0:d.displayName)??"Environment",url:Ai(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function J7(t,s,o,r,c){const d=q7(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.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=[oa];v&&g&&(b.push(ph),b.push({label:v.displayName,url:Ai(g)})),m&&g&&b.push({label:m.name,url:Ga(m.id,g)});for(let S=0;S<d.length-1;S++)b.push({label:d[S].title,url:On(d[S].id,void 0,p,g)});const y=d[d.length-1];return b.push({label:(y==null?void 0:y.title)??t,url:void 0}),b}const W7={label:"Findings",url:Dd};function X7(){return[oa,{label:"Findings",url:void 0}]}function sk(t,s,o,r,c){const d=[oa];if(s&&o){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===o);d.push(ph),p&&d.push({label:p.displayName,url:Ai(o)}),u&&d.push({label:u.name,url:Ga(s,o)}),d.push({label:"Findings",url:wN(s,o)})}else d.push(W7);return d.push({label:t,url:void 0}),d}function mh(t){const s=[];for(const o of t){const r=s[s.length-1];o.eventType==="text"&&(r==null?void 0:r.eventType)==="text"?s[s.length-1]={...r,content:r.content+o.content}:s.push(o)}return s}function Yc(t){if(typeof t.id=="string")return t.id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function Q7(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 o=t.item;if(o&&typeof o.id=="string")return o.id}function hh(t){const s=new Map;for(const v of t)if(v.raw)try{s.set(v,JSON.parse(v.raw))}catch{}const o=new Map;for(const v of t){if(v.eventType!=="tool_use")continue;const b=s.get(v),y=b?Yc(b):void 0;if(y)try{const S=JSON.parse(v.content);o.set(y,{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 y=s.get(v),S=y?Q7(y):void 0;if(!S)return v;const k=o.get(S);if(!k)return v;r.add(S),c.add(b);let j;const N=v.content.trim();if(N.startsWith("{"))try{const T=JSON.parse(N);typeof T.detailedContent=="string"&&(j=T.detailedContent)}catch{}return{...v,toolUseCtx:{...k,detailedResult:j}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const b=s.get(d[v]),y=b?Yc(b):void 0;y&&r.has(y)||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 y=d[v],S=d[b];let k;try{const j=JSON.parse(y.content);k={tool:j.tool,args:j.args}}catch{}if(k){let j;const N=S.content.trim();if(N.startsWith("{"))try{const A=JSON.parse(N);typeof A.detailedContent=="string"&&(j=A.detailedContent)}catch{}d[b]={...S,toolUseCtx:{...k,detailedResult:j}},c.add(b);const T=s.get(y),C=T?Yc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(y,{...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 y=Yc(b);if(y&&r.has(y))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 y=v+1;y<g.length;y++)if(g[y].eventType!=="tool_use"){b=!0;break}b&&(g[v]={...g[v],settled:!0})}return g}function ez(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=ak(s),d=s.filter(m=>hm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||hm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function ak(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function hm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function tz(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=ak(t),c=[];for(const p of t){const m=p.workspaceId?((u=o.get(p.workspaceId))==null?void 0:u.name)??"Unknown":"Unknown";p.status==="failed"?c.push({task:p,reason:"failed",workspaceName:m}):hm(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 nz(t,s){const o=new Map;for(const r of s)o.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=o.get(r.environmentId))==null?void 0:c.displayName)??"Unknown"}})}function sz(t,s,o){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 ws=[{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
280
280
  export function verifyToken(req: Request, res: Response, next: NextFunction): void {
281
281
  const header = req.headers.authorization;
282
282
  if (!header?.startsWith("Bearer ")) {
@@ -717,4 +717,4 @@ const grackle = await host.mcpServer({
717
717
  url: env.vars.GRACKLE_MCP_URL,
718
718
  });
719
719
 
720
- $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),D==="agent"&&i.jsxs("div",{children:[i.jsx("label",{children:"Allowed MCP Tools"}),i.jsx(sx,{selectedTools:Q,onChange:re=>{$(re),xe(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,re),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!Ce&&!ue&&i.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,i.jsx(ia,{isOpen:J,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:Se,onCancel:()=>me(!1)})]})}function u9(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=dt(),{showToast:c}=pn(),d=mt();return i.jsx(P8,{schedules:t,personas:r,onDeleteSchedule:async u=>{try{await s(u)}catch(p){throw console.error("Failed to delete schedule",{scheduleId:u,error:p}),c("Failed to delete schedule","error"),p}},onToggleEnabled:async(u,p)=>{try{return await o(u,p)}catch(m){throw console.error("Failed to update schedule",{scheduleId:u,error:m}),c("Failed to update schedule","error"),m}},onNavigateToNew:()=>d(_N),onNavigateToSchedule:u=>d(Jx(u))})}const f9="_container_1g4qh_1",p9="_form_1g4qh_7",m9="_formActions_1g4qh_66",h9="_editableSection_1g4qh_73",g9="_helperText_1g4qh_84",v9="_metaSection_1g4qh_90",y9="_optional_1g4qh_108",b9="_readonlyValue_1g4qh_113",yn={container:f9,form:p9,formActions:m9,editableSection:h9,helperText:g9,metaSection:v9,optional:y9,readonlyValue:b9};function vx(){const{scheduleId:t}=as(),s=mt(),{showToast:o}=pn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},environments:{environments:g},workspaces:{workspaces:v}}=dt(),b=t===void 0,y=b?void 0:r.find(k=>k.id===t);if(!b&&!c&&r.length>0&&!y)return i.jsx(ts,{to:tp,replace:!0});const S=[{label:"Settings",url:Ni},{label:"Schedules",url:tp},{label:b?"New Schedule":(y==null?void 0:y.title)??"Schedule",url:void 0}];return i.jsxs("div",{className:yn.container,children:[i.jsx(vs,{segments:S}),i.jsx(x9,{existing:y,isNew:b,personas:m,environments:g,workspaces:v,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(tp)},showToast:o})]})}function x9({existing:t,isNew:s,personas:o,environments:r,workspaces:c,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:m,showToast:g}){var W;const v=mt(),[b,y]=x.useState((t==null?void 0:t.title)??""),[S,k]=x.useState((t==null?void 0:t.description)??""),[j,N]=x.useState((t==null?void 0:t.scheduleExpression)??""),[T,C]=x.useState((t==null?void 0:t.personaId)??""),[A,I]=x.useState((t==null?void 0:t.environmentId)??""),[E,D]=x.useState((t==null?void 0:t.workspaceId)??""),[P,O]=x.useState(!1),[z,Q]=x.useState(null);x.useEffect(()=>{s||t&&z===null&&(y(t.title),k(t.description),N(t.scheduleExpression),C(t.personaId),I(t.environmentId),D(t.workspaceId))},[s,t,z]);const $=!s&&t===void 0,J=s&&b.trim().length>0&&j.trim().length>0&&T.length>0,me=o.map(ee=>({value:ee.id,label:ee.name})),te=[{value:"",label:"Auto-select (first connected)"},...r.map(ee=>({value:ee.id,label:ee.displayName}))],X=[{value:"",label:"System-level (no workspace)"},...c.map(ee=>({value:ee.id,label:ee.name}))],B=ee=>{ee.preventDefault(),J&&d(b,S,j,T,A||void 0,E||void 0).then(ue=>{g("Schedule created","success"),v(Jx(ue.id),{replace:!0})},()=>{g("Failed to create schedule","error")})},F=(ee,ue)=>{t&&u(t.id,{[ee]:ue}).then(()=>{g("Schedule updated","success"),ee==="title"&&y(String(ue)),ee==="description"&&k(String(ue)),ee==="scheduleExpression"&&N(String(ue)),ee==="personaId"&&C(String(ue)),ee==="environmentId"&&I(String(ue))},()=>{g("Failed to update schedule","error")})},Z=()=>{if(!t)return;const ee=!t.enabled;u(t.id,{enabled:ee}).then(()=>{g(ee?"Schedule enabled":"Schedule disabled","success")},()=>{g("Failed to update schedule","error")})},de=()=>{t&&p(t.id).then(()=>{g("Schedule deleted","success"),m()},()=>{g("Failed to delete schedule","error")})};return i.jsxs(i.Fragment,{children:[$?i.jsxs("div",{className:yn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsx("p",{children:"Loading schedule..."})]}):s?i.jsxs("form",{onSubmit:B,className:yn.form,children:[i.jsx("h3",{children:"Create Schedule"}),i.jsxs("label",{children:["Title",i.jsx("input",{type:"text",value:b,onChange:ee=>y(ee.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description ",i.jsx("span",{className:yn.optional,children:"(optional)"}),i.jsx("input",{type:"text",value:S,onChange:ee=>k(ee.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx("input",{type:"text",value:j,onChange:ee=>N(ee.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),i.jsxs("p",{className:yn.helperText,children:["Interval: ",i.jsx("code",{children:"30s"}),", ",i.jsx("code",{children:"5m"}),", ",i.jsx("code",{children:"1h"}),", ",i.jsx("code",{children:"1d"})," (min 10s)  |  Cron: ",i.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),i.jsxs("label",{children:["Persona",i.jsxs("select",{value:T,onChange:ee=>C(ee.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[i.jsx("option",{value:"",children:"Select a persona..."}),me.map(ee=>i.jsx("option",{value:ee.value,children:ee.label},ee.value))]})]}),i.jsxs("label",{children:["Environment ",i.jsx("span",{className:yn.optional,children:"(optional)"}),i.jsx("select",{value:A,onChange:ee=>I(ee.target.value),"data-testid":"schedule-detail-environment",children:te.map(ee=>i.jsx("option",{value:ee.value,children:ee.label},ee.value))})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:yn.optional,children:"(optional)"}),i.jsx("select",{value:E,onChange:ee=>D(ee.target.value),"data-testid":"schedule-detail-workspace",children:X.map(ee=>i.jsx("option",{value:ee.value,children:ee.label},ee.value))})]}),i.jsxs("div",{className:yn.formActions,children:[i.jsx(tn,{type:"submit",variant:"primary",size:"md",disabled:!J,"data-testid":"schedule-detail-save",children:"Create"}),i.jsx(tn,{type:"button",variant:"outline",size:"md",onClick:m,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?i.jsxs("div",{className:yn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsxs("div",{className:yn.formActions,children:[i.jsx(tn,{type:"button",variant:"outline",size:"md",onClick:m,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),i.jsx(tn,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:Z,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),i.jsx(tn,{type:"button",variant:"danger",size:"md",onClick:()=>O(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),i.jsxs("div",{className:yn.editableSection,children:[i.jsxs("label",{children:["Title",i.jsx(Ft,{value:b,onSave:ee=>{F("title",ee)},validate:ee=>ee.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:z,onActivate:Q,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description",i.jsx(Ft,{value:S,onSave:ee=>{F("description",ee)},fieldId:"schedule-description",activeFieldId:z,onActivate:Q,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx(Ft,{value:j,onSave:ee=>{F("scheduleExpression",ee)},validate:ee=>ee.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:z,onActivate:Q,placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",ariaLabel:"Schedule expression","data-testid":"schedule-detail-expression"})]}),i.jsxs("label",{children:["Persona",i.jsx(Uo,{value:T,onSave:ee=>{F("personaId",ee)},options:me,fieldId:"schedule-persona",activeFieldId:z,onActivate:Q,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),i.jsxs("label",{children:["Environment ",i.jsx("span",{className:yn.optional,children:"(optional — empty = auto-select)"}),i.jsx(Uo,{value:A,onSave:ee=>{F("environmentId",ee)},options:te,fieldId:"schedule-environment",activeFieldId:z,onActivate:Q,ariaLabel:"Schedule environment","data-testid":"schedule-detail-environment"})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:yn.optional,children:"(optional — set at creation)"}),i.jsx("span",{className:yn.readonlyValue,"data-testid":"schedule-detail-workspace",children:((W=c.find(ee=>ee.id===t.workspaceId))==null?void 0:W.name)??"System-level (no workspace)"})]})]}),i.jsxs("div",{className:yn.metaSection,children:[t.lastRunAt?i.jsxs("span",{children:["Last run: ",Po(t.lastRunAt)]}):i.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?i.jsxs("span",{children:["Next run: ",B1(t.nextRunAt)]}):null,t.runCount>0&&i.jsxs("span",{children:["Total runs: ",t.runCount]}),i.jsxs("span",{children:["Created: ",Po(t.createdAt)]})]})]}):null,i.jsx(ia,{isOpen:P,title:"Delete Schedule?",description:`"${t==null?void 0:t.title}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:de,onCancel:()=>O(!1)})]})}function _9(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=J1();return i.jsx(lB,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function k9(){const[t,s]=x.useState(void 0);return x.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Qe.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function S9(){const{connected:t,environments:{environments:s},sessions:{sessions:o}}=dt(),r=k9();return i.jsxs(i.Fragment,{children:[r&&i.jsx(fO,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),i.jsx(cB,{connected:t,environments:s,sessions:o})]})}function T9(){return i.jsx(WL,{})}const yx=Ii();function j9(){const t=mt();return na({key:"?"},()=>{t(kN)}),na({key:"n"},()=>{t(yx)}),na({key:"N"},()=>{t(yx)}),i.jsx(i.Fragment,{})}function xl(t){const s=U7();x.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function w9(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=dt(),o=x.useMemo(()=>i.jsx(H5,{workspaces:t,tasks:s}),[t,s]);return xl(o),i.jsx(Ya,{})}function N9(){const{environments:{environments:t}}=dt(),s=x.useMemo(()=>i.jsx(XI,{environments:t}),[t]);return xl(s),i.jsx(Ya,{})}function C9(){const t=x.useMemo(()=>i.jsx(F8,{}),[]);return xl(t),i.jsx(Ya,{})}function E9(){const{findings:{findings:t,loadFindings:s,loadAllFindings:o}}=dt(),{workspaceId:r,environmentId:c}=as();x.useEffect(()=>{r?s(r).catch(()=>{}):o().catch(()=>{})},[r,s,o]);const d=x.useMemo(()=>i.jsx(c5,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return xl(d),i.jsx(Ya,{})}function A9(){const{knowledge:t,workspaces:{workspaces:s}}=dt(),o=x.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=x.useCallback(()=>{t.clearSearch()},[t]),c=x.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=x.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=x.useMemo(()=>i.jsx(uI,{nodes:t.graphData.nodes,workspaces:s,loading:t.loading,searchQuery:t.searchQuery,onSearch:o,onClearSearch:r,onSelectNode:c,onWorkspaceChange:d}),[t,s,o,r,c,d]);return xl(u),i.jsx(Ya,{})}const D9="_container_ce571_1",R9="_title_ce571_6",kd={container:D9,title:R9};function M9(){return i.jsxs("div",{className:kd.container,"aria-hidden":"true",children:[i.jsx("h1",{className:kd.title,children:"Findings"}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>i.jsx(bd,{lines:3},s))})]})}function bx(){const{environmentId:t,workspaceId:s}=as(),{findings:{findings:o,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=dt(),p=mt();x.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=x.useCallback(v=>{p(Gp(v,s,t))},[p,s,t]);if(r)return i.jsx(M9,{});const g=s&&t?sk("Findings",s,t,d,u).slice(0,-1):X7();return i.jsxs("div",{className:kd.container,"data-testid":"findings-list-page",children:[i.jsx(vs,{segments:g}),i.jsx("h1",{className:kd.title,children:"Findings"}),i.jsx(P1,{findings:o,onFindingClick:m})]})}const I9="_container_1wwpb_1",O9="_notFound_1wwpb_6",B9="_header_1wwpb_12",L9="_categoryBadge_1wwpb_19",z9="_title_1wwpb_28",$9="_content_1wwpb_35",U9="_tags_1wwpb_77",P9="_tag_1wwpb_77",H9="_meta_1wwpb_92",V9="_metaTimestamp_1wwpb_100",q9="_metaLink_1wwpb_105",vn={container:I9,notFound:O9,header:B9,categoryBadge:L9,title:z9,content:$9,tags:U9,tag:P9,meta:H9,metaTimestamp:V9,metaLink:q9};function xx(){const{findingId:t,environmentId:s,workspaceId:o}=as(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=dt(),m=mt();if(x.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return i.jsx("div",{className:vn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:vn.notFound,children:"Loading..."})});if(!r)return i.jsx("div",{className:vn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:vn.notFound,children:"Finding not found."})});const g=sk(r.title,o,s,u,p),v=xd(r.category);return i.jsxs("div",{className:vn.container,"data-testid":"finding-detail-page",children:[i.jsx(vs,{segments:g}),i.jsxs("div",{className:vn.header,children:[i.jsx("span",{className:vn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),i.jsx("h1",{className:vn.title,children:r.title})]}),r.content&&i.jsx("div",{className:vn.content,children:i.jsx(Td,{remarkPlugins:[jd],children:r.content})}),r.tags.length>0&&i.jsx("div",{className:vn.tags,children:r.tags.map(b=>i.jsx("span",{className:vn.tag,children:b},b))}),i.jsxs("div",{className:vn.meta,children:[i.jsx("span",{className:vn.metaTimestamp,title:r.createdAt,children:Po(r.createdAt)}),r.taskId&&i.jsx("button",{type:"button",className:vn.metaLink,onClick:()=>{m(On(r.taskId))},children:"View Task"}),r.sessionId&&i.jsx("button",{type:"button",className:vn.metaLink,onClick:()=>{m(Cm(r.sessionId))},children:"View Session"})]})]})}const G9="_wizard_1260s_1",F9="_container_1260s_10",Z9="_stepContent_1260s_19",K9="_logoArea_1260s_28",Y9="_logoImage_1260s_32",J9="_heading_1260s_41",W9="_tagline_1260s_49",X9="_subtitle_1260s_56",Q9="_featureList_1260s_64",eH="_runtimeGrid_1260s_89",tH="_runtimeCard_1260s_101",nH="_runtimeName_1260s_133",sH="_runtimeDescription_1260s_139",aH="_buttonRow_1260s_144",iH="_primaryButton_1260s_151",oH="_ghostButton_1260s_185",rH="_dots_1260s_213",lH="_dot_1260s_213",Ze={wizard:G9,container:F9,stepContent:Z9,logoArea:K9,logoImage:Y9,heading:J9,tagline:W9,subtitle:X9,featureList:Q9,runtimeGrid:eH,runtimeCard:tH,runtimeName:nH,runtimeDescription:sH,buttonRow:aH,primaryButton:iH,ghostButton:oH,dots:rH,dot:lH};function cH({onNext:t}){return i.jsxs("div",{className:Ze.stepContent,"data-testid":"setup-welcome",children:[i.jsx("div",{className:Ze.logoArea,children:i.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Ze.logoImage})}),i.jsx("h1",{className:Ze.heading,children:"Welcome to Grackle"}),i.jsx("p",{className:Ze.tagline,children:"Multi-agent orchestration for software teams"}),i.jsx("button",{type:"button",className:Ze.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function dH({onNext:t,onBack:s}){return i.jsxs("div",{className:Ze.stepContent,"data-testid":"setup-about",children:[i.jsx("h2",{className:Ze.heading,children:"What is Grackle?"}),i.jsxs("ul",{className:Ze.featureList,children:[i.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),i.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),i.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),i.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),i.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),i.jsxs("div",{className:Ze.buttonRow,children:[i.jsx("button",{type:"button",className:Ze.ghostButton,onClick:s,children:"Back"}),i.jsx("button",{type:"button",className:Ze.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const uH=[{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 fH({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=x.useState(t||"claude-code");return x.useEffect(()=>{t&&d(t)},[t]),i.jsxs("div",{className:Ze.stepContent,"data-testid":"setup-runtime",children:[i.jsx("h2",{className:Ze.heading,children:"Choose Your Runtime"}),i.jsx("p",{className:Ze.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),i.jsx("div",{className:Ze.runtimeGrid,children:uH.map(u=>i.jsxs("button",{type:"button",className:Ze.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[i.jsx("span",{className:Ze.runtimeName,children:u.name}),i.jsx("span",{className:Ze.runtimeDescription,children:u.description})]},u.id))}),i.jsxs("div",{className:Ze.buttonRow,children:[i.jsx("button",{type:"button",className:Ze.ghostButton,onClick:o,children:"Back"}),i.jsx("button",{type:"button",className:Ze.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function pH(){return typeof Notification<"u"}function mH({onFinish:t,onBack:s,finishDisabled:o}){const r=pH(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return i.jsxs("div",{className:Ze.stepContent,"data-testid":"setup-notifications",children:[i.jsx("h2",{className:Ze.heading,children:"Stay in the Loop"}),i.jsx("p",{className:Ze.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?i.jsx("p",{className:Ze.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,i.jsxs("div",{className:Ze.buttonRow,children:[i.jsx("button",{type:"button",className:Ze.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:Ze.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),i.jsx("button",{type:"button",className:Ze.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):i.jsx("button",{type:"button",className:Ze.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const hH=4,_x={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function gH(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=dt(),{showToast:c}=pn(),d=mt(),[u,p]=x.useState(0),[m,g]=x.useState("claude-code"),[v,b]=x.useState(!1),y=t.find(j=>j.id==="claude-code"),S=x.useCallback(j=>{g(j),p(3)},[]),k=x.useCallback(()=>{const j=m;b(!0);const N=[];if(y&&j!==y.runtime){const C=_x[j]??"sonnet";N.push(s(y.id,void 0,void 0,void 0,j,C))}const T=t.find(C=>C.id===dy);if(T&&j!==T.runtime){const C=_x[j]??"sonnet";N.push(s(dy,void 0,void 0,void 0,j,C))}Promise.all(N).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,y,t,s,o,d,c]);return r===!0?i.jsx(ts,{to:"/",replace:!0}):i.jsx("div",{className:Ze.wizard,"data-testid":"setup-wizard",children:i.jsxs("div",{className:Ze.container,children:[i.jsx(gs,{mode:"wait",children:i.jsxs(Mt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&i.jsx(cH,{onNext:()=>p(1)}),u===1&&i.jsx(dH,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&i.jsx(fH,{currentRuntime:m,onFinish:S,onBack:()=>p(1),finishDisabled:!y}),u===3&&i.jsx(mH,{onFinish:k,onBack:()=>p(2),finishDisabled:v})]},u)}),i.jsx("div",{className:Ze.dots,children:Array.from({length:hH},(j,N)=>i.jsx("span",{className:Ze.dot,"data-active":N===u},N))})]})})}const vH="_root_zndgp_1",yH="_body_zndgp_7",bH="_main_zndgp_19",xH="_sidebarWrapper_zndgp_26",_H="_overlay_zndgp_51",Wr={root:vH,body:yH,main:bH,sidebarWrapper:xH,overlay:_H},kH=x.lazy(()=>YT(()=>import("./KnowledgePage-xY8zG7iT.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),rk=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function SH({tabs:t}){const{connected:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=dt(),{toasts:d,dismissToast:u}=pn(),p=Yt(),m=$7(),g=m!==void 0,[v,b]=x.useState(!1),y=x.useCallback(()=>b(S=>!S),[]);return x.useEffect(()=>{b(!1)},[p.pathname]),x.useEffect(()=>{if(!v)return;const S=k=>{k.key==="Escape"&&b(!1)};return document.addEventListener("keydown",S),()=>{document.removeEventListener("keydown",S)}},[v]),i.jsxs(i.Fragment,{children:[i.jsx(_I,{connected:s,environments:o,sessions:r,onToggleSidebar:g?y:void 0,sidebarOpen:v}),i.jsx(CI,{tabs:t}),i.jsxs("div",{className:Wr.body,children:[g&&i.jsx("div",{className:Wr.sidebarWrapper,"data-sidebar-open":v,children:i.jsx(II,{content:m})}),g&&v&&i.jsx("div",{className:Wr.overlay,"data-testid":"drawer-overlay",onClick:()=>b(!1)}),i.jsxs("div",{className:Wr.main,children:[i.jsx(Ya,{}),i.jsx(HI,{sessions:r,tasks:c,environments:o})]})]}),i.jsx(tO,{toasts:d,onDismiss:u}),i.jsx(j9,{})]})}function TH(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connected:d,onboardingCompleted:u}=dt(),{pluginNames:p}=gh(),{showToast:m}=pn();Gz(s,m),Jz(c,m),Fz(o,r,m);const g=mt(),v=Yt();if(x.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(Cm(t),{replace:!0})},[t,g,v.pathname]),d&&u===!1)return i.jsx(ts,{to:"/setup",replace:!0});const b=xz(p);return i.jsx(z7,{children:i.jsxs("div",{className:Wr.root,children:[rk&&i.jsx(XN,{}),i.jsx(SH,{tabs:b})]})})}function Up(){const{workspaceId:t}=as(),{workspaces:{workspaces:s}}=dt(),o=Yt(),r=s.find(m=>m.id===t);if(!(r!=null&&r.environmentId))return s.length===0?void 0:i.jsx(ts,{to:"/environments",replace:!0});const c=encodeURIComponent(t),d=`/workspaces/${c}`,u=o.pathname.startsWith(d)?o.pathname.slice(d.length):"",p=`/environments/${encodeURIComponent(r.environmentId)}/workspaces/${c}${u}${o.search}${o.hash}`;return i.jsx(ts,{to:p,replace:!0})}function jH(){const{pluginNames:t}=gh(),s=t.includes("orchestration"),o=t.includes("knowledge");return i.jsxs(Bw,{children:[i.jsx(Ne,{path:"setup",element:i.jsx(gH,{})}),i.jsxs(Ne,{element:i.jsx(TH,{}),children:[i.jsx(Ne,{index:!0,element:i.jsx(BU,{})}),i.jsx(Ne,{path:"chat",element:i.jsx(FU,{})}),i.jsx(Ne,{path:"sessions/new",element:i.jsx(ZU,{})}),i.jsx(Ne,{path:"sessions/:sessionId",element:i.jsx(WU,{})}),o&&i.jsx(Ne,{element:i.jsx(A9,{}),children:i.jsx(Ne,{path:"knowledge",element:i.jsx(x.Suspense,{fallback:i.jsx(A1,{}),children:i.jsx(kH,{})})})}),s&&i.jsxs(Ne,{element:i.jsx(w9,{}),children:[i.jsx(Ne,{path:"tasks",element:i.jsx(IU,{})}),i.jsx(Ne,{path:"tasks/new",element:i.jsx(px,{})}),i.jsx(Ne,{path:"tasks/:taskId",element:i.jsx(Ua,{})}),i.jsx(Ne,{path:"tasks/:taskId/edit",element:i.jsx(Ua,{})}),i.jsx(Ne,{path:"tasks/:taskId/stream",element:i.jsx(Ua,{})}),i.jsx(Ne,{path:"tasks/:taskId/findings",element:i.jsx(Ua,{})})]}),s&&i.jsxs(Ne,{element:i.jsx(E9,{}),children:[i.jsx(Ne,{path:"findings",element:i.jsx(bx,{})}),i.jsx(Ne,{path:"findings/:findingId",element:i.jsx(xx,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:i.jsx(bx,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:i.jsx(xx,{})})]}),i.jsxs(Ne,{element:i.jsx(N9,{}),children:[i.jsx(Ne,{path:"workspaces",element:i.jsx(ts,{to:"/environments",replace:!0})}),i.jsx(Ne,{path:"workspaces/new",element:i.jsx(fP,{})}),i.jsx(Ne,{path:"workspaces/:workspaceId",element:i.jsx(Up,{})}),i.jsx(Ne,{path:"workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Up,{})}),i.jsx(Ne,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:i.jsx(Up,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId",element:i.jsx(tP,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:i.jsx(px,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Ua,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:i.jsx(Ua,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:i.jsx(Ua,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:i.jsx(Ua,{})}),i.jsxs(Ne,{path:"environments",element:i.jsx(bP,{}),children:[i.jsx(Ne,{index:!0,element:i.jsx(OU,{})}),i.jsx(Ne,{path:"new",element:i.jsx(mP,{})}),i.jsx(Ne,{path:":environmentId",element:i.jsx(YP,{})}),i.jsx(Ne,{path:":environmentId/edit",element:i.jsx(hP,{})})]})]}),i.jsx(Ne,{element:i.jsx(C9,{}),children:i.jsxs(Ne,{path:"settings",element:i.jsx(XP,{}),children:[i.jsx(Ne,{index:!0,element:i.jsx(ts,{to:"credentials",replace:!0})}),i.jsx(Ne,{path:"environments",element:i.jsx(ts,{to:"/environments",replace:!0})}),i.jsx(Ne,{path:"credentials",element:i.jsx(QP,{})}),i.jsx(Ne,{path:"tokens",element:i.jsx(ts,{to:"../credentials",replace:!0})}),i.jsx(Ne,{path:"personas",element:i.jsx(e9,{})}),i.jsx(Ne,{path:"personas/new",element:i.jsx(gx,{})}),i.jsx(Ne,{path:"personas/:personaId",element:i.jsx(gx,{})}),i.jsx(Ne,{path:"schedules",element:i.jsx(u9,{})}),i.jsx(Ne,{path:"schedules/new",element:i.jsx(vx,{})}),i.jsx(Ne,{path:"schedules/:scheduleId",element:i.jsx(vx,{})}),i.jsx(Ne,{path:"appearance",element:i.jsx(_9,{})}),i.jsx(Ne,{path:"shortcuts",element:i.jsx(T9,{})}),i.jsx(Ne,{path:"about",element:i.jsx(S9,{})})]})}),i.jsx(Ne,{path:"*",element:i.jsx(ts,{to:"/",replace:!0})})]})]})}const wH=1e4;function NH(){const{onboardingCompleted:t}=dt(),[s,o]=x.useState(!1);x.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),wH);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return i.jsx(gs,{mode:"wait",children:r?i.jsx(Mt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:i.jsx(A1,{})},"splash"):i.jsx(Mt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:i.jsx(rN,{basename:"/".replace(/\/$/,""),children:i.jsx(jH,{})})},"app")})}function CH(){const t=rk?pz:qz;return i.jsx(gz,{children:i.jsx(L7,{children:i.jsx(M7,{children:i.jsx(t,{children:i.jsx(NH,{})})})})})}FT.createRoot(document.getElementById("root")).render(i.jsx(x.StrictMode,{children:i.jsx(CH,{})}));export{vs as B,Xx as K,dt as a,Gp as f,Cm as s,On as t,mt as u};
720
+ $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),D==="agent"&&i.jsxs("div",{children:[i.jsx("label",{children:"Allowed MCP Tools"}),i.jsx(sx,{selectedTools:Q,onChange:re=>{$(re),xe(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,re),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!Ce&&!ue&&i.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,i.jsx(ia,{isOpen:J,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:Se,onCancel:()=>me(!1)})]})}function u9(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=dt(),{showToast:c}=pn(),d=mt();return i.jsx(P8,{schedules:t,personas:r,onDeleteSchedule:async u=>{try{await s(u)}catch(p){throw console.error("Failed to delete schedule",{scheduleId:u,error:p}),c("Failed to delete schedule","error"),p}},onToggleEnabled:async(u,p)=>{try{return await o(u,p)}catch(m){throw console.error("Failed to update schedule",{scheduleId:u,error:m}),c("Failed to update schedule","error"),m}},onNavigateToNew:()=>d(_N),onNavigateToSchedule:u=>d(Jx(u))})}const f9="_container_1g4qh_1",p9="_form_1g4qh_7",m9="_formActions_1g4qh_66",h9="_editableSection_1g4qh_73",g9="_helperText_1g4qh_84",v9="_metaSection_1g4qh_90",y9="_optional_1g4qh_108",b9="_readonlyValue_1g4qh_113",yn={container:f9,form:p9,formActions:m9,editableSection:h9,helperText:g9,metaSection:v9,optional:y9,readonlyValue:b9};function vx(){const{scheduleId:t}=as(),s=mt(),{showToast:o}=pn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},environments:{environments:g},workspaces:{workspaces:v}}=dt(),b=t===void 0,y=b?void 0:r.find(k=>k.id===t);if(!b&&!c&&r.length>0&&!y)return i.jsx(ts,{to:tp,replace:!0});const S=[{label:"Settings",url:Ni},{label:"Schedules",url:tp},{label:b?"New Schedule":(y==null?void 0:y.title)??"Schedule",url:void 0}];return i.jsxs("div",{className:yn.container,children:[i.jsx(vs,{segments:S}),i.jsx(x9,{existing:y,isNew:b,personas:m,environments:g,workspaces:v,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(tp)},showToast:o})]})}function x9({existing:t,isNew:s,personas:o,environments:r,workspaces:c,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:m,showToast:g}){var W;const v=mt(),[b,y]=x.useState((t==null?void 0:t.title)??""),[S,k]=x.useState((t==null?void 0:t.description)??""),[j,N]=x.useState((t==null?void 0:t.scheduleExpression)??""),[T,C]=x.useState((t==null?void 0:t.personaId)??""),[A,I]=x.useState((t==null?void 0:t.environmentId)??""),[E,D]=x.useState((t==null?void 0:t.workspaceId)??""),[P,O]=x.useState(!1),[z,Q]=x.useState(null);x.useEffect(()=>{s||t&&z===null&&(y(t.title),k(t.description),N(t.scheduleExpression),C(t.personaId),I(t.environmentId),D(t.workspaceId))},[s,t,z]);const $=!s&&t===void 0,J=s&&b.trim().length>0&&j.trim().length>0&&T.length>0,me=o.map(ee=>({value:ee.id,label:ee.name})),te=[{value:"",label:"Auto-select (first connected)"},...r.map(ee=>({value:ee.id,label:ee.displayName}))],X=[{value:"",label:"System-level (no workspace)"},...c.map(ee=>({value:ee.id,label:ee.name}))],B=ee=>{ee.preventDefault(),J&&d(b,S,j,T,A||void 0,E||void 0).then(ue=>{g("Schedule created","success"),v(Jx(ue.id),{replace:!0})},()=>{g("Failed to create schedule","error")})},F=(ee,ue)=>{t&&u(t.id,{[ee]:ue}).then(()=>{g("Schedule updated","success"),ee==="title"&&y(String(ue)),ee==="description"&&k(String(ue)),ee==="scheduleExpression"&&N(String(ue)),ee==="personaId"&&C(String(ue)),ee==="environmentId"&&I(String(ue))},()=>{g("Failed to update schedule","error")})},Z=()=>{if(!t)return;const ee=!t.enabled;u(t.id,{enabled:ee}).then(()=>{g(ee?"Schedule enabled":"Schedule disabled","success")},()=>{g("Failed to update schedule","error")})},de=()=>{t&&p(t.id).then(()=>{g("Schedule deleted","success"),m()},()=>{g("Failed to delete schedule","error")})};return i.jsxs(i.Fragment,{children:[$?i.jsxs("div",{className:yn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsx("p",{children:"Loading schedule..."})]}):s?i.jsxs("form",{onSubmit:B,className:yn.form,children:[i.jsx("h3",{children:"Create Schedule"}),i.jsxs("label",{children:["Title",i.jsx("input",{type:"text",value:b,onChange:ee=>y(ee.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description ",i.jsx("span",{className:yn.optional,children:"(optional)"}),i.jsx("input",{type:"text",value:S,onChange:ee=>k(ee.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx("input",{type:"text",value:j,onChange:ee=>N(ee.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),i.jsxs("p",{className:yn.helperText,children:["Interval: ",i.jsx("code",{children:"30s"}),", ",i.jsx("code",{children:"5m"}),", ",i.jsx("code",{children:"1h"}),", ",i.jsx("code",{children:"1d"})," (min 10s)  |  Cron: ",i.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),i.jsxs("label",{children:["Persona",i.jsxs("select",{value:T,onChange:ee=>C(ee.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[i.jsx("option",{value:"",children:"Select a persona..."}),me.map(ee=>i.jsx("option",{value:ee.value,children:ee.label},ee.value))]})]}),i.jsxs("label",{children:["Environment ",i.jsx("span",{className:yn.optional,children:"(optional)"}),i.jsx("select",{value:A,onChange:ee=>I(ee.target.value),"data-testid":"schedule-detail-environment",children:te.map(ee=>i.jsx("option",{value:ee.value,children:ee.label},ee.value))})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:yn.optional,children:"(optional)"}),i.jsx("select",{value:E,onChange:ee=>D(ee.target.value),"data-testid":"schedule-detail-workspace",children:X.map(ee=>i.jsx("option",{value:ee.value,children:ee.label},ee.value))})]}),i.jsxs("div",{className:yn.formActions,children:[i.jsx(tn,{type:"submit",variant:"primary",size:"md",disabled:!J,"data-testid":"schedule-detail-save",children:"Create"}),i.jsx(tn,{type:"button",variant:"outline",size:"md",onClick:m,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?i.jsxs("div",{className:yn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsxs("div",{className:yn.formActions,children:[i.jsx(tn,{type:"button",variant:"outline",size:"md",onClick:m,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),i.jsx(tn,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:Z,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),i.jsx(tn,{type:"button",variant:"danger",size:"md",onClick:()=>O(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),i.jsxs("div",{className:yn.editableSection,children:[i.jsxs("label",{children:["Title",i.jsx(Ft,{value:b,onSave:ee=>{F("title",ee)},validate:ee=>ee.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:z,onActivate:Q,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description",i.jsx(Ft,{value:S,onSave:ee=>{F("description",ee)},fieldId:"schedule-description",activeFieldId:z,onActivate:Q,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx(Ft,{value:j,onSave:ee=>{F("scheduleExpression",ee)},validate:ee=>ee.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:z,onActivate:Q,placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",ariaLabel:"Schedule expression","data-testid":"schedule-detail-expression"})]}),i.jsxs("label",{children:["Persona",i.jsx(Uo,{value:T,onSave:ee=>{F("personaId",ee)},options:me,fieldId:"schedule-persona",activeFieldId:z,onActivate:Q,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),i.jsxs("label",{children:["Environment ",i.jsx("span",{className:yn.optional,children:"(optional — empty = auto-select)"}),i.jsx(Uo,{value:A,onSave:ee=>{F("environmentId",ee)},options:te,fieldId:"schedule-environment",activeFieldId:z,onActivate:Q,ariaLabel:"Schedule environment","data-testid":"schedule-detail-environment"})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:yn.optional,children:"(optional — set at creation)"}),i.jsx("span",{className:yn.readonlyValue,"data-testid":"schedule-detail-workspace",children:((W=c.find(ee=>ee.id===t.workspaceId))==null?void 0:W.name)??"System-level (no workspace)"})]})]}),i.jsxs("div",{className:yn.metaSection,children:[t.lastRunAt?i.jsxs("span",{children:["Last run: ",Po(t.lastRunAt)]}):i.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?i.jsxs("span",{children:["Next run: ",B1(t.nextRunAt)]}):null,t.runCount>0&&i.jsxs("span",{children:["Total runs: ",t.runCount]}),i.jsxs("span",{children:["Created: ",Po(t.createdAt)]})]})]}):null,i.jsx(ia,{isOpen:P,title:"Delete Schedule?",description:`"${t==null?void 0:t.title}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:de,onCancel:()=>O(!1)})]})}function _9(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=J1();return i.jsx(lB,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function k9(){const[t,s]=x.useState(void 0);return x.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Qe.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function S9(){const{connected:t,environments:{environments:s},sessions:{sessions:o}}=dt(),r=k9();return i.jsxs(i.Fragment,{children:[r&&i.jsx(fO,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),i.jsx(cB,{connected:t,environments:s,sessions:o})]})}function T9(){return i.jsx(WL,{})}const yx=Ii();function j9(){const t=mt();return na({key:"?"},()=>{t(kN)}),na({key:"n"},()=>{t(yx)}),na({key:"N"},()=>{t(yx)}),i.jsx(i.Fragment,{})}function xl(t){const s=U7();x.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function w9(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=dt(),o=x.useMemo(()=>i.jsx(H5,{workspaces:t,tasks:s}),[t,s]);return xl(o),i.jsx(Ya,{})}function N9(){const{environments:{environments:t}}=dt(),s=x.useMemo(()=>i.jsx(XI,{environments:t}),[t]);return xl(s),i.jsx(Ya,{})}function C9(){const t=x.useMemo(()=>i.jsx(F8,{}),[]);return xl(t),i.jsx(Ya,{})}function E9(){const{findings:{findings:t,loadFindings:s,loadAllFindings:o}}=dt(),{workspaceId:r,environmentId:c}=as();x.useEffect(()=>{r?s(r).catch(()=>{}):o().catch(()=>{})},[r,s,o]);const d=x.useMemo(()=>i.jsx(c5,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return xl(d),i.jsx(Ya,{})}function A9(){const{knowledge:t,workspaces:{workspaces:s}}=dt(),o=x.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=x.useCallback(()=>{t.clearSearch()},[t]),c=x.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=x.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=x.useMemo(()=>i.jsx(uI,{nodes:t.graphData.nodes,workspaces:s,loading:t.loading,searchQuery:t.searchQuery,onSearch:o,onClearSearch:r,onSelectNode:c,onWorkspaceChange:d}),[t,s,o,r,c,d]);return xl(u),i.jsx(Ya,{})}const D9="_container_ce571_1",R9="_title_ce571_6",kd={container:D9,title:R9};function M9(){return i.jsxs("div",{className:kd.container,"aria-hidden":"true",children:[i.jsx("h1",{className:kd.title,children:"Findings"}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>i.jsx(bd,{lines:3},s))})]})}function bx(){const{environmentId:t,workspaceId:s}=as(),{findings:{findings:o,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=dt(),p=mt();x.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=x.useCallback(v=>{p(Gp(v,s,t))},[p,s,t]);if(r)return i.jsx(M9,{});const g=s&&t?sk("Findings",s,t,d,u).slice(0,-1):X7();return i.jsxs("div",{className:kd.container,"data-testid":"findings-list-page",children:[i.jsx(vs,{segments:g}),i.jsx("h1",{className:kd.title,children:"Findings"}),i.jsx(P1,{findings:o,onFindingClick:m})]})}const I9="_container_1wwpb_1",O9="_notFound_1wwpb_6",B9="_header_1wwpb_12",L9="_categoryBadge_1wwpb_19",z9="_title_1wwpb_28",$9="_content_1wwpb_35",U9="_tags_1wwpb_77",P9="_tag_1wwpb_77",H9="_meta_1wwpb_92",V9="_metaTimestamp_1wwpb_100",q9="_metaLink_1wwpb_105",vn={container:I9,notFound:O9,header:B9,categoryBadge:L9,title:z9,content:$9,tags:U9,tag:P9,meta:H9,metaTimestamp:V9,metaLink:q9};function xx(){const{findingId:t,environmentId:s,workspaceId:o}=as(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=dt(),m=mt();if(x.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return i.jsx("div",{className:vn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:vn.notFound,children:"Loading..."})});if(!r)return i.jsx("div",{className:vn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:vn.notFound,children:"Finding not found."})});const g=sk(r.title,o,s,u,p),v=xd(r.category);return i.jsxs("div",{className:vn.container,"data-testid":"finding-detail-page",children:[i.jsx(vs,{segments:g}),i.jsxs("div",{className:vn.header,children:[i.jsx("span",{className:vn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),i.jsx("h1",{className:vn.title,children:r.title})]}),r.content&&i.jsx("div",{className:vn.content,children:i.jsx(Td,{remarkPlugins:[jd],children:r.content})}),r.tags.length>0&&i.jsx("div",{className:vn.tags,children:r.tags.map(b=>i.jsx("span",{className:vn.tag,children:b},b))}),i.jsxs("div",{className:vn.meta,children:[i.jsx("span",{className:vn.metaTimestamp,title:r.createdAt,children:Po(r.createdAt)}),r.taskId&&i.jsx("button",{type:"button",className:vn.metaLink,onClick:()=>{m(On(r.taskId))},children:"View Task"}),r.sessionId&&i.jsx("button",{type:"button",className:vn.metaLink,onClick:()=>{m(Cm(r.sessionId))},children:"View Session"})]})]})}const G9="_wizard_1260s_1",F9="_container_1260s_10",Z9="_stepContent_1260s_19",K9="_logoArea_1260s_28",Y9="_logoImage_1260s_32",J9="_heading_1260s_41",W9="_tagline_1260s_49",X9="_subtitle_1260s_56",Q9="_featureList_1260s_64",eH="_runtimeGrid_1260s_89",tH="_runtimeCard_1260s_101",nH="_runtimeName_1260s_133",sH="_runtimeDescription_1260s_139",aH="_buttonRow_1260s_144",iH="_primaryButton_1260s_151",oH="_ghostButton_1260s_185",rH="_dots_1260s_213",lH="_dot_1260s_213",Ze={wizard:G9,container:F9,stepContent:Z9,logoArea:K9,logoImage:Y9,heading:J9,tagline:W9,subtitle:X9,featureList:Q9,runtimeGrid:eH,runtimeCard:tH,runtimeName:nH,runtimeDescription:sH,buttonRow:aH,primaryButton:iH,ghostButton:oH,dots:rH,dot:lH};function cH({onNext:t}){return i.jsxs("div",{className:Ze.stepContent,"data-testid":"setup-welcome",children:[i.jsx("div",{className:Ze.logoArea,children:i.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Ze.logoImage})}),i.jsx("h1",{className:Ze.heading,children:"Welcome to Grackle"}),i.jsx("p",{className:Ze.tagline,children:"Multi-agent orchestration for software teams"}),i.jsx("button",{type:"button",className:Ze.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function dH({onNext:t,onBack:s}){return i.jsxs("div",{className:Ze.stepContent,"data-testid":"setup-about",children:[i.jsx("h2",{className:Ze.heading,children:"What is Grackle?"}),i.jsxs("ul",{className:Ze.featureList,children:[i.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),i.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),i.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),i.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),i.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),i.jsxs("div",{className:Ze.buttonRow,children:[i.jsx("button",{type:"button",className:Ze.ghostButton,onClick:s,children:"Back"}),i.jsx("button",{type:"button",className:Ze.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const uH=[{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 fH({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=x.useState(t||"claude-code");return x.useEffect(()=>{t&&d(t)},[t]),i.jsxs("div",{className:Ze.stepContent,"data-testid":"setup-runtime",children:[i.jsx("h2",{className:Ze.heading,children:"Choose Your Runtime"}),i.jsx("p",{className:Ze.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),i.jsx("div",{className:Ze.runtimeGrid,children:uH.map(u=>i.jsxs("button",{type:"button",className:Ze.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[i.jsx("span",{className:Ze.runtimeName,children:u.name}),i.jsx("span",{className:Ze.runtimeDescription,children:u.description})]},u.id))}),i.jsxs("div",{className:Ze.buttonRow,children:[i.jsx("button",{type:"button",className:Ze.ghostButton,onClick:o,children:"Back"}),i.jsx("button",{type:"button",className:Ze.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function pH(){return typeof Notification<"u"}function mH({onFinish:t,onBack:s,finishDisabled:o}){const r=pH(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return i.jsxs("div",{className:Ze.stepContent,"data-testid":"setup-notifications",children:[i.jsx("h2",{className:Ze.heading,children:"Stay in the Loop"}),i.jsx("p",{className:Ze.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?i.jsx("p",{className:Ze.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,i.jsxs("div",{className:Ze.buttonRow,children:[i.jsx("button",{type:"button",className:Ze.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:Ze.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),i.jsx("button",{type:"button",className:Ze.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):i.jsx("button",{type:"button",className:Ze.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const hH=4,_x={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function gH(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=dt(),{showToast:c}=pn(),d=mt(),[u,p]=x.useState(0),[m,g]=x.useState("claude-code"),[v,b]=x.useState(!1),y=t.find(j=>j.id==="claude-code"),S=x.useCallback(j=>{g(j),p(3)},[]),k=x.useCallback(()=>{const j=m;b(!0);const N=[];if(y&&j!==y.runtime){const C=_x[j]??"sonnet";N.push(s(y.id,void 0,void 0,void 0,j,C))}const T=t.find(C=>C.id===dy);if(T&&j!==T.runtime){const C=_x[j]??"sonnet";N.push(s(dy,void 0,void 0,void 0,j,C))}Promise.all(N).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,y,t,s,o,d,c]);return r===!0?i.jsx(ts,{to:"/",replace:!0}):i.jsx("div",{className:Ze.wizard,"data-testid":"setup-wizard",children:i.jsxs("div",{className:Ze.container,children:[i.jsx(gs,{mode:"wait",children:i.jsxs(Mt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&i.jsx(cH,{onNext:()=>p(1)}),u===1&&i.jsx(dH,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&i.jsx(fH,{currentRuntime:m,onFinish:S,onBack:()=>p(1),finishDisabled:!y}),u===3&&i.jsx(mH,{onFinish:k,onBack:()=>p(2),finishDisabled:v})]},u)}),i.jsx("div",{className:Ze.dots,children:Array.from({length:hH},(j,N)=>i.jsx("span",{className:Ze.dot,"data-active":N===u},N))})]})})}const vH="_root_zndgp_1",yH="_body_zndgp_7",bH="_main_zndgp_19",xH="_sidebarWrapper_zndgp_26",_H="_overlay_zndgp_51",Wr={root:vH,body:yH,main:bH,sidebarWrapper:xH,overlay:_H},kH=x.lazy(()=>YT(()=>import("./KnowledgePage-UWFPbEn4.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),rk=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function SH({tabs:t}){const{connected:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=dt(),{toasts:d,dismissToast:u}=pn(),p=Yt(),m=$7(),g=m!==void 0,[v,b]=x.useState(!1),y=x.useCallback(()=>b(S=>!S),[]);return x.useEffect(()=>{b(!1)},[p.pathname]),x.useEffect(()=>{if(!v)return;const S=k=>{k.key==="Escape"&&b(!1)};return document.addEventListener("keydown",S),()=>{document.removeEventListener("keydown",S)}},[v]),i.jsxs(i.Fragment,{children:[i.jsx(_I,{connected:s,environments:o,sessions:r,onToggleSidebar:g?y:void 0,sidebarOpen:v}),i.jsx(CI,{tabs:t}),i.jsxs("div",{className:Wr.body,children:[g&&i.jsx("div",{className:Wr.sidebarWrapper,"data-sidebar-open":v,children:i.jsx(II,{content:m})}),g&&v&&i.jsx("div",{className:Wr.overlay,"data-testid":"drawer-overlay",onClick:()=>b(!1)}),i.jsxs("div",{className:Wr.main,children:[i.jsx(Ya,{}),i.jsx(HI,{sessions:r,tasks:c,environments:o})]})]}),i.jsx(tO,{toasts:d,onDismiss:u}),i.jsx(j9,{})]})}function TH(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connected:d,onboardingCompleted:u}=dt(),{pluginNames:p}=gh(),{showToast:m}=pn();Gz(s,m),Jz(c,m),Fz(o,r,m);const g=mt(),v=Yt();if(x.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(Cm(t),{replace:!0})},[t,g,v.pathname]),d&&u===!1)return i.jsx(ts,{to:"/setup",replace:!0});const b=xz(p);return i.jsx(z7,{children:i.jsxs("div",{className:Wr.root,children:[rk&&i.jsx(XN,{}),i.jsx(SH,{tabs:b})]})})}function Up(){const{workspaceId:t}=as(),{workspaces:{workspaces:s}}=dt(),o=Yt(),r=s.find(m=>m.id===t);if(!(r!=null&&r.environmentId))return s.length===0?void 0:i.jsx(ts,{to:"/environments",replace:!0});const c=encodeURIComponent(t),d=`/workspaces/${c}`,u=o.pathname.startsWith(d)?o.pathname.slice(d.length):"",p=`/environments/${encodeURIComponent(r.environmentId)}/workspaces/${c}${u}${o.search}${o.hash}`;return i.jsx(ts,{to:p,replace:!0})}function jH(){const{pluginNames:t}=gh(),s=t.includes("orchestration"),o=t.includes("knowledge");return i.jsxs(Bw,{children:[i.jsx(Ne,{path:"setup",element:i.jsx(gH,{})}),i.jsxs(Ne,{element:i.jsx(TH,{}),children:[i.jsx(Ne,{index:!0,element:i.jsx(BU,{})}),i.jsx(Ne,{path:"chat",element:i.jsx(FU,{})}),i.jsx(Ne,{path:"sessions/new",element:i.jsx(ZU,{})}),i.jsx(Ne,{path:"sessions/:sessionId",element:i.jsx(WU,{})}),o&&i.jsx(Ne,{element:i.jsx(A9,{}),children:i.jsx(Ne,{path:"knowledge",element:i.jsx(x.Suspense,{fallback:i.jsx(A1,{}),children:i.jsx(kH,{})})})}),s&&i.jsxs(Ne,{element:i.jsx(w9,{}),children:[i.jsx(Ne,{path:"tasks",element:i.jsx(IU,{})}),i.jsx(Ne,{path:"tasks/new",element:i.jsx(px,{})}),i.jsx(Ne,{path:"tasks/:taskId",element:i.jsx(Ua,{})}),i.jsx(Ne,{path:"tasks/:taskId/edit",element:i.jsx(Ua,{})}),i.jsx(Ne,{path:"tasks/:taskId/stream",element:i.jsx(Ua,{})}),i.jsx(Ne,{path:"tasks/:taskId/findings",element:i.jsx(Ua,{})})]}),s&&i.jsxs(Ne,{element:i.jsx(E9,{}),children:[i.jsx(Ne,{path:"findings",element:i.jsx(bx,{})}),i.jsx(Ne,{path:"findings/:findingId",element:i.jsx(xx,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:i.jsx(bx,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:i.jsx(xx,{})})]}),i.jsxs(Ne,{element:i.jsx(N9,{}),children:[i.jsx(Ne,{path:"workspaces",element:i.jsx(ts,{to:"/environments",replace:!0})}),i.jsx(Ne,{path:"workspaces/new",element:i.jsx(fP,{})}),i.jsx(Ne,{path:"workspaces/:workspaceId",element:i.jsx(Up,{})}),i.jsx(Ne,{path:"workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Up,{})}),i.jsx(Ne,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:i.jsx(Up,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId",element:i.jsx(tP,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:i.jsx(px,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Ua,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:i.jsx(Ua,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:i.jsx(Ua,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:i.jsx(Ua,{})}),i.jsxs(Ne,{path:"environments",element:i.jsx(bP,{}),children:[i.jsx(Ne,{index:!0,element:i.jsx(OU,{})}),i.jsx(Ne,{path:"new",element:i.jsx(mP,{})}),i.jsx(Ne,{path:":environmentId",element:i.jsx(YP,{})}),i.jsx(Ne,{path:":environmentId/edit",element:i.jsx(hP,{})})]})]}),i.jsx(Ne,{element:i.jsx(C9,{}),children:i.jsxs(Ne,{path:"settings",element:i.jsx(XP,{}),children:[i.jsx(Ne,{index:!0,element:i.jsx(ts,{to:"credentials",replace:!0})}),i.jsx(Ne,{path:"environments",element:i.jsx(ts,{to:"/environments",replace:!0})}),i.jsx(Ne,{path:"credentials",element:i.jsx(QP,{})}),i.jsx(Ne,{path:"tokens",element:i.jsx(ts,{to:"../credentials",replace:!0})}),i.jsx(Ne,{path:"personas",element:i.jsx(e9,{})}),i.jsx(Ne,{path:"personas/new",element:i.jsx(gx,{})}),i.jsx(Ne,{path:"personas/:personaId",element:i.jsx(gx,{})}),i.jsx(Ne,{path:"schedules",element:i.jsx(u9,{})}),i.jsx(Ne,{path:"schedules/new",element:i.jsx(vx,{})}),i.jsx(Ne,{path:"schedules/:scheduleId",element:i.jsx(vx,{})}),i.jsx(Ne,{path:"appearance",element:i.jsx(_9,{})}),i.jsx(Ne,{path:"shortcuts",element:i.jsx(T9,{})}),i.jsx(Ne,{path:"about",element:i.jsx(S9,{})})]})}),i.jsx(Ne,{path:"*",element:i.jsx(ts,{to:"/",replace:!0})})]})]})}const wH=1e4;function NH(){const{onboardingCompleted:t}=dt(),[s,o]=x.useState(!1);x.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),wH);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return i.jsx(gs,{mode:"wait",children:r?i.jsx(Mt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:i.jsx(A1,{})},"splash"):i.jsx(Mt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:i.jsx(rN,{basename:"/".replace(/\/$/,""),children:i.jsx(jH,{})})},"app")})}function CH(){const t=rk?pz:qz;return i.jsx(gz,{children:i.jsx(L7,{children:i.jsx(M7,{children:i.jsx(t,{children:i.jsx(NH,{})})})})})}FT.createRoot(document.getElementById("root")).render(i.jsx(x.StrictMode,{children:i.jsx(CH,{})}));export{vs as B,Xx as K,dt as a,Gp as f,Cm as s,On as t,mt as u};