@grackle-ai/web 0.95.0 → 0.95.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{t as nt,f as rt,b as A,z as it,s as T,h as st,k as X,j as N}from"./dagview-tHPW3Rz3.js";import{u as at,f as ot,s as ct,t as lt,a as ut,B as ft,K as ht}from"./index-Bwk_xNWH.js";import"./grpc-Cjo4GFxo.js";import"./markdown-Yr3vTPLR.js";function dt(t,e){var n,o=1;t==null&&(t=0),e==null&&(e=0);function s(){var r,c=n.length,d,y=0,i=0;for(r=0;r<c;++r)d=n[r],y+=d.x,i+=d.y;for(y=(y/c-t)*o,i=(i/c-e)*o,r=0;r<c;++r)d=n[r],d.x-=y,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 gt(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,y=t._y0,i=t._x1,v=t._y1,w,_,h,p,l,a,u,f;if(!r)return t._root=c,t;for(;r.length;)if((l=e>=(w=(d+i)/2))?d=w:i=w,(a=n>=(_=(y+v)/2))?y=_:v=_,s=r,!(r=r[u=a<<1|l]))return s[u]=c,t;if(h=+t._x.call(null,r.data),p=+t._y.call(null,r.data),e===h&&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>=(w=(d+i)/2))?d=w:i=w,(a=n>=(_=(y+v)/2))?y=_:v=_;while((u=a<<1|l)===(f=(p>=_)<<1|h>=w));return s[f]=r,s[u]=c,t}function xt(t){var e,n,o=t.length,s,r,c=new Array(o),d=new Array(o),y=1/0,i=1/0,v=-1/0,w=-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<y&&(y=s),s>v&&(v=s),r<i&&(i=r),r>w&&(w=r));if(y>v||i>w)return this;for(this.cover(y,i).cover(v,w),n=0;n<o;++n)q(this,c[n],d[n],t[n]);return this}function _t(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,y,i;n>t||t>=s||o>e||e>=r;)switch(i=(e<o)<<1|t<n,y=new Array(4),y[i]=d,d=y,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 vt(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 mt(t,e,n){var o,s=this._x0,r=this._y0,c,d,y,i,v=this._x1,w=this._y1,_=[],h=this._root,p,l;for(h&&_.push(new L(h,s,r,v,w)),n==null?n=1/0:(s=t-n,r=e-n,v=t+n,w=e+n,n*=n);p=_.pop();)if(!(!(h=p.node)||(c=p.x0)>v||(d=p.y0)>w||(y=p.x1)<s||(i=p.y1)<r))if(h.length){var a=(c+y)/2,u=(d+i)/2;_.push(new L(h[3],a,u,y,i),new L(h[2],c,u,a,i),new L(h[1],a,d,y,u),new L(h[0],c,d,a,u)),(l=(e>=u)<<1|t>=a)&&(p=_[_.length-1],_[_.length-1]=_[_.length-1-l],_[_.length-1-l]=p)}else{var f=t-+this._x.call(null,h.data),m=e-+this._y.call(null,h.data),x=f*f+m*m;if(x<n){var b=Math.sqrt(n=x);s=t-b,r=e-b,v=t+b,w=e+b,o=h.data}}return o}function pt(t){if(isNaN(v=+this._x.call(null,t))||isNaN(w=+this._y.call(null,t)))return this;var e,n=this._root,o,s,r,c=this._x0,d=this._y0,y=this._x1,i=this._y1,v,w,_,h,p,l,a,u;if(!n)return this;if(n.length)for(;;){if((p=v>=(_=(c+y)/2))?c=_:y=_,(l=w>=(h=(d+i)/2))?d=h:i=h,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 wt(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function Nt(){return this._root}function bt(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function kt(t){var e=[],n,o=this._root,s,r,c,d,y;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,y=n.y1)&&o.length){var i=(r+d)/2,v=(c+y)/2;(s=o[3])&&e.push(new L(s,i,v,d,y)),(s=o[2])&&e.push(new L(s,r,v,i,y)),(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,y=o.x1,i=o.y1,v=(c+y)/2,w=(d+i)/2;(r=s[0])&&e.push(new L(r,c,d,v,w)),(r=s[1])&&e.push(new L(r,v,d,y,w)),(r=s[2])&&e.push(new L(r,c,w,v,i)),(r=s[3])&&e.push(new L(r,v,w,y,i))}n.push(o)}for(;o=n.pop();)t(o.node,o.x0,o.y0,o.x1,o.y1);return this}function At(t){return t[0]}function It(t){return arguments.length?(this._x=t,this):this._x}function Mt(t){return t[1]}function Ct(t){return arguments.length?(this._y=t,this):this._y}function U(t,e,n){var o=new P(e??At,n??Mt,NaN,NaN,NaN,NaN);return t==null?o:o.addAll(t)}function P(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=U.prototype=P.prototype;R.copy=function(){var t=new P(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=gt;R.addAll=xt;R.cover=_t;R.data=yt;R.extent=vt;R.find=mt;R.remove=pt;R.removeAll=wt;R.root=Nt;R.size=bt;R.visit=kt;R.visitAfter=jt;R.x=It;R.y=Ct;function O(t){return function(){return t}}function S(t){return(t()-.5)*1e-6}function Lt(t){return t.x+t.vx}function Rt(t){return t.y+t.vy}function Et(t){var e,n,o,s=1,r=1;typeof t!="function"&&(t=O(t==null?1:+t));function c(){for(var i,v=e.length,w,_,h,p,l,a,u=0;u<r;++u)for(w=U(e,Lt,Rt).visitAfter(d),i=0;i<v;++i)_=e[i],l=n[_.index],a=l*l,h=_.x+_.vx,p=_.y+_.vy,w.visit(f);function f(m,x,b,I,C){var k=m.data,D=m.r,g=l+D;if(k){if(k.index>_.index){var j=h-k.x-k.vx,z=p-k.y-k.vy,B=j*j+z*z;B<g*g&&(j===0&&(j=S(o),B+=j*j),z===0&&(z=S(o),B+=z*z),B=(g-(B=Math.sqrt(B)))/B*s,_.vx+=(j*=B)*(g=(D*=D)/(a+D)),_.vy+=(z*=B)*g,k.vx-=j*(g=1-g),k.vy-=z*g)}return}return x>h+g||I<h-g||b>p+g||C<p-g}}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 y(){if(e){var i,v=e.length,w;for(n=new Array(v),i=0;i<v;++i)w=e[i],n[w.index]=+t(w,i,e)}}return c.initialize=function(i,v){e=i,o=v,y()},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:O(+i),y(),c):t},c}function Dt(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=Dt,n=w,o,s=O(30),r,c,d,y,i,v=1;t==null&&(t=[]);function w(a){return 1/Math.min(d[a.source.index],d[a.target.index])}function _(a){for(var u=0,f=t.length;u<v;++u)for(var m=0,x,b,I,C,k,D,g;m<f;++m)x=t[m],b=x.source,I=x.target,C=I.x+I.vx-b.x-b.vx||S(i),k=I.y+I.vy-b.y-b.vy||S(i),D=Math.sqrt(C*C+k*k),D=(D-r[m])/D*a*o[m],C*=D,k*=D,I.vx-=C*(g=y[m]),I.vy-=k*g,b.vx+=C*(g=1-g),b.vy+=k*g}function h(){if(c){var a,u=c.length,f=t.length,m=new Map(c.map((b,I)=>[e(b,I,c),b])),x;for(a=0,d=new Array(u);a<f;++a)x=t[a],x.index=a,typeof x.source!="object"&&(x.source=W(m,x.source)),typeof x.target!="object"&&(x.target=W(m,x.target)),d[x.source.index]=(d[x.source.index]||0)+1,d[x.target.index]=(d[x.target.index]||0)+1;for(a=0,y=new Array(f);a<f;++a)x=t[a],y[a]=d[x.source.index]/(d[x.source.index]+d[x.target.index]);o=new Array(f),p(),r=new Array(f),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 _.initialize=function(a,u){c=a,i=u,h()},_.links=function(a){return arguments.length?(t=a,h(),_):t},_.id=function(a){return arguments.length?(e=a,_):e},_.iterations=function(a){return arguments.length?(v=+a,_):v},_.strength=function(a){return arguments.length?(n=typeof a=="function"?a:O(+a),p(),_):n},_.distance=function(a){return arguments.length?(s=typeof a=="function"?a:O(+a),l(),_):s},_}const zt=1664525,Tt=1013904223,Q=4294967296;function St(){let t=1;return()=>(t=(zt*t+Tt)%Q)/Q}function $t(t){return t.x}function Gt(t){return t.y}var Ot=10,Ft=Math.PI*(3-Math.sqrt(5));function Kt(t){var e,n=1,o=.001,s=1-Math.pow(o,1/300),r=0,c=.6,d=new Map,y=nt(w),i=rt("tick","end"),v=St();t==null&&(t=[]);function w(){_(),i.call("tick",e),n<o&&(y.stop(),i.call("end",e))}function _(l){var a,u=t.length,f;l===void 0&&(l=1);for(var m=0;m<l;++m)for(n+=(r-n)*s,d.forEach(function(x){x(n)}),a=0;a<u;++a)f=t[a],f.fx==null?f.x+=f.vx*=c:(f.x=f.fx,f.vx=0),f.fy==null?f.y+=f.vy*=c:(f.y=f.fy,f.vy=0);return e}function h(){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 f=Ot*Math.sqrt(.5+l),m=l*Ft;u.x=f*Math.cos(m),u.y=f*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 h(),e={tick:_,restart:function(){return y.restart(w),e},stop:function(){return y.stop(),e},nodes:function(l){return arguments.length?(t=l,h(),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 f=0,m=t.length,x,b,I,C,k;for(u==null?u=1/0:u*=u,f=0;f<m;++f)C=t[f],x=l-C.x,b=a-C.y,I=x*x+b*b,I<u&&(k=C,u=I);return k},on:function(l,a){return arguments.length>1?(i.on(l,a),e):i.on(l)}}}function Ht(){var t,e,n,o,s=O(-30),r,c=1,d=1/0,y=.81;function i(h){var p,l=t.length,a=U(t,$t,Gt).visitAfter(w);for(o=h,p=0;p<l;++p)e=t[p],a.visit(_)}function v(){if(t){var h,p=t.length,l;for(r=new Array(p),h=0;h<p;++h)l=t[h],r[l.index]=+s(l,h,t)}}function w(h){var p=0,l,a,u=0,f,m,x;if(h.length){for(f=m=x=0;x<4;++x)(l=h[x])&&(a=Math.abs(l.value))&&(p+=l.value,u+=a,f+=a*l.x,m+=a*l.y);h.x=f/u,h.y=m/u}else{l=h,l.x=l.data.x,l.y=l.data.y;do p+=r[l.data.index];while(l=l.next)}h.value=p}function _(h,p,l,a){if(!h.value)return!0;var u=h.x-e.x,f=h.y-e.y,m=a-p,x=u*u+f*f;if(m*m/y<x)return x<d&&(u===0&&(u=S(n),x+=u*u),f===0&&(f=S(n),x+=f*f),x<c&&(x=Math.sqrt(c*x)),e.vx+=u*h.value*o/x,e.vy+=f*h.value*o/x),!0;if(h.length||x>=d)return;(h.data!==e||h.next)&&(u===0&&(u=S(n),x+=u*u),f===0&&(f=S(n),x+=f*f),x<c&&(x=Math.sqrt(c*x)));do h.data!==e&&(m=r[h.data.index]*o/x,e.vx+=u*m,e.vy+=f*m);while(h=h.next)}return i.initialize=function(h,p){t=h,n=p,v()},i.strength=function(h){return arguments.length?(s=typeof h=="function"?h:O(+h),v(),i):s},i.distanceMin=function(h){return arguments.length?(c=h*h,i):Math.sqrt(c)},i.distanceMax=function(h){return arguments.length?(d=h*h,i):Math.sqrt(d)},i.theta=function(h){return arguments.length?(y=h*h,i):Math.sqrt(y)},i}const Ut="_graphContainer_13vy2_1",Pt="_svg_13vy2_10",Xt="_link_13vy2_18",Yt="_node_13vy2_30",Wt="_nodeCard_13vy2_37",Qt="_nodeLabel_13vy2_43",Vt="_selected_13vy2_47",Zt="_dimmed_13vy2_54",Jt="_dimmedLink_13vy2_59",qt="_nodeIndicator_13vy2_71",te="_nodeBadge_13vy2_85",E={graphContainer:Ut,svg:Pt,link:Xt,node:Yt,nodeCard:Wt,nodeLabel:Qt,selected:Vt,dimmed:Zt,dimmedLink:Jt,nodeIndicator:qt,nodeBadge:te},K={reference:"#4A9EFF",decision:"#22C55E",insight:"#EAB308",concept:"#A855F7",snippet:"#6B7280"};function V(t){return t.kind==="reference"?K.reference:K[t.category??"insight"]??K.insight}const $=200,G=52,Z=12,F=40,J=3;function ee(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-$/2-F,d=o+$/2+F,y=s-G/2-F,i=r+G/2+F,v=d-c,w=i-y,_=Math.min(e.width/v,e.height/w,1),h=(c+d)/2,p=(y+i)/2;return{translateX:e.width/2-h*_,translateY:e.height/2-p*_,scale:_}}function ne({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),y=A.useRef(void 0),i=A.useRef(void 0),v=A.useRef(e);v.current=e;const w=A.useRef(!1),[_,h]=A.useState({width:800,height:600}),p=A.useRef(0);A.useEffect(()=>{var x;const f=((x=s.current)==null?void 0:x.parentElement)??null;if(!f)return;const m=new ResizeObserver(b=>{for(const I of b)h({width:I.contentRect.width,height:I.contentRect.height})});return m.observe(f),h({width:f.clientWidth,height:f.clientHeight}),()=>{m.disconnect()}},[]),A.useEffect(()=>{if(!s.current||!r.current)return;const f=s.current,m=r.current,x=it().scaleExtent([.1,4]).filter(b=>b.type!=="dblclick").on("zoom",b=>{T(m).attr("transform",String(b.transform))});return T(f).call(x),d.current=x,()=>{T(f).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 f=r.current;if(c.current&&(c.current.stop(),c.current=void 0),w.current=!1,t.nodes.length===0){T(f).selectAll("*").remove();return}const m=t.nodes.map(g=>({...g})),x=new Map(m.map(g=>[g.id,g])),b=t.links.filter(g=>x.has(g.source)&&x.has(g.target)).map(g=>({source:g.source,target:g.target,type:g.type}));T(f).selectAll("*").remove();const I=T(f).selectAll("line").data(b).enter().append("line").attr("class",E.link);I.append("title").text(g=>g.type),y.current=I;const C=T(f).selectAll("g.kg-node").data(m).enter().append("g").attr("class",`kg-node ${E.node}`).on("click",(g,j)=>{p.current>J||l.current(j.id)}).on("dblclick",(g,j)=>{a.current(j.id)});i.current=C,C.append("rect").attr("class",E.nodeCard).attr("width",$).attr("height",G).attr("rx",Z).attr("ry",Z).style("--node-color",g=>V(g)),C.append("rect").attr("class",E.nodeIndicator).attr("width",4).attr("height",G).attr("rx",2).attr("fill",g=>V(g)),C.append("text").attr("class",E.nodeLabel).attr("x",$/2).attr("y",G/2-4).attr("text-anchor","middle").attr("dominant-baseline","central").text(g=>g.label.length>26?g.label.substring(0,24)+"...":g.label),C.append("text").attr("class",E.nodeBadge).attr("x",$/2).attr("y",G-8).attr("text-anchor","middle").text(g=>(g.kind==="reference"?g.sourceType??"ref":g.category??"").toUpperCase());const k=Kt(m).force("link",Bt(b).id(g=>g.id).distance(140)).force("charge",Ht().strength(-400)).force("center",dt(_.width/2,_.height/2)).force("collide",Et($/2+16)).on("tick",()=>{I.attr("x1",g=>g.source.x??0).attr("y1",g=>g.source.y??0).attr("x2",g=>g.target.x??0).attr("y2",g=>g.target.y??0),C.attr("transform",g=>`translate(${(g.x??0)-$/2},${(g.y??0)-G/2})`)});c.current=k;const D=st().on("start",(g,j)=>{j.fx=j.x,j.fy=j.y,p.current=0}).on("drag",(g,j)=>{j.fx=g.x,j.fy=g.y,p.current+=Math.abs(g.dx)+Math.abs(g.dy),p.current>J&&k.alphaTarget()===0&&k.alphaTarget(.3).restart()}).on("end",(g,j)=>{g.active||k.alphaTarget(0),j.fx=void 0,j.fy=void 0});return C.call(D),k.on("end",()=>{if(s.current&&d.current&&m.length>0&&!w.current&&!v.current){w.current=!0;const g=ee(m,_);if(!g)return;const{translateX:j,translateY:z,scale:B}=g,tt=d.current,et=X.translate(j,z).scale(B);T(s.current).transition().duration(500).call(tt.transform,et)}}),()=>{k.stop()}},[t,_]),A.useEffect(()=>{if(!r.current||!i.current||!y.current)return;if(!e){i.current.classed(E.dimmed,!1).classed(E.selected,!1),y.current.classed(E.dimmedLink,!1);return}const f=new Set([e]);y.current.each(m=>{const x=m.source.id,b=m.target.id;(x===e||b===e)&&(f.add(x),f.add(b))}),i.current.classed(E.selected,m=>m.id===e).classed(E.dimmed,m=>!f.has(m.id)),y.current.classed(E.dimmedLink,m=>{const x=m.source.id,b=m.target.id;return!f.has(x)||!f.has(b)})},[e,t]);const u=A.useCallback(()=>{if(!e||!c.current||!s.current||!d.current)return;const f=c.current.nodes().find(m=>m.id===e);if(f&&Number.isFinite(f.x)&&Number.isFinite(f.y)){const m=d.current,x=X.translate(_.width/2,_.height/2).scale(1.2).translate(-(f.x??0),-(f.y??0));T(s.current).transition().duration(500).call(m.transform,x)}},[e,_]);return A.useEffect(()=>{u()},[u]),N.jsx("div",{className:E.graphContainer,"data-testid":"knowledge-graph",children:N.jsxs("svg",{ref:s,width:_.width,height:_.height,className:E.svg,children:[N.jsx("defs",{children:N.jsxs("filter",{id:"glow",children:[N.jsx("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),N.jsxs("feMerge",{children:[N.jsx("feMergeNode",{in:"coloredBlur"}),N.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),N.jsx("g",{ref:r})]})})}const re="_panel_1ml6r_1",ie="_header_1ml6r_24",se="_title_1ml6r_32",ae="_closeButton_1ml6r_42",oe="_body_1ml6r_55",ce="_badge_1ml6r_61",le="_section_1ml6r_72",ue="_sectionLabel_1ml6r_76",fe="_content_1ml6r_84",he="_tags_1ml6r_92",de="_tag_1ml6r_92",ge="_viewLink_1ml6r_107",xe="_edgeList_1ml6r_121",_e="_edgeItem_1ml6r_127",ye="_edgeType_1ml6r_136",ve="_edgeNodeLink_1ml6r_142",me="_timestamps_1ml6r_154",M={panel:re,header:ie,title:se,closeButton:ae,body:oe,badge:ce,section:le,sectionLabel:ue,content:fe,tags:he,tag:de,viewLink:ge,edgeList:xe,edgeItem:_e,edgeType:ye,edgeNodeLink:ve,timestamps:me};function pe({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 y(){if(!(r.kind!=="reference"||!r.sourceId))switch(r.sourceType){case"task":s(lt(r.sourceId));break;case"session":s(ct(r.sourceId));break;case"finding":s(ot(r.sourceId));break}}return N.jsxs("div",{className:M.panel,"data-testid":"knowledge-detail-panel",children:[N.jsxs("div",{className:M.header,children:[N.jsx("h3",{className:M.title,children:r.label}),N.jsx("button",{className:M.closeButton,onClick:n,"aria-label":"Close",children:"×"})]}),N.jsxs("div",{className:M.body,children:[N.jsx("div",{className:M.badge,children:r.kind==="reference"?`Reference (${r.sourceType})`:r.category}),r.content&&N.jsxs("div",{className:M.section,children:[N.jsx("div",{className:M.sectionLabel,children:"Content"}),N.jsx("p",{className:M.content,children:r.content})]}),r.tags&&r.tags.length>0&&N.jsxs("div",{className:M.section,children:[N.jsx("div",{className:M.sectionLabel,children:"Tags"}),N.jsx("div",{className:M.tags,children:r.tags.map(i=>N.jsx("span",{className:M.tag,children:i},i))})]}),r.kind==="reference"&&r.sourceId&&N.jsx("div",{className:M.section,children:N.jsx("button",{className:M.viewLink,onClick:y,children:"View in Grackle →"})}),c.length>0&&N.jsxs("div",{className:M.section,children:[N.jsxs("div",{className:M.sectionLabel,children:["Edges (",c.length,")"]}),N.jsx("ul",{className:M.edgeList,children:c.map(i=>{var _;const v=i.fromId===r.id?i.toId:i.fromId,w=`${i.fromId}:${i.toId}:${i.type}`;return N.jsxs("li",{className:M.edgeItem,"data-testid":"edge-item",children:[N.jsx("span",{className:M.edgeType,"data-testid":"edge-type",children:i.type}),N.jsx("button",{className:M.edgeNodeLink,"data-testid":"edge-node-link",onClick:()=>{o(v)},children:((_=d.get(v))==null?void 0:_.label)??`${v.substring(0,8)}...`})]},w)})})]}),N.jsxs("div",{className:M.timestamps,children:[r.createdAt&&N.jsxs("div",{children:["Created: ",new Date(r.createdAt).toLocaleDateString()]}),r.updatedAt&&N.jsxs("div",{children:["Updated: ",new Date(r.updatedAt).toLocaleDateString()]})]})]})]})}const we="_layout_n9vg6_1",Ne="_graphArea_n9vg6_8",be="_empty_n9vg6_15",H={layout:we,graphArea:Ne,empty:be};function Me(){const{knowledge:t}=ut();A.useEffect(()=>{t.loadRecent().catch(()=>{})},[t]);const e=A.useCallback(r=>{t.selectNode(r).catch(()=>{})},[t]),n=A.useCallback(r=>{t.expandNode(r).catch(()=>{})},[t]),o=A.useCallback(()=>{t.clearSelection()},[t]),s=[{label:"Knowledge",url:ht}];return N.jsxs("div",{className:H.layout,"data-testid":"knowledge-page",children:[N.jsx(ft,{segments:s}),N.jsxs("div",{className:H.graphArea,children:[t.graphData.nodes.length===0&&!t.loading?N.jsxs("div",{className:H.empty,children:[N.jsx("p",{children:"No knowledge nodes found."}),N.jsx("p",{children:"Create knowledge via MCP tools or let agents discover it during tasks."})]}):N.jsx(ne,{graphData:t.graphData,selectedNodeId:t.selectedId,onNodeClick:e,onNodeDoubleClick:n}),t.selectedNode&&t.selectedId&&N.jsx(pe,{detail:t.selectedNode,nodes:t.graphData.nodes,onClose:o,onSelectNode:e})]})]})}export{Me as KnowledgePage};
1
+ import{t as nt,f as rt,b as A,z as it,s as T,h as st,k as X,j as N}from"./dagview-tHPW3Rz3.js";import{u as at,f as ot,s as ct,t as lt,a as ut,B as ft,K as ht}from"./index-BPlp2Jr8.js";import"./grpc-Cjo4GFxo.js";import"./markdown-Yr3vTPLR.js";function dt(t,e){var n,o=1;t==null&&(t=0),e==null&&(e=0);function s(){var r,c=n.length,d,y=0,i=0;for(r=0;r<c;++r)d=n[r],y+=d.x,i+=d.y;for(y=(y/c-t)*o,i=(i/c-e)*o,r=0;r<c;++r)d=n[r],d.x-=y,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 gt(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,y=t._y0,i=t._x1,v=t._y1,w,_,h,p,l,a,u,f;if(!r)return t._root=c,t;for(;r.length;)if((l=e>=(w=(d+i)/2))?d=w:i=w,(a=n>=(_=(y+v)/2))?y=_:v=_,s=r,!(r=r[u=a<<1|l]))return s[u]=c,t;if(h=+t._x.call(null,r.data),p=+t._y.call(null,r.data),e===h&&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>=(w=(d+i)/2))?d=w:i=w,(a=n>=(_=(y+v)/2))?y=_:v=_;while((u=a<<1|l)===(f=(p>=_)<<1|h>=w));return s[f]=r,s[u]=c,t}function xt(t){var e,n,o=t.length,s,r,c=new Array(o),d=new Array(o),y=1/0,i=1/0,v=-1/0,w=-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<y&&(y=s),s>v&&(v=s),r<i&&(i=r),r>w&&(w=r));if(y>v||i>w)return this;for(this.cover(y,i).cover(v,w),n=0;n<o;++n)q(this,c[n],d[n],t[n]);return this}function _t(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,y,i;n>t||t>=s||o>e||e>=r;)switch(i=(e<o)<<1|t<n,y=new Array(4),y[i]=d,d=y,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 vt(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 mt(t,e,n){var o,s=this._x0,r=this._y0,c,d,y,i,v=this._x1,w=this._y1,_=[],h=this._root,p,l;for(h&&_.push(new L(h,s,r,v,w)),n==null?n=1/0:(s=t-n,r=e-n,v=t+n,w=e+n,n*=n);p=_.pop();)if(!(!(h=p.node)||(c=p.x0)>v||(d=p.y0)>w||(y=p.x1)<s||(i=p.y1)<r))if(h.length){var a=(c+y)/2,u=(d+i)/2;_.push(new L(h[3],a,u,y,i),new L(h[2],c,u,a,i),new L(h[1],a,d,y,u),new L(h[0],c,d,a,u)),(l=(e>=u)<<1|t>=a)&&(p=_[_.length-1],_[_.length-1]=_[_.length-1-l],_[_.length-1-l]=p)}else{var f=t-+this._x.call(null,h.data),m=e-+this._y.call(null,h.data),x=f*f+m*m;if(x<n){var b=Math.sqrt(n=x);s=t-b,r=e-b,v=t+b,w=e+b,o=h.data}}return o}function pt(t){if(isNaN(v=+this._x.call(null,t))||isNaN(w=+this._y.call(null,t)))return this;var e,n=this._root,o,s,r,c=this._x0,d=this._y0,y=this._x1,i=this._y1,v,w,_,h,p,l,a,u;if(!n)return this;if(n.length)for(;;){if((p=v>=(_=(c+y)/2))?c=_:y=_,(l=w>=(h=(d+i)/2))?d=h:i=h,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 wt(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function Nt(){return this._root}function bt(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function kt(t){var e=[],n,o=this._root,s,r,c,d,y;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,y=n.y1)&&o.length){var i=(r+d)/2,v=(c+y)/2;(s=o[3])&&e.push(new L(s,i,v,d,y)),(s=o[2])&&e.push(new L(s,r,v,i,y)),(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,y=o.x1,i=o.y1,v=(c+y)/2,w=(d+i)/2;(r=s[0])&&e.push(new L(r,c,d,v,w)),(r=s[1])&&e.push(new L(r,v,d,y,w)),(r=s[2])&&e.push(new L(r,c,w,v,i)),(r=s[3])&&e.push(new L(r,v,w,y,i))}n.push(o)}for(;o=n.pop();)t(o.node,o.x0,o.y0,o.x1,o.y1);return this}function At(t){return t[0]}function It(t){return arguments.length?(this._x=t,this):this._x}function Mt(t){return t[1]}function Ct(t){return arguments.length?(this._y=t,this):this._y}function U(t,e,n){var o=new P(e??At,n??Mt,NaN,NaN,NaN,NaN);return t==null?o:o.addAll(t)}function P(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=U.prototype=P.prototype;R.copy=function(){var t=new P(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=gt;R.addAll=xt;R.cover=_t;R.data=yt;R.extent=vt;R.find=mt;R.remove=pt;R.removeAll=wt;R.root=Nt;R.size=bt;R.visit=kt;R.visitAfter=jt;R.x=It;R.y=Ct;function O(t){return function(){return t}}function S(t){return(t()-.5)*1e-6}function Lt(t){return t.x+t.vx}function Rt(t){return t.y+t.vy}function Et(t){var e,n,o,s=1,r=1;typeof t!="function"&&(t=O(t==null?1:+t));function c(){for(var i,v=e.length,w,_,h,p,l,a,u=0;u<r;++u)for(w=U(e,Lt,Rt).visitAfter(d),i=0;i<v;++i)_=e[i],l=n[_.index],a=l*l,h=_.x+_.vx,p=_.y+_.vy,w.visit(f);function f(m,x,b,I,C){var k=m.data,D=m.r,g=l+D;if(k){if(k.index>_.index){var j=h-k.x-k.vx,z=p-k.y-k.vy,B=j*j+z*z;B<g*g&&(j===0&&(j=S(o),B+=j*j),z===0&&(z=S(o),B+=z*z),B=(g-(B=Math.sqrt(B)))/B*s,_.vx+=(j*=B)*(g=(D*=D)/(a+D)),_.vy+=(z*=B)*g,k.vx-=j*(g=1-g),k.vy-=z*g)}return}return x>h+g||I<h-g||b>p+g||C<p-g}}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 y(){if(e){var i,v=e.length,w;for(n=new Array(v),i=0;i<v;++i)w=e[i],n[w.index]=+t(w,i,e)}}return c.initialize=function(i,v){e=i,o=v,y()},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:O(+i),y(),c):t},c}function Dt(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=Dt,n=w,o,s=O(30),r,c,d,y,i,v=1;t==null&&(t=[]);function w(a){return 1/Math.min(d[a.source.index],d[a.target.index])}function _(a){for(var u=0,f=t.length;u<v;++u)for(var m=0,x,b,I,C,k,D,g;m<f;++m)x=t[m],b=x.source,I=x.target,C=I.x+I.vx-b.x-b.vx||S(i),k=I.y+I.vy-b.y-b.vy||S(i),D=Math.sqrt(C*C+k*k),D=(D-r[m])/D*a*o[m],C*=D,k*=D,I.vx-=C*(g=y[m]),I.vy-=k*g,b.vx+=C*(g=1-g),b.vy+=k*g}function h(){if(c){var a,u=c.length,f=t.length,m=new Map(c.map((b,I)=>[e(b,I,c),b])),x;for(a=0,d=new Array(u);a<f;++a)x=t[a],x.index=a,typeof x.source!="object"&&(x.source=W(m,x.source)),typeof x.target!="object"&&(x.target=W(m,x.target)),d[x.source.index]=(d[x.source.index]||0)+1,d[x.target.index]=(d[x.target.index]||0)+1;for(a=0,y=new Array(f);a<f;++a)x=t[a],y[a]=d[x.source.index]/(d[x.source.index]+d[x.target.index]);o=new Array(f),p(),r=new Array(f),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 _.initialize=function(a,u){c=a,i=u,h()},_.links=function(a){return arguments.length?(t=a,h(),_):t},_.id=function(a){return arguments.length?(e=a,_):e},_.iterations=function(a){return arguments.length?(v=+a,_):v},_.strength=function(a){return arguments.length?(n=typeof a=="function"?a:O(+a),p(),_):n},_.distance=function(a){return arguments.length?(s=typeof a=="function"?a:O(+a),l(),_):s},_}const zt=1664525,Tt=1013904223,Q=4294967296;function St(){let t=1;return()=>(t=(zt*t+Tt)%Q)/Q}function $t(t){return t.x}function Gt(t){return t.y}var Ot=10,Ft=Math.PI*(3-Math.sqrt(5));function Kt(t){var e,n=1,o=.001,s=1-Math.pow(o,1/300),r=0,c=.6,d=new Map,y=nt(w),i=rt("tick","end"),v=St();t==null&&(t=[]);function w(){_(),i.call("tick",e),n<o&&(y.stop(),i.call("end",e))}function _(l){var a,u=t.length,f;l===void 0&&(l=1);for(var m=0;m<l;++m)for(n+=(r-n)*s,d.forEach(function(x){x(n)}),a=0;a<u;++a)f=t[a],f.fx==null?f.x+=f.vx*=c:(f.x=f.fx,f.vx=0),f.fy==null?f.y+=f.vy*=c:(f.y=f.fy,f.vy=0);return e}function h(){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 f=Ot*Math.sqrt(.5+l),m=l*Ft;u.x=f*Math.cos(m),u.y=f*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 h(),e={tick:_,restart:function(){return y.restart(w),e},stop:function(){return y.stop(),e},nodes:function(l){return arguments.length?(t=l,h(),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 f=0,m=t.length,x,b,I,C,k;for(u==null?u=1/0:u*=u,f=0;f<m;++f)C=t[f],x=l-C.x,b=a-C.y,I=x*x+b*b,I<u&&(k=C,u=I);return k},on:function(l,a){return arguments.length>1?(i.on(l,a),e):i.on(l)}}}function Ht(){var t,e,n,o,s=O(-30),r,c=1,d=1/0,y=.81;function i(h){var p,l=t.length,a=U(t,$t,Gt).visitAfter(w);for(o=h,p=0;p<l;++p)e=t[p],a.visit(_)}function v(){if(t){var h,p=t.length,l;for(r=new Array(p),h=0;h<p;++h)l=t[h],r[l.index]=+s(l,h,t)}}function w(h){var p=0,l,a,u=0,f,m,x;if(h.length){for(f=m=x=0;x<4;++x)(l=h[x])&&(a=Math.abs(l.value))&&(p+=l.value,u+=a,f+=a*l.x,m+=a*l.y);h.x=f/u,h.y=m/u}else{l=h,l.x=l.data.x,l.y=l.data.y;do p+=r[l.data.index];while(l=l.next)}h.value=p}function _(h,p,l,a){if(!h.value)return!0;var u=h.x-e.x,f=h.y-e.y,m=a-p,x=u*u+f*f;if(m*m/y<x)return x<d&&(u===0&&(u=S(n),x+=u*u),f===0&&(f=S(n),x+=f*f),x<c&&(x=Math.sqrt(c*x)),e.vx+=u*h.value*o/x,e.vy+=f*h.value*o/x),!0;if(h.length||x>=d)return;(h.data!==e||h.next)&&(u===0&&(u=S(n),x+=u*u),f===0&&(f=S(n),x+=f*f),x<c&&(x=Math.sqrt(c*x)));do h.data!==e&&(m=r[h.data.index]*o/x,e.vx+=u*m,e.vy+=f*m);while(h=h.next)}return i.initialize=function(h,p){t=h,n=p,v()},i.strength=function(h){return arguments.length?(s=typeof h=="function"?h:O(+h),v(),i):s},i.distanceMin=function(h){return arguments.length?(c=h*h,i):Math.sqrt(c)},i.distanceMax=function(h){return arguments.length?(d=h*h,i):Math.sqrt(d)},i.theta=function(h){return arguments.length?(y=h*h,i):Math.sqrt(y)},i}const Ut="_graphContainer_13vy2_1",Pt="_svg_13vy2_10",Xt="_link_13vy2_18",Yt="_node_13vy2_30",Wt="_nodeCard_13vy2_37",Qt="_nodeLabel_13vy2_43",Vt="_selected_13vy2_47",Zt="_dimmed_13vy2_54",Jt="_dimmedLink_13vy2_59",qt="_nodeIndicator_13vy2_71",te="_nodeBadge_13vy2_85",E={graphContainer:Ut,svg:Pt,link:Xt,node:Yt,nodeCard:Wt,nodeLabel:Qt,selected:Vt,dimmed:Zt,dimmedLink:Jt,nodeIndicator:qt,nodeBadge:te},K={reference:"#4A9EFF",decision:"#22C55E",insight:"#EAB308",concept:"#A855F7",snippet:"#6B7280"};function V(t){return t.kind==="reference"?K.reference:K[t.category??"insight"]??K.insight}const $=200,G=52,Z=12,F=40,J=3;function ee(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-$/2-F,d=o+$/2+F,y=s-G/2-F,i=r+G/2+F,v=d-c,w=i-y,_=Math.min(e.width/v,e.height/w,1),h=(c+d)/2,p=(y+i)/2;return{translateX:e.width/2-h*_,translateY:e.height/2-p*_,scale:_}}function ne({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),y=A.useRef(void 0),i=A.useRef(void 0),v=A.useRef(e);v.current=e;const w=A.useRef(!1),[_,h]=A.useState({width:800,height:600}),p=A.useRef(0);A.useEffect(()=>{var x;const f=((x=s.current)==null?void 0:x.parentElement)??null;if(!f)return;const m=new ResizeObserver(b=>{for(const I of b)h({width:I.contentRect.width,height:I.contentRect.height})});return m.observe(f),h({width:f.clientWidth,height:f.clientHeight}),()=>{m.disconnect()}},[]),A.useEffect(()=>{if(!s.current||!r.current)return;const f=s.current,m=r.current,x=it().scaleExtent([.1,4]).filter(b=>b.type!=="dblclick").on("zoom",b=>{T(m).attr("transform",String(b.transform))});return T(f).call(x),d.current=x,()=>{T(f).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 f=r.current;if(c.current&&(c.current.stop(),c.current=void 0),w.current=!1,t.nodes.length===0){T(f).selectAll("*").remove();return}const m=t.nodes.map(g=>({...g})),x=new Map(m.map(g=>[g.id,g])),b=t.links.filter(g=>x.has(g.source)&&x.has(g.target)).map(g=>({source:g.source,target:g.target,type:g.type}));T(f).selectAll("*").remove();const I=T(f).selectAll("line").data(b).enter().append("line").attr("class",E.link);I.append("title").text(g=>g.type),y.current=I;const C=T(f).selectAll("g.kg-node").data(m).enter().append("g").attr("class",`kg-node ${E.node}`).on("click",(g,j)=>{p.current>J||l.current(j.id)}).on("dblclick",(g,j)=>{a.current(j.id)});i.current=C,C.append("rect").attr("class",E.nodeCard).attr("width",$).attr("height",G).attr("rx",Z).attr("ry",Z).style("--node-color",g=>V(g)),C.append("rect").attr("class",E.nodeIndicator).attr("width",4).attr("height",G).attr("rx",2).attr("fill",g=>V(g)),C.append("text").attr("class",E.nodeLabel).attr("x",$/2).attr("y",G/2-4).attr("text-anchor","middle").attr("dominant-baseline","central").text(g=>g.label.length>26?g.label.substring(0,24)+"...":g.label),C.append("text").attr("class",E.nodeBadge).attr("x",$/2).attr("y",G-8).attr("text-anchor","middle").text(g=>(g.kind==="reference"?g.sourceType??"ref":g.category??"").toUpperCase());const k=Kt(m).force("link",Bt(b).id(g=>g.id).distance(140)).force("charge",Ht().strength(-400)).force("center",dt(_.width/2,_.height/2)).force("collide",Et($/2+16)).on("tick",()=>{I.attr("x1",g=>g.source.x??0).attr("y1",g=>g.source.y??0).attr("x2",g=>g.target.x??0).attr("y2",g=>g.target.y??0),C.attr("transform",g=>`translate(${(g.x??0)-$/2},${(g.y??0)-G/2})`)});c.current=k;const D=st().on("start",(g,j)=>{j.fx=j.x,j.fy=j.y,p.current=0}).on("drag",(g,j)=>{j.fx=g.x,j.fy=g.y,p.current+=Math.abs(g.dx)+Math.abs(g.dy),p.current>J&&k.alphaTarget()===0&&k.alphaTarget(.3).restart()}).on("end",(g,j)=>{g.active||k.alphaTarget(0),j.fx=void 0,j.fy=void 0});return C.call(D),k.on("end",()=>{if(s.current&&d.current&&m.length>0&&!w.current&&!v.current){w.current=!0;const g=ee(m,_);if(!g)return;const{translateX:j,translateY:z,scale:B}=g,tt=d.current,et=X.translate(j,z).scale(B);T(s.current).transition().duration(500).call(tt.transform,et)}}),()=>{k.stop()}},[t,_]),A.useEffect(()=>{if(!r.current||!i.current||!y.current)return;if(!e){i.current.classed(E.dimmed,!1).classed(E.selected,!1),y.current.classed(E.dimmedLink,!1);return}const f=new Set([e]);y.current.each(m=>{const x=m.source.id,b=m.target.id;(x===e||b===e)&&(f.add(x),f.add(b))}),i.current.classed(E.selected,m=>m.id===e).classed(E.dimmed,m=>!f.has(m.id)),y.current.classed(E.dimmedLink,m=>{const x=m.source.id,b=m.target.id;return!f.has(x)||!f.has(b)})},[e,t]);const u=A.useCallback(()=>{if(!e||!c.current||!s.current||!d.current)return;const f=c.current.nodes().find(m=>m.id===e);if(f&&Number.isFinite(f.x)&&Number.isFinite(f.y)){const m=d.current,x=X.translate(_.width/2,_.height/2).scale(1.2).translate(-(f.x??0),-(f.y??0));T(s.current).transition().duration(500).call(m.transform,x)}},[e,_]);return A.useEffect(()=>{u()},[u]),N.jsx("div",{className:E.graphContainer,"data-testid":"knowledge-graph",children:N.jsxs("svg",{ref:s,width:_.width,height:_.height,className:E.svg,children:[N.jsx("defs",{children:N.jsxs("filter",{id:"glow",children:[N.jsx("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),N.jsxs("feMerge",{children:[N.jsx("feMergeNode",{in:"coloredBlur"}),N.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),N.jsx("g",{ref:r})]})})}const re="_panel_1ml6r_1",ie="_header_1ml6r_24",se="_title_1ml6r_32",ae="_closeButton_1ml6r_42",oe="_body_1ml6r_55",ce="_badge_1ml6r_61",le="_section_1ml6r_72",ue="_sectionLabel_1ml6r_76",fe="_content_1ml6r_84",he="_tags_1ml6r_92",de="_tag_1ml6r_92",ge="_viewLink_1ml6r_107",xe="_edgeList_1ml6r_121",_e="_edgeItem_1ml6r_127",ye="_edgeType_1ml6r_136",ve="_edgeNodeLink_1ml6r_142",me="_timestamps_1ml6r_154",M={panel:re,header:ie,title:se,closeButton:ae,body:oe,badge:ce,section:le,sectionLabel:ue,content:fe,tags:he,tag:de,viewLink:ge,edgeList:xe,edgeItem:_e,edgeType:ye,edgeNodeLink:ve,timestamps:me};function pe({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 y(){if(!(r.kind!=="reference"||!r.sourceId))switch(r.sourceType){case"task":s(lt(r.sourceId));break;case"session":s(ct(r.sourceId));break;case"finding":s(ot(r.sourceId));break}}return N.jsxs("div",{className:M.panel,"data-testid":"knowledge-detail-panel",children:[N.jsxs("div",{className:M.header,children:[N.jsx("h3",{className:M.title,children:r.label}),N.jsx("button",{className:M.closeButton,onClick:n,"aria-label":"Close",children:"×"})]}),N.jsxs("div",{className:M.body,children:[N.jsx("div",{className:M.badge,children:r.kind==="reference"?`Reference (${r.sourceType})`:r.category}),r.content&&N.jsxs("div",{className:M.section,children:[N.jsx("div",{className:M.sectionLabel,children:"Content"}),N.jsx("p",{className:M.content,children:r.content})]}),r.tags&&r.tags.length>0&&N.jsxs("div",{className:M.section,children:[N.jsx("div",{className:M.sectionLabel,children:"Tags"}),N.jsx("div",{className:M.tags,children:r.tags.map(i=>N.jsx("span",{className:M.tag,children:i},i))})]}),r.kind==="reference"&&r.sourceId&&N.jsx("div",{className:M.section,children:N.jsx("button",{className:M.viewLink,onClick:y,children:"View in Grackle →"})}),c.length>0&&N.jsxs("div",{className:M.section,children:[N.jsxs("div",{className:M.sectionLabel,children:["Edges (",c.length,")"]}),N.jsx("ul",{className:M.edgeList,children:c.map(i=>{var _;const v=i.fromId===r.id?i.toId:i.fromId,w=`${i.fromId}:${i.toId}:${i.type}`;return N.jsxs("li",{className:M.edgeItem,"data-testid":"edge-item",children:[N.jsx("span",{className:M.edgeType,"data-testid":"edge-type",children:i.type}),N.jsx("button",{className:M.edgeNodeLink,"data-testid":"edge-node-link",onClick:()=>{o(v)},children:((_=d.get(v))==null?void 0:_.label)??`${v.substring(0,8)}...`})]},w)})})]}),N.jsxs("div",{className:M.timestamps,children:[r.createdAt&&N.jsxs("div",{children:["Created: ",new Date(r.createdAt).toLocaleDateString()]}),r.updatedAt&&N.jsxs("div",{children:["Updated: ",new Date(r.updatedAt).toLocaleDateString()]})]})]})]})}const we="_layout_n9vg6_1",Ne="_graphArea_n9vg6_8",be="_empty_n9vg6_15",H={layout:we,graphArea:Ne,empty:be};function Me(){const{knowledge:t}=ut();A.useEffect(()=>{t.loadRecent().catch(()=>{})},[t]);const e=A.useCallback(r=>{t.selectNode(r).catch(()=>{})},[t]),n=A.useCallback(r=>{t.expandNode(r).catch(()=>{})},[t]),o=A.useCallback(()=>{t.clearSelection()},[t]),s=[{label:"Knowledge",url:ht}];return N.jsxs("div",{className:H.layout,"data-testid":"knowledge-page",children:[N.jsx(ft,{segments:s}),N.jsxs("div",{className:H.graphArea,children:[t.graphData.nodes.length===0&&!t.loading?N.jsxs("div",{className:H.empty,children:[N.jsx("p",{children:"No knowledge nodes found."}),N.jsx("p",{children:"Create knowledge via MCP tools or let agents discover it during tasks."})]}):N.jsx(ne,{graphData:t.graphData,selectedNodeId:t.selectedId,onNodeClick:e,onNodeDoubleClick:n}),t.selectedNode&&t.selectedId&&N.jsx(pe,{detail:t.selectedNode,nodes:t.graphData.nodes,onClose:o,onSelectNode:e})]})]})}export{Me as KnowledgePage};
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-CezpSlWG.js","assets/dagview-tHPW3Rz3.js","assets/grpc-Cjo4GFxo.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-DNSe88De.js","assets/dagview-tHPW3Rz3.js","assets/grpc-Cjo4GFxo.js","assets/markdown-Yr3vTPLR.js","assets/KnowledgePage-BmY14aDt.css"])))=>i.map(i=>d[i]);
2
2
  import{r as eT,a as tT,b as y,j as o,d as Z0,H as K0,P as Y0,i as nT,B as sT,c as aT,C as iT,M as oT,e as rT}from"./dagview-tHPW3Rz3.js";import{c as lT,a as cT,G as dT,f as uT,M as fT,A as ox,D as rx,W as pT,O as mT,b as hT,C as Ao,d as lx,e as cx,w as gT,t as vT,p as Nc,g as yT,R as Dr,S as J0}from"./grpc-Cjo4GFxo.js";import{v as bT,r as xT,t as Cc,i as _T,f as kT,M as pd,a as md}from"./markdown-Yr3vTPLR.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const u of d.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function i(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function r(c){if(c.ep)return;c.ep=!0;const d=i(c);fetch(c.href,d)}})();var Bf={exports:{}},Rr={},zf={exports:{}},Uf={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
@@ -271,7 +271,7 @@ ${JSON.stringify(u,void 0,2)}
271
271
  \`\`\``):s.push(`${m} (${c}):`);break}case"error":{s.push(`**Error** (${c}):
272
272
  ${r.content}`);break}}}return s.join(`
273
273
 
274
- `)}function X6({events:t,formatForClipboard:s}){const[i,r]=y.useState(!1),[c,d]=y.useState(new Set),u=y.useRef(void 0),p=y.useMemo(()=>c.size,[c]),m=y.useCallback(k=>{r(!0),k!==void 0?(d(new Set([k])),u.current=k):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((k,w)=>{if(w&&u.current!==void 0){const N=Math.min(u.current,k),T=Math.max(u.current,k);d(C=>{const D=new Set(C);for(let L=N;L<=T;L++)L<t.length&&ol(t[L])&&D.add(L);return D})}else d(N=>{const T=new Set(N);return T.has(k)?T.delete(k):T.add(k),T.size===0?(r(!1),u.current=void 0):u.current=k,T})},[t]),b=y.useCallback(()=>{const k=new Set;for(let w=0;w<t.length;w++)ol(t[w])&&k.add(w);d(k)},[t]),x=y.useCallback(()=>{d(new Set)},[]),S=y.useCallback(async()=>{const w=[...c].sort((T,C)=>T-C).filter(T=>T<t.length).map(T=>t[T]);if(w.length===0)return!1;const N=s(w);try{return await navigator.clipboard.writeText(N),!0}catch{return!1}},[c,t,s]);return{isSelecting:i,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:x,copySelected:S}}const Q6="_wrapper_1cdza_1",e4="_scrollContainer_1cdza_9",t4="_selectingPadding_1cdza_16",n4="_toolbar_1cdza_20",s4="_directionToggle_1cdza_27",a4="_scrollToAnchor_1cdza_65",i4="_scrollToAnchorBottom_1cdza_89",o4="_scrollToAnchorTop_1cdza_93",r4="_eventOverflowWarning_1cdza_97",Ys={wrapper:Q6,scrollContainer:e4,selectingPadding:t4,toolbar:n4,directionToggle:s4,scrollToAnchor:a4,scrollToAnchorBottom:i4,scrollToAnchorTop:o4,eventOverflowWarning:r4};function l4(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 g1="grackle-stream-direction";function c4(){try{return localStorage.getItem(g1)==="reversed"}catch{return!1}}function d4({eventsDropped:t}){return t<=0?o.jsx(o.Fragment,{}):o.jsxs("div",{className:Ys.eventOverflowWarning,role:"alert",children:[o.jsx(am,{size:en,"aria-hidden":"true"})," ",t.toLocaleString()," older event",t===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function Jm({events:t,eventsDropped:s,emptyState:i,onShowToast:r}){const c=y.useRef(null),[d,u]=y.useState(c4),p=KM(),m=X6({events:t,formatForClipboard:W6}),g=y.useMemo(()=>t.filter(ol).length,[t]),v=y.useMemo(()=>d?[...t].reverse():t,[t,d]),{isAtAnchor:b,scrollToAnchor:x}=K6({scrollRef:c,contentLength:t.length,isReversed:d,paused:m.isSelecting}),S=()=>{const T=!d;u(T);try{localStorage.setItem(g1,T?"reversed":"default")}catch{}};y.useEffect(()=>{if(!m.isSelecting)return;const T=C=>{C.key==="Escape"&&m.cancelSelection()};return window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T)}},[m.isSelecting,m.cancelSelection]);const k=y.useCallback(async()=>{await m.copySelected()&&(r==null||r(`Copied ${m.selectedCount} message${m.selectedCount===1?"":"s"} to clipboard`,"success"))},[m,r]),w=p?0:.2,N=d?-8:8;return o.jsxs("div",{className:Ys.wrapper,children:[o.jsx("div",{className:Ys.toolbar,children:o.jsx(Lo,{text:d?"Showing newest first":"Showing oldest first",children:o.jsx("button",{className:Ys.directionToggle,onClick:S,"aria-label":d?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:d?o.jsx(ay,{size:en,"aria-hidden":"true"}):o.jsx(iy,{size:en,"aria-hidden":"true"})})})}),o.jsxs("div",{ref:c,className:`${Ys.scrollContainer} ${m.isSelecting?Ys.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&i,o.jsx(d4,{eventsDropped:s}),o.jsx(ps,{initial:!1,children:v.map((T,C)=>{const D=d?t.length-1-C:C;return o.jsx(Rt.div,{initial:{opacity:0,y:N},animate:{opacity:1,y:0},transition:{duration:w,ease:"easeOut"},children:o.jsx(B6,{copyText:J6(T),isContentBearing:ol(T),isSelecting:m.isSelecting,isSelected:m.selectedIndices.has(D),checkboxLabel:l4(T),onSelect:()=>{m.enterSelectionMode(D)},onToggle:L=>{m.toggleEvent(D,L)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:o.jsx(kA,{event:T,toolUseCtx:T.toolUseCtx,settled:T.settled})})},`${T.sessionId}-${T.timestamp}-${D}`)})})]}),o.jsx(ps,{children:m.isSelecting&&o.jsx(G6,{selectedCount:m.selectedCount,totalSelectable:g,onSelectAll:m.selectAll,onDeselectAll:m.deselectAll,onCopy:()=>{k().catch(()=>{})},onCancel:m.cancelSelection})}),o.jsx(ps,{children:!b&&o.jsxs(Rt.button,{className:`${Ys.scrollToAnchor} ${d?Ys.scrollToAnchorTop:Ys.scrollToAnchorBottom}`,onClick:x,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[d?o.jsx(iy,{size:en,"aria-hidden":"true"}):o.jsx(ay,{size:en,"aria-hidden":"true"})," New events"]})})]})}function Wm(t){const{value:s,onSave:i,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[b,x]=y.useState(""),S=y.useRef(!1),k=d===c,w=y.useCallback(O=>{v(O),x("")},[]),N=y.useCallback(()=>{x("")},[]),T=y.useCallback(()=>{S.current=!1,u==null||u(null),v(""),x("")},[u]),C=y.useCallback(()=>{const O=m?g.trim():g;if(r){const $=r(g);if($){x($);return}}const z=m?s.trim():s;if(O===z){T();return}i(O),T()},[g,s,m,r,i,T]),D=y.useCallback(()=>{S.current=!0,u==null||u(c),v(s),x("")},[c,s,u]),L=y.useCallback(O=>{if(S.current){S.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===c||C()},[c,C]),A=y.useCallback(O=>{O.key==="Escape"?T():O.key==="Enter"&&p&&C()},[T,p,C]),R=(()=>{if(!k)return!1;const O=m?s.trim():s;return(m?g.trim():g)!==O})();return y.useEffect(()=>{!k&&(g!==""||b!=="")&&(v(""),x(""))},[k,g,b]),{isEditing:k,draft:g,error:b,isDirty:R,startEdit:D,cancelEdit:T,save:C,setDraft:w,clearError:N,handleBlur:L,handleKeyDown:A,ignoreInitialBlurRef:S}}const u4="_editFieldWrapper_yuzty_1",f4="_editInput_yuzty_10",p4="_editTextarea_yuzty_42",m4="_editSelect_yuzty_78",h4="_editError_yuzty_111",g4="_editInputInvalid_yuzty_118",v4="_editHint_yuzty_123",y4="_unsavedDot_yuzty_132",b4="_metaValueClickable_yuzty_140",x4="_editButton_yuzty_159",_4="_metaPlaceholder_yuzty_175",k4="_worktreeToggle_yuzty_180",tt={editFieldWrapper:u4,editInput:f4,editTextarea:p4,editSelect:m4,editError:h4,editInputInvalid:g4,editHint:v4,unsavedDot:y4,metaValueClickable:b4,editButton:x4,metaPlaceholder:_4,worktreeToggle:k4};function ln(t){const{value:s,onSave:i,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:b,ariaLabel:x,"data-testid":S}=t,k=y.useRef(null),w=Wm({value:s,onSave:i,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(w.isEditing){const T=window.setTimeout(()=>{var C;(C=k.current)==null||C.focus()},0);return()=>window.clearTimeout(T)}},[w.isEditing]),c==="create"){const T=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return o.jsxs("div",{className:tt.editFieldWrapper,children:[o.jsx("input",{className:`${tt.editInput} ${C?tt.editInputInvalid:""}`,value:s,onChange:T,maxLength:b,placeholder:v,"aria-label":x,"data-testid":S?`${S}-input`:void 0}),C&&o.jsx("span",{className:tt.editError,"data-testid":"edit-error",children:C})]})}if(w.isEditing)return o.jsxs("div",{className:tt.editFieldWrapper,children:[o.jsx("input",{ref:k,className:`${tt.editInput} ${w.error?tt.editInputInvalid:""}`,value:w.draft,onChange:T=>w.setDraft(T.target.value),onBlur:w.handleBlur,onKeyDown:w.handleKeyDown,maxLength:b,placeholder:v,"aria-label":x,"data-testid":S?`${S}-input`:void 0}),w.isDirty&&o.jsx("span",{className:tt.unsavedDot,title:"Unsaved changes"}),w.error&&o.jsx("span",{className:tt.editError,"data-testid":"edit-error",children:w.error}),o.jsx("span",{className:tt.editHint,children:"Enter to save · Esc to cancel"})]});const N=g==null?void 0:g(s);return o.jsxs("span",{role:"button",tabIndex:0,className:tt.metaValueClickable,onClick:()=>w.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),w.startEdit())},title:"Click to edit","aria-label":x,"data-testid":S?`${S}-button`:void 0,children:[N!==void 0?N:s?o.jsx("span",{children:s}):o.jsx("span",{className:tt.metaPlaceholder,children:v||"None"}),o.jsx("span",{className:tt.editButton,"aria-hidden":"true",children:"✏️"})]})}function Wp(t){const{value:s,onSave:i,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":x}=t,S=y.useRef(null),k=Wm({value:s,onSave:i,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(k.isEditing){const N=window.setTimeout(()=>{var T;(T=S.current)==null||T.focus()},0);return()=>window.clearTimeout(N)}},[k.isEditing]),c==="create"){const N=C=>{m==null||m(C.target.value)},T=r==null?void 0:r(s);return o.jsxs("div",{className:tt.editFieldWrapper,children:[o.jsx("textarea",{className:`${tt.editTextarea} ${T?tt.editInputInvalid:""}`,value:s,onChange:N,placeholder:v,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),T&&o.jsx("span",{className:tt.editError,"data-testid":"edit-error",children:T})]})}if(k.isEditing)return o.jsxs("div",{className:tt.editFieldWrapper,children:[o.jsx("textarea",{ref:S,className:`${tt.editTextarea} ${k.error?tt.editInputInvalid:""}`,value:k.draft,onChange:N=>k.setDraft(N.target.value),onBlur:k.handleBlur,onKeyDown:k.handleKeyDown,title:b,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),k.isDirty&&o.jsx("span",{className:tt.unsavedDot,title:"Unsaved changes"}),k.error&&o.jsx("span",{className:tt.editError,"data-testid":"edit-error",children:k.error}),o.jsx("span",{className:tt.editHint,children:"Tab to save · Esc to cancel"})]});const w=g==null?void 0:g(s);return o.jsxs("span",{role:"button",tabIndex:0,className:tt.metaValueClickable,onClick:()=>k.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),k.startEdit())},title:"Click to edit","aria-label":b,"data-testid":x?`${x}-button`:void 0,children:[w!==void 0?w:s?o.jsx("span",{children:s}):o.jsx("span",{className:tt.metaPlaceholder,children:v||"None"}),o.jsx("span",{className:tt.editButton,"aria-hidden":"true",children:"✏️"})]})}function cd(t){var D;const{value:s,onSave:i,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":x}=t,S=y.useRef(null),k=Wm({value:s,onSave:i,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(k.isEditing){const L=window.setTimeout(()=>{var A;(A=S.current)==null||A.focus()},0);return()=>window.clearTimeout(L)}},[k.isEditing]);const w=y.useCallback(L=>{const A=L.target.value;k.ignoreInitialBlurRef.current=!1,A!==s&&i(A),k.cancelEdit()},[s,i,k]),N=y.useCallback(L=>{if(k.ignoreInitialBlurRef.current){k.ignoreInitialBlurRef.current=!1;return}L.relatedTarget instanceof HTMLElement&&L.relatedTarget.dataset.editAction===d||k.cancelEdit()},[d,k]);if(r==="create")return o.jsx("select",{className:tt.editSelect,value:s,onChange:L=>m==null?void 0:m(L.target.value),"aria-label":b,"data-testid":x?`${x}-select`:void 0,children:c.map(L=>o.jsx("option",{value:L.value,children:L.label},L.value))});if(k.isEditing)return o.jsx("select",{ref:S,className:tt.editSelect,value:k.draft,onChange:w,onBlur:N,title:b,"aria-label":b,"data-testid":x?`${x}-select`:void 0,children:c.map(L=>o.jsx("option",{value:L.value,children:L.label},L.value))});const T=g==null?void 0:g(s),C=(D=c.find(L=>L.value===s))==null?void 0:D.label;return o.jsxs("button",{type:"button",className:tt.metaValueClickable,onClick:()=>k.startEdit(),title:"Click to change","aria-label":b,"data-testid":x?`${x}-button`:void 0,children:[T!==void 0?T:C?o.jsx("span",{children:C}):o.jsx("span",{className:tt.metaPlaceholder,children:v||"None"}),o.jsx("span",{className:tt.editButton,"aria-hidden":"true",children:"✏️"})]})}function S4(t){const{checked:s,onChange:i,label:r,ariaLabel:c,"data-testid":d}=t;return o.jsxs("label",{className:tt.worktreeToggle,"data-testid":d,children:[o.jsx("input",{type:"checkbox",checked:s,onChange:u=>i(u.target.checked),"aria-label":c}),o.jsx("span",{children:r})]})}const T4="_envRow_1e1r5_1",w4="_envDot_1e1r5_7",j4="_envDotGreen_1e1r5_14",N4="_envDotYellow_1e1r5_18",C4="_envDotRed_1e1r5_22",E4="_envDotGray_1e1r5_26",Co={envRow:T4,envDot:w4,envDotGreen:j4,envDotYellow:N4,envDotRed:C4,envDotGray:E4};function A4(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?Co.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?Co.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?Co.envDotRed:Co.envDotGray}function D4(t){const{value:s,onSave:i,environments:r,allowNone:c=!1,fieldId:d="environment",activeFieldId:u,onActivate:p,placeholder:m="No environment",ariaLabel:g="Environment","data-testid":v}=t,b=r.find(k=>k.id===s),x=[...c?[{value:"",label:"None"}]:[],...r.map(k=>({value:k.id,label:k.displayName}))],S=()=>{if(b)return o.jsxs("span",{className:Co.envRow,children:[o.jsx("span",{className:`${Co.envDot} ${A4(b.status)}`}),b.displayName]})};return o.jsx(cd,{value:s,onSave:i,options:x,fieldId:d,activeFieldId:u,onActivate:p,renderDisplay:S,placeholder:m,ariaLabel:g,"data-testid":v})}const R4="_nav_1snmp_1",M4="_searchForm_1snmp_8",I4="_searchInput_1snmp_15",O4="_searchButton_1snmp_33",L4="_clearButton_1snmp_68",B4="_workspaceSelect_1snmp_85",z4="_listHeader_1snmp_99",U4="_nodeList_1snmp_108",$4="_nodeItem_1snmp_116",P4="_indicator_1snmp_129",H4="_label_1snmp_136",V4="_badge_1snmp_145",Yn={nav:R4,searchForm:M4,searchInput:I4,searchButton:O4,clearButton:L4,workspaceSelect:B4,listHeader:z4,nodeList:U4,nodeItem:$4,indicator:P4,label:H4,badge:V4};function q4({nodes:t,workspaces:s,loading:i,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(k=>{k.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=y.useCallback(()=>{g(""),d()},[d]),x=y.useCallback(k=>{u(k)},[u]),S=y.useCallback(k=>{g(""),p(k)},[p]);return o.jsxs("div",{className:Yn.nav,"data-testid":"knowledge-nav",children:[o.jsxs("form",{className:Yn.searchForm,onSubmit:v,children:[o.jsx("input",{className:Yn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:k=>{g(k.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),o.jsx("button",{type:"submit",className:Yn.searchButton,disabled:i,children:"Go"})]}),r&&o.jsx("button",{type:"button",className:Yn.clearButton,onClick:b,children:"Clear search"}),o.jsxs("select",{className:Yn.workspaceSelect,onChange:k=>{S(k.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[o.jsx("option",{value:"",children:"All workspaces"}),s.map(k=>o.jsx("option",{value:k.id,children:k.name},k.id))]}),o.jsxs("div",{className:Yn.listHeader,children:["Nodes (",t.length,")"]}),o.jsx("ul",{className:Yn.nodeList,children:t.map(k=>o.jsxs("li",{className:Yn.nodeItem,onClick:()=>{x(k.id)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),x(k.id))},role:"button",tabIndex:0,children:[o.jsx("span",{className:Yn.indicator,style:{backgroundColor:k.kind==="reference"?"#4A9EFF":k.category==="decision"?"#22C55E":k.category==="concept"?"#A855F7":k.category==="snippet"?"#6B7280":"#EAB308"}}),o.jsx("span",{className:Yn.label,children:k.label}),o.jsx("span",{className:Yn.badge,children:k.kind==="reference"?k.sourceType:k.category})]},k.id))})]})}const G4="_container_1mq5u_1",F4="_hamburger_1mq5u_33",Z4="_brand_1mq5u_49",K4="_brandLogo_1mq5u_68",Y4="_info_1mq5u_75",J4="_connectionLabel_1mq5u_90",W4="_connectionDot_1mq5u_103",X4="_connected_1mq5u_106",Q4="_disconnected_1mq5u_110",Zs={container:G4,hamburger:F4,brand:Z4,brandLogo:K4,info:Y4,connectionLabel:J4,connectionDot:W4,connected:X4,disconnected:Q4};function e5({connected:t,environments:s,sessions:i,onToggleSidebar:r,sidebarOpen:c}){const d=_t(),u=s.length,p=s.filter(g=>g.status==="connected").length,m=i.filter(g=>["running","idle"].includes(g.status)).length;return o.jsxs("div",{className:Zs.container,children:[r&&o.jsx("button",{type:"button",className:Zs.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:o.jsx(M2,{size:Bt,"aria-hidden":"true"})}),o.jsx(Lo,{text:"Home",placement:"bottom",children:o.jsxs("button",{type:"button",className:Zs.brand,onClick:()=>d(Ti),"data-testid":"statusbar-brand",children:[o.jsx("img",{src:"/icon-192x192.png",alt:"",className:Zs.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),o.jsxs("div",{className:Zs.info,children:[o.jsxs("span",{"aria-label":t?"Connected":"Disconnected",children:[o.jsx("span",{className:`${Zs.connectionDot} ${t?Zs.connected:Zs.disconnected}`,"aria-hidden":"true",children:o.jsx(Ba,{size:im,fill:"currentColor"})})," ",o.jsx("span",{className:Zs.connectionLabel,"aria-hidden":"true",children:t?"Connected":"Disconnected"})]}),o.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),o.jsxs("span",{children:[m," active"]})]})]})}const t5="_nav_13gkc_1",n5="_tab_13gkc_35",s5="_tabIcon_13gkc_68",a5="_tabLabel_13gkc_79",i5="_tabActive_13gkc_84",Br={nav:t5,tab:n5,tabIcon:s5,tabLabel:a5,tabActive:i5},vi=[{view:"dashboard",label:"Dashboard",icon:o.jsx(x2,{size:Bt}),route:Ti,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:o.jsx(O2,{size:Bt}),route:sN,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:o.jsx(r2,{size:Bt}),route:aN,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:o.jsx(B2,{size:Bt}),route:Do,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:o.jsx(t2,{size:Bt}),route:Ox,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:o.jsx(px,{size:Bt}),route:bd,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:o.jsx(F2,{size:Bt}),route:Qj,testId:"sidebar-tab-settings"}];function o5(t){return t===Ti||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(Ox)?"knowledge":t.startsWith(bd)?"findings":t.startsWith(Eo)?"settings":"tasks"}function r5(){const t=Zt(),s=_t(),i=y.useRef(null),r=o5(t.pathname),c=y.useCallback(u=>{s(u.route)},[s]),d=y.useCallback(u=>{var b,x;const p=(b=i.current)==null?void 0:b.querySelectorAll('[role="tab"]');if(!p)return;const m=Array.from(p).findIndex(S=>S===document.activeElement),g=m>=0?m:vi.findIndex(S=>S.view===r);let v=g;if(u.key==="ArrowRight"||u.key==="j"||u.key==="J")u.preventDefault(),v=(g+1)%vi.length;else if(u.key==="ArrowLeft"||u.key==="k"||u.key==="K")u.preventDefault(),v=(g-1+vi.length)%vi.length;else if(u.key==="Home")u.preventDefault(),v=0;else if(u.key==="End")u.preventDefault(),v=vi.length-1;else return;s(vi[v].route),(x=p[v])==null||x.focus()},[r,s]);return o.jsx("nav",{className:Br.nav,ref:i,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:d,"data-testid":"sidebar-nav",children:vi.map(u=>{const p=u.view===r;return o.jsx(Lo,{text:u.label,placement:"bottom",children:o.jsxs("button",{role:"tab",type:"button","aria-selected":p,tabIndex:p?0:-1,className:`${Br.tab} ${p?Br.tabActive:""}`,onClick:()=>c(u),"data-testid":u.testId,"aria-label":u.label,children:[o.jsx("span",{className:Br.tabIcon,"aria-hidden":"true",children:u.icon}),o.jsx("span",{className:Br.tabLabel,children:u.label})]})},u.view)})})}const l5="_container_pi6ii_1",c5="_content_pi6ii_66",zb={container:l5,content:c5},d5=320,v1=220,y1=600,b1="grackle-sidebar-width";function u5(){try{const t=localStorage.getItem(b1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=v1&&s<=y1)return s}}catch{}return d5}function f5(t){try{localStorage.setItem(b1,String(t))}catch{}}function p5({content:t}){const[s]=y.useState(u5),i=y.useRef(null);if(y.useEffect(()=>{const r=i.current;if(!r)return;const c=new ResizeObserver(d=>{for(const u of d){const p=u.borderBoxSize[0];if(p){const m=Math.round(p.inlineSize);m>=v1&&m<=y1&&f5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return o.jsx("div",{className:zb.container,ref:i,"data-testid":"sidebar",style:{width:s},children:o.jsx("div",{className:zb.content,children:t})})}const m5="_bar_tnfsh_1",h5="_btnPrimary_tnfsh_32",g5="_statusText_tnfsh_85",v5="_statusCompleted_tnfsh_90",y5="_statusFailed_tnfsh_94",b5="_statusBlocked_tnfsh_98",x5="_hintText_tnfsh_103",Tt={bar:m5,btnPrimary:h5,statusText:g5,statusCompleted:v5,statusFailed:y5,statusBlocked:b5,hintText:x5};function _5({sessions:t,tasks:s,environments:i}){const r=_t(),c=Zt(),d=At("/sessions/:sessionId"),u=At("/tasks/:taskId"),p=At("/tasks/:taskId/stream"),m=At("/tasks/:taskId/findings"),g=At("/tasks/:taskId/edit"),v=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),b=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),x=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),S=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),k=At("/sessions/new"),w=At("/environments/:environmentId/workspaces/:workspaceId"),N=At("/tasks/new"),T=At("/chat"),C=At("/"),D=At("/settings/*"),L=d==null?void 0:d.params.sessionId,A=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(m==null?void 0:m.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId)??(x==null?void 0:x.params.taskId)??(S==null?void 0:S.params.taskId),R=v??b??x??S,O=(R==null?void 0:R.params.environmentId)??(w==null?void 0:w.params.environmentId),z=c.pathname.startsWith("/environments")&&!w&&!R,$=!!T,X=!!k,te=!!w&&!v&&!b&&!x&&!S,P=!!N;if(!!C&&!X&&!te&&!P||!!D||(!!g||!!S)||P||z||X)return o.jsx(o.Fragment,{});if($)return i.find(F=>F.adapterType==="local"&&F.status==="connected")?o.jsx(o.Fragment,{}):o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Add a local environment to start chatting"})});if(te)return o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Select a task or click + to create one"})});if(A){const E=s.find(pe=>pe.id===A);if(!E)return o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Loading..."})});const F=new Map(s.map(pe=>[pe.id,pe])),ae=E.dependsOn.some(pe=>{const de=F.get(pe);return de!==void 0&&de.status!=="complete"});if(E.status==="not_started"){const pe=ae?E.dependsOn.map(de=>F.get(de)).filter(de=>de&&de.status!=="complete").map(de=>de.title):[];return o.jsx("div",{className:Tt.bar,children:ae?o.jsxs("span",{className:Tt.statusBlocked,children:["Blocked by: ",pe.join(", ")]}):o.jsx("span",{className:Tt.hintText,children:"Use the buttons above to start or manage this task"})})}if(E.status==="working"||E.status==="paused"){const pe=E.latestSessionId||void 0,de=pe?t.find(ke=>ke.id===pe):void 0;return de&&de.status!=="stopped"?o.jsx(o.Fragment,{}):o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Waiting for agent..."})})}if(E.status==="complete")return o.jsxs("div",{className:Tt.bar,children:[o.jsx("span",{className:`${Tt.statusText} ${Tt.statusCompleted}`,children:"Task completed"}),o.jsx("button",{onClick:()=>r(Ci(E.workspaceId,void 0,O)),className:Tt.btnPrimary,children:"+ New Task"})]});if(E.status==="failed")return o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:`${Tt.statusText} ${Tt.statusFailed}`,children:"Task failed"})})}if(L){const E=t.find(pe=>pe.id===L),F=(E==null?void 0:E.status)==="stopped";if(E!==void 0&&!F)return o.jsx(o.Fragment,{});if(F)return o.jsxs("div",{className:Tt.bar,children:[o.jsxs("span",{className:`${Tt.statusText} ${Tt.hintText}`,children:["Session ",E.endReason||E.status]}),o.jsx("button",{onClick:()=>r(Rx(E.environmentId)),className:Tt.btnPrimary,children:"+ New Chat"})]})}return o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Loading..."})})}const k5="_nav_14i94_1",S5="_tab_14i94_24",T5="_tabActive_14i94_62",w5="_tabLabel_14i94_75",j5="_statusDot_14i94_81",N5="_pulse_14i94_87",C5="_addButton_14i94_99",E5="_empty_14i94_132",Aa={nav:k5,tab:S5,tabActive:T5,tabLabel:w5,statusDot:j5,pulse:N5,addButton:C5,empty:E5},A5={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function D5({environments:t}){const s=_t(),i=y.useRef(null),r=At("/environments/:environmentId"),c=At("/environments/:environmentId/edit"),d=At("/environments/:environmentId/workspaces/:workspaceId"),u=At("/environments/:environmentId/workspaces/:workspaceId/*"),p=(r==null?void 0:r.params.environmentId)??(c==null?void 0:c.params.environmentId)??(d==null?void 0:d.params.environmentId)??(u==null?void 0:u.params.environmentId),m=p==="new"?void 0:p,g=y.useCallback(x=>{s(Si(x))},[s]),v=y.useCallback(x=>{var T;const S=(T=i.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),w=k>=0?k:t.findIndex(C=>C.id===m);let N=w;if(x.key==="ArrowDown"||x.key==="j"||x.key==="J")x.preventDefault(),N=(w+1)%S.length;else if(x.key==="ArrowUp"||x.key==="k"||x.key==="K")x.preventDefault(),N=(w-1+S.length)%S.length;else if(x.key==="Home")x.preventDefault(),N=0;else if(x.key==="End")x.preventDefault(),N=S.length-1;else return;N<t.length&&s(Si(t[N].id)),S[N].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return o.jsxs("div",{className:Aa.nav,"data-testid":"environment-nav",children:[o.jsx("nav",{ref:i,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(x=>{const S=x.id===m,k=x.id===b,w=A5[x.status]||"var(--text-tertiary)",N=x.status==="connected";return o.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${Aa.tab} ${S?Aa.tabActive:""}`,onClick:()=>g(x.id),"data-testid":"env-nav-item",children:[o.jsx("span",{className:`${Aa.statusDot} ${N?Aa.pulse:""}`,style:{color:w},"aria-hidden":"true",children:o.jsx(Ba,{size:im,fill:"currentColor"})}),o.jsx("span",{className:Aa.tabLabel,title:x.displayName||x.id,children:x.displayName||x.id})]},x.id)})}),o.jsx("button",{type:"button",className:Aa.addButton,onClick:()=>s(Wj),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&o.jsx("div",{className:Aa.empty,children:"No environments yet."})]})}function Xm(t){const s=new Date(t),i=new Date,r=i.getTime()-s.getTime(),c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return"just now";if(d<60)return`${d}m ago`;if(u<24)return`${u}h ago`;if(p===1)return"yesterday";if(p<7)return`${p} days ago`;const m=s.getFullYear()===i.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const Ub={architecture:{text:"var(--accent-blue)",bg:"var(--accent-blue-dim)"},api:{text:"var(--accent-green)",bg:"var(--accent-green-dim)"},bug:{text:"var(--accent-red)",bg:"var(--accent-red-dim)"},decision:{text:"var(--accent-yellow)",bg:"var(--accent-yellow-dim)"},dependency:{text:"var(--accent-purple)",bg:"var(--accent-purple-dim)"},pattern:{text:"var(--accent-cyan)",bg:"var(--accent-cyan-dim)"},general:{text:"var(--text-secondary)",bg:"var(--bg-elevated)"}};function dd(t){return Ub[t]||Ub.general}const R5="_nav_dlm8m_1",M5="_categoryPills_dlm8m_24",I5="_categoryPill_dlm8m_24",O5="_tab_dlm8m_42",L5="_tabActive_dlm8m_80",B5="_tabContent_dlm8m_93",z5="_tabLabel_dlm8m_100",U5="_tabMeta_dlm8m_106",$5="_categoryDot_dlm8m_111",P5="_empty_dlm8m_118",xs={nav:R5,categoryPills:M5,categoryPill:I5,tab:O5,tabActive:L5,tabContent:B5,tabLabel:z5,tabMeta:U5,categoryDot:$5,empty:P5};function H5({findings:t,workspaceId:s,environmentId:i}){const r=_t(),c=y.useRef(null),d=At("/findings/:findingId"),u=At("/environments/:environmentId/workspaces/:workspaceId/findings/:findingId"),p=(d==null?void 0:d.params.findingId)??(u==null?void 0:u.params.findingId),m=y.useMemo(()=>{const x=new Set(t.map(S=>S.category).filter(Boolean));return Array.from(x).sort()},[t]),g=y.useCallback(x=>{r(Rp(x,s,i))},[r,s,i]),v=y.useCallback(x=>{var T;const S=(T=c.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),w=k>=0?k:t.findIndex(C=>C.id===p);let N=w;if(x.key==="ArrowDown"||x.key==="j"||x.key==="J")x.preventDefault(),N=(w+1)%S.length;else if(x.key==="ArrowUp"||x.key==="k"||x.key==="K")x.preventDefault(),N=(w-1+S.length)%S.length;else if(x.key==="Home")x.preventDefault(),N=0;else if(x.key==="End")x.preventDefault(),N=S.length-1;else return;N<t.length&&r(Rp(t[N].id,s,i)),S[N].focus()},[p,t,r,s,i]),b=p??(t.length>0?t[0].id:void 0);return o.jsxs("div",{className:xs.nav,"data-testid":"findings-nav",children:[m.length>1&&o.jsx("div",{className:xs.categoryPills,"data-testid":"findings-nav-categories",children:m.map(x=>o.jsx("span",{className:xs.categoryPill,style:{color:dd(x).text},children:x},x))}),o.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(x=>{const S=x.id===p,k=x.id===b;return o.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${xs.tab} ${S?xs.tabActive:""}`,onClick:()=>g(x.id),"data-testid":"finding-nav-item",children:[o.jsx("span",{className:xs.categoryDot,style:{color:dd(x.category).text},"aria-hidden":"true",children:o.jsx(Ba,{size:im,fill:"currentColor"})}),o.jsxs("span",{className:xs.tabContent,children:[o.jsx("span",{className:xs.tabLabel,title:x.title,children:x.title}),o.jsx("span",{className:xs.tabMeta,title:x.createdAt,children:Xm(x.createdAt)})]})]},x.id)})}),t.length===0&&o.jsx("div",{className:xs.empty,children:"No findings yet. Agents will post discoveries here."})]})}function V5(t){if(t.length===0)return[];const s=[...t].sort((r,c)=>r[0]-c[0]),i=[[s[0][0],s[0][1]]];for(let r=1;r<s.length;r++){const c=i[i.length-1],[d,u]=s[r];d<=c[1]+1?c[1]=Math.max(c[1],u):i.push([d,u])}return i}function x1({text:t,indices:s,highlightClass:i}){if(!s||s.length===0)return o.jsx(o.Fragment,{children:t});const r=V5(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(o.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(o.jsx("mark",{className:i,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(o.jsx("span",{children:t.slice(d)},`p${d}`)),o.jsx(o.Fragment,{children:c})}function q5(t){const s=new Map(t.map(r=>[r.id,{...r,children:[]}])),i=[];for(const r of s.values())r.parentTaskId&&s.has(r.parentTaskId)?s.get(r.parentTaskId).children.push(r):i.push(r);for(const r of s.values())r.children.sort((c,d)=>c.sortOrder-d.sortOrder);return i.sort((r,c)=>r.sortOrder-c.sortOrder)}function G5(t,s){const i=new Map;for(const d of t){const p=d.dependsOn.length>0&&d.dependsOn.some(g=>s.get(g)!=="complete")?"blocked":d.status,m=i.get(p);m?m.push(d):i.set(p,[d])}const r=[],c=new Set;for(const d of tw){c.add(d);const u=i.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=za(d);r.push({status:d,label:p.label,style:p,tasks:u})}}for(const[d,u]of i)if(!c.has(d)&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=za(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const F5="_container_z4i38_1",Z5="_header_z4i38_5",K5="_headerActions_z4i38_17",Y5="_searchInput_z4i38_23",J5="_searchHighlight_z4i38_56",W5="_groupToggle_z4i38_62",X5="_groupToggleActive_z4i38_89",Q5="_addButton_z4i38_93",eI="_taskRow_z4i38_120",tI="_selected_z4i38_140",nI="_expandArrow_z4i38_150",sI="_expanded_z4i38_157",aI="_leafSpacer_z4i38_161",iI="_taskStatusIcon_z4i38_166",oI="_taskTitle_z4i38_170",rI="_workspaceBadge_z4i38_177",lI="_childCountBadge_z4i38_195",cI="_dependencyBadge_z4i38_208",dI="_blockedBadge_z4i38_220",uI="_addChildButton_z4i38_225",fI="_emptyState_z4i38_268",pI="_statusGroupHeader_z4i38_275",mI="_statusGroupIcon_z4i38_294",hI="_statusGroupLabel_z4i38_298",gI="_statusGroupCount_z4i38_303",Fe={container:F5,header:Z5,headerActions:K5,searchInput:Y5,searchHighlight:J5,groupToggle:W5,groupToggleActive:X5,addButton:Q5,taskRow:eI,selected:tI,expandArrow:nI,expanded:sI,leafSpacer:aI,taskStatusIcon:iI,taskTitle:oI,workspaceBadge:rI,childCountBadge:lI,dependencyBadge:cI,blockedBadge:dI,addChildButton:uI,emptyState:fI,statusGroupHeader:pI,statusGroupIcon:mI,statusGroupLabel:hI,statusGroupCount:gI},vI=[{name:"title",weight:2},{name:"description",weight:1}],_1=16,yI=16,k1="grackle-task-group-by-status";function $b(){try{return localStorage.getItem(k1)==="true"}catch{return!1}}function bI(t){try{localStorage.setItem(k1,String(t))}catch{}}function xI({group:t,isExpanded:s,onToggle:i,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return o.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[o.jsxs("div",{className:Fe.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:i,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),i())},children:[o.jsx("span",{className:`${Fe.expandArrow} ${s?Fe.expanded:""}`,"aria-hidden":"true",children:o.jsx(sa,{size:ot})}),o.jsx("span",{className:Fe.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),o.jsx("span",{className:Fe.statusGroupLabel,children:t.label}),o.jsx("span",{className:Fe.statusGroupCount,children:t.tasks.length})]}),o.jsx(ps,{children:s&&o.jsx(Rt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},style:{overflow:"hidden"},children:t.tasks.map(p=>{const m=za(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return o.jsxs("div",{onClick:()=>c(In(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(In(p.id)))},className:`${Fe.taskRow} ${g?Fe.selected:""}`,style:{"--task-indent":`${_1}px`},"data-task-id":p.id,children:[o.jsx("span",{className:Fe.leafSpacer}),o.jsx("span",{className:Fe.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${rl(p.status)}`,children:m.icon}),o.jsx("span",{className:Fe.taskTitle,title:p.title,children:o.jsx(x1,{text:p.title,indices:d.get(p.id),highlightClass:Fe.searchHighlight})}),v&&o.jsx("span",{className:Fe.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function S1({node:t,depth:s,expandedTasks:i,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=za(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),b=i.has(t.id),x=t.children.length>0,S=c===t.id,k=_1+s*yI,N=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{onClick:()=>d(In(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:T=>{T.currentTarget===T.target&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(In(t.id)))},className:`${Fe.taskRow} ${S?Fe.selected:""}`,style:{"--task-indent":`${k}px`},"data-task-id":t.id,children:[x&&o.jsx("span",{className:`${Fe.expandArrow} ${b?Fe.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:T=>{T.stopPropagation(),r(t.id)},onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),T.stopPropagation(),r(t.id))},children:o.jsx(sa,{size:ot,"aria-hidden":"true"})}),!x&&o.jsx("span",{className:Fe.leafSpacer}),o.jsx("span",{className:Fe.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${rl(t.status)}`,children:g.icon}),o.jsx("span",{className:Fe.taskTitle,title:t.title,children:o.jsx(x1,{text:t.title,indices:p.get(t.id),highlightClass:Fe.searchHighlight})}),N&&o.jsx("span",{className:Fe.workspaceBadge,title:N,children:N}),x&&o.jsxs("span",{className:Fe.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&o.jsx("span",{className:`${Fe.dependencyBadge} ${v?Fe.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<fT&&o.jsx(Lo,{text:"Add child task",children:o.jsx("button",{onClick:T=>{T.stopPropagation(),d(Ci(t.workspaceId,t.id))},"aria-label":"Add child task",className:Fe.addChildButton,children:"+"})})]}),o.jsx(ps,{children:x&&b&&o.jsx(Rt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:t.children.map(T=>o.jsx(S1,{node:T,depth:s+1,expandedTasks:i,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function _I({workspaces:t,tasks:s}){const i=_t(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState($b),[g,v]=y.useState($b),[b,x]=y.useState(new Map),S=At("/tasks/:taskId/*"),k=(S==null?void 0:S.params.taskId)!=="new"?S==null?void 0:S.params.taskId:void 0,w=y.useMemo(()=>new Map(s.map(H=>[H.id,H.status])),[s]),N=y.useMemo(()=>new Map(t.map(H=>[H.id,H.name])),[t]),T=()=>{const H=!p;bI(H),m(H),H&&(v(!0),x(new Map))},C=H=>{x(oe=>{const E=new Map(oe),F=E.has(H)?E.get(H):g;return E.set(H,!F),E})},D=H=>b.has(H)?b.get(H):g,L=H=>{c(oe=>{const E=new Set(oe);return E.has(H)?(E.delete(H),u(F=>new Set(F).add(H))):(E.add(H),u(F=>{const ae=new Set(F);return ae.delete(H),ae})),E})};y.useEffect(()=>{const H=new Set(s.filter(oe=>oe.parentTaskId).map(oe=>oe.parentTaskId));H.size>0&&c(oe=>{const E=new Set(oe);for(const F of H)d.has(F)||E.add(F);return E})},[s,d]);const[A,R]=y.useState(""),{directMatchTaskIds:O,treeMatchTaskIds:z,titleHighlights:$}=y.useMemo(()=>{if(!A.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const H=uT(s,A,vI),oe=new Set(H.map(pe=>pe.item.id)),E=new Map;for(const pe of H){const de=pe.matches.find(Oe=>Oe.key==="title");de&&E.set(pe.item.id,de.indices)}const F=new Set(oe),ae=new Map(s.map(pe=>[pe.id,pe]));for(const pe of[...oe]){let de=ae.get(pe);for(;de!=null&&de.parentTaskId;)F.add(de.parentTaskId),de=ae.get(de.parentTaskId)}return{directMatchTaskIds:oe,treeMatchTaskIds:F,titleHighlights:E}},[A,s]),X=O!==null,te=X?p?O:z:null,P=te?s.filter(H=>te.has(H.id)):s,re=p?[]:q5(P);return o.jsxs("div",{className:Fe.container,children:[o.jsxs("div",{className:Fe.header,children:[o.jsx("span",{children:"Tasks"}),o.jsxs("div",{className:Fe.headerActions,children:[o.jsx(Lo,{text:p?"Switch to tree view":"Group tasks by status",children:o.jsx("button",{className:`${Fe.groupToggle} ${p?Fe.groupToggleActive:""}`,onClick:T,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:o.jsx(E2,{size:en})})}),o.jsx(Lo,{text:"New task",children:o.jsx("button",{className:Fe.addButton,onClick:()=>i(Ci()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&o.jsx("input",{type:"text",value:A,onChange:H=>R(H.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Fe.searchInput,"data-testid":"sidebar-search"}),p?G5(P,w).map(H=>o.jsx(xI,{group:H,isExpanded:D(H.status),onToggle:()=>C(H.status),selectedTaskId:k,navigate:i,titleHighlights:$,workspaceNames:N},H.status)):re.map(H=>o.jsx(S1,{node:H,depth:0,expandedTasks:r,toggleTask:L,selectedTaskId:k,navigate:i,taskStatusById:w,titleHighlights:$,workspaceNames:N},H.id)),P.length===0&&!X&&o.jsx("div",{className:Fe.emptyState,children:"No tasks yet. Click + to create one."}),P.length===0&&X&&o.jsx("div",{className:Fe.emptyState,children:"No matching tasks"})]})}const kI="_toast_ed2dk_1",SI="_success_ed2dk_18",TI="_icon_ed2dk_22",wI="_error_ed2dk_25",jI="_warning_ed2dk_32",NI="_info_ed2dk_38",CI="_message_ed2dk_53",EI="_close_ed2dk_60",zr={toast:kI,success:SI,icon:TI,error:wI,warning:jI,info:NI,message:CI,close:EI},AI={success:o.jsx(ji,{size:Bt}),error:o.jsx(Ha,{size:Bt}),warning:o.jsx(am,{size:Bt}),info:o.jsx(sm,{size:Bt})};function DI({toast:t,onDismiss:s}){return y.useEffect(()=>{const i=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(i)},[t.id,t.duration,s]),o.jsxs(Rt.div,{className:`${zr.toast} ${zr[t.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[o.jsx("span",{className:zr.icon,"aria-hidden":"true",children:AI[t.variant]}),o.jsx("span",{className:zr.message,children:t.message}),o.jsx("button",{type:"button",className:zr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:o.jsx(Ha,{size:en,"aria-hidden":"true"})})]})}const RI="_container_qqse2_1",MI={container:RI};function II({toasts:t,onDismiss:s}){return o.jsx("div",{className:MI.container,"data-testid":"toast-container",children:o.jsx(ps,{children:t.map(i=>o.jsx(DI,{toast:i,onDismiss:s},i.id))})})}const OI="_callout_e5awm_1",LI="_success_e5awm_11",BI="_icon_e5awm_15",zI="_error_e5awm_18",UI="_warning_e5awm_25",$I="_info_e5awm_32",PI="_content_e5awm_48",HI="_close_e5awm_53",Ur={callout:OI,success:LI,icon:BI,error:zI,warning:UI,info:$I,content:PI,close:HI},VI={success:o.jsx(ji,{size:Bt}),error:o.jsx(Ha,{size:Bt}),warning:o.jsx(am,{size:Bt}),info:o.jsx(sm,{size:Bt})};function qI({variant:t="info",children:s,dismissible:i=!1,className:r}){const[c,d]=y.useState(!1);return o.jsx(o.Fragment,{children:!c&&o.jsxs("div",{className:[Ur.callout,Ur[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[o.jsx("span",{className:Ur.icon,"aria-hidden":"true",children:VI[t]}),o.jsx("span",{className:Ur.content,children:s}),i&&o.jsx("button",{type:"button",className:Ur.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:o.jsx(Ha,{size:en,"aria-hidden":"true"})})]})})}function GI({currentVersion:t,latestVersion:s,updateAvailable:i,isDocker:r}){if(!i)return o.jsx(o.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return o.jsx("div",{"data-testid":"update-banner",children:o.jsxs(qI,{variant:"info",dismissible:!0,children:[o.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",o.jsx("code",{children:c})]})})}const FI="_container_de44x_1",ZI="_emptyState_de44x_8",KI="_card_de44x_14",YI="_cardClickable_de44x_34",JI="_cardHeader_de44x_42",WI="_categoryBadge_de44x_54",XI="_findingTitle_de44x_62",QI="_findingDate_de44x_68",eO="_findingContent_de44x_80",tO="_tags_de44x_86",nO="_tag_de44x_86",cs={container:FI,emptyState:ZI,card:KI,cardClickable:YI,cardHeader:JI,categoryBadge:WI,findingTitle:XI,findingDate:QI,findingContent:eO,tags:tO,tag:nO};function T1({findings:t,onFindingClick:s}){return t.length===0?o.jsx("div",{className:cs.emptyState,children:"No findings yet. Agents will post discoveries here."}):o.jsx("div",{className:cs.container,children:t.map((i,r)=>{const c=dd(i.category),d=s?Rt.button:Rt.div;return o.jsxs(d,{type:s?"button":void 0,className:`${cs.card} ${s?cs.cardClickable:""}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:r*.05,duration:.2},onClick:s?()=>{s(i.id)}:void 0,children:[o.jsxs("div",{className:cs.cardHeader,children:[o.jsx("span",{className:cs.categoryBadge,style:{background:c.bg,color:c.text},children:i.category}),o.jsx("span",{className:cs.findingTitle,children:i.title}),o.jsx("span",{className:cs.findingDate,title:i.createdAt,children:Xm(i.createdAt)})]}),o.jsx("div",{className:cs.findingContent,children:i.content.length>300?i.content.slice(0,300)+"...":i.content}),i.tags.length>0&&o.jsx("div",{className:cs.tags,children:i.tags.map(u=>o.jsx("span",{className:cs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},i.id)})})}const sO="_section_1ingb_14",aO="_sectionTitle_1ingb_26",iO="_sectionDescription_1ingb_35",oO="_tokenList_1ingb_48",rO="_tokenRow_1ingb_55",lO="_tokenBadge_1ingb_68",cO="_tokenName_1ingb_83",dO="_tokenTarget_1ingb_90",uO="_deleteButton_1ingb_99",fO="_addForm_1ingb_113",pO="_formRow_1ingb_119",mO="_input_1ingb_125",hO="_select_1ingb_155",gO="_addButton_1ingb_187",vO="_emptyStateInfo_1ingb_221",yO="_themeOptions_1ingb_229",bO="_themeOption_1ingb_229",xO="_themeOptionSelected_1ingb_254",_O="_themeOptionHeader_1ingb_259",kO="_themeOptionLabel_1ingb_266",SO="_themeOptionDesc_1ingb_273",TO="_variantToggle_1ingb_279",wO="_variantButton_1ingb_286",jO="_variantActive_1ingb_305",NO="_themeSwatches_1ingb_311",CO="_themeSwatch_1ingb_311",EO="_systemToggle_1ingb_325",AO="_systemToggleHint_1ingb_341",DO="_themeActive_1ingb_348",RO="_aboutGrid_1ingb_354",MO="_aboutItem_1ingb_360",IO="_aboutLabel_1ingb_373",OO="_aboutValue_1ingb_379",LO="_aboutDot_1ingb_387",BO="_aboutDotConnected_1ingb_394",zO="_aboutDotDisconnected_1ingb_398",ge={section:sO,sectionTitle:aO,sectionDescription:iO,tokenList:oO,tokenRow:rO,tokenBadge:lO,tokenName:cO,tokenTarget:dO,deleteButton:uO,addForm:fO,formRow:pO,input:mO,select:hO,addButton:gO,emptyStateInfo:vO,themeOptions:yO,themeOption:bO,themeOptionSelected:xO,themeOptionHeader:_O,themeOptionLabel:kO,themeOptionDesc:SO,variantToggle:TO,variantButton:wO,variantActive:jO,themeSwatches:NO,themeSwatch:CO,systemToggle:EO,systemToggleHint:AO,themeActive:DO,aboutGrid:RO,aboutItem:MO,aboutLabel:IO,aboutValue:OO,aboutDot:LO,aboutDotConnected:BO,aboutDotDisconnected:zO},UO=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function $O({tokens:t,onSetToken:s,onDeleteToken:i,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,b]=y.useState(""),[x,S]=y.useState(null),k=T=>{if(T.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),b("")},w=T=>{S(T)},N=()=>{x&&(i(x),r==null||r("Token deleted","info")),S(null)};return o.jsxs(o.Fragment,{children:[o.jsx(wi,{isOpen:x!==null,title:"Delete Token?",description:x?`"${x}" will be permanently removed.`:void 0,onConfirm:N,onCancel:()=>S(null)}),o.jsxs("section",{className:ge.section,children:[o.jsx("h3",{className:ge.sectionTitle,children:"Tokens"}),o.jsx("p",{className:ge.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?o.jsx("div",{className:ge.emptyStateInfo,children:"Add your first API token to enable service integrations."}):o.jsx("div",{className:ge.tokenList,children:t.map(T=>o.jsxs("div",{className:ge.tokenRow,children:[o.jsx("span",{className:ge.tokenBadge,children:T.tokenType}),o.jsx("span",{className:ge.tokenName,children:T.name}),o.jsx("span",{className:ge.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),o.jsx("button",{className:ge.deleteButton,onClick:()=>w(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:o.jsx(Ha,{size:en,"aria-hidden":"true"})})]},T.name))}),o.jsxs("form",{className:ge.addForm,onSubmit:k,children:[o.jsxs("div",{className:ge.formRow,children:[o.jsx("input",{className:ge.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),o.jsx("input",{className:ge.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),o.jsxs("div",{className:ge.formRow,children:[o.jsx("select",{className:ge.select,value:m,onChange:T=>g(T.target.value),children:UO.map(T=>o.jsx("option",{value:T.value,children:T.label},T.value))}),o.jsx("input",{className:ge.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:T=>b(T.target.value)}),o.jsx("button",{className:ge.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const jd=[{id:"grackle",label:"Grackle",description:"The default Grackle theme — iridescent purple on clean dark.",swatches:["#0e1218","#8b5cf6","#60a5fa","#e5e7eb","#34d399"],variantLightId:"grackle-light",variantDarkId:"grackle-dark"},{id:"grackle-light",label:"Grackle Light",description:"Light Grackle variant.",hidden:!0},{id:"grackle-dark",label:"Grackle Dark",description:"Dark Grackle variant.",hidden:!0},{id:"glass",label:"Glassmorphism",description:"Dark frosted-glass aesthetic with backdrop blur effects.",swatches:["#0a0c14","#4ecca3","#70a1ff","#e2e8f0","#a855f7"]},{id:"matrix",label:"Matrix",description:"Phosphor-green CRT terminal with scanlines and glow.",swatches:["#050505","#00ff41","#00bfff","#33ff77","#ffb000"]},{id:"brutalist",label:"Neubrutalism",description:"Thick borders, raw colors, bold type — ugly on purpose.",swatches:["#f5f0e8","#ff5757","#5ce1e6","#1a1a1a","#ffde59"],variantLightId:"brutalist-light",variantDarkId:"brutalist-dark"},{id:"brutalist-light",label:"Neubrutalism Light",description:"Light neubrutalism variant.",hidden:!0},{id:"brutalist-dark",label:"Neubrutalism Dark",description:"Dark neubrutalism variant.",hidden:!0},{id:"monokai",label:"Monokai",description:"Classic warm editor palette — pink, green, and purple.",swatches:["#272822","#f92672","#a6e22e","#f8f8f2","#ae81ff"],variantLightId:"monokai-light",variantDarkId:"monokai-dark"},{id:"monokai-dark",label:"Monokai Dark",description:"Dark Monokai variant.",hidden:!0},{id:"monokai-light",label:"Monokai Light",description:"Light Monokai variant.",hidden:!0},{id:"ubuntu",label:"Ubuntu",description:"Aubergine terminal with the GNOME Tango palette.",swatches:["#300a24","#8ae234","#ef2929","#eeeeec","#fce94f"]},{id:"sandstone",label:"Sandstone",description:"Warm terracotta accent on dark brown, in the style of Claude Code.",swatches:["#1a1815","#C15F3C","#6b8afd","#e8e6e3","#a78bfa"]},{id:"verdigris",label:"Verdigris",description:"Teal accent on charcoal, in the style of ChatGPT.",swatches:["#141414","#00a67e","#3b82f6","#ececec","#ab68ff"]},{id:"primer",label:"Primer",description:"Blue accent on ink-dark grey, in the style of GitHub.",swatches:["#0d1117","#58a6ff","#3fb950","#c9d1d9","#bc8cff"]}],w1=new Set(jd.map(t=>t.id)),Pb="grackle";function Xp(t){return jd.find(s=>s.id===t)}function PO({themeId:t,resolvedThemeId:s,onSetTheme:i,preferSystem:r,onSetPreferSystem:c}){return o.jsxs("section",{className:ge.section,children:[o.jsx("h3",{className:ge.sectionTitle,children:"Appearance"}),o.jsx("p",{className:ge.sectionDescription,children:"Choose how Grackle looks across the app."}),o.jsx("div",{className:ge.themeOptions,children:jd.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?t===d.id||t===d.variantLightId||t===d.variantDarkId:t===d.id,m=u&&s===d.variantLightId;return o.jsxs("button",{type:"button",className:`${ge.themeOption} ${p?ge.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>i(d.id),children:[o.jsxs("span",{className:ge.themeOptionHeader,children:[o.jsxs("span",{children:[o.jsx("span",{className:ge.themeOptionLabel,children:d.label}),o.jsx("span",{className:ge.themeOptionDesc,children:d.description})]}),u&&o.jsxs("span",{className:ge.variantToggle,children:[o.jsx("span",{role:"button",tabIndex:0,className:`${ge.variantButton} ${p&&m?ge.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),i(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),i(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),o.jsx("span",{role:"button",tabIndex:0,className:`${ge.variantButton} ${p&&!m?ge.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),i(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),i(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&o.jsx("span",{className:ge.themeSwatches,children:d.swatches.map((g,v)=>o.jsx("span",{className:ge.themeSwatch,style:{background:g}},v))})]},d.id)})}),o.jsxs("label",{className:ge.systemToggle,children:[o.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),o.jsx("span",{children:"Match system light/dark preference"})]}),o.jsx("p",{className:ge.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),o.jsxs("p",{className:ge.themeActive,children:["Active theme: ",o.jsx("strong",{children:s})]})]})}function HO({connected:t,environments:s,sessions:i}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=i.filter(u=>["running","idle"].includes(u.status)).length;return o.jsxs("section",{className:ge.section,"data-testid":"about-panel",children:[o.jsx("h3",{className:ge.sectionTitle,children:"About"}),o.jsx("p",{className:ge.sectionDescription,children:"Connection status and application information."}),o.jsxs("div",{className:ge.aboutGrid,children:[o.jsxs("div",{className:ge.aboutItem,children:[o.jsx("span",{className:ge.aboutLabel,children:"Connection"}),o.jsxs("span",{className:ge.aboutValue,children:[o.jsx("span",{className:`${ge.aboutDot} ${t?ge.aboutDotConnected:ge.aboutDotDisconnected}`}),t?"Connected":"Disconnected"]})]}),o.jsxs("div",{className:ge.aboutItem,children:[o.jsx("span",{className:ge.aboutLabel,children:"Environments"}),o.jsxs("span",{className:ge.aboutValue,children:[r,"/",c," connected"]})]}),o.jsxs("div",{className:ge.aboutItem,children:[o.jsx("span",{className:ge.aboutLabel,children:"Active Sessions"}),o.jsx("span",{className:ge.aboutValue,children:d})]}),o.jsxs("div",{className:ge.aboutItem,children:[o.jsx("span",{className:ge.aboutLabel,children:"Version"}),o.jsx("span",{className:ge.aboutValue,children:"0.94.0"})]})]})]})}const VO="_container_cddyd_1",qO="_header_cddyd_8",GO="_headerTitle_cddyd_35",FO="_badge_cddyd_44",ZO="_headerActions_cddyd_54",KO="_body_cddyd_61",YO="_formContent_cddyd_73",JO="_section_cddyd_85",WO="_label_cddyd_91",XO="_titleInput_cddyd_98",QO="_descriptionTextarea_cddyd_131",eL="_parentContext_cddyd_167",tL="_parentLabel_cddyd_175",nL="_parentName_cddyd_182",sL="_personaSelect_cddyd_186",aL="_depList_cddyd_220",iL="_depItem_cddyd_226",oL="_depItemSelected_cddyd_248",rL="_noDeps_cddyd_252",lL="_btnPrimary_cddyd_258",cL="_btnGhost_cddyd_289",et={container:VO,header:qO,headerTitle:GO,badge:FO,headerActions:ZO,body:KO,formContent:YO,section:JO,label:WO,titleInput:XO,descriptionTextarea:QO,parentContext:eL,parentLabel:tL,parentName:nL,personaSelect:sL,depList:aL,depItem:iL,depItemSelected:oL,noDeps:rL,btnPrimary:lL,btnGhost:cL};function j1({mode:t,taskId:s,workspaceId:i,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:b}){const x=_t(),S=t==="edit",k=S&&s?d.find(me=>me.id===s):void 0,w=S?(k==null?void 0:k.workspaceId)??"":i??"",[N,T]=y.useState(w),C=w||N,D=u.find(me=>me.id===C),L=c??(D==null?void 0:D.environmentId),A=!S&&!i,R=S?(k==null?void 0:k.parentTaskId)??"":r??"",O=R?d.find(me=>me.id===R):void 0,[z,$]=y.useState((k==null?void 0:k.title)??""),[X,te]=y.useState((k==null?void 0:k.description)??""),[P,re]=y.useState((k==null?void 0:k.dependsOn)??[]),[H,oe]=y.useState((k==null?void 0:k.defaultPersonaId)??""),[E,F]=y.useState((k==null?void 0:k.canDecompose)??!1),[ae,pe]=y.useState(!1),de=y.useRef(!1);y.useEffect(()=>{S&&k&&!de.current&&(de.current=!0,$(k.title),te(k.description),re(k.dependsOn),oe(k.defaultPersonaId),F(k.canDecompose))},[S,k]);const Oe=d.filter(me=>me.workspaceId===C&&(!S||me.id!==s)&&me.id!==R),ke=z.trim().length>0&&(!S||k!==void 0)&&C.length>0,Ee=me=>{re(Be=>Be.includes(me)?Be.filter(mt=>mt!==me):[...Be,me])},ze=()=>{!ke||ae||S&&k===void 0||(S&&s?(g(s,z.trim(),X,P,H),b==null||b("Task updated","success"),v?v():x(In(s,void 0,C,L),{replace:!0})):(pe(!0),m(C,z.trim(),X,P.length>0?P:void 0,R||void 0,H,E,()=>{b==null||b("Task created","success"),x(i?Ua(i,L):"/tasks",{replace:!0})},me=>{b==null||b(me,"error"),pe(!1)})))},ue=()=>{if(v){v();return}x(S&&s?In(s,void 0,C,L):i?Ua(i,L):"/tasks")},xe=S?"edit task":R?"child task":"new task";return o.jsxs("div",{className:et.container,children:[o.jsxs("div",{className:et.header,children:[o.jsxs("div",{className:et.headerTitle,children:[o.jsx("span",{className:et.badge,children:xe}),O&&o.jsxs("span",{className:et.parentContext,children:[o.jsx("span",{className:et.parentLabel,children:"Child of"}),o.jsx("span",{className:et.parentName,children:O.title})]})]}),o.jsxs("div",{className:et.headerActions,children:[o.jsx("button",{onClick:ze,disabled:!ke||ae,className:et.btnPrimary,"data-testid":"task-edit-save",children:ae?"Creating…":S?"Save Changes":"Create"}),o.jsx("button",{onClick:ue,className:et.btnGhost,children:"Cancel"})]})]}),o.jsx("div",{className:et.body,children:o.jsxs("div",{className:et.formContent,children:[A&&o.jsxs("div",{className:et.section,children:[o.jsx("label",{className:et.label,htmlFor:"task-edit-workspace",children:"Workspace"}),o.jsxs("select",{id:"task-edit-workspace",value:N,onChange:me=>T(me.target.value),className:et.personaSelect,"data-testid":"task-edit-workspace",children:[o.jsx("option",{value:"",children:"Select a workspace..."}),u.map(me=>o.jsx("option",{value:me.id,children:me.name},me.id))]})]}),o.jsxs("div",{className:et.section,children:[o.jsx("label",{className:et.label,htmlFor:"task-edit-title",children:"Title"}),o.jsx("input",{id:"task-edit-title",type:"text",value:z,onChange:me=>$(me.target.value),placeholder:"Task title...",autoFocus:!0,className:et.titleInput,"data-testid":"task-edit-title",onKeyDown:me=>{me.key==="Enter"&&ke&&ze()}})]}),o.jsxs("div",{className:et.section,children:[o.jsx("label",{className:et.label,htmlFor:"task-edit-description",children:"Description"}),o.jsx("textarea",{id:"task-edit-description",value:X,onChange:me=>te(me.target.value),placeholder:"Describe the task... (markdown supported)",className:et.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),o.jsxs("div",{className:et.section,children:[o.jsx("label",{className:et.label,htmlFor:"task-edit-persona",children:"Default Persona"}),o.jsxs("select",{id:"task-edit-persona",value:H,onChange:me=>oe(me.target.value),className:et.personaSelect,"data-testid":"task-edit-persona",children:[o.jsx("option",{value:"",children:"(Inherit)"}),p.map(me=>o.jsx("option",{value:me.id,children:me.name},me.id))]})]}),!S&&o.jsx("div",{className:et.section,children:o.jsxs("label",{className:et.depItem,"data-testid":"task-edit-can-decompose",children:[o.jsx("input",{type:"checkbox",checked:E,onChange:me=>F(me.target.checked)}),"Can spawn subtasks"]})}),o.jsxs("div",{className:et.section,children:[o.jsx("div",{className:et.label,children:"Dependencies"}),Oe.length===0?o.jsx("div",{className:et.noDeps,children:"No other tasks in this workspace"}):o.jsx("div",{className:et.depList,children:Oe.map(me=>{const Be=P.includes(me.id);return o.jsxs("label",{className:`${et.depItem} ${Be?et.depItemSelected:""}`,"data-testid":`dep-option-${me.id}`,children:[o.jsx("input",{type:"checkbox",checked:Be,onChange:()=>Ee(me.id)}),me.title,o.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",me.status,")"]})]},me.id)})})]})]})})]})}const dL="_actionButtons_1rjka_1",uL="_btnPrimary_1rjka_8",fL="_btnDanger_1rjka_39",pL="_btnGhost_1rjka_78",Ft={actionButtons:dL,btnPrimary:uL,btnDanger:fL,btnGhost:pL};function mL({task:t,sessionId:s,isBlocked:i,onStart:r,onResume:c,onStop:d,onPause:u,onDelete:p,onEdit:m}){if(t.status==="not_started")return i?o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{onClick:m,className:Ft.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Ft.btnPrimary,children:"Start"}),o.jsx("button",{onClick:m,className:Ft.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{onClick:d,className:Ft.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),o.jsx("button",{onClick:u,disabled:!s,className:Ft.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{onClick:d,className:Ft.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),o.jsx("button",{onClick:c,className:Ft.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return o.jsx("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{onClick:r,className:Ft.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const hL="_workpadSection_y8nj9_1",gL="_workpadLabel_y8nj9_9",vL="_workpadStatus_y8nj9_17",yL="_workpadSummary_y8nj9_23",bL="_workpadExtra_y8nj9_29",Da={workpadSection:hL,workpadLabel:gL,workpadStatus:vL,workpadSummary:yL,workpadExtra:bL};function xL({workpad:t}){if(!t)return;let s;try{const i=JSON.parse(t);if(i==null||typeof i!="object"||Array.isArray(i))return;s=i}catch{return o.jsxs("div",{className:Da.workpadSection,"data-testid":"workpad-panel",children:[o.jsx("div",{className:Da.workpadLabel,children:"Workpad"}),o.jsx("div",{className:Da.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return o.jsxs("div",{className:Da.workpadSection,"data-testid":"workpad-panel",children:[o.jsx("div",{className:Da.workpadLabel,children:"Workpad"}),s.status&&o.jsx("div",{className:Da.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&o.jsx("div",{className:Da.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&o.jsx("div",{className:Da.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const _L="_overviewDashboard_r05qm_1",kL="_overviewHero_r05qm_7",SL="_statusBadge_r05qm_14",TL="_statusPending_r05qm_26",wL="_statusAssigned_r05qm_31",jL="_statusInProgress_r05qm_36",NL="_statusReview_r05qm_41",CL="_statusDone_r05qm_46",EL="_statusFailed_r05qm_51",AL="_statusWaitingInput_r05qm_56",DL="_overviewBranchPill_r05qm_61",RL="_branchLink_r05qm_76",ML="_overviewSection_r05qm_87",IL="_overviewLabel_r05qm_93",OL="_overviewValue_r05qm_100",LL="_overviewMuted_r05qm_105",BL="_overviewMarkdown_r05qm_111",zL="_envRow_r05qm_180",UL="_envDot_r05qm_186",$L="_envDotGreen_r05qm_193",PL="_envDotYellow_r05qm_197",HL="_envDotRed_r05qm_201",VL="_envDotGray_r05qm_205",qL="_depList_r05qm_209",GL="_depItem_r05qm_215",FL="_depBlocked_r05qm_222",ZL="_depDone_r05qm_226",KL="_timeline_r05qm_230",YL="_timelineRow_r05qm_236",JL="_timelineKey_r05qm_243",WL="_timelineValue_r05qm_249",XL="_timelineDelta_r05qm_253",QL="_reviewNotes_r05qm_264",ye={overviewDashboard:_L,overviewHero:kL,statusBadge:SL,statusPending:TL,statusAssigned:wL,statusInProgress:jL,statusReview:NL,statusDone:CL,statusFailed:EL,statusWaitingInput:AL,overviewBranchPill:DL,branchLink:RL,overviewSection:ML,overviewLabel:IL,overviewValue:OL,overviewMuted:LL,overviewMarkdown:BL,envRow:zL,envDot:UL,envDotGreen:$L,envDotYellow:PL,envDotRed:HL,envDotGray:VL,depList:qL,depItem:GL,depBlocked:FL,depDone:ZL,timeline:KL,timelineRow:YL,timelineKey:JL,timelineValue:WL,timelineDelta:XL,reviewNotes:QL};function Lc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function vp(t,s){if(!t||!s)return;const i=new Date(s).getTime()-new Date(t).getTime();if(isNaN(i)||i<0)return;const r=Math.floor(i/6e4),c=Math.floor(i%6e4/1e3);if(r===0)return`${c}s`;const d=Math.floor(r/60),u=r%60;return d===0?`${r}m ${c}s`:`${d}h ${u}m`}function Hb(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?ye.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?ye.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?ye.envDotRed:ye.envDotGray}function eB({status:t}){const s=za(t),i=ew(t);return o.jsx("span",{className:`${ye.statusBadge} ${ye[i]??ye.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function tB({task:t,tasksById:s,environments:i,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?i.find(k=>k.id===g):void 0,b=r.find(k=>k.id===t.workspaceId),x=i.find(k=>k.id===d),S=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return o.jsxs("div",{className:ye.overviewDashboard,"data-testid":"task-overview-panel",children:[o.jsxs("div",{className:ye.overviewHero,children:[o.jsx(eB,{status:t.status}),t.branch&&o.jsx("span",{className:ye.overviewBranchPill,"data-testid":"task-overview-branch",children:S?o.jsxs("a",{href:S,target:"_blank",rel:"noreferrer noopener",className:ye.branchLink,children:["🔗"," ",t.branch]}):o.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-description",children:[o.jsx("div",{className:ye.overviewLabel,children:"Description"}),o.jsx("div",{className:ye.overviewMarkdown,children:o.jsx(pd,{remarkPlugins:[md],children:t.description})})]}),t.workpad&&o.jsx(xL,{workpad:t.workpad}),o.jsxs("div",{className:ye.overviewSection,children:[o.jsx("div",{className:ye.overviewLabel,children:"Environment"}),g&&v?o.jsxs("div",{className:ye.envRow,"data-testid":"task-overview-environment",children:[o.jsx("span",{className:`${ye.envDot} ${Hb(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),o.jsx("span",{className:ye.overviewValue,children:v.displayName})]}):x?o.jsxs("div",{className:ye.envRow,"data-testid":"task-overview-environment",children:[o.jsx("span",{className:`${ye.envDot} ${Hb(x.status)}`,title:x.status,"aria-label":`Status: ${x.status}`,role:"img"}),o.jsx("span",{className:ye.overviewValue,children:x.displayName}),o.jsx("span",{className:ye.overviewMuted,children:"(workspace default)"})]}):o.jsx("div",{className:ye.overviewMuted,children:"Set in workspace settings"})]}),o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-dependencies",children:[o.jsx("div",{className:ye.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?o.jsx("div",{className:ye.overviewMuted,children:"None"}):o.jsx("div",{className:ye.depList,children:t.dependsOn.map(k=>{const w=s.get(k),N=(w==null?void 0:w.status)==="complete";return o.jsxs("div",{className:`${ye.depItem} ${N?ye.depDone:ye.depBlocked}`,children:[o.jsx("span",{children:N?"✓":"○"}),o.jsx("span",{children:(w==null?void 0:w.title)??k})]},k)})})]}),o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-timeline",children:[o.jsx("div",{className:ye.overviewLabel,children:"Timeline"}),o.jsxs("div",{className:ye.timeline,children:[t.createdAt&&o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Created"}),o.jsx("span",{className:ye.timelineValue,children:Lc(t.createdAt)})]}),t.assignedAt&&(()=>{const k=vp(t.createdAt,t.assignedAt);return o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Assigned"}),o.jsx("span",{className:ye.timelineValue,children:Lc(t.assignedAt)}),k!==void 0&&o.jsx("span",{className:ye.timelineDelta,children:k})]})})(),t.startedAt&&(()=>{const k=vp(t.assignedAt??t.createdAt,t.startedAt);return o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Started"}),o.jsx("span",{className:ye.timelineValue,children:Lc(t.startedAt)}),k!==void 0&&o.jsx("span",{className:ye.timelineDelta,children:k})]})})(),t.completedAt&&(()=>{const k=vp(t.startedAt,t.completedAt);return o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Completed"}),o.jsx("span",{className:ye.timelineValue,children:Lc(t.completedAt)}),k!==void 0&&o.jsx("span",{className:ye.timelineDelta,children:k})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&o.jsx("div",{className:ye.overviewMuted,children:"No timing data"})]})]}),u&&u.costUsd>0&&o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-usage",children:[o.jsx("div",{className:ye.overviewLabel,children:"Usage"}),o.jsxs("div",{className:ye.timeline,children:[o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Cost"}),o.jsx("span",{className:ye.timelineValue,children:Ro(u.costUsd)}),o.jsxs("span",{className:ye.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costUsd>u.costUsd&&o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Total (incl. subtasks)"}),o.jsx("span",{className:ye.timelineValue,children:Ro(p.costUsd)}),o.jsxs("span",{className:ye.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),t.reviewNotes&&o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-review-notes",children:[o.jsx("div",{className:ye.overviewLabel,children:"Review Notes"}),o.jsx("div",{className:ye.reviewNotes,children:t.reviewNotes})]})]})}const nB="_container_legrg_1",sB="_header_legrg_8",aB="_headerTitle_legrg_35",iB="_badge_legrg_44",oB="_headerActions_legrg_54",rB="_body_legrg_61",lB="_formContent_legrg_73",cB="_section_legrg_85",dB="_label_legrg_91",uB="_nameInput_legrg_98",fB="_fieldInput_legrg_131",pB="_adapterSelect_legrg_164",mB="_readOnlyValue_legrg_198",hB="_codespaceSection_legrg_204",gB="_codespaceActions_legrg_210",vB="_creatingHint_legrg_216",yB="_errorHint_legrg_222",bB="_btnPrimary_legrg_235",xB="_btnGhost_legrg_266",ie={container:nB,header:sB,headerTitle:aB,badge:iB,headerActions:oB,body:rB,formContent:lB,section:cB,label:dB,nameInput:uB,fieldInput:fB,adapterSelect:pB,readOnlyValue:mB,codespaceSection:hB,codespaceActions:gB,creatingHint:vB,errorHint:yB,btnPrimary:bB,btnGhost:xB},Yc=1,Jc=65535;function yp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=Yc&&s<=Jc}function bp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function _B({codespaceName:t,onCodespaceNameChange:s,envName:i,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[b,x]=y.useState(""),[S,k]=y.useState("");return g==="create"?o.jsxs("div",{className:ie.codespaceSection,children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Repository"}),o.jsx("input",{type:"text",value:b,onChange:w=>x(w.target.value),placeholder:"owner/repo",className:ie.fieldInput,"data-testid":"env-codespace-repo"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Machine Type"}),o.jsx("input",{type:"text",value:S,onChange:w=>k(w.target.value),placeholder:"Machine type (optional)...",className:ie.fieldInput,"data-testid":"env-codespace-machine"})]}),o.jsxs("div",{className:ie.codespaceActions,children:[o.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),S.trim()||void 0),v("pick"),x(""),k(""))},disabled:!b.trim(),className:ie.btnPrimary,children:"Create"}),o.jsx("button",{onClick:()=>{v("pick"),x(""),k("")},className:ie.btnGhost,children:"Cancel"})]})]}):o.jsx("div",{className:ie.codespaceSection,children:o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Codespace"}),!u&&o.jsxs("select",{value:t,onChange:w=>{w.target.value==="__create__"?(v("create"),s("")):(s(w.target.value),w.target.value&&!i.trim()&&r(w.target.value))},disabled:p,className:ie.adapterSelect,"data-testid":"env-codespace-select",children:[o.jsx("option",{value:"",children:"Select a codespace..."}),c.map(w=>o.jsxs("option",{value:w.name,children:[w.name," (",w.repository,") — ",w.state]},w.name)),o.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&o.jsx("span",{className:ie.creatingHint,children:"Creating codespace..."}),u&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:ie.errorHint,children:u}),o.jsx("input",{type:"text",value:t,onChange:w=>s(w.target.value),placeholder:"Or enter codespace name manually...",className:ie.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&o.jsx("span",{className:ie.errorHint,children:d})]})})}function N1({mode:t,environmentId:s,environments:i,onAddEnvironment:r,onUpdateEnvironment:c,onListCodespaces:d,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v,onShowToast:b}){const x=_t(),S=t==="edit",k=S&&s?i.find(ue=>ue.id===s):void 0,[w,N]=y.useState(""),[T,C]=y.useState("local"),[D,L]=y.useState(""),[A,R]=y.useState(""),[O,z]=y.useState(""),[$,X]=y.useState(""),[te,P]=y.useState(""),[re,H]=y.useState(""),[oe,E]=y.useState(""),[F,ae]=y.useState(null),pe=y.useCallback(()=>{const ue={};if(T==="local"){if(D.trim()&&(ue.host=D.trim()),A.trim()){const xe=Number(A);Number.isInteger(xe)&&(ue.port=xe)}}else if(T==="ssh"){if(ue.host=D.trim(),O.trim()&&(ue.user=O.trim()),A.trim()){const xe=Number(A);Number.isInteger(xe)&&(ue.sshPort=xe)}$.trim()&&(ue.identityFile=$.trim())}else T==="docker"?(te.trim()&&(ue.image=te.trim()),re.trim()&&(ue.repo=re.trim())):T==="codespace"&&(ue.codespaceName=oe.trim());return ue},[T,D,A,O,$,te,re,oe]),de=()=>!(!w.trim()||T==="ssh"&&!D.trim()||T==="codespace"&&!oe.trim()||(T==="local"||T==="ssh")&&!yp(A)),Oe=()=>{de()&&(r(w.trim(),T,pe()),b==null||b("Environment added successfully","success"),x(Do,{replace:!0}))},ke=()=>{x(s?Si(s):Do)},Ee=y.useCallback((ue,xe)=>{if(!k||!s)return;const me=bp(k.adapterConfig),Be=xe.trim();Be?me[ue]=Be:delete me[ue],c(s,{adapterConfig:me})},[k,s,c]),ze=y.useCallback((ue,xe)=>{if(!k||!s)return;const me=bp(k.adapterConfig);if(xe.trim()){const Be=Number(xe);Number.isInteger(Be)&&Be>=Yc&&Be<=Jc&&(me[ue]=Be)}else delete me[ue];c(s,{adapterConfig:me})},[k,s,c]);if(S){if(!k)return o.jsxs("div",{className:ie.container,children:[o.jsxs("div",{className:ie.header,children:[o.jsx("div",{className:ie.headerTitle,children:o.jsx("span",{className:ie.badge,children:"edit environment"})}),o.jsx("div",{className:ie.headerActions,children:o.jsx("button",{onClick:ke,className:ie.btnGhost,children:"Back"})})]}),o.jsx("div",{className:ie.body,children:o.jsx("div",{className:ie.formContent,children:o.jsx("span",{className:ie.readOnlyValue,children:"Environment not found"})})})]});const ue=bp(k.adapterConfig);return o.jsxs("div",{className:ie.container,"data-testid":"env-edit-panel",children:[o.jsxs("div",{className:ie.header,children:[o.jsx("div",{className:ie.headerTitle,children:o.jsx("span",{className:ie.badge,children:"edit environment"})}),o.jsx("div",{className:ie.headerActions,children:o.jsx("button",{onClick:ke,className:ie.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),o.jsx("div",{className:ie.body,children:o.jsxs("div",{className:ie.formContent,children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Name"}),o.jsx(ln,{value:k.displayName,onSave:xe=>{s&&c(s,{displayName:xe})},validate:xe=>xe.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:F,onActivate:ae,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Adapter Type"}),o.jsx("span",{className:ie.readOnlyValue,"data-testid":"env-edit-adapter-type",children:k.adapterType})]}),k.adapterType==="local"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Host"}),o.jsx(ln,{value:String(ue.host??""),onSave:xe=>Ee("host",xe),mode:"edit",fieldId:"host",activeFieldId:F,onActivate:ae,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Port"}),o.jsx(ln,{value:String(ue.port??""),onSave:xe=>ze("port",xe),validate:xe=>yp(xe)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:F,onActivate:ae,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),k.adapterType==="ssh"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Host"}),o.jsx(ln,{value:String(ue.host??""),onSave:xe=>Ee("host",xe),validate:xe=>xe.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:F,onActivate:ae,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"User"}),o.jsx(ln,{value:String(ue.user??""),onSave:xe=>Ee("user",xe),mode:"edit",fieldId:"user",activeFieldId:F,onActivate:ae,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"SSH Port"}),o.jsx(ln,{value:String(ue.sshPort??""),onSave:xe=>ze("sshPort",xe),validate:xe=>yp(xe)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:F,onActivate:ae,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Identity File"}),o.jsx(ln,{value:String(ue.identityFile??""),onSave:xe=>Ee("identityFile",xe),mode:"edit",fieldId:"identityFile",activeFieldId:F,onActivate:ae,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),k.adapterType==="docker"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Image"}),o.jsx(ln,{value:String(ue.image??""),onSave:xe=>Ee("image",xe),mode:"edit",fieldId:"image",activeFieldId:F,onActivate:ae,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Repo"}),o.jsx(ln,{value:String(ue.repo??""),onSave:xe=>Ee("repo",xe),mode:"edit",fieldId:"repo",activeFieldId:F,onActivate:ae,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),k.adapterType==="codespace"&&o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Codespace Name"}),o.jsx(ln,{value:String(ue.codespaceName??""),onSave:xe=>Ee("codespaceName",xe),validate:xe=>xe.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:F,onActivate:ae,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return o.jsxs("div",{className:ie.container,"data-testid":"env-create-panel",children:[o.jsxs("div",{className:ie.header,children:[o.jsx("div",{className:ie.headerTitle,children:o.jsx("span",{className:ie.badge,children:"new environment"})}),o.jsxs("div",{className:ie.headerActions,children:[o.jsx("button",{onClick:Oe,disabled:!de(),className:ie.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),o.jsx("button",{onClick:ke,className:ie.btnGhost,children:"Cancel"})]})]}),o.jsx("div",{className:ie.body,children:o.jsxs("div",{className:ie.formContent,children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-name",children:"Name"}),o.jsx("input",{id:"env-create-name",type:"text",value:w,onChange:ue=>N(ue.target.value),placeholder:"Environment name...",autoFocus:!0,className:ie.nameInput,"data-testid":"env-create-name",onKeyDown:ue=>{ue.key==="Enter"&&de()&&Oe()}})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),o.jsxs("select",{id:"env-create-adapter",value:T,onChange:ue=>{C(ue.target.value),ue.target.value==="codespace"&&d()},className:ie.adapterSelect,"data-testid":"env-create-adapter",children:[o.jsx("option",{value:"local",children:"local"}),o.jsx("option",{value:"ssh",children:"ssh"}),o.jsx("option",{value:"docker",children:"docker"}),o.jsx("option",{value:"codespace",children:"codespace"})]})]}),T==="local"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-host",children:"Host"}),o.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:ue=>L(ue.target.value),placeholder:"Host (optional)...",className:ie.fieldInput,"data-testid":"env-create-host"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-port",children:"Port"}),o.jsx("input",{id:"env-create-port",type:"number",min:Yc,max:Jc,value:A,onChange:ue=>R(ue.target.value),placeholder:"Port (optional)...",className:ie.fieldInput,"data-testid":"env-create-port"})]})]}),T==="ssh"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-host",children:"Host"}),o.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:ue=>L(ue.target.value),placeholder:"Host (required)...",className:ie.fieldInput,"data-testid":"env-create-host"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-user",children:"User"}),o.jsx("input",{id:"env-create-user",type:"text",value:O,onChange:ue=>z(ue.target.value),placeholder:"User (optional)...",className:ie.fieldInput,"data-testid":"env-create-user"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-port",children:"SSH Port"}),o.jsx("input",{id:"env-create-port",type:"number",min:Yc,max:Jc,value:A,onChange:ue=>R(ue.target.value),placeholder:"SSH port (optional)...",className:ie.fieldInput,"data-testid":"env-create-port"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-identity",children:"Identity File"}),o.jsx("input",{id:"env-create-identity",type:"text",value:$,onChange:ue=>X(ue.target.value),placeholder:"Identity file (optional)...",className:ie.fieldInput,"data-testid":"env-create-identity"})]})]}),T==="docker"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-image",children:"Image"}),o.jsx("input",{id:"env-create-image",type:"text",value:te,onChange:ue=>P(ue.target.value),placeholder:"Image (optional)...",className:ie.fieldInput,"data-testid":"env-create-image"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-repo",children:"Repo"}),o.jsx("input",{id:"env-create-repo",type:"text",value:re,onChange:ue=>H(ue.target.value),placeholder:"Repo (optional)...",className:ie.fieldInput,"data-testid":"env-create-repo"})]})]}),T==="codespace"&&o.jsx(_B,{codespaceName:oe,onCodespaceNameChange:E,envName:w,onEnvNameChange:N,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v})]})})]})}const kB="_group_1iprv_1",SB="_groupTitle_1iprv_8",TB="_shortcutList_1iprv_17",wB="_shortcutRow_1iprv_23",jB="_keys_1iprv_36",NB="_kbd_1iprv_43",CB="_description_1iprv_60",yi={group:kB,groupTitle:SB,shortcutList:TB,shortcutRow:wB,keys:jB,kbd:NB,description:CB},EB=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"},{keys:["3"],description:"Switch to Findings tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Chat",shortcuts:[{keys:["Enter"],description:"Send message (when input is focused)"}]}];function AB(){return o.jsxs("section",{className:ge.section,"data-testid":"keyboard-shortcuts-panel",children:[o.jsx("h3",{className:ge.sectionTitle,children:"Keyboard Shortcuts"}),o.jsx("p",{className:ge.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),EB.map(t=>o.jsxs("div",{className:yi.group,children:[o.jsx("h4",{className:yi.groupTitle,children:t.title}),o.jsx("div",{className:yi.shortcutList,children:t.shortcuts.map(s=>o.jsxs("div",{className:yi.shortcutRow,children:[o.jsx("span",{className:yi.keys,children:s.keys.map(i=>o.jsx("kbd",{className:yi.kbd,children:i},i))}),o.jsx("span",{className:yi.description,children:s.description})]},s.description))})]},t.title))]})}const DB=[{key:"claude",label:"Claude",description:"Forward Claude credentials for AI agent access.",options:[{value:"off",label:"Off"},{value:"subscription",label:"Subscription"},{value:"api_key",label:"API Key"}]},{key:"github",label:"GitHub",description:"Forward GITHUB_TOKEN and GH_TOKEN for git operations.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"copilot",label:"Copilot",description:"Forward Copilot tokens (COPILOT_GITHUB_TOKEN, CLI config).",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"codex",label:"Codex",description:"Forward OPENAI_API_KEY for Codex/OpenAI access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"goose",label:"Goose",description:"Forward Goose config and API keys for Goose agent access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]}];function RB({credentialProviders:t,onUpdateCredentialProviders:s}){const i=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return o.jsxs("section",{className:ge.section,children:[o.jsx("h3",{className:ge.sectionTitle,children:"Credential Providers"}),o.jsx("p",{className:ge.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),o.jsx("div",{className:ge.tokenList,children:DB.map(r=>o.jsxs("div",{className:ge.tokenRow,children:[o.jsx("span",{className:ge.tokenName,children:r.label}),o.jsx("span",{className:ge.tokenTarget,children:r.description}),o.jsx("select",{className:ge.select,value:t[r.key],onChange:c=>i(r.key,c.target.value),children:r.options.map(c=>o.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const MB="_container_10efq_1",IB="_header_10efq_7",OB="_list_10efq_105",LB="_card_10efq_111",BB="_cardHeader_10efq_125",zB="_cardTitle_10efq_135",UB="_defaultBadge_10efq_141",$B="_cardActions_10efq_155",PB="_description_10efq_160",HB="_meta_10efq_166",VB="_empty_10efq_212",qB="_typeBadge_10efq_362",Jn={container:MB,header:IB,list:OB,card:LB,cardHeader:BB,cardTitle:zB,defaultBadge:UB,cardActions:$B,description:PB,meta:HB,empty:VB,typeBadge:qB};function GB({personas:t,appDefaultPersonaId:s,onDeletePersona:i,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await i(v),p(null)};return o.jsxs("div",{className:Jn.container,children:[o.jsxs("div",{className:Jn.header,children:[o.jsx("h2",{children:"Personas"}),o.jsx(Js,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?o.jsx("p",{className:Jn.empty,children:"No personas yet. Create one to get started."}):o.jsx("div",{className:Jn.list,children:t.map(v=>{const b=s===v.id,x=v.type==="script";return o.jsxs("div",{className:Jn.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),d(v.id))},children:[o.jsxs("div",{className:Jn.cardHeader,children:[o.jsxs("span",{className:Jn.cardTitle,children:[o.jsx("strong",{children:v.name}),o.jsx("span",{className:Jn.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:x?"Script":"Agent"}),b&&o.jsx("span",{className:Jn.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),o.jsxs("div",{className:Jn.cardActions,onClick:S=>S.stopPropagation(),children:[!b&&o.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>{r(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),o.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),o.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&o.jsx("p",{className:Jn.description,children:v.description}),o.jsxs("div",{className:Jn.meta,children:[v.runtime&&o.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&o.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&o.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),o.jsx(wi,{isOpen:u!==null,title:"Delete Persona?",description:`"${(m==null?void 0:m.name)??""}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const FB="_container_uy08i_1",ZB="_header_uy08i_7",KB="_count_uy08i_13",YB="_presets_uy08i_18",JB="_presetButton_uy08i_24",WB="_filterInput_uy08i_41",XB="_groups_uy08i_53",QB="_group_uy08i_53",e8="_groupHeader_uy08i_68",t8="_groupName_uy08i_77",n8="_groupCount_uy08i_81",s8="_toolList_uy08i_87",a8="_toolItem_uy08i_95",i8="_toolName_uy08i_103",mn={container:FB,header:ZB,count:KB,presets:YB,presetButton:JB,filterInput:WB,groups:XB,group:QB,groupHeader:e8,groupName:t8,groupCount:n8,toolList:s8,toolItem:a8,toolName:i8},o8=(()=>{const t=new Map;for(const s of ox){const i=s==="get_version_status"?"version":s.split("_")[0];t.has(i)||t.set(i,[]),t.get(i).push(s)}return[...t.entries()].sort(([s],[i])=>s.localeCompare(i)).map(([s,i])=>({group:s,tools:i.sort()}))})(),r8=[{name:"default",label:"Default",tools:rx},{name:"worker",label:"Worker",tools:pT},{name:"orchestrator",label:"Orchestrator",tools:mT},{name:"admin",label:"Admin",tools:hT}];function Vb({selectedTools:t,onChange:s,disabled:i}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.useCallback(v=>{if(i)return;const b=new Set(d);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[d,s,i]),p=y.useCallback((v,b)=>{if(i)return;const x=new Set(d);for(const S of v)b?x.delete(S):x.add(S);s([...x].sort())},[d,s,i]),m=y.useCallback(v=>{i||s([...v].sort())},[s,i]),g=r.toLowerCase();return o.jsxs("div",{className:mn.container,"data-testid":"mcp-tool-selector",children:[o.jsx("div",{className:mn.header,children:o.jsx("span",{className:mn.count,children:t.length===0?`Using default (${rx.length} tools)`:`${t.length} of ${ox.size} tools selected`})}),o.jsxs("div",{className:mn.presets,"data-testid":"mcp-tool-presets",children:[r8.map(v=>o.jsx("button",{type:"button",className:mn.presetButton,disabled:i,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),o.jsx("button",{type:"button",className:mn.presetButton,disabled:i,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),o.jsx("input",{type:"text",className:mn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:i,"data-testid":"mcp-tool-filter"}),o.jsx("div",{className:mn.groups,children:o8.map(({group:v,tools:b})=>{const x=g?b.filter(k=>k.toLowerCase().includes(g)):b;if(x.length===0)return null;const S=x.every(k=>d.has(k));return o.jsxs("div",{className:mn.group,"data-testid":`tool-group-${v}`,children:[o.jsxs("label",{className:mn.groupHeader,children:[o.jsx("input",{type:"checkbox",checked:S,onChange:()=>p(x,S),disabled:i,"data-testid":`group-toggle-${v}`}),o.jsx("span",{className:mn.groupName,children:v}),o.jsxs("span",{className:mn.groupCount,children:["(",x.filter(k=>d.has(k)).length,"/",x.length,")"]})]}),o.jsx("div",{className:mn.toolList,children:x.map(k=>o.jsxs("label",{className:mn.toolItem,children:[o.jsx("input",{type:"checkbox",checked:d.has(k),onChange:()=>u(k),disabled:i,"data-testid":`tool-${k}`}),o.jsx("span",{className:mn.toolName,children:k})]},k))})]},v)})})]})}const l8="_nav_1bhou_1",c8="_tab_1bhou_24",d8="_tabIcon_1bhou_62",u8="_tabActive_1bhou_68",Bc={nav:l8,tab:c8,tabIcon:d8,tabActive:u8},Ks=[{path:"credentials",label:"Credentials",icon:o.jsx(S2,{size:Bt})},{path:"personas",label:"Personas",icon:o.jsx(W2,{size:Bt})},{path:"appearance",label:"Appearance",icon:o.jsx(U2,{size:Bt})},{path:"shortcuts",label:"Shortcuts",icon:o.jsx(w2,{size:Bt})},{path:"about",label:"About",icon:o.jsx(sm,{size:Bt})}];function f8(){var u;const t=Zt(),s=_t(),i=y.useRef(null),r=((u=Ks.find(p=>{const m=`${Eo}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??Ks[0].path,c=y.useCallback(p=>{s(`${Eo}/${p}`)},[s]),d=y.useCallback(p=>{var S,k;const m=(S=i.current)==null?void 0:S.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(w=>w===document.activeElement),v=g>=0?g:Ks.findIndex(w=>w.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%Ks.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+Ks.length)%Ks.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=Ks.length-1;else return;const x=Ks[b].path;s(`${Eo}/${x}`),(k=m[b])==null||k.focus()},[r,s]);return o.jsx("nav",{className:Bc.nav,ref:i,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:Ks.map(p=>{const m=p.path===r;return o.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Bc.tab} ${m?Bc.tabActive:""}`,onClick:()=>c(p.path),children:[o.jsx("span",{className:Bc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}function p8({tasks:t,taskStatusById:s,sessionStatusByTaskId:i}){const r=new Map;for(const d of t)if(d.parentTaskId){const u=r.get(d.parentTaskId);u?u.push(d):r.set(d.parentTaskId,[d])}const c=new Map(oy.map(d=>[d,[]]));for(const d of t){const u=rl(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(k=>s.get(k)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(k=>k.status==="complete").length;let b;if(u==="paused"&&i){const k=i.get(d.id);k==="idle"?b="Needs input":k==="completed"&&(b="Ready to complete")}const x={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},S=c.get(u);S?S.push(x):c.get("not_started").push(x)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return oy.map(d=>{const u=za(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const m8="_boardContainer_1c4y1_1",h8="_column_1c4y1_17",g8="_columnHeader_1c4y1_34",v8="_columnIcon_1c4y1_47",y8="_columnLabel_1c4y1_52",b8="_columnCount_1c4y1_57",x8="_cardList_1c4y1_67",_8="_emptyPlaceholder_1c4y1_76",k8="_card_1c4y1_67",S8="_cardHeader_1c4y1_107",T8="_cardStatusIcon_1c4y1_113",w8="_cardTitle_1c4y1_119",j8="_cardBadges_1c4y1_127",N8="_badge_1c4y1_134",C8="_blockedBadge_1c4y1_146",E8="_childBadge_1c4y1_151",A8="_depBadge_1c4y1_155",D8="_parentBadge_1c4y1_159",R8="_pausedSubBadge_1c4y1_166",M8="_personaBadge_1c4y1_170",I8="_envBadge_1c4y1_174",O8="_emptyCta_1c4y1_178",L8="_ctaButton_1c4y1_188",B8="_ctaDescription_1c4y1_204",st={boardContainer:m8,column:h8,columnHeader:g8,columnIcon:v8,columnLabel:y8,columnCount:b8,cardList:x8,emptyPlaceholder:_8,card:k8,cardHeader:S8,cardStatusIcon:T8,cardTitle:w8,cardBadges:j8,badge:N8,blockedBadge:C8,childBadge:E8,depBadge:A8,parentBadge:D8,pausedSubBadge:R8,personaBadge:M8,envBadge:I8,emptyCta:O8,ctaButton:L8,ctaDescription:B8};function z8({workspaceId:t,environmentId:s,tasks:i,sessions:r,personas:c,environments:d}){const u=_t(),p=y.useMemo(()=>i.filter(x=>x.workspaceId===t),[i,t]),m=y.useMemo(()=>new Map(i.map(x=>[x.id,x.status])),[i]),g=y.useMemo(()=>new Map(p.map(x=>[x.id,x])),[p]),v=y.useMemo(()=>{const x=new Map(r.map(C=>[C.id,C])),S=new Map(c.map(C=>[C.id,C])),k=new Map(d.map(C=>[C.id,C])),w=new Map,N=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const D=x.get(C.latestSessionId);if(D){if(w.set(C.id,D.endReason||D.status),D.personaId){const L=S.get(D.personaId);L&&N.set(C.id,L.name)}if(D.environmentId){const L=k.get(D.environmentId);L&&T.set(C.id,L.displayName)}}}return{sessionStatusByTaskId:w,personaNameByTaskId:N,environmentNameByTaskId:T}},[p,r,c,d]),b=y.useMemo(()=>p8({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?o.jsxs("div",{className:st.emptyCta,"data-testid":"board-empty-cta",children:[o.jsx("button",{className:st.ctaButton,onClick:()=>u(Ci(t,void 0,s)),children:"Create Task"}),o.jsx("div",{className:st.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):o.jsx("div",{className:st.boardContainer,"data-testid":"board-container",children:b.map(x=>o.jsxs("section",{className:st.column,"data-testid":`board-column-${x.status}`,"aria-label":`${x.label}, ${x.tasks.length} ${x.tasks.length===1?"task":"tasks"}`,children:[o.jsxs("div",{className:st.columnHeader,children:[o.jsx("span",{className:st.columnIcon,style:{color:x.style.color},children:x.style.icon}),o.jsx("span",{className:st.columnLabel,children:x.label}),o.jsx("span",{className:st.columnCount,"data-testid":`board-count-${x.status}`,children:x.tasks.length})]}),o.jsx("div",{className:st.cardList,children:x.tasks.length===0?o.jsx("div",{className:st.emptyPlaceholder,children:"No tasks"}):o.jsx(ps,{mode:"popLayout",children:x.tasks.map(S=>o.jsx(Rt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:o.jsx(U8,{boardTask:S,tasksById:g,personaName:v.personaNameByTaskId.get(S.task.id),envName:v.environmentNameByTaskId.get(S.task.id),onClick:()=>u(In(S.task.id,void 0,t,s))})},S.task.id))})})]},x.status))})}function U8({boardTask:t,tasksById:s,personaName:i,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=za(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return o.jsxs("div",{className:st.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),c())},children:[o.jsxs("div",{className:st.cardHeader,children:[o.jsx("span",{className:st.cardStatusIcon,style:{color:v.color},children:v.icon}),o.jsx("span",{className:st.cardTitle,children:d.title})]}),o.jsxs("div",{className:st.cardBadges,children:[b&&o.jsx("span",{className:`${st.badge} ${st.parentBadge}`,title:b.title,children:b.title}),p>0&&o.jsxs("span",{className:`${st.badge} ${st.childBadge}`,children:[m,"/",p]}),u&&o.jsx("span",{className:`${st.badge} ${st.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&o.jsx("span",{className:`${st.badge} ${st.depBadge}`,children:"dep"}),g&&o.jsx("span",{className:`${st.badge} ${st.pausedSubBadge}`,children:g}),i&&o.jsx("span",{className:`${st.badge} ${st.personaBadge}`,children:i}),r&&o.jsx("span",{className:`${st.badge} ${st.envBadge}`,children:r})]})]})}const $8="_formContent_ymnez_1",P8="_section_ymnez_13",H8="_label_ymnez_19",V8="_titleInput_ymnez_26",q8="_descriptionTextarea_ymnez_58",G8="_selectField_ymnez_94",F8="_checkboxRow_ymnez_128",Z8="_checkboxLabel_ymnez_141",K8="_fieldError_ymnez_146",yt={formContent:$8,section:P8,label:H8,titleInput:V8,descriptionTextarea:q8,selectField:G8,checkboxRow:F8,checkboxLabel:Z8,fieldError:K8};function Y8(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.environmentId)??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const J8=100;function W8({values:t,onChange:s,environments:i,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return o.jsxs("div",{className:yt.formContent,children:[o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-name",children:"Name"}),o.jsx("input",{id:"ws-name",className:yt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:J8,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&o.jsx("span",{className:yt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-description",children:"Description"}),o.jsx("textarea",{id:"ws-description",className:yt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-repo",children:"Repository URL"}),o.jsx("input",{id:"ws-repo",className:yt.titleInput,type:"text",value:t.repoUrl,onChange:m=>p("repoUrl",m.target.value),placeholder:"https://github.com/org/repo",disabled:d,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&o.jsx("span",{className:yt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-environment",children:"Environment"}),o.jsxs("select",{id:"ws-environment",className:yt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[o.jsx("option",{value:"",children:"Select environment…"}),i.map(m=>o.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&o.jsx("span",{className:yt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-persona",children:"Default Persona"}),o.jsxs("select",{id:"ws-persona",className:yt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[o.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>o.jsx("option",{value:m.id,children:m.name},m.id))]})]}),o.jsx("div",{className:yt.section,children:o.jsxs("label",{className:yt.checkboxRow,children:[o.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),o.jsx("span",{className:yt.checkboxLabel,children:"Enable worktree isolation"})]})}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-workdir",children:"Working Directory"}),o.jsx("input",{id:"ws-workdir",className:yt.titleInput,type:"text",value:t.workingDirectory,onChange:m=>p("workingDirectory",m.target.value),placeholder:"Default (server default)",disabled:d,"data-testid":"workspace-form-workdir"})]})]})}const C1=y.createContext(void 0),X8=4e3;function Q8({children:t}){const[s,i]=y.useState([]),r=y.useRef(0),c=y.useCallback(u=>{i(p=>p.filter(m=>m.id!==u))},[]),d=y.useCallback((u,p="info",m=X8)=>{const g=`toast-${++r.current}`;i(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return o.jsx(C1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function Tn(){const t=y.useContext(C1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const Qp="grackle-theme",E1="grackle-prefer-system",A1="(prefers-color-scheme: dark)";let qr=[],Wc;function xp(){Wc=void 0;for(const t of qr)t()}function em(){return typeof window>"u"?!1:window.matchMedia(A1).matches}function Jr(){if(typeof localStorage>"u")return Pb;try{const t=localStorage.getItem(Qp);if(t!==null&&w1.has(t))return t}catch{}return Pb}function ud(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(E1)==="true"}catch{return!1}}function tm(t){return jd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function D1(t,s){const i=Xp(t);if(i!=null&&i.variantDarkId)return s&&i.variantLightId?em()?i.variantDarkId:i.variantLightId:i.variantDarkId;if(i!=null&&i.hidden&&s){const r=tm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return em()?r.variantDarkId:r.variantLightId}return t}function ko(t,s,i=!1){i&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=D1(t,s),i&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&ko(Jr(),ud());function ez(){return Wc===void 0&&(Wc={themeId:Jr(),systemDark:em(),preferSystem:ud()}),Wc}function tz(t){return qr=[...qr,t],()=>{qr=qr.filter(s=>s!==t)}}function nz(){const t=y.useSyncExternalStore(tz,ez),{themeId:s,preferSystem:i}=t,r=D1(s,i),c=y.useCallback(u=>{if(w1.has(u)){try{localStorage.setItem(Qp,u)}catch{}ko(u,ud(),!0),xp()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(E1,u?"true":"false")}catch{}if(u){const p=Jr(),m=Xp(p);if(m!=null&&m.hidden){const g=tm(p);if(g)try{localStorage.setItem(Qp,g.id)}catch{}}}ko(Jr(),u,!0),xp()},[]);return y.useEffect(()=>{ko(s,i)},[s,i]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(A1),p=()=>{const m=Jr(),g=ud();if(g){const v=Xp(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&ko(m,g),v!=null&&v.hidden){const b=tm(m);b!=null&&b.variantDarkId&&b.variantLightId&&ko(m,g)}}xp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:i,setPreferSystem:d}}const R1=y.createContext(void 0);function sz({children:t}){const s=nz();return o.jsx(R1.Provider,{value:s,children:t})}function M1(){const t=y.useContext(R1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const I1=y.createContext(void 0),O1=y.createContext(void 0);function az({children:t}){const[s,i]=y.useState(void 0),r=y.useCallback(c=>{i(c)},[]);return o.jsx(O1.Provider,{value:r,children:o.jsx(I1.Provider,{value:s,children:t})})}function iz(){return y.useContext(I1)}function oz(){const t=y.useContext(O1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const Qm=y.createContext(void 0);function ft(){const t=y.useContext(Qm);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function L1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function B1(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function rz(t){return L1(t)&&typeof t.sessionId=="string"&&typeof t.eventType=="string"&&typeof t.timestamp=="string"&&typeof t.content=="string"&&(t.raw===void 0||typeof t.raw=="string")}const lz=new Set(["off","subscription","api_key"]),zc=new Set(["off","on"]);function cz(t){return L1(t)&&lz.has(t.claude)&&zc.has(t.github)&&zc.has(t.copilot)&&zc.has(t.codex)&&zc.has(t.goose)}function z1(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 U1(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 _o=5e3;function dz(t,s){const i=[];let r=t;const c=new Set;for(;r&&s.has(r)&&!c.has(r);){c.add(r);const d=s.get(r);i.unshift(d),r=d.parentTaskId||void 0}return i}const na={label:"Home",url:Ti};function uz(t){return t?[na,{label:"Settings",url:Eo},{label:t,url:void 0}]:[na,{label:"Settings",url:void 0}]}const eh={label:"Environments",url:Do};function fz(){return[na,{label:"Environments",url:void 0}]}function pz(){return[na,{label:"New Chat",url:void 0}]}function mz(t){return[na,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function hz(t,s,i,r){const c=i.find(u=>u.id===t),d=r.find(u=>u.id===s);return[na,eh,{label:(d==null?void 0:d.displayName)??"Environment",url:Si(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function gz(t,s,i,r,c){const d=dz(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?i.find(S=>S.id===p):void 0,g=s??(m==null?void 0:m.environmentId),v=g?r.find(S=>S.id===g):void 0,b=[na];v&&g&&(b.push(eh),b.push({label:v.displayName,url:Si(g)})),m&&g&&b.push({label:m.name,url:Ua(m.id,g)});for(let S=0;S<d.length-1;S++)b.push({label:d[S].title,url:In(d[S].id,void 0,p,g)});const x=d[d.length-1];return b.push({label:(x==null?void 0:x.title)??t,url:void 0}),b}const vz={label:"Findings",url:bd};function yz(){return[na,{label:"Findings",url:void 0}]}function $1(t,s,i,r,c){const d=[na];if(s&&i){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===i);d.push(eh),p&&d.push({label:p.displayName,url:Si(i)}),u&&d.push({label:u.name,url:Ua(s,i)}),d.push({label:"Findings",url:iN(s,i)})}else d.push(vz);return d.push({label:t,url:void 0}),d}function th(t){const s=[];for(const i of t){const r=s[s.length-1];i.eventType==="text"&&(r==null?void 0:r.eventType)==="text"?s[s.length-1]={...r,content:r.content+i.content}:s.push(i)}return s}function Uc(t){if(typeof t.id=="string")return t.id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const i=t.item;if(i&&typeof i.id=="string")return i.id}function bz(t){if(typeof t.tool_use_id=="string")return t.tool_use_id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const i=t.item;if(i&&typeof i.id=="string")return i.id}function nh(t){const s=new Map;for(const v of t)if(v.raw)try{s.set(v,JSON.parse(v.raw))}catch{}const i=new Map;for(const v of t){if(v.eventType!=="tool_use")continue;const b=s.get(v),x=b?Uc(b):void 0;if(x)try{const S=JSON.parse(v.content);i.set(x,{tool:S.tool,args:S.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,b)=>{if(v.eventType!=="tool_result")return v;const x=s.get(v),S=x?bz(x):void 0;if(!S)return v;const k=i.get(S);if(!k)return v;r.add(S),c.add(b);let w;const N=v.content.trim();if(N.startsWith("{"))try{const T=JSON.parse(N);typeof T.detailedContent=="string"&&(w=T.detailedContent)}catch{}return{...v,toolUseCtx:{...k,detailedResult:w}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const b=s.get(d[v]),x=b?Uc(b):void 0;x&&r.has(x)||u.push(v)}const p=[];for(let v=0;v<d.length;v++)d[v].eventType!=="tool_result"||c.has(v)||p.push(v);let m=0;for(const v of u){for(;m<p.length&&p[m]<v;)m++;if(m>=p.length)break;const b=p[m];if(b!==v+1)continue;const x=d[v],S=d[b];let k;try{const w=JSON.parse(x.content);k={tool:w.tool,args:w.args}}catch{}if(k){let w;const N=S.content.trim();if(N.startsWith("{"))try{const D=JSON.parse(N);typeof D.detailedContent=="string"&&(w=D.detailedContent)}catch{}d[b]={...S,toolUseCtx:{...k,detailedResult:w}},c.add(b);const T=s.get(x),C=T?Uc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(x,{...T??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const b=s.get(v);if(!b)return!0;const x=Uc(b);if(x&&r.has(x))return!1;const S=b.__seqId;return!(S&&r.has(S))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let b=!1;for(let x=v+1;x<g.length;x++)if(g[x].eventType!=="tool_use"){b=!0;break}b&&(g[v]={...g[v],settled:!0})}return g}function xz(t,s,i){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=P1(s),d=s.filter(m=>nm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||nm(m,c)).length,p=i.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function P1(t){const s=new Map;for(const i of t)s.set(i.id,i.status);return s}function nm(t,s){return t.dependsOn.some(i=>s.get(i)!=="complete")}function _z(t,s){var u;const i=new Map;for(const p of s)i.set(p.id,p);const r=P1(t),c=[];for(const p of t){const m=p.workspaceId?((u=i.get(p.workspaceId))==null?void 0:u.name)??"Unknown":"Unknown";p.status==="failed"?c.push({task:p,reason:"failed",workspaceName:m}):nm(p,r)?c.push({task:p,reason:"blocked",workspaceName:m}):p.status==="paused"&&c.push({task:p,reason:"paused",workspaceName:m})}const d={failed:0,blocked:1,paused:2};return c.sort((p,m)=>(d[p.reason]??3)-(d[m.reason]??3)),c}function kz(t,s){const i=new Map;for(const r of s)i.set(r.id,r);return t.filter(r=>r.status==="running"||r.status==="idle"||r.status==="waiting").map(r=>{var c;return{session:r,environmentName:((c=i.get(r.environmentId))==null?void 0:c.displayName)??"Unknown"}})}function Sz(t,s,i){const r=new Map;for(const c of s){if(!c.workspaceId)continue;let d=r.get(c.workspaceId);d||(d={totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0},r.set(c.workspaceId,d)),d.totalTasks+=1,c.status==="complete"?d.completedTasks+=1:c.status==="working"?d.workingTasks+=1:c.status==="failed"&&(d.failedTasks+=1)}return t.map(c=>{const d=r.get(c.id)??{totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0};return{workspace:c,totalTasks:d.totalTasks,completedTasks:d.completedTasks,workingTasks:d.workingTasks,failedTasks:d.failedTasks}})}const ks=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
274
+ `)}function X6({events:t,formatForClipboard:s}){const[i,r]=y.useState(!1),[c,d]=y.useState(new Set),u=y.useRef(void 0),p=y.useMemo(()=>c.size,[c]),m=y.useCallback(k=>{r(!0),k!==void 0?(d(new Set([k])),u.current=k):(d(new Set),u.current=void 0)},[]),g=y.useCallback(()=>{r(!1),d(new Set),u.current=void 0},[]),v=y.useCallback((k,w)=>{if(w&&u.current!==void 0){const N=Math.min(u.current,k),T=Math.max(u.current,k);d(C=>{const D=new Set(C);for(let L=N;L<=T;L++)L<t.length&&ol(t[L])&&D.add(L);return D})}else d(N=>{const T=new Set(N);return T.has(k)?T.delete(k):T.add(k),T.size===0?(r(!1),u.current=void 0):u.current=k,T})},[t]),b=y.useCallback(()=>{const k=new Set;for(let w=0;w<t.length;w++)ol(t[w])&&k.add(w);d(k)},[t]),x=y.useCallback(()=>{d(new Set)},[]),S=y.useCallback(async()=>{const w=[...c].sort((T,C)=>T-C).filter(T=>T<t.length).map(T=>t[T]);if(w.length===0)return!1;const N=s(w);try{return await navigator.clipboard.writeText(N),!0}catch{return!1}},[c,t,s]);return{isSelecting:i,selectedIndices:c,selectedCount:p,enterSelectionMode:m,cancelSelection:g,toggleEvent:v,selectAll:b,deselectAll:x,copySelected:S}}const Q6="_wrapper_1cdza_1",e4="_scrollContainer_1cdza_9",t4="_selectingPadding_1cdza_16",n4="_toolbar_1cdza_20",s4="_directionToggle_1cdza_27",a4="_scrollToAnchor_1cdza_65",i4="_scrollToAnchorBottom_1cdza_89",o4="_scrollToAnchorTop_1cdza_93",r4="_eventOverflowWarning_1cdza_97",Ys={wrapper:Q6,scrollContainer:e4,selectingPadding:t4,toolbar:n4,directionToggle:s4,scrollToAnchor:a4,scrollToAnchorBottom:i4,scrollToAnchorTop:o4,eventOverflowWarning:r4};function l4(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 g1="grackle-stream-direction";function c4(){try{return localStorage.getItem(g1)==="reversed"}catch{return!1}}function d4({eventsDropped:t}){return t<=0?o.jsx(o.Fragment,{}):o.jsxs("div",{className:Ys.eventOverflowWarning,role:"alert",children:[o.jsx(am,{size:en,"aria-hidden":"true"})," ",t.toLocaleString()," older event",t===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function Jm({events:t,eventsDropped:s,emptyState:i,onShowToast:r}){const c=y.useRef(null),[d,u]=y.useState(c4),p=KM(),m=X6({events:t,formatForClipboard:W6}),g=y.useMemo(()=>t.filter(ol).length,[t]),v=y.useMemo(()=>d?[...t].reverse():t,[t,d]),{isAtAnchor:b,scrollToAnchor:x}=K6({scrollRef:c,contentLength:t.length,isReversed:d,paused:m.isSelecting}),S=()=>{const T=!d;u(T);try{localStorage.setItem(g1,T?"reversed":"default")}catch{}};y.useEffect(()=>{if(!m.isSelecting)return;const T=C=>{C.key==="Escape"&&m.cancelSelection()};return window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T)}},[m.isSelecting,m.cancelSelection]);const k=y.useCallback(async()=>{await m.copySelected()&&(r==null||r(`Copied ${m.selectedCount} message${m.selectedCount===1?"":"s"} to clipboard`,"success"))},[m,r]),w=p?0:.2,N=d?-8:8;return o.jsxs("div",{className:Ys.wrapper,children:[o.jsx("div",{className:Ys.toolbar,children:o.jsx(Lo,{text:d?"Showing newest first":"Showing oldest first",children:o.jsx("button",{className:Ys.directionToggle,onClick:S,"aria-label":d?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:d?o.jsx(ay,{size:en,"aria-hidden":"true"}):o.jsx(iy,{size:en,"aria-hidden":"true"})})})}),o.jsxs("div",{ref:c,className:`${Ys.scrollContainer} ${m.isSelecting?Ys.selectingPadding:""}`,"data-testid":"event-stream-scroll",children:[t.length===0&&i,o.jsx(d4,{eventsDropped:s}),o.jsx(ps,{initial:!1,children:v.map((T,C)=>{const D=d?t.length-1-C:C;return o.jsx(Rt.div,{initial:{opacity:0,y:N},animate:{opacity:1,y:0},transition:{duration:w,ease:"easeOut"},children:o.jsx(B6,{copyText:J6(T),isContentBearing:ol(T),isSelecting:m.isSelecting,isSelected:m.selectedIndices.has(D),checkboxLabel:l4(T),onSelect:()=>{m.enterSelectionMode(D)},onToggle:L=>{m.toggleEvent(D,L)},onCopied:()=>{r==null||r("Copied to clipboard","success")},children:o.jsx(kA,{event:T,toolUseCtx:T.toolUseCtx,settled:T.settled})})},`${T.sessionId}-${T.timestamp}-${D}`)})})]}),o.jsx(ps,{children:m.isSelecting&&o.jsx(G6,{selectedCount:m.selectedCount,totalSelectable:g,onSelectAll:m.selectAll,onDeselectAll:m.deselectAll,onCopy:()=>{k().catch(()=>{})},onCancel:m.cancelSelection})}),o.jsx(ps,{children:!b&&o.jsxs(Rt.button,{className:`${Ys.scrollToAnchor} ${d?Ys.scrollToAnchorTop:Ys.scrollToAnchorBottom}`,onClick:x,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[d?o.jsx(iy,{size:en,"aria-hidden":"true"}):o.jsx(ay,{size:en,"aria-hidden":"true"})," New events"]})})]})}function Wm(t){const{value:s,onSave:i,validate:r,fieldId:c,activeFieldId:d,onActivate:u,enterToSave:p=!0,trimOnSave:m=!0}=t,[g,v]=y.useState(""),[b,x]=y.useState(""),S=y.useRef(!1),k=d===c,w=y.useCallback(O=>{v(O),x("")},[]),N=y.useCallback(()=>{x("")},[]),T=y.useCallback(()=>{S.current=!1,u==null||u(null),v(""),x("")},[u]),C=y.useCallback(()=>{const O=m?g.trim():g;if(r){const $=r(g);if($){x($);return}}const z=m?s.trim():s;if(O===z){T();return}i(O),T()},[g,s,m,r,i,T]),D=y.useCallback(()=>{S.current=!0,u==null||u(c),v(s),x("")},[c,s,u]),L=y.useCallback(O=>{if(S.current){S.current=!1;return}O.relatedTarget instanceof HTMLElement&&O.relatedTarget.dataset.editAction===c||C()},[c,C]),A=y.useCallback(O=>{O.key==="Escape"?T():O.key==="Enter"&&p&&C()},[T,p,C]),R=(()=>{if(!k)return!1;const O=m?s.trim():s;return(m?g.trim():g)!==O})();return y.useEffect(()=>{!k&&(g!==""||b!=="")&&(v(""),x(""))},[k,g,b]),{isEditing:k,draft:g,error:b,isDirty:R,startEdit:D,cancelEdit:T,save:C,setDraft:w,clearError:N,handleBlur:L,handleKeyDown:A,ignoreInitialBlurRef:S}}const u4="_editFieldWrapper_yuzty_1",f4="_editInput_yuzty_10",p4="_editTextarea_yuzty_42",m4="_editSelect_yuzty_78",h4="_editError_yuzty_111",g4="_editInputInvalid_yuzty_118",v4="_editHint_yuzty_123",y4="_unsavedDot_yuzty_132",b4="_metaValueClickable_yuzty_140",x4="_editButton_yuzty_159",_4="_metaPlaceholder_yuzty_175",k4="_worktreeToggle_yuzty_180",tt={editFieldWrapper:u4,editInput:f4,editTextarea:p4,editSelect:m4,editError:h4,editInputInvalid:g4,editHint:v4,unsavedDot:y4,metaValueClickable:b4,editButton:x4,metaPlaceholder:_4,worktreeToggle:k4};function ln(t){const{value:s,onSave:i,validate:r,mode:c="edit",fieldId:d="text",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,maxLength:b,ariaLabel:x,"data-testid":S}=t,k=y.useRef(null),w=Wm({value:s,onSave:i,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(w.isEditing){const T=window.setTimeout(()=>{var C;(C=k.current)==null||C.focus()},0);return()=>window.clearTimeout(T)}},[w.isEditing]),c==="create"){const T=D=>{m==null||m(D.target.value)},C=r==null?void 0:r(s);return o.jsxs("div",{className:tt.editFieldWrapper,children:[o.jsx("input",{className:`${tt.editInput} ${C?tt.editInputInvalid:""}`,value:s,onChange:T,maxLength:b,placeholder:v,"aria-label":x,"data-testid":S?`${S}-input`:void 0}),C&&o.jsx("span",{className:tt.editError,"data-testid":"edit-error",children:C})]})}if(w.isEditing)return o.jsxs("div",{className:tt.editFieldWrapper,children:[o.jsx("input",{ref:k,className:`${tt.editInput} ${w.error?tt.editInputInvalid:""}`,value:w.draft,onChange:T=>w.setDraft(T.target.value),onBlur:w.handleBlur,onKeyDown:w.handleKeyDown,maxLength:b,placeholder:v,"aria-label":x,"data-testid":S?`${S}-input`:void 0}),w.isDirty&&o.jsx("span",{className:tt.unsavedDot,title:"Unsaved changes"}),w.error&&o.jsx("span",{className:tt.editError,"data-testid":"edit-error",children:w.error}),o.jsx("span",{className:tt.editHint,children:"Enter to save · Esc to cancel"})]});const N=g==null?void 0:g(s);return o.jsxs("span",{role:"button",tabIndex:0,className:tt.metaValueClickable,onClick:()=>w.startEdit(),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),w.startEdit())},title:"Click to edit","aria-label":x,"data-testid":S?`${S}-button`:void 0,children:[N!==void 0?N:s?o.jsx("span",{children:s}):o.jsx("span",{className:tt.metaPlaceholder,children:v||"None"}),o.jsx("span",{className:tt.editButton,"aria-hidden":"true",children:"✏️"})]})}function Wp(t){const{value:s,onSave:i,validate:r,mode:c="edit",fieldId:d="textarea",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":x}=t,S=y.useRef(null),k=Wm({value:s,onSave:i,validate:r,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(k.isEditing){const N=window.setTimeout(()=>{var T;(T=S.current)==null||T.focus()},0);return()=>window.clearTimeout(N)}},[k.isEditing]),c==="create"){const N=C=>{m==null||m(C.target.value)},T=r==null?void 0:r(s);return o.jsxs("div",{className:tt.editFieldWrapper,children:[o.jsx("textarea",{className:`${tt.editTextarea} ${T?tt.editInputInvalid:""}`,value:s,onChange:N,placeholder:v,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),T&&o.jsx("span",{className:tt.editError,"data-testid":"edit-error",children:T})]})}if(k.isEditing)return o.jsxs("div",{className:tt.editFieldWrapper,children:[o.jsx("textarea",{ref:S,className:`${tt.editTextarea} ${k.error?tt.editInputInvalid:""}`,value:k.draft,onChange:N=>k.setDraft(N.target.value),onBlur:k.handleBlur,onKeyDown:k.handleKeyDown,title:b,"aria-label":b,"data-testid":x?`${x}-input`:void 0}),k.isDirty&&o.jsx("span",{className:tt.unsavedDot,title:"Unsaved changes"}),k.error&&o.jsx("span",{className:tt.editError,"data-testid":"edit-error",children:k.error}),o.jsx("span",{className:tt.editHint,children:"Tab to save · Esc to cancel"})]});const w=g==null?void 0:g(s);return o.jsxs("span",{role:"button",tabIndex:0,className:tt.metaValueClickable,onClick:()=>k.startEdit(),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),k.startEdit())},title:"Click to edit","aria-label":b,"data-testid":x?`${x}-button`:void 0,children:[w!==void 0?w:s?o.jsx("span",{children:s}):o.jsx("span",{className:tt.metaPlaceholder,children:v||"None"}),o.jsx("span",{className:tt.editButton,"aria-hidden":"true",children:"✏️"})]})}function cd(t){var D;const{value:s,onSave:i,mode:r="edit",options:c,fieldId:d="select",activeFieldId:u,onActivate:p,onChange:m,renderDisplay:g,placeholder:v,ariaLabel:b,"data-testid":x}=t,S=y.useRef(null),k=Wm({value:s,onSave:i,fieldId:d,activeFieldId:u,onActivate:p,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(k.isEditing){const L=window.setTimeout(()=>{var A;(A=S.current)==null||A.focus()},0);return()=>window.clearTimeout(L)}},[k.isEditing]);const w=y.useCallback(L=>{const A=L.target.value;k.ignoreInitialBlurRef.current=!1,A!==s&&i(A),k.cancelEdit()},[s,i,k]),N=y.useCallback(L=>{if(k.ignoreInitialBlurRef.current){k.ignoreInitialBlurRef.current=!1;return}L.relatedTarget instanceof HTMLElement&&L.relatedTarget.dataset.editAction===d||k.cancelEdit()},[d,k]);if(r==="create")return o.jsx("select",{className:tt.editSelect,value:s,onChange:L=>m==null?void 0:m(L.target.value),"aria-label":b,"data-testid":x?`${x}-select`:void 0,children:c.map(L=>o.jsx("option",{value:L.value,children:L.label},L.value))});if(k.isEditing)return o.jsx("select",{ref:S,className:tt.editSelect,value:k.draft,onChange:w,onBlur:N,title:b,"aria-label":b,"data-testid":x?`${x}-select`:void 0,children:c.map(L=>o.jsx("option",{value:L.value,children:L.label},L.value))});const T=g==null?void 0:g(s),C=(D=c.find(L=>L.value===s))==null?void 0:D.label;return o.jsxs("button",{type:"button",className:tt.metaValueClickable,onClick:()=>k.startEdit(),title:"Click to change","aria-label":b,"data-testid":x?`${x}-button`:void 0,children:[T!==void 0?T:C?o.jsx("span",{children:C}):o.jsx("span",{className:tt.metaPlaceholder,children:v||"None"}),o.jsx("span",{className:tt.editButton,"aria-hidden":"true",children:"✏️"})]})}function S4(t){const{checked:s,onChange:i,label:r,ariaLabel:c,"data-testid":d}=t;return o.jsxs("label",{className:tt.worktreeToggle,"data-testid":d,children:[o.jsx("input",{type:"checkbox",checked:s,onChange:u=>i(u.target.checked),"aria-label":c}),o.jsx("span",{children:r})]})}const T4="_envRow_1e1r5_1",w4="_envDot_1e1r5_7",j4="_envDotGreen_1e1r5_14",N4="_envDotYellow_1e1r5_18",C4="_envDotRed_1e1r5_22",E4="_envDotGray_1e1r5_26",Co={envRow:T4,envDot:w4,envDotGreen:j4,envDotYellow:N4,envDotRed:C4,envDotGray:E4};function A4(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?Co.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?Co.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?Co.envDotRed:Co.envDotGray}function D4(t){const{value:s,onSave:i,environments:r,allowNone:c=!1,fieldId:d="environment",activeFieldId:u,onActivate:p,placeholder:m="No environment",ariaLabel:g="Environment","data-testid":v}=t,b=r.find(k=>k.id===s),x=[...c?[{value:"",label:"None"}]:[],...r.map(k=>({value:k.id,label:k.displayName}))],S=()=>{if(b)return o.jsxs("span",{className:Co.envRow,children:[o.jsx("span",{className:`${Co.envDot} ${A4(b.status)}`}),b.displayName]})};return o.jsx(cd,{value:s,onSave:i,options:x,fieldId:d,activeFieldId:u,onActivate:p,renderDisplay:S,placeholder:m,ariaLabel:g,"data-testid":v})}const R4="_nav_1snmp_1",M4="_searchForm_1snmp_8",I4="_searchInput_1snmp_15",O4="_searchButton_1snmp_33",L4="_clearButton_1snmp_68",B4="_workspaceSelect_1snmp_85",z4="_listHeader_1snmp_99",U4="_nodeList_1snmp_108",$4="_nodeItem_1snmp_116",P4="_indicator_1snmp_129",H4="_label_1snmp_136",V4="_badge_1snmp_145",Yn={nav:R4,searchForm:M4,searchInput:I4,searchButton:O4,clearButton:L4,workspaceSelect:B4,listHeader:z4,nodeList:U4,nodeItem:$4,indicator:P4,label:H4,badge:V4};function q4({nodes:t,workspaces:s,loading:i,searchQuery:r,onSearch:c,onClearSearch:d,onSelectNode:u,onWorkspaceChange:p}){const[m,g]=y.useState(""),v=y.useCallback(k=>{k.preventDefault(),m.trim()&&c(m.trim())},[m,c]),b=y.useCallback(()=>{g(""),d()},[d]),x=y.useCallback(k=>{u(k)},[u]),S=y.useCallback(k=>{g(""),p(k)},[p]);return o.jsxs("div",{className:Yn.nav,"data-testid":"knowledge-nav",children:[o.jsxs("form",{className:Yn.searchForm,onSubmit:v,children:[o.jsx("input",{className:Yn.searchInput,type:"text",placeholder:"Search...",value:m,onChange:k=>{g(k.target.value)},"data-testid":"knowledge-search-input","aria-label":"Search knowledge nodes"}),o.jsx("button",{type:"submit",className:Yn.searchButton,disabled:i,children:"Go"})]}),r&&o.jsx("button",{type:"button",className:Yn.clearButton,onClick:b,children:"Clear search"}),o.jsxs("select",{className:Yn.workspaceSelect,onChange:k=>{S(k.target.value)},"data-testid":"knowledge-workspace-filter","aria-label":"Filter by workspace",children:[o.jsx("option",{value:"",children:"All workspaces"}),s.map(k=>o.jsx("option",{value:k.id,children:k.name},k.id))]}),o.jsxs("div",{className:Yn.listHeader,children:["Nodes (",t.length,")"]}),o.jsx("ul",{className:Yn.nodeList,children:t.map(k=>o.jsxs("li",{className:Yn.nodeItem,onClick:()=>{x(k.id)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),x(k.id))},role:"button",tabIndex:0,children:[o.jsx("span",{className:Yn.indicator,style:{backgroundColor:k.kind==="reference"?"#4A9EFF":k.category==="decision"?"#22C55E":k.category==="concept"?"#A855F7":k.category==="snippet"?"#6B7280":"#EAB308"}}),o.jsx("span",{className:Yn.label,children:k.label}),o.jsx("span",{className:Yn.badge,children:k.kind==="reference"?k.sourceType:k.category})]},k.id))})]})}const G4="_container_1mq5u_1",F4="_hamburger_1mq5u_33",Z4="_brand_1mq5u_49",K4="_brandLogo_1mq5u_68",Y4="_info_1mq5u_75",J4="_connectionLabel_1mq5u_90",W4="_connectionDot_1mq5u_103",X4="_connected_1mq5u_106",Q4="_disconnected_1mq5u_110",Zs={container:G4,hamburger:F4,brand:Z4,brandLogo:K4,info:Y4,connectionLabel:J4,connectionDot:W4,connected:X4,disconnected:Q4};function e5({connected:t,environments:s,sessions:i,onToggleSidebar:r,sidebarOpen:c}){const d=_t(),u=s.length,p=s.filter(g=>g.status==="connected").length,m=i.filter(g=>["running","idle"].includes(g.status)).length;return o.jsxs("div",{className:Zs.container,children:[r&&o.jsx("button",{type:"button",className:Zs.hamburger,onClick:r,"aria-label":"Toggle sidebar","aria-expanded":c,children:o.jsx(M2,{size:Bt,"aria-hidden":"true"})}),o.jsx(Lo,{text:"Home",placement:"bottom",children:o.jsxs("button",{type:"button",className:Zs.brand,onClick:()=>d(Ti),"data-testid":"statusbar-brand",children:[o.jsx("img",{src:"/icon-192x192.png",alt:"",className:Zs.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]})}),o.jsxs("div",{className:Zs.info,children:[o.jsxs("span",{"aria-label":t?"Connected":"Disconnected",children:[o.jsx("span",{className:`${Zs.connectionDot} ${t?Zs.connected:Zs.disconnected}`,"aria-hidden":"true",children:o.jsx(Ba,{size:im,fill:"currentColor"})})," ",o.jsx("span",{className:Zs.connectionLabel,"aria-hidden":"true",children:t?"Connected":"Disconnected"})]}),o.jsxs("span",{children:[p,"/",u," env",u!==1?"s":""]}),o.jsxs("span",{children:[m," active"]})]})]})}const t5="_nav_13gkc_1",n5="_tab_13gkc_35",s5="_tabIcon_13gkc_68",a5="_tabLabel_13gkc_79",i5="_tabActive_13gkc_84",Br={nav:t5,tab:n5,tabIcon:s5,tabLabel:a5,tabActive:i5},vi=[{view:"dashboard",label:"Dashboard",icon:o.jsx(x2,{size:Bt}),route:Ti,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:o.jsx(O2,{size:Bt}),route:sN,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:o.jsx(r2,{size:Bt}),route:aN,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:o.jsx(B2,{size:Bt}),route:Do,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:o.jsx(t2,{size:Bt}),route:Ox,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:o.jsx(px,{size:Bt}),route:bd,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:o.jsx(F2,{size:Bt}),route:Qj,testId:"sidebar-tab-settings"}];function o5(t){return t===Ti||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(Ox)?"knowledge":t.startsWith(bd)?"findings":t.startsWith(Eo)?"settings":"tasks"}function r5(){const t=Zt(),s=_t(),i=y.useRef(null),r=o5(t.pathname),c=y.useCallback(u=>{s(u.route)},[s]),d=y.useCallback(u=>{var b,x;const p=(b=i.current)==null?void 0:b.querySelectorAll('[role="tab"]');if(!p)return;const m=Array.from(p).findIndex(S=>S===document.activeElement),g=m>=0?m:vi.findIndex(S=>S.view===r);let v=g;if(u.key==="ArrowRight"||u.key==="j"||u.key==="J")u.preventDefault(),v=(g+1)%vi.length;else if(u.key==="ArrowLeft"||u.key==="k"||u.key==="K")u.preventDefault(),v=(g-1+vi.length)%vi.length;else if(u.key==="Home")u.preventDefault(),v=0;else if(u.key==="End")u.preventDefault(),v=vi.length-1;else return;s(vi[v].route),(x=p[v])==null||x.focus()},[r,s]);return o.jsx("nav",{className:Br.nav,ref:i,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:d,"data-testid":"sidebar-nav",children:vi.map(u=>{const p=u.view===r;return o.jsx(Lo,{text:u.label,placement:"bottom",children:o.jsxs("button",{role:"tab",type:"button","aria-selected":p,tabIndex:p?0:-1,className:`${Br.tab} ${p?Br.tabActive:""}`,onClick:()=>c(u),"data-testid":u.testId,"aria-label":u.label,children:[o.jsx("span",{className:Br.tabIcon,"aria-hidden":"true",children:u.icon}),o.jsx("span",{className:Br.tabLabel,children:u.label})]})},u.view)})})}const l5="_container_pi6ii_1",c5="_content_pi6ii_66",zb={container:l5,content:c5},d5=320,v1=220,y1=600,b1="grackle-sidebar-width";function u5(){try{const t=localStorage.getItem(b1);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=v1&&s<=y1)return s}}catch{}return d5}function f5(t){try{localStorage.setItem(b1,String(t))}catch{}}function p5({content:t}){const[s]=y.useState(u5),i=y.useRef(null);if(y.useEffect(()=>{const r=i.current;if(!r)return;const c=new ResizeObserver(d=>{for(const u of d){const p=u.borderBoxSize[0];if(p){const m=Math.round(p.inlineSize);m>=v1&&m<=y1&&f5(m)}}});return c.observe(r),()=>{c.disconnect()}},[]),t!==void 0)return o.jsx("div",{className:zb.container,ref:i,"data-testid":"sidebar",style:{width:s},children:o.jsx("div",{className:zb.content,children:t})})}const m5="_bar_tnfsh_1",h5="_btnPrimary_tnfsh_32",g5="_statusText_tnfsh_85",v5="_statusCompleted_tnfsh_90",y5="_statusFailed_tnfsh_94",b5="_statusBlocked_tnfsh_98",x5="_hintText_tnfsh_103",Tt={bar:m5,btnPrimary:h5,statusText:g5,statusCompleted:v5,statusFailed:y5,statusBlocked:b5,hintText:x5};function _5({sessions:t,tasks:s,environments:i}){const r=_t(),c=Zt(),d=At("/sessions/:sessionId"),u=At("/tasks/:taskId"),p=At("/tasks/:taskId/stream"),m=At("/tasks/:taskId/findings"),g=At("/tasks/:taskId/edit"),v=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),b=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),x=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),S=At("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),k=At("/sessions/new"),w=At("/environments/:environmentId/workspaces/:workspaceId"),N=At("/tasks/new"),T=At("/chat"),C=At("/"),D=At("/settings/*"),L=d==null?void 0:d.params.sessionId,A=(u==null?void 0:u.params.taskId)??(p==null?void 0:p.params.taskId)??(m==null?void 0:m.params.taskId)??(v==null?void 0:v.params.taskId)??(b==null?void 0:b.params.taskId)??(x==null?void 0:x.params.taskId)??(S==null?void 0:S.params.taskId),R=v??b??x??S,O=(R==null?void 0:R.params.environmentId)??(w==null?void 0:w.params.environmentId),z=c.pathname.startsWith("/environments")&&!w&&!R,$=!!T,X=!!k,te=!!w&&!v&&!b&&!x&&!S,P=!!N;if(!!C&&!X&&!te&&!P||!!D||(!!g||!!S)||P||z||X)return o.jsx(o.Fragment,{});if($)return i.find(F=>F.adapterType==="local"&&F.status==="connected")?o.jsx(o.Fragment,{}):o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Add a local environment to start chatting"})});if(te)return o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Select a task or click + to create one"})});if(A){const E=s.find(pe=>pe.id===A);if(!E)return o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Loading..."})});const F=new Map(s.map(pe=>[pe.id,pe])),ae=E.dependsOn.some(pe=>{const de=F.get(pe);return de!==void 0&&de.status!=="complete"});if(E.status==="not_started"){const pe=ae?E.dependsOn.map(de=>F.get(de)).filter(de=>de&&de.status!=="complete").map(de=>de.title):[];return o.jsx("div",{className:Tt.bar,children:ae?o.jsxs("span",{className:Tt.statusBlocked,children:["Blocked by: ",pe.join(", ")]}):o.jsx("span",{className:Tt.hintText,children:"Use the buttons above to start or manage this task"})})}if(E.status==="working"||E.status==="paused"){const pe=E.latestSessionId||void 0,de=pe?t.find(ke=>ke.id===pe):void 0;return de&&de.status!=="stopped"?o.jsx(o.Fragment,{}):o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Waiting for agent..."})})}if(E.status==="complete")return o.jsxs("div",{className:Tt.bar,children:[o.jsx("span",{className:`${Tt.statusText} ${Tt.statusCompleted}`,children:"Task completed"}),o.jsx("button",{onClick:()=>r(Ci(E.workspaceId,void 0,O)),className:Tt.btnPrimary,children:"+ New Task"})]});if(E.status==="failed")return o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:`${Tt.statusText} ${Tt.statusFailed}`,children:"Task failed"})})}if(L){const E=t.find(pe=>pe.id===L),F=(E==null?void 0:E.status)==="stopped";if(E!==void 0&&!F)return o.jsx(o.Fragment,{});if(F)return o.jsxs("div",{className:Tt.bar,children:[o.jsxs("span",{className:`${Tt.statusText} ${Tt.hintText}`,children:["Session ",E.endReason||E.status]}),o.jsx("button",{onClick:()=>r(Rx(E.environmentId)),className:Tt.btnPrimary,children:"+ New Chat"})]})}return o.jsx("div",{className:Tt.bar,children:o.jsx("span",{className:Tt.hintText,children:"Loading..."})})}const k5="_nav_14i94_1",S5="_tab_14i94_24",T5="_tabActive_14i94_62",w5="_tabLabel_14i94_75",j5="_statusDot_14i94_81",N5="_pulse_14i94_87",C5="_addButton_14i94_99",E5="_empty_14i94_132",Aa={nav:k5,tab:S5,tabActive:T5,tabLabel:w5,statusDot:j5,pulse:N5,addButton:C5,empty:E5},A5={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function D5({environments:t}){const s=_t(),i=y.useRef(null),r=At("/environments/:environmentId"),c=At("/environments/:environmentId/edit"),d=At("/environments/:environmentId/workspaces/:workspaceId"),u=At("/environments/:environmentId/workspaces/:workspaceId/*"),p=(r==null?void 0:r.params.environmentId)??(c==null?void 0:c.params.environmentId)??(d==null?void 0:d.params.environmentId)??(u==null?void 0:u.params.environmentId),m=p==="new"?void 0:p,g=y.useCallback(x=>{s(Si(x))},[s]),v=y.useCallback(x=>{var T;const S=(T=i.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),w=k>=0?k:t.findIndex(C=>C.id===m);let N=w;if(x.key==="ArrowDown"||x.key==="j"||x.key==="J")x.preventDefault(),N=(w+1)%S.length;else if(x.key==="ArrowUp"||x.key==="k"||x.key==="K")x.preventDefault(),N=(w-1+S.length)%S.length;else if(x.key==="Home")x.preventDefault(),N=0;else if(x.key==="End")x.preventDefault(),N=S.length-1;else return;N<t.length&&s(Si(t[N].id)),S[N].focus()},[m,t,s]),b=m??(t.length>0?t[0].id:void 0);return o.jsxs("div",{className:Aa.nav,"data-testid":"environment-nav",children:[o.jsx("nav",{ref:i,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(x=>{const S=x.id===m,k=x.id===b,w=A5[x.status]||"var(--text-tertiary)",N=x.status==="connected";return o.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${Aa.tab} ${S?Aa.tabActive:""}`,onClick:()=>g(x.id),"data-testid":"env-nav-item",children:[o.jsx("span",{className:`${Aa.statusDot} ${N?Aa.pulse:""}`,style:{color:w},"aria-hidden":"true",children:o.jsx(Ba,{size:im,fill:"currentColor"})}),o.jsx("span",{className:Aa.tabLabel,title:x.displayName||x.id,children:x.displayName||x.id})]},x.id)})}),o.jsx("button",{type:"button",className:Aa.addButton,onClick:()=>s(Wj),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&o.jsx("div",{className:Aa.empty,children:"No environments yet."})]})}function Xm(t){const s=new Date(t),i=new Date,r=i.getTime()-s.getTime(),c=Math.floor(r/1e3),d=Math.floor(c/60),u=Math.floor(d/60),p=Math.floor(u/24);if(c<60)return"just now";if(d<60)return`${d}m ago`;if(u<24)return`${u}h ago`;if(p===1)return"yesterday";if(p<7)return`${p} days ago`;const m=s.getFullYear()===i.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return m?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const Ub={architecture:{text:"var(--accent-blue)",bg:"var(--accent-blue-dim)"},api:{text:"var(--accent-green)",bg:"var(--accent-green-dim)"},bug:{text:"var(--accent-red)",bg:"var(--accent-red-dim)"},decision:{text:"var(--accent-yellow)",bg:"var(--accent-yellow-dim)"},dependency:{text:"var(--accent-purple)",bg:"var(--accent-purple-dim)"},pattern:{text:"var(--accent-cyan)",bg:"var(--accent-cyan-dim)"},general:{text:"var(--text-secondary)",bg:"var(--bg-elevated)"}};function dd(t){return Ub[t]||Ub.general}const R5="_nav_dlm8m_1",M5="_categoryPills_dlm8m_24",I5="_categoryPill_dlm8m_24",O5="_tab_dlm8m_42",L5="_tabActive_dlm8m_80",B5="_tabContent_dlm8m_93",z5="_tabLabel_dlm8m_100",U5="_tabMeta_dlm8m_106",$5="_categoryDot_dlm8m_111",P5="_empty_dlm8m_118",xs={nav:R5,categoryPills:M5,categoryPill:I5,tab:O5,tabActive:L5,tabContent:B5,tabLabel:z5,tabMeta:U5,categoryDot:$5,empty:P5};function H5({findings:t,workspaceId:s,environmentId:i}){const r=_t(),c=y.useRef(null),d=At("/findings/:findingId"),u=At("/environments/:environmentId/workspaces/:workspaceId/findings/:findingId"),p=(d==null?void 0:d.params.findingId)??(u==null?void 0:u.params.findingId),m=y.useMemo(()=>{const x=new Set(t.map(S=>S.category).filter(Boolean));return Array.from(x).sort()},[t]),g=y.useCallback(x=>{r(Rp(x,s,i))},[r,s,i]),v=y.useCallback(x=>{var T;const S=(T=c.current)==null?void 0:T.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const k=Array.from(S).findIndex(C=>C===document.activeElement),w=k>=0?k:t.findIndex(C=>C.id===p);let N=w;if(x.key==="ArrowDown"||x.key==="j"||x.key==="J")x.preventDefault(),N=(w+1)%S.length;else if(x.key==="ArrowUp"||x.key==="k"||x.key==="K")x.preventDefault(),N=(w-1+S.length)%S.length;else if(x.key==="Home")x.preventDefault(),N=0;else if(x.key==="End")x.preventDefault(),N=S.length-1;else return;N<t.length&&r(Rp(t[N].id,s,i)),S[N].focus()},[p,t,r,s,i]),b=p??(t.length>0?t[0].id:void 0);return o.jsxs("div",{className:xs.nav,"data-testid":"findings-nav",children:[m.length>1&&o.jsx("div",{className:xs.categoryPills,"data-testid":"findings-nav-categories",children:m.map(x=>o.jsx("span",{className:xs.categoryPill,style:{color:dd(x).text},children:x},x))}),o.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(x=>{const S=x.id===p,k=x.id===b;return o.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:k?0:-1,className:`${xs.tab} ${S?xs.tabActive:""}`,onClick:()=>g(x.id),"data-testid":"finding-nav-item",children:[o.jsx("span",{className:xs.categoryDot,style:{color:dd(x.category).text},"aria-hidden":"true",children:o.jsx(Ba,{size:im,fill:"currentColor"})}),o.jsxs("span",{className:xs.tabContent,children:[o.jsx("span",{className:xs.tabLabel,title:x.title,children:x.title}),o.jsx("span",{className:xs.tabMeta,title:x.createdAt,children:Xm(x.createdAt)})]})]},x.id)})}),t.length===0&&o.jsx("div",{className:xs.empty,children:"No findings yet. Agents will post discoveries here."})]})}function V5(t){if(t.length===0)return[];const s=[...t].sort((r,c)=>r[0]-c[0]),i=[[s[0][0],s[0][1]]];for(let r=1;r<s.length;r++){const c=i[i.length-1],[d,u]=s[r];d<=c[1]+1?c[1]=Math.max(c[1],u):i.push([d,u])}return i}function x1({text:t,indices:s,highlightClass:i}){if(!s||s.length===0)return o.jsx(o.Fragment,{children:t});const r=V5(s),c=[];let d=0;for(const[u,p]of r)u>d&&c.push(o.jsx("span",{children:t.slice(d,u)},`p${d}`)),c.push(o.jsx("mark",{className:i,children:t.slice(u,p+1)},`m${u}`)),d=p+1;return d<t.length&&c.push(o.jsx("span",{children:t.slice(d)},`p${d}`)),o.jsx(o.Fragment,{children:c})}function q5(t){const s=new Map(t.map(r=>[r.id,{...r,children:[]}])),i=[];for(const r of s.values())r.parentTaskId&&s.has(r.parentTaskId)?s.get(r.parentTaskId).children.push(r):i.push(r);for(const r of s.values())r.children.sort((c,d)=>c.sortOrder-d.sortOrder);return i.sort((r,c)=>r.sortOrder-c.sortOrder)}function G5(t,s){const i=new Map;for(const d of t){const p=d.dependsOn.length>0&&d.dependsOn.some(g=>s.get(g)!=="complete")?"blocked":d.status,m=i.get(p);m?m.push(d):i.set(p,[d])}const r=[],c=new Set;for(const d of tw){c.add(d);const u=i.get(d);if(u&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=za(d);r.push({status:d,label:p.label,style:p,tasks:u})}}for(const[d,u]of i)if(!c.has(d)&&u.length>0){u.sort((m,g)=>m.sortOrder-g.sortOrder);const p=za(d);r.push({status:d,label:p.label,style:p,tasks:u})}return r}const F5="_container_z4i38_1",Z5="_header_z4i38_5",K5="_headerActions_z4i38_17",Y5="_searchInput_z4i38_23",J5="_searchHighlight_z4i38_56",W5="_groupToggle_z4i38_62",X5="_groupToggleActive_z4i38_89",Q5="_addButton_z4i38_93",eI="_taskRow_z4i38_120",tI="_selected_z4i38_140",nI="_expandArrow_z4i38_150",sI="_expanded_z4i38_157",aI="_leafSpacer_z4i38_161",iI="_taskStatusIcon_z4i38_166",oI="_taskTitle_z4i38_170",rI="_workspaceBadge_z4i38_177",lI="_childCountBadge_z4i38_195",cI="_dependencyBadge_z4i38_208",dI="_blockedBadge_z4i38_220",uI="_addChildButton_z4i38_225",fI="_emptyState_z4i38_268",pI="_statusGroupHeader_z4i38_275",mI="_statusGroupIcon_z4i38_294",hI="_statusGroupLabel_z4i38_298",gI="_statusGroupCount_z4i38_303",Fe={container:F5,header:Z5,headerActions:K5,searchInput:Y5,searchHighlight:J5,groupToggle:W5,groupToggleActive:X5,addButton:Q5,taskRow:eI,selected:tI,expandArrow:nI,expanded:sI,leafSpacer:aI,taskStatusIcon:iI,taskTitle:oI,workspaceBadge:rI,childCountBadge:lI,dependencyBadge:cI,blockedBadge:dI,addChildButton:uI,emptyState:fI,statusGroupHeader:pI,statusGroupIcon:mI,statusGroupLabel:hI,statusGroupCount:gI},vI=[{name:"title",weight:2},{name:"description",weight:1}],_1=16,yI=16,k1="grackle-task-group-by-status";function $b(){try{return localStorage.getItem(k1)==="true"}catch{return!1}}function bI(t){try{localStorage.setItem(k1,String(t))}catch{}}function xI({group:t,isExpanded:s,onToggle:i,selectedTaskId:r,navigate:c,titleHighlights:d,workspaceNames:u}){return o.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[o.jsxs("div",{className:Fe.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:i,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),i())},children:[o.jsx("span",{className:`${Fe.expandArrow} ${s?Fe.expanded:""}`,"aria-hidden":"true",children:o.jsx(sa,{size:ot})}),o.jsx("span",{className:Fe.statusGroupIcon,style:{color:t.style.color},"aria-hidden":"true",children:t.style.icon}),o.jsx("span",{className:Fe.statusGroupLabel,children:t.label}),o.jsx("span",{className:Fe.statusGroupCount,children:t.tasks.length})]}),o.jsx(ps,{children:s&&o.jsx(Rt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},style:{overflow:"hidden"},children:t.tasks.map(p=>{const m=za(p.status),g=r===p.id,v=p.parentTaskId||!p.workspaceId?void 0:u.get(p.workspaceId);return o.jsxs("div",{onClick:()=>c(In(p.id)),role:"button",tabIndex:0,"aria-label":p.title,onKeyDown:b=>{b.currentTarget===b.target&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c(In(p.id)))},className:`${Fe.taskRow} ${g?Fe.selected:""}`,style:{"--task-indent":`${_1}px`},"data-task-id":p.id,children:[o.jsx("span",{className:Fe.leafSpacer}),o.jsx("span",{className:Fe.taskStatusIcon,style:{color:m.color},"aria-hidden":"true","data-testid":`task-status-${rl(p.status)}`,children:m.icon}),o.jsx("span",{className:Fe.taskTitle,title:p.title,children:o.jsx(x1,{text:p.title,indices:d.get(p.id),highlightClass:Fe.searchHighlight})}),v&&o.jsx("span",{className:Fe.workspaceBadge,title:v,children:v})]},p.id)})})})]})}function S1({node:t,depth:s,expandedTasks:i,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m}){const g=za(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(T=>u.get(T)!=="complete"),b=i.has(t.id),x=t.children.length>0,S=c===t.id,k=_1+s*yI,N=s===0&&!t.parentTaskId&&t.workspaceId?m.get(t.workspaceId):void 0;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{onClick:()=>d(In(t.id)),role:"button",tabIndex:0,"aria-label":t.title,onKeyDown:T=>{T.currentTarget===T.target&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),d(In(t.id)))},className:`${Fe.taskRow} ${S?Fe.selected:""}`,style:{"--task-indent":`${k}px`},"data-task-id":t.id,children:[x&&o.jsx("span",{className:`${Fe.expandArrow} ${b?Fe.expanded:""}`,role:"button",tabIndex:0,"aria-label":b?"Collapse task":"Expand task",onClick:T=>{T.stopPropagation(),r(t.id)},onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),T.stopPropagation(),r(t.id))},children:o.jsx(sa,{size:ot,"aria-hidden":"true"})}),!x&&o.jsx("span",{className:Fe.leafSpacer}),o.jsx("span",{className:Fe.taskStatusIcon,style:{color:g.color},"aria-hidden":"true","data-testid":`task-status-${rl(t.status)}`,children:g.icon}),o.jsx("span",{className:Fe.taskTitle,title:t.title,children:o.jsx(x1,{text:t.title,indices:p.get(t.id),highlightClass:Fe.searchHighlight})}),N&&o.jsx("span",{className:Fe.workspaceBadge,title:N,children:N}),x&&o.jsxs("span",{className:Fe.childCountBadge,children:[t.children.filter(T=>T.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&o.jsx("span",{className:`${Fe.dependencyBadge} ${v?Fe.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<fT&&o.jsx(Lo,{text:"Add child task",children:o.jsx("button",{onClick:T=>{T.stopPropagation(),d(Ci(t.workspaceId,t.id))},"aria-label":"Add child task",className:Fe.addChildButton,children:"+"})})]}),o.jsx(ps,{children:x&&b&&o.jsx(Rt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:t.children.map(T=>o.jsx(S1,{node:T,depth:s+1,expandedTasks:i,toggleTask:r,selectedTaskId:c,navigate:d,taskStatusById:u,titleHighlights:p,workspaceNames:m},T.id))})})]})}function _I({workspaces:t,tasks:s}){const i=_t(),[r,c]=y.useState(new Set),[d,u]=y.useState(new Set),[p,m]=y.useState($b),[g,v]=y.useState($b),[b,x]=y.useState(new Map),S=At("/tasks/:taskId/*"),k=(S==null?void 0:S.params.taskId)!=="new"?S==null?void 0:S.params.taskId:void 0,w=y.useMemo(()=>new Map(s.map(H=>[H.id,H.status])),[s]),N=y.useMemo(()=>new Map(t.map(H=>[H.id,H.name])),[t]),T=()=>{const H=!p;bI(H),m(H),H&&(v(!0),x(new Map))},C=H=>{x(oe=>{const E=new Map(oe),F=E.has(H)?E.get(H):g;return E.set(H,!F),E})},D=H=>b.has(H)?b.get(H):g,L=H=>{c(oe=>{const E=new Set(oe);return E.has(H)?(E.delete(H),u(F=>new Set(F).add(H))):(E.add(H),u(F=>{const ae=new Set(F);return ae.delete(H),ae})),E})};y.useEffect(()=>{const H=new Set(s.filter(oe=>oe.parentTaskId).map(oe=>oe.parentTaskId));H.size>0&&c(oe=>{const E=new Set(oe);for(const F of H)d.has(F)||E.add(F);return E})},[s,d]);const[A,R]=y.useState(""),{directMatchTaskIds:O,treeMatchTaskIds:z,titleHighlights:$}=y.useMemo(()=>{if(!A.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const H=uT(s,A,vI),oe=new Set(H.map(pe=>pe.item.id)),E=new Map;for(const pe of H){const de=pe.matches.find(Oe=>Oe.key==="title");de&&E.set(pe.item.id,de.indices)}const F=new Set(oe),ae=new Map(s.map(pe=>[pe.id,pe]));for(const pe of[...oe]){let de=ae.get(pe);for(;de!=null&&de.parentTaskId;)F.add(de.parentTaskId),de=ae.get(de.parentTaskId)}return{directMatchTaskIds:oe,treeMatchTaskIds:F,titleHighlights:E}},[A,s]),X=O!==null,te=X?p?O:z:null,P=te?s.filter(H=>te.has(H.id)):s,re=p?[]:q5(P);return o.jsxs("div",{className:Fe.container,children:[o.jsxs("div",{className:Fe.header,children:[o.jsx("span",{children:"Tasks"}),o.jsxs("div",{className:Fe.headerActions,children:[o.jsx(Lo,{text:p?"Switch to tree view":"Group tasks by status",children:o.jsx("button",{className:`${Fe.groupToggle} ${p?Fe.groupToggleActive:""}`,onClick:T,"aria-label":p?"Switch to tree view":"Group tasks by status","aria-pressed":p,"data-testid":"task-group-by-status-toggle",children:o.jsx(E2,{size:en})})}),o.jsx(Lo,{text:"New task",children:o.jsx("button",{className:Fe.addButton,onClick:()=>i(Ci()),"aria-label":"New task","data-testid":"new-task-button",children:"+"})})]})]}),s.length>0&&o.jsx("input",{type:"text",value:A,onChange:H=>R(H.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:Fe.searchInput,"data-testid":"sidebar-search"}),p?G5(P,w).map(H=>o.jsx(xI,{group:H,isExpanded:D(H.status),onToggle:()=>C(H.status),selectedTaskId:k,navigate:i,titleHighlights:$,workspaceNames:N},H.status)):re.map(H=>o.jsx(S1,{node:H,depth:0,expandedTasks:r,toggleTask:L,selectedTaskId:k,navigate:i,taskStatusById:w,titleHighlights:$,workspaceNames:N},H.id)),P.length===0&&!X&&o.jsx("div",{className:Fe.emptyState,children:"No tasks yet. Click + to create one."}),P.length===0&&X&&o.jsx("div",{className:Fe.emptyState,children:"No matching tasks"})]})}const kI="_toast_ed2dk_1",SI="_success_ed2dk_18",TI="_icon_ed2dk_22",wI="_error_ed2dk_25",jI="_warning_ed2dk_32",NI="_info_ed2dk_38",CI="_message_ed2dk_53",EI="_close_ed2dk_60",zr={toast:kI,success:SI,icon:TI,error:wI,warning:jI,info:NI,message:CI,close:EI},AI={success:o.jsx(ji,{size:Bt}),error:o.jsx(Ha,{size:Bt}),warning:o.jsx(am,{size:Bt}),info:o.jsx(sm,{size:Bt})};function DI({toast:t,onDismiss:s}){return y.useEffect(()=>{const i=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(i)},[t.id,t.duration,s]),o.jsxs(Rt.div,{className:`${zr.toast} ${zr[t.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[o.jsx("span",{className:zr.icon,"aria-hidden":"true",children:AI[t.variant]}),o.jsx("span",{className:zr.message,children:t.message}),o.jsx("button",{type:"button",className:zr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:o.jsx(Ha,{size:en,"aria-hidden":"true"})})]})}const RI="_container_qqse2_1",MI={container:RI};function II({toasts:t,onDismiss:s}){return o.jsx("div",{className:MI.container,"data-testid":"toast-container",children:o.jsx(ps,{children:t.map(i=>o.jsx(DI,{toast:i,onDismiss:s},i.id))})})}const OI="_callout_e5awm_1",LI="_success_e5awm_11",BI="_icon_e5awm_15",zI="_error_e5awm_18",UI="_warning_e5awm_25",$I="_info_e5awm_32",PI="_content_e5awm_48",HI="_close_e5awm_53",Ur={callout:OI,success:LI,icon:BI,error:zI,warning:UI,info:$I,content:PI,close:HI},VI={success:o.jsx(ji,{size:Bt}),error:o.jsx(Ha,{size:Bt}),warning:o.jsx(am,{size:Bt}),info:o.jsx(sm,{size:Bt})};function qI({variant:t="info",children:s,dismissible:i=!1,className:r}){const[c,d]=y.useState(!1);return o.jsx(o.Fragment,{children:!c&&o.jsxs("div",{className:[Ur.callout,Ur[t],r].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[o.jsx("span",{className:Ur.icon,"aria-hidden":"true",children:VI[t]}),o.jsx("span",{className:Ur.content,children:s}),i&&o.jsx("button",{type:"button",className:Ur.close,onClick:()=>d(!0),"aria-label":"Dismiss",children:o.jsx(Ha,{size:en,"aria-hidden":"true"})})]})})}function GI({currentVersion:t,latestVersion:s,updateAvailable:i,isDocker:r}){if(!i)return o.jsx(o.Fragment,{});const c=r?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return o.jsx("div",{"data-testid":"update-banner",children:o.jsxs(qI,{variant:"info",dismissible:!0,children:[o.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",o.jsx("code",{children:c})]})})}const FI="_container_de44x_1",ZI="_emptyState_de44x_8",KI="_card_de44x_14",YI="_cardClickable_de44x_34",JI="_cardHeader_de44x_42",WI="_categoryBadge_de44x_54",XI="_findingTitle_de44x_62",QI="_findingDate_de44x_68",eO="_findingContent_de44x_80",tO="_tags_de44x_86",nO="_tag_de44x_86",cs={container:FI,emptyState:ZI,card:KI,cardClickable:YI,cardHeader:JI,categoryBadge:WI,findingTitle:XI,findingDate:QI,findingContent:eO,tags:tO,tag:nO};function T1({findings:t,onFindingClick:s}){return t.length===0?o.jsx("div",{className:cs.emptyState,children:"No findings yet. Agents will post discoveries here."}):o.jsx("div",{className:cs.container,children:t.map((i,r)=>{const c=dd(i.category),d=s?Rt.button:Rt.div;return o.jsxs(d,{type:s?"button":void 0,className:`${cs.card} ${s?cs.cardClickable:""}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:r*.05,duration:.2},onClick:s?()=>{s(i.id)}:void 0,children:[o.jsxs("div",{className:cs.cardHeader,children:[o.jsx("span",{className:cs.categoryBadge,style:{background:c.bg,color:c.text},children:i.category}),o.jsx("span",{className:cs.findingTitle,children:i.title}),o.jsx("span",{className:cs.findingDate,title:i.createdAt,children:Xm(i.createdAt)})]}),o.jsx("div",{className:cs.findingContent,children:i.content.length>300?i.content.slice(0,300)+"...":i.content}),i.tags.length>0&&o.jsx("div",{className:cs.tags,children:i.tags.map(u=>o.jsx("span",{className:cs.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:u},u))})]},i.id)})})}const sO="_section_1ingb_14",aO="_sectionTitle_1ingb_26",iO="_sectionDescription_1ingb_35",oO="_tokenList_1ingb_48",rO="_tokenRow_1ingb_55",lO="_tokenBadge_1ingb_68",cO="_tokenName_1ingb_83",dO="_tokenTarget_1ingb_90",uO="_deleteButton_1ingb_99",fO="_addForm_1ingb_113",pO="_formRow_1ingb_119",mO="_input_1ingb_125",hO="_select_1ingb_155",gO="_addButton_1ingb_187",vO="_emptyStateInfo_1ingb_221",yO="_themeOptions_1ingb_229",bO="_themeOption_1ingb_229",xO="_themeOptionSelected_1ingb_254",_O="_themeOptionHeader_1ingb_259",kO="_themeOptionLabel_1ingb_266",SO="_themeOptionDesc_1ingb_273",TO="_variantToggle_1ingb_279",wO="_variantButton_1ingb_286",jO="_variantActive_1ingb_305",NO="_themeSwatches_1ingb_311",CO="_themeSwatch_1ingb_311",EO="_systemToggle_1ingb_325",AO="_systemToggleHint_1ingb_341",DO="_themeActive_1ingb_348",RO="_aboutGrid_1ingb_354",MO="_aboutItem_1ingb_360",IO="_aboutLabel_1ingb_373",OO="_aboutValue_1ingb_379",LO="_aboutDot_1ingb_387",BO="_aboutDotConnected_1ingb_394",zO="_aboutDotDisconnected_1ingb_398",ge={section:sO,sectionTitle:aO,sectionDescription:iO,tokenList:oO,tokenRow:rO,tokenBadge:lO,tokenName:cO,tokenTarget:dO,deleteButton:uO,addForm:fO,formRow:pO,input:mO,select:hO,addButton:gO,emptyStateInfo:vO,themeOptions:yO,themeOption:bO,themeOptionSelected:xO,themeOptionHeader:_O,themeOptionLabel:kO,themeOptionDesc:SO,variantToggle:TO,variantButton:wO,variantActive:jO,themeSwatches:NO,themeSwatch:CO,systemToggle:EO,systemToggleHint:AO,themeActive:DO,aboutGrid:RO,aboutItem:MO,aboutLabel:IO,aboutValue:OO,aboutDot:LO,aboutDotConnected:BO,aboutDotDisconnected:zO},UO=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function $O({tokens:t,onSetToken:s,onDeleteToken:i,onShowToast:r}){const[c,d]=y.useState(""),[u,p]=y.useState(""),[m,g]=y.useState("env_var"),[v,b]=y.useState(""),[x,S]=y.useState(null),k=T=>{if(T.preventDefault(),!c||!u)return;const C=m==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,u,m,C,m==="file"?v:""),r==null||r("Token saved successfully","success"),d(""),p(""),b("")},w=T=>{S(T)},N=()=>{x&&(i(x),r==null||r("Token deleted","info")),S(null)};return o.jsxs(o.Fragment,{children:[o.jsx(wi,{isOpen:x!==null,title:"Delete Token?",description:x?`"${x}" will be permanently removed.`:void 0,onConfirm:N,onCancel:()=>S(null)}),o.jsxs("section",{className:ge.section,children:[o.jsx("h3",{className:ge.sectionTitle,children:"Tokens"}),o.jsx("p",{className:ge.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?o.jsx("div",{className:ge.emptyStateInfo,children:"Add your first API token to enable service integrations."}):o.jsx("div",{className:ge.tokenList,children:t.map(T=>o.jsxs("div",{className:ge.tokenRow,children:[o.jsx("span",{className:ge.tokenBadge,children:T.tokenType}),o.jsx("span",{className:ge.tokenName,children:T.name}),o.jsx("span",{className:ge.tokenTarget,children:T.tokenType==="env_var"?T.envVar:T.filePath}),o.jsx("button",{className:ge.deleteButton,onClick:()=>w(T.name),title:`Delete ${T.name}`,"aria-label":`Delete ${T.name}`,children:o.jsx(Ha,{size:en,"aria-hidden":"true"})})]},T.name))}),o.jsxs("form",{className:ge.addForm,onSubmit:k,children:[o.jsxs("div",{className:ge.formRow,children:[o.jsx("input",{className:ge.input,type:"text",placeholder:"Token name",value:c,onChange:T=>d(T.target.value)}),o.jsx("input",{className:ge.input,type:"password",placeholder:"Value",value:u,onChange:T=>p(T.target.value)})]}),o.jsxs("div",{className:ge.formRow,children:[o.jsx("select",{className:ge.select,value:m,onChange:T=>g(T.target.value),children:UO.map(T=>o.jsx("option",{value:T.value,children:T.label},T.value))}),o.jsx("input",{className:ge.input,type:"text",placeholder:m==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:T=>b(T.target.value)}),o.jsx("button",{className:ge.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const jd=[{id:"grackle",label:"Grackle",description:"The default Grackle theme — iridescent purple on clean dark.",swatches:["#0e1218","#8b5cf6","#60a5fa","#e5e7eb","#34d399"],variantLightId:"grackle-light",variantDarkId:"grackle-dark"},{id:"grackle-light",label:"Grackle Light",description:"Light Grackle variant.",hidden:!0},{id:"grackle-dark",label:"Grackle Dark",description:"Dark Grackle variant.",hidden:!0},{id:"glass",label:"Glassmorphism",description:"Dark frosted-glass aesthetic with backdrop blur effects.",swatches:["#0a0c14","#4ecca3","#70a1ff","#e2e8f0","#a855f7"]},{id:"matrix",label:"Matrix",description:"Phosphor-green CRT terminal with scanlines and glow.",swatches:["#050505","#00ff41","#00bfff","#33ff77","#ffb000"]},{id:"brutalist",label:"Neubrutalism",description:"Thick borders, raw colors, bold type — ugly on purpose.",swatches:["#f5f0e8","#ff5757","#5ce1e6","#1a1a1a","#ffde59"],variantLightId:"brutalist-light",variantDarkId:"brutalist-dark"},{id:"brutalist-light",label:"Neubrutalism Light",description:"Light neubrutalism variant.",hidden:!0},{id:"brutalist-dark",label:"Neubrutalism Dark",description:"Dark neubrutalism variant.",hidden:!0},{id:"monokai",label:"Monokai",description:"Classic warm editor palette — pink, green, and purple.",swatches:["#272822","#f92672","#a6e22e","#f8f8f2","#ae81ff"],variantLightId:"monokai-light",variantDarkId:"monokai-dark"},{id:"monokai-dark",label:"Monokai Dark",description:"Dark Monokai variant.",hidden:!0},{id:"monokai-light",label:"Monokai Light",description:"Light Monokai variant.",hidden:!0},{id:"ubuntu",label:"Ubuntu",description:"Aubergine terminal with the GNOME Tango palette.",swatches:["#300a24","#8ae234","#ef2929","#eeeeec","#fce94f"]},{id:"sandstone",label:"Sandstone",description:"Warm terracotta accent on dark brown, in the style of Claude Code.",swatches:["#1a1815","#C15F3C","#6b8afd","#e8e6e3","#a78bfa"]},{id:"verdigris",label:"Verdigris",description:"Teal accent on charcoal, in the style of ChatGPT.",swatches:["#141414","#00a67e","#3b82f6","#ececec","#ab68ff"]},{id:"primer",label:"Primer",description:"Blue accent on ink-dark grey, in the style of GitHub.",swatches:["#0d1117","#58a6ff","#3fb950","#c9d1d9","#bc8cff"]}],w1=new Set(jd.map(t=>t.id)),Pb="grackle";function Xp(t){return jd.find(s=>s.id===t)}function PO({themeId:t,resolvedThemeId:s,onSetTheme:i,preferSystem:r,onSetPreferSystem:c}){return o.jsxs("section",{className:ge.section,children:[o.jsx("h3",{className:ge.sectionTitle,children:"Appearance"}),o.jsx("p",{className:ge.sectionDescription,children:"Choose how Grackle looks across the app."}),o.jsx("div",{className:ge.themeOptions,children:jd.filter(d=>!d.hidden).map(d=>{const u=!!(d.variantLightId&&d.variantDarkId),p=u?t===d.id||t===d.variantLightId||t===d.variantDarkId:t===d.id,m=u&&s===d.variantLightId;return o.jsxs("button",{type:"button",className:`${ge.themeOption} ${p?ge.themeOptionSelected:""}`,"aria-pressed":p,onClick:()=>i(d.id),children:[o.jsxs("span",{className:ge.themeOptionHeader,children:[o.jsxs("span",{children:[o.jsx("span",{className:ge.themeOptionLabel,children:d.label}),o.jsx("span",{className:ge.themeOptionDesc,children:d.description})]}),u&&o.jsxs("span",{className:ge.variantToggle,children:[o.jsx("span",{role:"button",tabIndex:0,className:`${ge.variantButton} ${p&&m?ge.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),i(d.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),i(d.variantLightId))},"aria-label":"Light variant","aria-pressed":p&&m,children:"☼"}),o.jsx("span",{role:"button",tabIndex:0,className:`${ge.variantButton} ${p&&!m?ge.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),i(d.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),i(d.variantDarkId))},"aria-label":"Dark variant","aria-pressed":p&&!m,children:"☾"})]})]}),d.swatches&&o.jsx("span",{className:ge.themeSwatches,children:d.swatches.map((g,v)=>o.jsx("span",{className:ge.themeSwatch,style:{background:g}},v))})]},d.id)})}),o.jsxs("label",{className:ge.systemToggle,children:[o.jsx("input",{type:"checkbox",checked:r,onChange:d=>c(d.target.checked)}),o.jsx("span",{children:"Match system light/dark preference"})]}),o.jsx("p",{className:ge.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),o.jsxs("p",{className:ge.themeActive,children:["Active theme: ",o.jsx("strong",{children:s})]})]})}function HO({connected:t,environments:s,sessions:i}){const r=s.filter(u=>u.status==="connected").length,c=s.length,d=i.filter(u=>["running","idle"].includes(u.status)).length;return o.jsxs("section",{className:ge.section,"data-testid":"about-panel",children:[o.jsx("h3",{className:ge.sectionTitle,children:"About"}),o.jsx("p",{className:ge.sectionDescription,children:"Connection status and application information."}),o.jsxs("div",{className:ge.aboutGrid,children:[o.jsxs("div",{className:ge.aboutItem,children:[o.jsx("span",{className:ge.aboutLabel,children:"Connection"}),o.jsxs("span",{className:ge.aboutValue,children:[o.jsx("span",{className:`${ge.aboutDot} ${t?ge.aboutDotConnected:ge.aboutDotDisconnected}`}),t?"Connected":"Disconnected"]})]}),o.jsxs("div",{className:ge.aboutItem,children:[o.jsx("span",{className:ge.aboutLabel,children:"Environments"}),o.jsxs("span",{className:ge.aboutValue,children:[r,"/",c," connected"]})]}),o.jsxs("div",{className:ge.aboutItem,children:[o.jsx("span",{className:ge.aboutLabel,children:"Active Sessions"}),o.jsx("span",{className:ge.aboutValue,children:d})]}),o.jsxs("div",{className:ge.aboutItem,children:[o.jsx("span",{className:ge.aboutLabel,children:"Version"}),o.jsx("span",{className:ge.aboutValue,children:"0.95.0"})]})]})]})}const VO="_container_cddyd_1",qO="_header_cddyd_8",GO="_headerTitle_cddyd_35",FO="_badge_cddyd_44",ZO="_headerActions_cddyd_54",KO="_body_cddyd_61",YO="_formContent_cddyd_73",JO="_section_cddyd_85",WO="_label_cddyd_91",XO="_titleInput_cddyd_98",QO="_descriptionTextarea_cddyd_131",eL="_parentContext_cddyd_167",tL="_parentLabel_cddyd_175",nL="_parentName_cddyd_182",sL="_personaSelect_cddyd_186",aL="_depList_cddyd_220",iL="_depItem_cddyd_226",oL="_depItemSelected_cddyd_248",rL="_noDeps_cddyd_252",lL="_btnPrimary_cddyd_258",cL="_btnGhost_cddyd_289",et={container:VO,header:qO,headerTitle:GO,badge:FO,headerActions:ZO,body:KO,formContent:YO,section:JO,label:WO,titleInput:XO,descriptionTextarea:QO,parentContext:eL,parentLabel:tL,parentName:nL,personaSelect:sL,depList:aL,depItem:iL,depItemSelected:oL,noDeps:rL,btnPrimary:lL,btnGhost:cL};function j1({mode:t,taskId:s,workspaceId:i,parentTaskId:r,environmentId:c,tasks:d,workspaces:u,personas:p,onCreateTask:m,onUpdateTask:g,onEditDone:v,onShowToast:b}){const x=_t(),S=t==="edit",k=S&&s?d.find(me=>me.id===s):void 0,w=S?(k==null?void 0:k.workspaceId)??"":i??"",[N,T]=y.useState(w),C=w||N,D=u.find(me=>me.id===C),L=c??(D==null?void 0:D.environmentId),A=!S&&!i,R=S?(k==null?void 0:k.parentTaskId)??"":r??"",O=R?d.find(me=>me.id===R):void 0,[z,$]=y.useState((k==null?void 0:k.title)??""),[X,te]=y.useState((k==null?void 0:k.description)??""),[P,re]=y.useState((k==null?void 0:k.dependsOn)??[]),[H,oe]=y.useState((k==null?void 0:k.defaultPersonaId)??""),[E,F]=y.useState((k==null?void 0:k.canDecompose)??!1),[ae,pe]=y.useState(!1),de=y.useRef(!1);y.useEffect(()=>{S&&k&&!de.current&&(de.current=!0,$(k.title),te(k.description),re(k.dependsOn),oe(k.defaultPersonaId),F(k.canDecompose))},[S,k]);const Oe=d.filter(me=>me.workspaceId===C&&(!S||me.id!==s)&&me.id!==R),ke=z.trim().length>0&&(!S||k!==void 0)&&C.length>0,Ee=me=>{re(Be=>Be.includes(me)?Be.filter(mt=>mt!==me):[...Be,me])},ze=()=>{!ke||ae||S&&k===void 0||(S&&s?(g(s,z.trim(),X,P,H),b==null||b("Task updated","success"),v?v():x(In(s,void 0,C,L),{replace:!0})):(pe(!0),m(C,z.trim(),X,P.length>0?P:void 0,R||void 0,H,E,()=>{b==null||b("Task created","success"),x(i?Ua(i,L):"/tasks",{replace:!0})},me=>{b==null||b(me,"error"),pe(!1)})))},ue=()=>{if(v){v();return}x(S&&s?In(s,void 0,C,L):i?Ua(i,L):"/tasks")},xe=S?"edit task":R?"child task":"new task";return o.jsxs("div",{className:et.container,children:[o.jsxs("div",{className:et.header,children:[o.jsxs("div",{className:et.headerTitle,children:[o.jsx("span",{className:et.badge,children:xe}),O&&o.jsxs("span",{className:et.parentContext,children:[o.jsx("span",{className:et.parentLabel,children:"Child of"}),o.jsx("span",{className:et.parentName,children:O.title})]})]}),o.jsxs("div",{className:et.headerActions,children:[o.jsx("button",{onClick:ze,disabled:!ke||ae,className:et.btnPrimary,"data-testid":"task-edit-save",children:ae?"Creating…":S?"Save Changes":"Create"}),o.jsx("button",{onClick:ue,className:et.btnGhost,children:"Cancel"})]})]}),o.jsx("div",{className:et.body,children:o.jsxs("div",{className:et.formContent,children:[A&&o.jsxs("div",{className:et.section,children:[o.jsx("label",{className:et.label,htmlFor:"task-edit-workspace",children:"Workspace"}),o.jsxs("select",{id:"task-edit-workspace",value:N,onChange:me=>T(me.target.value),className:et.personaSelect,"data-testid":"task-edit-workspace",children:[o.jsx("option",{value:"",children:"Select a workspace..."}),u.map(me=>o.jsx("option",{value:me.id,children:me.name},me.id))]})]}),o.jsxs("div",{className:et.section,children:[o.jsx("label",{className:et.label,htmlFor:"task-edit-title",children:"Title"}),o.jsx("input",{id:"task-edit-title",type:"text",value:z,onChange:me=>$(me.target.value),placeholder:"Task title...",autoFocus:!0,className:et.titleInput,"data-testid":"task-edit-title",onKeyDown:me=>{me.key==="Enter"&&ke&&ze()}})]}),o.jsxs("div",{className:et.section,children:[o.jsx("label",{className:et.label,htmlFor:"task-edit-description",children:"Description"}),o.jsx("textarea",{id:"task-edit-description",value:X,onChange:me=>te(me.target.value),placeholder:"Describe the task... (markdown supported)",className:et.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),o.jsxs("div",{className:et.section,children:[o.jsx("label",{className:et.label,htmlFor:"task-edit-persona",children:"Default Persona"}),o.jsxs("select",{id:"task-edit-persona",value:H,onChange:me=>oe(me.target.value),className:et.personaSelect,"data-testid":"task-edit-persona",children:[o.jsx("option",{value:"",children:"(Inherit)"}),p.map(me=>o.jsx("option",{value:me.id,children:me.name},me.id))]})]}),!S&&o.jsx("div",{className:et.section,children:o.jsxs("label",{className:et.depItem,"data-testid":"task-edit-can-decompose",children:[o.jsx("input",{type:"checkbox",checked:E,onChange:me=>F(me.target.checked)}),"Can spawn subtasks"]})}),o.jsxs("div",{className:et.section,children:[o.jsx("div",{className:et.label,children:"Dependencies"}),Oe.length===0?o.jsx("div",{className:et.noDeps,children:"No other tasks in this workspace"}):o.jsx("div",{className:et.depList,children:Oe.map(me=>{const Be=P.includes(me.id);return o.jsxs("label",{className:`${et.depItem} ${Be?et.depItemSelected:""}`,"data-testid":`dep-option-${me.id}`,children:[o.jsx("input",{type:"checkbox",checked:Be,onChange:()=>Ee(me.id)}),me.title,o.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",me.status,")"]})]},me.id)})})]})]})})]})}const dL="_actionButtons_1rjka_1",uL="_btnPrimary_1rjka_8",fL="_btnDanger_1rjka_39",pL="_btnGhost_1rjka_78",Ft={actionButtons:dL,btnPrimary:uL,btnDanger:fL,btnGhost:pL};function mL({task:t,sessionId:s,isBlocked:i,onStart:r,onResume:c,onStop:d,onPause:u,onDelete:p,onEdit:m}){if(t.status==="not_started")return i?o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{onClick:m,className:Ft.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]}):o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{"data-testid":"task-header-start",onClick:r,className:Ft.btnPrimary,children:"Start"}),o.jsx("button",{onClick:m,className:Ft.btnGhost,"data-testid":"task-action-edit",children:"Edit"}),o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="working")return o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{onClick:d,className:Ft.btnDanger,"data-testid":"task-action-stop",children:"Stop"}),o.jsx("button",{onClick:u,disabled:!s,className:Ft.btnGhost,"data-testid":"task-action-pause",children:"Pause"})]});if(t.status==="paused")return o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{onClick:d,className:Ft.btnPrimary,"data-testid":"task-action-stop",children:"Stop"}),o.jsx("button",{onClick:c,className:Ft.btnGhost,"data-testid":"task-action-resume",children:"Resume"}),o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]});if(t.status==="complete")return o.jsx("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})});if(t.status==="failed")return o.jsxs("div",{className:Ft.actionButtons,"data-testid":"task-action-buttons",children:[o.jsx("button",{onClick:r,className:Ft.btnPrimary,"data-testid":"task-header-start",children:"Retry"}),o.jsx("button",{onClick:p,className:Ft.btnDanger,"data-testid":"task-action-delete",children:"Delete"})]})}const hL="_workpadSection_y8nj9_1",gL="_workpadLabel_y8nj9_9",vL="_workpadStatus_y8nj9_17",yL="_workpadSummary_y8nj9_23",bL="_workpadExtra_y8nj9_29",Da={workpadSection:hL,workpadLabel:gL,workpadStatus:vL,workpadSummary:yL,workpadExtra:bL};function xL({workpad:t}){if(!t)return;let s;try{const i=JSON.parse(t);if(i==null||typeof i!="object"||Array.isArray(i))return;s=i}catch{return o.jsxs("div",{className:Da.workpadSection,"data-testid":"workpad-panel",children:[o.jsx("div",{className:Da.workpadLabel,children:"Workpad"}),o.jsx("div",{className:Da.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return o.jsxs("div",{className:Da.workpadSection,"data-testid":"workpad-panel",children:[o.jsx("div",{className:Da.workpadLabel,children:"Workpad"}),s.status&&o.jsx("div",{className:Da.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&o.jsx("div",{className:Da.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&o.jsx("div",{className:Da.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const _L="_overviewDashboard_r05qm_1",kL="_overviewHero_r05qm_7",SL="_statusBadge_r05qm_14",TL="_statusPending_r05qm_26",wL="_statusAssigned_r05qm_31",jL="_statusInProgress_r05qm_36",NL="_statusReview_r05qm_41",CL="_statusDone_r05qm_46",EL="_statusFailed_r05qm_51",AL="_statusWaitingInput_r05qm_56",DL="_overviewBranchPill_r05qm_61",RL="_branchLink_r05qm_76",ML="_overviewSection_r05qm_87",IL="_overviewLabel_r05qm_93",OL="_overviewValue_r05qm_100",LL="_overviewMuted_r05qm_105",BL="_overviewMarkdown_r05qm_111",zL="_envRow_r05qm_180",UL="_envDot_r05qm_186",$L="_envDotGreen_r05qm_193",PL="_envDotYellow_r05qm_197",HL="_envDotRed_r05qm_201",VL="_envDotGray_r05qm_205",qL="_depList_r05qm_209",GL="_depItem_r05qm_215",FL="_depBlocked_r05qm_222",ZL="_depDone_r05qm_226",KL="_timeline_r05qm_230",YL="_timelineRow_r05qm_236",JL="_timelineKey_r05qm_243",WL="_timelineValue_r05qm_249",XL="_timelineDelta_r05qm_253",QL="_reviewNotes_r05qm_264",ye={overviewDashboard:_L,overviewHero:kL,statusBadge:SL,statusPending:TL,statusAssigned:wL,statusInProgress:jL,statusReview:NL,statusDone:CL,statusFailed:EL,statusWaitingInput:AL,overviewBranchPill:DL,branchLink:RL,overviewSection:ML,overviewLabel:IL,overviewValue:OL,overviewMuted:LL,overviewMarkdown:BL,envRow:zL,envDot:UL,envDotGreen:$L,envDotYellow:PL,envDotRed:HL,envDotGray:VL,depList:qL,depItem:GL,depBlocked:FL,depDone:ZL,timeline:KL,timelineRow:YL,timelineKey:JL,timelineValue:WL,timelineDelta:XL,reviewNotes:QL};function Lc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function vp(t,s){if(!t||!s)return;const i=new Date(s).getTime()-new Date(t).getTime();if(isNaN(i)||i<0)return;const r=Math.floor(i/6e4),c=Math.floor(i%6e4/1e3);if(r===0)return`${c}s`;const d=Math.floor(r/60),u=r%60;return d===0?`${r}m ${c}s`:`${d}h ${u}m`}function Hb(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?ye.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?ye.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?ye.envDotRed:ye.envDotGray}function eB({status:t}){const s=za(t),i=ew(t);return o.jsx("span",{className:`${ye.statusBadge} ${ye[i]??ye.statusPending}`,"data-testid":"task-overview-status-badge",children:s.label})}function tB({task:t,tasksById:s,environments:i,workspaces:r,taskSessions:c,selectedEnvId:d,taskUsage:u,treeUsage:p}){const m=c.length>0?c[c.length-1]:void 0,g=(m==null?void 0:m.environmentId)??"",v=g?i.find(k=>k.id===g):void 0,b=r.find(k=>k.id===t.workspaceId),x=i.find(k=>k.id===d),S=t.branch&&(b!=null&&b.repoUrl)?`${b.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return o.jsxs("div",{className:ye.overviewDashboard,"data-testid":"task-overview-panel",children:[o.jsxs("div",{className:ye.overviewHero,children:[o.jsx(eB,{status:t.status}),t.branch&&o.jsx("span",{className:ye.overviewBranchPill,"data-testid":"task-overview-branch",children:S?o.jsxs("a",{href:S,target:"_blank",rel:"noreferrer noopener",className:ye.branchLink,children:["🔗"," ",t.branch]}):o.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-description",children:[o.jsx("div",{className:ye.overviewLabel,children:"Description"}),o.jsx("div",{className:ye.overviewMarkdown,children:o.jsx(pd,{remarkPlugins:[md],children:t.description})})]}),t.workpad&&o.jsx(xL,{workpad:t.workpad}),o.jsxs("div",{className:ye.overviewSection,children:[o.jsx("div",{className:ye.overviewLabel,children:"Environment"}),g&&v?o.jsxs("div",{className:ye.envRow,"data-testid":"task-overview-environment",children:[o.jsx("span",{className:`${ye.envDot} ${Hb(v.status)}`,title:v.status,"aria-label":`Status: ${v.status}`,role:"img"}),o.jsx("span",{className:ye.overviewValue,children:v.displayName})]}):x?o.jsxs("div",{className:ye.envRow,"data-testid":"task-overview-environment",children:[o.jsx("span",{className:`${ye.envDot} ${Hb(x.status)}`,title:x.status,"aria-label":`Status: ${x.status}`,role:"img"}),o.jsx("span",{className:ye.overviewValue,children:x.displayName}),o.jsx("span",{className:ye.overviewMuted,children:"(workspace default)"})]}):o.jsx("div",{className:ye.overviewMuted,children:"Set in workspace settings"})]}),o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-dependencies",children:[o.jsx("div",{className:ye.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?o.jsx("div",{className:ye.overviewMuted,children:"None"}):o.jsx("div",{className:ye.depList,children:t.dependsOn.map(k=>{const w=s.get(k),N=(w==null?void 0:w.status)==="complete";return o.jsxs("div",{className:`${ye.depItem} ${N?ye.depDone:ye.depBlocked}`,children:[o.jsx("span",{children:N?"✓":"○"}),o.jsx("span",{children:(w==null?void 0:w.title)??k})]},k)})})]}),o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-timeline",children:[o.jsx("div",{className:ye.overviewLabel,children:"Timeline"}),o.jsxs("div",{className:ye.timeline,children:[t.createdAt&&o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Created"}),o.jsx("span",{className:ye.timelineValue,children:Lc(t.createdAt)})]}),t.assignedAt&&(()=>{const k=vp(t.createdAt,t.assignedAt);return o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Assigned"}),o.jsx("span",{className:ye.timelineValue,children:Lc(t.assignedAt)}),k!==void 0&&o.jsx("span",{className:ye.timelineDelta,children:k})]})})(),t.startedAt&&(()=>{const k=vp(t.assignedAt??t.createdAt,t.startedAt);return o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Started"}),o.jsx("span",{className:ye.timelineValue,children:Lc(t.startedAt)}),k!==void 0&&o.jsx("span",{className:ye.timelineDelta,children:k})]})})(),t.completedAt&&(()=>{const k=vp(t.startedAt,t.completedAt);return o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Completed"}),o.jsx("span",{className:ye.timelineValue,children:Lc(t.completedAt)}),k!==void 0&&o.jsx("span",{className:ye.timelineDelta,children:k})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&o.jsx("div",{className:ye.overviewMuted,children:"No timing data"})]})]}),u&&u.costUsd>0&&o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-usage",children:[o.jsx("div",{className:ye.overviewLabel,children:"Usage"}),o.jsxs("div",{className:ye.timeline,children:[o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Cost"}),o.jsx("span",{className:ye.timelineValue,children:Ro(u.costUsd)}),o.jsxs("span",{className:ye.timelineDelta,children:[u.sessionCount," session",u.sessionCount!==1?"s":""]})]}),p&&p.costUsd>u.costUsd&&o.jsxs("div",{className:ye.timelineRow,children:[o.jsx("span",{className:ye.timelineKey,children:"Total (incl. subtasks)"}),o.jsx("span",{className:ye.timelineValue,children:Ro(p.costUsd)}),o.jsxs("span",{className:ye.timelineDelta,children:[p.sessionCount," session",p.sessionCount!==1?"s":""]})]})]})]}),t.reviewNotes&&o.jsxs("div",{className:ye.overviewSection,"data-testid":"task-overview-review-notes",children:[o.jsx("div",{className:ye.overviewLabel,children:"Review Notes"}),o.jsx("div",{className:ye.reviewNotes,children:t.reviewNotes})]})]})}const nB="_container_legrg_1",sB="_header_legrg_8",aB="_headerTitle_legrg_35",iB="_badge_legrg_44",oB="_headerActions_legrg_54",rB="_body_legrg_61",lB="_formContent_legrg_73",cB="_section_legrg_85",dB="_label_legrg_91",uB="_nameInput_legrg_98",fB="_fieldInput_legrg_131",pB="_adapterSelect_legrg_164",mB="_readOnlyValue_legrg_198",hB="_codespaceSection_legrg_204",gB="_codespaceActions_legrg_210",vB="_creatingHint_legrg_216",yB="_errorHint_legrg_222",bB="_btnPrimary_legrg_235",xB="_btnGhost_legrg_266",ie={container:nB,header:sB,headerTitle:aB,badge:iB,headerActions:oB,body:rB,formContent:lB,section:cB,label:dB,nameInput:uB,fieldInput:fB,adapterSelect:pB,readOnlyValue:mB,codespaceSection:hB,codespaceActions:gB,creatingHint:vB,errorHint:yB,btnPrimary:bB,btnGhost:xB},Yc=1,Jc=65535;function yp(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=Yc&&s<=Jc}function bp(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function _B({codespaceName:t,onCodespaceNameChange:s,envName:i,onEnvNameChange:r,codespaces:c,codespaceError:d,codespaceListError:u,codespaceCreating:p,onCreateCodespace:m}){const[g,v]=y.useState("pick"),[b,x]=y.useState(""),[S,k]=y.useState("");return g==="create"?o.jsxs("div",{className:ie.codespaceSection,children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Repository"}),o.jsx("input",{type:"text",value:b,onChange:w=>x(w.target.value),placeholder:"owner/repo",className:ie.fieldInput,"data-testid":"env-codespace-repo"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Machine Type"}),o.jsx("input",{type:"text",value:S,onChange:w=>k(w.target.value),placeholder:"Machine type (optional)...",className:ie.fieldInput,"data-testid":"env-codespace-machine"})]}),o.jsxs("div",{className:ie.codespaceActions,children:[o.jsx("button",{onClick:()=>{b.trim()&&(m(b.trim(),S.trim()||void 0),v("pick"),x(""),k(""))},disabled:!b.trim(),className:ie.btnPrimary,children:"Create"}),o.jsx("button",{onClick:()=>{v("pick"),x(""),k("")},className:ie.btnGhost,children:"Cancel"})]})]}):o.jsx("div",{className:ie.codespaceSection,children:o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Codespace"}),!u&&o.jsxs("select",{value:t,onChange:w=>{w.target.value==="__create__"?(v("create"),s("")):(s(w.target.value),w.target.value&&!i.trim()&&r(w.target.value))},disabled:p,className:ie.adapterSelect,"data-testid":"env-codespace-select",children:[o.jsx("option",{value:"",children:"Select a codespace..."}),c.map(w=>o.jsxs("option",{value:w.name,children:[w.name," (",w.repository,") — ",w.state]},w.name)),o.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),p&&o.jsx("span",{className:ie.creatingHint,children:"Creating codespace..."}),u&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:ie.errorHint,children:u}),o.jsx("input",{type:"text",value:t,onChange:w=>s(w.target.value),placeholder:"Or enter codespace name manually...",className:ie.fieldInput,"data-testid":"env-codespace-manual"})]}),d&&!u&&o.jsx("span",{className:ie.errorHint,children:d})]})})}function N1({mode:t,environmentId:s,environments:i,onAddEnvironment:r,onUpdateEnvironment:c,onListCodespaces:d,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v,onShowToast:b}){const x=_t(),S=t==="edit",k=S&&s?i.find(ue=>ue.id===s):void 0,[w,N]=y.useState(""),[T,C]=y.useState("local"),[D,L]=y.useState(""),[A,R]=y.useState(""),[O,z]=y.useState(""),[$,X]=y.useState(""),[te,P]=y.useState(""),[re,H]=y.useState(""),[oe,E]=y.useState(""),[F,ae]=y.useState(null),pe=y.useCallback(()=>{const ue={};if(T==="local"){if(D.trim()&&(ue.host=D.trim()),A.trim()){const xe=Number(A);Number.isInteger(xe)&&(ue.port=xe)}}else if(T==="ssh"){if(ue.host=D.trim(),O.trim()&&(ue.user=O.trim()),A.trim()){const xe=Number(A);Number.isInteger(xe)&&(ue.sshPort=xe)}$.trim()&&(ue.identityFile=$.trim())}else T==="docker"?(te.trim()&&(ue.image=te.trim()),re.trim()&&(ue.repo=re.trim())):T==="codespace"&&(ue.codespaceName=oe.trim());return ue},[T,D,A,O,$,te,re,oe]),de=()=>!(!w.trim()||T==="ssh"&&!D.trim()||T==="codespace"&&!oe.trim()||(T==="local"||T==="ssh")&&!yp(A)),Oe=()=>{de()&&(r(w.trim(),T,pe()),b==null||b("Environment added successfully","success"),x(Do,{replace:!0}))},ke=()=>{x(s?Si(s):Do)},Ee=y.useCallback((ue,xe)=>{if(!k||!s)return;const me=bp(k.adapterConfig),Be=xe.trim();Be?me[ue]=Be:delete me[ue],c(s,{adapterConfig:me})},[k,s,c]),ze=y.useCallback((ue,xe)=>{if(!k||!s)return;const me=bp(k.adapterConfig);if(xe.trim()){const Be=Number(xe);Number.isInteger(Be)&&Be>=Yc&&Be<=Jc&&(me[ue]=Be)}else delete me[ue];c(s,{adapterConfig:me})},[k,s,c]);if(S){if(!k)return o.jsxs("div",{className:ie.container,children:[o.jsxs("div",{className:ie.header,children:[o.jsx("div",{className:ie.headerTitle,children:o.jsx("span",{className:ie.badge,children:"edit environment"})}),o.jsx("div",{className:ie.headerActions,children:o.jsx("button",{onClick:ke,className:ie.btnGhost,children:"Back"})})]}),o.jsx("div",{className:ie.body,children:o.jsx("div",{className:ie.formContent,children:o.jsx("span",{className:ie.readOnlyValue,children:"Environment not found"})})})]});const ue=bp(k.adapterConfig);return o.jsxs("div",{className:ie.container,"data-testid":"env-edit-panel",children:[o.jsxs("div",{className:ie.header,children:[o.jsx("div",{className:ie.headerTitle,children:o.jsx("span",{className:ie.badge,children:"edit environment"})}),o.jsx("div",{className:ie.headerActions,children:o.jsx("button",{onClick:ke,className:ie.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),o.jsx("div",{className:ie.body,children:o.jsxs("div",{className:ie.formContent,children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Name"}),o.jsx(ln,{value:k.displayName,onSave:xe=>{s&&c(s,{displayName:xe})},validate:xe=>xe.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:F,onActivate:ae,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Adapter Type"}),o.jsx("span",{className:ie.readOnlyValue,"data-testid":"env-edit-adapter-type",children:k.adapterType})]}),k.adapterType==="local"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Host"}),o.jsx(ln,{value:String(ue.host??""),onSave:xe=>Ee("host",xe),mode:"edit",fieldId:"host",activeFieldId:F,onActivate:ae,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Port"}),o.jsx(ln,{value:String(ue.port??""),onSave:xe=>ze("port",xe),validate:xe=>yp(xe)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:F,onActivate:ae,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),k.adapterType==="ssh"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Host"}),o.jsx(ln,{value:String(ue.host??""),onSave:xe=>Ee("host",xe),validate:xe=>xe.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:F,onActivate:ae,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"User"}),o.jsx(ln,{value:String(ue.user??""),onSave:xe=>Ee("user",xe),mode:"edit",fieldId:"user",activeFieldId:F,onActivate:ae,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"SSH Port"}),o.jsx(ln,{value:String(ue.sshPort??""),onSave:xe=>ze("sshPort",xe),validate:xe=>yp(xe)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:F,onActivate:ae,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Identity File"}),o.jsx(ln,{value:String(ue.identityFile??""),onSave:xe=>Ee("identityFile",xe),mode:"edit",fieldId:"identityFile",activeFieldId:F,onActivate:ae,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),k.adapterType==="docker"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Image"}),o.jsx(ln,{value:String(ue.image??""),onSave:xe=>Ee("image",xe),mode:"edit",fieldId:"image",activeFieldId:F,onActivate:ae,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Repo"}),o.jsx(ln,{value:String(ue.repo??""),onSave:xe=>Ee("repo",xe),mode:"edit",fieldId:"repo",activeFieldId:F,onActivate:ae,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),k.adapterType==="codespace"&&o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,children:"Codespace Name"}),o.jsx(ln,{value:String(ue.codespaceName??""),onSave:xe=>Ee("codespaceName",xe),validate:xe=>xe.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:F,onActivate:ae,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return o.jsxs("div",{className:ie.container,"data-testid":"env-create-panel",children:[o.jsxs("div",{className:ie.header,children:[o.jsx("div",{className:ie.headerTitle,children:o.jsx("span",{className:ie.badge,children:"new environment"})}),o.jsxs("div",{className:ie.headerActions,children:[o.jsx("button",{onClick:Oe,disabled:!de(),className:ie.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),o.jsx("button",{onClick:ke,className:ie.btnGhost,children:"Cancel"})]})]}),o.jsx("div",{className:ie.body,children:o.jsxs("div",{className:ie.formContent,children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-name",children:"Name"}),o.jsx("input",{id:"env-create-name",type:"text",value:w,onChange:ue=>N(ue.target.value),placeholder:"Environment name...",autoFocus:!0,className:ie.nameInput,"data-testid":"env-create-name",onKeyDown:ue=>{ue.key==="Enter"&&de()&&Oe()}})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),o.jsxs("select",{id:"env-create-adapter",value:T,onChange:ue=>{C(ue.target.value),ue.target.value==="codespace"&&d()},className:ie.adapterSelect,"data-testid":"env-create-adapter",children:[o.jsx("option",{value:"local",children:"local"}),o.jsx("option",{value:"ssh",children:"ssh"}),o.jsx("option",{value:"docker",children:"docker"}),o.jsx("option",{value:"codespace",children:"codespace"})]})]}),T==="local"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-host",children:"Host"}),o.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:ue=>L(ue.target.value),placeholder:"Host (optional)...",className:ie.fieldInput,"data-testid":"env-create-host"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-port",children:"Port"}),o.jsx("input",{id:"env-create-port",type:"number",min:Yc,max:Jc,value:A,onChange:ue=>R(ue.target.value),placeholder:"Port (optional)...",className:ie.fieldInput,"data-testid":"env-create-port"})]})]}),T==="ssh"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-host",children:"Host"}),o.jsx("input",{id:"env-create-host",type:"text",value:D,onChange:ue=>L(ue.target.value),placeholder:"Host (required)...",className:ie.fieldInput,"data-testid":"env-create-host"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-user",children:"User"}),o.jsx("input",{id:"env-create-user",type:"text",value:O,onChange:ue=>z(ue.target.value),placeholder:"User (optional)...",className:ie.fieldInput,"data-testid":"env-create-user"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-port",children:"SSH Port"}),o.jsx("input",{id:"env-create-port",type:"number",min:Yc,max:Jc,value:A,onChange:ue=>R(ue.target.value),placeholder:"SSH port (optional)...",className:ie.fieldInput,"data-testid":"env-create-port"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-identity",children:"Identity File"}),o.jsx("input",{id:"env-create-identity",type:"text",value:$,onChange:ue=>X(ue.target.value),placeholder:"Identity file (optional)...",className:ie.fieldInput,"data-testid":"env-create-identity"})]})]}),T==="docker"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-image",children:"Image"}),o.jsx("input",{id:"env-create-image",type:"text",value:te,onChange:ue=>P(ue.target.value),placeholder:"Image (optional)...",className:ie.fieldInput,"data-testid":"env-create-image"})]}),o.jsxs("div",{className:ie.section,children:[o.jsx("label",{className:ie.label,htmlFor:"env-create-repo",children:"Repo"}),o.jsx("input",{id:"env-create-repo",type:"text",value:re,onChange:ue=>H(ue.target.value),placeholder:"Repo (optional)...",className:ie.fieldInput,"data-testid":"env-create-repo"})]})]}),T==="codespace"&&o.jsx(_B,{codespaceName:oe,onCodespaceNameChange:E,envName:w,onEnvNameChange:N,codespaces:u,codespaceError:p,codespaceListError:m,codespaceCreating:g,onCreateCodespace:v})]})})]})}const kB="_group_1iprv_1",SB="_groupTitle_1iprv_8",TB="_shortcutList_1iprv_17",wB="_shortcutRow_1iprv_23",jB="_keys_1iprv_36",NB="_kbd_1iprv_43",CB="_description_1iprv_60",yi={group:kB,groupTitle:SB,shortcutList:TB,shortcutRow:wB,keys:jB,kbd:NB,description:CB},EB=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"},{keys:["3"],description:"Switch to Findings tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Chat",shortcuts:[{keys:["Enter"],description:"Send message (when input is focused)"}]}];function AB(){return o.jsxs("section",{className:ge.section,"data-testid":"keyboard-shortcuts-panel",children:[o.jsx("h3",{className:ge.sectionTitle,children:"Keyboard Shortcuts"}),o.jsx("p",{className:ge.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),EB.map(t=>o.jsxs("div",{className:yi.group,children:[o.jsx("h4",{className:yi.groupTitle,children:t.title}),o.jsx("div",{className:yi.shortcutList,children:t.shortcuts.map(s=>o.jsxs("div",{className:yi.shortcutRow,children:[o.jsx("span",{className:yi.keys,children:s.keys.map(i=>o.jsx("kbd",{className:yi.kbd,children:i},i))}),o.jsx("span",{className:yi.description,children:s.description})]},s.description))})]},t.title))]})}const DB=[{key:"claude",label:"Claude",description:"Forward Claude credentials for AI agent access.",options:[{value:"off",label:"Off"},{value:"subscription",label:"Subscription"},{value:"api_key",label:"API Key"}]},{key:"github",label:"GitHub",description:"Forward GITHUB_TOKEN and GH_TOKEN for git operations.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"copilot",label:"Copilot",description:"Forward Copilot tokens (COPILOT_GITHUB_TOKEN, CLI config).",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"codex",label:"Codex",description:"Forward OPENAI_API_KEY for Codex/OpenAI access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"goose",label:"Goose",description:"Forward Goose config and API keys for Goose agent access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]}];function RB({credentialProviders:t,onUpdateCredentialProviders:s}){const i=(r,c)=>{const d={...t};r==="claude"?d.claude=c:d[r]=c,s(d)};return o.jsxs("section",{className:ge.section,children:[o.jsx("h3",{className:ge.sectionTitle,children:"Credential Providers"}),o.jsx("p",{className:ge.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),o.jsx("div",{className:ge.tokenList,children:DB.map(r=>o.jsxs("div",{className:ge.tokenRow,children:[o.jsx("span",{className:ge.tokenName,children:r.label}),o.jsx("span",{className:ge.tokenTarget,children:r.description}),o.jsx("select",{className:ge.select,value:t[r.key],onChange:c=>i(r.key,c.target.value),children:r.options.map(c=>o.jsx("option",{value:c.value,children:c.label},c.value))})]},r.key))})]})}const MB="_container_10efq_1",IB="_header_10efq_7",OB="_list_10efq_105",LB="_card_10efq_111",BB="_cardHeader_10efq_125",zB="_cardTitle_10efq_135",UB="_defaultBadge_10efq_141",$B="_cardActions_10efq_155",PB="_description_10efq_160",HB="_meta_10efq_166",VB="_empty_10efq_212",qB="_typeBadge_10efq_362",Jn={container:MB,header:IB,list:OB,card:LB,cardHeader:BB,cardTitle:zB,defaultBadge:UB,cardActions:$B,description:PB,meta:HB,empty:VB,typeBadge:qB};function GB({personas:t,appDefaultPersonaId:s,onDeletePersona:i,onSetAppDefaultPersonaId:r,onNavigateToNew:c,onNavigateToPersona:d}){const[u,p]=y.useState(null),m=u?t.find(v=>v.id===u):void 0,g=async v=>{await i(v),p(null)};return o.jsxs("div",{className:Jn.container,children:[o.jsxs("div",{className:Jn.header,children:[o.jsx("h2",{children:"Personas"}),o.jsx(Js,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?o.jsx("p",{className:Jn.empty,children:"No personas yet. Create one to get started."}):o.jsx("div",{className:Jn.list,children:t.map(v=>{const b=s===v.id,x=v.type==="script";return o.jsxs("div",{className:Jn.card,"data-testid":`persona-card-${v.id}`,onClick:()=>d(v.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),d(v.id))},children:[o.jsxs("div",{className:Jn.cardHeader,children:[o.jsxs("span",{className:Jn.cardTitle,children:[o.jsx("strong",{children:v.name}),o.jsx("span",{className:Jn.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:x?"Script":"Agent"}),b&&o.jsx("span",{className:Jn.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),o.jsxs("div",{className:Jn.cardActions,onClick:S=>S.stopPropagation(),children:[!b&&o.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>{r(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),o.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>d(v.id),children:"Edit"}),o.jsx(Js,{variant:"ghost",size:"sm",onClick:()=>p(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&o.jsx("p",{className:Jn.description,children:v.description}),o.jsxs("div",{className:Jn.meta,children:[v.runtime&&o.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&o.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&o.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),o.jsx(wi,{isOpen:u!==null,title:"Delete Persona?",description:`"${(m==null?void 0:m.name)??""}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:()=>{u&&g(u).catch(()=>{})},onCancel:()=>p(null)})]})}const FB="_container_uy08i_1",ZB="_header_uy08i_7",KB="_count_uy08i_13",YB="_presets_uy08i_18",JB="_presetButton_uy08i_24",WB="_filterInput_uy08i_41",XB="_groups_uy08i_53",QB="_group_uy08i_53",e8="_groupHeader_uy08i_68",t8="_groupName_uy08i_77",n8="_groupCount_uy08i_81",s8="_toolList_uy08i_87",a8="_toolItem_uy08i_95",i8="_toolName_uy08i_103",mn={container:FB,header:ZB,count:KB,presets:YB,presetButton:JB,filterInput:WB,groups:XB,group:QB,groupHeader:e8,groupName:t8,groupCount:n8,toolList:s8,toolItem:a8,toolName:i8},o8=(()=>{const t=new Map;for(const s of ox){const i=s==="get_version_status"?"version":s.split("_")[0];t.has(i)||t.set(i,[]),t.get(i).push(s)}return[...t.entries()].sort(([s],[i])=>s.localeCompare(i)).map(([s,i])=>({group:s,tools:i.sort()}))})(),r8=[{name:"default",label:"Default",tools:rx},{name:"worker",label:"Worker",tools:pT},{name:"orchestrator",label:"Orchestrator",tools:mT},{name:"admin",label:"Admin",tools:hT}];function Vb({selectedTools:t,onChange:s,disabled:i}){const[r,c]=y.useState(""),d=y.useMemo(()=>new Set(t),[t]),u=y.useCallback(v=>{if(i)return;const b=new Set(d);b.has(v)?b.delete(v):b.add(v),s([...b].sort())},[d,s,i]),p=y.useCallback((v,b)=>{if(i)return;const x=new Set(d);for(const S of v)b?x.delete(S):x.add(S);s([...x].sort())},[d,s,i]),m=y.useCallback(v=>{i||s([...v].sort())},[s,i]),g=r.toLowerCase();return o.jsxs("div",{className:mn.container,"data-testid":"mcp-tool-selector",children:[o.jsx("div",{className:mn.header,children:o.jsx("span",{className:mn.count,children:t.length===0?`Using default (${rx.length} tools)`:`${t.length} of ${ox.size} tools selected`})}),o.jsxs("div",{className:mn.presets,"data-testid":"mcp-tool-presets",children:[r8.map(v=>o.jsx("button",{type:"button",className:mn.presetButton,disabled:i,onClick:()=>m(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),o.jsx("button",{type:"button",className:mn.presetButton,disabled:i,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),o.jsx("input",{type:"text",className:mn.filterInput,placeholder:"Filter tools...",value:r,onChange:v=>c(v.target.value),disabled:i,"data-testid":"mcp-tool-filter"}),o.jsx("div",{className:mn.groups,children:o8.map(({group:v,tools:b})=>{const x=g?b.filter(k=>k.toLowerCase().includes(g)):b;if(x.length===0)return null;const S=x.every(k=>d.has(k));return o.jsxs("div",{className:mn.group,"data-testid":`tool-group-${v}`,children:[o.jsxs("label",{className:mn.groupHeader,children:[o.jsx("input",{type:"checkbox",checked:S,onChange:()=>p(x,S),disabled:i,"data-testid":`group-toggle-${v}`}),o.jsx("span",{className:mn.groupName,children:v}),o.jsxs("span",{className:mn.groupCount,children:["(",x.filter(k=>d.has(k)).length,"/",x.length,")"]})]}),o.jsx("div",{className:mn.toolList,children:x.map(k=>o.jsxs("label",{className:mn.toolItem,children:[o.jsx("input",{type:"checkbox",checked:d.has(k),onChange:()=>u(k),disabled:i,"data-testid":`tool-${k}`}),o.jsx("span",{className:mn.toolName,children:k})]},k))})]},v)})})]})}const l8="_nav_1bhou_1",c8="_tab_1bhou_24",d8="_tabIcon_1bhou_62",u8="_tabActive_1bhou_68",Bc={nav:l8,tab:c8,tabIcon:d8,tabActive:u8},Ks=[{path:"credentials",label:"Credentials",icon:o.jsx(S2,{size:Bt})},{path:"personas",label:"Personas",icon:o.jsx(W2,{size:Bt})},{path:"appearance",label:"Appearance",icon:o.jsx(U2,{size:Bt})},{path:"shortcuts",label:"Shortcuts",icon:o.jsx(w2,{size:Bt})},{path:"about",label:"About",icon:o.jsx(sm,{size:Bt})}];function f8(){var u;const t=Zt(),s=_t(),i=y.useRef(null),r=((u=Ks.find(p=>{const m=`${Eo}/${p.path}`;return t.pathname===m||t.pathname.startsWith(`${m}/`)}))==null?void 0:u.path)??Ks[0].path,c=y.useCallback(p=>{s(`${Eo}/${p}`)},[s]),d=y.useCallback(p=>{var S,k;const m=(S=i.current)==null?void 0:S.querySelectorAll('[role="tab"]');if(!m)return;const g=Array.from(m).findIndex(w=>w===document.activeElement),v=g>=0?g:Ks.findIndex(w=>w.path===r);let b=v;if(p.key==="ArrowDown"||p.key==="j"||p.key==="J")p.preventDefault(),b=(v+1)%Ks.length;else if(p.key==="ArrowUp"||p.key==="k"||p.key==="K")p.preventDefault(),b=(v-1+Ks.length)%Ks.length;else if(p.key==="Home")p.preventDefault(),b=0;else if(p.key==="End")p.preventDefault(),b=Ks.length-1;else return;const x=Ks[b].path;s(`${Eo}/${x}`),(k=m[b])==null||k.focus()},[r,s]);return o.jsx("nav",{className:Bc.nav,ref:i,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:d,children:Ks.map(p=>{const m=p.path===r;return o.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${Bc.tab} ${m?Bc.tabActive:""}`,onClick:()=>c(p.path),children:[o.jsx("span",{className:Bc.tabIcon,"aria-hidden":"true",children:p.icon}),p.label]},p.path)})})}function p8({tasks:t,taskStatusById:s,sessionStatusByTaskId:i}){const r=new Map;for(const d of t)if(d.parentTaskId){const u=r.get(d.parentTaskId);u?u.push(d):r.set(d.parentTaskId,[d])}const c=new Map(oy.map(d=>[d,[]]));for(const d of t){const u=rl(d.status),p=d.dependsOn.length>0&&d.dependsOn.some(k=>s.get(k)!=="complete"),m=r.get(d.id)??[],g=m.length,v=m.filter(k=>k.status==="complete").length;let b;if(u==="paused"&&i){const k=i.get(d.id);k==="idle"?b="Needs input":k==="completed"&&(b="Ready to complete")}const x={task:d,isBlocked:p,childCount:g,doneChildCount:v,pausedSubBadge:b},S=c.get(u);S?S.push(x):c.get("not_started").push(x)}for(const d of c.values())d.sort((u,p)=>u.task.sortOrder-p.task.sortOrder);return oy.map(d=>{const u=za(d);return{status:d,label:u.label,style:u,tasks:c.get(d)??[]}})}const m8="_boardContainer_1c4y1_1",h8="_column_1c4y1_17",g8="_columnHeader_1c4y1_34",v8="_columnIcon_1c4y1_47",y8="_columnLabel_1c4y1_52",b8="_columnCount_1c4y1_57",x8="_cardList_1c4y1_67",_8="_emptyPlaceholder_1c4y1_76",k8="_card_1c4y1_67",S8="_cardHeader_1c4y1_107",T8="_cardStatusIcon_1c4y1_113",w8="_cardTitle_1c4y1_119",j8="_cardBadges_1c4y1_127",N8="_badge_1c4y1_134",C8="_blockedBadge_1c4y1_146",E8="_childBadge_1c4y1_151",A8="_depBadge_1c4y1_155",D8="_parentBadge_1c4y1_159",R8="_pausedSubBadge_1c4y1_166",M8="_personaBadge_1c4y1_170",I8="_envBadge_1c4y1_174",O8="_emptyCta_1c4y1_178",L8="_ctaButton_1c4y1_188",B8="_ctaDescription_1c4y1_204",st={boardContainer:m8,column:h8,columnHeader:g8,columnIcon:v8,columnLabel:y8,columnCount:b8,cardList:x8,emptyPlaceholder:_8,card:k8,cardHeader:S8,cardStatusIcon:T8,cardTitle:w8,cardBadges:j8,badge:N8,blockedBadge:C8,childBadge:E8,depBadge:A8,parentBadge:D8,pausedSubBadge:R8,personaBadge:M8,envBadge:I8,emptyCta:O8,ctaButton:L8,ctaDescription:B8};function z8({workspaceId:t,environmentId:s,tasks:i,sessions:r,personas:c,environments:d}){const u=_t(),p=y.useMemo(()=>i.filter(x=>x.workspaceId===t),[i,t]),m=y.useMemo(()=>new Map(i.map(x=>[x.id,x.status])),[i]),g=y.useMemo(()=>new Map(p.map(x=>[x.id,x])),[p]),v=y.useMemo(()=>{const x=new Map(r.map(C=>[C.id,C])),S=new Map(c.map(C=>[C.id,C])),k=new Map(d.map(C=>[C.id,C])),w=new Map,N=new Map,T=new Map;for(const C of p)if(C.latestSessionId){const D=x.get(C.latestSessionId);if(D){if(w.set(C.id,D.endReason||D.status),D.personaId){const L=S.get(D.personaId);L&&N.set(C.id,L.name)}if(D.environmentId){const L=k.get(D.environmentId);L&&T.set(C.id,L.displayName)}}}return{sessionStatusByTaskId:w,personaNameByTaskId:N,environmentNameByTaskId:T}},[p,r,c,d]),b=y.useMemo(()=>p8({tasks:p,taskStatusById:m,sessionStatusByTaskId:v.sessionStatusByTaskId}),[p,m,v]);return p.length===0?o.jsxs("div",{className:st.emptyCta,"data-testid":"board-empty-cta",children:[o.jsx("button",{className:st.ctaButton,onClick:()=>u(Ci(t,void 0,s)),children:"Create Task"}),o.jsx("div",{className:st.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):o.jsx("div",{className:st.boardContainer,"data-testid":"board-container",children:b.map(x=>o.jsxs("section",{className:st.column,"data-testid":`board-column-${x.status}`,"aria-label":`${x.label}, ${x.tasks.length} ${x.tasks.length===1?"task":"tasks"}`,children:[o.jsxs("div",{className:st.columnHeader,children:[o.jsx("span",{className:st.columnIcon,style:{color:x.style.color},children:x.style.icon}),o.jsx("span",{className:st.columnLabel,children:x.label}),o.jsx("span",{className:st.columnCount,"data-testid":`board-count-${x.status}`,children:x.tasks.length})]}),o.jsx("div",{className:st.cardList,children:x.tasks.length===0?o.jsx("div",{className:st.emptyPlaceholder,children:"No tasks"}):o.jsx(ps,{mode:"popLayout",children:x.tasks.map(S=>o.jsx(Rt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:o.jsx(U8,{boardTask:S,tasksById:g,personaName:v.personaNameByTaskId.get(S.task.id),envName:v.environmentNameByTaskId.get(S.task.id),onClick:()=>u(In(S.task.id,void 0,t,s))})},S.task.id))})})]},x.status))})}function U8({boardTask:t,tasksById:s,personaName:i,envName:r,onClick:c}){const{task:d,isBlocked:u,childCount:p,doneChildCount:m,pausedSubBadge:g}=t,v=za(d.status),b=d.parentTaskId?s.get(d.parentTaskId):void 0;return o.jsxs("div",{className:st.card,tabIndex:0,role:"button","data-testid":`board-card-${d.id}`,onClick:c,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),c())},children:[o.jsxs("div",{className:st.cardHeader,children:[o.jsx("span",{className:st.cardStatusIcon,style:{color:v.color},children:v.icon}),o.jsx("span",{className:st.cardTitle,children:d.title})]}),o.jsxs("div",{className:st.cardBadges,children:[b&&o.jsx("span",{className:`${st.badge} ${st.parentBadge}`,title:b.title,children:b.title}),p>0&&o.jsxs("span",{className:`${st.badge} ${st.childBadge}`,children:[m,"/",p]}),u&&o.jsx("span",{className:`${st.badge} ${st.blockedBadge}`,children:"blocked"}),d.dependsOn.length>0&&!u&&o.jsx("span",{className:`${st.badge} ${st.depBadge}`,children:"dep"}),g&&o.jsx("span",{className:`${st.badge} ${st.pausedSubBadge}`,children:g}),i&&o.jsx("span",{className:`${st.badge} ${st.personaBadge}`,children:i}),r&&o.jsx("span",{className:`${st.badge} ${st.envBadge}`,children:r})]})]})}const $8="_formContent_ymnez_1",P8="_section_ymnez_13",H8="_label_ymnez_19",V8="_titleInput_ymnez_26",q8="_descriptionTextarea_ymnez_58",G8="_selectField_ymnez_94",F8="_checkboxRow_ymnez_128",Z8="_checkboxLabel_ymnez_141",K8="_fieldError_ymnez_146",yt={formContent:$8,section:P8,label:H8,titleInput:V8,descriptionTextarea:q8,selectField:G8,checkboxRow:F8,checkboxLabel:Z8,fieldError:K8};function Y8(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.environmentId)??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const J8=100;function W8({values:t,onChange:s,environments:i,personas:r,errors:c,disabled:d,autoFocusName:u}){const p=(m,g)=>{s({...t,[m]:g})};return o.jsxs("div",{className:yt.formContent,children:[o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-name",children:"Name"}),o.jsx("input",{id:"ws-name",className:yt.titleInput,type:"text",value:t.name,onChange:m=>p("name",m.target.value),placeholder:"Workspace name",maxLength:J8,autoFocus:u,disabled:d,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&o.jsx("span",{className:yt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-description",children:"Description"}),o.jsx("textarea",{id:"ws-description",className:yt.descriptionTextarea,value:t.description,onChange:m=>p("description",m.target.value),placeholder:"Optional description (Markdown supported)",disabled:d,"data-testid":"workspace-form-description"})]}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-repo",children:"Repository URL"}),o.jsx("input",{id:"ws-repo",className:yt.titleInput,type:"text",value:t.repoUrl,onChange:m=>p("repoUrl",m.target.value),placeholder:"https://github.com/org/repo",disabled:d,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&o.jsx("span",{className:yt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-environment",children:"Environment"}),o.jsxs("select",{id:"ws-environment",className:yt.selectField,value:t.environmentId,onChange:m=>p("environmentId",m.target.value),disabled:d,"data-testid":"workspace-form-environment",children:[o.jsx("option",{value:"",children:"Select environment…"}),i.map(m=>o.jsx("option",{value:m.id,children:m.displayName||m.id},m.id))]}),(c==null?void 0:c.environmentId)&&o.jsx("span",{className:yt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-persona",children:"Default Persona"}),o.jsxs("select",{id:"ws-persona",className:yt.selectField,value:t.defaultPersonaId,onChange:m=>p("defaultPersonaId",m.target.value),disabled:d,"data-testid":"workspace-form-persona",children:[o.jsx("option",{value:"",children:"(Inherit)"}),r.map(m=>o.jsx("option",{value:m.id,children:m.name},m.id))]})]}),o.jsx("div",{className:yt.section,children:o.jsxs("label",{className:yt.checkboxRow,children:[o.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:m=>p("useWorktrees",m.target.checked),disabled:d,"data-testid":"workspace-form-worktrees"}),o.jsx("span",{className:yt.checkboxLabel,children:"Enable worktree isolation"})]})}),o.jsxs("div",{className:yt.section,children:[o.jsx("label",{className:yt.label,htmlFor:"ws-workdir",children:"Working Directory"}),o.jsx("input",{id:"ws-workdir",className:yt.titleInput,type:"text",value:t.workingDirectory,onChange:m=>p("workingDirectory",m.target.value),placeholder:"Default (server default)",disabled:d,"data-testid":"workspace-form-workdir"})]})]})}const C1=y.createContext(void 0),X8=4e3;function Q8({children:t}){const[s,i]=y.useState([]),r=y.useRef(0),c=y.useCallback(u=>{i(p=>p.filter(m=>m.id!==u))},[]),d=y.useCallback((u,p="info",m=X8)=>{const g=`toast-${++r.current}`;i(v=>[...v,{id:g,message:u,variant:p,duration:m}])},[]);return o.jsx(C1.Provider,{value:{toasts:s,showToast:d,dismissToast:c},children:t})}function Tn(){const t=y.useContext(C1);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const Qp="grackle-theme",E1="grackle-prefer-system",A1="(prefers-color-scheme: dark)";let qr=[],Wc;function xp(){Wc=void 0;for(const t of qr)t()}function em(){return typeof window>"u"?!1:window.matchMedia(A1).matches}function Jr(){if(typeof localStorage>"u")return Pb;try{const t=localStorage.getItem(Qp);if(t!==null&&w1.has(t))return t}catch{}return Pb}function ud(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(E1)==="true"}catch{return!1}}function tm(t){return jd.find(s=>s.variantLightId===t||s.variantDarkId===t)}function D1(t,s){const i=Xp(t);if(i!=null&&i.variantDarkId)return s&&i.variantLightId?em()?i.variantDarkId:i.variantLightId:i.variantDarkId;if(i!=null&&i.hidden&&s){const r=tm(t);if(r!=null&&r.variantLightId&&r.variantDarkId)return em()?r.variantDarkId:r.variantLightId}return t}function ko(t,s,i=!1){i&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=D1(t,s),i&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&ko(Jr(),ud());function ez(){return Wc===void 0&&(Wc={themeId:Jr(),systemDark:em(),preferSystem:ud()}),Wc}function tz(t){return qr=[...qr,t],()=>{qr=qr.filter(s=>s!==t)}}function nz(){const t=y.useSyncExternalStore(tz,ez),{themeId:s,preferSystem:i}=t,r=D1(s,i),c=y.useCallback(u=>{if(w1.has(u)){try{localStorage.setItem(Qp,u)}catch{}ko(u,ud(),!0),xp()}},[]),d=y.useCallback(u=>{try{localStorage.setItem(E1,u?"true":"false")}catch{}if(u){const p=Jr(),m=Xp(p);if(m!=null&&m.hidden){const g=tm(p);if(g)try{localStorage.setItem(Qp,g.id)}catch{}}}ko(Jr(),u,!0),xp()},[]);return y.useEffect(()=>{ko(s,i)},[s,i]),y.useEffect(()=>{if(typeof window>"u")return;const u=window.matchMedia(A1),p=()=>{const m=Jr(),g=ud();if(g){const v=Xp(m);if(v!=null&&v.variantDarkId&&v.variantLightId&&ko(m,g),v!=null&&v.hidden){const b=tm(m);b!=null&&b.variantDarkId&&b.variantLightId&&ko(m,g)}}xp()};return u.addEventListener("change",p),()=>{u.removeEventListener("change",p)}},[]),{themeId:s,setTheme:c,resolvedThemeId:r,preferSystem:i,setPreferSystem:d}}const R1=y.createContext(void 0);function sz({children:t}){const s=nz();return o.jsx(R1.Provider,{value:s,children:t})}function M1(){const t=y.useContext(R1);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const I1=y.createContext(void 0),O1=y.createContext(void 0);function az({children:t}){const[s,i]=y.useState(void 0),r=y.useCallback(c=>{i(c)},[]);return o.jsx(O1.Provider,{value:r,children:o.jsx(I1.Provider,{value:s,children:t})})}function iz(){return y.useContext(I1)}function oz(){const t=y.useContext(O1);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const Qm=y.createContext(void 0);function ft(){const t=y.useContext(Qm);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function L1(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function B1(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function rz(t){return L1(t)&&typeof t.sessionId=="string"&&typeof t.eventType=="string"&&typeof t.timestamp=="string"&&typeof t.content=="string"&&(t.raw===void 0||typeof t.raw=="string")}const lz=new Set(["off","subscription","api_key"]),zc=new Set(["off","on"]);function cz(t){return L1(t)&&lz.has(t.claude)&&zc.has(t.github)&&zc.has(t.copilot)&&zc.has(t.codex)&&zc.has(t.goose)}function z1(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 U1(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 _o=5e3;function dz(t,s){const i=[];let r=t;const c=new Set;for(;r&&s.has(r)&&!c.has(r);){c.add(r);const d=s.get(r);i.unshift(d),r=d.parentTaskId||void 0}return i}const na={label:"Home",url:Ti};function uz(t){return t?[na,{label:"Settings",url:Eo},{label:t,url:void 0}]:[na,{label:"Settings",url:void 0}]}const eh={label:"Environments",url:Do};function fz(){return[na,{label:"Environments",url:void 0}]}function pz(){return[na,{label:"New Chat",url:void 0}]}function mz(t){return[na,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function hz(t,s,i,r){const c=i.find(u=>u.id===t),d=r.find(u=>u.id===s);return[na,eh,{label:(d==null?void 0:d.displayName)??"Environment",url:Si(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function gz(t,s,i,r,c){const d=dz(t,c),u=c.get(t),p=u==null?void 0:u.workspaceId,m=p?i.find(S=>S.id===p):void 0,g=s??(m==null?void 0:m.environmentId),v=g?r.find(S=>S.id===g):void 0,b=[na];v&&g&&(b.push(eh),b.push({label:v.displayName,url:Si(g)})),m&&g&&b.push({label:m.name,url:Ua(m.id,g)});for(let S=0;S<d.length-1;S++)b.push({label:d[S].title,url:In(d[S].id,void 0,p,g)});const x=d[d.length-1];return b.push({label:(x==null?void 0:x.title)??t,url:void 0}),b}const vz={label:"Findings",url:bd};function yz(){return[na,{label:"Findings",url:void 0}]}function $1(t,s,i,r,c){const d=[na];if(s&&i){const u=r.find(m=>m.id===s),p=c.find(m=>m.id===i);d.push(eh),p&&d.push({label:p.displayName,url:Si(i)}),u&&d.push({label:u.name,url:Ua(s,i)}),d.push({label:"Findings",url:iN(s,i)})}else d.push(vz);return d.push({label:t,url:void 0}),d}function th(t){const s=[];for(const i of t){const r=s[s.length-1];i.eventType==="text"&&(r==null?void 0:r.eventType)==="text"?s[s.length-1]={...r,content:r.content+i.content}:s.push(i)}return s}function Uc(t){if(typeof t.id=="string")return t.id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const i=t.item;if(i&&typeof i.id=="string")return i.id}function bz(t){if(typeof t.tool_use_id=="string")return t.tool_use_id;const s=t.data;if(s&&typeof s.toolCallId=="string")return s.toolCallId;const i=t.item;if(i&&typeof i.id=="string")return i.id}function nh(t){const s=new Map;for(const v of t)if(v.raw)try{s.set(v,JSON.parse(v.raw))}catch{}const i=new Map;for(const v of t){if(v.eventType!=="tool_use")continue;const b=s.get(v),x=b?Uc(b):void 0;if(x)try{const S=JSON.parse(v.content);i.set(x,{tool:S.tool,args:S.args})}catch{}}const r=new Set,c=new Set,d=t.map((v,b)=>{if(v.eventType!=="tool_result")return v;const x=s.get(v),S=x?bz(x):void 0;if(!S)return v;const k=i.get(S);if(!k)return v;r.add(S),c.add(b);let w;const N=v.content.trim();if(N.startsWith("{"))try{const T=JSON.parse(N);typeof T.detailedContent=="string"&&(w=T.detailedContent)}catch{}return{...v,toolUseCtx:{...k,detailedResult:w}}}),u=[];for(let v=0;v<d.length;v++){if(d[v].eventType!=="tool_use")continue;const b=s.get(d[v]),x=b?Uc(b):void 0;x&&r.has(x)||u.push(v)}const p=[];for(let v=0;v<d.length;v++)d[v].eventType!=="tool_result"||c.has(v)||p.push(v);let m=0;for(const v of u){for(;m<p.length&&p[m]<v;)m++;if(m>=p.length)break;const b=p[m];if(b!==v+1)continue;const x=d[v],S=d[b];let k;try{const w=JSON.parse(x.content);k={tool:w.tool,args:w.args}}catch{}if(k){let w;const N=S.content.trim();if(N.startsWith("{"))try{const D=JSON.parse(N);typeof D.detailedContent=="string"&&(w=D.detailedContent)}catch{}d[b]={...S,toolUseCtx:{...k,detailedResult:w}},c.add(b);const T=s.get(x),C=T?Uc(T):void 0;C?r.add(C):(r.add(`__seq_${v}`),s.set(x,{...T??{},__seqId:`__seq_${v}`})),m++}}const g=d.filter(v=>{if(v.eventType!=="tool_use")return!0;const b=s.get(v);if(!b)return!0;const x=Uc(b);if(x&&r.has(x))return!1;const S=b.__seqId;return!(S&&r.has(S))});for(let v=0;v<g.length;v++){if(g[v].eventType!=="tool_use")continue;let b=!1;for(let x=v+1;x<g.length;x++)if(g[x].eventType!=="tool_use"){b=!0;break}b&&(g[v]={...g[v],settled:!0})}return g}function xz(t,s,i){const r=t.filter(m=>m.status==="running"||m.status==="idle"||m.status==="waiting").length,c=P1(s),d=s.filter(m=>nm(m,c)).length,u=s.filter(m=>m.status==="paused"||m.status==="failed"||nm(m,c)).length,p=i.filter(m=>m.status==="disconnected"||m.status==="error").length;return{activeSessions:r,blockedTasks:d,attentionTasks:u,unhealthyEnvironments:p}}function P1(t){const s=new Map;for(const i of t)s.set(i.id,i.status);return s}function nm(t,s){return t.dependsOn.some(i=>s.get(i)!=="complete")}function _z(t,s){var u;const i=new Map;for(const p of s)i.set(p.id,p);const r=P1(t),c=[];for(const p of t){const m=p.workspaceId?((u=i.get(p.workspaceId))==null?void 0:u.name)??"Unknown":"Unknown";p.status==="failed"?c.push({task:p,reason:"failed",workspaceName:m}):nm(p,r)?c.push({task:p,reason:"blocked",workspaceName:m}):p.status==="paused"&&c.push({task:p,reason:"paused",workspaceName:m})}const d={failed:0,blocked:1,paused:2};return c.sort((p,m)=>(d[p.reason]??3)-(d[m.reason]??3)),c}function kz(t,s){const i=new Map;for(const r of s)i.set(r.id,r);return t.filter(r=>r.status==="running"||r.status==="idle"||r.status==="waiting").map(r=>{var c;return{session:r,environmentName:((c=i.get(r.environmentId))==null?void 0:c.displayName)??"Unknown"}})}function Sz(t,s,i){const r=new Map;for(const c of s){if(!c.workspaceId)continue;let d=r.get(c.workspaceId);d||(d={totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0},r.set(c.workspaceId,d)),d.totalTasks+=1,c.status==="complete"?d.completedTasks+=1:c.status==="working"?d.workingTasks+=1:c.status==="failed"&&(d.failedTasks+=1)}return t.map(c=>{const d=r.get(c.id)??{totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0};return{workspace:c,totalTasks:d.totalTasks,completedTasks:d.completedTasks,workingTasks:d.workingTasks,failedTasks:d.failedTasks}})}const ks=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
275
275
  export function verifyToken(req: Request, res: Response, next: NextFunction): void {
276
276
  const header = req.headers.authorization;
277
277
  if (!header?.startsWith("Bearer ")) {
@@ -712,4 +712,4 @@ const grackle = await host.mcpServer({
712
712
  url: env.vars.GRACKLE_MCP_URL,
713
713
  });
714
714
 
715
- $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),R==="agent"&&o.jsxs("div",{children:[o.jsx("label",{children:"Allowed MCP Tools"}),o.jsx(Vb,{selectedTools:X,onChange:se=>{te(se),me(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,se),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!Ee&&!ke&&o.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,o.jsx(wi,{isOpen:P,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:xe,onCancel:()=>re(!1)})]})}function xP(){const{themeId:t,resolvedThemeId:s,setTheme:i,preferSystem:r,setPreferSystem:c}=M1();return o.jsx(PO,{themeId:t,resolvedThemeId:s,onSetTheme:i,preferSystem:r,onSetPreferSystem:c})}function _P(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let i=!1;return(async()=>{try{const c=await je.getVersionStatus({});i||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{i=!0}},[]),t}function kP(){const{connected:t,environments:{environments:s},sessions:{sessions:i}}=ft(),r=_P();return o.jsxs(o.Fragment,{children:[r&&o.jsx(GI,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),o.jsx(HO,{connected:t,environments:s,sessions:i})]})}function SP(){return o.jsx(AB,{})}const nx=Ci();function TP(){const t=_t();return Qs({key:"?"},()=>{t(tN)}),Qs({key:"n"},()=>{t(nx)}),Qs({key:"N"},()=>{t(nx)}),o.jsx(o.Fragment,{})}function ml(t){const s=oz();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function wP(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=ft(),i=y.useMemo(()=>o.jsx(_I,{workspaces:t,tasks:s}),[t,s]);return ml(i),o.jsx(Va,{})}function jP(){const{environments:{environments:t}}=ft(),s=y.useMemo(()=>o.jsx(D5,{environments:t}),[t]);return ml(s),o.jsx(Va,{})}function NP(){const t=y.useMemo(()=>o.jsx(f8,{}),[]);return ml(t),o.jsx(Va,{})}function CP(){const{findings:{findings:t,loadFindings:s,loadAllFindings:i}}=ft(),{workspaceId:r,environmentId:c}=ms();y.useEffect(()=>{r?s(r).catch(()=>{}):i().catch(()=>{})},[r,s,i]);const d=y.useMemo(()=>o.jsx(H5,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return ml(d),o.jsx(Va,{})}function EP(){const{knowledge:t,workspaces:{workspaces:s}}=ft(),i=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>o.jsx(q4,{nodes:t.graphData.nodes,workspaces:s,loading:t.loading,searchQuery:t.searchQuery,onSearch:i,onClearSearch:r,onSelectNode:c,onWorkspaceChange:d}),[t,s,i,r,c,d]);return ml(u),o.jsx(Va,{})}const AP="_container_ce571_1",DP="_title_ce571_6",fd={container:AP,title:DP};function RP(){return o.jsxs("div",{className:fd.container,"aria-hidden":"true",children:[o.jsx("h1",{className:fd.title,children:"Findings"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>o.jsx(ld,{lines:3},s))})]})}function sx(){const{environmentId:t,workspaceId:s}=ms(),{findings:{findings:i,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=ft(),p=_t();y.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=y.useCallback(v=>{p(Rp(v,s,t))},[p,s,t]);if(r)return o.jsx(RP,{});const g=s&&t?$1("Findings",s,t,d,u).slice(0,-1):yz();return o.jsxs("div",{className:fd.container,"data-testid":"findings-list-page",children:[o.jsx(js,{segments:g}),o.jsx("h1",{className:fd.title,children:"Findings"}),o.jsx(T1,{findings:i,onFindingClick:m})]})}const MP="_container_1wwpb_1",IP="_notFound_1wwpb_6",OP="_header_1wwpb_12",LP="_categoryBadge_1wwpb_19",BP="_title_1wwpb_28",zP="_content_1wwpb_35",UP="_tags_1wwpb_77",$P="_tag_1wwpb_77",PP="_meta_1wwpb_92",HP="_metaTimestamp_1wwpb_100",VP="_metaLink_1wwpb_105",hn={container:MP,notFound:IP,header:OP,categoryBadge:LP,title:BP,content:zP,tags:UP,tag:$P,meta:PP,metaTimestamp:HP,metaLink:VP};function ax(){const{findingId:t,environmentId:s,workspaceId:i}=ms(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=ft(),m=_t();if(y.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return o.jsx("div",{className:hn.container,"data-testid":"finding-detail-page",children:o.jsx("div",{className:hn.notFound,children:"Loading..."})});if(!r)return o.jsx("div",{className:hn.container,"data-testid":"finding-detail-page",children:o.jsx("div",{className:hn.notFound,children:"Finding not found."})});const g=$1(r.title,i,s,u,p),v=dd(r.category);return o.jsxs("div",{className:hn.container,"data-testid":"finding-detail-page",children:[o.jsx(js,{segments:g}),o.jsxs("div",{className:hn.header,children:[o.jsx("span",{className:hn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),o.jsx("h1",{className:hn.title,children:r.title})]}),r.content&&o.jsx("div",{className:hn.content,children:o.jsx(pd,{remarkPlugins:[md],children:r.content})}),r.tags.length>0&&o.jsx("div",{className:hn.tags,children:r.tags.map(b=>o.jsx("span",{className:hn.tag,children:b},b))}),o.jsxs("div",{className:hn.meta,children:[o.jsx("span",{className:hn.metaTimestamp,title:r.createdAt,children:Xm(r.createdAt)}),r.taskId&&o.jsx("button",{type:"button",className:hn.metaLink,onClick:()=>{m(In(r.taskId))},children:"View Task"}),r.sessionId&&o.jsx("button",{type:"button",className:hn.metaLink,onClick:()=>{m(mm(r.sessionId))},children:"View Session"})]})]})}const qP="_wizard_1260s_1",GP="_container_1260s_10",FP="_stepContent_1260s_19",ZP="_logoArea_1260s_28",KP="_logoImage_1260s_32",YP="_heading_1260s_41",JP="_tagline_1260s_49",WP="_subtitle_1260s_56",XP="_featureList_1260s_64",QP="_runtimeGrid_1260s_89",e9="_runtimeCard_1260s_101",t9="_runtimeName_1260s_133",n9="_runtimeDescription_1260s_139",s9="_buttonRow_1260s_144",a9="_primaryButton_1260s_151",i9="_ghostButton_1260s_185",o9="_dots_1260s_213",r9="_dot_1260s_213",Ze={wizard:qP,container:GP,stepContent:FP,logoArea:ZP,logoImage:KP,heading:YP,tagline:JP,subtitle:WP,featureList:XP,runtimeGrid:QP,runtimeCard:e9,runtimeName:t9,runtimeDescription:n9,buttonRow:s9,primaryButton:a9,ghostButton:i9,dots:o9,dot:r9};function l9({onNext:t}){return o.jsxs("div",{className:Ze.stepContent,"data-testid":"setup-welcome",children:[o.jsx("div",{className:Ze.logoArea,children:o.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Ze.logoImage})}),o.jsx("h1",{className:Ze.heading,children:"Welcome to Grackle"}),o.jsx("p",{className:Ze.tagline,children:"Multi-agent orchestration for software teams"}),o.jsx("button",{type:"button",className:Ze.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function c9({onNext:t,onBack:s}){return o.jsxs("div",{className:Ze.stepContent,"data-testid":"setup-about",children:[o.jsx("h2",{className:Ze.heading,children:"What is Grackle?"}),o.jsxs("ul",{className:Ze.featureList,children:[o.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),o.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),o.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),o.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),o.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),o.jsxs("div",{className:Ze.buttonRow,children:[o.jsx("button",{type:"button",className:Ze.ghostButton,onClick:s,children:"Back"}),o.jsx("button",{type:"button",className:Ze.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const d9=[{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 u9({currentRuntime:t,onFinish:s,onBack:i,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),o.jsxs("div",{className:Ze.stepContent,"data-testid":"setup-runtime",children:[o.jsx("h2",{className:Ze.heading,children:"Choose Your Runtime"}),o.jsx("p",{className:Ze.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),o.jsx("div",{className:Ze.runtimeGrid,children:d9.map(u=>o.jsxs("button",{type:"button",className:Ze.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[o.jsx("span",{className:Ze.runtimeName,children:u.name}),o.jsx("span",{className:Ze.runtimeDescription,children:u.description})]},u.id))}),o.jsxs("div",{className:Ze.buttonRow,children:[o.jsx("button",{type:"button",className:Ze.ghostButton,onClick:i,children:"Back"}),o.jsx("button",{type:"button",className:Ze.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function f9(){return typeof Notification<"u"}function p9({onFinish:t,onBack:s,finishDisabled:i}){const r=f9(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return o.jsxs("div",{className:Ze.stepContent,"data-testid":"setup-notifications",children:[o.jsx("h2",{className:Ze.heading,children:"Stay in the Loop"}),o.jsx("p",{className:Ze.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?o.jsx("p",{className:Ze.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,o.jsxs("div",{className:Ze.buttonRow,children:[o.jsx("button",{type:"button",className:Ze.ghostButton,onClick:s,disabled:i,children:"Back"}),!c&&r?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:Ze.ghostButton,onClick:t,disabled:i,"data-testid":"setup-notifications-skip",children:"Skip"}),o.jsx("button",{type:"button",className:Ze.primaryButton,onClick:d,disabled:i,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):o.jsx("button",{type:"button",className:Ze.primaryButton,onClick:t,disabled:i,"data-testid":"setup-finish",children:"Finish"})]})]})}const m9=4,ix={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function h9(){const{personas:{personas:t,updatePersona:s},completeOnboarding:i,onboardingCompleted:r}=ft(),{showToast:c}=Tn(),d=_t(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,b]=y.useState(!1),x=t.find(w=>w.id==="claude-code"),S=y.useCallback(w=>{g(w),p(3)},[]),k=y.useCallback(()=>{const w=m;b(!0);const N=[];if(x&&w!==x.runtime){const C=ix[w]??"sonnet";N.push(s(x.id,void 0,void 0,void 0,w,C))}const T=t.find(C=>C.id===J0);if(T&&w!==T.runtime){const C=ix[w]??"sonnet";N.push(s(J0,void 0,void 0,void 0,w,C))}Promise.all(N).then(()=>i()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,x,t,s,i,d,c]);return r===!0?o.jsx(fs,{to:"/",replace:!0}):o.jsx("div",{className:Ze.wizard,"data-testid":"setup-wizard",children:o.jsxs("div",{className:Ze.container,children:[o.jsx(ps,{mode:"wait",children:o.jsxs(Rt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&o.jsx(l9,{onNext:()=>p(1)}),u===1&&o.jsx(c9,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&o.jsx(u9,{currentRuntime:m,onFinish:S,onBack:()=>p(1),finishDisabled:!x}),u===3&&o.jsx(p9,{onFinish:k,onBack:()=>p(2),finishDisabled:v})]},u)}),o.jsx("div",{className:Ze.dots,children:Array.from({length:m9},(w,N)=>o.jsx("span",{className:Ze.dot,"data-active":N===u},N))})]})})}const g9="_root_zndgp_1",v9="_body_zndgp_7",y9="_main_zndgp_19",b9="_sidebarWrapper_zndgp_26",x9="_overlay_zndgp_51",Gr={root:g9,body:v9,main:y9,sidebarWrapper:b9,overlay:x9},_9=y.lazy(()=>AT(()=>import("./KnowledgePage-CezpSlWG.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),H1=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function k9(){const{connected:t,environments:{environments:s},sessions:{sessions:i},tasks:{tasks:r}}=ft(),{toasts:c,dismissToast:d}=Tn(),u=Zt(),p=iz(),m=p!==void 0,[g,v]=y.useState(!1),b=y.useCallback(()=>v(x=>!x),[]);return y.useEffect(()=>{v(!1)},[u.pathname]),y.useEffect(()=>{if(!g)return;const x=S=>{S.key==="Escape"&&v(!1)};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x)}},[g]),o.jsxs(o.Fragment,{children:[o.jsx(e5,{connected:t,environments:s,sessions:i,onToggleSidebar:m?b:void 0,sidebarOpen:g}),o.jsx(r5,{}),o.jsxs("div",{className:Gr.body,children:[m&&o.jsx("div",{className:Gr.sidebarWrapper,"data-sidebar-open":g,children:o.jsx(p5,{content:p})}),m&&g&&o.jsx("div",{className:Gr.overlay,"data-testid":"drawer-overlay",onClick:()=>v(!1)}),o.jsxs("div",{className:Gr.main,children:[o.jsx(Va,{}),o.jsx(_5,{sessions:i,tasks:r,environments:s})]})]}),o.jsx(II,{toasts:c,onDismiss:d}),o.jsx(TP,{})]})}function S9(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:i,clearOperationError:r},tasks:{tasks:c},connected:d,onboardingCompleted:u}=ft(),{showToast:p}=Tn();a7(s,p),c7(c,p),i7(i,r,p);const m=_t(),g=Zt();return y.useEffect(()=>{t&&!g.pathname.includes("/tasks/")&&m(mm(t),{replace:!0})},[t,m,g.pathname]),d&&u===!1?o.jsx(fs,{to:"/setup",replace:!0}):o.jsx(az,{children:o.jsxs("div",{className:Gr.root,children:[H1&&o.jsx(DN,{}),o.jsx(k9,{})]})})}function Np(){const{workspaceId:t}=ms(),{workspaces:{workspaces:s}}=ft(),i=Zt(),r=s.find(m=>m.id===t);if(!(r!=null&&r.environmentId))return s.length===0?void 0:o.jsx(fs,{to:"/environments",replace:!0});const c=encodeURIComponent(t),d=`/workspaces/${c}`,u=i.pathname.startsWith(d)?i.pathname.slice(d.length):"",p=`/environments/${encodeURIComponent(r.environmentId)}/workspaces/${c}${u}${i.search}${i.hash}`;return o.jsx(fs,{to:p,replace:!0})}function T9(){return o.jsxs(gj,{children:[o.jsx(Ce,{path:"setup",element:o.jsx(h9,{})}),o.jsxs(Ce,{element:o.jsx(S9,{}),children:[o.jsx(Ce,{index:!0,element:o.jsx(FU,{})}),o.jsx(Ce,{path:"chat",element:o.jsx(n$,{})}),o.jsx(Ce,{path:"sessions/new",element:o.jsx(s$,{})}),o.jsx(Ce,{path:"sessions/:sessionId",element:o.jsx(r$,{})}),o.jsx(Ce,{element:o.jsx(EP,{}),children:o.jsx(Ce,{path:"knowledge",element:o.jsx(y.Suspense,{fallback:o.jsx(m1,{}),children:o.jsx(_9,{})})})}),o.jsxs(Ce,{element:o.jsx(wP,{}),children:[o.jsx(Ce,{path:"tasks",element:o.jsx(qU,{})}),o.jsx(Ce,{path:"tasks/new",element:o.jsx(Xb,{})}),o.jsx(Ce,{path:"tasks/:taskId",element:o.jsx(Ia,{})}),o.jsx(Ce,{path:"tasks/:taskId/edit",element:o.jsx(Ia,{})}),o.jsx(Ce,{path:"tasks/:taskId/stream",element:o.jsx(Ia,{})}),o.jsx(Ce,{path:"tasks/:taskId/findings",element:o.jsx(Ia,{})})]}),o.jsxs(Ce,{element:o.jsx(CP,{}),children:[o.jsx(Ce,{path:"findings",element:o.jsx(sx,{})}),o.jsx(Ce,{path:"findings/:findingId",element:o.jsx(ax,{})}),o.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:o.jsx(sx,{})}),o.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:o.jsx(ax,{})})]}),o.jsxs(Ce,{element:o.jsx(jP,{}),children:[o.jsx(Ce,{path:"workspaces",element:o.jsx(fs,{to:"/environments",replace:!0})}),o.jsx(Ce,{path:"workspaces/new",element:o.jsx(k$,{})}),o.jsx(Ce,{path:"workspaces/:workspaceId",element:o.jsx(Np,{})}),o.jsx(Ce,{path:"workspaces/:workspaceId/tasks/:taskId",element:o.jsx(Np,{})}),o.jsx(Ce,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:o.jsx(Np,{})}),o.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId",element:o.jsx(u$,{})}),o.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:o.jsx(Xb,{})}),o.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:o.jsx(Ia,{})}),o.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:o.jsx(Ia,{})}),o.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:o.jsx(Ia,{})}),o.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:o.jsx(Ia,{})}),o.jsxs(Ce,{path:"environments",element:o.jsx(E$,{}),children:[o.jsx(Ce,{index:!0,element:o.jsx(GU,{})}),o.jsx(Ce,{path:"new",element:o.jsx(T$,{})}),o.jsx(Ce,{path:":environmentId",element:o.jsx(aP,{})}),o.jsx(Ce,{path:":environmentId/edit",element:o.jsx(w$,{})})]})]}),o.jsx(Ce,{element:o.jsx(NP,{}),children:o.jsxs(Ce,{path:"settings",element:o.jsx(rP,{}),children:[o.jsx(Ce,{index:!0,element:o.jsx(fs,{to:"credentials",replace:!0})}),o.jsx(Ce,{path:"environments",element:o.jsx(fs,{to:"/environments",replace:!0})}),o.jsx(Ce,{path:"credentials",element:o.jsx(lP,{})}),o.jsx(Ce,{path:"tokens",element:o.jsx(fs,{to:"../credentials",replace:!0})}),o.jsx(Ce,{path:"personas",element:o.jsx(cP,{})}),o.jsx(Ce,{path:"personas/new",element:o.jsx(tx,{})}),o.jsx(Ce,{path:"personas/:personaId",element:o.jsx(tx,{})}),o.jsx(Ce,{path:"appearance",element:o.jsx(xP,{})}),o.jsx(Ce,{path:"shortcuts",element:o.jsx(SP,{})}),o.jsx(Ce,{path:"about",element:o.jsx(kP,{})})]})}),o.jsx(Ce,{path:"*",element:o.jsx(fs,{to:"/",replace:!0})})]})]})}const w9=1e4;function j9(){const{onboardingCompleted:t}=ft(),[s,i]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>i(!0),w9);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return o.jsx(ps,{mode:"wait",children:r?o.jsx(Rt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:o.jsx(m1,{})},"splash"):o.jsx(Rt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:o.jsx(Pj,{basename:"/".replace(/\/$/,""),children:o.jsx(T9,{})})},"app")})}function N9(){const t=H1?Mz:s7;return o.jsx(sz,{children:o.jsx(Q8,{children:o.jsx(t,{children:o.jsx(j9,{})})})})}NT.createRoot(document.getElementById("root")).render(o.jsx(y.StrictMode,{children:o.jsx(N9,{})}));export{js as B,Ox as K,ft as a,Rp as f,mm as s,In as t,_t as u};
715
+ $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),R==="agent"&&o.jsxs("div",{children:[o.jsx("label",{children:"Allowed MCP Tools"}),o.jsx(Vb,{selectedTools:X,onChange:se=>{te(se),me(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,se),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!Ee&&!ke&&o.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,o.jsx(wi,{isOpen:P,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:xe,onCancel:()=>re(!1)})]})}function xP(){const{themeId:t,resolvedThemeId:s,setTheme:i,preferSystem:r,setPreferSystem:c}=M1();return o.jsx(PO,{themeId:t,resolvedThemeId:s,onSetTheme:i,preferSystem:r,onSetPreferSystem:c})}function _P(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let i=!1;return(async()=>{try{const c=await je.getVersionStatus({});i||s({currentVersion:c.currentVersion,latestVersion:c.latestVersion,updateAvailable:c.updateAvailable,isDocker:c.isDocker})}catch{}})().catch(()=>{}),()=>{i=!0}},[]),t}function kP(){const{connected:t,environments:{environments:s},sessions:{sessions:i}}=ft(),r=_P();return o.jsxs(o.Fragment,{children:[r&&o.jsx(GI,{currentVersion:r.currentVersion,latestVersion:r.latestVersion,updateAvailable:r.updateAvailable,isDocker:r.isDocker}),o.jsx(HO,{connected:t,environments:s,sessions:i})]})}function SP(){return o.jsx(AB,{})}const nx=Ci();function TP(){const t=_t();return Qs({key:"?"},()=>{t(tN)}),Qs({key:"n"},()=>{t(nx)}),Qs({key:"N"},()=>{t(nx)}),o.jsx(o.Fragment,{})}function ml(t){const s=oz();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function wP(){const{workspaces:{workspaces:t},tasks:{tasks:s}}=ft(),i=y.useMemo(()=>o.jsx(_I,{workspaces:t,tasks:s}),[t,s]);return ml(i),o.jsx(Va,{})}function jP(){const{environments:{environments:t}}=ft(),s=y.useMemo(()=>o.jsx(D5,{environments:t}),[t]);return ml(s),o.jsx(Va,{})}function NP(){const t=y.useMemo(()=>o.jsx(f8,{}),[]);return ml(t),o.jsx(Va,{})}function CP(){const{findings:{findings:t,loadFindings:s,loadAllFindings:i}}=ft(),{workspaceId:r,environmentId:c}=ms();y.useEffect(()=>{r?s(r).catch(()=>{}):i().catch(()=>{})},[r,s,i]);const d=y.useMemo(()=>o.jsx(H5,{findings:t,workspaceId:r,environmentId:c}),[t,r,c]);return ml(d),o.jsx(Va,{})}function EP(){const{knowledge:t,workspaces:{workspaces:s}}=ft(),i=y.useCallback(p=>{t.search(p).catch(()=>{})},[t]),r=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(p=>{t.selectNode(p).catch(()=>{})},[t]),d=y.useCallback(p=>{t.loadRecent(p||void 0).catch(()=>{})},[t]),u=y.useMemo(()=>o.jsx(q4,{nodes:t.graphData.nodes,workspaces:s,loading:t.loading,searchQuery:t.searchQuery,onSearch:i,onClearSearch:r,onSelectNode:c,onWorkspaceChange:d}),[t,s,i,r,c,d]);return ml(u),o.jsx(Va,{})}const AP="_container_ce571_1",DP="_title_ce571_6",fd={container:AP,title:DP};function RP(){return o.jsxs("div",{className:fd.container,"aria-hidden":"true",children:[o.jsx("h1",{className:fd.title,children:"Findings"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:Array.from({length:4},(t,s)=>o.jsx(ld,{lines:3},s))})]})}function sx(){const{environmentId:t,workspaceId:s}=ms(),{findings:{findings:i,findingsLoading:r,loadFindings:c},workspaces:{workspaces:d},environments:{environments:u}}=ft(),p=_t();y.useEffect(()=>{s&&c(s).catch(()=>{})},[s,c]);const m=y.useCallback(v=>{p(Rp(v,s,t))},[p,s,t]);if(r)return o.jsx(RP,{});const g=s&&t?$1("Findings",s,t,d,u).slice(0,-1):yz();return o.jsxs("div",{className:fd.container,"data-testid":"findings-list-page",children:[o.jsx(js,{segments:g}),o.jsx("h1",{className:fd.title,children:"Findings"}),o.jsx(T1,{findings:i,onFindingClick:m})]})}const MP="_container_1wwpb_1",IP="_notFound_1wwpb_6",OP="_header_1wwpb_12",LP="_categoryBadge_1wwpb_19",BP="_title_1wwpb_28",zP="_content_1wwpb_35",UP="_tags_1wwpb_77",$P="_tag_1wwpb_77",PP="_meta_1wwpb_92",HP="_metaTimestamp_1wwpb_100",VP="_metaLink_1wwpb_105",hn={container:MP,notFound:IP,header:OP,categoryBadge:LP,title:BP,content:zP,tags:UP,tag:$P,meta:PP,metaTimestamp:HP,metaLink:VP};function ax(){const{findingId:t,environmentId:s,workspaceId:i}=ms(),{findings:{selectedFinding:r,findingLoading:c,loadFinding:d},workspaces:{workspaces:u},environments:{environments:p}}=ft(),m=_t();if(y.useEffect(()=>{t&&d(t).catch(()=>{})},[t,d]),c)return o.jsx("div",{className:hn.container,"data-testid":"finding-detail-page",children:o.jsx("div",{className:hn.notFound,children:"Loading..."})});if(!r)return o.jsx("div",{className:hn.container,"data-testid":"finding-detail-page",children:o.jsx("div",{className:hn.notFound,children:"Finding not found."})});const g=$1(r.title,i,s,u,p),v=dd(r.category);return o.jsxs("div",{className:hn.container,"data-testid":"finding-detail-page",children:[o.jsx(js,{segments:g}),o.jsxs("div",{className:hn.header,children:[o.jsx("span",{className:hn.categoryBadge,style:{background:v.bg,color:v.text},children:r.category}),o.jsx("h1",{className:hn.title,children:r.title})]}),r.content&&o.jsx("div",{className:hn.content,children:o.jsx(pd,{remarkPlugins:[md],children:r.content})}),r.tags.length>0&&o.jsx("div",{className:hn.tags,children:r.tags.map(b=>o.jsx("span",{className:hn.tag,children:b},b))}),o.jsxs("div",{className:hn.meta,children:[o.jsx("span",{className:hn.metaTimestamp,title:r.createdAt,children:Xm(r.createdAt)}),r.taskId&&o.jsx("button",{type:"button",className:hn.metaLink,onClick:()=>{m(In(r.taskId))},children:"View Task"}),r.sessionId&&o.jsx("button",{type:"button",className:hn.metaLink,onClick:()=>{m(mm(r.sessionId))},children:"View Session"})]})]})}const qP="_wizard_1260s_1",GP="_container_1260s_10",FP="_stepContent_1260s_19",ZP="_logoArea_1260s_28",KP="_logoImage_1260s_32",YP="_heading_1260s_41",JP="_tagline_1260s_49",WP="_subtitle_1260s_56",XP="_featureList_1260s_64",QP="_runtimeGrid_1260s_89",e9="_runtimeCard_1260s_101",t9="_runtimeName_1260s_133",n9="_runtimeDescription_1260s_139",s9="_buttonRow_1260s_144",a9="_primaryButton_1260s_151",i9="_ghostButton_1260s_185",o9="_dots_1260s_213",r9="_dot_1260s_213",Ze={wizard:qP,container:GP,stepContent:FP,logoArea:ZP,logoImage:KP,heading:YP,tagline:JP,subtitle:WP,featureList:XP,runtimeGrid:QP,runtimeCard:e9,runtimeName:t9,runtimeDescription:n9,buttonRow:s9,primaryButton:a9,ghostButton:i9,dots:o9,dot:r9};function l9({onNext:t}){return o.jsxs("div",{className:Ze.stepContent,"data-testid":"setup-welcome",children:[o.jsx("div",{className:Ze.logoArea,children:o.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Ze.logoImage})}),o.jsx("h1",{className:Ze.heading,children:"Welcome to Grackle"}),o.jsx("p",{className:Ze.tagline,children:"Multi-agent orchestration for software teams"}),o.jsx("button",{type:"button",className:Ze.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function c9({onNext:t,onBack:s}){return o.jsxs("div",{className:Ze.stepContent,"data-testid":"setup-about",children:[o.jsx("h2",{className:Ze.heading,children:"What is Grackle?"}),o.jsxs("ul",{className:Ze.featureList,children:[o.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),o.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),o.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),o.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),o.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),o.jsxs("div",{className:Ze.buttonRow,children:[o.jsx("button",{type:"button",className:Ze.ghostButton,onClick:s,children:"Back"}),o.jsx("button",{type:"button",className:Ze.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const d9=[{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 u9({currentRuntime:t,onFinish:s,onBack:i,finishDisabled:r}){const[c,d]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&d(t)},[t]),o.jsxs("div",{className:Ze.stepContent,"data-testid":"setup-runtime",children:[o.jsx("h2",{className:Ze.heading,children:"Choose Your Runtime"}),o.jsx("p",{className:Ze.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),o.jsx("div",{className:Ze.runtimeGrid,children:d9.map(u=>o.jsxs("button",{type:"button",className:Ze.runtimeCard,"data-selected":c===u.id,"aria-pressed":c===u.id,"data-testid":`runtime-card-${u.id}`,onClick:()=>d(u.id),children:[o.jsx("span",{className:Ze.runtimeName,children:u.name}),o.jsx("span",{className:Ze.runtimeDescription,children:u.description})]},u.id))}),o.jsxs("div",{className:Ze.buttonRow,children:[o.jsx("button",{type:"button",className:Ze.ghostButton,onClick:i,children:"Back"}),o.jsx("button",{type:"button",className:Ze.primaryButton,onClick:()=>{s(c)},disabled:r,"data-testid":"setup-runtime-next",children:"Next"})]})]})}function f9(){return typeof Notification<"u"}function p9({onFinish:t,onBack:s,finishDisabled:i}){const r=f9(),c=r&&Notification.permission!=="default";function d(){r&&Notification.requestPermission().catch(()=>{}),t()}return o.jsxs("div",{className:Ze.stepContent,"data-testid":"setup-notifications",children:[o.jsx("h2",{className:Ze.heading,children:"Stay in the Loop"}),o.jsx("p",{className:Ze.subtitle,children:"Grackle can send you a browser notification when an agent needs your input, so you never miss an important moment."}),c?o.jsx("p",{className:Ze.subtitle,children:Notification.permission==="granted"?"Notifications are already enabled.":"Notifications have been blocked. You can change this in your browser settings."}):null,o.jsxs("div",{className:Ze.buttonRow,children:[o.jsx("button",{type:"button",className:Ze.ghostButton,onClick:s,disabled:i,children:"Back"}),!c&&r?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:Ze.ghostButton,onClick:t,disabled:i,"data-testid":"setup-notifications-skip",children:"Skip"}),o.jsx("button",{type:"button",className:Ze.primaryButton,onClick:d,disabled:i,"data-testid":"setup-notifications-enable",children:"Enable Notifications"})]}):o.jsx("button",{type:"button",className:Ze.primaryButton,onClick:t,disabled:i,"data-testid":"setup-finish",children:"Finish"})]})]})}const m9=4,ix={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function h9(){const{personas:{personas:t,updatePersona:s},completeOnboarding:i,onboardingCompleted:r}=ft(),{showToast:c}=Tn(),d=_t(),[u,p]=y.useState(0),[m,g]=y.useState("claude-code"),[v,b]=y.useState(!1),x=t.find(w=>w.id==="claude-code"),S=y.useCallback(w=>{g(w),p(3)},[]),k=y.useCallback(()=>{const w=m;b(!0);const N=[];if(x&&w!==x.runtime){const C=ix[w]??"sonnet";N.push(s(x.id,void 0,void 0,void 0,w,C))}const T=t.find(C=>C.id===J0);if(T&&w!==T.runtime){const C=ix[w]??"sonnet";N.push(s(J0,void 0,void 0,void 0,w,C))}Promise.all(N).then(()=>i()).then(()=>{d("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),b(!1)})},[m,x,t,s,i,d,c]);return r===!0?o.jsx(fs,{to:"/",replace:!0}):o.jsx("div",{className:Ze.wizard,"data-testid":"setup-wizard",children:o.jsxs("div",{className:Ze.container,children:[o.jsx(ps,{mode:"wait",children:o.jsxs(Rt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[u===0&&o.jsx(l9,{onNext:()=>p(1)}),u===1&&o.jsx(c9,{onNext:()=>p(2),onBack:()=>p(0)}),u===2&&o.jsx(u9,{currentRuntime:m,onFinish:S,onBack:()=>p(1),finishDisabled:!x}),u===3&&o.jsx(p9,{onFinish:k,onBack:()=>p(2),finishDisabled:v})]},u)}),o.jsx("div",{className:Ze.dots,children:Array.from({length:m9},(w,N)=>o.jsx("span",{className:Ze.dot,"data-active":N===u},N))})]})})}const g9="_root_zndgp_1",v9="_body_zndgp_7",y9="_main_zndgp_19",b9="_sidebarWrapper_zndgp_26",x9="_overlay_zndgp_51",Gr={root:g9,body:v9,main:y9,sidebarWrapper:b9,overlay:x9},_9=y.lazy(()=>AT(()=>import("./KnowledgePage-DNSe88De.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),H1=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function k9(){const{connected:t,environments:{environments:s},sessions:{sessions:i},tasks:{tasks:r}}=ft(),{toasts:c,dismissToast:d}=Tn(),u=Zt(),p=iz(),m=p!==void 0,[g,v]=y.useState(!1),b=y.useCallback(()=>v(x=>!x),[]);return y.useEffect(()=>{v(!1)},[u.pathname]),y.useEffect(()=>{if(!g)return;const x=S=>{S.key==="Escape"&&v(!1)};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x)}},[g]),o.jsxs(o.Fragment,{children:[o.jsx(e5,{connected:t,environments:s,sessions:i,onToggleSidebar:m?b:void 0,sidebarOpen:g}),o.jsx(r5,{}),o.jsxs("div",{className:Gr.body,children:[m&&o.jsx("div",{className:Gr.sidebarWrapper,"data-sidebar-open":g,children:o.jsx(p5,{content:p})}),m&&g&&o.jsx("div",{className:Gr.overlay,"data-testid":"drawer-overlay",onClick:()=>v(!1)}),o.jsxs("div",{className:Gr.main,children:[o.jsx(Va,{}),o.jsx(_5,{sessions:i,tasks:r,environments:s})]})]}),o.jsx(II,{toasts:c,onDismiss:d}),o.jsx(TP,{})]})}function S9(){const{sessions:{lastSpawnedId:t},environments:{environments:s,operationError:i,clearOperationError:r},tasks:{tasks:c},connected:d,onboardingCompleted:u}=ft(),{showToast:p}=Tn();a7(s,p),c7(c,p),i7(i,r,p);const m=_t(),g=Zt();return y.useEffect(()=>{t&&!g.pathname.includes("/tasks/")&&m(mm(t),{replace:!0})},[t,m,g.pathname]),d&&u===!1?o.jsx(fs,{to:"/setup",replace:!0}):o.jsx(az,{children:o.jsxs("div",{className:Gr.root,children:[H1&&o.jsx(DN,{}),o.jsx(k9,{})]})})}function Np(){const{workspaceId:t}=ms(),{workspaces:{workspaces:s}}=ft(),i=Zt(),r=s.find(m=>m.id===t);if(!(r!=null&&r.environmentId))return s.length===0?void 0:o.jsx(fs,{to:"/environments",replace:!0});const c=encodeURIComponent(t),d=`/workspaces/${c}`,u=i.pathname.startsWith(d)?i.pathname.slice(d.length):"",p=`/environments/${encodeURIComponent(r.environmentId)}/workspaces/${c}${u}${i.search}${i.hash}`;return o.jsx(fs,{to:p,replace:!0})}function T9(){return o.jsxs(gj,{children:[o.jsx(Ce,{path:"setup",element:o.jsx(h9,{})}),o.jsxs(Ce,{element:o.jsx(S9,{}),children:[o.jsx(Ce,{index:!0,element:o.jsx(FU,{})}),o.jsx(Ce,{path:"chat",element:o.jsx(n$,{})}),o.jsx(Ce,{path:"sessions/new",element:o.jsx(s$,{})}),o.jsx(Ce,{path:"sessions/:sessionId",element:o.jsx(r$,{})}),o.jsx(Ce,{element:o.jsx(EP,{}),children:o.jsx(Ce,{path:"knowledge",element:o.jsx(y.Suspense,{fallback:o.jsx(m1,{}),children:o.jsx(_9,{})})})}),o.jsxs(Ce,{element:o.jsx(wP,{}),children:[o.jsx(Ce,{path:"tasks",element:o.jsx(qU,{})}),o.jsx(Ce,{path:"tasks/new",element:o.jsx(Xb,{})}),o.jsx(Ce,{path:"tasks/:taskId",element:o.jsx(Ia,{})}),o.jsx(Ce,{path:"tasks/:taskId/edit",element:o.jsx(Ia,{})}),o.jsx(Ce,{path:"tasks/:taskId/stream",element:o.jsx(Ia,{})}),o.jsx(Ce,{path:"tasks/:taskId/findings",element:o.jsx(Ia,{})})]}),o.jsxs(Ce,{element:o.jsx(CP,{}),children:[o.jsx(Ce,{path:"findings",element:o.jsx(sx,{})}),o.jsx(Ce,{path:"findings/:findingId",element:o.jsx(ax,{})}),o.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:o.jsx(sx,{})}),o.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:o.jsx(ax,{})})]}),o.jsxs(Ce,{element:o.jsx(jP,{}),children:[o.jsx(Ce,{path:"workspaces",element:o.jsx(fs,{to:"/environments",replace:!0})}),o.jsx(Ce,{path:"workspaces/new",element:o.jsx(k$,{})}),o.jsx(Ce,{path:"workspaces/:workspaceId",element:o.jsx(Np,{})}),o.jsx(Ce,{path:"workspaces/:workspaceId/tasks/:taskId",element:o.jsx(Np,{})}),o.jsx(Ce,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:o.jsx(Np,{})}),o.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId",element:o.jsx(u$,{})}),o.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:o.jsx(Xb,{})}),o.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:o.jsx(Ia,{})}),o.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:o.jsx(Ia,{})}),o.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:o.jsx(Ia,{})}),o.jsx(Ce,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:o.jsx(Ia,{})}),o.jsxs(Ce,{path:"environments",element:o.jsx(E$,{}),children:[o.jsx(Ce,{index:!0,element:o.jsx(GU,{})}),o.jsx(Ce,{path:"new",element:o.jsx(T$,{})}),o.jsx(Ce,{path:":environmentId",element:o.jsx(aP,{})}),o.jsx(Ce,{path:":environmentId/edit",element:o.jsx(w$,{})})]})]}),o.jsx(Ce,{element:o.jsx(NP,{}),children:o.jsxs(Ce,{path:"settings",element:o.jsx(rP,{}),children:[o.jsx(Ce,{index:!0,element:o.jsx(fs,{to:"credentials",replace:!0})}),o.jsx(Ce,{path:"environments",element:o.jsx(fs,{to:"/environments",replace:!0})}),o.jsx(Ce,{path:"credentials",element:o.jsx(lP,{})}),o.jsx(Ce,{path:"tokens",element:o.jsx(fs,{to:"../credentials",replace:!0})}),o.jsx(Ce,{path:"personas",element:o.jsx(cP,{})}),o.jsx(Ce,{path:"personas/new",element:o.jsx(tx,{})}),o.jsx(Ce,{path:"personas/:personaId",element:o.jsx(tx,{})}),o.jsx(Ce,{path:"appearance",element:o.jsx(xP,{})}),o.jsx(Ce,{path:"shortcuts",element:o.jsx(SP,{})}),o.jsx(Ce,{path:"about",element:o.jsx(kP,{})})]})}),o.jsx(Ce,{path:"*",element:o.jsx(fs,{to:"/",replace:!0})})]})]})}const w9=1e4;function j9(){const{onboardingCompleted:t}=ft(),[s,i]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>i(!0),w9);return()=>clearTimeout(c)},[t]);const r=t===void 0&&!s;return o.jsx(ps,{mode:"wait",children:r?o.jsx(Rt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:o.jsx(m1,{})},"splash"):o.jsx(Rt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:o.jsx(Pj,{basename:"/".replace(/\/$/,""),children:o.jsx(T9,{})})},"app")})}function N9(){const t=H1?Mz:s7;return o.jsx(sz,{children:o.jsx(Q8,{children:o.jsx(t,{children:o.jsx(j9,{})})})})}NT.createRoot(document.getElementById("root")).render(o.jsx(y.StrictMode,{children:o.jsx(N9,{})}));export{js as B,Ox as K,ft as a,Rp as f,mm as s,In as t,_t 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-Bwk_xNWH.js"></script>
13
+ <script type="module" crossorigin src="/assets/index-BPlp2Jr8.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="/assets/dagview-tHPW3Rz3.js">
15
15
  <link rel="modulepreload" crossorigin href="/assets/grpc-Cjo4GFxo.js">
16
16
  <link rel="modulepreload" crossorigin href="/assets/markdown-Yr3vTPLR.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grackle-ai/web",
3
- "version": "0.95.0",
3
+ "version": "0.95.1",
4
4
  "description": "React web UI for the Grackle multi-agent coordination platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,7 +38,7 @@
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.95.0",
41
+ "@grackle-ai/common": "0.95.1",
42
42
  "@grackle-ai/web-components": "0.83.2"
43
43
  },
44
44
  "devDependencies": {