@grackle-ai/web 0.117.0 → 0.118.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/McpAppWidget-DbYqtOnr.js","assets/dagview-tHPW3Rz3.js","assets/KnowledgePage-CeXH3fcj.js","assets/grpc-C_kp5RGL.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
2
- import{r as y2,a as b2,b as y,j as i,d as Q0,H as ey,P as ty,i as _2,B as x2,c as k2,C as S2,M as j2,e as T2}from"./dagview-tHPW3Rz3.js";import{c as w2,a as pd,G as N2,b as C2,d as E2,e as A2,f as D2,M as M2,D as g_,A as v_,W as R2,O as I2,g as O2,C as ra,h as y_,i as b_,w as B2,t as L2,p as Nc,j as z2,R as Cc,S as ny}from"./grpc-C_kp5RGL.js";import{v as $2,r as H2,t as Ec,i as P2,f as U2,M as cm,a as dm}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 Hf={exports:{}},Mr={},Pf={exports:{}},Uf={};/**
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/McpAppWidget-DbYqtOnr.js","assets/dagview-tHPW3Rz3.js","assets/KnowledgePage-CZ_d8wQh.js","assets/grpc-DZTrE-Du.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
2
+ import{r as y2,a as b2,b as y,j as i,d as Q0,H as ey,P as ty,i as _2,B as x2,c as k2,C as S2,M as j2,e as T2}from"./dagview-tHPW3Rz3.js";import{c as w2,a as pd,G as N2,b as C2,d as E2,e as A2,f as D2,M as M2,D as g_,A as v_,W as R2,O as I2,g as O2,C as ra,h as y_,i as b_,w as B2,t as L2,p as Nc,j as z2,R as Cc,S as ny}from"./grpc-DZTrE-Du.js";import{v as $2,r as H2,t as Ec,i as P2,f as U2,M as cm,a as dm}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 Hf={exports:{}},Mr={},Pf={exports:{}},Uf={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
5
5
  *
@@ -322,7 +322,7 @@ ${r.content}`);break}}}return s.join(`
322
322
 
323
323
  ${r}
324
324
 
325
- --- End forwarded ---`}function n5(t){return t.replace(/[\r\n]+/g," ").trim().replace(/---/g,"—")}function s5({events:t,formatForClipboard:s}){const[o,r]=y.useState(!1),[c,d]=y.useState(new Set),u=y.useRef(void 0),p=y.useMemo(()=>c.size,[c]),m=y.useCallback(S=>{r(!0),S!==void 0?(d(new Set([S])),u.current=S):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((S,j)=>{if(j&&u.current!==void 0){const T=Math.min(u.current,S),w=Math.max(u.current,S);d(C=>{const D=new Set(C);for(let R=T;R<=w;R++)R<t.length&&il(t[R])&&D.add(R);return D})}else d(T=>{const w=new Set(T);return w.has(S)?w.delete(S):w.add(S),w.size===0?(r(!1),u.current=void 0):u.current=S,w})},[t]),b=y.useCallback(()=>{const S=new Set;for(let j=0;j<t.length;j++)il(t[j])&&S.add(j);d(S)},[t]),_=y.useCallback(()=>{d(new Set)},[]),k=y.useCallback(async()=>{const j=[...c].sort((w,C)=>w-C).filter(w=>w<t.length).map(w=>t[w]);if(j.length===0)return!1;const T=s(j);try{return await navigator.clipboard.writeText(T),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:_,copySelected:k}}const a5="_wrapper_1cdza_1",i5="_scrollContainer_1cdza_9",o5="_selectingPadding_1cdza_16",r5="_toolbar_1cdza_20",l5="_directionToggle_1cdza_27",c5="_scrollToAnchor_1cdza_65",d5="_scrollToAnchorBottom_1cdza_89",u5="_scrollToAnchorTop_1cdza_93",f5="_eventOverflowWarning_1cdza_97",sa={wrapper:a5,scrollContainer:i5,selectingPadding:o5,toolbar:r5,directionToggle:l5,scrollToAnchor:c5,scrollToAnchorBottom:d5,scrollToAnchorTop:u5,eventOverflowWarning:f5},p5=10*1024,m5=new Set(["running","idle"]);function h5(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 A1="grackle-stream-direction";function g5(){try{return localStorage.getItem(A1)==="reversed"}catch{return!1}}function v5({eventsDropped:t}){return t<=0?i.jsx(i.Fragment,{}):i.jsxs("div",{className:sa.eventOverflowWarning,role:"alert",children:[i.jsx(fm,{size:zt,"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 sh({events:t,eventsDropped:s,emptyState:o,onShowToast:r,sessions:c,currentSessionId:d,environments:u,personas:p,onForward:m,sandboxProxyUrl:g}){const v=y.useRef(null),[b,_]=y.useState(g5),k=E3(),[S,j]=y.useState(!1),[T,w]=y.useState(!1),[C,D]=y.useState(void 0),R=s5({events:t,formatForClipboard:E1}),E=y.useMemo(()=>t.filter(il).length,[t]),M=y.useMemo(()=>c?c.filter(ce=>m5.has(ce.status)&&ce.id!==d):[],[c,d]),O=y.useMemo(()=>b?[...t].reverse():t,[t,b]),{isAtAnchor:A,scrollToAnchor:$}=X6({scrollRef:v,contentLength:t.length,isReversed:b,paused:R.isSelecting}),Y=()=>{const ce=!b;_(ce);try{localStorage.setItem(A1,ce?"reversed":"default")}catch{}};y.useEffect(()=>{if(!R.isSelecting)return;const ce=me=>{me.key==="Escape"&&!S&&!T&&R.cancelSelection()};return window.addEventListener("keydown",ce),()=>{window.removeEventListener("keydown",ce)}},[R.isSelecting,R.cancelSelection,S,T]);const V=y.useCallback(async()=>{await R.copySelected()&&(r==null||r(`Copied ${R.selectedCount} message${R.selectedCount===1?"":"s"} to clipboard`,"success"))},[R,r]),ee=y.useCallback(()=>[...R.selectedIndices].sort((me,ke)=>me-ke).filter(me=>me<t.length).map(me=>t[me]),[R.selectedIndices,t]),le=y.useCallback(ce=>{if(!ce)return"this session";const me=c==null?void 0:c.find(De=>De.id===ce);if(!me)return ce.slice(0,8);const ke=u==null?void 0:u.find(De=>De.id===me.environmentId);return(ke==null?void 0:ke.displayName)??me.environmentId.slice(0,8)},[c,u]),Z=y.useCallback(async(ce,me)=>{if(!m)return;const ke=le(ce);try{await m(ce,me);const De=R.selectedCount;r==null||r(`Forwarded ${De} message${De===1?"":"s"} to ${ke}`,"success"),R.cancelSelection()}catch{r==null||r("Failed to forward messages","error")}},[m,le,r,R]),ae=y.useCallback(ce=>{j(!1);const me=ee(),ke=le(d),De=t5(ke,me);if(new TextEncoder().encode(De).length>p5){D({sessionId:ce,text:De}),w(!0);return}Z(ce,De).catch(()=>{})},[ee,le,d,Z]),H=y.useCallback(()=>{w(!1),C&&(Z(C.sessionId,C.text).catch(()=>{}),D(void 0))},[C,Z]),B=y.useCallback(()=>{w(!1),D(void 0)},[]),F=k?0:.2,ge=b?-8:8,ne=C?Math.round(new TextEncoder().encode(C.text).length/1024):0;return i.jsxs("div",{className:sa.wrapper,children:[i.jsx("div",{className:sa.toolbar,children:i.jsx(Ti,{text:b?"Showing newest first":"Showing oldest first",children:i.jsx("button",{className:sa.directionToggle,onClick:Y,"aria-label":b?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:b?i.jsx(dy,{size:zt,"aria-hidden":"true"}):i.jsx(uy,{size:zt,"aria-hidden":"true"})})})}),i.jsxs("div",{ref:v,className:`${sa.scrollContainer} ${R.isSelecting?sa.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,i.jsx(v5,{eventsDropped:s}),i.jsx(as,{initial:!1,children:O.map((ce,me)=>{const ke=b?t.length-1-me:me;return i.jsx($t.div,{initial:{opacity:0,y:ge},animate:{opacity:1,y:0},transition:{duration:F,ease:"easeOut"},children:i.jsx(y6,{copyText:e5(ce),isContentBearing:il(ce),isSelecting:R.isSelecting,isSelected:R.selectedIndices.has(ke),checkboxLabel:h5(ce),onSelect:()=>{R.enterSelectionMode(ke)},onToggle:De=>{R.toggleEvent(ke,De)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:i.jsx(sD,{event:ce,toolUseCtx:ce.toolUseCtx,settled:ce.settled,sandboxProxyUrl:g})})},`${ce.sessionId}-${ce.timestamp}-${ke}`)})})]}),i.jsx(as,{children:R.isSelecting&&i.jsx(N6,{selectedCount:R.selectedCount,totalSelectable:E,onSelectAll:R.selectAll,onDeselectAll:R.deselectAll,onCopy:()=>{V().catch(()=>{})},onForward:m!==void 0?()=>{j(!0)}:void 0,forwardDisabled:M.length===0,onCancel:R.cancelSelection})}),i.jsx(Y6,{isOpen:S,sessions:M,environments:u??[],personas:p,onSelect:ae,onCancel:()=>{j(!1)}}),i.jsx(ys,{isOpen:T,title:"Send large message?",description:`This will forward a large message (${ne} KB). Continue?`,confirmLabel:"Send",onConfirm:H,onCancel:B}),i.jsx(as,{children:!A&&i.jsxs($t.button,{className:`${sa.scrollToAnchor} ${b?sa.scrollToAnchorTop:sa.scrollToAnchorBottom}`,onClick:$,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[b?i.jsx(uy,{size:zt,"aria-hidden":"true"}):i.jsx(dy,{size:zt,"aria-hidden":"true"})," New events"]})})]})}function ah(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[b,_]=y.useState(""),k=y.useRef(!1),S=d===c,j=y.useCallback(O=>{v(O),_("")},[]),T=y.useCallback(()=>{_("")},[]),w=y.useCallback(()=>{k.current=!1,u==null||u(null),v(""),_("")},[u]),C=y.useCallback(()=>{const O=m?g.trim():g;if(r){const $=r(g);if($){_($);return}}const A=m?s.trim():s;if(O===A){w();return}o(O),w()},[g,s,m,r,o,w]),D=y.useCallback(()=>{k.current=!0,u==null||u(c),v(s),_("")},[c,s,u]),R=y.useCallback(O=>{if(k.current){k.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(O=>{O.key==="Escape"?w():O.key==="Enter"&&p&&C()},[w,p,C]),M=(()=>{if(!S)return!1;const O=m?s.trim():s;return(m?g.trim():g)!==O})();return y.useEffect(()=>{!S&&(g!==""||b!=="")&&(v(""),_(""))},[S,g,b]),{isEditing:S,draft:g,error:b,isDirty:M,startEdit:D,cancelEdit:w,save:C,setDraft:j,clearError:T,handleBlur:R,handleKeyDown:E,ignoreInitialBlurRef:k}}const y5="_editFieldWrapper_yuzty_1",b5="_editInput_yuzty_10",_5="_editTextarea_yuzty_42",x5="_editSelect_yuzty_78",k5="_editError_yuzty_111",S5="_editInputInvalid_yuzty_118",j5="_editHint_yuzty_123",T5="_unsavedDot_yuzty_132",w5="_metaValueClickable_yuzty_140",N5="_editButton_yuzty_159",C5="_metaPlaceholder_yuzty_175",E5="_worktreeToggle_yuzty_180",it={editFieldWrapper:y5,editInput:b5,editTextarea:_5,editSelect:x5,editError:k5,editInputInvalid:S5,editHint:j5,unsavedDot:T5,metaValueClickable:w5,editButton:N5,metaPlaceholder:C5,worktreeToggle:E5};function Bt(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:_,"data-testid":k}=t,S=y.useRef(null),j=ah({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(j.isEditing){const w=window.setTimeout(()=>{var C;(C=S.current)==null||C.focus()},0);return()=>window.clearTimeout(w)}},[j.isEditing]),c==="create"){const w=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return i.jsxs("div",{className:it.editFieldWrapper,children:[i.jsx("input",{className:`${it.editInput} ${C?it.editInputInvalid:""}`,value:s,onChange:w,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),C&&i.jsx("span",{className:it.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return i.jsxs("div",{className:it.editFieldWrapper,children:[i.jsx("input",{ref:S,className:`${it.editInput} ${j.error?it.editInputInvalid:""}`,value:j.draft,onChange:w=>j.setDraft(w.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),j.isDirty&&i.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),j.error&&i.jsx("span",{className:it.editError,"data-testid":"edit-error",children:j.error}),i.jsx("span",{className:it.editHint,children:"Enter to save · Esc to cancel"})]});const T=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":_,"data-testid":k?`${k}-button`:void 0,children:[T!==void 0?T:s?i.jsx("span",{children:s}):i.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function tm(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":_}=t,k=y.useRef(null),S=ah({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(S.isEditing){const T=window.setTimeout(()=>{var w;(w=k.current)==null||w.focus()},0);return()=>window.clearTimeout(T)}},[S.isEditing]),c==="create"){const T=C=>{m==null||m(C.target.value)},w=r==null?void 0:r(s);return i.jsxs("div",{className:it.editFieldWrapper,children:[i.jsx("textarea",{className:`${it.editTextarea} ${w?it.editInputInvalid:""}`,value:s,onChange:T,placeholder:v,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),w&&i.jsx("span",{className:it.editError,"data-testid":"edit-error",children:w})]})}if(S.isEditing)return i.jsxs("div",{className:it.editFieldWrapper,children:[i.jsx("textarea",{ref:k,className:`${it.editTextarea} ${S.error?it.editInputInvalid:""}`,value:S.draft,onChange:T=>S.setDraft(T.target.value),onBlur:S.handleBlur,onKeyDown:S.handleKeyDown,title:b,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),S.isDirty&&i.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),S.error&&i.jsx("span",{className:it.editError,"data-testid":"edit-error",children:S.error}),i.jsx("span",{className:it.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:it.metaValueClickable,onClick:()=>S.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),S.startEdit())},title:"Click to edit","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[j!==void 0?j:s?i.jsx("span",{children:s}):i.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function ud(t){var D;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":_}=t,k=y.useRef(null),S=ah({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(S.isEditing){const R=window.setTimeout(()=>{var E;(E=k.current)==null||E.focus()},0);return()=>window.clearTimeout(R)}},[S.isEditing]);const j=y.useCallback(R=>{const E=R.target.value;S.ignoreInitialBlurRef.current=!1,E!==s&&o(E),S.cancelEdit()},[s,o,S]),T=y.useCallback(R=>{if(S.ignoreInitialBlurRef.current){S.ignoreInitialBlurRef.current=!1;return}R.relatedTarget instanceof HTMLElement&&R.relatedTarget.dataset.editAction===d||S.cancelEdit()},[d,S]);if(r==="create")return i.jsx("select",{className:it.editSelect,value:s,onChange:R=>m==null?void 0:m(R.target.value),"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(R=>i.jsx("option",{value:R.value,children:R.label},R.value))});if(S.isEditing)return i.jsx("select",{ref:k,className:it.editSelect,value:S.draft,onChange:j,onBlur:T,title:b,"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(R=>i.jsx("option",{value:R.value,children:R.label},R.value))});const w=g==null?void 0:g(s),C=(D=c.find(R=>R.value===s))==null?void 0:D.label;return i.jsxs("button",{type:"button",className:it.metaValueClickable,onClick:()=>S.startEdit(),title:"Click to change","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[w!==void 0?w:C?i.jsx("span",{children:C}):i.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function A5(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return i.jsxs("label",{className:it.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 D5="_nav_1snmp_1",M5="_searchForm_1snmp_8",R5="_searchInput_1snmp_15",I5="_searchButton_1snmp_33",O5="_clearButton_1snmp_68",B5="_workspaceSelect_1snmp_85",L5="_listHeader_1snmp_99",z5="_nodeList_1snmp_108",$5="_nodeItem_1snmp_116",H5="_indicator_1snmp_129",P5="_label_1snmp_136",U5="_badge_1snmp_145",Qn={nav:D5,searchForm:M5,searchInput:R5,searchButton:I5,clearButton:O5,workspaceSelect:B5,listHeader:L5,nodeList:z5,nodeItem:$5,indicator:H5,label:P5,badge:U5};function V5({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(S=>{S.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=y.useCallback(()=>{g(""),d()},[d]),_=y.useCallback(S=>{u(S)},[u]),k=y.useCallback(S=>{g(""),p(S)},[p]);return i.jsxs("div",{className:Qn.nav,"data-testid":"knowledge-nav",children:[i.jsxs("form",{className:Qn.searchForm,onSubmit:v,children:[i.jsx("input",{className:Qn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:S=>{g(S.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),i.jsx("button",{type:"submit",className:Qn.searchButton,disabled:o,children:"Go"})]}),r&&i.jsx("button",{type:"button",className:Qn.clearButton,onClick:b,children:"Clear search"}),i.jsxs("select",{className:Qn.workspaceSelect,onChange:S=>{k(S.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[i.jsx("option",{value:"",children:"All workspaces"}),s.map(S=>i.jsx("option",{value:S.id,children:S.name},S.id))]}),i.jsxs("div",{className:Qn.listHeader,children:["Nodes (",t.length,")"]}),i.jsx("ul",{className:Qn.nodeList,children:t.map(S=>i.jsxs("li",{className:Qn.nodeItem,onClick:()=>{_(S.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),_(S.id))},role:"button",tabIndex:0,children:[i.jsx("span",{className:Qn.indicator,style:{backgroundColor:S.kind==="reference"?"#4A9EFF":S.category==="decision"?"#22C55E":S.category==="concept"?"#A855F7":S.category==="snippet"?"#6B7280":"#EAB308"}}),i.jsx("span",{className:Qn.label,children:S.label}),i.jsx("span",{className:Qn.badge,children:S.kind==="reference"?S.sourceType:S.category})]},S.id))})]})}const q5="_container_bwu10_1",G5="_hamburger_bwu10_33",F5="_brand_bwu10_49",K5="_brandLogo_bwu10_68",Z5="_info_bwu10_75",Y5="_connectionLabel_bwu10_90",J5="_connectionDot_bwu10_103",W5="_connected_bwu10_106",X5="_disconnected_bwu10_110",Q5="_connecting_bwu10_113",Es={container:q5,hamburger:G5,brand:F5,brandLogo:K5,info:Z5,connectionLabel:Y5,connectionDot:J5,connected:W5,disconnected:X5,connecting:Q5},eI={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},tI={connected:Es.connected,connecting:Es.connecting,disconnected:Es.disconnected};function nI({connectionStatus:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=vt(),u=s.length,p=s.filter(v=>v.status==="connected").length,m=o.filter(v=>["running","idle"].includes(v.status)).length,g=eI[t];return i.jsxs("div",{className:Es.container,children:[r&&i.jsx("button",{type:"button",className:Es.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:i.jsx(lT,{size:wt,"aria-hidden":"true"})}),i.jsx(Ti,{text:"Home",placement:"bottom",children:i.jsxs("button",{type:"button",className:Es.brand,onClick:()=>d(Ho),"data-testid":"statusbar-brand",children:[i.jsx("img",{src:wd("icon-192x192.png"),alt:"",className:Es.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),i.jsxs("div",{className:Es.info,children:[i.jsxs("span",{"aria-label":g,children:[i.jsx("span",{className:`${Es.connectionDot} ${tI[t]}`,"aria-hidden":"true",children:i.jsx(Si,{size:j_,fill:"currentColor"})})," ",i.jsx("span",{className:Es.connectionLabel,"aria-hidden":"true",children:g})]}),i.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),i.jsxs("span",{children:[m," active"]})]})]})}const sI="_nav_gx5h3_1",aI="_tab_gx5h3_35",iI="_tabIcon_gx5h3_68",oI="_tabLabel_gx5h3_79",rI="_tabActive_gx5h3_84",lI="_tabEnd_gx5h3_90",So={nav:sI,tab:aI,tabIcon:iI,tabLabel:oI,tabActive:rI,tabEnd:lI},Wc=[{view:"dashboard",label:"Dashboard",icon:i.jsx(Yj,{size:wt}),route:Ho,testId:"sidebar-tab-dashboard",order:0},{view:"tasks",label:"Tasks",icon:i.jsx(Cj,{size:wt}),route:qN,testId:"sidebar-tab-tasks",order:1},{view:"environments",label:"Environments",icon:i.jsx(mT,{size:wt}),route:Mo,testId:"sidebar-tab-environments",order:2},{view:"chat",label:"Root",icon:i.jsx(dT,{size:wt}),route:VN,testId:"sidebar-tab-chat",order:3},{view:"knowledge",label:"Knowledge",icon:i.jsx(_j,{size:wt}),route:Z_,testId:"sidebar-tab-knowledge",order:5},{view:"coordination",label:"Coordination",icon:i.jsx(gT,{size:wt}),route:F_,testId:"sidebar-tab-coordination",order:6},{view:"settings",label:"Settings",icon:i.jsx(ET,{size:wt}),route:zN,testId:"sidebar-tab-settings",align:"end"}];function cI(t){return t===Ho||t==="/"?"dashboard":t.startsWith(F_)?"coordination":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(Z_)?"knowledge":t.startsWith(xi)?"settings":"tasks"}function dI({tabs:t=Wc}){var g;const s=Jt(),o=vt(),r=y.useRef(null),c=cI(s.pathname),d=y.useMemo(()=>{const v=(b,_)=>(b.order??Number.MAX_SAFE_INTEGER)-(_.order??Number.MAX_SAFE_INTEGER);return[...t.filter(b=>b.align!=="end").sort(v),...t.filter(b=>b.align==="end")]},[t]),u=(g=d.find(v=>v.align==="end"))==null?void 0:g.view,p=y.useCallback(v=>{o(v.route)},[o]),m=y.useCallback(v=>{var j,T;const b=(j=r.current)==null?void 0:j.querySelectorAll('[role="tab"]');if(!b)return;const _=Array.from(b).findIndex(w=>w===document.activeElement),k=_>=0?_:d.findIndex(w=>w.view===c);let S=k;if(v.key==="ArrowRight"||v.key==="j"||v.key==="J")v.preventDefault(),S=(k+1)%d.length;else if(v.key==="ArrowLeft"||v.key==="k"||v.key==="K")v.preventDefault(),S=(k-1+d.length)%d.length;else if(v.key==="Home")v.preventDefault(),S=0;else if(v.key==="End")v.preventDefault(),S=d.length-1;else return;o(d[S].route),(T=b[S])==null||T.focus()},[c,o,d]);return i.jsx("nav",{className:So.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:m,"data-testid":"sidebar-nav",children:d.map(v=>{const b=v.view===c,_=v.view===u;return i.jsx(Ti,{text:v.label,placement:"bottom",className:_?So.tabEnd:void 0,children:i.jsxs("button",{role:"tab",type:"button","aria-selected":b,tabIndex:b?0:-1,className:`${So.tab} ${b?So.tabActive:""}`,onClick:()=>p(v),"data-testid":v.testId,"aria-label":v.label,children:[i.jsx("span",{className:So.tabIcon,"aria-hidden":"true",children:v.icon}),i.jsx("span",{className:So.tabLabel,children:v.label})]})},v.view)})})}const uI="_container_pi6ii_1",fI="_content_pi6ii_66",Gb={container:uI,content:fI},pI=320,D1=220,M1=600,R1="grackle-sidebar-width";function mI(){try{const t=localStorage.getItem(R1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=D1&&s<=M1)return s}}catch{}return pI}function hI(t){try{localStorage.setItem(R1,String(t))}catch{}}function gI({content:t}){const[s]=y.useState(mI),o=y.useRef(null);if(y.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>=D1&&m<=M1&&hI(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return i.jsx("div",{className:Gb.container,ref:o,"data-testid":"sidebar",style:{width:s},children:i.jsx("div",{className:Gb.content,children:t})})}const vI="_bar_tnfsh_1",yI="_btnPrimary_tnfsh_32",bI="_statusText_tnfsh_85",_I="_statusCompleted_tnfsh_90",xI="_statusFailed_tnfsh_94",kI="_statusBlocked_tnfsh_98",SI="_hintText_tnfsh_103",Tt={bar:vI,btnPrimary:yI,statusText:bI,statusCompleted:_I,statusFailed:xI,statusBlocked:kI,hintText:SI};function jI({sessions:t,tasks:s,environments:o}){const r=vt(),c=Jt(),d=nn("/sessions/:sessionId"),u=nn("/tasks/:taskId"),p=nn("/tasks/:taskId/stream"),m=nn("/tasks/:taskId/edit"),g=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),v=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),b=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),_=nn("/sessions/new"),k=nn("/environments/:environmentId/workspaces/:workspaceId"),S=nn("/tasks/new"),j=nn("/chat"),T=nn("/"),w=nn("/settings/*"),C=d==null?void 0:d.params.sessionId,D=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(g==null?void 0:g.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId),R=g??v??b,E=(R==null?void 0:R.params.environmentId)??(k==null?void 0:k.params.environmentId),M=c.pathname.startsWith("/environments")&&!k&&!R,O=!!j,A=!!_,$=!!k&&!g&&!v&&!b,Y=!!S;if(!!T&&!A&&!$&&!Y||!!w||(!!m||!!b)||Y||M||A)return i.jsx(i.Fragment,{});if(O)return o.find(ae=>ae.adapterType==="local"&&ae.status==="connected")?i.jsx(i.Fragment,{}):i.jsx("div",{className:Tt.bar,children:i.jsx("span",{className:Tt.hintText,children:"Add a local environment to start chatting"})});if($)return i.jsx("div",{className:Tt.bar,children:i.jsx("span",{className:Tt.hintText,children:"Select a task or click + to create one"})});if(D){const Z=s.find(B=>B.id===D);if(!Z)return i.jsx("div",{className:Tt.bar,children:i.jsx("span",{className:Tt.hintText,children:"Loading..."})});const ae=new Map(s.map(B=>[B.id,B])),H=Z.dependsOn.some(B=>{const F=ae.get(B);return F!==void 0&&F.status!=="complete"});if(Z.status==="not_started"){const B=H?Z.dependsOn.map(F=>ae.get(F)).filter(F=>F&&F.status!=="complete").map(F=>F.title):[];return i.jsx("div",{className:Tt.bar,children:H?i.jsxs("span",{className:Tt.statusBlocked,children:["Blocked by: ",B.join(", ")]}):i.jsx("span",{className:Tt.hintText,children:"Use the buttons above to start or manage this task"})})}if(Z.status==="working"||Z.status==="paused"){const B=Z.latestSessionId||void 0,F=B?t.find(ne=>ne.id===B):void 0;return F&&F.status!=="stopped"?i.jsx(i.Fragment,{}):i.jsx("div",{className:Tt.bar,children:i.jsx("span",{className:Tt.hintText,children:"Waiting for agent..."})})}if(Z.status==="complete")return i.jsxs("div",{className:Tt.bar,children:[i.jsx("span",{className:`${Tt.statusText} ${Tt.statusCompleted}`,children:"Task completed"}),i.jsx("button",{onClick:()=>r(Ai(Z.workspaceId,void 0,E)),className:Tt.btnPrimary,children:"+ New Task"})]});if(Z.status==="failed")return i.jsx("div",{className:Tt.bar,children:i.jsx("span",{className:`${Tt.statusText} ${Tt.statusFailed}`,children:"Task failed"})})}if(C){const Z=t.find(B=>B.id===C),ae=(Z==null?void 0:Z.status)==="stopped";if(Z!==void 0&&!ae)return i.jsx(i.Fragment,{});if(ae)return i.jsxs("div",{className:Tt.bar,children:[i.jsxs("span",{className:`${Tt.statusText} ${Tt.hintText}`,children:["Session ",Z.endReason||Z.status]}),i.jsx("button",{onClick:()=>r(V_(Z.environmentId)),className:Tt.btnPrimary,children:"+ New Chat"})]})}return i.jsx("div",{className:Tt.bar,children:i.jsx("span",{className:Tt.hintText,children:"Loading..."})})}const TI="_nav_14i94_1",wI="_tab_14i94_24",NI="_tabActive_14i94_62",CI="_tabLabel_14i94_75",EI="_statusDot_14i94_81",AI="_pulse_14i94_87",DI="_addButton_14i94_99",MI="_empty_14i94_132",Ha={nav:TI,tab:wI,tabActive:NI,tabLabel:CI,statusDot:EI,pulse:AI,addButton:DI,empty:MI},RI={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function II({environments:t}){const s=vt(),o=y.useRef(null),r=nn("/environments/:environmentId"),c=nn("/environments/:environmentId/edit"),d=nn("/environments/:environmentId/workspaces/:workspaceId"),u=nn("/environments/:environmentId/workspaces/:workspaceId/*"),p=(r==null?void 0:r.params.environmentId)??(c==null?void 0:c.params.environmentId)??(d==null?void 0:d.params.environmentId)??(u==null?void 0:u.params.environmentId),m=p==="new"?void 0:p,g=y.useCallback(_=>{s(Ro(_))},[s]),v=y.useCallback(_=>{var w;const k=(w=o.current)==null?void 0:w.querySelectorAll('[role="tab"]');if(!k||k.length===0)return;const S=Array.from(k).findIndex(C=>C===document.activeElement),j=S>=0?S:t.findIndex(C=>C.id===m);let T=j;if(_.key==="ArrowDown"||_.key==="j"||_.key==="J")_.preventDefault(),T=(j+1)%k.length;else if(_.key==="ArrowUp"||_.key==="k"||_.key==="K")_.preventDefault(),T=(j-1+k.length)%k.length;else if(_.key==="Home")_.preventDefault(),T=0;else if(_.key==="End")_.preventDefault(),T=k.length-1;else return;T<t.length&&s(Ro(t[T].id)),k[T].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:Ha.nav,"data-testid":"environment-nav",children:[i.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(_=>{const k=_.id===m,S=_.id===b,j=RI[_.status]||"var(--text-tertiary)",T=_.status==="connected";return i.jsxs("button",{role:"tab",type:"button","aria-selected":k,tabIndex:S?0:-1,className:`${Ha.tab} ${k?Ha.tabActive:""}`,onClick:()=>g(_.id),"data-testid":"env-nav-item",children:[i.jsx("span",{className:`${Ha.statusDot} ${T?Ha.pulse:""}`,style:{color:j},"aria-hidden":"true",children:i.jsx(Si,{size:j_,fill:"currentColor"})}),i.jsx("span",{className:Ha.tabLabel,title:_.displayName||_.id,children:_.displayName||_.id})]},_.id)})}),i.jsx("button",{type:"button",className:Ha.addButton,onClick:()=>s(BN),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&i.jsx("div",{className:Ha.empty,children:"No environments yet."})]})}function OI(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 I1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return i.jsx(i.Fragment,{children:t});const r=OI(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 BI(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 LI(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 HT){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Fa(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=Fa(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const zI="_container_z4i38_1",$I="_header_z4i38_5",HI="_headerActions_z4i38_17",PI="_searchInput_z4i38_23",UI="_searchHighlight_z4i38_56",VI="_groupToggle_z4i38_62",qI="_groupToggleActive_z4i38_89",GI="_addButton_z4i38_93",FI="_taskRow_z4i38_120",KI="_selected_z4i38_140",ZI="_expandArrow_z4i38_150",YI="_expanded_z4i38_157",JI="_leafSpacer_z4i38_161",WI="_taskStatusIcon_z4i38_166",XI="_taskTitle_z4i38_170",QI="_workspaceBadge_z4i38_177",eO="_childCountBadge_z4i38_195",tO="_dependencyBadge_z4i38_208",nO="_blockedBadge_z4i38_220",sO="_addChildButton_z4i38_225",aO="_emptyState_z4i38_268",iO="_statusGroupHeader_z4i38_275",oO="_statusGroupIcon_z4i38_294",rO="_statusGroupLabel_z4i38_298",lO="_statusGroupCount_z4i38_303",Je={container:zI,header:$I,headerActions:HI,searchInput:PI,searchHighlight:UI,groupToggle:VI,groupToggleActive:qI,addButton:GI,taskRow:FI,selected:KI,expandArrow:ZI,expanded:YI,leafSpacer:JI,taskStatusIcon:WI,taskTitle:XI,workspaceBadge:QI,childCountBadge:eO,dependencyBadge:tO,blockedBadge:nO,addChildButton:sO,emptyState:aO,statusGroupHeader:iO,statusGroupIcon:oO,statusGroupLabel:rO,statusGroupCount:lO},cO=[{name:"title",weight:2},{name:"description",weight:1}],O1=16,dO=16,B1="grackle-task-group-by-status";function Fb(){try{return localStorage.getItem(B1)==="true"}catch{return!1}}function uO(t){try{localStorage.setItem(B1,String(t))}catch{}}function fO({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:Je.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:`${Je.expandArrow} ${s?Je.expanded:""}`,"aria-hidden":"true",children:i.jsx(da,{size:Ze})}),i.jsx("span",{className:Je.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),i.jsx("span",{className:Je.statusGroupLabel,children:t.label}),i.jsx("span",{className:Je.statusGroupCount,children:t.tasks.length})]}),i.jsx(as,{children:s&&i.jsx($t.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=Fa(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return i.jsxs("div",{onClick:()=>c(os(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(os(p.id)))},className:`${Je.taskRow} ${g?Je.selected:""}`,style:{"--task-indent":`${O1}px`},"data-task-id":p.id,children:[i.jsx("span",{className:Je.leafSpacer}),i.jsx("span",{className:Je.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${ol(p.status)}`,children:m.icon}),i.jsx("span",{className:Je.taskTitle,title:p.title,children:i.jsx(I1,{text:p.title,indices:d.get(p.id),highlightClass:Je.searchHighlight})}),v&&i.jsx("span",{className:Je.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function L1({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=Fa(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(w=>u.get(w)!=="complete"),b=o.has(t.id),_=t.children.length>0,k=c===t.id,S=O1+s*dO,T=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{onClick:()=>d(os(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:w=>{w.currentTarget===w.target&&(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),d(os(t.id)))},className:`${Je.taskRow} ${k?Je.selected:""}`,style:{"--task-indent":`${S}px`},"data-task-id":t.id,children:[_&&i.jsx("span",{className:`${Je.expandArrow} ${b?Je.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:w=>{w.stopPropagation(),r(t.id)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),w.stopPropagation(),r(t.id))},children:i.jsx(da,{size:Ze,"aria-hidden":"true"})}),!_&&i.jsx("span",{className:Je.leafSpacer}),i.jsx("span",{className:Je.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${ol(t.status)}`,children:g.icon}),i.jsx("span",{className:Je.taskTitle,title:t.title,children:i.jsx(I1,{text:t.title,indices:p.get(t.id),highlightClass:Je.searchHighlight})}),T&&i.jsx("span",{className:Je.workspaceBadge,title:T,children:T}),_&&i.jsxs("span",{className:Je.childCountBadge,children:[t.children.filter(w=>w.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&i.jsx("span",{className:`${Je.dependencyBadge} ${v?Je.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<M2&&i.jsx(Ti,{text:"Add child task",children:i.jsx("button",{onClick:w=>{w.stopPropagation(),d(Ai(t.workspaceId,t.id))},"aria-label":"Add child task",className:Je.addChildButton,children:"+"})})]}),i.jsx(as,{children:_&&b&&i.jsx($t.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(w=>i.jsx(L1,{node:w,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},w.id))})})]})}function pO({workspaces:t,tasks:s}){const o=vt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(Fb),[g,v]=y.useState(Fb),[b,_]=y.useState(new Map),k=nn("/tasks/:taskId/*"),S=(k==null?void 0:k.params.taskId)!=="new"?k==null?void 0:k.params.taskId:void 0,j=y.useMemo(()=>new Map(s.map(Z=>[Z.id,Z.status])),[s]),T=y.useMemo(()=>new Map(t.map(Z=>[Z.id,Z.name])),[t]),w=()=>{const Z=!p;uO(Z),m(Z),Z&&(v(!0),_(new Map))},C=Z=>{_(ae=>{const H=new Map(ae),B=H.has(Z)?H.get(Z):g;return H.set(Z,!B),H})},D=Z=>b.has(Z)?b.get(Z):g,R=Z=>{c(ae=>{const H=new Set(ae);return H.has(Z)?(H.delete(Z),u(B=>new Set(B).add(Z))):(H.add(Z),u(B=>{const F=new Set(B);return F.delete(Z),F})),H})};y.useEffect(()=>{const Z=new Set(s.filter(ae=>ae.parentTaskId).map(ae=>ae.parentTaskId));Z.size>0&&c(ae=>{const H=new Set(ae);for(const B of Z)d.has(B)||H.add(B);return H})},[s,d]);const[E,M]=y.useState(""),{directMatchTaskIds:O,treeMatchTaskIds:A,titleHighlights:$}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const Z=D2(s,E,cO),ae=new Set(Z.map(ge=>ge.item.id)),H=new Map;for(const ge of Z){const ne=ge.matches.find(ce=>ce.key==="title");ne&&H.set(ge.item.id,ne.indices)}const B=new Set(ae),F=new Map(s.map(ge=>[ge.id,ge]));for(const ge of[...ae]){let ne=F.get(ge);for(;ne!=null&&ne.parentTaskId;)B.add(ne.parentTaskId),ne=F.get(ne.parentTaskId)}return{directMatchTaskIds:ae,treeMatchTaskIds:B,titleHighlights:H}},[E,s]),Y=O!==null,V=Y?p?O:A:null,ee=V?s.filter(Z=>V.has(Z.id)):s,le=p?[]:BI(ee);return i.jsxs("div",{className:Je.container,children:[i.jsxs("div",{className:Je.header,children:[i.jsx("span",{children:"Tasks"}),i.jsxs("div",{className:Je.headerActions,children:[i.jsx(Ti,{text:p?"Switch to tree view":"Group tasks by status",children:i.jsx("button",{className:`${Je.groupToggle} ${p?Je.groupToggleActive:""}`,onClick:w,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:i.jsx(aT,{size:zt})})}),i.jsx(Ti,{text:"New task",children:i.jsx("button",{className:Je.addButton,onClick:()=>o(Ai()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&i.jsx("input",{type:"text",value:E,onChange:Z=>M(Z.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Je.searchInput,"data-testid":"sidebar-search"}),p?LI(ee,j).map(Z=>i.jsx(fO,{group:Z,isExpanded:D(Z.status),onToggle:()=>C(Z.status),selectedTaskId:S,navigate:o,titleHighlights:$,workspaceNames:T},Z.status)):le.map(Z=>i.jsx(L1,{node:Z,depth:0,expandedTasks:r,toggleTask:R,selectedTaskId:S,navigate:o,taskStatusById:j,titleHighlights:$,workspaceNames:T},Z.id)),ee.length===0&&!Y&&i.jsx("div",{className:Je.emptyState,children:"No tasks yet. Click + to create one."}),ee.length===0&&Y&&i.jsx("div",{className:Je.emptyState,children:"No matching tasks"})]})}const mO="_toast_ed2dk_1",hO="_success_ed2dk_18",gO="_icon_ed2dk_22",vO="_error_ed2dk_25",yO="_warning_ed2dk_32",bO="_info_ed2dk_38",_O="_message_ed2dk_53",xO="_close_ed2dk_60",zr={toast:mO,success:hO,icon:gO,error:vO,warning:yO,info:bO,message:_O,close:xO},kO={success:i.jsx(Ni,{size:wt}),error:i.jsx(Is,{size:wt}),warning:i.jsx(fm,{size:wt}),info:i.jsx(um,{size:wt})};function SO({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),i.jsxs($t.div,{className:`${zr.toast} ${zr[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:zr.icon,"aria-hidden":"true",children:kO[t.variant]}),i.jsx("span",{className:zr.message,children:t.message}),i.jsx("button",{type:"button",className:zr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:i.jsx(Is,{size:zt,"aria-hidden":"true"})})]})}const jO="_container_qqse2_1",TO={container:jO};function wO({toasts:t,onDismiss:s}){return i.jsx("div",{className:TO.container,"data-testid":"toast-container",children:i.jsx(as,{children:t.map(o=>i.jsx(SO,{toast:o,onDismiss:s},o.id))})})}const NO="_callout_e5awm_1",CO="_success_e5awm_11",EO="_icon_e5awm_15",AO="_error_e5awm_18",DO="_warning_e5awm_25",MO="_info_e5awm_32",RO="_content_e5awm_48",IO="_close_e5awm_53",$r={callout:NO,success:CO,icon:EO,error:AO,warning:DO,info:MO,content:RO,close:IO},OO={success:i.jsx(Ni,{size:wt}),error:i.jsx(Is,{size:wt}),warning:i.jsx(fm,{size:wt}),info:i.jsx(um,{size:wt})};function BO({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return i.jsx(i.Fragment,{children:!c&&i.jsxs("div",{className:[$r.callout,$r[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[i.jsx("span",{className:$r.icon,"aria-hidden":"true",children:OO[t]}),i.jsx("span",{className:$r.content,children:s}),o&&i.jsx("button",{type:"button",className:$r.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:i.jsx(Is,{size:zt,"aria-hidden":"true"})})]})})}function LO({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(BO,{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 zO="_container_m1fsr_1",$O="_heading_m1fsr_7",HO="_section_m1fsr_14",PO="_sectionTitle_m1fsr_26",UO="_sectionDescription_m1fsr_35",VO="_emptyState_m1fsr_41",qO="_tokenList_m1fsr_48",GO="_tokenRow_m1fsr_55",FO="_tokenBadge_m1fsr_68",KO="_tokenName_m1fsr_83",ZO="_tokenTarget_m1fsr_90",YO="_deleteButton_m1fsr_99",JO="_addForm_m1fsr_113",WO="_formRow_m1fsr_119",XO="_input_m1fsr_125",QO="_select_m1fsr_155",eB="_addButton_m1fsr_187",tB="_emptyStateInfo_m1fsr_221",nB="_themeOptions_m1fsr_229",sB="_themeOption_m1fsr_229",aB="_themeOptionSelected_m1fsr_254",iB="_themeOptionHeader_m1fsr_259",oB="_themeOptionLabel_m1fsr_266",rB="_themeOptionDesc_m1fsr_273",lB="_variantToggle_m1fsr_279",cB="_variantButton_m1fsr_286",dB="_variantActive_m1fsr_305",uB="_themeSwatches_m1fsr_311",fB="_themeSwatch_m1fsr_311",pB="_systemToggle_m1fsr_325",mB="_systemToggleHint_m1fsr_341",hB="_themeActive_m1fsr_348",gB="_aboutGrid_m1fsr_354",vB="_aboutItem_m1fsr_360",yB="_aboutLabel_m1fsr_373",bB="_aboutValue_m1fsr_379",_B="_aboutDot_m1fsr_387",xB="_aboutDotConnected_m1fsr_394",kB="_aboutDotDisconnected_m1fsr_398",SB="_aboutDotConnecting_m1fsr_402",fe={container:zO,heading:$O,section:HO,sectionTitle:PO,sectionDescription:UO,emptyState:VO,tokenList:qO,tokenRow:GO,tokenBadge:FO,tokenName:KO,tokenTarget:ZO,deleteButton:YO,addForm:JO,formRow:WO,input:XO,select:QO,addButton:eB,emptyStateInfo:tB,themeOptions:nB,themeOption:sB,themeOptionSelected:aB,themeOptionHeader:iB,themeOptionLabel:oB,themeOptionDesc:rB,variantToggle:lB,variantButton:cB,variantActive:dB,themeSwatches:uB,themeSwatch:fB,systemToggle:pB,systemToggleHint:mB,themeActive:hB,aboutGrid:gB,aboutItem:vB,aboutLabel:yB,aboutValue:bB,aboutDot:_B,aboutDotConnected:xB,aboutDotDisconnected:kB,aboutDotConnecting:SB},jB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function TB({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,b]=y.useState(""),[_,k]=y.useState(null),S=w=>{if(w.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=w=>{k(w)},T=()=>{_&&(o(_),r==null||r("Token deleted","info")),k(null)};return i.jsxs(i.Fragment,{children:[i.jsx(ys,{isOpen:_!==null,title:"Delete Token?",description:_?`"${_}" will be permanently removed.`:void 0,onConfirm:T,onCancel:()=>k(null)}),i.jsxs("section",{className:fe.section,children:[i.jsx("h3",{className:fe.sectionTitle,children:"Tokens"}),i.jsx("p",{className:fe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?i.jsx("div",{className:fe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):i.jsx("div",{className:fe.tokenList,children:t.map(w=>i.jsxs("div",{className:fe.tokenRow,children:[i.jsx("span",{className:fe.tokenBadge,children:w.tokenType}),i.jsx("span",{className:fe.tokenName,children:w.name}),i.jsx("span",{className:fe.tokenTarget,children:w.tokenType==="env_var"?w.envVar:w.filePath}),i.jsx("button",{className:fe.deleteButton,onClick:()=>j(w.name),title:`Delete ${w.name}`,"aria-label":`Delete ${w.name}`,children:i.jsx(Is,{size:zt,"aria-hidden":"true"})})]},w.name))}),i.jsxs("form",{className:fe.addForm,onSubmit:S,children:[i.jsxs("div",{className:fe.formRow,children:[i.jsx("input",{className:fe.input,type:"text",placeholder:"Token name",value:c,onChange:w=>d(w.target.value)}),i.jsx("input",{className:fe.input,type:"password",placeholder:"Value",value:u,onChange:w=>p(w.target.value)})]}),i.jsxs("div",{className:fe.formRow,children:[i.jsx("select",{className:fe.select,value:m,onChange:w=>g(w.target.value),children:jB.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))}),i.jsx("input",{className:fe.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:w=>b(w.target.value)}),i.jsx("button",{className:fe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Nd=[{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"]}],z1=new Set(Nd.map(t=>t.id)),Kb="grackle";function nm(t){return Nd.find(s=>s.id===t)}function wB({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return i.jsxs("section",{className:fe.section,children:[i.jsx("h3",{className:fe.sectionTitle,children:"Appearance"}),i.jsx("p",{className:fe.sectionDescription,children:"Choose how Grackle looks across the app."}),i.jsx("div",{className:fe.themeOptions,children:Nd.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:`${fe.themeOption} ${p?fe.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[i.jsxs("span",{className:fe.themeOptionHeader,children:[i.jsxs("span",{children:[i.jsx("span",{className:fe.themeOptionLabel,children:d.label}),i.jsx("span",{className:fe.themeOptionDesc,children:d.description})]}),u&&i.jsxs("span",{className:fe.variantToggle,children:[i.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&m?fe.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:`${fe.variantButton} ${p&&!m?fe.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:fe.themeSwatches,children:d.swatches.map((g,v)=>i.jsx("span",{className:fe.themeSwatch,style:{background:g}},v))})]},d.id)})}),i.jsxs("label",{className:fe.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:fe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),i.jsxs("p",{className:fe.themeActive,children:["Active theme: ",i.jsx("strong",{children:s})]})]})}const NB={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},CB={connected:fe.aboutDotConnected,connecting:fe.aboutDotConnecting,disconnected:fe.aboutDotDisconnected};function EB({connectionStatus: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:fe.section,"data-testid":"about-panel",children:[i.jsx("h3",{className:fe.sectionTitle,children:"About"}),i.jsx("p",{className:fe.sectionDescription,children:"Connection status and application information."}),i.jsxs("div",{className:fe.aboutGrid,children:[i.jsxs("div",{className:fe.aboutItem,children:[i.jsx("span",{className:fe.aboutLabel,children:"Connection"}),i.jsxs("span",{className:fe.aboutValue,children:[i.jsx("span",{className:`${fe.aboutDot} ${CB[t]}`}),NB[t]]})]}),i.jsxs("div",{className:fe.aboutItem,children:[i.jsx("span",{className:fe.aboutLabel,children:"Environments"}),i.jsxs("span",{className:fe.aboutValue,children:[r,"/",c," connected"]})]}),i.jsxs("div",{className:fe.aboutItem,children:[i.jsx("span",{className:fe.aboutLabel,children:"Active Sessions"}),i.jsx("span",{className:fe.aboutValue,children:d})]}),i.jsxs("div",{className:fe.aboutItem,children:[i.jsx("span",{className:fe.aboutLabel,children:"Version"}),i.jsx("span",{className:fe.aboutValue,children:"0.116.0"})]})]})]})}const AB="_container_cddyd_1",DB="_header_cddyd_8",MB="_headerTitle_cddyd_35",RB="_badge_cddyd_44",IB="_headerActions_cddyd_54",OB="_body_cddyd_61",BB="_formContent_cddyd_73",LB="_section_cddyd_85",zB="_label_cddyd_91",$B="_titleInput_cddyd_98",HB="_descriptionTextarea_cddyd_131",PB="_parentContext_cddyd_167",UB="_parentLabel_cddyd_175",VB="_parentName_cddyd_182",qB="_personaSelect_cddyd_186",GB="_depList_cddyd_220",FB="_depItem_cddyd_226",KB="_depItemSelected_cddyd_248",ZB="_noDeps_cddyd_252",YB="_btnPrimary_cddyd_258",JB="_btnGhost_cddyd_289",at={container:AB,header:DB,headerTitle:MB,badge:RB,headerActions:IB,body:OB,formContent:BB,section:LB,label:zB,titleInput:$B,descriptionTextarea:HB,parentContext:PB,parentLabel:UB,parentName:VB,personaSelect:qB,depList:GB,depItem:FB,depItemSelected:KB,noDeps:ZB,btnPrimary:YB,btnGhost:JB};function $1({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 _=vt(),k=t==="edit",S=k&&s?d.find(_e=>_e.id===s):void 0,j=k?(S==null?void 0:S.workspaceId)??"":o??"",[T,w]=y.useState(j),C=j||T,D=u.find(_e=>_e.id===C),R=c??(D==null?void 0:D.linkedEnvironmentIds[0]),E=!k&&!o,M=k?(S==null?void 0:S.parentTaskId)??"":r??"",O=M?d.find(_e=>_e.id===M):void 0,[A,$]=y.useState((S==null?void 0:S.title)??""),[Y,V]=y.useState((S==null?void 0:S.description)??""),[ee,le]=y.useState((S==null?void 0:S.dependsOn)??[]),[Z,ae]=y.useState((S==null?void 0:S.defaultPersonaId)??""),[H,B]=y.useState((S==null?void 0:S.canDecompose)??!1),[F,ge]=y.useState(!1),ne=y.useRef(!1);y.useEffect(()=>{k&&S&&!ne.current&&(ne.current=!0,$(S.title),V(S.description),le(S.dependsOn),ae(S.defaultPersonaId),B(S.canDecompose))},[k,S]);const ce=d.filter(_e=>_e.workspaceId===C&&(!k||_e.id!==s)&&_e.id!==M),me=A.trim().length>0&&(!k||S!==void 0)&&C.length>0,ke=_e=>{le(Oe=>Oe.includes(_e)?Oe.filter(Ht=>Ht!==_e):[...Oe,_e])},De=()=>{!me||F||k&&S===void 0||(k&&s?(g(s,A.trim(),Y,ee,Z),b==null||b("Task updated","success"),v?v():_(os(s,void 0,C,R),{replace:!0})):(ge(!0),m(C,A.trim(),Y,ee.length>0?ee:void 0,M||void 0,Z,H,()=>{b==null||b("Task created","success"),_(o?ji(o,R):"/tasks",{replace:!0})},_e=>{b==null||b(_e,"error"),ge(!1)})))},ot=()=>{if(v){v();return}_(k&&s?os(s,void 0,C,R):o?ji(o,R):"/tasks")},yt=k?"edit task":M?"child task":"new task";return i.jsxs("div",{className:at.container,children:[i.jsxs("div",{className:at.header,children:[i.jsxs("div",{className:at.headerTitle,children:[i.jsx("span",{className:at.badge,children:yt}),O&&i.jsxs("span",{className:at.parentContext,children:[i.jsx("span",{className:at.parentLabel,children:"Child of"}),i.jsx("span",{className:at.parentName,children:O.title})]})]}),i.jsxs("div",{className:at.headerActions,children:[i.jsx("button",{onClick:De,disabled:!me||F,className:at.btnPrimary,"data-testid":"task-edit-save",children:F?"Creating…":k?"Save Changes":"Create"}),i.jsx("button",{onClick:ot,className:at.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:at.body,children:i.jsxs("div",{className:at.formContent,children:[E&&i.jsxs("div",{className:at.section,children:[i.jsx("label",{className:at.label,htmlFor:"task-edit-workspace",children:"Workspace"}),i.jsxs("select",{id:"task-edit-workspace",value:T,onChange:_e=>w(_e.target.value),className:at.personaSelect,"data-testid":"task-edit-workspace",children:[i.jsx("option",{value:"",children:"Select a workspace..."}),u.map(_e=>i.jsx("option",{value:_e.id,children:_e.name},_e.id))]})]}),i.jsxs("div",{className:at.section,children:[i.jsx("label",{className:at.label,htmlFor:"task-edit-title",children:"Title"}),i.jsx("input",{id:"task-edit-title",type:"text",value:A,onChange:_e=>$(_e.target.value),placeholder:"Task title...",autoFocus:!0,className:at.titleInput,"data-testid":"task-edit-title",onKeyDown:_e=>{_e.key==="Enter"&&me&&De()}})]}),i.jsxs("div",{className:at.section,children:[i.jsx("label",{className:at.label,htmlFor:"task-edit-description",children:"Description"}),i.jsx("textarea",{id:"task-edit-description",value:Y,onChange:_e=>V(_e.target.value),placeholder:"Describe the task... (markdown supported)",className:at.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),i.jsxs("div",{className:at.section,children:[i.jsx("label",{className:at.label,htmlFor:"task-edit-persona",children:"Default Persona"}),i.jsxs("select",{id:"task-edit-persona",value:Z,onChange:_e=>ae(_e.target.value),className:at.personaSelect,"data-testid":"task-edit-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),p.map(_e=>i.jsx("option",{value:_e.id,children:_e.name},_e.id))]})]}),!k&&i.jsx("div",{className:at.section,children:i.jsxs("label",{className:at.depItem,"data-testid":"task-edit-can-decompose",children:[i.jsx("input",{type:"checkbox",checked:H,onChange:_e=>B(_e.target.checked)}),"Can spawn subtasks"]})}),i.jsxs("div",{className:at.section,children:[i.jsx("div",{className:at.label,children:"Dependencies"}),ce.length===0?i.jsx("div",{className:at.noDeps,children:"No other tasks in this workspace"}):i.jsx("div",{className:at.depList,children:ce.map(_e=>{const Oe=ee.includes(_e.id);return i.jsxs("label",{className:`${at.depItem} ${Oe?at.depItemSelected:""}`,"data-testid":`dep-option-${_e.id}`,children:[i.jsx("input",{type:"checkbox",checked:Oe,onChange:()=>ke(_e.id)}),_e.title,i.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",_e.status,")"]})]},_e.id)})})]})]})})]})}const WB="_actionButtons_1rjka_1",XB="_btnPrimary_1rjka_8",QB="_btnDanger_1rjka_39",eL="_btnGhost_1rjka_78",Zt={actionButtons:WB,btnPrimary:XB,btnDanger:QB,btnGhost:eL};function tL({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:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:m,className:Zt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Zt.btnPrimary,children:"Start"}),i.jsx("button",{onClick:m,className:Zt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Zt.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:u,disabled:!s,className:Zt.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Zt.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:c,className:Zt.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return i.jsx("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:r,className:Zt.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const nL="_workpadSection_y8nj9_1",sL="_workpadLabel_y8nj9_9",aL="_workpadStatus_y8nj9_17",iL="_workpadSummary_y8nj9_23",oL="_workpadExtra_y8nj9_29",Pa={workpadSection:nL,workpadLabel:sL,workpadStatus:aL,workpadSummary:iL,workpadExtra:oL};function rL({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:Pa.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:Pa.workpadLabel,children:"Workpad"}),i.jsx("div",{className:Pa.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return i.jsxs("div",{className:Pa.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:Pa.workpadLabel,children:"Workpad"}),s.status&&i.jsx("div",{className:Pa.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&i.jsx("div",{className:Pa.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&i.jsx("div",{className:Pa.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const lL="_overviewDashboard_r05qm_1",cL="_overviewHero_r05qm_7",dL="_statusBadge_r05qm_14",uL="_statusPending_r05qm_26",fL="_statusAssigned_r05qm_31",pL="_statusInProgress_r05qm_36",mL="_statusReview_r05qm_41",hL="_statusDone_r05qm_46",gL="_statusFailed_r05qm_51",vL="_statusWaitingInput_r05qm_56",yL="_overviewBranchPill_r05qm_61",bL="_branchLink_r05qm_76",_L="_overviewSection_r05qm_87",xL="_overviewLabel_r05qm_93",kL="_overviewValue_r05qm_100",SL="_overviewMuted_r05qm_105",jL="_overviewMarkdown_r05qm_111",TL="_envRow_r05qm_180",wL="_envDot_r05qm_186",NL="_envDotGreen_r05qm_193",CL="_envDotYellow_r05qm_197",EL="_envDotRed_r05qm_201",AL="_envDotGray_r05qm_205",DL="_depList_r05qm_209",ML="_depItem_r05qm_215",RL="_depBlocked_r05qm_222",IL="_depDone_r05qm_226",OL="_timeline_r05qm_230",BL="_timelineRow_r05qm_236",LL="_timelineKey_r05qm_243",zL="_timelineValue_r05qm_249",$L="_timelineDelta_r05qm_253",HL="_reviewNotes_r05qm_264",be={overviewDashboard:lL,overviewHero:cL,statusBadge:dL,statusPending:uL,statusAssigned:fL,statusInProgress:pL,statusReview:mL,statusDone:hL,statusFailed:gL,statusWaitingInput:vL,overviewBranchPill:yL,branchLink:bL,overviewSection:_L,overviewLabel:xL,overviewValue:kL,overviewMuted:SL,overviewMarkdown:jL,envRow:TL,envDot:wL,envDotGreen:NL,envDotYellow:CL,envDotRed:EL,envDotGray:AL,depList:DL,depItem:ML,depBlocked:RL,depDone:IL,timeline:OL,timelineRow:BL,timelineKey:LL,timelineValue:zL,timelineDelta:$L,reviewNotes:HL};function $c(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 _p(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 Zb(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?be.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?be.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?be.envDotRed:be.envDotGray}function PL({status:t}){const s=Fa(t),o=$T(t);return i.jsx("span",{className:`${be.statusBadge} ${be[o]??be.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function UL({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(S=>S.id===g):void 0,b=r.find(S=>S.id===t.workspaceId),_=o.find(S=>S.id===d),k=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return i.jsxs("div",{className:be.overviewDashboard,"data-testid":"task-overview-panel",children:[i.jsxs("div",{className:be.overviewHero,children:[i.jsx(PL,{status:t.status}),t.branch&&i.jsx("span",{className:be.overviewBranchPill,"data-testid":"task-overview-branch",children:k?i.jsxs("a",{href:k,target:"_blank",rel:"noreferrer noopener",className:be.branchLink,children:["🔗"," ",t.branch]}):i.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-description",children:[i.jsx("div",{className:be.overviewLabel,children:"Description"}),i.jsx("div",{className:be.overviewMarkdown,children:i.jsx(cm,{remarkPlugins:[dm],children:t.description})})]}),t.workpad&&i.jsx(rL,{workpad:t.workpad}),i.jsxs("div",{className:be.overviewSection,children:[i.jsx("div",{className:be.overviewLabel,children:"Environment"}),g&&v?i.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${be.envDot} ${Zb(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),i.jsx("span",{className:be.overviewValue,children:v.displayName})]}):_?i.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${be.envDot} ${Zb(_.status)}`,title:_.status,"aria-label":`Status: ${_.status}`,role:"img"}),i.jsx("span",{className:be.overviewValue,children:_.displayName}),i.jsx("span",{className:be.overviewMuted,children:"(workspace default)"})]}):i.jsx("div",{className:be.overviewMuted,children:"Set in workspace settings"})]}),i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-dependencies",children:[i.jsx("div",{className:be.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?i.jsx("div",{className:be.overviewMuted,children:"None"}):i.jsx("div",{className:be.depList,children:t.dependsOn.map(S=>{const j=s.get(S),T=(j==null?void 0:j.status)==="complete";return i.jsxs("div",{className:`${be.depItem} ${T?be.depDone:be.depBlocked}`,children:[i.jsx("span",{children:T?"✓":"○"}),i.jsx("span",{children:(j==null?void 0:j.title)??S})]},S)})})]}),i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-timeline",children:[i.jsx("div",{className:be.overviewLabel,children:"Timeline"}),i.jsxs("div",{className:be.timeline,children:[t.createdAt&&i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Created"}),i.jsx("span",{className:be.timelineValue,children:$c(t.createdAt)})]}),t.assignedAt&&(()=>{const S=_p(t.createdAt,t.assignedAt);return i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Assigned"}),i.jsx("span",{className:be.timelineValue,children:$c(t.assignedAt)}),S!==void 0&&i.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.startedAt&&(()=>{const S=_p(t.assignedAt??t.createdAt,t.startedAt);return i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Started"}),i.jsx("span",{className:be.timelineValue,children:$c(t.startedAt)}),S!==void 0&&i.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.completedAt&&(()=>{const S=_p(t.startedAt,t.completedAt);return i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Completed"}),i.jsx("span",{className:be.timelineValue,children:$c(t.completedAt)}),S!==void 0&&i.jsx("span",{className:be.timelineDelta,children:S})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&i.jsx("div",{className:be.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-usage",children:[i.jsx("div",{className:be.overviewLabel,children:"Usage"}),i.jsxs("div",{className:be.timeline,children:[i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Cost"}),i.jsx("span",{className:be.timelineValue,children:As(u.costMillicents)}),i.jsxs("span",{className:be.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Total (incl. subtasks)"}),i.jsx("span",{className:be.timelineValue,children:As(p.costMillicents)}),i.jsxs("span",{className:be.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-budget",children:[i.jsx("div",{className:be.overviewLabel,children:"Budget"}),i.jsxs("div",{className:be.timeline,children:[t.tokenBudget>0&&i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Tokens"}),i.jsxs("span",{className:be.timelineValue,children:[Io(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",Io(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Cost"}),i.jsxs("span",{className:be.timelineValue,children:[As((u==null?void 0:u.costMillicents)??0)," / ",As(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-review-notes",children:[i.jsx("div",{className:be.overviewLabel,children:"Review Notes"}),i.jsx("div",{className:be.reviewNotes,children:t.reviewNotes})]})]})}function VL({plugins:t,loading:s,onSetPluginEnabled:o}){return i.jsxs("div",{className:fe.container,"data-testid":"plugins-panel",children:[i.jsx("h2",{className:fe.heading,children:"Plugins"}),i.jsxs("div",{className:fe.section,children:[i.jsx("p",{className:fe.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&i.jsx("p",{className:fe.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&i.jsx("p",{className:fe.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return i.jsxs("div",{className:fe.tokenRow,"data-testid":`plugin-row-${r.name}`,children:[i.jsxs("div",{style:{flex:1},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[i.jsx("span",{className:fe.tokenName,children:r.name}),r.required&&i.jsx("span",{className:fe.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),i.jsx("div",{className:fe.tokenTarget,children:r.description}),c&&i.jsx("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--accent-yellow)",marginTop:"2px"},"data-testid":`plugin-restart-notice-${r.name}`,children:"Restart Grackle to apply changes"})]}),i.jsx("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:r.required?"not-allowed":"pointer"},title:r.required?"Core is required and cannot be disabled":void 0,children:i.jsx("input",{type:"checkbox",checked:r.enabled,disabled:r.required,onChange:d=>o(r.name,d.target.checked),"data-testid":`plugin-toggle-${r.name}`,"aria-label":`Enable or disable ${r.name} plugin`,style:{accentColor:"var(--accent-green)",width:"16px",height:"16px"}})})]},r.name)})]})]})}function qL({githubAccounts:t,githubAccountsLoading:s,onAddGitHubAccount:o,onUpdateGitHubAccount:r,onRemoveGitHubAccount:c,onImportGitHubAccounts:d,onShowToast:u}){const[p,m]=y.useState(""),[g,v]=y.useState(""),[b,_]=y.useState(!1),[k,S]=y.useState(!1),[j,T]=y.useState(!1),[w,C]=y.useState(null),D=t.find(A=>A.id===w),R=async A=>{if(A.preventDefault(),!(!p.trim()||!g.trim())){S(!0);try{await o(p.trim(),g.trim(),"",b),u==null||u("GitHub account added","success"),m(""),v(""),_(!1)}catch($){const Y=$ instanceof Error?$.message:"Failed to add account";u==null||u(Y,"error")}finally{S(!1)}}},E=async A=>{try{await r(A,{isDefault:!0}),u==null||u("Default account updated","success")}catch($){const Y=$ instanceof Error?$.message:"Failed to update account";u==null||u(Y,"error")}},M=async()=>{if(w)try{await c(w),u==null||u("GitHub account removed","info")}catch(A){const $=A instanceof Error?A.message:"Failed to remove account";u==null||u($,"error")}finally{C(null)}},O=async()=>{T(!0);try{const A=await d();A.imported>0?u==null||u(`Imported ${A.imported} account(s): ${A.usernames.join(", ")}`,"success"):u==null||u("No new accounts to import","info")}catch(A){const $=A instanceof Error?A.message:"Import failed";u==null||u($,"error")}finally{T(!1)}};return i.jsxs(i.Fragment,{children:[i.jsx(ys,{isOpen:w!==null,title:"Remove GitHub Account?",description:D?`"${D.label}"${D.username?` (@${D.username})`:""} will be permanently removed.`:void 0,onConfirm:()=>{M().catch(()=>{})},onCancel:()=>C(null)}),i.jsxs("section",{className:fe.section,"data-testid":"github-accounts-panel",children:[i.jsx("h3",{className:fe.sectionTitle,children:"GitHub Accounts"}),i.jsx("p",{className:fe.sectionDescription,children:"Register multiple GitHub accounts to use different identities per environment. The default account is used when no specific account is assigned."}),s&&t.length===0?i.jsx("div",{className:fe.emptyState,children:"Loading..."}):t.length===0?i.jsx("div",{className:fe.emptyStateInfo,children:"No GitHub accounts registered. Add one below or import from the gh CLI."}):i.jsx("div",{className:fe.tokenList,children:t.map(A=>i.jsxs("div",{className:fe.tokenRow,"data-testid":`github-account-row-${A.id}`,children:[A.isDefault&&i.jsx("span",{className:fe.tokenBadge,title:"Default account",children:"default"}),i.jsx("span",{className:fe.tokenName,children:A.label}),A.username&&i.jsxs("span",{className:fe.tokenTarget,children:["@",A.username]}),!A.isDefault&&i.jsx("button",{className:fe.deleteButton,onClick:()=>{E(A.id).catch(()=>{})},title:"Set as default","aria-label":`Set ${A.label} as default`,"data-testid":`github-account-set-default-${A.id}`,children:i.jsx(RT,{size:zt,"aria-hidden":"true"})}),i.jsx("button",{className:fe.deleteButton,onClick:()=>C(A.id),title:`Remove ${A.label}`,"aria-label":`Remove ${A.label}`,"data-testid":`github-account-remove-${A.id}`,children:i.jsx(Is,{size:zt,"aria-hidden":"true"})})]},A.id))}),i.jsxs("form",{className:fe.addForm,onSubmit:A=>{R(A).catch(()=>{})},children:[i.jsxs("div",{className:fe.formRow,children:[i.jsx("input",{className:fe.input,type:"text",placeholder:"Label (e.g. personal, work)",value:p,onChange:A=>m(A.target.value),"data-testid":"github-account-label-input"}),i.jsx("input",{className:fe.input,type:"password",placeholder:"Personal access token",value:g,onChange:A=>v(A.target.value),"data-testid":"github-account-token-input"})]}),i.jsxs("div",{className:fe.formRow,children:[i.jsxs("label",{className:fe.tokenTarget,style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[i.jsx("input",{type:"checkbox",checked:b,onChange:A=>_(A.target.checked),"data-testid":"github-account-default-checkbox"}),"Set as default"]}),i.jsx("button",{className:fe.addButton,type:"submit",disabled:!p.trim()||!g.trim()||k,"data-testid":"github-account-add-button",children:k?"Adding...":"Add Account"}),i.jsx("button",{className:fe.addButton,type:"button",onClick:()=>{O().catch(()=>{})},disabled:j,"data-testid":"github-account-import-button",children:j?"Importing...":"Import from gh CLI"})]})]})]})]})}const GL="_container_legrg_1",FL="_header_legrg_8",KL="_headerTitle_legrg_35",ZL="_badge_legrg_44",YL="_headerActions_legrg_54",JL="_body_legrg_61",WL="_formContent_legrg_73",XL="_section_legrg_85",QL="_label_legrg_91",e8="_nameInput_legrg_98",t8="_fieldInput_legrg_131",n8="_adapterSelect_legrg_164",s8="_readOnlyValue_legrg_198",a8="_codespaceSection_legrg_204",i8="_codespaceActions_legrg_210",o8="_creatingHint_legrg_216",r8="_errorHint_legrg_222",l8="_btnPrimary_legrg_235",c8="_btnGhost_legrg_266",oe={container:GL,header:FL,headerTitle:KL,badge:ZL,headerActions:YL,body:JL,formContent:WL,section:XL,label:QL,nameInput:e8,fieldInput:t8,adapterSelect:n8,readOnlyValue:s8,codespaceSection:a8,codespaceActions:i8,creatingHint:o8,errorHint:r8,btnPrimary:l8,btnGhost:c8},Xc=1,Qc=65535;function xp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=Xc&&s<=Qc}function kp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function d8({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[b,_]=y.useState(""),[k,S]=y.useState("");return g==="create"?i.jsxs("div",{className:oe.codespaceSection,children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Repository"}),i.jsx("input",{type:"text",value:b,onChange:j=>_(j.target.value),placeholder:"owner/repo",className:oe.fieldInput,"data-testid":"env-codespace-repo"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Machine Type"}),i.jsx("input",{type:"text",value:k,onChange:j=>S(j.target.value),placeholder:"Machine type (optional)...",className:oe.fieldInput,"data-testid":"env-codespace-machine"})]}),i.jsxs("div",{className:oe.codespaceActions,children:[i.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),k.trim()||void 0),v("pick"),_(""),S(""))},disabled:!b.trim(),className:oe.btnPrimary,children:"Create"}),i.jsx("button",{onClick:()=>{v("pick"),_(""),S("")},className:oe.btnGhost,children:"Cancel"})]})]}):i.jsx("div",{className:oe.codespaceSection,children:i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.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:oe.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:oe.creatingHint,children:"Creating codespace..."}),u&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:oe.errorHint,children:u}),i.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:oe.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&i.jsx("span",{className:oe.errorHint,children:d})]})})}function H1({mode:t,environmentId:s,environments:o,githubAccounts:r,onAddEnvironment:c,onUpdateEnvironment:d,onListCodespaces:u,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b,onListDockerContainers:_,dockerContainers:k,dockerContainersError:S,onShowToast:j}){const T=vt(),w=t==="edit",C=w&&s?o.find(re=>re.id===s):void 0,[D,R]=y.useState(""),[E,M]=y.useState("local"),[O,A]=y.useState(""),[$,Y]=y.useState(""),[V,ee]=y.useState(""),[le,Z]=y.useState(""),[ae,H]=y.useState(""),[B,F]=y.useState(""),[ge,ne]=y.useState(""),[ce,me]=y.useState(""),[ke,De]=y.useState("create"),[ot,yt]=y.useState(""),[_e,Oe]=y.useState(null),Ht=y.useCallback(()=>{const re={};if(E==="local"){if(O.trim()&&(re.host=O.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(re.port=ve)}}else if(E==="ssh"){if(re.host=O.trim(),V.trim()&&(re.user=V.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(re.sshPort=ve)}le.trim()&&(re.identityFile=le.trim())}else E==="docker"?ke==="attach"?ot.trim()&&(re.attach=ot.trim()):(ae.trim()&&(re.image=ae.trim()),B.trim()&&(re.repo=B.trim())):E==="codespace"&&(re.codespaceName=ge.trim());return re},[E,O,$,V,le,ae,B,ge,ke,ot]),Nt=()=>!(!D.trim()||E==="ssh"&&!O.trim()||E==="codespace"&&!ge.trim()||E==="docker"&&ke==="attach"&&!ot.trim()||(E==="local"||E==="ssh")&&!xp($)),ue=()=>{Nt()&&(c(D.trim(),E,Ht(),ce||void 0),j==null||j("Environment added successfully","success"),T(Mo,{replace:!0}))},Re=()=>{T(s?Ro(s):Mo)},Q=y.useCallback((re,ve)=>{if(!C||!s)return;const Xe=kp(C.adapterConfig),an=ve.trim();an?Xe[re]=an:delete Xe[re],d(s,{adapterConfig:Xe})},[C,s,d]),et=y.useCallback((re,ve)=>{if(!C||!s)return;const Xe=kp(C.adapterConfig);if(ve.trim()){const an=Number(ve);Number.isInteger(an)&&an>=Xc&&an<=Qc&&(Xe[re]=an)}else delete Xe[re];d(s,{adapterConfig:Xe})},[C,s,d]);if(w){if(!C)return i.jsxs("div",{className:oe.container,children:[i.jsxs("div",{className:oe.header,children:[i.jsx("div",{className:oe.headerTitle,children:i.jsx("span",{className:oe.badge,children:"edit environment"})}),i.jsx("div",{className:oe.headerActions,children:i.jsx("button",{onClick:Re,className:oe.btnGhost,children:"Back"})})]}),i.jsx("div",{className:oe.body,children:i.jsx("div",{className:oe.formContent,children:i.jsx("span",{className:oe.readOnlyValue,children:"Environment not found"})})})]});const re=kp(C.adapterConfig);return i.jsxs("div",{className:oe.container,"data-testid":"env-edit-panel",children:[i.jsxs("div",{className:oe.header,children:[i.jsx("div",{className:oe.headerTitle,children:i.jsx("span",{className:oe.badge,children:"edit environment"})}),i.jsx("div",{className:oe.headerActions,children:i.jsx("button",{onClick:Re,className:oe.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),i.jsx("div",{className:oe.body,children:i.jsxs("div",{className:oe.formContent,children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Name"}),i.jsx(Bt,{value:C.displayName,onSave:ve=>{s&&d(s,{displayName:ve})},validate:ve=>ve.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:_e,onActivate:Oe,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Adapter Type"}),i.jsx("span",{className:oe.readOnlyValue,"data-testid":"env-edit-adapter-type",children:C.adapterType})]}),(C.adapterType==="codespace"||C.adapterType==="docker")&&(r.length>0||!!C.githubAccountId)&&i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"GitHub Account"}),i.jsxs("select",{value:C.githubAccountId||"",onChange:ve=>{s&&d(s,{githubAccountId:ve.target.value})},className:oe.adapterSelect,"data-testid":"env-edit-github-account",children:[i.jsx("option",{value:"",children:"(Default)"}),r.map(ve=>i.jsxs("option",{value:ve.id,children:[ve.label,ve.username?` (@${ve.username})`:"",ve.isDefault?" — default":""]},ve.id))]})]}),C.adapterType==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Host"}),i.jsx(Bt,{value:String(re.host??""),onSave:ve=>Q("host",ve),mode:"edit",fieldId:"host",activeFieldId:_e,onActivate:Oe,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Port"}),i.jsx(Bt,{value:String(re.port??""),onSave:ve=>et("port",ve),validate:ve=>xp(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:_e,onActivate:Oe,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),C.adapterType==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Host"}),i.jsx(Bt,{value:String(re.host??""),onSave:ve=>Q("host",ve),validate:ve=>ve.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:_e,onActivate:Oe,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"User"}),i.jsx(Bt,{value:String(re.user??""),onSave:ve=>Q("user",ve),mode:"edit",fieldId:"user",activeFieldId:_e,onActivate:Oe,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"SSH Port"}),i.jsx(Bt,{value:String(re.sshPort??""),onSave:ve=>et("sshPort",ve),validate:ve=>xp(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:_e,onActivate:Oe,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Identity File"}),i.jsx(Bt,{value:String(re.identityFile??""),onSave:ve=>Q("identityFile",ve),mode:"edit",fieldId:"identityFile",activeFieldId:_e,onActivate:Oe,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),C.adapterType==="docker"&&re.attach!==void 0&&i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Attach (container)"}),i.jsx(Bt,{value:String(re.attach??""),onSave:ve=>Q("attach",ve),validate:ve=>ve.trim()===""?"Container name is required":void 0,mode:"edit",fieldId:"attach",activeFieldId:_e,onActivate:Oe,placeholder:"container name or ID",ariaLabel:"Attach container","data-testid":"env-edit-attach"})]}),C.adapterType==="docker"&&re.attach===void 0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Image"}),i.jsx(Bt,{value:String(re.image??""),onSave:ve=>Q("image",ve),mode:"edit",fieldId:"image",activeFieldId:_e,onActivate:Oe,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Repo"}),i.jsx(Bt,{value:String(re.repo??""),onSave:ve=>Q("repo",ve),mode:"edit",fieldId:"repo",activeFieldId:_e,onActivate:Oe,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),C.adapterType==="codespace"&&i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Codespace Name"}),i.jsx(Bt,{value:String(re.codespaceName??""),onSave:ve=>Q("codespaceName",ve),validate:ve=>ve.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:_e,onActivate:Oe,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return i.jsxs("div",{className:oe.container,"data-testid":"env-create-panel",children:[i.jsxs("div",{className:oe.header,children:[i.jsx("div",{className:oe.headerTitle,children:i.jsx("span",{className:oe.badge,children:"new environment"})}),i.jsxs("div",{className:oe.headerActions,children:[i.jsx("button",{onClick:ue,disabled:!Nt(),className:oe.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),i.jsx("button",{onClick:Re,className:oe.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:oe.body,children:i.jsxs("div",{className:oe.formContent,children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-name",children:"Name"}),i.jsx("input",{id:"env-create-name",type:"text",value:D,onChange:re=>R(re.target.value),placeholder:"Environment name...",autoFocus:!0,className:oe.nameInput,"data-testid":"env-create-name",onKeyDown:re=>{re.key==="Enter"&&Nt()&&ue()}})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),i.jsxs("select",{id:"env-create-adapter",value:E,onChange:re=>{M(re.target.value),re.target.value==="codespace"&&u(ce||void 0)},className:oe.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"})]})]}),(E==="codespace"||E==="docker")&&r.length>0&&i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-github-account",children:"GitHub Account"}),i.jsxs("select",{id:"env-create-github-account",value:ce,onChange:re=>{me(re.target.value),E==="codespace"&&u(re.target.value||void 0)},className:oe.adapterSelect,"data-testid":"env-create-github-account",children:[i.jsx("option",{value:"",children:"(Default)"}),r.map(re=>i.jsxs("option",{value:re.id,children:[re.label," (@",re.username,")",re.isDefault?" — default":""]},re.id))]})]}),E==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:O,onChange:re=>A(re.target.value),placeholder:"Host (optional)...",className:oe.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-port",children:"Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:Xc,max:Qc,value:$,onChange:re=>Y(re.target.value),placeholder:"Port (optional)...",className:oe.fieldInput,"data-testid":"env-create-port"})]})]}),E==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:O,onChange:re=>A(re.target.value),placeholder:"Host (required)...",className:oe.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-user",children:"User"}),i.jsx("input",{id:"env-create-user",type:"text",value:V,onChange:re=>ee(re.target.value),placeholder:"User (optional)...",className:oe.fieldInput,"data-testid":"env-create-user"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-port",children:"SSH Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:Xc,max:Qc,value:$,onChange:re=>Y(re.target.value),placeholder:"SSH port (optional)...",className:oe.fieldInput,"data-testid":"env-create-port"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-identity",children:"Identity File"}),i.jsx("input",{id:"env-create-identity",type:"text",value:le,onChange:re=>Z(re.target.value),placeholder:"Identity file (optional)...",className:oe.fieldInput,"data-testid":"env-create-identity"})]})]}),E==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-docker-mode",children:"Source"}),i.jsxs("select",{id:"env-docker-mode",value:ke,onChange:re=>{const ve=re.target.value;De(ve),ve==="attach"&&_()},className:oe.adapterSelect,"data-testid":"env-docker-mode",children:[i.jsx("option",{value:"create",children:"Create new container"}),i.jsx("option",{value:"attach",children:"Attach to existing container"})]})]}),ke==="create"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-image",children:"Image"}),i.jsx("input",{id:"env-create-image",type:"text",value:ae,onChange:re=>H(re.target.value),placeholder:"Image (optional)...",className:oe.fieldInput,"data-testid":"env-create-image"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-repo",children:"Repo"}),i.jsx("input",{id:"env-create-repo",type:"text",value:B,onChange:re=>F(re.target.value),placeholder:"Repo (optional)...",className:oe.fieldInput,"data-testid":"env-create-repo"})]})]}):i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Container"}),!S&&k.length>0&&i.jsxs("select",{value:ot,onChange:re=>{yt(re.target.value),re.target.value&&!D.trim()&&R(re.target.value)},className:oe.adapterSelect,"data-testid":"env-docker-container-select",children:[i.jsx("option",{value:"",children:"Select a container..."}),k.map(re=>i.jsxs("option",{value:re.name,children:[re.name," (",re.image,") ",re.status]},re.id))]}),(S||k.length===0)&&i.jsxs(i.Fragment,{children:[S?i.jsx("span",{className:oe.errorHint,children:S}):i.jsx("span",{className:oe.creatingHint,children:"No running containers found."}),i.jsx("input",{type:"text",value:ot,onChange:re=>{yt(re.target.value),re.target.value&&!D.trim()&&R(re.target.value)},placeholder:"Enter container name/ID...",className:oe.fieldInput,"data-testid":"env-docker-container-manual"})]})]})]}),E==="codespace"&&i.jsx(d8,{codespaceName:ge,onCodespaceNameChange:ne,envName:D,onEnvNameChange:R,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b})]})})]})}const u8="_group_1iprv_1",f8="_groupTitle_1iprv_8",p8="_shortcutList_1iprv_17",m8="_shortcutRow_1iprv_23",h8="_keys_1iprv_36",g8="_kbd_1iprv_43",v8="_description_1iprv_60",vi={group:u8,groupTitle:f8,shortcutList:p8,shortcutRow:m8,keys:h8,kbd:g8,description:v8},y8=[{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"}]},{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:"Root",shortcuts:[{keys:["Ctrl/Cmd","Enter"],description:"Send message (when the composer is focused)"},{keys:["Enter"],description:"Insert a new line in the message composer"}]}];function b8(){return i.jsxs("section",{className:fe.section,"data-testid":"keyboard-shortcuts-panel",children:[i.jsx("h3",{className:fe.sectionTitle,children:"Keyboard Shortcuts"}),i.jsx("p",{className:fe.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),y8.map(t=>i.jsxs("div",{className:vi.group,children:[i.jsx("h4",{className:vi.groupTitle,children:t.title}),i.jsx("div",{className:vi.shortcutList,children:t.shortcuts.map(s=>i.jsxs("div",{className:vi.shortcutRow,children:[i.jsx("span",{className:vi.keys,children:s.keys.map(o=>i.jsx("kbd",{className:vi.kbd,children:o},o))}),i.jsx("span",{className:vi.description,children:s.description})]},s.description))})]},t.title))]})}const _8=[{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 x8({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:fe.section,children:[i.jsx("h3",{className:fe.sectionTitle,children:"Credential Providers"}),i.jsx("p",{className:fe.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:fe.tokenList,children:_8.map(r=>i.jsxs("div",{className:fe.tokenRow,children:[i.jsx("span",{className:fe.tokenName,children:r.label}),i.jsx("span",{className:fe.tokenTarget,children:r.description}),i.jsx("select",{className:fe.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 k8="_container_10efq_1",S8="_header_10efq_7",j8="_list_10efq_105",T8="_card_10efq_111",w8="_cardHeader_10efq_125",N8="_cardTitle_10efq_135",C8="_defaultBadge_10efq_141",E8="_cardActions_10efq_155",A8="_description_10efq_160",D8="_meta_10efq_166",M8="_empty_10efq_212",R8="_typeBadge_10efq_362",es={container:k8,header:S8,list:j8,card:T8,cardHeader:w8,cardTitle:N8,defaultBadge:C8,cardActions:E8,description:A8,meta:D8,empty:M8,typeBadge:R8};function I8({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return i.jsxs("div",{className:es.container,children:[i.jsxs("div",{className:es.header,children:[i.jsx("h2",{children:"Personas"}),i.jsx(sn,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?i.jsx("p",{className:es.empty,children:"No personas yet. Create one to get started."}):i.jsx("div",{className:es.list,children:t.map(v=>{const b=s===v.id,_=v.type==="script";return i.jsxs("div",{className:es.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(v.id))},children:[i.jsxs("div",{className:es.cardHeader,children:[i.jsxs("span",{className:es.cardTitle,children:[i.jsx("strong",{children:v.name}),i.jsx("span",{className:es.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:_?"Script":"Agent"}),b&&i.jsx("span",{className:es.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),i.jsxs("div",{className:es.cardActions,onClick:k=>k.stopPropagation(),children:[!b&&i.jsx(sn,{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(sn,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&i.jsx("p",{className:es.description,children:v.description}),i.jsxs("div",{className:es.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(ys,{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 O8="_container_uy08i_1",B8="_header_uy08i_7",L8="_count_uy08i_13",z8="_presets_uy08i_18",$8="_presetButton_uy08i_24",H8="_filterInput_uy08i_41",P8="_groups_uy08i_53",U8="_group_uy08i_53",V8="_groupHeader_uy08i_68",q8="_groupName_uy08i_77",G8="_groupCount_uy08i_81",F8="_toolList_uy08i_87",K8="_toolItem_uy08i_95",Z8="_toolName_uy08i_103",yn={container:O8,header:B8,count:L8,presets:z8,presetButton:$8,filterInput:H8,groups:P8,group:U8,groupHeader:V8,groupName:q8,groupCount:G8,toolList:F8,toolItem:K8,toolName:Z8},Y8=(()=>{const t=new Map;for(const s of v_){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()}))})(),J8=[{name:"default",label:"Default",tools:g_},{name:"worker",label:"Worker",tools:R2},{name:"orchestrator",label:"Orchestrator",tools:I2},{name:"admin",label:"Admin",tools:O2}];function Yb({selectedTools:t,onChange:s,disabled:o}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.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=y.useCallback((v,b)=>{if(o)return;const _=new Set(d);for(const k of v)b?_.delete(k):_.add(k);s([..._].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return i.jsxs("div",{className:yn.container,"data-testid":"mcp-tool-selector",children:[i.jsx("div",{className:yn.header,children:i.jsx("span",{className:yn.count,children:t.length===0?`Using default (${g_.length} tools)`:`${t.length} of ${v_.size} tools selected`})}),i.jsxs("div",{className:yn.presets,"data-testid":"mcp-tool-presets",children:[J8.map(v=>i.jsx("button",{type:"button",className:yn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),i.jsx("button",{type:"button",className:yn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),i.jsx("input",{type:"text",className:yn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),i.jsx("div",{className:yn.groups,children:Y8.map(({group:v,tools:b})=>{const _=g?b.filter(S=>S.toLowerCase().includes(g)):b;if(_.length===0)return null;const k=_.every(S=>d.has(S));return i.jsxs("div",{className:yn.group,"data-testid":`tool-group-${v}`,children:[i.jsxs("label",{className:yn.groupHeader,children:[i.jsx("input",{type:"checkbox",checked:k,onChange:()=>p(_,k),disabled:o,"data-testid":`group-toggle-${v}`}),i.jsx("span",{className:yn.groupName,children:v}),i.jsxs("span",{className:yn.groupCount,children:["(",_.filter(S=>d.has(S)).length,"/",_.length,")"]})]}),i.jsx("div",{className:yn.toolList,children:_.map(S=>i.jsxs("label",{className:yn.toolItem,children:[i.jsx("input",{type:"checkbox",checked:d.has(S),onChange:()=>u(S),disabled:o,"data-testid":`tool-${S}`}),i.jsx("span",{className:yn.toolName,children:S})]},S))})]},v)})})]})}function sm(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 P1(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 W8="_container_1gfuq_1",X8="_header_1gfuq_7",Q8="_list_1gfuq_19",e7="_card_1gfuq_25",t7="_cardHeader_1gfuq_40",n7="_cardTitle_1gfuq_46",s7="_statusBadge_1gfuq_56",a7="_enabled_1gfuq_68",i7="_disabled_1gfuq_71",o7="_cardActions_1gfuq_75",r7="_cardMeta_1gfuq_80",l7="_empty_1gfuq_98",ts={container:W8,header:X8,list:Q8,card:e7,cardHeader:t7,cardTitle:n7,statusBadge:s7,enabled:a7,disabled:i7,cardActions:o7,cardMeta:r7,empty:l7};function c7({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=y.useState(null),m=u?t.find(_=>_.id===u):void 0,g=async _=>{await o(_),p(null)},v=y.useMemo(()=>{const _=new Map;for(const k of s)_.set(k.id,k.name);return _},[s]),b=_=>v.get(_)??_;return i.jsxs("div",{className:ts.container,children:[i.jsxs("div",{className:ts.header,children:[i.jsx("h2",{children:"Schedules"}),i.jsx(sn,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?i.jsx("p",{className:ts.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):i.jsx("div",{className:ts.list,children:t.map(_=>i.jsxs("div",{className:ts.card,"data-testid":`schedule-card-${_.id}`,onClick:()=>d(_.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(_.id))},children:[i.jsxs("div",{className:ts.cardHeader,children:[i.jsxs("span",{className:ts.cardTitle,children:[i.jsx("strong",{children:_.title}),i.jsx("span",{className:`${ts.statusBadge} ${_.enabled?ts.enabled:ts.disabled}`,"data-testid":`schedule-status-badge-${_.id}`,children:_.enabled?"Enabled":"Disabled"})]}),i.jsxs("div",{className:ts.cardActions,onClick:k=>k.stopPropagation(),children:[i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(_.id,{enabled:!_.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${_.id}`,title:_.enabled?"Disable schedule":"Enable schedule",children:_.enabled?"Disable":"Enable"}),i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>d(_.id),"data-testid":`schedule-edit-${_.id}`,children:"Edit"}),i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>p(_.id),"data-testid":`schedule-delete-${_.id}`,children:"Delete"})]})]}),i.jsxs("div",{className:ts.cardMeta,children:[i.jsx("span",{"data-testid":`schedule-expression-${_.id}`,children:_.scheduleExpression}),_.personaId&&i.jsxs("span",{"data-testid":`schedule-persona-${_.id}`,children:["Persona: ",b(_.personaId)]}),i.jsxs("span",{"data-testid":`schedule-last-run-${_.id}`,children:["Last run: ",_.lastRunAt?sm(_.lastRunAt):"Never"]}),_.enabled&&_.nextRunAt?i.jsxs("span",{"data-testid":`schedule-next-run-${_.id}`,children:["Next run: ",P1(_.nextRunAt)]}):null,_.runCount>0&&i.jsxs("span",{"data-testid":`schedule-run-count-${_.id}`,children:["Runs: ",_.runCount]})]})]},_.id))}),i.jsx(ys,{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 d7="_nav_1bhou_1",u7="_tab_1bhou_24",f7="_tabIcon_1bhou_62",p7="_tabActive_1bhou_68",Hc={nav:d7,tab:u7,tabIcon:f7,tabActive:p7},na=[{path:"credentials",label:"Credentials",icon:i.jsx(Xj,{size:wt})},{path:"github-accounts",label:"GitHub Accounts",icon:i.jsx(Gj,{size:wt})},{path:"personas",label:"Personas",icon:i.jsx(BT,{size:wt})},{path:"schedules",label:"Schedules",icon:i.jsx(kj,{size:wt})},{path:"appearance",label:"Appearance",icon:i.jsx(yT,{size:wt})},{path:"shortcuts",label:"Shortcuts",icon:i.jsx(eT,{size:wt})},{path:"plugins",label:"Plugins",icon:i.jsx(jT,{size:wt})},{path:"about",label:"About",icon:i.jsx(um,{size:wt})}];function m7(){var u;const t=Jt(),s=vt(),o=y.useRef(null),r=((u=na.find(p=>{const m=`${xi}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??na[0].path,c=y.useCallback(p=>{s(`${xi}/${p}`)},[s]),d=y.useCallback(p=>{var k,S;const m=(k=o.current)==null?void 0:k.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:na.findIndex(j=>j.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%na.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+na.length)%na.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=na.length-1;else return;const _=na[b].path;s(`${xi}/${_}`),(S=m[b])==null||S.focus()},[r,s]);return i.jsx("nav",{className:Hc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:na.map(p=>{const m=p.path===r;return i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Hc.tab} ${m?Hc.tabActive:""}`,onClick:()=>c(p.path),children:[i.jsx("span",{className:Hc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}const h7=["lifecycle:","pipe:","stdin:"];function U1(t){return t.selfEcho?"chatroom":t.name.startsWith("pipe:")?"pipe":"channel"}function g7(t,s){let o=!1;for(const r of t.subscribers){const c=s.get(r.sessionId);if(c&&(o=!0,c.taskId))return{kind:"task",taskId:c.taskId}}return o?{kind:"unattached"}:{kind:"external"}}function v7(t,s){const o=new Map(s.map(u=>[u.id,u])),r=new Map,c=[];for(const u of t){const p=g7(u,o);if(p.kind==="task"){const m=r.get(p.taskId);m?m.push(u):r.set(p.taskId,[u])}else c.push(u)}const d=Array.from(r,([u,p])=>({taskId:u,streams:p}));return c.length>0&&d.push({taskId:void 0,streams:c}),d}const y7="_container_16qkd_1",b7="_header_16qkd_7",_7="_title_16qkd_15",x7="_headerActions_16qkd_21",k7="_internalsToggle_16qkd_27",S7="_refreshButton_16qkd_37",j7="_state_16qkd_52",T7="_group_16qkd_59",w7="_groupHeader_16qkd_63",N7="_row_16qkd_72",C7="_selected_16qkd_92",E7="_kindBadge_16qkd_96",A7="_kindChatroom_16qkd_108",D7="_kindPipe_16qkd_114",M7="_kindChannel_16qkd_120",R7="_streamName_16qkd_126",I7="_meta_16qkd_135",Yt={container:y7,header:b7,title:_7,headerActions:x7,internalsToggle:k7,refreshButton:S7,state:j7,group:T7,groupHeader:w7,row:N7,selected:C7,kindBadge:E7,kindChatroom:A7,kindPipe:D7,kindChannel:M7,streamName:R7,meta:I7},O7={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function B7({kind:t}){return t==="chatroom"?i.jsx(fT,{size:Ze,"aria-hidden":"true"}):t==="pipe"?i.jsx(Vj,{size:Ze,"aria-hidden":"true"}):i.jsx(Kj,{size:Ze,"aria-hidden":"true"})}function L7({streams:t,sessions:s,tasks:o,loading:r,loadError:c=!1,loadedOnce:d=!0,showInternals:u,onToggleInternals:p,selectedStreamId:m,onSelectStream:g,onRefresh:v}){const b=v7(t,s),_={chatroom:Yt.kindChatroom,pipe:Yt.kindPipe,channel:Yt.kindChannel},k=S=>{var j;return((j=o.find(T=>T.id===S))==null?void 0:j.title)??S};return i.jsxs("div",{className:Yt.container,"data-testid":"coordination-list",children:[i.jsxs("div",{className:Yt.header,children:[i.jsx("span",{className:Yt.title,children:"Coordination"}),i.jsxs("div",{className:Yt.headerActions,children:[i.jsxs("label",{className:Yt.internalsToggle,children:[i.jsx("input",{type:"checkbox",checked:u,onChange:S=>p(S.target.checked),"data-testid":"coordination-show-internals"}),"Show internals"]}),v&&i.jsx("button",{type:"button",className:Yt.refreshButton,onClick:v,"aria-label":"Refresh streams","data-testid":"coordination-refresh",children:i.jsx(wT,{size:Ze,"aria-hidden":"true"})})]})]}),r&&t.length===0&&i.jsxs("div",{className:Yt.state,children:["Loading","…"]}),!r&&c&&i.jsx("div",{className:Yt.state,"data-testid":"coordination-error",children:"Unable to load streams"}),!r&&!c&&d&&t.length===0&&i.jsx("div",{className:Yt.state,"data-testid":"coordination-empty",children:"No active streams"}),b.map(S=>i.jsxs("div",{className:Yt.group,children:[i.jsx("div",{className:Yt.groupHeader,children:S.taskId?k(S.taskId):"Unattached / external (CLI · MCP)"}),S.streams.map(j=>{const T=U1(j),w=j.id===m;return i.jsxs("button",{type:"button",className:`${Yt.row}${w?` ${Yt.selected}`:""}`,onClick:()=>g(j.id),"data-testid":`coordination-row-${j.id}`,"aria-current":w?"page":void 0,children:[i.jsxs("span",{className:`${Yt.kindBadge} ${_[T]}`,children:[i.jsx(B7,{kind:T})," ",O7[T]]}),i.jsx("span",{className:Yt.streamName,children:j.name}),i.jsxs("span",{className:Yt.meta,children:[j.subscriberCount," ",j.subscriberCount===1?"sub":"subs"," ","·"," ",j.messageBufferDepth," buffered"]})]},j.id)})]},S.taskId??"__orphans__"))]})}const z7="_panel_iibrt_1",$7="_header_iibrt_24",H7="_title_iibrt_33",P7="_closeButton_iibrt_43",U7="_body_iibrt_57",V7="_section_iibrt_63",q7="_sectionLabel_iibrt_67",G7="_metaRow_iibrt_76",F7="_metaKey_iibrt_84",K7="_metaValue_iibrt_90",Z7="_subscriberCard_iibrt_99",Y7="_subscriberHeader_iibrt_107",J7="_sessionLink_iibrt_114",W7="_badges_iibrt_132",X7="_badgeRw_iibrt_150 _badge_iibrt_132",Q7="_badgeR_iibrt_150 _badge_iibrt_132",ez="_badgeW_iibrt_162 _badge_iibrt_132",tz="_badgeAsync_iibrt_168 _badge_iibrt_132",nz="_badgeSync_iibrt_174 _badge_iibrt_132",sz="_badgeDetach_iibrt_178 _badge_iibrt_132",az="_spawnTag_iibrt_184 _badge_iibrt_132",iz="_fdNumber_iibrt_189",oz="_emptySubscribers_iibrt_195",rz="_metaValueMono_iibrt_201 _metaValue_iibrt_90",lz="_placeholder_iibrt_207",cz="_advanced_iibrt_216",dz="_advancedSummary_iibrt_220",Pe={panel:z7,header:$7,title:H7,closeButton:P7,body:U7,section:V7,sectionLabel:q7,metaRow:G7,metaKey:F7,metaValue:K7,subscriberCard:Z7,subscriberHeader:Y7,sessionLink:J7,badges:W7,badgeRw:X7,badgeR:Q7,badgeW:ez,badgeAsync:tz,badgeSync:nz,badgeDetach:sz,spawnTag:az,fdNumber:iz,emptySubscribers:oz,metaValueMono:rz,placeholder:lz,advanced:cz,advancedSummary:dz},uz={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function fz({permission:t}){const s=t==="rw"?Pe.badgeRw:t==="r"?Pe.badgeR:Pe.badgeW;return i.jsx("span",{className:s,children:t})}function pz({mode:t}){const s=t==="async"?Pe.badgeAsync:t==="detach"?Pe.badgeDetach:Pe.badgeSync;return i.jsx("span",{className:s,children:t})}function mz({stream:t,onClose:s}){const o=vt();return y.useEffect(()=>{const r=c=>{c.key==="Escape"&&s()};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[s]),i.jsxs("div",{className:Pe.panel,"data-testid":"stream-detail-panel",children:[i.jsxs("div",{className:Pe.header,children:[i.jsx("h3",{className:Pe.title,children:t.name}),i.jsx("button",{type:"button",className:Pe.closeButton,onClick:s,"aria-label":"Close stream details",children:"×"})]}),i.jsxs("div",{className:Pe.body,children:[i.jsxs("div",{className:Pe.section,children:[i.jsx("div",{className:Pe.sectionLabel,children:"Overview"}),i.jsxs("div",{className:Pe.metaRow,children:[i.jsx("span",{className:Pe.metaKey,children:"Kind"}),i.jsx("span",{className:Pe.metaValue,children:uz[U1(t)]})]}),i.jsxs("div",{className:Pe.metaRow,children:[i.jsx("span",{className:Pe.metaKey,children:"Participants"}),i.jsx("span",{className:Pe.metaValue,children:t.subscriberCount})]}),i.jsxs("div",{className:Pe.metaRow,children:[i.jsx("span",{className:Pe.metaKey,children:"Buffered"}),i.jsxs("span",{className:Pe.metaValue,children:[t.messageBufferDepth," msgs"]})]})]}),i.jsxs("div",{className:Pe.section,children:[i.jsx("div",{className:Pe.sectionLabel,children:"Participants"}),t.subscribers.length===0?i.jsx("div",{className:Pe.emptySubscribers,children:"No active subscribers"}):t.subscribers.map(r=>i.jsxs("div",{className:Pe.subscriberCard,"data-testid":`subscriber-card-${r.subscriptionId}`,children:[i.jsxs("button",{type:"button",className:Pe.sessionLink,onClick:()=>{o(xm(r.sessionId))},title:r.sessionId,children:[r.sessionId.slice(0,12),"…"]}),r.createdBySpawn&&i.jsx("span",{className:Pe.spawnTag,children:"spawn"})]},r.subscriptionId))]}),i.jsxs("div",{className:Pe.section,children:[i.jsx("div",{className:Pe.sectionLabel,children:"Conversation"}),i.jsx("div",{className:Pe.placeholder,"data-testid":"stream-conversation-placeholder",children:"Live conversation view — coming in V2."})]}),i.jsxs("details",{className:Pe.advanced,"data-testid":"stream-advanced",children:[i.jsx("summary",{className:Pe.advancedSummary,children:"Advanced"}),i.jsxs("div",{className:Pe.metaRow,children:[i.jsx("span",{className:Pe.metaKey,children:"Stream ID"}),i.jsx("span",{className:Pe.metaValueMono,children:t.id})]}),t.subscribers.map(r=>i.jsxs("div",{className:Pe.subscriberCard,children:[i.jsxs("div",{className:Pe.subscriberHeader,children:[i.jsxs("span",{className:Pe.fdNumber,children:["fd ",r.fd]}),i.jsxs("span",{className:Pe.metaValueMono,title:r.subscriptionId,children:[r.subscriptionId.slice(0,12),"…"]})]}),i.jsxs("div",{className:Pe.badges,children:[i.jsx(fz,{permission:r.permission}),i.jsx(pz,{mode:r.deliveryMode})]})]},r.subscriptionId))]})]})]})}function hz({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(fy.map(d=>[d,[]]));for(const d of t){const u=ol(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(S=>s.get(S)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(S=>S.status==="complete").length;let b;if(u==="paused"&&o){const S=o.get(d.id);S==="idle"?b="Needs input":S==="completed"&&(b="Ready to complete")}const _={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},k=c.get(u);k?k.push(_):c.get("not_started").push(_)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return fy.map(d=>{const u=Fa(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const gz="_boardContainer_1c4y1_1",vz="_column_1c4y1_17",yz="_columnHeader_1c4y1_34",bz="_columnIcon_1c4y1_47",_z="_columnLabel_1c4y1_52",xz="_columnCount_1c4y1_57",kz="_cardList_1c4y1_67",Sz="_emptyPlaceholder_1c4y1_76",jz="_card_1c4y1_67",Tz="_cardHeader_1c4y1_107",wz="_cardStatusIcon_1c4y1_113",Nz="_cardTitle_1c4y1_119",Cz="_cardBadges_1c4y1_127",Ez="_badge_1c4y1_134",Az="_blockedBadge_1c4y1_146",Dz="_childBadge_1c4y1_151",Mz="_depBadge_1c4y1_155",Rz="_parentBadge_1c4y1_159",Iz="_pausedSubBadge_1c4y1_166",Oz="_personaBadge_1c4y1_170",Bz="_envBadge_1c4y1_174",Lz="_emptyCta_1c4y1_178",zz="_ctaButton_1c4y1_188",$z="_ctaDescription_1c4y1_204",lt={boardContainer:gz,column:vz,columnHeader:yz,columnIcon:bz,columnLabel:_z,columnCount:xz,cardList:kz,emptyPlaceholder:Sz,card:jz,cardHeader:Tz,cardStatusIcon:wz,cardTitle:Nz,cardBadges:Cz,badge:Ez,blockedBadge:Az,childBadge:Dz,depBadge:Mz,parentBadge:Rz,pausedSubBadge:Iz,personaBadge:Oz,envBadge:Bz,emptyCta:Lz,ctaButton:zz,ctaDescription:$z};function Hz({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=vt(),p=y.useMemo(()=>o.filter(_=>_.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(_=>[_.id,_.status])),[o]),g=y.useMemo(()=>new Map(p.map(_=>[_.id,_])),[p]),v=y.useMemo(()=>{const _=new Map(r.map(C=>[C.id,C])),k=new Map(c.map(C=>[C.id,C])),S=new Map(d.map(C=>[C.id,C])),j=new Map,T=new Map,w=new Map;for(const C of p)if(C.latestSessionId){const D=_.get(C.latestSessionId);if(D){if(j.set(C.id,D.endReason||D.status),D.personaId){const R=k.get(D.personaId);R&&T.set(C.id,R.name)}if(D.environmentId){const R=S.get(D.environmentId);R&&w.set(C.id,R.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:T,environmentNameByTaskId:w}},[p,r,c,d]),b=y.useMemo(()=>hz({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?i.jsxs("div",{className:lt.emptyCta,"data-testid":"board-empty-cta",children:[i.jsx("button",{className:lt.ctaButton,onClick:()=>u(Ai(t,void 0,s)),children:"Create Task"}),i.jsx("div",{className:lt.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):i.jsx("div",{className:lt.boardContainer,"data-testid":"board-container",children:b.map(_=>i.jsxs("section",{className:lt.column,"data-testid":`board-column-${_.status}`,"aria-label":`${_.label}, ${_.tasks.length} ${_.tasks.length===1?"task":"tasks"}`,children:[i.jsxs("div",{className:lt.columnHeader,children:[i.jsx("span",{className:lt.columnIcon,style:{color:_.style.color},children:_.style.icon}),i.jsx("span",{className:lt.columnLabel,children:_.label}),i.jsx("span",{className:lt.columnCount,"data-testid":`board-count-${_.status}`,children:_.tasks.length})]}),i.jsx("div",{className:lt.cardList,children:_.tasks.length===0?i.jsx("div",{className:lt.emptyPlaceholder,children:"No tasks"}):i.jsx(as,{mode:"popLayout",children:_.tasks.map(k=>i.jsx($t.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:i.jsx(Pz,{boardTask:k,tasksById:g,personaName:v.personaNameByTaskId.get(k.task.id),envName:v.environmentNameByTaskId.get(k.task.id),onClick:()=>u(os(k.task.id,void 0,t,s))})},k.task.id))})})]},_.status))})}function Pz({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=Fa(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return i.jsxs("div",{className:lt.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c())},children:[i.jsxs("div",{className:lt.cardHeader,children:[i.jsx("span",{className:lt.cardStatusIcon,style:{color:v.color},children:v.icon}),i.jsx("span",{className:lt.cardTitle,children:d.title})]}),i.jsxs("div",{className:lt.cardBadges,children:[b&&i.jsx("span",{className:`${lt.badge} ${lt.parentBadge}`,title:b.title,children:b.title}),p>0&&i.jsxs("span",{className:`${lt.badge} ${lt.childBadge}`,children:[m,"/",p]}),u&&i.jsx("span",{className:`${lt.badge} ${lt.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&i.jsx("span",{className:`${lt.badge} ${lt.depBadge}`,children:"dep"}),g&&i.jsx("span",{className:`${lt.badge} ${lt.pausedSubBadge}`,children:g}),o&&i.jsx("span",{className:`${lt.badge} ${lt.personaBadge}`,children:o}),r&&i.jsx("span",{className:`${lt.badge} ${lt.envBadge}`,children:r})]})]})}const Uz="_formContent_ymnez_1",Vz="_section_ymnez_13",qz="_label_ymnez_19",Gz="_titleInput_ymnez_26",Fz="_descriptionTextarea_ymnez_58",Kz="_selectField_ymnez_94",Zz="_checkboxRow_ymnez_128",Yz="_checkboxLabel_ymnez_141",Jz="_fieldError_ymnez_146",xt={formContent:Uz,section:Vz,label:qz,titleInput:Gz,descriptionTextarea:Fz,selectField:Kz,checkboxRow:Zz,checkboxLabel:Yz,fieldError:Jz};function Wz(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.linkedEnvironmentIds[0])??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const Xz=100;function Qz({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:Xz,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 V1=y.createContext(void 0),e$=4e3;function t$({children:t}){const[s,o]=y.useState([]),r=y.useRef(0),c=y.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=y.useCallback((u,p="info",m=e$)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return i.jsx(V1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function pn(){const t=y.useContext(V1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const am="grackle-theme",q1="grackle-prefer-system",G1="(prefers-color-scheme: dark)";let qr=[],ed;function Sp(){ed=void 0;for(const t of qr)t()}function im(){return typeof window>"u"?!1:window.matchMedia(G1).matches}function Jr(){if(typeof localStorage>"u")return Kb;try{const t=localStorage.getItem(am);if(t!==null&&z1.has(t))return t}catch{}return Kb}function fd(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(q1)==="true"}catch{return!1}}function om(t){return Nd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function F1(t,s){const o=nm(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?im()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=om(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return im()?r.variantDarkId:r.variantLightId}return t}function wo(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=F1(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&wo(Jr(),fd());function n$(){return ed===void 0&&(ed={themeId:Jr(),systemDark:im(),preferSystem:fd()}),ed}function s$(t){return qr=[...qr,t],()=>{qr=qr.filter(s=>s!==t)}}function a$(){const t=y.useSyncExternalStore(s$,n$),{themeId:s,preferSystem:o}=t,r=F1(s,o),c=y.useCallback(u=>{if(z1.has(u)){try{localStorage.setItem(am,u)}catch{}wo(u,fd(),!0),Sp()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(q1,u?"true":"false")}catch{}if(u){const p=Jr(),m=nm(p);if(m!=null&&m.hidden){const g=om(p);if(g)try{localStorage.setItem(am,g.id)}catch{}}}wo(Jr(),u,!0),Sp()},[]);return y.useEffect(()=>{wo(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(G1),p=()=>{const m=Jr(),g=fd();if(g){const v=nm(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&wo(m,g),v!=null&&v.hidden){const b=om(m);b!=null&&b.variantDarkId&&b.variantLightId&&wo(m,g)}}Sp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const K1=y.createContext(void 0);function i$({children:t}){const s=a$();return i.jsx(K1.Provider,{value:s,children:t})}function Z1(){const t=y.useContext(K1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const Y1=y.createContext(void 0),J1=y.createContext(void 0);function o$({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return i.jsx(J1.Provider,{value:r,children:i.jsx(Y1.Provider,{value:s,children:t})})}function r$(){return y.useContext(Y1)}function l$(){const t=y.useContext(J1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const ih=y.createContext(void 0);function ut(){const t=y.useContext(ih);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function W1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function X1(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function c$(t){return W1(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 d$=new Set(["off","subscription","api_key"]),Pc=new Set(["off","on"]);function u$(t){return W1(t)&&d$.has(t.claude)&&Pc.has(t.github)&&Pc.has(t.copilot)&&Pc.has(t.codex)&&Pc.has(t.goose)}function Q1(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 ek(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 jo=5e3;function f$(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 wi={label:"Home",url:Ho};function p$(t){return t?[wi,{label:"Settings",url:xi},{label:t,url:void 0}]:[wi,{label:"Settings",url:void 0}]}const tk={label:"Environments",url:Mo};function m$(){return[wi,{label:"Environments",url:void 0}]}function h$(){return[wi,{label:"New Chat",url:void 0}]}function g$(t){return[wi,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function v$(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[wi,tk,{label:(d==null?void 0:d.displayName)??"Environment",url:Ro(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function y$(t,s,o,r,c){const d=f$(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(k=>k.id===p):void 0,g=s??(m==null?void 0:m.linkedEnvironmentIds[0]),v=g?r.find(k=>k.id===g):void 0,b=[wi];v&&g&&(b.push(tk),b.push({label:v.displayName,url:Ro(g)})),m&&g&&b.push({label:m.name,url:ji(m.id,g)});for(let k=0;k<d.length-1;k++)b.push({label:d[k].title,url:os(d[k].id,void 0,p,g)});const _=d[d.length-1];return b.push({label:(_==null?void 0:_.title)??t,url:void 0}),b}function oh(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 Uc(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 b$(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 rh(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),_=b?Uc(b):void 0;if(_)try{const k=JSON.parse(v.content);o.set(_,{tool:k.tool,args:k.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,b)=>{if(v.eventType!=="tool_result")return v;const _=s.get(v),k=_?b$(_):void 0;if(!k)return v;const S=o.get(k);if(!S)return v;r.add(k),c.add(b);let j;const T=v.content.trim();if(T.startsWith("{"))try{const w=JSON.parse(T);typeof w.detailedContent=="string"&&(j=w.detailedContent)}catch{}return{...v,toolUseCtx:{...S,detailedResult:j}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const b=s.get(d[v]),_=b?Uc(b):void 0;_&&r.has(_)||u.push(v)}const p=[];for(let v=0;v<d.length;v++)d[v].eventType!=="tool_result"||c.has(v)||p.push(v);let m=0;for(const v of u){for(;m<p.length&&p[m]<v;)m++;if(m>=p.length)break;const b=p[m];if(b!==v+1)continue;const _=d[v],k=d[b];let S;try{const j=JSON.parse(_.content);S={tool:j.tool,args:j.args}}catch{}if(S){let j;const T=k.content.trim();if(T.startsWith("{"))try{const D=JSON.parse(T);typeof D.detailedContent=="string"&&(j=D.detailedContent)}catch{}d[b]={...k,toolUseCtx:{...S,detailedResult:j}},c.add(b);const w=s.get(_),C=w?Uc(w):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(_,{...w??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const b=s.get(v);if(!b)return!0;const _=Uc(b);if(_&&r.has(_))return!1;const k=b.__seqId;return!(k&&r.has(k))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let b=!1;for(let _=v+1;_<g.length;_++)if(g[_].eventType!=="tool_use"){b=!0;break}b&&(g[v]={...g[v],settled:!0})}return g}function _$(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=nk(s),d=s.filter(m=>rm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||rm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function nk(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function rm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function x$(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=nk(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}):rm(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 k$(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 S$(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 Cs=[{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
325
+ --- End forwarded ---`}function n5(t){return t.replace(/[\r\n]+/g," ").trim().replace(/---/g,"—")}function s5({events:t,formatForClipboard:s}){const[o,r]=y.useState(!1),[c,d]=y.useState(new Set),u=y.useRef(void 0),p=y.useMemo(()=>c.size,[c]),m=y.useCallback(S=>{r(!0),S!==void 0?(d(new Set([S])),u.current=S):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((S,j)=>{if(j&&u.current!==void 0){const T=Math.min(u.current,S),w=Math.max(u.current,S);d(C=>{const D=new Set(C);for(let R=T;R<=w;R++)R<t.length&&il(t[R])&&D.add(R);return D})}else d(T=>{const w=new Set(T);return w.has(S)?w.delete(S):w.add(S),w.size===0?(r(!1),u.current=void 0):u.current=S,w})},[t]),b=y.useCallback(()=>{const S=new Set;for(let j=0;j<t.length;j++)il(t[j])&&S.add(j);d(S)},[t]),_=y.useCallback(()=>{d(new Set)},[]),k=y.useCallback(async()=>{const j=[...c].sort((w,C)=>w-C).filter(w=>w<t.length).map(w=>t[w]);if(j.length===0)return!1;const T=s(j);try{return await navigator.clipboard.writeText(T),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:_,copySelected:k}}const a5="_wrapper_1cdza_1",i5="_scrollContainer_1cdza_9",o5="_selectingPadding_1cdza_16",r5="_toolbar_1cdza_20",l5="_directionToggle_1cdza_27",c5="_scrollToAnchor_1cdza_65",d5="_scrollToAnchorBottom_1cdza_89",u5="_scrollToAnchorTop_1cdza_93",f5="_eventOverflowWarning_1cdza_97",sa={wrapper:a5,scrollContainer:i5,selectingPadding:o5,toolbar:r5,directionToggle:l5,scrollToAnchor:c5,scrollToAnchorBottom:d5,scrollToAnchorTop:u5,eventOverflowWarning:f5},p5=10*1024,m5=new Set(["running","idle"]);function h5(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 A1="grackle-stream-direction";function g5(){try{return localStorage.getItem(A1)==="reversed"}catch{return!1}}function v5({eventsDropped:t}){return t<=0?i.jsx(i.Fragment,{}):i.jsxs("div",{className:sa.eventOverflowWarning,role:"alert",children:[i.jsx(fm,{size:zt,"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 sh({events:t,eventsDropped:s,emptyState:o,onShowToast:r,sessions:c,currentSessionId:d,environments:u,personas:p,onForward:m,sandboxProxyUrl:g}){const v=y.useRef(null),[b,_]=y.useState(g5),k=E3(),[S,j]=y.useState(!1),[T,w]=y.useState(!1),[C,D]=y.useState(void 0),R=s5({events:t,formatForClipboard:E1}),E=y.useMemo(()=>t.filter(il).length,[t]),M=y.useMemo(()=>c?c.filter(ce=>m5.has(ce.status)&&ce.id!==d):[],[c,d]),O=y.useMemo(()=>b?[...t].reverse():t,[t,b]),{isAtAnchor:A,scrollToAnchor:$}=X6({scrollRef:v,contentLength:t.length,isReversed:b,paused:R.isSelecting}),Y=()=>{const ce=!b;_(ce);try{localStorage.setItem(A1,ce?"reversed":"default")}catch{}};y.useEffect(()=>{if(!R.isSelecting)return;const ce=me=>{me.key==="Escape"&&!S&&!T&&R.cancelSelection()};return window.addEventListener("keydown",ce),()=>{window.removeEventListener("keydown",ce)}},[R.isSelecting,R.cancelSelection,S,T]);const V=y.useCallback(async()=>{await R.copySelected()&&(r==null||r(`Copied ${R.selectedCount} message${R.selectedCount===1?"":"s"} to clipboard`,"success"))},[R,r]),ee=y.useCallback(()=>[...R.selectedIndices].sort((me,ke)=>me-ke).filter(me=>me<t.length).map(me=>t[me]),[R.selectedIndices,t]),le=y.useCallback(ce=>{if(!ce)return"this session";const me=c==null?void 0:c.find(De=>De.id===ce);if(!me)return ce.slice(0,8);const ke=u==null?void 0:u.find(De=>De.id===me.environmentId);return(ke==null?void 0:ke.displayName)??me.environmentId.slice(0,8)},[c,u]),Z=y.useCallback(async(ce,me)=>{if(!m)return;const ke=le(ce);try{await m(ce,me);const De=R.selectedCount;r==null||r(`Forwarded ${De} message${De===1?"":"s"} to ${ke}`,"success"),R.cancelSelection()}catch{r==null||r("Failed to forward messages","error")}},[m,le,r,R]),ae=y.useCallback(ce=>{j(!1);const me=ee(),ke=le(d),De=t5(ke,me);if(new TextEncoder().encode(De).length>p5){D({sessionId:ce,text:De}),w(!0);return}Z(ce,De).catch(()=>{})},[ee,le,d,Z]),H=y.useCallback(()=>{w(!1),C&&(Z(C.sessionId,C.text).catch(()=>{}),D(void 0))},[C,Z]),B=y.useCallback(()=>{w(!1),D(void 0)},[]),F=k?0:.2,ge=b?-8:8,ne=C?Math.round(new TextEncoder().encode(C.text).length/1024):0;return i.jsxs("div",{className:sa.wrapper,children:[i.jsx("div",{className:sa.toolbar,children:i.jsx(Ti,{text:b?"Showing newest first":"Showing oldest first",children:i.jsx("button",{className:sa.directionToggle,onClick:Y,"aria-label":b?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:b?i.jsx(dy,{size:zt,"aria-hidden":"true"}):i.jsx(uy,{size:zt,"aria-hidden":"true"})})})}),i.jsxs("div",{ref:v,className:`${sa.scrollContainer} ${R.isSelecting?sa.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,i.jsx(v5,{eventsDropped:s}),i.jsx(as,{initial:!1,children:O.map((ce,me)=>{const ke=b?t.length-1-me:me;return i.jsx($t.div,{initial:{opacity:0,y:ge},animate:{opacity:1,y:0},transition:{duration:F,ease:"easeOut"},children:i.jsx(y6,{copyText:e5(ce),isContentBearing:il(ce),isSelecting:R.isSelecting,isSelected:R.selectedIndices.has(ke),checkboxLabel:h5(ce),onSelect:()=>{R.enterSelectionMode(ke)},onToggle:De=>{R.toggleEvent(ke,De)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:i.jsx(sD,{event:ce,toolUseCtx:ce.toolUseCtx,settled:ce.settled,sandboxProxyUrl:g})})},`${ce.sessionId}-${ce.timestamp}-${ke}`)})})]}),i.jsx(as,{children:R.isSelecting&&i.jsx(N6,{selectedCount:R.selectedCount,totalSelectable:E,onSelectAll:R.selectAll,onDeselectAll:R.deselectAll,onCopy:()=>{V().catch(()=>{})},onForward:m!==void 0?()=>{j(!0)}:void 0,forwardDisabled:M.length===0,onCancel:R.cancelSelection})}),i.jsx(Y6,{isOpen:S,sessions:M,environments:u??[],personas:p,onSelect:ae,onCancel:()=>{j(!1)}}),i.jsx(ys,{isOpen:T,title:"Send large message?",description:`This will forward a large message (${ne} KB). Continue?`,confirmLabel:"Send",onConfirm:H,onCancel:B}),i.jsx(as,{children:!A&&i.jsxs($t.button,{className:`${sa.scrollToAnchor} ${b?sa.scrollToAnchorTop:sa.scrollToAnchorBottom}`,onClick:$,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[b?i.jsx(uy,{size:zt,"aria-hidden":"true"}):i.jsx(dy,{size:zt,"aria-hidden":"true"})," New events"]})})]})}function ah(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[b,_]=y.useState(""),k=y.useRef(!1),S=d===c,j=y.useCallback(O=>{v(O),_("")},[]),T=y.useCallback(()=>{_("")},[]),w=y.useCallback(()=>{k.current=!1,u==null||u(null),v(""),_("")},[u]),C=y.useCallback(()=>{const O=m?g.trim():g;if(r){const $=r(g);if($){_($);return}}const A=m?s.trim():s;if(O===A){w();return}o(O),w()},[g,s,m,r,o,w]),D=y.useCallback(()=>{k.current=!0,u==null||u(c),v(s),_("")},[c,s,u]),R=y.useCallback(O=>{if(k.current){k.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(O=>{O.key==="Escape"?w():O.key==="Enter"&&p&&C()},[w,p,C]),M=(()=>{if(!S)return!1;const O=m?s.trim():s;return(m?g.trim():g)!==O})();return y.useEffect(()=>{!S&&(g!==""||b!=="")&&(v(""),_(""))},[S,g,b]),{isEditing:S,draft:g,error:b,isDirty:M,startEdit:D,cancelEdit:w,save:C,setDraft:j,clearError:T,handleBlur:R,handleKeyDown:E,ignoreInitialBlurRef:k}}const y5="_editFieldWrapper_yuzty_1",b5="_editInput_yuzty_10",_5="_editTextarea_yuzty_42",x5="_editSelect_yuzty_78",k5="_editError_yuzty_111",S5="_editInputInvalid_yuzty_118",j5="_editHint_yuzty_123",T5="_unsavedDot_yuzty_132",w5="_metaValueClickable_yuzty_140",N5="_editButton_yuzty_159",C5="_metaPlaceholder_yuzty_175",E5="_worktreeToggle_yuzty_180",it={editFieldWrapper:y5,editInput:b5,editTextarea:_5,editSelect:x5,editError:k5,editInputInvalid:S5,editHint:j5,unsavedDot:T5,metaValueClickable:w5,editButton:N5,metaPlaceholder:C5,worktreeToggle:E5};function Bt(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:_,"data-testid":k}=t,S=y.useRef(null),j=ah({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(j.isEditing){const w=window.setTimeout(()=>{var C;(C=S.current)==null||C.focus()},0);return()=>window.clearTimeout(w)}},[j.isEditing]),c==="create"){const w=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return i.jsxs("div",{className:it.editFieldWrapper,children:[i.jsx("input",{className:`${it.editInput} ${C?it.editInputInvalid:""}`,value:s,onChange:w,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),C&&i.jsx("span",{className:it.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return i.jsxs("div",{className:it.editFieldWrapper,children:[i.jsx("input",{ref:S,className:`${it.editInput} ${j.error?it.editInputInvalid:""}`,value:j.draft,onChange:w=>j.setDraft(w.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),j.isDirty&&i.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),j.error&&i.jsx("span",{className:it.editError,"data-testid":"edit-error",children:j.error}),i.jsx("span",{className:it.editHint,children:"Enter to save · Esc to cancel"})]});const T=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":_,"data-testid":k?`${k}-button`:void 0,children:[T!==void 0?T:s?i.jsx("span",{children:s}):i.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function tm(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":_}=t,k=y.useRef(null),S=ah({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(S.isEditing){const T=window.setTimeout(()=>{var w;(w=k.current)==null||w.focus()},0);return()=>window.clearTimeout(T)}},[S.isEditing]),c==="create"){const T=C=>{m==null||m(C.target.value)},w=r==null?void 0:r(s);return i.jsxs("div",{className:it.editFieldWrapper,children:[i.jsx("textarea",{className:`${it.editTextarea} ${w?it.editInputInvalid:""}`,value:s,onChange:T,placeholder:v,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),w&&i.jsx("span",{className:it.editError,"data-testid":"edit-error",children:w})]})}if(S.isEditing)return i.jsxs("div",{className:it.editFieldWrapper,children:[i.jsx("textarea",{ref:k,className:`${it.editTextarea} ${S.error?it.editInputInvalid:""}`,value:S.draft,onChange:T=>S.setDraft(T.target.value),onBlur:S.handleBlur,onKeyDown:S.handleKeyDown,title:b,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),S.isDirty&&i.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),S.error&&i.jsx("span",{className:it.editError,"data-testid":"edit-error",children:S.error}),i.jsx("span",{className:it.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:it.metaValueClickable,onClick:()=>S.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),S.startEdit())},title:"Click to edit","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[j!==void 0?j:s?i.jsx("span",{children:s}):i.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function ud(t){var D;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":_}=t,k=y.useRef(null),S=ah({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(S.isEditing){const R=window.setTimeout(()=>{var E;(E=k.current)==null||E.focus()},0);return()=>window.clearTimeout(R)}},[S.isEditing]);const j=y.useCallback(R=>{const E=R.target.value;S.ignoreInitialBlurRef.current=!1,E!==s&&o(E),S.cancelEdit()},[s,o,S]),T=y.useCallback(R=>{if(S.ignoreInitialBlurRef.current){S.ignoreInitialBlurRef.current=!1;return}R.relatedTarget instanceof HTMLElement&&R.relatedTarget.dataset.editAction===d||S.cancelEdit()},[d,S]);if(r==="create")return i.jsx("select",{className:it.editSelect,value:s,onChange:R=>m==null?void 0:m(R.target.value),"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(R=>i.jsx("option",{value:R.value,children:R.label},R.value))});if(S.isEditing)return i.jsx("select",{ref:k,className:it.editSelect,value:S.draft,onChange:j,onBlur:T,title:b,"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(R=>i.jsx("option",{value:R.value,children:R.label},R.value))});const w=g==null?void 0:g(s),C=(D=c.find(R=>R.value===s))==null?void 0:D.label;return i.jsxs("button",{type:"button",className:it.metaValueClickable,onClick:()=>S.startEdit(),title:"Click to change","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[w!==void 0?w:C?i.jsx("span",{children:C}):i.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function A5(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return i.jsxs("label",{className:it.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 D5="_nav_1snmp_1",M5="_searchForm_1snmp_8",R5="_searchInput_1snmp_15",I5="_searchButton_1snmp_33",O5="_clearButton_1snmp_68",B5="_workspaceSelect_1snmp_85",L5="_listHeader_1snmp_99",z5="_nodeList_1snmp_108",$5="_nodeItem_1snmp_116",H5="_indicator_1snmp_129",P5="_label_1snmp_136",U5="_badge_1snmp_145",Qn={nav:D5,searchForm:M5,searchInput:R5,searchButton:I5,clearButton:O5,workspaceSelect:B5,listHeader:L5,nodeList:z5,nodeItem:$5,indicator:H5,label:P5,badge:U5};function V5({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(S=>{S.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=y.useCallback(()=>{g(""),d()},[d]),_=y.useCallback(S=>{u(S)},[u]),k=y.useCallback(S=>{g(""),p(S)},[p]);return i.jsxs("div",{className:Qn.nav,"data-testid":"knowledge-nav",children:[i.jsxs("form",{className:Qn.searchForm,onSubmit:v,children:[i.jsx("input",{className:Qn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:S=>{g(S.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),i.jsx("button",{type:"submit",className:Qn.searchButton,disabled:o,children:"Go"})]}),r&&i.jsx("button",{type:"button",className:Qn.clearButton,onClick:b,children:"Clear search"}),i.jsxs("select",{className:Qn.workspaceSelect,onChange:S=>{k(S.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[i.jsx("option",{value:"",children:"All workspaces"}),s.map(S=>i.jsx("option",{value:S.id,children:S.name},S.id))]}),i.jsxs("div",{className:Qn.listHeader,children:["Nodes (",t.length,")"]}),i.jsx("ul",{className:Qn.nodeList,children:t.map(S=>i.jsxs("li",{className:Qn.nodeItem,onClick:()=>{_(S.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),_(S.id))},role:"button",tabIndex:0,children:[i.jsx("span",{className:Qn.indicator,style:{backgroundColor:S.kind==="reference"?"#4A9EFF":S.category==="decision"?"#22C55E":S.category==="concept"?"#A855F7":S.category==="snippet"?"#6B7280":"#EAB308"}}),i.jsx("span",{className:Qn.label,children:S.label}),i.jsx("span",{className:Qn.badge,children:S.kind==="reference"?S.sourceType:S.category})]},S.id))})]})}const q5="_container_bwu10_1",G5="_hamburger_bwu10_33",F5="_brand_bwu10_49",K5="_brandLogo_bwu10_68",Z5="_info_bwu10_75",Y5="_connectionLabel_bwu10_90",J5="_connectionDot_bwu10_103",W5="_connected_bwu10_106",X5="_disconnected_bwu10_110",Q5="_connecting_bwu10_113",Es={container:q5,hamburger:G5,brand:F5,brandLogo:K5,info:Z5,connectionLabel:Y5,connectionDot:J5,connected:W5,disconnected:X5,connecting:Q5},eI={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},tI={connected:Es.connected,connecting:Es.connecting,disconnected:Es.disconnected};function nI({connectionStatus:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=vt(),u=s.length,p=s.filter(v=>v.status==="connected").length,m=o.filter(v=>["running","idle"].includes(v.status)).length,g=eI[t];return i.jsxs("div",{className:Es.container,children:[r&&i.jsx("button",{type:"button",className:Es.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:i.jsx(lT,{size:wt,"aria-hidden":"true"})}),i.jsx(Ti,{text:"Home",placement:"bottom",children:i.jsxs("button",{type:"button",className:Es.brand,onClick:()=>d(Ho),"data-testid":"statusbar-brand",children:[i.jsx("img",{src:wd("icon-192x192.png"),alt:"",className:Es.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),i.jsxs("div",{className:Es.info,children:[i.jsxs("span",{"aria-label":g,children:[i.jsx("span",{className:`${Es.connectionDot} ${tI[t]}`,"aria-hidden":"true",children:i.jsx(Si,{size:j_,fill:"currentColor"})})," ",i.jsx("span",{className:Es.connectionLabel,"aria-hidden":"true",children:g})]}),i.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),i.jsxs("span",{children:[m," active"]})]})]})}const sI="_nav_gx5h3_1",aI="_tab_gx5h3_35",iI="_tabIcon_gx5h3_68",oI="_tabLabel_gx5h3_79",rI="_tabActive_gx5h3_84",lI="_tabEnd_gx5h3_90",So={nav:sI,tab:aI,tabIcon:iI,tabLabel:oI,tabActive:rI,tabEnd:lI},Wc=[{view:"dashboard",label:"Dashboard",icon:i.jsx(Yj,{size:wt}),route:Ho,testId:"sidebar-tab-dashboard",order:0},{view:"tasks",label:"Tasks",icon:i.jsx(Cj,{size:wt}),route:qN,testId:"sidebar-tab-tasks",order:1},{view:"environments",label:"Environments",icon:i.jsx(mT,{size:wt}),route:Mo,testId:"sidebar-tab-environments",order:2},{view:"chat",label:"Root",icon:i.jsx(dT,{size:wt}),route:VN,testId:"sidebar-tab-chat",order:3},{view:"knowledge",label:"Knowledge",icon:i.jsx(_j,{size:wt}),route:Z_,testId:"sidebar-tab-knowledge",order:5},{view:"coordination",label:"Coordination",icon:i.jsx(gT,{size:wt}),route:F_,testId:"sidebar-tab-coordination",order:6},{view:"settings",label:"Settings",icon:i.jsx(ET,{size:wt}),route:zN,testId:"sidebar-tab-settings",align:"end"}];function cI(t){return t===Ho||t==="/"?"dashboard":t.startsWith(F_)?"coordination":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(Z_)?"knowledge":t.startsWith(xi)?"settings":"tasks"}function dI({tabs:t=Wc}){var g;const s=Jt(),o=vt(),r=y.useRef(null),c=cI(s.pathname),d=y.useMemo(()=>{const v=(b,_)=>(b.order??Number.MAX_SAFE_INTEGER)-(_.order??Number.MAX_SAFE_INTEGER);return[...t.filter(b=>b.align!=="end").sort(v),...t.filter(b=>b.align==="end")]},[t]),u=(g=d.find(v=>v.align==="end"))==null?void 0:g.view,p=y.useCallback(v=>{o(v.route)},[o]),m=y.useCallback(v=>{var j,T;const b=(j=r.current)==null?void 0:j.querySelectorAll('[role="tab"]');if(!b)return;const _=Array.from(b).findIndex(w=>w===document.activeElement),k=_>=0?_:d.findIndex(w=>w.view===c);let S=k;if(v.key==="ArrowRight"||v.key==="j"||v.key==="J")v.preventDefault(),S=(k+1)%d.length;else if(v.key==="ArrowLeft"||v.key==="k"||v.key==="K")v.preventDefault(),S=(k-1+d.length)%d.length;else if(v.key==="Home")v.preventDefault(),S=0;else if(v.key==="End")v.preventDefault(),S=d.length-1;else return;o(d[S].route),(T=b[S])==null||T.focus()},[c,o,d]);return i.jsx("nav",{className:So.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:m,"data-testid":"sidebar-nav",children:d.map(v=>{const b=v.view===c,_=v.view===u;return i.jsx(Ti,{text:v.label,placement:"bottom",className:_?So.tabEnd:void 0,children:i.jsxs("button",{role:"tab",type:"button","aria-selected":b,tabIndex:b?0:-1,className:`${So.tab} ${b?So.tabActive:""}`,onClick:()=>p(v),"data-testid":v.testId,"aria-label":v.label,children:[i.jsx("span",{className:So.tabIcon,"aria-hidden":"true",children:v.icon}),i.jsx("span",{className:So.tabLabel,children:v.label})]})},v.view)})})}const uI="_container_pi6ii_1",fI="_content_pi6ii_66",Gb={container:uI,content:fI},pI=320,D1=220,M1=600,R1="grackle-sidebar-width";function mI(){try{const t=localStorage.getItem(R1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=D1&&s<=M1)return s}}catch{}return pI}function hI(t){try{localStorage.setItem(R1,String(t))}catch{}}function gI({content:t}){const[s]=y.useState(mI),o=y.useRef(null);if(y.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>=D1&&m<=M1&&hI(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return i.jsx("div",{className:Gb.container,ref:o,"data-testid":"sidebar",style:{width:s},children:i.jsx("div",{className:Gb.content,children:t})})}const vI="_bar_tnfsh_1",yI="_btnPrimary_tnfsh_32",bI="_statusText_tnfsh_85",_I="_statusCompleted_tnfsh_90",xI="_statusFailed_tnfsh_94",kI="_statusBlocked_tnfsh_98",SI="_hintText_tnfsh_103",Tt={bar:vI,btnPrimary:yI,statusText:bI,statusCompleted:_I,statusFailed:xI,statusBlocked:kI,hintText:SI};function jI({sessions:t,tasks:s,environments:o}){const r=vt(),c=Jt(),d=nn("/sessions/:sessionId"),u=nn("/tasks/:taskId"),p=nn("/tasks/:taskId/stream"),m=nn("/tasks/:taskId/edit"),g=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),v=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),b=nn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),_=nn("/sessions/new"),k=nn("/environments/:environmentId/workspaces/:workspaceId"),S=nn("/tasks/new"),j=nn("/chat"),T=nn("/"),w=nn("/settings/*"),C=d==null?void 0:d.params.sessionId,D=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(g==null?void 0:g.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId),R=g??v??b,E=(R==null?void 0:R.params.environmentId)??(k==null?void 0:k.params.environmentId),M=c.pathname.startsWith("/environments")&&!k&&!R,O=!!j,A=!!_,$=!!k&&!g&&!v&&!b,Y=!!S;if(!!T&&!A&&!$&&!Y||!!w||(!!m||!!b)||Y||M||A)return i.jsx(i.Fragment,{});if(O)return o.find(ae=>ae.adapterType==="local"&&ae.status==="connected")?i.jsx(i.Fragment,{}):i.jsx("div",{className:Tt.bar,children:i.jsx("span",{className:Tt.hintText,children:"Add a local environment to start chatting"})});if($)return i.jsx("div",{className:Tt.bar,children:i.jsx("span",{className:Tt.hintText,children:"Select a task or click + to create one"})});if(D){const Z=s.find(B=>B.id===D);if(!Z)return i.jsx("div",{className:Tt.bar,children:i.jsx("span",{className:Tt.hintText,children:"Loading..."})});const ae=new Map(s.map(B=>[B.id,B])),H=Z.dependsOn.some(B=>{const F=ae.get(B);return F!==void 0&&F.status!=="complete"});if(Z.status==="not_started"){const B=H?Z.dependsOn.map(F=>ae.get(F)).filter(F=>F&&F.status!=="complete").map(F=>F.title):[];return i.jsx("div",{className:Tt.bar,children:H?i.jsxs("span",{className:Tt.statusBlocked,children:["Blocked by: ",B.join(", ")]}):i.jsx("span",{className:Tt.hintText,children:"Use the buttons above to start or manage this task"})})}if(Z.status==="working"||Z.status==="paused"){const B=Z.latestSessionId||void 0,F=B?t.find(ne=>ne.id===B):void 0;return F&&F.status!=="stopped"?i.jsx(i.Fragment,{}):i.jsx("div",{className:Tt.bar,children:i.jsx("span",{className:Tt.hintText,children:"Waiting for agent..."})})}if(Z.status==="complete")return i.jsxs("div",{className:Tt.bar,children:[i.jsx("span",{className:`${Tt.statusText} ${Tt.statusCompleted}`,children:"Task completed"}),i.jsx("button",{onClick:()=>r(Ai(Z.workspaceId,void 0,E)),className:Tt.btnPrimary,children:"+ New Task"})]});if(Z.status==="failed")return i.jsx("div",{className:Tt.bar,children:i.jsx("span",{className:`${Tt.statusText} ${Tt.statusFailed}`,children:"Task failed"})})}if(C){const Z=t.find(B=>B.id===C),ae=(Z==null?void 0:Z.status)==="stopped";if(Z!==void 0&&!ae)return i.jsx(i.Fragment,{});if(ae)return i.jsxs("div",{className:Tt.bar,children:[i.jsxs("span",{className:`${Tt.statusText} ${Tt.hintText}`,children:["Session ",Z.endReason||Z.status]}),i.jsx("button",{onClick:()=>r(V_(Z.environmentId)),className:Tt.btnPrimary,children:"+ New Chat"})]})}return i.jsx("div",{className:Tt.bar,children:i.jsx("span",{className:Tt.hintText,children:"Loading..."})})}const TI="_nav_14i94_1",wI="_tab_14i94_24",NI="_tabActive_14i94_62",CI="_tabLabel_14i94_75",EI="_statusDot_14i94_81",AI="_pulse_14i94_87",DI="_addButton_14i94_99",MI="_empty_14i94_132",Ha={nav:TI,tab:wI,tabActive:NI,tabLabel:CI,statusDot:EI,pulse:AI,addButton:DI,empty:MI},RI={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function II({environments:t}){const s=vt(),o=y.useRef(null),r=nn("/environments/:environmentId"),c=nn("/environments/:environmentId/edit"),d=nn("/environments/:environmentId/workspaces/:workspaceId"),u=nn("/environments/:environmentId/workspaces/:workspaceId/*"),p=(r==null?void 0:r.params.environmentId)??(c==null?void 0:c.params.environmentId)??(d==null?void 0:d.params.environmentId)??(u==null?void 0:u.params.environmentId),m=p==="new"?void 0:p,g=y.useCallback(_=>{s(Ro(_))},[s]),v=y.useCallback(_=>{var w;const k=(w=o.current)==null?void 0:w.querySelectorAll('[role="tab"]');if(!k||k.length===0)return;const S=Array.from(k).findIndex(C=>C===document.activeElement),j=S>=0?S:t.findIndex(C=>C.id===m);let T=j;if(_.key==="ArrowDown"||_.key==="j"||_.key==="J")_.preventDefault(),T=(j+1)%k.length;else if(_.key==="ArrowUp"||_.key==="k"||_.key==="K")_.preventDefault(),T=(j-1+k.length)%k.length;else if(_.key==="Home")_.preventDefault(),T=0;else if(_.key==="End")_.preventDefault(),T=k.length-1;else return;T<t.length&&s(Ro(t[T].id)),k[T].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:Ha.nav,"data-testid":"environment-nav",children:[i.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(_=>{const k=_.id===m,S=_.id===b,j=RI[_.status]||"var(--text-tertiary)",T=_.status==="connected";return i.jsxs("button",{role:"tab",type:"button","aria-selected":k,tabIndex:S?0:-1,className:`${Ha.tab} ${k?Ha.tabActive:""}`,onClick:()=>g(_.id),"data-testid":"env-nav-item",children:[i.jsx("span",{className:`${Ha.statusDot} ${T?Ha.pulse:""}`,style:{color:j},"aria-hidden":"true",children:i.jsx(Si,{size:j_,fill:"currentColor"})}),i.jsx("span",{className:Ha.tabLabel,title:_.displayName||_.id,children:_.displayName||_.id})]},_.id)})}),i.jsx("button",{type:"button",className:Ha.addButton,onClick:()=>s(BN),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&i.jsx("div",{className:Ha.empty,children:"No environments yet."})]})}function OI(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 I1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return i.jsx(i.Fragment,{children:t});const r=OI(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 BI(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 LI(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 HT){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Fa(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=Fa(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const zI="_container_z4i38_1",$I="_header_z4i38_5",HI="_headerActions_z4i38_17",PI="_searchInput_z4i38_23",UI="_searchHighlight_z4i38_56",VI="_groupToggle_z4i38_62",qI="_groupToggleActive_z4i38_89",GI="_addButton_z4i38_93",FI="_taskRow_z4i38_120",KI="_selected_z4i38_140",ZI="_expandArrow_z4i38_150",YI="_expanded_z4i38_157",JI="_leafSpacer_z4i38_161",WI="_taskStatusIcon_z4i38_166",XI="_taskTitle_z4i38_170",QI="_workspaceBadge_z4i38_177",eO="_childCountBadge_z4i38_195",tO="_dependencyBadge_z4i38_208",nO="_blockedBadge_z4i38_220",sO="_addChildButton_z4i38_225",aO="_emptyState_z4i38_268",iO="_statusGroupHeader_z4i38_275",oO="_statusGroupIcon_z4i38_294",rO="_statusGroupLabel_z4i38_298",lO="_statusGroupCount_z4i38_303",Je={container:zI,header:$I,headerActions:HI,searchInput:PI,searchHighlight:UI,groupToggle:VI,groupToggleActive:qI,addButton:GI,taskRow:FI,selected:KI,expandArrow:ZI,expanded:YI,leafSpacer:JI,taskStatusIcon:WI,taskTitle:XI,workspaceBadge:QI,childCountBadge:eO,dependencyBadge:tO,blockedBadge:nO,addChildButton:sO,emptyState:aO,statusGroupHeader:iO,statusGroupIcon:oO,statusGroupLabel:rO,statusGroupCount:lO},cO=[{name:"title",weight:2},{name:"description",weight:1}],O1=16,dO=16,B1="grackle-task-group-by-status";function Fb(){try{return localStorage.getItem(B1)==="true"}catch{return!1}}function uO(t){try{localStorage.setItem(B1,String(t))}catch{}}function fO({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:Je.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:`${Je.expandArrow} ${s?Je.expanded:""}`,"aria-hidden":"true",children:i.jsx(da,{size:Ze})}),i.jsx("span",{className:Je.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),i.jsx("span",{className:Je.statusGroupLabel,children:t.label}),i.jsx("span",{className:Je.statusGroupCount,children:t.tasks.length})]}),i.jsx(as,{children:s&&i.jsx($t.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=Fa(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return i.jsxs("div",{onClick:()=>c(os(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(os(p.id)))},className:`${Je.taskRow} ${g?Je.selected:""}`,style:{"--task-indent":`${O1}px`},"data-task-id":p.id,children:[i.jsx("span",{className:Je.leafSpacer}),i.jsx("span",{className:Je.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${ol(p.status)}`,children:m.icon}),i.jsx("span",{className:Je.taskTitle,title:p.title,children:i.jsx(I1,{text:p.title,indices:d.get(p.id),highlightClass:Je.searchHighlight})}),v&&i.jsx("span",{className:Je.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function L1({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=Fa(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(w=>u.get(w)!=="complete"),b=o.has(t.id),_=t.children.length>0,k=c===t.id,S=O1+s*dO,T=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{onClick:()=>d(os(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:w=>{w.currentTarget===w.target&&(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),d(os(t.id)))},className:`${Je.taskRow} ${k?Je.selected:""}`,style:{"--task-indent":`${S}px`},"data-task-id":t.id,children:[_&&i.jsx("span",{className:`${Je.expandArrow} ${b?Je.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:w=>{w.stopPropagation(),r(t.id)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),w.stopPropagation(),r(t.id))},children:i.jsx(da,{size:Ze,"aria-hidden":"true"})}),!_&&i.jsx("span",{className:Je.leafSpacer}),i.jsx("span",{className:Je.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${ol(t.status)}`,children:g.icon}),i.jsx("span",{className:Je.taskTitle,title:t.title,children:i.jsx(I1,{text:t.title,indices:p.get(t.id),highlightClass:Je.searchHighlight})}),T&&i.jsx("span",{className:Je.workspaceBadge,title:T,children:T}),_&&i.jsxs("span",{className:Je.childCountBadge,children:[t.children.filter(w=>w.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&i.jsx("span",{className:`${Je.dependencyBadge} ${v?Je.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<M2&&i.jsx(Ti,{text:"Add child task",children:i.jsx("button",{onClick:w=>{w.stopPropagation(),d(Ai(t.workspaceId,t.id))},"aria-label":"Add child task",className:Je.addChildButton,children:"+"})})]}),i.jsx(as,{children:_&&b&&i.jsx($t.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(w=>i.jsx(L1,{node:w,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},w.id))})})]})}function pO({workspaces:t,tasks:s}){const o=vt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(Fb),[g,v]=y.useState(Fb),[b,_]=y.useState(new Map),k=nn("/tasks/:taskId/*"),S=(k==null?void 0:k.params.taskId)!=="new"?k==null?void 0:k.params.taskId:void 0,j=y.useMemo(()=>new Map(s.map(Z=>[Z.id,Z.status])),[s]),T=y.useMemo(()=>new Map(t.map(Z=>[Z.id,Z.name])),[t]),w=()=>{const Z=!p;uO(Z),m(Z),Z&&(v(!0),_(new Map))},C=Z=>{_(ae=>{const H=new Map(ae),B=H.has(Z)?H.get(Z):g;return H.set(Z,!B),H})},D=Z=>b.has(Z)?b.get(Z):g,R=Z=>{c(ae=>{const H=new Set(ae);return H.has(Z)?(H.delete(Z),u(B=>new Set(B).add(Z))):(H.add(Z),u(B=>{const F=new Set(B);return F.delete(Z),F})),H})};y.useEffect(()=>{const Z=new Set(s.filter(ae=>ae.parentTaskId).map(ae=>ae.parentTaskId));Z.size>0&&c(ae=>{const H=new Set(ae);for(const B of Z)d.has(B)||H.add(B);return H})},[s,d]);const[E,M]=y.useState(""),{directMatchTaskIds:O,treeMatchTaskIds:A,titleHighlights:$}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const Z=D2(s,E,cO),ae=new Set(Z.map(ge=>ge.item.id)),H=new Map;for(const ge of Z){const ne=ge.matches.find(ce=>ce.key==="title");ne&&H.set(ge.item.id,ne.indices)}const B=new Set(ae),F=new Map(s.map(ge=>[ge.id,ge]));for(const ge of[...ae]){let ne=F.get(ge);for(;ne!=null&&ne.parentTaskId;)B.add(ne.parentTaskId),ne=F.get(ne.parentTaskId)}return{directMatchTaskIds:ae,treeMatchTaskIds:B,titleHighlights:H}},[E,s]),Y=O!==null,V=Y?p?O:A:null,ee=V?s.filter(Z=>V.has(Z.id)):s,le=p?[]:BI(ee);return i.jsxs("div",{className:Je.container,children:[i.jsxs("div",{className:Je.header,children:[i.jsx("span",{children:"Tasks"}),i.jsxs("div",{className:Je.headerActions,children:[i.jsx(Ti,{text:p?"Switch to tree view":"Group tasks by status",children:i.jsx("button",{className:`${Je.groupToggle} ${p?Je.groupToggleActive:""}`,onClick:w,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:i.jsx(aT,{size:zt})})}),i.jsx(Ti,{text:"New task",children:i.jsx("button",{className:Je.addButton,onClick:()=>o(Ai()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&i.jsx("input",{type:"text",value:E,onChange:Z=>M(Z.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Je.searchInput,"data-testid":"sidebar-search"}),p?LI(ee,j).map(Z=>i.jsx(fO,{group:Z,isExpanded:D(Z.status),onToggle:()=>C(Z.status),selectedTaskId:S,navigate:o,titleHighlights:$,workspaceNames:T},Z.status)):le.map(Z=>i.jsx(L1,{node:Z,depth:0,expandedTasks:r,toggleTask:R,selectedTaskId:S,navigate:o,taskStatusById:j,titleHighlights:$,workspaceNames:T},Z.id)),ee.length===0&&!Y&&i.jsx("div",{className:Je.emptyState,children:"No tasks yet. Click + to create one."}),ee.length===0&&Y&&i.jsx("div",{className:Je.emptyState,children:"No matching tasks"})]})}const mO="_toast_ed2dk_1",hO="_success_ed2dk_18",gO="_icon_ed2dk_22",vO="_error_ed2dk_25",yO="_warning_ed2dk_32",bO="_info_ed2dk_38",_O="_message_ed2dk_53",xO="_close_ed2dk_60",zr={toast:mO,success:hO,icon:gO,error:vO,warning:yO,info:bO,message:_O,close:xO},kO={success:i.jsx(Ni,{size:wt}),error:i.jsx(Is,{size:wt}),warning:i.jsx(fm,{size:wt}),info:i.jsx(um,{size:wt})};function SO({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),i.jsxs($t.div,{className:`${zr.toast} ${zr[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:zr.icon,"aria-hidden":"true",children:kO[t.variant]}),i.jsx("span",{className:zr.message,children:t.message}),i.jsx("button",{type:"button",className:zr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:i.jsx(Is,{size:zt,"aria-hidden":"true"})})]})}const jO="_container_qqse2_1",TO={container:jO};function wO({toasts:t,onDismiss:s}){return i.jsx("div",{className:TO.container,"data-testid":"toast-container",children:i.jsx(as,{children:t.map(o=>i.jsx(SO,{toast:o,onDismiss:s},o.id))})})}const NO="_callout_e5awm_1",CO="_success_e5awm_11",EO="_icon_e5awm_15",AO="_error_e5awm_18",DO="_warning_e5awm_25",MO="_info_e5awm_32",RO="_content_e5awm_48",IO="_close_e5awm_53",$r={callout:NO,success:CO,icon:EO,error:AO,warning:DO,info:MO,content:RO,close:IO},OO={success:i.jsx(Ni,{size:wt}),error:i.jsx(Is,{size:wt}),warning:i.jsx(fm,{size:wt}),info:i.jsx(um,{size:wt})};function BO({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return i.jsx(i.Fragment,{children:!c&&i.jsxs("div",{className:[$r.callout,$r[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[i.jsx("span",{className:$r.icon,"aria-hidden":"true",children:OO[t]}),i.jsx("span",{className:$r.content,children:s}),o&&i.jsx("button",{type:"button",className:$r.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:i.jsx(Is,{size:zt,"aria-hidden":"true"})})]})})}function LO({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(BO,{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 zO="_container_m1fsr_1",$O="_heading_m1fsr_7",HO="_section_m1fsr_14",PO="_sectionTitle_m1fsr_26",UO="_sectionDescription_m1fsr_35",VO="_emptyState_m1fsr_41",qO="_tokenList_m1fsr_48",GO="_tokenRow_m1fsr_55",FO="_tokenBadge_m1fsr_68",KO="_tokenName_m1fsr_83",ZO="_tokenTarget_m1fsr_90",YO="_deleteButton_m1fsr_99",JO="_addForm_m1fsr_113",WO="_formRow_m1fsr_119",XO="_input_m1fsr_125",QO="_select_m1fsr_155",eB="_addButton_m1fsr_187",tB="_emptyStateInfo_m1fsr_221",nB="_themeOptions_m1fsr_229",sB="_themeOption_m1fsr_229",aB="_themeOptionSelected_m1fsr_254",iB="_themeOptionHeader_m1fsr_259",oB="_themeOptionLabel_m1fsr_266",rB="_themeOptionDesc_m1fsr_273",lB="_variantToggle_m1fsr_279",cB="_variantButton_m1fsr_286",dB="_variantActive_m1fsr_305",uB="_themeSwatches_m1fsr_311",fB="_themeSwatch_m1fsr_311",pB="_systemToggle_m1fsr_325",mB="_systemToggleHint_m1fsr_341",hB="_themeActive_m1fsr_348",gB="_aboutGrid_m1fsr_354",vB="_aboutItem_m1fsr_360",yB="_aboutLabel_m1fsr_373",bB="_aboutValue_m1fsr_379",_B="_aboutDot_m1fsr_387",xB="_aboutDotConnected_m1fsr_394",kB="_aboutDotDisconnected_m1fsr_398",SB="_aboutDotConnecting_m1fsr_402",fe={container:zO,heading:$O,section:HO,sectionTitle:PO,sectionDescription:UO,emptyState:VO,tokenList:qO,tokenRow:GO,tokenBadge:FO,tokenName:KO,tokenTarget:ZO,deleteButton:YO,addForm:JO,formRow:WO,input:XO,select:QO,addButton:eB,emptyStateInfo:tB,themeOptions:nB,themeOption:sB,themeOptionSelected:aB,themeOptionHeader:iB,themeOptionLabel:oB,themeOptionDesc:rB,variantToggle:lB,variantButton:cB,variantActive:dB,themeSwatches:uB,themeSwatch:fB,systemToggle:pB,systemToggleHint:mB,themeActive:hB,aboutGrid:gB,aboutItem:vB,aboutLabel:yB,aboutValue:bB,aboutDot:_B,aboutDotConnected:xB,aboutDotDisconnected:kB,aboutDotConnecting:SB},jB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function TB({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,b]=y.useState(""),[_,k]=y.useState(null),S=w=>{if(w.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=w=>{k(w)},T=()=>{_&&(o(_),r==null||r("Token deleted","info")),k(null)};return i.jsxs(i.Fragment,{children:[i.jsx(ys,{isOpen:_!==null,title:"Delete Token?",description:_?`"${_}" will be permanently removed.`:void 0,onConfirm:T,onCancel:()=>k(null)}),i.jsxs("section",{className:fe.section,children:[i.jsx("h3",{className:fe.sectionTitle,children:"Tokens"}),i.jsx("p",{className:fe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?i.jsx("div",{className:fe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):i.jsx("div",{className:fe.tokenList,children:t.map(w=>i.jsxs("div",{className:fe.tokenRow,children:[i.jsx("span",{className:fe.tokenBadge,children:w.tokenType}),i.jsx("span",{className:fe.tokenName,children:w.name}),i.jsx("span",{className:fe.tokenTarget,children:w.tokenType==="env_var"?w.envVar:w.filePath}),i.jsx("button",{className:fe.deleteButton,onClick:()=>j(w.name),title:`Delete ${w.name}`,"aria-label":`Delete ${w.name}`,children:i.jsx(Is,{size:zt,"aria-hidden":"true"})})]},w.name))}),i.jsxs("form",{className:fe.addForm,onSubmit:S,children:[i.jsxs("div",{className:fe.formRow,children:[i.jsx("input",{className:fe.input,type:"text",placeholder:"Token name",value:c,onChange:w=>d(w.target.value)}),i.jsx("input",{className:fe.input,type:"password",placeholder:"Value",value:u,onChange:w=>p(w.target.value)})]}),i.jsxs("div",{className:fe.formRow,children:[i.jsx("select",{className:fe.select,value:m,onChange:w=>g(w.target.value),children:jB.map(w=>i.jsx("option",{value:w.value,children:w.label},w.value))}),i.jsx("input",{className:fe.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:w=>b(w.target.value)}),i.jsx("button",{className:fe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Nd=[{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"]}],z1=new Set(Nd.map(t=>t.id)),Kb="grackle";function nm(t){return Nd.find(s=>s.id===t)}function wB({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return i.jsxs("section",{className:fe.section,children:[i.jsx("h3",{className:fe.sectionTitle,children:"Appearance"}),i.jsx("p",{className:fe.sectionDescription,children:"Choose how Grackle looks across the app."}),i.jsx("div",{className:fe.themeOptions,children:Nd.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:`${fe.themeOption} ${p?fe.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[i.jsxs("span",{className:fe.themeOptionHeader,children:[i.jsxs("span",{children:[i.jsx("span",{className:fe.themeOptionLabel,children:d.label}),i.jsx("span",{className:fe.themeOptionDesc,children:d.description})]}),u&&i.jsxs("span",{className:fe.variantToggle,children:[i.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&m?fe.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:`${fe.variantButton} ${p&&!m?fe.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:fe.themeSwatches,children:d.swatches.map((g,v)=>i.jsx("span",{className:fe.themeSwatch,style:{background:g}},v))})]},d.id)})}),i.jsxs("label",{className:fe.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:fe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),i.jsxs("p",{className:fe.themeActive,children:["Active theme: ",i.jsx("strong",{children:s})]})]})}const NB={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},CB={connected:fe.aboutDotConnected,connecting:fe.aboutDotConnecting,disconnected:fe.aboutDotDisconnected};function EB({connectionStatus: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:fe.section,"data-testid":"about-panel",children:[i.jsx("h3",{className:fe.sectionTitle,children:"About"}),i.jsx("p",{className:fe.sectionDescription,children:"Connection status and application information."}),i.jsxs("div",{className:fe.aboutGrid,children:[i.jsxs("div",{className:fe.aboutItem,children:[i.jsx("span",{className:fe.aboutLabel,children:"Connection"}),i.jsxs("span",{className:fe.aboutValue,children:[i.jsx("span",{className:`${fe.aboutDot} ${CB[t]}`}),NB[t]]})]}),i.jsxs("div",{className:fe.aboutItem,children:[i.jsx("span",{className:fe.aboutLabel,children:"Environments"}),i.jsxs("span",{className:fe.aboutValue,children:[r,"/",c," connected"]})]}),i.jsxs("div",{className:fe.aboutItem,children:[i.jsx("span",{className:fe.aboutLabel,children:"Active Sessions"}),i.jsx("span",{className:fe.aboutValue,children:d})]}),i.jsxs("div",{className:fe.aboutItem,children:[i.jsx("span",{className:fe.aboutLabel,children:"Version"}),i.jsx("span",{className:fe.aboutValue,children:"0.117.0"})]})]})]})}const AB="_container_cddyd_1",DB="_header_cddyd_8",MB="_headerTitle_cddyd_35",RB="_badge_cddyd_44",IB="_headerActions_cddyd_54",OB="_body_cddyd_61",BB="_formContent_cddyd_73",LB="_section_cddyd_85",zB="_label_cddyd_91",$B="_titleInput_cddyd_98",HB="_descriptionTextarea_cddyd_131",PB="_parentContext_cddyd_167",UB="_parentLabel_cddyd_175",VB="_parentName_cddyd_182",qB="_personaSelect_cddyd_186",GB="_depList_cddyd_220",FB="_depItem_cddyd_226",KB="_depItemSelected_cddyd_248",ZB="_noDeps_cddyd_252",YB="_btnPrimary_cddyd_258",JB="_btnGhost_cddyd_289",at={container:AB,header:DB,headerTitle:MB,badge:RB,headerActions:IB,body:OB,formContent:BB,section:LB,label:zB,titleInput:$B,descriptionTextarea:HB,parentContext:PB,parentLabel:UB,parentName:VB,personaSelect:qB,depList:GB,depItem:FB,depItemSelected:KB,noDeps:ZB,btnPrimary:YB,btnGhost:JB};function $1({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 _=vt(),k=t==="edit",S=k&&s?d.find(_e=>_e.id===s):void 0,j=k?(S==null?void 0:S.workspaceId)??"":o??"",[T,w]=y.useState(j),C=j||T,D=u.find(_e=>_e.id===C),R=c??(D==null?void 0:D.linkedEnvironmentIds[0]),E=!k&&!o,M=k?(S==null?void 0:S.parentTaskId)??"":r??"",O=M?d.find(_e=>_e.id===M):void 0,[A,$]=y.useState((S==null?void 0:S.title)??""),[Y,V]=y.useState((S==null?void 0:S.description)??""),[ee,le]=y.useState((S==null?void 0:S.dependsOn)??[]),[Z,ae]=y.useState((S==null?void 0:S.defaultPersonaId)??""),[H,B]=y.useState((S==null?void 0:S.canDecompose)??!1),[F,ge]=y.useState(!1),ne=y.useRef(!1);y.useEffect(()=>{k&&S&&!ne.current&&(ne.current=!0,$(S.title),V(S.description),le(S.dependsOn),ae(S.defaultPersonaId),B(S.canDecompose))},[k,S]);const ce=d.filter(_e=>_e.workspaceId===C&&(!k||_e.id!==s)&&_e.id!==M),me=A.trim().length>0&&(!k||S!==void 0)&&C.length>0,ke=_e=>{le(Oe=>Oe.includes(_e)?Oe.filter(Ht=>Ht!==_e):[...Oe,_e])},De=()=>{!me||F||k&&S===void 0||(k&&s?(g(s,A.trim(),Y,ee,Z),b==null||b("Task updated","success"),v?v():_(os(s,void 0,C,R),{replace:!0})):(ge(!0),m(C,A.trim(),Y,ee.length>0?ee:void 0,M||void 0,Z,H,()=>{b==null||b("Task created","success"),_(o?ji(o,R):"/tasks",{replace:!0})},_e=>{b==null||b(_e,"error"),ge(!1)})))},ot=()=>{if(v){v();return}_(k&&s?os(s,void 0,C,R):o?ji(o,R):"/tasks")},yt=k?"edit task":M?"child task":"new task";return i.jsxs("div",{className:at.container,children:[i.jsxs("div",{className:at.header,children:[i.jsxs("div",{className:at.headerTitle,children:[i.jsx("span",{className:at.badge,children:yt}),O&&i.jsxs("span",{className:at.parentContext,children:[i.jsx("span",{className:at.parentLabel,children:"Child of"}),i.jsx("span",{className:at.parentName,children:O.title})]})]}),i.jsxs("div",{className:at.headerActions,children:[i.jsx("button",{onClick:De,disabled:!me||F,className:at.btnPrimary,"data-testid":"task-edit-save",children:F?"Creating…":k?"Save Changes":"Create"}),i.jsx("button",{onClick:ot,className:at.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:at.body,children:i.jsxs("div",{className:at.formContent,children:[E&&i.jsxs("div",{className:at.section,children:[i.jsx("label",{className:at.label,htmlFor:"task-edit-workspace",children:"Workspace"}),i.jsxs("select",{id:"task-edit-workspace",value:T,onChange:_e=>w(_e.target.value),className:at.personaSelect,"data-testid":"task-edit-workspace",children:[i.jsx("option",{value:"",children:"Select a workspace..."}),u.map(_e=>i.jsx("option",{value:_e.id,children:_e.name},_e.id))]})]}),i.jsxs("div",{className:at.section,children:[i.jsx("label",{className:at.label,htmlFor:"task-edit-title",children:"Title"}),i.jsx("input",{id:"task-edit-title",type:"text",value:A,onChange:_e=>$(_e.target.value),placeholder:"Task title...",autoFocus:!0,className:at.titleInput,"data-testid":"task-edit-title",onKeyDown:_e=>{_e.key==="Enter"&&me&&De()}})]}),i.jsxs("div",{className:at.section,children:[i.jsx("label",{className:at.label,htmlFor:"task-edit-description",children:"Description"}),i.jsx("textarea",{id:"task-edit-description",value:Y,onChange:_e=>V(_e.target.value),placeholder:"Describe the task... (markdown supported)",className:at.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),i.jsxs("div",{className:at.section,children:[i.jsx("label",{className:at.label,htmlFor:"task-edit-persona",children:"Default Persona"}),i.jsxs("select",{id:"task-edit-persona",value:Z,onChange:_e=>ae(_e.target.value),className:at.personaSelect,"data-testid":"task-edit-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),p.map(_e=>i.jsx("option",{value:_e.id,children:_e.name},_e.id))]})]}),!k&&i.jsx("div",{className:at.section,children:i.jsxs("label",{className:at.depItem,"data-testid":"task-edit-can-decompose",children:[i.jsx("input",{type:"checkbox",checked:H,onChange:_e=>B(_e.target.checked)}),"Can spawn subtasks"]})}),i.jsxs("div",{className:at.section,children:[i.jsx("div",{className:at.label,children:"Dependencies"}),ce.length===0?i.jsx("div",{className:at.noDeps,children:"No other tasks in this workspace"}):i.jsx("div",{className:at.depList,children:ce.map(_e=>{const Oe=ee.includes(_e.id);return i.jsxs("label",{className:`${at.depItem} ${Oe?at.depItemSelected:""}`,"data-testid":`dep-option-${_e.id}`,children:[i.jsx("input",{type:"checkbox",checked:Oe,onChange:()=>ke(_e.id)}),_e.title,i.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",_e.status,")"]})]},_e.id)})})]})]})})]})}const WB="_actionButtons_1rjka_1",XB="_btnPrimary_1rjka_8",QB="_btnDanger_1rjka_39",eL="_btnGhost_1rjka_78",Zt={actionButtons:WB,btnPrimary:XB,btnDanger:QB,btnGhost:eL};function tL({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:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:m,className:Zt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Zt.btnPrimary,children:"Start"}),i.jsx("button",{onClick:m,className:Zt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Zt.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:u,disabled:!s,className:Zt.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Zt.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:c,className:Zt.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return i.jsx("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return i.jsxs("div",{className:Zt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:r,className:Zt.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),i.jsx("button",{onClick:p,className:Zt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const nL="_workpadSection_y8nj9_1",sL="_workpadLabel_y8nj9_9",aL="_workpadStatus_y8nj9_17",iL="_workpadSummary_y8nj9_23",oL="_workpadExtra_y8nj9_29",Pa={workpadSection:nL,workpadLabel:sL,workpadStatus:aL,workpadSummary:iL,workpadExtra:oL};function rL({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:Pa.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:Pa.workpadLabel,children:"Workpad"}),i.jsx("div",{className:Pa.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return i.jsxs("div",{className:Pa.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:Pa.workpadLabel,children:"Workpad"}),s.status&&i.jsx("div",{className:Pa.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&i.jsx("div",{className:Pa.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&i.jsx("div",{className:Pa.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const lL="_overviewDashboard_r05qm_1",cL="_overviewHero_r05qm_7",dL="_statusBadge_r05qm_14",uL="_statusPending_r05qm_26",fL="_statusAssigned_r05qm_31",pL="_statusInProgress_r05qm_36",mL="_statusReview_r05qm_41",hL="_statusDone_r05qm_46",gL="_statusFailed_r05qm_51",vL="_statusWaitingInput_r05qm_56",yL="_overviewBranchPill_r05qm_61",bL="_branchLink_r05qm_76",_L="_overviewSection_r05qm_87",xL="_overviewLabel_r05qm_93",kL="_overviewValue_r05qm_100",SL="_overviewMuted_r05qm_105",jL="_overviewMarkdown_r05qm_111",TL="_envRow_r05qm_180",wL="_envDot_r05qm_186",NL="_envDotGreen_r05qm_193",CL="_envDotYellow_r05qm_197",EL="_envDotRed_r05qm_201",AL="_envDotGray_r05qm_205",DL="_depList_r05qm_209",ML="_depItem_r05qm_215",RL="_depBlocked_r05qm_222",IL="_depDone_r05qm_226",OL="_timeline_r05qm_230",BL="_timelineRow_r05qm_236",LL="_timelineKey_r05qm_243",zL="_timelineValue_r05qm_249",$L="_timelineDelta_r05qm_253",HL="_reviewNotes_r05qm_264",be={overviewDashboard:lL,overviewHero:cL,statusBadge:dL,statusPending:uL,statusAssigned:fL,statusInProgress:pL,statusReview:mL,statusDone:hL,statusFailed:gL,statusWaitingInput:vL,overviewBranchPill:yL,branchLink:bL,overviewSection:_L,overviewLabel:xL,overviewValue:kL,overviewMuted:SL,overviewMarkdown:jL,envRow:TL,envDot:wL,envDotGreen:NL,envDotYellow:CL,envDotRed:EL,envDotGray:AL,depList:DL,depItem:ML,depBlocked:RL,depDone:IL,timeline:OL,timelineRow:BL,timelineKey:LL,timelineValue:zL,timelineDelta:$L,reviewNotes:HL};function $c(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 _p(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 Zb(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?be.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?be.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?be.envDotRed:be.envDotGray}function PL({status:t}){const s=Fa(t),o=$T(t);return i.jsx("span",{className:`${be.statusBadge} ${be[o]??be.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function UL({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(S=>S.id===g):void 0,b=r.find(S=>S.id===t.workspaceId),_=o.find(S=>S.id===d),k=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return i.jsxs("div",{className:be.overviewDashboard,"data-testid":"task-overview-panel",children:[i.jsxs("div",{className:be.overviewHero,children:[i.jsx(PL,{status:t.status}),t.branch&&i.jsx("span",{className:be.overviewBranchPill,"data-testid":"task-overview-branch",children:k?i.jsxs("a",{href:k,target:"_blank",rel:"noreferrer noopener",className:be.branchLink,children:["🔗"," ",t.branch]}):i.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-description",children:[i.jsx("div",{className:be.overviewLabel,children:"Description"}),i.jsx("div",{className:be.overviewMarkdown,children:i.jsx(cm,{remarkPlugins:[dm],children:t.description})})]}),t.workpad&&i.jsx(rL,{workpad:t.workpad}),i.jsxs("div",{className:be.overviewSection,children:[i.jsx("div",{className:be.overviewLabel,children:"Environment"}),g&&v?i.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${be.envDot} ${Zb(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),i.jsx("span",{className:be.overviewValue,children:v.displayName})]}):_?i.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${be.envDot} ${Zb(_.status)}`,title:_.status,"aria-label":`Status: ${_.status}`,role:"img"}),i.jsx("span",{className:be.overviewValue,children:_.displayName}),i.jsx("span",{className:be.overviewMuted,children:"(workspace default)"})]}):i.jsx("div",{className:be.overviewMuted,children:"Set in workspace settings"})]}),i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-dependencies",children:[i.jsx("div",{className:be.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?i.jsx("div",{className:be.overviewMuted,children:"None"}):i.jsx("div",{className:be.depList,children:t.dependsOn.map(S=>{const j=s.get(S),T=(j==null?void 0:j.status)==="complete";return i.jsxs("div",{className:`${be.depItem} ${T?be.depDone:be.depBlocked}`,children:[i.jsx("span",{children:T?"✓":"○"}),i.jsx("span",{children:(j==null?void 0:j.title)??S})]},S)})})]}),i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-timeline",children:[i.jsx("div",{className:be.overviewLabel,children:"Timeline"}),i.jsxs("div",{className:be.timeline,children:[t.createdAt&&i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Created"}),i.jsx("span",{className:be.timelineValue,children:$c(t.createdAt)})]}),t.assignedAt&&(()=>{const S=_p(t.createdAt,t.assignedAt);return i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Assigned"}),i.jsx("span",{className:be.timelineValue,children:$c(t.assignedAt)}),S!==void 0&&i.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.startedAt&&(()=>{const S=_p(t.assignedAt??t.createdAt,t.startedAt);return i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Started"}),i.jsx("span",{className:be.timelineValue,children:$c(t.startedAt)}),S!==void 0&&i.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.completedAt&&(()=>{const S=_p(t.startedAt,t.completedAt);return i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Completed"}),i.jsx("span",{className:be.timelineValue,children:$c(t.completedAt)}),S!==void 0&&i.jsx("span",{className:be.timelineDelta,children:S})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&i.jsx("div",{className:be.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-usage",children:[i.jsx("div",{className:be.overviewLabel,children:"Usage"}),i.jsxs("div",{className:be.timeline,children:[i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Cost"}),i.jsx("span",{className:be.timelineValue,children:As(u.costMillicents)}),i.jsxs("span",{className:be.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Total (incl. subtasks)"}),i.jsx("span",{className:be.timelineValue,children:As(p.costMillicents)}),i.jsxs("span",{className:be.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-budget",children:[i.jsx("div",{className:be.overviewLabel,children:"Budget"}),i.jsxs("div",{className:be.timeline,children:[t.tokenBudget>0&&i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Tokens"}),i.jsxs("span",{className:be.timelineValue,children:[Io(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",Io(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&i.jsxs("div",{className:be.timelineRow,children:[i.jsx("span",{className:be.timelineKey,children:"Cost"}),i.jsxs("span",{className:be.timelineValue,children:[As((u==null?void 0:u.costMillicents)??0)," / ",As(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&i.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-review-notes",children:[i.jsx("div",{className:be.overviewLabel,children:"Review Notes"}),i.jsx("div",{className:be.reviewNotes,children:t.reviewNotes})]})]})}function VL({plugins:t,loading:s,onSetPluginEnabled:o}){return i.jsxs("div",{className:fe.container,"data-testid":"plugins-panel",children:[i.jsx("h2",{className:fe.heading,children:"Plugins"}),i.jsxs("div",{className:fe.section,children:[i.jsx("p",{className:fe.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&i.jsx("p",{className:fe.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&i.jsx("p",{className:fe.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return i.jsxs("div",{className:fe.tokenRow,"data-testid":`plugin-row-${r.name}`,children:[i.jsxs("div",{style:{flex:1},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[i.jsx("span",{className:fe.tokenName,children:r.name}),r.required&&i.jsx("span",{className:fe.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),i.jsx("div",{className:fe.tokenTarget,children:r.description}),c&&i.jsx("div",{style:{fontSize:"var(--font-size-xs)",color:"var(--accent-yellow)",marginTop:"2px"},"data-testid":`plugin-restart-notice-${r.name}`,children:"Restart Grackle to apply changes"})]}),i.jsx("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:r.required?"not-allowed":"pointer"},title:r.required?"Core is required and cannot be disabled":void 0,children:i.jsx("input",{type:"checkbox",checked:r.enabled,disabled:r.required,onChange:d=>o(r.name,d.target.checked),"data-testid":`plugin-toggle-${r.name}`,"aria-label":`Enable or disable ${r.name} plugin`,style:{accentColor:"var(--accent-green)",width:"16px",height:"16px"}})})]},r.name)})]})]})}function qL({githubAccounts:t,githubAccountsLoading:s,onAddGitHubAccount:o,onUpdateGitHubAccount:r,onRemoveGitHubAccount:c,onImportGitHubAccounts:d,onShowToast:u}){const[p,m]=y.useState(""),[g,v]=y.useState(""),[b,_]=y.useState(!1),[k,S]=y.useState(!1),[j,T]=y.useState(!1),[w,C]=y.useState(null),D=t.find(A=>A.id===w),R=async A=>{if(A.preventDefault(),!(!p.trim()||!g.trim())){S(!0);try{await o(p.trim(),g.trim(),"",b),u==null||u("GitHub account added","success"),m(""),v(""),_(!1)}catch($){const Y=$ instanceof Error?$.message:"Failed to add account";u==null||u(Y,"error")}finally{S(!1)}}},E=async A=>{try{await r(A,{isDefault:!0}),u==null||u("Default account updated","success")}catch($){const Y=$ instanceof Error?$.message:"Failed to update account";u==null||u(Y,"error")}},M=async()=>{if(w)try{await c(w),u==null||u("GitHub account removed","info")}catch(A){const $=A instanceof Error?A.message:"Failed to remove account";u==null||u($,"error")}finally{C(null)}},O=async()=>{T(!0);try{const A=await d();A.imported>0?u==null||u(`Imported ${A.imported} account(s): ${A.usernames.join(", ")}`,"success"):u==null||u("No new accounts to import","info")}catch(A){const $=A instanceof Error?A.message:"Import failed";u==null||u($,"error")}finally{T(!1)}};return i.jsxs(i.Fragment,{children:[i.jsx(ys,{isOpen:w!==null,title:"Remove GitHub Account?",description:D?`"${D.label}"${D.username?` (@${D.username})`:""} will be permanently removed.`:void 0,onConfirm:()=>{M().catch(()=>{})},onCancel:()=>C(null)}),i.jsxs("section",{className:fe.section,"data-testid":"github-accounts-panel",children:[i.jsx("h3",{className:fe.sectionTitle,children:"GitHub Accounts"}),i.jsx("p",{className:fe.sectionDescription,children:"Register multiple GitHub accounts to use different identities per environment. The default account is used when no specific account is assigned."}),s&&t.length===0?i.jsx("div",{className:fe.emptyState,children:"Loading..."}):t.length===0?i.jsx("div",{className:fe.emptyStateInfo,children:"No GitHub accounts registered. Add one below or import from the gh CLI."}):i.jsx("div",{className:fe.tokenList,children:t.map(A=>i.jsxs("div",{className:fe.tokenRow,"data-testid":`github-account-row-${A.id}`,children:[A.isDefault&&i.jsx("span",{className:fe.tokenBadge,title:"Default account",children:"default"}),i.jsx("span",{className:fe.tokenName,children:A.label}),A.username&&i.jsxs("span",{className:fe.tokenTarget,children:["@",A.username]}),!A.isDefault&&i.jsx("button",{className:fe.deleteButton,onClick:()=>{E(A.id).catch(()=>{})},title:"Set as default","aria-label":`Set ${A.label} as default`,"data-testid":`github-account-set-default-${A.id}`,children:i.jsx(RT,{size:zt,"aria-hidden":"true"})}),i.jsx("button",{className:fe.deleteButton,onClick:()=>C(A.id),title:`Remove ${A.label}`,"aria-label":`Remove ${A.label}`,"data-testid":`github-account-remove-${A.id}`,children:i.jsx(Is,{size:zt,"aria-hidden":"true"})})]},A.id))}),i.jsxs("form",{className:fe.addForm,onSubmit:A=>{R(A).catch(()=>{})},children:[i.jsxs("div",{className:fe.formRow,children:[i.jsx("input",{className:fe.input,type:"text",placeholder:"Label (e.g. personal, work)",value:p,onChange:A=>m(A.target.value),"data-testid":"github-account-label-input"}),i.jsx("input",{className:fe.input,type:"password",placeholder:"Personal access token",value:g,onChange:A=>v(A.target.value),"data-testid":"github-account-token-input"})]}),i.jsxs("div",{className:fe.formRow,children:[i.jsxs("label",{className:fe.tokenTarget,style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[i.jsx("input",{type:"checkbox",checked:b,onChange:A=>_(A.target.checked),"data-testid":"github-account-default-checkbox"}),"Set as default"]}),i.jsx("button",{className:fe.addButton,type:"submit",disabled:!p.trim()||!g.trim()||k,"data-testid":"github-account-add-button",children:k?"Adding...":"Add Account"}),i.jsx("button",{className:fe.addButton,type:"button",onClick:()=>{O().catch(()=>{})},disabled:j,"data-testid":"github-account-import-button",children:j?"Importing...":"Import from gh CLI"})]})]})]})]})}const GL="_container_legrg_1",FL="_header_legrg_8",KL="_headerTitle_legrg_35",ZL="_badge_legrg_44",YL="_headerActions_legrg_54",JL="_body_legrg_61",WL="_formContent_legrg_73",XL="_section_legrg_85",QL="_label_legrg_91",e8="_nameInput_legrg_98",t8="_fieldInput_legrg_131",n8="_adapterSelect_legrg_164",s8="_readOnlyValue_legrg_198",a8="_codespaceSection_legrg_204",i8="_codespaceActions_legrg_210",o8="_creatingHint_legrg_216",r8="_errorHint_legrg_222",l8="_btnPrimary_legrg_235",c8="_btnGhost_legrg_266",oe={container:GL,header:FL,headerTitle:KL,badge:ZL,headerActions:YL,body:JL,formContent:WL,section:XL,label:QL,nameInput:e8,fieldInput:t8,adapterSelect:n8,readOnlyValue:s8,codespaceSection:a8,codespaceActions:i8,creatingHint:o8,errorHint:r8,btnPrimary:l8,btnGhost:c8},Xc=1,Qc=65535;function xp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=Xc&&s<=Qc}function kp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function d8({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[b,_]=y.useState(""),[k,S]=y.useState("");return g==="create"?i.jsxs("div",{className:oe.codespaceSection,children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Repository"}),i.jsx("input",{type:"text",value:b,onChange:j=>_(j.target.value),placeholder:"owner/repo",className:oe.fieldInput,"data-testid":"env-codespace-repo"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Machine Type"}),i.jsx("input",{type:"text",value:k,onChange:j=>S(j.target.value),placeholder:"Machine type (optional)...",className:oe.fieldInput,"data-testid":"env-codespace-machine"})]}),i.jsxs("div",{className:oe.codespaceActions,children:[i.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),k.trim()||void 0),v("pick"),_(""),S(""))},disabled:!b.trim(),className:oe.btnPrimary,children:"Create"}),i.jsx("button",{onClick:()=>{v("pick"),_(""),S("")},className:oe.btnGhost,children:"Cancel"})]})]}):i.jsx("div",{className:oe.codespaceSection,children:i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.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:oe.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:oe.creatingHint,children:"Creating codespace..."}),u&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:oe.errorHint,children:u}),i.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:oe.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&i.jsx("span",{className:oe.errorHint,children:d})]})})}function H1({mode:t,environmentId:s,environments:o,githubAccounts:r,onAddEnvironment:c,onUpdateEnvironment:d,onListCodespaces:u,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b,onListDockerContainers:_,dockerContainers:k,dockerContainersError:S,onShowToast:j}){const T=vt(),w=t==="edit",C=w&&s?o.find(re=>re.id===s):void 0,[D,R]=y.useState(""),[E,M]=y.useState("local"),[O,A]=y.useState(""),[$,Y]=y.useState(""),[V,ee]=y.useState(""),[le,Z]=y.useState(""),[ae,H]=y.useState(""),[B,F]=y.useState(""),[ge,ne]=y.useState(""),[ce,me]=y.useState(""),[ke,De]=y.useState("create"),[ot,yt]=y.useState(""),[_e,Oe]=y.useState(null),Ht=y.useCallback(()=>{const re={};if(E==="local"){if(O.trim()&&(re.host=O.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(re.port=ve)}}else if(E==="ssh"){if(re.host=O.trim(),V.trim()&&(re.user=V.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(re.sshPort=ve)}le.trim()&&(re.identityFile=le.trim())}else E==="docker"?ke==="attach"?ot.trim()&&(re.attach=ot.trim()):(ae.trim()&&(re.image=ae.trim()),B.trim()&&(re.repo=B.trim())):E==="codespace"&&(re.codespaceName=ge.trim());return re},[E,O,$,V,le,ae,B,ge,ke,ot]),Nt=()=>!(!D.trim()||E==="ssh"&&!O.trim()||E==="codespace"&&!ge.trim()||E==="docker"&&ke==="attach"&&!ot.trim()||(E==="local"||E==="ssh")&&!xp($)),ue=()=>{Nt()&&(c(D.trim(),E,Ht(),ce||void 0),j==null||j("Environment added successfully","success"),T(Mo,{replace:!0}))},Re=()=>{T(s?Ro(s):Mo)},Q=y.useCallback((re,ve)=>{if(!C||!s)return;const Xe=kp(C.adapterConfig),an=ve.trim();an?Xe[re]=an:delete Xe[re],d(s,{adapterConfig:Xe})},[C,s,d]),et=y.useCallback((re,ve)=>{if(!C||!s)return;const Xe=kp(C.adapterConfig);if(ve.trim()){const an=Number(ve);Number.isInteger(an)&&an>=Xc&&an<=Qc&&(Xe[re]=an)}else delete Xe[re];d(s,{adapterConfig:Xe})},[C,s,d]);if(w){if(!C)return i.jsxs("div",{className:oe.container,children:[i.jsxs("div",{className:oe.header,children:[i.jsx("div",{className:oe.headerTitle,children:i.jsx("span",{className:oe.badge,children:"edit environment"})}),i.jsx("div",{className:oe.headerActions,children:i.jsx("button",{onClick:Re,className:oe.btnGhost,children:"Back"})})]}),i.jsx("div",{className:oe.body,children:i.jsx("div",{className:oe.formContent,children:i.jsx("span",{className:oe.readOnlyValue,children:"Environment not found"})})})]});const re=kp(C.adapterConfig);return i.jsxs("div",{className:oe.container,"data-testid":"env-edit-panel",children:[i.jsxs("div",{className:oe.header,children:[i.jsx("div",{className:oe.headerTitle,children:i.jsx("span",{className:oe.badge,children:"edit environment"})}),i.jsx("div",{className:oe.headerActions,children:i.jsx("button",{onClick:Re,className:oe.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),i.jsx("div",{className:oe.body,children:i.jsxs("div",{className:oe.formContent,children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Name"}),i.jsx(Bt,{value:C.displayName,onSave:ve=>{s&&d(s,{displayName:ve})},validate:ve=>ve.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:_e,onActivate:Oe,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Adapter Type"}),i.jsx("span",{className:oe.readOnlyValue,"data-testid":"env-edit-adapter-type",children:C.adapterType})]}),(C.adapterType==="codespace"||C.adapterType==="docker")&&(r.length>0||!!C.githubAccountId)&&i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"GitHub Account"}),i.jsxs("select",{value:C.githubAccountId||"",onChange:ve=>{s&&d(s,{githubAccountId:ve.target.value})},className:oe.adapterSelect,"data-testid":"env-edit-github-account",children:[i.jsx("option",{value:"",children:"(Default)"}),r.map(ve=>i.jsxs("option",{value:ve.id,children:[ve.label,ve.username?` (@${ve.username})`:"",ve.isDefault?" — default":""]},ve.id))]})]}),C.adapterType==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Host"}),i.jsx(Bt,{value:String(re.host??""),onSave:ve=>Q("host",ve),mode:"edit",fieldId:"host",activeFieldId:_e,onActivate:Oe,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Port"}),i.jsx(Bt,{value:String(re.port??""),onSave:ve=>et("port",ve),validate:ve=>xp(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:_e,onActivate:Oe,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),C.adapterType==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Host"}),i.jsx(Bt,{value:String(re.host??""),onSave:ve=>Q("host",ve),validate:ve=>ve.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:_e,onActivate:Oe,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"User"}),i.jsx(Bt,{value:String(re.user??""),onSave:ve=>Q("user",ve),mode:"edit",fieldId:"user",activeFieldId:_e,onActivate:Oe,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"SSH Port"}),i.jsx(Bt,{value:String(re.sshPort??""),onSave:ve=>et("sshPort",ve),validate:ve=>xp(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:_e,onActivate:Oe,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Identity File"}),i.jsx(Bt,{value:String(re.identityFile??""),onSave:ve=>Q("identityFile",ve),mode:"edit",fieldId:"identityFile",activeFieldId:_e,onActivate:Oe,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),C.adapterType==="docker"&&re.attach!==void 0&&i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Attach (container)"}),i.jsx(Bt,{value:String(re.attach??""),onSave:ve=>Q("attach",ve),validate:ve=>ve.trim()===""?"Container name is required":void 0,mode:"edit",fieldId:"attach",activeFieldId:_e,onActivate:Oe,placeholder:"container name or ID",ariaLabel:"Attach container","data-testid":"env-edit-attach"})]}),C.adapterType==="docker"&&re.attach===void 0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Image"}),i.jsx(Bt,{value:String(re.image??""),onSave:ve=>Q("image",ve),mode:"edit",fieldId:"image",activeFieldId:_e,onActivate:Oe,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Repo"}),i.jsx(Bt,{value:String(re.repo??""),onSave:ve=>Q("repo",ve),mode:"edit",fieldId:"repo",activeFieldId:_e,onActivate:Oe,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),C.adapterType==="codespace"&&i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Codespace Name"}),i.jsx(Bt,{value:String(re.codespaceName??""),onSave:ve=>Q("codespaceName",ve),validate:ve=>ve.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:_e,onActivate:Oe,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return i.jsxs("div",{className:oe.container,"data-testid":"env-create-panel",children:[i.jsxs("div",{className:oe.header,children:[i.jsx("div",{className:oe.headerTitle,children:i.jsx("span",{className:oe.badge,children:"new environment"})}),i.jsxs("div",{className:oe.headerActions,children:[i.jsx("button",{onClick:ue,disabled:!Nt(),className:oe.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),i.jsx("button",{onClick:Re,className:oe.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:oe.body,children:i.jsxs("div",{className:oe.formContent,children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-name",children:"Name"}),i.jsx("input",{id:"env-create-name",type:"text",value:D,onChange:re=>R(re.target.value),placeholder:"Environment name...",autoFocus:!0,className:oe.nameInput,"data-testid":"env-create-name",onKeyDown:re=>{re.key==="Enter"&&Nt()&&ue()}})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),i.jsxs("select",{id:"env-create-adapter",value:E,onChange:re=>{M(re.target.value),re.target.value==="codespace"&&u(ce||void 0)},className:oe.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"})]})]}),(E==="codespace"||E==="docker")&&r.length>0&&i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-github-account",children:"GitHub Account"}),i.jsxs("select",{id:"env-create-github-account",value:ce,onChange:re=>{me(re.target.value),E==="codespace"&&u(re.target.value||void 0)},className:oe.adapterSelect,"data-testid":"env-create-github-account",children:[i.jsx("option",{value:"",children:"(Default)"}),r.map(re=>i.jsxs("option",{value:re.id,children:[re.label," (@",re.username,")",re.isDefault?" — default":""]},re.id))]})]}),E==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:O,onChange:re=>A(re.target.value),placeholder:"Host (optional)...",className:oe.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-port",children:"Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:Xc,max:Qc,value:$,onChange:re=>Y(re.target.value),placeholder:"Port (optional)...",className:oe.fieldInput,"data-testid":"env-create-port"})]})]}),E==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:O,onChange:re=>A(re.target.value),placeholder:"Host (required)...",className:oe.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-user",children:"User"}),i.jsx("input",{id:"env-create-user",type:"text",value:V,onChange:re=>ee(re.target.value),placeholder:"User (optional)...",className:oe.fieldInput,"data-testid":"env-create-user"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-port",children:"SSH Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:Xc,max:Qc,value:$,onChange:re=>Y(re.target.value),placeholder:"SSH port (optional)...",className:oe.fieldInput,"data-testid":"env-create-port"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-identity",children:"Identity File"}),i.jsx("input",{id:"env-create-identity",type:"text",value:le,onChange:re=>Z(re.target.value),placeholder:"Identity file (optional)...",className:oe.fieldInput,"data-testid":"env-create-identity"})]})]}),E==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-docker-mode",children:"Source"}),i.jsxs("select",{id:"env-docker-mode",value:ke,onChange:re=>{const ve=re.target.value;De(ve),ve==="attach"&&_()},className:oe.adapterSelect,"data-testid":"env-docker-mode",children:[i.jsx("option",{value:"create",children:"Create new container"}),i.jsx("option",{value:"attach",children:"Attach to existing container"})]})]}),ke==="create"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-image",children:"Image"}),i.jsx("input",{id:"env-create-image",type:"text",value:ae,onChange:re=>H(re.target.value),placeholder:"Image (optional)...",className:oe.fieldInput,"data-testid":"env-create-image"})]}),i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,htmlFor:"env-create-repo",children:"Repo"}),i.jsx("input",{id:"env-create-repo",type:"text",value:B,onChange:re=>F(re.target.value),placeholder:"Repo (optional)...",className:oe.fieldInput,"data-testid":"env-create-repo"})]})]}):i.jsxs("div",{className:oe.section,children:[i.jsx("label",{className:oe.label,children:"Container"}),!S&&k.length>0&&i.jsxs("select",{value:ot,onChange:re=>{yt(re.target.value),re.target.value&&!D.trim()&&R(re.target.value)},className:oe.adapterSelect,"data-testid":"env-docker-container-select",children:[i.jsx("option",{value:"",children:"Select a container..."}),k.map(re=>i.jsxs("option",{value:re.name,children:[re.name," (",re.image,") ",re.status]},re.id))]}),(S||k.length===0)&&i.jsxs(i.Fragment,{children:[S?i.jsx("span",{className:oe.errorHint,children:S}):i.jsx("span",{className:oe.creatingHint,children:"No running containers found."}),i.jsx("input",{type:"text",value:ot,onChange:re=>{yt(re.target.value),re.target.value&&!D.trim()&&R(re.target.value)},placeholder:"Enter container name/ID...",className:oe.fieldInput,"data-testid":"env-docker-container-manual"})]})]})]}),E==="codespace"&&i.jsx(d8,{codespaceName:ge,onCodespaceNameChange:ne,envName:D,onEnvNameChange:R,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b})]})})]})}const u8="_group_1iprv_1",f8="_groupTitle_1iprv_8",p8="_shortcutList_1iprv_17",m8="_shortcutRow_1iprv_23",h8="_keys_1iprv_36",g8="_kbd_1iprv_43",v8="_description_1iprv_60",vi={group:u8,groupTitle:f8,shortcutList:p8,shortcutRow:m8,keys:h8,kbd:g8,description:v8},y8=[{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"}]},{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:"Root",shortcuts:[{keys:["Ctrl/Cmd","Enter"],description:"Send message (when the composer is focused)"},{keys:["Enter"],description:"Insert a new line in the message composer"}]}];function b8(){return i.jsxs("section",{className:fe.section,"data-testid":"keyboard-shortcuts-panel",children:[i.jsx("h3",{className:fe.sectionTitle,children:"Keyboard Shortcuts"}),i.jsx("p",{className:fe.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),y8.map(t=>i.jsxs("div",{className:vi.group,children:[i.jsx("h4",{className:vi.groupTitle,children:t.title}),i.jsx("div",{className:vi.shortcutList,children:t.shortcuts.map(s=>i.jsxs("div",{className:vi.shortcutRow,children:[i.jsx("span",{className:vi.keys,children:s.keys.map(o=>i.jsx("kbd",{className:vi.kbd,children:o},o))}),i.jsx("span",{className:vi.description,children:s.description})]},s.description))})]},t.title))]})}const _8=[{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 x8({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:fe.section,children:[i.jsx("h3",{className:fe.sectionTitle,children:"Credential Providers"}),i.jsx("p",{className:fe.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:fe.tokenList,children:_8.map(r=>i.jsxs("div",{className:fe.tokenRow,children:[i.jsx("span",{className:fe.tokenName,children:r.label}),i.jsx("span",{className:fe.tokenTarget,children:r.description}),i.jsx("select",{className:fe.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 k8="_container_10efq_1",S8="_header_10efq_7",j8="_list_10efq_105",T8="_card_10efq_111",w8="_cardHeader_10efq_125",N8="_cardTitle_10efq_135",C8="_defaultBadge_10efq_141",E8="_cardActions_10efq_155",A8="_description_10efq_160",D8="_meta_10efq_166",M8="_empty_10efq_212",R8="_typeBadge_10efq_362",es={container:k8,header:S8,list:j8,card:T8,cardHeader:w8,cardTitle:N8,defaultBadge:C8,cardActions:E8,description:A8,meta:D8,empty:M8,typeBadge:R8};function I8({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return i.jsxs("div",{className:es.container,children:[i.jsxs("div",{className:es.header,children:[i.jsx("h2",{children:"Personas"}),i.jsx(sn,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?i.jsx("p",{className:es.empty,children:"No personas yet. Create one to get started."}):i.jsx("div",{className:es.list,children:t.map(v=>{const b=s===v.id,_=v.type==="script";return i.jsxs("div",{className:es.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(v.id))},children:[i.jsxs("div",{className:es.cardHeader,children:[i.jsxs("span",{className:es.cardTitle,children:[i.jsx("strong",{children:v.name}),i.jsx("span",{className:es.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:_?"Script":"Agent"}),b&&i.jsx("span",{className:es.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),i.jsxs("div",{className:es.cardActions,onClick:k=>k.stopPropagation(),children:[!b&&i.jsx(sn,{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(sn,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&i.jsx("p",{className:es.description,children:v.description}),i.jsxs("div",{className:es.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(ys,{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 O8="_container_uy08i_1",B8="_header_uy08i_7",L8="_count_uy08i_13",z8="_presets_uy08i_18",$8="_presetButton_uy08i_24",H8="_filterInput_uy08i_41",P8="_groups_uy08i_53",U8="_group_uy08i_53",V8="_groupHeader_uy08i_68",q8="_groupName_uy08i_77",G8="_groupCount_uy08i_81",F8="_toolList_uy08i_87",K8="_toolItem_uy08i_95",Z8="_toolName_uy08i_103",yn={container:O8,header:B8,count:L8,presets:z8,presetButton:$8,filterInput:H8,groups:P8,group:U8,groupHeader:V8,groupName:q8,groupCount:G8,toolList:F8,toolItem:K8,toolName:Z8},Y8=(()=>{const t=new Map;for(const s of v_){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()}))})(),J8=[{name:"default",label:"Default",tools:g_},{name:"worker",label:"Worker",tools:R2},{name:"orchestrator",label:"Orchestrator",tools:I2},{name:"admin",label:"Admin",tools:O2}];function Yb({selectedTools:t,onChange:s,disabled:o}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.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=y.useCallback((v,b)=>{if(o)return;const _=new Set(d);for(const k of v)b?_.delete(k):_.add(k);s([..._].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return i.jsxs("div",{className:yn.container,"data-testid":"mcp-tool-selector",children:[i.jsx("div",{className:yn.header,children:i.jsx("span",{className:yn.count,children:t.length===0?`Using default (${g_.length} tools)`:`${t.length} of ${v_.size} tools selected`})}),i.jsxs("div",{className:yn.presets,"data-testid":"mcp-tool-presets",children:[J8.map(v=>i.jsx("button",{type:"button",className:yn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),i.jsx("button",{type:"button",className:yn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),i.jsx("input",{type:"text",className:yn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),i.jsx("div",{className:yn.groups,children:Y8.map(({group:v,tools:b})=>{const _=g?b.filter(S=>S.toLowerCase().includes(g)):b;if(_.length===0)return null;const k=_.every(S=>d.has(S));return i.jsxs("div",{className:yn.group,"data-testid":`tool-group-${v}`,children:[i.jsxs("label",{className:yn.groupHeader,children:[i.jsx("input",{type:"checkbox",checked:k,onChange:()=>p(_,k),disabled:o,"data-testid":`group-toggle-${v}`}),i.jsx("span",{className:yn.groupName,children:v}),i.jsxs("span",{className:yn.groupCount,children:["(",_.filter(S=>d.has(S)).length,"/",_.length,")"]})]}),i.jsx("div",{className:yn.toolList,children:_.map(S=>i.jsxs("label",{className:yn.toolItem,children:[i.jsx("input",{type:"checkbox",checked:d.has(S),onChange:()=>u(S),disabled:o,"data-testid":`tool-${S}`}),i.jsx("span",{className:yn.toolName,children:S})]},S))})]},v)})})]})}function sm(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 P1(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 W8="_container_1gfuq_1",X8="_header_1gfuq_7",Q8="_list_1gfuq_19",e7="_card_1gfuq_25",t7="_cardHeader_1gfuq_40",n7="_cardTitle_1gfuq_46",s7="_statusBadge_1gfuq_56",a7="_enabled_1gfuq_68",i7="_disabled_1gfuq_71",o7="_cardActions_1gfuq_75",r7="_cardMeta_1gfuq_80",l7="_empty_1gfuq_98",ts={container:W8,header:X8,list:Q8,card:e7,cardHeader:t7,cardTitle:n7,statusBadge:s7,enabled:a7,disabled:i7,cardActions:o7,cardMeta:r7,empty:l7};function c7({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=y.useState(null),m=u?t.find(_=>_.id===u):void 0,g=async _=>{await o(_),p(null)},v=y.useMemo(()=>{const _=new Map;for(const k of s)_.set(k.id,k.name);return _},[s]),b=_=>v.get(_)??_;return i.jsxs("div",{className:ts.container,children:[i.jsxs("div",{className:ts.header,children:[i.jsx("h2",{children:"Schedules"}),i.jsx(sn,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?i.jsx("p",{className:ts.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):i.jsx("div",{className:ts.list,children:t.map(_=>i.jsxs("div",{className:ts.card,"data-testid":`schedule-card-${_.id}`,onClick:()=>d(_.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(_.id))},children:[i.jsxs("div",{className:ts.cardHeader,children:[i.jsxs("span",{className:ts.cardTitle,children:[i.jsx("strong",{children:_.title}),i.jsx("span",{className:`${ts.statusBadge} ${_.enabled?ts.enabled:ts.disabled}`,"data-testid":`schedule-status-badge-${_.id}`,children:_.enabled?"Enabled":"Disabled"})]}),i.jsxs("div",{className:ts.cardActions,onClick:k=>k.stopPropagation(),children:[i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(_.id,{enabled:!_.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${_.id}`,title:_.enabled?"Disable schedule":"Enable schedule",children:_.enabled?"Disable":"Enable"}),i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>d(_.id),"data-testid":`schedule-edit-${_.id}`,children:"Edit"}),i.jsx(sn,{variant:"ghost",size:"sm",onClick:()=>p(_.id),"data-testid":`schedule-delete-${_.id}`,children:"Delete"})]})]}),i.jsxs("div",{className:ts.cardMeta,children:[i.jsx("span",{"data-testid":`schedule-expression-${_.id}`,children:_.scheduleExpression}),_.personaId&&i.jsxs("span",{"data-testid":`schedule-persona-${_.id}`,children:["Persona: ",b(_.personaId)]}),i.jsxs("span",{"data-testid":`schedule-last-run-${_.id}`,children:["Last run: ",_.lastRunAt?sm(_.lastRunAt):"Never"]}),_.enabled&&_.nextRunAt?i.jsxs("span",{"data-testid":`schedule-next-run-${_.id}`,children:["Next run: ",P1(_.nextRunAt)]}):null,_.runCount>0&&i.jsxs("span",{"data-testid":`schedule-run-count-${_.id}`,children:["Runs: ",_.runCount]})]})]},_.id))}),i.jsx(ys,{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 d7="_nav_1bhou_1",u7="_tab_1bhou_24",f7="_tabIcon_1bhou_62",p7="_tabActive_1bhou_68",Hc={nav:d7,tab:u7,tabIcon:f7,tabActive:p7},na=[{path:"credentials",label:"Credentials",icon:i.jsx(Xj,{size:wt})},{path:"github-accounts",label:"GitHub Accounts",icon:i.jsx(Gj,{size:wt})},{path:"personas",label:"Personas",icon:i.jsx(BT,{size:wt})},{path:"schedules",label:"Schedules",icon:i.jsx(kj,{size:wt})},{path:"appearance",label:"Appearance",icon:i.jsx(yT,{size:wt})},{path:"shortcuts",label:"Shortcuts",icon:i.jsx(eT,{size:wt})},{path:"plugins",label:"Plugins",icon:i.jsx(jT,{size:wt})},{path:"about",label:"About",icon:i.jsx(um,{size:wt})}];function m7(){var u;const t=Jt(),s=vt(),o=y.useRef(null),r=((u=na.find(p=>{const m=`${xi}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??na[0].path,c=y.useCallback(p=>{s(`${xi}/${p}`)},[s]),d=y.useCallback(p=>{var k,S;const m=(k=o.current)==null?void 0:k.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:na.findIndex(j=>j.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%na.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+na.length)%na.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=na.length-1;else return;const _=na[b].path;s(`${xi}/${_}`),(S=m[b])==null||S.focus()},[r,s]);return i.jsx("nav",{className:Hc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:na.map(p=>{const m=p.path===r;return i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Hc.tab} ${m?Hc.tabActive:""}`,onClick:()=>c(p.path),children:[i.jsx("span",{className:Hc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}const h7=["lifecycle:","pipe:","stdin:"];function U1(t){return t.selfEcho?"chatroom":t.name.startsWith("pipe:")?"pipe":"channel"}function g7(t,s){let o=!1;for(const r of t.subscribers){const c=s.get(r.sessionId);if(c&&(o=!0,c.taskId))return{kind:"task",taskId:c.taskId}}return o?{kind:"unattached"}:{kind:"external"}}function v7(t,s){const o=new Map(s.map(u=>[u.id,u])),r=new Map,c=[];for(const u of t){const p=g7(u,o);if(p.kind==="task"){const m=r.get(p.taskId);m?m.push(u):r.set(p.taskId,[u])}else c.push(u)}const d=Array.from(r,([u,p])=>({taskId:u,streams:p}));return c.length>0&&d.push({taskId:void 0,streams:c}),d}const y7="_container_16qkd_1",b7="_header_16qkd_7",_7="_title_16qkd_15",x7="_headerActions_16qkd_21",k7="_internalsToggle_16qkd_27",S7="_refreshButton_16qkd_37",j7="_state_16qkd_52",T7="_group_16qkd_59",w7="_groupHeader_16qkd_63",N7="_row_16qkd_72",C7="_selected_16qkd_92",E7="_kindBadge_16qkd_96",A7="_kindChatroom_16qkd_108",D7="_kindPipe_16qkd_114",M7="_kindChannel_16qkd_120",R7="_streamName_16qkd_126",I7="_meta_16qkd_135",Yt={container:y7,header:b7,title:_7,headerActions:x7,internalsToggle:k7,refreshButton:S7,state:j7,group:T7,groupHeader:w7,row:N7,selected:C7,kindBadge:E7,kindChatroom:A7,kindPipe:D7,kindChannel:M7,streamName:R7,meta:I7},O7={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function B7({kind:t}){return t==="chatroom"?i.jsx(fT,{size:Ze,"aria-hidden":"true"}):t==="pipe"?i.jsx(Vj,{size:Ze,"aria-hidden":"true"}):i.jsx(Kj,{size:Ze,"aria-hidden":"true"})}function L7({streams:t,sessions:s,tasks:o,loading:r,loadError:c=!1,loadedOnce:d=!0,showInternals:u,onToggleInternals:p,selectedStreamId:m,onSelectStream:g,onRefresh:v}){const b=v7(t,s),_={chatroom:Yt.kindChatroom,pipe:Yt.kindPipe,channel:Yt.kindChannel},k=S=>{var j;return((j=o.find(T=>T.id===S))==null?void 0:j.title)??S};return i.jsxs("div",{className:Yt.container,"data-testid":"coordination-list",children:[i.jsxs("div",{className:Yt.header,children:[i.jsx("span",{className:Yt.title,children:"Coordination"}),i.jsxs("div",{className:Yt.headerActions,children:[i.jsxs("label",{className:Yt.internalsToggle,children:[i.jsx("input",{type:"checkbox",checked:u,onChange:S=>p(S.target.checked),"data-testid":"coordination-show-internals"}),"Show internals"]}),v&&i.jsx("button",{type:"button",className:Yt.refreshButton,onClick:v,"aria-label":"Refresh streams","data-testid":"coordination-refresh",children:i.jsx(wT,{size:Ze,"aria-hidden":"true"})})]})]}),r&&t.length===0&&i.jsxs("div",{className:Yt.state,children:["Loading","…"]}),!r&&c&&i.jsx("div",{className:Yt.state,"data-testid":"coordination-error",children:"Unable to load streams"}),!r&&!c&&d&&t.length===0&&i.jsx("div",{className:Yt.state,"data-testid":"coordination-empty",children:"No active streams"}),b.map(S=>i.jsxs("div",{className:Yt.group,children:[i.jsx("div",{className:Yt.groupHeader,children:S.taskId?k(S.taskId):"Unattached / external (CLI · MCP)"}),S.streams.map(j=>{const T=U1(j),w=j.id===m;return i.jsxs("button",{type:"button",className:`${Yt.row}${w?` ${Yt.selected}`:""}`,onClick:()=>g(j.id),"data-testid":`coordination-row-${j.id}`,"aria-current":w?"page":void 0,children:[i.jsxs("span",{className:`${Yt.kindBadge} ${_[T]}`,children:[i.jsx(B7,{kind:T})," ",O7[T]]}),i.jsx("span",{className:Yt.streamName,children:j.name}),i.jsxs("span",{className:Yt.meta,children:[j.subscriberCount," ",j.subscriberCount===1?"sub":"subs"," ","·"," ",j.messageBufferDepth," buffered"]})]},j.id)})]},S.taskId??"__orphans__"))]})}const z7="_panel_iibrt_1",$7="_header_iibrt_24",H7="_title_iibrt_33",P7="_closeButton_iibrt_43",U7="_body_iibrt_57",V7="_section_iibrt_63",q7="_sectionLabel_iibrt_67",G7="_metaRow_iibrt_76",F7="_metaKey_iibrt_84",K7="_metaValue_iibrt_90",Z7="_subscriberCard_iibrt_99",Y7="_subscriberHeader_iibrt_107",J7="_sessionLink_iibrt_114",W7="_badges_iibrt_132",X7="_badgeRw_iibrt_150 _badge_iibrt_132",Q7="_badgeR_iibrt_150 _badge_iibrt_132",ez="_badgeW_iibrt_162 _badge_iibrt_132",tz="_badgeAsync_iibrt_168 _badge_iibrt_132",nz="_badgeSync_iibrt_174 _badge_iibrt_132",sz="_badgeDetach_iibrt_178 _badge_iibrt_132",az="_spawnTag_iibrt_184 _badge_iibrt_132",iz="_fdNumber_iibrt_189",oz="_emptySubscribers_iibrt_195",rz="_metaValueMono_iibrt_201 _metaValue_iibrt_90",lz="_placeholder_iibrt_207",cz="_advanced_iibrt_216",dz="_advancedSummary_iibrt_220",Pe={panel:z7,header:$7,title:H7,closeButton:P7,body:U7,section:V7,sectionLabel:q7,metaRow:G7,metaKey:F7,metaValue:K7,subscriberCard:Z7,subscriberHeader:Y7,sessionLink:J7,badges:W7,badgeRw:X7,badgeR:Q7,badgeW:ez,badgeAsync:tz,badgeSync:nz,badgeDetach:sz,spawnTag:az,fdNumber:iz,emptySubscribers:oz,metaValueMono:rz,placeholder:lz,advanced:cz,advancedSummary:dz},uz={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function fz({permission:t}){const s=t==="rw"?Pe.badgeRw:t==="r"?Pe.badgeR:Pe.badgeW;return i.jsx("span",{className:s,children:t})}function pz({mode:t}){const s=t==="async"?Pe.badgeAsync:t==="detach"?Pe.badgeDetach:Pe.badgeSync;return i.jsx("span",{className:s,children:t})}function mz({stream:t,onClose:s}){const o=vt();return y.useEffect(()=>{const r=c=>{c.key==="Escape"&&s()};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[s]),i.jsxs("div",{className:Pe.panel,"data-testid":"stream-detail-panel",children:[i.jsxs("div",{className:Pe.header,children:[i.jsx("h3",{className:Pe.title,children:t.name}),i.jsx("button",{type:"button",className:Pe.closeButton,onClick:s,"aria-label":"Close stream details",children:"×"})]}),i.jsxs("div",{className:Pe.body,children:[i.jsxs("div",{className:Pe.section,children:[i.jsx("div",{className:Pe.sectionLabel,children:"Overview"}),i.jsxs("div",{className:Pe.metaRow,children:[i.jsx("span",{className:Pe.metaKey,children:"Kind"}),i.jsx("span",{className:Pe.metaValue,children:uz[U1(t)]})]}),i.jsxs("div",{className:Pe.metaRow,children:[i.jsx("span",{className:Pe.metaKey,children:"Participants"}),i.jsx("span",{className:Pe.metaValue,children:t.subscriberCount})]}),i.jsxs("div",{className:Pe.metaRow,children:[i.jsx("span",{className:Pe.metaKey,children:"Buffered"}),i.jsxs("span",{className:Pe.metaValue,children:[t.messageBufferDepth," msgs"]})]})]}),i.jsxs("div",{className:Pe.section,children:[i.jsx("div",{className:Pe.sectionLabel,children:"Participants"}),t.subscribers.length===0?i.jsx("div",{className:Pe.emptySubscribers,children:"No active subscribers"}):t.subscribers.map(r=>i.jsxs("div",{className:Pe.subscriberCard,"data-testid":`subscriber-card-${r.subscriptionId}`,children:[i.jsxs("button",{type:"button",className:Pe.sessionLink,onClick:()=>{o(xm(r.sessionId))},title:r.sessionId,children:[r.sessionId.slice(0,12),"…"]}),r.createdBySpawn&&i.jsx("span",{className:Pe.spawnTag,children:"spawn"})]},r.subscriptionId))]}),i.jsxs("div",{className:Pe.section,children:[i.jsx("div",{className:Pe.sectionLabel,children:"Conversation"}),i.jsx("div",{className:Pe.placeholder,"data-testid":"stream-conversation-placeholder",children:"Live conversation view — coming in V2."})]}),i.jsxs("details",{className:Pe.advanced,"data-testid":"stream-advanced",children:[i.jsx("summary",{className:Pe.advancedSummary,children:"Advanced"}),i.jsxs("div",{className:Pe.metaRow,children:[i.jsx("span",{className:Pe.metaKey,children:"Stream ID"}),i.jsx("span",{className:Pe.metaValueMono,children:t.id})]}),t.subscribers.map(r=>i.jsxs("div",{className:Pe.subscriberCard,children:[i.jsxs("div",{className:Pe.subscriberHeader,children:[i.jsxs("span",{className:Pe.fdNumber,children:["fd ",r.fd]}),i.jsxs("span",{className:Pe.metaValueMono,title:r.subscriptionId,children:[r.subscriptionId.slice(0,12),"…"]})]}),i.jsxs("div",{className:Pe.badges,children:[i.jsx(fz,{permission:r.permission}),i.jsx(pz,{mode:r.deliveryMode})]})]},r.subscriptionId))]})]})]})}function hz({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(fy.map(d=>[d,[]]));for(const d of t){const u=ol(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(S=>s.get(S)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(S=>S.status==="complete").length;let b;if(u==="paused"&&o){const S=o.get(d.id);S==="idle"?b="Needs input":S==="completed"&&(b="Ready to complete")}const _={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},k=c.get(u);k?k.push(_):c.get("not_started").push(_)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return fy.map(d=>{const u=Fa(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const gz="_boardContainer_1c4y1_1",vz="_column_1c4y1_17",yz="_columnHeader_1c4y1_34",bz="_columnIcon_1c4y1_47",_z="_columnLabel_1c4y1_52",xz="_columnCount_1c4y1_57",kz="_cardList_1c4y1_67",Sz="_emptyPlaceholder_1c4y1_76",jz="_card_1c4y1_67",Tz="_cardHeader_1c4y1_107",wz="_cardStatusIcon_1c4y1_113",Nz="_cardTitle_1c4y1_119",Cz="_cardBadges_1c4y1_127",Ez="_badge_1c4y1_134",Az="_blockedBadge_1c4y1_146",Dz="_childBadge_1c4y1_151",Mz="_depBadge_1c4y1_155",Rz="_parentBadge_1c4y1_159",Iz="_pausedSubBadge_1c4y1_166",Oz="_personaBadge_1c4y1_170",Bz="_envBadge_1c4y1_174",Lz="_emptyCta_1c4y1_178",zz="_ctaButton_1c4y1_188",$z="_ctaDescription_1c4y1_204",lt={boardContainer:gz,column:vz,columnHeader:yz,columnIcon:bz,columnLabel:_z,columnCount:xz,cardList:kz,emptyPlaceholder:Sz,card:jz,cardHeader:Tz,cardStatusIcon:wz,cardTitle:Nz,cardBadges:Cz,badge:Ez,blockedBadge:Az,childBadge:Dz,depBadge:Mz,parentBadge:Rz,pausedSubBadge:Iz,personaBadge:Oz,envBadge:Bz,emptyCta:Lz,ctaButton:zz,ctaDescription:$z};function Hz({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=vt(),p=y.useMemo(()=>o.filter(_=>_.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(_=>[_.id,_.status])),[o]),g=y.useMemo(()=>new Map(p.map(_=>[_.id,_])),[p]),v=y.useMemo(()=>{const _=new Map(r.map(C=>[C.id,C])),k=new Map(c.map(C=>[C.id,C])),S=new Map(d.map(C=>[C.id,C])),j=new Map,T=new Map,w=new Map;for(const C of p)if(C.latestSessionId){const D=_.get(C.latestSessionId);if(D){if(j.set(C.id,D.endReason||D.status),D.personaId){const R=k.get(D.personaId);R&&T.set(C.id,R.name)}if(D.environmentId){const R=S.get(D.environmentId);R&&w.set(C.id,R.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:T,environmentNameByTaskId:w}},[p,r,c,d]),b=y.useMemo(()=>hz({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?i.jsxs("div",{className:lt.emptyCta,"data-testid":"board-empty-cta",children:[i.jsx("button",{className:lt.ctaButton,onClick:()=>u(Ai(t,void 0,s)),children:"Create Task"}),i.jsx("div",{className:lt.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):i.jsx("div",{className:lt.boardContainer,"data-testid":"board-container",children:b.map(_=>i.jsxs("section",{className:lt.column,"data-testid":`board-column-${_.status}`,"aria-label":`${_.label}, ${_.tasks.length} ${_.tasks.length===1?"task":"tasks"}`,children:[i.jsxs("div",{className:lt.columnHeader,children:[i.jsx("span",{className:lt.columnIcon,style:{color:_.style.color},children:_.style.icon}),i.jsx("span",{className:lt.columnLabel,children:_.label}),i.jsx("span",{className:lt.columnCount,"data-testid":`board-count-${_.status}`,children:_.tasks.length})]}),i.jsx("div",{className:lt.cardList,children:_.tasks.length===0?i.jsx("div",{className:lt.emptyPlaceholder,children:"No tasks"}):i.jsx(as,{mode:"popLayout",children:_.tasks.map(k=>i.jsx($t.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:i.jsx(Pz,{boardTask:k,tasksById:g,personaName:v.personaNameByTaskId.get(k.task.id),envName:v.environmentNameByTaskId.get(k.task.id),onClick:()=>u(os(k.task.id,void 0,t,s))})},k.task.id))})})]},_.status))})}function Pz({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=Fa(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return i.jsxs("div",{className:lt.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c())},children:[i.jsxs("div",{className:lt.cardHeader,children:[i.jsx("span",{className:lt.cardStatusIcon,style:{color:v.color},children:v.icon}),i.jsx("span",{className:lt.cardTitle,children:d.title})]}),i.jsxs("div",{className:lt.cardBadges,children:[b&&i.jsx("span",{className:`${lt.badge} ${lt.parentBadge}`,title:b.title,children:b.title}),p>0&&i.jsxs("span",{className:`${lt.badge} ${lt.childBadge}`,children:[m,"/",p]}),u&&i.jsx("span",{className:`${lt.badge} ${lt.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&i.jsx("span",{className:`${lt.badge} ${lt.depBadge}`,children:"dep"}),g&&i.jsx("span",{className:`${lt.badge} ${lt.pausedSubBadge}`,children:g}),o&&i.jsx("span",{className:`${lt.badge} ${lt.personaBadge}`,children:o}),r&&i.jsx("span",{className:`${lt.badge} ${lt.envBadge}`,children:r})]})]})}const Uz="_formContent_ymnez_1",Vz="_section_ymnez_13",qz="_label_ymnez_19",Gz="_titleInput_ymnez_26",Fz="_descriptionTextarea_ymnez_58",Kz="_selectField_ymnez_94",Zz="_checkboxRow_ymnez_128",Yz="_checkboxLabel_ymnez_141",Jz="_fieldError_ymnez_146",xt={formContent:Uz,section:Vz,label:qz,titleInput:Gz,descriptionTextarea:Fz,selectField:Kz,checkboxRow:Zz,checkboxLabel:Yz,fieldError:Jz};function Wz(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.linkedEnvironmentIds[0])??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const Xz=100;function Qz({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:Xz,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 V1=y.createContext(void 0),e$=4e3;function t$({children:t}){const[s,o]=y.useState([]),r=y.useRef(0),c=y.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=y.useCallback((u,p="info",m=e$)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return i.jsx(V1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function pn(){const t=y.useContext(V1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const am="grackle-theme",q1="grackle-prefer-system",G1="(prefers-color-scheme: dark)";let qr=[],ed;function Sp(){ed=void 0;for(const t of qr)t()}function im(){return typeof window>"u"?!1:window.matchMedia(G1).matches}function Jr(){if(typeof localStorage>"u")return Kb;try{const t=localStorage.getItem(am);if(t!==null&&z1.has(t))return t}catch{}return Kb}function fd(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(q1)==="true"}catch{return!1}}function om(t){return Nd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function F1(t,s){const o=nm(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?im()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=om(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return im()?r.variantDarkId:r.variantLightId}return t}function wo(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=F1(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&wo(Jr(),fd());function n$(){return ed===void 0&&(ed={themeId:Jr(),systemDark:im(),preferSystem:fd()}),ed}function s$(t){return qr=[...qr,t],()=>{qr=qr.filter(s=>s!==t)}}function a$(){const t=y.useSyncExternalStore(s$,n$),{themeId:s,preferSystem:o}=t,r=F1(s,o),c=y.useCallback(u=>{if(z1.has(u)){try{localStorage.setItem(am,u)}catch{}wo(u,fd(),!0),Sp()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(q1,u?"true":"false")}catch{}if(u){const p=Jr(),m=nm(p);if(m!=null&&m.hidden){const g=om(p);if(g)try{localStorage.setItem(am,g.id)}catch{}}}wo(Jr(),u,!0),Sp()},[]);return y.useEffect(()=>{wo(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(G1),p=()=>{const m=Jr(),g=fd();if(g){const v=nm(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&wo(m,g),v!=null&&v.hidden){const b=om(m);b!=null&&b.variantDarkId&&b.variantLightId&&wo(m,g)}}Sp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const K1=y.createContext(void 0);function i$({children:t}){const s=a$();return i.jsx(K1.Provider,{value:s,children:t})}function Z1(){const t=y.useContext(K1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const Y1=y.createContext(void 0),J1=y.createContext(void 0);function o$({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return i.jsx(J1.Provider,{value:r,children:i.jsx(Y1.Provider,{value:s,children:t})})}function r$(){return y.useContext(Y1)}function l$(){const t=y.useContext(J1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const ih=y.createContext(void 0);function ut(){const t=y.useContext(ih);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function W1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function X1(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function c$(t){return W1(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 d$=new Set(["off","subscription","api_key"]),Pc=new Set(["off","on"]);function u$(t){return W1(t)&&d$.has(t.claude)&&Pc.has(t.github)&&Pc.has(t.copilot)&&Pc.has(t.codex)&&Pc.has(t.goose)}function Q1(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 ek(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 jo=5e3;function f$(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 wi={label:"Home",url:Ho};function p$(t){return t?[wi,{label:"Settings",url:xi},{label:t,url:void 0}]:[wi,{label:"Settings",url:void 0}]}const tk={label:"Environments",url:Mo};function m$(){return[wi,{label:"Environments",url:void 0}]}function h$(){return[wi,{label:"New Chat",url:void 0}]}function g$(t){return[wi,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function v$(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[wi,tk,{label:(d==null?void 0:d.displayName)??"Environment",url:Ro(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function y$(t,s,o,r,c){const d=f$(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(k=>k.id===p):void 0,g=s??(m==null?void 0:m.linkedEnvironmentIds[0]),v=g?r.find(k=>k.id===g):void 0,b=[wi];v&&g&&(b.push(tk),b.push({label:v.displayName,url:Ro(g)})),m&&g&&b.push({label:m.name,url:ji(m.id,g)});for(let k=0;k<d.length-1;k++)b.push({label:d[k].title,url:os(d[k].id,void 0,p,g)});const _=d[d.length-1];return b.push({label:(_==null?void 0:_.title)??t,url:void 0}),b}function oh(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 Uc(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 b$(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 rh(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),_=b?Uc(b):void 0;if(_)try{const k=JSON.parse(v.content);o.set(_,{tool:k.tool,args:k.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,b)=>{if(v.eventType!=="tool_result")return v;const _=s.get(v),k=_?b$(_):void 0;if(!k)return v;const S=o.get(k);if(!S)return v;r.add(k),c.add(b);let j;const T=v.content.trim();if(T.startsWith("{"))try{const w=JSON.parse(T);typeof w.detailedContent=="string"&&(j=w.detailedContent)}catch{}return{...v,toolUseCtx:{...S,detailedResult:j}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const b=s.get(d[v]),_=b?Uc(b):void 0;_&&r.has(_)||u.push(v)}const p=[];for(let v=0;v<d.length;v++)d[v].eventType!=="tool_result"||c.has(v)||p.push(v);let m=0;for(const v of u){for(;m<p.length&&p[m]<v;)m++;if(m>=p.length)break;const b=p[m];if(b!==v+1)continue;const _=d[v],k=d[b];let S;try{const j=JSON.parse(_.content);S={tool:j.tool,args:j.args}}catch{}if(S){let j;const T=k.content.trim();if(T.startsWith("{"))try{const D=JSON.parse(T);typeof D.detailedContent=="string"&&(j=D.detailedContent)}catch{}d[b]={...k,toolUseCtx:{...S,detailedResult:j}},c.add(b);const w=s.get(_),C=w?Uc(w):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(_,{...w??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const b=s.get(v);if(!b)return!0;const _=Uc(b);if(_&&r.has(_))return!1;const k=b.__seqId;return!(k&&r.has(k))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let b=!1;for(let _=v+1;_<g.length;_++)if(g[_].eventType!=="tool_use"){b=!0;break}b&&(g[v]={...g[v],settled:!0})}return g}function _$(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=nk(s),d=s.filter(m=>rm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||rm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function nk(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function rm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function x$(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=nk(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}):rm(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 k$(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 S$(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 Cs=[{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
326
326
  export function verifyToken(req: Request, res: Response, next: NextFunction): void {
327
327
  const header = req.headers.authorization;
328
328
  if (!header?.startsWith("Bearer ")) {
@@ -752,4 +752,4 @@ const grackle = await host.mcpServer({
752
752
  url: env.vars.GRACKLE_MCP_URL,
753
753
  });
754
754
 
755
- $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),M==="agent"&&i.jsxs("div",{children:[i.jsx("label",{children:"Allowed MCP Tools"}),i.jsx(Yb,{selectedTools:Y,onChange:ue=>{V(ue),_e(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ue),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!ke&&!me&&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(ys,{isOpen:ee,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:yt,onCancel:()=>le(!1)})]})}function zU(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=ut(),{showToast:c}=pn(),d=vt();return i.jsx(c7,{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(HN),onNavigateToSchedule:u=>d(G_(u))})}const $U="_container_1g4qh_1",HU="_form_1g4qh_7",PU="_formActions_1g4qh_66",UU="_editableSection_1g4qh_73",VU="_helperText_1g4qh_84",qU="_metaSection_1g4qh_90",GU="_optional_1g4qh_108",FU="_readonlyValue_1g4qh_113",Bn={container:$U,form:HU,formActions:PU,editableSection:UU,helperText:VU,metaSection:qU,optional:GU,readonlyValue:FU};function p_(){const{scheduleId:t}=ua(),s=vt(),{showToast:o}=pn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},workspaces:{workspaces:g}}=ut(),v=t===void 0,b=v?void 0:r.find(k=>k.id===t);if(!v&&!c&&r.length>0&&!b)return i.jsx(zn,{to:Zf,replace:!0});const _=[{label:"Settings",url:xi},{label:"Schedules",url:Zf},{label:v?"New Schedule":(b==null?void 0:b.title)??"Schedule",url:void 0}];return i.jsxs("div",{className:Bn.container,children:[i.jsx(fa,{segments:_}),i.jsx(KU,{existing:b,isNew:v,personas:m,workspaces:g,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(Zf)},showToast:o})]})}function KU({existing:t,isNew:s,personas:o,workspaces:r,onCreateSchedule:c,onUpdateSchedule:d,onDeleteSchedule:u,onDone:p,showToast:m}){var H;const g=vt(),[v,b]=y.useState((t==null?void 0:t.title)??""),[_,k]=y.useState((t==null?void 0:t.description)??""),[S,j]=y.useState((t==null?void 0:t.scheduleExpression)??""),[T,w]=y.useState((t==null?void 0:t.personaId)??""),[C,D]=y.useState((t==null?void 0:t.workspaceId)??""),[R,E]=y.useState(!1),[M,O]=y.useState(null);y.useEffect(()=>{s||t&&M===null&&(b(t.title),k(t.description),j(t.scheduleExpression),w(t.personaId),D(t.workspaceId))},[s,t,M]);const A=!s&&t===void 0,$=s&&v.trim().length>0&&S.trim().length>0&&T.length>0,Y=o.map(B=>({value:B.id,label:B.name})),V=[{value:"",label:"System-level (no workspace)"},...r.map(B=>({value:B.id,label:B.name}))],ee=B=>{B.preventDefault(),$&&c(v,_,S,T,C||void 0).then(F=>{m("Schedule created","success"),g(G_(F.id),{replace:!0})},()=>{m("Failed to create schedule","error")})},le=(B,F)=>{t&&d(t.id,{[B]:F}).then(()=>{m("Schedule updated","success"),B==="title"&&b(String(F)),B==="description"&&k(String(F)),B==="scheduleExpression"&&j(String(F)),B==="personaId"&&w(String(F))},()=>{m("Failed to update schedule","error")})},Z=()=>{if(!t)return;const B=!t.enabled;d(t.id,{enabled:B}).then(()=>{m(B?"Schedule enabled":"Schedule disabled","success")},()=>{m("Failed to update schedule","error")})},ae=()=>{t&&u(t.id).then(()=>{m("Schedule deleted","success"),p()},()=>{m("Failed to delete schedule","error")})};return i.jsxs(i.Fragment,{children:[A?i.jsxs("div",{className:Bn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsx("p",{children:"Loading schedule..."})]}):s?i.jsxs("form",{onSubmit:ee,className:Bn.form,children:[i.jsx("h3",{children:"Create Schedule"}),i.jsxs("label",{children:["Title",i.jsx("input",{type:"text",value:v,onChange:B=>b(B.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description ",i.jsx("span",{className:Bn.optional,children:"(optional)"}),i.jsx("input",{type:"text",value:_,onChange:B=>k(B.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx("input",{type:"text",value:S,onChange:B=>j(B.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),i.jsxs("p",{className:Bn.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:B=>w(B.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[i.jsx("option",{value:"",children:"Select a persona..."}),Y.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))]})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:Bn.optional,children:"(optional)"}),i.jsx("select",{value:C,onChange:B=>D(B.target.value),"data-testid":"schedule-detail-workspace",children:V.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))})]}),i.jsxs("div",{className:Bn.formActions,children:[i.jsx(sn,{type:"submit",variant:"primary",size:"md",disabled:!$,"data-testid":"schedule-detail-save",children:"Create"}),i.jsx(sn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?i.jsxs("div",{className:Bn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsxs("div",{className:Bn.formActions,children:[i.jsx(sn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),i.jsx(sn,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:Z,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),i.jsx(sn,{type:"button",variant:"danger",size:"md",onClick:()=>E(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),i.jsxs("div",{className:Bn.editableSection,children:[i.jsxs("label",{children:["Title",i.jsx(Bt,{value:v,onSave:B=>{le("title",B)},validate:B=>B.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:M,onActivate:O,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description",i.jsx(Bt,{value:_,onSave:B=>{le("description",B)},fieldId:"schedule-description",activeFieldId:M,onActivate:O,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx(Bt,{value:S,onSave:B=>{le("scheduleExpression",B)},validate:B=>B.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:M,onActivate:O,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(ud,{value:T,onSave:B=>{le("personaId",B)},options:Y,fieldId:"schedule-persona",activeFieldId:M,onActivate:O,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:Bn.optional,children:"(optional — set at creation)"}),i.jsx("span",{className:Bn.readonlyValue,"data-testid":"schedule-detail-workspace",children:((H=r.find(B=>B.id===t.workspaceId))==null?void 0:H.name)??"System-level (no workspace)"})]})]}),i.jsxs("div",{className:Bn.metaSection,children:[t.lastRunAt?i.jsxs("span",{children:["Last run: ",sm(t.lastRunAt)]}):i.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?i.jsxs("span",{children:["Next run: ",P1(t.nextRunAt)]}):null,t.runCount>0&&i.jsxs("span",{children:["Total runs: ",t.runCount]}),i.jsxs("span",{children:["Created: ",sm(t.createdAt)]})]})]}):null,i.jsx(ys,{isOpen:R,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:ae,onCancel:()=>E(!1)})]})}function ZU(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=Z1();return i.jsx(wB,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function YU(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await $e.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function JU(){const{connectionStatus:t,environments:{environments:s},sessions:{sessions:o}}=ut(),r=YU();return i.jsxs(i.Fragment,{children:[r&&i.jsx(LO,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),i.jsx(EB,{connectionStatus:t,environments:s,sessions:o})]})}function WU(){return i.jsx(b8,{})}function XU(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=ut();return i.jsx(VL,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const m_=Ai();function QU(){const t=vt();return Ga({key:"?"},()=>{t(PN)}),Ga({key:"n"},()=>{t(m_)}),Ga({key:"N"},()=>{t(m_)}),i.jsx(i.Fragment,{})}function Ed(t){const s=l$();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function eV(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=ut(),o=y.useMemo(()=>i.jsx(pO,{workspaces:t,tasks:s}),[t,s]);return Ed(o),i.jsx(Ei,{})}function tV(){const{environments:{environments:t}}=ut(),s=y.useMemo(()=>i.jsx(II,{environments:t}),[t]);return Ed(s),i.jsx(Ei,{})}function nV(){const t=y.useMemo(()=>i.jsx(m7,{}),[]);return Ed(t),i.jsx(Ei,{})}function sV(){const{knowledge:t,workspaces:{workspaces:s}}=ut(),o=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>i.jsx(V5,{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 Ed(u),i.jsx(Ei,{})}const aV="_wizard_1260s_1",iV="_container_1260s_10",oV="_stepContent_1260s_19",rV="_logoArea_1260s_28",lV="_logoImage_1260s_32",cV="_heading_1260s_41",dV="_tagline_1260s_49",uV="_subtitle_1260s_56",fV="_featureList_1260s_64",pV="_runtimeGrid_1260s_89",mV="_runtimeCard_1260s_101",hV="_runtimeName_1260s_133",gV="_runtimeDescription_1260s_139",vV="_buttonRow_1260s_144",yV="_primaryButton_1260s_151",bV="_ghostButton_1260s_185",_V="_dots_1260s_213",xV="_dot_1260s_213",We={wizard:aV,container:iV,stepContent:oV,logoArea:rV,logoImage:lV,heading:cV,tagline:dV,subtitle:uV,featureList:fV,runtimeGrid:pV,runtimeCard:mV,runtimeName:hV,runtimeDescription:gV,buttonRow:vV,primaryButton:yV,ghostButton:bV,dots:_V,dot:xV};function kV({onNext:t}){return i.jsxs("div",{className:We.stepContent,"data-testid":"setup-welcome",children:[i.jsx("div",{className:We.logoArea,children:i.jsx("img",{src:wd("grackle-logo.png"),alt:"Grackle",className:We.logoImage})}),i.jsx("h1",{className:We.heading,children:"Welcome to Grackle"}),i.jsx("p",{className:We.tagline,children:"Multi-agent orchestration for software teams"}),i.jsx("button",{type:"button",className:We.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function SV({onNext:t,onBack:s}){return i.jsxs("div",{className:We.stepContent,"data-testid":"setup-about",children:[i.jsx("h2",{className:We.heading,children:"What is Grackle?"}),i.jsxs("ul",{className:We.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:We.buttonRow,children:[i.jsx("button",{type:"button",className:We.ghostButton,onClick:s,children:"Back"}),i.jsx("button",{type:"button",className:We.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const jV=[{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 TV({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),i.jsxs("div",{className:We.stepContent,"data-testid":"setup-runtime",children:[i.jsx("h2",{className:We.heading,children:"Choose Your Runtime"}),i.jsx("p",{className:We.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),i.jsx("div",{className:We.runtimeGrid,children:jV.map(u=>i.jsxs("button",{type:"button",className:We.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:We.runtimeName,children:u.name}),i.jsx("span",{className:We.runtimeDescription,children:u.description})]},u.id))}),i.jsxs("div",{className:We.buttonRow,children:[i.jsx("button",{type:"button",className:We.ghostButton,onClick:o,children:"Back"}),i.jsx("button",{type:"button",className:We.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function wV(){return typeof Notification<"u"}function NV({onFinish:t,onBack:s,finishDisabled:o}){const r=wV(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return i.jsxs("div",{className:We.stepContent,"data-testid":"setup-notifications",children:[i.jsx("h2",{className:We.heading,children:"Stay in the Loop"}),i.jsx("p",{className:We.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:We.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:We.buttonRow,children:[i.jsx("button",{type:"button",className:We.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:We.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),i.jsx("button",{type:"button",className:We.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):i.jsx("button",{type:"button",className:We.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const CV=4,h_={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function EV(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=ut(),{showToast:c}=pn(),d=vt(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,b]=y.useState(!1),_=t.find(j=>j.id==="claude-code"),k=y.useCallback(j=>{g(j),p(3)},[]),S=y.useCallback(()=>{const j=m;b(!0);const T=[];if(_&&j!==_.runtime){const C=h_[j]??"sonnet";T.push(s(_.id,void 0,void 0,void 0,j,C))}const w=t.find(C=>C.id===ny);if(w&&j!==w.runtime){const C=h_[j]??"sonnet";T.push(s(ny,void 0,void 0,void 0,j,C))}Promise.all(T).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,_,t,s,o,d,c]);return r===!0?i.jsx(zn,{to:"/",replace:!0}):i.jsx("div",{className:We.wizard,"data-testid":"setup-wizard",children:i.jsxs("div",{className:We.container,children:[i.jsx(as,{mode:"wait",children:i.jsxs($t.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(kV,{onNext:()=>p(1)}),u===1&&i.jsx(SV,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&i.jsx(TV,{currentRuntime:m,onFinish:k,onBack:()=>p(1),finishDisabled:!_}),u===3&&i.jsx(NV,{onFinish:S,onBack:()=>p(2),finishDisabled:v})]},u)}),i.jsx("div",{className:We.dots,children:Array.from({length:CV},(j,T)=>i.jsx("span",{className:We.dot,"data-active":T===u},T))})]})})}const AV="_root_zndgp_1",DV="_body_zndgp_7",MV="_main_zndgp_19",RV="_sidebarWrapper_zndgp_26",IV="_overlay_zndgp_51",Gr={root:AV,body:DV,main:MV,sidebarWrapper:RV,overlay:IV},OV=y.lazy(()=>__(()=>import("./KnowledgePage-CeXH3fcj.js"),__vite__mapDeps([2,1,3,4,5])).then(t=>({default:t.KnowledgePage}))),ok=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function BV({tabs:t}){const{connectionStatus:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=ut(),{toasts:d,dismissToast:u}=pn(),p=Jt(),m=r$(),g=m!==void 0,[v,b]=y.useState(!1),_=y.useCallback(()=>b(k=>!k),[]);return y.useEffect(()=>{b(!1)},[p.pathname]),y.useEffect(()=>{if(!v)return;const k=S=>{S.key==="Escape"&&b(!1)};return document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[v]),i.jsxs(i.Fragment,{children:[i.jsx(nI,{connectionStatus:s,environments:o,sessions:r,onToggleSidebar:g?_:void 0,sidebarOpen:v}),i.jsx(dI,{tabs:t}),i.jsxs("div",{className:Gr.body,children:[g&&i.jsx("div",{className:Gr.sidebarWrapper,"data-sidebar-open":v,children:i.jsx(gI,{content:m})}),g&&v&&i.jsx("div",{className:Gr.overlay,"data-testid":"drawer-overlay",onClick:()=>b(!1)}),i.jsxs("div",{className:Gr.main,children:[i.jsx(Ei,{}),i.jsx(jI,{sessions:r,tasks:c,environments:o})]})]}),i.jsx(wO,{toasts:d,onDismiss:u}),i.jsx(QU,{})]})}function LV(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connectionStatus:d,onboardingCompleted:u}=ut(),{pluginNames:p}=Cd(),{showToast:m}=pn();g9(s,m),x9(c,m),v9(o,r,m);const g=vt(),v=Jt();if(y.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(xm(t),{replace:!0})},[t,g,v.pathname]),d==="connected"&&u===!1)return i.jsx(zn,{to:"/setup",replace:!0});const b=H$(p);return i.jsx(o$,{children:i.jsxs("div",{className:Gr.root,children:[ok&&i.jsx(gC,{}),i.jsx(BV,{tabs:b})]})})}function Ap(){const{workspaceId:t}=ua(),{workspaces:{workspaces:s}}=ut(),o=Jt(),r=s.find(g=>g.id===t),c=r!=null&&r.linkedEnvironmentIds?[...r.linkedEnvironmentIds].sort()[0]:void 0;if(!c)return s.length===0?void 0:i.jsx(zn,{to:"/environments",replace:!0});const d=encodeURIComponent(t),u=`/workspaces/${d}`,p=o.pathname.startsWith(u)?o.pathname.slice(u.length):"",m=`/environments/${encodeURIComponent(c)}/workspaces/${d}${p}${o.search}${o.hash}`;return i.jsx(zn,{to:m,replace:!0})}function zV(){const{pluginNames:t}=Cd(),s=t.includes("orchestration"),o=t.includes("knowledge");return i.jsxs(tN,{children:[i.jsx(Ee,{path:"setup",element:i.jsx(EV,{})}),i.jsxs(Ee,{element:i.jsx(LV,{}),children:[i.jsx(Ee,{index:!0,element:i.jsx(iP,{})}),i.jsx(Ee,{path:"sessions/new",element:i.jsx(bP,{})}),i.jsx(Ee,{path:"chat",element:i.jsx(hP,{})}),i.jsx(Ee,{path:"chat/:streamId",element:i.jsx(zn,{to:"/coordination",replace:!0})}),i.jsx(Ee,{path:"coordination",element:i.jsx(yP,{})}),i.jsx(Ee,{path:"sessions/:sessionId",element:i.jsx(SP,{})}),o&&i.jsx(Ee,{element:i.jsx(sV,{}),children:i.jsx(Ee,{path:"knowledge",element:i.jsx(y.Suspense,{fallback:i.jsx(N1,{}),children:i.jsx(OV,{})})})}),s&&i.jsxs(Ee,{element:i.jsx(eV,{}),children:[i.jsx(Ee,{path:"tasks",element:i.jsx(sP,{})}),i.jsx(Ee,{path:"tasks/new",element:i.jsx(c_,{})}),i.jsx(Ee,{path:"tasks/:taskId",element:i.jsx(To,{})}),i.jsx(Ee,{path:"tasks/:taskId/edit",element:i.jsx(To,{})}),i.jsx(Ee,{path:"tasks/:taskId/stream",element:i.jsx(To,{})})]}),i.jsxs(Ee,{element:i.jsx(tV,{}),children:[i.jsx(Ee,{path:"workspaces",element:i.jsx(zn,{to:"/environments",replace:!0})}),i.jsx(Ee,{path:"workspaces/new",element:i.jsx(zP,{})}),i.jsx(Ee,{path:"workspaces/:workspaceId",element:i.jsx(Ap,{})}),i.jsx(Ee,{path:"workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Ap,{})}),i.jsx(Ee,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:i.jsx(Ap,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId",element:i.jsx(NP,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:i.jsx(c_,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:i.jsx(To,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:i.jsx(To,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:i.jsx(To,{})}),i.jsxs(Ee,{path:"environments",element:i.jsx(GP,{}),children:[i.jsx(Ee,{index:!0,element:i.jsx(aP,{})}),i.jsx(Ee,{path:"new",element:i.jsx(HP,{})}),i.jsx(Ee,{path:":environmentId",element:i.jsx(xU,{})}),i.jsx(Ee,{path:":environmentId/edit",element:i.jsx(PP,{})})]})]}),i.jsx(Ee,{element:i.jsx(nV,{}),children:i.jsxs(Ee,{path:"settings",element:i.jsx(jU,{}),children:[i.jsx(Ee,{index:!0,element:i.jsx(zn,{to:"credentials",replace:!0})}),i.jsx(Ee,{path:"environments",element:i.jsx(zn,{to:"/environments",replace:!0})}),i.jsx(Ee,{path:"credentials",element:i.jsx(TU,{})}),i.jsx(Ee,{path:"github-accounts",element:i.jsx(wU,{})}),i.jsx(Ee,{path:"tokens",element:i.jsx(zn,{to:"../credentials",replace:!0})}),i.jsx(Ee,{path:"personas",element:i.jsx(NU,{})}),i.jsx(Ee,{path:"personas/new",element:i.jsx(f_,{})}),i.jsx(Ee,{path:"personas/:personaId",element:i.jsx(f_,{})}),i.jsx(Ee,{path:"schedules",element:i.jsx(zU,{})}),i.jsx(Ee,{path:"schedules/new",element:i.jsx(p_,{})}),i.jsx(Ee,{path:"schedules/:scheduleId",element:i.jsx(p_,{})}),i.jsx(Ee,{path:"appearance",element:i.jsx(ZU,{})}),i.jsx(Ee,{path:"shortcuts",element:i.jsx(WU,{})}),i.jsx(Ee,{path:"plugins",element:i.jsx(XU,{})}),i.jsx(Ee,{path:"about",element:i.jsx(JU,{})})]})}),i.jsx(Ee,{path:"*",element:i.jsx(zn,{to:"/",replace:!0})})]})]})}const $V=1e4;function HV(){const{onboardingCompleted:t}=ut(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),$V);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return i.jsx(as,{mode:"wait",children:r?i.jsx($t.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:i.jsx(N1,{})},"splash"):i.jsx($t.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:i.jsx(wN,{basename:"/".replace(/\/$/,""),children:i.jsx(zV,{})})},"app")})}function PV(){const t=ok?R$:h9;return i.jsx(B$,{children:i.jsx(i$,{children:i.jsx(t$,{children:i.jsx(t,{children:i.jsx(HV,{})})})})})}K2.createRoot(document.getElementById("root")).render(i.jsx(y.StrictMode,{children:i.jsx(PV,{})}));export{fa as B,Z_ as K,ut as a,xm as s,os as t,vt as u};
755
+ $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),M==="agent"&&i.jsxs("div",{children:[i.jsx("label",{children:"Allowed MCP Tools"}),i.jsx(Yb,{selectedTools:Y,onChange:ue=>{V(ue),_e(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ue),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!ke&&!me&&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(ys,{isOpen:ee,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:yt,onCancel:()=>le(!1)})]})}function zU(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=ut(),{showToast:c}=pn(),d=vt();return i.jsx(c7,{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(HN),onNavigateToSchedule:u=>d(G_(u))})}const $U="_container_1g4qh_1",HU="_form_1g4qh_7",PU="_formActions_1g4qh_66",UU="_editableSection_1g4qh_73",VU="_helperText_1g4qh_84",qU="_metaSection_1g4qh_90",GU="_optional_1g4qh_108",FU="_readonlyValue_1g4qh_113",Bn={container:$U,form:HU,formActions:PU,editableSection:UU,helperText:VU,metaSection:qU,optional:GU,readonlyValue:FU};function p_(){const{scheduleId:t}=ua(),s=vt(),{showToast:o}=pn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},workspaces:{workspaces:g}}=ut(),v=t===void 0,b=v?void 0:r.find(k=>k.id===t);if(!v&&!c&&r.length>0&&!b)return i.jsx(zn,{to:Zf,replace:!0});const _=[{label:"Settings",url:xi},{label:"Schedules",url:Zf},{label:v?"New Schedule":(b==null?void 0:b.title)??"Schedule",url:void 0}];return i.jsxs("div",{className:Bn.container,children:[i.jsx(fa,{segments:_}),i.jsx(KU,{existing:b,isNew:v,personas:m,workspaces:g,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(Zf)},showToast:o})]})}function KU({existing:t,isNew:s,personas:o,workspaces:r,onCreateSchedule:c,onUpdateSchedule:d,onDeleteSchedule:u,onDone:p,showToast:m}){var H;const g=vt(),[v,b]=y.useState((t==null?void 0:t.title)??""),[_,k]=y.useState((t==null?void 0:t.description)??""),[S,j]=y.useState((t==null?void 0:t.scheduleExpression)??""),[T,w]=y.useState((t==null?void 0:t.personaId)??""),[C,D]=y.useState((t==null?void 0:t.workspaceId)??""),[R,E]=y.useState(!1),[M,O]=y.useState(null);y.useEffect(()=>{s||t&&M===null&&(b(t.title),k(t.description),j(t.scheduleExpression),w(t.personaId),D(t.workspaceId))},[s,t,M]);const A=!s&&t===void 0,$=s&&v.trim().length>0&&S.trim().length>0&&T.length>0,Y=o.map(B=>({value:B.id,label:B.name})),V=[{value:"",label:"System-level (no workspace)"},...r.map(B=>({value:B.id,label:B.name}))],ee=B=>{B.preventDefault(),$&&c(v,_,S,T,C||void 0).then(F=>{m("Schedule created","success"),g(G_(F.id),{replace:!0})},()=>{m("Failed to create schedule","error")})},le=(B,F)=>{t&&d(t.id,{[B]:F}).then(()=>{m("Schedule updated","success"),B==="title"&&b(String(F)),B==="description"&&k(String(F)),B==="scheduleExpression"&&j(String(F)),B==="personaId"&&w(String(F))},()=>{m("Failed to update schedule","error")})},Z=()=>{if(!t)return;const B=!t.enabled;d(t.id,{enabled:B}).then(()=>{m(B?"Schedule enabled":"Schedule disabled","success")},()=>{m("Failed to update schedule","error")})},ae=()=>{t&&u(t.id).then(()=>{m("Schedule deleted","success"),p()},()=>{m("Failed to delete schedule","error")})};return i.jsxs(i.Fragment,{children:[A?i.jsxs("div",{className:Bn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsx("p",{children:"Loading schedule..."})]}):s?i.jsxs("form",{onSubmit:ee,className:Bn.form,children:[i.jsx("h3",{children:"Create Schedule"}),i.jsxs("label",{children:["Title",i.jsx("input",{type:"text",value:v,onChange:B=>b(B.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description ",i.jsx("span",{className:Bn.optional,children:"(optional)"}),i.jsx("input",{type:"text",value:_,onChange:B=>k(B.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx("input",{type:"text",value:S,onChange:B=>j(B.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),i.jsxs("p",{className:Bn.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:B=>w(B.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[i.jsx("option",{value:"",children:"Select a persona..."}),Y.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))]})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:Bn.optional,children:"(optional)"}),i.jsx("select",{value:C,onChange:B=>D(B.target.value),"data-testid":"schedule-detail-workspace",children:V.map(B=>i.jsx("option",{value:B.value,children:B.label},B.value))})]}),i.jsxs("div",{className:Bn.formActions,children:[i.jsx(sn,{type:"submit",variant:"primary",size:"md",disabled:!$,"data-testid":"schedule-detail-save",children:"Create"}),i.jsx(sn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?i.jsxs("div",{className:Bn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsxs("div",{className:Bn.formActions,children:[i.jsx(sn,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),i.jsx(sn,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:Z,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),i.jsx(sn,{type:"button",variant:"danger",size:"md",onClick:()=>E(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),i.jsxs("div",{className:Bn.editableSection,children:[i.jsxs("label",{children:["Title",i.jsx(Bt,{value:v,onSave:B=>{le("title",B)},validate:B=>B.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:M,onActivate:O,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description",i.jsx(Bt,{value:_,onSave:B=>{le("description",B)},fieldId:"schedule-description",activeFieldId:M,onActivate:O,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx(Bt,{value:S,onSave:B=>{le("scheduleExpression",B)},validate:B=>B.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:M,onActivate:O,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(ud,{value:T,onSave:B=>{le("personaId",B)},options:Y,fieldId:"schedule-persona",activeFieldId:M,onActivate:O,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:Bn.optional,children:"(optional — set at creation)"}),i.jsx("span",{className:Bn.readonlyValue,"data-testid":"schedule-detail-workspace",children:((H=r.find(B=>B.id===t.workspaceId))==null?void 0:H.name)??"System-level (no workspace)"})]})]}),i.jsxs("div",{className:Bn.metaSection,children:[t.lastRunAt?i.jsxs("span",{children:["Last run: ",sm(t.lastRunAt)]}):i.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?i.jsxs("span",{children:["Next run: ",P1(t.nextRunAt)]}):null,t.runCount>0&&i.jsxs("span",{children:["Total runs: ",t.runCount]}),i.jsxs("span",{children:["Created: ",sm(t.createdAt)]})]})]}):null,i.jsx(ys,{isOpen:R,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:ae,onCancel:()=>E(!1)})]})}function ZU(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=Z1();return i.jsx(wB,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function YU(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await $e.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function JU(){const{connectionStatus:t,environments:{environments:s},sessions:{sessions:o}}=ut(),r=YU();return i.jsxs(i.Fragment,{children:[r&&i.jsx(LO,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),i.jsx(EB,{connectionStatus:t,environments:s,sessions:o})]})}function WU(){return i.jsx(b8,{})}function XU(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=ut();return i.jsx(VL,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const m_=Ai();function QU(){const t=vt();return Ga({key:"?"},()=>{t(PN)}),Ga({key:"n"},()=>{t(m_)}),Ga({key:"N"},()=>{t(m_)}),i.jsx(i.Fragment,{})}function Ed(t){const s=l$();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function eV(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=ut(),o=y.useMemo(()=>i.jsx(pO,{workspaces:t,tasks:s}),[t,s]);return Ed(o),i.jsx(Ei,{})}function tV(){const{environments:{environments:t}}=ut(),s=y.useMemo(()=>i.jsx(II,{environments:t}),[t]);return Ed(s),i.jsx(Ei,{})}function nV(){const t=y.useMemo(()=>i.jsx(m7,{}),[]);return Ed(t),i.jsx(Ei,{})}function sV(){const{knowledge:t,workspaces:{workspaces:s}}=ut(),o=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>i.jsx(V5,{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 Ed(u),i.jsx(Ei,{})}const aV="_wizard_1260s_1",iV="_container_1260s_10",oV="_stepContent_1260s_19",rV="_logoArea_1260s_28",lV="_logoImage_1260s_32",cV="_heading_1260s_41",dV="_tagline_1260s_49",uV="_subtitle_1260s_56",fV="_featureList_1260s_64",pV="_runtimeGrid_1260s_89",mV="_runtimeCard_1260s_101",hV="_runtimeName_1260s_133",gV="_runtimeDescription_1260s_139",vV="_buttonRow_1260s_144",yV="_primaryButton_1260s_151",bV="_ghostButton_1260s_185",_V="_dots_1260s_213",xV="_dot_1260s_213",We={wizard:aV,container:iV,stepContent:oV,logoArea:rV,logoImage:lV,heading:cV,tagline:dV,subtitle:uV,featureList:fV,runtimeGrid:pV,runtimeCard:mV,runtimeName:hV,runtimeDescription:gV,buttonRow:vV,primaryButton:yV,ghostButton:bV,dots:_V,dot:xV};function kV({onNext:t}){return i.jsxs("div",{className:We.stepContent,"data-testid":"setup-welcome",children:[i.jsx("div",{className:We.logoArea,children:i.jsx("img",{src:wd("grackle-logo.png"),alt:"Grackle",className:We.logoImage})}),i.jsx("h1",{className:We.heading,children:"Welcome to Grackle"}),i.jsx("p",{className:We.tagline,children:"Multi-agent orchestration for software teams"}),i.jsx("button",{type:"button",className:We.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function SV({onNext:t,onBack:s}){return i.jsxs("div",{className:We.stepContent,"data-testid":"setup-about",children:[i.jsx("h2",{className:We.heading,children:"What is Grackle?"}),i.jsxs("ul",{className:We.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:We.buttonRow,children:[i.jsx("button",{type:"button",className:We.ghostButton,onClick:s,children:"Back"}),i.jsx("button",{type:"button",className:We.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const jV=[{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 TV({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),i.jsxs("div",{className:We.stepContent,"data-testid":"setup-runtime",children:[i.jsx("h2",{className:We.heading,children:"Choose Your Runtime"}),i.jsx("p",{className:We.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),i.jsx("div",{className:We.runtimeGrid,children:jV.map(u=>i.jsxs("button",{type:"button",className:We.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:We.runtimeName,children:u.name}),i.jsx("span",{className:We.runtimeDescription,children:u.description})]},u.id))}),i.jsxs("div",{className:We.buttonRow,children:[i.jsx("button",{type:"button",className:We.ghostButton,onClick:o,children:"Back"}),i.jsx("button",{type:"button",className:We.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function wV(){return typeof Notification<"u"}function NV({onFinish:t,onBack:s,finishDisabled:o}){const r=wV(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return i.jsxs("div",{className:We.stepContent,"data-testid":"setup-notifications",children:[i.jsx("h2",{className:We.heading,children:"Stay in the Loop"}),i.jsx("p",{className:We.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:We.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:We.buttonRow,children:[i.jsx("button",{type:"button",className:We.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:We.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),i.jsx("button",{type:"button",className:We.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):i.jsx("button",{type:"button",className:We.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const CV=4,h_={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function EV(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=ut(),{showToast:c}=pn(),d=vt(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,b]=y.useState(!1),_=t.find(j=>j.id==="claude-code"),k=y.useCallback(j=>{g(j),p(3)},[]),S=y.useCallback(()=>{const j=m;b(!0);const T=[];if(_&&j!==_.runtime){const C=h_[j]??"sonnet";T.push(s(_.id,void 0,void 0,void 0,j,C))}const w=t.find(C=>C.id===ny);if(w&&j!==w.runtime){const C=h_[j]??"sonnet";T.push(s(ny,void 0,void 0,void 0,j,C))}Promise.all(T).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,_,t,s,o,d,c]);return r===!0?i.jsx(zn,{to:"/",replace:!0}):i.jsx("div",{className:We.wizard,"data-testid":"setup-wizard",children:i.jsxs("div",{className:We.container,children:[i.jsx(as,{mode:"wait",children:i.jsxs($t.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(kV,{onNext:()=>p(1)}),u===1&&i.jsx(SV,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&i.jsx(TV,{currentRuntime:m,onFinish:k,onBack:()=>p(1),finishDisabled:!_}),u===3&&i.jsx(NV,{onFinish:S,onBack:()=>p(2),finishDisabled:v})]},u)}),i.jsx("div",{className:We.dots,children:Array.from({length:CV},(j,T)=>i.jsx("span",{className:We.dot,"data-active":T===u},T))})]})})}const AV="_root_zndgp_1",DV="_body_zndgp_7",MV="_main_zndgp_19",RV="_sidebarWrapper_zndgp_26",IV="_overlay_zndgp_51",Gr={root:AV,body:DV,main:MV,sidebarWrapper:RV,overlay:IV},OV=y.lazy(()=>__(()=>import("./KnowledgePage-CZ_d8wQh.js"),__vite__mapDeps([2,1,3,4,5])).then(t=>({default:t.KnowledgePage}))),ok=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function BV({tabs:t}){const{connectionStatus:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=ut(),{toasts:d,dismissToast:u}=pn(),p=Jt(),m=r$(),g=m!==void 0,[v,b]=y.useState(!1),_=y.useCallback(()=>b(k=>!k),[]);return y.useEffect(()=>{b(!1)},[p.pathname]),y.useEffect(()=>{if(!v)return;const k=S=>{S.key==="Escape"&&b(!1)};return document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[v]),i.jsxs(i.Fragment,{children:[i.jsx(nI,{connectionStatus:s,environments:o,sessions:r,onToggleSidebar:g?_:void 0,sidebarOpen:v}),i.jsx(dI,{tabs:t}),i.jsxs("div",{className:Gr.body,children:[g&&i.jsx("div",{className:Gr.sidebarWrapper,"data-sidebar-open":v,children:i.jsx(gI,{content:m})}),g&&v&&i.jsx("div",{className:Gr.overlay,"data-testid":"drawer-overlay",onClick:()=>b(!1)}),i.jsxs("div",{className:Gr.main,children:[i.jsx(Ei,{}),i.jsx(jI,{sessions:r,tasks:c,environments:o})]})]}),i.jsx(wO,{toasts:d,onDismiss:u}),i.jsx(QU,{})]})}function LV(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connectionStatus:d,onboardingCompleted:u}=ut(),{pluginNames:p}=Cd(),{showToast:m}=pn();g9(s,m),x9(c,m),v9(o,r,m);const g=vt(),v=Jt();if(y.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(xm(t),{replace:!0})},[t,g,v.pathname]),d==="connected"&&u===!1)return i.jsx(zn,{to:"/setup",replace:!0});const b=H$(p);return i.jsx(o$,{children:i.jsxs("div",{className:Gr.root,children:[ok&&i.jsx(gC,{}),i.jsx(BV,{tabs:b})]})})}function Ap(){const{workspaceId:t}=ua(),{workspaces:{workspaces:s}}=ut(),o=Jt(),r=s.find(g=>g.id===t),c=r!=null&&r.linkedEnvironmentIds?[...r.linkedEnvironmentIds].sort()[0]:void 0;if(!c)return s.length===0?void 0:i.jsx(zn,{to:"/environments",replace:!0});const d=encodeURIComponent(t),u=`/workspaces/${d}`,p=o.pathname.startsWith(u)?o.pathname.slice(u.length):"",m=`/environments/${encodeURIComponent(c)}/workspaces/${d}${p}${o.search}${o.hash}`;return i.jsx(zn,{to:m,replace:!0})}function zV(){const{pluginNames:t}=Cd(),s=t.includes("orchestration"),o=t.includes("knowledge");return i.jsxs(tN,{children:[i.jsx(Ee,{path:"setup",element:i.jsx(EV,{})}),i.jsxs(Ee,{element:i.jsx(LV,{}),children:[i.jsx(Ee,{index:!0,element:i.jsx(iP,{})}),i.jsx(Ee,{path:"sessions/new",element:i.jsx(bP,{})}),i.jsx(Ee,{path:"chat",element:i.jsx(hP,{})}),i.jsx(Ee,{path:"chat/:streamId",element:i.jsx(zn,{to:"/coordination",replace:!0})}),i.jsx(Ee,{path:"coordination",element:i.jsx(yP,{})}),i.jsx(Ee,{path:"sessions/:sessionId",element:i.jsx(SP,{})}),o&&i.jsx(Ee,{element:i.jsx(sV,{}),children:i.jsx(Ee,{path:"knowledge",element:i.jsx(y.Suspense,{fallback:i.jsx(N1,{}),children:i.jsx(OV,{})})})}),s&&i.jsxs(Ee,{element:i.jsx(eV,{}),children:[i.jsx(Ee,{path:"tasks",element:i.jsx(sP,{})}),i.jsx(Ee,{path:"tasks/new",element:i.jsx(c_,{})}),i.jsx(Ee,{path:"tasks/:taskId",element:i.jsx(To,{})}),i.jsx(Ee,{path:"tasks/:taskId/edit",element:i.jsx(To,{})}),i.jsx(Ee,{path:"tasks/:taskId/stream",element:i.jsx(To,{})})]}),i.jsxs(Ee,{element:i.jsx(tV,{}),children:[i.jsx(Ee,{path:"workspaces",element:i.jsx(zn,{to:"/environments",replace:!0})}),i.jsx(Ee,{path:"workspaces/new",element:i.jsx(zP,{})}),i.jsx(Ee,{path:"workspaces/:workspaceId",element:i.jsx(Ap,{})}),i.jsx(Ee,{path:"workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Ap,{})}),i.jsx(Ee,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:i.jsx(Ap,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId",element:i.jsx(NP,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:i.jsx(c_,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:i.jsx(To,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:i.jsx(To,{})}),i.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:i.jsx(To,{})}),i.jsxs(Ee,{path:"environments",element:i.jsx(GP,{}),children:[i.jsx(Ee,{index:!0,element:i.jsx(aP,{})}),i.jsx(Ee,{path:"new",element:i.jsx(HP,{})}),i.jsx(Ee,{path:":environmentId",element:i.jsx(xU,{})}),i.jsx(Ee,{path:":environmentId/edit",element:i.jsx(PP,{})})]})]}),i.jsx(Ee,{element:i.jsx(nV,{}),children:i.jsxs(Ee,{path:"settings",element:i.jsx(jU,{}),children:[i.jsx(Ee,{index:!0,element:i.jsx(zn,{to:"credentials",replace:!0})}),i.jsx(Ee,{path:"environments",element:i.jsx(zn,{to:"/environments",replace:!0})}),i.jsx(Ee,{path:"credentials",element:i.jsx(TU,{})}),i.jsx(Ee,{path:"github-accounts",element:i.jsx(wU,{})}),i.jsx(Ee,{path:"tokens",element:i.jsx(zn,{to:"../credentials",replace:!0})}),i.jsx(Ee,{path:"personas",element:i.jsx(NU,{})}),i.jsx(Ee,{path:"personas/new",element:i.jsx(f_,{})}),i.jsx(Ee,{path:"personas/:personaId",element:i.jsx(f_,{})}),i.jsx(Ee,{path:"schedules",element:i.jsx(zU,{})}),i.jsx(Ee,{path:"schedules/new",element:i.jsx(p_,{})}),i.jsx(Ee,{path:"schedules/:scheduleId",element:i.jsx(p_,{})}),i.jsx(Ee,{path:"appearance",element:i.jsx(ZU,{})}),i.jsx(Ee,{path:"shortcuts",element:i.jsx(WU,{})}),i.jsx(Ee,{path:"plugins",element:i.jsx(XU,{})}),i.jsx(Ee,{path:"about",element:i.jsx(JU,{})})]})}),i.jsx(Ee,{path:"*",element:i.jsx(zn,{to:"/",replace:!0})})]})]})}const $V=1e4;function HV(){const{onboardingCompleted:t}=ut(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),$V);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return i.jsx(as,{mode:"wait",children:r?i.jsx($t.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:i.jsx(N1,{})},"splash"):i.jsx($t.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:i.jsx(wN,{basename:"/".replace(/\/$/,""),children:i.jsx(zV,{})})},"app")})}function PV(){const t=ok?R$:h9;return i.jsx(B$,{children:i.jsx(i$,{children:i.jsx(t$,{children:i.jsx(t,{children:i.jsx(HV,{})})})})})}K2.createRoot(document.getElementById("root")).render(i.jsx(y.StrictMode,{children:i.jsx(PV,{})}));export{fa as B,Z_ as K,ut as a,xm as s,os as t,vt as u};