@grackle-ai/web 0.132.2 → 0.133.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.html CHANGED
@@ -10,9 +10,9 @@
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-YrnxTjCO.js"></script>
13
+ <script type="module" crossorigin src="/assets/index-LVRDlLuv.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="/assets/dagview-B70jDsRo.js">
15
- <link rel="modulepreload" crossorigin href="/assets/grpc-D5yEdhAi.js">
15
+ <link rel="modulepreload" crossorigin href="/assets/grpc-CHXyF1mC.js">
16
16
  <link rel="modulepreload" crossorigin href="/assets/markdown-CPoGw-1N.js">
17
17
  <link rel="stylesheet" crossorigin href="/assets/index-64ZshnVc.css">
18
18
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grackle-ai/web",
3
- "version": "0.132.2",
3
+ "version": "0.133.0",
4
4
  "description": "React web UI for the Grackle multi-agent coordination platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,8 +38,8 @@
38
38
  "rehype-prism-plus": "^2.0.0",
39
39
  "remark-gfm": "^4.0.0",
40
40
  "react-router": "^7.0.0",
41
- "@grackle-ai/web-components": "0.132.2",
42
- "@grackle-ai/common": "0.132.2"
41
+ "@grackle-ai/web-components": "0.133.0",
42
+ "@grackle-ai/common": "0.133.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@rushstack/heft": "1.2.7",
@@ -1 +0,0 @@
1
- import{t as nt,l as rt,b as A,z as it,s as T,m as st,n as X,j as N}from"./dagview-B70jDsRo.js";import{u as at,s as ot,t as ct,a as lt,B as ut,K as ft}from"./index-YrnxTjCO.js";import"./grpc-D5yEdhAi.js";import"./markdown-CPoGw-1N.js";function ht(t,e){var n,o=1;t==null&&(t=0),e==null&&(e=0);function s(){var r,c=n.length,d,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 dt(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return q(this.cover(e,n),e,n,t)}function q(t,e,n,o){if(isNaN(e)||isNaN(n))return t;var s,r=t._root,c={data:o},d=t._x0,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 gt(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 xt(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,o=this._y0,s=this._x1,r=this._y1;if(isNaN(n))s=(n=Math.floor(t))+1,r=(o=Math.floor(e))+1;else{for(var c=s-n||1,d=this._root,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 _t(){var t=[];return this.visit(function(e){if(!e.length)do t.push(e.data);while(e=e.next)}),t}function yt(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function L(t,e,n,o,s){this.node=t,this.x0=e,this.y0=n,this.x1=o,this.y1=s}function vt(t,e,n){var o,s=this._x0,r=this._y0,c,d,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 mt(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 pt(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this}function wt(){return this._root}function Nt(){var t=0;return this.visit(function(e){if(!e.length)do++t;while(e=e.next)}),t}function bt(t){var e=[],n,o=this._root,s,r,c,d,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 kt(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 jt(t){return t[0]}function At(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 P(t,e,n){var o=new U(e??jt,n??Mt,NaN,NaN,NaN,NaN);return t==null?o:o.addAll(t)}function U(t,e,n,o,s,r){this._x=t,this._y=e,this._x0=n,this._y0=o,this._x1=s,this._y1=r,this._root=void 0}function Y(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var R=P.prototype=U.prototype;R.copy=function(){var t=new U(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,n,o;if(!e)return t;if(!e.length)return t._root=Y(e),t;for(n=[{source:e,target:t._root=new Array(4)}];e=n.pop();)for(var s=0;s<4;++s)(o=e.source[s])&&(o.length?n.push({source:o,target:e.target[s]=new Array(4)}):e.target[s]=Y(o));return t};R.add=dt;R.addAll=gt;R.cover=xt;R.data=_t;R.extent=yt;R.find=vt;R.remove=mt;R.removeAll=pt;R.root=wt;R.size=Nt;R.visit=bt;R.visitAfter=kt;R.x=At;R.y=Ct;function O(t){return function(){return t}}function S(t){return(t()-.5)*1e-6}function It(t){return t.x+t.vx}function Lt(t){return t.y+t.vy}function Rt(t){var e,n,o,s=1,r=1;typeof t!="function"&&(t=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=P(e,It,Lt).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,M,I){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||M<h-g||b>p+g||I<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 Et(t){return t.index}function W(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Dt(t){var e=Et,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,M,I,k,D,g;m<f;++m)x=t[m],b=x.source,M=x.target,I=M.x+M.vx-b.x-b.vx||S(i),k=M.y+M.vy-b.y-b.vy||S(i),D=Math.sqrt(I*I+k*k),D=(D-r[m])/D*a*o[m],I*=D,k*=D,M.vx-=I*(g=y[m]),M.vy-=k*g,b.vx+=I*(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,M)=>[e(b,M,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 Bt=1664525,zt=1013904223,Q=4294967296;function Tt(){let t=1;return()=>(t=(Bt*t+zt)%Q)/Q}function St(t){return t.x}function $t(t){return t.y}var Gt=10,Ot=Math.PI*(3-Math.sqrt(5));function Ft(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=Tt();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=Gt*Math.sqrt(.5+l),m=l*Ot;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,M,I,k;for(u==null?u=1/0:u*=u,f=0;f<m;++f)I=t[f],x=l-I.x,b=a-I.y,M=x*x+b*b,M<u&&(k=I,u=M);return k},on:function(l,a){return arguments.length>1?(i.on(l,a),e):i.on(l)}}}function Kt(){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=P(t,St,$t).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 Ht="_graphContainer_13vy2_1",Pt="_svg_13vy2_10",Ut="_link_13vy2_18",Xt="_node_13vy2_30",Yt="_nodeCard_13vy2_37",Wt="_nodeLabel_13vy2_43",Qt="_selected_13vy2_47",Vt="_dimmed_13vy2_54",Zt="_dimmedLink_13vy2_59",Jt="_nodeIndicator_13vy2_71",qt="_nodeBadge_13vy2_85",E={graphContainer:Ht,svg:Pt,link:Ut,node:Xt,nodeCard:Yt,nodeLabel:Wt,selected:Qt,dimmed:Vt,dimmedLink:Zt,nodeIndicator:Jt,nodeBadge:qt},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 te(t,e){if(e.width<=0||e.height<=0)return;let n=1/0,o=-1/0,s=1/0,r=-1/0;for(const l of t){const a=l.x??0,u=l.y??0;a<n&&(n=a),a>o&&(o=a),u<s&&(s=u),u>r&&(r=u)}const c=n-$/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 ee({graphData:t,selectedNodeId:e,onNodeClick:n,onNodeDoubleClick:o}){const s=A.useRef(null),r=A.useRef(null),c=A.useRef(void 0),d=A.useRef(void 0),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 M of b)h({width:M.contentRect.width,height:M.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 M=T(f).selectAll("line").data(b).enter().append("line").attr("class",E.link);M.append("title").text(g=>g.type),y.current=M;const I=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=I,I.append("rect").attr("class",E.nodeCard).attr("width",$).attr("height",G).attr("rx",Z).attr("ry",Z).style("--node-color",g=>V(g)),I.append("rect").attr("class",E.nodeIndicator).attr("width",4).attr("height",G).attr("rx",2).attr("fill",g=>V(g)),I.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),I.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=Ft(m).force("link",Dt(b).id(g=>g.id).distance(140)).force("charge",Kt().strength(-400)).force("center",ht(_.width/2,_.height/2)).force("collide",Rt($/2+16)).on("tick",()=>{M.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),I.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 I.call(D),k.on("end",()=>{if(s.current&&d.current&&m.length>0&&!w.current&&!v.current){w.current=!0;const g=te(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 ne="_panel_1wumt_1",re="_header_1wumt_24",ie="_title_1wumt_32",se="_closeButton_1wumt_42",ae="_body_1wumt_55",oe="_badge_1wumt_61",ce="_section_1wumt_72",le="_sectionLabel_1wumt_76",ue="_content_1wumt_84",fe="_tags_1wumt_92",he="_tag_1wumt_92",de="_viewLink_1wumt_107",ge="_edgeList_1wumt_121",xe="_edgeItem_1wumt_127",_e="_edgeType_1wumt_136",ye="_edgeNodeLink_1wumt_142",ve="_timestamps_1wumt_154",C={panel:ne,header:re,title:ie,closeButton:se,body:ae,badge:oe,section:ce,sectionLabel:le,content:ue,tags:fe,tag:he,viewLink:de,edgeList:ge,edgeItem:xe,edgeType:_e,edgeNodeLink:ye,timestamps:ve};function me({detail:t,nodes:e,onClose:n,onSelectNode:o}){const s=at(),{node:r,edges:c}=t,d=A.useMemo(()=>new Map(e.map(i=>[i.id,i])),[e]);function y(){if(!(r.kind!=="reference"||!r.sourceId))switch(r.sourceType){case"task":s(ct(r.sourceId));break;case"session":s(ot(r.sourceId));break}}return N.jsxs("div",{className:C.panel,"data-testid":"knowledge-detail-panel",children:[N.jsxs("div",{className:C.header,children:[N.jsx("h3",{className:C.title,children:r.label}),N.jsx("button",{className:C.closeButton,onClick:n,"aria-label":"Close",children:"×"})]}),N.jsxs("div",{className:C.body,children:[N.jsx("div",{className:C.badge,children:r.kind==="reference"?`Reference (${r.sourceType})`:r.category}),r.content&&N.jsxs("div",{className:C.section,children:[N.jsx("div",{className:C.sectionLabel,children:"Content"}),N.jsx("p",{className:C.content,children:r.content})]}),r.tags&&r.tags.length>0&&N.jsxs("div",{className:C.section,children:[N.jsx("div",{className:C.sectionLabel,children:"Tags"}),N.jsx("div",{className:C.tags,children:r.tags.map(i=>N.jsx("span",{className:C.tag,children:i},i))})]}),r.kind==="reference"&&r.sourceId&&N.jsx("div",{className:C.section,children:N.jsx("button",{className:C.viewLink,onClick:y,children:"View in Grackle →"})}),c.length>0&&N.jsxs("div",{className:C.section,children:[N.jsxs("div",{className:C.sectionLabel,children:["Edges (",c.length,")"]}),N.jsx("ul",{className:C.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:C.edgeItem,"data-testid":"edge-item",children:[N.jsx("span",{className:C.edgeType,"data-testid":"edge-type",children:i.type}),N.jsx("button",{className:C.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:C.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 pe="_layout_n9vg6_1",we="_graphArea_n9vg6_8",Ne="_empty_n9vg6_15",H={layout:pe,graphArea:we,empty:Ne};function Me(){const{knowledge:t}=lt();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:ft}];return N.jsxs("div",{className:H.layout,"data-testid":"knowledge-page",children:[N.jsx(ut,{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(ee,{graphData:t.graphData,selectedNodeId:t.selectedId,onNodeClick:e,onNodeDoubleClick:n}),t.selectedNode&&t.selectedId&&N.jsx(me,{detail:t.selectedNode,nodes:t.graphData.nodes,onClose:o,onSelectNode:e})]})]})}export{Me as KnowledgePage};