@grackle-ai/web 0.104.0 → 0.105.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-
|
|
2
|
-
import{r as vT,a as yT,b,j as i,d as ry,H as ly,P as cy,i as bT,B as xT,c as _T,C as kT,M as ST,e as TT}from"./dagview-tHPW3Rz3.js";import{c as jT,a as Sd,G as wT,b as NT,d as CT,e as ET,f as AT,M as DT,A as kx,D as Sx,W as RT,O as MT,g as IT,C as Ei,h as Tx,i as jx,w as OT,t as BT,p as Oc,j as LT,R as Lr,S as dy}from"./grpc-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-Dx7P15XQ.js","assets/dagview-tHPW3Rz3.js","assets/grpc-DTzuoFMa.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as vT,a as yT,b,j as i,d as ry,H as ly,P as cy,i as bT,B as xT,c as _T,C as kT,M as ST,e as TT}from"./dagview-tHPW3Rz3.js";import{c as jT,a as Sd,G as wT,b as NT,d as CT,e as ET,f as AT,M as DT,A as kx,D as Sx,W as RT,O as MT,g as IT,C as Ei,h as Tx,i as jx,w as OT,t as BT,p as Oc,j as LT,R as Lr,S as dy}from"./grpc-DTzuoFMa.js";import{v as zT,r as $T,t as Bc,i as PT,f as UT,M as Td,a as jd}from"./markdown-Yr3vTPLR.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const u of d.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function o(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function r(c){if(c.ep)return;c.ep=!0;const d=o(c);fetch(c.href,d)}})();var Kf={exports:{}},zr={},Yf={exports:{}},Jf={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* scheduler.production.js
|
|
5
5
|
*
|
|
@@ -237,7 +237,7 @@ Error generating stack: `+l.message+`
|
|
|
237
237
|
Please change the parent <Route path="${T}"> to <Route path="${T==="/"?"*":`${T}/*`}">.`)}let v=Yt(),x;if(s){let T=typeof s=="string"?Ho(s):s;_t(m==="/"||((N=T.pathname)==null?void 0:N.startsWith(m)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${m}" but pathname "${T.pathname}" was given in the \`location\` prop.`),x=T}else x=v;let y=x.pathname||"/",S=y;if(m!=="/"){let T=m.replace(/^\//,"").split("/");S="/"+y.replace(/^\//,"").split("/").slice(T.length).join("/")}let k=Ax(t,{pathname:S});ns(g||k!=null,`No routes matched location "${x.pathname}${x.search}${x.hash}" `),ns(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.length-1].route.lazy!==void 0,`Matched leaf route at location "${x.pathname}${x.search}${x.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let j=Ew(k&&k.map(T=>Object.assign({},T,{params:Object.assign({},u,T.params),pathname:Cs([m,r.encodeLocation?r.encodeLocation(T.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathname]),pathnameBase:T.pathnameBase==="/"?m:Cs([m,r.encodeLocation?r.encodeLocation(T.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:T.pathnameBase])})),c,o);return s&&j?b.createElement(ml.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...x},navigationType:"POP"}},j):j}function jw(){let t=Iw(),s=dw(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),o=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:r},d={padding:"2px 4px",backgroundColor:r},u=null;return console.error("Error handled by React Router default ErrorBoundary:",t),u=b.createElement(b.Fragment,null,b.createElement("p",null,"💿 Hey developer 👋"),b.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",b.createElement("code",{style:d},"ErrorBoundary")," or"," ",b.createElement("code",{style:d},"errorElement")," prop on your route.")),b.createElement(b.Fragment,null,b.createElement("h2",null,"Unexpected Application Error!"),b.createElement("h3",{style:{fontStyle:"italic"}},s),o?b.createElement("pre",{style:c},o):null,u)}var ww=b.createElement(jw,null),Hx=class extends b.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,s){return s.location!==t.location||s.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:s.error,location:s.location,revalidation:t.revalidation||s.revalidation}}componentDidCatch(t,s){this.props.onError?this.props.onError(t,s):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const o=bw(t.digest);o&&(t=o)}let s=t!==void 0?b.createElement(ss.Provider,{value:this.props.routeContext},b.createElement(_m.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?b.createElement(Nw,{error:t},s):s}};Hx.contextType=pw;var Xf=new WeakMap;function Nw({children:t,error:s}){let{basename:o}=b.useContext(Ln);if(typeof s=="object"&&s&&"digest"in s&&typeof s.digest=="string"){let r=yw(s.digest);if(r){let c=Xf.get(s);if(c)throw c;let d=Ox(r.location,o);if(Ix&&!Xf.get(s))if(d.isExternal||r.reloadDocument)window.location.href=d.absoluteURL||d.to;else{const u=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(d.to,{replace:r.replace}));throw Xf.set(s,u),u}return b.createElement("meta",{httpEquiv:"refresh",content:`0;url=${d.absoluteURL||d.to}`})}}return t}function Cw({routeContext:t,match:s,children:o}){let r=b.useContext(Vo);return r&&r.static&&r.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=s.route.id),b.createElement(ss.Provider,{value:t},o)}function Ew(t,s=[],o){let r=o==null?void 0:o.state;if(t==null){if(!r)return null;if(r.errors)t=r.matches;else if(s.length===0&&!r.initialized&&r.matches.length>0)t=r.matches;else return null}let c=t,d=r==null?void 0:r.errors;if(d!=null){let v=c.findIndex(x=>x.route.id&&(d==null?void 0:d[x.route.id])!==void 0);_t(v>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(d).join(",")}`),c=c.slice(0,Math.min(c.length,v+1))}let u=!1,p=-1;if(o&&r){u=r.renderFallback;for(let v=0;v<c.length;v++){let x=c[v];if((x.route.HydrateFallback||x.route.hydrateFallbackElement)&&(p=v),x.route.id){let{loaderData:y,errors:S}=r,k=x.route.loader&&!y.hasOwnProperty(x.route.id)&&(!S||S[x.route.id]===void 0);if(x.route.lazy||k){o.isStatic&&(u=!0),p>=0?c=c.slice(0,p+1):c=[c[0]];break}}}}let m=o==null?void 0:o.onError,g=r&&m?(v,x)=>{var y,S;m(v,{location:r.location,params:((S=(y=r.matches)==null?void 0:y[0])==null?void 0:S.params)??{},unstable_pattern:uw(r.matches),errorInfo:x})}:void 0;return c.reduceRight((v,x,y)=>{let S,k=!1,j=null,N=null;r&&(S=d&&x.route.id?d[x.route.id]:void 0,j=x.route.errorElement||ww,u&&(p<0&&y===0?(Vx("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,N=null):p===y&&(k=!0,N=x.route.hydrateFallbackElement||null)));let T=s.concat(c.slice(0,y+1)),C=()=>{let A;return S?A=j:k?A=N:x.route.Component?A=b.createElement(x.route.Component,null):x.route.element?A=x.route.element:A=v,b.createElement(Cw,{match:x,routeContext:{outlet:v,matches:T,isDataRoute:r!=null},children:A})};return r&&(x.route.ErrorBoundary||x.route.errorElement||y===0)?b.createElement(Hx,{location:r.location,revalidation:r.revalidation,component:j,error:S,children:C(),routeContext:{outlet:null,matches:T,isDataRoute:!0},onError:g}):C()},null)}function km(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Aw(t){let s=b.useContext(Vo);return _t(s,km(t)),s}function Dw(t){let s=b.useContext(Cd);return _t(s,km(t)),s}function Rw(t){let s=b.useContext(ss);return _t(s,km(t)),s}function Sm(t){let s=Rw(t),o=s.matches[s.matches.length-1];return _t(o.route.id,`${t} can only be used on routes that contain a unique "id"`),o.route.id}function Mw(){return Sm("useRouteId")}function Iw(){var r;let t=b.useContext(_m),s=Dw("useRouteError"),o=Sm("useRouteError");return t!==void 0?t:(r=s.errors)==null?void 0:r[o]}function Ow(){let{router:t}=Aw("useNavigate"),s=Sm("useNavigate"),o=b.useRef(!1);return Px(()=>{o.current=!0}),b.useCallback(async(c,d={})=>{ns(o.current,$x),o.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:s,...d}))},[t,s])}var wy={};function Vx(t,s,o){!s&&!wy[t]&&(wy[t]=!0,ns(!1,o))}b.memo(Bw);function Bw({routes:t,future:s,state:o,isStatic:r,onError:c}){return Ux(t,void 0,{state:o,isStatic:r,onError:c})}function ts({to:t,replace:s,state:o,relative:r}){_t(Mi(),"<Navigate> may be used only in the context of a <Router> component.");let{static:c}=b.useContext(Ln);ns(!c,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:d}=b.useContext(ss),{pathname:u}=Yt(),p=Ed(),m=Nd(t,xm(d),u,r==="path"),g=JSON.stringify(m);return b.useEffect(()=>{p(JSON.parse(g),{replace:s,state:o,relative:r})},[p,g,r,s,o]),null}function Ya(t){return Sw(t.context)}function Ne(t){_t(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Lw({basename:t="/",children:s=null,location:o,navigationType:r="POP",navigator:c,static:d=!1,unstable_useTransitions:u}){_t(!Mi(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let p=t.replace(/^\/*/,"/"),m=b.useMemo(()=>({basename:p,navigator:c,static:d,unstable_useTransitions:u,future:{}}),[p,c,d,u]);typeof o=="string"&&(o=Ho(o));let{pathname:g="/",search:v="",hash:x="",state:y=null,key:S="default",unstable_mask:k}=o,j=b.useMemo(()=>{let N=aa(g,p);return N==null?null:{location:{pathname:N,search:v,hash:x,state:y,key:S,unstable_mask:k},navigationType:r}},[p,g,v,x,y,S,r,k]);return ns(j!=null,`<Router basename="${p}"> is not able to match the URL "${g}${v}${x}" because it does not start with the basename, so the <Router> won't render anything.`),j==null?null:b.createElement(Ln.Provider,{value:m},b.createElement(ml.Provider,{children:s,value:j}))}function zw({children:t,location:s}){return Tw(Vp(t),s)}function Vp(t,s=[]){let o=[];return b.Children.forEach(t,(r,c)=>{if(!b.isValidElement(r))return;let d=[...s,c];if(r.type===b.Fragment){o.push.apply(o,Vp(r.props.children,d));return}_t(r.type===Ne,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),_t(!r.props.index||!r.props.children,"An index route cannot have child routes.");let u={id:r.props.id||d.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(u.children=Vp(r.props.children,d)),o.push(u)}),o}var ed="get",td="application/x-www-form-urlencoded";function Ad(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function $w(t){return Ad(t)&&t.tagName.toLowerCase()==="button"}function Pw(t){return Ad(t)&&t.tagName.toLowerCase()==="form"}function Uw(t){return Ad(t)&&t.tagName.toLowerCase()==="input"}function Hw(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Vw(t,s){return t.button===0&&(!s||s==="_self")&&!Hw(t)}function qp(t=""){return new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((s,o)=>{let r=t[o];return s.concat(Array.isArray(r)?r.map(c=>[o,c]):[[o,r]])},[]))}function qw(t,s){let o=qp(t);return s&&s.forEach((r,c)=>{o.has(c)||s.getAll(c).forEach(d=>{o.append(c,d)})}),o}var $c=null;function Gw(){if($c===null)try{new FormData(document.createElement("form"),0),$c=!1}catch{$c=!0}return $c}var Fw=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Qf(t){return t!=null&&!Fw.has(t)?(ns(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${td}"`),null):t}function Zw(t,s){let o,r,c,d,u;if(Pw(t)){let p=t.getAttribute("action");r=p?aa(p,s):null,o=t.getAttribute("method")||ed,c=Qf(t.getAttribute("enctype"))||td,d=new FormData(t)}else if($w(t)||Uw(t)&&(t.type==="submit"||t.type==="image")){let p=t.form;if(p==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let m=t.getAttribute("formaction")||p.getAttribute("action");if(r=m?aa(m,s):null,o=t.getAttribute("formmethod")||p.getAttribute("method")||ed,c=Qf(t.getAttribute("formenctype"))||Qf(p.getAttribute("enctype"))||td,d=new FormData(p,t),!Gw()){let{name:g,type:v,value:x}=t;if(v==="image"){let y=g?`${g}.`:"";d.append(`${y}x`,"0"),d.append(`${y}y`,"0")}else g&&d.append(g,x)}}else{if(Ad(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');o=ed,r=null,c=td,u=t}return d&&c==="text/plain"&&(u=d,d=void 0),{action:r,method:o.toLowerCase(),encType:c,formData:d,body:u}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Tm(t,s){if(t===!1||t===null||typeof t>"u")throw new Error(s)}function Kw(t,s,o,r){let c=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return o?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${r}`:c.pathname=`${c.pathname}.${r}`:c.pathname==="/"?c.pathname=`_root.${r}`:s&&aa(c.pathname,s)==="/"?c.pathname=`${s.replace(/\/$/,"")}/_root.${r}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${r}`,c}async function Yw(t,s){if(t.id in s)return s[t.id];try{let o=await import(t.module);return s[t.id]=o,o}catch(o){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(o),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Jw(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function Ww(t,s,o){let r=await Promise.all(t.map(async c=>{let d=s.routes[c.route.id];if(d){let u=await Yw(d,o);return u.links?u.links():[]}return[]}));return tN(r.flat(1).filter(Jw).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function Ny(t,s,o,r,c,d){let u=(m,g)=>o[g]?m.route.id!==o[g].route.id:!0,p=(m,g)=>{var v;return o[g].pathname!==m.pathname||((v=o[g].route.path)==null?void 0:v.endsWith("*"))&&o[g].params["*"]!==m.params["*"]};return d==="assets"?s.filter((m,g)=>u(m,g)||p(m,g)):d==="data"?s.filter((m,g)=>{var x;let v=r.routes[m.route.id];if(!v||!v.hasLoader)return!1;if(u(m,g)||p(m,g))return!0;if(m.route.shouldRevalidate){let y=m.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((x=o[0])==null?void 0:x.params)||{},nextUrl:new URL(t,window.origin),nextParams:m.params,defaultShouldRevalidate:!0});if(typeof y=="boolean")return y}return!0}):[]}function Xw(t,s,{includeHydrateFallback:o}={}){return Qw(t.map(r=>{let c=s.routes[r.route.id];if(!c)return[];let d=[c.module];return c.clientActionModule&&(d=d.concat(c.clientActionModule)),c.clientLoaderModule&&(d=d.concat(c.clientLoaderModule)),o&&c.hydrateFallbackModule&&(d=d.concat(c.hydrateFallbackModule)),c.imports&&(d=d.concat(c.imports)),d}).flat(1))}function Qw(t){return[...new Set(t)]}function eN(t){let s={},o=Object.keys(t).sort();for(let r of o)s[r]=t[r];return s}function tN(t,s){let o=new Set;return new Set(s),t.reduce((r,c)=>{let d=JSON.stringify(eN(c));return o.has(d)||(o.add(d),r.push({key:d,link:c})),r},[])}function qx(){let t=b.useContext(Vo);return Tm(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function nN(){let t=b.useContext(Cd);return Tm(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var jm=b.createContext(void 0);jm.displayName="FrameworkContext";function Gx(){let t=b.useContext(jm);return Tm(t,"You must render this element inside a <HydratedRouter> element"),t}function sN(t,s){let o=b.useContext(jm),[r,c]=b.useState(!1),[d,u]=b.useState(!1),{onFocus:p,onBlur:m,onMouseEnter:g,onMouseLeave:v,onTouchStart:x}=s,y=b.useRef(null);b.useEffect(()=>{if(t==="render"&&u(!0),t==="viewport"){let j=T=>{T.forEach(C=>{u(C.isIntersecting)})},N=new IntersectionObserver(j,{threshold:.5});return y.current&&N.observe(y.current),()=>{N.disconnect()}}},[t]),b.useEffect(()=>{if(r){let j=setTimeout(()=>{u(!0)},100);return()=>{clearTimeout(j)}}},[r]);let S=()=>{c(!0)},k=()=>{c(!1),u(!1)};return o?t!=="intent"?[d,y,{}]:[d,y,{onFocus:$r(p,S),onBlur:$r(m,k),onMouseEnter:$r(g,S),onMouseLeave:$r(v,k),onTouchStart:$r(x,S)}]:[!1,y,{}]}function $r(t,s){return o=>{t&&t(o),o.defaultPrevented||s(o)}}function aN({page:t,...s}){let{router:o}=qx(),r=b.useMemo(()=>Ax(o.routes,t,o.basename),[o.routes,t,o.basename]);return r?b.createElement(oN,{page:t,matches:r,...s}):null}function iN(t){let{manifest:s,routeModules:o}=Gx(),[r,c]=b.useState([]);return b.useEffect(()=>{let d=!1;return Ww(t,s,o).then(u=>{d||c(u)}),()=>{d=!0}},[t,s,o]),r}function oN({page:t,matches:s,...o}){let r=Yt(),{future:c,manifest:d,routeModules:u}=Gx(),{basename:p}=qx(),{loaderData:m,matches:g}=nN(),v=b.useMemo(()=>Ny(t,s,g,d,r,"data"),[t,s,g,d,r]),x=b.useMemo(()=>Ny(t,s,g,d,r,"assets"),[t,s,g,d,r]),y=b.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let j=new Set,N=!1;if(s.forEach(C=>{var O;let A=d.routes[C.route.id];!A||!A.hasLoader||(!v.some(E=>E.route.id===C.route.id)&&C.route.id in m&&((O=u[C.route.id])!=null&&O.shouldRevalidate)||A.hasClientLoader?N=!0:j.add(C.route.id))}),j.size===0)return[];let T=Kw(t,p,c.unstable_trailingSlashAwareDataRequests,"data");return N&&j.size>0&&T.searchParams.set("_routes",s.filter(C=>j.has(C.route.id)).map(C=>C.route.id).join(",")),[T.pathname+T.search]},[p,c.unstable_trailingSlashAwareDataRequests,m,r,d,v,s,t,u]),S=b.useMemo(()=>Xw(x,d),[x,d]),k=iN(x);return b.createElement(b.Fragment,null,y.map(j=>b.createElement("link",{key:j,rel:"prefetch",as:"fetch",href:j,...o})),S.map(j=>b.createElement("link",{key:j,rel:"modulepreload",href:j,...o})),k.map(({key:j,link:N})=>b.createElement("link",{key:j,nonce:o.nonce,...N,crossOrigin:N.crossOrigin??o.crossOrigin})))}function rN(...t){return s=>{t.forEach(o=>{typeof o=="function"?o(s):o!=null&&(o.current=s)})}}var lN=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{lN&&(window.__reactRouterVersion="7.13.2")}catch{}function cN({basename:t,children:s,unstable_useTransitions:o,window:r}){let c=b.useRef();c.current==null&&(c.current=Uj({window:r,v5Compat:!0}));let d=c.current,[u,p]=b.useState({action:d.action,location:d.location}),m=b.useCallback(g=>{o===!1?p(g):b.startTransition(()=>p(g))},[o]);return b.useLayoutEffect(()=>d.listen(m),[d,m]),b.createElement(Lw,{basename:t,children:s,location:u.location,navigationType:u.action,navigator:d,unstable_useTransitions:o})}var Fx=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,wm=b.forwardRef(function({onClick:s,discover:o="render",prefetch:r="none",relative:c,reloadDocument:d,replace:u,unstable_mask:p,state:m,target:g,to:v,preventScrollReset:x,viewTransition:y,unstable_defaultShouldRevalidate:S,...k},j){let{basename:N,navigator:T,unstable_useTransitions:C}=b.useContext(Ln),A=typeof v=="string"&&Fx.test(v),O=Ox(v,N);v=O.to;let E=xw(v,{relative:c}),D=Yt(),U=null;if(p){let oe=Nd(p,[],D.unstable_mask?D.unstable_mask.pathname:"/",!0);N!=="/"&&(oe.pathname=oe.pathname==="/"?N:Cs([N,oe.pathname])),U=T.createHref(oe)}let[B,z,X]=sN(r,k),$=pN(v,{replace:u,unstable_mask:p,state:m,target:g,preventScrollReset:x,relative:c,viewTransition:y,unstable_defaultShouldRevalidate:S,unstable_useTransitions:C});function J(oe){s&&s(oe),oe.defaultPrevented||$(oe)}let me=!(O.isExternal||d),ee=b.createElement("a",{...k,...X,href:(me?U:void 0)||O.absoluteURL||E,onClick:me?J:s,ref:rN(j,z),target:g,"data-discover":!A&&o==="render"?"true":void 0});return B&&!A?b.createElement(b.Fragment,null,ee,b.createElement(aN,{page:E})):ee});wm.displayName="Link";var dN=b.forwardRef(function({"aria-current":s="page",caseSensitive:o=!1,className:r="",end:c=!1,style:d,to:u,viewTransition:p,children:m,...g},v){let x=hl(u,{relative:g.relative}),y=Yt(),S=b.useContext(Cd),{navigator:k,basename:j}=b.useContext(Ln),N=S!=null&&yN(x)&&p===!0,T=k.encodeLocation?k.encodeLocation(x).pathname:x.pathname,C=y.pathname,A=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;o||(C=C.toLowerCase(),A=A?A.toLowerCase():null,T=T.toLowerCase()),A&&j&&(A=aa(A,j)||A);const O=T!=="/"&&T.endsWith("/")?T.length-1:T.length;let E=C===T||!c&&C.startsWith(T)&&C.charAt(O)==="/",D=A!=null&&(A===T||!c&&A.startsWith(T)&&A.charAt(T.length)==="/"),U={isActive:E,isPending:D,isTransitioning:N},B=E?s:void 0,z;typeof r=="function"?z=r(U):z=[r,E?"active":null,D?"pending":null,N?"transitioning":null].filter(Boolean).join(" ");let X=typeof d=="function"?d(U):d;return b.createElement(wm,{...g,"aria-current":B,className:z,ref:v,style:X,to:u,viewTransition:p},typeof m=="function"?m(U):m)});dN.displayName="NavLink";var uN=b.forwardRef(({discover:t="render",fetcherKey:s,navigate:o,reloadDocument:r,replace:c,state:d,method:u=ed,action:p,onSubmit:m,relative:g,preventScrollReset:v,viewTransition:x,unstable_defaultShouldRevalidate:y,...S},k)=>{let{unstable_useTransitions:j}=b.useContext(Ln),N=gN(),T=vN(p,{relative:g}),C=u.toLowerCase()==="get"?"get":"post",A=typeof p=="string"&&Fx.test(p),O=E=>{if(m&&m(E),E.defaultPrevented)return;E.preventDefault();let D=E.nativeEvent.submitter,U=(D==null?void 0:D.getAttribute("formmethod"))||u,B=()=>N(D||E.currentTarget,{fetcherKey:s,method:U,navigate:o,replace:c,state:d,relative:g,preventScrollReset:v,viewTransition:x,unstable_defaultShouldRevalidate:y});j&&o!==!1?b.startTransition(()=>B()):B()};return b.createElement("form",{ref:k,method:C,action:T,onSubmit:r?m:O,...S,"data-discover":!A&&t==="render"?"true":void 0})});uN.displayName="Form";function fN(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Zx(t){let s=b.useContext(Vo);return _t(s,fN(t)),s}function pN(t,{target:s,replace:o,unstable_mask:r,state:c,preventScrollReset:d,relative:u,viewTransition:p,unstable_defaultShouldRevalidate:m,unstable_useTransitions:g}={}){let v=Ed(),x=Yt(),y=hl(t,{relative:u});return b.useCallback(S=>{if(Vw(S,s)){S.preventDefault();let k=o!==void 0?o:il(x)===il(y),j=()=>v(t,{replace:k,unstable_mask:r,state:c,preventScrollReset:d,relative:u,viewTransition:p,unstable_defaultShouldRevalidate:m});g?b.startTransition(()=>j()):j()}},[x,v,y,o,r,c,s,t,d,u,p,m,g])}function Nm(t){ns(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let s=b.useRef(qp(t)),o=b.useRef(!1),r=Yt(),c=b.useMemo(()=>qw(r.search,o.current?null:s.current),[r.search]),d=Ed(),u=b.useCallback((p,m)=>{const g=qp(typeof p=="function"?p(new URLSearchParams(c)):p);o.current=!0,d("?"+g,m)},[d,c]);return[c,u]}var mN=0,hN=()=>`__${String(++mN)}__`;function gN(){let{router:t}=Zx("useSubmit"),{basename:s}=b.useContext(Ln),o=Mw(),r=t.fetch,c=t.navigate;return b.useCallback(async(d,u={})=>{let{action:p,method:m,encType:g,formData:v,body:x}=Zw(d,s);if(u.navigate===!1){let y=u.fetcherKey||hN();await r(y,o,u.action||p,{unstable_defaultShouldRevalidate:u.unstable_defaultShouldRevalidate,preventScrollReset:u.preventScrollReset,formData:v,body:x,formMethod:u.method||m,formEncType:u.encType||g,flushSync:u.flushSync})}else await c(u.action||p,{unstable_defaultShouldRevalidate:u.unstable_defaultShouldRevalidate,preventScrollReset:u.preventScrollReset,formData:v,body:x,formMethod:u.method||m,formEncType:u.encType||g,replace:u.replace,state:u.state,fromRouteId:o,flushSync:u.flushSync,viewTransition:u.viewTransition})},[r,c,s,o])}function vN(t,{relative:s}={}){let{basename:o}=b.useContext(Ln),r=b.useContext(ss);_t(r,"useFormAction must be used inside a RouteContext");let[c]=r.matches.slice(-1),d={...hl(t||".",{relative:s})},u=Yt();if(t==null){d.search=u.search;let p=new URLSearchParams(d.search),m=p.getAll("index");if(m.some(v=>v==="")){p.delete("index"),m.filter(x=>x).forEach(x=>p.append("index",x));let v=p.toString();d.search=v?`?${v}`:""}}return(!t||t===".")&&c.route.index&&(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),o!=="/"&&(d.pathname=d.pathname==="/"?o:Cs([o,d.pathname])),il(d)}function yN(t,{relative:s}={}){let o=b.useContext(Lx);_t(o!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Zx("useViewTransitionState"),c=hl(t,{relative:s});if(!o.isTransitioning)return!1;let d=aa(o.currentLocation.pathname,r)||o.currentLocation.pathname,u=aa(o.nextLocation.pathname,r)||o.nextLocation.pathname;return ol(c.pathname,u)!=null||ol(c.pathname,d)!=null}function mt(){const t=Ed();return b.useCallback((s,o)=>{typeof s=="number"?t(s):t(s,o)},[t])}function Cm(t){return`/sessions/${encodeURIComponent(t)}`}function Ga(t,s){return s?`/environments/${encodeURIComponent(s)}/workspaces/${encodeURIComponent(t)}`:`/workspaces/${encodeURIComponent(t)}`}function On(t,s,o,r){const c=encodeURIComponent(t);let d;return o&&r?d=`/environments/${encodeURIComponent(r)}/workspaces/${encodeURIComponent(o)}/tasks/${c}`:o?d=`/workspaces/${encodeURIComponent(o)}/tasks/${c}`:d=`/tasks/${c}`,s?`${d}/${s}`:d}function Ii(t,s,o){const r=new URLSearchParams;t&&r.set("workspace",t),s&&r.set("parent",s);const c=r.toString();if(t&&o){const d=`/environments/${encodeURIComponent(o)}/workspaces/${encodeURIComponent(t)}/tasks/new`;return s?`${d}?parent=${encodeURIComponent(s)}`:d}return c?`/tasks/new?${c}`:"/tasks/new"}function Kx(t){return`/sessions/new?${new URLSearchParams({env:t}).toString()}`}const Io="/environments",bN="/environments/new";function Ai(t){return`/environments/${encodeURIComponent(t)}`}function xN(t){return`/environments/${encodeURIComponent(t)}/edit`}const Ni="/settings",_N="/settings/credentials",ep="/settings/personas",kN="/settings/personas/new";function Yx(t){return`/settings/personas/${encodeURIComponent(t)}`}const tp="/settings/schedules",SN="/settings/schedules/new";function Jx(t){return`/settings/schedules/${encodeURIComponent(t)}`}const TN="/settings/shortcuts",jN="/pair",wN="/chat",Di="/",NN="/tasks",Wx="/workspaces/new",Xx="/knowledge",Dd="/findings";function CN(t,s){return t&&s?`/environments/${encodeURIComponent(s)}/workspaces/${encodeURIComponent(t)}/findings`:Dd}function Gp(t,s,o){const r=encodeURIComponent(t);return s&&o?`/environments/${encodeURIComponent(o)}/workspaces/${encodeURIComponent(s)}/findings/${r}`:`/findings/${r}`}const EN=jj,AN={task:Pj};function DN({workspaceId:t,environmentId:s,tasks:o,resolvedThemeId:r}){const c=mt(),d=b.useMemo(()=>o.filter(x=>x.workspaceId===t),[o,t]),{nodes:u,edges:p}=d2(d),m=b.useMemo(()=>{const x=getComputedStyle(document.documentElement),y={};for(const[S,k]of Object.entries(EN))y[S]=x.getPropertyValue(k).trim()||"#6b7a8d";return y},[r]),g=b.useCallback((x,y)=>{c(On(y.id,void 0,t,s))},[c,t,s]),v=b.useCallback(x=>{const y=x.data;return m[y.task.status]||m.pending},[m]);return d.length===0?i.jsxs("div",{className:bn.emptyCta,children:[i.jsx("button",{className:bn.ctaButton,onClick:()=>c(Ii(t,void 0,s)),children:"Create Task"}),i.jsx("div",{className:bn.ctaDescription,children:"Create tasks to see the dependency graph"})]}):i.jsx("div",{className:bn.dagContainer,children:i.jsxs(bT,{nodes:u,edges:p,nodeTypes:AN,onNodeClick:g,fitView:!0,fitViewOptions:{padding:.2},minZoom:.3,maxZoom:2,children:[i.jsx(xT,{variant:_T.Dots,gap:24,size:1,color:"var(--text-disabled)"}),i.jsx(kT,{showInteractive:!1}),i.jsx(ST,{nodeColor:v,maskColor:"var(--bg-overlay)",style:{background:"var(--bg-inset)"}})]})})}const RN="_breadcrumbs_17or2_1",MN="_list_17or2_11",IN="_item_17or2_21",ON="_separator_17or2_28",BN="_link_17or2_34",LN="_current_17or2_57",jo={breadcrumbs:RN,list:MN,item:IN,separator:ON,link:BN,current:LN};function vs({segments:t}){return i.jsx("nav",{className:jo.breadcrumbs,"aria-label":"Breadcrumb","data-testid":"breadcrumbs",children:i.jsx("ol",{className:jo.list,children:t.map((s,o)=>{const r=o===t.length-1;return i.jsxs("li",{className:jo.item,children:[o>0&&i.jsx("span",{className:jo.separator,"aria-hidden":"true",children:i.jsx(la,{size:dt})}),s.url&&!r?i.jsx(wm,{className:jo.link,to:s.url,title:s.label,children:s.label}):i.jsx("span",{className:jo.current,"aria-current":"page",title:s.label,children:s.label})]},o)})})})}const zN="_btn_dwk2o_1",$N="_sm_dwk2o_22",PN="_md_dwk2o_28",UN="_lg_dwk2o_34",HN="_primary_dwk2o_40",VN="_danger_dwk2o_55",qN="_outline_dwk2o_70",GN="_ghost_dwk2o_80",np={btn:zN,sm:$N,md:PN,lg:UN,primary:HN,danger:VN,outline:qN,ghost:GN},tn=b.forwardRef(function({variant:s="primary",size:o="md",className:r,children:c,...d},u){const p=[np.btn,np[s],np[o],r].filter(Boolean).join(" ");return i.jsx("button",{ref:u,className:p,...d,children:c})}),FN="_copyButton_1bqk0_1",ZN={copyButton:FN},KN=2e3;function YN({text:t,className:s,"data-testid":o}){const[r,c]=b.useState(!1),d=b.useRef(void 0);b.useEffect(()=>()=>{d.current!==void 0&&clearTimeout(d.current)},[]);const u=b.useCallback(async()=>{try{await navigator.clipboard.writeText(t),c(!0),d.current!==void 0&&clearTimeout(d.current),d.current=setTimeout(()=>{c(!1),d.current=void 0},KN)}catch{}},[t]);return i.jsx("button",{type:"button",className:`${ZN.copyButton} ${s??""}`,onClick:()=>{u().catch(()=>{})},"aria-label":r?"Copied":"Copy to clipboard","data-testid":o??"copy-button",children:r?i.jsx(Ri,{size:nn,"aria-hidden":"true"}):i.jsx(Cx,{size:nn,"aria-hidden":"true"})})}const JN="_banner_bxqlh_1",WN="_label_bxqlh_15",XN="_text_bxqlh_25",QN="_link_bxqlh_29",Pc={banner:JN,label:WN,text:XN,link:QN};function eC(){return i.jsxs("div",{className:Pc.banner,"data-testid":"demo-banner",children:[i.jsx("span",{className:Pc.label,children:"DEMO"}),i.jsxs("span",{className:Pc.text,children:["This is an interactive demo with mock data."," ",i.jsx("a",{href:"https://github.com/nick-pape/grackle",target:"_blank",rel:"noopener noreferrer",className:Pc.link,children:"Install Grackle"})," ","to use it for real."]})]})}const tC="_container_og0yp_1",nC="_chevronButton_og0yp_6",sC="_mainButton_og0yp_6",aC="_sm_og0yp_34",iC="_md_og0yp_34",oC="_lg_og0yp_34",rC="_primary_og0yp_57",lC="_danger_og0yp_70",cC="_outline_og0yp_83",dC="_ghost_og0yp_92",uC="_dropdown_og0yp_100",fC="_option_og0yp_113",pC="_optionLabel_og0yp_130",mC="_optionDesc_og0yp_135",Ws={container:tC,chevronButton:nC,mainButton:sC,sm:aC,md:iC,lg:oC,primary:rC,danger:lC,outline:cC,ghost:dC,dropdown:uC,option:fC,optionLabel:pC,optionDesc:mC};function Qx({label:t,onClick:s,options:o,variant:r="primary",size:c="md","data-testid":d}){const[u,p]=b.useState(!1),m=b.useRef(null);b.useEffect(()=>{if(!u)return;function y(S){m.current&&S.target instanceof Node&&!m.current.contains(S.target)&&p(!1)}return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[u]),b.useEffect(()=>{if(!u)return;function y(S){S.key==="Escape"&&p(!1)}return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[u]);const g=Ws[r]||"",v=Ws[c]||"",x=()=>{u&&p(!1),s()};return i.jsxs("div",{ref:m,className:Ws.container,"data-testid":d,children:[i.jsx("button",{type:"button",className:`${Ws.mainButton} ${g} ${v}`,onClick:x,"data-testid":d?`${d}-main`:void 0,children:t}),i.jsx("button",{type:"button",className:`${Ws.chevronButton} ${g} ${v}`,onClick:()=>p(y=>!y),"aria-label":`More options for ${t}`,"aria-haspopup":"menu","aria-expanded":u,"data-testid":d?`${d}-chevron`:void 0,children:i.jsx(Nx,{size:nn,"aria-hidden":"true"})}),u&&i.jsx("div",{className:Ws.dropdown,"data-testid":d?`${d}-menu`:void 0,children:o.map((y,S)=>i.jsxs("button",{type:"button",className:Ws.option,onClick:()=>{y.onClick(),p(!1)},children:[i.jsx("span",{className:Ws.optionLabel,children:y.label}),y.description&&i.jsx("span",{className:Ws.optionDesc,children:y.description})]},S))})]})}function Fp(){Fp=function(c,d){return new o(c,void 0,d)};var t=RegExp.prototype,s=new WeakMap;function o(c,d,u){var p=new RegExp(c,d);return s.set(p,u||s.get(c)),cd(p,o.prototype)}function r(c,d){var u=s.get(d);return Object.keys(u).reduce(function(p,m){var g=u[m];if(typeof g=="number")p[m]=c[g];else{for(var v=0;c[g[v]]===void 0&&v+1<g.length;)v++;p[m]=c[g[v]]}return p},Object.create(null))}return(function(c,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(d&&d.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),Object.defineProperty(c,"prototype",{writable:!1}),d&&cd(c,d)})(o,RegExp),o.prototype.exec=function(c){var d=t.exec.call(this,c);if(d){d.groups=r(d,this);var u=d.indices;u&&(u.groups=r(u,this))}return d},o.prototype[Symbol.replace]=function(c,d){if(typeof d=="string"){var u=s.get(this);return t[Symbol.replace].call(this,c,d.replace(/\$<([^>]+)>/g,function(m,g){var v=u[g];return"$"+(Array.isArray(v)?v.join("$"):v)}))}if(typeof d=="function"){var p=this;return t[Symbol.replace].call(this,c,function(){var m=arguments;return typeof m[m.length-1]!="object"&&(m=[].slice.call(m)).push(r(m,p)),d.apply(this,m)})}return t[Symbol.replace].call(this,c,d)},Fp.apply(this,arguments)}function cd(t,s){return cd=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,r){return o.__proto__=r,o},cd(t,s)}function Cy(t,s){(s==null||s>t.length)&&(s=t.length);for(var o=0,r=new Array(s);o<s;o++)r[o]=t[o];return r}function sp(t,s){var o=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(o)return(o=o.call(t)).next.bind(o);if(Array.isArray(t)||(o=(function(c,d){if(c){if(typeof c=="string")return Cy(c,d);var u=Object.prototype.toString.call(c).slice(8,-1);return u==="Object"&&c.constructor&&(u=c.constructor.name),u==="Map"||u==="Set"?Array.from(c):u==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(u)?Cy(c,d):void 0}})(t))||s){o&&(t=o);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
238
238
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var hC=(function(t){return function(s){return s===void 0&&(s={}),(function(r,c){if(c&&!r.registered(c))throw new Error('The default language "'+c+'" is not registered with refractor.')})(t,s.defaultLanguage),function(r){zT(r,"element",o)};function o(r,c,d){var u,p;if(d&&d.tagName==="pre"&&r.tagName==="code"){var m=(r==null||(u=r.data)==null?void 0:u.meta)||(r==null||(p=r.properties)==null?void 0:p.metastring)||"";r.properties.className?typeof r.properties.className=="boolean"?r.properties.className=[]:Array.isArray(r.properties.className)||(r.properties.className=[r.properties.className]):r.properties.className=[];var g,v,x=(function(E){for(var D,U=sp(E.properties.className);!(D=U()).done;){var B=D.value;if(B.slice(0,9)==="language-")return B.slice(9).toLowerCase()}return null})(r);if(!x&&s.defaultLanguage&&r.properties.className.push("language-"+(x=s.defaultLanguage)),r.properties.className.push("code-highlight"),x)try{var y,S;S=(y=x)!=null&&y.includes("diff-")?x.split("-")[1]:x,g=t.highlight(Bc(r),S),d.properties.className=(d.properties.className||[]).concat("language-"+S)}catch(E){if(!s.ignoreMissing||!/Unknown language/.test(E.message))throw E;g=r}else g=r;g.children=(v=1,function E(D){return D.reduce(function(U,B){if(B.type==="text"){var z=B.value,X=(z.match(/\n/g)||"").length;if(X===0)B.position={start:{line:v,column:1},end:{line:v,column:1}},U.push(B);else for(var $,J=z.split(`
|
|
239
239
|
`),me=sp(J.entries());!($=me()).done;){var ee=$.value,oe=ee[0],R=ee[1];U.push({type:"text",value:oe===J.length-1?R:R+`
|
|
240
|
-
`,position:{start:{line:v+oe,column:1},end:{line:v+oe,column:1}}})}return v+=X,U}if(Object.prototype.hasOwnProperty.call(B,"children")){var G=v;return B.children=E(B.children),U.push(B),B.position={start:{line:G,column:1},end:{line:v,column:1}},U}return U.push(B),U},[])})(g.children),g.position=g.children.length>0?{start:{line:g.children[0].position.start.line,column:0},end:{line:g.children[g.children.length-1].position.end.line,column:0}}:{start:{line:0,column:0},end:{line:0,column:0}};for(var k,j=(function(E){var D=/{([\d,-]+)}/,U=E.split(",").map(function(X){return X.trim()}).join();if(D.test(U)){var B=D.exec(U)[1],z=PT(B);return function(X){return z.includes(X+1)}}return function(){return!1}})(m),N=(function(E){var D=Fp(/showLineNumbers=(\d+)/i,{lines:1});if(D.test(E)){var U=D.exec(E);return Number(U.groups.lines)}return 1})(m),T=(function(E){for(var D=new Array(E),U=0;U<E;U++)D[U]={type:"element",tagName:"span",properties:{className:[]},children:[]};return D})(g.position.end.line),C=["showlinenumbers=false",'showlinenumbers="false"',"showlinenumbers={false}"],A=function(){var E,D,U=k.value,B=U[0],z=U[1];z.properties.className=["code-line"];var X=UT(g,function($){return $.position.start.line<=B+1&&$.position.end.line>=B+1});z.children=X.children,(m.toLowerCase().includes("showLineNumbers".toLowerCase())||s.showLineNumbers===!0||typeof s.showLineNumbers=="object"&&s.showLineNumbers.includes(x))&&!C.some(function($){return m.toLowerCase().includes($)})&&(z.properties.line=[(B+N).toString()],z.properties.className.push("line-number")),j(B)&&z.properties.className.push("highlight-line"),(x==="diff"||(E=x)!=null&&E.includes("diff-"))&&Bc(z).substring(0,1)==="-"?z.properties.className.push("deleted"):(x==="diff"||(D=x)!=null&&D.includes("diff-"))&&Bc(z).substring(0,1)==="+"&&z.properties.className.push("inserted")},O=sp(T.entries());!(k=O()).done;)A();T.length>0&&Bc(T[T.length-1]).trim()===""&&T.pop(),r.children=T}}}})($T);function Oo(t){if(t>=1e6)return`${(t/1e6).toFixed(1)}M`;if(t>=1e3){const s=Number((t/1e3).toFixed(1));return s>=1e3?`${(t/1e6).toFixed(1)}M`:`${s.toFixed(1)}k`}return String(t)}function Ns(t){if(t===0)return"-";const s=t/1e5;if(s<.01){const o=t<5?5:4;return`$${s.toFixed(o)}`}return`$${s.toFixed(2)}`}const Ey=new Set(["grackle"]);function qo(t){if(t.startsWith("mcp__")){const o=t.indexOf("__",5);if(o>5){const r=t.slice(5,o);if(Ey.has(r))return t.slice(o+2)}}const s=t.indexOf("-");if(s>0){const o=t.slice(0,s);if(Ey.has(o))return t.slice(s+1)}return t}const gC={read:"file-read",view:"file-read",edit:"file-edit",file_change:"file-edit",write:"file-write",bash:"shell",powershell:"shell",command_execution:"shell",grep:"search",glob:"search",todowrite:"todo",update_plan:"todo",todo_write:"todo",report_intent:"metadata",finding_post:"finding",finding_list:"finding",task_list:"task",task_create:"task",task_show:"task",task_update:"task",task_start:"task",task_complete:"task",task_resume:"task",task_delete:"task",workpad_write:"workpad",workpad_read:"workpad",knowledge_search:"knowledge",knowledge_get_node:"knowledge",knowledge_create_node:"knowledge",ipc_spawn:"ipc",ipc_write:"ipc",ipc_close:"ipc",ipc_list_fds:"ipc",ipc_terminate:"ipc",ipc_create_stream:"ipc",ipc_attach:"ipc",toolsearch:"tool-search",agent:"agent",task:"agent",read_agent:"agent"};function vC(t){const s=qo(t);return gC[s.toLowerCase()]??"generic"}const yC="_card_qkm9i_2",bC="_cardBlue_qkm9i_20",xC="_cardOrange_qkm9i_24",_C="_cardGreen_qkm9i_28",kC="_cardPurple_qkm9i_32",SC="_cardNeutral_qkm9i_36",TC="_cardRed_qkm9i_40",jC="_cardTeal_qkm9i_44",wC="_header_qkm9i_48",NC="_icon_qkm9i_55",CC="_toolName_qkm9i_64",EC="_fileName_qkm9i_71",AC="_badge_qkm9i_80",DC="_spacer_qkm9i_87",RC="_bodyToggle_qkm9i_91",MC="_chevron_qkm9i_109",IC="_chevronExpanded_qkm9i_115",OC="_pre_qkm9i_119",BC="_diffAdd_qkm9i_143",LC="_diffRemove_qkm9i_155",zC="_diffContext_qkm9i_167",$C="_diffHeader_qkm9i_176",PC="_diffLine_qkm9i_182",UC="_exitOk_qkm9i_188",HC="_exitError_qkm9i_194",VC="_exitPending_qkm9i_200",qC="_inProgress_qkm9i_228",GC="_metadata_qkm9i_232",FC="_metadataPrefix_qkm9i_239",I={card:yC,cardBlue:bC,cardOrange:xC,cardGreen:_C,cardPurple:kC,cardNeutral:SC,cardRed:TC,cardTeal:jC,header:wC,icon:NC,toolName:CC,fileName:EC,badge:AC,spacer:DC,bodyToggle:RC,chevron:MC,chevronExpanded:IC,pre:OC,diffAdd:BC,diffRemove:LC,diffContext:zC,diffHeader:$C,diffLine:PC,exitOk:UC,exitError:HC,exitPending:VC,inProgress:qC,metadata:GC,metadataPrefix:FC};function ZC(t){if(t==null||typeof t!="object")return"";const s=t;return typeof s.file_path=="string"?s.file_path:typeof s.path=="string"?s.path:""}function KC(t){const s=t.split(/[/\\]/);return s[s.length-1]||t}const ap=5;function Ay({tool:t,args:s,result:o,isError:r,writeVariant:c}){const[d,u]=b.useState(!1),p=ZC(s),m=KC(p),g=o===void 0,v=r?I.cardRed:c?I.cardGreen:I.cardBlue,x=c?"var(--accent-green)":"var(--accent-blue)",y=c?i.jsx(B2,{size:nn}):i.jsx(z2,{size:nn}),S=c?"tool-card-file-write":"tool-card-file-read",k=(o==null?void 0:o.split(`
|
|
240
|
+
`,position:{start:{line:v+oe,column:1},end:{line:v+oe,column:1}}})}return v+=X,U}if(Object.prototype.hasOwnProperty.call(B,"children")){var G=v;return B.children=E(B.children),U.push(B),B.position={start:{line:G,column:1},end:{line:v,column:1}},U}return U.push(B),U},[])})(g.children),g.position=g.children.length>0?{start:{line:g.children[0].position.start.line,column:0},end:{line:g.children[g.children.length-1].position.end.line,column:0}}:{start:{line:0,column:0},end:{line:0,column:0}};for(var k,j=(function(E){var D=/{([\d,-]+)}/,U=E.split(",").map(function(X){return X.trim()}).join();if(D.test(U)){var B=D.exec(U)[1],z=PT(B);return function(X){return z.includes(X+1)}}return function(){return!1}})(m),N=(function(E){var D=Fp(/showLineNumbers=(\d+)/i,{lines:1});if(D.test(E)){var U=D.exec(E);return Number(U.groups.lines)}return 1})(m),T=(function(E){for(var D=new Array(E),U=0;U<E;U++)D[U]={type:"element",tagName:"span",properties:{className:[]},children:[]};return D})(g.position.end.line),C=["showlinenumbers=false",'showlinenumbers="false"',"showlinenumbers={false}"],A=function(){var E,D,U=k.value,B=U[0],z=U[1];z.properties.className=["code-line"];var X=UT(g,function($){return $.position.start.line<=B+1&&$.position.end.line>=B+1});z.children=X.children,(m.toLowerCase().includes("showLineNumbers".toLowerCase())||s.showLineNumbers===!0||typeof s.showLineNumbers=="object"&&s.showLineNumbers.includes(x))&&!C.some(function($){return m.toLowerCase().includes($)})&&(z.properties.line=[(B+N).toString()],z.properties.className.push("line-number")),j(B)&&z.properties.className.push("highlight-line"),(x==="diff"||(E=x)!=null&&E.includes("diff-"))&&Bc(z).substring(0,1)==="-"?z.properties.className.push("deleted"):(x==="diff"||(D=x)!=null&&D.includes("diff-"))&&Bc(z).substring(0,1)==="+"&&z.properties.className.push("inserted")},O=sp(T.entries());!(k=O()).done;)A();T.length>0&&Bc(T[T.length-1]).trim()===""&&T.pop(),r.children=T}}}})($T);function Oo(t){if(t>=1e6)return`${(t/1e6).toFixed(1)}M`;if(t>=1e3){const s=Number((t/1e3).toFixed(1));return s>=1e3?`${(t/1e6).toFixed(1)}M`:`${s.toFixed(1)}k`}return String(t)}function Ns(t){if(t===0)return"-";const s=t/1e5;if(s<.01){const o=t<5?5:4;return`$${s.toFixed(o)}`}return`$${s.toFixed(2)}`}const Ey=new Set(["grackle"]);function qo(t){if(t.startsWith("mcp__")){const o=t.indexOf("__",5);if(o>5){const r=t.slice(5,o);if(Ey.has(r))return t.slice(o+2)}}const s=t.indexOf("-");if(s>0){const o=t.slice(0,s);if(Ey.has(o))return t.slice(s+1)}return t}const gC={read:"file-read",view:"file-read",edit:"file-edit",file_change:"file-edit",write:"file-write",bash:"shell",powershell:"shell",command_execution:"shell",grep:"search",glob:"search",todowrite:"todo",update_plan:"todo",todo_write:"todo",report_intent:"metadata",finding_post:"finding",finding_list:"finding",task_list:"task",task_create:"task",task_show:"task",task_update:"task",task_start:"task",task_complete:"task",task_resume:"task",task_delete:"task",workpad_write:"workpad",workpad_read:"workpad",knowledge_search:"knowledge",knowledge_get_node:"knowledge",knowledge_create_node:"knowledge",ipc_spawn:"ipc",ipc_write:"ipc",ipc_close:"ipc",ipc_list_fds:"ipc",ipc_terminate:"ipc",ipc_create_stream:"ipc",ipc_attach:"ipc",ipc_share_stream:"ipc",ipc_list_streams:"ipc",toolsearch:"tool-search",agent:"agent",task:"agent",read_agent:"agent"};function vC(t){const s=qo(t);return gC[s.toLowerCase()]??"generic"}const yC="_card_qkm9i_2",bC="_cardBlue_qkm9i_20",xC="_cardOrange_qkm9i_24",_C="_cardGreen_qkm9i_28",kC="_cardPurple_qkm9i_32",SC="_cardNeutral_qkm9i_36",TC="_cardRed_qkm9i_40",jC="_cardTeal_qkm9i_44",wC="_header_qkm9i_48",NC="_icon_qkm9i_55",CC="_toolName_qkm9i_64",EC="_fileName_qkm9i_71",AC="_badge_qkm9i_80",DC="_spacer_qkm9i_87",RC="_bodyToggle_qkm9i_91",MC="_chevron_qkm9i_109",IC="_chevronExpanded_qkm9i_115",OC="_pre_qkm9i_119",BC="_diffAdd_qkm9i_143",LC="_diffRemove_qkm9i_155",zC="_diffContext_qkm9i_167",$C="_diffHeader_qkm9i_176",PC="_diffLine_qkm9i_182",UC="_exitOk_qkm9i_188",HC="_exitError_qkm9i_194",VC="_exitPending_qkm9i_200",qC="_inProgress_qkm9i_228",GC="_metadata_qkm9i_232",FC="_metadataPrefix_qkm9i_239",I={card:yC,cardBlue:bC,cardOrange:xC,cardGreen:_C,cardPurple:kC,cardNeutral:SC,cardRed:TC,cardTeal:jC,header:wC,icon:NC,toolName:CC,fileName:EC,badge:AC,spacer:DC,bodyToggle:RC,chevron:MC,chevronExpanded:IC,pre:OC,diffAdd:BC,diffRemove:LC,diffContext:zC,diffHeader:$C,diffLine:PC,exitOk:UC,exitError:HC,exitPending:VC,inProgress:qC,metadata:GC,metadataPrefix:FC};function ZC(t){if(t==null||typeof t!="object")return"";const s=t;return typeof s.file_path=="string"?s.file_path:typeof s.path=="string"?s.path:""}function KC(t){const s=t.split(/[/\\]/);return s[s.length-1]||t}const ap=5;function Ay({tool:t,args:s,result:o,isError:r,writeVariant:c}){const[d,u]=b.useState(!1),p=ZC(s),m=KC(p),g=o===void 0,v=r?I.cardRed:c?I.cardGreen:I.cardBlue,x=c?"var(--accent-green)":"var(--accent-blue)",y=c?i.jsx(B2,{size:nn}):i.jsx(z2,{size:nn}),S=c?"tool-card-file-write":"tool-card-file-read",k=(o==null?void 0:o.split(`
|
|
241
241
|
`))??[],j=k.length>ap,N=d?k:k.slice(0,ap);return i.jsxs("div",{className:`${I.card} ${v} ${g?I.inProgress:""}`,"data-testid":S,children:[i.jsxs("div",{className:I.header,children:[i.jsx("span",{className:I.icon,children:y}),i.jsx("span",{className:I.toolName,style:{color:x},children:t}),m&&i.jsx("span",{className:I.fileName,title:p,children:m}),!g&&k.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:I.spacer}),i.jsxs("span",{className:I.badge,children:[k.length," lines"]})]})]}),r&&o&&i.jsx("pre",{className:I.pre,"data-testid":"tool-card-error",children:o}),!r&&!g&&k.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("pre",{className:I.pre,"data-testid":"tool-card-content",children:N.map((T,C)=>i.jsxs("span",{className:I.diffLine,children:[i.jsx("span",{style:{color:"var(--text-tertiary)",userSelect:"none",marginRight:"var(--space-sm)",display:"inline-block",width:"3ch",textAlign:"right"},children:C+1}),T]},C))}),j&&i.jsxs("button",{type:"button",className:I.bodyToggle,onClick:()=>{u(T=>!T)},"aria-expanded":d,"data-testid":"tool-card-toggle",children:[i.jsx("span",{className:`${I.chevron} ${d?I.chevronExpanded:""}`,"aria-hidden":"true",children:i.jsx(la,{size:dt})}),d?"collapse":`${k.length-ap} more lines`]})]})]})}function YC(t){const s=t.split(`
|
|
242
242
|
`),o=[];for(const r of s)r.startsWith("diff --git")||r.startsWith("index ")||(r.startsWith("--- ")||r.startsWith("+++ "))&&!r.startsWith("---- ")&&!r.startsWith("++++ ")||(r.startsWith("@@")?o.push({type:"header",content:r}):r.startsWith("+")?o.push({type:"add",content:r.slice(1)}):r.startsWith("-")?o.push({type:"remove",content:r.slice(1)}):r.startsWith(" ")?o.push({type:"context",content:r.slice(1)}):r===""&&o.push({type:"context",content:""}));return o}function JC(t,s){const o=t.split(`
|
|
243
243
|
`),r=s.split(`
|
|
@@ -281,7 +281,7 @@ ${JSON.stringify(u,void 0,2)}
|
|
|
281
281
|
\`\`\``):s.push(`${m} (${c}):`);break}case"error":{s.push(`**Error** (${c}):
|
|
282
282
|
${r.content}`);break}}}return s.join(`
|
|
283
283
|
|
|
284
|
-
`)}function _6({events:t,formatForClipboard:s}){const[o,r]=b.useState(!1),[c,d]=b.useState(new Set),u=b.useRef(void 0),p=b.useMemo(()=>c.size,[c]),m=b.useCallback(k=>{r(!0),k!==void 0?(d(new Set([k])),u.current=k):(d(new Set),u.current=void 0)},[]),g=b.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=b.useCallback((k,j)=>{if(j&&u.current!==void 0){const N=Math.min(u.current,k),T=Math.max(u.current,k);d(C=>{const A=new Set(C);for(let O=N;O<=T;O++)O<t.length&&fl(t[O])&&A.add(O);return A})}else d(N=>{const T=new Set(N);return T.has(k)?T.delete(k):T.add(k),T.size===0?(r(!1),u.current=void 0):u.current=k,T})},[t]),x=b.useCallback(()=>{const k=new Set;for(let j=0;j<t.length;j++)fl(t[j])&&k.add(j);d(k)},[t]),y=b.useCallback(()=>{d(new Set)},[]),S=b.useCallback(async()=>{const j=[...c].sort((T,C)=>T-C).filter(T=>T<t.length).map(T=>t[T]);if(j.length===0)return!1;const N=s(j);try{return await navigator.clipboard.writeText(N),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:x,deselectAll:y,copySelected:S}}const k6="_wrapper_1cdza_1",S6="_scrollContainer_1cdza_9",T6="_selectingPadding_1cdza_16",j6="_toolbar_1cdza_20",w6="_directionToggle_1cdza_27",N6="_scrollToAnchor_1cdza_65",C6="_scrollToAnchorBottom_1cdza_89",E6="_scrollToAnchorTop_1cdza_93",A6="_eventOverflowWarning_1cdza_97",ea={wrapper:k6,scrollContainer:S6,selectingPadding:T6,toolbar:j6,directionToggle:w6,scrollToAnchor:N6,scrollToAnchorBottom:C6,scrollToAnchorTop:E6,eventOverflowWarning:A6};function D6(t){const s=new Date(t.timestamp).toLocaleTimeString();switch(t.eventType){case"text":case"output":return`Select message from assistant at ${s}`;case"user_input":return`Select message from user at ${s}`;case"tool_result":case"tool_use":return`Select tool event at ${s}`;case"error":return`Select error at ${s}`;default:return`Select event at ${s}`}}const R1="grackle-stream-direction";function R6(){try{return localStorage.getItem(R1)==="reversed"}catch{return!1}}function M6({eventsDropped:t}){return t<=0?i.jsx(i.Fragment,{}):i.jsxs("div",{className:ea.eventOverflowWarning,role:"alert",children:[i.jsx(ym,{size:nn,"aria-hidden":"true"})," ",t.toLocaleString()," older event",t===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function dh({events:t,eventsDropped:s,emptyState:o,onShowToast:r}){const c=b.useRef(null),[d,u]=b.useState(R6),p=v3(),m=_6({events:t,formatForClipboard:x6}),g=b.useMemo(()=>t.filter(fl).length,[t]),v=b.useMemo(()=>d?[...t].reverse():t,[t,d]),{isAtAnchor:x,scrollToAnchor:y}=v6({scrollRef:c,contentLength:t.length,isReversed:d,paused:m.isSelecting}),S=()=>{const T=!d;u(T);try{localStorage.setItem(R1,T?"reversed":"default")}catch{}};b.useEffect(()=>{if(!m.isSelecting)return;const T=C=>{C.key==="Escape"&&m.cancelSelection()};return window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T)}},[m.isSelecting,m.cancelSelection]);const k=b.useCallback(async()=>{await m.copySelected()&&(r==null||r(`Copied ${m.selectedCount} message${m.selectedCount===1?"":"s"} to clipboard`,"success"))},[m,r]),j=p?0:.2,N=d?-8:8;return i.jsxs("div",{className:ea.wrapper,children:[i.jsx("div",{className:ea.toolbar,children:i.jsx($o,{text:d?"Showing newest first":"Showing oldest first",children:i.jsx("button",{className:ea.directionToggle,onClick:S,"aria-label":d?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:d?i.jsx(yy,{size:nn,"aria-hidden":"true"}):i.jsx(by,{size:nn,"aria-hidden":"true"})})})}),i.jsxs("div",{ref:c,className:`${ea.scrollContainer} ${m.isSelecting?ea.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,i.jsx(M6,{eventsDropped:s}),i.jsx(gs,{initial:!1,children:v.map((T,C)=>{const A=d?t.length-1-C:C;return i.jsx(Mt.div,{initial:{opacity:0,y:N},animate:{opacity:1,y:0},transition:{duration:j,ease:"easeOut"},children:i.jsx(o6,{copyText:b6(T),isContentBearing:fl(T),isSelecting:m.isSelecting,isSelected:m.selectedIndices.has(A),checkboxLabel:D6(T),onSelect:()=>{m.enterSelectionMode(A)},onToggle:O=>{m.toggleEvent(A,O)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:i.jsx(GA,{event:T,toolUseCtx:T.toolUseCtx,settled:T.settled})})},`${T.sessionId}-${T.timestamp}-${A}`)})})]}),i.jsx(gs,{children:m.isSelecting&&i.jsx(m6,{selectedCount:m.selectedCount,totalSelectable:g,onSelectAll:m.selectAll,onDeselectAll:m.deselectAll,onCopy:()=>{k().catch(()=>{})},onCancel:m.cancelSelection})}),i.jsx(gs,{children:!x&&i.jsxs(Mt.button,{className:`${ea.scrollToAnchor} ${d?ea.scrollToAnchorTop:ea.scrollToAnchorBottom}`,onClick:y,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[d?i.jsx(by,{size:nn,"aria-hidden":"true"}):i.jsx(yy,{size:nn,"aria-hidden":"true"})," New events"]})})]})}function uh(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=b.useState(""),[x,y]=b.useState(""),S=b.useRef(!1),k=d===c,j=b.useCallback(U=>{v(U),y("")},[]),N=b.useCallback(()=>{y("")},[]),T=b.useCallback(()=>{S.current=!1,u==null||u(null),v(""),y("")},[u]),C=b.useCallback(()=>{const U=m?g.trim():g;if(r){const z=r(g);if(z){y(z);return}}const B=m?s.trim():s;if(U===B){T();return}o(U),T()},[g,s,m,r,o,T]),A=b.useCallback(()=>{S.current=!0,u==null||u(c),v(s),y("")},[c,s,u]),O=b.useCallback(U=>{if(S.current){S.current=!1;return}U.relatedTarget instanceof HTMLElement&&U.relatedTarget.dataset.editAction===c||C()},[c,C]),E=b.useCallback(U=>{U.key==="Escape"?T():U.key==="Enter"&&p&&C()},[T,p,C]),D=(()=>{if(!k)return!1;const U=m?s.trim():s;return(m?g.trim():g)!==U})();return b.useEffect(()=>{!k&&(g!==""||x!=="")&&(v(""),y(""))},[k,g,x]),{isEditing:k,draft:g,error:x,isDirty:D,startEdit:A,cancelEdit:T,save:C,setDraft:j,clearError:N,handleBlur:O,handleKeyDown:E,ignoreInitialBlurRef:S}}const I6="_editFieldWrapper_yuzty_1",O6="_editInput_yuzty_10",B6="_editTextarea_yuzty_42",L6="_editSelect_yuzty_78",z6="_editError_yuzty_111",$6="_editInputInvalid_yuzty_118",P6="_editHint_yuzty_123",U6="_unsavedDot_yuzty_132",H6="_metaValueClickable_yuzty_140",V6="_editButton_yuzty_159",q6="_metaPlaceholder_yuzty_175",G6="_worktreeToggle_yuzty_180",st={editFieldWrapper:I6,editInput:O6,editTextarea:B6,editSelect:L6,editError:z6,editInputInvalid:$6,editHint:P6,unsavedDot:U6,metaValueClickable:H6,editButton:V6,metaPlaceholder:q6,worktreeToggle:G6};function Ft(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:x,ariaLabel:y,"data-testid":S}=t,k=b.useRef(null),j=uh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(b.useEffect(()=>{if(j.isEditing){const T=window.setTimeout(()=>{var C;(C=k.current)==null||C.focus()},0);return()=>window.clearTimeout(T)}},[j.isEditing]),c==="create"){const T=A=>{m==null||m(A.target.value)},C=r==null?void 0:r(s);return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("input",{className:`${st.editInput} ${C?st.editInputInvalid:""}`,value:s,onChange:T,maxLength:x,placeholder:v,"aria-label":y,"data-testid":S?`${S}-input`:void 0}),C&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("input",{ref:k,className:`${st.editInput} ${j.error?st.editInputInvalid:""}`,value:j.draft,onChange:T=>j.setDraft(T.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:x,placeholder:v,"aria-label":y,"data-testid":S?`${S}-input`:void 0}),j.isDirty&&i.jsx("span",{className:st.unsavedDot,title:"Unsaved changes"}),j.error&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:j.error}),i.jsx("span",{className:st.editHint,children:"Enter to save · Esc to cancel"})]});const N=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:st.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":y,"data-testid":S?`${S}-button`:void 0,children:[N!==void 0?N:s?i.jsx("span",{children:s}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function dm(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:x,"data-testid":y}=t,S=b.useRef(null),k=uh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(b.useEffect(()=>{if(k.isEditing){const N=window.setTimeout(()=>{var T;(T=S.current)==null||T.focus()},0);return()=>window.clearTimeout(N)}},[k.isEditing]),c==="create"){const N=C=>{m==null||m(C.target.value)},T=r==null?void 0:r(s);return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("textarea",{className:`${st.editTextarea} ${T?st.editInputInvalid:""}`,value:s,onChange:N,placeholder:v,"aria-label":x,"data-testid":y?`${y}-input`:void 0}),T&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:T})]})}if(k.isEditing)return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("textarea",{ref:S,className:`${st.editTextarea} ${k.error?st.editInputInvalid:""}`,value:k.draft,onChange:N=>k.setDraft(N.target.value),onBlur:k.handleBlur,onKeyDown:k.handleKeyDown,title:x,"aria-label":x,"data-testid":y?`${y}-input`:void 0}),k.isDirty&&i.jsx("span",{className:st.unsavedDot,title:"Unsaved changes"}),k.error&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:k.error}),i.jsx("span",{className:st.editHint,children:"Tab to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:st.metaValueClickable,onClick:()=>k.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),k.startEdit())},title:"Click to edit","aria-label":x,"data-testid":y?`${y}-button`:void 0,children:[j!==void 0?j:s?i.jsx("span",{children:s}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function Po(t){var A;const{value:s,onSave:o,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:x,"data-testid":y}=t,S=b.useRef(null),k=uh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});b.useEffect(()=>{if(k.isEditing){const O=window.setTimeout(()=>{var E;(E=S.current)==null||E.focus()},0);return()=>window.clearTimeout(O)}},[k.isEditing]);const j=b.useCallback(O=>{const E=O.target.value;k.ignoreInitialBlurRef.current=!1,E!==s&&o(E),k.cancelEdit()},[s,o,k]),N=b.useCallback(O=>{if(k.ignoreInitialBlurRef.current){k.ignoreInitialBlurRef.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===d||k.cancelEdit()},[d,k]);if(r==="create")return i.jsx("select",{className:st.editSelect,value:s,onChange:O=>m==null?void 0:m(O.target.value),"aria-label":x,"data-testid":y?`${y}-select`:void 0,children:c.map(O=>i.jsx("option",{value:O.value,children:O.label},O.value))});if(k.isEditing)return i.jsx("select",{ref:S,className:st.editSelect,value:k.draft,onChange:j,onBlur:N,title:x,"aria-label":x,"data-testid":y?`${y}-select`:void 0,children:c.map(O=>i.jsx("option",{value:O.value,children:O.label},O.value))});const T=g==null?void 0:g(s),C=(A=c.find(O=>O.value===s))==null?void 0:A.label;return i.jsxs("button",{type:"button",className:st.metaValueClickable,onClick:()=>k.startEdit(),title:"Click to change","aria-label":x,"data-testid":y?`${y}-button`:void 0,children:[T!==void 0?T:C?i.jsx("span",{children:C}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function F6(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return i.jsxs("label",{className:st.worktreeToggle,"data-testid":d,children:[i.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),i.jsx("span",{children:r})]})}const Z6="_envRow_1e1r5_1",K6="_envDot_1e1r5_7",Y6="_envDotGreen_1e1r5_14",J6="_envDotYellow_1e1r5_18",W6="_envDotRed_1e1r5_22",X6="_envDotGray_1e1r5_26",Mo={envRow:Z6,envDot:K6,envDotGreen:Y6,envDotYellow:J6,envDotRed:W6,envDotGray:X6};function Q6(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?Mo.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?Mo.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?Mo.envDotRed:Mo.envDotGray}function eI(t){const{value:s,onSave:o,environments:r,allowNone:c=!1,fieldId:d="environment",activeFieldId:u,onActivate:p,placeholder:m="No environment",ariaLabel:g="Environment","data-testid":v}=t,x=r.find(k=>k.id===s),y=[...c?[{value:"",label:"None"}]:[],...r.map(k=>({value:k.id,label:k.displayName}))],S=()=>{if(x)return i.jsxs("span",{className:Mo.envRow,children:[i.jsx("span",{className:`${Mo.envDot} ${Q6(x.status)}`}),x.displayName]})};return i.jsx(Po,{value:s,onSave:o,options:y,fieldId:d,activeFieldId:u,onActivate:p,renderDisplay:S,placeholder:m,ariaLabel:g,"data-testid":v})}const tI="_nav_1snmp_1",nI="_searchForm_1snmp_8",sI="_searchInput_1snmp_15",aI="_searchButton_1snmp_33",iI="_clearButton_1snmp_68",oI="_workspaceSelect_1snmp_85",rI="_listHeader_1snmp_99",lI="_nodeList_1snmp_108",cI="_nodeItem_1snmp_116",dI="_indicator_1snmp_129",uI="_label_1snmp_136",fI="_badge_1snmp_145",Wn={nav:tI,searchForm:nI,searchInput:sI,searchButton:aI,clearButton:iI,workspaceSelect:oI,listHeader:rI,nodeList:lI,nodeItem:cI,indicator:dI,label:uI,badge:fI};function pI({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=b.useState(""),v=b.useCallback(k=>{k.preventDefault(),m.trim()&&c(m.trim())},[m,c]),x=b.useCallback(()=>{g(""),d()},[d]),y=b.useCallback(k=>{u(k)},[u]),S=b.useCallback(k=>{g(""),p(k)},[p]);return i.jsxs("div",{className:Wn.nav,"data-testid":"knowledge-nav",children:[i.jsxs("form",{className:Wn.searchForm,onSubmit:v,children:[i.jsx("input",{className:Wn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:k=>{g(k.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),i.jsx("button",{type:"submit",className:Wn.searchButton,disabled:o,children:"Go"})]}),r&&i.jsx("button",{type:"button",className:Wn.clearButton,onClick:x,children:"Clear search"}),i.jsxs("select",{className:Wn.workspaceSelect,onChange:k=>{S(k.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[i.jsx("option",{value:"",children:"All workspaces"}),s.map(k=>i.jsx("option",{value:k.id,children:k.name},k.id))]}),i.jsxs("div",{className:Wn.listHeader,children:["Nodes (",t.length,")"]}),i.jsx("ul",{className:Wn.nodeList,children:t.map(k=>i.jsxs("li",{className:Wn.nodeItem,onClick:()=>{y(k.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),y(k.id))},role:"button",tabIndex:0,children:[i.jsx("span",{className:Wn.indicator,style:{backgroundColor:k.kind==="reference"?"#4A9EFF":k.category==="decision"?"#22C55E":k.category==="concept"?"#A855F7":k.category==="snippet"?"#6B7280":"#EAB308"}}),i.jsx("span",{className:Wn.label,children:k.label}),i.jsx("span",{className:Wn.badge,children:k.kind==="reference"?k.sourceType:k.category})]},k.id))})]})}const mI="_container_1mq5u_1",hI="_hamburger_1mq5u_33",gI="_brand_1mq5u_49",vI="_brandLogo_1mq5u_68",yI="_info_1mq5u_75",bI="_connectionLabel_1mq5u_90",xI="_connectionDot_1mq5u_103",_I="_connected_1mq5u_106",kI="_disconnected_1mq5u_110",Xs={container:mI,hamburger:hI,brand:gI,brandLogo:vI,info:yI,connectionLabel:bI,connectionDot:xI,connected:_I,disconnected:kI};function SI({connected:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=mt(),u=s.length,p=s.filter(g=>g.status==="connected").length,m=o.filter(g=>["running","idle"].includes(g.status)).length;return i.jsxs("div",{className:Xs.container,children:[r&&i.jsx("button",{type:"button",className:Xs.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:i.jsx(Q2,{size:Nt,"aria-hidden":"true"})}),i.jsx($o,{text:"Home",placement:"bottom",children:i.jsxs("button",{type:"button",className:Xs.brand,onClick:()=>d(Di),"data-testid":"statusbar-brand",children:[i.jsx("img",{src:"/icon-192x192.png",alt:"",className:Xs.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),i.jsxs("div",{className:Xs.info,children:[i.jsxs("span",{"aria-label":t?"Connected":"Disconnected",children:[i.jsx("span",{className:`${Xs.connectionDot} ${t?Xs.connected:Xs.disconnected}`,"aria-hidden":"true",children:i.jsx(Va,{size:bm,fill:"currentColor"})})," ",i.jsx("span",{className:Xs.connectionLabel,"aria-hidden":"true",children:t?"Connected":"Disconnected"})]}),i.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),i.jsxs("span",{children:[m," active"]})]})]})}const TI="_nav_13gkc_1",jI="_tab_13gkc_35",wI="_tabIcon_13gkc_68",NI="_tabLabel_13gkc_79",CI="_tabActive_13gkc_84",Vr={nav:TI,tab:jI,tabIcon:wI,tabLabel:NI,tabActive:CI},id=[{view:"dashboard",label:"Dashboard",icon:i.jsx(P2,{size:Nt}),route:Di,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:i.jsx(tj,{size:Nt}),route:wN,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:i.jsx(N2,{size:Nt}),route:NN,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:i.jsx(sj,{size:Nt}),route:Io,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:i.jsx(b2,{size:Nt}),route:Xx,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:i.jsx(Ex,{size:Nt}),route:Dd,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:i.jsx(mj,{size:Nt}),route:_N,testId:"sidebar-tab-settings"}];function EI(t){return t===Di||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(Xx)?"knowledge":t.startsWith(Dd)?"findings":t.startsWith(Ni)?"settings":"tasks"}function AI({tabs:t=id}){const s=Yt(),o=mt(),r=b.useRef(null),c=EI(s.pathname),d=b.useCallback(p=>{o(p.route)},[o]),u=b.useCallback(p=>{var y,S;const m=(y=r.current)==null?void 0:y.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(k=>k===document.activeElement),v=g>=0?g:t.findIndex(k=>k.view===c);let x=v;if(p.key==="ArrowRight"||p.key==="j"||p.key==="J")p.preventDefault(),x=(v+1)%t.length;else if(p.key==="ArrowLeft"||p.key==="k"||p.key==="K")p.preventDefault(),x=(v-1+t.length)%t.length;else if(p.key==="Home")p.preventDefault(),x=0;else if(p.key==="End")p.preventDefault(),x=t.length-1;else return;o(t[x].route),(S=m[x])==null||S.focus()},[c,o,t]);return i.jsx("nav",{className:Vr.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:u,"data-testid":"sidebar-nav",children:t.map(p=>{const m=p.view===c;return i.jsx($o,{text:p.label,placement:"bottom",children:i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Vr.tab} ${m?Vr.tabActive:""}`,onClick:()=>d(p),"data-testid":p.testId,"aria-label":p.label,children:[i.jsx("span",{className:Vr.tabIcon,"aria-hidden":"true",children:p.icon}),i.jsx("span",{className:Vr.tabLabel,children:p.label})]})},p.view)})})}const DI="_container_pi6ii_1",RI="_content_pi6ii_66",Xb={container:DI,content:RI},MI=320,M1=220,I1=600,O1="grackle-sidebar-width";function II(){try{const t=localStorage.getItem(O1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=M1&&s<=I1)return s}}catch{}return MI}function OI(t){try{localStorage.setItem(O1,String(t))}catch{}}function BI({content:t}){const[s]=b.useState(II),o=b.useRef(null);if(b.useEffect(()=>{const r=o.current;if(!r)return;const c=new ResizeObserver(d=>{for(const u of d){const p=u.borderBoxSize[0];if(p){const m=Math.round(p.inlineSize);m>=M1&&m<=I1&&OI(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return i.jsx("div",{className:Xb.container,ref:o,"data-testid":"sidebar",style:{width:s},children:i.jsx("div",{className:Xb.content,children:t})})}const LI="_bar_tnfsh_1",zI="_btnPrimary_tnfsh_32",$I="_statusText_tnfsh_85",PI="_statusCompleted_tnfsh_90",UI="_statusFailed_tnfsh_94",HI="_statusBlocked_tnfsh_98",VI="_hintText_tnfsh_103",jt={bar:LI,btnPrimary:zI,statusText:$I,statusCompleted:PI,statusFailed:UI,statusBlocked:HI,hintText:VI};function qI({sessions:t,tasks:s,environments:o}){const r=mt(),c=Yt(),d=Dt("/sessions/:sessionId"),u=Dt("/tasks/:taskId"),p=Dt("/tasks/:taskId/stream"),m=Dt("/tasks/:taskId/findings"),g=Dt("/tasks/:taskId/edit"),v=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),x=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),y=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),S=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),k=Dt("/sessions/new"),j=Dt("/environments/:environmentId/workspaces/:workspaceId"),N=Dt("/tasks/new"),T=Dt("/chat"),C=Dt("/"),A=Dt("/settings/*"),O=d==null?void 0:d.params.sessionId,E=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(m==null?void 0:m.params.taskId)??(v==null?void 0:v.params.taskId)??(x==null?void 0:x.params.taskId)??(y==null?void 0:y.params.taskId)??(S==null?void 0:S.params.taskId),D=v??x??y??S,U=(D==null?void 0:D.params.environmentId)??(j==null?void 0:j.params.environmentId),B=c.pathname.startsWith("/environments")&&!j&&!D,z=!!T,X=!!k,$=!!j&&!v&&!x&&!y&&!S,J=!!N;if(!!C&&!X&&!$&&!J||!!A||(!!g||!!S)||J||B||X)return i.jsx(i.Fragment,{});if(z)return o.find(G=>G.adapterType==="local"&&G.status==="connected")?i.jsx(i.Fragment,{}):i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Add a local environment to start chatting"})});if($)return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Select a task or click + to create one"})});if(E){const R=s.find(de=>de.id===E);if(!R)return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Loading..."})});const G=new Map(s.map(de=>[de.id,de])),Z=R.dependsOn.some(de=>{const W=G.get(de);return W!==void 0&&W.status!=="complete"});if(R.status==="not_started"){const de=Z?R.dependsOn.map(W=>G.get(W)).filter(W=>W&&W.status!=="complete").map(W=>W.title):[];return i.jsx("div",{className:jt.bar,children:Z?i.jsxs("span",{className:jt.statusBlocked,children:["Blocked by: ",de.join(", ")]}):i.jsx("span",{className:jt.hintText,children:"Use the buttons above to start or manage this task"})})}if(R.status==="working"||R.status==="paused"){const de=R.latestSessionId||void 0,W=de?t.find(ue=>ue.id===de):void 0;return W&&W.status!=="stopped"?i.jsx(i.Fragment,{}):i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Waiting for agent..."})})}if(R.status==="complete")return i.jsxs("div",{className:jt.bar,children:[i.jsx("span",{className:`${jt.statusText} ${jt.statusCompleted}`,children:"Task completed"}),i.jsx("button",{onClick:()=>r(Ii(R.workspaceId,void 0,U)),className:jt.btnPrimary,children:"+ New Task"})]});if(R.status==="failed")return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:`${jt.statusText} ${jt.statusFailed}`,children:"Task failed"})})}if(O){const R=t.find(de=>de.id===O),G=(R==null?void 0:R.status)==="stopped";if(R!==void 0&&!G)return i.jsx(i.Fragment,{});if(G)return i.jsxs("div",{className:jt.bar,children:[i.jsxs("span",{className:`${jt.statusText} ${jt.hintText}`,children:["Session ",R.endReason||R.status]}),i.jsx("button",{onClick:()=>r(Kx(R.environmentId)),className:jt.btnPrimary,children:"+ New Chat"})]})}return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Loading..."})})}const GI="_nav_14i94_1",FI="_tab_14i94_24",ZI="_tabActive_14i94_62",KI="_tabLabel_14i94_75",YI="_statusDot_14i94_81",JI="_pulse_14i94_87",WI="_addButton_14i94_99",XI="_empty_14i94_132",Ba={nav:GI,tab:FI,tabActive:ZI,tabLabel:KI,statusDot:YI,pulse:JI,addButton:WI,empty:XI},QI={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function e5({environments:t}){const s=mt(),o=b.useRef(null),r=Dt("/environments/:environmentId"),c=Dt("/environments/:environmentId/edit"),d=Dt("/environments/:environmentId/workspaces/:workspaceId"),u=Dt("/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=b.useCallback(y=>{s(Ai(y))},[s]),v=b.useCallback(y=>{var T;const S=(T=o.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),j=k>=0?k:t.findIndex(C=>C.id===m);let N=j;if(y.key==="ArrowDown"||y.key==="j"||y.key==="J")y.preventDefault(),N=(j+1)%S.length;else if(y.key==="ArrowUp"||y.key==="k"||y.key==="K")y.preventDefault(),N=(j-1+S.length)%S.length;else if(y.key==="Home")y.preventDefault(),N=0;else if(y.key==="End")y.preventDefault(),N=S.length-1;else return;N<t.length&&s(Ai(t[N].id)),S[N].focus()},[m,t,s]),x=m??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:Ba.nav,"data-testid":"environment-nav",children:[i.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(y=>{const S=y.id===m,k=y.id===x,j=QI[y.status]||"var(--text-tertiary)",N=y.status==="connected";return i.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${Ba.tab} ${S?Ba.tabActive:""}`,onClick:()=>g(y.id),"data-testid":"env-nav-item",children:[i.jsx("span",{className:`${Ba.statusDot} ${N?Ba.pulse:""}`,style:{color:j},"aria-hidden":"true",children:i.jsx(Va,{size:bm,fill:"currentColor"})}),i.jsx("span",{className:Ba.tabLabel,title:y.displayName||y.id,children:y.displayName||y.id})]},y.id)})}),i.jsx("button",{type:"button",className:Ba.addButton,onClick:()=>s(bN),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&i.jsx("div",{className:Ba.empty,children:"No environments yet."})]})}function Uo(t){const s=new Date(t),o=new Date,r=o.getTime()-s.getTime(),c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return"just now";if(d<60)return`${d}m ago`;if(u<24)return`${u}h ago`;if(p===1)return"yesterday";if(p<7)return`${p} days ago`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}function B1(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return"—";const o=new Date,r=s.getTime()-o.getTime();if(r<=0)return"overdue";const c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return`in ${c}s`;if(d<60)return`in ${d}m`;if(u<24)return`in ${u}h`;if(p<7)return`in ${p} day${p===1?"":"s"}`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const Qb={architecture:{text:"var(--accent-blue)",bg:"var(--accent-blue-dim)"},api:{text:"var(--accent-green)",bg:"var(--accent-green-dim)"},bug:{text:"var(--accent-red)",bg:"var(--accent-red-dim)"},decision:{text:"var(--accent-yellow)",bg:"var(--accent-yellow-dim)"},dependency:{text:"var(--accent-purple)",bg:"var(--accent-purple-dim)"},pattern:{text:"var(--accent-cyan)",bg:"var(--accent-cyan-dim)"},general:{text:"var(--text-secondary)",bg:"var(--bg-elevated)"}};function xd(t){return Qb[t]||Qb.general}const t5="_nav_dlm8m_1",n5="_categoryPills_dlm8m_24",s5="_categoryPill_dlm8m_24",a5="_tab_dlm8m_42",i5="_tabActive_dlm8m_80",o5="_tabContent_dlm8m_93",r5="_tabLabel_dlm8m_100",l5="_tabMeta_dlm8m_106",c5="_categoryDot_dlm8m_111",d5="_empty_dlm8m_118",js={nav:t5,categoryPills:n5,categoryPill:s5,tab:a5,tabActive:i5,tabContent:o5,tabLabel:r5,tabMeta:l5,categoryDot:c5,empty:d5};function u5({findings:t,workspaceId:s,environmentId:o}){const r=mt(),c=b.useRef(null),d=Dt("/findings/:findingId"),u=Dt("/environments/:environmentId/workspaces/:workspaceId/findings/:findingId"),p=(d==null?void 0:d.params.findingId)??(u==null?void 0:u.params.findingId),m=b.useMemo(()=>{const y=new Set(t.map(S=>S.category).filter(Boolean));return Array.from(y).sort()},[t]),g=b.useCallback(y=>{r(Gp(y,s,o))},[r,s,o]),v=b.useCallback(y=>{var T;const S=(T=c.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),j=k>=0?k:t.findIndex(C=>C.id===p);let N=j;if(y.key==="ArrowDown"||y.key==="j"||y.key==="J")y.preventDefault(),N=(j+1)%S.length;else if(y.key==="ArrowUp"||y.key==="k"||y.key==="K")y.preventDefault(),N=(j-1+S.length)%S.length;else if(y.key==="Home")y.preventDefault(),N=0;else if(y.key==="End")y.preventDefault(),N=S.length-1;else return;N<t.length&&r(Gp(t[N].id,s,o)),S[N].focus()},[p,t,r,s,o]),x=p??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:js.nav,"data-testid":"findings-nav",children:[m.length>1&&i.jsx("div",{className:js.categoryPills,"data-testid":"findings-nav-categories",children:m.map(y=>i.jsx("span",{className:js.categoryPill,style:{color:xd(y).text},children:y},y))}),i.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(y=>{const S=y.id===p,k=y.id===x;return i.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${js.tab} ${S?js.tabActive:""}`,onClick:()=>g(y.id),"data-testid":"finding-nav-item",children:[i.jsx("span",{className:js.categoryDot,style:{color:xd(y.category).text},"aria-hidden":"true",children:i.jsx(Va,{size:bm,fill:"currentColor"})}),i.jsxs("span",{className:js.tabContent,children:[i.jsx("span",{className:js.tabLabel,title:y.title,children:y.title}),i.jsx("span",{className:js.tabMeta,title:y.createdAt,children:Uo(y.createdAt)})]})]},y.id)})}),t.length===0&&i.jsx("div",{className:js.empty,children:"No findings yet. Agents will post discoveries here."})]})}function f5(t){if(t.length===0)return[];const s=[...t].sort((r,c)=>r[0]-c[0]),o=[[s[0][0],s[0][1]]];for(let r=1;r<s.length;r++){const c=o[o.length-1],[d,u]=s[r];d<=c[1]+1?c[1]=Math.max(c[1],u):o.push([d,u])}return o}function L1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return i.jsx(i.Fragment,{children:t});const r=f5(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 p5(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 m5(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 Sj){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=qa(d);r.push({status:d,label:p.label,style:p,tasks:u})}}for(const[d,u]of o)if(!c.has(d)&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=qa(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const h5="_container_z4i38_1",g5="_header_z4i38_5",v5="_headerActions_z4i38_17",y5="_searchInput_z4i38_23",b5="_searchHighlight_z4i38_56",x5="_groupToggle_z4i38_62",_5="_groupToggleActive_z4i38_89",k5="_addButton_z4i38_93",S5="_taskRow_z4i38_120",T5="_selected_z4i38_140",j5="_expandArrow_z4i38_150",w5="_expanded_z4i38_157",N5="_leafSpacer_z4i38_161",C5="_taskStatusIcon_z4i38_166",E5="_taskTitle_z4i38_170",A5="_workspaceBadge_z4i38_177",D5="_childCountBadge_z4i38_195",R5="_dependencyBadge_z4i38_208",M5="_blockedBadge_z4i38_220",I5="_addChildButton_z4i38_225",O5="_emptyState_z4i38_268",B5="_statusGroupHeader_z4i38_275",L5="_statusGroupIcon_z4i38_294",z5="_statusGroupLabel_z4i38_298",$5="_statusGroupCount_z4i38_303",Ze={container:h5,header:g5,headerActions:v5,searchInput:y5,searchHighlight:b5,groupToggle:x5,groupToggleActive:_5,addButton:k5,taskRow:S5,selected:T5,expandArrow:j5,expanded:w5,leafSpacer:N5,taskStatusIcon:C5,taskTitle:E5,workspaceBadge:A5,childCountBadge:D5,dependencyBadge:R5,blockedBadge:M5,addChildButton:I5,emptyState:O5,statusGroupHeader:B5,statusGroupIcon:L5,statusGroupLabel:z5,statusGroupCount:$5},P5=[{name:"title",weight:2},{name:"description",weight:1}],z1=16,U5=16,$1="grackle-task-group-by-status";function ex(){try{return localStorage.getItem($1)==="true"}catch{return!1}}function H5(t){try{localStorage.setItem($1,String(t))}catch{}}function V5({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:Ze.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:`${Ze.expandArrow} ${s?Ze.expanded:""}`,"aria-hidden":"true",children:i.jsx(la,{size:dt})}),i.jsx("span",{className:Ze.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),i.jsx("span",{className:Ze.statusGroupLabel,children:t.label}),i.jsx("span",{className:Ze.statusGroupCount,children:t.tasks.length})]}),i.jsx(gs,{children:s&&i.jsx(Mt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},style:{overflow:"hidden"},children:t.tasks.map(p=>{const m=qa(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return i.jsxs("div",{onClick:()=>c(On(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:x=>{x.currentTarget===x.target&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),c(On(p.id)))},className:`${Ze.taskRow} ${g?Ze.selected:""}`,style:{"--task-indent":`${z1}px`},"data-task-id":p.id,children:[i.jsx("span",{className:Ze.leafSpacer}),i.jsx("span",{className:Ze.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${pl(p.status)}`,children:m.icon}),i.jsx("span",{className:Ze.taskTitle,title:p.title,children:i.jsx(L1,{text:p.title,indices:d.get(p.id),highlightClass:Ze.searchHighlight})}),v&&i.jsx("span",{className:Ze.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function P1({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=qa(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),x=o.has(t.id),y=t.children.length>0,S=c===t.id,k=z1+s*U5,N=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{onClick:()=>d(On(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:T=>{T.currentTarget===T.target&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(On(t.id)))},className:`${Ze.taskRow} ${S?Ze.selected:""}`,style:{"--task-indent":`${k}px`},"data-task-id":t.id,children:[y&&i.jsx("span",{className:`${Ze.expandArrow} ${x?Ze.expanded:""}`,role:"button",tabIndex:0,"aria-label":x?"Collapse task":"Expand task",onClick:T=>{T.stopPropagation(),r(t.id)},onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),T.stopPropagation(),r(t.id))},children:i.jsx(la,{size:dt,"aria-hidden":"true"})}),!y&&i.jsx("span",{className:Ze.leafSpacer}),i.jsx("span",{className:Ze.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${pl(t.status)}`,children:g.icon}),i.jsx("span",{className:Ze.taskTitle,title:t.title,children:i.jsx(L1,{text:t.title,indices:p.get(t.id),highlightClass:Ze.searchHighlight})}),N&&i.jsx("span",{className:Ze.workspaceBadge,title:N,children:N}),y&&i.jsxs("span",{className:Ze.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&i.jsx("span",{className:`${Ze.dependencyBadge} ${v?Ze.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<DT&&i.jsx($o,{text:"Add child task",children:i.jsx("button",{onClick:T=>{T.stopPropagation(),d(Ii(t.workspaceId,t.id))},"aria-label":"Add child task",className:Ze.addChildButton,children:"+"})})]}),i.jsx(gs,{children:y&&x&&i.jsx(Mt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:t.children.map(T=>i.jsx(P1,{node:T,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function q5({workspaces:t,tasks:s}){const o=mt(),[r,c]=b.useState(new Set),[d,u]=b.useState(new Set),[p,m]=b.useState(ex),[g,v]=b.useState(ex),[x,y]=b.useState(new Map),S=Dt("/tasks/:taskId/*"),k=(S==null?void 0:S.params.taskId)!=="new"?S==null?void 0:S.params.taskId:void 0,j=b.useMemo(()=>new Map(s.map(ee=>[ee.id,ee.status])),[s]),N=b.useMemo(()=>new Map(t.map(ee=>[ee.id,ee.name])),[t]),T=()=>{const ee=!p;H5(ee),m(ee),ee&&(v(!0),y(new Map))},C=ee=>{y(oe=>{const R=new Map(oe),G=R.has(ee)?R.get(ee):g;return R.set(ee,!G),R})},A=ee=>x.has(ee)?x.get(ee):g,O=ee=>{c(oe=>{const R=new Set(oe);return R.has(ee)?(R.delete(ee),u(G=>new Set(G).add(ee))):(R.add(ee),u(G=>{const Z=new Set(G);return Z.delete(ee),Z})),R})};b.useEffect(()=>{const ee=new Set(s.filter(oe=>oe.parentTaskId).map(oe=>oe.parentTaskId));ee.size>0&&c(oe=>{const R=new Set(oe);for(const G of ee)d.has(G)||R.add(G);return R})},[s,d]);const[E,D]=b.useState(""),{directMatchTaskIds:U,treeMatchTaskIds:B,titleHighlights:z}=b.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const ee=AT(s,E,P5),oe=new Set(ee.map(de=>de.item.id)),R=new Map;for(const de of ee){const W=de.matches.find(Q=>Q.key==="title");W&&R.set(de.item.id,W.indices)}const G=new Set(oe),Z=new Map(s.map(de=>[de.id,de]));for(const de of[...oe]){let W=Z.get(de);for(;W!=null&&W.parentTaskId;)G.add(W.parentTaskId),W=Z.get(W.parentTaskId)}return{directMatchTaskIds:oe,treeMatchTaskIds:G,titleHighlights:R}},[E,s]),X=U!==null,$=X?p?U:B:null,J=$?s.filter(ee=>$.has(ee.id)):s,me=p?[]:p5(J);return i.jsxs("div",{className:Ze.container,children:[i.jsxs("div",{className:Ze.header,children:[i.jsx("span",{children:"Tasks"}),i.jsxs("div",{className:Ze.headerActions,children:[i.jsx($o,{text:p?"Switch to tree view":"Group tasks by status",children:i.jsx("button",{className:`${Ze.groupToggle} ${p?Ze.groupToggleActive:""}`,onClick:T,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:i.jsx(Y2,{size:nn})})}),i.jsx($o,{text:"New task",children:i.jsx("button",{className:Ze.addButton,onClick:()=>o(Ii()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&i.jsx("input",{type:"text",value:E,onChange:ee=>D(ee.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Ze.searchInput,"data-testid":"sidebar-search"}),p?m5(J,j).map(ee=>i.jsx(V5,{group:ee,isExpanded:A(ee.status),onToggle:()=>C(ee.status),selectedTaskId:k,navigate:o,titleHighlights:z,workspaceNames:N},ee.status)):me.map(ee=>i.jsx(P1,{node:ee,depth:0,expandedTasks:r,toggleTask:O,selectedTaskId:k,navigate:o,taskStatusById:j,titleHighlights:z,workspaceNames:N},ee.id)),J.length===0&&!X&&i.jsx("div",{className:Ze.emptyState,children:"No tasks yet. Click + to create one."}),J.length===0&&X&&i.jsx("div",{className:Ze.emptyState,children:"No matching tasks"})]})}const G5="_toast_ed2dk_1",F5="_success_ed2dk_18",Z5="_icon_ed2dk_22",K5="_error_ed2dk_25",Y5="_warning_ed2dk_32",J5="_info_ed2dk_38",W5="_message_ed2dk_53",X5="_close_ed2dk_60",qr={toast:G5,success:F5,icon:Z5,error:K5,warning:Y5,info:J5,message:W5,close:X5},Q5={success:i.jsx(Ri,{size:Nt}),error:i.jsx(Ka,{size:Nt}),warning:i.jsx(ym,{size:Nt}),info:i.jsx(vm,{size:Nt})};function eO({toast:t,onDismiss:s}){return b.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),i.jsxs(Mt.div,{className:`${qr.toast} ${qr[t.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[i.jsx("span",{className:qr.icon,"aria-hidden":"true",children:Q5[t.variant]}),i.jsx("span",{className:qr.message,children:t.message}),i.jsx("button",{type:"button",className:qr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:i.jsx(Ka,{size:nn,"aria-hidden":"true"})})]})}const tO="_container_qqse2_1",nO={container:tO};function sO({toasts:t,onDismiss:s}){return i.jsx("div",{className:nO.container,"data-testid":"toast-container",children:i.jsx(gs,{children:t.map(o=>i.jsx(eO,{toast:o,onDismiss:s},o.id))})})}const aO="_callout_e5awm_1",iO="_success_e5awm_11",oO="_icon_e5awm_15",rO="_error_e5awm_18",lO="_warning_e5awm_25",cO="_info_e5awm_32",dO="_content_e5awm_48",uO="_close_e5awm_53",Gr={callout:aO,success:iO,icon:oO,error:rO,warning:lO,info:cO,content:dO,close:uO},fO={success:i.jsx(Ri,{size:Nt}),error:i.jsx(Ka,{size:Nt}),warning:i.jsx(ym,{size:Nt}),info:i.jsx(vm,{size:Nt})};function pO({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=b.useState(!1);return i.jsx(i.Fragment,{children:!c&&i.jsxs("div",{className:[Gr.callout,Gr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[i.jsx("span",{className:Gr.icon,"aria-hidden":"true",children:fO[t]}),i.jsx("span",{className:Gr.content,children:s}),o&&i.jsx("button",{type:"button",className:Gr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:i.jsx(Ka,{size:nn,"aria-hidden":"true"})})]})})}function mO({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(pO,{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 hO="_container_de44x_1",gO="_emptyState_de44x_8",vO="_card_de44x_14",yO="_cardClickable_de44x_34",bO="_cardHeader_de44x_42",xO="_categoryBadge_de44x_54",_O="_findingTitle_de44x_62",kO="_findingDate_de44x_68",SO="_findingContent_de44x_80",TO="_tags_de44x_86",jO="_tag_de44x_86",fs={container:hO,emptyState:gO,card:vO,cardClickable:yO,cardHeader:bO,categoryBadge:xO,findingTitle:_O,findingDate:kO,findingContent:SO,tags:TO,tag:jO};function U1({findings:t,onFindingClick:s}){return t.length===0?i.jsx("div",{className:fs.emptyState,children:"No findings yet. Agents will post discoveries here."}):i.jsx("div",{className:fs.container,children:t.map((o,r)=>{const c=xd(o.category),d=s?Mt.button:Mt.div;return i.jsxs(d,{type:s?"button":void 0,className:`${fs.card} ${s?fs.cardClickable:""}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:r*.05,duration:.2},onClick:s?()=>{s(o.id)}:void 0,children:[i.jsxs("div",{className:fs.cardHeader,children:[i.jsx("span",{className:fs.categoryBadge,style:{background:c.bg,color:c.text},children:o.category}),i.jsx("span",{className:fs.findingTitle,children:o.title}),i.jsx("span",{className:fs.findingDate,title:o.createdAt,children:Uo(o.createdAt)})]}),i.jsx("div",{className:fs.findingContent,children:o.content.length>300?o.content.slice(0,300)+"...":o.content}),o.tags.length>0&&i.jsx("div",{className:fs.tags,children:o.tags.map(u=>i.jsx("span",{className:fs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},o.id)})})}const wO="_container_1ingb_1",NO="_heading_1ingb_7",CO="_section_1ingb_14",EO="_sectionTitle_1ingb_26",AO="_sectionDescription_1ingb_35",DO="_emptyState_1ingb_41",RO="_tokenList_1ingb_48",MO="_tokenRow_1ingb_55",IO="_tokenBadge_1ingb_68",OO="_tokenName_1ingb_83",BO="_tokenTarget_1ingb_90",LO="_deleteButton_1ingb_99",zO="_addForm_1ingb_113",$O="_formRow_1ingb_119",PO="_input_1ingb_125",UO="_select_1ingb_155",HO="_addButton_1ingb_187",VO="_emptyStateInfo_1ingb_221",qO="_themeOptions_1ingb_229",GO="_themeOption_1ingb_229",FO="_themeOptionSelected_1ingb_254",ZO="_themeOptionHeader_1ingb_259",KO="_themeOptionLabel_1ingb_266",YO="_themeOptionDesc_1ingb_273",JO="_variantToggle_1ingb_279",WO="_variantButton_1ingb_286",XO="_variantActive_1ingb_305",QO="_themeSwatches_1ingb_311",eB="_themeSwatch_1ingb_311",tB="_systemToggle_1ingb_325",nB="_systemToggleHint_1ingb_341",sB="_themeActive_1ingb_348",aB="_aboutGrid_1ingb_354",iB="_aboutItem_1ingb_360",oB="_aboutLabel_1ingb_373",rB="_aboutValue_1ingb_379",lB="_aboutDot_1ingb_387",cB="_aboutDotConnected_1ingb_394",dB="_aboutDotDisconnected_1ingb_398",he={container:wO,heading:NO,section:CO,sectionTitle:EO,sectionDescription:AO,emptyState:DO,tokenList:RO,tokenRow:MO,tokenBadge:IO,tokenName:OO,tokenTarget:BO,deleteButton:LO,addForm:zO,formRow:$O,input:PO,select:UO,addButton:HO,emptyStateInfo:VO,themeOptions:qO,themeOption:GO,themeOptionSelected:FO,themeOptionHeader:ZO,themeOptionLabel:KO,themeOptionDesc:YO,variantToggle:JO,variantButton:WO,variantActive:XO,themeSwatches:QO,themeSwatch:eB,systemToggle:tB,systemToggleHint:nB,themeActive:sB,aboutGrid:aB,aboutItem:iB,aboutLabel:oB,aboutValue:rB,aboutDot:lB,aboutDotConnected:cB,aboutDotDisconnected:dB},uB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function fB({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=b.useState(""),[u,p]=b.useState(""),[m,g]=b.useState("env_var"),[v,x]=b.useState(""),[y,S]=b.useState(null),k=T=>{if(T.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),x("")},j=T=>{S(T)},N=()=>{y&&(o(y),r==null||r("Token deleted","info")),S(null)};return i.jsxs(i.Fragment,{children:[i.jsx(oa,{isOpen:y!==null,title:"Delete Token?",description:y?`"${y}" will be permanently removed.`:void 0,onConfirm:N,onCancel:()=>S(null)}),i.jsxs("section",{className:he.section,children:[i.jsx("h3",{className:he.sectionTitle,children:"Tokens"}),i.jsx("p",{className:he.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?i.jsx("div",{className:he.emptyStateInfo,children:"Add your first API token to enable service integrations."}):i.jsx("div",{className:he.tokenList,children:t.map(T=>i.jsxs("div",{className:he.tokenRow,children:[i.jsx("span",{className:he.tokenBadge,children:T.tokenType}),i.jsx("span",{className:he.tokenName,children:T.name}),i.jsx("span",{className:he.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),i.jsx("button",{className:he.deleteButton,onClick:()=>j(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:i.jsx(Ka,{size:nn,"aria-hidden":"true"})})]},T.name))}),i.jsxs("form",{className:he.addForm,onSubmit:k,children:[i.jsxs("div",{className:he.formRow,children:[i.jsx("input",{className:he.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),i.jsx("input",{className:he.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),i.jsxs("div",{className:he.formRow,children:[i.jsx("select",{className:he.select,value:m,onChange:T=>g(T.target.value),children:uB.map(T=>i.jsx("option",{value:T.value,children:T.label},T.value))}),i.jsx("input",{className:he.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:T=>x(T.target.value)}),i.jsx("button",{className:he.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const zd=[{id:"grackle",label:"Grackle",description:"The default Grackle theme — iridescent purple on clean dark.",swatches:["#0e1218","#8b5cf6","#60a5fa","#e5e7eb","#34d399"],variantLightId:"grackle-light",variantDarkId:"grackle-dark"},{id:"grackle-light",label:"Grackle Light",description:"Light Grackle variant.",hidden:!0},{id:"grackle-dark",label:"Grackle Dark",description:"Dark Grackle variant.",hidden:!0},{id:"glass",label:"Glassmorphism",description:"Dark frosted-glass aesthetic with backdrop blur effects.",swatches:["#0a0c14","#4ecca3","#70a1ff","#e2e8f0","#a855f7"]},{id:"matrix",label:"Matrix",description:"Phosphor-green CRT terminal with scanlines and glow.",swatches:["#050505","#00ff41","#00bfff","#33ff77","#ffb000"]},{id:"brutalist",label:"Neubrutalism",description:"Thick borders, raw colors, bold type — ugly on purpose.",swatches:["#f5f0e8","#ff5757","#5ce1e6","#1a1a1a","#ffde59"],variantLightId:"brutalist-light",variantDarkId:"brutalist-dark"},{id:"brutalist-light",label:"Neubrutalism Light",description:"Light neubrutalism variant.",hidden:!0},{id:"brutalist-dark",label:"Neubrutalism Dark",description:"Dark neubrutalism variant.",hidden:!0},{id:"monokai",label:"Monokai",description:"Classic warm editor palette — pink, green, and purple.",swatches:["#272822","#f92672","#a6e22e","#f8f8f2","#ae81ff"],variantLightId:"monokai-light",variantDarkId:"monokai-dark"},{id:"monokai-dark",label:"Monokai Dark",description:"Dark Monokai variant.",hidden:!0},{id:"monokai-light",label:"Monokai Light",description:"Light Monokai variant.",hidden:!0},{id:"ubuntu",label:"Ubuntu",description:"Aubergine terminal with the GNOME Tango palette.",swatches:["#300a24","#8ae234","#ef2929","#eeeeec","#fce94f"]},{id:"sandstone",label:"Sandstone",description:"Warm terracotta accent on dark brown, in the style of Claude Code.",swatches:["#1a1815","#C15F3C","#6b8afd","#e8e6e3","#a78bfa"]},{id:"verdigris",label:"Verdigris",description:"Teal accent on charcoal, in the style of ChatGPT.",swatches:["#141414","#00a67e","#3b82f6","#ececec","#ab68ff"]},{id:"primer",label:"Primer",description:"Blue accent on ink-dark grey, in the style of GitHub.",swatches:["#0d1117","#58a6ff","#3fb950","#c9d1d9","#bc8cff"]}],H1=new Set(zd.map(t=>t.id)),tx="grackle";function um(t){return zd.find(s=>s.id===t)}function pB({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return i.jsxs("section",{className:he.section,children:[i.jsx("h3",{className:he.sectionTitle,children:"Appearance"}),i.jsx("p",{className:he.sectionDescription,children:"Choose how Grackle looks across the app."}),i.jsx("div",{className:he.themeOptions,children:zd.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?t===d.id||t===d.variantLightId||t===d.variantDarkId:t===d.id,m=u&&s===d.variantLightId;return i.jsxs("button",{type:"button",className:`${he.themeOption} ${p?he.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[i.jsxs("span",{className:he.themeOptionHeader,children:[i.jsxs("span",{children:[i.jsx("span",{className:he.themeOptionLabel,children:d.label}),i.jsx("span",{className:he.themeOptionDesc,children:d.description})]}),u&&i.jsxs("span",{className:he.variantToggle,children:[i.jsx("span",{role:"button",tabIndex:0,className:`${he.variantButton} ${p&&m?he.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:`${he.variantButton} ${p&&!m?he.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:he.themeSwatches,children:d.swatches.map((g,v)=>i.jsx("span",{className:he.themeSwatch,style:{background:g}},v))})]},d.id)})}),i.jsxs("label",{className:he.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:he.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),i.jsxs("p",{className:he.themeActive,children:["Active theme: ",i.jsx("strong",{children:s})]})]})}function mB({connected:t,environments:s,sessions:o}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=o.filter(u=>["running","idle"].includes(u.status)).length;return i.jsxs("section",{className:he.section,"data-testid":"about-panel",children:[i.jsx("h3",{className:he.sectionTitle,children:"About"}),i.jsx("p",{className:he.sectionDescription,children:"Connection status and application information."}),i.jsxs("div",{className:he.aboutGrid,children:[i.jsxs("div",{className:he.aboutItem,children:[i.jsx("span",{className:he.aboutLabel,children:"Connection"}),i.jsxs("span",{className:he.aboutValue,children:[i.jsx("span",{className:`${he.aboutDot} ${t?he.aboutDotConnected:he.aboutDotDisconnected}`}),t?"Connected":"Disconnected"]})]}),i.jsxs("div",{className:he.aboutItem,children:[i.jsx("span",{className:he.aboutLabel,children:"Environments"}),i.jsxs("span",{className:he.aboutValue,children:[r,"/",c," connected"]})]}),i.jsxs("div",{className:he.aboutItem,children:[i.jsx("span",{className:he.aboutLabel,children:"Active Sessions"}),i.jsx("span",{className:he.aboutValue,children:d})]}),i.jsxs("div",{className:he.aboutItem,children:[i.jsx("span",{className:he.aboutLabel,children:"Version"}),i.jsx("span",{className:he.aboutValue,children:"0.103.0"})]})]})]})}const hB="_container_cddyd_1",gB="_header_cddyd_8",vB="_headerTitle_cddyd_35",yB="_badge_cddyd_44",bB="_headerActions_cddyd_54",xB="_body_cddyd_61",_B="_formContent_cddyd_73",kB="_section_cddyd_85",SB="_label_cddyd_91",TB="_titleInput_cddyd_98",jB="_descriptionTextarea_cddyd_131",wB="_parentContext_cddyd_167",NB="_parentLabel_cddyd_175",CB="_parentName_cddyd_182",EB="_personaSelect_cddyd_186",AB="_depList_cddyd_220",DB="_depItem_cddyd_226",RB="_depItemSelected_cddyd_248",MB="_noDeps_cddyd_252",IB="_btnPrimary_cddyd_258",OB="_btnGhost_cddyd_289",nt={container:hB,header:gB,headerTitle:vB,badge:yB,headerActions:bB,body:xB,formContent:_B,section:kB,label:SB,titleInput:TB,descriptionTextarea:jB,parentContext:wB,parentLabel:NB,parentName:CB,personaSelect:EB,depList:AB,depItem:DB,depItemSelected:RB,noDeps:MB,btnPrimary:IB,btnGhost:OB};function V1({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:x}){const y=mt(),S=t==="edit",k=S&&s?d.find(xe=>xe.id===s):void 0,j=S?(k==null?void 0:k.workspaceId)??"":o??"",[N,T]=b.useState(j),C=j||N,A=u.find(xe=>xe.id===C),O=c??(A==null?void 0:A.environmentId),E=!S&&!o,D=S?(k==null?void 0:k.parentTaskId)??"":r??"",U=D?d.find(xe=>xe.id===D):void 0,[B,z]=b.useState((k==null?void 0:k.title)??""),[X,$]=b.useState((k==null?void 0:k.description)??""),[J,me]=b.useState((k==null?void 0:k.dependsOn)??[]),[ee,oe]=b.useState((k==null?void 0:k.defaultPersonaId)??""),[R,G]=b.useState((k==null?void 0:k.canDecompose)??!1),[Z,de]=b.useState(!1),W=b.useRef(!1);b.useEffect(()=>{S&&k&&!W.current&&(W.current=!0,z(k.title),$(k.description),me(k.dependsOn),oe(k.defaultPersonaId),G(k.canDecompose))},[S,k]);const Q=d.filter(xe=>xe.workspaceId===C&&(!S||xe.id!==s)&&xe.id!==D),ue=B.trim().length>0&&(!S||k!==void 0)&&C.length>0,Ce=xe=>{me(Be=>Be.includes(xe)?Be.filter(It=>It!==xe):[...Be,xe])},Ue=()=>{!ue||Z||S&&k===void 0||(S&&s?(g(s,B.trim(),X,J,ee),x==null||x("Task updated","success"),v?v():y(On(s,void 0,C,O),{replace:!0})):(de(!0),m(C,B.trim(),X,J.length>0?J:void 0,D||void 0,ee,R,()=>{x==null||x("Task created","success"),y(o?Ga(o,O):"/tasks",{replace:!0})},xe=>{x==null||x(xe,"error"),de(!1)})))},ve=()=>{if(v){v();return}y(S&&s?On(s,void 0,C,O):o?Ga(o,O):"/tasks")},Se=S?"edit task":D?"child task":"new task";return i.jsxs("div",{className:nt.container,children:[i.jsxs("div",{className:nt.header,children:[i.jsxs("div",{className:nt.headerTitle,children:[i.jsx("span",{className:nt.badge,children:Se}),U&&i.jsxs("span",{className:nt.parentContext,children:[i.jsx("span",{className:nt.parentLabel,children:"Child of"}),i.jsx("span",{className:nt.parentName,children:U.title})]})]}),i.jsxs("div",{className:nt.headerActions,children:[i.jsx("button",{onClick:Ue,disabled:!ue||Z,className:nt.btnPrimary,"data-testid":"task-edit-save",children:Z?"Creating…":S?"Save Changes":"Create"}),i.jsx("button",{onClick:ve,className:nt.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:nt.body,children:i.jsxs("div",{className:nt.formContent,children:[E&&i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-workspace",children:"Workspace"}),i.jsxs("select",{id:"task-edit-workspace",value:N,onChange:xe=>T(xe.target.value),className:nt.personaSelect,"data-testid":"task-edit-workspace",children:[i.jsx("option",{value:"",children:"Select a workspace..."}),u.map(xe=>i.jsx("option",{value:xe.id,children:xe.name},xe.id))]})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-title",children:"Title"}),i.jsx("input",{id:"task-edit-title",type:"text",value:B,onChange:xe=>z(xe.target.value),placeholder:"Task title...",autoFocus:!0,className:nt.titleInput,"data-testid":"task-edit-title",onKeyDown:xe=>{xe.key==="Enter"&&ue&&Ue()}})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-description",children:"Description"}),i.jsx("textarea",{id:"task-edit-description",value:X,onChange:xe=>$(xe.target.value),placeholder:"Describe the task... (markdown supported)",className:nt.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-persona",children:"Default Persona"}),i.jsxs("select",{id:"task-edit-persona",value:ee,onChange:xe=>oe(xe.target.value),className:nt.personaSelect,"data-testid":"task-edit-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),p.map(xe=>i.jsx("option",{value:xe.id,children:xe.name},xe.id))]})]}),!S&&i.jsx("div",{className:nt.section,children:i.jsxs("label",{className:nt.depItem,"data-testid":"task-edit-can-decompose",children:[i.jsx("input",{type:"checkbox",checked:R,onChange:xe=>G(xe.target.checked)}),"Can spawn subtasks"]})}),i.jsxs("div",{className:nt.section,children:[i.jsx("div",{className:nt.label,children:"Dependencies"}),Q.length===0?i.jsx("div",{className:nt.noDeps,children:"No other tasks in this workspace"}):i.jsx("div",{className:nt.depList,children:Q.map(xe=>{const Be=J.includes(xe.id);return i.jsxs("label",{className:`${nt.depItem} ${Be?nt.depItemSelected:""}`,"data-testid":`dep-option-${xe.id}`,children:[i.jsx("input",{type:"checkbox",checked:Be,onChange:()=>Ce(xe.id)}),xe.title,i.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",xe.status,")"]})]},xe.id)})})]})]})})]})}const BB="_actionButtons_1rjka_1",LB="_btnPrimary_1rjka_8",zB="_btnDanger_1rjka_39",$B="_btnGhost_1rjka_78",Kt={actionButtons:BB,btnPrimary:LB,btnDanger:zB,btnGhost:$B};function PB({task:t,sessionId:s,isBlocked:o,onStart:r,onResume:c,onStop:d,onPause:u,onDelete:p,onEdit:m}){if(t.status==="not_started")return o?i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:m,className:Kt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Kt.btnPrimary,children:"Start"}),i.jsx("button",{onClick:m,className:Kt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Kt.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:u,disabled:!s,className:Kt.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Kt.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:c,className:Kt.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return i.jsx("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:r,className:Kt.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const UB="_workpadSection_y8nj9_1",HB="_workpadLabel_y8nj9_9",VB="_workpadStatus_y8nj9_17",qB="_workpadSummary_y8nj9_23",GB="_workpadExtra_y8nj9_29",La={workpadSection:UB,workpadLabel:HB,workpadStatus:VB,workpadSummary:qB,workpadExtra:GB};function FB({workpad:t}){if(!t)return;let s;try{const o=JSON.parse(t);if(o==null||typeof o!="object"||Array.isArray(o))return;s=o}catch{return i.jsxs("div",{className:La.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:La.workpadLabel,children:"Workpad"}),i.jsx("div",{className:La.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return i.jsxs("div",{className:La.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:La.workpadLabel,children:"Workpad"}),s.status&&i.jsx("div",{className:La.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&i.jsx("div",{className:La.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&i.jsx("div",{className:La.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const ZB="_overviewDashboard_r05qm_1",KB="_overviewHero_r05qm_7",YB="_statusBadge_r05qm_14",JB="_statusPending_r05qm_26",WB="_statusAssigned_r05qm_31",XB="_statusInProgress_r05qm_36",QB="_statusReview_r05qm_41",eL="_statusDone_r05qm_46",tL="_statusFailed_r05qm_51",nL="_statusWaitingInput_r05qm_56",sL="_overviewBranchPill_r05qm_61",aL="_branchLink_r05qm_76",iL="_overviewSection_r05qm_87",oL="_overviewLabel_r05qm_93",rL="_overviewValue_r05qm_100",lL="_overviewMuted_r05qm_105",cL="_overviewMarkdown_r05qm_111",dL="_envRow_r05qm_180",uL="_envDot_r05qm_186",fL="_envDotGreen_r05qm_193",pL="_envDotYellow_r05qm_197",mL="_envDotRed_r05qm_201",hL="_envDotGray_r05qm_205",gL="_depList_r05qm_209",vL="_depItem_r05qm_215",yL="_depBlocked_r05qm_222",bL="_depDone_r05qm_226",xL="_timeline_r05qm_230",_L="_timelineRow_r05qm_236",kL="_timelineKey_r05qm_243",SL="_timelineValue_r05qm_249",TL="_timelineDelta_r05qm_253",jL="_reviewNotes_r05qm_264",ye={overviewDashboard:ZB,overviewHero:KB,statusBadge:YB,statusPending:JB,statusAssigned:WB,statusInProgress:XB,statusReview:QB,statusDone:eL,statusFailed:tL,statusWaitingInput:nL,overviewBranchPill:sL,branchLink:aL,overviewSection:iL,overviewLabel:oL,overviewValue:rL,overviewMuted:lL,overviewMarkdown:cL,envRow:dL,envDot:uL,envDotGreen:fL,envDotYellow:pL,envDotRed:mL,envDotGray:hL,depList:gL,depItem:vL,depBlocked:yL,depDone:bL,timeline:xL,timelineRow:_L,timelineKey:kL,timelineValue:SL,timelineDelta:TL,reviewNotes:jL};function Fc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Ep(t,s){if(!t||!s)return;const o=new Date(s).getTime()-new Date(t).getTime();if(isNaN(o)||o<0)return;const r=Math.floor(o/6e4),c=Math.floor(o%6e4/1e3);if(r===0)return`${c}s`;const d=Math.floor(r/60),u=r%60;return d===0?`${r}m ${c}s`:`${d}h ${u}m`}function nx(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?ye.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?ye.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?ye.envDotRed:ye.envDotGray}function wL({status:t}){const s=qa(t),o=kj(t);return i.jsx("span",{className:`${ye.statusBadge} ${ye[o]??ye.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function NL({task:t,tasksById:s,environments:o,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?o.find(k=>k.id===g):void 0,x=r.find(k=>k.id===t.workspaceId),y=o.find(k=>k.id===d),S=t.branch&&(x!=null&&x.repoUrl)?`${x.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return i.jsxs("div",{className:ye.overviewDashboard,"data-testid":"task-overview-panel",children:[i.jsxs("div",{className:ye.overviewHero,children:[i.jsx(wL,{status:t.status}),t.branch&&i.jsx("span",{className:ye.overviewBranchPill,"data-testid":"task-overview-branch",children:S?i.jsxs("a",{href:S,target:"_blank",rel:"noreferrer noopener",className:ye.branchLink,children:["🔗"," ",t.branch]}):i.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&i.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-description",children:[i.jsx("div",{className:ye.overviewLabel,children:"Description"}),i.jsx("div",{className:ye.overviewMarkdown,children:i.jsx(Td,{remarkPlugins:[jd],children:t.description})})]}),t.workpad&&i.jsx(FB,{workpad:t.workpad}),i.jsxs("div",{className:ye.overviewSection,children:[i.jsx("div",{className:ye.overviewLabel,children:"Environment"}),g&&v?i.jsxs("div",{className:ye.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${ye.envDot} ${nx(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),i.jsx("span",{className:ye.overviewValue,children:v.displayName})]}):y?i.jsxs("div",{className:ye.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${ye.envDot} ${nx(y.status)}`,title:y.status,"aria-label":`Status: ${y.status}`,role:"img"}),i.jsx("span",{className:ye.overviewValue,children:y.displayName}),i.jsx("span",{className:ye.overviewMuted,children:"(workspace default)"})]}):i.jsx("div",{className:ye.overviewMuted,children:"Set in workspace settings"})]}),i.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-dependencies",children:[i.jsx("div",{className:ye.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?i.jsx("div",{className:ye.overviewMuted,children:"None"}):i.jsx("div",{className:ye.depList,children:t.dependsOn.map(k=>{const j=s.get(k),N=(j==null?void 0:j.status)==="complete";return i.jsxs("div",{className:`${ye.depItem} ${N?ye.depDone:ye.depBlocked}`,children:[i.jsx("span",{children:N?"✓":"○"}),i.jsx("span",{children:(j==null?void 0:j.title)??k})]},k)})})]}),i.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-timeline",children:[i.jsx("div",{className:ye.overviewLabel,children:"Timeline"}),i.jsxs("div",{className:ye.timeline,children:[t.createdAt&&i.jsxs("div",{className:ye.timelineRow,children:[i.jsx("span",{className:ye.timelineKey,children:"Created"}),i.jsx("span",{className:ye.timelineValue,children:Fc(t.createdAt)})]}),t.assignedAt&&(()=>{const k=Ep(t.createdAt,t.assignedAt);return i.jsxs("div",{className:ye.timelineRow,children:[i.jsx("span",{className:ye.timelineKey,children:"Assigned"}),i.jsx("span",{className:ye.timelineValue,children:Fc(t.assignedAt)}),k!==void 0&&i.jsx("span",{className:ye.timelineDelta,children:k})]})})(),t.startedAt&&(()=>{const k=Ep(t.assignedAt??t.createdAt,t.startedAt);return i.jsxs("div",{className:ye.timelineRow,children:[i.jsx("span",{className:ye.timelineKey,children:"Started"}),i.jsx("span",{className:ye.timelineValue,children:Fc(t.startedAt)}),k!==void 0&&i.jsx("span",{className:ye.timelineDelta,children:k})]})})(),t.completedAt&&(()=>{const k=Ep(t.startedAt,t.completedAt);return i.jsxs("div",{className:ye.timelineRow,children:[i.jsx("span",{className:ye.timelineKey,children:"Completed"}),i.jsx("span",{className:ye.timelineValue,children:Fc(t.completedAt)}),k!==void 0&&i.jsx("span",{className:ye.timelineDelta,children:k})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&i.jsx("div",{className:ye.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&i.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-usage",children:[i.jsx("div",{className:ye.overviewLabel,children:"Usage"}),i.jsxs("div",{className:ye.timeline,children:[i.jsxs("div",{className:ye.timelineRow,children:[i.jsx("span",{className:ye.timelineKey,children:"Cost"}),i.jsx("span",{className:ye.timelineValue,children:Ns(u.costMillicents)}),i.jsxs("span",{className:ye.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&i.jsxs("div",{className:ye.timelineRow,children:[i.jsx("span",{className:ye.timelineKey,children:"Total (incl. subtasks)"}),i.jsx("span",{className:ye.timelineValue,children:Ns(p.costMillicents)}),i.jsxs("span",{className:ye.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&i.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-budget",children:[i.jsx("div",{className:ye.overviewLabel,children:"Budget"}),i.jsxs("div",{className:ye.timeline,children:[t.tokenBudget>0&&i.jsxs("div",{className:ye.timelineRow,children:[i.jsx("span",{className:ye.timelineKey,children:"Tokens"}),i.jsxs("span",{className:ye.timelineValue,children:[Oo(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",Oo(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&i.jsxs("div",{className:ye.timelineRow,children:[i.jsx("span",{className:ye.timelineKey,children:"Cost"}),i.jsxs("span",{className:ye.timelineValue,children:[Ns((u==null?void 0:u.costMillicents)??0)," / ",Ns(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&i.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-review-notes",children:[i.jsx("div",{className:ye.overviewLabel,children:"Review Notes"}),i.jsx("div",{className:ye.reviewNotes,children:t.reviewNotes})]})]})}function CL({plugins:t,loading:s,onSetPluginEnabled:o}){return i.jsxs("div",{className:he.container,"data-testid":"plugins-panel",children:[i.jsx("h2",{className:he.heading,children:"Plugins"}),i.jsxs("div",{className:he.section,children:[i.jsx("p",{className:he.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&i.jsx("p",{className:he.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&i.jsx("p",{className:he.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return i.jsxs("div",{className:he.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:he.tokenName,children:r.name}),r.required&&i.jsx("span",{className:he.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),i.jsx("div",{className:he.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)})]})]})}const EL="_container_legrg_1",AL="_header_legrg_8",DL="_headerTitle_legrg_35",RL="_badge_legrg_44",ML="_headerActions_legrg_54",IL="_body_legrg_61",OL="_formContent_legrg_73",BL="_section_legrg_85",LL="_label_legrg_91",zL="_nameInput_legrg_98",$L="_fieldInput_legrg_131",PL="_adapterSelect_legrg_164",UL="_readOnlyValue_legrg_198",HL="_codespaceSection_legrg_204",VL="_codespaceActions_legrg_210",qL="_creatingHint_legrg_216",GL="_errorHint_legrg_222",FL="_btnPrimary_legrg_235",ZL="_btnGhost_legrg_266",ce={container:EL,header:AL,headerTitle:DL,badge:RL,headerActions:ML,body:IL,formContent:OL,section:BL,label:LL,nameInput:zL,fieldInput:$L,adapterSelect:PL,readOnlyValue:UL,codespaceSection:HL,codespaceActions:VL,creatingHint:qL,errorHint:GL,btnPrimary:FL,btnGhost:ZL},od=1,rd=65535;function Ap(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=od&&s<=rd}function Dp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function KL({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=b.useState("pick"),[x,y]=b.useState(""),[S,k]=b.useState("");return g==="create"?i.jsxs("div",{className:ce.codespaceSection,children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Repository"}),i.jsx("input",{type:"text",value:x,onChange:j=>y(j.target.value),placeholder:"owner/repo",className:ce.fieldInput,"data-testid":"env-codespace-repo"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Machine Type"}),i.jsx("input",{type:"text",value:S,onChange:j=>k(j.target.value),placeholder:"Machine type (optional)...",className:ce.fieldInput,"data-testid":"env-codespace-machine"})]}),i.jsxs("div",{className:ce.codespaceActions,children:[i.jsx("button",{onClick:()=>{x.trim()&&(m(x.trim(),S.trim()||void 0),v("pick"),y(""),k(""))},disabled:!x.trim(),className:ce.btnPrimary,children:"Create"}),i.jsx("button",{onClick:()=>{v("pick"),y(""),k("")},className:ce.btnGhost,children:"Cancel"})]})]}):i.jsx("div",{className:ce.codespaceSection,children:i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Codespace"}),!u&&i.jsxs("select",{value:t,onChange:j=>{j.target.value==="__create__"?(v("create"),s("")):(s(j.target.value),j.target.value&&!o.trim()&&r(j.target.value))},disabled:p,className:ce.adapterSelect,"data-testid":"env-codespace-select",children:[i.jsx("option",{value:"",children:"Select a codespace..."}),c.map(j=>i.jsxs("option",{value:j.name,children:[j.name," (",j.repository,") — ",j.state]},j.name)),i.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&i.jsx("span",{className:ce.creatingHint,children:"Creating codespace..."}),u&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:ce.errorHint,children:u}),i.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:ce.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&i.jsx("span",{className:ce.errorHint,children:d})]})})}function q1({mode:t,environmentId:s,environments:o,onAddEnvironment:r,onUpdateEnvironment:c,onListCodespaces:d,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v,onShowToast:x}){const y=mt(),S=t==="edit",k=S&&s?o.find(ve=>ve.id===s):void 0,[j,N]=b.useState(""),[T,C]=b.useState("local"),[A,O]=b.useState(""),[E,D]=b.useState(""),[U,B]=b.useState(""),[z,X]=b.useState(""),[$,J]=b.useState(""),[me,ee]=b.useState(""),[oe,R]=b.useState(""),[G,Z]=b.useState(null),de=b.useCallback(()=>{const ve={};if(T==="local"){if(A.trim()&&(ve.host=A.trim()),E.trim()){const Se=Number(E);Number.isInteger(Se)&&(ve.port=Se)}}else if(T==="ssh"){if(ve.host=A.trim(),U.trim()&&(ve.user=U.trim()),E.trim()){const Se=Number(E);Number.isInteger(Se)&&(ve.sshPort=Se)}z.trim()&&(ve.identityFile=z.trim())}else T==="docker"?($.trim()&&(ve.image=$.trim()),me.trim()&&(ve.repo=me.trim())):T==="codespace"&&(ve.codespaceName=oe.trim());return ve},[T,A,E,U,z,$,me,oe]),W=()=>!(!j.trim()||T==="ssh"&&!A.trim()||T==="codespace"&&!oe.trim()||(T==="local"||T==="ssh")&&!Ap(E)),Q=()=>{W()&&(r(j.trim(),T,de()),x==null||x("Environment added successfully","success"),y(Io,{replace:!0}))},ue=()=>{y(s?Ai(s):Io)},Ce=b.useCallback((ve,Se)=>{if(!k||!s)return;const xe=Dp(k.adapterConfig),Be=Se.trim();Be?xe[ve]=Be:delete xe[ve],c(s,{adapterConfig:xe})},[k,s,c]),Ue=b.useCallback((ve,Se)=>{if(!k||!s)return;const xe=Dp(k.adapterConfig);if(Se.trim()){const Be=Number(Se);Number.isInteger(Be)&&Be>=od&&Be<=rd&&(xe[ve]=Be)}else delete xe[ve];c(s,{adapterConfig:xe})},[k,s,c]);if(S){if(!k)return i.jsxs("div",{className:ce.container,children:[i.jsxs("div",{className:ce.header,children:[i.jsx("div",{className:ce.headerTitle,children:i.jsx("span",{className:ce.badge,children:"edit environment"})}),i.jsx("div",{className:ce.headerActions,children:i.jsx("button",{onClick:ue,className:ce.btnGhost,children:"Back"})})]}),i.jsx("div",{className:ce.body,children:i.jsx("div",{className:ce.formContent,children:i.jsx("span",{className:ce.readOnlyValue,children:"Environment not found"})})})]});const ve=Dp(k.adapterConfig);return i.jsxs("div",{className:ce.container,"data-testid":"env-edit-panel",children:[i.jsxs("div",{className:ce.header,children:[i.jsx("div",{className:ce.headerTitle,children:i.jsx("span",{className:ce.badge,children:"edit environment"})}),i.jsx("div",{className:ce.headerActions,children:i.jsx("button",{onClick:ue,className:ce.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),i.jsx("div",{className:ce.body,children:i.jsxs("div",{className:ce.formContent,children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Name"}),i.jsx(Ft,{value:k.displayName,onSave:Se=>{s&&c(s,{displayName:Se})},validate:Se=>Se.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:G,onActivate:Z,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Adapter Type"}),i.jsx("span",{className:ce.readOnlyValue,"data-testid":"env-edit-adapter-type",children:k.adapterType})]}),k.adapterType==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Host"}),i.jsx(Ft,{value:String(ve.host??""),onSave:Se=>Ce("host",Se),mode:"edit",fieldId:"host",activeFieldId:G,onActivate:Z,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Port"}),i.jsx(Ft,{value:String(ve.port??""),onSave:Se=>Ue("port",Se),validate:Se=>Ap(Se)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:G,onActivate:Z,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),k.adapterType==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Host"}),i.jsx(Ft,{value:String(ve.host??""),onSave:Se=>Ce("host",Se),validate:Se=>Se.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:G,onActivate:Z,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"User"}),i.jsx(Ft,{value:String(ve.user??""),onSave:Se=>Ce("user",Se),mode:"edit",fieldId:"user",activeFieldId:G,onActivate:Z,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"SSH Port"}),i.jsx(Ft,{value:String(ve.sshPort??""),onSave:Se=>Ue("sshPort",Se),validate:Se=>Ap(Se)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:G,onActivate:Z,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Identity File"}),i.jsx(Ft,{value:String(ve.identityFile??""),onSave:Se=>Ce("identityFile",Se),mode:"edit",fieldId:"identityFile",activeFieldId:G,onActivate:Z,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),k.adapterType==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Image"}),i.jsx(Ft,{value:String(ve.image??""),onSave:Se=>Ce("image",Se),mode:"edit",fieldId:"image",activeFieldId:G,onActivate:Z,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Repo"}),i.jsx(Ft,{value:String(ve.repo??""),onSave:Se=>Ce("repo",Se),mode:"edit",fieldId:"repo",activeFieldId:G,onActivate:Z,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),k.adapterType==="codespace"&&i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Codespace Name"}),i.jsx(Ft,{value:String(ve.codespaceName??""),onSave:Se=>Ce("codespaceName",Se),validate:Se=>Se.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:G,onActivate:Z,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return i.jsxs("div",{className:ce.container,"data-testid":"env-create-panel",children:[i.jsxs("div",{className:ce.header,children:[i.jsx("div",{className:ce.headerTitle,children:i.jsx("span",{className:ce.badge,children:"new environment"})}),i.jsxs("div",{className:ce.headerActions,children:[i.jsx("button",{onClick:Q,disabled:!W(),className:ce.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),i.jsx("button",{onClick:ue,className:ce.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:ce.body,children:i.jsxs("div",{className:ce.formContent,children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-name",children:"Name"}),i.jsx("input",{id:"env-create-name",type:"text",value:j,onChange:ve=>N(ve.target.value),placeholder:"Environment name...",autoFocus:!0,className:ce.nameInput,"data-testid":"env-create-name",onKeyDown:ve=>{ve.key==="Enter"&&W()&&Q()}})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),i.jsxs("select",{id:"env-create-adapter",value:T,onChange:ve=>{C(ve.target.value),ve.target.value==="codespace"&&d()},className:ce.adapterSelect,"data-testid":"env-create-adapter",children:[i.jsx("option",{value:"local",children:"local"}),i.jsx("option",{value:"ssh",children:"ssh"}),i.jsx("option",{value:"docker",children:"docker"}),i.jsx("option",{value:"codespace",children:"codespace"})]})]}),T==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:A,onChange:ve=>O(ve.target.value),placeholder:"Host (optional)...",className:ce.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-port",children:"Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:od,max:rd,value:E,onChange:ve=>D(ve.target.value),placeholder:"Port (optional)...",className:ce.fieldInput,"data-testid":"env-create-port"})]})]}),T==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:A,onChange:ve=>O(ve.target.value),placeholder:"Host (required)...",className:ce.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-user",children:"User"}),i.jsx("input",{id:"env-create-user",type:"text",value:U,onChange:ve=>B(ve.target.value),placeholder:"User (optional)...",className:ce.fieldInput,"data-testid":"env-create-user"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-port",children:"SSH Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:od,max:rd,value:E,onChange:ve=>D(ve.target.value),placeholder:"SSH port (optional)...",className:ce.fieldInput,"data-testid":"env-create-port"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-identity",children:"Identity File"}),i.jsx("input",{id:"env-create-identity",type:"text",value:z,onChange:ve=>X(ve.target.value),placeholder:"Identity file (optional)...",className:ce.fieldInput,"data-testid":"env-create-identity"})]})]}),T==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-image",children:"Image"}),i.jsx("input",{id:"env-create-image",type:"text",value:$,onChange:ve=>J(ve.target.value),placeholder:"Image (optional)...",className:ce.fieldInput,"data-testid":"env-create-image"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-repo",children:"Repo"}),i.jsx("input",{id:"env-create-repo",type:"text",value:me,onChange:ve=>ee(ve.target.value),placeholder:"Repo (optional)...",className:ce.fieldInput,"data-testid":"env-create-repo"})]})]}),T==="codespace"&&i.jsx(KL,{codespaceName:oe,onCodespaceNameChange:R,envName:j,onEnvNameChange:N,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v})]})})]})}const YL="_group_1iprv_1",JL="_groupTitle_1iprv_8",WL="_shortcutList_1iprv_17",XL="_shortcutRow_1iprv_23",QL="_keys_1iprv_36",e8="_kbd_1iprv_43",t8="_description_1iprv_60",Si={group:YL,groupTitle:JL,shortcutList:WL,shortcutRow:XL,keys:QL,kbd:e8,description:t8},n8=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"},{keys:["3"],description:"Switch to Findings tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Chat",shortcuts:[{keys:["Enter"],description:"Send message (when input is focused)"}]}];function s8(){return i.jsxs("section",{className:he.section,"data-testid":"keyboard-shortcuts-panel",children:[i.jsx("h3",{className:he.sectionTitle,children:"Keyboard Shortcuts"}),i.jsx("p",{className:he.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),n8.map(t=>i.jsxs("div",{className:Si.group,children:[i.jsx("h4",{className:Si.groupTitle,children:t.title}),i.jsx("div",{className:Si.shortcutList,children:t.shortcuts.map(s=>i.jsxs("div",{className:Si.shortcutRow,children:[i.jsx("span",{className:Si.keys,children:s.keys.map(o=>i.jsx("kbd",{className:Si.kbd,children:o},o))}),i.jsx("span",{className:Si.description,children:s.description})]},s.description))})]},t.title))]})}const a8=[{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 i8({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:he.section,children:[i.jsx("h3",{className:he.sectionTitle,children:"Credential Providers"}),i.jsx("p",{className:he.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:he.tokenList,children:a8.map(r=>i.jsxs("div",{className:he.tokenRow,children:[i.jsx("span",{className:he.tokenName,children:r.label}),i.jsx("span",{className:he.tokenTarget,children:r.description}),i.jsx("select",{className:he.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 o8="_container_10efq_1",r8="_header_10efq_7",l8="_list_10efq_105",c8="_card_10efq_111",d8="_cardHeader_10efq_125",u8="_cardTitle_10efq_135",f8="_defaultBadge_10efq_141",p8="_cardActions_10efq_155",m8="_description_10efq_160",h8="_meta_10efq_166",g8="_empty_10efq_212",v8="_typeBadge_10efq_362",Xn={container:o8,header:r8,list:l8,card:c8,cardHeader:d8,cardTitle:u8,defaultBadge:f8,cardActions:p8,description:m8,meta:h8,empty:g8,typeBadge:v8};function y8({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=b.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return i.jsxs("div",{className:Xn.container,children:[i.jsxs("div",{className:Xn.header,children:[i.jsx("h2",{children:"Personas"}),i.jsx(tn,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?i.jsx("p",{className:Xn.empty,children:"No personas yet. Create one to get started."}):i.jsx("div",{className:Xn.list,children:t.map(v=>{const x=s===v.id,y=v.type==="script";return i.jsxs("div",{className:Xn.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),d(v.id))},children:[i.jsxs("div",{className:Xn.cardHeader,children:[i.jsxs("span",{className:Xn.cardTitle,children:[i.jsx("strong",{children:v.name}),i.jsx("span",{className:Xn.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:y?"Script":"Agent"}),x&&i.jsx("span",{className:Xn.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),i.jsxs("div",{className:Xn.cardActions,onClick:S=>S.stopPropagation(),children:[!x&&i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>{r(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&i.jsx("p",{className:Xn.description,children:v.description}),i.jsxs("div",{className:Xn.meta,children:[v.runtime&&i.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&i.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&i.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),i.jsx(oa,{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 b8="_container_uy08i_1",x8="_header_uy08i_7",_8="_count_uy08i_13",k8="_presets_uy08i_18",S8="_presetButton_uy08i_24",T8="_filterInput_uy08i_41",j8="_groups_uy08i_53",w8="_group_uy08i_53",N8="_groupHeader_uy08i_68",C8="_groupName_uy08i_77",E8="_groupCount_uy08i_81",A8="_toolList_uy08i_87",D8="_toolItem_uy08i_95",R8="_toolName_uy08i_103",gn={container:b8,header:x8,count:_8,presets:k8,presetButton:S8,filterInput:T8,groups:j8,group:w8,groupHeader:N8,groupName:C8,groupCount:E8,toolList:A8,toolItem:D8,toolName:R8},M8=(()=>{const t=new Map;for(const s of kx){const o=s==="get_version_status"?"version":s.split("_")[0];t.has(o)||t.set(o,[]),t.get(o).push(s)}return[...t.entries()].sort(([s],[o])=>s.localeCompare(o)).map(([s,o])=>({group:s,tools:o.sort()}))})(),I8=[{name:"default",label:"Default",tools:Sx},{name:"worker",label:"Worker",tools:RT},{name:"orchestrator",label:"Orchestrator",tools:MT},{name:"admin",label:"Admin",tools:IT}];function sx({selectedTools:t,onChange:s,disabled:o}){const[r,c]=b.useState(""),d=b.useMemo(()=>new Set(t),[t]),u=b.useCallback(v=>{if(o)return;const x=new Set(d);x.has(v)?x.delete(v):x.add(v),s([...x].sort())},[d,s,o]),p=b.useCallback((v,x)=>{if(o)return;const y=new Set(d);for(const S of v)x?y.delete(S):y.add(S);s([...y].sort())},[d,s,o]),m=b.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return i.jsxs("div",{className:gn.container,"data-testid":"mcp-tool-selector",children:[i.jsx("div",{className:gn.header,children:i.jsx("span",{className:gn.count,children:t.length===0?`Using default (${Sx.length} tools)`:`${t.length} of ${kx.size} tools selected`})}),i.jsxs("div",{className:gn.presets,"data-testid":"mcp-tool-presets",children:[I8.map(v=>i.jsx("button",{type:"button",className:gn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),i.jsx("button",{type:"button",className:gn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),i.jsx("input",{type:"text",className:gn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),i.jsx("div",{className:gn.groups,children:M8.map(({group:v,tools:x})=>{const y=g?x.filter(k=>k.toLowerCase().includes(g)):x;if(y.length===0)return null;const S=y.every(k=>d.has(k));return i.jsxs("div",{className:gn.group,"data-testid":`tool-group-${v}`,children:[i.jsxs("label",{className:gn.groupHeader,children:[i.jsx("input",{type:"checkbox",checked:S,onChange:()=>p(y,S),disabled:o,"data-testid":`group-toggle-${v}`}),i.jsx("span",{className:gn.groupName,children:v}),i.jsxs("span",{className:gn.groupCount,children:["(",y.filter(k=>d.has(k)).length,"/",y.length,")"]})]}),i.jsx("div",{className:gn.toolList,children:y.map(k=>i.jsxs("label",{className:gn.toolItem,children:[i.jsx("input",{type:"checkbox",checked:d.has(k),onChange:()=>u(k),disabled:o,"data-testid":`tool-${k}`}),i.jsx("span",{className:gn.toolName,children:k})]},k))})]},v)})})]})}const O8="_container_1gfuq_1",B8="_header_1gfuq_7",L8="_list_1gfuq_19",z8="_card_1gfuq_25",$8="_cardHeader_1gfuq_40",P8="_cardTitle_1gfuq_46",U8="_statusBadge_1gfuq_56",H8="_enabled_1gfuq_68",V8="_disabled_1gfuq_71",q8="_cardActions_1gfuq_75",G8="_cardMeta_1gfuq_80",F8="_empty_1gfuq_98",Qn={container:O8,header:B8,list:L8,card:z8,cardHeader:$8,cardTitle:P8,statusBadge:U8,enabled:H8,disabled:V8,cardActions:q8,cardMeta:G8,empty:F8};function Z8({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=b.useState(null),m=u?t.find(y=>y.id===u):void 0,g=async y=>{await o(y),p(null)},v=b.useMemo(()=>{const y=new Map;for(const S of s)y.set(S.id,S.name);return y},[s]),x=y=>v.get(y)??y;return i.jsxs("div",{className:Qn.container,children:[i.jsxs("div",{className:Qn.header,children:[i.jsx("h2",{children:"Schedules"}),i.jsx(tn,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?i.jsx("p",{className:Qn.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):i.jsx("div",{className:Qn.list,children:t.map(y=>i.jsxs("div",{className:Qn.card,"data-testid":`schedule-card-${y.id}`,onClick:()=>d(y.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),d(y.id))},children:[i.jsxs("div",{className:Qn.cardHeader,children:[i.jsxs("span",{className:Qn.cardTitle,children:[i.jsx("strong",{children:y.title}),i.jsx("span",{className:`${Qn.statusBadge} ${y.enabled?Qn.enabled:Qn.disabled}`,"data-testid":`schedule-status-badge-${y.id}`,children:y.enabled?"Enabled":"Disabled"})]}),i.jsxs("div",{className:Qn.cardActions,onClick:S=>S.stopPropagation(),children:[i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(y.id,{enabled:!y.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${y.id}`,title:y.enabled?"Disable schedule":"Enable schedule",children:y.enabled?"Disable":"Enable"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>d(y.id),"data-testid":`schedule-edit-${y.id}`,children:"Edit"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>p(y.id),"data-testid":`schedule-delete-${y.id}`,children:"Delete"})]})]}),i.jsxs("div",{className:Qn.cardMeta,children:[i.jsx("span",{"data-testid":`schedule-expression-${y.id}`,children:y.scheduleExpression}),y.personaId&&i.jsxs("span",{"data-testid":`schedule-persona-${y.id}`,children:["Persona: ",x(y.personaId)]}),i.jsxs("span",{"data-testid":`schedule-last-run-${y.id}`,children:["Last run: ",y.lastRunAt?Uo(y.lastRunAt):"Never"]}),y.enabled&&y.nextRunAt?i.jsxs("span",{"data-testid":`schedule-next-run-${y.id}`,children:["Next run: ",B1(y.nextRunAt)]}):null,y.runCount>0&&i.jsxs("span",{"data-testid":`schedule-run-count-${y.id}`,children:["Runs: ",y.runCount]})]})]},y.id))}),i.jsx(oa,{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 K8="_nav_1bhou_1",Y8="_tab_1bhou_24",J8="_tabIcon_1bhou_62",W8="_tabActive_1bhou_68",Zc={nav:K8,tab:Y8,tabIcon:J8,tabActive:W8},Qs=[{path:"credentials",label:"Credentials",icon:i.jsx(V2,{size:Nt})},{path:"personas",label:"Personas",icon:i.jsx(bj,{size:Nt})},{path:"schedules",label:"Schedules",icon:i.jsx(_2,{size:Nt})},{path:"appearance",label:"Appearance",icon:i.jsx(ij,{size:Nt})},{path:"shortcuts",label:"Shortcuts",icon:i.jsx(G2,{size:Nt})},{path:"plugins",label:"Plugins",icon:i.jsx(uj,{size:Nt})},{path:"about",label:"About",icon:i.jsx(vm,{size:Nt})}];function X8(){var u;const t=Yt(),s=mt(),o=b.useRef(null),r=((u=Qs.find(p=>{const m=`${Ni}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??Qs[0].path,c=b.useCallback(p=>{s(`${Ni}/${p}`)},[s]),d=b.useCallback(p=>{var S,k;const m=(S=o.current)==null?void 0:S.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:Qs.findIndex(j=>j.path===r);let x=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),x=(v+1)%Qs.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),x=(v-1+Qs.length)%Qs.length;else if(p.key==="Home")p.preventDefault(),x=0;else if(p.key==="End")p.preventDefault(),x=Qs.length-1;else return;const y=Qs[x].path;s(`${Ni}/${y}`),(k=m[x])==null||k.focus()},[r,s]);return i.jsx("nav",{className:Zc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:Qs.map(p=>{const m=p.path===r;return i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Zc.tab} ${m?Zc.tabActive:""}`,onClick:()=>c(p.path),children:[i.jsx("span",{className:Zc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}function Q8({tasks:t,taskStatusById:s,sessionStatusByTaskId:o}){const r=new Map;for(const d of t)if(d.parentTaskId){const u=r.get(d.parentTaskId);u?u.push(d):r.set(d.parentTaskId,[d])}const c=new Map(xy.map(d=>[d,[]]));for(const d of t){const u=pl(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(k=>s.get(k)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(k=>k.status==="complete").length;let x;if(u==="paused"&&o){const k=o.get(d.id);k==="idle"?x="Needs input":k==="completed"&&(x="Ready to complete")}const y={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:x},S=c.get(u);S?S.push(y):c.get("not_started").push(y)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return xy.map(d=>{const u=qa(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const e7="_boardContainer_1c4y1_1",t7="_column_1c4y1_17",n7="_columnHeader_1c4y1_34",s7="_columnIcon_1c4y1_47",a7="_columnLabel_1c4y1_52",i7="_columnCount_1c4y1_57",o7="_cardList_1c4y1_67",r7="_emptyPlaceholder_1c4y1_76",l7="_card_1c4y1_67",c7="_cardHeader_1c4y1_107",d7="_cardStatusIcon_1c4y1_113",u7="_cardTitle_1c4y1_119",f7="_cardBadges_1c4y1_127",p7="_badge_1c4y1_134",m7="_blockedBadge_1c4y1_146",h7="_childBadge_1c4y1_151",g7="_depBadge_1c4y1_155",v7="_parentBadge_1c4y1_159",y7="_pausedSubBadge_1c4y1_166",b7="_personaBadge_1c4y1_170",x7="_envBadge_1c4y1_174",_7="_emptyCta_1c4y1_178",k7="_ctaButton_1c4y1_188",S7="_ctaDescription_1c4y1_204",it={boardContainer:e7,column:t7,columnHeader:n7,columnIcon:s7,columnLabel:a7,columnCount:i7,cardList:o7,emptyPlaceholder:r7,card:l7,cardHeader:c7,cardStatusIcon:d7,cardTitle:u7,cardBadges:f7,badge:p7,blockedBadge:m7,childBadge:h7,depBadge:g7,parentBadge:v7,pausedSubBadge:y7,personaBadge:b7,envBadge:x7,emptyCta:_7,ctaButton:k7,ctaDescription:S7};function T7({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=mt(),p=b.useMemo(()=>o.filter(y=>y.workspaceId===t),[o,t]),m=b.useMemo(()=>new Map(o.map(y=>[y.id,y.status])),[o]),g=b.useMemo(()=>new Map(p.map(y=>[y.id,y])),[p]),v=b.useMemo(()=>{const y=new Map(r.map(C=>[C.id,C])),S=new Map(c.map(C=>[C.id,C])),k=new Map(d.map(C=>[C.id,C])),j=new Map,N=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const A=y.get(C.latestSessionId);if(A){if(j.set(C.id,A.endReason||A.status),A.personaId){const O=S.get(A.personaId);O&&N.set(C.id,O.name)}if(A.environmentId){const O=k.get(A.environmentId);O&&T.set(C.id,O.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:N,environmentNameByTaskId:T}},[p,r,c,d]),x=b.useMemo(()=>Q8({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?i.jsxs("div",{className:it.emptyCta,"data-testid":"board-empty-cta",children:[i.jsx("button",{className:it.ctaButton,onClick:()=>u(Ii(t,void 0,s)),children:"Create Task"}),i.jsx("div",{className:it.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):i.jsx("div",{className:it.boardContainer,"data-testid":"board-container",children:x.map(y=>i.jsxs("section",{className:it.column,"data-testid":`board-column-${y.status}`,"aria-label":`${y.label}, ${y.tasks.length} ${y.tasks.length===1?"task":"tasks"}`,children:[i.jsxs("div",{className:it.columnHeader,children:[i.jsx("span",{className:it.columnIcon,style:{color:y.style.color},children:y.style.icon}),i.jsx("span",{className:it.columnLabel,children:y.label}),i.jsx("span",{className:it.columnCount,"data-testid":`board-count-${y.status}`,children:y.tasks.length})]}),i.jsx("div",{className:it.cardList,children:y.tasks.length===0?i.jsx("div",{className:it.emptyPlaceholder,children:"No tasks"}):i.jsx(gs,{mode:"popLayout",children:y.tasks.map(S=>i.jsx(Mt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:i.jsx(j7,{boardTask:S,tasksById:g,personaName:v.personaNameByTaskId.get(S.task.id),envName:v.environmentNameByTaskId.get(S.task.id),onClick:()=>u(On(S.task.id,void 0,t,s))})},S.task.id))})})]},y.status))})}function j7({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=qa(d.status),x=d.parentTaskId?s.get(d.parentTaskId):void 0;return i.jsxs("div",{className:it.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),c())},children:[i.jsxs("div",{className:it.cardHeader,children:[i.jsx("span",{className:it.cardStatusIcon,style:{color:v.color},children:v.icon}),i.jsx("span",{className:it.cardTitle,children:d.title})]}),i.jsxs("div",{className:it.cardBadges,children:[x&&i.jsx("span",{className:`${it.badge} ${it.parentBadge}`,title:x.title,children:x.title}),p>0&&i.jsxs("span",{className:`${it.badge} ${it.childBadge}`,children:[m,"/",p]}),u&&i.jsx("span",{className:`${it.badge} ${it.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&i.jsx("span",{className:`${it.badge} ${it.depBadge}`,children:"dep"}),g&&i.jsx("span",{className:`${it.badge} ${it.pausedSubBadge}`,children:g}),o&&i.jsx("span",{className:`${it.badge} ${it.personaBadge}`,children:o}),r&&i.jsx("span",{className:`${it.badge} ${it.envBadge}`,children:r})]})]})}const w7="_formContent_ymnez_1",N7="_section_ymnez_13",C7="_label_ymnez_19",E7="_titleInput_ymnez_26",A7="_descriptionTextarea_ymnez_58",D7="_selectField_ymnez_94",R7="_checkboxRow_ymnez_128",M7="_checkboxLabel_ymnez_141",I7="_fieldError_ymnez_146",xt={formContent:w7,section:N7,label:C7,titleInput:E7,descriptionTextarea:A7,selectField:D7,checkboxRow:R7,checkboxLabel:M7,fieldError:I7};function O7(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.environmentId)??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const B7=100;function L7({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:B7,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-description",children:"Description"}),i.jsx("textarea",{id:"ws-description",className:xt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-repo",children:"Repository URL"}),i.jsx("input",{id:"ws-repo",className:xt.titleInput,type:"text",value:t.repoUrl,onChange:m=>p("repoUrl",m.target.value),placeholder:"https://github.com/org/repo",disabled:d,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-environment",children:"Environment"}),i.jsxs("select",{id:"ws-environment",className:xt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[i.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>i.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-persona",children:"Default Persona"}),i.jsxs("select",{id:"ws-persona",className:xt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>i.jsx("option",{value:m.id,children:m.name},m.id))]})]}),i.jsx("div",{className:xt.section,children:i.jsxs("label",{className:xt.checkboxRow,children:[i.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),i.jsx("span",{className:xt.checkboxLabel,children:"Enable worktree isolation"})]})}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-workdir",children:"Working Directory"}),i.jsx("input",{id:"ws-workdir",className:xt.titleInput,type:"text",value:t.workingDirectory,onChange:m=>p("workingDirectory",m.target.value),placeholder:"Default (server default)",disabled:d,"data-testid":"workspace-form-workdir"})]})]})}const G1=b.createContext(void 0),z7=4e3;function $7({children:t}){const[s,o]=b.useState([]),r=b.useRef(0),c=b.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=b.useCallback((u,p="info",m=z7)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return i.jsx(G1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function pn(){const t=b.useContext(G1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const fm="grackle-theme",F1="grackle-prefer-system",Z1="(prefers-color-scheme: dark)";let Jr=[],ld;function Rp(){ld=void 0;for(const t of Jr)t()}function pm(){return typeof window>"u"?!1:window.matchMedia(Z1).matches}function nl(){if(typeof localStorage>"u")return tx;try{const t=localStorage.getItem(fm);if(t!==null&&H1.has(t))return t}catch{}return tx}function _d(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(F1)==="true"}catch{return!1}}function mm(t){return zd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function K1(t,s){const o=um(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?pm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=mm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return pm()?r.variantDarkId:r.variantLightId}return t}function No(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=K1(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&No(nl(),_d());function P7(){return ld===void 0&&(ld={themeId:nl(),systemDark:pm(),preferSystem:_d()}),ld}function U7(t){return Jr=[...Jr,t],()=>{Jr=Jr.filter(s=>s!==t)}}function H7(){const t=b.useSyncExternalStore(U7,P7),{themeId:s,preferSystem:o}=t,r=K1(s,o),c=b.useCallback(u=>{if(H1.has(u)){try{localStorage.setItem(fm,u)}catch{}No(u,_d(),!0),Rp()}},[]),d=b.useCallback(u=>{try{localStorage.setItem(F1,u?"true":"false")}catch{}if(u){const p=nl(),m=um(p);if(m!=null&&m.hidden){const g=mm(p);if(g)try{localStorage.setItem(fm,g.id)}catch{}}}No(nl(),u,!0),Rp()},[]);return b.useEffect(()=>{No(s,o)},[s,o]),b.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(Z1),p=()=>{const m=nl(),g=_d();if(g){const v=um(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&No(m,g),v!=null&&v.hidden){const x=mm(m);x!=null&&x.variantDarkId&&x.variantLightId&&No(m,g)}}Rp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const Y1=b.createContext(void 0);function V7({children:t}){const s=H7();return i.jsx(Y1.Provider,{value:s,children:t})}function J1(){const t=b.useContext(Y1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const W1=b.createContext(void 0),X1=b.createContext(void 0);function q7({children:t}){const[s,o]=b.useState(void 0),r=b.useCallback(c=>{o(c)},[]);return i.jsx(X1.Provider,{value:r,children:i.jsx(W1.Provider,{value:s,children:t})})}function G7(){return b.useContext(W1)}function F7(){const t=b.useContext(X1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const fh=b.createContext(void 0);function ot(){const t=b.useContext(fh);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function Q1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ek(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function Z7(t){return Q1(t)&&typeof t.sessionId=="string"&&typeof t.eventType=="string"&&typeof t.timestamp=="string"&&typeof t.content=="string"&&(t.raw===void 0||typeof t.raw=="string")}const K7=new Set(["off","subscription","api_key"]),Kc=new Set(["off","on"]);function Y7(t){return Q1(t)&&K7.has(t.claude)&&Kc.has(t.github)&&Kc.has(t.copilot)&&Kc.has(t.codex)&&Kc.has(t.goose)}function tk(t){switch(t){case"waiting_input":return"idle";case"completed":return"stopped";case"killed":return"stopped";case"failed":return"stopped";case"interrupted":return"stopped";case"terminated":return"stopped";default:return t}}function nk(t){switch(t){case"completed":return"completed";case"killed":return"killed";case"failed":return"interrupted";case"interrupted":return"interrupted";case"terminated":return"terminated";default:return}}const wo=5e3;function J7(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 ra={label:"Home",url:Di};function W7(t){return t?[ra,{label:"Settings",url:Ni},{label:t,url:void 0}]:[ra,{label:"Settings",url:void 0}]}const ph={label:"Environments",url:Io};function X7(){return[ra,{label:"Environments",url:void 0}]}function Q7(){return[ra,{label:"New Chat",url:void 0}]}function ez(t){return[ra,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function tz(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[ra,ph,{label:(d==null?void 0:d.displayName)??"Environment",url:Ai(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function nz(t,s,o,r,c){const d=J7(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(S=>S.id===p):void 0,g=s??(m==null?void 0:m.environmentId),v=g?r.find(S=>S.id===g):void 0,x=[ra];v&&g&&(x.push(ph),x.push({label:v.displayName,url:Ai(g)})),m&&g&&x.push({label:m.name,url:Ga(m.id,g)});for(let S=0;S<d.length-1;S++)x.push({label:d[S].title,url:On(d[S].id,void 0,p,g)});const y=d[d.length-1];return x.push({label:(y==null?void 0:y.title)??t,url:void 0}),x}const sz={label:"Findings",url:Dd};function az(){return[ra,{label:"Findings",url:void 0}]}function sk(t,s,o,r,c){const d=[ra];if(s&&o){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===o);d.push(ph),p&&d.push({label:p.displayName,url:Ai(o)}),u&&d.push({label:u.name,url:Ga(s,o)}),d.push({label:"Findings",url:CN(s,o)})}else d.push(sz);return d.push({label:t,url:void 0}),d}function mh(t){const s=[];for(const o of t){const r=s[s.length-1];o.eventType==="text"&&(r==null?void 0:r.eventType)==="text"?s[s.length-1]={...r,content:r.content+o.content}:s.push(o)}return s}function Yc(t){if(typeof t.id=="string")return t.id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function iz(t){if(typeof t.tool_use_id=="string")return t.tool_use_id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function hh(t){const s=new Map;for(const v of t)if(v.raw)try{s.set(v,JSON.parse(v.raw))}catch{}const o=new Map;for(const v of t){if(v.eventType!=="tool_use")continue;const x=s.get(v),y=x?Yc(x):void 0;if(y)try{const S=JSON.parse(v.content);o.set(y,{tool:S.tool,args:S.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,x)=>{if(v.eventType!=="tool_result")return v;const y=s.get(v),S=y?iz(y):void 0;if(!S)return v;const k=o.get(S);if(!k)return v;r.add(S),c.add(x);let j;const N=v.content.trim();if(N.startsWith("{"))try{const T=JSON.parse(N);typeof T.detailedContent=="string"&&(j=T.detailedContent)}catch{}return{...v,toolUseCtx:{...k,detailedResult:j}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const x=s.get(d[v]),y=x?Yc(x):void 0;y&&r.has(y)||u.push(v)}const p=[];for(let v=0;v<d.length;v++)d[v].eventType!=="tool_result"||c.has(v)||p.push(v);let m=0;for(const v of u){for(;m<p.length&&p[m]<v;)m++;if(m>=p.length)break;const x=p[m];if(x!==v+1)continue;const y=d[v],S=d[x];let k;try{const j=JSON.parse(y.content);k={tool:j.tool,args:j.args}}catch{}if(k){let j;const N=S.content.trim();if(N.startsWith("{"))try{const A=JSON.parse(N);typeof A.detailedContent=="string"&&(j=A.detailedContent)}catch{}d[x]={...S,toolUseCtx:{...k,detailedResult:j}},c.add(x);const T=s.get(y),C=T?Yc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(y,{...T??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const x=s.get(v);if(!x)return!0;const y=Yc(x);if(y&&r.has(y))return!1;const S=x.__seqId;return!(S&&r.has(S))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let x=!1;for(let y=v+1;y<g.length;y++)if(g[y].eventType!=="tool_use"){x=!0;break}x&&(g[v]={...g[v],settled:!0})}return g}function oz(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=ak(s),d=s.filter(m=>hm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||hm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function ak(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function hm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function rz(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=ak(t),c=[];for(const p of t){const m=p.workspaceId?((u=o.get(p.workspaceId))==null?void 0:u.name)??"Unknown":"Unknown";p.status==="failed"?c.push({task:p,reason:"failed",workspaceName:m}):hm(p,r)?c.push({task:p,reason:"blocked",workspaceName:m}):p.status==="paused"&&c.push({task:p,reason:"paused",workspaceName:m})}const d={failed:0,blocked:1,paused:2};return c.sort((p,m)=>(d[p.reason]??3)-(d[m.reason]??3)),c}function lz(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 cz(t,s,o){const r=new Map;for(const c of s){if(!c.workspaceId)continue;let d=r.get(c.workspaceId);d||(d={totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0},r.set(c.workspaceId,d)),d.totalTasks+=1,c.status==="complete"?d.completedTasks+=1:c.status==="working"?d.workingTasks+=1:c.status==="failed"&&(d.failedTasks+=1)}return t.map(c=>{const d=r.get(c.id)??{totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0};return{workspace:c,totalTasks:d.totalTasks,completedTasks:d.completedTasks,workingTasks:d.workingTasks,failedTasks:d.failedTasks}})}const ws=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
|
|
284
|
+
`)}function _6({events:t,formatForClipboard:s}){const[o,r]=b.useState(!1),[c,d]=b.useState(new Set),u=b.useRef(void 0),p=b.useMemo(()=>c.size,[c]),m=b.useCallback(k=>{r(!0),k!==void 0?(d(new Set([k])),u.current=k):(d(new Set),u.current=void 0)},[]),g=b.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=b.useCallback((k,j)=>{if(j&&u.current!==void 0){const N=Math.min(u.current,k),T=Math.max(u.current,k);d(C=>{const A=new Set(C);for(let O=N;O<=T;O++)O<t.length&&fl(t[O])&&A.add(O);return A})}else d(N=>{const T=new Set(N);return T.has(k)?T.delete(k):T.add(k),T.size===0?(r(!1),u.current=void 0):u.current=k,T})},[t]),x=b.useCallback(()=>{const k=new Set;for(let j=0;j<t.length;j++)fl(t[j])&&k.add(j);d(k)},[t]),y=b.useCallback(()=>{d(new Set)},[]),S=b.useCallback(async()=>{const j=[...c].sort((T,C)=>T-C).filter(T=>T<t.length).map(T=>t[T]);if(j.length===0)return!1;const N=s(j);try{return await navigator.clipboard.writeText(N),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:x,deselectAll:y,copySelected:S}}const k6="_wrapper_1cdza_1",S6="_scrollContainer_1cdza_9",T6="_selectingPadding_1cdza_16",j6="_toolbar_1cdza_20",w6="_directionToggle_1cdza_27",N6="_scrollToAnchor_1cdza_65",C6="_scrollToAnchorBottom_1cdza_89",E6="_scrollToAnchorTop_1cdza_93",A6="_eventOverflowWarning_1cdza_97",ea={wrapper:k6,scrollContainer:S6,selectingPadding:T6,toolbar:j6,directionToggle:w6,scrollToAnchor:N6,scrollToAnchorBottom:C6,scrollToAnchorTop:E6,eventOverflowWarning:A6};function D6(t){const s=new Date(t.timestamp).toLocaleTimeString();switch(t.eventType){case"text":case"output":return`Select message from assistant at ${s}`;case"user_input":return`Select message from user at ${s}`;case"tool_result":case"tool_use":return`Select tool event at ${s}`;case"error":return`Select error at ${s}`;default:return`Select event at ${s}`}}const R1="grackle-stream-direction";function R6(){try{return localStorage.getItem(R1)==="reversed"}catch{return!1}}function M6({eventsDropped:t}){return t<=0?i.jsx(i.Fragment,{}):i.jsxs("div",{className:ea.eventOverflowWarning,role:"alert",children:[i.jsx(ym,{size:nn,"aria-hidden":"true"})," ",t.toLocaleString()," older event",t===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function dh({events:t,eventsDropped:s,emptyState:o,onShowToast:r}){const c=b.useRef(null),[d,u]=b.useState(R6),p=v3(),m=_6({events:t,formatForClipboard:x6}),g=b.useMemo(()=>t.filter(fl).length,[t]),v=b.useMemo(()=>d?[...t].reverse():t,[t,d]),{isAtAnchor:x,scrollToAnchor:y}=v6({scrollRef:c,contentLength:t.length,isReversed:d,paused:m.isSelecting}),S=()=>{const T=!d;u(T);try{localStorage.setItem(R1,T?"reversed":"default")}catch{}};b.useEffect(()=>{if(!m.isSelecting)return;const T=C=>{C.key==="Escape"&&m.cancelSelection()};return window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T)}},[m.isSelecting,m.cancelSelection]);const k=b.useCallback(async()=>{await m.copySelected()&&(r==null||r(`Copied ${m.selectedCount} message${m.selectedCount===1?"":"s"} to clipboard`,"success"))},[m,r]),j=p?0:.2,N=d?-8:8;return i.jsxs("div",{className:ea.wrapper,children:[i.jsx("div",{className:ea.toolbar,children:i.jsx($o,{text:d?"Showing newest first":"Showing oldest first",children:i.jsx("button",{className:ea.directionToggle,onClick:S,"aria-label":d?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:d?i.jsx(yy,{size:nn,"aria-hidden":"true"}):i.jsx(by,{size:nn,"aria-hidden":"true"})})})}),i.jsxs("div",{ref:c,className:`${ea.scrollContainer} ${m.isSelecting?ea.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,i.jsx(M6,{eventsDropped:s}),i.jsx(gs,{initial:!1,children:v.map((T,C)=>{const A=d?t.length-1-C:C;return i.jsx(Mt.div,{initial:{opacity:0,y:N},animate:{opacity:1,y:0},transition:{duration:j,ease:"easeOut"},children:i.jsx(o6,{copyText:b6(T),isContentBearing:fl(T),isSelecting:m.isSelecting,isSelected:m.selectedIndices.has(A),checkboxLabel:D6(T),onSelect:()=>{m.enterSelectionMode(A)},onToggle:O=>{m.toggleEvent(A,O)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:i.jsx(GA,{event:T,toolUseCtx:T.toolUseCtx,settled:T.settled})})},`${T.sessionId}-${T.timestamp}-${A}`)})})]}),i.jsx(gs,{children:m.isSelecting&&i.jsx(m6,{selectedCount:m.selectedCount,totalSelectable:g,onSelectAll:m.selectAll,onDeselectAll:m.deselectAll,onCopy:()=>{k().catch(()=>{})},onCancel:m.cancelSelection})}),i.jsx(gs,{children:!x&&i.jsxs(Mt.button,{className:`${ea.scrollToAnchor} ${d?ea.scrollToAnchorTop:ea.scrollToAnchorBottom}`,onClick:y,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[d?i.jsx(by,{size:nn,"aria-hidden":"true"}):i.jsx(yy,{size:nn,"aria-hidden":"true"})," New events"]})})]})}function uh(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=b.useState(""),[x,y]=b.useState(""),S=b.useRef(!1),k=d===c,j=b.useCallback(U=>{v(U),y("")},[]),N=b.useCallback(()=>{y("")},[]),T=b.useCallback(()=>{S.current=!1,u==null||u(null),v(""),y("")},[u]),C=b.useCallback(()=>{const U=m?g.trim():g;if(r){const z=r(g);if(z){y(z);return}}const B=m?s.trim():s;if(U===B){T();return}o(U),T()},[g,s,m,r,o,T]),A=b.useCallback(()=>{S.current=!0,u==null||u(c),v(s),y("")},[c,s,u]),O=b.useCallback(U=>{if(S.current){S.current=!1;return}U.relatedTarget instanceof HTMLElement&&U.relatedTarget.dataset.editAction===c||C()},[c,C]),E=b.useCallback(U=>{U.key==="Escape"?T():U.key==="Enter"&&p&&C()},[T,p,C]),D=(()=>{if(!k)return!1;const U=m?s.trim():s;return(m?g.trim():g)!==U})();return b.useEffect(()=>{!k&&(g!==""||x!=="")&&(v(""),y(""))},[k,g,x]),{isEditing:k,draft:g,error:x,isDirty:D,startEdit:A,cancelEdit:T,save:C,setDraft:j,clearError:N,handleBlur:O,handleKeyDown:E,ignoreInitialBlurRef:S}}const I6="_editFieldWrapper_yuzty_1",O6="_editInput_yuzty_10",B6="_editTextarea_yuzty_42",L6="_editSelect_yuzty_78",z6="_editError_yuzty_111",$6="_editInputInvalid_yuzty_118",P6="_editHint_yuzty_123",U6="_unsavedDot_yuzty_132",H6="_metaValueClickable_yuzty_140",V6="_editButton_yuzty_159",q6="_metaPlaceholder_yuzty_175",G6="_worktreeToggle_yuzty_180",st={editFieldWrapper:I6,editInput:O6,editTextarea:B6,editSelect:L6,editError:z6,editInputInvalid:$6,editHint:P6,unsavedDot:U6,metaValueClickable:H6,editButton:V6,metaPlaceholder:q6,worktreeToggle:G6};function Ft(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:x,ariaLabel:y,"data-testid":S}=t,k=b.useRef(null),j=uh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(b.useEffect(()=>{if(j.isEditing){const T=window.setTimeout(()=>{var C;(C=k.current)==null||C.focus()},0);return()=>window.clearTimeout(T)}},[j.isEditing]),c==="create"){const T=A=>{m==null||m(A.target.value)},C=r==null?void 0:r(s);return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("input",{className:`${st.editInput} ${C?st.editInputInvalid:""}`,value:s,onChange:T,maxLength:x,placeholder:v,"aria-label":y,"data-testid":S?`${S}-input`:void 0}),C&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("input",{ref:k,className:`${st.editInput} ${j.error?st.editInputInvalid:""}`,value:j.draft,onChange:T=>j.setDraft(T.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:x,placeholder:v,"aria-label":y,"data-testid":S?`${S}-input`:void 0}),j.isDirty&&i.jsx("span",{className:st.unsavedDot,title:"Unsaved changes"}),j.error&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:j.error}),i.jsx("span",{className:st.editHint,children:"Enter to save · Esc to cancel"})]});const N=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:st.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":y,"data-testid":S?`${S}-button`:void 0,children:[N!==void 0?N:s?i.jsx("span",{children:s}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function dm(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:x,"data-testid":y}=t,S=b.useRef(null),k=uh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(b.useEffect(()=>{if(k.isEditing){const N=window.setTimeout(()=>{var T;(T=S.current)==null||T.focus()},0);return()=>window.clearTimeout(N)}},[k.isEditing]),c==="create"){const N=C=>{m==null||m(C.target.value)},T=r==null?void 0:r(s);return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("textarea",{className:`${st.editTextarea} ${T?st.editInputInvalid:""}`,value:s,onChange:N,placeholder:v,"aria-label":x,"data-testid":y?`${y}-input`:void 0}),T&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:T})]})}if(k.isEditing)return i.jsxs("div",{className:st.editFieldWrapper,children:[i.jsx("textarea",{ref:S,className:`${st.editTextarea} ${k.error?st.editInputInvalid:""}`,value:k.draft,onChange:N=>k.setDraft(N.target.value),onBlur:k.handleBlur,onKeyDown:k.handleKeyDown,title:x,"aria-label":x,"data-testid":y?`${y}-input`:void 0}),k.isDirty&&i.jsx("span",{className:st.unsavedDot,title:"Unsaved changes"}),k.error&&i.jsx("span",{className:st.editError,"data-testid":"edit-error",children:k.error}),i.jsx("span",{className:st.editHint,children:"Tab to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return i.jsxs("span",{role:"button",tabIndex:0,className:st.metaValueClickable,onClick:()=>k.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),k.startEdit())},title:"Click to edit","aria-label":x,"data-testid":y?`${y}-button`:void 0,children:[j!==void 0?j:s?i.jsx("span",{children:s}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function Po(t){var A;const{value:s,onSave:o,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:x,"data-testid":y}=t,S=b.useRef(null),k=uh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});b.useEffect(()=>{if(k.isEditing){const O=window.setTimeout(()=>{var E;(E=S.current)==null||E.focus()},0);return()=>window.clearTimeout(O)}},[k.isEditing]);const j=b.useCallback(O=>{const E=O.target.value;k.ignoreInitialBlurRef.current=!1,E!==s&&o(E),k.cancelEdit()},[s,o,k]),N=b.useCallback(O=>{if(k.ignoreInitialBlurRef.current){k.ignoreInitialBlurRef.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===d||k.cancelEdit()},[d,k]);if(r==="create")return i.jsx("select",{className:st.editSelect,value:s,onChange:O=>m==null?void 0:m(O.target.value),"aria-label":x,"data-testid":y?`${y}-select`:void 0,children:c.map(O=>i.jsx("option",{value:O.value,children:O.label},O.value))});if(k.isEditing)return i.jsx("select",{ref:S,className:st.editSelect,value:k.draft,onChange:j,onBlur:N,title:x,"aria-label":x,"data-testid":y?`${y}-select`:void 0,children:c.map(O=>i.jsx("option",{value:O.value,children:O.label},O.value))});const T=g==null?void 0:g(s),C=(A=c.find(O=>O.value===s))==null?void 0:A.label;return i.jsxs("button",{type:"button",className:st.metaValueClickable,onClick:()=>k.startEdit(),title:"Click to change","aria-label":x,"data-testid":y?`${y}-button`:void 0,children:[T!==void 0?T:C?i.jsx("span",{children:C}):i.jsx("span",{className:st.metaPlaceholder,children:v||"None"}),i.jsx("span",{className:st.editButton,"aria-hidden":"true",children:"✏️"})]})}function F6(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return i.jsxs("label",{className:st.worktreeToggle,"data-testid":d,children:[i.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),i.jsx("span",{children:r})]})}const Z6="_envRow_1e1r5_1",K6="_envDot_1e1r5_7",Y6="_envDotGreen_1e1r5_14",J6="_envDotYellow_1e1r5_18",W6="_envDotRed_1e1r5_22",X6="_envDotGray_1e1r5_26",Mo={envRow:Z6,envDot:K6,envDotGreen:Y6,envDotYellow:J6,envDotRed:W6,envDotGray:X6};function Q6(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?Mo.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?Mo.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?Mo.envDotRed:Mo.envDotGray}function eI(t){const{value:s,onSave:o,environments:r,allowNone:c=!1,fieldId:d="environment",activeFieldId:u,onActivate:p,placeholder:m="No environment",ariaLabel:g="Environment","data-testid":v}=t,x=r.find(k=>k.id===s),y=[...c?[{value:"",label:"None"}]:[],...r.map(k=>({value:k.id,label:k.displayName}))],S=()=>{if(x)return i.jsxs("span",{className:Mo.envRow,children:[i.jsx("span",{className:`${Mo.envDot} ${Q6(x.status)}`}),x.displayName]})};return i.jsx(Po,{value:s,onSave:o,options:y,fieldId:d,activeFieldId:u,onActivate:p,renderDisplay:S,placeholder:m,ariaLabel:g,"data-testid":v})}const tI="_nav_1snmp_1",nI="_searchForm_1snmp_8",sI="_searchInput_1snmp_15",aI="_searchButton_1snmp_33",iI="_clearButton_1snmp_68",oI="_workspaceSelect_1snmp_85",rI="_listHeader_1snmp_99",lI="_nodeList_1snmp_108",cI="_nodeItem_1snmp_116",dI="_indicator_1snmp_129",uI="_label_1snmp_136",fI="_badge_1snmp_145",Wn={nav:tI,searchForm:nI,searchInput:sI,searchButton:aI,clearButton:iI,workspaceSelect:oI,listHeader:rI,nodeList:lI,nodeItem:cI,indicator:dI,label:uI,badge:fI};function pI({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=b.useState(""),v=b.useCallback(k=>{k.preventDefault(),m.trim()&&c(m.trim())},[m,c]),x=b.useCallback(()=>{g(""),d()},[d]),y=b.useCallback(k=>{u(k)},[u]),S=b.useCallback(k=>{g(""),p(k)},[p]);return i.jsxs("div",{className:Wn.nav,"data-testid":"knowledge-nav",children:[i.jsxs("form",{className:Wn.searchForm,onSubmit:v,children:[i.jsx("input",{className:Wn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:k=>{g(k.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),i.jsx("button",{type:"submit",className:Wn.searchButton,disabled:o,children:"Go"})]}),r&&i.jsx("button",{type:"button",className:Wn.clearButton,onClick:x,children:"Clear search"}),i.jsxs("select",{className:Wn.workspaceSelect,onChange:k=>{S(k.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[i.jsx("option",{value:"",children:"All workspaces"}),s.map(k=>i.jsx("option",{value:k.id,children:k.name},k.id))]}),i.jsxs("div",{className:Wn.listHeader,children:["Nodes (",t.length,")"]}),i.jsx("ul",{className:Wn.nodeList,children:t.map(k=>i.jsxs("li",{className:Wn.nodeItem,onClick:()=>{y(k.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),y(k.id))},role:"button",tabIndex:0,children:[i.jsx("span",{className:Wn.indicator,style:{backgroundColor:k.kind==="reference"?"#4A9EFF":k.category==="decision"?"#22C55E":k.category==="concept"?"#A855F7":k.category==="snippet"?"#6B7280":"#EAB308"}}),i.jsx("span",{className:Wn.label,children:k.label}),i.jsx("span",{className:Wn.badge,children:k.kind==="reference"?k.sourceType:k.category})]},k.id))})]})}const mI="_container_1mq5u_1",hI="_hamburger_1mq5u_33",gI="_brand_1mq5u_49",vI="_brandLogo_1mq5u_68",yI="_info_1mq5u_75",bI="_connectionLabel_1mq5u_90",xI="_connectionDot_1mq5u_103",_I="_connected_1mq5u_106",kI="_disconnected_1mq5u_110",Xs={container:mI,hamburger:hI,brand:gI,brandLogo:vI,info:yI,connectionLabel:bI,connectionDot:xI,connected:_I,disconnected:kI};function SI({connected:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=mt(),u=s.length,p=s.filter(g=>g.status==="connected").length,m=o.filter(g=>["running","idle"].includes(g.status)).length;return i.jsxs("div",{className:Xs.container,children:[r&&i.jsx("button",{type:"button",className:Xs.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:i.jsx(Q2,{size:Nt,"aria-hidden":"true"})}),i.jsx($o,{text:"Home",placement:"bottom",children:i.jsxs("button",{type:"button",className:Xs.brand,onClick:()=>d(Di),"data-testid":"statusbar-brand",children:[i.jsx("img",{src:"/icon-192x192.png",alt:"",className:Xs.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),i.jsxs("div",{className:Xs.info,children:[i.jsxs("span",{"aria-label":t?"Connected":"Disconnected",children:[i.jsx("span",{className:`${Xs.connectionDot} ${t?Xs.connected:Xs.disconnected}`,"aria-hidden":"true",children:i.jsx(Va,{size:bm,fill:"currentColor"})})," ",i.jsx("span",{className:Xs.connectionLabel,"aria-hidden":"true",children:t?"Connected":"Disconnected"})]}),i.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),i.jsxs("span",{children:[m," active"]})]})]})}const TI="_nav_13gkc_1",jI="_tab_13gkc_35",wI="_tabIcon_13gkc_68",NI="_tabLabel_13gkc_79",CI="_tabActive_13gkc_84",Vr={nav:TI,tab:jI,tabIcon:wI,tabLabel:NI,tabActive:CI},id=[{view:"dashboard",label:"Dashboard",icon:i.jsx(P2,{size:Nt}),route:Di,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:i.jsx(tj,{size:Nt}),route:wN,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:i.jsx(N2,{size:Nt}),route:NN,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:i.jsx(sj,{size:Nt}),route:Io,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:i.jsx(b2,{size:Nt}),route:Xx,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:i.jsx(Ex,{size:Nt}),route:Dd,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:i.jsx(mj,{size:Nt}),route:_N,testId:"sidebar-tab-settings"}];function EI(t){return t===Di||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(Xx)?"knowledge":t.startsWith(Dd)?"findings":t.startsWith(Ni)?"settings":"tasks"}function AI({tabs:t=id}){const s=Yt(),o=mt(),r=b.useRef(null),c=EI(s.pathname),d=b.useCallback(p=>{o(p.route)},[o]),u=b.useCallback(p=>{var y,S;const m=(y=r.current)==null?void 0:y.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(k=>k===document.activeElement),v=g>=0?g:t.findIndex(k=>k.view===c);let x=v;if(p.key==="ArrowRight"||p.key==="j"||p.key==="J")p.preventDefault(),x=(v+1)%t.length;else if(p.key==="ArrowLeft"||p.key==="k"||p.key==="K")p.preventDefault(),x=(v-1+t.length)%t.length;else if(p.key==="Home")p.preventDefault(),x=0;else if(p.key==="End")p.preventDefault(),x=t.length-1;else return;o(t[x].route),(S=m[x])==null||S.focus()},[c,o,t]);return i.jsx("nav",{className:Vr.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:u,"data-testid":"sidebar-nav",children:t.map(p=>{const m=p.view===c;return i.jsx($o,{text:p.label,placement:"bottom",children:i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Vr.tab} ${m?Vr.tabActive:""}`,onClick:()=>d(p),"data-testid":p.testId,"aria-label":p.label,children:[i.jsx("span",{className:Vr.tabIcon,"aria-hidden":"true",children:p.icon}),i.jsx("span",{className:Vr.tabLabel,children:p.label})]})},p.view)})})}const DI="_container_pi6ii_1",RI="_content_pi6ii_66",Xb={container:DI,content:RI},MI=320,M1=220,I1=600,O1="grackle-sidebar-width";function II(){try{const t=localStorage.getItem(O1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=M1&&s<=I1)return s}}catch{}return MI}function OI(t){try{localStorage.setItem(O1,String(t))}catch{}}function BI({content:t}){const[s]=b.useState(II),o=b.useRef(null);if(b.useEffect(()=>{const r=o.current;if(!r)return;const c=new ResizeObserver(d=>{for(const u of d){const p=u.borderBoxSize[0];if(p){const m=Math.round(p.inlineSize);m>=M1&&m<=I1&&OI(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return i.jsx("div",{className:Xb.container,ref:o,"data-testid":"sidebar",style:{width:s},children:i.jsx("div",{className:Xb.content,children:t})})}const LI="_bar_tnfsh_1",zI="_btnPrimary_tnfsh_32",$I="_statusText_tnfsh_85",PI="_statusCompleted_tnfsh_90",UI="_statusFailed_tnfsh_94",HI="_statusBlocked_tnfsh_98",VI="_hintText_tnfsh_103",jt={bar:LI,btnPrimary:zI,statusText:$I,statusCompleted:PI,statusFailed:UI,statusBlocked:HI,hintText:VI};function qI({sessions:t,tasks:s,environments:o}){const r=mt(),c=Yt(),d=Dt("/sessions/:sessionId"),u=Dt("/tasks/:taskId"),p=Dt("/tasks/:taskId/stream"),m=Dt("/tasks/:taskId/findings"),g=Dt("/tasks/:taskId/edit"),v=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),x=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),y=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),S=Dt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),k=Dt("/sessions/new"),j=Dt("/environments/:environmentId/workspaces/:workspaceId"),N=Dt("/tasks/new"),T=Dt("/chat"),C=Dt("/"),A=Dt("/settings/*"),O=d==null?void 0:d.params.sessionId,E=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(m==null?void 0:m.params.taskId)??(v==null?void 0:v.params.taskId)??(x==null?void 0:x.params.taskId)??(y==null?void 0:y.params.taskId)??(S==null?void 0:S.params.taskId),D=v??x??y??S,U=(D==null?void 0:D.params.environmentId)??(j==null?void 0:j.params.environmentId),B=c.pathname.startsWith("/environments")&&!j&&!D,z=!!T,X=!!k,$=!!j&&!v&&!x&&!y&&!S,J=!!N;if(!!C&&!X&&!$&&!J||!!A||(!!g||!!S)||J||B||X)return i.jsx(i.Fragment,{});if(z)return o.find(G=>G.adapterType==="local"&&G.status==="connected")?i.jsx(i.Fragment,{}):i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Add a local environment to start chatting"})});if($)return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Select a task or click + to create one"})});if(E){const R=s.find(de=>de.id===E);if(!R)return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Loading..."})});const G=new Map(s.map(de=>[de.id,de])),Z=R.dependsOn.some(de=>{const W=G.get(de);return W!==void 0&&W.status!=="complete"});if(R.status==="not_started"){const de=Z?R.dependsOn.map(W=>G.get(W)).filter(W=>W&&W.status!=="complete").map(W=>W.title):[];return i.jsx("div",{className:jt.bar,children:Z?i.jsxs("span",{className:jt.statusBlocked,children:["Blocked by: ",de.join(", ")]}):i.jsx("span",{className:jt.hintText,children:"Use the buttons above to start or manage this task"})})}if(R.status==="working"||R.status==="paused"){const de=R.latestSessionId||void 0,W=de?t.find(ue=>ue.id===de):void 0;return W&&W.status!=="stopped"?i.jsx(i.Fragment,{}):i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Waiting for agent..."})})}if(R.status==="complete")return i.jsxs("div",{className:jt.bar,children:[i.jsx("span",{className:`${jt.statusText} ${jt.statusCompleted}`,children:"Task completed"}),i.jsx("button",{onClick:()=>r(Ii(R.workspaceId,void 0,U)),className:jt.btnPrimary,children:"+ New Task"})]});if(R.status==="failed")return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:`${jt.statusText} ${jt.statusFailed}`,children:"Task failed"})})}if(O){const R=t.find(de=>de.id===O),G=(R==null?void 0:R.status)==="stopped";if(R!==void 0&&!G)return i.jsx(i.Fragment,{});if(G)return i.jsxs("div",{className:jt.bar,children:[i.jsxs("span",{className:`${jt.statusText} ${jt.hintText}`,children:["Session ",R.endReason||R.status]}),i.jsx("button",{onClick:()=>r(Kx(R.environmentId)),className:jt.btnPrimary,children:"+ New Chat"})]})}return i.jsx("div",{className:jt.bar,children:i.jsx("span",{className:jt.hintText,children:"Loading..."})})}const GI="_nav_14i94_1",FI="_tab_14i94_24",ZI="_tabActive_14i94_62",KI="_tabLabel_14i94_75",YI="_statusDot_14i94_81",JI="_pulse_14i94_87",WI="_addButton_14i94_99",XI="_empty_14i94_132",Ba={nav:GI,tab:FI,tabActive:ZI,tabLabel:KI,statusDot:YI,pulse:JI,addButton:WI,empty:XI},QI={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function e5({environments:t}){const s=mt(),o=b.useRef(null),r=Dt("/environments/:environmentId"),c=Dt("/environments/:environmentId/edit"),d=Dt("/environments/:environmentId/workspaces/:workspaceId"),u=Dt("/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=b.useCallback(y=>{s(Ai(y))},[s]),v=b.useCallback(y=>{var T;const S=(T=o.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),j=k>=0?k:t.findIndex(C=>C.id===m);let N=j;if(y.key==="ArrowDown"||y.key==="j"||y.key==="J")y.preventDefault(),N=(j+1)%S.length;else if(y.key==="ArrowUp"||y.key==="k"||y.key==="K")y.preventDefault(),N=(j-1+S.length)%S.length;else if(y.key==="Home")y.preventDefault(),N=0;else if(y.key==="End")y.preventDefault(),N=S.length-1;else return;N<t.length&&s(Ai(t[N].id)),S[N].focus()},[m,t,s]),x=m??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:Ba.nav,"data-testid":"environment-nav",children:[i.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(y=>{const S=y.id===m,k=y.id===x,j=QI[y.status]||"var(--text-tertiary)",N=y.status==="connected";return i.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${Ba.tab} ${S?Ba.tabActive:""}`,onClick:()=>g(y.id),"data-testid":"env-nav-item",children:[i.jsx("span",{className:`${Ba.statusDot} ${N?Ba.pulse:""}`,style:{color:j},"aria-hidden":"true",children:i.jsx(Va,{size:bm,fill:"currentColor"})}),i.jsx("span",{className:Ba.tabLabel,title:y.displayName||y.id,children:y.displayName||y.id})]},y.id)})}),i.jsx("button",{type:"button",className:Ba.addButton,onClick:()=>s(bN),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&i.jsx("div",{className:Ba.empty,children:"No environments yet."})]})}function Uo(t){const s=new Date(t),o=new Date,r=o.getTime()-s.getTime(),c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return"just now";if(d<60)return`${d}m ago`;if(u<24)return`${u}h ago`;if(p===1)return"yesterday";if(p<7)return`${p} days ago`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}function B1(t){const s=new Date(t);if(Number.isNaN(s.getTime()))return"—";const o=new Date,r=s.getTime()-o.getTime();if(r<=0)return"overdue";const c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return`in ${c}s`;if(d<60)return`in ${d}m`;if(u<24)return`in ${u}h`;if(p<7)return`in ${p} day${p===1?"":"s"}`;const m=s.getFullYear()===o.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const Qb={architecture:{text:"var(--accent-blue)",bg:"var(--accent-blue-dim)"},api:{text:"var(--accent-green)",bg:"var(--accent-green-dim)"},bug:{text:"var(--accent-red)",bg:"var(--accent-red-dim)"},decision:{text:"var(--accent-yellow)",bg:"var(--accent-yellow-dim)"},dependency:{text:"var(--accent-purple)",bg:"var(--accent-purple-dim)"},pattern:{text:"var(--accent-cyan)",bg:"var(--accent-cyan-dim)"},general:{text:"var(--text-secondary)",bg:"var(--bg-elevated)"}};function xd(t){return Qb[t]||Qb.general}const t5="_nav_dlm8m_1",n5="_categoryPills_dlm8m_24",s5="_categoryPill_dlm8m_24",a5="_tab_dlm8m_42",i5="_tabActive_dlm8m_80",o5="_tabContent_dlm8m_93",r5="_tabLabel_dlm8m_100",l5="_tabMeta_dlm8m_106",c5="_categoryDot_dlm8m_111",d5="_empty_dlm8m_118",js={nav:t5,categoryPills:n5,categoryPill:s5,tab:a5,tabActive:i5,tabContent:o5,tabLabel:r5,tabMeta:l5,categoryDot:c5,empty:d5};function u5({findings:t,workspaceId:s,environmentId:o}){const r=mt(),c=b.useRef(null),d=Dt("/findings/:findingId"),u=Dt("/environments/:environmentId/workspaces/:workspaceId/findings/:findingId"),p=(d==null?void 0:d.params.findingId)??(u==null?void 0:u.params.findingId),m=b.useMemo(()=>{const y=new Set(t.map(S=>S.category).filter(Boolean));return Array.from(y).sort()},[t]),g=b.useCallback(y=>{r(Gp(y,s,o))},[r,s,o]),v=b.useCallback(y=>{var T;const S=(T=c.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),j=k>=0?k:t.findIndex(C=>C.id===p);let N=j;if(y.key==="ArrowDown"||y.key==="j"||y.key==="J")y.preventDefault(),N=(j+1)%S.length;else if(y.key==="ArrowUp"||y.key==="k"||y.key==="K")y.preventDefault(),N=(j-1+S.length)%S.length;else if(y.key==="Home")y.preventDefault(),N=0;else if(y.key==="End")y.preventDefault(),N=S.length-1;else return;N<t.length&&r(Gp(t[N].id,s,o)),S[N].focus()},[p,t,r,s,o]),x=p??(t.length>0?t[0].id:void 0);return i.jsxs("div",{className:js.nav,"data-testid":"findings-nav",children:[m.length>1&&i.jsx("div",{className:js.categoryPills,"data-testid":"findings-nav-categories",children:m.map(y=>i.jsx("span",{className:js.categoryPill,style:{color:xd(y).text},children:y},y))}),i.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(y=>{const S=y.id===p,k=y.id===x;return i.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${js.tab} ${S?js.tabActive:""}`,onClick:()=>g(y.id),"data-testid":"finding-nav-item",children:[i.jsx("span",{className:js.categoryDot,style:{color:xd(y.category).text},"aria-hidden":"true",children:i.jsx(Va,{size:bm,fill:"currentColor"})}),i.jsxs("span",{className:js.tabContent,children:[i.jsx("span",{className:js.tabLabel,title:y.title,children:y.title}),i.jsx("span",{className:js.tabMeta,title:y.createdAt,children:Uo(y.createdAt)})]})]},y.id)})}),t.length===0&&i.jsx("div",{className:js.empty,children:"No findings yet. Agents will post discoveries here."})]})}function f5(t){if(t.length===0)return[];const s=[...t].sort((r,c)=>r[0]-c[0]),o=[[s[0][0],s[0][1]]];for(let r=1;r<s.length;r++){const c=o[o.length-1],[d,u]=s[r];d<=c[1]+1?c[1]=Math.max(c[1],u):o.push([d,u])}return o}function L1({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return i.jsx(i.Fragment,{children:t});const r=f5(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 p5(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 m5(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 Sj){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=qa(d);r.push({status:d,label:p.label,style:p,tasks:u})}}for(const[d,u]of o)if(!c.has(d)&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=qa(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const h5="_container_z4i38_1",g5="_header_z4i38_5",v5="_headerActions_z4i38_17",y5="_searchInput_z4i38_23",b5="_searchHighlight_z4i38_56",x5="_groupToggle_z4i38_62",_5="_groupToggleActive_z4i38_89",k5="_addButton_z4i38_93",S5="_taskRow_z4i38_120",T5="_selected_z4i38_140",j5="_expandArrow_z4i38_150",w5="_expanded_z4i38_157",N5="_leafSpacer_z4i38_161",C5="_taskStatusIcon_z4i38_166",E5="_taskTitle_z4i38_170",A5="_workspaceBadge_z4i38_177",D5="_childCountBadge_z4i38_195",R5="_dependencyBadge_z4i38_208",M5="_blockedBadge_z4i38_220",I5="_addChildButton_z4i38_225",O5="_emptyState_z4i38_268",B5="_statusGroupHeader_z4i38_275",L5="_statusGroupIcon_z4i38_294",z5="_statusGroupLabel_z4i38_298",$5="_statusGroupCount_z4i38_303",Ze={container:h5,header:g5,headerActions:v5,searchInput:y5,searchHighlight:b5,groupToggle:x5,groupToggleActive:_5,addButton:k5,taskRow:S5,selected:T5,expandArrow:j5,expanded:w5,leafSpacer:N5,taskStatusIcon:C5,taskTitle:E5,workspaceBadge:A5,childCountBadge:D5,dependencyBadge:R5,blockedBadge:M5,addChildButton:I5,emptyState:O5,statusGroupHeader:B5,statusGroupIcon:L5,statusGroupLabel:z5,statusGroupCount:$5},P5=[{name:"title",weight:2},{name:"description",weight:1}],z1=16,U5=16,$1="grackle-task-group-by-status";function ex(){try{return localStorage.getItem($1)==="true"}catch{return!1}}function H5(t){try{localStorage.setItem($1,String(t))}catch{}}function V5({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:Ze.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:`${Ze.expandArrow} ${s?Ze.expanded:""}`,"aria-hidden":"true",children:i.jsx(la,{size:dt})}),i.jsx("span",{className:Ze.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),i.jsx("span",{className:Ze.statusGroupLabel,children:t.label}),i.jsx("span",{className:Ze.statusGroupCount,children:t.tasks.length})]}),i.jsx(gs,{children:s&&i.jsx(Mt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},style:{overflow:"hidden"},children:t.tasks.map(p=>{const m=qa(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return i.jsxs("div",{onClick:()=>c(On(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:x=>{x.currentTarget===x.target&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),c(On(p.id)))},className:`${Ze.taskRow} ${g?Ze.selected:""}`,style:{"--task-indent":`${z1}px`},"data-task-id":p.id,children:[i.jsx("span",{className:Ze.leafSpacer}),i.jsx("span",{className:Ze.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${pl(p.status)}`,children:m.icon}),i.jsx("span",{className:Ze.taskTitle,title:p.title,children:i.jsx(L1,{text:p.title,indices:d.get(p.id),highlightClass:Ze.searchHighlight})}),v&&i.jsx("span",{className:Ze.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function P1({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=qa(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),x=o.has(t.id),y=t.children.length>0,S=c===t.id,k=z1+s*U5,N=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{onClick:()=>d(On(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:T=>{T.currentTarget===T.target&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(On(t.id)))},className:`${Ze.taskRow} ${S?Ze.selected:""}`,style:{"--task-indent":`${k}px`},"data-task-id":t.id,children:[y&&i.jsx("span",{className:`${Ze.expandArrow} ${x?Ze.expanded:""}`,role:"button",tabIndex:0,"aria-label":x?"Collapse task":"Expand task",onClick:T=>{T.stopPropagation(),r(t.id)},onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),T.stopPropagation(),r(t.id))},children:i.jsx(la,{size:dt,"aria-hidden":"true"})}),!y&&i.jsx("span",{className:Ze.leafSpacer}),i.jsx("span",{className:Ze.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${pl(t.status)}`,children:g.icon}),i.jsx("span",{className:Ze.taskTitle,title:t.title,children:i.jsx(L1,{text:t.title,indices:p.get(t.id),highlightClass:Ze.searchHighlight})}),N&&i.jsx("span",{className:Ze.workspaceBadge,title:N,children:N}),y&&i.jsxs("span",{className:Ze.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&i.jsx("span",{className:`${Ze.dependencyBadge} ${v?Ze.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<DT&&i.jsx($o,{text:"Add child task",children:i.jsx("button",{onClick:T=>{T.stopPropagation(),d(Ii(t.workspaceId,t.id))},"aria-label":"Add child task",className:Ze.addChildButton,children:"+"})})]}),i.jsx(gs,{children:y&&x&&i.jsx(Mt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:t.children.map(T=>i.jsx(P1,{node:T,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function q5({workspaces:t,tasks:s}){const o=mt(),[r,c]=b.useState(new Set),[d,u]=b.useState(new Set),[p,m]=b.useState(ex),[g,v]=b.useState(ex),[x,y]=b.useState(new Map),S=Dt("/tasks/:taskId/*"),k=(S==null?void 0:S.params.taskId)!=="new"?S==null?void 0:S.params.taskId:void 0,j=b.useMemo(()=>new Map(s.map(ee=>[ee.id,ee.status])),[s]),N=b.useMemo(()=>new Map(t.map(ee=>[ee.id,ee.name])),[t]),T=()=>{const ee=!p;H5(ee),m(ee),ee&&(v(!0),y(new Map))},C=ee=>{y(oe=>{const R=new Map(oe),G=R.has(ee)?R.get(ee):g;return R.set(ee,!G),R})},A=ee=>x.has(ee)?x.get(ee):g,O=ee=>{c(oe=>{const R=new Set(oe);return R.has(ee)?(R.delete(ee),u(G=>new Set(G).add(ee))):(R.add(ee),u(G=>{const Z=new Set(G);return Z.delete(ee),Z})),R})};b.useEffect(()=>{const ee=new Set(s.filter(oe=>oe.parentTaskId).map(oe=>oe.parentTaskId));ee.size>0&&c(oe=>{const R=new Set(oe);for(const G of ee)d.has(G)||R.add(G);return R})},[s,d]);const[E,D]=b.useState(""),{directMatchTaskIds:U,treeMatchTaskIds:B,titleHighlights:z}=b.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const ee=AT(s,E,P5),oe=new Set(ee.map(de=>de.item.id)),R=new Map;for(const de of ee){const W=de.matches.find(Q=>Q.key==="title");W&&R.set(de.item.id,W.indices)}const G=new Set(oe),Z=new Map(s.map(de=>[de.id,de]));for(const de of[...oe]){let W=Z.get(de);for(;W!=null&&W.parentTaskId;)G.add(W.parentTaskId),W=Z.get(W.parentTaskId)}return{directMatchTaskIds:oe,treeMatchTaskIds:G,titleHighlights:R}},[E,s]),X=U!==null,$=X?p?U:B:null,J=$?s.filter(ee=>$.has(ee.id)):s,me=p?[]:p5(J);return i.jsxs("div",{className:Ze.container,children:[i.jsxs("div",{className:Ze.header,children:[i.jsx("span",{children:"Tasks"}),i.jsxs("div",{className:Ze.headerActions,children:[i.jsx($o,{text:p?"Switch to tree view":"Group tasks by status",children:i.jsx("button",{className:`${Ze.groupToggle} ${p?Ze.groupToggleActive:""}`,onClick:T,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:i.jsx(Y2,{size:nn})})}),i.jsx($o,{text:"New task",children:i.jsx("button",{className:Ze.addButton,onClick:()=>o(Ii()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&i.jsx("input",{type:"text",value:E,onChange:ee=>D(ee.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Ze.searchInput,"data-testid":"sidebar-search"}),p?m5(J,j).map(ee=>i.jsx(V5,{group:ee,isExpanded:A(ee.status),onToggle:()=>C(ee.status),selectedTaskId:k,navigate:o,titleHighlights:z,workspaceNames:N},ee.status)):me.map(ee=>i.jsx(P1,{node:ee,depth:0,expandedTasks:r,toggleTask:O,selectedTaskId:k,navigate:o,taskStatusById:j,titleHighlights:z,workspaceNames:N},ee.id)),J.length===0&&!X&&i.jsx("div",{className:Ze.emptyState,children:"No tasks yet. Click + to create one."}),J.length===0&&X&&i.jsx("div",{className:Ze.emptyState,children:"No matching tasks"})]})}const G5="_toast_ed2dk_1",F5="_success_ed2dk_18",Z5="_icon_ed2dk_22",K5="_error_ed2dk_25",Y5="_warning_ed2dk_32",J5="_info_ed2dk_38",W5="_message_ed2dk_53",X5="_close_ed2dk_60",qr={toast:G5,success:F5,icon:Z5,error:K5,warning:Y5,info:J5,message:W5,close:X5},Q5={success:i.jsx(Ri,{size:Nt}),error:i.jsx(Ka,{size:Nt}),warning:i.jsx(ym,{size:Nt}),info:i.jsx(vm,{size:Nt})};function eO({toast:t,onDismiss:s}){return b.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),i.jsxs(Mt.div,{className:`${qr.toast} ${qr[t.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[i.jsx("span",{className:qr.icon,"aria-hidden":"true",children:Q5[t.variant]}),i.jsx("span",{className:qr.message,children:t.message}),i.jsx("button",{type:"button",className:qr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:i.jsx(Ka,{size:nn,"aria-hidden":"true"})})]})}const tO="_container_qqse2_1",nO={container:tO};function sO({toasts:t,onDismiss:s}){return i.jsx("div",{className:nO.container,"data-testid":"toast-container",children:i.jsx(gs,{children:t.map(o=>i.jsx(eO,{toast:o,onDismiss:s},o.id))})})}const aO="_callout_e5awm_1",iO="_success_e5awm_11",oO="_icon_e5awm_15",rO="_error_e5awm_18",lO="_warning_e5awm_25",cO="_info_e5awm_32",dO="_content_e5awm_48",uO="_close_e5awm_53",Gr={callout:aO,success:iO,icon:oO,error:rO,warning:lO,info:cO,content:dO,close:uO},fO={success:i.jsx(Ri,{size:Nt}),error:i.jsx(Ka,{size:Nt}),warning:i.jsx(ym,{size:Nt}),info:i.jsx(vm,{size:Nt})};function pO({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=b.useState(!1);return i.jsx(i.Fragment,{children:!c&&i.jsxs("div",{className:[Gr.callout,Gr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[i.jsx("span",{className:Gr.icon,"aria-hidden":"true",children:fO[t]}),i.jsx("span",{className:Gr.content,children:s}),o&&i.jsx("button",{type:"button",className:Gr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:i.jsx(Ka,{size:nn,"aria-hidden":"true"})})]})})}function mO({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(pO,{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 hO="_container_de44x_1",gO="_emptyState_de44x_8",vO="_card_de44x_14",yO="_cardClickable_de44x_34",bO="_cardHeader_de44x_42",xO="_categoryBadge_de44x_54",_O="_findingTitle_de44x_62",kO="_findingDate_de44x_68",SO="_findingContent_de44x_80",TO="_tags_de44x_86",jO="_tag_de44x_86",fs={container:hO,emptyState:gO,card:vO,cardClickable:yO,cardHeader:bO,categoryBadge:xO,findingTitle:_O,findingDate:kO,findingContent:SO,tags:TO,tag:jO};function U1({findings:t,onFindingClick:s}){return t.length===0?i.jsx("div",{className:fs.emptyState,children:"No findings yet. Agents will post discoveries here."}):i.jsx("div",{className:fs.container,children:t.map((o,r)=>{const c=xd(o.category),d=s?Mt.button:Mt.div;return i.jsxs(d,{type:s?"button":void 0,className:`${fs.card} ${s?fs.cardClickable:""}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:r*.05,duration:.2},onClick:s?()=>{s(o.id)}:void 0,children:[i.jsxs("div",{className:fs.cardHeader,children:[i.jsx("span",{className:fs.categoryBadge,style:{background:c.bg,color:c.text},children:o.category}),i.jsx("span",{className:fs.findingTitle,children:o.title}),i.jsx("span",{className:fs.findingDate,title:o.createdAt,children:Uo(o.createdAt)})]}),i.jsx("div",{className:fs.findingContent,children:o.content.length>300?o.content.slice(0,300)+"...":o.content}),o.tags.length>0&&i.jsx("div",{className:fs.tags,children:o.tags.map(u=>i.jsx("span",{className:fs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},o.id)})})}const wO="_container_1ingb_1",NO="_heading_1ingb_7",CO="_section_1ingb_14",EO="_sectionTitle_1ingb_26",AO="_sectionDescription_1ingb_35",DO="_emptyState_1ingb_41",RO="_tokenList_1ingb_48",MO="_tokenRow_1ingb_55",IO="_tokenBadge_1ingb_68",OO="_tokenName_1ingb_83",BO="_tokenTarget_1ingb_90",LO="_deleteButton_1ingb_99",zO="_addForm_1ingb_113",$O="_formRow_1ingb_119",PO="_input_1ingb_125",UO="_select_1ingb_155",HO="_addButton_1ingb_187",VO="_emptyStateInfo_1ingb_221",qO="_themeOptions_1ingb_229",GO="_themeOption_1ingb_229",FO="_themeOptionSelected_1ingb_254",ZO="_themeOptionHeader_1ingb_259",KO="_themeOptionLabel_1ingb_266",YO="_themeOptionDesc_1ingb_273",JO="_variantToggle_1ingb_279",WO="_variantButton_1ingb_286",XO="_variantActive_1ingb_305",QO="_themeSwatches_1ingb_311",eB="_themeSwatch_1ingb_311",tB="_systemToggle_1ingb_325",nB="_systemToggleHint_1ingb_341",sB="_themeActive_1ingb_348",aB="_aboutGrid_1ingb_354",iB="_aboutItem_1ingb_360",oB="_aboutLabel_1ingb_373",rB="_aboutValue_1ingb_379",lB="_aboutDot_1ingb_387",cB="_aboutDotConnected_1ingb_394",dB="_aboutDotDisconnected_1ingb_398",he={container:wO,heading:NO,section:CO,sectionTitle:EO,sectionDescription:AO,emptyState:DO,tokenList:RO,tokenRow:MO,tokenBadge:IO,tokenName:OO,tokenTarget:BO,deleteButton:LO,addForm:zO,formRow:$O,input:PO,select:UO,addButton:HO,emptyStateInfo:VO,themeOptions:qO,themeOption:GO,themeOptionSelected:FO,themeOptionHeader:ZO,themeOptionLabel:KO,themeOptionDesc:YO,variantToggle:JO,variantButton:WO,variantActive:XO,themeSwatches:QO,themeSwatch:eB,systemToggle:tB,systemToggleHint:nB,themeActive:sB,aboutGrid:aB,aboutItem:iB,aboutLabel:oB,aboutValue:rB,aboutDot:lB,aboutDotConnected:cB,aboutDotDisconnected:dB},uB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function fB({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=b.useState(""),[u,p]=b.useState(""),[m,g]=b.useState("env_var"),[v,x]=b.useState(""),[y,S]=b.useState(null),k=T=>{if(T.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),x("")},j=T=>{S(T)},N=()=>{y&&(o(y),r==null||r("Token deleted","info")),S(null)};return i.jsxs(i.Fragment,{children:[i.jsx(oa,{isOpen:y!==null,title:"Delete Token?",description:y?`"${y}" will be permanently removed.`:void 0,onConfirm:N,onCancel:()=>S(null)}),i.jsxs("section",{className:he.section,children:[i.jsx("h3",{className:he.sectionTitle,children:"Tokens"}),i.jsx("p",{className:he.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?i.jsx("div",{className:he.emptyStateInfo,children:"Add your first API token to enable service integrations."}):i.jsx("div",{className:he.tokenList,children:t.map(T=>i.jsxs("div",{className:he.tokenRow,children:[i.jsx("span",{className:he.tokenBadge,children:T.tokenType}),i.jsx("span",{className:he.tokenName,children:T.name}),i.jsx("span",{className:he.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),i.jsx("button",{className:he.deleteButton,onClick:()=>j(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:i.jsx(Ka,{size:nn,"aria-hidden":"true"})})]},T.name))}),i.jsxs("form",{className:he.addForm,onSubmit:k,children:[i.jsxs("div",{className:he.formRow,children:[i.jsx("input",{className:he.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),i.jsx("input",{className:he.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),i.jsxs("div",{className:he.formRow,children:[i.jsx("select",{className:he.select,value:m,onChange:T=>g(T.target.value),children:uB.map(T=>i.jsx("option",{value:T.value,children:T.label},T.value))}),i.jsx("input",{className:he.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:T=>x(T.target.value)}),i.jsx("button",{className:he.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const zd=[{id:"grackle",label:"Grackle",description:"The default Grackle theme — iridescent purple on clean dark.",swatches:["#0e1218","#8b5cf6","#60a5fa","#e5e7eb","#34d399"],variantLightId:"grackle-light",variantDarkId:"grackle-dark"},{id:"grackle-light",label:"Grackle Light",description:"Light Grackle variant.",hidden:!0},{id:"grackle-dark",label:"Grackle Dark",description:"Dark Grackle variant.",hidden:!0},{id:"glass",label:"Glassmorphism",description:"Dark frosted-glass aesthetic with backdrop blur effects.",swatches:["#0a0c14","#4ecca3","#70a1ff","#e2e8f0","#a855f7"]},{id:"matrix",label:"Matrix",description:"Phosphor-green CRT terminal with scanlines and glow.",swatches:["#050505","#00ff41","#00bfff","#33ff77","#ffb000"]},{id:"brutalist",label:"Neubrutalism",description:"Thick borders, raw colors, bold type — ugly on purpose.",swatches:["#f5f0e8","#ff5757","#5ce1e6","#1a1a1a","#ffde59"],variantLightId:"brutalist-light",variantDarkId:"brutalist-dark"},{id:"brutalist-light",label:"Neubrutalism Light",description:"Light neubrutalism variant.",hidden:!0},{id:"brutalist-dark",label:"Neubrutalism Dark",description:"Dark neubrutalism variant.",hidden:!0},{id:"monokai",label:"Monokai",description:"Classic warm editor palette — pink, green, and purple.",swatches:["#272822","#f92672","#a6e22e","#f8f8f2","#ae81ff"],variantLightId:"monokai-light",variantDarkId:"monokai-dark"},{id:"monokai-dark",label:"Monokai Dark",description:"Dark Monokai variant.",hidden:!0},{id:"monokai-light",label:"Monokai Light",description:"Light Monokai variant.",hidden:!0},{id:"ubuntu",label:"Ubuntu",description:"Aubergine terminal with the GNOME Tango palette.",swatches:["#300a24","#8ae234","#ef2929","#eeeeec","#fce94f"]},{id:"sandstone",label:"Sandstone",description:"Warm terracotta accent on dark brown, in the style of Claude Code.",swatches:["#1a1815","#C15F3C","#6b8afd","#e8e6e3","#a78bfa"]},{id:"verdigris",label:"Verdigris",description:"Teal accent on charcoal, in the style of ChatGPT.",swatches:["#141414","#00a67e","#3b82f6","#ececec","#ab68ff"]},{id:"primer",label:"Primer",description:"Blue accent on ink-dark grey, in the style of GitHub.",swatches:["#0d1117","#58a6ff","#3fb950","#c9d1d9","#bc8cff"]}],H1=new Set(zd.map(t=>t.id)),tx="grackle";function um(t){return zd.find(s=>s.id===t)}function pB({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return i.jsxs("section",{className:he.section,children:[i.jsx("h3",{className:he.sectionTitle,children:"Appearance"}),i.jsx("p",{className:he.sectionDescription,children:"Choose how Grackle looks across the app."}),i.jsx("div",{className:he.themeOptions,children:zd.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?t===d.id||t===d.variantLightId||t===d.variantDarkId:t===d.id,m=u&&s===d.variantLightId;return i.jsxs("button",{type:"button",className:`${he.themeOption} ${p?he.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[i.jsxs("span",{className:he.themeOptionHeader,children:[i.jsxs("span",{children:[i.jsx("span",{className:he.themeOptionLabel,children:d.label}),i.jsx("span",{className:he.themeOptionDesc,children:d.description})]}),u&&i.jsxs("span",{className:he.variantToggle,children:[i.jsx("span",{role:"button",tabIndex:0,className:`${he.variantButton} ${p&&m?he.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:`${he.variantButton} ${p&&!m?he.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:he.themeSwatches,children:d.swatches.map((g,v)=>i.jsx("span",{className:he.themeSwatch,style:{background:g}},v))})]},d.id)})}),i.jsxs("label",{className:he.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:he.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),i.jsxs("p",{className:he.themeActive,children:["Active theme: ",i.jsx("strong",{children:s})]})]})}function mB({connected:t,environments:s,sessions:o}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=o.filter(u=>["running","idle"].includes(u.status)).length;return i.jsxs("section",{className:he.section,"data-testid":"about-panel",children:[i.jsx("h3",{className:he.sectionTitle,children:"About"}),i.jsx("p",{className:he.sectionDescription,children:"Connection status and application information."}),i.jsxs("div",{className:he.aboutGrid,children:[i.jsxs("div",{className:he.aboutItem,children:[i.jsx("span",{className:he.aboutLabel,children:"Connection"}),i.jsxs("span",{className:he.aboutValue,children:[i.jsx("span",{className:`${he.aboutDot} ${t?he.aboutDotConnected:he.aboutDotDisconnected}`}),t?"Connected":"Disconnected"]})]}),i.jsxs("div",{className:he.aboutItem,children:[i.jsx("span",{className:he.aboutLabel,children:"Environments"}),i.jsxs("span",{className:he.aboutValue,children:[r,"/",c," connected"]})]}),i.jsxs("div",{className:he.aboutItem,children:[i.jsx("span",{className:he.aboutLabel,children:"Active Sessions"}),i.jsx("span",{className:he.aboutValue,children:d})]}),i.jsxs("div",{className:he.aboutItem,children:[i.jsx("span",{className:he.aboutLabel,children:"Version"}),i.jsx("span",{className:he.aboutValue,children:"0.104.0"})]})]})]})}const hB="_container_cddyd_1",gB="_header_cddyd_8",vB="_headerTitle_cddyd_35",yB="_badge_cddyd_44",bB="_headerActions_cddyd_54",xB="_body_cddyd_61",_B="_formContent_cddyd_73",kB="_section_cddyd_85",SB="_label_cddyd_91",TB="_titleInput_cddyd_98",jB="_descriptionTextarea_cddyd_131",wB="_parentContext_cddyd_167",NB="_parentLabel_cddyd_175",CB="_parentName_cddyd_182",EB="_personaSelect_cddyd_186",AB="_depList_cddyd_220",DB="_depItem_cddyd_226",RB="_depItemSelected_cddyd_248",MB="_noDeps_cddyd_252",IB="_btnPrimary_cddyd_258",OB="_btnGhost_cddyd_289",nt={container:hB,header:gB,headerTitle:vB,badge:yB,headerActions:bB,body:xB,formContent:_B,section:kB,label:SB,titleInput:TB,descriptionTextarea:jB,parentContext:wB,parentLabel:NB,parentName:CB,personaSelect:EB,depList:AB,depItem:DB,depItemSelected:RB,noDeps:MB,btnPrimary:IB,btnGhost:OB};function V1({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:x}){const y=mt(),S=t==="edit",k=S&&s?d.find(xe=>xe.id===s):void 0,j=S?(k==null?void 0:k.workspaceId)??"":o??"",[N,T]=b.useState(j),C=j||N,A=u.find(xe=>xe.id===C),O=c??(A==null?void 0:A.environmentId),E=!S&&!o,D=S?(k==null?void 0:k.parentTaskId)??"":r??"",U=D?d.find(xe=>xe.id===D):void 0,[B,z]=b.useState((k==null?void 0:k.title)??""),[X,$]=b.useState((k==null?void 0:k.description)??""),[J,me]=b.useState((k==null?void 0:k.dependsOn)??[]),[ee,oe]=b.useState((k==null?void 0:k.defaultPersonaId)??""),[R,G]=b.useState((k==null?void 0:k.canDecompose)??!1),[Z,de]=b.useState(!1),W=b.useRef(!1);b.useEffect(()=>{S&&k&&!W.current&&(W.current=!0,z(k.title),$(k.description),me(k.dependsOn),oe(k.defaultPersonaId),G(k.canDecompose))},[S,k]);const Q=d.filter(xe=>xe.workspaceId===C&&(!S||xe.id!==s)&&xe.id!==D),ue=B.trim().length>0&&(!S||k!==void 0)&&C.length>0,Ce=xe=>{me(Be=>Be.includes(xe)?Be.filter(It=>It!==xe):[...Be,xe])},Ue=()=>{!ue||Z||S&&k===void 0||(S&&s?(g(s,B.trim(),X,J,ee),x==null||x("Task updated","success"),v?v():y(On(s,void 0,C,O),{replace:!0})):(de(!0),m(C,B.trim(),X,J.length>0?J:void 0,D||void 0,ee,R,()=>{x==null||x("Task created","success"),y(o?Ga(o,O):"/tasks",{replace:!0})},xe=>{x==null||x(xe,"error"),de(!1)})))},ve=()=>{if(v){v();return}y(S&&s?On(s,void 0,C,O):o?Ga(o,O):"/tasks")},Se=S?"edit task":D?"child task":"new task";return i.jsxs("div",{className:nt.container,children:[i.jsxs("div",{className:nt.header,children:[i.jsxs("div",{className:nt.headerTitle,children:[i.jsx("span",{className:nt.badge,children:Se}),U&&i.jsxs("span",{className:nt.parentContext,children:[i.jsx("span",{className:nt.parentLabel,children:"Child of"}),i.jsx("span",{className:nt.parentName,children:U.title})]})]}),i.jsxs("div",{className:nt.headerActions,children:[i.jsx("button",{onClick:Ue,disabled:!ue||Z,className:nt.btnPrimary,"data-testid":"task-edit-save",children:Z?"Creating…":S?"Save Changes":"Create"}),i.jsx("button",{onClick:ve,className:nt.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:nt.body,children:i.jsxs("div",{className:nt.formContent,children:[E&&i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-workspace",children:"Workspace"}),i.jsxs("select",{id:"task-edit-workspace",value:N,onChange:xe=>T(xe.target.value),className:nt.personaSelect,"data-testid":"task-edit-workspace",children:[i.jsx("option",{value:"",children:"Select a workspace..."}),u.map(xe=>i.jsx("option",{value:xe.id,children:xe.name},xe.id))]})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-title",children:"Title"}),i.jsx("input",{id:"task-edit-title",type:"text",value:B,onChange:xe=>z(xe.target.value),placeholder:"Task title...",autoFocus:!0,className:nt.titleInput,"data-testid":"task-edit-title",onKeyDown:xe=>{xe.key==="Enter"&&ue&&Ue()}})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-description",children:"Description"}),i.jsx("textarea",{id:"task-edit-description",value:X,onChange:xe=>$(xe.target.value),placeholder:"Describe the task... (markdown supported)",className:nt.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),i.jsxs("div",{className:nt.section,children:[i.jsx("label",{className:nt.label,htmlFor:"task-edit-persona",children:"Default Persona"}),i.jsxs("select",{id:"task-edit-persona",value:ee,onChange:xe=>oe(xe.target.value),className:nt.personaSelect,"data-testid":"task-edit-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),p.map(xe=>i.jsx("option",{value:xe.id,children:xe.name},xe.id))]})]}),!S&&i.jsx("div",{className:nt.section,children:i.jsxs("label",{className:nt.depItem,"data-testid":"task-edit-can-decompose",children:[i.jsx("input",{type:"checkbox",checked:R,onChange:xe=>G(xe.target.checked)}),"Can spawn subtasks"]})}),i.jsxs("div",{className:nt.section,children:[i.jsx("div",{className:nt.label,children:"Dependencies"}),Q.length===0?i.jsx("div",{className:nt.noDeps,children:"No other tasks in this workspace"}):i.jsx("div",{className:nt.depList,children:Q.map(xe=>{const Be=J.includes(xe.id);return i.jsxs("label",{className:`${nt.depItem} ${Be?nt.depItemSelected:""}`,"data-testid":`dep-option-${xe.id}`,children:[i.jsx("input",{type:"checkbox",checked:Be,onChange:()=>Ce(xe.id)}),xe.title,i.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",xe.status,")"]})]},xe.id)})})]})]})})]})}const BB="_actionButtons_1rjka_1",LB="_btnPrimary_1rjka_8",zB="_btnDanger_1rjka_39",$B="_btnGhost_1rjka_78",Kt={actionButtons:BB,btnPrimary:LB,btnDanger:zB,btnGhost:$B};function PB({task:t,sessionId:s,isBlocked:o,onStart:r,onResume:c,onStop:d,onPause:u,onDelete:p,onEdit:m}){if(t.status==="not_started")return o?i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:m,className:Kt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Kt.btnPrimary,children:"Start"}),i.jsx("button",{onClick:m,className:Kt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Kt.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:u,disabled:!s,className:Kt.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:d,className:Kt.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),i.jsx("button",{onClick:c,className:Kt.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return i.jsx("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return i.jsxs("div",{className:Kt.actionButtons,"data-testid":"task-action-buttons",children:[i.jsx("button",{onClick:r,className:Kt.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),i.jsx("button",{onClick:p,className:Kt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const UB="_workpadSection_y8nj9_1",HB="_workpadLabel_y8nj9_9",VB="_workpadStatus_y8nj9_17",qB="_workpadSummary_y8nj9_23",GB="_workpadExtra_y8nj9_29",La={workpadSection:UB,workpadLabel:HB,workpadStatus:VB,workpadSummary:qB,workpadExtra:GB};function FB({workpad:t}){if(!t)return;let s;try{const o=JSON.parse(t);if(o==null||typeof o!="object"||Array.isArray(o))return;s=o}catch{return i.jsxs("div",{className:La.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:La.workpadLabel,children:"Workpad"}),i.jsx("div",{className:La.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return i.jsxs("div",{className:La.workpadSection,"data-testid":"workpad-panel",children:[i.jsx("div",{className:La.workpadLabel,children:"Workpad"}),s.status&&i.jsx("div",{className:La.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&i.jsx("div",{className:La.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&i.jsx("div",{className:La.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const ZB="_overviewDashboard_r05qm_1",KB="_overviewHero_r05qm_7",YB="_statusBadge_r05qm_14",JB="_statusPending_r05qm_26",WB="_statusAssigned_r05qm_31",XB="_statusInProgress_r05qm_36",QB="_statusReview_r05qm_41",eL="_statusDone_r05qm_46",tL="_statusFailed_r05qm_51",nL="_statusWaitingInput_r05qm_56",sL="_overviewBranchPill_r05qm_61",aL="_branchLink_r05qm_76",iL="_overviewSection_r05qm_87",oL="_overviewLabel_r05qm_93",rL="_overviewValue_r05qm_100",lL="_overviewMuted_r05qm_105",cL="_overviewMarkdown_r05qm_111",dL="_envRow_r05qm_180",uL="_envDot_r05qm_186",fL="_envDotGreen_r05qm_193",pL="_envDotYellow_r05qm_197",mL="_envDotRed_r05qm_201",hL="_envDotGray_r05qm_205",gL="_depList_r05qm_209",vL="_depItem_r05qm_215",yL="_depBlocked_r05qm_222",bL="_depDone_r05qm_226",xL="_timeline_r05qm_230",_L="_timelineRow_r05qm_236",kL="_timelineKey_r05qm_243",SL="_timelineValue_r05qm_249",TL="_timelineDelta_r05qm_253",jL="_reviewNotes_r05qm_264",ye={overviewDashboard:ZB,overviewHero:KB,statusBadge:YB,statusPending:JB,statusAssigned:WB,statusInProgress:XB,statusReview:QB,statusDone:eL,statusFailed:tL,statusWaitingInput:nL,overviewBranchPill:sL,branchLink:aL,overviewSection:iL,overviewLabel:oL,overviewValue:rL,overviewMuted:lL,overviewMarkdown:cL,envRow:dL,envDot:uL,envDotGreen:fL,envDotYellow:pL,envDotRed:mL,envDotGray:hL,depList:gL,depItem:vL,depBlocked:yL,depDone:bL,timeline:xL,timelineRow:_L,timelineKey:kL,timelineValue:SL,timelineDelta:TL,reviewNotes:jL};function Fc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Ep(t,s){if(!t||!s)return;const o=new Date(s).getTime()-new Date(t).getTime();if(isNaN(o)||o<0)return;const r=Math.floor(o/6e4),c=Math.floor(o%6e4/1e3);if(r===0)return`${c}s`;const d=Math.floor(r/60),u=r%60;return d===0?`${r}m ${c}s`:`${d}h ${u}m`}function nx(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?ye.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?ye.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?ye.envDotRed:ye.envDotGray}function wL({status:t}){const s=qa(t),o=kj(t);return i.jsx("span",{className:`${ye.statusBadge} ${ye[o]??ye.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function NL({task:t,tasksById:s,environments:o,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?o.find(k=>k.id===g):void 0,x=r.find(k=>k.id===t.workspaceId),y=o.find(k=>k.id===d),S=t.branch&&(x!=null&&x.repoUrl)?`${x.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return i.jsxs("div",{className:ye.overviewDashboard,"data-testid":"task-overview-panel",children:[i.jsxs("div",{className:ye.overviewHero,children:[i.jsx(wL,{status:t.status}),t.branch&&i.jsx("span",{className:ye.overviewBranchPill,"data-testid":"task-overview-branch",children:S?i.jsxs("a",{href:S,target:"_blank",rel:"noreferrer noopener",className:ye.branchLink,children:["🔗"," ",t.branch]}):i.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&i.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-description",children:[i.jsx("div",{className:ye.overviewLabel,children:"Description"}),i.jsx("div",{className:ye.overviewMarkdown,children:i.jsx(Td,{remarkPlugins:[jd],children:t.description})})]}),t.workpad&&i.jsx(FB,{workpad:t.workpad}),i.jsxs("div",{className:ye.overviewSection,children:[i.jsx("div",{className:ye.overviewLabel,children:"Environment"}),g&&v?i.jsxs("div",{className:ye.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${ye.envDot} ${nx(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),i.jsx("span",{className:ye.overviewValue,children:v.displayName})]}):y?i.jsxs("div",{className:ye.envRow,"data-testid":"task-overview-environment",children:[i.jsx("span",{className:`${ye.envDot} ${nx(y.status)}`,title:y.status,"aria-label":`Status: ${y.status}`,role:"img"}),i.jsx("span",{className:ye.overviewValue,children:y.displayName}),i.jsx("span",{className:ye.overviewMuted,children:"(workspace default)"})]}):i.jsx("div",{className:ye.overviewMuted,children:"Set in workspace settings"})]}),i.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-dependencies",children:[i.jsx("div",{className:ye.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?i.jsx("div",{className:ye.overviewMuted,children:"None"}):i.jsx("div",{className:ye.depList,children:t.dependsOn.map(k=>{const j=s.get(k),N=(j==null?void 0:j.status)==="complete";return i.jsxs("div",{className:`${ye.depItem} ${N?ye.depDone:ye.depBlocked}`,children:[i.jsx("span",{children:N?"✓":"○"}),i.jsx("span",{children:(j==null?void 0:j.title)??k})]},k)})})]}),i.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-timeline",children:[i.jsx("div",{className:ye.overviewLabel,children:"Timeline"}),i.jsxs("div",{className:ye.timeline,children:[t.createdAt&&i.jsxs("div",{className:ye.timelineRow,children:[i.jsx("span",{className:ye.timelineKey,children:"Created"}),i.jsx("span",{className:ye.timelineValue,children:Fc(t.createdAt)})]}),t.assignedAt&&(()=>{const k=Ep(t.createdAt,t.assignedAt);return i.jsxs("div",{className:ye.timelineRow,children:[i.jsx("span",{className:ye.timelineKey,children:"Assigned"}),i.jsx("span",{className:ye.timelineValue,children:Fc(t.assignedAt)}),k!==void 0&&i.jsx("span",{className:ye.timelineDelta,children:k})]})})(),t.startedAt&&(()=>{const k=Ep(t.assignedAt??t.createdAt,t.startedAt);return i.jsxs("div",{className:ye.timelineRow,children:[i.jsx("span",{className:ye.timelineKey,children:"Started"}),i.jsx("span",{className:ye.timelineValue,children:Fc(t.startedAt)}),k!==void 0&&i.jsx("span",{className:ye.timelineDelta,children:k})]})})(),t.completedAt&&(()=>{const k=Ep(t.startedAt,t.completedAt);return i.jsxs("div",{className:ye.timelineRow,children:[i.jsx("span",{className:ye.timelineKey,children:"Completed"}),i.jsx("span",{className:ye.timelineValue,children:Fc(t.completedAt)}),k!==void 0&&i.jsx("span",{className:ye.timelineDelta,children:k})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&i.jsx("div",{className:ye.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&i.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-usage",children:[i.jsx("div",{className:ye.overviewLabel,children:"Usage"}),i.jsxs("div",{className:ye.timeline,children:[i.jsxs("div",{className:ye.timelineRow,children:[i.jsx("span",{className:ye.timelineKey,children:"Cost"}),i.jsx("span",{className:ye.timelineValue,children:Ns(u.costMillicents)}),i.jsxs("span",{className:ye.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&i.jsxs("div",{className:ye.timelineRow,children:[i.jsx("span",{className:ye.timelineKey,children:"Total (incl. subtasks)"}),i.jsx("span",{className:ye.timelineValue,children:Ns(p.costMillicents)}),i.jsxs("span",{className:ye.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&i.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-budget",children:[i.jsx("div",{className:ye.overviewLabel,children:"Budget"}),i.jsxs("div",{className:ye.timeline,children:[t.tokenBudget>0&&i.jsxs("div",{className:ye.timelineRow,children:[i.jsx("span",{className:ye.timelineKey,children:"Tokens"}),i.jsxs("span",{className:ye.timelineValue,children:[Oo(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," / ",Oo(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&i.jsxs("div",{className:ye.timelineRow,children:[i.jsx("span",{className:ye.timelineKey,children:"Cost"}),i.jsxs("span",{className:ye.timelineValue,children:[Ns((u==null?void 0:u.costMillicents)??0)," / ",Ns(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&i.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-review-notes",children:[i.jsx("div",{className:ye.overviewLabel,children:"Review Notes"}),i.jsx("div",{className:ye.reviewNotes,children:t.reviewNotes})]})]})}function CL({plugins:t,loading:s,onSetPluginEnabled:o}){return i.jsxs("div",{className:he.container,"data-testid":"plugins-panel",children:[i.jsx("h2",{className:he.heading,children:"Plugins"}),i.jsxs("div",{className:he.section,children:[i.jsx("p",{className:he.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&i.jsx("p",{className:he.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&i.jsx("p",{className:he.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return i.jsxs("div",{className:he.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:he.tokenName,children:r.name}),r.required&&i.jsx("span",{className:he.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),i.jsx("div",{className:he.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)})]})]})}const EL="_container_legrg_1",AL="_header_legrg_8",DL="_headerTitle_legrg_35",RL="_badge_legrg_44",ML="_headerActions_legrg_54",IL="_body_legrg_61",OL="_formContent_legrg_73",BL="_section_legrg_85",LL="_label_legrg_91",zL="_nameInput_legrg_98",$L="_fieldInput_legrg_131",PL="_adapterSelect_legrg_164",UL="_readOnlyValue_legrg_198",HL="_codespaceSection_legrg_204",VL="_codespaceActions_legrg_210",qL="_creatingHint_legrg_216",GL="_errorHint_legrg_222",FL="_btnPrimary_legrg_235",ZL="_btnGhost_legrg_266",ce={container:EL,header:AL,headerTitle:DL,badge:RL,headerActions:ML,body:IL,formContent:OL,section:BL,label:LL,nameInput:zL,fieldInput:$L,adapterSelect:PL,readOnlyValue:UL,codespaceSection:HL,codespaceActions:VL,creatingHint:qL,errorHint:GL,btnPrimary:FL,btnGhost:ZL},od=1,rd=65535;function Ap(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=od&&s<=rd}function Dp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function KL({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=b.useState("pick"),[x,y]=b.useState(""),[S,k]=b.useState("");return g==="create"?i.jsxs("div",{className:ce.codespaceSection,children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Repository"}),i.jsx("input",{type:"text",value:x,onChange:j=>y(j.target.value),placeholder:"owner/repo",className:ce.fieldInput,"data-testid":"env-codespace-repo"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Machine Type"}),i.jsx("input",{type:"text",value:S,onChange:j=>k(j.target.value),placeholder:"Machine type (optional)...",className:ce.fieldInput,"data-testid":"env-codespace-machine"})]}),i.jsxs("div",{className:ce.codespaceActions,children:[i.jsx("button",{onClick:()=>{x.trim()&&(m(x.trim(),S.trim()||void 0),v("pick"),y(""),k(""))},disabled:!x.trim(),className:ce.btnPrimary,children:"Create"}),i.jsx("button",{onClick:()=>{v("pick"),y(""),k("")},className:ce.btnGhost,children:"Cancel"})]})]}):i.jsx("div",{className:ce.codespaceSection,children:i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Codespace"}),!u&&i.jsxs("select",{value:t,onChange:j=>{j.target.value==="__create__"?(v("create"),s("")):(s(j.target.value),j.target.value&&!o.trim()&&r(j.target.value))},disabled:p,className:ce.adapterSelect,"data-testid":"env-codespace-select",children:[i.jsx("option",{value:"",children:"Select a codespace..."}),c.map(j=>i.jsxs("option",{value:j.name,children:[j.name," (",j.repository,") — ",j.state]},j.name)),i.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&i.jsx("span",{className:ce.creatingHint,children:"Creating codespace..."}),u&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:ce.errorHint,children:u}),i.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:ce.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&i.jsx("span",{className:ce.errorHint,children:d})]})})}function q1({mode:t,environmentId:s,environments:o,onAddEnvironment:r,onUpdateEnvironment:c,onListCodespaces:d,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v,onShowToast:x}){const y=mt(),S=t==="edit",k=S&&s?o.find(ve=>ve.id===s):void 0,[j,N]=b.useState(""),[T,C]=b.useState("local"),[A,O]=b.useState(""),[E,D]=b.useState(""),[U,B]=b.useState(""),[z,X]=b.useState(""),[$,J]=b.useState(""),[me,ee]=b.useState(""),[oe,R]=b.useState(""),[G,Z]=b.useState(null),de=b.useCallback(()=>{const ve={};if(T==="local"){if(A.trim()&&(ve.host=A.trim()),E.trim()){const Se=Number(E);Number.isInteger(Se)&&(ve.port=Se)}}else if(T==="ssh"){if(ve.host=A.trim(),U.trim()&&(ve.user=U.trim()),E.trim()){const Se=Number(E);Number.isInteger(Se)&&(ve.sshPort=Se)}z.trim()&&(ve.identityFile=z.trim())}else T==="docker"?($.trim()&&(ve.image=$.trim()),me.trim()&&(ve.repo=me.trim())):T==="codespace"&&(ve.codespaceName=oe.trim());return ve},[T,A,E,U,z,$,me,oe]),W=()=>!(!j.trim()||T==="ssh"&&!A.trim()||T==="codespace"&&!oe.trim()||(T==="local"||T==="ssh")&&!Ap(E)),Q=()=>{W()&&(r(j.trim(),T,de()),x==null||x("Environment added successfully","success"),y(Io,{replace:!0}))},ue=()=>{y(s?Ai(s):Io)},Ce=b.useCallback((ve,Se)=>{if(!k||!s)return;const xe=Dp(k.adapterConfig),Be=Se.trim();Be?xe[ve]=Be:delete xe[ve],c(s,{adapterConfig:xe})},[k,s,c]),Ue=b.useCallback((ve,Se)=>{if(!k||!s)return;const xe=Dp(k.adapterConfig);if(Se.trim()){const Be=Number(Se);Number.isInteger(Be)&&Be>=od&&Be<=rd&&(xe[ve]=Be)}else delete xe[ve];c(s,{adapterConfig:xe})},[k,s,c]);if(S){if(!k)return i.jsxs("div",{className:ce.container,children:[i.jsxs("div",{className:ce.header,children:[i.jsx("div",{className:ce.headerTitle,children:i.jsx("span",{className:ce.badge,children:"edit environment"})}),i.jsx("div",{className:ce.headerActions,children:i.jsx("button",{onClick:ue,className:ce.btnGhost,children:"Back"})})]}),i.jsx("div",{className:ce.body,children:i.jsx("div",{className:ce.formContent,children:i.jsx("span",{className:ce.readOnlyValue,children:"Environment not found"})})})]});const ve=Dp(k.adapterConfig);return i.jsxs("div",{className:ce.container,"data-testid":"env-edit-panel",children:[i.jsxs("div",{className:ce.header,children:[i.jsx("div",{className:ce.headerTitle,children:i.jsx("span",{className:ce.badge,children:"edit environment"})}),i.jsx("div",{className:ce.headerActions,children:i.jsx("button",{onClick:ue,className:ce.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),i.jsx("div",{className:ce.body,children:i.jsxs("div",{className:ce.formContent,children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Name"}),i.jsx(Ft,{value:k.displayName,onSave:Se=>{s&&c(s,{displayName:Se})},validate:Se=>Se.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:G,onActivate:Z,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Adapter Type"}),i.jsx("span",{className:ce.readOnlyValue,"data-testid":"env-edit-adapter-type",children:k.adapterType})]}),k.adapterType==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Host"}),i.jsx(Ft,{value:String(ve.host??""),onSave:Se=>Ce("host",Se),mode:"edit",fieldId:"host",activeFieldId:G,onActivate:Z,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Port"}),i.jsx(Ft,{value:String(ve.port??""),onSave:Se=>Ue("port",Se),validate:Se=>Ap(Se)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:G,onActivate:Z,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),k.adapterType==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Host"}),i.jsx(Ft,{value:String(ve.host??""),onSave:Se=>Ce("host",Se),validate:Se=>Se.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:G,onActivate:Z,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"User"}),i.jsx(Ft,{value:String(ve.user??""),onSave:Se=>Ce("user",Se),mode:"edit",fieldId:"user",activeFieldId:G,onActivate:Z,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"SSH Port"}),i.jsx(Ft,{value:String(ve.sshPort??""),onSave:Se=>Ue("sshPort",Se),validate:Se=>Ap(Se)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:G,onActivate:Z,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Identity File"}),i.jsx(Ft,{value:String(ve.identityFile??""),onSave:Se=>Ce("identityFile",Se),mode:"edit",fieldId:"identityFile",activeFieldId:G,onActivate:Z,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),k.adapterType==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Image"}),i.jsx(Ft,{value:String(ve.image??""),onSave:Se=>Ce("image",Se),mode:"edit",fieldId:"image",activeFieldId:G,onActivate:Z,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Repo"}),i.jsx(Ft,{value:String(ve.repo??""),onSave:Se=>Ce("repo",Se),mode:"edit",fieldId:"repo",activeFieldId:G,onActivate:Z,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),k.adapterType==="codespace"&&i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,children:"Codespace Name"}),i.jsx(Ft,{value:String(ve.codespaceName??""),onSave:Se=>Ce("codespaceName",Se),validate:Se=>Se.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:G,onActivate:Z,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return i.jsxs("div",{className:ce.container,"data-testid":"env-create-panel",children:[i.jsxs("div",{className:ce.header,children:[i.jsx("div",{className:ce.headerTitle,children:i.jsx("span",{className:ce.badge,children:"new environment"})}),i.jsxs("div",{className:ce.headerActions,children:[i.jsx("button",{onClick:Q,disabled:!W(),className:ce.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),i.jsx("button",{onClick:ue,className:ce.btnGhost,children:"Cancel"})]})]}),i.jsx("div",{className:ce.body,children:i.jsxs("div",{className:ce.formContent,children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-name",children:"Name"}),i.jsx("input",{id:"env-create-name",type:"text",value:j,onChange:ve=>N(ve.target.value),placeholder:"Environment name...",autoFocus:!0,className:ce.nameInput,"data-testid":"env-create-name",onKeyDown:ve=>{ve.key==="Enter"&&W()&&Q()}})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),i.jsxs("select",{id:"env-create-adapter",value:T,onChange:ve=>{C(ve.target.value),ve.target.value==="codespace"&&d()},className:ce.adapterSelect,"data-testid":"env-create-adapter",children:[i.jsx("option",{value:"local",children:"local"}),i.jsx("option",{value:"ssh",children:"ssh"}),i.jsx("option",{value:"docker",children:"docker"}),i.jsx("option",{value:"codespace",children:"codespace"})]})]}),T==="local"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:A,onChange:ve=>O(ve.target.value),placeholder:"Host (optional)...",className:ce.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-port",children:"Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:od,max:rd,value:E,onChange:ve=>D(ve.target.value),placeholder:"Port (optional)...",className:ce.fieldInput,"data-testid":"env-create-port"})]})]}),T==="ssh"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-host",children:"Host"}),i.jsx("input",{id:"env-create-host",type:"text",value:A,onChange:ve=>O(ve.target.value),placeholder:"Host (required)...",className:ce.fieldInput,"data-testid":"env-create-host"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-user",children:"User"}),i.jsx("input",{id:"env-create-user",type:"text",value:U,onChange:ve=>B(ve.target.value),placeholder:"User (optional)...",className:ce.fieldInput,"data-testid":"env-create-user"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-port",children:"SSH Port"}),i.jsx("input",{id:"env-create-port",type:"number",min:od,max:rd,value:E,onChange:ve=>D(ve.target.value),placeholder:"SSH port (optional)...",className:ce.fieldInput,"data-testid":"env-create-port"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-identity",children:"Identity File"}),i.jsx("input",{id:"env-create-identity",type:"text",value:z,onChange:ve=>X(ve.target.value),placeholder:"Identity file (optional)...",className:ce.fieldInput,"data-testid":"env-create-identity"})]})]}),T==="docker"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-image",children:"Image"}),i.jsx("input",{id:"env-create-image",type:"text",value:$,onChange:ve=>J(ve.target.value),placeholder:"Image (optional)...",className:ce.fieldInput,"data-testid":"env-create-image"})]}),i.jsxs("div",{className:ce.section,children:[i.jsx("label",{className:ce.label,htmlFor:"env-create-repo",children:"Repo"}),i.jsx("input",{id:"env-create-repo",type:"text",value:me,onChange:ve=>ee(ve.target.value),placeholder:"Repo (optional)...",className:ce.fieldInput,"data-testid":"env-create-repo"})]})]}),T==="codespace"&&i.jsx(KL,{codespaceName:oe,onCodespaceNameChange:R,envName:j,onEnvNameChange:N,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v})]})})]})}const YL="_group_1iprv_1",JL="_groupTitle_1iprv_8",WL="_shortcutList_1iprv_17",XL="_shortcutRow_1iprv_23",QL="_keys_1iprv_36",e8="_kbd_1iprv_43",t8="_description_1iprv_60",Si={group:YL,groupTitle:JL,shortcutList:WL,shortcutRow:XL,keys:QL,kbd:e8,description:t8},n8=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"},{keys:["3"],description:"Switch to Findings tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Chat",shortcuts:[{keys:["Enter"],description:"Send message (when input is focused)"}]}];function s8(){return i.jsxs("section",{className:he.section,"data-testid":"keyboard-shortcuts-panel",children:[i.jsx("h3",{className:he.sectionTitle,children:"Keyboard Shortcuts"}),i.jsx("p",{className:he.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),n8.map(t=>i.jsxs("div",{className:Si.group,children:[i.jsx("h4",{className:Si.groupTitle,children:t.title}),i.jsx("div",{className:Si.shortcutList,children:t.shortcuts.map(s=>i.jsxs("div",{className:Si.shortcutRow,children:[i.jsx("span",{className:Si.keys,children:s.keys.map(o=>i.jsx("kbd",{className:Si.kbd,children:o},o))}),i.jsx("span",{className:Si.description,children:s.description})]},s.description))})]},t.title))]})}const a8=[{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 i8({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:he.section,children:[i.jsx("h3",{className:he.sectionTitle,children:"Credential Providers"}),i.jsx("p",{className:he.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:he.tokenList,children:a8.map(r=>i.jsxs("div",{className:he.tokenRow,children:[i.jsx("span",{className:he.tokenName,children:r.label}),i.jsx("span",{className:he.tokenTarget,children:r.description}),i.jsx("select",{className:he.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 o8="_container_10efq_1",r8="_header_10efq_7",l8="_list_10efq_105",c8="_card_10efq_111",d8="_cardHeader_10efq_125",u8="_cardTitle_10efq_135",f8="_defaultBadge_10efq_141",p8="_cardActions_10efq_155",m8="_description_10efq_160",h8="_meta_10efq_166",g8="_empty_10efq_212",v8="_typeBadge_10efq_362",Xn={container:o8,header:r8,list:l8,card:c8,cardHeader:d8,cardTitle:u8,defaultBadge:f8,cardActions:p8,description:m8,meta:h8,empty:g8,typeBadge:v8};function y8({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=b.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return i.jsxs("div",{className:Xn.container,children:[i.jsxs("div",{className:Xn.header,children:[i.jsx("h2",{children:"Personas"}),i.jsx(tn,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?i.jsx("p",{className:Xn.empty,children:"No personas yet. Create one to get started."}):i.jsx("div",{className:Xn.list,children:t.map(v=>{const x=s===v.id,y=v.type==="script";return i.jsxs("div",{className:Xn.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),d(v.id))},children:[i.jsxs("div",{className:Xn.cardHeader,children:[i.jsxs("span",{className:Xn.cardTitle,children:[i.jsx("strong",{children:v.name}),i.jsx("span",{className:Xn.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:y?"Script":"Agent"}),x&&i.jsx("span",{className:Xn.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),i.jsxs("div",{className:Xn.cardActions,onClick:S=>S.stopPropagation(),children:[!x&&i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>{r(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&i.jsx("p",{className:Xn.description,children:v.description}),i.jsxs("div",{className:Xn.meta,children:[v.runtime&&i.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&i.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&i.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),i.jsx(oa,{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 b8="_container_uy08i_1",x8="_header_uy08i_7",_8="_count_uy08i_13",k8="_presets_uy08i_18",S8="_presetButton_uy08i_24",T8="_filterInput_uy08i_41",j8="_groups_uy08i_53",w8="_group_uy08i_53",N8="_groupHeader_uy08i_68",C8="_groupName_uy08i_77",E8="_groupCount_uy08i_81",A8="_toolList_uy08i_87",D8="_toolItem_uy08i_95",R8="_toolName_uy08i_103",gn={container:b8,header:x8,count:_8,presets:k8,presetButton:S8,filterInput:T8,groups:j8,group:w8,groupHeader:N8,groupName:C8,groupCount:E8,toolList:A8,toolItem:D8,toolName:R8},M8=(()=>{const t=new Map;for(const s of kx){const o=s==="get_version_status"?"version":s.split("_")[0];t.has(o)||t.set(o,[]),t.get(o).push(s)}return[...t.entries()].sort(([s],[o])=>s.localeCompare(o)).map(([s,o])=>({group:s,tools:o.sort()}))})(),I8=[{name:"default",label:"Default",tools:Sx},{name:"worker",label:"Worker",tools:RT},{name:"orchestrator",label:"Orchestrator",tools:MT},{name:"admin",label:"Admin",tools:IT}];function sx({selectedTools:t,onChange:s,disabled:o}){const[r,c]=b.useState(""),d=b.useMemo(()=>new Set(t),[t]),u=b.useCallback(v=>{if(o)return;const x=new Set(d);x.has(v)?x.delete(v):x.add(v),s([...x].sort())},[d,s,o]),p=b.useCallback((v,x)=>{if(o)return;const y=new Set(d);for(const S of v)x?y.delete(S):y.add(S);s([...y].sort())},[d,s,o]),m=b.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return i.jsxs("div",{className:gn.container,"data-testid":"mcp-tool-selector",children:[i.jsx("div",{className:gn.header,children:i.jsx("span",{className:gn.count,children:t.length===0?`Using default (${Sx.length} tools)`:`${t.length} of ${kx.size} tools selected`})}),i.jsxs("div",{className:gn.presets,"data-testid":"mcp-tool-presets",children:[I8.map(v=>i.jsx("button",{type:"button",className:gn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),i.jsx("button",{type:"button",className:gn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),i.jsx("input",{type:"text",className:gn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),i.jsx("div",{className:gn.groups,children:M8.map(({group:v,tools:x})=>{const y=g?x.filter(k=>k.toLowerCase().includes(g)):x;if(y.length===0)return null;const S=y.every(k=>d.has(k));return i.jsxs("div",{className:gn.group,"data-testid":`tool-group-${v}`,children:[i.jsxs("label",{className:gn.groupHeader,children:[i.jsx("input",{type:"checkbox",checked:S,onChange:()=>p(y,S),disabled:o,"data-testid":`group-toggle-${v}`}),i.jsx("span",{className:gn.groupName,children:v}),i.jsxs("span",{className:gn.groupCount,children:["(",y.filter(k=>d.has(k)).length,"/",y.length,")"]})]}),i.jsx("div",{className:gn.toolList,children:y.map(k=>i.jsxs("label",{className:gn.toolItem,children:[i.jsx("input",{type:"checkbox",checked:d.has(k),onChange:()=>u(k),disabled:o,"data-testid":`tool-${k}`}),i.jsx("span",{className:gn.toolName,children:k})]},k))})]},v)})})]})}const O8="_container_1gfuq_1",B8="_header_1gfuq_7",L8="_list_1gfuq_19",z8="_card_1gfuq_25",$8="_cardHeader_1gfuq_40",P8="_cardTitle_1gfuq_46",U8="_statusBadge_1gfuq_56",H8="_enabled_1gfuq_68",V8="_disabled_1gfuq_71",q8="_cardActions_1gfuq_75",G8="_cardMeta_1gfuq_80",F8="_empty_1gfuq_98",Qn={container:O8,header:B8,list:L8,card:z8,cardHeader:$8,cardTitle:P8,statusBadge:U8,enabled:H8,disabled:V8,cardActions:q8,cardMeta:G8,empty:F8};function Z8({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=b.useState(null),m=u?t.find(y=>y.id===u):void 0,g=async y=>{await o(y),p(null)},v=b.useMemo(()=>{const y=new Map;for(const S of s)y.set(S.id,S.name);return y},[s]),x=y=>v.get(y)??y;return i.jsxs("div",{className:Qn.container,children:[i.jsxs("div",{className:Qn.header,children:[i.jsx("h2",{children:"Schedules"}),i.jsx(tn,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?i.jsx("p",{className:Qn.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):i.jsx("div",{className:Qn.list,children:t.map(y=>i.jsxs("div",{className:Qn.card,"data-testid":`schedule-card-${y.id}`,onClick:()=>d(y.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),d(y.id))},children:[i.jsxs("div",{className:Qn.cardHeader,children:[i.jsxs("span",{className:Qn.cardTitle,children:[i.jsx("strong",{children:y.title}),i.jsx("span",{className:`${Qn.statusBadge} ${y.enabled?Qn.enabled:Qn.disabled}`,"data-testid":`schedule-status-badge-${y.id}`,children:y.enabled?"Enabled":"Disabled"})]}),i.jsxs("div",{className:Qn.cardActions,onClick:S=>S.stopPropagation(),children:[i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(y.id,{enabled:!y.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${y.id}`,title:y.enabled?"Disable schedule":"Enable schedule",children:y.enabled?"Disable":"Enable"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>d(y.id),"data-testid":`schedule-edit-${y.id}`,children:"Edit"}),i.jsx(tn,{variant:"ghost",size:"sm",onClick:()=>p(y.id),"data-testid":`schedule-delete-${y.id}`,children:"Delete"})]})]}),i.jsxs("div",{className:Qn.cardMeta,children:[i.jsx("span",{"data-testid":`schedule-expression-${y.id}`,children:y.scheduleExpression}),y.personaId&&i.jsxs("span",{"data-testid":`schedule-persona-${y.id}`,children:["Persona: ",x(y.personaId)]}),i.jsxs("span",{"data-testid":`schedule-last-run-${y.id}`,children:["Last run: ",y.lastRunAt?Uo(y.lastRunAt):"Never"]}),y.enabled&&y.nextRunAt?i.jsxs("span",{"data-testid":`schedule-next-run-${y.id}`,children:["Next run: ",B1(y.nextRunAt)]}):null,y.runCount>0&&i.jsxs("span",{"data-testid":`schedule-run-count-${y.id}`,children:["Runs: ",y.runCount]})]})]},y.id))}),i.jsx(oa,{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 K8="_nav_1bhou_1",Y8="_tab_1bhou_24",J8="_tabIcon_1bhou_62",W8="_tabActive_1bhou_68",Zc={nav:K8,tab:Y8,tabIcon:J8,tabActive:W8},Qs=[{path:"credentials",label:"Credentials",icon:i.jsx(V2,{size:Nt})},{path:"personas",label:"Personas",icon:i.jsx(bj,{size:Nt})},{path:"schedules",label:"Schedules",icon:i.jsx(_2,{size:Nt})},{path:"appearance",label:"Appearance",icon:i.jsx(ij,{size:Nt})},{path:"shortcuts",label:"Shortcuts",icon:i.jsx(G2,{size:Nt})},{path:"plugins",label:"Plugins",icon:i.jsx(uj,{size:Nt})},{path:"about",label:"About",icon:i.jsx(vm,{size:Nt})}];function X8(){var u;const t=Yt(),s=mt(),o=b.useRef(null),r=((u=Qs.find(p=>{const m=`${Ni}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??Qs[0].path,c=b.useCallback(p=>{s(`${Ni}/${p}`)},[s]),d=b.useCallback(p=>{var S,k;const m=(S=o.current)==null?void 0:S.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:Qs.findIndex(j=>j.path===r);let x=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),x=(v+1)%Qs.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),x=(v-1+Qs.length)%Qs.length;else if(p.key==="Home")p.preventDefault(),x=0;else if(p.key==="End")p.preventDefault(),x=Qs.length-1;else return;const y=Qs[x].path;s(`${Ni}/${y}`),(k=m[x])==null||k.focus()},[r,s]);return i.jsx("nav",{className:Zc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:Qs.map(p=>{const m=p.path===r;return i.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Zc.tab} ${m?Zc.tabActive:""}`,onClick:()=>c(p.path),children:[i.jsx("span",{className:Zc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}function Q8({tasks:t,taskStatusById:s,sessionStatusByTaskId:o}){const r=new Map;for(const d of t)if(d.parentTaskId){const u=r.get(d.parentTaskId);u?u.push(d):r.set(d.parentTaskId,[d])}const c=new Map(xy.map(d=>[d,[]]));for(const d of t){const u=pl(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(k=>s.get(k)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(k=>k.status==="complete").length;let x;if(u==="paused"&&o){const k=o.get(d.id);k==="idle"?x="Needs input":k==="completed"&&(x="Ready to complete")}const y={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:x},S=c.get(u);S?S.push(y):c.get("not_started").push(y)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return xy.map(d=>{const u=qa(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const e7="_boardContainer_1c4y1_1",t7="_column_1c4y1_17",n7="_columnHeader_1c4y1_34",s7="_columnIcon_1c4y1_47",a7="_columnLabel_1c4y1_52",i7="_columnCount_1c4y1_57",o7="_cardList_1c4y1_67",r7="_emptyPlaceholder_1c4y1_76",l7="_card_1c4y1_67",c7="_cardHeader_1c4y1_107",d7="_cardStatusIcon_1c4y1_113",u7="_cardTitle_1c4y1_119",f7="_cardBadges_1c4y1_127",p7="_badge_1c4y1_134",m7="_blockedBadge_1c4y1_146",h7="_childBadge_1c4y1_151",g7="_depBadge_1c4y1_155",v7="_parentBadge_1c4y1_159",y7="_pausedSubBadge_1c4y1_166",b7="_personaBadge_1c4y1_170",x7="_envBadge_1c4y1_174",_7="_emptyCta_1c4y1_178",k7="_ctaButton_1c4y1_188",S7="_ctaDescription_1c4y1_204",it={boardContainer:e7,column:t7,columnHeader:n7,columnIcon:s7,columnLabel:a7,columnCount:i7,cardList:o7,emptyPlaceholder:r7,card:l7,cardHeader:c7,cardStatusIcon:d7,cardTitle:u7,cardBadges:f7,badge:p7,blockedBadge:m7,childBadge:h7,depBadge:g7,parentBadge:v7,pausedSubBadge:y7,personaBadge:b7,envBadge:x7,emptyCta:_7,ctaButton:k7,ctaDescription:S7};function T7({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=mt(),p=b.useMemo(()=>o.filter(y=>y.workspaceId===t),[o,t]),m=b.useMemo(()=>new Map(o.map(y=>[y.id,y.status])),[o]),g=b.useMemo(()=>new Map(p.map(y=>[y.id,y])),[p]),v=b.useMemo(()=>{const y=new Map(r.map(C=>[C.id,C])),S=new Map(c.map(C=>[C.id,C])),k=new Map(d.map(C=>[C.id,C])),j=new Map,N=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const A=y.get(C.latestSessionId);if(A){if(j.set(C.id,A.endReason||A.status),A.personaId){const O=S.get(A.personaId);O&&N.set(C.id,O.name)}if(A.environmentId){const O=k.get(A.environmentId);O&&T.set(C.id,O.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:N,environmentNameByTaskId:T}},[p,r,c,d]),x=b.useMemo(()=>Q8({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?i.jsxs("div",{className:it.emptyCta,"data-testid":"board-empty-cta",children:[i.jsx("button",{className:it.ctaButton,onClick:()=>u(Ii(t,void 0,s)),children:"Create Task"}),i.jsx("div",{className:it.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):i.jsx("div",{className:it.boardContainer,"data-testid":"board-container",children:x.map(y=>i.jsxs("section",{className:it.column,"data-testid":`board-column-${y.status}`,"aria-label":`${y.label}, ${y.tasks.length} ${y.tasks.length===1?"task":"tasks"}`,children:[i.jsxs("div",{className:it.columnHeader,children:[i.jsx("span",{className:it.columnIcon,style:{color:y.style.color},children:y.style.icon}),i.jsx("span",{className:it.columnLabel,children:y.label}),i.jsx("span",{className:it.columnCount,"data-testid":`board-count-${y.status}`,children:y.tasks.length})]}),i.jsx("div",{className:it.cardList,children:y.tasks.length===0?i.jsx("div",{className:it.emptyPlaceholder,children:"No tasks"}):i.jsx(gs,{mode:"popLayout",children:y.tasks.map(S=>i.jsx(Mt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:i.jsx(j7,{boardTask:S,tasksById:g,personaName:v.personaNameByTaskId.get(S.task.id),envName:v.environmentNameByTaskId.get(S.task.id),onClick:()=>u(On(S.task.id,void 0,t,s))})},S.task.id))})})]},y.status))})}function j7({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=qa(d.status),x=d.parentTaskId?s.get(d.parentTaskId):void 0;return i.jsxs("div",{className:it.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),c())},children:[i.jsxs("div",{className:it.cardHeader,children:[i.jsx("span",{className:it.cardStatusIcon,style:{color:v.color},children:v.icon}),i.jsx("span",{className:it.cardTitle,children:d.title})]}),i.jsxs("div",{className:it.cardBadges,children:[x&&i.jsx("span",{className:`${it.badge} ${it.parentBadge}`,title:x.title,children:x.title}),p>0&&i.jsxs("span",{className:`${it.badge} ${it.childBadge}`,children:[m,"/",p]}),u&&i.jsx("span",{className:`${it.badge} ${it.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&i.jsx("span",{className:`${it.badge} ${it.depBadge}`,children:"dep"}),g&&i.jsx("span",{className:`${it.badge} ${it.pausedSubBadge}`,children:g}),o&&i.jsx("span",{className:`${it.badge} ${it.personaBadge}`,children:o}),r&&i.jsx("span",{className:`${it.badge} ${it.envBadge}`,children:r})]})]})}const w7="_formContent_ymnez_1",N7="_section_ymnez_13",C7="_label_ymnez_19",E7="_titleInput_ymnez_26",A7="_descriptionTextarea_ymnez_58",D7="_selectField_ymnez_94",R7="_checkboxRow_ymnez_128",M7="_checkboxLabel_ymnez_141",I7="_fieldError_ymnez_146",xt={formContent:w7,section:N7,label:C7,titleInput:E7,descriptionTextarea:A7,selectField:D7,checkboxRow:R7,checkboxLabel:M7,fieldError:I7};function O7(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.environmentId)??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const B7=100;function L7({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:B7,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-description",children:"Description"}),i.jsx("textarea",{id:"ws-description",className:xt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-repo",children:"Repository URL"}),i.jsx("input",{id:"ws-repo",className:xt.titleInput,type:"text",value:t.repoUrl,onChange:m=>p("repoUrl",m.target.value),placeholder:"https://github.com/org/repo",disabled:d,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-environment",children:"Environment"}),i.jsxs("select",{id:"ws-environment",className:xt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[i.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>i.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&i.jsx("span",{className:xt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-persona",children:"Default Persona"}),i.jsxs("select",{id:"ws-persona",className:xt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[i.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>i.jsx("option",{value:m.id,children:m.name},m.id))]})]}),i.jsx("div",{className:xt.section,children:i.jsxs("label",{className:xt.checkboxRow,children:[i.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),i.jsx("span",{className:xt.checkboxLabel,children:"Enable worktree isolation"})]})}),i.jsxs("div",{className:xt.section,children:[i.jsx("label",{className:xt.label,htmlFor:"ws-workdir",children:"Working Directory"}),i.jsx("input",{id:"ws-workdir",className:xt.titleInput,type:"text",value:t.workingDirectory,onChange:m=>p("workingDirectory",m.target.value),placeholder:"Default (server default)",disabled:d,"data-testid":"workspace-form-workdir"})]})]})}const G1=b.createContext(void 0),z7=4e3;function $7({children:t}){const[s,o]=b.useState([]),r=b.useRef(0),c=b.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=b.useCallback((u,p="info",m=z7)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return i.jsx(G1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function pn(){const t=b.useContext(G1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const fm="grackle-theme",F1="grackle-prefer-system",Z1="(prefers-color-scheme: dark)";let Jr=[],ld;function Rp(){ld=void 0;for(const t of Jr)t()}function pm(){return typeof window>"u"?!1:window.matchMedia(Z1).matches}function nl(){if(typeof localStorage>"u")return tx;try{const t=localStorage.getItem(fm);if(t!==null&&H1.has(t))return t}catch{}return tx}function _d(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(F1)==="true"}catch{return!1}}function mm(t){return zd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function K1(t,s){const o=um(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?pm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=mm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return pm()?r.variantDarkId:r.variantLightId}return t}function No(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=K1(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&No(nl(),_d());function P7(){return ld===void 0&&(ld={themeId:nl(),systemDark:pm(),preferSystem:_d()}),ld}function U7(t){return Jr=[...Jr,t],()=>{Jr=Jr.filter(s=>s!==t)}}function H7(){const t=b.useSyncExternalStore(U7,P7),{themeId:s,preferSystem:o}=t,r=K1(s,o),c=b.useCallback(u=>{if(H1.has(u)){try{localStorage.setItem(fm,u)}catch{}No(u,_d(),!0),Rp()}},[]),d=b.useCallback(u=>{try{localStorage.setItem(F1,u?"true":"false")}catch{}if(u){const p=nl(),m=um(p);if(m!=null&&m.hidden){const g=mm(p);if(g)try{localStorage.setItem(fm,g.id)}catch{}}}No(nl(),u,!0),Rp()},[]);return b.useEffect(()=>{No(s,o)},[s,o]),b.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(Z1),p=()=>{const m=nl(),g=_d();if(g){const v=um(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&No(m,g),v!=null&&v.hidden){const x=mm(m);x!=null&&x.variantDarkId&&x.variantLightId&&No(m,g)}}Rp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const Y1=b.createContext(void 0);function V7({children:t}){const s=H7();return i.jsx(Y1.Provider,{value:s,children:t})}function J1(){const t=b.useContext(Y1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const W1=b.createContext(void 0),X1=b.createContext(void 0);function q7({children:t}){const[s,o]=b.useState(void 0),r=b.useCallback(c=>{o(c)},[]);return i.jsx(X1.Provider,{value:r,children:i.jsx(W1.Provider,{value:s,children:t})})}function G7(){return b.useContext(W1)}function F7(){const t=b.useContext(X1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const fh=b.createContext(void 0);function ot(){const t=b.useContext(fh);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function Q1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ek(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function Z7(t){return Q1(t)&&typeof t.sessionId=="string"&&typeof t.eventType=="string"&&typeof t.timestamp=="string"&&typeof t.content=="string"&&(t.raw===void 0||typeof t.raw=="string")}const K7=new Set(["off","subscription","api_key"]),Kc=new Set(["off","on"]);function Y7(t){return Q1(t)&&K7.has(t.claude)&&Kc.has(t.github)&&Kc.has(t.copilot)&&Kc.has(t.codex)&&Kc.has(t.goose)}function tk(t){switch(t){case"waiting_input":return"idle";case"completed":return"stopped";case"killed":return"stopped";case"failed":return"stopped";case"interrupted":return"stopped";case"terminated":return"stopped";default:return t}}function nk(t){switch(t){case"completed":return"completed";case"killed":return"killed";case"failed":return"interrupted";case"interrupted":return"interrupted";case"terminated":return"terminated";default:return}}const wo=5e3;function J7(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 ra={label:"Home",url:Di};function W7(t){return t?[ra,{label:"Settings",url:Ni},{label:t,url:void 0}]:[ra,{label:"Settings",url:void 0}]}const ph={label:"Environments",url:Io};function X7(){return[ra,{label:"Environments",url:void 0}]}function Q7(){return[ra,{label:"New Chat",url:void 0}]}function ez(t){return[ra,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function tz(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[ra,ph,{label:(d==null?void 0:d.displayName)??"Environment",url:Ai(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function nz(t,s,o,r,c){const d=J7(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(S=>S.id===p):void 0,g=s??(m==null?void 0:m.environmentId),v=g?r.find(S=>S.id===g):void 0,x=[ra];v&&g&&(x.push(ph),x.push({label:v.displayName,url:Ai(g)})),m&&g&&x.push({label:m.name,url:Ga(m.id,g)});for(let S=0;S<d.length-1;S++)x.push({label:d[S].title,url:On(d[S].id,void 0,p,g)});const y=d[d.length-1];return x.push({label:(y==null?void 0:y.title)??t,url:void 0}),x}const sz={label:"Findings",url:Dd};function az(){return[ra,{label:"Findings",url:void 0}]}function sk(t,s,o,r,c){const d=[ra];if(s&&o){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===o);d.push(ph),p&&d.push({label:p.displayName,url:Ai(o)}),u&&d.push({label:u.name,url:Ga(s,o)}),d.push({label:"Findings",url:CN(s,o)})}else d.push(sz);return d.push({label:t,url:void 0}),d}function mh(t){const s=[];for(const o of t){const r=s[s.length-1];o.eventType==="text"&&(r==null?void 0:r.eventType)==="text"?s[s.length-1]={...r,content:r.content+o.content}:s.push(o)}return s}function Yc(t){if(typeof t.id=="string")return t.id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function iz(t){if(typeof t.tool_use_id=="string")return t.tool_use_id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const o=t.item;if(o&&typeof o.id=="string")return o.id}function hh(t){const s=new Map;for(const v of t)if(v.raw)try{s.set(v,JSON.parse(v.raw))}catch{}const o=new Map;for(const v of t){if(v.eventType!=="tool_use")continue;const x=s.get(v),y=x?Yc(x):void 0;if(y)try{const S=JSON.parse(v.content);o.set(y,{tool:S.tool,args:S.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,x)=>{if(v.eventType!=="tool_result")return v;const y=s.get(v),S=y?iz(y):void 0;if(!S)return v;const k=o.get(S);if(!k)return v;r.add(S),c.add(x);let j;const N=v.content.trim();if(N.startsWith("{"))try{const T=JSON.parse(N);typeof T.detailedContent=="string"&&(j=T.detailedContent)}catch{}return{...v,toolUseCtx:{...k,detailedResult:j}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const x=s.get(d[v]),y=x?Yc(x):void 0;y&&r.has(y)||u.push(v)}const p=[];for(let v=0;v<d.length;v++)d[v].eventType!=="tool_result"||c.has(v)||p.push(v);let m=0;for(const v of u){for(;m<p.length&&p[m]<v;)m++;if(m>=p.length)break;const x=p[m];if(x!==v+1)continue;const y=d[v],S=d[x];let k;try{const j=JSON.parse(y.content);k={tool:j.tool,args:j.args}}catch{}if(k){let j;const N=S.content.trim();if(N.startsWith("{"))try{const A=JSON.parse(N);typeof A.detailedContent=="string"&&(j=A.detailedContent)}catch{}d[x]={...S,toolUseCtx:{...k,detailedResult:j}},c.add(x);const T=s.get(y),C=T?Yc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(y,{...T??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const x=s.get(v);if(!x)return!0;const y=Yc(x);if(y&&r.has(y))return!1;const S=x.__seqId;return!(S&&r.has(S))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let x=!1;for(let y=v+1;y<g.length;y++)if(g[y].eventType!=="tool_use"){x=!0;break}x&&(g[v]={...g[v],settled:!0})}return g}function oz(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=ak(s),d=s.filter(m=>hm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||hm(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function ak(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function hm(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function rz(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=ak(t),c=[];for(const p of t){const m=p.workspaceId?((u=o.get(p.workspaceId))==null?void 0:u.name)??"Unknown":"Unknown";p.status==="failed"?c.push({task:p,reason:"failed",workspaceName:m}):hm(p,r)?c.push({task:p,reason:"blocked",workspaceName:m}):p.status==="paused"&&c.push({task:p,reason:"paused",workspaceName:m})}const d={failed:0,blocked:1,paused:2};return c.sort((p,m)=>(d[p.reason]??3)-(d[m.reason]??3)),c}function lz(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 cz(t,s,o){const r=new Map;for(const c of s){if(!c.workspaceId)continue;let d=r.get(c.workspaceId);d||(d={totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0},r.set(c.workspaceId,d)),d.totalTasks+=1,c.status==="complete"?d.completedTasks+=1:c.status==="working"?d.workingTasks+=1:c.status==="failed"&&(d.failedTasks+=1)}return t.map(c=>{const d=r.get(c.id)??{totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0};return{workspace:c,totalTasks:d.totalTasks,completedTasks:d.completedTasks,workingTasks:d.workingTasks,failedTasks:d.failedTasks}})}const ws=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
|
|
285
285
|
export function verifyToken(req: Request, res: Response, next: NextFunction): void {
|
|
286
286
|
const header = req.headers.authorization;
|
|
287
287
|
if (!header?.startsWith("Bearer ")) {
|
|
@@ -722,4 +722,4 @@ const grackle = await host.mcpServer({
|
|
|
722
722
|
url: env.vars.GRACKLE_MCP_URL,
|
|
723
723
|
});
|
|
724
724
|
|
|
725
|
-
$\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),D==="agent"&&i.jsxs("div",{children:[i.jsx("label",{children:"Allowed MCP Tools"}),i.jsx(sx,{selectedTools:X,onChange:re=>{$(re),xe(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,re),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!Ce&&!ue&&i.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,i.jsx(oa,{isOpen:J,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:Se,onCancel:()=>me(!1)})]})}function y9(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=ot(),{showToast:c}=pn(),d=mt();return i.jsx(Z8,{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(SN),onNavigateToSchedule:u=>d(Jx(u))})}const b9="_container_1g4qh_1",x9="_form_1g4qh_7",_9="_formActions_1g4qh_66",k9="_editableSection_1g4qh_73",S9="_helperText_1g4qh_84",T9="_metaSection_1g4qh_90",j9="_optional_1g4qh_108",w9="_readonlyValue_1g4qh_113",yn={container:b9,form:x9,formActions:_9,editableSection:k9,helperText:S9,metaSection:T9,optional:j9,readonlyValue:w9};function vx(){const{scheduleId:t}=as(),s=mt(),{showToast:o}=pn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},environments:{environments:g},workspaces:{workspaces:v}}=ot(),x=t===void 0,y=x?void 0:r.find(k=>k.id===t);if(!x&&!c&&r.length>0&&!y)return i.jsx(ts,{to:tp,replace:!0});const S=[{label:"Settings",url:Ni},{label:"Schedules",url:tp},{label:x?"New Schedule":(y==null?void 0:y.title)??"Schedule",url:void 0}];return i.jsxs("div",{className:yn.container,children:[i.jsx(vs,{segments:S}),i.jsx(N9,{existing:y,isNew:x,personas:m,environments:g,workspaces:v,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(tp)},showToast:o})]})}function N9({existing:t,isNew:s,personas:o,environments:r,workspaces:c,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:m,showToast:g}){var W;const v=mt(),[x,y]=b.useState((t==null?void 0:t.title)??""),[S,k]=b.useState((t==null?void 0:t.description)??""),[j,N]=b.useState((t==null?void 0:t.scheduleExpression)??""),[T,C]=b.useState((t==null?void 0:t.personaId)??""),[A,O]=b.useState((t==null?void 0:t.environmentId)??""),[E,D]=b.useState((t==null?void 0:t.workspaceId)??""),[U,B]=b.useState(!1),[z,X]=b.useState(null);b.useEffect(()=>{s||t&&z===null&&(y(t.title),k(t.description),N(t.scheduleExpression),C(t.personaId),O(t.environmentId),D(t.workspaceId))},[s,t,z]);const $=!s&&t===void 0,J=s&&x.trim().length>0&&j.trim().length>0&&T.length>0,me=o.map(Q=>({value:Q.id,label:Q.name})),ee=[{value:"",label:"Auto-select (first connected)"},...r.map(Q=>({value:Q.id,label:Q.displayName}))],oe=[{value:"",label:"System-level (no workspace)"},...c.map(Q=>({value:Q.id,label:Q.name}))],R=Q=>{Q.preventDefault(),J&&d(x,S,j,T,A||void 0,E||void 0).then(ue=>{g("Schedule created","success"),v(Jx(ue.id),{replace:!0})},()=>{g("Failed to create schedule","error")})},G=(Q,ue)=>{t&&u(t.id,{[Q]:ue}).then(()=>{g("Schedule updated","success"),Q==="title"&&y(String(ue)),Q==="description"&&k(String(ue)),Q==="scheduleExpression"&&N(String(ue)),Q==="personaId"&&C(String(ue)),Q==="environmentId"&&O(String(ue))},()=>{g("Failed to update schedule","error")})},Z=()=>{if(!t)return;const Q=!t.enabled;u(t.id,{enabled:Q}).then(()=>{g(Q?"Schedule enabled":"Schedule disabled","success")},()=>{g("Failed to update schedule","error")})},de=()=>{t&&p(t.id).then(()=>{g("Schedule deleted","success"),m()},()=>{g("Failed to delete schedule","error")})};return i.jsxs(i.Fragment,{children:[$?i.jsxs("div",{className:yn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsx("p",{children:"Loading schedule..."})]}):s?i.jsxs("form",{onSubmit:R,className:yn.form,children:[i.jsx("h3",{children:"Create Schedule"}),i.jsxs("label",{children:["Title",i.jsx("input",{type:"text",value:x,onChange:Q=>y(Q.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description ",i.jsx("span",{className:yn.optional,children:"(optional)"}),i.jsx("input",{type:"text",value:S,onChange:Q=>k(Q.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx("input",{type:"text",value:j,onChange:Q=>N(Q.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),i.jsxs("p",{className:yn.helperText,children:["Interval: ",i.jsx("code",{children:"30s"}),", ",i.jsx("code",{children:"5m"}),", ",i.jsx("code",{children:"1h"}),", ",i.jsx("code",{children:"1d"})," (min 10s) | Cron: ",i.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),i.jsxs("label",{children:["Persona",i.jsxs("select",{value:T,onChange:Q=>C(Q.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[i.jsx("option",{value:"",children:"Select a persona..."}),me.map(Q=>i.jsx("option",{value:Q.value,children:Q.label},Q.value))]})]}),i.jsxs("label",{children:["Environment ",i.jsx("span",{className:yn.optional,children:"(optional)"}),i.jsx("select",{value:A,onChange:Q=>O(Q.target.value),"data-testid":"schedule-detail-environment",children:ee.map(Q=>i.jsx("option",{value:Q.value,children:Q.label},Q.value))})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:yn.optional,children:"(optional)"}),i.jsx("select",{value:E,onChange:Q=>D(Q.target.value),"data-testid":"schedule-detail-workspace",children:oe.map(Q=>i.jsx("option",{value:Q.value,children:Q.label},Q.value))})]}),i.jsxs("div",{className:yn.formActions,children:[i.jsx(tn,{type:"submit",variant:"primary",size:"md",disabled:!J,"data-testid":"schedule-detail-save",children:"Create"}),i.jsx(tn,{type:"button",variant:"outline",size:"md",onClick:m,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?i.jsxs("div",{className:yn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsxs("div",{className:yn.formActions,children:[i.jsx(tn,{type:"button",variant:"outline",size:"md",onClick:m,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),i.jsx(tn,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:Z,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),i.jsx(tn,{type:"button",variant:"danger",size:"md",onClick:()=>B(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),i.jsxs("div",{className:yn.editableSection,children:[i.jsxs("label",{children:["Title",i.jsx(Ft,{value:x,onSave:Q=>{G("title",Q)},validate:Q=>Q.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:z,onActivate:X,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description",i.jsx(Ft,{value:S,onSave:Q=>{G("description",Q)},fieldId:"schedule-description",activeFieldId:z,onActivate:X,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx(Ft,{value:j,onSave:Q=>{G("scheduleExpression",Q)},validate:Q=>Q.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:z,onActivate:X,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(Po,{value:T,onSave:Q=>{G("personaId",Q)},options:me,fieldId:"schedule-persona",activeFieldId:z,onActivate:X,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),i.jsxs("label",{children:["Environment ",i.jsx("span",{className:yn.optional,children:"(optional — empty = auto-select)"}),i.jsx(Po,{value:A,onSave:Q=>{G("environmentId",Q)},options:ee,fieldId:"schedule-environment",activeFieldId:z,onActivate:X,ariaLabel:"Schedule environment","data-testid":"schedule-detail-environment"})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:yn.optional,children:"(optional — set at creation)"}),i.jsx("span",{className:yn.readonlyValue,"data-testid":"schedule-detail-workspace",children:((W=c.find(Q=>Q.id===t.workspaceId))==null?void 0:W.name)??"System-level (no workspace)"})]})]}),i.jsxs("div",{className:yn.metaSection,children:[t.lastRunAt?i.jsxs("span",{children:["Last run: ",Uo(t.lastRunAt)]}):i.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?i.jsxs("span",{children:["Next run: ",B1(t.nextRunAt)]}):null,t.runCount>0&&i.jsxs("span",{children:["Total runs: ",t.runCount]}),i.jsxs("span",{children:["Created: ",Uo(t.createdAt)]})]})]}):null,i.jsx(oa,{isOpen:U,title:"Delete Schedule?",description:`"${t==null?void 0:t.title}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:de,onCancel:()=>B(!1)})]})}function C9(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=J1();return i.jsx(pB,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function E9(){const[t,s]=b.useState(void 0);return b.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Ye.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function A9(){const{connected:t,environments:{environments:s},sessions:{sessions:o}}=ot(),r=E9();return i.jsxs(i.Fragment,{children:[r&&i.jsx(mO,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),i.jsx(mB,{connected:t,environments:s,sessions:o})]})}function D9(){return i.jsx(s8,{})}function R9(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=ot();return i.jsx(CL,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const yx=Ii();function M9(){const t=mt();return sa({key:"?"},()=>{t(TN)}),sa({key:"n"},()=>{t(yx)}),sa({key:"N"},()=>{t(yx)}),i.jsx(i.Fragment,{})}function xl(t){const s=F7();b.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function I9(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=ot(),o=b.useMemo(()=>i.jsx(q5,{workspaces:t,tasks:s}),[t,s]);return xl(o),i.jsx(Ya,{})}function O9(){const{environments:{environments:t}}=ot(),s=b.useMemo(()=>i.jsx(e5,{environments:t}),[t]);return xl(s),i.jsx(Ya,{})}function B9(){const t=b.useMemo(()=>i.jsx(X8,{}),[]);return xl(t),i.jsx(Ya,{})}function L9(){const{findings:{findings:t,loadFindings:s,loadAllFindings:o}}=ot(),{workspaceId:r,environmentId:c}=as();b.useEffect(()=>{r?s(r).catch(()=>{}):o().catch(()=>{})},[r,s,o]);const d=b.useMemo(()=>i.jsx(u5,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return xl(d),i.jsx(Ya,{})}function z9(){const{knowledge:t,workspaces:{workspaces:s}}=ot(),o=b.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=b.useCallback(()=>{t.clearSearch()},[t]),c=b.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=b.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=b.useMemo(()=>i.jsx(pI,{nodes:t.graphData.nodes,workspaces:s,loading:t.loading,searchQuery:t.searchQuery,onSearch:o,onClearSearch:r,onSelectNode:c,onWorkspaceChange:d}),[t,s,o,r,c,d]);return xl(u),i.jsx(Ya,{})}const $9="_container_ce571_1",P9="_title_ce571_6",kd={container:$9,title:P9};function U9(){return i.jsxs("div",{className:kd.container,"aria-hidden":"true",children:[i.jsx("h1",{className:kd.title,children:"Findings"}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>i.jsx(bd,{lines:3},s))})]})}function bx(){const{environmentId:t,workspaceId:s}=as(),{findings:{findings:o,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=ot(),p=mt();b.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=b.useCallback(v=>{p(Gp(v,s,t))},[p,s,t]);if(r)return i.jsx(U9,{});const g=s&&t?sk("Findings",s,t,d,u).slice(0,-1):az();return i.jsxs("div",{className:kd.container,"data-testid":"findings-list-page",children:[i.jsx(vs,{segments:g}),i.jsx("h1",{className:kd.title,children:"Findings"}),i.jsx(U1,{findings:o,onFindingClick:m})]})}const H9="_container_1wwpb_1",V9="_notFound_1wwpb_6",q9="_header_1wwpb_12",G9="_categoryBadge_1wwpb_19",F9="_title_1wwpb_28",Z9="_content_1wwpb_35",K9="_tags_1wwpb_77",Y9="_tag_1wwpb_77",J9="_meta_1wwpb_92",W9="_metaTimestamp_1wwpb_100",X9="_metaLink_1wwpb_105",vn={container:H9,notFound:V9,header:q9,categoryBadge:G9,title:F9,content:Z9,tags:K9,tag:Y9,meta:J9,metaTimestamp:W9,metaLink:X9};function xx(){const{findingId:t,environmentId:s,workspaceId:o}=as(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=ot(),m=mt();if(b.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return i.jsx("div",{className:vn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:vn.notFound,children:"Loading..."})});if(!r)return i.jsx("div",{className:vn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:vn.notFound,children:"Finding not found."})});const g=sk(r.title,o,s,u,p),v=xd(r.category);return i.jsxs("div",{className:vn.container,"data-testid":"finding-detail-page",children:[i.jsx(vs,{segments:g}),i.jsxs("div",{className:vn.header,children:[i.jsx("span",{className:vn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),i.jsx("h1",{className:vn.title,children:r.title})]}),r.content&&i.jsx("div",{className:vn.content,children:i.jsx(Td,{remarkPlugins:[jd],children:r.content})}),r.tags.length>0&&i.jsx("div",{className:vn.tags,children:r.tags.map(x=>i.jsx("span",{className:vn.tag,children:x},x))}),i.jsxs("div",{className:vn.meta,children:[i.jsx("span",{className:vn.metaTimestamp,title:r.createdAt,children:Uo(r.createdAt)}),r.taskId&&i.jsx("button",{type:"button",className:vn.metaLink,onClick:()=>{m(On(r.taskId))},children:"View Task"}),r.sessionId&&i.jsx("button",{type:"button",className:vn.metaLink,onClick:()=>{m(Cm(r.sessionId))},children:"View Session"})]})]})}const Q9="_wizard_1260s_1",eH="_container_1260s_10",tH="_stepContent_1260s_19",nH="_logoArea_1260s_28",sH="_logoImage_1260s_32",aH="_heading_1260s_41",iH="_tagline_1260s_49",oH="_subtitle_1260s_56",rH="_featureList_1260s_64",lH="_runtimeGrid_1260s_89",cH="_runtimeCard_1260s_101",dH="_runtimeName_1260s_133",uH="_runtimeDescription_1260s_139",fH="_buttonRow_1260s_144",pH="_primaryButton_1260s_151",mH="_ghostButton_1260s_185",hH="_dots_1260s_213",gH="_dot_1260s_213",Ke={wizard:Q9,container:eH,stepContent:tH,logoArea:nH,logoImage:sH,heading:aH,tagline:iH,subtitle:oH,featureList:rH,runtimeGrid:lH,runtimeCard:cH,runtimeName:dH,runtimeDescription:uH,buttonRow:fH,primaryButton:pH,ghostButton:mH,dots:hH,dot:gH};function vH({onNext:t}){return i.jsxs("div",{className:Ke.stepContent,"data-testid":"setup-welcome",children:[i.jsx("div",{className:Ke.logoArea,children:i.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Ke.logoImage})}),i.jsx("h1",{className:Ke.heading,children:"Welcome to Grackle"}),i.jsx("p",{className:Ke.tagline,children:"Multi-agent orchestration for software teams"}),i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function yH({onNext:t,onBack:s}){return i.jsxs("div",{className:Ke.stepContent,"data-testid":"setup-about",children:[i.jsx("h2",{className:Ke.heading,children:"What is Grackle?"}),i.jsxs("ul",{className:Ke.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:Ke.buttonRow,children:[i.jsx("button",{type:"button",className:Ke.ghostButton,onClick:s,children:"Back"}),i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const bH=[{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 xH({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=b.useState(t||"claude-code");return b.useEffect(()=>{t&&d(t)},[t]),i.jsxs("div",{className:Ke.stepContent,"data-testid":"setup-runtime",children:[i.jsx("h2",{className:Ke.heading,children:"Choose Your Runtime"}),i.jsx("p",{className:Ke.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),i.jsx("div",{className:Ke.runtimeGrid,children:bH.map(u=>i.jsxs("button",{type:"button",className:Ke.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:Ke.runtimeName,children:u.name}),i.jsx("span",{className:Ke.runtimeDescription,children:u.description})]},u.id))}),i.jsxs("div",{className:Ke.buttonRow,children:[i.jsx("button",{type:"button",className:Ke.ghostButton,onClick:o,children:"Back"}),i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function _H(){return typeof Notification<"u"}function kH({onFinish:t,onBack:s,finishDisabled:o}){const r=_H(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return i.jsxs("div",{className:Ke.stepContent,"data-testid":"setup-notifications",children:[i.jsx("h2",{className:Ke.heading,children:"Stay in the Loop"}),i.jsx("p",{className:Ke.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:Ke.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:Ke.buttonRow,children:[i.jsx("button",{type:"button",className:Ke.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:Ke.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const SH=4,_x={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function TH(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=ot(),{showToast:c}=pn(),d=mt(),[u,p]=b.useState(0),[m,g]=b.useState("claude-code"),[v,x]=b.useState(!1),y=t.find(j=>j.id==="claude-code"),S=b.useCallback(j=>{g(j),p(3)},[]),k=b.useCallback(()=>{const j=m;x(!0);const N=[];if(y&&j!==y.runtime){const C=_x[j]??"sonnet";N.push(s(y.id,void 0,void 0,void 0,j,C))}const T=t.find(C=>C.id===dy);if(T&&j!==T.runtime){const C=_x[j]??"sonnet";N.push(s(dy,void 0,void 0,void 0,j,C))}Promise.all(N).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),x(!1)})},[m,y,t,s,o,d,c]);return r===!0?i.jsx(ts,{to:"/",replace:!0}):i.jsx("div",{className:Ke.wizard,"data-testid":"setup-wizard",children:i.jsxs("div",{className:Ke.container,children:[i.jsx(gs,{mode:"wait",children:i.jsxs(Mt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&i.jsx(vH,{onNext:()=>p(1)}),u===1&&i.jsx(yH,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&i.jsx(xH,{currentRuntime:m,onFinish:S,onBack:()=>p(1),finishDisabled:!y}),u===3&&i.jsx(kH,{onFinish:k,onBack:()=>p(2),finishDisabled:v})]},u)}),i.jsx("div",{className:Ke.dots,children:Array.from({length:SH},(j,N)=>i.jsx("span",{className:Ke.dot,"data-active":N===u},N))})]})})}const jH="_root_zndgp_1",wH="_body_zndgp_7",NH="_main_zndgp_19",CH="_sidebarWrapper_zndgp_26",EH="_overlay_zndgp_51",Wr={root:jH,body:wH,main:NH,sidebarWrapper:CH,overlay:EH},AH=b.lazy(()=>YT(()=>import("./KnowledgePage-BuQIog9j.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),rk=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function DH({tabs:t}){const{connected:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=ot(),{toasts:d,dismissToast:u}=pn(),p=Yt(),m=G7(),g=m!==void 0,[v,x]=b.useState(!1),y=b.useCallback(()=>x(S=>!S),[]);return b.useEffect(()=>{x(!1)},[p.pathname]),b.useEffect(()=>{if(!v)return;const S=k=>{k.key==="Escape"&&x(!1)};return document.addEventListener("keydown",S),()=>{document.removeEventListener("keydown",S)}},[v]),i.jsxs(i.Fragment,{children:[i.jsx(SI,{connected:s,environments:o,sessions:r,onToggleSidebar:g?y:void 0,sidebarOpen:v}),i.jsx(AI,{tabs:t}),i.jsxs("div",{className:Wr.body,children:[g&&i.jsx("div",{className:Wr.sidebarWrapper,"data-sidebar-open":v,children:i.jsx(BI,{content:m})}),g&&v&&i.jsx("div",{className:Wr.overlay,"data-testid":"drawer-overlay",onClick:()=>x(!1)}),i.jsxs("div",{className:Wr.main,children:[i.jsx(Ya,{}),i.jsx(qI,{sessions:r,tasks:c,environments:o})]})]}),i.jsx(sO,{toasts:d,onDismiss:u}),i.jsx(M9,{})]})}function RH(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connected:d,onboardingCompleted:u}=ot(),{pluginNames:p}=gh(),{showToast:m}=pn();Xz(s,m),s$(c,m),Qz(o,r,m);const g=mt(),v=Yt();if(b.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(Cm(t),{replace:!0})},[t,g,v.pathname]),d&&u===!1)return i.jsx(ts,{to:"/setup",replace:!0});const x=wz(p);return i.jsx(q7,{children:i.jsxs("div",{className:Wr.root,children:[rk&&i.jsx(eC,{}),i.jsx(DH,{tabs:x})]})})}function Pp(){const{workspaceId:t}=as(),{workspaces:{workspaces:s}}=ot(),o=Yt(),r=s.find(m=>m.id===t);if(!(r!=null&&r.environmentId))return s.length===0?void 0:i.jsx(ts,{to:"/environments",replace:!0});const c=encodeURIComponent(t),d=`/workspaces/${c}`,u=o.pathname.startsWith(d)?o.pathname.slice(d.length):"",p=`/environments/${encodeURIComponent(r.environmentId)}/workspaces/${c}${u}${o.search}${o.hash}`;return i.jsx(ts,{to:p,replace:!0})}function MH(){const{pluginNames:t}=gh(),s=t.includes("orchestration"),o=t.includes("knowledge");return i.jsxs(zw,{children:[i.jsx(Ne,{path:"setup",element:i.jsx(TH,{})}),i.jsxs(Ne,{element:i.jsx(RH,{}),children:[i.jsx(Ne,{index:!0,element:i.jsx(VP,{})}),i.jsx(Ne,{path:"chat",element:i.jsx(QP,{})}),i.jsx(Ne,{path:"sessions/new",element:i.jsx(eU,{})}),i.jsx(Ne,{path:"sessions/:sessionId",element:i.jsx(aU,{})}),o&&i.jsx(Ne,{element:i.jsx(z9,{}),children:i.jsx(Ne,{path:"knowledge",element:i.jsx(b.Suspense,{fallback:i.jsx(A1,{}),children:i.jsx(AH,{})})})}),s&&i.jsxs(Ne,{element:i.jsx(I9,{}),children:[i.jsx(Ne,{path:"tasks",element:i.jsx(UP,{})}),i.jsx(Ne,{path:"tasks/new",element:i.jsx(px,{})}),i.jsx(Ne,{path:"tasks/:taskId",element:i.jsx(Pa,{})}),i.jsx(Ne,{path:"tasks/:taskId/edit",element:i.jsx(Pa,{})}),i.jsx(Ne,{path:"tasks/:taskId/stream",element:i.jsx(Pa,{})}),i.jsx(Ne,{path:"tasks/:taskId/findings",element:i.jsx(Pa,{})})]}),s&&i.jsxs(Ne,{element:i.jsx(L9,{}),children:[i.jsx(Ne,{path:"findings",element:i.jsx(bx,{})}),i.jsx(Ne,{path:"findings/:findingId",element:i.jsx(xx,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:i.jsx(bx,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:i.jsx(xx,{})})]}),i.jsxs(Ne,{element:i.jsx(O9,{}),children:[i.jsx(Ne,{path:"workspaces",element:i.jsx(ts,{to:"/environments",replace:!0})}),i.jsx(Ne,{path:"workspaces/new",element:i.jsx(bU,{})}),i.jsx(Ne,{path:"workspaces/:workspaceId",element:i.jsx(Pp,{})}),i.jsx(Ne,{path:"workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Pp,{})}),i.jsx(Ne,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:i.jsx(Pp,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId",element:i.jsx(lU,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:i.jsx(px,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Pa,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:i.jsx(Pa,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:i.jsx(Pa,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:i.jsx(Pa,{})}),i.jsxs(Ne,{path:"environments",element:i.jsx(wU,{}),children:[i.jsx(Ne,{index:!0,element:i.jsx(HP,{})}),i.jsx(Ne,{path:"new",element:i.jsx(_U,{})}),i.jsx(Ne,{path:":environmentId",element:i.jsx(n9,{})}),i.jsx(Ne,{path:":environmentId/edit",element:i.jsx(kU,{})})]})]}),i.jsx(Ne,{element:i.jsx(B9,{}),children:i.jsxs(Ne,{path:"settings",element:i.jsx(i9,{}),children:[i.jsx(Ne,{index:!0,element:i.jsx(ts,{to:"credentials",replace:!0})}),i.jsx(Ne,{path:"environments",element:i.jsx(ts,{to:"/environments",replace:!0})}),i.jsx(Ne,{path:"credentials",element:i.jsx(o9,{})}),i.jsx(Ne,{path:"tokens",element:i.jsx(ts,{to:"../credentials",replace:!0})}),i.jsx(Ne,{path:"personas",element:i.jsx(r9,{})}),i.jsx(Ne,{path:"personas/new",element:i.jsx(gx,{})}),i.jsx(Ne,{path:"personas/:personaId",element:i.jsx(gx,{})}),i.jsx(Ne,{path:"schedules",element:i.jsx(y9,{})}),i.jsx(Ne,{path:"schedules/new",element:i.jsx(vx,{})}),i.jsx(Ne,{path:"schedules/:scheduleId",element:i.jsx(vx,{})}),i.jsx(Ne,{path:"appearance",element:i.jsx(C9,{})}),i.jsx(Ne,{path:"shortcuts",element:i.jsx(D9,{})}),i.jsx(Ne,{path:"plugins",element:i.jsx(R9,{})}),i.jsx(Ne,{path:"about",element:i.jsx(A9,{})})]})}),i.jsx(Ne,{path:"*",element:i.jsx(ts,{to:"/",replace:!0})})]})]})}const IH=1e4;function OH(){const{onboardingCompleted:t}=ot(),[s,o]=b.useState(!1);b.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),IH);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return i.jsx(gs,{mode:"wait",children:r?i.jsx(Mt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:i.jsx(A1,{})},"splash"):i.jsx(Mt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:i.jsx(cN,{basename:"/".replace(/\/$/,""),children:i.jsx(MH,{})})},"app")})}function BH(){const t=rk?bz:Wz;return i.jsx(kz,{children:i.jsx(V7,{children:i.jsx($7,{children:i.jsx(t,{children:i.jsx(OH,{})})})})})}FT.createRoot(document.getElementById("root")).render(i.jsx(b.StrictMode,{children:i.jsx(BH,{})}));export{vs as B,Xx as K,ot as a,Gp as f,Cm as s,On as t,mt as u};
|
|
725
|
+
$\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),D==="agent"&&i.jsxs("div",{children:[i.jsx("label",{children:"Allowed MCP Tools"}),i.jsx(sx,{selectedTools:X,onChange:re=>{$(re),xe(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,re),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!Ce&&!ue&&i.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,i.jsx(oa,{isOpen:J,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:Se,onCancel:()=>me(!1)})]})}function y9(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=ot(),{showToast:c}=pn(),d=mt();return i.jsx(Z8,{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(SN),onNavigateToSchedule:u=>d(Jx(u))})}const b9="_container_1g4qh_1",x9="_form_1g4qh_7",_9="_formActions_1g4qh_66",k9="_editableSection_1g4qh_73",S9="_helperText_1g4qh_84",T9="_metaSection_1g4qh_90",j9="_optional_1g4qh_108",w9="_readonlyValue_1g4qh_113",yn={container:b9,form:x9,formActions:_9,editableSection:k9,helperText:S9,metaSection:T9,optional:j9,readonlyValue:w9};function vx(){const{scheduleId:t}=as(),s=mt(),{showToast:o}=pn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},environments:{environments:g},workspaces:{workspaces:v}}=ot(),x=t===void 0,y=x?void 0:r.find(k=>k.id===t);if(!x&&!c&&r.length>0&&!y)return i.jsx(ts,{to:tp,replace:!0});const S=[{label:"Settings",url:Ni},{label:"Schedules",url:tp},{label:x?"New Schedule":(y==null?void 0:y.title)??"Schedule",url:void 0}];return i.jsxs("div",{className:yn.container,children:[i.jsx(vs,{segments:S}),i.jsx(N9,{existing:y,isNew:x,personas:m,environments:g,workspaces:v,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(tp)},showToast:o})]})}function N9({existing:t,isNew:s,personas:o,environments:r,workspaces:c,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:m,showToast:g}){var W;const v=mt(),[x,y]=b.useState((t==null?void 0:t.title)??""),[S,k]=b.useState((t==null?void 0:t.description)??""),[j,N]=b.useState((t==null?void 0:t.scheduleExpression)??""),[T,C]=b.useState((t==null?void 0:t.personaId)??""),[A,O]=b.useState((t==null?void 0:t.environmentId)??""),[E,D]=b.useState((t==null?void 0:t.workspaceId)??""),[U,B]=b.useState(!1),[z,X]=b.useState(null);b.useEffect(()=>{s||t&&z===null&&(y(t.title),k(t.description),N(t.scheduleExpression),C(t.personaId),O(t.environmentId),D(t.workspaceId))},[s,t,z]);const $=!s&&t===void 0,J=s&&x.trim().length>0&&j.trim().length>0&&T.length>0,me=o.map(Q=>({value:Q.id,label:Q.name})),ee=[{value:"",label:"Auto-select (first connected)"},...r.map(Q=>({value:Q.id,label:Q.displayName}))],oe=[{value:"",label:"System-level (no workspace)"},...c.map(Q=>({value:Q.id,label:Q.name}))],R=Q=>{Q.preventDefault(),J&&d(x,S,j,T,A||void 0,E||void 0).then(ue=>{g("Schedule created","success"),v(Jx(ue.id),{replace:!0})},()=>{g("Failed to create schedule","error")})},G=(Q,ue)=>{t&&u(t.id,{[Q]:ue}).then(()=>{g("Schedule updated","success"),Q==="title"&&y(String(ue)),Q==="description"&&k(String(ue)),Q==="scheduleExpression"&&N(String(ue)),Q==="personaId"&&C(String(ue)),Q==="environmentId"&&O(String(ue))},()=>{g("Failed to update schedule","error")})},Z=()=>{if(!t)return;const Q=!t.enabled;u(t.id,{enabled:Q}).then(()=>{g(Q?"Schedule enabled":"Schedule disabled","success")},()=>{g("Failed to update schedule","error")})},de=()=>{t&&p(t.id).then(()=>{g("Schedule deleted","success"),m()},()=>{g("Failed to delete schedule","error")})};return i.jsxs(i.Fragment,{children:[$?i.jsxs("div",{className:yn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsx("p",{children:"Loading schedule..."})]}):s?i.jsxs("form",{onSubmit:R,className:yn.form,children:[i.jsx("h3",{children:"Create Schedule"}),i.jsxs("label",{children:["Title",i.jsx("input",{type:"text",value:x,onChange:Q=>y(Q.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description ",i.jsx("span",{className:yn.optional,children:"(optional)"}),i.jsx("input",{type:"text",value:S,onChange:Q=>k(Q.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx("input",{type:"text",value:j,onChange:Q=>N(Q.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),i.jsxs("p",{className:yn.helperText,children:["Interval: ",i.jsx("code",{children:"30s"}),", ",i.jsx("code",{children:"5m"}),", ",i.jsx("code",{children:"1h"}),", ",i.jsx("code",{children:"1d"})," (min 10s) | Cron: ",i.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),i.jsxs("label",{children:["Persona",i.jsxs("select",{value:T,onChange:Q=>C(Q.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[i.jsx("option",{value:"",children:"Select a persona..."}),me.map(Q=>i.jsx("option",{value:Q.value,children:Q.label},Q.value))]})]}),i.jsxs("label",{children:["Environment ",i.jsx("span",{className:yn.optional,children:"(optional)"}),i.jsx("select",{value:A,onChange:Q=>O(Q.target.value),"data-testid":"schedule-detail-environment",children:ee.map(Q=>i.jsx("option",{value:Q.value,children:Q.label},Q.value))})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:yn.optional,children:"(optional)"}),i.jsx("select",{value:E,onChange:Q=>D(Q.target.value),"data-testid":"schedule-detail-workspace",children:oe.map(Q=>i.jsx("option",{value:Q.value,children:Q.label},Q.value))})]}),i.jsxs("div",{className:yn.formActions,children:[i.jsx(tn,{type:"submit",variant:"primary",size:"md",disabled:!J,"data-testid":"schedule-detail-save",children:"Create"}),i.jsx(tn,{type:"button",variant:"outline",size:"md",onClick:m,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?i.jsxs("div",{className:yn.form,children:[i.jsx("h3",{children:"Edit Schedule"}),i.jsxs("div",{className:yn.formActions,children:[i.jsx(tn,{type:"button",variant:"outline",size:"md",onClick:m,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),i.jsx(tn,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:Z,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),i.jsx(tn,{type:"button",variant:"danger",size:"md",onClick:()=>B(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),i.jsxs("div",{className:yn.editableSection,children:[i.jsxs("label",{children:["Title",i.jsx(Ft,{value:x,onSave:Q=>{G("title",Q)},validate:Q=>Q.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:z,onActivate:X,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),i.jsxs("label",{children:["Description",i.jsx(Ft,{value:S,onSave:Q=>{G("description",Q)},fieldId:"schedule-description",activeFieldId:z,onActivate:X,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),i.jsxs("label",{children:["Schedule Expression",i.jsx(Ft,{value:j,onSave:Q=>{G("scheduleExpression",Q)},validate:Q=>Q.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:z,onActivate:X,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(Po,{value:T,onSave:Q=>{G("personaId",Q)},options:me,fieldId:"schedule-persona",activeFieldId:z,onActivate:X,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),i.jsxs("label",{children:["Environment ",i.jsx("span",{className:yn.optional,children:"(optional — empty = auto-select)"}),i.jsx(Po,{value:A,onSave:Q=>{G("environmentId",Q)},options:ee,fieldId:"schedule-environment",activeFieldId:z,onActivate:X,ariaLabel:"Schedule environment","data-testid":"schedule-detail-environment"})]}),i.jsxs("label",{children:["Workspace ",i.jsx("span",{className:yn.optional,children:"(optional — set at creation)"}),i.jsx("span",{className:yn.readonlyValue,"data-testid":"schedule-detail-workspace",children:((W=c.find(Q=>Q.id===t.workspaceId))==null?void 0:W.name)??"System-level (no workspace)"})]})]}),i.jsxs("div",{className:yn.metaSection,children:[t.lastRunAt?i.jsxs("span",{children:["Last run: ",Uo(t.lastRunAt)]}):i.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?i.jsxs("span",{children:["Next run: ",B1(t.nextRunAt)]}):null,t.runCount>0&&i.jsxs("span",{children:["Total runs: ",t.runCount]}),i.jsxs("span",{children:["Created: ",Uo(t.createdAt)]})]})]}):null,i.jsx(oa,{isOpen:U,title:"Delete Schedule?",description:`"${t==null?void 0:t.title}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:de,onCancel:()=>B(!1)})]})}function C9(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=J1();return i.jsx(pB,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function E9(){const[t,s]=b.useState(void 0);return b.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Ye.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function A9(){const{connected:t,environments:{environments:s},sessions:{sessions:o}}=ot(),r=E9();return i.jsxs(i.Fragment,{children:[r&&i.jsx(mO,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),i.jsx(mB,{connected:t,environments:s,sessions:o})]})}function D9(){return i.jsx(s8,{})}function R9(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=ot();return i.jsx(CL,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const yx=Ii();function M9(){const t=mt();return sa({key:"?"},()=>{t(TN)}),sa({key:"n"},()=>{t(yx)}),sa({key:"N"},()=>{t(yx)}),i.jsx(i.Fragment,{})}function xl(t){const s=F7();b.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function I9(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=ot(),o=b.useMemo(()=>i.jsx(q5,{workspaces:t,tasks:s}),[t,s]);return xl(o),i.jsx(Ya,{})}function O9(){const{environments:{environments:t}}=ot(),s=b.useMemo(()=>i.jsx(e5,{environments:t}),[t]);return xl(s),i.jsx(Ya,{})}function B9(){const t=b.useMemo(()=>i.jsx(X8,{}),[]);return xl(t),i.jsx(Ya,{})}function L9(){const{findings:{findings:t,loadFindings:s,loadAllFindings:o}}=ot(),{workspaceId:r,environmentId:c}=as();b.useEffect(()=>{r?s(r).catch(()=>{}):o().catch(()=>{})},[r,s,o]);const d=b.useMemo(()=>i.jsx(u5,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return xl(d),i.jsx(Ya,{})}function z9(){const{knowledge:t,workspaces:{workspaces:s}}=ot(),o=b.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=b.useCallback(()=>{t.clearSearch()},[t]),c=b.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=b.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=b.useMemo(()=>i.jsx(pI,{nodes:t.graphData.nodes,workspaces:s,loading:t.loading,searchQuery:t.searchQuery,onSearch:o,onClearSearch:r,onSelectNode:c,onWorkspaceChange:d}),[t,s,o,r,c,d]);return xl(u),i.jsx(Ya,{})}const $9="_container_ce571_1",P9="_title_ce571_6",kd={container:$9,title:P9};function U9(){return i.jsxs("div",{className:kd.container,"aria-hidden":"true",children:[i.jsx("h1",{className:kd.title,children:"Findings"}),i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>i.jsx(bd,{lines:3},s))})]})}function bx(){const{environmentId:t,workspaceId:s}=as(),{findings:{findings:o,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=ot(),p=mt();b.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=b.useCallback(v=>{p(Gp(v,s,t))},[p,s,t]);if(r)return i.jsx(U9,{});const g=s&&t?sk("Findings",s,t,d,u).slice(0,-1):az();return i.jsxs("div",{className:kd.container,"data-testid":"findings-list-page",children:[i.jsx(vs,{segments:g}),i.jsx("h1",{className:kd.title,children:"Findings"}),i.jsx(U1,{findings:o,onFindingClick:m})]})}const H9="_container_1wwpb_1",V9="_notFound_1wwpb_6",q9="_header_1wwpb_12",G9="_categoryBadge_1wwpb_19",F9="_title_1wwpb_28",Z9="_content_1wwpb_35",K9="_tags_1wwpb_77",Y9="_tag_1wwpb_77",J9="_meta_1wwpb_92",W9="_metaTimestamp_1wwpb_100",X9="_metaLink_1wwpb_105",vn={container:H9,notFound:V9,header:q9,categoryBadge:G9,title:F9,content:Z9,tags:K9,tag:Y9,meta:J9,metaTimestamp:W9,metaLink:X9};function xx(){const{findingId:t,environmentId:s,workspaceId:o}=as(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=ot(),m=mt();if(b.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return i.jsx("div",{className:vn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:vn.notFound,children:"Loading..."})});if(!r)return i.jsx("div",{className:vn.container,"data-testid":"finding-detail-page",children:i.jsx("div",{className:vn.notFound,children:"Finding not found."})});const g=sk(r.title,o,s,u,p),v=xd(r.category);return i.jsxs("div",{className:vn.container,"data-testid":"finding-detail-page",children:[i.jsx(vs,{segments:g}),i.jsxs("div",{className:vn.header,children:[i.jsx("span",{className:vn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),i.jsx("h1",{className:vn.title,children:r.title})]}),r.content&&i.jsx("div",{className:vn.content,children:i.jsx(Td,{remarkPlugins:[jd],children:r.content})}),r.tags.length>0&&i.jsx("div",{className:vn.tags,children:r.tags.map(x=>i.jsx("span",{className:vn.tag,children:x},x))}),i.jsxs("div",{className:vn.meta,children:[i.jsx("span",{className:vn.metaTimestamp,title:r.createdAt,children:Uo(r.createdAt)}),r.taskId&&i.jsx("button",{type:"button",className:vn.metaLink,onClick:()=>{m(On(r.taskId))},children:"View Task"}),r.sessionId&&i.jsx("button",{type:"button",className:vn.metaLink,onClick:()=>{m(Cm(r.sessionId))},children:"View Session"})]})]})}const Q9="_wizard_1260s_1",eH="_container_1260s_10",tH="_stepContent_1260s_19",nH="_logoArea_1260s_28",sH="_logoImage_1260s_32",aH="_heading_1260s_41",iH="_tagline_1260s_49",oH="_subtitle_1260s_56",rH="_featureList_1260s_64",lH="_runtimeGrid_1260s_89",cH="_runtimeCard_1260s_101",dH="_runtimeName_1260s_133",uH="_runtimeDescription_1260s_139",fH="_buttonRow_1260s_144",pH="_primaryButton_1260s_151",mH="_ghostButton_1260s_185",hH="_dots_1260s_213",gH="_dot_1260s_213",Ke={wizard:Q9,container:eH,stepContent:tH,logoArea:nH,logoImage:sH,heading:aH,tagline:iH,subtitle:oH,featureList:rH,runtimeGrid:lH,runtimeCard:cH,runtimeName:dH,runtimeDescription:uH,buttonRow:fH,primaryButton:pH,ghostButton:mH,dots:hH,dot:gH};function vH({onNext:t}){return i.jsxs("div",{className:Ke.stepContent,"data-testid":"setup-welcome",children:[i.jsx("div",{className:Ke.logoArea,children:i.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Ke.logoImage})}),i.jsx("h1",{className:Ke.heading,children:"Welcome to Grackle"}),i.jsx("p",{className:Ke.tagline,children:"Multi-agent orchestration for software teams"}),i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function yH({onNext:t,onBack:s}){return i.jsxs("div",{className:Ke.stepContent,"data-testid":"setup-about",children:[i.jsx("h2",{className:Ke.heading,children:"What is Grackle?"}),i.jsxs("ul",{className:Ke.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:Ke.buttonRow,children:[i.jsx("button",{type:"button",className:Ke.ghostButton,onClick:s,children:"Back"}),i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const bH=[{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 xH({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=b.useState(t||"claude-code");return b.useEffect(()=>{t&&d(t)},[t]),i.jsxs("div",{className:Ke.stepContent,"data-testid":"setup-runtime",children:[i.jsx("h2",{className:Ke.heading,children:"Choose Your Runtime"}),i.jsx("p",{className:Ke.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),i.jsx("div",{className:Ke.runtimeGrid,children:bH.map(u=>i.jsxs("button",{type:"button",className:Ke.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:Ke.runtimeName,children:u.name}),i.jsx("span",{className:Ke.runtimeDescription,children:u.description})]},u.id))}),i.jsxs("div",{className:Ke.buttonRow,children:[i.jsx("button",{type:"button",className:Ke.ghostButton,onClick:o,children:"Back"}),i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function _H(){return typeof Notification<"u"}function kH({onFinish:t,onBack:s,finishDisabled:o}){const r=_H(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return i.jsxs("div",{className:Ke.stepContent,"data-testid":"setup-notifications",children:[i.jsx("h2",{className:Ke.heading,children:"Stay in the Loop"}),i.jsx("p",{className:Ke.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:Ke.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:Ke.buttonRow,children:[i.jsx("button",{type:"button",className:Ke.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:Ke.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):i.jsx("button",{type:"button",className:Ke.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const SH=4,_x={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function TH(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=ot(),{showToast:c}=pn(),d=mt(),[u,p]=b.useState(0),[m,g]=b.useState("claude-code"),[v,x]=b.useState(!1),y=t.find(j=>j.id==="claude-code"),S=b.useCallback(j=>{g(j),p(3)},[]),k=b.useCallback(()=>{const j=m;x(!0);const N=[];if(y&&j!==y.runtime){const C=_x[j]??"sonnet";N.push(s(y.id,void 0,void 0,void 0,j,C))}const T=t.find(C=>C.id===dy);if(T&&j!==T.runtime){const C=_x[j]??"sonnet";N.push(s(dy,void 0,void 0,void 0,j,C))}Promise.all(N).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),x(!1)})},[m,y,t,s,o,d,c]);return r===!0?i.jsx(ts,{to:"/",replace:!0}):i.jsx("div",{className:Ke.wizard,"data-testid":"setup-wizard",children:i.jsxs("div",{className:Ke.container,children:[i.jsx(gs,{mode:"wait",children:i.jsxs(Mt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&i.jsx(vH,{onNext:()=>p(1)}),u===1&&i.jsx(yH,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&i.jsx(xH,{currentRuntime:m,onFinish:S,onBack:()=>p(1),finishDisabled:!y}),u===3&&i.jsx(kH,{onFinish:k,onBack:()=>p(2),finishDisabled:v})]},u)}),i.jsx("div",{className:Ke.dots,children:Array.from({length:SH},(j,N)=>i.jsx("span",{className:Ke.dot,"data-active":N===u},N))})]})})}const jH="_root_zndgp_1",wH="_body_zndgp_7",NH="_main_zndgp_19",CH="_sidebarWrapper_zndgp_26",EH="_overlay_zndgp_51",Wr={root:jH,body:wH,main:NH,sidebarWrapper:CH,overlay:EH},AH=b.lazy(()=>YT(()=>import("./KnowledgePage-Dx7P15XQ.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),rk=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function DH({tabs:t}){const{connected:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=ot(),{toasts:d,dismissToast:u}=pn(),p=Yt(),m=G7(),g=m!==void 0,[v,x]=b.useState(!1),y=b.useCallback(()=>x(S=>!S),[]);return b.useEffect(()=>{x(!1)},[p.pathname]),b.useEffect(()=>{if(!v)return;const S=k=>{k.key==="Escape"&&x(!1)};return document.addEventListener("keydown",S),()=>{document.removeEventListener("keydown",S)}},[v]),i.jsxs(i.Fragment,{children:[i.jsx(SI,{connected:s,environments:o,sessions:r,onToggleSidebar:g?y:void 0,sidebarOpen:v}),i.jsx(AI,{tabs:t}),i.jsxs("div",{className:Wr.body,children:[g&&i.jsx("div",{className:Wr.sidebarWrapper,"data-sidebar-open":v,children:i.jsx(BI,{content:m})}),g&&v&&i.jsx("div",{className:Wr.overlay,"data-testid":"drawer-overlay",onClick:()=>x(!1)}),i.jsxs("div",{className:Wr.main,children:[i.jsx(Ya,{}),i.jsx(qI,{sessions:r,tasks:c,environments:o})]})]}),i.jsx(sO,{toasts:d,onDismiss:u}),i.jsx(M9,{})]})}function RH(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connected:d,onboardingCompleted:u}=ot(),{pluginNames:p}=gh(),{showToast:m}=pn();Xz(s,m),s$(c,m),Qz(o,r,m);const g=mt(),v=Yt();if(b.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(Cm(t),{replace:!0})},[t,g,v.pathname]),d&&u===!1)return i.jsx(ts,{to:"/setup",replace:!0});const x=wz(p);return i.jsx(q7,{children:i.jsxs("div",{className:Wr.root,children:[rk&&i.jsx(eC,{}),i.jsx(DH,{tabs:x})]})})}function Pp(){const{workspaceId:t}=as(),{workspaces:{workspaces:s}}=ot(),o=Yt(),r=s.find(m=>m.id===t);if(!(r!=null&&r.environmentId))return s.length===0?void 0:i.jsx(ts,{to:"/environments",replace:!0});const c=encodeURIComponent(t),d=`/workspaces/${c}`,u=o.pathname.startsWith(d)?o.pathname.slice(d.length):"",p=`/environments/${encodeURIComponent(r.environmentId)}/workspaces/${c}${u}${o.search}${o.hash}`;return i.jsx(ts,{to:p,replace:!0})}function MH(){const{pluginNames:t}=gh(),s=t.includes("orchestration"),o=t.includes("knowledge");return i.jsxs(zw,{children:[i.jsx(Ne,{path:"setup",element:i.jsx(TH,{})}),i.jsxs(Ne,{element:i.jsx(RH,{}),children:[i.jsx(Ne,{index:!0,element:i.jsx(VP,{})}),i.jsx(Ne,{path:"chat",element:i.jsx(QP,{})}),i.jsx(Ne,{path:"sessions/new",element:i.jsx(eU,{})}),i.jsx(Ne,{path:"sessions/:sessionId",element:i.jsx(aU,{})}),o&&i.jsx(Ne,{element:i.jsx(z9,{}),children:i.jsx(Ne,{path:"knowledge",element:i.jsx(b.Suspense,{fallback:i.jsx(A1,{}),children:i.jsx(AH,{})})})}),s&&i.jsxs(Ne,{element:i.jsx(I9,{}),children:[i.jsx(Ne,{path:"tasks",element:i.jsx(UP,{})}),i.jsx(Ne,{path:"tasks/new",element:i.jsx(px,{})}),i.jsx(Ne,{path:"tasks/:taskId",element:i.jsx(Pa,{})}),i.jsx(Ne,{path:"tasks/:taskId/edit",element:i.jsx(Pa,{})}),i.jsx(Ne,{path:"tasks/:taskId/stream",element:i.jsx(Pa,{})}),i.jsx(Ne,{path:"tasks/:taskId/findings",element:i.jsx(Pa,{})})]}),s&&i.jsxs(Ne,{element:i.jsx(L9,{}),children:[i.jsx(Ne,{path:"findings",element:i.jsx(bx,{})}),i.jsx(Ne,{path:"findings/:findingId",element:i.jsx(xx,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:i.jsx(bx,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:i.jsx(xx,{})})]}),i.jsxs(Ne,{element:i.jsx(O9,{}),children:[i.jsx(Ne,{path:"workspaces",element:i.jsx(ts,{to:"/environments",replace:!0})}),i.jsx(Ne,{path:"workspaces/new",element:i.jsx(bU,{})}),i.jsx(Ne,{path:"workspaces/:workspaceId",element:i.jsx(Pp,{})}),i.jsx(Ne,{path:"workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Pp,{})}),i.jsx(Ne,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:i.jsx(Pp,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId",element:i.jsx(lU,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:i.jsx(px,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:i.jsx(Pa,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:i.jsx(Pa,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:i.jsx(Pa,{})}),i.jsx(Ne,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:i.jsx(Pa,{})}),i.jsxs(Ne,{path:"environments",element:i.jsx(wU,{}),children:[i.jsx(Ne,{index:!0,element:i.jsx(HP,{})}),i.jsx(Ne,{path:"new",element:i.jsx(_U,{})}),i.jsx(Ne,{path:":environmentId",element:i.jsx(n9,{})}),i.jsx(Ne,{path:":environmentId/edit",element:i.jsx(kU,{})})]})]}),i.jsx(Ne,{element:i.jsx(B9,{}),children:i.jsxs(Ne,{path:"settings",element:i.jsx(i9,{}),children:[i.jsx(Ne,{index:!0,element:i.jsx(ts,{to:"credentials",replace:!0})}),i.jsx(Ne,{path:"environments",element:i.jsx(ts,{to:"/environments",replace:!0})}),i.jsx(Ne,{path:"credentials",element:i.jsx(o9,{})}),i.jsx(Ne,{path:"tokens",element:i.jsx(ts,{to:"../credentials",replace:!0})}),i.jsx(Ne,{path:"personas",element:i.jsx(r9,{})}),i.jsx(Ne,{path:"personas/new",element:i.jsx(gx,{})}),i.jsx(Ne,{path:"personas/:personaId",element:i.jsx(gx,{})}),i.jsx(Ne,{path:"schedules",element:i.jsx(y9,{})}),i.jsx(Ne,{path:"schedules/new",element:i.jsx(vx,{})}),i.jsx(Ne,{path:"schedules/:scheduleId",element:i.jsx(vx,{})}),i.jsx(Ne,{path:"appearance",element:i.jsx(C9,{})}),i.jsx(Ne,{path:"shortcuts",element:i.jsx(D9,{})}),i.jsx(Ne,{path:"plugins",element:i.jsx(R9,{})}),i.jsx(Ne,{path:"about",element:i.jsx(A9,{})})]})}),i.jsx(Ne,{path:"*",element:i.jsx(ts,{to:"/",replace:!0})})]})]})}const IH=1e4;function OH(){const{onboardingCompleted:t}=ot(),[s,o]=b.useState(!1);b.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),IH);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return i.jsx(gs,{mode:"wait",children:r?i.jsx(Mt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:i.jsx(A1,{})},"splash"):i.jsx(Mt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:i.jsx(cN,{basename:"/".replace(/\/$/,""),children:i.jsx(MH,{})})},"app")})}function BH(){const t=rk?bz:Wz;return i.jsx(kz,{children:i.jsx(V7,{children:i.jsx($7,{children:i.jsx(t,{children:i.jsx(OH,{})})})})})}FT.createRoot(document.getElementById("root")).render(i.jsx(b.StrictMode,{children:i.jsx(BH,{})}));export{vs as B,Xx as K,ot as a,Gp as f,Cm as s,On as t,mt as u};
|