@grackle-ai/web 0.133.1 → 0.134.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 +1 @@
1
- import{t as nt,l as rt,b as A,z as it,s as T,m as st,n as X,j as w}from"./dagview-B70jDsRo.js";import{u as at,s as ot,t as ct,a as lt,B as ut,K as ft}from"./index-BYoJMBJg.js";import"./grpc-CHXyF1mC.js";import"./markdown-CPoGw-1N.js";function ht(t,e){var n,o=1;t==null&&(t=0),e==null&&(e=0);function s(){var r,c=n.length,d,_=0,i=0;for(r=0;r<c;++r)d=n[r],_+=d.x,i+=d.y;for(_=(_/c-t)*o,i=(i/c-e)*o,r=0;r<c;++r)d=n[r],d.x-=_,d.y-=i}return s.initialize=function(r){n=r},s.x=function(r){return arguments.length?(t=+r,s):t},s.y=function(r){return arguments.length?(e=+r,s):e},s.strength=function(r){return arguments.length?(o=+r,s):o},s}function dt(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return q(this.cover(e,n),e,n,t)}function q(t,e,n,o){if(isNaN(e)||isNaN(n))return t;var s,r=t._root,c={data:o},d=t._x0,_=t._y0,i=t._x1,v=t._y1,N,g,f,p,l,a,u,h;if(!r)return t._root=c,t;for(;r.length;)if((l=e>=(N=(d+i)/2))?d=N:i=N,(a=n>=(g=(_+v)/2))?_=g:v=g,s=r,!(r=r[u=a<<1|l]))return s[u]=c,t;if(f=+t._x.call(null,r.data),p=+t._y.call(null,r.data),e===f&&n===p)return c.next=r,s?s[u]=c:t._root=c,t;do s=s?s[u]=new Array(4):t._root=new Array(4),(l=e>=(N=(d+i)/2))?d=N:i=N,(a=n>=(g=(_+v)/2))?_=g:v=g;while((u=a<<1|l)===(h=(p>=g)<<1|f>=N));return s[h]=r,s[u]=c,t}function gt(t){var e,n,o=t.length,s,r,c=new Array(o),d=new Array(o),_=1/0,i=1/0,v=-1/0,N=-1/0;for(n=0;n<o;++n)isNaN(s=+this._x.call(null,e=t[n]))||isNaN(r=+this._y.call(null,e))||(c[n]=s,d[n]=r,s<_&&(_=s),s>v&&(v=s),r<i&&(i=r),r>N&&(N=r));if(_>v||i>N)return this;for(this.cover(_,i).cover(v,N),n=0;n<o;++n)q(this,c[n],d[n],t[n]);return this}function xt(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,o=this._y0,s=this._x1,r=this._y1;if(isNaN(n))s=(n=Math.floor(t))+1,r=(o=Math.floor(e))+1;else{for(var c=s-n||1,d=this._root,_,i;n>t||t>=s||o>e||e>=r;)switch(i=(e<o)<<1|t<n,_=new Array(4),_[i]=d,d=_,c*=2,i){case 0:s=n+c,r=o+c;break;case 1:n=s-c,r=o+c;break;case 2:s=n+c,o=r-c;break;case 3:n=s-c,o=r-c;break}this._root&&this._root.length&&(this._root=d)}return this._x0=n,this._y0=o,this._x1=s,this._y1=r,this}function yt(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function _t(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function L(t,e,n,o,s){this.node=t,this.x0=e,this.y0=n,this.x1=o,this.y1=s}function vt(t,e,n){var o,s=this._x0,r=this._y0,c,d,_,i,v=this._x1,N=this._y1,g=[],f=this._root,p,l;for(f&&g.push(new L(f,s,r,v,N)),n==null?n=1/0:(s=t-n,r=e-n,v=t+n,N=e+n,n*=n);p=g.pop();)if(!(!(f=p.node)||(c=p.x0)>v||(d=p.y0)>N||(_=p.x1)<s||(i=p.y1)<r))if(f.length){var a=(c+_)/2,u=(d+i)/2;g.push(new L(f[3],a,u,_,i),new L(f[2],c,u,a,i),new L(f[1],a,d,_,u),new L(f[0],c,d,a,u)),(l=(e>=u)<<1|t>=a)&&(p=g[g.length-1],g[g.length-1]=g[g.length-1-l],g[g.length-1-l]=p)}else{var h=t-+this._x.call(null,f.data),m=e-+this._y.call(null,f.data),y=h*h+m*m;if(y<n){var b=Math.sqrt(n=y);s=t-b,r=e-b,v=t+b,N=e+b,o=f.data}}return o}function mt(t){if(isNaN(v=+this._x.call(null,t))||isNaN(N=+this._y.call(null,t)))return this;var e,n=this._root,o,s,r,c=this._x0,d=this._y0,_=this._x1,i=this._y1,v,N,g,f,p,l,a,u;if(!n)return this;if(n.length)for(;;){if((p=v>=(g=(c+_)/2))?c=g:_=g,(l=N>=(f=(d+i)/2))?d=f:i=f,e=n,!(n=n[a=l<<1|p]))return this;if(!n.length)break;(e[a+1&3]||e[a+2&3]||e[a+3&3])&&(o=e,u=a)}for(;n.data!==t;)if(s=n,!(n=n.next))return this;return(r=n.next)&&delete n.next,s?(r?s.next=r:delete s.next,this):e?(r?e[a]=r:delete e[a],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(o?o[u]=n:this._root=n),this):(this._root=r,this)}function pt(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function wt(){return this._root}function Nt(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function bt(t){var e=[],n,o=this._root,s,r,c,d,_;for(o&&e.push(new L(o,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(o=n.node,r=n.x0,c=n.y0,d=n.x1,_=n.y1)&&o.length){var i=(r+d)/2,v=(c+_)/2;(s=o[3])&&e.push(new L(s,i,v,d,_)),(s=o[2])&&e.push(new L(s,r,v,i,_)),(s=o[1])&&e.push(new L(s,i,c,d,v)),(s=o[0])&&e.push(new L(s,r,c,i,v))}return this}function jt(t){var e=[],n=[],o;for(this._root&&e.push(new L(this._root,this._x0,this._y0,this._x1,this._y1));o=e.pop();){var s=o.node;if(s.length){var r,c=o.x0,d=o.y0,_=o.x1,i=o.y1,v=(c+_)/2,N=(d+i)/2;(r=s[0])&&e.push(new L(r,c,d,v,N)),(r=s[1])&&e.push(new L(r,v,d,_,N)),(r=s[2])&&e.push(new L(r,c,N,v,i)),(r=s[3])&&e.push(new L(r,v,N,_,i))}n.push(o)}for(;o=n.pop();)t(o.node,o.x0,o.y0,o.x1,o.y1);return this}function kt(t){return t[0]}function At(t){return arguments.length?(this._x=t,this):this._x}function Ct(t){return t[1]}function Mt(t){return arguments.length?(this._y=t,this):this._y}function P(t,e,n){var o=new U(e??kt,n??Ct,NaN,NaN,NaN,NaN);return t==null?o:o.addAll(t)}function U(t,e,n,o,s,r){this._x=t,this._y=e,this._x0=n,this._y0=o,this._x1=s,this._y1=r,this._root=void 0}function Y(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var R=P.prototype=U.prototype;R.copy=function(){var t=new U(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,o;if(!e)return t;if(!e.length)return t._root=Y(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var s=0;s<4;++s)(o=e.source[s])&&(o.length?n.push({source:o,target:e.target[s]=new Array(4)}):e.target[s]=Y(o));return t};R.add=dt;R.addAll=gt;R.cover=xt;R.data=yt;R.extent=_t;R.find=vt;R.remove=mt;R.removeAll=pt;R.root=wt;R.size=Nt;R.visit=bt;R.visitAfter=jt;R.x=At;R.y=Mt;function G(t){return function(){return t}}function S(t){return(t()-.5)*1e-6}function It(t){return t.x+t.vx}function Lt(t){return t.y+t.vy}function Rt(t){var e,n,o,s=1,r=1;typeof t!="function"&&(t=G(t==null?1:+t));function c(){for(var i,v=e.length,N,g,f,p,l,a,u=0;u<r;++u)for(N=P(e,It,Lt).visitAfter(d),i=0;i<v;++i)g=e[i],l=n[g.index],a=l*l,f=g.x+g.vx,p=g.y+g.vy,N.visit(h);function h(m,y,b,C,I){var j=m.data,B=m.r,x=l+B;if(j){if(j.index>g.index){var k=f-j.x-j.vx,z=p-j.y-j.vy,D=k*k+z*z;D<x*x&&(k===0&&(k=S(o),D+=k*k),z===0&&(z=S(o),D+=z*z),D=(x-(D=Math.sqrt(D)))/D*s,g.vx+=(k*=D)*(x=(B*=B)/(a+B)),g.vy+=(z*=D)*x,j.vx-=k*(x=1-x),j.vy-=z*x)}return}return y>f+x||C<f-x||b>p+x||I<p-x}}function d(i){if(i.data)return i.r=n[i.data.index];for(var v=i.r=0;v<4;++v)i[v]&&i[v].r>i.r&&(i.r=i[v].r)}function _(){if(e){var i,v=e.length,N;for(n=new Array(v),i=0;i<v;++i)N=e[i],n[N.index]=+t(N,i,e)}}return c.initialize=function(i,v){e=i,o=v,_()},c.iterations=function(i){return arguments.length?(r=+i,c):r},c.strength=function(i){return arguments.length?(s=+i,c):s},c.radius=function(i){return arguments.length?(t=typeof i=="function"?i:G(+i),_(),c):t},c}function Et(t){return t.index}function W(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Bt(t){var e=Et,n=N,o,s=G(30),r,c,d,_,i,v=1;t==null&&(t=[]);function N(a){return 1/Math.min(d[a.source.index],d[a.target.index])}function g(a){for(var u=0,h=t.length;u<v;++u)for(var m=0,y,b,C,I,j,B,x;m<h;++m)y=t[m],b=y.source,C=y.target,I=C.x+C.vx-b.x-b.vx||S(i),j=C.y+C.vy-b.y-b.vy||S(i),B=Math.sqrt(I*I+j*j),B=(B-r[m])/B*a*o[m],I*=B,j*=B,C.vx-=I*(x=_[m]),C.vy-=j*x,b.vx+=I*(x=1-x),b.vy+=j*x}function f(){if(c){var a,u=c.length,h=t.length,m=new Map(c.map((b,C)=>[e(b,C,c),b])),y;for(a=0,d=new Array(u);a<h;++a)y=t[a],y.index=a,typeof y.source!="object"&&(y.source=W(m,y.source)),typeof y.target!="object"&&(y.target=W(m,y.target)),d[y.source.index]=(d[y.source.index]||0)+1,d[y.target.index]=(d[y.target.index]||0)+1;for(a=0,_=new Array(h);a<h;++a)y=t[a],_[a]=d[y.source.index]/(d[y.source.index]+d[y.target.index]);o=new Array(h),p(),r=new Array(h),l()}}function p(){if(c)for(var a=0,u=t.length;a<u;++a)o[a]=+n(t[a],a,t)}function l(){if(c)for(var a=0,u=t.length;a<u;++a)r[a]=+s(t[a],a,t)}return g.initialize=function(a,u){c=a,i=u,f()},g.links=function(a){return arguments.length?(t=a,f(),g):t},g.id=function(a){return arguments.length?(e=a,g):e},g.iterations=function(a){return arguments.length?(v=+a,g):v},g.strength=function(a){return arguments.length?(n=typeof a=="function"?a:G(+a),p(),g):n},g.distance=function(a){return arguments.length?(s=typeof a=="function"?a:G(+a),l(),g):s},g}const Dt=1664525,zt=1013904223,Q=4294967296;function Tt(){let t=1;return()=>(t=(Dt*t+zt)%Q)/Q}function St(t){return t.x}function Ft(t){return t.y}var $t=10,Gt=Math.PI*(3-Math.sqrt(5));function Ot(t){var e,n=1,o=.001,s=1-Math.pow(o,1/300),r=0,c=.6,d=new Map,_=nt(N),i=rt("tick","end"),v=Tt();t==null&&(t=[]);function N(){g(),i.call("tick",e),n<o&&(_.stop(),i.call("end",e))}function g(l){var a,u=t.length,h;l===void 0&&(l=1);for(var m=0;m<l;++m)for(n+=(r-n)*s,d.forEach(function(y){y(n)}),a=0;a<u;++a)h=t[a],h.fx==null?h.x+=h.vx*=c:(h.x=h.fx,h.vx=0),h.fy==null?h.y+=h.vy*=c:(h.y=h.fy,h.vy=0);return e}function f(){for(var l=0,a=t.length,u;l<a;++l){if(u=t[l],u.index=l,u.fx!=null&&(u.x=u.fx),u.fy!=null&&(u.y=u.fy),isNaN(u.x)||isNaN(u.y)){var h=$t*Math.sqrt(.5+l),m=l*Gt;u.x=h*Math.cos(m),u.y=h*Math.sin(m)}(isNaN(u.vx)||isNaN(u.vy))&&(u.vx=u.vy=0)}}function p(l){return l.initialize&&l.initialize(t,v),l}return f(),e={tick:g,restart:function(){return _.restart(N),e},stop:function(){return _.stop(),e},nodes:function(l){return arguments.length?(t=l,f(),d.forEach(p),e):t},alpha:function(l){return arguments.length?(n=+l,e):n},alphaMin:function(l){return arguments.length?(o=+l,e):o},alphaDecay:function(l){return arguments.length?(s=+l,e):+s},alphaTarget:function(l){return arguments.length?(r=+l,e):r},velocityDecay:function(l){return arguments.length?(c=1-l,e):1-c},randomSource:function(l){return arguments.length?(v=l,d.forEach(p),e):v},force:function(l,a){return arguments.length>1?(a==null?d.delete(l):d.set(l,p(a)),e):d.get(l)},find:function(l,a,u){var h=0,m=t.length,y,b,C,I,j;for(u==null?u=1/0:u*=u,h=0;h<m;++h)I=t[h],y=l-I.x,b=a-I.y,C=y*y+b*b,C<u&&(j=I,u=C);return j},on:function(l,a){return arguments.length>1?(i.on(l,a),e):i.on(l)}}}function Kt(){var t,e,n,o,s=G(-30),r,c=1,d=1/0,_=.81;function i(f){var p,l=t.length,a=P(t,St,Ft).visitAfter(N);for(o=f,p=0;p<l;++p)e=t[p],a.visit(g)}function v(){if(t){var f,p=t.length,l;for(r=new Array(p),f=0;f<p;++f)l=t[f],r[l.index]=+s(l,f,t)}}function N(f){var p=0,l,a,u=0,h,m,y;if(f.length){for(h=m=y=0;y<4;++y)(l=f[y])&&(a=Math.abs(l.value))&&(p+=l.value,u+=a,h+=a*l.x,m+=a*l.y);f.x=h/u,f.y=m/u}else{l=f,l.x=l.data.x,l.y=l.data.y;do p+=r[l.data.index];while(l=l.next)}f.value=p}function g(f,p,l,a){if(!f.value)return!0;var u=f.x-e.x,h=f.y-e.y,m=a-p,y=u*u+h*h;if(m*m/_<y)return y<d&&(u===0&&(u=S(n),y+=u*u),h===0&&(h=S(n),y+=h*h),y<c&&(y=Math.sqrt(c*y)),e.vx+=u*f.value*o/y,e.vy+=h*f.value*o/y),!0;if(f.length||y>=d)return;(f.data!==e||f.next)&&(u===0&&(u=S(n),y+=u*u),h===0&&(h=S(n),y+=h*h),y<c&&(y=Math.sqrt(c*y)));do f.data!==e&&(m=r[f.data.index]*o/y,e.vx+=u*m,e.vy+=h*m);while(f=f.next)}return i.initialize=function(f,p){t=f,n=p,v()},i.strength=function(f){return arguments.length?(s=typeof f=="function"?f:G(+f),v(),i):s},i.distanceMin=function(f){return arguments.length?(c=f*f,i):Math.sqrt(c)},i.distanceMax=function(f){return arguments.length?(d=f*f,i):Math.sqrt(d)},i.theta=function(f){return arguments.length?(_=f*f,i):Math.sqrt(_)},i}const Ht="_graphContainer_13vy2_1",Pt="_svg_13vy2_10",Ut="_link_13vy2_18",Xt="_node_13vy2_30",Yt="_nodeCard_13vy2_37",Wt="_nodeLabel_13vy2_43",Qt="_selected_13vy2_47",Vt="_dimmed_13vy2_54",Zt="_dimmedLink_13vy2_59",Jt="_nodeIndicator_13vy2_71",qt="_nodeBadge_13vy2_85",E={graphContainer:Ht,svg:Pt,link:Ut,node:Xt,nodeCard:Yt,nodeLabel:Wt,selected:Qt,dimmed:Vt,dimmedLink:Zt,nodeIndicator:Jt,nodeBadge:qt},H={reference:"#4A9EFF",decision:"#22C55E",insight:"#EAB308",concept:"#A855F7",snippet:"#6B7280"};function V(t){return t.kind==="reference"?H.reference:H[t.category??"insight"]??H.insight}const F=200,$=52,Z=12,K=40,J=3;function te(t,e){if(e.width<=0||e.height<=0)return;let n=1/0,o=-1/0,s=1/0,r=-1/0;for(const l of t){const a=l.x??0,u=l.y??0;a<n&&(n=a),a>o&&(o=a),u<s&&(s=u),u>r&&(r=u)}const c=n-F/2-K,d=o+F/2+K,_=s-$/2-K,i=r+$/2+K,v=d-c,N=i-_,g=Math.min(e.width/v,e.height/N,1),f=(c+d)/2,p=(_+i)/2;return{translateX:e.width/2-f*g,translateY:e.height/2-p*g,scale:g}}function ee({graphData:t,selectedNodeId:e,onNodeClick:n,onNodeDoubleClick:o}){const s=A.useRef(null),r=A.useRef(null),c=A.useRef(void 0),d=A.useRef(void 0),_=A.useRef(void 0),i=A.useRef(void 0),v=A.useRef(e);v.current=e;const N=A.useRef(!1),[g,f]=A.useState({width:800,height:600}),p=A.useRef(0);A.useEffect(()=>{var y;const h=((y=s.current)==null?void 0:y.parentElement)??null;if(!h)return;const m=new ResizeObserver(b=>{for(const C of b)f({width:C.contentRect.width,height:C.contentRect.height})});return m.observe(h),f({width:h.clientWidth,height:h.clientHeight}),()=>{m.disconnect()}},[]),A.useEffect(()=>{if(!s.current||!r.current)return;const h=s.current,m=r.current,y=it().scaleExtent([.1,4]).filter(b=>b.type!=="dblclick").on("zoom",b=>{T(m).attr("transform",String(b.transform))});return T(h).call(y),d.current=y,()=>{T(h).on(".zoom",null)}},[]);const l=A.useRef(n);l.current=n;const a=A.useRef(o);a.current=o,A.useEffect(()=>{if(!r.current)return;const h=r.current;if(c.current&&(c.current.stop(),c.current=void 0),N.current=!1,t.nodes.length===0){T(h).selectAll("*").remove();return}const m=t.nodes.map(x=>({...x})),y=new Map(m.map(x=>[x.id,x])),b=t.links.filter(x=>y.has(x.source)&&y.has(x.target)).map(x=>({source:x.source,target:x.target,type:x.type}));T(h).selectAll("*").remove();const C=T(h).selectAll("line").data(b).enter().append("line").attr("class",E.link);C.append("title").text(x=>x.type),_.current=C;const I=T(h).selectAll("g.kg-node").data(m).enter().append("g").attr("class",`kg-node ${E.node}`).on("click",(x,k)=>{p.current>J||l.current(k.id)}).on("dblclick",(x,k)=>{a.current(k.id)});i.current=I,I.append("rect").attr("class",E.nodeCard).attr("width",F).attr("height",$).attr("rx",Z).attr("ry",Z).style("--node-color",x=>V(x)),I.append("rect").attr("class",E.nodeIndicator).attr("width",4).attr("height",$).attr("rx",2).attr("fill",x=>V(x)),I.append("text").attr("class",E.nodeLabel).attr("x",F/2).attr("y",$/2-4).attr("text-anchor","middle").attr("dominant-baseline","central").text(x=>x.label.length>26?x.label.substring(0,24)+"...":x.label),I.append("text").attr("class",E.nodeBadge).attr("x",F/2).attr("y",$-8).attr("text-anchor","middle").text(x=>(x.kind==="reference"?x.sourceType??"ref":x.category??"").toUpperCase());const j=Ot(m).force("link",Bt(b).id(x=>x.id).distance(140)).force("charge",Kt().strength(-400)).force("center",ht(g.width/2,g.height/2)).force("collide",Rt(F/2+16)).on("tick",()=>{C.attr("x1",x=>x.source.x??0).attr("y1",x=>x.source.y??0).attr("x2",x=>x.target.x??0).attr("y2",x=>x.target.y??0),I.attr("transform",x=>`translate(${(x.x??0)-F/2},${(x.y??0)-$/2})`)});c.current=j;const B=st().on("start",(x,k)=>{k.fx=k.x,k.fy=k.y,p.current=0}).on("drag",(x,k)=>{k.fx=x.x,k.fy=x.y,p.current+=Math.abs(x.dx)+Math.abs(x.dy),p.current>J&&j.alphaTarget()===0&&j.alphaTarget(.3).restart()}).on("end",(x,k)=>{x.active||j.alphaTarget(0),k.fx=void 0,k.fy=void 0});return I.call(B),j.on("end",()=>{if(s.current&&d.current&&m.length>0&&!N.current&&!v.current){N.current=!0;const x=te(m,g);if(!x)return;const{translateX:k,translateY:z,scale:D}=x,tt=d.current,et=X.translate(k,z).scale(D);T(s.current).transition().duration(500).call(tt.transform,et)}}),()=>{j.stop()}},[t,g]),A.useEffect(()=>{if(!r.current||!i.current||!_.current)return;if(!e){i.current.classed(E.dimmed,!1).classed(E.selected,!1),_.current.classed(E.dimmedLink,!1);return}const h=new Set([e]);_.current.each(m=>{const y=m.source.id,b=m.target.id;(y===e||b===e)&&(h.add(y),h.add(b))}),i.current.classed(E.selected,m=>m.id===e).classed(E.dimmed,m=>!h.has(m.id)),_.current.classed(E.dimmedLink,m=>{const y=m.source.id,b=m.target.id;return!h.has(y)||!h.has(b)})},[e,t]);const u=A.useCallback(()=>{if(!e||!c.current||!s.current||!d.current)return;const h=c.current.nodes().find(m=>m.id===e);if(h&&Number.isFinite(h.x)&&Number.isFinite(h.y)){const m=d.current,y=X.translate(g.width/2,g.height/2).scale(1.2).translate(-(h.x??0),-(h.y??0));T(s.current).transition().duration(500).call(m.transform,y)}},[e,g]);return A.useEffect(()=>{u()},[u]),w.jsx("div",{className:E.graphContainer,"data-testid":"knowledge-graph",children:w.jsxs("svg",{ref:s,width:g.width,height:g.height,className:E.svg,children:[w.jsx("defs",{children:w.jsxs("filter",{id:"glow",children:[w.jsx("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),w.jsxs("feMerge",{children:[w.jsx("feMergeNode",{in:"coloredBlur"}),w.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),w.jsx("g",{ref:r})]})})}const ne="_panel_1wumt_1",re="_header_1wumt_24",ie="_title_1wumt_32",se="_closeButton_1wumt_42",ae="_body_1wumt_55",oe="_badge_1wumt_61",ce="_section_1wumt_72",le="_sectionLabel_1wumt_76",ue="_content_1wumt_84",fe="_tags_1wumt_92",he="_tag_1wumt_92",de="_viewLink_1wumt_107",ge="_edgeList_1wumt_121",xe="_edgeItem_1wumt_127",ye="_edgeType_1wumt_136",_e="_edgeNodeLink_1wumt_142",ve="_timestamps_1wumt_154",M={panel:ne,header:re,title:ie,closeButton:se,body:ae,badge:oe,section:ce,sectionLabel:le,content:ue,tags:fe,tag:he,viewLink:de,edgeList:ge,edgeItem:xe,edgeType:ye,edgeNodeLink:_e,timestamps:ve};function me({detail:t,nodes:e,onClose:n,onSelectNode:o}){const s=at(),{node:r,edges:c}=t,d=A.useMemo(()=>new Map(e.map(i=>[i.id,i])),[e]);function _(){if(!(r.kind!=="reference"||!r.sourceId))switch(r.sourceType){case"task":s(ct(r.sourceId));break;case"session":s(ot(r.sourceId));break}}return w.jsxs("div",{className:M.panel,"data-testid":"knowledge-detail-panel",children:[w.jsxs("div",{className:M.header,children:[w.jsx("h3",{className:M.title,children:r.label}),w.jsx("button",{className:M.closeButton,onClick:n,"aria-label":"Close",children:"×"})]}),w.jsxs("div",{className:M.body,children:[w.jsx("div",{className:M.badge,children:r.kind==="reference"?`Reference (${r.sourceType})`:r.category}),r.content&&w.jsxs("div",{className:M.section,children:[w.jsx("div",{className:M.sectionLabel,children:"Content"}),w.jsx("p",{className:M.content,children:r.content})]}),r.tags&&r.tags.length>0&&w.jsxs("div",{className:M.section,children:[w.jsx("div",{className:M.sectionLabel,children:"Tags"}),w.jsx("div",{className:M.tags,children:r.tags.map(i=>w.jsx("span",{className:M.tag,children:i},i))})]}),r.kind==="reference"&&r.sourceId&&w.jsx("div",{className:M.section,children:w.jsx("button",{className:M.viewLink,onClick:_,children:"View in Grackle →"})}),c.length>0&&w.jsxs("div",{className:M.section,children:[w.jsxs("div",{className:M.sectionLabel,children:["Edges (",c.length,")"]}),w.jsx("ul",{className:M.edgeList,children:c.map(i=>{var g;const v=i.fromId===r.id?i.toId:i.fromId,N=`${i.fromId}:${i.toId}:${i.type}`;return w.jsxs("li",{className:M.edgeItem,"data-testid":"edge-item",children:[w.jsx("span",{className:M.edgeType,"data-testid":"edge-type",children:i.type}),w.jsx("button",{className:M.edgeNodeLink,"data-testid":"edge-node-link",onClick:()=>{o(v)},children:((g=d.get(v))==null?void 0:g.label)??`${v.substring(0,8)}...`})]},N)})})]}),w.jsxs("div",{className:M.timestamps,children:[r.createdAt&&w.jsxs("div",{children:["Created: ",new Date(r.createdAt).toLocaleDateString()]}),r.updatedAt&&w.jsxs("div",{children:["Updated: ",new Date(r.updatedAt).toLocaleDateString()]})]})]})]})}const pe="_layout_1wp49_1",we="_graphArea_1wp49_8",Ne="_empty_1wp49_15",be="_retryButton_1wp49_30",O={layout:pe,graphArea:we,empty:Ne,retryButton:be};function Me(){const{knowledge:t}=lt(),{loadRecent:e,loadError:n,loading:o,graphData:s,selectedId:r,selectedNode:c}=t,{selectNode:d,expandNode:_,clearSelection:i}=t;A.useEffect(()=>{e().catch(()=>{})},[e]);const v=A.useCallback(()=>{e().catch(()=>{})},[e]),N=A.useCallback(u=>{d(u).catch(()=>{})},[d]),g=A.useCallback(u=>{_(u).catch(()=>{})},[_]),f=A.useCallback(()=>{i()},[i]),p=[{label:"Knowledge",url:ft}],l=n!==void 0&&!o,a=!l&&s.nodes.length===0&&!o;return w.jsxs("div",{className:O.layout,"data-testid":"knowledge-page",children:[w.jsx(ut,{segments:p}),w.jsxs("div",{className:O.graphArea,children:[l?w.jsxs("div",{className:O.empty,"data-testid":"knowledge-error",children:[n==="unavailable"?w.jsxs(w.Fragment,{children:[w.jsx("p",{children:"Knowledge server can't be reached."}),w.jsx("p",{children:"The knowledge graph database (Neo4j) isn't running or is unreachable. Start it, then retry."})]}):w.jsxs(w.Fragment,{children:[w.jsx("p",{children:"Failed to load the knowledge graph."}),w.jsx("p",{children:"Something went wrong while loading knowledge nodes."})]}),w.jsx("button",{type:"button",className:O.retryButton,onClick:v,"data-testid":"knowledge-retry",children:"Retry"})]}):a?w.jsxs("div",{className:O.empty,children:[w.jsx("p",{children:"No knowledge nodes found."}),w.jsx("p",{children:"Create knowledge via MCP tools or let agents discover it during tasks."})]}):w.jsx(ee,{graphData:s,selectedNodeId:r,onNodeClick:N,onNodeDoubleClick:g}),c&&r&&w.jsx(me,{detail:c,nodes:s.nodes,onClose:f,onSelectNode:N})]})]})}export{Me as KnowledgePage};
1
+ import{t as nt,l as rt,b as A,z as it,s as T,m as st,n as X,j as w}from"./dagview-B70jDsRo.js";import{u as at,s as ot,t as ct,a as lt,B as ut,K as ft}from"./index-BzbnBHCp.js";import"./grpc-CHXyF1mC.js";import"./markdown-CPoGw-1N.js";function ht(t,e){var n,o=1;t==null&&(t=0),e==null&&(e=0);function s(){var r,c=n.length,d,_=0,i=0;for(r=0;r<c;++r)d=n[r],_+=d.x,i+=d.y;for(_=(_/c-t)*o,i=(i/c-e)*o,r=0;r<c;++r)d=n[r],d.x-=_,d.y-=i}return s.initialize=function(r){n=r},s.x=function(r){return arguments.length?(t=+r,s):t},s.y=function(r){return arguments.length?(e=+r,s):e},s.strength=function(r){return arguments.length?(o=+r,s):o},s}function dt(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return q(this.cover(e,n),e,n,t)}function q(t,e,n,o){if(isNaN(e)||isNaN(n))return t;var s,r=t._root,c={data:o},d=t._x0,_=t._y0,i=t._x1,v=t._y1,N,g,f,p,l,a,u,h;if(!r)return t._root=c,t;for(;r.length;)if((l=e>=(N=(d+i)/2))?d=N:i=N,(a=n>=(g=(_+v)/2))?_=g:v=g,s=r,!(r=r[u=a<<1|l]))return s[u]=c,t;if(f=+t._x.call(null,r.data),p=+t._y.call(null,r.data),e===f&&n===p)return c.next=r,s?s[u]=c:t._root=c,t;do s=s?s[u]=new Array(4):t._root=new Array(4),(l=e>=(N=(d+i)/2))?d=N:i=N,(a=n>=(g=(_+v)/2))?_=g:v=g;while((u=a<<1|l)===(h=(p>=g)<<1|f>=N));return s[h]=r,s[u]=c,t}function gt(t){var e,n,o=t.length,s,r,c=new Array(o),d=new Array(o),_=1/0,i=1/0,v=-1/0,N=-1/0;for(n=0;n<o;++n)isNaN(s=+this._x.call(null,e=t[n]))||isNaN(r=+this._y.call(null,e))||(c[n]=s,d[n]=r,s<_&&(_=s),s>v&&(v=s),r<i&&(i=r),r>N&&(N=r));if(_>v||i>N)return this;for(this.cover(_,i).cover(v,N),n=0;n<o;++n)q(this,c[n],d[n],t[n]);return this}function xt(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,o=this._y0,s=this._x1,r=this._y1;if(isNaN(n))s=(n=Math.floor(t))+1,r=(o=Math.floor(e))+1;else{for(var c=s-n||1,d=this._root,_,i;n>t||t>=s||o>e||e>=r;)switch(i=(e<o)<<1|t<n,_=new Array(4),_[i]=d,d=_,c*=2,i){case 0:s=n+c,r=o+c;break;case 1:n=s-c,r=o+c;break;case 2:s=n+c,o=r-c;break;case 3:n=s-c,o=r-c;break}this._root&&this._root.length&&(this._root=d)}return this._x0=n,this._y0=o,this._x1=s,this._y1=r,this}function yt(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function _t(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function L(t,e,n,o,s){this.node=t,this.x0=e,this.y0=n,this.x1=o,this.y1=s}function vt(t,e,n){var o,s=this._x0,r=this._y0,c,d,_,i,v=this._x1,N=this._y1,g=[],f=this._root,p,l;for(f&&g.push(new L(f,s,r,v,N)),n==null?n=1/0:(s=t-n,r=e-n,v=t+n,N=e+n,n*=n);p=g.pop();)if(!(!(f=p.node)||(c=p.x0)>v||(d=p.y0)>N||(_=p.x1)<s||(i=p.y1)<r))if(f.length){var a=(c+_)/2,u=(d+i)/2;g.push(new L(f[3],a,u,_,i),new L(f[2],c,u,a,i),new L(f[1],a,d,_,u),new L(f[0],c,d,a,u)),(l=(e>=u)<<1|t>=a)&&(p=g[g.length-1],g[g.length-1]=g[g.length-1-l],g[g.length-1-l]=p)}else{var h=t-+this._x.call(null,f.data),m=e-+this._y.call(null,f.data),y=h*h+m*m;if(y<n){var b=Math.sqrt(n=y);s=t-b,r=e-b,v=t+b,N=e+b,o=f.data}}return o}function mt(t){if(isNaN(v=+this._x.call(null,t))||isNaN(N=+this._y.call(null,t)))return this;var e,n=this._root,o,s,r,c=this._x0,d=this._y0,_=this._x1,i=this._y1,v,N,g,f,p,l,a,u;if(!n)return this;if(n.length)for(;;){if((p=v>=(g=(c+_)/2))?c=g:_=g,(l=N>=(f=(d+i)/2))?d=f:i=f,e=n,!(n=n[a=l<<1|p]))return this;if(!n.length)break;(e[a+1&3]||e[a+2&3]||e[a+3&3])&&(o=e,u=a)}for(;n.data!==t;)if(s=n,!(n=n.next))return this;return(r=n.next)&&delete n.next,s?(r?s.next=r:delete s.next,this):e?(r?e[a]=r:delete e[a],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(o?o[u]=n:this._root=n),this):(this._root=r,this)}function pt(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function wt(){return this._root}function Nt(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function bt(t){var e=[],n,o=this._root,s,r,c,d,_;for(o&&e.push(new L(o,this._x0,this._y0,this._x1,this._y1));n=e.pop();)if(!t(o=n.node,r=n.x0,c=n.y0,d=n.x1,_=n.y1)&&o.length){var i=(r+d)/2,v=(c+_)/2;(s=o[3])&&e.push(new L(s,i,v,d,_)),(s=o[2])&&e.push(new L(s,r,v,i,_)),(s=o[1])&&e.push(new L(s,i,c,d,v)),(s=o[0])&&e.push(new L(s,r,c,i,v))}return this}function jt(t){var e=[],n=[],o;for(this._root&&e.push(new L(this._root,this._x0,this._y0,this._x1,this._y1));o=e.pop();){var s=o.node;if(s.length){var r,c=o.x0,d=o.y0,_=o.x1,i=o.y1,v=(c+_)/2,N=(d+i)/2;(r=s[0])&&e.push(new L(r,c,d,v,N)),(r=s[1])&&e.push(new L(r,v,d,_,N)),(r=s[2])&&e.push(new L(r,c,N,v,i)),(r=s[3])&&e.push(new L(r,v,N,_,i))}n.push(o)}for(;o=n.pop();)t(o.node,o.x0,o.y0,o.x1,o.y1);return this}function kt(t){return t[0]}function At(t){return arguments.length?(this._x=t,this):this._x}function Ct(t){return t[1]}function Mt(t){return arguments.length?(this._y=t,this):this._y}function P(t,e,n){var o=new U(e??kt,n??Ct,NaN,NaN,NaN,NaN);return t==null?o:o.addAll(t)}function U(t,e,n,o,s,r){this._x=t,this._y=e,this._x0=n,this._y0=o,this._x1=s,this._y1=r,this._root=void 0}function Y(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var R=P.prototype=U.prototype;R.copy=function(){var t=new U(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,o;if(!e)return t;if(!e.length)return t._root=Y(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var s=0;s<4;++s)(o=e.source[s])&&(o.length?n.push({source:o,target:e.target[s]=new Array(4)}):e.target[s]=Y(o));return t};R.add=dt;R.addAll=gt;R.cover=xt;R.data=yt;R.extent=_t;R.find=vt;R.remove=mt;R.removeAll=pt;R.root=wt;R.size=Nt;R.visit=bt;R.visitAfter=jt;R.x=At;R.y=Mt;function G(t){return function(){return t}}function S(t){return(t()-.5)*1e-6}function It(t){return t.x+t.vx}function Lt(t){return t.y+t.vy}function Rt(t){var e,n,o,s=1,r=1;typeof t!="function"&&(t=G(t==null?1:+t));function c(){for(var i,v=e.length,N,g,f,p,l,a,u=0;u<r;++u)for(N=P(e,It,Lt).visitAfter(d),i=0;i<v;++i)g=e[i],l=n[g.index],a=l*l,f=g.x+g.vx,p=g.y+g.vy,N.visit(h);function h(m,y,b,C,I){var j=m.data,B=m.r,x=l+B;if(j){if(j.index>g.index){var k=f-j.x-j.vx,z=p-j.y-j.vy,D=k*k+z*z;D<x*x&&(k===0&&(k=S(o),D+=k*k),z===0&&(z=S(o),D+=z*z),D=(x-(D=Math.sqrt(D)))/D*s,g.vx+=(k*=D)*(x=(B*=B)/(a+B)),g.vy+=(z*=D)*x,j.vx-=k*(x=1-x),j.vy-=z*x)}return}return y>f+x||C<f-x||b>p+x||I<p-x}}function d(i){if(i.data)return i.r=n[i.data.index];for(var v=i.r=0;v<4;++v)i[v]&&i[v].r>i.r&&(i.r=i[v].r)}function _(){if(e){var i,v=e.length,N;for(n=new Array(v),i=0;i<v;++i)N=e[i],n[N.index]=+t(N,i,e)}}return c.initialize=function(i,v){e=i,o=v,_()},c.iterations=function(i){return arguments.length?(r=+i,c):r},c.strength=function(i){return arguments.length?(s=+i,c):s},c.radius=function(i){return arguments.length?(t=typeof i=="function"?i:G(+i),_(),c):t},c}function Et(t){return t.index}function W(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Bt(t){var e=Et,n=N,o,s=G(30),r,c,d,_,i,v=1;t==null&&(t=[]);function N(a){return 1/Math.min(d[a.source.index],d[a.target.index])}function g(a){for(var u=0,h=t.length;u<v;++u)for(var m=0,y,b,C,I,j,B,x;m<h;++m)y=t[m],b=y.source,C=y.target,I=C.x+C.vx-b.x-b.vx||S(i),j=C.y+C.vy-b.y-b.vy||S(i),B=Math.sqrt(I*I+j*j),B=(B-r[m])/B*a*o[m],I*=B,j*=B,C.vx-=I*(x=_[m]),C.vy-=j*x,b.vx+=I*(x=1-x),b.vy+=j*x}function f(){if(c){var a,u=c.length,h=t.length,m=new Map(c.map((b,C)=>[e(b,C,c),b])),y;for(a=0,d=new Array(u);a<h;++a)y=t[a],y.index=a,typeof y.source!="object"&&(y.source=W(m,y.source)),typeof y.target!="object"&&(y.target=W(m,y.target)),d[y.source.index]=(d[y.source.index]||0)+1,d[y.target.index]=(d[y.target.index]||0)+1;for(a=0,_=new Array(h);a<h;++a)y=t[a],_[a]=d[y.source.index]/(d[y.source.index]+d[y.target.index]);o=new Array(h),p(),r=new Array(h),l()}}function p(){if(c)for(var a=0,u=t.length;a<u;++a)o[a]=+n(t[a],a,t)}function l(){if(c)for(var a=0,u=t.length;a<u;++a)r[a]=+s(t[a],a,t)}return g.initialize=function(a,u){c=a,i=u,f()},g.links=function(a){return arguments.length?(t=a,f(),g):t},g.id=function(a){return arguments.length?(e=a,g):e},g.iterations=function(a){return arguments.length?(v=+a,g):v},g.strength=function(a){return arguments.length?(n=typeof a=="function"?a:G(+a),p(),g):n},g.distance=function(a){return arguments.length?(s=typeof a=="function"?a:G(+a),l(),g):s},g}const Dt=1664525,zt=1013904223,Q=4294967296;function Tt(){let t=1;return()=>(t=(Dt*t+zt)%Q)/Q}function St(t){return t.x}function Ft(t){return t.y}var $t=10,Gt=Math.PI*(3-Math.sqrt(5));function Ot(t){var e,n=1,o=.001,s=1-Math.pow(o,1/300),r=0,c=.6,d=new Map,_=nt(N),i=rt("tick","end"),v=Tt();t==null&&(t=[]);function N(){g(),i.call("tick",e),n<o&&(_.stop(),i.call("end",e))}function g(l){var a,u=t.length,h;l===void 0&&(l=1);for(var m=0;m<l;++m)for(n+=(r-n)*s,d.forEach(function(y){y(n)}),a=0;a<u;++a)h=t[a],h.fx==null?h.x+=h.vx*=c:(h.x=h.fx,h.vx=0),h.fy==null?h.y+=h.vy*=c:(h.y=h.fy,h.vy=0);return e}function f(){for(var l=0,a=t.length,u;l<a;++l){if(u=t[l],u.index=l,u.fx!=null&&(u.x=u.fx),u.fy!=null&&(u.y=u.fy),isNaN(u.x)||isNaN(u.y)){var h=$t*Math.sqrt(.5+l),m=l*Gt;u.x=h*Math.cos(m),u.y=h*Math.sin(m)}(isNaN(u.vx)||isNaN(u.vy))&&(u.vx=u.vy=0)}}function p(l){return l.initialize&&l.initialize(t,v),l}return f(),e={tick:g,restart:function(){return _.restart(N),e},stop:function(){return _.stop(),e},nodes:function(l){return arguments.length?(t=l,f(),d.forEach(p),e):t},alpha:function(l){return arguments.length?(n=+l,e):n},alphaMin:function(l){return arguments.length?(o=+l,e):o},alphaDecay:function(l){return arguments.length?(s=+l,e):+s},alphaTarget:function(l){return arguments.length?(r=+l,e):r},velocityDecay:function(l){return arguments.length?(c=1-l,e):1-c},randomSource:function(l){return arguments.length?(v=l,d.forEach(p),e):v},force:function(l,a){return arguments.length>1?(a==null?d.delete(l):d.set(l,p(a)),e):d.get(l)},find:function(l,a,u){var h=0,m=t.length,y,b,C,I,j;for(u==null?u=1/0:u*=u,h=0;h<m;++h)I=t[h],y=l-I.x,b=a-I.y,C=y*y+b*b,C<u&&(j=I,u=C);return j},on:function(l,a){return arguments.length>1?(i.on(l,a),e):i.on(l)}}}function Kt(){var t,e,n,o,s=G(-30),r,c=1,d=1/0,_=.81;function i(f){var p,l=t.length,a=P(t,St,Ft).visitAfter(N);for(o=f,p=0;p<l;++p)e=t[p],a.visit(g)}function v(){if(t){var f,p=t.length,l;for(r=new Array(p),f=0;f<p;++f)l=t[f],r[l.index]=+s(l,f,t)}}function N(f){var p=0,l,a,u=0,h,m,y;if(f.length){for(h=m=y=0;y<4;++y)(l=f[y])&&(a=Math.abs(l.value))&&(p+=l.value,u+=a,h+=a*l.x,m+=a*l.y);f.x=h/u,f.y=m/u}else{l=f,l.x=l.data.x,l.y=l.data.y;do p+=r[l.data.index];while(l=l.next)}f.value=p}function g(f,p,l,a){if(!f.value)return!0;var u=f.x-e.x,h=f.y-e.y,m=a-p,y=u*u+h*h;if(m*m/_<y)return y<d&&(u===0&&(u=S(n),y+=u*u),h===0&&(h=S(n),y+=h*h),y<c&&(y=Math.sqrt(c*y)),e.vx+=u*f.value*o/y,e.vy+=h*f.value*o/y),!0;if(f.length||y>=d)return;(f.data!==e||f.next)&&(u===0&&(u=S(n),y+=u*u),h===0&&(h=S(n),y+=h*h),y<c&&(y=Math.sqrt(c*y)));do f.data!==e&&(m=r[f.data.index]*o/y,e.vx+=u*m,e.vy+=h*m);while(f=f.next)}return i.initialize=function(f,p){t=f,n=p,v()},i.strength=function(f){return arguments.length?(s=typeof f=="function"?f:G(+f),v(),i):s},i.distanceMin=function(f){return arguments.length?(c=f*f,i):Math.sqrt(c)},i.distanceMax=function(f){return arguments.length?(d=f*f,i):Math.sqrt(d)},i.theta=function(f){return arguments.length?(_=f*f,i):Math.sqrt(_)},i}const Ht="_graphContainer_13vy2_1",Pt="_svg_13vy2_10",Ut="_link_13vy2_18",Xt="_node_13vy2_30",Yt="_nodeCard_13vy2_37",Wt="_nodeLabel_13vy2_43",Qt="_selected_13vy2_47",Vt="_dimmed_13vy2_54",Zt="_dimmedLink_13vy2_59",Jt="_nodeIndicator_13vy2_71",qt="_nodeBadge_13vy2_85",E={graphContainer:Ht,svg:Pt,link:Ut,node:Xt,nodeCard:Yt,nodeLabel:Wt,selected:Qt,dimmed:Vt,dimmedLink:Zt,nodeIndicator:Jt,nodeBadge:qt},H={reference:"#4A9EFF",decision:"#22C55E",insight:"#EAB308",concept:"#A855F7",snippet:"#6B7280"};function V(t){return t.kind==="reference"?H.reference:H[t.category??"insight"]??H.insight}const F=200,$=52,Z=12,K=40,J=3;function te(t,e){if(e.width<=0||e.height<=0)return;let n=1/0,o=-1/0,s=1/0,r=-1/0;for(const l of t){const a=l.x??0,u=l.y??0;a<n&&(n=a),a>o&&(o=a),u<s&&(s=u),u>r&&(r=u)}const c=n-F/2-K,d=o+F/2+K,_=s-$/2-K,i=r+$/2+K,v=d-c,N=i-_,g=Math.min(e.width/v,e.height/N,1),f=(c+d)/2,p=(_+i)/2;return{translateX:e.width/2-f*g,translateY:e.height/2-p*g,scale:g}}function ee({graphData:t,selectedNodeId:e,onNodeClick:n,onNodeDoubleClick:o}){const s=A.useRef(null),r=A.useRef(null),c=A.useRef(void 0),d=A.useRef(void 0),_=A.useRef(void 0),i=A.useRef(void 0),v=A.useRef(e);v.current=e;const N=A.useRef(!1),[g,f]=A.useState({width:800,height:600}),p=A.useRef(0);A.useEffect(()=>{var y;const h=((y=s.current)==null?void 0:y.parentElement)??null;if(!h)return;const m=new ResizeObserver(b=>{for(const C of b)f({width:C.contentRect.width,height:C.contentRect.height})});return m.observe(h),f({width:h.clientWidth,height:h.clientHeight}),()=>{m.disconnect()}},[]),A.useEffect(()=>{if(!s.current||!r.current)return;const h=s.current,m=r.current,y=it().scaleExtent([.1,4]).filter(b=>b.type!=="dblclick").on("zoom",b=>{T(m).attr("transform",String(b.transform))});return T(h).call(y),d.current=y,()=>{T(h).on(".zoom",null)}},[]);const l=A.useRef(n);l.current=n;const a=A.useRef(o);a.current=o,A.useEffect(()=>{if(!r.current)return;const h=r.current;if(c.current&&(c.current.stop(),c.current=void 0),N.current=!1,t.nodes.length===0){T(h).selectAll("*").remove();return}const m=t.nodes.map(x=>({...x})),y=new Map(m.map(x=>[x.id,x])),b=t.links.filter(x=>y.has(x.source)&&y.has(x.target)).map(x=>({source:x.source,target:x.target,type:x.type}));T(h).selectAll("*").remove();const C=T(h).selectAll("line").data(b).enter().append("line").attr("class",E.link);C.append("title").text(x=>x.type),_.current=C;const I=T(h).selectAll("g.kg-node").data(m).enter().append("g").attr("class",`kg-node ${E.node}`).on("click",(x,k)=>{p.current>J||l.current(k.id)}).on("dblclick",(x,k)=>{a.current(k.id)});i.current=I,I.append("rect").attr("class",E.nodeCard).attr("width",F).attr("height",$).attr("rx",Z).attr("ry",Z).style("--node-color",x=>V(x)),I.append("rect").attr("class",E.nodeIndicator).attr("width",4).attr("height",$).attr("rx",2).attr("fill",x=>V(x)),I.append("text").attr("class",E.nodeLabel).attr("x",F/2).attr("y",$/2-4).attr("text-anchor","middle").attr("dominant-baseline","central").text(x=>x.label.length>26?x.label.substring(0,24)+"...":x.label),I.append("text").attr("class",E.nodeBadge).attr("x",F/2).attr("y",$-8).attr("text-anchor","middle").text(x=>(x.kind==="reference"?x.sourceType??"ref":x.category??"").toUpperCase());const j=Ot(m).force("link",Bt(b).id(x=>x.id).distance(140)).force("charge",Kt().strength(-400)).force("center",ht(g.width/2,g.height/2)).force("collide",Rt(F/2+16)).on("tick",()=>{C.attr("x1",x=>x.source.x??0).attr("y1",x=>x.source.y??0).attr("x2",x=>x.target.x??0).attr("y2",x=>x.target.y??0),I.attr("transform",x=>`translate(${(x.x??0)-F/2},${(x.y??0)-$/2})`)});c.current=j;const B=st().on("start",(x,k)=>{k.fx=k.x,k.fy=k.y,p.current=0}).on("drag",(x,k)=>{k.fx=x.x,k.fy=x.y,p.current+=Math.abs(x.dx)+Math.abs(x.dy),p.current>J&&j.alphaTarget()===0&&j.alphaTarget(.3).restart()}).on("end",(x,k)=>{x.active||j.alphaTarget(0),k.fx=void 0,k.fy=void 0});return I.call(B),j.on("end",()=>{if(s.current&&d.current&&m.length>0&&!N.current&&!v.current){N.current=!0;const x=te(m,g);if(!x)return;const{translateX:k,translateY:z,scale:D}=x,tt=d.current,et=X.translate(k,z).scale(D);T(s.current).transition().duration(500).call(tt.transform,et)}}),()=>{j.stop()}},[t,g]),A.useEffect(()=>{if(!r.current||!i.current||!_.current)return;if(!e){i.current.classed(E.dimmed,!1).classed(E.selected,!1),_.current.classed(E.dimmedLink,!1);return}const h=new Set([e]);_.current.each(m=>{const y=m.source.id,b=m.target.id;(y===e||b===e)&&(h.add(y),h.add(b))}),i.current.classed(E.selected,m=>m.id===e).classed(E.dimmed,m=>!h.has(m.id)),_.current.classed(E.dimmedLink,m=>{const y=m.source.id,b=m.target.id;return!h.has(y)||!h.has(b)})},[e,t]);const u=A.useCallback(()=>{if(!e||!c.current||!s.current||!d.current)return;const h=c.current.nodes().find(m=>m.id===e);if(h&&Number.isFinite(h.x)&&Number.isFinite(h.y)){const m=d.current,y=X.translate(g.width/2,g.height/2).scale(1.2).translate(-(h.x??0),-(h.y??0));T(s.current).transition().duration(500).call(m.transform,y)}},[e,g]);return A.useEffect(()=>{u()},[u]),w.jsx("div",{className:E.graphContainer,"data-testid":"knowledge-graph",children:w.jsxs("svg",{ref:s,width:g.width,height:g.height,className:E.svg,children:[w.jsx("defs",{children:w.jsxs("filter",{id:"glow",children:[w.jsx("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),w.jsxs("feMerge",{children:[w.jsx("feMergeNode",{in:"coloredBlur"}),w.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),w.jsx("g",{ref:r})]})})}const ne="_panel_1wumt_1",re="_header_1wumt_24",ie="_title_1wumt_32",se="_closeButton_1wumt_42",ae="_body_1wumt_55",oe="_badge_1wumt_61",ce="_section_1wumt_72",le="_sectionLabel_1wumt_76",ue="_content_1wumt_84",fe="_tags_1wumt_92",he="_tag_1wumt_92",de="_viewLink_1wumt_107",ge="_edgeList_1wumt_121",xe="_edgeItem_1wumt_127",ye="_edgeType_1wumt_136",_e="_edgeNodeLink_1wumt_142",ve="_timestamps_1wumt_154",M={panel:ne,header:re,title:ie,closeButton:se,body:ae,badge:oe,section:ce,sectionLabel:le,content:ue,tags:fe,tag:he,viewLink:de,edgeList:ge,edgeItem:xe,edgeType:ye,edgeNodeLink:_e,timestamps:ve};function me({detail:t,nodes:e,onClose:n,onSelectNode:o}){const s=at(),{node:r,edges:c}=t,d=A.useMemo(()=>new Map(e.map(i=>[i.id,i])),[e]);function _(){if(!(r.kind!=="reference"||!r.sourceId))switch(r.sourceType){case"task":s(ct(r.sourceId));break;case"session":s(ot(r.sourceId));break}}return w.jsxs("div",{className:M.panel,"data-testid":"knowledge-detail-panel",children:[w.jsxs("div",{className:M.header,children:[w.jsx("h3",{className:M.title,children:r.label}),w.jsx("button",{className:M.closeButton,onClick:n,"aria-label":"Close",children:"×"})]}),w.jsxs("div",{className:M.body,children:[w.jsx("div",{className:M.badge,children:r.kind==="reference"?`Reference (${r.sourceType})`:r.category}),r.content&&w.jsxs("div",{className:M.section,children:[w.jsx("div",{className:M.sectionLabel,children:"Content"}),w.jsx("p",{className:M.content,children:r.content})]}),r.tags&&r.tags.length>0&&w.jsxs("div",{className:M.section,children:[w.jsx("div",{className:M.sectionLabel,children:"Tags"}),w.jsx("div",{className:M.tags,children:r.tags.map(i=>w.jsx("span",{className:M.tag,children:i},i))})]}),r.kind==="reference"&&r.sourceId&&w.jsx("div",{className:M.section,children:w.jsx("button",{className:M.viewLink,onClick:_,children:"View in Grackle →"})}),c.length>0&&w.jsxs("div",{className:M.section,children:[w.jsxs("div",{className:M.sectionLabel,children:["Edges (",c.length,")"]}),w.jsx("ul",{className:M.edgeList,children:c.map(i=>{var g;const v=i.fromId===r.id?i.toId:i.fromId,N=`${i.fromId}:${i.toId}:${i.type}`;return w.jsxs("li",{className:M.edgeItem,"data-testid":"edge-item",children:[w.jsx("span",{className:M.edgeType,"data-testid":"edge-type",children:i.type}),w.jsx("button",{className:M.edgeNodeLink,"data-testid":"edge-node-link",onClick:()=>{o(v)},children:((g=d.get(v))==null?void 0:g.label)??`${v.substring(0,8)}...`})]},N)})})]}),w.jsxs("div",{className:M.timestamps,children:[r.createdAt&&w.jsxs("div",{children:["Created: ",new Date(r.createdAt).toLocaleDateString()]}),r.updatedAt&&w.jsxs("div",{children:["Updated: ",new Date(r.updatedAt).toLocaleDateString()]})]})]})]})}const pe="_layout_1wp49_1",we="_graphArea_1wp49_8",Ne="_empty_1wp49_15",be="_retryButton_1wp49_30",O={layout:pe,graphArea:we,empty:Ne,retryButton:be};function Me(){const{knowledge:t}=lt(),{loadRecent:e,loadError:n,loading:o,graphData:s,selectedId:r,selectedNode:c}=t,{selectNode:d,expandNode:_,clearSelection:i}=t;A.useEffect(()=>{e().catch(()=>{})},[e]);const v=A.useCallback(()=>{e().catch(()=>{})},[e]),N=A.useCallback(u=>{d(u).catch(()=>{})},[d]),g=A.useCallback(u=>{_(u).catch(()=>{})},[_]),f=A.useCallback(()=>{i()},[i]),p=[{label:"Knowledge",url:ft}],l=n!==void 0&&!o,a=!l&&s.nodes.length===0&&!o;return w.jsxs("div",{className:O.layout,"data-testid":"knowledge-page",children:[w.jsx(ut,{segments:p}),w.jsxs("div",{className:O.graphArea,children:[l?w.jsxs("div",{className:O.empty,"data-testid":"knowledge-error",children:[n==="unavailable"?w.jsxs(w.Fragment,{children:[w.jsx("p",{children:"Knowledge server can't be reached."}),w.jsx("p",{children:"The knowledge graph database (Neo4j) isn't running or is unreachable. Start it, then retry."})]}):w.jsxs(w.Fragment,{children:[w.jsx("p",{children:"Failed to load the knowledge graph."}),w.jsx("p",{children:"Something went wrong while loading knowledge nodes."})]}),w.jsx("button",{type:"button",className:O.retryButton,onClick:v,"data-testid":"knowledge-retry",children:"Retry"})]}):a?w.jsxs("div",{className:O.empty,children:[w.jsx("p",{children:"No knowledge nodes found."}),w.jsx("p",{children:"Create knowledge via MCP tools or let agents discover it during tasks."})]}):w.jsx(ee,{graphData:s,selectedNodeId:r,onNodeClick:N,onNodeDoubleClick:g}),c&&r&&w.jsx(me,{detail:c,nodes:s.nodes,onClose:f,onSelectNode:N})]})]})}export{Me as KnowledgePage};
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/McpAppWidget-bBtl27Gs.js","assets/dagview-B70jDsRo.js","assets/grpc-CHXyF1mC.js","assets/KnowledgePage-DJ9NcB1C.js","assets/markdown-CPoGw-1N.js","assets/KnowledgePage-CcVVrk7r.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/McpAppWidget-bBtl27Gs.js","assets/dagview-B70jDsRo.js","assets/grpc-CHXyF1mC.js","assets/KnowledgePage-DNjACSvg.js","assets/markdown-CPoGw-1N.js","assets/KnowledgePage-CcVVrk7r.css"])))=>i.map(i=>d[i]);
2
2
  import{r as P2,a as U2,b as y,j as a,d as ld,H as Bo,P as Lo,i as I_,B as O_,c as B_,C as L_,M as z_,e as V2,f as Mc,h as q2,k as G2}from"./dagview-B70jDsRo.js";import{c as F2,a as xd,G as K2,b as Z2,d as Y2,e as J2,f as W2,M as X2,D as $_,A as H_,W as Q2,O as ej,g as tj,C as Bs,h as _m,i as P_,w as nj,t as sj,p as Rc,j as aj,R as Ic,S as my}from"./grpc-CHXyF1mC.js";import{v as ij,r as oj,t as Oc,i as rj,f as lj,M as xm,a as km}from"./markdown-CPoGw-1N.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 Zf={exports:{}},zr={},Yf={exports:{}},Jf={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
@@ -322,7 +322,7 @@ ${r.content}`);break}}}return s.join(`
322
322
 
323
323
  ${r}
324
324
 
325
- --- End forwarded ---`}function kI(t){return t.replace(/[\r\n]+/g," ").trim().replace(/---/g,"—")}function SI({events:t,formatForClipboard:s}){const[o,r]=y.useState(!1),[c,d]=y.useState(new Set),u=y.useRef(void 0),p=y.useMemo(()=>c.size,[c]),m=y.useCallback(S=>{r(!0),S!==void 0?(d(new Set([S])),u.current=S):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((S,j)=>{if(j&&u.current!==void 0){const T=Math.min(u.current,S),N=Math.max(u.current,S);d(C=>{const D=new Set(C);for(let A=T;A<=N;A++)A<t.length&&ul(t[A])&&D.add(A);return D})}else d(T=>{const N=new Set(T);return N.has(S)?N.delete(S):N.add(S),N.size===0?(r(!1),u.current=void 0):u.current=S,N})},[t]),b=y.useCallback(()=>{const S=new Set;for(let j=0;j<t.length;j++)ul(t[j])&&S.add(j);d(S)},[t]),_=y.useCallback(()=>{d(new Set)},[]),k=y.useCallback(async()=>{const j=[...c].sort((N,C)=>N-C).filter(N=>N<t.length).map(N=>t[N]);if(j.length===0)return!1;const T=s(j);try{return await navigator.clipboard.writeText(T),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:_,copySelected:k}}const jI="_wrapper_1cdza_1",TI="_scrollContainer_1cdza_9",NI="_selectingPadding_1cdza_16",wI="_toolbar_1cdza_20",CI="_directionToggle_1cdza_27",EI="_scrollToAnchor_1cdza_65",AI="_scrollToAnchorBottom_1cdza_89",DI="_scrollToAnchorTop_1cdza_93",MI="_eventOverflowWarning_1cdza_97",oa={wrapper:jI,scrollContainer:TI,selectingPadding:NI,toolbar:wI,directionToggle:CI,scrollToAnchor:EI,scrollToAnchorBottom:AI,scrollToAnchorTop:DI,eventOverflowWarning:MI},RI=10*1024,II=new Set(["running","idle"]);function OI(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 X1="grackle-stream-direction";function BI(){try{return localStorage.getItem(X1)==="reversed"}catch{return!1}}function LI({eventsDropped:t}){return t<=0?a.jsx(a.Fragment,{}):a.jsxs("div",{className:oa.eventOverflowWarning,role:"alert",children:[a.jsx(jm,{size:Pt,"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 hh({events:t,eventsDropped:s,emptyState:o,onShowToast:r,sessions:c,currentSessionId:d,environments:u,personas:p,onForward:m,sandboxProxyUrl:g}){const v=y.useRef(null),[b,_]=y.useState(BI),k=Y4(),[S,j]=y.useState(!1),[T,N]=y.useState(!1),[C,D]=y.useState(void 0),A=SI({events:t,formatForClipboard:W1}),E=y.useMemo(()=>t.filter(ul).length,[t]),R=y.useMemo(()=>c?c.filter(ce=>II.has(ce.status)&&ce.id!==d):[],[c,d]),B=y.useMemo(()=>b?[...t].reverse():t,[t,b]),{isAtAnchor:M,scrollToAnchor:$}=yI({scrollRef:v,contentLength:t.length,isReversed:b,paused:A.isSelecting}),Y=()=>{const ce=!b;_(ce);try{localStorage.setItem(X1,ce?"reversed":"default")}catch{}};y.useEffect(()=>{if(!A.isSelecting)return;const ce=me=>{me.key==="Escape"&&!S&&!T&&A.cancelSelection()};return window.addEventListener("keydown",ce),()=>{window.removeEventListener("keydown",ce)}},[A.isSelecting,A.cancelSelection,S,T]);const U=y.useCallback(async()=>{await A.copySelected()&&(r==null||r(`Copied ${A.selectedCount} message${A.selectedCount===1?"":"s"} to clipboard`,"success"))},[A,r]),X=y.useCallback(()=>[...A.selectedIndices].sort((me,xe)=>me-xe).filter(me=>me<t.length).map(me=>t[me]),[A.selectedIndices,t]),te=y.useCallback(ce=>{if(!ce)return"this session";const me=c==null?void 0:c.find(De=>De.id===ce);if(!me)return ce.slice(0,8);const xe=u==null?void 0:u.find(De=>De.id===me.environmentId);return(xe==null?void 0:xe.displayName)??me.environmentId.slice(0,8)},[c,u]),G=y.useCallback(async(ce,me)=>{if(!m)return;const xe=te(ce);try{await m(ce,me);const De=A.selectedCount;r==null||r(`Forwarded ${De} message${De===1?"":"s"} to ${xe}`,"success"),A.cancelSelection()}catch{r==null||r("Failed to forward messages","error")}},[m,te,r,A]),ne=y.useCallback(ce=>{j(!1);const me=X(),xe=te(d),De=xI(xe,me);if(new TextEncoder().encode(De).length>RI){D({sessionId:ce,text:De}),N(!0);return}G(ce,De).catch(()=>{})},[X,te,d,G]),H=y.useCallback(()=>{N(!1),C&&(G(C.sessionId,C.text).catch(()=>{}),D(void 0))},[C,G]),O=y.useCallback(()=>{N(!1),D(void 0)},[]),q=k?0:.2,ge=b?-8:8,se=C?Math.round(new TextEncoder().encode(C.text).length/1024):0;return a.jsxs("div",{className:oa.wrapper,children:[a.jsx("div",{className:oa.toolbar,children:a.jsx(Ei,{text:b?"Showing newest first":"Showing oldest first",children:a.jsx("button",{className:oa.directionToggle,onClick:Y,"aria-label":b?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:b?a.jsx(ky,{size:Pt,"aria-hidden":"true"}):a.jsx(Sy,{size:Pt,"aria-hidden":"true"})})})}),a.jsxs("div",{ref:v,className:`${oa.scrollContainer} ${A.isSelecting?oa.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,a.jsx(LI,{eventsDropped:s}),a.jsx(is,{initial:!1,children:B.map((ce,me)=>{const xe=b?t.length-1-me:me;return a.jsx(Ut.div,{initial:{opacity:0,y:ge},animate:{opacity:1,y:0},transition:{duration:q,ease:"easeOut"},children:a.jsx(z6,{copyText:_I(ce),isContentBearing:ul(ce),isSelecting:A.isSelecting,isSelected:A.selectedIndices.has(xe),checkboxLabel:OI(ce),onSelect:()=>{A.enterSelectionMode(xe)},onToggle:De=>{A.toggleEvent(xe,De)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:a.jsx(SD,{event:ce,toolUseCtx:ce.toolUseCtx,settled:ce.settled,sandboxProxyUrl:g})})},`${ce.sessionId}-${ce.timestamp}-${xe}`)})})]}),a.jsx(is,{children:A.isSelecting&&a.jsx(K6,{selectedCount:A.selectedCount,totalSelectable:E,onSelectAll:A.selectAll,onDeselectAll:A.deselectAll,onCopy:()=>{U().catch(()=>{})},onForward:m!==void 0?()=>{j(!0)}:void 0,forwardDisabled:R.length===0,onCancel:A.cancelSelection})}),a.jsx(hI,{isOpen:S,sessions:R,environments:u??[],personas:p,onSelect:ne,onCancel:()=>{j(!1)}}),a.jsx(bs,{isOpen:T,title:"Send large message?",description:`This will forward a large message (${se} KB). Continue?`,confirmLabel:"Send",onConfirm:H,onCancel:O}),a.jsx(is,{children:!M&&a.jsxs(Ut.button,{className:`${oa.scrollToAnchor} ${b?oa.scrollToAnchorTop:oa.scrollToAnchorBottom}`,onClick:$,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[b?a.jsx(Sy,{size:Pt,"aria-hidden":"true"}):a.jsx(ky,{size:Pt,"aria-hidden":"true"})," ","New events"]})})]})}function gh(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[b,_]=y.useState(""),k=y.useRef(!1),S=d===c,j=y.useCallback(B=>{v(B),_("")},[]),T=y.useCallback(()=>{_("")},[]),N=y.useCallback(()=>{k.current=!1,u==null||u(null),v(""),_("")},[u]),C=y.useCallback(()=>{const B=m?g.trim():g;if(r){const $=r(g);if($){_($);return}}const M=m?s.trim():s;if(B===M){N();return}o(B),N()},[g,s,m,r,o,N]),D=y.useCallback(()=>{k.current=!0,u==null||u(c),v(s),_("")},[c,s,u]),A=y.useCallback(B=>{if(k.current){k.current=!1;return}B.relatedTarget instanceof HTMLElement&&B.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(B=>{B.key==="Escape"?N():B.key==="Enter"&&p&&C()},[N,p,C]),R=(()=>{if(!S)return!1;const B=m?s.trim():s;return(m?g.trim():g)!==B})();return y.useEffect(()=>{!S&&(g!==""||b!=="")&&(v(""),_(""))},[S,g,b]),{isEditing:S,draft:g,error:b,isDirty:R,startEdit:D,cancelEdit:N,save:C,setDraft:j,clearError:T,handleBlur:A,handleKeyDown:E,ignoreInitialBlurRef:k}}const zI="_editFieldWrapper_yuzty_1",$I="_editInput_yuzty_10",HI="_editTextarea_yuzty_42",PI="_editSelect_yuzty_78",UI="_editError_yuzty_111",VI="_editInputInvalid_yuzty_118",qI="_editHint_yuzty_123",GI="_unsavedDot_yuzty_132",FI="_metaValueClickable_yuzty_140",KI="_editButton_yuzty_159",ZI="_metaPlaceholder_yuzty_175",YI="_worktreeToggle_yuzty_180",it={editFieldWrapper:zI,editInput:$I,editTextarea:HI,editSelect:PI,editError:UI,editInputInvalid:VI,editHint:qI,unsavedDot:GI,metaValueClickable:FI,editButton:KI,metaPlaceholder:ZI,worktreeToggle:YI};function $t(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:b,ariaLabel:_,"data-testid":k}=t,S=y.useRef(null),j=gh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(j.isEditing){const N=window.setTimeout(()=>{var C;(C=S.current)==null||C.focus()},0);return()=>window.clearTimeout(N)}},[j.isEditing]),c==="create"){const N=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("input",{className:`${it.editInput} ${C?it.editInputInvalid:""}`,value:s,onChange:N,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),C&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("input",{ref:S,className:`${it.editInput} ${j.error?it.editInputInvalid:""}`,value:j.draft,onChange:N=>j.setDraft(N.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),j.isDirty&&a.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),j.error&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:j.error}),a.jsx("span",{className:it.editHint,children:"Enter to save · Esc to cancel"})]});const T=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":_,"data-testid":k?`${k}-button`:void 0,children:[T!==void 0?T:s?a.jsx("span",{children:s}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function fm(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=t,k=y.useRef(null),S=gh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(S.isEditing){const T=window.setTimeout(()=>{var N;(N=k.current)==null||N.focus()},0);return()=>window.clearTimeout(T)}},[S.isEditing]),c==="create"){const T=C=>{m==null||m(C.target.value)},N=r==null?void 0:r(s);return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("textarea",{className:`${it.editTextarea} ${N?it.editInputInvalid:""}`,value:s,onChange:T,placeholder:v,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),N&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:N})]})}if(S.isEditing)return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("textarea",{ref:k,className:`${it.editTextarea} ${S.error?it.editInputInvalid:""}`,value:S.draft,onChange:T=>S.setDraft(T.target.value),onBlur:S.handleBlur,onKeyDown:S.handleKeyDown,title:b,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),S.isDirty&&a.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),S.error&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:S.error}),a.jsx("span",{className:it.editHint,children:"Tab to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>S.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),S.startEdit())},title:"Click to edit","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[j!==void 0?j:s?a.jsx("span",{children:s}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function bd(t){var D;const{value:s,onSave:o,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=t,k=y.useRef(null),S=gh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(S.isEditing){const A=window.setTimeout(()=>{var E;(E=k.current)==null||E.focus()},0);return()=>window.clearTimeout(A)}},[S.isEditing]);const j=y.useCallback(A=>{const E=A.target.value;S.ignoreInitialBlurRef.current=!1,E!==s&&o(E),S.cancelEdit()},[s,o,S]),T=y.useCallback(A=>{if(S.ignoreInitialBlurRef.current){S.ignoreInitialBlurRef.current=!1;return}A.relatedTarget instanceof HTMLElement&&A.relatedTarget.dataset.editAction===d||S.cancelEdit()},[d,S]);if(r==="create")return a.jsx("select",{className:it.editSelect,value:s,onChange:A=>m==null?void 0:m(A.target.value),"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(A=>a.jsx("option",{value:A.value,children:A.label},A.value))});if(S.isEditing)return a.jsx("select",{ref:k,className:it.editSelect,value:S.draft,onChange:j,onBlur:T,title:b,"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(A=>a.jsx("option",{value:A.value,children:A.label},A.value))});const N=g==null?void 0:g(s),C=(D=c.find(A=>A.value===s))==null?void 0:D.label;return a.jsxs("button",{type:"button",className:it.metaValueClickable,onClick:()=>S.startEdit(),title:"Click to change","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[N!==void 0?N:C?a.jsx("span",{children:C}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function JI(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return a.jsxs("label",{className:it.worktreeToggle,"data-testid":d,children:[a.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),a.jsx("span",{children:r})]})}const WI="_nav_1snmp_1",XI="_searchForm_1snmp_8",QI="_searchInput_1snmp_15",e5="_searchButton_1snmp_33",t5="_clearButton_1snmp_68",n5="_workspaceSelect_1snmp_85",s5="_listHeader_1snmp_99",a5="_nodeList_1snmp_108",i5="_nodeItem_1snmp_116",o5="_indicator_1snmp_129",r5="_label_1snmp_136",l5="_badge_1snmp_145",Qn={nav:WI,searchForm:XI,searchInput:QI,searchButton:e5,clearButton:t5,workspaceSelect:n5,listHeader:s5,nodeList:a5,nodeItem:i5,indicator:o5,label:r5,badge:l5};function c5({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(S=>{S.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=y.useCallback(()=>{g(""),d()},[d]),_=y.useCallback(S=>{u(S)},[u]),k=y.useCallback(S=>{g(""),p(S)},[p]);return a.jsxs("div",{className:Qn.nav,"data-testid":"knowledge-nav",children:[a.jsxs("form",{className:Qn.searchForm,onSubmit:v,children:[a.jsx("input",{className:Qn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:S=>{g(S.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),a.jsx("button",{type:"submit",className:Qn.searchButton,disabled:o,children:"Go"})]}),r&&a.jsx("button",{type:"button",className:Qn.clearButton,onClick:b,children:"Clear search"}),a.jsxs("select",{className:Qn.workspaceSelect,onChange:S=>{k(S.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[a.jsx("option",{value:"",children:"All workspaces"}),s.map(S=>a.jsx("option",{value:S.id,children:S.name},S.id))]}),a.jsxs("div",{className:Qn.listHeader,children:["Nodes (",t.length,")"]}),a.jsx("ul",{className:Qn.nodeList,children:t.map(S=>a.jsxs("li",{className:Qn.nodeItem,onClick:()=>{_(S.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),_(S.id))},role:"button",tabIndex:0,children:[a.jsx("span",{className:Qn.indicator,style:{backgroundColor:S.kind==="reference"?"#4A9EFF":S.category==="decision"?"#22C55E":S.category==="concept"?"#A855F7":S.category==="snippet"?"#6B7280":"#EAB308"}}),a.jsx("span",{className:Qn.label,children:S.label}),a.jsx("span",{className:Qn.badge,children:S.kind==="reference"?S.sourceType:S.category})]},S.id))})]})}const d5="_container_bwu10_1",u5="_hamburger_bwu10_33",f5="_brand_bwu10_49",p5="_brandLogo_bwu10_68",m5="_info_bwu10_75",h5="_connectionLabel_bwu10_90",g5="_connectionDot_bwu10_103",v5="_connected_bwu10_106",y5="_disconnected_bwu10_110",b5="_connecting_bwu10_113",Ds={container:d5,hamburger:u5,brand:f5,brandLogo:p5,info:m5,connectionLabel:h5,connectionDot:g5,connected:v5,disconnected:y5,connecting:b5},_5={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},x5={connected:Ds.connected,connecting:Ds.connecting,disconnected:Ds.disconnected};function k5({connectionStatus:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=xt(),u=s.length,p=s.filter(v=>v.status==="connected").length,m=o.filter(v=>["running","idle"].includes(v.status)).length,g=_5[t];return a.jsxs("div",{className:Ds.container,children:[r&&a.jsx("button",{type:"button",className:Ds.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:a.jsx(CT,{size:At,"aria-hidden":"true"})}),a.jsx(Ei,{text:"Home",placement:"bottom",children:a.jsxs("button",{type:"button",className:Ds.brand,onClick:()=>d(Fo),"data-testid":"statusbar-brand",children:[a.jsx("img",{src:Id("icon-192x192.png"),alt:"",className:Ds.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),a.jsxs("div",{className:Ds.info,children:[a.jsxs("span",{"aria-label":g,children:[a.jsx("span",{className:`${Ds.connectionDot} ${x5[t]}`,"aria-hidden":"true",children:a.jsx(wi,{size:F_,fill:"currentColor"})})," ",a.jsx("span",{className:Ds.connectionLabel,"aria-hidden":"true",children:g})]}),a.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),a.jsxs("span",{children:[m," active"]})]})]})}const S5="_nav_gx5h3_1",j5="_tab_gx5h3_35",T5="_tabIcon_gx5h3_68",N5="_tabLabel_gx5h3_79",w5="_tabActive_gx5h3_84",C5="_tabEnd_gx5h3_90",wo={nav:S5,tab:j5,tabIcon:T5,tabLabel:N5,tabActive:w5,tabEnd:C5},ad=[{view:"dashboard",label:"Dashboard",icon:a.jsx(hT,{size:At}),route:Fo,testId:"sidebar-tab-dashboard",order:0},{view:"tasks",label:"Tasks",icon:a.jsx(Zj,{size:At}),route:dC,testId:"sidebar-tab-tasks",order:1},{view:"environments",label:"Environments",icon:a.jsx(IT,{size:At}),route:zo,testId:"sidebar-tab-environments",order:2},{view:"chat",label:"Root",icon:a.jsx(AT,{size:At}),route:cC,testId:"sidebar-tab-chat",order:3},{view:"knowledge",label:"Knowledge",icon:a.jsx(Hj,{size:At}),route:gx,testId:"sidebar-tab-knowledge",order:5},{view:"coordination",label:"Coordination",icon:a.jsx(BT,{size:At}),route:mx,testId:"sidebar-tab-coordination",order:6},{view:"settings",label:"Settings",icon:a.jsx(YT,{size:At}),route:aC,testId:"sidebar-tab-settings",align:"end"}];function E5(t){return t===Fo||t==="/"?"dashboard":t.startsWith(mx)?"coordination":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(gx)?"knowledge":t.startsWith(Ti)?"settings":"tasks"}function A5({tabs:t=ad}){var g;const s=Wt(),o=xt(),r=y.useRef(null),c=E5(s.pathname),d=y.useMemo(()=>{const v=(b,_)=>(b.order??Number.MAX_SAFE_INTEGER)-(_.order??Number.MAX_SAFE_INTEGER);return[...t.filter(b=>b.align!=="end").sort(v),...t.filter(b=>b.align==="end")]},[t]),u=(g=d.find(v=>v.align==="end"))==null?void 0:g.view,p=y.useCallback(v=>{o(v.route)},[o]),m=y.useCallback(v=>{var j,T;const b=(j=r.current)==null?void 0:j.querySelectorAll('[role="tab"]');if(!b)return;const _=Array.from(b).findIndex(N=>N===document.activeElement),k=_>=0?_:d.findIndex(N=>N.view===c);let S=k;if(v.key==="ArrowRight"||v.key==="j"||v.key==="J")v.preventDefault(),S=(k+1)%d.length;else if(v.key==="ArrowLeft"||v.key==="k"||v.key==="K")v.preventDefault(),S=(k-1+d.length)%d.length;else if(v.key==="Home")v.preventDefault(),S=0;else if(v.key==="End")v.preventDefault(),S=d.length-1;else return;o(d[S].route),(T=b[S])==null||T.focus()},[c,o,d]);return a.jsx("nav",{className:wo.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:m,"data-testid":"sidebar-nav",children:d.map(v=>{const b=v.view===c,_=v.view===u;return a.jsx(Ei,{text:v.label,placement:"bottom",className:_?wo.tabEnd:void 0,children:a.jsxs("button",{role:"tab",type:"button","aria-selected":b,tabIndex:b?0:-1,className:`${wo.tab} ${b?wo.tabActive:""}`,onClick:()=>p(v),"data-testid":v.testId,"aria-label":v.label,children:[a.jsx("span",{className:wo.tabIcon,"aria-hidden":"true",children:v.icon}),a.jsx("span",{className:wo.tabLabel,children:v.label})]})},v.view)})})}const D5="_container_pi6ii_1",M5="_content_pi6ii_66",s_={container:D5,content:M5},R5=320,Q1=220,ek=600,tk="grackle-sidebar-width";function I5(){try{const t=localStorage.getItem(tk);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=Q1&&s<=ek)return s}}catch{}return R5}function O5(t){try{localStorage.setItem(tk,String(t))}catch{}}function B5({content:t}){const[s]=y.useState(I5),o=y.useRef(null);if(y.useEffect(()=>{const r=o.current;if(!r)return;const c=new ResizeObserver(d=>{for(const u of d){const p=u.borderBoxSize[0];if(p){const m=Math.round(p.inlineSize);m>=Q1&&m<=ek&&O5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return a.jsx("div",{className:s_.container,ref:o,"data-testid":"sidebar",style:{width:s},children:a.jsx("div",{className:s_.content,children:t})})}const L5="_bar_tnfsh_1",z5="_btnPrimary_tnfsh_32",$5="_statusText_tnfsh_85",H5="_statusCompleted_tnfsh_90",P5="_statusFailed_tnfsh_94",U5="_statusBlocked_tnfsh_98",V5="_hintText_tnfsh_103",Et={bar:L5,btnPrimary:z5,statusText:$5,statusCompleted:H5,statusFailed:P5,statusBlocked:U5,hintText:V5};function q5({sessions:t,tasks:s,environments:o}){const r=xt(),c=Wt(),d=sn("/sessions/:sessionId"),u=sn("/tasks/:taskId"),p=sn("/tasks/:taskId/stream"),m=sn("/tasks/:taskId/edit"),g=sn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),v=sn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),b=sn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),_=sn("/sessions/new"),k=sn("/environments/:environmentId/workspaces/:workspaceId"),S=sn("/tasks/new"),j=sn("/chat"),T=sn("/"),N=sn("/settings/*"),C=d==null?void 0:d.params.sessionId,D=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(g==null?void 0:g.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId),A=g??v??b,E=(A==null?void 0:A.params.environmentId)??(k==null?void 0:k.params.environmentId),R=c.pathname.startsWith("/environments")&&!k&&!A,B=!!j,M=!!_,$=!!k&&!g&&!v&&!b,Y=!!S;if(!!T&&!M&&!$&&!Y||!!N||(!!m||!!b)||Y||R||M)return a.jsx(a.Fragment,{});if(B)return o.find(ne=>ne.adapterType==="local"&&ne.status==="connected")?a.jsx(a.Fragment,{}):a.jsx("div",{className:Et.bar,children:a.jsx("span",{className:Et.hintText,children:"Add a local environment to start chatting"})});if($)return a.jsx("div",{className:Et.bar,children:a.jsx("span",{className:Et.hintText,children:"Select a task or click + to create one"})});if(D){const G=s.find(O=>O.id===D);if(!G)return a.jsx("div",{className:Et.bar,children:a.jsx("span",{className:Et.hintText,children:"Loading..."})});const ne=new Map(s.map(O=>[O.id,O])),H=G.dependsOn.some(O=>{const q=ne.get(O);return q!==void 0&&q.status!=="complete"});if(G.status==="not_started"){const O=H?G.dependsOn.map(q=>ne.get(q)).filter(q=>q&&q.status!=="complete").map(q=>q.title):[];return a.jsx("div",{className:Et.bar,children:H?a.jsxs("span",{className:Et.statusBlocked,children:["Blocked by: ",O.join(", ")]}):a.jsx("span",{className:Et.hintText,children:"Use the buttons above to start or manage this task"})})}if(G.status==="working"||G.status==="paused"){const O=G.latestSessionId||void 0,q=O?t.find(se=>se.id===O):void 0;return q&&q.status!=="stopped"?a.jsx(a.Fragment,{}):a.jsx("div",{className:Et.bar,children:a.jsx("span",{className:Et.hintText,children:"Waiting for agent..."})})}if(G.status==="complete")return a.jsxs("div",{className:Et.bar,children:[a.jsx("span",{className:`${Et.statusText} ${Et.statusCompleted}`,children:"Task completed"}),a.jsx("button",{onClick:()=>r(Ii(G.workspaceId,void 0,E)),className:Et.btnPrimary,children:"+ New Task"})]});if(G.status==="failed")return a.jsx("div",{className:Et.bar,children:a.jsx("span",{className:`${Et.statusText} ${Et.statusFailed}`,children:"Task failed"})})}if(C){const G=t.find(O=>O.id===C),ne=(G==null?void 0:G.status)==="stopped";if(G!==void 0&&!ne)return a.jsx(a.Fragment,{});if(ne)return a.jsxs("div",{className:Et.bar,children:[a.jsxs("span",{className:`${Et.statusText} ${Et.hintText}`,children:["Session ",G.endReason||G.status]}),a.jsx("button",{onClick:()=>r(ux(G.environmentId)),className:Et.btnPrimary,children:"+ New Chat"})]})}return a.jsx("div",{className:Et.bar,children:a.jsx("span",{className:Et.hintText,children:"Loading..."})})}const G5="_nav_14i94_1",F5="_tab_14i94_24",K5="_tabActive_14i94_62",Z5="_tabLabel_14i94_75",Y5="_statusDot_14i94_81",J5="_pulse_14i94_87",W5="_addButton_14i94_99",X5="_empty_14i94_132",Va={nav:G5,tab:F5,tabActive:K5,tabLabel:Z5,statusDot:Y5,pulse:J5,addButton:W5,empty:X5},Q5={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function eO({environments:t}){const s=xt(),o=y.useRef(null),r=sn("/environments/:environmentId"),c=sn("/environments/:environmentId/edit"),d=sn("/environments/:environmentId/workspaces/:workspaceId"),u=sn("/environments/:environmentId/workspaces/:workspaceId/*"),p=(r==null?void 0:r.params.environmentId)??(c==null?void 0:c.params.environmentId)??(d==null?void 0:d.params.environmentId)??(u==null?void 0:u.params.environmentId),m=p==="new"?void 0:p,g=y.useCallback(_=>{s($o(_))},[s]),v=y.useCallback(_=>{var N;const k=(N=o.current)==null?void 0:N.querySelectorAll('[role="tab"]');if(!k||k.length===0)return;const S=Array.from(k).findIndex(C=>C===document.activeElement),j=S>=0?S:t.findIndex(C=>C.id===m);let T=j;if(_.key==="ArrowDown"||_.key==="j"||_.key==="J")_.preventDefault(),T=(j+1)%k.length;else if(_.key==="ArrowUp"||_.key==="k"||_.key==="K")_.preventDefault(),T=(j-1+k.length)%k.length;else if(_.key==="Home")_.preventDefault(),T=0;else if(_.key==="End")_.preventDefault(),T=k.length-1;else return;T<t.length&&s($o(t[T].id)),k[T].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return a.jsxs("div",{className:Va.nav,"data-testid":"environment-nav",children:[a.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(_=>{const k=_.id===m,S=_.id===b,j=Q5[_.status]||"var(--text-tertiary)",T=_.status==="connected";return a.jsxs("button",{role:"tab",type:"button","aria-selected":k,tabIndex:S?0:-1,className:`${Va.tab} ${k?Va.tabActive:""}`,onClick:()=>g(_.id),"data-testid":"env-nav-item",children:[a.jsx("span",{className:`${Va.statusDot} ${T?Va.pulse:""}`,style:{color:j},"aria-hidden":"true",children:a.jsx(wi,{size:F_,fill:"currentColor"})}),a.jsx("span",{className:Va.tabLabel,title:_.displayName||_.id,children:_.displayName||_.id})]},_.id)})}),a.jsx("button",{type:"button",className:Va.addButton,onClick:()=>s(nC),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&a.jsx("div",{className:Va.empty,children:"No environments yet."})]})}function tO(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 nk({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return a.jsx(a.Fragment,{children:t});const r=tO(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(a.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(a.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(a.jsx("span",{children:t.slice(d)},`p${d}`)),a.jsx(a.Fragment,{children:c})}function nO(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 sO(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 oN){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Ja(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=Ja(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const aO="_container_z4i38_1",iO="_header_z4i38_5",oO="_headerActions_z4i38_17",rO="_searchInput_z4i38_23",lO="_searchHighlight_z4i38_56",cO="_groupToggle_z4i38_62",dO="_groupToggleActive_z4i38_89",uO="_addButton_z4i38_93",fO="_taskRow_z4i38_120",pO="_selected_z4i38_140",mO="_expandArrow_z4i38_150",hO="_expanded_z4i38_157",gO="_leafSpacer_z4i38_161",vO="_taskStatusIcon_z4i38_166",yO="_taskTitle_z4i38_170",bO="_workspaceBadge_z4i38_177",_O="_childCountBadge_z4i38_195",xO="_dependencyBadge_z4i38_208",kO="_blockedBadge_z4i38_220",SO="_addChildButton_z4i38_225",jO="_emptyState_z4i38_268",TO="_statusGroupHeader_z4i38_275",NO="_statusGroupIcon_z4i38_294",wO="_statusGroupLabel_z4i38_298",CO="_statusGroupCount_z4i38_303",We={container:aO,header:iO,headerActions:oO,searchInput:rO,searchHighlight:lO,groupToggle:cO,groupToggleActive:dO,addButton:uO,taskRow:fO,selected:pO,expandArrow:mO,expanded:hO,leafSpacer:gO,taskStatusIcon:vO,taskTitle:yO,workspaceBadge:bO,childCountBadge:_O,dependencyBadge:xO,blockedBadge:kO,addChildButton:SO,emptyState:jO,statusGroupHeader:TO,statusGroupIcon:NO,statusGroupLabel:wO,statusGroupCount:CO},EO=[{name:"title",weight:2},{name:"description",weight:1}],sk=16,AO=16,ak="grackle-task-group-by-status";function a_(){try{return localStorage.getItem(ak)==="true"}catch{return!1}}function DO(t){try{localStorage.setItem(ak,String(t))}catch{}}function MO({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return a.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[a.jsxs("div",{className:We.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[a.jsx("span",{className:`${We.expandArrow} ${s?We.expanded:""}`,"aria-hidden":"true",children:a.jsx(fa,{size:Ye})}),a.jsx("span",{className:We.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),a.jsx("span",{className:We.statusGroupLabel,children:t.label}),a.jsx("span",{className:We.statusGroupCount,children:t.tasks.length})]}),a.jsx(is,{children:s&&a.jsx(Ut.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=Ja(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return a.jsxs("div",{onClick:()=>c(rs(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(rs(p.id)))},className:`${We.taskRow} ${g?We.selected:""}`,style:{"--task-indent":`${sk}px`},"data-task-id":p.id,children:[a.jsx("span",{className:We.leafSpacer}),a.jsx("span",{className:We.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${fl(p.status)}`,children:m.icon}),a.jsx("span",{className:We.taskTitle,title:p.title,children:a.jsx(nk,{text:p.title,indices:d.get(p.id),highlightClass:We.searchHighlight})}),v&&a.jsx("span",{className:We.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function ik({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=Ja(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(N=>u.get(N)!=="complete"),b=o.has(t.id),_=t.children.length>0,k=c===t.id,S=sk+s*AO,T=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{onClick:()=>d(rs(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:N=>{N.currentTarget===N.target&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),d(rs(t.id)))},className:`${We.taskRow} ${k?We.selected:""}`,style:{"--task-indent":`${S}px`},"data-task-id":t.id,children:[_&&a.jsx("span",{className:`${We.expandArrow} ${b?We.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:N=>{N.stopPropagation(),r(t.id)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),N.stopPropagation(),r(t.id))},children:a.jsx(fa,{size:Ye,"aria-hidden":"true"})}),!_&&a.jsx("span",{className:We.leafSpacer}),a.jsx("span",{className:We.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${fl(t.status)}`,children:g.icon}),a.jsx("span",{className:We.taskTitle,title:t.title,children:a.jsx(nk,{text:t.title,indices:p.get(t.id),highlightClass:We.searchHighlight})}),T&&a.jsx("span",{className:We.workspaceBadge,title:T,children:T}),_&&a.jsxs("span",{className:We.childCountBadge,children:[t.children.filter(N=>N.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&a.jsx("span",{className:`${We.dependencyBadge} ${v?We.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<X2&&a.jsx(Ei,{text:"Add child task",children:a.jsx("button",{onClick:N=>{N.stopPropagation(),d(Ii(t.workspaceId,t.id))},"aria-label":"Add child task",className:We.addChildButton,children:"+"})})]}),a.jsx(is,{children:_&&b&&a.jsx(Ut.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(N=>a.jsx(ik,{node:N,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},N.id))})})]})}function RO({workspaces:t,tasks:s}){const o=xt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(a_),[g,v]=y.useState(a_),[b,_]=y.useState(new Map),k=sn("/tasks/:taskId/*"),S=(k==null?void 0:k.params.taskId)!=="new"?k==null?void 0:k.params.taskId:void 0,j=y.useMemo(()=>new Map(s.map(G=>[G.id,G.status])),[s]),T=y.useMemo(()=>new Map(t.map(G=>[G.id,G.name])),[t]),N=()=>{const G=!p;DO(G),m(G),G&&(v(!0),_(new Map))},C=G=>{_(ne=>{const H=new Map(ne),O=H.has(G)?H.get(G):g;return H.set(G,!O),H})},D=G=>b.has(G)?b.get(G):g,A=G=>{c(ne=>{const H=new Set(ne);return H.has(G)?(H.delete(G),u(O=>new Set(O).add(G))):(H.add(G),u(O=>{const q=new Set(O);return q.delete(G),q})),H})};y.useEffect(()=>{const G=new Set(s.filter(ne=>ne.parentTaskId).map(ne=>ne.parentTaskId));G.size>0&&c(ne=>{const H=new Set(ne);for(const O of G)d.has(O)||H.add(O);return H})},[s,d]);const[E,R]=y.useState(""),{directMatchTaskIds:B,treeMatchTaskIds:M,titleHighlights:$}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const G=W2(s,E,EO),ne=new Set(G.map(ge=>ge.item.id)),H=new Map;for(const ge of G){const se=ge.matches.find(ce=>ce.key==="title");se&&H.set(ge.item.id,se.indices)}const O=new Set(ne),q=new Map(s.map(ge=>[ge.id,ge]));for(const ge of[...ne]){let se=q.get(ge);for(;se!=null&&se.parentTaskId;)O.add(se.parentTaskId),se=q.get(se.parentTaskId)}return{directMatchTaskIds:ne,treeMatchTaskIds:O,titleHighlights:H}},[E,s]),Y=B!==null,U=Y?p?B:M:null,X=U?s.filter(G=>U.has(G.id)):s,te=p?[]:nO(X);return a.jsxs("div",{className:We.container,children:[a.jsxs("div",{className:We.header,children:[a.jsx("span",{children:"Tasks"}),a.jsxs("div",{className:We.headerActions,children:[a.jsx(Ei,{text:p?"Switch to tree view":"Group tasks by status",children:a.jsx("button",{className:`${We.groupToggle} ${p?We.groupToggleActive:""}`,onClick:N,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:a.jsx(jT,{size:Pt})})}),a.jsx(Ei,{text:"New task",children:a.jsx("button",{className:We.addButton,onClick:()=>o(Ii()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&a.jsx("input",{type:"text",value:E,onChange:G=>R(G.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:We.searchInput,"data-testid":"sidebar-search"}),p?sO(X,j).map(G=>a.jsx(MO,{group:G,isExpanded:D(G.status),onToggle:()=>C(G.status),selectedTaskId:S,navigate:o,titleHighlights:$,workspaceNames:T},G.status)):te.map(G=>a.jsx(ik,{node:G,depth:0,expandedTasks:r,toggleTask:A,selectedTaskId:S,navigate:o,taskStatusById:j,titleHighlights:$,workspaceNames:T},G.id)),X.length===0&&!Y&&a.jsx("div",{className:We.emptyState,children:"No tasks yet. Click + to create one."}),X.length===0&&Y&&a.jsx("div",{className:We.emptyState,children:"No matching tasks"})]})}const IO="_toast_ed2dk_1",OO="_success_ed2dk_18",BO="_icon_ed2dk_22",LO="_error_ed2dk_25",zO="_warning_ed2dk_32",$O="_info_ed2dk_38",HO="_message_ed2dk_53",PO="_close_ed2dk_60",qr={toast:IO,success:OO,icon:BO,error:LO,warning:zO,info:$O,message:HO,close:PO},UO={success:a.jsx(Di,{size:At}),error:a.jsx(Ls,{size:At}),warning:a.jsx(jm,{size:At}),info:a.jsx(Sm,{size:At})};function VO({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),a.jsxs(Ut.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:[a.jsx("span",{className:qr.icon,"aria-hidden":"true",children:UO[t.variant]}),a.jsx("span",{className:qr.message,children:t.message}),a.jsx("button",{type:"button",className:qr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:a.jsx(Ls,{size:Pt,"aria-hidden":"true"})})]})}const qO="_container_qqse2_1",GO={container:qO};function FO({toasts:t,onDismiss:s}){return a.jsx("div",{className:GO.container,"data-testid":"toast-container",children:a.jsx(is,{children:t.map(o=>a.jsx(VO,{toast:o,onDismiss:s},o.id))})})}const KO="_callout_e5awm_1",ZO="_success_e5awm_11",YO="_icon_e5awm_15",JO="_error_e5awm_18",WO="_warning_e5awm_25",XO="_info_e5awm_32",QO="_content_e5awm_48",eB="_close_e5awm_53",Gr={callout:KO,success:ZO,icon:YO,error:JO,warning:WO,info:XO,content:QO,close:eB},tB={success:a.jsx(Di,{size:At}),error:a.jsx(Ls,{size:At}),warning:a.jsx(jm,{size:At}),info:a.jsx(Sm,{size:At})};function nB({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return a.jsx(a.Fragment,{children:!c&&a.jsxs("div",{className:[Gr.callout,Gr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[a.jsx("span",{className:Gr.icon,"aria-hidden":"true",children:tB[t]}),a.jsx("span",{className:Gr.content,children:s}),o&&a.jsx("button",{type:"button",className:Gr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:a.jsx(Ls,{size:Pt,"aria-hidden":"true"})})]})})}function sB({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return a.jsx(a.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return a.jsx("div",{"data-testid":"update-banner",children:a.jsxs(nB,{variant:"info",dismissible:!0,children:[a.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,"). Run:"," ",a.jsx("code",{children:c})]})})}const aB="_container_m1fsr_1",iB="_heading_m1fsr_7",oB="_section_m1fsr_14",rB="_sectionTitle_m1fsr_26",lB="_sectionDescription_m1fsr_35",cB="_emptyState_m1fsr_41",dB="_tokenList_m1fsr_48",uB="_tokenRow_m1fsr_55",fB="_tokenBadge_m1fsr_68",pB="_tokenName_m1fsr_83",mB="_tokenTarget_m1fsr_90",hB="_deleteButton_m1fsr_99",gB="_addForm_m1fsr_113",vB="_formRow_m1fsr_119",yB="_input_m1fsr_125",bB="_select_m1fsr_155",_B="_addButton_m1fsr_187",xB="_emptyStateInfo_m1fsr_221",kB="_themeOptions_m1fsr_229",SB="_themeOption_m1fsr_229",jB="_themeOptionSelected_m1fsr_254",TB="_themeOptionHeader_m1fsr_259",NB="_themeOptionLabel_m1fsr_266",wB="_themeOptionDesc_m1fsr_273",CB="_variantToggle_m1fsr_279",EB="_variantButton_m1fsr_286",AB="_variantActive_m1fsr_305",DB="_themeSwatches_m1fsr_311",MB="_themeSwatch_m1fsr_311",RB="_systemToggle_m1fsr_325",IB="_systemToggleHint_m1fsr_341",OB="_themeActive_m1fsr_348",BB="_aboutGrid_m1fsr_354",LB="_aboutItem_m1fsr_360",zB="_aboutLabel_m1fsr_373",$B="_aboutValue_m1fsr_379",HB="_aboutDot_m1fsr_387",PB="_aboutDotConnected_m1fsr_394",UB="_aboutDotDisconnected_m1fsr_398",VB="_aboutDotConnecting_m1fsr_402",fe={container:aB,heading:iB,section:oB,sectionTitle:rB,sectionDescription:lB,emptyState:cB,tokenList:dB,tokenRow:uB,tokenBadge:fB,tokenName:pB,tokenTarget:mB,deleteButton:hB,addForm:gB,formRow:vB,input:yB,select:bB,addButton:_B,emptyStateInfo:xB,themeOptions:kB,themeOption:SB,themeOptionSelected:jB,themeOptionHeader:TB,themeOptionLabel:NB,themeOptionDesc:wB,variantToggle:CB,variantButton:EB,variantActive:AB,themeSwatches:DB,themeSwatch:MB,systemToggle:RB,systemToggleHint:IB,themeActive:OB,aboutGrid:BB,aboutItem:LB,aboutLabel:zB,aboutValue:$B,aboutDot:HB,aboutDotConnected:PB,aboutDotDisconnected:UB,aboutDotConnecting:VB},qB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function GB({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,b]=y.useState(""),[_,k]=y.useState(null),S=N=>{if(N.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),b("")},j=N=>{k(N)},T=()=>{_&&(o(_),r==null||r("Token deleted","info")),k(null)};return a.jsxs(a.Fragment,{children:[a.jsx(bs,{isOpen:_!==null,title:"Delete Token?",description:_?`"${_}" will be permanently removed.`:void 0,onConfirm:T,onCancel:()=>k(null)}),a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Tokens"}),a.jsx("p",{className:fe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?a.jsx("div",{className:fe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):a.jsx("div",{className:fe.tokenList,children:t.map(N=>a.jsxs("div",{className:fe.tokenRow,children:[a.jsx("span",{className:fe.tokenBadge,children:N.tokenType}),a.jsx("span",{className:fe.tokenName,children:N.name}),a.jsx("span",{className:fe.tokenTarget,children:N.tokenType==="env_var"?N.envVar:N.filePath}),a.jsx("button",{className:fe.deleteButton,onClick:()=>j(N.name),title:`Delete ${N.name}`,"aria-label":`Delete ${N.name}`,children:a.jsx(Ls,{size:Pt,"aria-hidden":"true"})})]},N.name))}),a.jsxs("form",{className:fe.addForm,onSubmit:S,children:[a.jsxs("div",{className:fe.formRow,children:[a.jsx("input",{className:fe.input,type:"text",placeholder:"Token name",value:c,onChange:N=>d(N.target.value)}),a.jsx("input",{className:fe.input,type:"password",placeholder:"Value",value:u,onChange:N=>p(N.target.value)})]}),a.jsxs("div",{className:fe.formRow,children:[a.jsx("select",{className:fe.select,value:m,onChange:N=>g(N.target.value),children:qB.map(N=>a.jsx("option",{value:N.value,children:N.label},N.value))}),a.jsx("input",{className:fe.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:N=>b(N.target.value)}),a.jsx("button",{className:fe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Od=[{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"]}],ok=new Set(Od.map(t=>t.id)),i_="grackle";function pm(t){return Od.find(s=>s.id===t)}function FB({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Appearance"}),a.jsx("p",{className:fe.sectionDescription,children:"Choose how Grackle looks across the app."}),a.jsx("div",{className:fe.themeOptions,children:Od.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 a.jsxs("button",{type:"button",className:`${fe.themeOption} ${p?fe.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[a.jsxs("span",{className:fe.themeOptionHeader,children:[a.jsxs("span",{children:[a.jsx("span",{className:fe.themeOptionLabel,children:d.label}),a.jsx("span",{className:fe.themeOptionDesc,children:d.description})]}),u&&a.jsxs("span",{className:fe.variantToggle,children:[a.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),a.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&!m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&a.jsx("span",{className:fe.themeSwatches,children:d.swatches.map((g,v)=>a.jsx("span",{className:fe.themeSwatch,style:{background:g}},v))})]},d.id)})}),a.jsxs("label",{className:fe.systemToggle,children:[a.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),a.jsx("span",{children:"Match system light/dark preference"})]}),a.jsx("p",{className:fe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),a.jsxs("p",{className:fe.themeActive,children:["Active theme: ",a.jsx("strong",{children:s})]})]})}const KB={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},ZB={connected:fe.aboutDotConnected,connecting:fe.aboutDotConnecting,disconnected:fe.aboutDotDisconnected};function YB({connectionStatus:t,environments:s,sessions:o}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=o.filter(u=>["running","idle"].includes(u.status)).length;return a.jsxs("section",{className:fe.section,"data-testid":"about-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"About"}),a.jsx("p",{className:fe.sectionDescription,children:"Connection status and application information."}),a.jsxs("div",{className:fe.aboutGrid,children:[a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Connection"}),a.jsxs("span",{className:fe.aboutValue,children:[a.jsx("span",{className:`${fe.aboutDot} ${ZB[t]}`}),KB[t]]})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Environments"}),a.jsxs("span",{className:fe.aboutValue,children:[r,"/",c," connected"]})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Active Sessions"}),a.jsx("span",{className:fe.aboutValue,children:d})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Version"}),a.jsx("span",{className:fe.aboutValue,children:"0.133.0"})]})]})]})}const JB="_container_cddyd_1",WB="_header_cddyd_8",XB="_headerTitle_cddyd_35",QB="_badge_cddyd_44",eL="_headerActions_cddyd_54",tL="_body_cddyd_61",nL="_formContent_cddyd_73",sL="_section_cddyd_85",aL="_label_cddyd_91",iL="_titleInput_cddyd_98",oL="_descriptionTextarea_cddyd_131",rL="_parentContext_cddyd_167",lL="_parentLabel_cddyd_175",cL="_parentName_cddyd_182",dL="_personaSelect_cddyd_186",uL="_depList_cddyd_220",fL="_depItem_cddyd_226",pL="_depItemSelected_cddyd_248",mL="_noDeps_cddyd_252",hL="_btnPrimary_cddyd_258",gL="_btnGhost_cddyd_289",Qe={container:JB,header:WB,headerTitle:XB,badge:QB,headerActions:eL,body:tL,formContent:nL,section:sL,label:aL,titleInput:iL,descriptionTextarea:oL,parentContext:rL,parentLabel:lL,parentName:cL,personaSelect:dL,depList:uL,depItem:fL,depItemSelected:pL,noDeps:mL,btnPrimary:hL,btnGhost:gL};function rk({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:b}){const _=xt(),k=t==="edit",S=k&&s?d.find(ke=>ke.id===s):void 0,j=k?(S==null?void 0:S.workspaceId)??"":o??"",[T,N]=y.useState(j),C=j||T,D=u.find(ke=>ke.id===C),A=c??(D==null?void 0:D.linkedEnvironmentIds[0]),E=!k&&!o,R=k?(S==null?void 0:S.parentTaskId)??"":r??"",B=R?d.find(ke=>ke.id===R):void 0,[M,$]=y.useState((S==null?void 0:S.title)??""),[Y,U]=y.useState((S==null?void 0:S.description)??""),[X,te]=y.useState((S==null?void 0:S.dependsOn)??[]),[G,ne]=y.useState((S==null?void 0:S.defaultPersonaId)??""),[H,O]=y.useState((S==null?void 0:S.canDecompose)??!1),[q,ge]=y.useState((S==null?void 0:S.injectKnowledge)??!0),[se,ce]=y.useState(!1),me=y.useRef(!1);y.useEffect(()=>{k&&S&&!me.current&&(me.current=!0,$(S.title),U(S.description),te(S.dependsOn),ne(S.defaultPersonaId),O(S.canDecompose),ge(S.injectKnowledge))},[k,S]);const xe=d.filter(ke=>ke.workspaceId===C&&(!k||ke.id!==s)&&ke.id!==R),De=M.trim().length>0&&(!k||S!==void 0)&&C.length>0,ot=ke=>{te(ct=>ct.includes(ke)?ct.filter(ue=>ue!==ke):[...ct,ke])},bt=()=>{!De||se||k&&S===void 0||(k&&s?(g(s,M.trim(),Y,X,G),b==null||b("Task updated","success"),v?v():_(rs(s,void 0,C,A),{replace:!0})):(ce(!0),m(C,M.trim(),Y,X.length>0?X:void 0,R||void 0,G,H,q,()=>{b==null||b("Task created","success"),_(o?Ci(o,A):"/tasks",{replace:!0})},ke=>{b==null||b(ke,"error"),ce(!1)})))},lt=()=>{if(v){v();return}_(k&&s?rs(s,void 0,C,A):o?Ci(o,A):"/tasks")},Pe=k?"edit task":R?"child task":"new task";return a.jsxs("div",{className:Qe.container,children:[a.jsxs("div",{className:Qe.header,children:[a.jsxs("div",{className:Qe.headerTitle,children:[a.jsx("span",{className:Qe.badge,children:Pe}),B&&a.jsxs("span",{className:Qe.parentContext,children:[a.jsx("span",{className:Qe.parentLabel,children:"Child of"}),a.jsx("span",{className:Qe.parentName,children:B.title})]})]}),a.jsxs("div",{className:Qe.headerActions,children:[a.jsx("button",{onClick:bt,disabled:!De||se,className:Qe.btnPrimary,"data-testid":"task-edit-save",children:se?"Creating…":k?"Save Changes":"Create"}),a.jsx("button",{onClick:lt,className:Qe.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:Qe.body,children:a.jsxs("div",{className:Qe.formContent,children:[E&&a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-workspace",children:"Workspace"}),a.jsxs("select",{id:"task-edit-workspace",value:T,onChange:ke=>N(ke.target.value),className:Qe.personaSelect,"data-testid":"task-edit-workspace",children:[a.jsx("option",{value:"",children:"Select a workspace..."}),u.map(ke=>a.jsx("option",{value:ke.id,children:ke.name},ke.id))]})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-title",children:"Title"}),a.jsx("input",{id:"task-edit-title",type:"text",value:M,onChange:ke=>$(ke.target.value),placeholder:"Task title...",autoFocus:!0,className:Qe.titleInput,"data-testid":"task-edit-title",onKeyDown:ke=>{ke.key==="Enter"&&De&&bt()}})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-description",children:"Description"}),a.jsx("textarea",{id:"task-edit-description",value:Y,onChange:ke=>U(ke.target.value),placeholder:"Describe the task... (markdown supported)",className:Qe.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-persona",children:"Default Persona"}),a.jsxs("select",{id:"task-edit-persona",value:G,onChange:ke=>ne(ke.target.value),className:Qe.personaSelect,"data-testid":"task-edit-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),p.map(ke=>a.jsx("option",{value:ke.id,children:ke.name},ke.id))]})]}),!k&&a.jsx("div",{className:Qe.section,children:a.jsxs("label",{className:Qe.depItem,"data-testid":"task-edit-can-decompose",children:[a.jsx("input",{type:"checkbox",checked:H,onChange:ke=>O(ke.target.checked)}),"Can spawn subtasks"]})}),!k&&a.jsx("div",{className:Qe.section,children:a.jsxs("label",{className:Qe.depItem,"data-testid":"task-edit-inject-knowledge",children:[a.jsx("input",{type:"checkbox",checked:q,onChange:ke=>ge(ke.target.checked)}),"Inject related prior work from the knowledge graph"]})}),a.jsxs("div",{className:Qe.section,children:[a.jsx("div",{className:Qe.label,children:"Dependencies"}),xe.length===0?a.jsx("div",{className:Qe.noDeps,children:"No other tasks in this workspace"}):a.jsx("div",{className:Qe.depList,children:xe.map(ke=>{const ct=X.includes(ke.id);return a.jsxs("label",{className:`${Qe.depItem} ${ct?Qe.depItemSelected:""}`,"data-testid":`dep-option-${ke.id}`,children:[a.jsx("input",{type:"checkbox",checked:ct,onChange:()=>ot(ke.id)}),ke.title,a.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",ke.status,")"]})]},ke.id)})})]})]})})]})}const vL="_actionButtons_1rjka_1",yL="_btnPrimary_1rjka_8",bL="_btnDanger_1rjka_39",_L="_btnGhost_1rjka_78",Yt={actionButtons:vL,btnPrimary:yL,btnDanger:bL,btnGhost:_L},xL=new Set(["stopped","suspended"]);function kL({task:t,sessionId:s,latestSessionStatus:o,isBlocked:r,onStart:c,onResume:d,onStop:u,onPause:p,onDelete:m,onEdit:g}){if(t.status==="not_started")return r?a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:g,className:Yt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{"data-testid":"task-header-start",onClick:c,className:Yt.btnPrimary,children:"Start"}),a.jsx("button",{onClick:g,className:Yt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:u,className:Yt.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),a.jsx("button",{onClick:p,disabled:!s,className:Yt.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused"){const v=o!==void 0&&xL.has(o);return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:u,className:Yt.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),v&&a.jsx("button",{onClick:d,className:Yt.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}if(t.status==="complete")return a.jsx("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:c,className:Yt.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const SL="_workpadSection_y8nj9_1",jL="_workpadLabel_y8nj9_9",TL="_workpadStatus_y8nj9_17",NL="_workpadSummary_y8nj9_23",wL="_workpadExtra_y8nj9_29",qa={workpadSection:SL,workpadLabel:jL,workpadStatus:TL,workpadSummary:NL,workpadExtra:wL};function CL({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 a.jsxs("div",{className:qa.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:qa.workpadLabel,children:"Workpad"}),a.jsx("div",{className:qa.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return a.jsxs("div",{className:qa.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:qa.workpadLabel,children:"Workpad"}),s.status&&a.jsx("div",{className:qa.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&a.jsx("div",{className:qa.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&a.jsx("div",{className:qa.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const EL="_overviewDashboard_ng7kf_1",AL="_overviewHero_ng7kf_7",DL="_statusBadge_ng7kf_14",ML="_statusPending_ng7kf_26",RL="_statusAssigned_ng7kf_31",IL="_statusInProgress_ng7kf_36",OL="_statusReview_ng7kf_41",BL="_statusDone_ng7kf_46",LL="_statusFailed_ng7kf_51",zL="_statusWaitingInput_ng7kf_56",$L="_overviewBranchPill_ng7kf_61",HL="_branchLink_ng7kf_76",PL="_overviewSection_ng7kf_87",UL="_overviewLabel_ng7kf_93",VL="_overviewValue_ng7kf_100",qL="_overviewMuted_ng7kf_105",GL="_overviewMarkdown_ng7kf_111",FL="_envRow_ng7kf_186",KL="_envDot_ng7kf_192",ZL="_envDotGreen_ng7kf_199",YL="_envDotYellow_ng7kf_203",JL="_envDotRed_ng7kf_207",WL="_envDotGray_ng7kf_211",XL="_depList_ng7kf_215",QL="_depItem_ng7kf_221",e8="_depBlocked_ng7kf_228",t8="_depDone_ng7kf_232",n8="_timeline_ng7kf_236",s8="_timelineRow_ng7kf_242",a8="_timelineKey_ng7kf_249",i8="_timelineValue_ng7kf_255",o8="_timelineDelta_ng7kf_259",r8="_reviewNotes_ng7kf_270",be={overviewDashboard:EL,overviewHero:AL,statusBadge:DL,statusPending:ML,statusAssigned:RL,statusInProgress:IL,statusReview:OL,statusDone:BL,statusFailed:LL,statusWaitingInput:zL,overviewBranchPill:$L,branchLink:HL,overviewSection:PL,overviewLabel:UL,overviewValue:VL,overviewMuted:qL,overviewMarkdown:GL,envRow:FL,envDot:KL,envDotGreen:ZL,envDotYellow:YL,envDotRed:JL,envDotGray:WL,depList:XL,depItem:QL,depBlocked:e8,depDone:t8,timeline:n8,timelineRow:s8,timelineKey:a8,timelineValue:i8,timelineDelta:o8,reviewNotes:r8};function Gc(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 Cp(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 o_(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?be.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?be.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?be.envDotRed:be.envDotGray}function l8({status:t}){const s=Ja(t),o=iN(t);return a.jsx("span",{className:`${be.statusBadge} ${be[o]??be.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function c8({task:t,tasksById:s,environments:o,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?o.find(S=>S.id===g):void 0,b=r.find(S=>S.id===t.workspaceId),_=o.find(S=>S.id===d),k=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return a.jsxs("div",{className:be.overviewDashboard,"data-testid":"task-overview-panel",children:[a.jsxs("div",{className:be.overviewHero,children:[a.jsx(l8,{status:t.status}),t.branch&&a.jsx("span",{className:be.overviewBranchPill,"data-testid":"task-overview-branch",children:k?a.jsxs("a",{href:k,target:"_blank",rel:"noreferrer noopener",className:be.branchLink,children:["🔗"," ",t.branch]}):a.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-description",children:[a.jsx("div",{className:be.overviewLabel,children:"Description"}),a.jsx("div",{className:be.overviewMarkdown,children:a.jsx(xm,{remarkPlugins:[km],children:t.description})})]}),t.workpad&&a.jsx(CL,{workpad:t.workpad}),a.jsxs("div",{className:be.overviewSection,children:[a.jsx("div",{className:be.overviewLabel,children:"Environment"}),g&&v?a.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${be.envDot} ${o_(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),a.jsx("span",{className:be.overviewValue,children:v.displayName})]}):_?a.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${be.envDot} ${o_(_.status)}`,title:_.status,"aria-label":`Status: ${_.status}`,role:"img"}),a.jsx("span",{className:be.overviewValue,children:_.displayName}),a.jsx("span",{className:be.overviewMuted,children:"(workspace default)"})]}):a.jsx("div",{className:be.overviewMuted,children:"Set in workspace settings"})]}),a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-dependencies",children:[a.jsx("div",{className:be.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?a.jsx("div",{className:be.overviewMuted,children:"None"}):a.jsx("div",{className:be.depList,children:t.dependsOn.map(S=>{const j=s.get(S),T=(j==null?void 0:j.status)==="complete";return a.jsxs("div",{className:`${be.depItem} ${T?be.depDone:be.depBlocked}`,children:[a.jsx("span",{children:T?"✓":"○"}),a.jsx("span",{children:(j==null?void 0:j.title)??S})]},S)})})]}),a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-timeline",children:[a.jsx("div",{className:be.overviewLabel,children:"Timeline"}),a.jsxs("div",{className:be.timeline,children:[t.createdAt&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Created"}),a.jsx("span",{className:be.timelineValue,children:Gc(t.createdAt)})]}),t.assignedAt&&(()=>{const S=Cp(t.createdAt,t.assignedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Assigned"}),a.jsx("span",{className:be.timelineValue,children:Gc(t.assignedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.startedAt&&(()=>{const S=Cp(t.assignedAt??t.createdAt,t.startedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Started"}),a.jsx("span",{className:be.timelineValue,children:Gc(t.startedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.completedAt&&(()=>{const S=Cp(t.startedAt,t.completedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Completed"}),a.jsx("span",{className:be.timelineValue,children:Gc(t.completedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&a.jsx("div",{className:be.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-usage",children:[a.jsx("div",{className:be.overviewLabel,children:"Usage"}),a.jsxs("div",{className:be.timeline,children:[a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Cost"}),a.jsx("span",{className:be.timelineValue,children:Ms(u.costMillicents)}),a.jsxs("span",{className:be.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Total (incl. subtasks)"}),a.jsx("span",{className:be.timelineValue,children:Ms(p.costMillicents)}),a.jsxs("span",{className:be.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-budget",children:[a.jsx("div",{className:be.overviewLabel,children:"Budget"}),a.jsxs("div",{className:be.timeline,children:[t.tokenBudget>0&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Tokens"}),a.jsxs("span",{className:be.timelineValue,children:[Ho(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," /"," ",Ho(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Cost"}),a.jsxs("span",{className:be.timelineValue,children:[Ms((u==null?void 0:u.costMillicents)??0)," /"," ",Ms(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-review-notes",children:[a.jsx("div",{className:be.overviewLabel,children:"Review Notes"}),a.jsx("div",{className:be.reviewNotes,children:t.reviewNotes})]})]})}function d8({plugins:t,loading:s,onSetPluginEnabled:o}){return a.jsxs("div",{className:fe.container,"data-testid":"plugins-panel",children:[a.jsx("h2",{className:fe.heading,children:"Plugins"}),a.jsxs("div",{className:fe.section,children:[a.jsx("p",{className:fe.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&a.jsx("p",{className:fe.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&a.jsx("p",{className:fe.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return a.jsxs("div",{className:fe.tokenRow,"data-testid":`plugin-row-${r.name}`,children:[a.jsxs("div",{style:{flex:1},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[a.jsx("span",{className:fe.tokenName,children:r.name}),r.required&&a.jsx("span",{className:fe.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),a.jsx("div",{className:fe.tokenTarget,children:r.description}),c&&a.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"})]}),a.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:a.jsx("input",{type:"checkbox",checked:r.enabled,disabled:r.required,onChange:d=>o(r.name,d.target.checked),"data-testid":`plugin-toggle-${r.name}`,"aria-label":`Enable or disable ${r.name} plugin`,style:{accentColor:"var(--accent-green)",width:"16px",height:"16px"}})})]},r.name)})]})]})}function u8({githubAccounts:t,githubAccountsLoading:s,onAddGitHubAccount:o,onUpdateGitHubAccount:r,onRemoveGitHubAccount:c,onImportGitHubAccounts:d,onShowToast:u}){const[p,m]=y.useState(""),[g,v]=y.useState(""),[b,_]=y.useState(!1),[k,S]=y.useState(!1),[j,T]=y.useState(!1),[N,C]=y.useState(null),D=t.find(M=>M.id===N),A=async M=>{if(M.preventDefault(),!(!p.trim()||!g.trim())){S(!0);try{await o(p.trim(),g.trim(),"",b),u==null||u("GitHub account added","success"),m(""),v(""),_(!1)}catch($){const Y=$ instanceof Error?$.message:"Failed to add account";u==null||u(Y,"error")}finally{S(!1)}}},E=async M=>{try{await r(M,{isDefault:!0}),u==null||u("Default account updated","success")}catch($){const Y=$ instanceof Error?$.message:"Failed to update account";u==null||u(Y,"error")}},R=async()=>{if(N)try{await c(N),u==null||u("GitHub account removed","info")}catch(M){const $=M instanceof Error?M.message:"Failed to remove account";u==null||u($,"error")}finally{C(null)}},B=async()=>{T(!0);try{const M=await d();M.imported>0?u==null||u(`Imported ${M.imported} account(s): ${M.usernames.join(", ")}`,"success"):u==null||u("No new accounts to import","info")}catch(M){const $=M instanceof Error?M.message:"Import failed";u==null||u($,"error")}finally{T(!1)}};return a.jsxs(a.Fragment,{children:[a.jsx(bs,{isOpen:N!==null,title:"Remove GitHub Account?",description:D?`"${D.label}"${D.username?` (@${D.username})`:""} will be permanently removed.`:void 0,onConfirm:()=>{R().catch(()=>{})},onCancel:()=>C(null)}),a.jsxs("section",{className:fe.section,"data-testid":"github-accounts-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"GitHub Accounts"}),a.jsx("p",{className:fe.sectionDescription,children:"Register multiple GitHub accounts to use different identities per environment. The default account is used when no specific account is assigned."}),s&&t.length===0?a.jsx("div",{className:fe.emptyState,children:"Loading..."}):t.length===0?a.jsx("div",{className:fe.emptyStateInfo,children:"No GitHub accounts registered. Add one below or import from the gh CLI."}):a.jsx("div",{className:fe.tokenList,children:t.map(M=>a.jsxs("div",{className:fe.tokenRow,"data-testid":`github-account-row-${M.id}`,children:[M.isDefault&&a.jsx("span",{className:fe.tokenBadge,title:"Default account",children:"default"}),a.jsx("span",{className:fe.tokenName,children:M.label}),M.username&&a.jsxs("span",{className:fe.tokenTarget,children:["@",M.username]}),!M.isDefault&&a.jsx("button",{className:fe.deleteButton,onClick:()=>{E(M.id).catch(()=>{})},title:"Set as default","aria-label":`Set ${M.label} as default`,"data-testid":`github-account-set-default-${M.id}`,children:a.jsx(QT,{size:Pt,"aria-hidden":"true"})}),a.jsx("button",{className:fe.deleteButton,onClick:()=>C(M.id),title:`Remove ${M.label}`,"aria-label":`Remove ${M.label}`,"data-testid":`github-account-remove-${M.id}`,children:a.jsx(Ls,{size:Pt,"aria-hidden":"true"})})]},M.id))}),a.jsxs("form",{className:fe.addForm,onSubmit:M=>{A(M).catch(()=>{})},children:[a.jsxs("div",{className:fe.formRow,children:[a.jsx("input",{className:fe.input,type:"text",placeholder:"Label (e.g. personal, work)",value:p,onChange:M=>m(M.target.value),"data-testid":"github-account-label-input"}),a.jsx("input",{className:fe.input,type:"password",placeholder:"Personal access token",value:g,onChange:M=>v(M.target.value),"data-testid":"github-account-token-input"})]}),a.jsxs("div",{className:fe.formRow,children:[a.jsxs("label",{className:fe.tokenTarget,style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:b,onChange:M=>_(M.target.checked),"data-testid":"github-account-default-checkbox"}),"Set as default"]}),a.jsx("button",{className:fe.addButton,type:"submit",disabled:!p.trim()||!g.trim()||k,"data-testid":"github-account-add-button",children:k?"Adding...":"Add Account"}),a.jsx("button",{className:fe.addButton,type:"button",onClick:()=>{B().catch(()=>{})},disabled:j,"data-testid":"github-account-import-button",children:j?"Importing...":"Import from gh CLI"})]})]})]})]})}const f8="_container_legrg_1",p8="_header_legrg_8",m8="_headerTitle_legrg_35",h8="_badge_legrg_44",g8="_headerActions_legrg_54",v8="_body_legrg_61",y8="_formContent_legrg_73",b8="_section_legrg_85",_8="_label_legrg_91",x8="_nameInput_legrg_98",k8="_fieldInput_legrg_131",S8="_adapterSelect_legrg_164",j8="_readOnlyValue_legrg_198",T8="_codespaceSection_legrg_204",N8="_codespaceActions_legrg_210",w8="_creatingHint_legrg_216",C8="_errorHint_legrg_222",E8="_btnPrimary_legrg_235",A8="_btnGhost_legrg_266",re={container:f8,header:p8,headerTitle:m8,badge:h8,headerActions:g8,body:v8,formContent:y8,section:b8,label:_8,nameInput:x8,fieldInput:k8,adapterSelect:S8,readOnlyValue:j8,codespaceSection:T8,codespaceActions:N8,creatingHint:w8,errorHint:C8,btnPrimary:E8,btnGhost:A8},id=1,od=65535;function Ep(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=id&&s<=od}function Ap(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function D8({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[b,_]=y.useState(""),[k,S]=y.useState("");return g==="create"?a.jsxs("div",{className:re.codespaceSection,children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Repository"}),a.jsx("input",{type:"text",value:b,onChange:j=>_(j.target.value),placeholder:"owner/repo",className:re.fieldInput,"data-testid":"env-codespace-repo"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Machine Type"}),a.jsx("input",{type:"text",value:k,onChange:j=>S(j.target.value),placeholder:"Machine type (optional)...",className:re.fieldInput,"data-testid":"env-codespace-machine"})]}),a.jsxs("div",{className:re.codespaceActions,children:[a.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),k.trim()||void 0),v("pick"),_(""),S(""))},disabled:!b.trim(),className:re.btnPrimary,children:"Create"}),a.jsx("button",{onClick:()=>{v("pick"),_(""),S("")},className:re.btnGhost,children:"Cancel"})]})]}):a.jsx("div",{className:re.codespaceSection,children:a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Codespace"}),!u&&a.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:re.adapterSelect,"data-testid":"env-codespace-select",children:[a.jsx("option",{value:"",children:"Select a codespace..."}),c.map(j=>a.jsxs("option",{value:j.name,children:[j.name," (",j.repository,") — ",j.state]},j.name)),a.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&a.jsx("span",{className:re.creatingHint,children:"Creating codespace..."}),u&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:re.errorHint,children:u}),a.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:re.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&a.jsx("span",{className:re.errorHint,children:d})]})})}function lk({mode:t,environmentId:s,environments:o,githubAccounts:r,onAddEnvironment:c,onUpdateEnvironment:d,onListCodespaces:u,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b,onListDockerContainers:_,dockerContainers:k,dockerContainersError:S,onShowToast:j}){const T=xt(),N=t==="edit",C=N&&s?o.find(le=>le.id===s):void 0,[D,A]=y.useState(""),[E,R]=y.useState("local"),[B,M]=y.useState(""),[$,Y]=y.useState(""),[U,X]=y.useState(""),[te,G]=y.useState(""),[ne,H]=y.useState(""),[O,q]=y.useState(""),[ge,se]=y.useState(""),[ce,me]=y.useState(""),[xe,De]=y.useState("create"),[ot,bt]=y.useState(""),[lt,Pe]=y.useState(null),ke=y.useCallback(()=>{const le={};if(E==="local"){if(B.trim()&&(le.host=B.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(le.port=ve)}}else if(E==="ssh"){if(le.host=B.trim(),U.trim()&&(le.user=U.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(le.sshPort=ve)}te.trim()&&(le.identityFile=te.trim())}else E==="docker"?xe==="attach"?ot.trim()&&(le.attach=ot.trim()):(ne.trim()&&(le.image=ne.trim()),O.trim()&&(le.repo=O.trim())):E==="codespace"&&(le.codespaceName=ge.trim());return le},[E,B,$,U,te,ne,O,ge,xe,ot]),ct=()=>!(!D.trim()||E==="ssh"&&!B.trim()||E==="codespace"&&!ge.trim()||E==="docker"&&xe==="attach"&&!ot.trim()||(E==="local"||E==="ssh")&&!Ep($)),ue=()=>{ct()&&(c(D.trim(),E,ke(),ce||void 0),j==null||j("Environment added successfully","success"),T(zo,{replace:!0}))},Re=()=>{T(s?$o(s):zo)},ee=y.useCallback((le,ve)=>{if(!C||!s)return;const et=Ap(C.adapterConfig),on=ve.trim();on?et[le]=on:delete et[le],d(s,{adapterConfig:et})},[C,s,d]),nt=y.useCallback((le,ve)=>{if(!C||!s)return;const et=Ap(C.adapterConfig);if(ve.trim()){const on=Number(ve);Number.isInteger(on)&&on>=id&&on<=od&&(et[le]=on)}else delete et[le];d(s,{adapterConfig:et})},[C,s,d]);if(N){if(!C)return a.jsxs("div",{className:re.container,children:[a.jsxs("div",{className:re.header,children:[a.jsx("div",{className:re.headerTitle,children:a.jsx("span",{className:re.badge,children:"edit environment"})}),a.jsx("div",{className:re.headerActions,children:a.jsx("button",{onClick:Re,className:re.btnGhost,children:"Back"})})]}),a.jsx("div",{className:re.body,children:a.jsx("div",{className:re.formContent,children:a.jsx("span",{className:re.readOnlyValue,children:"Environment not found"})})})]});const le=Ap(C.adapterConfig);return a.jsxs("div",{className:re.container,"data-testid":"env-edit-panel",children:[a.jsxs("div",{className:re.header,children:[a.jsx("div",{className:re.headerTitle,children:a.jsx("span",{className:re.badge,children:"edit environment"})}),a.jsx("div",{className:re.headerActions,children:a.jsx("button",{onClick:Re,className:re.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),a.jsx("div",{className:re.body,children:a.jsxs("div",{className:re.formContent,children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Name"}),a.jsx($t,{value:C.displayName,onSave:ve=>{s&&d(s,{displayName:ve})},validate:ve=>ve.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:lt,onActivate:Pe,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Adapter Type"}),a.jsx("span",{className:re.readOnlyValue,"data-testid":"env-edit-adapter-type",children:C.adapterType})]}),(C.adapterType==="codespace"||C.adapterType==="docker")&&(r.length>0||!!C.githubAccountId)&&a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"GitHub Account"}),a.jsxs("select",{value:C.githubAccountId||"",onChange:ve=>{s&&d(s,{githubAccountId:ve.target.value})},className:re.adapterSelect,"data-testid":"env-edit-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(ve=>a.jsxs("option",{value:ve.id,children:[ve.label,ve.username?` (@${ve.username})`:"",ve.isDefault?" — default":""]},ve.id))]})]}),C.adapterType==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Host"}),a.jsx($t,{value:String(le.host??""),onSave:ve=>ee("host",ve),mode:"edit",fieldId:"host",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Port"}),a.jsx($t,{value:String(le.port??""),onSave:ve=>nt("port",ve),validate:ve=>Ep(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),C.adapterType==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Host"}),a.jsx($t,{value:String(le.host??""),onSave:ve=>ee("host",ve),validate:ve=>ve.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:lt,onActivate:Pe,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"User"}),a.jsx($t,{value:String(le.user??""),onSave:ve=>ee("user",ve),mode:"edit",fieldId:"user",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"SSH Port"}),a.jsx($t,{value:String(le.sshPort??""),onSave:ve=>nt("sshPort",ve),validate:ve=>Ep(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:lt,onActivate:Pe,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Identity File"}),a.jsx($t,{value:String(le.identityFile??""),onSave:ve=>ee("identityFile",ve),mode:"edit",fieldId:"identityFile",activeFieldId:lt,onActivate:Pe,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),C.adapterType==="docker"&&le.attach!==void 0&&a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Attach (container)"}),a.jsx($t,{value:String(le.attach??""),onSave:ve=>ee("attach",ve),validate:ve=>ve.trim()===""?"Container name is required":void 0,mode:"edit",fieldId:"attach",activeFieldId:lt,onActivate:Pe,placeholder:"container name or ID",ariaLabel:"Attach container","data-testid":"env-edit-attach"})]}),C.adapterType==="docker"&&le.attach===void 0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Image"}),a.jsx($t,{value:String(le.image??""),onSave:ve=>ee("image",ve),mode:"edit",fieldId:"image",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Repo"}),a.jsx($t,{value:String(le.repo??""),onSave:ve=>ee("repo",ve),mode:"edit",fieldId:"repo",activeFieldId:lt,onActivate:Pe,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),C.adapterType==="codespace"&&a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Codespace Name"}),a.jsx($t,{value:String(le.codespaceName??""),onSave:ve=>ee("codespaceName",ve),validate:ve=>ve.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:lt,onActivate:Pe,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return a.jsxs("div",{className:re.container,"data-testid":"env-create-panel",children:[a.jsxs("div",{className:re.header,children:[a.jsx("div",{className:re.headerTitle,children:a.jsx("span",{className:re.badge,children:"new environment"})}),a.jsxs("div",{className:re.headerActions,children:[a.jsx("button",{onClick:ue,disabled:!ct(),className:re.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),a.jsx("button",{onClick:Re,className:re.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:re.body,children:a.jsxs("div",{className:re.formContent,children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-name",children:"Name"}),a.jsx("input",{id:"env-create-name",type:"text",value:D,onChange:le=>A(le.target.value),placeholder:"Environment name...",autoFocus:!0,className:re.nameInput,"data-testid":"env-create-name",onKeyDown:le=>{le.key==="Enter"&&ct()&&ue()}})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),a.jsxs("select",{id:"env-create-adapter",value:E,onChange:le=>{R(le.target.value),le.target.value==="codespace"&&u(ce||void 0)},className:re.adapterSelect,"data-testid":"env-create-adapter",children:[a.jsx("option",{value:"local",children:"local"}),a.jsx("option",{value:"ssh",children:"ssh"}),a.jsx("option",{value:"docker",children:"docker"}),a.jsx("option",{value:"codespace",children:"codespace"})]})]}),(E==="codespace"||E==="docker")&&r.length>0&&a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-github-account",children:"GitHub Account"}),a.jsxs("select",{id:"env-create-github-account",value:ce,onChange:le=>{me(le.target.value),E==="codespace"&&u(le.target.value||void 0)},className:re.adapterSelect,"data-testid":"env-create-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(le=>a.jsxs("option",{value:le.id,children:[le.label," (@",le.username,")",le.isDefault?" — default":""]},le.id))]})]}),E==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:B,onChange:le=>M(le.target.value),placeholder:"Host (optional)...",className:re.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-port",children:"Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:id,max:od,value:$,onChange:le=>Y(le.target.value),placeholder:"Port (optional)...",className:re.fieldInput,"data-testid":"env-create-port"})]})]}),E==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:B,onChange:le=>M(le.target.value),placeholder:"Host (required)...",className:re.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-user",children:"User"}),a.jsx("input",{id:"env-create-user",type:"text",value:U,onChange:le=>X(le.target.value),placeholder:"User (optional)...",className:re.fieldInput,"data-testid":"env-create-user"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-port",children:"SSH Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:id,max:od,value:$,onChange:le=>Y(le.target.value),placeholder:"SSH port (optional)...",className:re.fieldInput,"data-testid":"env-create-port"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-identity",children:"Identity File"}),a.jsx("input",{id:"env-create-identity",type:"text",value:te,onChange:le=>G(le.target.value),placeholder:"Identity file (optional)...",className:re.fieldInput,"data-testid":"env-create-identity"})]})]}),E==="docker"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-docker-mode",children:"Source"}),a.jsxs("select",{id:"env-docker-mode",value:xe,onChange:le=>{const ve=le.target.value;De(ve),ve==="attach"&&_()},className:re.adapterSelect,"data-testid":"env-docker-mode",children:[a.jsx("option",{value:"create",children:"Create new container"}),a.jsx("option",{value:"attach",children:"Attach to existing container"})]})]}),xe==="create"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-image",children:"Image"}),a.jsx("input",{id:"env-create-image",type:"text",value:ne,onChange:le=>H(le.target.value),placeholder:"Image (optional)...",className:re.fieldInput,"data-testid":"env-create-image"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-repo",children:"Repo"}),a.jsx("input",{id:"env-create-repo",type:"text",value:O,onChange:le=>q(le.target.value),placeholder:"Repo (optional)...",className:re.fieldInput,"data-testid":"env-create-repo"})]})]}):a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Container"}),!S&&k.length>0&&a.jsxs("select",{value:ot,onChange:le=>{bt(le.target.value),le.target.value&&!D.trim()&&A(le.target.value)},className:re.adapterSelect,"data-testid":"env-docker-container-select",children:[a.jsx("option",{value:"",children:"Select a container..."}),k.map(le=>a.jsxs("option",{value:le.name,children:[le.name," (",le.image,") ",le.status]},le.id))]}),(S||k.length===0)&&a.jsxs(a.Fragment,{children:[S?a.jsx("span",{className:re.errorHint,children:S}):a.jsx("span",{className:re.creatingHint,children:"No running containers found."}),a.jsx("input",{type:"text",value:ot,onChange:le=>{bt(le.target.value),le.target.value&&!D.trim()&&A(le.target.value)},placeholder:"Enter container name/ID...",className:re.fieldInput,"data-testid":"env-docker-container-manual"})]})]})]}),E==="codespace"&&a.jsx(D8,{codespaceName:ge,onCodespaceNameChange:se,envName:D,onEnvNameChange:A,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b})]})})]})}const M8="_group_1iprv_1",R8="_groupTitle_1iprv_8",I8="_shortcutList_1iprv_17",O8="_shortcutRow_1iprv_23",B8="_keys_1iprv_36",L8="_kbd_1iprv_43",z8="_description_1iprv_60",xi={group:M8,groupTitle:R8,shortcutList:I8,shortcutRow:O8,keys:B8,kbd:L8,description:z8},$8=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Root",shortcuts:[{keys:["Ctrl/Cmd","Enter"],description:"Send message (when the composer is focused)"},{keys:["Enter"],description:"Insert a new line in the message composer"}]}];function H8(){return a.jsxs("section",{className:fe.section,"data-testid":"keyboard-shortcuts-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"Keyboard Shortcuts"}),a.jsx("p",{className:fe.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),$8.map(t=>a.jsxs("div",{className:xi.group,children:[a.jsx("h4",{className:xi.groupTitle,children:t.title}),a.jsx("div",{className:xi.shortcutList,children:t.shortcuts.map(s=>a.jsxs("div",{className:xi.shortcutRow,children:[a.jsx("span",{className:xi.keys,children:s.keys.map(o=>a.jsx("kbd",{className:xi.kbd,children:o},o))}),a.jsx("span",{className:xi.description,children:s.description})]},s.description))})]},t.title))]})}const P8=[{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 U8({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Credential Providers"}),a.jsx("p",{className:fe.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),a.jsx("div",{className:fe.tokenList,children:P8.map(r=>a.jsxs("div",{className:fe.tokenRow,children:[a.jsx("span",{className:fe.tokenName,children:r.label}),a.jsx("span",{className:fe.tokenTarget,children:r.description}),a.jsx("select",{className:fe.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>a.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const V8="_container_10efq_1",q8="_header_10efq_7",G8="_list_10efq_105",F8="_card_10efq_111",K8="_cardHeader_10efq_125",Z8="_cardTitle_10efq_135",Y8="_defaultBadge_10efq_141",J8="_cardActions_10efq_155",W8="_description_10efq_160",X8="_meta_10efq_166",Q8="_empty_10efq_212",e7="_typeBadge_10efq_362",es={container:V8,header:q8,list:G8,card:F8,cardHeader:K8,cardTitle:Z8,defaultBadge:Y8,cardActions:J8,description:W8,meta:X8,empty:Q8,typeBadge:e7};function t7({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return a.jsxs("div",{className:es.container,children:[a.jsxs("div",{className:es.header,children:[a.jsx("h2",{children:"Personas"}),a.jsx(an,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?a.jsx("p",{className:es.empty,children:"No personas yet. Create one to get started."}):a.jsx("div",{className:es.list,children:t.map(v=>{const b=s===v.id,_=v.type==="script";return a.jsxs("div",{className:es.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(v.id))},children:[a.jsxs("div",{className:es.cardHeader,children:[a.jsxs("span",{className:es.cardTitle,children:[a.jsx("strong",{children:v.name}),a.jsx("span",{className:es.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:_?"Script":"Agent"}),b&&a.jsx("span",{className:es.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),a.jsxs("div",{className:es.cardActions,onClick:k=>k.stopPropagation(),children:[!b&&a.jsx(an,{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"}),a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&a.jsx("p",{className:es.description,children:v.description}),a.jsxs("div",{className:es.meta,children:[v.runtime&&a.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&a.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&a.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),a.jsx(bs,{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 n7="_container_uy08i_1",s7="_header_uy08i_7",a7="_count_uy08i_13",i7="_presets_uy08i_18",o7="_presetButton_uy08i_24",r7="_filterInput_uy08i_41",l7="_groups_uy08i_53",c7="_group_uy08i_53",d7="_groupHeader_uy08i_68",u7="_groupName_uy08i_77",f7="_groupCount_uy08i_81",p7="_toolList_uy08i_87",m7="_toolItem_uy08i_95",h7="_toolName_uy08i_103",bn={container:n7,header:s7,count:a7,presets:i7,presetButton:o7,filterInput:r7,groups:l7,group:c7,groupHeader:d7,groupName:u7,groupCount:f7,toolList:p7,toolItem:m7,toolName:h7},g7=(()=>{const t=new Map;for(const s of H_){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()}))})(),v7=[{name:"default",label:"Default",tools:$_},{name:"worker",label:"Worker",tools:Q2},{name:"orchestrator",label:"Orchestrator",tools:ej},{name:"admin",label:"Admin",tools:tj}];function r_({selectedTools:t,onChange:s,disabled:o}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.useCallback(v=>{if(o)return;const b=new Set(d);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[d,s,o]),p=y.useCallback((v,b)=>{if(o)return;const _=new Set(d);for(const k of v)b?_.delete(k):_.add(k);s([..._].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return a.jsxs("div",{className:bn.container,"data-testid":"mcp-tool-selector",children:[a.jsx("div",{className:bn.header,children:a.jsx("span",{className:bn.count,children:t.length===0?`Using default (${$_.length} tools)`:`${t.length} of ${H_.size} tools selected`})}),a.jsxs("div",{className:bn.presets,"data-testid":"mcp-tool-presets",children:[v7.map(v=>a.jsx("button",{type:"button",className:bn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),a.jsx("button",{type:"button",className:bn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),a.jsx("input",{type:"text",className:bn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),a.jsx("div",{className:bn.groups,children:g7.map(({group:v,tools:b})=>{const _=g?b.filter(S=>S.toLowerCase().includes(g)):b;if(_.length===0)return null;const k=_.every(S=>d.has(S));return a.jsxs("div",{className:bn.group,"data-testid":`tool-group-${v}`,children:[a.jsxs("label",{className:bn.groupHeader,children:[a.jsx("input",{type:"checkbox",checked:k,onChange:()=>p(_,k),disabled:o,"data-testid":`group-toggle-${v}`}),a.jsx("span",{className:bn.groupName,children:v}),a.jsxs("span",{className:bn.groupCount,children:["(",_.filter(S=>d.has(S)).length,"/",_.length,")"]})]}),a.jsx("div",{className:bn.toolList,children:_.map(S=>a.jsxs("label",{className:bn.toolItem,children:[a.jsx("input",{type:"checkbox",checked:d.has(S),onChange:()=>u(S),disabled:o,"data-testid":`tool-${S}`}),a.jsx("span",{className:bn.toolName,children:S})]},S))})]},v)})})]})}function mm(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 ck(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 y7="_container_1gfuq_1",b7="_header_1gfuq_7",_7="_list_1gfuq_19",x7="_card_1gfuq_25",k7="_cardHeader_1gfuq_40",S7="_cardTitle_1gfuq_46",j7="_statusBadge_1gfuq_56",T7="_enabled_1gfuq_68",N7="_disabled_1gfuq_71",w7="_cardActions_1gfuq_75",C7="_cardMeta_1gfuq_80",E7="_empty_1gfuq_98",ts={container:y7,header:b7,list:_7,card:x7,cardHeader:k7,cardTitle:S7,statusBadge:j7,enabled:T7,disabled:N7,cardActions:w7,cardMeta:C7,empty:E7};function A7({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=y.useState(null),m=u?t.find(_=>_.id===u):void 0,g=async _=>{await o(_),p(null)},v=y.useMemo(()=>{const _=new Map;for(const k of s)_.set(k.id,k.name);return _},[s]),b=_=>v.get(_)??_;return a.jsxs("div",{className:ts.container,children:[a.jsxs("div",{className:ts.header,children:[a.jsx("h2",{children:"Schedules"}),a.jsx(an,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?a.jsx("p",{className:ts.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):a.jsx("div",{className:ts.list,children:t.map(_=>a.jsxs("div",{className:ts.card,"data-testid":`schedule-card-${_.id}`,onClick:()=>d(_.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(_.id))},children:[a.jsxs("div",{className:ts.cardHeader,children:[a.jsxs("span",{className:ts.cardTitle,children:[a.jsx("strong",{children:_.title}),a.jsx("span",{className:`${ts.statusBadge} ${_.enabled?ts.enabled:ts.disabled}`,"data-testid":`schedule-status-badge-${_.id}`,children:_.enabled?"Enabled":"Disabled"})]}),a.jsxs("div",{className:ts.cardActions,onClick:k=>k.stopPropagation(),children:[a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(_.id,{enabled:!_.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${_.id}`,title:_.enabled?"Disable schedule":"Enable schedule",children:_.enabled?"Disable":"Enable"}),a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>d(_.id),"data-testid":`schedule-edit-${_.id}`,children:"Edit"}),a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>p(_.id),"data-testid":`schedule-delete-${_.id}`,children:"Delete"})]})]}),a.jsxs("div",{className:ts.cardMeta,children:[a.jsx("span",{"data-testid":`schedule-expression-${_.id}`,children:_.scheduleExpression}),_.personaId&&a.jsxs("span",{"data-testid":`schedule-persona-${_.id}`,children:["Persona: ",b(_.personaId)]}),a.jsxs("span",{"data-testid":`schedule-last-run-${_.id}`,children:["Last run: ",_.lastRunAt?mm(_.lastRunAt):"Never"]}),_.enabled&&_.nextRunAt?a.jsxs("span",{"data-testid":`schedule-next-run-${_.id}`,children:["Next run: ",ck(_.nextRunAt)]}):null,_.runCount>0&&a.jsxs("span",{"data-testid":`schedule-run-count-${_.id}`,children:["Runs: ",_.runCount]})]})]},_.id))}),a.jsx(bs,{isOpen:u!==null,title:"Delete Schedule?",description:`"${(m==null?void 0:m.title)??""}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const D7="_nav_1bhou_1",M7="_tab_1bhou_24",R7="_tabIcon_1bhou_62",I7="_tabActive_1bhou_68",Fc={nav:D7,tab:M7,tabIcon:R7,tabActive:I7},ia=[{path:"credentials",label:"Credentials",icon:a.jsx(yT,{size:At})},{path:"github-accounts",label:"GitHub Accounts",icon:a.jsx(uT,{size:At})},{path:"personas",label:"Personas",icon:a.jsx(nN,{size:At})},{path:"schedules",label:"Schedules",icon:a.jsx(Uj,{size:At})},{path:"appearance",label:"Appearance",icon:a.jsx(zT,{size:At})},{path:"shortcuts",label:"Shortcuts",icon:a.jsx(_T,{size:At})},{path:"plugins",label:"Plugins",icon:a.jsx(qT,{size:At})},{path:"about",label:"About",icon:a.jsx(Sm,{size:At})}];function O7(){var u;const t=Wt(),s=xt(),o=y.useRef(null),r=((u=ia.find(p=>{const m=`${Ti}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??ia[0].path,c=y.useCallback(p=>{s(`${Ti}/${p}`)},[s]),d=y.useCallback(p=>{var k,S;const m=(k=o.current)==null?void 0:k.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:ia.findIndex(j=>j.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%ia.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+ia.length)%ia.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=ia.length-1;else return;const _=ia[b].path;s(`${Ti}/${_}`),(S=m[b])==null||S.focus()},[r,s]);return a.jsx("nav",{className:Fc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:ia.map(p=>{const m=p.path===r;return a.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Fc.tab} ${m?Fc.tabActive:""}`,onClick:()=>c(p.path),children:[a.jsx("span",{className:Fc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}const B7=["lifecycle:","pipe:","stdin:"];function vh(t){return t.selfEcho?"chatroom":t.name.startsWith("pipe:")?"pipe":"channel"}function dk(t,s){let o=!1;for(const r of t.subscribers){const c=s.get(r.sessionId);if(c&&(o=!0,c.taskId))return{kind:"task",taskId:c.taskId}}return o?{kind:"unattached"}:{kind:"external"}}function L7(t,s){const o=new Map(s.map(u=>[u.id,u])),r=new Map,c=[];for(const u of t){const p=dk(u,o);if(p.kind==="task"){const m=r.get(p.taskId);m?m.push(u):r.set(p.taskId,[u])}else c.push(u)}const d=Array.from(r,([u,p])=>({taskId:u,streams:p}));return c.length>0&&d.push({taskId:void 0,streams:c}),d}const z7="_container_16qkd_1",$7="_header_16qkd_7",H7="_title_16qkd_15",P7="_headerActions_16qkd_21",U7="_internalsToggle_16qkd_27",V7="_refreshButton_16qkd_37",q7="_state_16qkd_52",G7="_group_16qkd_59",F7="_groupHeader_16qkd_63",K7="_row_16qkd_72",Z7="_selected_16qkd_92",Y7="_kindBadge_16qkd_96",J7="_kindChatroom_16qkd_108",W7="_kindPipe_16qkd_114",X7="_kindChannel_16qkd_120",Q7="_streamName_16qkd_126",ez="_meta_16qkd_135",Jt={container:z7,header:$7,title:H7,headerActions:P7,internalsToggle:U7,refreshButton:V7,state:q7,group:G7,groupHeader:F7,row:K7,selected:Z7,kindBadge:Y7,kindChatroom:J7,kindPipe:W7,kindChannel:X7,streamName:Q7,meta:ez},tz={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function nz({kind:t}){return t==="chatroom"?a.jsx(MT,{size:Ye,"aria-hidden":"true"}):t==="pipe"?a.jsx(cT,{size:Ye,"aria-hidden":"true"}):a.jsx(pT,{size:Ye,"aria-hidden":"true"})}function sz({streams:t,sessions:s,tasks:o,loading:r,loadError:c=!1,loadedOnce:d=!0,showInternals:u,onToggleInternals:p,selectedStreamId:m,onSelectStream:g,onRefresh:v,hideHeaderControls:b=!1}){const _=L7(t,s),k={chatroom:Jt.kindChatroom,pipe:Jt.kindPipe,channel:Jt.kindChannel},S=j=>{var T;return((T=o.find(N=>N.id===j))==null?void 0:T.title)??j};return a.jsxs("div",{className:Jt.container,"data-testid":"coordination-list",children:[a.jsxs("div",{className:Jt.header,children:[a.jsx("span",{className:Jt.title,children:"Coordination"}),!b&&a.jsxs("div",{className:Jt.headerActions,children:[a.jsxs("label",{className:Jt.internalsToggle,children:[a.jsx("input",{type:"checkbox",checked:u,onChange:j=>p(j.target.checked),"data-testid":"coordination-show-internals"}),"Show internals"]}),v&&a.jsx("button",{type:"button",className:Jt.refreshButton,onClick:v,"aria-label":"Refresh streams","data-testid":"coordination-refresh",children:a.jsx(FT,{size:Ye,"aria-hidden":"true"})})]})]}),r&&t.length===0&&a.jsxs("div",{className:Jt.state,children:["Loading","…"]}),!r&&c&&a.jsx("div",{className:Jt.state,"data-testid":"coordination-error",children:"Unable to load streams"}),!r&&!c&&d&&t.length===0&&a.jsx("div",{className:Jt.state,"data-testid":"coordination-empty",children:"No active streams"}),_.map(j=>a.jsxs("div",{className:Jt.group,children:[a.jsx("div",{className:Jt.groupHeader,children:j.taskId?S(j.taskId):"Unattached / external (CLI · MCP)"}),j.streams.map(T=>{const N=vh(T),C=T.id===m;return a.jsxs("button",{type:"button",className:`${Jt.row}${C?` ${Jt.selected}`:""}`,onClick:()=>g(T.id),"data-testid":`coordination-row-${T.id}`,"aria-current":C?"page":void 0,children:[a.jsxs("span",{className:`${Jt.kindBadge} ${k[N]}`,children:[a.jsx(nz,{kind:N})," ",tz[N]]}),a.jsx("span",{className:Jt.streamName,children:T.name}),a.jsxs("span",{className:Jt.meta,children:[T.subscriberCount," ",T.subscriberCount===1?"sub":"subs"," ","·"," ",T.messageBufferDepth," buffered"]})]},T.id)})]},j.taskId??"__orphans__"))]})}const az="_transcript_1p4cm_1",iz="_message_1p4cm_10",oz="_meta_1p4cm_16",rz="_sender_1p4cm_24",lz="_time_1p4cm_29",cz="_content_1p4cm_34",dz="_state_1p4cm_42",Ga={transcript:az,message:iz,meta:oz,sender:rz,time:lz,content:cz,state:dz};function uz(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleTimeString()}function fz({messages:t,loading:s=!1}){return s?a.jsx("div",{className:Ga.state,"data-testid":"stream-transcript-loading",children:"Loading transcript…"}):t.length===0?a.jsx("div",{className:Ga.state,"data-testid":"stream-transcript-empty",children:"No messages yet."}):a.jsx("div",{className:Ga.transcript,"data-testid":"stream-transcript",children:t.map(o=>a.jsxs("div",{className:Ga.message,"data-testid":"stream-transcript-message",children:[a.jsxs("div",{className:Ga.meta,children:[a.jsx("span",{className:Ga.sender,title:o.senderId,children:o.senderId.slice(0,12)}),a.jsx("span",{className:Ga.time,children:uz(o.timestamp)})]}),a.jsx("div",{className:Ga.content,children:o.content})]},o.seq))})}const pz="_panel_i6ltf_1",mz="_header_i6ltf_24",hz="_title_i6ltf_33",gz="_closeButton_i6ltf_43",vz="_body_i6ltf_57",yz="_section_i6ltf_63",bz="_sectionLabel_i6ltf_67",_z="_metaRow_i6ltf_76",xz="_metaKey_i6ltf_84",kz="_metaValue_i6ltf_90",Sz="_subscriberCard_i6ltf_99",jz="_subscriberHeader_i6ltf_107",Tz="_sessionLink_i6ltf_114",Nz="_badges_i6ltf_132",wz="_badgeRw_i6ltf_150 _badge_i6ltf_132",Cz="_badgeR_i6ltf_150 _badge_i6ltf_132",Ez="_badgeW_i6ltf_162 _badge_i6ltf_132",Az="_badgeAsync_i6ltf_168 _badge_i6ltf_132",Dz="_badgeSync_i6ltf_174 _badge_i6ltf_132",Mz="_badgeDetach_i6ltf_178 _badge_i6ltf_132",Rz="_spawnTag_i6ltf_184 _badge_i6ltf_132",Iz="_fdNumber_i6ltf_189",Oz="_emptySubscribers_i6ltf_195",Bz="_metaValueMono_i6ltf_201 _metaValue_i6ltf_90",Lz="_advanced_i6ltf_216",zz="_advancedSummary_i6ltf_220",He={panel:pz,header:mz,title:hz,closeButton:gz,body:vz,section:yz,sectionLabel:bz,metaRow:_z,metaKey:xz,metaValue:kz,subscriberCard:Sz,subscriberHeader:jz,sessionLink:Tz,badges:Nz,badgeRw:wz,badgeR:Cz,badgeW:Ez,badgeAsync:Az,badgeSync:Dz,badgeDetach:Mz,spawnTag:Rz,fdNumber:Iz,emptySubscribers:Oz,metaValueMono:Bz,advanced:Lz,advancedSummary:zz},$z={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function Hz({permission:t}){const s=t==="rw"?He.badgeRw:t==="r"?He.badgeR:He.badgeW;return a.jsx("span",{className:s,children:t})}function Pz({mode:t}){const s=t==="async"?He.badgeAsync:t==="detach"?He.badgeDetach:He.badgeSync;return a.jsx("span",{className:s,children:t})}function Uz({stream:t,messages:s,transcriptLoading:o,onClose:r}){const c=xt();return y.useEffect(()=>{const d=u=>{u.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[r]),a.jsxs("div",{className:He.panel,"data-testid":"stream-detail-panel",children:[a.jsxs("div",{className:He.header,children:[a.jsx("h3",{className:He.title,children:t.name}),a.jsx("button",{type:"button",className:He.closeButton,onClick:r,"aria-label":"Close stream details",children:"×"})]}),a.jsxs("div",{className:He.body,children:[a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Overview"}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Kind"}),a.jsx("span",{className:He.metaValue,children:$z[vh(t)]})]}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Participants"}),a.jsx("span",{className:He.metaValue,children:t.subscriberCount})]}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Buffered"}),a.jsxs("span",{className:He.metaValue,children:[t.messageBufferDepth," msgs"]})]})]}),a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Participants"}),t.subscribers.length===0?a.jsx("div",{className:He.emptySubscribers,children:"No active subscribers"}):t.subscribers.map(d=>a.jsxs("div",{className:He.subscriberCard,"data-testid":`subscriber-card-${d.subscriptionId}`,children:[a.jsxs("button",{type:"button",className:He.sessionLink,onClick:()=>{c(Rm(d.sessionId))},title:d.sessionId,children:[d.sessionId.slice(0,12),"…"]}),d.createdBySpawn&&a.jsx("span",{className:He.spawnTag,children:"spawn"})]},d.subscriptionId))]}),a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Conversation"}),a.jsx(fz,{messages:s??[],loading:o??!1})]}),a.jsxs("details",{className:He.advanced,"data-testid":"stream-advanced",children:[a.jsx("summary",{className:He.advancedSummary,children:"Advanced"}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Stream ID"}),a.jsx("span",{className:He.metaValueMono,children:t.id})]}),t.subscribers.map(d=>a.jsxs("div",{className:He.subscriberCard,children:[a.jsxs("div",{className:He.subscriberHeader,children:[a.jsxs("span",{className:He.fdNumber,children:["fd ",d.fd]}),a.jsxs("span",{className:He.metaValueMono,title:d.subscriptionId,children:[d.subscriptionId.slice(0,12),"…"]})]}),a.jsxs("div",{className:He.badges,children:[a.jsx(Hz,{permission:d.permission}),a.jsx(Pz,{mode:d.deliveryMode})]})]},d.subscriptionId))]})]})]})}function Dp(t){return t.length>0?t.charAt(0).toUpperCase()+t.slice(1):t}const Vz=["--accent-green","--accent-yellow","--accent-red","--text-tertiary"];function uk(t,s){if(s)return{varName:"--text-tertiary",label:"External"};switch(t){case"running":return{varName:"--accent-green",label:"Running"};case"idle":case"suspended":case"hibernating":return{varName:"--accent-yellow",label:Dp(t)};case"failed":case"interrupted":return{varName:"--accent-red",label:Dp(t)};default:return{varName:"--text-tertiary",label:t.length>0?Dp(t):"Unknown"}}}const fk="session",yh="stream",l_="messageDot";function Kc(t){return`session:${t}`}function c_(t){return`stream:${t}`}function qz(t){return{id:t,environmentId:"",runtime:"external",status:"external",prompt:"",startedAt:""}}function Gz(t,s){return t==="detach"?{stroke:s,strokeWidth:1.5,strokeDasharray:"4 4",opacity:.6}:{stroke:s,strokeWidth:1.5}}function Fz(t,s){const o=t.permission.includes("w"),r=s.permission.includes("w"),c=t.permission.includes("r"),d=s.permission.includes("r");if(o&&!r&&d)return{source:t,target:s,bidirectional:!1};if(r&&!o&&c)return{source:s,target:t,bidirectional:!1};const u=[t,s].sort((p,m)=>p.sessionId.localeCompare(m.sessionId));return{source:u[0],target:u[1],bidirectional:!0}}function Kz(t,s){if(t.length===0)return{nodes:[],edges:[]};const o=new Map(s.map(m=>[m.id,m])),r=new Map,c=new Map,d=[],u=m=>{let g=r.get(m);if(!g){const v=o.get(m);g={kind:"session",session:v??qz(m),streamCount:0,external:v===void 0},r.set(m,g)}return g};for(const m of t){const g=vh(m);if(g==="pipe"&&m.subscribers.length===2&&m.subscribers[0].sessionId!==m.subscribers[1].sessionId){const[v,b]=m.subscribers;u(v.sessionId).streamCount+=1,u(b.sessionId).streamCount+=1;const{source:_,target:k,bidirectional:S}=Fz(v,b);d.push({id:`edge-pipe-${m.id}`,source:Kc(_.sessionId),target:Kc(k.sessionId),type:l_,data:{edgeKind:"pipe",streamId:m.id,permission:S?"rw":_.permission,deliveryMode:_.deliveryMode},style:{stroke:"var(--accent-yellow)",strokeWidth:1.5,strokeDasharray:"6 3"},markerEnd:{type:Mc.ArrowClosed},markerStart:S?{type:Mc.ArrowClosed}:void 0,animated:!1});continue}c.set(m.id,{kind:"stream",stream:m,streamKind:g,ownership:dk(m,o)});for(const v of m.subscribers){u(v.sessionId).streamCount+=1;const b=c_(m.id),_=Kc(v.sessionId),k=v.permission.includes("w"),S=v.permission.includes("r");let j,T,N=!1;k&&S?(j=_,T=b,N=!0):S?(j=b,T=_):(j=_,T=b),d.push({id:`edge-part-${m.id}-${v.subscriptionId}`,source:j,target:T,type:l_,data:{edgeKind:"participation",streamId:m.id,permission:v.permission,deliveryMode:v.deliveryMode},style:Gz(v.deliveryMode,"var(--text-tertiary)"),markerEnd:{type:Mc.ArrowClosed},markerStart:N?{type:Mc.ArrowClosed}:void 0,animated:!1})}}const p=[];for(const[m,g]of r)p.push({id:Kc(m),type:fk,position:{x:0,y:0},data:g});for(const[m,g]of c)p.push({id:c_(m),type:yh,position:{x:0,y:0},data:g});return{nodes:p,edges:d}}const Zz=200,Yz=64,Jz=180,Wz=56,Xz=40,Qz=70;function d_(t){return t===yh?{width:Jz,height:Wz}:{width:Zz,height:Yz}}function e$(t){if(t.nodes.length===0)return t;const s=new ld.graphlib.Graph({multigraph:!0});s.setDefaultEdgeLabel(()=>({})),s.setGraph({rankdir:"LR",nodesep:Xz,ranksep:Qz});for(const r of t.nodes){const{width:c,height:d}=d_(r.type);s.setNode(r.id,{width:c,height:d})}for(const r of t.edges)s.setEdge(r.source,r.target,{},r.id);return ld.layout(s),{nodes:t.nodes.map(r=>{const c=s.node(r.id),{width:d,height:u}=d_(r.type);return{...r,position:{x:c.x-d/2,y:c.y-u/2}}}),edges:t.edges}}function t$(t,s){return y.useMemo(()=>e$(Kz(t,s)),[t,s])}const n$="_graphContainer_1uzcp_1",s$="_empty_1uzcp_18",a$="_nodeContent_1uzcp_28",i$="_nodeHeader_1uzcp_38",o$="_nodeTitle_1uzcp_50",r$="_nodeMeta_1uzcp_58",l$="_nodeSubtle_1uzcp_64",c$="_countBadge_1uzcp_69",d$="_sessionNode_1uzcp_81",u$="_sessionAccent_1uzcp_103",f$="_external_1uzcp_109",p$="_streamNode_1uzcp_114",m$="_chatroom_1uzcp_134",h$="_channel_1uzcp_139",g$="_pipe_1uzcp_143",v$="_haloless_1uzcp_147",y$="_selected_1uzcp_153",b$="_kindBadge_1uzcp_158",_$="_handle_1uzcp_172",x$="_messageDot_1uzcp_179",vt={graphContainer:n$,empty:s$,nodeContent:a$,nodeHeader:i$,nodeTitle:o$,nodeMeta:r$,nodeSubtle:l$,countBadge:c$,sessionNode:d$,sessionAccent:u$,external:f$,streamNode:p$,chatroom:m$,channel:h$,pipe:g$,haloless:v$,selected:y$,kindBadge:b$,handle:_$,messageDot:x$};function k$({data:t}){const{session:s,streamCount:o,external:r}=t,c=uk(s.status,r),d=`var(${c.varName})`,u=r?`${vt.sessionNode} ${vt.external}`:vt.sessionNode;return a.jsxs("div",{className:u,"data-testid":`coordination-node-session-${s.id}`,children:[a.jsx(Bo,{type:"target",position:Lo.Left,isConnectable:!1,className:vt.handle}),a.jsx("div",{className:vt.sessionAccent,style:{backgroundColor:d}}),a.jsxs("div",{className:vt.nodeContent,children:[a.jsx("div",{className:vt.nodeHeader,children:a.jsx("span",{className:vt.nodeTitle,children:r?s.id:s.runtime})}),a.jsxs("div",{className:vt.nodeMeta,children:[a.jsx("span",{className:vt.nodeSubtle,style:{color:d},children:c.label}),o>0&&a.jsx("span",{className:vt.countBadge,children:o})]})]}),a.jsx(Bo,{type:"source",position:Lo.Right,isConnectable:!1,className:vt.handle})]})}function S$({data:t,selected:s}){const{stream:o,streamKind:r,ownership:c}=t,d=r==="chatroom"?vt.chatroom:r==="pipe"?vt.pipe:vt.channel,u=[vt.streamNode,d];return c.kind!=="task"&&u.push(vt.haloless),s&&u.push(vt.selected),a.jsxs("div",{className:u.join(" "),"data-testid":`coordination-node-stream-${o.id}`,children:[a.jsx(Bo,{type:"target",position:Lo.Left,isConnectable:!1,className:vt.handle}),a.jsxs("div",{className:vt.nodeContent,children:[a.jsx("div",{className:vt.nodeHeader,children:a.jsx("span",{className:vt.kindBadge,children:r})}),a.jsx("span",{className:vt.nodeTitle,children:o.name}),a.jsxs("span",{className:vt.nodeSubtle,children:[o.subscriberCount," ",o.subscriberCount===1?"subscriber":"subscribers"]})]}),a.jsx(Bo,{type:"source",position:Lo.Right,isConnectable:!1,className:vt.handle})]})}const u_="0.7s",j$=3;function T$(t){const{sourceX:s,sourceY:o,targetX:r,targetY:c,sourcePosition:d,targetPosition:u,markerStart:p,markerEnd:m,style:g,data:v}=t,[b]=q2({sourceX:s,sourceY:o,targetX:r,targetY:c,sourcePosition:d,targetPosition:u}),_=v==null?void 0:v.pulseSeq;return a.jsxs(a.Fragment,{children:[a.jsx(G2,{path:b,markerStart:p,markerEnd:m,style:g}),_!==void 0&&a.jsxs("circle",{r:j$,opacity:0,className:vt.messageDot,"data-testid":"coordination-message-dot",children:[a.jsx("animateMotion",{dur:u_,repeatCount:"1",path:b}),a.jsx("animate",{attributeName:"opacity",dur:u_,repeatCount:"1",values:"0;1;1;0",keyTimes:"0;0.1;0.85;1"})]},_)]})}const Mp="#6b7a8d",N$={[fk]:k$,[yh]:S$},w$={messageDot:T$};function C$({streams:t,sessions:s,selectedStreamId:o,onSelectStream:r,recentMessages:c,resolvedThemeId:d}){const u=t$(t,s),p=y.useMemo(()=>u.edges.map(_=>{var S,j;if(!_.data)return _;const k=(j=(S=c==null?void 0:c[_.data.streamId])==null?void 0:S.at(-1))==null?void 0:j.seq;return k===void 0?_:{..._,data:{..._.data,pulseSeq:k}}}),[u.edges,c]),m=y.useMemo(()=>u.nodes.map(_=>{const k=_.data;return k.kind==="stream"&&k.stream.id===o?{..._,selected:!0}:_}),[u.nodes,o]),g=y.useMemo(()=>{const _=getComputedStyle(document.documentElement),k={};for(const S of Vz)k[S]=_.getPropertyValue(S).trim()||Mp;return k},[d]),v=y.useCallback((_,k)=>{const S=k.data;S.kind==="stream"&&r(S.stream.id)},[r]),b=y.useCallback(_=>{const k=_.data;return k.kind==="session"?g[uk(k.session.status,k.external).varName]??Mp:Mp},[g]);return u.nodes.length===0?a.jsx("div",{className:vt.empty,"data-testid":"coordination-graph-empty",children:"No active streams to visualize"}):a.jsx("div",{className:vt.graphContainer,"data-testid":"coordination-graph",children:a.jsxs(I_,{nodes:m,edges:p,nodeTypes:N$,edgeTypes:w$,onNodeClick:v,nodesConnectable:!1,fitView:!0,fitViewOptions:{padding:.2},minZoom:.3,maxZoom:2,children:[a.jsx(O_,{variant:B_.Dots,gap:24,size:1,color:"var(--text-disabled)"}),a.jsx(L_,{showInteractive:!1}),a.jsx(z_,{nodeColor:b,maskColor:"var(--bg-overlay)",style:{background:"var(--bg-inset)"}})]})})}function E$({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(jy.map(d=>[d,[]]));for(const d of t){const u=fl(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(S=>s.get(S)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(S=>S.status==="complete").length;let b;if(u==="paused"&&o){const S=o.get(d.id);S==="idle"?b="Needs input":S==="completed"&&(b="Ready to complete")}const _={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},k=c.get(u);k?k.push(_):c.get("not_started").push(_)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return jy.map(d=>{const u=Ja(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const A$="_boardContainer_1c4y1_1",D$="_column_1c4y1_17",M$="_columnHeader_1c4y1_34",R$="_columnIcon_1c4y1_47",I$="_columnLabel_1c4y1_52",O$="_columnCount_1c4y1_57",B$="_cardList_1c4y1_67",L$="_emptyPlaceholder_1c4y1_76",z$="_card_1c4y1_67",$$="_cardHeader_1c4y1_107",H$="_cardStatusIcon_1c4y1_113",P$="_cardTitle_1c4y1_119",U$="_cardBadges_1c4y1_127",V$="_badge_1c4y1_134",q$="_blockedBadge_1c4y1_146",G$="_childBadge_1c4y1_151",F$="_depBadge_1c4y1_155",K$="_parentBadge_1c4y1_159",Z$="_pausedSubBadge_1c4y1_166",Y$="_personaBadge_1c4y1_170",J$="_envBadge_1c4y1_174",W$="_emptyCta_1c4y1_178",X$="_ctaButton_1c4y1_188",Q$="_ctaDescription_1c4y1_204",dt={boardContainer:A$,column:D$,columnHeader:M$,columnIcon:R$,columnLabel:I$,columnCount:O$,cardList:B$,emptyPlaceholder:L$,card:z$,cardHeader:$$,cardStatusIcon:H$,cardTitle:P$,cardBadges:U$,badge:V$,blockedBadge:q$,childBadge:G$,depBadge:F$,parentBadge:K$,pausedSubBadge:Z$,personaBadge:Y$,envBadge:J$,emptyCta:W$,ctaButton:X$,ctaDescription:Q$};function e9({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=xt(),p=y.useMemo(()=>o.filter(_=>_.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(_=>[_.id,_.status])),[o]),g=y.useMemo(()=>new Map(p.map(_=>[_.id,_])),[p]),v=y.useMemo(()=>{const _=new Map(r.map(C=>[C.id,C])),k=new Map(c.map(C=>[C.id,C])),S=new Map(d.map(C=>[C.id,C])),j=new Map,T=new Map,N=new Map;for(const C of p)if(C.latestSessionId){const D=_.get(C.latestSessionId);if(D){if(j.set(C.id,D.endReason||D.status),D.personaId){const A=k.get(D.personaId);A&&T.set(C.id,A.name)}if(D.environmentId){const A=S.get(D.environmentId);A&&N.set(C.id,A.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:T,environmentNameByTaskId:N}},[p,r,c,d]),b=y.useMemo(()=>E$({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?a.jsxs("div",{className:dt.emptyCta,"data-testid":"board-empty-cta",children:[a.jsx("button",{className:dt.ctaButton,onClick:()=>u(Ii(t,void 0,s)),children:"Create Task"}),a.jsx("div",{className:dt.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):a.jsx("div",{className:dt.boardContainer,"data-testid":"board-container",children:b.map(_=>a.jsxs("section",{className:dt.column,"data-testid":`board-column-${_.status}`,"aria-label":`${_.label}, ${_.tasks.length} ${_.tasks.length===1?"task":"tasks"}`,children:[a.jsxs("div",{className:dt.columnHeader,children:[a.jsx("span",{className:dt.columnIcon,style:{color:_.style.color},children:_.style.icon}),a.jsx("span",{className:dt.columnLabel,children:_.label}),a.jsx("span",{className:dt.columnCount,"data-testid":`board-count-${_.status}`,children:_.tasks.length})]}),a.jsx("div",{className:dt.cardList,children:_.tasks.length===0?a.jsx("div",{className:dt.emptyPlaceholder,children:"No tasks"}):a.jsx(is,{mode:"popLayout",children:_.tasks.map(k=>a.jsx(Ut.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:a.jsx(t9,{boardTask:k,tasksById:g,personaName:v.personaNameByTaskId.get(k.task.id),envName:v.environmentNameByTaskId.get(k.task.id),onClick:()=>u(rs(k.task.id,void 0,t,s))})},k.task.id))})})]},_.status))})}function t9({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=Ja(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return a.jsxs("div",{className:dt.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c())},children:[a.jsxs("div",{className:dt.cardHeader,children:[a.jsx("span",{className:dt.cardStatusIcon,style:{color:v.color},children:v.icon}),a.jsx("span",{className:dt.cardTitle,children:d.title})]}),a.jsxs("div",{className:dt.cardBadges,children:[b&&a.jsx("span",{className:`${dt.badge} ${dt.parentBadge}`,title:b.title,children:b.title}),p>0&&a.jsxs("span",{className:`${dt.badge} ${dt.childBadge}`,children:[m,"/",p]}),u&&a.jsx("span",{className:`${dt.badge} ${dt.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&a.jsx("span",{className:`${dt.badge} ${dt.depBadge}`,children:"dep"}),g&&a.jsx("span",{className:`${dt.badge} ${dt.pausedSubBadge}`,children:g}),o&&a.jsx("span",{className:`${dt.badge} ${dt.personaBadge}`,children:o}),r&&a.jsx("span",{className:`${dt.badge} ${dt.envBadge}`,children:r})]})]})}const n9="_formContent_ymnez_1",s9="_section_ymnez_13",a9="_label_ymnez_19",i9="_titleInput_ymnez_26",o9="_descriptionTextarea_ymnez_58",r9="_selectField_ymnez_94",l9="_checkboxRow_ymnez_128",c9="_checkboxLabel_ymnez_141",d9="_fieldError_ymnez_146",jt={formContent:n9,section:s9,label:a9,titleInput:i9,descriptionTextarea:o9,selectField:r9,checkboxRow:l9,checkboxLabel:c9,fieldError:d9};function u9(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.linkedEnvironmentIds[0])??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const f9=100;function p9({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return a.jsxs("div",{className:jt.formContent,children:[a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-name",children:"Name"}),a.jsx("input",{id:"ws-name",className:jt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:f9,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-description",children:"Description"}),a.jsx("textarea",{id:"ws-description",className:jt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-repo",children:"Repository URL"}),a.jsx("input",{id:"ws-repo",className:jt.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)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-environment",children:"Environment"}),a.jsxs("select",{id:"ws-environment",className:jt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[a.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>a.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-persona",children:"Default Persona"}),a.jsxs("select",{id:"ws-persona",className:jt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>a.jsx("option",{value:m.id,children:m.name},m.id))]})]}),a.jsx("div",{className:jt.section,children:a.jsxs("label",{className:jt.checkboxRow,children:[a.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),a.jsx("span",{className:jt.checkboxLabel,children:"Enable worktree isolation"})]})}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-workdir",children:"Working Directory"}),a.jsx("input",{id:"ws-workdir",className:jt.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 pk=y.createContext(void 0),m9=4e3;function h9({children:t}){const[s,o]=y.useState([]),r=y.useRef(0),c=y.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=y.useCallback((u,p="info",m=m9)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return a.jsx(pk.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function mn(){const t=y.useContext(pk);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const hm="grackle-theme",mk="grackle-prefer-system",hk="(prefers-color-scheme: dark)";let Jr=[],rd;function Rp(){rd=void 0;for(const t of Jr)t()}function gm(){return typeof window>"u"?!1:window.matchMedia(hk).matches}function nl(){if(typeof localStorage>"u")return i_;try{const t=localStorage.getItem(hm);if(t!==null&&ok.has(t))return t}catch{}return i_}function _d(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(mk)==="true"}catch{return!1}}function vm(t){return Od.find(s=>s.variantLightId===t||s.variantDarkId===t)}function gk(t,s){const o=pm(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?gm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=vm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return gm()?r.variantDarkId:r.variantLightId}return t}function Ao(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=gk(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&Ao(nl(),_d());function g9(){return rd===void 0&&(rd={themeId:nl(),systemDark:gm(),preferSystem:_d()}),rd}function v9(t){return Jr=[...Jr,t],()=>{Jr=Jr.filter(s=>s!==t)}}function y9(){const t=y.useSyncExternalStore(v9,g9),{themeId:s,preferSystem:o}=t,r=gk(s,o),c=y.useCallback(u=>{if(ok.has(u)){try{localStorage.setItem(hm,u)}catch{}Ao(u,_d(),!0),Rp()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(mk,u?"true":"false")}catch{}if(u){const p=nl(),m=pm(p);if(m!=null&&m.hidden){const g=vm(p);if(g)try{localStorage.setItem(hm,g.id)}catch{}}}Ao(nl(),u,!0),Rp()},[]);return y.useEffect(()=>{Ao(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(hk),p=()=>{const m=nl(),g=_d();if(g){const v=pm(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&Ao(m,g),v!=null&&v.hidden){const b=vm(m);b!=null&&b.variantDarkId&&b.variantLightId&&Ao(m,g)}}Rp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const vk=y.createContext(void 0);function b9({children:t}){const s=y9();return a.jsx(vk.Provider,{value:s,children:t})}function bh(){const t=y.useContext(vk);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const yk=y.createContext(void 0),bk=y.createContext(void 0);function _9({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return a.jsx(bk.Provider,{value:r,children:a.jsx(yk.Provider,{value:s,children:t})})}function x9(){return y.useContext(yk)}function k9(){const t=y.useContext(bk);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const _h=y.createContext(void 0);function pt(){const t=y.useContext(_h);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function _k(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function xk(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function S9(t){return _k(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")&&(t.toolCallId===void 0||typeof t.toolCallId=="string")&&(t.turnId===void 0||typeof t.turnId=="string")&&(t.serverSeq===void 0||typeof t.serverSeq=="string")}const j9=new Set(["off","subscription","api_key"]),Zc=new Set(["off","on"]);function T9(t){return _k(t)&&j9.has(t.claude)&&Zc.has(t.github)&&Zc.has(t.copilot)&&Zc.has(t.codex)&&Zc.has(t.goose)}function kk(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 Sk(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 Co=5e3;function N9(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 Ai={label:"Home",url:Fo};function w9(t){return t?[Ai,{label:"Settings",url:Ti},{label:t,url:void 0}]:[Ai,{label:"Settings",url:void 0}]}const jk={label:"Environments",url:zo};function C9(){return[Ai,{label:"Environments",url:void 0}]}function E9(){return[Ai,{label:"New Chat",url:void 0}]}function A9(t){return[Ai,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function D9(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[Ai,jk,{label:(d==null?void 0:d.displayName)??"Environment",url:$o(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function M9(t,s,o,r,c){const d=N9(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(k=>k.id===p):void 0,g=s??(m==null?void 0:m.linkedEnvironmentIds[0]),v=g?r.find(k=>k.id===g):void 0,b=[Ai];v&&g&&(b.push(jk),b.push({label:v.displayName,url:$o(g)})),m&&g&&b.push({label:m.name,url:Ci(m.id,g)});for(let k=0;k<d.length-1;k++)b.push({label:d[k].title,url:rs(d[k].id,void 0,p,g)});const _=d[d.length-1];return b.push({label:(_==null?void 0:_.title)??t,url:void 0}),b}function xh(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 f_(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 R9(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 Ip(t,s,o){return t.toolCallId?t.toolCallId:s?o(s):void 0}function kh(t){const s=new Map;for(const u of t)if(u.raw)try{s.set(u,JSON.parse(u.raw))}catch{}const o=new Map;for(const u of t){if(u.eventType!=="tool_use")continue;const p=Ip(u,s.get(u),f_);if(p)try{const m=JSON.parse(u.content);o.set(p,{tool:m.tool,args:m.args})}catch{}}const r=new Set,d=t.map(u=>{if(u.eventType!=="tool_result")return u;const p=Ip(u,s.get(u),R9);if(!p)return u;const m=o.get(p);if(!m)return u;r.add(p);let g;const v=u.content.trim();if(v.startsWith("{"))try{const b=JSON.parse(v);typeof b.detailedContent=="string"&&(g=b.detailedContent)}catch{}return{...u,toolUseCtx:{...m,detailedResult:g}}}).filter(u=>{if(u.eventType!=="tool_use")return!0;const p=Ip(u,s.get(u),f_);return!(p&&r.has(p))});for(let u=0;u<d.length;u++){if(d[u].eventType!=="tool_use")continue;let p=!1;for(let m=u+1;m<d.length;m++)if(d[m].eventType!=="tool_use"){p=!0;break}p&&(d[u]={...d[u],settled:!0})}return d}function I9(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=Tk(s),d=s.filter(m=>ym(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||ym(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function Tk(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function ym(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function O9(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=Tk(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}):ym(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 B9(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 L9(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 As=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
325
+ --- End forwarded ---`}function kI(t){return t.replace(/[\r\n]+/g," ").trim().replace(/---/g,"—")}function SI({events:t,formatForClipboard:s}){const[o,r]=y.useState(!1),[c,d]=y.useState(new Set),u=y.useRef(void 0),p=y.useMemo(()=>c.size,[c]),m=y.useCallback(S=>{r(!0),S!==void 0?(d(new Set([S])),u.current=S):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((S,j)=>{if(j&&u.current!==void 0){const T=Math.min(u.current,S),N=Math.max(u.current,S);d(C=>{const D=new Set(C);for(let A=T;A<=N;A++)A<t.length&&ul(t[A])&&D.add(A);return D})}else d(T=>{const N=new Set(T);return N.has(S)?N.delete(S):N.add(S),N.size===0?(r(!1),u.current=void 0):u.current=S,N})},[t]),b=y.useCallback(()=>{const S=new Set;for(let j=0;j<t.length;j++)ul(t[j])&&S.add(j);d(S)},[t]),_=y.useCallback(()=>{d(new Set)},[]),k=y.useCallback(async()=>{const j=[...c].sort((N,C)=>N-C).filter(N=>N<t.length).map(N=>t[N]);if(j.length===0)return!1;const T=s(j);try{return await navigator.clipboard.writeText(T),!0}catch{return!1}},[c,t,s]);return{isSelecting:o,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:_,copySelected:k}}const jI="_wrapper_1cdza_1",TI="_scrollContainer_1cdza_9",NI="_selectingPadding_1cdza_16",wI="_toolbar_1cdza_20",CI="_directionToggle_1cdza_27",EI="_scrollToAnchor_1cdza_65",AI="_scrollToAnchorBottom_1cdza_89",DI="_scrollToAnchorTop_1cdza_93",MI="_eventOverflowWarning_1cdza_97",oa={wrapper:jI,scrollContainer:TI,selectingPadding:NI,toolbar:wI,directionToggle:CI,scrollToAnchor:EI,scrollToAnchorBottom:AI,scrollToAnchorTop:DI,eventOverflowWarning:MI},RI=10*1024,II=new Set(["running","idle"]);function OI(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 X1="grackle-stream-direction";function BI(){try{return localStorage.getItem(X1)==="reversed"}catch{return!1}}function LI({eventsDropped:t}){return t<=0?a.jsx(a.Fragment,{}):a.jsxs("div",{className:oa.eventOverflowWarning,role:"alert",children:[a.jsx(jm,{size:Pt,"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 hh({events:t,eventsDropped:s,emptyState:o,onShowToast:r,sessions:c,currentSessionId:d,environments:u,personas:p,onForward:m,sandboxProxyUrl:g}){const v=y.useRef(null),[b,_]=y.useState(BI),k=Y4(),[S,j]=y.useState(!1),[T,N]=y.useState(!1),[C,D]=y.useState(void 0),A=SI({events:t,formatForClipboard:W1}),E=y.useMemo(()=>t.filter(ul).length,[t]),R=y.useMemo(()=>c?c.filter(ce=>II.has(ce.status)&&ce.id!==d):[],[c,d]),B=y.useMemo(()=>b?[...t].reverse():t,[t,b]),{isAtAnchor:M,scrollToAnchor:$}=yI({scrollRef:v,contentLength:t.length,isReversed:b,paused:A.isSelecting}),Y=()=>{const ce=!b;_(ce);try{localStorage.setItem(X1,ce?"reversed":"default")}catch{}};y.useEffect(()=>{if(!A.isSelecting)return;const ce=me=>{me.key==="Escape"&&!S&&!T&&A.cancelSelection()};return window.addEventListener("keydown",ce),()=>{window.removeEventListener("keydown",ce)}},[A.isSelecting,A.cancelSelection,S,T]);const U=y.useCallback(async()=>{await A.copySelected()&&(r==null||r(`Copied ${A.selectedCount} message${A.selectedCount===1?"":"s"} to clipboard`,"success"))},[A,r]),X=y.useCallback(()=>[...A.selectedIndices].sort((me,xe)=>me-xe).filter(me=>me<t.length).map(me=>t[me]),[A.selectedIndices,t]),te=y.useCallback(ce=>{if(!ce)return"this session";const me=c==null?void 0:c.find(De=>De.id===ce);if(!me)return ce.slice(0,8);const xe=u==null?void 0:u.find(De=>De.id===me.environmentId);return(xe==null?void 0:xe.displayName)??me.environmentId.slice(0,8)},[c,u]),G=y.useCallback(async(ce,me)=>{if(!m)return;const xe=te(ce);try{await m(ce,me);const De=A.selectedCount;r==null||r(`Forwarded ${De} message${De===1?"":"s"} to ${xe}`,"success"),A.cancelSelection()}catch{r==null||r("Failed to forward messages","error")}},[m,te,r,A]),ne=y.useCallback(ce=>{j(!1);const me=X(),xe=te(d),De=xI(xe,me);if(new TextEncoder().encode(De).length>RI){D({sessionId:ce,text:De}),N(!0);return}G(ce,De).catch(()=>{})},[X,te,d,G]),H=y.useCallback(()=>{N(!1),C&&(G(C.sessionId,C.text).catch(()=>{}),D(void 0))},[C,G]),O=y.useCallback(()=>{N(!1),D(void 0)},[]),q=k?0:.2,ge=b?-8:8,se=C?Math.round(new TextEncoder().encode(C.text).length/1024):0;return a.jsxs("div",{className:oa.wrapper,children:[a.jsx("div",{className:oa.toolbar,children:a.jsx(Ei,{text:b?"Showing newest first":"Showing oldest first",children:a.jsx("button",{className:oa.directionToggle,onClick:Y,"aria-label":b?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:b?a.jsx(ky,{size:Pt,"aria-hidden":"true"}):a.jsx(Sy,{size:Pt,"aria-hidden":"true"})})})}),a.jsxs("div",{ref:v,className:`${oa.scrollContainer} ${A.isSelecting?oa.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&o,a.jsx(LI,{eventsDropped:s}),a.jsx(is,{initial:!1,children:B.map((ce,me)=>{const xe=b?t.length-1-me:me;return a.jsx(Ut.div,{initial:{opacity:0,y:ge},animate:{opacity:1,y:0},transition:{duration:q,ease:"easeOut"},children:a.jsx(z6,{copyText:_I(ce),isContentBearing:ul(ce),isSelecting:A.isSelecting,isSelected:A.selectedIndices.has(xe),checkboxLabel:OI(ce),onSelect:()=>{A.enterSelectionMode(xe)},onToggle:De=>{A.toggleEvent(xe,De)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:a.jsx(SD,{event:ce,toolUseCtx:ce.toolUseCtx,settled:ce.settled,sandboxProxyUrl:g})})},`${ce.sessionId}-${ce.timestamp}-${xe}`)})})]}),a.jsx(is,{children:A.isSelecting&&a.jsx(K6,{selectedCount:A.selectedCount,totalSelectable:E,onSelectAll:A.selectAll,onDeselectAll:A.deselectAll,onCopy:()=>{U().catch(()=>{})},onForward:m!==void 0?()=>{j(!0)}:void 0,forwardDisabled:R.length===0,onCancel:A.cancelSelection})}),a.jsx(hI,{isOpen:S,sessions:R,environments:u??[],personas:p,onSelect:ne,onCancel:()=>{j(!1)}}),a.jsx(bs,{isOpen:T,title:"Send large message?",description:`This will forward a large message (${se} KB). Continue?`,confirmLabel:"Send",onConfirm:H,onCancel:O}),a.jsx(is,{children:!M&&a.jsxs(Ut.button,{className:`${oa.scrollToAnchor} ${b?oa.scrollToAnchorTop:oa.scrollToAnchorBottom}`,onClick:$,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[b?a.jsx(Sy,{size:Pt,"aria-hidden":"true"}):a.jsx(ky,{size:Pt,"aria-hidden":"true"})," ","New events"]})})]})}function gh(t){const{value:s,onSave:o,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[b,_]=y.useState(""),k=y.useRef(!1),S=d===c,j=y.useCallback(B=>{v(B),_("")},[]),T=y.useCallback(()=>{_("")},[]),N=y.useCallback(()=>{k.current=!1,u==null||u(null),v(""),_("")},[u]),C=y.useCallback(()=>{const B=m?g.trim():g;if(r){const $=r(g);if($){_($);return}}const M=m?s.trim():s;if(B===M){N();return}o(B),N()},[g,s,m,r,o,N]),D=y.useCallback(()=>{k.current=!0,u==null||u(c),v(s),_("")},[c,s,u]),A=y.useCallback(B=>{if(k.current){k.current=!1;return}B.relatedTarget instanceof HTMLElement&&B.relatedTarget.dataset.editAction===c||C()},[c,C]),E=y.useCallback(B=>{B.key==="Escape"?N():B.key==="Enter"&&p&&C()},[N,p,C]),R=(()=>{if(!S)return!1;const B=m?s.trim():s;return(m?g.trim():g)!==B})();return y.useEffect(()=>{!S&&(g!==""||b!=="")&&(v(""),_(""))},[S,g,b]),{isEditing:S,draft:g,error:b,isDirty:R,startEdit:D,cancelEdit:N,save:C,setDraft:j,clearError:T,handleBlur:A,handleKeyDown:E,ignoreInitialBlurRef:k}}const zI="_editFieldWrapper_yuzty_1",$I="_editInput_yuzty_10",HI="_editTextarea_yuzty_42",PI="_editSelect_yuzty_78",UI="_editError_yuzty_111",VI="_editInputInvalid_yuzty_118",qI="_editHint_yuzty_123",GI="_unsavedDot_yuzty_132",FI="_metaValueClickable_yuzty_140",KI="_editButton_yuzty_159",ZI="_metaPlaceholder_yuzty_175",YI="_worktreeToggle_yuzty_180",it={editFieldWrapper:zI,editInput:$I,editTextarea:HI,editSelect:PI,editError:UI,editInputInvalid:VI,editHint:qI,unsavedDot:GI,metaValueClickable:FI,editButton:KI,metaPlaceholder:ZI,worktreeToggle:YI};function $t(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:b,ariaLabel:_,"data-testid":k}=t,S=y.useRef(null),j=gh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(j.isEditing){const N=window.setTimeout(()=>{var C;(C=S.current)==null||C.focus()},0);return()=>window.clearTimeout(N)}},[j.isEditing]),c==="create"){const N=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("input",{className:`${it.editInput} ${C?it.editInputInvalid:""}`,value:s,onChange:N,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),C&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:C})]})}if(j.isEditing)return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("input",{ref:S,className:`${it.editInput} ${j.error?it.editInputInvalid:""}`,value:j.draft,onChange:N=>j.setDraft(N.target.value),onBlur:j.handleBlur,onKeyDown:j.handleKeyDown,maxLength:b,placeholder:v,"aria-label":_,"data-testid":k?`${k}-input`:void 0}),j.isDirty&&a.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),j.error&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:j.error}),a.jsx("span",{className:it.editHint,children:"Enter to save · Esc to cancel"})]});const T=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>j.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),j.startEdit())},title:"Click to edit","aria-label":_,"data-testid":k?`${k}-button`:void 0,children:[T!==void 0?T:s?a.jsx("span",{children:s}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function fm(t){const{value:s,onSave:o,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=t,k=y.useRef(null),S=gh({value:s,onSave:o,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(S.isEditing){const T=window.setTimeout(()=>{var N;(N=k.current)==null||N.focus()},0);return()=>window.clearTimeout(T)}},[S.isEditing]),c==="create"){const T=C=>{m==null||m(C.target.value)},N=r==null?void 0:r(s);return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("textarea",{className:`${it.editTextarea} ${N?it.editInputInvalid:""}`,value:s,onChange:T,placeholder:v,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),N&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:N})]})}if(S.isEditing)return a.jsxs("div",{className:it.editFieldWrapper,children:[a.jsx("textarea",{ref:k,className:`${it.editTextarea} ${S.error?it.editInputInvalid:""}`,value:S.draft,onChange:T=>S.setDraft(T.target.value),onBlur:S.handleBlur,onKeyDown:S.handleKeyDown,title:b,"aria-label":b,"data-testid":_?`${_}-input`:void 0}),S.isDirty&&a.jsx("span",{className:it.unsavedDot,title:"Unsaved changes"}),S.error&&a.jsx("span",{className:it.editError,"data-testid":"edit-error",children:S.error}),a.jsx("span",{className:it.editHint,children:"Tab to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return a.jsxs("span",{role:"button",tabIndex:0,className:it.metaValueClickable,onClick:()=>S.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),S.startEdit())},title:"Click to edit","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[j!==void 0?j:s?a.jsx("span",{children:s}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function bd(t){var D;const{value:s,onSave:o,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":_}=t,k=y.useRef(null),S=gh({value:s,onSave:o,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(S.isEditing){const A=window.setTimeout(()=>{var E;(E=k.current)==null||E.focus()},0);return()=>window.clearTimeout(A)}},[S.isEditing]);const j=y.useCallback(A=>{const E=A.target.value;S.ignoreInitialBlurRef.current=!1,E!==s&&o(E),S.cancelEdit()},[s,o,S]),T=y.useCallback(A=>{if(S.ignoreInitialBlurRef.current){S.ignoreInitialBlurRef.current=!1;return}A.relatedTarget instanceof HTMLElement&&A.relatedTarget.dataset.editAction===d||S.cancelEdit()},[d,S]);if(r==="create")return a.jsx("select",{className:it.editSelect,value:s,onChange:A=>m==null?void 0:m(A.target.value),"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(A=>a.jsx("option",{value:A.value,children:A.label},A.value))});if(S.isEditing)return a.jsx("select",{ref:k,className:it.editSelect,value:S.draft,onChange:j,onBlur:T,title:b,"aria-label":b,"data-testid":_?`${_}-select`:void 0,children:c.map(A=>a.jsx("option",{value:A.value,children:A.label},A.value))});const N=g==null?void 0:g(s),C=(D=c.find(A=>A.value===s))==null?void 0:D.label;return a.jsxs("button",{type:"button",className:it.metaValueClickable,onClick:()=>S.startEdit(),title:"Click to change","aria-label":b,"data-testid":_?`${_}-button`:void 0,children:[N!==void 0?N:C?a.jsx("span",{children:C}):a.jsx("span",{className:it.metaPlaceholder,children:v||"None"}),a.jsx("span",{className:it.editButton,"aria-hidden":"true",children:"✏️"})]})}function JI(t){const{checked:s,onChange:o,label:r,ariaLabel:c,"data-testid":d}=t;return a.jsxs("label",{className:it.worktreeToggle,"data-testid":d,children:[a.jsx("input",{type:"checkbox",checked:s,onChange:u=>o(u.target.checked),"aria-label":c}),a.jsx("span",{children:r})]})}const WI="_nav_1snmp_1",XI="_searchForm_1snmp_8",QI="_searchInput_1snmp_15",e5="_searchButton_1snmp_33",t5="_clearButton_1snmp_68",n5="_workspaceSelect_1snmp_85",s5="_listHeader_1snmp_99",a5="_nodeList_1snmp_108",i5="_nodeItem_1snmp_116",o5="_indicator_1snmp_129",r5="_label_1snmp_136",l5="_badge_1snmp_145",Qn={nav:WI,searchForm:XI,searchInput:QI,searchButton:e5,clearButton:t5,workspaceSelect:n5,listHeader:s5,nodeList:a5,nodeItem:i5,indicator:o5,label:r5,badge:l5};function c5({nodes:t,workspaces:s,loading:o,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(S=>{S.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=y.useCallback(()=>{g(""),d()},[d]),_=y.useCallback(S=>{u(S)},[u]),k=y.useCallback(S=>{g(""),p(S)},[p]);return a.jsxs("div",{className:Qn.nav,"data-testid":"knowledge-nav",children:[a.jsxs("form",{className:Qn.searchForm,onSubmit:v,children:[a.jsx("input",{className:Qn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:S=>{g(S.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),a.jsx("button",{type:"submit",className:Qn.searchButton,disabled:o,children:"Go"})]}),r&&a.jsx("button",{type:"button",className:Qn.clearButton,onClick:b,children:"Clear search"}),a.jsxs("select",{className:Qn.workspaceSelect,onChange:S=>{k(S.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[a.jsx("option",{value:"",children:"All workspaces"}),s.map(S=>a.jsx("option",{value:S.id,children:S.name},S.id))]}),a.jsxs("div",{className:Qn.listHeader,children:["Nodes (",t.length,")"]}),a.jsx("ul",{className:Qn.nodeList,children:t.map(S=>a.jsxs("li",{className:Qn.nodeItem,onClick:()=>{_(S.id)},onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),_(S.id))},role:"button",tabIndex:0,children:[a.jsx("span",{className:Qn.indicator,style:{backgroundColor:S.kind==="reference"?"#4A9EFF":S.category==="decision"?"#22C55E":S.category==="concept"?"#A855F7":S.category==="snippet"?"#6B7280":"#EAB308"}}),a.jsx("span",{className:Qn.label,children:S.label}),a.jsx("span",{className:Qn.badge,children:S.kind==="reference"?S.sourceType:S.category})]},S.id))})]})}const d5="_container_bwu10_1",u5="_hamburger_bwu10_33",f5="_brand_bwu10_49",p5="_brandLogo_bwu10_68",m5="_info_bwu10_75",h5="_connectionLabel_bwu10_90",g5="_connectionDot_bwu10_103",v5="_connected_bwu10_106",y5="_disconnected_bwu10_110",b5="_connecting_bwu10_113",Ds={container:d5,hamburger:u5,brand:f5,brandLogo:p5,info:m5,connectionLabel:h5,connectionDot:g5,connected:v5,disconnected:y5,connecting:b5},_5={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},x5={connected:Ds.connected,connecting:Ds.connecting,disconnected:Ds.disconnected};function k5({connectionStatus:t,environments:s,sessions:o,onToggleSidebar:r,sidebarOpen:c}){const d=xt(),u=s.length,p=s.filter(v=>v.status==="connected").length,m=o.filter(v=>["running","idle"].includes(v.status)).length,g=_5[t];return a.jsxs("div",{className:Ds.container,children:[r&&a.jsx("button",{type:"button",className:Ds.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:a.jsx(CT,{size:At,"aria-hidden":"true"})}),a.jsx(Ei,{text:"Home",placement:"bottom",children:a.jsxs("button",{type:"button",className:Ds.brand,onClick:()=>d(Fo),"data-testid":"statusbar-brand",children:[a.jsx("img",{src:Id("icon-192x192.png"),alt:"",className:Ds.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),a.jsxs("div",{className:Ds.info,children:[a.jsxs("span",{"aria-label":g,children:[a.jsx("span",{className:`${Ds.connectionDot} ${x5[t]}`,"aria-hidden":"true",children:a.jsx(wi,{size:F_,fill:"currentColor"})})," ",a.jsx("span",{className:Ds.connectionLabel,"aria-hidden":"true",children:g})]}),a.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),a.jsxs("span",{children:[m," active"]})]})]})}const S5="_nav_gx5h3_1",j5="_tab_gx5h3_35",T5="_tabIcon_gx5h3_68",N5="_tabLabel_gx5h3_79",w5="_tabActive_gx5h3_84",C5="_tabEnd_gx5h3_90",wo={nav:S5,tab:j5,tabIcon:T5,tabLabel:N5,tabActive:w5,tabEnd:C5},ad=[{view:"dashboard",label:"Dashboard",icon:a.jsx(hT,{size:At}),route:Fo,testId:"sidebar-tab-dashboard",order:0},{view:"tasks",label:"Tasks",icon:a.jsx(Zj,{size:At}),route:dC,testId:"sidebar-tab-tasks",order:1},{view:"environments",label:"Environments",icon:a.jsx(IT,{size:At}),route:zo,testId:"sidebar-tab-environments",order:2},{view:"chat",label:"Root",icon:a.jsx(AT,{size:At}),route:cC,testId:"sidebar-tab-chat",order:3},{view:"knowledge",label:"Knowledge",icon:a.jsx(Hj,{size:At}),route:gx,testId:"sidebar-tab-knowledge",order:5},{view:"coordination",label:"Coordination",icon:a.jsx(BT,{size:At}),route:mx,testId:"sidebar-tab-coordination",order:6},{view:"settings",label:"Settings",icon:a.jsx(YT,{size:At}),route:aC,testId:"sidebar-tab-settings",align:"end"}];function E5(t){return t===Fo||t==="/"?"dashboard":t.startsWith(mx)?"coordination":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(gx)?"knowledge":t.startsWith(Ti)?"settings":"tasks"}function A5({tabs:t=ad}){var g;const s=Wt(),o=xt(),r=y.useRef(null),c=E5(s.pathname),d=y.useMemo(()=>{const v=(b,_)=>(b.order??Number.MAX_SAFE_INTEGER)-(_.order??Number.MAX_SAFE_INTEGER);return[...t.filter(b=>b.align!=="end").sort(v),...t.filter(b=>b.align==="end")]},[t]),u=(g=d.find(v=>v.align==="end"))==null?void 0:g.view,p=y.useCallback(v=>{o(v.route)},[o]),m=y.useCallback(v=>{var j,T;const b=(j=r.current)==null?void 0:j.querySelectorAll('[role="tab"]');if(!b)return;const _=Array.from(b).findIndex(N=>N===document.activeElement),k=_>=0?_:d.findIndex(N=>N.view===c);let S=k;if(v.key==="ArrowRight"||v.key==="j"||v.key==="J")v.preventDefault(),S=(k+1)%d.length;else if(v.key==="ArrowLeft"||v.key==="k"||v.key==="K")v.preventDefault(),S=(k-1+d.length)%d.length;else if(v.key==="Home")v.preventDefault(),S=0;else if(v.key==="End")v.preventDefault(),S=d.length-1;else return;o(d[S].route),(T=b[S])==null||T.focus()},[c,o,d]);return a.jsx("nav",{className:wo.nav,ref:r,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:m,"data-testid":"sidebar-nav",children:d.map(v=>{const b=v.view===c,_=v.view===u;return a.jsx(Ei,{text:v.label,placement:"bottom",className:_?wo.tabEnd:void 0,children:a.jsxs("button",{role:"tab",type:"button","aria-selected":b,tabIndex:b?0:-1,className:`${wo.tab} ${b?wo.tabActive:""}`,onClick:()=>p(v),"data-testid":v.testId,"aria-label":v.label,children:[a.jsx("span",{className:wo.tabIcon,"aria-hidden":"true",children:v.icon}),a.jsx("span",{className:wo.tabLabel,children:v.label})]})},v.view)})})}const D5="_container_pi6ii_1",M5="_content_pi6ii_66",s_={container:D5,content:M5},R5=320,Q1=220,ek=600,tk="grackle-sidebar-width";function I5(){try{const t=localStorage.getItem(tk);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=Q1&&s<=ek)return s}}catch{}return R5}function O5(t){try{localStorage.setItem(tk,String(t))}catch{}}function B5({content:t}){const[s]=y.useState(I5),o=y.useRef(null);if(y.useEffect(()=>{const r=o.current;if(!r)return;const c=new ResizeObserver(d=>{for(const u of d){const p=u.borderBoxSize[0];if(p){const m=Math.round(p.inlineSize);m>=Q1&&m<=ek&&O5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return a.jsx("div",{className:s_.container,ref:o,"data-testid":"sidebar",style:{width:s},children:a.jsx("div",{className:s_.content,children:t})})}const L5="_bar_tnfsh_1",z5="_btnPrimary_tnfsh_32",$5="_statusText_tnfsh_85",H5="_statusCompleted_tnfsh_90",P5="_statusFailed_tnfsh_94",U5="_statusBlocked_tnfsh_98",V5="_hintText_tnfsh_103",Et={bar:L5,btnPrimary:z5,statusText:$5,statusCompleted:H5,statusFailed:P5,statusBlocked:U5,hintText:V5};function q5({sessions:t,tasks:s,environments:o}){const r=xt(),c=Wt(),d=sn("/sessions/:sessionId"),u=sn("/tasks/:taskId"),p=sn("/tasks/:taskId/stream"),m=sn("/tasks/:taskId/edit"),g=sn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),v=sn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),b=sn("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),_=sn("/sessions/new"),k=sn("/environments/:environmentId/workspaces/:workspaceId"),S=sn("/tasks/new"),j=sn("/chat"),T=sn("/"),N=sn("/settings/*"),C=d==null?void 0:d.params.sessionId,D=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(g==null?void 0:g.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId),A=g??v??b,E=(A==null?void 0:A.params.environmentId)??(k==null?void 0:k.params.environmentId),R=c.pathname.startsWith("/environments")&&!k&&!A,B=!!j,M=!!_,$=!!k&&!g&&!v&&!b,Y=!!S;if(!!T&&!M&&!$&&!Y||!!N||(!!m||!!b)||Y||R||M)return a.jsx(a.Fragment,{});if(B)return o.find(ne=>ne.adapterType==="local"&&ne.status==="connected")?a.jsx(a.Fragment,{}):a.jsx("div",{className:Et.bar,children:a.jsx("span",{className:Et.hintText,children:"Add a local environment to start chatting"})});if($)return a.jsx("div",{className:Et.bar,children:a.jsx("span",{className:Et.hintText,children:"Select a task or click + to create one"})});if(D){const G=s.find(O=>O.id===D);if(!G)return a.jsx("div",{className:Et.bar,children:a.jsx("span",{className:Et.hintText,children:"Loading..."})});const ne=new Map(s.map(O=>[O.id,O])),H=G.dependsOn.some(O=>{const q=ne.get(O);return q!==void 0&&q.status!=="complete"});if(G.status==="not_started"){const O=H?G.dependsOn.map(q=>ne.get(q)).filter(q=>q&&q.status!=="complete").map(q=>q.title):[];return a.jsx("div",{className:Et.bar,children:H?a.jsxs("span",{className:Et.statusBlocked,children:["Blocked by: ",O.join(", ")]}):a.jsx("span",{className:Et.hintText,children:"Use the buttons above to start or manage this task"})})}if(G.status==="working"||G.status==="paused"){const O=G.latestSessionId||void 0,q=O?t.find(se=>se.id===O):void 0;return q&&q.status!=="stopped"?a.jsx(a.Fragment,{}):a.jsx("div",{className:Et.bar,children:a.jsx("span",{className:Et.hintText,children:"Waiting for agent..."})})}if(G.status==="complete")return a.jsxs("div",{className:Et.bar,children:[a.jsx("span",{className:`${Et.statusText} ${Et.statusCompleted}`,children:"Task completed"}),a.jsx("button",{onClick:()=>r(Ii(G.workspaceId,void 0,E)),className:Et.btnPrimary,children:"+ New Task"})]});if(G.status==="failed")return a.jsx("div",{className:Et.bar,children:a.jsx("span",{className:`${Et.statusText} ${Et.statusFailed}`,children:"Task failed"})})}if(C){const G=t.find(O=>O.id===C),ne=(G==null?void 0:G.status)==="stopped";if(G!==void 0&&!ne)return a.jsx(a.Fragment,{});if(ne)return a.jsxs("div",{className:Et.bar,children:[a.jsxs("span",{className:`${Et.statusText} ${Et.hintText}`,children:["Session ",G.endReason||G.status]}),a.jsx("button",{onClick:()=>r(ux(G.environmentId)),className:Et.btnPrimary,children:"+ New Chat"})]})}return a.jsx("div",{className:Et.bar,children:a.jsx("span",{className:Et.hintText,children:"Loading..."})})}const G5="_nav_14i94_1",F5="_tab_14i94_24",K5="_tabActive_14i94_62",Z5="_tabLabel_14i94_75",Y5="_statusDot_14i94_81",J5="_pulse_14i94_87",W5="_addButton_14i94_99",X5="_empty_14i94_132",Va={nav:G5,tab:F5,tabActive:K5,tabLabel:Z5,statusDot:Y5,pulse:J5,addButton:W5,empty:X5},Q5={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function eO({environments:t}){const s=xt(),o=y.useRef(null),r=sn("/environments/:environmentId"),c=sn("/environments/:environmentId/edit"),d=sn("/environments/:environmentId/workspaces/:workspaceId"),u=sn("/environments/:environmentId/workspaces/:workspaceId/*"),p=(r==null?void 0:r.params.environmentId)??(c==null?void 0:c.params.environmentId)??(d==null?void 0:d.params.environmentId)??(u==null?void 0:u.params.environmentId),m=p==="new"?void 0:p,g=y.useCallback(_=>{s($o(_))},[s]),v=y.useCallback(_=>{var N;const k=(N=o.current)==null?void 0:N.querySelectorAll('[role="tab"]');if(!k||k.length===0)return;const S=Array.from(k).findIndex(C=>C===document.activeElement),j=S>=0?S:t.findIndex(C=>C.id===m);let T=j;if(_.key==="ArrowDown"||_.key==="j"||_.key==="J")_.preventDefault(),T=(j+1)%k.length;else if(_.key==="ArrowUp"||_.key==="k"||_.key==="K")_.preventDefault(),T=(j-1+k.length)%k.length;else if(_.key==="Home")_.preventDefault(),T=0;else if(_.key==="End")_.preventDefault(),T=k.length-1;else return;T<t.length&&s($o(t[T].id)),k[T].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return a.jsxs("div",{className:Va.nav,"data-testid":"environment-nav",children:[a.jsx("nav",{ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(_=>{const k=_.id===m,S=_.id===b,j=Q5[_.status]||"var(--text-tertiary)",T=_.status==="connected";return a.jsxs("button",{role:"tab",type:"button","aria-selected":k,tabIndex:S?0:-1,className:`${Va.tab} ${k?Va.tabActive:""}`,onClick:()=>g(_.id),"data-testid":"env-nav-item",children:[a.jsx("span",{className:`${Va.statusDot} ${T?Va.pulse:""}`,style:{color:j},"aria-hidden":"true",children:a.jsx(wi,{size:F_,fill:"currentColor"})}),a.jsx("span",{className:Va.tabLabel,title:_.displayName||_.id,children:_.displayName||_.id})]},_.id)})}),a.jsx("button",{type:"button",className:Va.addButton,onClick:()=>s(nC),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&a.jsx("div",{className:Va.empty,children:"No environments yet."})]})}function tO(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 nk({text:t,indices:s,highlightClass:o}){if(!s||s.length===0)return a.jsx(a.Fragment,{children:t});const r=tO(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(a.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(a.jsx("mark",{className:o,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(a.jsx("span",{children:t.slice(d)},`p${d}`)),a.jsx(a.Fragment,{children:c})}function nO(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 sO(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 oN){c.add(d);const u=o.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=Ja(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=Ja(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const aO="_container_z4i38_1",iO="_header_z4i38_5",oO="_headerActions_z4i38_17",rO="_searchInput_z4i38_23",lO="_searchHighlight_z4i38_56",cO="_groupToggle_z4i38_62",dO="_groupToggleActive_z4i38_89",uO="_addButton_z4i38_93",fO="_taskRow_z4i38_120",pO="_selected_z4i38_140",mO="_expandArrow_z4i38_150",hO="_expanded_z4i38_157",gO="_leafSpacer_z4i38_161",vO="_taskStatusIcon_z4i38_166",yO="_taskTitle_z4i38_170",bO="_workspaceBadge_z4i38_177",_O="_childCountBadge_z4i38_195",xO="_dependencyBadge_z4i38_208",kO="_blockedBadge_z4i38_220",SO="_addChildButton_z4i38_225",jO="_emptyState_z4i38_268",TO="_statusGroupHeader_z4i38_275",NO="_statusGroupIcon_z4i38_294",wO="_statusGroupLabel_z4i38_298",CO="_statusGroupCount_z4i38_303",We={container:aO,header:iO,headerActions:oO,searchInput:rO,searchHighlight:lO,groupToggle:cO,groupToggleActive:dO,addButton:uO,taskRow:fO,selected:pO,expandArrow:mO,expanded:hO,leafSpacer:gO,taskStatusIcon:vO,taskTitle:yO,workspaceBadge:bO,childCountBadge:_O,dependencyBadge:xO,blockedBadge:kO,addChildButton:SO,emptyState:jO,statusGroupHeader:TO,statusGroupIcon:NO,statusGroupLabel:wO,statusGroupCount:CO},EO=[{name:"title",weight:2},{name:"description",weight:1}],sk=16,AO=16,ak="grackle-task-group-by-status";function a_(){try{return localStorage.getItem(ak)==="true"}catch{return!1}}function DO(t){try{localStorage.setItem(ak,String(t))}catch{}}function MO({group:t,isExpanded:s,onToggle:o,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return a.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[a.jsxs("div",{className:We.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:o,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),o())},children:[a.jsx("span",{className:`${We.expandArrow} ${s?We.expanded:""}`,"aria-hidden":"true",children:a.jsx(fa,{size:Ye})}),a.jsx("span",{className:We.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),a.jsx("span",{className:We.statusGroupLabel,children:t.label}),a.jsx("span",{className:We.statusGroupCount,children:t.tasks.length})]}),a.jsx(is,{children:s&&a.jsx(Ut.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=Ja(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return a.jsxs("div",{onClick:()=>c(rs(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(rs(p.id)))},className:`${We.taskRow} ${g?We.selected:""}`,style:{"--task-indent":`${sk}px`},"data-task-id":p.id,children:[a.jsx("span",{className:We.leafSpacer}),a.jsx("span",{className:We.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${fl(p.status)}`,children:m.icon}),a.jsx("span",{className:We.taskTitle,title:p.title,children:a.jsx(nk,{text:p.title,indices:d.get(p.id),highlightClass:We.searchHighlight})}),v&&a.jsx("span",{className:We.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function ik({node:t,depth:s,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=Ja(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(N=>u.get(N)!=="complete"),b=o.has(t.id),_=t.children.length>0,k=c===t.id,S=sk+s*AO,T=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{onClick:()=>d(rs(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:N=>{N.currentTarget===N.target&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),d(rs(t.id)))},className:`${We.taskRow} ${k?We.selected:""}`,style:{"--task-indent":`${S}px`},"data-task-id":t.id,children:[_&&a.jsx("span",{className:`${We.expandArrow} ${b?We.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:N=>{N.stopPropagation(),r(t.id)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),N.stopPropagation(),r(t.id))},children:a.jsx(fa,{size:Ye,"aria-hidden":"true"})}),!_&&a.jsx("span",{className:We.leafSpacer}),a.jsx("span",{className:We.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${fl(t.status)}`,children:g.icon}),a.jsx("span",{className:We.taskTitle,title:t.title,children:a.jsx(nk,{text:t.title,indices:p.get(t.id),highlightClass:We.searchHighlight})}),T&&a.jsx("span",{className:We.workspaceBadge,title:T,children:T}),_&&a.jsxs("span",{className:We.childCountBadge,children:[t.children.filter(N=>N.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&a.jsx("span",{className:`${We.dependencyBadge} ${v?We.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<X2&&a.jsx(Ei,{text:"Add child task",children:a.jsx("button",{onClick:N=>{N.stopPropagation(),d(Ii(t.workspaceId,t.id))},"aria-label":"Add child task",className:We.addChildButton,children:"+"})})]}),a.jsx(is,{children:_&&b&&a.jsx(Ut.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(N=>a.jsx(ik,{node:N,depth:s+1,expandedTasks:o,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},N.id))})})]})}function RO({workspaces:t,tasks:s}){const o=xt(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState(a_),[g,v]=y.useState(a_),[b,_]=y.useState(new Map),k=sn("/tasks/:taskId/*"),S=(k==null?void 0:k.params.taskId)!=="new"?k==null?void 0:k.params.taskId:void 0,j=y.useMemo(()=>new Map(s.map(G=>[G.id,G.status])),[s]),T=y.useMemo(()=>new Map(t.map(G=>[G.id,G.name])),[t]),N=()=>{const G=!p;DO(G),m(G),G&&(v(!0),_(new Map))},C=G=>{_(ne=>{const H=new Map(ne),O=H.has(G)?H.get(G):g;return H.set(G,!O),H})},D=G=>b.has(G)?b.get(G):g,A=G=>{c(ne=>{const H=new Set(ne);return H.has(G)?(H.delete(G),u(O=>new Set(O).add(G))):(H.add(G),u(O=>{const q=new Set(O);return q.delete(G),q})),H})};y.useEffect(()=>{const G=new Set(s.filter(ne=>ne.parentTaskId).map(ne=>ne.parentTaskId));G.size>0&&c(ne=>{const H=new Set(ne);for(const O of G)d.has(O)||H.add(O);return H})},[s,d]);const[E,R]=y.useState(""),{directMatchTaskIds:B,treeMatchTaskIds:M,titleHighlights:$}=y.useMemo(()=>{if(!E.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const G=W2(s,E,EO),ne=new Set(G.map(ge=>ge.item.id)),H=new Map;for(const ge of G){const se=ge.matches.find(ce=>ce.key==="title");se&&H.set(ge.item.id,se.indices)}const O=new Set(ne),q=new Map(s.map(ge=>[ge.id,ge]));for(const ge of[...ne]){let se=q.get(ge);for(;se!=null&&se.parentTaskId;)O.add(se.parentTaskId),se=q.get(se.parentTaskId)}return{directMatchTaskIds:ne,treeMatchTaskIds:O,titleHighlights:H}},[E,s]),Y=B!==null,U=Y?p?B:M:null,X=U?s.filter(G=>U.has(G.id)):s,te=p?[]:nO(X);return a.jsxs("div",{className:We.container,children:[a.jsxs("div",{className:We.header,children:[a.jsx("span",{children:"Tasks"}),a.jsxs("div",{className:We.headerActions,children:[a.jsx(Ei,{text:p?"Switch to tree view":"Group tasks by status",children:a.jsx("button",{className:`${We.groupToggle} ${p?We.groupToggleActive:""}`,onClick:N,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:a.jsx(jT,{size:Pt})})}),a.jsx(Ei,{text:"New task",children:a.jsx("button",{className:We.addButton,onClick:()=>o(Ii()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&a.jsx("input",{type:"text",value:E,onChange:G=>R(G.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:We.searchInput,"data-testid":"sidebar-search"}),p?sO(X,j).map(G=>a.jsx(MO,{group:G,isExpanded:D(G.status),onToggle:()=>C(G.status),selectedTaskId:S,navigate:o,titleHighlights:$,workspaceNames:T},G.status)):te.map(G=>a.jsx(ik,{node:G,depth:0,expandedTasks:r,toggleTask:A,selectedTaskId:S,navigate:o,taskStatusById:j,titleHighlights:$,workspaceNames:T},G.id)),X.length===0&&!Y&&a.jsx("div",{className:We.emptyState,children:"No tasks yet. Click + to create one."}),X.length===0&&Y&&a.jsx("div",{className:We.emptyState,children:"No matching tasks"})]})}const IO="_toast_ed2dk_1",OO="_success_ed2dk_18",BO="_icon_ed2dk_22",LO="_error_ed2dk_25",zO="_warning_ed2dk_32",$O="_info_ed2dk_38",HO="_message_ed2dk_53",PO="_close_ed2dk_60",qr={toast:IO,success:OO,icon:BO,error:LO,warning:zO,info:$O,message:HO,close:PO},UO={success:a.jsx(Di,{size:At}),error:a.jsx(Ls,{size:At}),warning:a.jsx(jm,{size:At}),info:a.jsx(Sm,{size:At})};function VO({toast:t,onDismiss:s}){return y.useEffect(()=>{const o=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(o)},[t.id,t.duration,s]),a.jsxs(Ut.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:[a.jsx("span",{className:qr.icon,"aria-hidden":"true",children:UO[t.variant]}),a.jsx("span",{className:qr.message,children:t.message}),a.jsx("button",{type:"button",className:qr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:a.jsx(Ls,{size:Pt,"aria-hidden":"true"})})]})}const qO="_container_qqse2_1",GO={container:qO};function FO({toasts:t,onDismiss:s}){return a.jsx("div",{className:GO.container,"data-testid":"toast-container",children:a.jsx(is,{children:t.map(o=>a.jsx(VO,{toast:o,onDismiss:s},o.id))})})}const KO="_callout_e5awm_1",ZO="_success_e5awm_11",YO="_icon_e5awm_15",JO="_error_e5awm_18",WO="_warning_e5awm_25",XO="_info_e5awm_32",QO="_content_e5awm_48",eB="_close_e5awm_53",Gr={callout:KO,success:ZO,icon:YO,error:JO,warning:WO,info:XO,content:QO,close:eB},tB={success:a.jsx(Di,{size:At}),error:a.jsx(Ls,{size:At}),warning:a.jsx(jm,{size:At}),info:a.jsx(Sm,{size:At})};function nB({variant:t="info",children:s,dismissible:o=!1,className:r}){const[c,d]=y.useState(!1);return a.jsx(a.Fragment,{children:!c&&a.jsxs("div",{className:[Gr.callout,Gr[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[a.jsx("span",{className:Gr.icon,"aria-hidden":"true",children:tB[t]}),a.jsx("span",{className:Gr.content,children:s}),o&&a.jsx("button",{type:"button",className:Gr.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:a.jsx(Ls,{size:Pt,"aria-hidden":"true"})})]})})}function sB({currentVersion:t,latestVersion:s,updateAvailable:o,isDocker:r}){if(!o)return a.jsx(a.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return a.jsx("div",{"data-testid":"update-banner",children:a.jsxs(nB,{variant:"info",dismissible:!0,children:[a.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,"). Run:"," ",a.jsx("code",{children:c})]})})}const aB="_container_m1fsr_1",iB="_heading_m1fsr_7",oB="_section_m1fsr_14",rB="_sectionTitle_m1fsr_26",lB="_sectionDescription_m1fsr_35",cB="_emptyState_m1fsr_41",dB="_tokenList_m1fsr_48",uB="_tokenRow_m1fsr_55",fB="_tokenBadge_m1fsr_68",pB="_tokenName_m1fsr_83",mB="_tokenTarget_m1fsr_90",hB="_deleteButton_m1fsr_99",gB="_addForm_m1fsr_113",vB="_formRow_m1fsr_119",yB="_input_m1fsr_125",bB="_select_m1fsr_155",_B="_addButton_m1fsr_187",xB="_emptyStateInfo_m1fsr_221",kB="_themeOptions_m1fsr_229",SB="_themeOption_m1fsr_229",jB="_themeOptionSelected_m1fsr_254",TB="_themeOptionHeader_m1fsr_259",NB="_themeOptionLabel_m1fsr_266",wB="_themeOptionDesc_m1fsr_273",CB="_variantToggle_m1fsr_279",EB="_variantButton_m1fsr_286",AB="_variantActive_m1fsr_305",DB="_themeSwatches_m1fsr_311",MB="_themeSwatch_m1fsr_311",RB="_systemToggle_m1fsr_325",IB="_systemToggleHint_m1fsr_341",OB="_themeActive_m1fsr_348",BB="_aboutGrid_m1fsr_354",LB="_aboutItem_m1fsr_360",zB="_aboutLabel_m1fsr_373",$B="_aboutValue_m1fsr_379",HB="_aboutDot_m1fsr_387",PB="_aboutDotConnected_m1fsr_394",UB="_aboutDotDisconnected_m1fsr_398",VB="_aboutDotConnecting_m1fsr_402",fe={container:aB,heading:iB,section:oB,sectionTitle:rB,sectionDescription:lB,emptyState:cB,tokenList:dB,tokenRow:uB,tokenBadge:fB,tokenName:pB,tokenTarget:mB,deleteButton:hB,addForm:gB,formRow:vB,input:yB,select:bB,addButton:_B,emptyStateInfo:xB,themeOptions:kB,themeOption:SB,themeOptionSelected:jB,themeOptionHeader:TB,themeOptionLabel:NB,themeOptionDesc:wB,variantToggle:CB,variantButton:EB,variantActive:AB,themeSwatches:DB,themeSwatch:MB,systemToggle:RB,systemToggleHint:IB,themeActive:OB,aboutGrid:BB,aboutItem:LB,aboutLabel:zB,aboutValue:$B,aboutDot:HB,aboutDotConnected:PB,aboutDotDisconnected:UB,aboutDotConnecting:VB},qB=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function GB({tokens:t,onSetToken:s,onDeleteToken:o,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,b]=y.useState(""),[_,k]=y.useState(null),S=N=>{if(N.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),b("")},j=N=>{k(N)},T=()=>{_&&(o(_),r==null||r("Token deleted","info")),k(null)};return a.jsxs(a.Fragment,{children:[a.jsx(bs,{isOpen:_!==null,title:"Delete Token?",description:_?`"${_}" will be permanently removed.`:void 0,onConfirm:T,onCancel:()=>k(null)}),a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Tokens"}),a.jsx("p",{className:fe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?a.jsx("div",{className:fe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):a.jsx("div",{className:fe.tokenList,children:t.map(N=>a.jsxs("div",{className:fe.tokenRow,children:[a.jsx("span",{className:fe.tokenBadge,children:N.tokenType}),a.jsx("span",{className:fe.tokenName,children:N.name}),a.jsx("span",{className:fe.tokenTarget,children:N.tokenType==="env_var"?N.envVar:N.filePath}),a.jsx("button",{className:fe.deleteButton,onClick:()=>j(N.name),title:`Delete ${N.name}`,"aria-label":`Delete ${N.name}`,children:a.jsx(Ls,{size:Pt,"aria-hidden":"true"})})]},N.name))}),a.jsxs("form",{className:fe.addForm,onSubmit:S,children:[a.jsxs("div",{className:fe.formRow,children:[a.jsx("input",{className:fe.input,type:"text",placeholder:"Token name",value:c,onChange:N=>d(N.target.value)}),a.jsx("input",{className:fe.input,type:"password",placeholder:"Value",value:u,onChange:N=>p(N.target.value)})]}),a.jsxs("div",{className:fe.formRow,children:[a.jsx("select",{className:fe.select,value:m,onChange:N=>g(N.target.value),children:qB.map(N=>a.jsx("option",{value:N.value,children:N.label},N.value))}),a.jsx("input",{className:fe.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:N=>b(N.target.value)}),a.jsx("button",{className:fe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Od=[{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"]}],ok=new Set(Od.map(t=>t.id)),i_="grackle";function pm(t){return Od.find(s=>s.id===t)}function FB({themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c}){return a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Appearance"}),a.jsx("p",{className:fe.sectionDescription,children:"Choose how Grackle looks across the app."}),a.jsx("div",{className:fe.themeOptions,children:Od.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 a.jsxs("button",{type:"button",className:`${fe.themeOption} ${p?fe.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>o(d.id),children:[a.jsxs("span",{className:fe.themeOptionHeader,children:[a.jsxs("span",{children:[a.jsx("span",{className:fe.themeOptionLabel,children:d.label}),a.jsx("span",{className:fe.themeOptionDesc,children:d.description})]}),u&&a.jsxs("span",{className:fe.variantToggle,children:[a.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),a.jsx("span",{role:"button",tabIndex:0,className:`${fe.variantButton} ${p&&!m?fe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),o(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),o(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&a.jsx("span",{className:fe.themeSwatches,children:d.swatches.map((g,v)=>a.jsx("span",{className:fe.themeSwatch,style:{background:g}},v))})]},d.id)})}),a.jsxs("label",{className:fe.systemToggle,children:[a.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),a.jsx("span",{children:"Match system light/dark preference"})]}),a.jsx("p",{className:fe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),a.jsxs("p",{className:fe.themeActive,children:["Active theme: ",a.jsx("strong",{children:s})]})]})}const KB={connected:"Connected",connecting:"Connecting...",disconnected:"Disconnected"},ZB={connected:fe.aboutDotConnected,connecting:fe.aboutDotConnecting,disconnected:fe.aboutDotDisconnected};function YB({connectionStatus:t,environments:s,sessions:o}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=o.filter(u=>["running","idle"].includes(u.status)).length;return a.jsxs("section",{className:fe.section,"data-testid":"about-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"About"}),a.jsx("p",{className:fe.sectionDescription,children:"Connection status and application information."}),a.jsxs("div",{className:fe.aboutGrid,children:[a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Connection"}),a.jsxs("span",{className:fe.aboutValue,children:[a.jsx("span",{className:`${fe.aboutDot} ${ZB[t]}`}),KB[t]]})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Environments"}),a.jsxs("span",{className:fe.aboutValue,children:[r,"/",c," connected"]})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Active Sessions"}),a.jsx("span",{className:fe.aboutValue,children:d})]}),a.jsxs("div",{className:fe.aboutItem,children:[a.jsx("span",{className:fe.aboutLabel,children:"Version"}),a.jsx("span",{className:fe.aboutValue,children:"0.133.1"})]})]})]})}const JB="_container_cddyd_1",WB="_header_cddyd_8",XB="_headerTitle_cddyd_35",QB="_badge_cddyd_44",eL="_headerActions_cddyd_54",tL="_body_cddyd_61",nL="_formContent_cddyd_73",sL="_section_cddyd_85",aL="_label_cddyd_91",iL="_titleInput_cddyd_98",oL="_descriptionTextarea_cddyd_131",rL="_parentContext_cddyd_167",lL="_parentLabel_cddyd_175",cL="_parentName_cddyd_182",dL="_personaSelect_cddyd_186",uL="_depList_cddyd_220",fL="_depItem_cddyd_226",pL="_depItemSelected_cddyd_248",mL="_noDeps_cddyd_252",hL="_btnPrimary_cddyd_258",gL="_btnGhost_cddyd_289",Qe={container:JB,header:WB,headerTitle:XB,badge:QB,headerActions:eL,body:tL,formContent:nL,section:sL,label:aL,titleInput:iL,descriptionTextarea:oL,parentContext:rL,parentLabel:lL,parentName:cL,personaSelect:dL,depList:uL,depItem:fL,depItemSelected:pL,noDeps:mL,btnPrimary:hL,btnGhost:gL};function rk({mode:t,taskId:s,workspaceId:o,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:b}){const _=xt(),k=t==="edit",S=k&&s?d.find(ke=>ke.id===s):void 0,j=k?(S==null?void 0:S.workspaceId)??"":o??"",[T,N]=y.useState(j),C=j||T,D=u.find(ke=>ke.id===C),A=c??(D==null?void 0:D.linkedEnvironmentIds[0]),E=!k&&!o,R=k?(S==null?void 0:S.parentTaskId)??"":r??"",B=R?d.find(ke=>ke.id===R):void 0,[M,$]=y.useState((S==null?void 0:S.title)??""),[Y,U]=y.useState((S==null?void 0:S.description)??""),[X,te]=y.useState((S==null?void 0:S.dependsOn)??[]),[G,ne]=y.useState((S==null?void 0:S.defaultPersonaId)??""),[H,O]=y.useState((S==null?void 0:S.canDecompose)??!1),[q,ge]=y.useState((S==null?void 0:S.injectKnowledge)??!0),[se,ce]=y.useState(!1),me=y.useRef(!1);y.useEffect(()=>{k&&S&&!me.current&&(me.current=!0,$(S.title),U(S.description),te(S.dependsOn),ne(S.defaultPersonaId),O(S.canDecompose),ge(S.injectKnowledge))},[k,S]);const xe=d.filter(ke=>ke.workspaceId===C&&(!k||ke.id!==s)&&ke.id!==R),De=M.trim().length>0&&(!k||S!==void 0)&&C.length>0,ot=ke=>{te(ct=>ct.includes(ke)?ct.filter(ue=>ue!==ke):[...ct,ke])},bt=()=>{!De||se||k&&S===void 0||(k&&s?(g(s,M.trim(),Y,X,G),b==null||b("Task updated","success"),v?v():_(rs(s,void 0,C,A),{replace:!0})):(ce(!0),m(C,M.trim(),Y,X.length>0?X:void 0,R||void 0,G,H,q,()=>{b==null||b("Task created","success"),_(o?Ci(o,A):"/tasks",{replace:!0})},ke=>{b==null||b(ke,"error"),ce(!1)})))},lt=()=>{if(v){v();return}_(k&&s?rs(s,void 0,C,A):o?Ci(o,A):"/tasks")},Pe=k?"edit task":R?"child task":"new task";return a.jsxs("div",{className:Qe.container,children:[a.jsxs("div",{className:Qe.header,children:[a.jsxs("div",{className:Qe.headerTitle,children:[a.jsx("span",{className:Qe.badge,children:Pe}),B&&a.jsxs("span",{className:Qe.parentContext,children:[a.jsx("span",{className:Qe.parentLabel,children:"Child of"}),a.jsx("span",{className:Qe.parentName,children:B.title})]})]}),a.jsxs("div",{className:Qe.headerActions,children:[a.jsx("button",{onClick:bt,disabled:!De||se,className:Qe.btnPrimary,"data-testid":"task-edit-save",children:se?"Creating…":k?"Save Changes":"Create"}),a.jsx("button",{onClick:lt,className:Qe.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:Qe.body,children:a.jsxs("div",{className:Qe.formContent,children:[E&&a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-workspace",children:"Workspace"}),a.jsxs("select",{id:"task-edit-workspace",value:T,onChange:ke=>N(ke.target.value),className:Qe.personaSelect,"data-testid":"task-edit-workspace",children:[a.jsx("option",{value:"",children:"Select a workspace..."}),u.map(ke=>a.jsx("option",{value:ke.id,children:ke.name},ke.id))]})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-title",children:"Title"}),a.jsx("input",{id:"task-edit-title",type:"text",value:M,onChange:ke=>$(ke.target.value),placeholder:"Task title...",autoFocus:!0,className:Qe.titleInput,"data-testid":"task-edit-title",onKeyDown:ke=>{ke.key==="Enter"&&De&&bt()}})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-description",children:"Description"}),a.jsx("textarea",{id:"task-edit-description",value:Y,onChange:ke=>U(ke.target.value),placeholder:"Describe the task... (markdown supported)",className:Qe.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),a.jsxs("div",{className:Qe.section,children:[a.jsx("label",{className:Qe.label,htmlFor:"task-edit-persona",children:"Default Persona"}),a.jsxs("select",{id:"task-edit-persona",value:G,onChange:ke=>ne(ke.target.value),className:Qe.personaSelect,"data-testid":"task-edit-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),p.map(ke=>a.jsx("option",{value:ke.id,children:ke.name},ke.id))]})]}),!k&&a.jsx("div",{className:Qe.section,children:a.jsxs("label",{className:Qe.depItem,"data-testid":"task-edit-can-decompose",children:[a.jsx("input",{type:"checkbox",checked:H,onChange:ke=>O(ke.target.checked)}),"Can spawn subtasks"]})}),!k&&a.jsx("div",{className:Qe.section,children:a.jsxs("label",{className:Qe.depItem,"data-testid":"task-edit-inject-knowledge",children:[a.jsx("input",{type:"checkbox",checked:q,onChange:ke=>ge(ke.target.checked)}),"Inject related prior work from the knowledge graph"]})}),a.jsxs("div",{className:Qe.section,children:[a.jsx("div",{className:Qe.label,children:"Dependencies"}),xe.length===0?a.jsx("div",{className:Qe.noDeps,children:"No other tasks in this workspace"}):a.jsx("div",{className:Qe.depList,children:xe.map(ke=>{const ct=X.includes(ke.id);return a.jsxs("label",{className:`${Qe.depItem} ${ct?Qe.depItemSelected:""}`,"data-testid":`dep-option-${ke.id}`,children:[a.jsx("input",{type:"checkbox",checked:ct,onChange:()=>ot(ke.id)}),ke.title,a.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",ke.status,")"]})]},ke.id)})})]})]})})]})}const vL="_actionButtons_1rjka_1",yL="_btnPrimary_1rjka_8",bL="_btnDanger_1rjka_39",_L="_btnGhost_1rjka_78",Yt={actionButtons:vL,btnPrimary:yL,btnDanger:bL,btnGhost:_L},xL=new Set(["stopped","suspended"]);function kL({task:t,sessionId:s,latestSessionStatus:o,isBlocked:r,onStart:c,onResume:d,onStop:u,onPause:p,onDelete:m,onEdit:g}){if(t.status==="not_started")return r?a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:g,className:Yt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{"data-testid":"task-header-start",onClick:c,className:Yt.btnPrimary,children:"Start"}),a.jsx("button",{onClick:g,className:Yt.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:u,className:Yt.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),a.jsx("button",{onClick:p,disabled:!s,className:Yt.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused"){const v=o!==void 0&&xL.has(o);return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:u,className:Yt.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),v&&a.jsx("button",{onClick:d,className:Yt.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}if(t.status==="complete")return a.jsx("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return a.jsxs("div",{className:Yt.actionButtons,"data-testid":"task-action-buttons",children:[a.jsx("button",{onClick:c,className:Yt.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),a.jsx("button",{onClick:m,className:Yt.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const SL="_workpadSection_y8nj9_1",jL="_workpadLabel_y8nj9_9",TL="_workpadStatus_y8nj9_17",NL="_workpadSummary_y8nj9_23",wL="_workpadExtra_y8nj9_29",qa={workpadSection:SL,workpadLabel:jL,workpadStatus:TL,workpadSummary:NL,workpadExtra:wL};function CL({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 a.jsxs("div",{className:qa.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:qa.workpadLabel,children:"Workpad"}),a.jsx("div",{className:qa.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return a.jsxs("div",{className:qa.workpadSection,"data-testid":"workpad-panel",children:[a.jsx("div",{className:qa.workpadLabel,children:"Workpad"}),s.status&&a.jsx("div",{className:qa.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&a.jsx("div",{className:qa.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&a.jsx("div",{className:qa.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const EL="_overviewDashboard_ng7kf_1",AL="_overviewHero_ng7kf_7",DL="_statusBadge_ng7kf_14",ML="_statusPending_ng7kf_26",RL="_statusAssigned_ng7kf_31",IL="_statusInProgress_ng7kf_36",OL="_statusReview_ng7kf_41",BL="_statusDone_ng7kf_46",LL="_statusFailed_ng7kf_51",zL="_statusWaitingInput_ng7kf_56",$L="_overviewBranchPill_ng7kf_61",HL="_branchLink_ng7kf_76",PL="_overviewSection_ng7kf_87",UL="_overviewLabel_ng7kf_93",VL="_overviewValue_ng7kf_100",qL="_overviewMuted_ng7kf_105",GL="_overviewMarkdown_ng7kf_111",FL="_envRow_ng7kf_186",KL="_envDot_ng7kf_192",ZL="_envDotGreen_ng7kf_199",YL="_envDotYellow_ng7kf_203",JL="_envDotRed_ng7kf_207",WL="_envDotGray_ng7kf_211",XL="_depList_ng7kf_215",QL="_depItem_ng7kf_221",e8="_depBlocked_ng7kf_228",t8="_depDone_ng7kf_232",n8="_timeline_ng7kf_236",s8="_timelineRow_ng7kf_242",a8="_timelineKey_ng7kf_249",i8="_timelineValue_ng7kf_255",o8="_timelineDelta_ng7kf_259",r8="_reviewNotes_ng7kf_270",be={overviewDashboard:EL,overviewHero:AL,statusBadge:DL,statusPending:ML,statusAssigned:RL,statusInProgress:IL,statusReview:OL,statusDone:BL,statusFailed:LL,statusWaitingInput:zL,overviewBranchPill:$L,branchLink:HL,overviewSection:PL,overviewLabel:UL,overviewValue:VL,overviewMuted:qL,overviewMarkdown:GL,envRow:FL,envDot:KL,envDotGreen:ZL,envDotYellow:YL,envDotRed:JL,envDotGray:WL,depList:XL,depItem:QL,depBlocked:e8,depDone:t8,timeline:n8,timelineRow:s8,timelineKey:a8,timelineValue:i8,timelineDelta:o8,reviewNotes:r8};function Gc(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 Cp(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 o_(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?be.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?be.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?be.envDotRed:be.envDotGray}function l8({status:t}){const s=Ja(t),o=iN(t);return a.jsx("span",{className:`${be.statusBadge} ${be[o]??be.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function c8({task:t,tasksById:s,environments:o,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?o.find(S=>S.id===g):void 0,b=r.find(S=>S.id===t.workspaceId),_=o.find(S=>S.id===d),k=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return a.jsxs("div",{className:be.overviewDashboard,"data-testid":"task-overview-panel",children:[a.jsxs("div",{className:be.overviewHero,children:[a.jsx(l8,{status:t.status}),t.branch&&a.jsx("span",{className:be.overviewBranchPill,"data-testid":"task-overview-branch",children:k?a.jsxs("a",{href:k,target:"_blank",rel:"noreferrer noopener",className:be.branchLink,children:["🔗"," ",t.branch]}):a.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-description",children:[a.jsx("div",{className:be.overviewLabel,children:"Description"}),a.jsx("div",{className:be.overviewMarkdown,children:a.jsx(xm,{remarkPlugins:[km],children:t.description})})]}),t.workpad&&a.jsx(CL,{workpad:t.workpad}),a.jsxs("div",{className:be.overviewSection,children:[a.jsx("div",{className:be.overviewLabel,children:"Environment"}),g&&v?a.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${be.envDot} ${o_(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),a.jsx("span",{className:be.overviewValue,children:v.displayName})]}):_?a.jsxs("div",{className:be.envRow,"data-testid":"task-overview-environment",children:[a.jsx("span",{className:`${be.envDot} ${o_(_.status)}`,title:_.status,"aria-label":`Status: ${_.status}`,role:"img"}),a.jsx("span",{className:be.overviewValue,children:_.displayName}),a.jsx("span",{className:be.overviewMuted,children:"(workspace default)"})]}):a.jsx("div",{className:be.overviewMuted,children:"Set in workspace settings"})]}),a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-dependencies",children:[a.jsx("div",{className:be.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?a.jsx("div",{className:be.overviewMuted,children:"None"}):a.jsx("div",{className:be.depList,children:t.dependsOn.map(S=>{const j=s.get(S),T=(j==null?void 0:j.status)==="complete";return a.jsxs("div",{className:`${be.depItem} ${T?be.depDone:be.depBlocked}`,children:[a.jsx("span",{children:T?"✓":"○"}),a.jsx("span",{children:(j==null?void 0:j.title)??S})]},S)})})]}),a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-timeline",children:[a.jsx("div",{className:be.overviewLabel,children:"Timeline"}),a.jsxs("div",{className:be.timeline,children:[t.createdAt&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Created"}),a.jsx("span",{className:be.timelineValue,children:Gc(t.createdAt)})]}),t.assignedAt&&(()=>{const S=Cp(t.createdAt,t.assignedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Assigned"}),a.jsx("span",{className:be.timelineValue,children:Gc(t.assignedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.startedAt&&(()=>{const S=Cp(t.assignedAt??t.createdAt,t.startedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Started"}),a.jsx("span",{className:be.timelineValue,children:Gc(t.startedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),t.completedAt&&(()=>{const S=Cp(t.startedAt,t.completedAt);return a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Completed"}),a.jsx("span",{className:be.timelineValue,children:Gc(t.completedAt)}),S!==void 0&&a.jsx("span",{className:be.timelineDelta,children:S})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&a.jsx("div",{className:be.overviewMuted,children:"No timing data"})]})]}),u&&u.costMillicents>0&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-usage",children:[a.jsx("div",{className:be.overviewLabel,children:"Usage"}),a.jsxs("div",{className:be.timeline,children:[a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Cost"}),a.jsx("span",{className:be.timelineValue,children:Ms(u.costMillicents)}),a.jsxs("span",{className:be.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costMillicents>u.costMillicents&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Total (incl. subtasks)"}),a.jsx("span",{className:be.timelineValue,children:Ms(p.costMillicents)}),a.jsxs("span",{className:be.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),(t.tokenBudget>0||t.costBudgetMillicents>0)&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-budget",children:[a.jsx("div",{className:be.overviewLabel,children:"Budget"}),a.jsxs("div",{className:be.timeline,children:[t.tokenBudget>0&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Tokens"}),a.jsxs("span",{className:be.timelineValue,children:[Ho(((u==null?void 0:u.inputTokens)??0)+((u==null?void 0:u.outputTokens)??0))," /"," ",Ho(t.tokenBudget)]})]}),t.costBudgetMillicents>0&&a.jsxs("div",{className:be.timelineRow,children:[a.jsx("span",{className:be.timelineKey,children:"Cost"}),a.jsxs("span",{className:be.timelineValue,children:[Ms((u==null?void 0:u.costMillicents)??0)," /"," ",Ms(t.costBudgetMillicents)]})]})]})]}),t.reviewNotes&&a.jsxs("div",{className:be.overviewSection,"data-testid":"task-overview-review-notes",children:[a.jsx("div",{className:be.overviewLabel,children:"Review Notes"}),a.jsx("div",{className:be.reviewNotes,children:t.reviewNotes})]})]})}function d8({plugins:t,loading:s,onSetPluginEnabled:o}){return a.jsxs("div",{className:fe.container,"data-testid":"plugins-panel",children:[a.jsx("h2",{className:fe.heading,children:"Plugins"}),a.jsxs("div",{className:fe.section,children:[a.jsx("p",{className:fe.sectionDescription,children:"Enable or disable optional Grackle plugins. A server restart is required for changes to take effect."}),s&&a.jsx("p",{className:fe.emptyState,children:"Loading plugins..."}),!s&&t.length===0&&a.jsx("p",{className:fe.emptyState,children:"No plugins found."}),!s&&t.map(r=>{const c=r.enabled!==r.loaded;return a.jsxs("div",{className:fe.tokenRow,"data-testid":`plugin-row-${r.name}`,children:[a.jsxs("div",{style:{flex:1},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[a.jsx("span",{className:fe.tokenName,children:r.name}),r.required&&a.jsx("span",{className:fe.tokenBadge,title:"Required — cannot be disabled",children:"required"})]}),a.jsx("div",{className:fe.tokenTarget,children:r.description}),c&&a.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"})]}),a.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:a.jsx("input",{type:"checkbox",checked:r.enabled,disabled:r.required,onChange:d=>o(r.name,d.target.checked),"data-testid":`plugin-toggle-${r.name}`,"aria-label":`Enable or disable ${r.name} plugin`,style:{accentColor:"var(--accent-green)",width:"16px",height:"16px"}})})]},r.name)})]})]})}function u8({githubAccounts:t,githubAccountsLoading:s,onAddGitHubAccount:o,onUpdateGitHubAccount:r,onRemoveGitHubAccount:c,onImportGitHubAccounts:d,onShowToast:u}){const[p,m]=y.useState(""),[g,v]=y.useState(""),[b,_]=y.useState(!1),[k,S]=y.useState(!1),[j,T]=y.useState(!1),[N,C]=y.useState(null),D=t.find(M=>M.id===N),A=async M=>{if(M.preventDefault(),!(!p.trim()||!g.trim())){S(!0);try{await o(p.trim(),g.trim(),"",b),u==null||u("GitHub account added","success"),m(""),v(""),_(!1)}catch($){const Y=$ instanceof Error?$.message:"Failed to add account";u==null||u(Y,"error")}finally{S(!1)}}},E=async M=>{try{await r(M,{isDefault:!0}),u==null||u("Default account updated","success")}catch($){const Y=$ instanceof Error?$.message:"Failed to update account";u==null||u(Y,"error")}},R=async()=>{if(N)try{await c(N),u==null||u("GitHub account removed","info")}catch(M){const $=M instanceof Error?M.message:"Failed to remove account";u==null||u($,"error")}finally{C(null)}},B=async()=>{T(!0);try{const M=await d();M.imported>0?u==null||u(`Imported ${M.imported} account(s): ${M.usernames.join(", ")}`,"success"):u==null||u("No new accounts to import","info")}catch(M){const $=M instanceof Error?M.message:"Import failed";u==null||u($,"error")}finally{T(!1)}};return a.jsxs(a.Fragment,{children:[a.jsx(bs,{isOpen:N!==null,title:"Remove GitHub Account?",description:D?`"${D.label}"${D.username?` (@${D.username})`:""} will be permanently removed.`:void 0,onConfirm:()=>{R().catch(()=>{})},onCancel:()=>C(null)}),a.jsxs("section",{className:fe.section,"data-testid":"github-accounts-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"GitHub Accounts"}),a.jsx("p",{className:fe.sectionDescription,children:"Register multiple GitHub accounts to use different identities per environment. The default account is used when no specific account is assigned."}),s&&t.length===0?a.jsx("div",{className:fe.emptyState,children:"Loading..."}):t.length===0?a.jsx("div",{className:fe.emptyStateInfo,children:"No GitHub accounts registered. Add one below or import from the gh CLI."}):a.jsx("div",{className:fe.tokenList,children:t.map(M=>a.jsxs("div",{className:fe.tokenRow,"data-testid":`github-account-row-${M.id}`,children:[M.isDefault&&a.jsx("span",{className:fe.tokenBadge,title:"Default account",children:"default"}),a.jsx("span",{className:fe.tokenName,children:M.label}),M.username&&a.jsxs("span",{className:fe.tokenTarget,children:["@",M.username]}),!M.isDefault&&a.jsx("button",{className:fe.deleteButton,onClick:()=>{E(M.id).catch(()=>{})},title:"Set as default","aria-label":`Set ${M.label} as default`,"data-testid":`github-account-set-default-${M.id}`,children:a.jsx(QT,{size:Pt,"aria-hidden":"true"})}),a.jsx("button",{className:fe.deleteButton,onClick:()=>C(M.id),title:`Remove ${M.label}`,"aria-label":`Remove ${M.label}`,"data-testid":`github-account-remove-${M.id}`,children:a.jsx(Ls,{size:Pt,"aria-hidden":"true"})})]},M.id))}),a.jsxs("form",{className:fe.addForm,onSubmit:M=>{A(M).catch(()=>{})},children:[a.jsxs("div",{className:fe.formRow,children:[a.jsx("input",{className:fe.input,type:"text",placeholder:"Label (e.g. personal, work)",value:p,onChange:M=>m(M.target.value),"data-testid":"github-account-label-input"}),a.jsx("input",{className:fe.input,type:"password",placeholder:"Personal access token",value:g,onChange:M=>v(M.target.value),"data-testid":"github-account-token-input"})]}),a.jsxs("div",{className:fe.formRow,children:[a.jsxs("label",{className:fe.tokenTarget,style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:b,onChange:M=>_(M.target.checked),"data-testid":"github-account-default-checkbox"}),"Set as default"]}),a.jsx("button",{className:fe.addButton,type:"submit",disabled:!p.trim()||!g.trim()||k,"data-testid":"github-account-add-button",children:k?"Adding...":"Add Account"}),a.jsx("button",{className:fe.addButton,type:"button",onClick:()=>{B().catch(()=>{})},disabled:j,"data-testid":"github-account-import-button",children:j?"Importing...":"Import from gh CLI"})]})]})]})]})}const f8="_container_legrg_1",p8="_header_legrg_8",m8="_headerTitle_legrg_35",h8="_badge_legrg_44",g8="_headerActions_legrg_54",v8="_body_legrg_61",y8="_formContent_legrg_73",b8="_section_legrg_85",_8="_label_legrg_91",x8="_nameInput_legrg_98",k8="_fieldInput_legrg_131",S8="_adapterSelect_legrg_164",j8="_readOnlyValue_legrg_198",T8="_codespaceSection_legrg_204",N8="_codespaceActions_legrg_210",w8="_creatingHint_legrg_216",C8="_errorHint_legrg_222",E8="_btnPrimary_legrg_235",A8="_btnGhost_legrg_266",re={container:f8,header:p8,headerTitle:m8,badge:h8,headerActions:g8,body:v8,formContent:y8,section:b8,label:_8,nameInput:x8,fieldInput:k8,adapterSelect:S8,readOnlyValue:j8,codespaceSection:T8,codespaceActions:N8,creatingHint:w8,errorHint:C8,btnPrimary:E8,btnGhost:A8},id=1,od=65535;function Ep(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=id&&s<=od}function Ap(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function D8({codespaceName:t,onCodespaceNameChange:s,envName:o,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[b,_]=y.useState(""),[k,S]=y.useState("");return g==="create"?a.jsxs("div",{className:re.codespaceSection,children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Repository"}),a.jsx("input",{type:"text",value:b,onChange:j=>_(j.target.value),placeholder:"owner/repo",className:re.fieldInput,"data-testid":"env-codespace-repo"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Machine Type"}),a.jsx("input",{type:"text",value:k,onChange:j=>S(j.target.value),placeholder:"Machine type (optional)...",className:re.fieldInput,"data-testid":"env-codespace-machine"})]}),a.jsxs("div",{className:re.codespaceActions,children:[a.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),k.trim()||void 0),v("pick"),_(""),S(""))},disabled:!b.trim(),className:re.btnPrimary,children:"Create"}),a.jsx("button",{onClick:()=>{v("pick"),_(""),S("")},className:re.btnGhost,children:"Cancel"})]})]}):a.jsx("div",{className:re.codespaceSection,children:a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Codespace"}),!u&&a.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:re.adapterSelect,"data-testid":"env-codespace-select",children:[a.jsx("option",{value:"",children:"Select a codespace..."}),c.map(j=>a.jsxs("option",{value:j.name,children:[j.name," (",j.repository,") — ",j.state]},j.name)),a.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&a.jsx("span",{className:re.creatingHint,children:"Creating codespace..."}),u&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:re.errorHint,children:u}),a.jsx("input",{type:"text",value:t,onChange:j=>s(j.target.value),placeholder:"Or enter codespace name manually...",className:re.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&a.jsx("span",{className:re.errorHint,children:d})]})})}function lk({mode:t,environmentId:s,environments:o,githubAccounts:r,onAddEnvironment:c,onUpdateEnvironment:d,onListCodespaces:u,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b,onListDockerContainers:_,dockerContainers:k,dockerContainersError:S,onShowToast:j}){const T=xt(),N=t==="edit",C=N&&s?o.find(le=>le.id===s):void 0,[D,A]=y.useState(""),[E,R]=y.useState("local"),[B,M]=y.useState(""),[$,Y]=y.useState(""),[U,X]=y.useState(""),[te,G]=y.useState(""),[ne,H]=y.useState(""),[O,q]=y.useState(""),[ge,se]=y.useState(""),[ce,me]=y.useState(""),[xe,De]=y.useState("create"),[ot,bt]=y.useState(""),[lt,Pe]=y.useState(null),ke=y.useCallback(()=>{const le={};if(E==="local"){if(B.trim()&&(le.host=B.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(le.port=ve)}}else if(E==="ssh"){if(le.host=B.trim(),U.trim()&&(le.user=U.trim()),$.trim()){const ve=Number($);Number.isInteger(ve)&&(le.sshPort=ve)}te.trim()&&(le.identityFile=te.trim())}else E==="docker"?xe==="attach"?ot.trim()&&(le.attach=ot.trim()):(ne.trim()&&(le.image=ne.trim()),O.trim()&&(le.repo=O.trim())):E==="codespace"&&(le.codespaceName=ge.trim());return le},[E,B,$,U,te,ne,O,ge,xe,ot]),ct=()=>!(!D.trim()||E==="ssh"&&!B.trim()||E==="codespace"&&!ge.trim()||E==="docker"&&xe==="attach"&&!ot.trim()||(E==="local"||E==="ssh")&&!Ep($)),ue=()=>{ct()&&(c(D.trim(),E,ke(),ce||void 0),j==null||j("Environment added successfully","success"),T(zo,{replace:!0}))},Re=()=>{T(s?$o(s):zo)},ee=y.useCallback((le,ve)=>{if(!C||!s)return;const et=Ap(C.adapterConfig),on=ve.trim();on?et[le]=on:delete et[le],d(s,{adapterConfig:et})},[C,s,d]),nt=y.useCallback((le,ve)=>{if(!C||!s)return;const et=Ap(C.adapterConfig);if(ve.trim()){const on=Number(ve);Number.isInteger(on)&&on>=id&&on<=od&&(et[le]=on)}else delete et[le];d(s,{adapterConfig:et})},[C,s,d]);if(N){if(!C)return a.jsxs("div",{className:re.container,children:[a.jsxs("div",{className:re.header,children:[a.jsx("div",{className:re.headerTitle,children:a.jsx("span",{className:re.badge,children:"edit environment"})}),a.jsx("div",{className:re.headerActions,children:a.jsx("button",{onClick:Re,className:re.btnGhost,children:"Back"})})]}),a.jsx("div",{className:re.body,children:a.jsx("div",{className:re.formContent,children:a.jsx("span",{className:re.readOnlyValue,children:"Environment not found"})})})]});const le=Ap(C.adapterConfig);return a.jsxs("div",{className:re.container,"data-testid":"env-edit-panel",children:[a.jsxs("div",{className:re.header,children:[a.jsx("div",{className:re.headerTitle,children:a.jsx("span",{className:re.badge,children:"edit environment"})}),a.jsx("div",{className:re.headerActions,children:a.jsx("button",{onClick:Re,className:re.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),a.jsx("div",{className:re.body,children:a.jsxs("div",{className:re.formContent,children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Name"}),a.jsx($t,{value:C.displayName,onSave:ve=>{s&&d(s,{displayName:ve})},validate:ve=>ve.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:lt,onActivate:Pe,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Adapter Type"}),a.jsx("span",{className:re.readOnlyValue,"data-testid":"env-edit-adapter-type",children:C.adapterType})]}),(C.adapterType==="codespace"||C.adapterType==="docker")&&(r.length>0||!!C.githubAccountId)&&a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"GitHub Account"}),a.jsxs("select",{value:C.githubAccountId||"",onChange:ve=>{s&&d(s,{githubAccountId:ve.target.value})},className:re.adapterSelect,"data-testid":"env-edit-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(ve=>a.jsxs("option",{value:ve.id,children:[ve.label,ve.username?` (@${ve.username})`:"",ve.isDefault?" — default":""]},ve.id))]})]}),C.adapterType==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Host"}),a.jsx($t,{value:String(le.host??""),onSave:ve=>ee("host",ve),mode:"edit",fieldId:"host",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Port"}),a.jsx($t,{value:String(le.port??""),onSave:ve=>nt("port",ve),validate:ve=>Ep(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),C.adapterType==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Host"}),a.jsx($t,{value:String(le.host??""),onSave:ve=>ee("host",ve),validate:ve=>ve.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:lt,onActivate:Pe,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"User"}),a.jsx($t,{value:String(le.user??""),onSave:ve=>ee("user",ve),mode:"edit",fieldId:"user",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"SSH Port"}),a.jsx($t,{value:String(le.sshPort??""),onSave:ve=>nt("sshPort",ve),validate:ve=>Ep(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:lt,onActivate:Pe,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Identity File"}),a.jsx($t,{value:String(le.identityFile??""),onSave:ve=>ee("identityFile",ve),mode:"edit",fieldId:"identityFile",activeFieldId:lt,onActivate:Pe,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),C.adapterType==="docker"&&le.attach!==void 0&&a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Attach (container)"}),a.jsx($t,{value:String(le.attach??""),onSave:ve=>ee("attach",ve),validate:ve=>ve.trim()===""?"Container name is required":void 0,mode:"edit",fieldId:"attach",activeFieldId:lt,onActivate:Pe,placeholder:"container name or ID",ariaLabel:"Attach container","data-testid":"env-edit-attach"})]}),C.adapterType==="docker"&&le.attach===void 0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Image"}),a.jsx($t,{value:String(le.image??""),onSave:ve=>ee("image",ve),mode:"edit",fieldId:"image",activeFieldId:lt,onActivate:Pe,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Repo"}),a.jsx($t,{value:String(le.repo??""),onSave:ve=>ee("repo",ve),mode:"edit",fieldId:"repo",activeFieldId:lt,onActivate:Pe,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),C.adapterType==="codespace"&&a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Codespace Name"}),a.jsx($t,{value:String(le.codespaceName??""),onSave:ve=>ee("codespaceName",ve),validate:ve=>ve.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:lt,onActivate:Pe,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return a.jsxs("div",{className:re.container,"data-testid":"env-create-panel",children:[a.jsxs("div",{className:re.header,children:[a.jsx("div",{className:re.headerTitle,children:a.jsx("span",{className:re.badge,children:"new environment"})}),a.jsxs("div",{className:re.headerActions,children:[a.jsx("button",{onClick:ue,disabled:!ct(),className:re.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),a.jsx("button",{onClick:Re,className:re.btnGhost,children:"Cancel"})]})]}),a.jsx("div",{className:re.body,children:a.jsxs("div",{className:re.formContent,children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-name",children:"Name"}),a.jsx("input",{id:"env-create-name",type:"text",value:D,onChange:le=>A(le.target.value),placeholder:"Environment name...",autoFocus:!0,className:re.nameInput,"data-testid":"env-create-name",onKeyDown:le=>{le.key==="Enter"&&ct()&&ue()}})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),a.jsxs("select",{id:"env-create-adapter",value:E,onChange:le=>{R(le.target.value),le.target.value==="codespace"&&u(ce||void 0)},className:re.adapterSelect,"data-testid":"env-create-adapter",children:[a.jsx("option",{value:"local",children:"local"}),a.jsx("option",{value:"ssh",children:"ssh"}),a.jsx("option",{value:"docker",children:"docker"}),a.jsx("option",{value:"codespace",children:"codespace"})]})]}),(E==="codespace"||E==="docker")&&r.length>0&&a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-github-account",children:"GitHub Account"}),a.jsxs("select",{id:"env-create-github-account",value:ce,onChange:le=>{me(le.target.value),E==="codespace"&&u(le.target.value||void 0)},className:re.adapterSelect,"data-testid":"env-create-github-account",children:[a.jsx("option",{value:"",children:"(Default)"}),r.map(le=>a.jsxs("option",{value:le.id,children:[le.label," (@",le.username,")",le.isDefault?" — default":""]},le.id))]})]}),E==="local"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:B,onChange:le=>M(le.target.value),placeholder:"Host (optional)...",className:re.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-port",children:"Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:id,max:od,value:$,onChange:le=>Y(le.target.value),placeholder:"Port (optional)...",className:re.fieldInput,"data-testid":"env-create-port"})]})]}),E==="ssh"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-host",children:"Host"}),a.jsx("input",{id:"env-create-host",type:"text",value:B,onChange:le=>M(le.target.value),placeholder:"Host (required)...",className:re.fieldInput,"data-testid":"env-create-host"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-user",children:"User"}),a.jsx("input",{id:"env-create-user",type:"text",value:U,onChange:le=>X(le.target.value),placeholder:"User (optional)...",className:re.fieldInput,"data-testid":"env-create-user"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-port",children:"SSH Port"}),a.jsx("input",{id:"env-create-port",type:"number",min:id,max:od,value:$,onChange:le=>Y(le.target.value),placeholder:"SSH port (optional)...",className:re.fieldInput,"data-testid":"env-create-port"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-identity",children:"Identity File"}),a.jsx("input",{id:"env-create-identity",type:"text",value:te,onChange:le=>G(le.target.value),placeholder:"Identity file (optional)...",className:re.fieldInput,"data-testid":"env-create-identity"})]})]}),E==="docker"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-docker-mode",children:"Source"}),a.jsxs("select",{id:"env-docker-mode",value:xe,onChange:le=>{const ve=le.target.value;De(ve),ve==="attach"&&_()},className:re.adapterSelect,"data-testid":"env-docker-mode",children:[a.jsx("option",{value:"create",children:"Create new container"}),a.jsx("option",{value:"attach",children:"Attach to existing container"})]})]}),xe==="create"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-image",children:"Image"}),a.jsx("input",{id:"env-create-image",type:"text",value:ne,onChange:le=>H(le.target.value),placeholder:"Image (optional)...",className:re.fieldInput,"data-testid":"env-create-image"})]}),a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,htmlFor:"env-create-repo",children:"Repo"}),a.jsx("input",{id:"env-create-repo",type:"text",value:O,onChange:le=>q(le.target.value),placeholder:"Repo (optional)...",className:re.fieldInput,"data-testid":"env-create-repo"})]})]}):a.jsxs("div",{className:re.section,children:[a.jsx("label",{className:re.label,children:"Container"}),!S&&k.length>0&&a.jsxs("select",{value:ot,onChange:le=>{bt(le.target.value),le.target.value&&!D.trim()&&A(le.target.value)},className:re.adapterSelect,"data-testid":"env-docker-container-select",children:[a.jsx("option",{value:"",children:"Select a container..."}),k.map(le=>a.jsxs("option",{value:le.name,children:[le.name," (",le.image,") ",le.status]},le.id))]}),(S||k.length===0)&&a.jsxs(a.Fragment,{children:[S?a.jsx("span",{className:re.errorHint,children:S}):a.jsx("span",{className:re.creatingHint,children:"No running containers found."}),a.jsx("input",{type:"text",value:ot,onChange:le=>{bt(le.target.value),le.target.value&&!D.trim()&&A(le.target.value)},placeholder:"Enter container name/ID...",className:re.fieldInput,"data-testid":"env-docker-container-manual"})]})]})]}),E==="codespace"&&a.jsx(D8,{codespaceName:ge,onCodespaceNameChange:se,envName:D,onEnvNameChange:A,codespaces:p,codespaceError:m,codespaceListError:g,codespaceCreating:v,onCreateCodespace:b})]})})]})}const M8="_group_1iprv_1",R8="_groupTitle_1iprv_8",I8="_shortcutList_1iprv_17",O8="_shortcutRow_1iprv_23",B8="_keys_1iprv_36",L8="_kbd_1iprv_43",z8="_description_1iprv_60",xi={group:M8,groupTitle:R8,shortcutList:I8,shortcutRow:O8,keys:B8,kbd:L8,description:z8},$8=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Root",shortcuts:[{keys:["Ctrl/Cmd","Enter"],description:"Send message (when the composer is focused)"},{keys:["Enter"],description:"Insert a new line in the message composer"}]}];function H8(){return a.jsxs("section",{className:fe.section,"data-testid":"keyboard-shortcuts-panel",children:[a.jsx("h3",{className:fe.sectionTitle,children:"Keyboard Shortcuts"}),a.jsx("p",{className:fe.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),$8.map(t=>a.jsxs("div",{className:xi.group,children:[a.jsx("h4",{className:xi.groupTitle,children:t.title}),a.jsx("div",{className:xi.shortcutList,children:t.shortcuts.map(s=>a.jsxs("div",{className:xi.shortcutRow,children:[a.jsx("span",{className:xi.keys,children:s.keys.map(o=>a.jsx("kbd",{className:xi.kbd,children:o},o))}),a.jsx("span",{className:xi.description,children:s.description})]},s.description))})]},t.title))]})}const P8=[{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 U8({credentialProviders:t,onUpdateCredentialProviders:s}){const o=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return a.jsxs("section",{className:fe.section,children:[a.jsx("h3",{className:fe.sectionTitle,children:"Credential Providers"}),a.jsx("p",{className:fe.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),a.jsx("div",{className:fe.tokenList,children:P8.map(r=>a.jsxs("div",{className:fe.tokenRow,children:[a.jsx("span",{className:fe.tokenName,children:r.label}),a.jsx("span",{className:fe.tokenTarget,children:r.description}),a.jsx("select",{className:fe.select,value:t[r.key],onChange:c=>o(r.key,c.target.value),children:r.options.map(c=>a.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const V8="_container_10efq_1",q8="_header_10efq_7",G8="_list_10efq_105",F8="_card_10efq_111",K8="_cardHeader_10efq_125",Z8="_cardTitle_10efq_135",Y8="_defaultBadge_10efq_141",J8="_cardActions_10efq_155",W8="_description_10efq_160",X8="_meta_10efq_166",Q8="_empty_10efq_212",e7="_typeBadge_10efq_362",es={container:V8,header:q8,list:G8,card:F8,cardHeader:K8,cardTitle:Z8,defaultBadge:Y8,cardActions:J8,description:W8,meta:X8,empty:Q8,typeBadge:e7};function t7({personas:t,appDefaultPersonaId:s,onDeletePersona:o,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await o(v),p(null)};return a.jsxs("div",{className:es.container,children:[a.jsxs("div",{className:es.header,children:[a.jsx("h2",{children:"Personas"}),a.jsx(an,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?a.jsx("p",{className:es.empty,children:"No personas yet. Create one to get started."}):a.jsx("div",{className:es.list,children:t.map(v=>{const b=s===v.id,_=v.type==="script";return a.jsxs("div",{className:es.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(v.id))},children:[a.jsxs("div",{className:es.cardHeader,children:[a.jsxs("span",{className:es.cardTitle,children:[a.jsx("strong",{children:v.name}),a.jsx("span",{className:es.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:_?"Script":"Agent"}),b&&a.jsx("span",{className:es.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),a.jsxs("div",{className:es.cardActions,onClick:k=>k.stopPropagation(),children:[!b&&a.jsx(an,{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"}),a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&a.jsx("p",{className:es.description,children:v.description}),a.jsxs("div",{className:es.meta,children:[v.runtime&&a.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&a.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&a.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),a.jsx(bs,{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 n7="_container_uy08i_1",s7="_header_uy08i_7",a7="_count_uy08i_13",i7="_presets_uy08i_18",o7="_presetButton_uy08i_24",r7="_filterInput_uy08i_41",l7="_groups_uy08i_53",c7="_group_uy08i_53",d7="_groupHeader_uy08i_68",u7="_groupName_uy08i_77",f7="_groupCount_uy08i_81",p7="_toolList_uy08i_87",m7="_toolItem_uy08i_95",h7="_toolName_uy08i_103",bn={container:n7,header:s7,count:a7,presets:i7,presetButton:o7,filterInput:r7,groups:l7,group:c7,groupHeader:d7,groupName:u7,groupCount:f7,toolList:p7,toolItem:m7,toolName:h7},g7=(()=>{const t=new Map;for(const s of H_){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()}))})(),v7=[{name:"default",label:"Default",tools:$_},{name:"worker",label:"Worker",tools:Q2},{name:"orchestrator",label:"Orchestrator",tools:ej},{name:"admin",label:"Admin",tools:tj}];function r_({selectedTools:t,onChange:s,disabled:o}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.useCallback(v=>{if(o)return;const b=new Set(d);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[d,s,o]),p=y.useCallback((v,b)=>{if(o)return;const _=new Set(d);for(const k of v)b?_.delete(k):_.add(k);s([..._].sort())},[d,s,o]),m=y.useCallback(v=>{o||s([...v].sort())},[s,o]),g=r.toLowerCase();return a.jsxs("div",{className:bn.container,"data-testid":"mcp-tool-selector",children:[a.jsx("div",{className:bn.header,children:a.jsx("span",{className:bn.count,children:t.length===0?`Using default (${$_.length} tools)`:`${t.length} of ${H_.size} tools selected`})}),a.jsxs("div",{className:bn.presets,"data-testid":"mcp-tool-presets",children:[v7.map(v=>a.jsx("button",{type:"button",className:bn.presetButton,disabled:o,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),a.jsx("button",{type:"button",className:bn.presetButton,disabled:o,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),a.jsx("input",{type:"text",className:bn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:o,"data-testid":"mcp-tool-filter"}),a.jsx("div",{className:bn.groups,children:g7.map(({group:v,tools:b})=>{const _=g?b.filter(S=>S.toLowerCase().includes(g)):b;if(_.length===0)return null;const k=_.every(S=>d.has(S));return a.jsxs("div",{className:bn.group,"data-testid":`tool-group-${v}`,children:[a.jsxs("label",{className:bn.groupHeader,children:[a.jsx("input",{type:"checkbox",checked:k,onChange:()=>p(_,k),disabled:o,"data-testid":`group-toggle-${v}`}),a.jsx("span",{className:bn.groupName,children:v}),a.jsxs("span",{className:bn.groupCount,children:["(",_.filter(S=>d.has(S)).length,"/",_.length,")"]})]}),a.jsx("div",{className:bn.toolList,children:_.map(S=>a.jsxs("label",{className:bn.toolItem,children:[a.jsx("input",{type:"checkbox",checked:d.has(S),onChange:()=>u(S),disabled:o,"data-testid":`tool-${S}`}),a.jsx("span",{className:bn.toolName,children:S})]},S))})]},v)})})]})}function mm(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 ck(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 y7="_container_1gfuq_1",b7="_header_1gfuq_7",_7="_list_1gfuq_19",x7="_card_1gfuq_25",k7="_cardHeader_1gfuq_40",S7="_cardTitle_1gfuq_46",j7="_statusBadge_1gfuq_56",T7="_enabled_1gfuq_68",N7="_disabled_1gfuq_71",w7="_cardActions_1gfuq_75",C7="_cardMeta_1gfuq_80",E7="_empty_1gfuq_98",ts={container:y7,header:b7,list:_7,card:x7,cardHeader:k7,cardTitle:S7,statusBadge:j7,enabled:T7,disabled:N7,cardActions:w7,cardMeta:C7,empty:E7};function A7({schedules:t,personas:s,onDeleteSchedule:o,onToggleEnabled:r,onNavigateToNew:c,onNavigateToSchedule:d}){const[u,p]=y.useState(null),m=u?t.find(_=>_.id===u):void 0,g=async _=>{await o(_),p(null)},v=y.useMemo(()=>{const _=new Map;for(const k of s)_.set(k.id,k.name);return _},[s]),b=_=>v.get(_)??_;return a.jsxs("div",{className:ts.container,children:[a.jsxs("div",{className:ts.header,children:[a.jsx("h2",{children:"Schedules"}),a.jsx(an,{variant:"primary",size:"md",onClick:c,"data-testid":"schedule-new-button",children:"+ New Schedule"})]}),t.length===0?a.jsx("p",{className:ts.empty,"data-testid":"schedule-empty-state",children:"No schedules yet. Create one to run tasks on a recurring cadence."}):a.jsx("div",{className:ts.list,children:t.map(_=>a.jsxs("div",{className:ts.card,"data-testid":`schedule-card-${_.id}`,onClick:()=>d(_.id),role:"button",tabIndex:0,onKeyDown:k=>{k.currentTarget===k.target&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(_.id))},children:[a.jsxs("div",{className:ts.cardHeader,children:[a.jsxs("span",{className:ts.cardTitle,children:[a.jsx("strong",{children:_.title}),a.jsx("span",{className:`${ts.statusBadge} ${_.enabled?ts.enabled:ts.disabled}`,"data-testid":`schedule-status-badge-${_.id}`,children:_.enabled?"Enabled":"Disabled"})]}),a.jsxs("div",{className:ts.cardActions,onClick:k=>k.stopPropagation(),children:[a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>{(async()=>{await r(_.id,{enabled:!_.enabled})})().catch(()=>{})},"data-testid":`schedule-toggle-${_.id}`,title:_.enabled?"Disable schedule":"Enable schedule",children:_.enabled?"Disable":"Enable"}),a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>d(_.id),"data-testid":`schedule-edit-${_.id}`,children:"Edit"}),a.jsx(an,{variant:"ghost",size:"sm",onClick:()=>p(_.id),"data-testid":`schedule-delete-${_.id}`,children:"Delete"})]})]}),a.jsxs("div",{className:ts.cardMeta,children:[a.jsx("span",{"data-testid":`schedule-expression-${_.id}`,children:_.scheduleExpression}),_.personaId&&a.jsxs("span",{"data-testid":`schedule-persona-${_.id}`,children:["Persona: ",b(_.personaId)]}),a.jsxs("span",{"data-testid":`schedule-last-run-${_.id}`,children:["Last run: ",_.lastRunAt?mm(_.lastRunAt):"Never"]}),_.enabled&&_.nextRunAt?a.jsxs("span",{"data-testid":`schedule-next-run-${_.id}`,children:["Next run: ",ck(_.nextRunAt)]}):null,_.runCount>0&&a.jsxs("span",{"data-testid":`schedule-run-count-${_.id}`,children:["Runs: ",_.runCount]})]})]},_.id))}),a.jsx(bs,{isOpen:u!==null,title:"Delete Schedule?",description:`"${(m==null?void 0:m.title)??""}" will be permanently removed. Tasks already created by this schedule will not be affected.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const D7="_nav_1bhou_1",M7="_tab_1bhou_24",R7="_tabIcon_1bhou_62",I7="_tabActive_1bhou_68",Fc={nav:D7,tab:M7,tabIcon:R7,tabActive:I7},ia=[{path:"credentials",label:"Credentials",icon:a.jsx(yT,{size:At})},{path:"github-accounts",label:"GitHub Accounts",icon:a.jsx(uT,{size:At})},{path:"personas",label:"Personas",icon:a.jsx(nN,{size:At})},{path:"schedules",label:"Schedules",icon:a.jsx(Uj,{size:At})},{path:"appearance",label:"Appearance",icon:a.jsx(zT,{size:At})},{path:"shortcuts",label:"Shortcuts",icon:a.jsx(_T,{size:At})},{path:"plugins",label:"Plugins",icon:a.jsx(qT,{size:At})},{path:"about",label:"About",icon:a.jsx(Sm,{size:At})}];function O7(){var u;const t=Wt(),s=xt(),o=y.useRef(null),r=((u=ia.find(p=>{const m=`${Ti}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??ia[0].path,c=y.useCallback(p=>{s(`${Ti}/${p}`)},[s]),d=y.useCallback(p=>{var k,S;const m=(k=o.current)==null?void 0:k.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(j=>j===document.activeElement),v=g>=0?g:ia.findIndex(j=>j.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%ia.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+ia.length)%ia.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=ia.length-1;else return;const _=ia[b].path;s(`${Ti}/${_}`),(S=m[b])==null||S.focus()},[r,s]);return a.jsx("nav",{className:Fc.nav,ref:o,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:ia.map(p=>{const m=p.path===r;return a.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Fc.tab} ${m?Fc.tabActive:""}`,onClick:()=>c(p.path),children:[a.jsx("span",{className:Fc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}const B7=["lifecycle:","pipe:","stdin:"];function vh(t){return t.selfEcho?"chatroom":t.name.startsWith("pipe:")?"pipe":"channel"}function dk(t,s){let o=!1;for(const r of t.subscribers){const c=s.get(r.sessionId);if(c&&(o=!0,c.taskId))return{kind:"task",taskId:c.taskId}}return o?{kind:"unattached"}:{kind:"external"}}function L7(t,s){const o=new Map(s.map(u=>[u.id,u])),r=new Map,c=[];for(const u of t){const p=dk(u,o);if(p.kind==="task"){const m=r.get(p.taskId);m?m.push(u):r.set(p.taskId,[u])}else c.push(u)}const d=Array.from(r,([u,p])=>({taskId:u,streams:p}));return c.length>0&&d.push({taskId:void 0,streams:c}),d}const z7="_container_16qkd_1",$7="_header_16qkd_7",H7="_title_16qkd_15",P7="_headerActions_16qkd_21",U7="_internalsToggle_16qkd_27",V7="_refreshButton_16qkd_37",q7="_state_16qkd_52",G7="_group_16qkd_59",F7="_groupHeader_16qkd_63",K7="_row_16qkd_72",Z7="_selected_16qkd_92",Y7="_kindBadge_16qkd_96",J7="_kindChatroom_16qkd_108",W7="_kindPipe_16qkd_114",X7="_kindChannel_16qkd_120",Q7="_streamName_16qkd_126",ez="_meta_16qkd_135",Jt={container:z7,header:$7,title:H7,headerActions:P7,internalsToggle:U7,refreshButton:V7,state:q7,group:G7,groupHeader:F7,row:K7,selected:Z7,kindBadge:Y7,kindChatroom:J7,kindPipe:W7,kindChannel:X7,streamName:Q7,meta:ez},tz={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function nz({kind:t}){return t==="chatroom"?a.jsx(MT,{size:Ye,"aria-hidden":"true"}):t==="pipe"?a.jsx(cT,{size:Ye,"aria-hidden":"true"}):a.jsx(pT,{size:Ye,"aria-hidden":"true"})}function sz({streams:t,sessions:s,tasks:o,loading:r,loadError:c=!1,loadedOnce:d=!0,showInternals:u,onToggleInternals:p,selectedStreamId:m,onSelectStream:g,onRefresh:v,hideHeaderControls:b=!1}){const _=L7(t,s),k={chatroom:Jt.kindChatroom,pipe:Jt.kindPipe,channel:Jt.kindChannel},S=j=>{var T;return((T=o.find(N=>N.id===j))==null?void 0:T.title)??j};return a.jsxs("div",{className:Jt.container,"data-testid":"coordination-list",children:[a.jsxs("div",{className:Jt.header,children:[a.jsx("span",{className:Jt.title,children:"Coordination"}),!b&&a.jsxs("div",{className:Jt.headerActions,children:[a.jsxs("label",{className:Jt.internalsToggle,children:[a.jsx("input",{type:"checkbox",checked:u,onChange:j=>p(j.target.checked),"data-testid":"coordination-show-internals"}),"Show internals"]}),v&&a.jsx("button",{type:"button",className:Jt.refreshButton,onClick:v,"aria-label":"Refresh streams","data-testid":"coordination-refresh",children:a.jsx(FT,{size:Ye,"aria-hidden":"true"})})]})]}),r&&t.length===0&&a.jsxs("div",{className:Jt.state,children:["Loading","…"]}),!r&&c&&a.jsx("div",{className:Jt.state,"data-testid":"coordination-error",children:"Unable to load streams"}),!r&&!c&&d&&t.length===0&&a.jsx("div",{className:Jt.state,"data-testid":"coordination-empty",children:"No active streams"}),_.map(j=>a.jsxs("div",{className:Jt.group,children:[a.jsx("div",{className:Jt.groupHeader,children:j.taskId?S(j.taskId):"Unattached / external (CLI · MCP)"}),j.streams.map(T=>{const N=vh(T),C=T.id===m;return a.jsxs("button",{type:"button",className:`${Jt.row}${C?` ${Jt.selected}`:""}`,onClick:()=>g(T.id),"data-testid":`coordination-row-${T.id}`,"aria-current":C?"page":void 0,children:[a.jsxs("span",{className:`${Jt.kindBadge} ${k[N]}`,children:[a.jsx(nz,{kind:N})," ",tz[N]]}),a.jsx("span",{className:Jt.streamName,children:T.name}),a.jsxs("span",{className:Jt.meta,children:[T.subscriberCount," ",T.subscriberCount===1?"sub":"subs"," ","·"," ",T.messageBufferDepth," buffered"]})]},T.id)})]},j.taskId??"__orphans__"))]})}const az="_transcript_1p4cm_1",iz="_message_1p4cm_10",oz="_meta_1p4cm_16",rz="_sender_1p4cm_24",lz="_time_1p4cm_29",cz="_content_1p4cm_34",dz="_state_1p4cm_42",Ga={transcript:az,message:iz,meta:oz,sender:rz,time:lz,content:cz,state:dz};function uz(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleTimeString()}function fz({messages:t,loading:s=!1}){return s?a.jsx("div",{className:Ga.state,"data-testid":"stream-transcript-loading",children:"Loading transcript…"}):t.length===0?a.jsx("div",{className:Ga.state,"data-testid":"stream-transcript-empty",children:"No messages yet."}):a.jsx("div",{className:Ga.transcript,"data-testid":"stream-transcript",children:t.map(o=>a.jsxs("div",{className:Ga.message,"data-testid":"stream-transcript-message",children:[a.jsxs("div",{className:Ga.meta,children:[a.jsx("span",{className:Ga.sender,title:o.senderId,children:o.senderId.slice(0,12)}),a.jsx("span",{className:Ga.time,children:uz(o.timestamp)})]}),a.jsx("div",{className:Ga.content,children:o.content})]},o.seq))})}const pz="_panel_i6ltf_1",mz="_header_i6ltf_24",hz="_title_i6ltf_33",gz="_closeButton_i6ltf_43",vz="_body_i6ltf_57",yz="_section_i6ltf_63",bz="_sectionLabel_i6ltf_67",_z="_metaRow_i6ltf_76",xz="_metaKey_i6ltf_84",kz="_metaValue_i6ltf_90",Sz="_subscriberCard_i6ltf_99",jz="_subscriberHeader_i6ltf_107",Tz="_sessionLink_i6ltf_114",Nz="_badges_i6ltf_132",wz="_badgeRw_i6ltf_150 _badge_i6ltf_132",Cz="_badgeR_i6ltf_150 _badge_i6ltf_132",Ez="_badgeW_i6ltf_162 _badge_i6ltf_132",Az="_badgeAsync_i6ltf_168 _badge_i6ltf_132",Dz="_badgeSync_i6ltf_174 _badge_i6ltf_132",Mz="_badgeDetach_i6ltf_178 _badge_i6ltf_132",Rz="_spawnTag_i6ltf_184 _badge_i6ltf_132",Iz="_fdNumber_i6ltf_189",Oz="_emptySubscribers_i6ltf_195",Bz="_metaValueMono_i6ltf_201 _metaValue_i6ltf_90",Lz="_advanced_i6ltf_216",zz="_advancedSummary_i6ltf_220",He={panel:pz,header:mz,title:hz,closeButton:gz,body:vz,section:yz,sectionLabel:bz,metaRow:_z,metaKey:xz,metaValue:kz,subscriberCard:Sz,subscriberHeader:jz,sessionLink:Tz,badges:Nz,badgeRw:wz,badgeR:Cz,badgeW:Ez,badgeAsync:Az,badgeSync:Dz,badgeDetach:Mz,spawnTag:Rz,fdNumber:Iz,emptySubscribers:Oz,metaValueMono:Bz,advanced:Lz,advancedSummary:zz},$z={chatroom:"Chatroom",pipe:"Pipe",channel:"Channel"};function Hz({permission:t}){const s=t==="rw"?He.badgeRw:t==="r"?He.badgeR:He.badgeW;return a.jsx("span",{className:s,children:t})}function Pz({mode:t}){const s=t==="async"?He.badgeAsync:t==="detach"?He.badgeDetach:He.badgeSync;return a.jsx("span",{className:s,children:t})}function Uz({stream:t,messages:s,transcriptLoading:o,onClose:r}){const c=xt();return y.useEffect(()=>{const d=u=>{u.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[r]),a.jsxs("div",{className:He.panel,"data-testid":"stream-detail-panel",children:[a.jsxs("div",{className:He.header,children:[a.jsx("h3",{className:He.title,children:t.name}),a.jsx("button",{type:"button",className:He.closeButton,onClick:r,"aria-label":"Close stream details",children:"×"})]}),a.jsxs("div",{className:He.body,children:[a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Overview"}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Kind"}),a.jsx("span",{className:He.metaValue,children:$z[vh(t)]})]}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Participants"}),a.jsx("span",{className:He.metaValue,children:t.subscriberCount})]}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Buffered"}),a.jsxs("span",{className:He.metaValue,children:[t.messageBufferDepth," msgs"]})]})]}),a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Participants"}),t.subscribers.length===0?a.jsx("div",{className:He.emptySubscribers,children:"No active subscribers"}):t.subscribers.map(d=>a.jsxs("div",{className:He.subscriberCard,"data-testid":`subscriber-card-${d.subscriptionId}`,children:[a.jsxs("button",{type:"button",className:He.sessionLink,onClick:()=>{c(Rm(d.sessionId))},title:d.sessionId,children:[d.sessionId.slice(0,12),"…"]}),d.createdBySpawn&&a.jsx("span",{className:He.spawnTag,children:"spawn"})]},d.subscriptionId))]}),a.jsxs("div",{className:He.section,children:[a.jsx("div",{className:He.sectionLabel,children:"Conversation"}),a.jsx(fz,{messages:s??[],loading:o??!1})]}),a.jsxs("details",{className:He.advanced,"data-testid":"stream-advanced",children:[a.jsx("summary",{className:He.advancedSummary,children:"Advanced"}),a.jsxs("div",{className:He.metaRow,children:[a.jsx("span",{className:He.metaKey,children:"Stream ID"}),a.jsx("span",{className:He.metaValueMono,children:t.id})]}),t.subscribers.map(d=>a.jsxs("div",{className:He.subscriberCard,children:[a.jsxs("div",{className:He.subscriberHeader,children:[a.jsxs("span",{className:He.fdNumber,children:["fd ",d.fd]}),a.jsxs("span",{className:He.metaValueMono,title:d.subscriptionId,children:[d.subscriptionId.slice(0,12),"…"]})]}),a.jsxs("div",{className:He.badges,children:[a.jsx(Hz,{permission:d.permission}),a.jsx(Pz,{mode:d.deliveryMode})]})]},d.subscriptionId))]})]})]})}function Dp(t){return t.length>0?t.charAt(0).toUpperCase()+t.slice(1):t}const Vz=["--accent-green","--accent-yellow","--accent-red","--text-tertiary"];function uk(t,s){if(s)return{varName:"--text-tertiary",label:"External"};switch(t){case"running":return{varName:"--accent-green",label:"Running"};case"idle":case"suspended":case"hibernating":return{varName:"--accent-yellow",label:Dp(t)};case"failed":case"interrupted":return{varName:"--accent-red",label:Dp(t)};default:return{varName:"--text-tertiary",label:t.length>0?Dp(t):"Unknown"}}}const fk="session",yh="stream",l_="messageDot";function Kc(t){return`session:${t}`}function c_(t){return`stream:${t}`}function qz(t){return{id:t,environmentId:"",runtime:"external",status:"external",prompt:"",startedAt:""}}function Gz(t,s){return t==="detach"?{stroke:s,strokeWidth:1.5,strokeDasharray:"4 4",opacity:.6}:{stroke:s,strokeWidth:1.5}}function Fz(t,s){const o=t.permission.includes("w"),r=s.permission.includes("w"),c=t.permission.includes("r"),d=s.permission.includes("r");if(o&&!r&&d)return{source:t,target:s,bidirectional:!1};if(r&&!o&&c)return{source:s,target:t,bidirectional:!1};const u=[t,s].sort((p,m)=>p.sessionId.localeCompare(m.sessionId));return{source:u[0],target:u[1],bidirectional:!0}}function Kz(t,s){if(t.length===0)return{nodes:[],edges:[]};const o=new Map(s.map(m=>[m.id,m])),r=new Map,c=new Map,d=[],u=m=>{let g=r.get(m);if(!g){const v=o.get(m);g={kind:"session",session:v??qz(m),streamCount:0,external:v===void 0},r.set(m,g)}return g};for(const m of t){const g=vh(m);if(g==="pipe"&&m.subscribers.length===2&&m.subscribers[0].sessionId!==m.subscribers[1].sessionId){const[v,b]=m.subscribers;u(v.sessionId).streamCount+=1,u(b.sessionId).streamCount+=1;const{source:_,target:k,bidirectional:S}=Fz(v,b);d.push({id:`edge-pipe-${m.id}`,source:Kc(_.sessionId),target:Kc(k.sessionId),type:l_,data:{edgeKind:"pipe",streamId:m.id,permission:S?"rw":_.permission,deliveryMode:_.deliveryMode},style:{stroke:"var(--accent-yellow)",strokeWidth:1.5,strokeDasharray:"6 3"},markerEnd:{type:Mc.ArrowClosed},markerStart:S?{type:Mc.ArrowClosed}:void 0,animated:!1});continue}c.set(m.id,{kind:"stream",stream:m,streamKind:g,ownership:dk(m,o)});for(const v of m.subscribers){u(v.sessionId).streamCount+=1;const b=c_(m.id),_=Kc(v.sessionId),k=v.permission.includes("w"),S=v.permission.includes("r");let j,T,N=!1;k&&S?(j=_,T=b,N=!0):S?(j=b,T=_):(j=_,T=b),d.push({id:`edge-part-${m.id}-${v.subscriptionId}`,source:j,target:T,type:l_,data:{edgeKind:"participation",streamId:m.id,permission:v.permission,deliveryMode:v.deliveryMode},style:Gz(v.deliveryMode,"var(--text-tertiary)"),markerEnd:{type:Mc.ArrowClosed},markerStart:N?{type:Mc.ArrowClosed}:void 0,animated:!1})}}const p=[];for(const[m,g]of r)p.push({id:Kc(m),type:fk,position:{x:0,y:0},data:g});for(const[m,g]of c)p.push({id:c_(m),type:yh,position:{x:0,y:0},data:g});return{nodes:p,edges:d}}const Zz=200,Yz=64,Jz=180,Wz=56,Xz=40,Qz=70;function d_(t){return t===yh?{width:Jz,height:Wz}:{width:Zz,height:Yz}}function e$(t){if(t.nodes.length===0)return t;const s=new ld.graphlib.Graph({multigraph:!0});s.setDefaultEdgeLabel(()=>({})),s.setGraph({rankdir:"LR",nodesep:Xz,ranksep:Qz});for(const r of t.nodes){const{width:c,height:d}=d_(r.type);s.setNode(r.id,{width:c,height:d})}for(const r of t.edges)s.setEdge(r.source,r.target,{},r.id);return ld.layout(s),{nodes:t.nodes.map(r=>{const c=s.node(r.id),{width:d,height:u}=d_(r.type);return{...r,position:{x:c.x-d/2,y:c.y-u/2}}}),edges:t.edges}}function t$(t,s){return y.useMemo(()=>e$(Kz(t,s)),[t,s])}const n$="_graphContainer_1uzcp_1",s$="_empty_1uzcp_18",a$="_nodeContent_1uzcp_28",i$="_nodeHeader_1uzcp_38",o$="_nodeTitle_1uzcp_50",r$="_nodeMeta_1uzcp_58",l$="_nodeSubtle_1uzcp_64",c$="_countBadge_1uzcp_69",d$="_sessionNode_1uzcp_81",u$="_sessionAccent_1uzcp_103",f$="_external_1uzcp_109",p$="_streamNode_1uzcp_114",m$="_chatroom_1uzcp_134",h$="_channel_1uzcp_139",g$="_pipe_1uzcp_143",v$="_haloless_1uzcp_147",y$="_selected_1uzcp_153",b$="_kindBadge_1uzcp_158",_$="_handle_1uzcp_172",x$="_messageDot_1uzcp_179",vt={graphContainer:n$,empty:s$,nodeContent:a$,nodeHeader:i$,nodeTitle:o$,nodeMeta:r$,nodeSubtle:l$,countBadge:c$,sessionNode:d$,sessionAccent:u$,external:f$,streamNode:p$,chatroom:m$,channel:h$,pipe:g$,haloless:v$,selected:y$,kindBadge:b$,handle:_$,messageDot:x$};function k$({data:t}){const{session:s,streamCount:o,external:r}=t,c=uk(s.status,r),d=`var(${c.varName})`,u=r?`${vt.sessionNode} ${vt.external}`:vt.sessionNode;return a.jsxs("div",{className:u,"data-testid":`coordination-node-session-${s.id}`,children:[a.jsx(Bo,{type:"target",position:Lo.Left,isConnectable:!1,className:vt.handle}),a.jsx("div",{className:vt.sessionAccent,style:{backgroundColor:d}}),a.jsxs("div",{className:vt.nodeContent,children:[a.jsx("div",{className:vt.nodeHeader,children:a.jsx("span",{className:vt.nodeTitle,children:r?s.id:s.runtime})}),a.jsxs("div",{className:vt.nodeMeta,children:[a.jsx("span",{className:vt.nodeSubtle,style:{color:d},children:c.label}),o>0&&a.jsx("span",{className:vt.countBadge,children:o})]})]}),a.jsx(Bo,{type:"source",position:Lo.Right,isConnectable:!1,className:vt.handle})]})}function S$({data:t,selected:s}){const{stream:o,streamKind:r,ownership:c}=t,d=r==="chatroom"?vt.chatroom:r==="pipe"?vt.pipe:vt.channel,u=[vt.streamNode,d];return c.kind!=="task"&&u.push(vt.haloless),s&&u.push(vt.selected),a.jsxs("div",{className:u.join(" "),"data-testid":`coordination-node-stream-${o.id}`,children:[a.jsx(Bo,{type:"target",position:Lo.Left,isConnectable:!1,className:vt.handle}),a.jsxs("div",{className:vt.nodeContent,children:[a.jsx("div",{className:vt.nodeHeader,children:a.jsx("span",{className:vt.kindBadge,children:r})}),a.jsx("span",{className:vt.nodeTitle,children:o.name}),a.jsxs("span",{className:vt.nodeSubtle,children:[o.subscriberCount," ",o.subscriberCount===1?"subscriber":"subscribers"]})]}),a.jsx(Bo,{type:"source",position:Lo.Right,isConnectable:!1,className:vt.handle})]})}const u_="0.7s",j$=3;function T$(t){const{sourceX:s,sourceY:o,targetX:r,targetY:c,sourcePosition:d,targetPosition:u,markerStart:p,markerEnd:m,style:g,data:v}=t,[b]=q2({sourceX:s,sourceY:o,targetX:r,targetY:c,sourcePosition:d,targetPosition:u}),_=v==null?void 0:v.pulseSeq;return a.jsxs(a.Fragment,{children:[a.jsx(G2,{path:b,markerStart:p,markerEnd:m,style:g}),_!==void 0&&a.jsxs("circle",{r:j$,opacity:0,className:vt.messageDot,"data-testid":"coordination-message-dot",children:[a.jsx("animateMotion",{dur:u_,repeatCount:"1",path:b}),a.jsx("animate",{attributeName:"opacity",dur:u_,repeatCount:"1",values:"0;1;1;0",keyTimes:"0;0.1;0.85;1"})]},_)]})}const Mp="#6b7a8d",N$={[fk]:k$,[yh]:S$},w$={messageDot:T$};function C$({streams:t,sessions:s,selectedStreamId:o,onSelectStream:r,recentMessages:c,resolvedThemeId:d}){const u=t$(t,s),p=y.useMemo(()=>u.edges.map(_=>{var S,j;if(!_.data)return _;const k=(j=(S=c==null?void 0:c[_.data.streamId])==null?void 0:S.at(-1))==null?void 0:j.seq;return k===void 0?_:{..._,data:{..._.data,pulseSeq:k}}}),[u.edges,c]),m=y.useMemo(()=>u.nodes.map(_=>{const k=_.data;return k.kind==="stream"&&k.stream.id===o?{..._,selected:!0}:_}),[u.nodes,o]),g=y.useMemo(()=>{const _=getComputedStyle(document.documentElement),k={};for(const S of Vz)k[S]=_.getPropertyValue(S).trim()||Mp;return k},[d]),v=y.useCallback((_,k)=>{const S=k.data;S.kind==="stream"&&r(S.stream.id)},[r]),b=y.useCallback(_=>{const k=_.data;return k.kind==="session"?g[uk(k.session.status,k.external).varName]??Mp:Mp},[g]);return u.nodes.length===0?a.jsx("div",{className:vt.empty,"data-testid":"coordination-graph-empty",children:"No active streams to visualize"}):a.jsx("div",{className:vt.graphContainer,"data-testid":"coordination-graph",children:a.jsxs(I_,{nodes:m,edges:p,nodeTypes:N$,edgeTypes:w$,onNodeClick:v,nodesConnectable:!1,fitView:!0,fitViewOptions:{padding:.2},minZoom:.3,maxZoom:2,children:[a.jsx(O_,{variant:B_.Dots,gap:24,size:1,color:"var(--text-disabled)"}),a.jsx(L_,{showInteractive:!1}),a.jsx(z_,{nodeColor:b,maskColor:"var(--bg-overlay)",style:{background:"var(--bg-inset)"}})]})})}function E$({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(jy.map(d=>[d,[]]));for(const d of t){const u=fl(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(S=>s.get(S)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(S=>S.status==="complete").length;let b;if(u==="paused"&&o){const S=o.get(d.id);S==="idle"?b="Needs input":S==="completed"&&(b="Ready to complete")}const _={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},k=c.get(u);k?k.push(_):c.get("not_started").push(_)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return jy.map(d=>{const u=Ja(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const A$="_boardContainer_1c4y1_1",D$="_column_1c4y1_17",M$="_columnHeader_1c4y1_34",R$="_columnIcon_1c4y1_47",I$="_columnLabel_1c4y1_52",O$="_columnCount_1c4y1_57",B$="_cardList_1c4y1_67",L$="_emptyPlaceholder_1c4y1_76",z$="_card_1c4y1_67",$$="_cardHeader_1c4y1_107",H$="_cardStatusIcon_1c4y1_113",P$="_cardTitle_1c4y1_119",U$="_cardBadges_1c4y1_127",V$="_badge_1c4y1_134",q$="_blockedBadge_1c4y1_146",G$="_childBadge_1c4y1_151",F$="_depBadge_1c4y1_155",K$="_parentBadge_1c4y1_159",Z$="_pausedSubBadge_1c4y1_166",Y$="_personaBadge_1c4y1_170",J$="_envBadge_1c4y1_174",W$="_emptyCta_1c4y1_178",X$="_ctaButton_1c4y1_188",Q$="_ctaDescription_1c4y1_204",dt={boardContainer:A$,column:D$,columnHeader:M$,columnIcon:R$,columnLabel:I$,columnCount:O$,cardList:B$,emptyPlaceholder:L$,card:z$,cardHeader:$$,cardStatusIcon:H$,cardTitle:P$,cardBadges:U$,badge:V$,blockedBadge:q$,childBadge:G$,depBadge:F$,parentBadge:K$,pausedSubBadge:Z$,personaBadge:Y$,envBadge:J$,emptyCta:W$,ctaButton:X$,ctaDescription:Q$};function e9({workspaceId:t,environmentId:s,tasks:o,sessions:r,personas:c,environments:d}){const u=xt(),p=y.useMemo(()=>o.filter(_=>_.workspaceId===t),[o,t]),m=y.useMemo(()=>new Map(o.map(_=>[_.id,_.status])),[o]),g=y.useMemo(()=>new Map(p.map(_=>[_.id,_])),[p]),v=y.useMemo(()=>{const _=new Map(r.map(C=>[C.id,C])),k=new Map(c.map(C=>[C.id,C])),S=new Map(d.map(C=>[C.id,C])),j=new Map,T=new Map,N=new Map;for(const C of p)if(C.latestSessionId){const D=_.get(C.latestSessionId);if(D){if(j.set(C.id,D.endReason||D.status),D.personaId){const A=k.get(D.personaId);A&&T.set(C.id,A.name)}if(D.environmentId){const A=S.get(D.environmentId);A&&N.set(C.id,A.displayName)}}}return{sessionStatusByTaskId:j,personaNameByTaskId:T,environmentNameByTaskId:N}},[p,r,c,d]),b=y.useMemo(()=>E$({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?a.jsxs("div",{className:dt.emptyCta,"data-testid":"board-empty-cta",children:[a.jsx("button",{className:dt.ctaButton,onClick:()=>u(Ii(t,void 0,s)),children:"Create Task"}),a.jsx("div",{className:dt.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):a.jsx("div",{className:dt.boardContainer,"data-testid":"board-container",children:b.map(_=>a.jsxs("section",{className:dt.column,"data-testid":`board-column-${_.status}`,"aria-label":`${_.label}, ${_.tasks.length} ${_.tasks.length===1?"task":"tasks"}`,children:[a.jsxs("div",{className:dt.columnHeader,children:[a.jsx("span",{className:dt.columnIcon,style:{color:_.style.color},children:_.style.icon}),a.jsx("span",{className:dt.columnLabel,children:_.label}),a.jsx("span",{className:dt.columnCount,"data-testid":`board-count-${_.status}`,children:_.tasks.length})]}),a.jsx("div",{className:dt.cardList,children:_.tasks.length===0?a.jsx("div",{className:dt.emptyPlaceholder,children:"No tasks"}):a.jsx(is,{mode:"popLayout",children:_.tasks.map(k=>a.jsx(Ut.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:a.jsx(t9,{boardTask:k,tasksById:g,personaName:v.personaNameByTaskId.get(k.task.id),envName:v.environmentNameByTaskId.get(k.task.id),onClick:()=>u(rs(k.task.id,void 0,t,s))})},k.task.id))})})]},_.status))})}function t9({boardTask:t,tasksById:s,personaName:o,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=Ja(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return a.jsxs("div",{className:dt.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),c())},children:[a.jsxs("div",{className:dt.cardHeader,children:[a.jsx("span",{className:dt.cardStatusIcon,style:{color:v.color},children:v.icon}),a.jsx("span",{className:dt.cardTitle,children:d.title})]}),a.jsxs("div",{className:dt.cardBadges,children:[b&&a.jsx("span",{className:`${dt.badge} ${dt.parentBadge}`,title:b.title,children:b.title}),p>0&&a.jsxs("span",{className:`${dt.badge} ${dt.childBadge}`,children:[m,"/",p]}),u&&a.jsx("span",{className:`${dt.badge} ${dt.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&a.jsx("span",{className:`${dt.badge} ${dt.depBadge}`,children:"dep"}),g&&a.jsx("span",{className:`${dt.badge} ${dt.pausedSubBadge}`,children:g}),o&&a.jsx("span",{className:`${dt.badge} ${dt.personaBadge}`,children:o}),r&&a.jsx("span",{className:`${dt.badge} ${dt.envBadge}`,children:r})]})]})}const n9="_formContent_ymnez_1",s9="_section_ymnez_13",a9="_label_ymnez_19",i9="_titleInput_ymnez_26",o9="_descriptionTextarea_ymnez_58",r9="_selectField_ymnez_94",l9="_checkboxRow_ymnez_128",c9="_checkboxLabel_ymnez_141",d9="_fieldError_ymnez_146",jt={formContent:n9,section:s9,label:a9,titleInput:i9,descriptionTextarea:o9,selectField:r9,checkboxRow:l9,checkboxLabel:c9,fieldError:d9};function u9(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.linkedEnvironmentIds[0])??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const f9=100;function p9({values:t,onChange:s,environments:o,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return a.jsxs("div",{className:jt.formContent,children:[a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-name",children:"Name"}),a.jsx("input",{id:"ws-name",className:jt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:f9,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-description",children:"Description"}),a.jsx("textarea",{id:"ws-description",className:jt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-repo",children:"Repository URL"}),a.jsx("input",{id:"ws-repo",className:jt.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)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-environment",children:"Environment"}),a.jsxs("select",{id:"ws-environment",className:jt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[a.jsx("option",{value:"",children:"Select environment…"}),o.map(m=>a.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&a.jsx("span",{className:jt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-persona",children:"Default Persona"}),a.jsxs("select",{id:"ws-persona",className:jt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[a.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>a.jsx("option",{value:m.id,children:m.name},m.id))]})]}),a.jsx("div",{className:jt.section,children:a.jsxs("label",{className:jt.checkboxRow,children:[a.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),a.jsx("span",{className:jt.checkboxLabel,children:"Enable worktree isolation"})]})}),a.jsxs("div",{className:jt.section,children:[a.jsx("label",{className:jt.label,htmlFor:"ws-workdir",children:"Working Directory"}),a.jsx("input",{id:"ws-workdir",className:jt.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 pk=y.createContext(void 0),m9=4e3;function h9({children:t}){const[s,o]=y.useState([]),r=y.useRef(0),c=y.useCallback(u=>{o(p=>p.filter(m=>m.id!==u))},[]),d=y.useCallback((u,p="info",m=m9)=>{const g=`toast-${++r.current}`;o(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return a.jsx(pk.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function mn(){const t=y.useContext(pk);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const hm="grackle-theme",mk="grackle-prefer-system",hk="(prefers-color-scheme: dark)";let Jr=[],rd;function Rp(){rd=void 0;for(const t of Jr)t()}function gm(){return typeof window>"u"?!1:window.matchMedia(hk).matches}function nl(){if(typeof localStorage>"u")return i_;try{const t=localStorage.getItem(hm);if(t!==null&&ok.has(t))return t}catch{}return i_}function _d(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(mk)==="true"}catch{return!1}}function vm(t){return Od.find(s=>s.variantLightId===t||s.variantDarkId===t)}function gk(t,s){const o=pm(t);if(o!=null&&o.variantDarkId)return s&&o.variantLightId?gm()?o.variantDarkId:o.variantLightId:o.variantDarkId;if(o!=null&&o.hidden&&s){const r=vm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return gm()?r.variantDarkId:r.variantLightId}return t}function Ao(t,s,o=!1){o&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=gk(t,s),o&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&Ao(nl(),_d());function g9(){return rd===void 0&&(rd={themeId:nl(),systemDark:gm(),preferSystem:_d()}),rd}function v9(t){return Jr=[...Jr,t],()=>{Jr=Jr.filter(s=>s!==t)}}function y9(){const t=y.useSyncExternalStore(v9,g9),{themeId:s,preferSystem:o}=t,r=gk(s,o),c=y.useCallback(u=>{if(ok.has(u)){try{localStorage.setItem(hm,u)}catch{}Ao(u,_d(),!0),Rp()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(mk,u?"true":"false")}catch{}if(u){const p=nl(),m=pm(p);if(m!=null&&m.hidden){const g=vm(p);if(g)try{localStorage.setItem(hm,g.id)}catch{}}}Ao(nl(),u,!0),Rp()},[]);return y.useEffect(()=>{Ao(s,o)},[s,o]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(hk),p=()=>{const m=nl(),g=_d();if(g){const v=pm(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&Ao(m,g),v!=null&&v.hidden){const b=vm(m);b!=null&&b.variantDarkId&&b.variantLightId&&Ao(m,g)}}Rp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:o,setPreferSystem:d}}const vk=y.createContext(void 0);function b9({children:t}){const s=y9();return a.jsx(vk.Provider,{value:s,children:t})}function bh(){const t=y.useContext(vk);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const yk=y.createContext(void 0),bk=y.createContext(void 0);function _9({children:t}){const[s,o]=y.useState(void 0),r=y.useCallback(c=>{o(c)},[]);return a.jsx(bk.Provider,{value:r,children:a.jsx(yk.Provider,{value:s,children:t})})}function x9(){return y.useContext(yk)}function k9(){const t=y.useContext(bk);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const _h=y.createContext(void 0);function pt(){const t=y.useContext(_h);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function _k(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function xk(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function S9(t){return _k(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")&&(t.toolCallId===void 0||typeof t.toolCallId=="string")&&(t.turnId===void 0||typeof t.turnId=="string")&&(t.serverSeq===void 0||typeof t.serverSeq=="string")}const j9=new Set(["off","subscription","api_key"]),Zc=new Set(["off","on"]);function T9(t){return _k(t)&&j9.has(t.claude)&&Zc.has(t.github)&&Zc.has(t.copilot)&&Zc.has(t.codex)&&Zc.has(t.goose)}function kk(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 Sk(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 Co=5e3;function N9(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 Ai={label:"Home",url:Fo};function w9(t){return t?[Ai,{label:"Settings",url:Ti},{label:t,url:void 0}]:[Ai,{label:"Settings",url:void 0}]}const jk={label:"Environments",url:zo};function C9(){return[Ai,{label:"Environments",url:void 0}]}function E9(){return[Ai,{label:"New Chat",url:void 0}]}function A9(t){return[Ai,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function D9(t,s,o,r){const c=o.find(u=>u.id===t),d=r.find(u=>u.id===s);return[Ai,jk,{label:(d==null?void 0:d.displayName)??"Environment",url:$o(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function M9(t,s,o,r,c){const d=N9(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?o.find(k=>k.id===p):void 0,g=s??(m==null?void 0:m.linkedEnvironmentIds[0]),v=g?r.find(k=>k.id===g):void 0,b=[Ai];v&&g&&(b.push(jk),b.push({label:v.displayName,url:$o(g)})),m&&g&&b.push({label:m.name,url:Ci(m.id,g)});for(let k=0;k<d.length-1;k++)b.push({label:d[k].title,url:rs(d[k].id,void 0,p,g)});const _=d[d.length-1];return b.push({label:(_==null?void 0:_.title)??t,url:void 0}),b}function xh(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 f_(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 R9(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 Ip(t,s,o){return t.toolCallId?t.toolCallId:s?o(s):void 0}function kh(t){const s=new Map;for(const u of t)if(u.raw)try{s.set(u,JSON.parse(u.raw))}catch{}const o=new Map;for(const u of t){if(u.eventType!=="tool_use")continue;const p=Ip(u,s.get(u),f_);if(p)try{const m=JSON.parse(u.content);o.set(p,{tool:m.tool,args:m.args})}catch{}}const r=new Set,d=t.map(u=>{if(u.eventType!=="tool_result")return u;const p=Ip(u,s.get(u),R9);if(!p)return u;const m=o.get(p);if(!m)return u;r.add(p);let g;const v=u.content.trim();if(v.startsWith("{"))try{const b=JSON.parse(v);typeof b.detailedContent=="string"&&(g=b.detailedContent)}catch{}return{...u,toolUseCtx:{...m,detailedResult:g}}}).filter(u=>{if(u.eventType!=="tool_use")return!0;const p=Ip(u,s.get(u),f_);return!(p&&r.has(p))});for(let u=0;u<d.length;u++){if(d[u].eventType!=="tool_use")continue;let p=!1;for(let m=u+1;m<d.length;m++)if(d[m].eventType!=="tool_use"){p=!0;break}p&&(d[u]={...d[u],settled:!0})}return d}function I9(t,s,o){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=Tk(s),d=s.filter(m=>ym(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||ym(m,c)).length,p=o.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function Tk(t){const s=new Map;for(const o of t)s.set(o.id,o.status);return s}function ym(t,s){return t.dependsOn.some(o=>s.get(o)!=="complete")}function O9(t,s){var u;const o=new Map;for(const p of s)o.set(p.id,p);const r=Tk(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}):ym(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 B9(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 L9(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 As=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
326
326
  export function verifyToken(req: Request, res: Response, next: NextFunction): void {
327
327
  const header = req.headers.authorization;
328
328
  if (!header?.startsWith("Bearer ")) {
@@ -752,4 +752,4 @@ const grackle = await host.mcpServer({
752
752
  url: env.vars.GRACKLE_MCP_URL,
753
753
  });
754
754
 
755
- $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),R==="agent"&&a.jsxs("div",{children:[a.jsx("label",{children:"Allowed MCP Tools"}),a.jsx(r_,{selectedTools:Y,onChange:ue=>{U(ue),lt(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ue),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!xe&&!me&&a.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,a.jsx(bs,{isOpen:X,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:bt,onCancel:()=>te(!1)})]})}function iq(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=pt(),{showToast:c}=mn(),d=xt();return a.jsx(A7,{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(oC),onNavigateToSchedule:u=>d(px(u))})}const oq="_container_1g4qh_1",rq="_form_1g4qh_7",lq="_formActions_1g4qh_66",cq="_editableSection_1g4qh_73",dq="_helperText_1g4qh_84",uq="_metaSection_1g4qh_90",fq="_optional_1g4qh_108",pq="_readonlyValue_1g4qh_113",Bn={container:oq,form:rq,formActions:lq,editableSection:cq,helperText:dq,metaSection:uq,optional:fq,readonlyValue:pq};function D_(){const{scheduleId:t}=pa(),s=xt(),{showToast:o}=mn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},workspaces:{workspaces:g}}=pt(),v=t===void 0,b=v?void 0:r.find(k=>k.id===t);if(!v&&!c&&r.length>0&&!b)return a.jsx(zn,{to:np,replace:!0});const _=[{label:"Settings",url:Ti},{label:"Schedules",url:np},{label:v?"New Schedule":(b==null?void 0:b.title)??"Schedule",url:void 0}];return a.jsxs("div",{className:Bn.container,children:[a.jsx(ma,{segments:_}),a.jsx(mq,{existing:b,isNew:v,personas:m,workspaces:g,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(np)},showToast:o})]})}function mq({existing:t,isNew:s,personas:o,workspaces:r,onCreateSchedule:c,onUpdateSchedule:d,onDeleteSchedule:u,onDone:p,showToast:m}){var H;const g=xt(),[v,b]=y.useState((t==null?void 0:t.title)??""),[_,k]=y.useState((t==null?void 0:t.description)??""),[S,j]=y.useState((t==null?void 0:t.scheduleExpression)??""),[T,N]=y.useState((t==null?void 0:t.personaId)??""),[C,D]=y.useState((t==null?void 0:t.workspaceId)??""),[A,E]=y.useState(!1),[R,B]=y.useState(null);y.useEffect(()=>{s||t&&R===null&&(b(t.title),k(t.description),j(t.scheduleExpression),N(t.personaId),D(t.workspaceId))},[s,t,R]);const M=!s&&t===void 0,$=s&&v.trim().length>0&&S.trim().length>0&&T.length>0,Y=o.map(O=>({value:O.id,label:O.name})),U=[{value:"",label:"System-level (no workspace)"},...r.map(O=>({value:O.id,label:O.name}))],X=O=>{O.preventDefault(),$&&c(v,_,S,T,C||void 0).then(q=>{m("Schedule created","success"),g(px(q.id),{replace:!0})},()=>{m("Failed to create schedule","error")})},te=(O,q)=>{t&&d(t.id,{[O]:q}).then(()=>{m("Schedule updated","success"),O==="title"&&b(String(q)),O==="description"&&k(String(q)),O==="scheduleExpression"&&j(String(q)),O==="personaId"&&N(String(q))},()=>{m("Failed to update schedule","error")})},G=()=>{if(!t)return;const O=!t.enabled;d(t.id,{enabled:O}).then(()=>{m(O?"Schedule enabled":"Schedule disabled","success")},()=>{m("Failed to update schedule","error")})},ne=()=>{t&&u(t.id).then(()=>{m("Schedule deleted","success"),p()},()=>{m("Failed to delete schedule","error")})};return a.jsxs(a.Fragment,{children:[M?a.jsxs("div",{className:Bn.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsx("p",{children:"Loading schedule..."})]}):s?a.jsxs("form",{onSubmit:X,className:Bn.form,children:[a.jsx("h3",{children:"Create Schedule"}),a.jsxs("label",{children:["Title",a.jsx("input",{type:"text",value:v,onChange:O=>b(O.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description ",a.jsx("span",{className:Bn.optional,children:"(optional)"}),a.jsx("input",{type:"text",value:_,onChange:O=>k(O.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx("input",{type:"text",value:S,onChange:O=>j(O.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),a.jsxs("p",{className:Bn.helperText,children:["Interval: ",a.jsx("code",{children:"30s"}),", ",a.jsx("code",{children:"5m"}),", ",a.jsx("code",{children:"1h"}),", ",a.jsx("code",{children:"1d"})," (min 10s)  |  Cron: ",a.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),a.jsxs("label",{children:["Persona",a.jsxs("select",{value:T,onChange:O=>N(O.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[a.jsx("option",{value:"",children:"Select a persona..."}),Y.map(O=>a.jsx("option",{value:O.value,children:O.label},O.value))]})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:Bn.optional,children:"(optional)"}),a.jsx("select",{value:C,onChange:O=>D(O.target.value),"data-testid":"schedule-detail-workspace",children:U.map(O=>a.jsx("option",{value:O.value,children:O.label},O.value))})]}),a.jsxs("div",{className:Bn.formActions,children:[a.jsx(an,{type:"submit",variant:"primary",size:"md",disabled:!$,"data-testid":"schedule-detail-save",children:"Create"}),a.jsx(an,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?a.jsxs("div",{className:Bn.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsxs("div",{className:Bn.formActions,children:[a.jsx(an,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),a.jsx(an,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:G,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),a.jsx(an,{type:"button",variant:"danger",size:"md",onClick:()=>E(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),a.jsxs("div",{className:Bn.editableSection,children:[a.jsxs("label",{children:["Title",a.jsx($t,{value:v,onSave:O=>{te("title",O)},validate:O=>O.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:R,onActivate:B,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description",a.jsx($t,{value:_,onSave:O=>{te("description",O)},fieldId:"schedule-description",activeFieldId:R,onActivate:B,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx($t,{value:S,onSave:O=>{te("scheduleExpression",O)},validate:O=>O.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:R,onActivate:B,placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",ariaLabel:"Schedule expression","data-testid":"schedule-detail-expression"})]}),a.jsxs("label",{children:["Persona",a.jsx(bd,{value:T,onSave:O=>{te("personaId",O)},options:Y,fieldId:"schedule-persona",activeFieldId:R,onActivate:B,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:Bn.optional,children:"(optional — set at creation)"}),a.jsx("span",{className:Bn.readonlyValue,"data-testid":"schedule-detail-workspace",children:((H=r.find(O=>O.id===t.workspaceId))==null?void 0:H.name)??"System-level (no workspace)"})]})]}),a.jsxs("div",{className:Bn.metaSection,children:[t.lastRunAt?a.jsxs("span",{children:["Last run: ",mm(t.lastRunAt)]}):a.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?a.jsxs("span",{children:["Next run: ",ck(t.nextRunAt)]}):null,t.runCount>0&&a.jsxs("span",{children:["Total runs: ",t.runCount]}),a.jsxs("span",{children:["Created: ",mm(t.createdAt)]})]})]}):null,a.jsx(bs,{isOpen:A,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:ne,onCancel:()=>E(!1)})]})}function hq(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=bh();return a.jsx(FB,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function gq(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Be.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function vq(){const{connectionStatus:t,environments:{environments:s},sessions:{sessions:o}}=pt(),r=gq();return a.jsxs(a.Fragment,{children:[r&&a.jsx(sB,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),a.jsx(YB,{connectionStatus:t,environments:s,sessions:o})]})}function yq(){return a.jsx(H8,{})}function bq(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=pt();return a.jsx(d8,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const M_=Ii();function _q(){const t=xt();return Ya({key:"?"},()=>{t(rC)}),Ya({key:"n"},()=>{t(M_)}),Ya({key:"N"},()=>{t(M_)}),a.jsx(a.Fragment,{})}function Ld(t){const s=k9();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function xq(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=pt(),o=y.useMemo(()=>a.jsx(RO,{workspaces:t,tasks:s}),[t,s]);return Ld(o),a.jsx(Ri,{})}function kq(){const{environments:{environments:t}}=pt(),s=y.useMemo(()=>a.jsx(eO,{environments:t}),[t]);return Ld(s),a.jsx(Ri,{})}function Sq(){const t=y.useMemo(()=>a.jsx(O7,{}),[]);return Ld(t),a.jsx(Ri,{})}function jq(){const{knowledge:t,workspaces:{workspaces:s}}=pt(),o=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>a.jsx(c5,{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 Ld(u),a.jsx(Ri,{})}const Tq="_wizard_1260s_1",Nq="_container_1260s_10",wq="_stepContent_1260s_19",Cq="_logoArea_1260s_28",Eq="_logoImage_1260s_32",Aq="_heading_1260s_41",Dq="_tagline_1260s_49",Mq="_subtitle_1260s_56",Rq="_featureList_1260s_64",Iq="_runtimeGrid_1260s_89",Oq="_runtimeCard_1260s_101",Bq="_runtimeName_1260s_133",Lq="_runtimeDescription_1260s_139",zq="_buttonRow_1260s_144",$q="_primaryButton_1260s_151",Hq="_ghostButton_1260s_185",Pq="_dots_1260s_213",Uq="_dot_1260s_213",Xe={wizard:Tq,container:Nq,stepContent:wq,logoArea:Cq,logoImage:Eq,heading:Aq,tagline:Dq,subtitle:Mq,featureList:Rq,runtimeGrid:Iq,runtimeCard:Oq,runtimeName:Bq,runtimeDescription:Lq,buttonRow:zq,primaryButton:$q,ghostButton:Hq,dots:Pq,dot:Uq};function Vq({onNext:t}){return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-welcome",children:[a.jsx("div",{className:Xe.logoArea,children:a.jsx("img",{src:Id("grackle-logo.png"),alt:"Grackle",className:Xe.logoImage})}),a.jsx("h1",{className:Xe.heading,children:"Welcome to Grackle"}),a.jsx("p",{className:Xe.tagline,children:"Multi-agent orchestration for software teams"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function qq({onNext:t,onBack:s}){return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-about",children:[a.jsx("h2",{className:Xe.heading,children:"What is Grackle?"}),a.jsxs("ul",{className:Xe.featureList,children:[a.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),a.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),a.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),a.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),a.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:s,children:"Back"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const Gq=[{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 Fq({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-runtime",children:[a.jsx("h2",{className:Xe.heading,children:"Choose Your Runtime"}),a.jsx("p",{className:Xe.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),a.jsx("div",{className:Xe.runtimeGrid,children:Gq.map(u=>a.jsxs("button",{type:"button",className:Xe.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[a.jsx("span",{className:Xe.runtimeName,children:u.name}),a.jsx("span",{className:Xe.runtimeDescription,children:u.description})]},u.id))}),a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:o,children:"Back"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function Kq(){return typeof Notification<"u"}function Zq({onFinish:t,onBack:s,finishDisabled:o}){const r=Kq(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-notifications",children:[a.jsx("h2",{className:Xe.heading,children:"Stay in the Loop"}),a.jsx("p",{className:Xe.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?a.jsx("p",{className:Xe.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const Yq=4,R_={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function Jq(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=pt(),{showToast:c}=mn(),d=xt(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,b]=y.useState(!1),_=t.find(j=>j.id==="claude-code"),k=y.useCallback(j=>{g(j),p(3)},[]),S=y.useCallback(()=>{const j=m;b(!0);const T=[];if(_&&j!==_.runtime){const C=R_[j]??"sonnet";T.push(s(_.id,void 0,void 0,void 0,j,C))}const N=t.find(C=>C.id===my);if(N&&j!==N.runtime){const C=R_[j]??"sonnet";T.push(s(my,void 0,void 0,void 0,j,C))}Promise.all(T).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,_,t,s,o,d,c]);return r===!0?a.jsx(zn,{to:"/",replace:!0}):a.jsx("div",{className:Xe.wizard,"data-testid":"setup-wizard",children:a.jsxs("div",{className:Xe.container,children:[a.jsx(is,{mode:"wait",children:a.jsxs(Ut.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&a.jsx(Vq,{onNext:()=>p(1)}),u===1&&a.jsx(qq,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&a.jsx(Fq,{currentRuntime:m,onFinish:k,onBack:()=>p(1),finishDisabled:!_}),u===3&&a.jsx(Zq,{onFinish:S,onBack:()=>p(2),finishDisabled:v})]},u)}),a.jsx("div",{className:Xe.dots,children:Array.from({length:Yq},(j,T)=>a.jsx("span",{className:Xe.dot,"data-active":T===u},T))})]})})}const Wq="_root_zndgp_1",Xq="_body_zndgp_7",Qq="_main_zndgp_19",eG="_sidebarWrapper_zndgp_26",tG="_overlay_zndgp_51",Wr={root:Wq,body:Xq,main:Qq,sidebarWrapper:eG,overlay:tG},nG=y.lazy(()=>U_(()=>import("./KnowledgePage-DJ9NcB1C.js"),__vite__mapDeps([3,1,2,4,5])).then(t=>({default:t.KnowledgePage}))),Ek=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function sG({tabs:t}){const{connectionStatus:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=pt(),{toasts:d,dismissToast:u}=mn(),p=Wt(),m=x9(),g=m!==void 0,[v,b]=y.useState(!1),_=y.useCallback(()=>b(k=>!k),[]);return y.useEffect(()=>{b(!1)},[p.pathname]),y.useEffect(()=>{if(!v)return;const k=S=>{S.key==="Escape"&&b(!1)};return document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[v]),a.jsxs(a.Fragment,{children:[a.jsx(k5,{connectionStatus:s,environments:o,sessions:r,onToggleSidebar:g?_:void 0,sidebarOpen:v}),a.jsx(A5,{tabs:t}),a.jsxs("div",{className:Wr.body,children:[g&&a.jsx("div",{className:Wr.sidebarWrapper,"data-sidebar-open":v,children:a.jsx(B5,{content:m})}),g&&v&&a.jsx("div",{className:Wr.overlay,"data-testid":"drawer-overlay",onClick:()=>b(!1)}),a.jsxs("div",{className:Wr.main,children:[a.jsx(Ri,{}),a.jsx(q5,{sessions:r,tasks:c,environments:o})]})]}),a.jsx(FO,{toasts:d,onDismiss:u}),a.jsx(_q,{})]})}function aG(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connectionStatus:d,onboardingCompleted:u}=pt(),{pluginNames:p}=Bd(),{showToast:m}=mn();DH(s,m),BH(c,m),MH(o,r,m);const g=xt(),v=Wt();if(y.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(Rm(t),{replace:!0})},[t,g,v.pathname]),d==="connected"&&u===!1)return a.jsx(zn,{to:"/setup",replace:!0});const b=tH(p);return a.jsx(_9,{children:a.jsxs("div",{className:Wr.root,children:[Ek&&a.jsx(BC,{}),a.jsx(sG,{tabs:b})]})})}function Pp(){const{workspaceId:t}=pa(),{workspaces:{workspaces:s}}=pt(),o=Wt(),r=s.find(g=>g.id===t),c=r!=null&&r.linkedEnvironmentIds?[...r.linkedEnvironmentIds].sort()[0]:void 0;if(!c)return s.length===0?void 0:a.jsx(zn,{to:"/environments",replace:!0});const d=encodeURIComponent(t),u=`/workspaces/${d}`,p=o.pathname.startsWith(u)?o.pathname.slice(u.length):"",m=`/environments/${encodeURIComponent(c)}/workspaces/${d}${p}${o.search}${o.hash}`;return a.jsx(zn,{to:m,replace:!0})}function iG(){const{pluginNames:t}=Bd(),s=t.includes("orchestration"),o=t.includes("knowledge");return a.jsxs(xw,{children:[a.jsx(Ee,{path:"setup",element:a.jsx(Jq,{})}),a.jsxs(Ee,{element:a.jsx(aG,{}),children:[a.jsx(Ee,{index:!0,element:a.jsx(_U,{})}),a.jsx(Ee,{path:"sessions/new",element:a.jsx(HU,{})}),a.jsx(Ee,{path:"chat",element:a.jsx(AU,{})}),a.jsx(Ee,{path:"chat/:streamId",element:a.jsx(zn,{to:"/coordination",replace:!0})}),a.jsx(Ee,{path:"coordination",element:a.jsx($U,{})}),a.jsx(Ee,{path:"sessions/:sessionId",element:a.jsx(qU,{})}),o&&a.jsx(Ee,{element:a.jsx(jq,{}),children:a.jsx(Ee,{path:"knowledge",element:a.jsx(y.Suspense,{fallback:a.jsx(Y1,{}),children:a.jsx(nG,{})})})}),s&&a.jsxs(Ee,{element:a.jsx(xq,{}),children:[a.jsx(Ee,{path:"tasks",element:a.jsx(yU,{})}),a.jsx(Ee,{path:"tasks/new",element:a.jsx(w_,{})}),a.jsx(Ee,{path:"tasks/:taskId",element:a.jsx(Eo,{})}),a.jsx(Ee,{path:"tasks/:taskId/edit",element:a.jsx(Eo,{})}),a.jsx(Ee,{path:"tasks/:taskId/stream",element:a.jsx(Eo,{})})]}),a.jsxs(Ee,{element:a.jsx(kq,{}),children:[a.jsx(Ee,{path:"workspaces",element:a.jsx(zn,{to:"/environments",replace:!0})}),a.jsx(Ee,{path:"workspaces/new",element:a.jsx(iV,{})}),a.jsx(Ee,{path:"workspaces/:workspaceId",element:a.jsx(Pp,{})}),a.jsx(Ee,{path:"workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Pp,{})}),a.jsx(Ee,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:a.jsx(Pp,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId",element:a.jsx(ZU,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:a.jsx(w_,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Eo,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:a.jsx(Eo,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:a.jsx(Eo,{})}),a.jsxs(Ee,{path:"environments",element:a.jsx(fV,{}),children:[a.jsx(Ee,{index:!0,element:a.jsx(bU,{})}),a.jsx(Ee,{path:"new",element:a.jsx(rV,{})}),a.jsx(Ee,{path:":environmentId",element:a.jsx(UV,{})}),a.jsx(Ee,{path:":environmentId/edit",element:a.jsx(lV,{})})]})]}),a.jsx(Ee,{element:a.jsx(Sq,{}),children:a.jsxs(Ee,{path:"settings",element:a.jsx(GV,{}),children:[a.jsx(Ee,{index:!0,element:a.jsx(zn,{to:"credentials",replace:!0})}),a.jsx(Ee,{path:"environments",element:a.jsx(zn,{to:"/environments",replace:!0})}),a.jsx(Ee,{path:"credentials",element:a.jsx(FV,{})}),a.jsx(Ee,{path:"github-accounts",element:a.jsx(KV,{})}),a.jsx(Ee,{path:"tokens",element:a.jsx(zn,{to:"../credentials",replace:!0})}),a.jsx(Ee,{path:"personas",element:a.jsx(ZV,{})}),a.jsx(Ee,{path:"personas/new",element:a.jsx(A_,{})}),a.jsx(Ee,{path:"personas/:personaId",element:a.jsx(A_,{})}),a.jsx(Ee,{path:"schedules",element:a.jsx(iq,{})}),a.jsx(Ee,{path:"schedules/new",element:a.jsx(D_,{})}),a.jsx(Ee,{path:"schedules/:scheduleId",element:a.jsx(D_,{})}),a.jsx(Ee,{path:"appearance",element:a.jsx(hq,{})}),a.jsx(Ee,{path:"shortcuts",element:a.jsx(yq,{})}),a.jsx(Ee,{path:"plugins",element:a.jsx(bq,{})}),a.jsx(Ee,{path:"about",element:a.jsx(vq,{})})]})}),a.jsx(Ee,{path:"*",element:a.jsx(zn,{to:"/",replace:!0})})]})]})}const oG=1e4;function rG(){const{onboardingCompleted:t}=pt(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),oG);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return a.jsx(is,{mode:"wait",children:r?a.jsx(Ut.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:a.jsx(Y1,{})},"splash"):a.jsx(Ut.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:a.jsx(Fw,{basename:"/".replace(/\/$/,""),children:a.jsx(iG,{})})},"app")})}function lG(){const t=Ek?Z9:AH;return a.jsx(W9,{children:a.jsx(b9,{children:a.jsx(h9,{children:a.jsx(t,{children:a.jsx(rG,{})})})})})}pj.createRoot(document.getElementById("root")).render(a.jsx(y.StrictMode,{children:a.jsx(lG,{})}));export{ma as B,gx as K,pt as a,Rm as s,rs as t,xt as u};
755
+ $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),R==="agent"&&a.jsxs("div",{children:[a.jsx("label",{children:"Allowed MCP Tools"}),a.jsx(r_,{selectedTools:Y,onChange:ue=>{U(ue),lt(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,ue),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!xe&&!me&&a.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,a.jsx(bs,{isOpen:X,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:bt,onCancel:()=>te(!1)})]})}function iq(){const{schedules:{schedules:t,deleteSchedule:s,updateSchedule:o},personas:{personas:r}}=pt(),{showToast:c}=mn(),d=xt();return a.jsx(A7,{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(oC),onNavigateToSchedule:u=>d(px(u))})}const oq="_container_1g4qh_1",rq="_form_1g4qh_7",lq="_formActions_1g4qh_66",cq="_editableSection_1g4qh_73",dq="_helperText_1g4qh_84",uq="_metaSection_1g4qh_90",fq="_optional_1g4qh_108",pq="_readonlyValue_1g4qh_113",Bn={container:oq,form:rq,formActions:lq,editableSection:cq,helperText:dq,metaSection:uq,optional:fq,readonlyValue:pq};function D_(){const{scheduleId:t}=pa(),s=xt(),{showToast:o}=mn(),{schedules:{schedules:r,schedulesLoading:c,createSchedule:d,updateSchedule:u,deleteSchedule:p},personas:{personas:m},workspaces:{workspaces:g}}=pt(),v=t===void 0,b=v?void 0:r.find(k=>k.id===t);if(!v&&!c&&r.length>0&&!b)return a.jsx(zn,{to:np,replace:!0});const _=[{label:"Settings",url:Ti},{label:"Schedules",url:np},{label:v?"New Schedule":(b==null?void 0:b.title)??"Schedule",url:void 0}];return a.jsxs("div",{className:Bn.container,children:[a.jsx(ma,{segments:_}),a.jsx(mq,{existing:b,isNew:v,personas:m,workspaces:g,onCreateSchedule:d,onUpdateSchedule:u,onDeleteSchedule:p,onDone:()=>{s(np)},showToast:o})]})}function mq({existing:t,isNew:s,personas:o,workspaces:r,onCreateSchedule:c,onUpdateSchedule:d,onDeleteSchedule:u,onDone:p,showToast:m}){var H;const g=xt(),[v,b]=y.useState((t==null?void 0:t.title)??""),[_,k]=y.useState((t==null?void 0:t.description)??""),[S,j]=y.useState((t==null?void 0:t.scheduleExpression)??""),[T,N]=y.useState((t==null?void 0:t.personaId)??""),[C,D]=y.useState((t==null?void 0:t.workspaceId)??""),[A,E]=y.useState(!1),[R,B]=y.useState(null);y.useEffect(()=>{s||t&&R===null&&(b(t.title),k(t.description),j(t.scheduleExpression),N(t.personaId),D(t.workspaceId))},[s,t,R]);const M=!s&&t===void 0,$=s&&v.trim().length>0&&S.trim().length>0&&T.length>0,Y=o.map(O=>({value:O.id,label:O.name})),U=[{value:"",label:"System-level (no workspace)"},...r.map(O=>({value:O.id,label:O.name}))],X=O=>{O.preventDefault(),$&&c(v,_,S,T,C||void 0).then(q=>{m("Schedule created","success"),g(px(q.id),{replace:!0})},()=>{m("Failed to create schedule","error")})},te=(O,q)=>{t&&d(t.id,{[O]:q}).then(()=>{m("Schedule updated","success"),O==="title"&&b(String(q)),O==="description"&&k(String(q)),O==="scheduleExpression"&&j(String(q)),O==="personaId"&&N(String(q))},()=>{m("Failed to update schedule","error")})},G=()=>{if(!t)return;const O=!t.enabled;d(t.id,{enabled:O}).then(()=>{m(O?"Schedule enabled":"Schedule disabled","success")},()=>{m("Failed to update schedule","error")})},ne=()=>{t&&u(t.id).then(()=>{m("Schedule deleted","success"),p()},()=>{m("Failed to delete schedule","error")})};return a.jsxs(a.Fragment,{children:[M?a.jsxs("div",{className:Bn.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsx("p",{children:"Loading schedule..."})]}):s?a.jsxs("form",{onSubmit:X,className:Bn.form,children:[a.jsx("h3",{children:"Create Schedule"}),a.jsxs("label",{children:["Title",a.jsx("input",{type:"text",value:v,onChange:O=>b(O.target.value),placeholder:"e.g. Nightly Review",required:!0,"data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description ",a.jsx("span",{className:Bn.optional,children:"(optional)"}),a.jsx("input",{type:"text",value:_,onChange:O=>k(O.target.value),placeholder:"Brief description...","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx("input",{type:"text",value:S,onChange:O=>j(O.target.value),placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",required:!0,"data-testid":"schedule-detail-expression"}),a.jsxs("p",{className:Bn.helperText,children:["Interval: ",a.jsx("code",{children:"30s"}),", ",a.jsx("code",{children:"5m"}),", ",a.jsx("code",{children:"1h"}),", ",a.jsx("code",{children:"1d"})," (min 10s)  |  Cron: ",a.jsx("code",{children:"0 9 * * MON"})," (standard 5-field cron syntax)"]})]}),a.jsxs("label",{children:["Persona",a.jsxs("select",{value:T,onChange:O=>N(O.target.value),required:!0,"data-testid":"schedule-detail-persona",children:[a.jsx("option",{value:"",children:"Select a persona..."}),Y.map(O=>a.jsx("option",{value:O.value,children:O.label},O.value))]})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:Bn.optional,children:"(optional)"}),a.jsx("select",{value:C,onChange:O=>D(O.target.value),"data-testid":"schedule-detail-workspace",children:U.map(O=>a.jsx("option",{value:O.value,children:O.label},O.value))})]}),a.jsxs("div",{className:Bn.formActions,children:[a.jsx(an,{type:"submit",variant:"primary",size:"md",disabled:!$,"data-testid":"schedule-detail-save",children:"Create"}),a.jsx(an,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Cancel"})]})]}):t?a.jsxs("div",{className:Bn.form,children:[a.jsx("h3",{children:"Edit Schedule"}),a.jsxs("div",{className:Bn.formActions,children:[a.jsx(an,{type:"button",variant:"outline",size:"md",onClick:p,"data-testid":"schedule-detail-cancel",children:"Back to Schedules"}),a.jsx(an,{type:"button",variant:t.enabled?"ghost":"primary",size:"md",onClick:G,"data-testid":"schedule-detail-toggle",children:t.enabled?"Disable":"Enable"}),a.jsx(an,{type:"button",variant:"danger",size:"md",onClick:()=>E(!0),"data-testid":"schedule-detail-delete",children:"Delete"})]}),a.jsxs("div",{className:Bn.editableSection,children:[a.jsxs("label",{children:["Title",a.jsx($t,{value:v,onSave:O=>{te("title",O)},validate:O=>O.trim()?void 0:"Title is required",fieldId:"schedule-title",activeFieldId:R,onActivate:B,ariaLabel:"Schedule title","data-testid":"schedule-detail-title"})]}),a.jsxs("label",{children:["Description",a.jsx($t,{value:_,onSave:O=>{te("description",O)},fieldId:"schedule-description",activeFieldId:R,onActivate:B,placeholder:"Brief description...",ariaLabel:"Schedule description","data-testid":"schedule-detail-description"})]}),a.jsxs("label",{children:["Schedule Expression",a.jsx($t,{value:S,onSave:O=>{te("scheduleExpression",O)},validate:O=>O.trim()?void 0:"Schedule expression is required",fieldId:"schedule-expression",activeFieldId:R,onActivate:B,placeholder:"e.g. 30s, 5m, 1h, or 0 9 * * MON",ariaLabel:"Schedule expression","data-testid":"schedule-detail-expression"})]}),a.jsxs("label",{children:["Persona",a.jsx(bd,{value:T,onSave:O=>{te("personaId",O)},options:Y,fieldId:"schedule-persona",activeFieldId:R,onActivate:B,ariaLabel:"Schedule persona","data-testid":"schedule-detail-persona"})]}),a.jsxs("label",{children:["Workspace ",a.jsx("span",{className:Bn.optional,children:"(optional — set at creation)"}),a.jsx("span",{className:Bn.readonlyValue,"data-testid":"schedule-detail-workspace",children:((H=r.find(O=>O.id===t.workspaceId))==null?void 0:H.name)??"System-level (no workspace)"})]})]}),a.jsxs("div",{className:Bn.metaSection,children:[t.lastRunAt?a.jsxs("span",{children:["Last run: ",mm(t.lastRunAt)]}):a.jsx("span",{children:"Last run: Never"}),t.enabled&&t.nextRunAt?a.jsxs("span",{children:["Next run: ",ck(t.nextRunAt)]}):null,t.runCount>0&&a.jsxs("span",{children:["Total runs: ",t.runCount]}),a.jsxs("span",{children:["Created: ",mm(t.createdAt)]})]})]}):null,a.jsx(bs,{isOpen:A,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:ne,onCancel:()=>E(!1)})]})}function hq(){const{themeId:t,resolvedThemeId:s,setTheme:o,preferSystem:r,setPreferSystem:c}=bh();return a.jsx(FB,{themeId:t,resolvedThemeId:s,onSetTheme:o,preferSystem:r,onSetPreferSystem:c})}function gq(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let o=!1;return(async()=>{try{const c=await Be.getVersionStatus({});o||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{o=!0}},[]),t}function vq(){const{connectionStatus:t,environments:{environments:s},sessions:{sessions:o}}=pt(),r=gq();return a.jsxs(a.Fragment,{children:[r&&a.jsx(sB,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),a.jsx(YB,{connectionStatus:t,environments:s,sessions:o})]})}function yq(){return a.jsx(H8,{})}function bq(){const{plugins:{plugins:t,pluginsLoading:s,setPluginEnabled:o}}=pt();return a.jsx(d8,{plugins:t,loading:s,onSetPluginEnabled:(r,c)=>{o(r,c).catch(()=>{})}})}const M_=Ii();function _q(){const t=xt();return Ya({key:"?"},()=>{t(rC)}),Ya({key:"n"},()=>{t(M_)}),Ya({key:"N"},()=>{t(M_)}),a.jsx(a.Fragment,{})}function Ld(t){const s=k9();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function xq(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=pt(),o=y.useMemo(()=>a.jsx(RO,{workspaces:t,tasks:s}),[t,s]);return Ld(o),a.jsx(Ri,{})}function kq(){const{environments:{environments:t}}=pt(),s=y.useMemo(()=>a.jsx(eO,{environments:t}),[t]);return Ld(s),a.jsx(Ri,{})}function Sq(){const t=y.useMemo(()=>a.jsx(O7,{}),[]);return Ld(t),a.jsx(Ri,{})}function jq(){const{knowledge:t,workspaces:{workspaces:s}}=pt(),o=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>a.jsx(c5,{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 Ld(u),a.jsx(Ri,{})}const Tq="_wizard_1260s_1",Nq="_container_1260s_10",wq="_stepContent_1260s_19",Cq="_logoArea_1260s_28",Eq="_logoImage_1260s_32",Aq="_heading_1260s_41",Dq="_tagline_1260s_49",Mq="_subtitle_1260s_56",Rq="_featureList_1260s_64",Iq="_runtimeGrid_1260s_89",Oq="_runtimeCard_1260s_101",Bq="_runtimeName_1260s_133",Lq="_runtimeDescription_1260s_139",zq="_buttonRow_1260s_144",$q="_primaryButton_1260s_151",Hq="_ghostButton_1260s_185",Pq="_dots_1260s_213",Uq="_dot_1260s_213",Xe={wizard:Tq,container:Nq,stepContent:wq,logoArea:Cq,logoImage:Eq,heading:Aq,tagline:Dq,subtitle:Mq,featureList:Rq,runtimeGrid:Iq,runtimeCard:Oq,runtimeName:Bq,runtimeDescription:Lq,buttonRow:zq,primaryButton:$q,ghostButton:Hq,dots:Pq,dot:Uq};function Vq({onNext:t}){return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-welcome",children:[a.jsx("div",{className:Xe.logoArea,children:a.jsx("img",{src:Id("grackle-logo.png"),alt:"Grackle",className:Xe.logoImage})}),a.jsx("h1",{className:Xe.heading,children:"Welcome to Grackle"}),a.jsx("p",{className:Xe.tagline,children:"Multi-agent orchestration for software teams"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function qq({onNext:t,onBack:s}){return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-about",children:[a.jsx("h2",{className:Xe.heading,children:"What is Grackle?"}),a.jsxs("ul",{className:Xe.featureList,children:[a.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),a.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),a.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),a.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),a.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:s,children:"Back"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const Gq=[{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 Fq({currentRuntime:t,onFinish:s,onBack:o,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-runtime",children:[a.jsx("h2",{className:Xe.heading,children:"Choose Your Runtime"}),a.jsx("p",{className:Xe.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),a.jsx("div",{className:Xe.runtimeGrid,children:Gq.map(u=>a.jsxs("button",{type:"button",className:Xe.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[a.jsx("span",{className:Xe.runtimeName,children:u.name}),a.jsx("span",{className:Xe.runtimeDescription,children:u.description})]},u.id))}),a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:o,children:"Back"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function Kq(){return typeof Notification<"u"}function Zq({onFinish:t,onBack:s,finishDisabled:o}){const r=Kq(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return a.jsxs("div",{className:Xe.stepContent,"data-testid":"setup-notifications",children:[a.jsx("h2",{className:Xe.heading,children:"Stay in the Loop"}),a.jsx("p",{className:Xe.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?a.jsx("p",{className:Xe.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,a.jsxs("div",{className:Xe.buttonRow,children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:s,disabled:o,children:"Back"}),!c&&r?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:Xe.ghostButton,onClick:t,disabled:o,"data-testid":"setup-notifications-skip",children:"Skip"}),a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:d,disabled:o,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):a.jsx("button",{type:"button",className:Xe.primaryButton,onClick:t,disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const Yq=4,R_={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function Jq(){const{personas:{personas:t,updatePersona:s},completeOnboarding:o,onboardingCompleted:r}=pt(),{showToast:c}=mn(),d=xt(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,b]=y.useState(!1),_=t.find(j=>j.id==="claude-code"),k=y.useCallback(j=>{g(j),p(3)},[]),S=y.useCallback(()=>{const j=m;b(!0);const T=[];if(_&&j!==_.runtime){const C=R_[j]??"sonnet";T.push(s(_.id,void 0,void 0,void 0,j,C))}const N=t.find(C=>C.id===my);if(N&&j!==N.runtime){const C=R_[j]??"sonnet";T.push(s(my,void 0,void 0,void 0,j,C))}Promise.all(T).then(()=>o()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,_,t,s,o,d,c]);return r===!0?a.jsx(zn,{to:"/",replace:!0}):a.jsx("div",{className:Xe.wizard,"data-testid":"setup-wizard",children:a.jsxs("div",{className:Xe.container,children:[a.jsx(is,{mode:"wait",children:a.jsxs(Ut.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&a.jsx(Vq,{onNext:()=>p(1)}),u===1&&a.jsx(qq,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&a.jsx(Fq,{currentRuntime:m,onFinish:k,onBack:()=>p(1),finishDisabled:!_}),u===3&&a.jsx(Zq,{onFinish:S,onBack:()=>p(2),finishDisabled:v})]},u)}),a.jsx("div",{className:Xe.dots,children:Array.from({length:Yq},(j,T)=>a.jsx("span",{className:Xe.dot,"data-active":T===u},T))})]})})}const Wq="_root_zndgp_1",Xq="_body_zndgp_7",Qq="_main_zndgp_19",eG="_sidebarWrapper_zndgp_26",tG="_overlay_zndgp_51",Wr={root:Wq,body:Xq,main:Qq,sidebarWrapper:eG,overlay:tG},nG=y.lazy(()=>U_(()=>import("./KnowledgePage-DNjACSvg.js"),__vite__mapDeps([3,1,2,4,5])).then(t=>({default:t.KnowledgePage}))),Ek=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function sG({tabs:t}){const{connectionStatus:s,environments:{environments:o},sessions:{sessions:r},tasks:{tasks:c}}=pt(),{toasts:d,dismissToast:u}=mn(),p=Wt(),m=x9(),g=m!==void 0,[v,b]=y.useState(!1),_=y.useCallback(()=>b(k=>!k),[]);return y.useEffect(()=>{b(!1)},[p.pathname]),y.useEffect(()=>{if(!v)return;const k=S=>{S.key==="Escape"&&b(!1)};return document.addEventListener("keydown",k),()=>{document.removeEventListener("keydown",k)}},[v]),a.jsxs(a.Fragment,{children:[a.jsx(k5,{connectionStatus:s,environments:o,sessions:r,onToggleSidebar:g?_:void 0,sidebarOpen:v}),a.jsx(A5,{tabs:t}),a.jsxs("div",{className:Wr.body,children:[g&&a.jsx("div",{className:Wr.sidebarWrapper,"data-sidebar-open":v,children:a.jsx(B5,{content:m})}),g&&v&&a.jsx("div",{className:Wr.overlay,"data-testid":"drawer-overlay",onClick:()=>b(!1)}),a.jsxs("div",{className:Wr.main,children:[a.jsx(Ri,{}),a.jsx(q5,{sessions:r,tasks:c,environments:o})]})]}),a.jsx(FO,{toasts:d,onDismiss:u}),a.jsx(_q,{})]})}function aG(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:o,clearOperationError:r},tasks:{tasks:c},connectionStatus:d,onboardingCompleted:u}=pt(),{pluginNames:p}=Bd(),{showToast:m}=mn();DH(s,m),BH(c,m),MH(o,r,m);const g=xt(),v=Wt();if(y.useEffect(()=>{t&&!v.pathname.includes("/tasks/")&&g(Rm(t),{replace:!0})},[t,g,v.pathname]),d==="connected"&&u===!1)return a.jsx(zn,{to:"/setup",replace:!0});const b=tH(p);return a.jsx(_9,{children:a.jsxs("div",{className:Wr.root,children:[Ek&&a.jsx(BC,{}),a.jsx(sG,{tabs:b})]})})}function Pp(){const{workspaceId:t}=pa(),{workspaces:{workspaces:s}}=pt(),o=Wt(),r=s.find(g=>g.id===t),c=r!=null&&r.linkedEnvironmentIds?[...r.linkedEnvironmentIds].sort()[0]:void 0;if(!c)return s.length===0?void 0:a.jsx(zn,{to:"/environments",replace:!0});const d=encodeURIComponent(t),u=`/workspaces/${d}`,p=o.pathname.startsWith(u)?o.pathname.slice(u.length):"",m=`/environments/${encodeURIComponent(c)}/workspaces/${d}${p}${o.search}${o.hash}`;return a.jsx(zn,{to:m,replace:!0})}function iG(){const{pluginNames:t}=Bd(),s=t.includes("orchestration"),o=t.includes("knowledge");return a.jsxs(xw,{children:[a.jsx(Ee,{path:"setup",element:a.jsx(Jq,{})}),a.jsxs(Ee,{element:a.jsx(aG,{}),children:[a.jsx(Ee,{index:!0,element:a.jsx(_U,{})}),a.jsx(Ee,{path:"sessions/new",element:a.jsx(HU,{})}),a.jsx(Ee,{path:"chat",element:a.jsx(AU,{})}),a.jsx(Ee,{path:"chat/:streamId",element:a.jsx(zn,{to:"/coordination",replace:!0})}),a.jsx(Ee,{path:"coordination",element:a.jsx($U,{})}),a.jsx(Ee,{path:"sessions/:sessionId",element:a.jsx(qU,{})}),o&&a.jsx(Ee,{element:a.jsx(jq,{}),children:a.jsx(Ee,{path:"knowledge",element:a.jsx(y.Suspense,{fallback:a.jsx(Y1,{}),children:a.jsx(nG,{})})})}),s&&a.jsxs(Ee,{element:a.jsx(xq,{}),children:[a.jsx(Ee,{path:"tasks",element:a.jsx(yU,{})}),a.jsx(Ee,{path:"tasks/new",element:a.jsx(w_,{})}),a.jsx(Ee,{path:"tasks/:taskId",element:a.jsx(Eo,{})}),a.jsx(Ee,{path:"tasks/:taskId/edit",element:a.jsx(Eo,{})}),a.jsx(Ee,{path:"tasks/:taskId/stream",element:a.jsx(Eo,{})})]}),a.jsxs(Ee,{element:a.jsx(kq,{}),children:[a.jsx(Ee,{path:"workspaces",element:a.jsx(zn,{to:"/environments",replace:!0})}),a.jsx(Ee,{path:"workspaces/new",element:a.jsx(iV,{})}),a.jsx(Ee,{path:"workspaces/:workspaceId",element:a.jsx(Pp,{})}),a.jsx(Ee,{path:"workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Pp,{})}),a.jsx(Ee,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:a.jsx(Pp,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId",element:a.jsx(ZU,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:a.jsx(w_,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:a.jsx(Eo,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:a.jsx(Eo,{})}),a.jsx(Ee,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:a.jsx(Eo,{})}),a.jsxs(Ee,{path:"environments",element:a.jsx(fV,{}),children:[a.jsx(Ee,{index:!0,element:a.jsx(bU,{})}),a.jsx(Ee,{path:"new",element:a.jsx(rV,{})}),a.jsx(Ee,{path:":environmentId",element:a.jsx(UV,{})}),a.jsx(Ee,{path:":environmentId/edit",element:a.jsx(lV,{})})]})]}),a.jsx(Ee,{element:a.jsx(Sq,{}),children:a.jsxs(Ee,{path:"settings",element:a.jsx(GV,{}),children:[a.jsx(Ee,{index:!0,element:a.jsx(zn,{to:"credentials",replace:!0})}),a.jsx(Ee,{path:"environments",element:a.jsx(zn,{to:"/environments",replace:!0})}),a.jsx(Ee,{path:"credentials",element:a.jsx(FV,{})}),a.jsx(Ee,{path:"github-accounts",element:a.jsx(KV,{})}),a.jsx(Ee,{path:"tokens",element:a.jsx(zn,{to:"../credentials",replace:!0})}),a.jsx(Ee,{path:"personas",element:a.jsx(ZV,{})}),a.jsx(Ee,{path:"personas/new",element:a.jsx(A_,{})}),a.jsx(Ee,{path:"personas/:personaId",element:a.jsx(A_,{})}),a.jsx(Ee,{path:"schedules",element:a.jsx(iq,{})}),a.jsx(Ee,{path:"schedules/new",element:a.jsx(D_,{})}),a.jsx(Ee,{path:"schedules/:scheduleId",element:a.jsx(D_,{})}),a.jsx(Ee,{path:"appearance",element:a.jsx(hq,{})}),a.jsx(Ee,{path:"shortcuts",element:a.jsx(yq,{})}),a.jsx(Ee,{path:"plugins",element:a.jsx(bq,{})}),a.jsx(Ee,{path:"about",element:a.jsx(vq,{})})]})}),a.jsx(Ee,{path:"*",element:a.jsx(zn,{to:"/",replace:!0})})]})]})}const oG=1e4;function rG(){const{onboardingCompleted:t}=pt(),[s,o]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>o(!0),oG);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return a.jsx(is,{mode:"wait",children:r?a.jsx(Ut.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:a.jsx(Y1,{})},"splash"):a.jsx(Ut.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:a.jsx(Fw,{basename:"/".replace(/\/$/,""),children:a.jsx(iG,{})})},"app")})}function lG(){const t=Ek?Z9:AH;return a.jsx(W9,{children:a.jsx(b9,{children:a.jsx(h9,{children:a.jsx(t,{children:a.jsx(rG,{})})})})})}pj.createRoot(document.getElementById("root")).render(a.jsx(y.StrictMode,{children:a.jsx(lG,{})}));export{ma as B,gx as K,pt as a,Rm as s,rs as t,xt as u};
package/dist/index.html CHANGED
@@ -10,7 +10,7 @@
10
10
  <link rel="icon" type="image/x-icon" href="/favicon.ico" />
11
11
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
12
12
  <link rel="manifest" href="/manifest.json" />
13
- <script type="module" crossorigin src="/assets/index-BYoJMBJg.js"></script>
13
+ <script type="module" crossorigin src="/assets/index-BzbnBHCp.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="/assets/dagview-B70jDsRo.js">
15
15
  <link rel="modulepreload" crossorigin href="/assets/grpc-CHXyF1mC.js">
16
16
  <link rel="modulepreload" crossorigin href="/assets/markdown-CPoGw-1N.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grackle-ai/web",
3
- "version": "0.133.1",
3
+ "version": "0.134.0",
4
4
  "description": "React web UI for the Grackle multi-agent coordination platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,8 +38,8 @@
38
38
  "rehype-prism-plus": "^2.0.0",
39
39
  "remark-gfm": "^4.0.0",
40
40
  "react-router": "^7.0.0",
41
- "@grackle-ai/common": "0.133.1",
42
- "@grackle-ai/web-components": "0.133.1"
41
+ "@grackle-ai/common": "0.134.0",
42
+ "@grackle-ai/web-components": "0.134.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@rushstack/heft": "1.2.7",