jfl 0.7.2 → 0.8.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/commands/context-hub.d.ts.map +1 -1
- package/dist/commands/context-hub.js +26 -0
- package/dist/commands/context-hub.js.map +1 -1
- package/dist/commands/migrate-tenet.d.ts +25 -0
- package/dist/commands/migrate-tenet.d.ts.map +1 -0
- package/dist/commands/migrate-tenet.js +252 -0
- package/dist/commands/migrate-tenet.js.map +1 -0
- package/dist/commands/peter.d.ts.map +1 -1
- package/dist/commands/peter.js +47 -5
- package/dist/commands/peter.js.map +1 -1
- package/dist/commands/pi.d.ts +1 -0
- package/dist/commands/pi.d.ts.map +1 -1
- package/dist/commands/pi.js +5 -1
- package/dist/commands/pi.js.map +1 -1
- package/dist/commands/pivot.d.ts +28 -0
- package/dist/commands/pivot.d.ts.map +1 -0
- package/dist/commands/pivot.js +219 -0
- package/dist/commands/pivot.js.map +1 -0
- package/dist/commands/services-create.js +348 -0
- package/dist/commands/services-create.js.map +1 -1
- package/dist/dashboard-static/assets/index-BVrmW-ZI.js +154 -0
- package/dist/dashboard-static/assets/{index-CW8oWAdr.css → index-DtruPD44.css} +1 -1
- package/dist/dashboard-static/index.html +2 -2
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-generator.d.ts.map +1 -1
- package/dist/lib/agent-generator.js +15 -0
- package/dist/lib/agent-generator.js.map +1 -1
- package/dist/lib/counterfactual-engine.d.ts +136 -0
- package/dist/lib/counterfactual-engine.d.ts.map +1 -0
- package/dist/lib/counterfactual-engine.js +417 -0
- package/dist/lib/counterfactual-engine.js.map +1 -0
- package/dist/lib/dynamics-model.d.ts +107 -0
- package/dist/lib/dynamics-model.d.ts.map +1 -0
- package/dist/lib/dynamics-model.js +363 -0
- package/dist/lib/dynamics-model.js.map +1 -0
- package/dist/lib/eval-snapshot.d.ts.map +1 -1
- package/dist/lib/eval-snapshot.js +15 -4
- package/dist/lib/eval-snapshot.js.map +1 -1
- package/dist/lib/invariant-monitor.d.ts +50 -0
- package/dist/lib/invariant-monitor.d.ts.map +1 -0
- package/dist/lib/invariant-monitor.js +400 -0
- package/dist/lib/invariant-monitor.js.map +1 -0
- package/dist/lib/meta-orchestrator.d.ts +40 -3
- package/dist/lib/meta-orchestrator.d.ts.map +1 -1
- package/dist/lib/meta-orchestrator.js +181 -2
- package/dist/lib/meta-orchestrator.js.map +1 -1
- package/dist/lib/openclaw-sdk.d.ts +8 -0
- package/dist/lib/openclaw-sdk.d.ts.map +1 -1
- package/dist/lib/openclaw-sdk.js +11 -0
- package/dist/lib/openclaw-sdk.js.map +1 -1
- package/dist/lib/peter-parker-bridge.d.ts +37 -1
- package/dist/lib/peter-parker-bridge.d.ts.map +1 -1
- package/dist/lib/peter-parker-bridge.js +201 -1
- package/dist/lib/peter-parker-bridge.js.map +1 -1
- package/dist/lib/service-detector.d.ts +1 -1
- package/dist/lib/service-detector.d.ts.map +1 -1
- package/dist/lib/service-detector.js +26 -6
- package/dist/lib/service-detector.js.map +1 -1
- package/dist/lib/service-gtm.d.ts +1 -1
- package/dist/lib/service-gtm.d.ts.map +1 -1
- package/dist/lib/state-capture.d.ts +36 -0
- package/dist/lib/state-capture.d.ts.map +1 -0
- package/dist/lib/state-capture.js +541 -0
- package/dist/lib/state-capture.js.map +1 -0
- package/dist/lib/stratus-client.d.ts +78 -2
- package/dist/lib/stratus-client.d.ts.map +1 -1
- package/dist/lib/stratus-client.js +432 -1
- package/dist/lib/stratus-client.js.map +1 -1
- package/dist/lib/world-model-store.d.ts +172 -0
- package/dist/lib/world-model-store.d.ts.map +1 -0
- package/dist/lib/world-model-store.js +487 -0
- package/dist/lib/world-model-store.js.map +1 -0
- package/dist/types/world-model.d.ts +478 -0
- package/dist/types/world-model.d.ts.map +1 -0
- package/dist/types/world-model.js +80 -0
- package/dist/types/world-model.js.map +1 -0
- package/dist/utils/jfl-config.d.ts +5 -0
- package/dist/utils/jfl-config.d.ts.map +1 -1
- package/dist/utils/jfl-config.js +13 -1
- package/dist/utils/jfl-config.js.map +1 -1
- package/package.json +1 -1
- package/packages/pi/extensions/hud-tool.ts +2 -24
- package/packages/pi/extensions/index.ts +48 -25
- package/packages/pi/extensions/onboarding-v1.ts +455 -0
- package/packages/pi/extensions/onboarding-v2.ts +516 -0
- package/packages/pi/extensions/onboarding-v3.ts +675 -0
- package/packages/pi/extensions/pivot-tool.ts +59 -0
- package/packages/pi/extensions/session.ts +58 -0
- package/packages/pi/extensions/types.ts +2 -0
- package/packages/pi/skills/pivot/SKILL.md +91 -0
- package/template/.claude/settings.json +9 -0
- package/dist/dashboard-static/assets/index-Ck8f9dcM.js +0 -121
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&s(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();var it,H,dr,Me,Rt,ur,pr,hr,St,mt,ft,rt={},nt=[],Or=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Ne=Array.isArray;function _e(t,r){for(var n in r)t[n]=r[n];return t}function Ct(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function xt(t,r,n){var s,o,i,l={};for(i in r)i=="key"?s=r[i]:i=="ref"?o=r[i]:l[i]=r[i];if(arguments.length>2&&(l.children=arguments.length>3?it.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)l[i]===void 0&&(l[i]=t.defaultProps[i]);return Ze(t,l,s,o,null)}function Ze(t,r,n,s,o){var i={type:t,props:r,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++dr,__i:-1,__u:0};return o==null&&H.vnode!=null&&H.vnode(i),i}function le(t){return t.children}function we(t,r){this.props=t,this.context=r}function De(t,r){if(r==null)return t.__?De(t.__,t.__i+1):null;for(var n;r<t.__k.length;r++)if((n=t.__k[r])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?De(t):null}function Br(t){if(t.__P&&t.__d){var r=t.__v,n=r.__e,s=[],o=[],i=_e({},r);i.__v=r.__v+1,H.vnode&&H.vnode(i),Mt(t.__P,i,r,t.__n,t.__P.namespaceURI,32&r.__u?[n]:null,s,n??De(r),!!(32&r.__u),o),i.__v=r.__v,i.__.__k[i.__i]=i,xr(s,i,o),r.__e=r.__=null,i.__e!=n&&gr(i)}}function gr(t){if((t=t.__)!=null&&t.__c!=null)return t.__e=t.__c.base=null,t.__k.some(function(r){if(r!=null&&r.__e!=null)return t.__e=t.__c.base=r.__e}),gr(t)}function Dt(t){(!t.__d&&(t.__d=!0)&&Me.push(t)&&!st.__r++||Rt!=H.debounceRendering)&&((Rt=H.debounceRendering)||ur)(st)}function st(){for(var t,r=1;Me.length;)Me.length>r&&Me.sort(pr),t=Me.shift(),r=Me.length,Br(t);st.__r=0}function mr(t,r,n,s,o,i,l,u,c,d,m){var a,g,y,v,T,_,R,w=s&&s.__k||nt,A=r.length;for(c=Gr(n,r,w,c,A),a=0;a<A;a++)(y=n.__k[a])!=null&&(g=y.__i!=-1&&w[y.__i]||rt,y.__i=a,_=Mt(t,y,g,o,i,l,u,c,d,m),v=y.__e,y.ref&&g.ref!=y.ref&&(g.ref&&Tt(g.ref,null,y),m.push(y.ref,y.__c||v,y)),T==null&&v!=null&&(T=v),(R=!!(4&y.__u))||g.__k===y.__k?c=fr(y,c,t,R):typeof y.type=="function"&&_!==void 0?c=_:v&&(c=v.nextSibling),y.__u&=-7);return n.__e=T,c}function Gr(t,r,n,s,o){var i,l,u,c,d,m=n.length,a=m,g=0;for(t.__k=new Array(o),i=0;i<o;i++)(l=r[i])!=null&&typeof l!="boolean"&&typeof l!="function"?(typeof l=="string"||typeof l=="number"||typeof l=="bigint"||l.constructor==String?l=t.__k[i]=Ze(null,l,null,null,null):Ne(l)?l=t.__k[i]=Ze(le,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=t.__k[i]=Ze(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):t.__k[i]=l,c=i+g,l.__=t,l.__b=t.__b+1,u=null,(d=l.__i=Nr(l,n,c,a))!=-1&&(a--,(u=n[d])&&(u.__u|=2)),u==null||u.__v==null?(d==-1&&(o>m?g--:o<m&&g++),typeof l.type!="function"&&(l.__u|=4)):d!=c&&(d==c-1?g--:d==c+1?g++:(d>c?g--:g++,l.__u|=4))):t.__k[i]=null;if(a)for(i=0;i<m;i++)(u=n[i])!=null&&(2&u.__u)==0&&(u.__e==s&&(s=De(u)),vr(u,u));return s}function fr(t,r,n,s){var o,i;if(typeof t.type=="function"){for(o=t.__k,i=0;o&&i<o.length;i++)o[i]&&(o[i].__=t,r=fr(o[i],r,n,s));return r}t.__e!=r&&(s&&(r&&t.type&&!r.parentNode&&(r=De(t)),n.insertBefore(t.__e,r||null)),r=t.__e);do r=r&&r.nextSibling;while(r!=null&&r.nodeType==8);return r}function ot(t,r){return r=r||[],t==null||typeof t=="boolean"||(Ne(t)?t.some(function(n){ot(n,r)}):r.push(t)),r}function Nr(t,r,n,s){var o,i,l,u=t.key,c=t.type,d=r[n],m=d!=null&&(2&d.__u)==0;if(d===null&&u==null||m&&u==d.key&&c==d.type)return n;if(s>(m?1:0)){for(o=n-1,i=n+1;o>=0||i<r.length;)if((d=r[l=o>=0?o--:i++])!=null&&(2&d.__u)==0&&u==d.key&&c==d.type)return l}return-1}function At(t,r,n){r[0]=="-"?t.setProperty(r,n??""):t[r]=n==null?"":typeof n!="number"||Or.test(r)?n:n+"px"}function Ue(t,r,n,s,o){var i,l;e:if(r=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof s=="string"&&(t.style.cssText=s=""),s)for(r in s)n&&r in n||At(t.style,r,"");if(n)for(r in n)s&&n[r]==s[r]||At(t.style,r,n[r])}else if(r[0]=="o"&&r[1]=="n")i=r!=(r=r.replace(hr,"$1")),l=r.toLowerCase(),r=l in t||r=="onFocusOut"||r=="onFocusIn"?l.slice(2):r.slice(2),t.l||(t.l={}),t.l[r+i]=n,n?s?n.u=s.u:(n.u=St,t.addEventListener(r,i?ft:mt,i)):t.removeEventListener(r,i?ft:mt,i);else{if(o=="http://www.w3.org/2000/svg")r=r.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(r!="width"&&r!="height"&&r!="href"&&r!="list"&&r!="form"&&r!="tabIndex"&&r!="download"&&r!="rowSpan"&&r!="colSpan"&&r!="role"&&r!="popover"&&r in t)try{t[r]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&r[4]!="-"?t.removeAttribute(r):t.setAttribute(r,r=="popover"&&n==1?"":n))}}function Pt(t){return function(r){if(this.l){var n=this.l[r.type+t];if(r.t==null)r.t=St++;else if(r.t<n.u)return;return n(H.event?H.event(r):r)}}}function Mt(t,r,n,s,o,i,l,u,c,d){var m,a,g,y,v,T,_,R,w,A,S,f,x,I,h,C=r.type;if(r.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),i=[u=r.__e=n.__e]),(m=H.__b)&&m(r);e:if(typeof C=="function")try{if(R=r.props,w="prototype"in C&&C.prototype.render,A=(m=C.contextType)&&s[m.__c],S=m?A?A.props.value:m.__:s,n.__c?_=(a=r.__c=n.__c).__=a.__E:(w?r.__c=a=new C(R,S):(r.__c=a=new we(R,S),a.constructor=C,a.render=Hr),A&&A.sub(a),a.state||(a.state={}),a.__n=s,g=a.__d=!0,a.__h=[],a._sb=[]),w&&a.__s==null&&(a.__s=a.state),w&&C.getDerivedStateFromProps!=null&&(a.__s==a.state&&(a.__s=_e({},a.__s)),_e(a.__s,C.getDerivedStateFromProps(R,a.__s))),y=a.props,v=a.state,a.__v=r,g)w&&C.getDerivedStateFromProps==null&&a.componentWillMount!=null&&a.componentWillMount(),w&&a.componentDidMount!=null&&a.__h.push(a.componentDidMount);else{if(w&&C.getDerivedStateFromProps==null&&R!==y&&a.componentWillReceiveProps!=null&&a.componentWillReceiveProps(R,S),r.__v==n.__v||!a.__e&&a.shouldComponentUpdate!=null&&a.shouldComponentUpdate(R,a.__s,S)===!1){r.__v!=n.__v&&(a.props=R,a.state=a.__s,a.__d=!1),r.__e=n.__e,r.__k=n.__k,r.__k.some(function(E){E&&(E.__=r)}),nt.push.apply(a.__h,a._sb),a._sb=[],a.__h.length&&l.push(a);break e}a.componentWillUpdate!=null&&a.componentWillUpdate(R,a.__s,S),w&&a.componentDidUpdate!=null&&a.__h.push(function(){a.componentDidUpdate(y,v,T)})}if(a.context=S,a.props=R,a.__P=t,a.__e=!1,f=H.__r,x=0,w)a.state=a.__s,a.__d=!1,f&&f(r),m=a.render(a.props,a.state,a.context),nt.push.apply(a.__h,a._sb),a._sb=[];else do a.__d=!1,f&&f(r),m=a.render(a.props,a.state,a.context),a.state=a.__s;while(a.__d&&++x<25);a.state=a.__s,a.getChildContext!=null&&(s=_e(_e({},s),a.getChildContext())),w&&!g&&a.getSnapshotBeforeUpdate!=null&&(T=a.getSnapshotBeforeUpdate(y,v)),I=m!=null&&m.type===le&&m.key==null?br(m.props.children):m,u=mr(t,Ne(I)?I:[I],r,n,s,o,i,l,u,c,d),a.base=r.__e,r.__u&=-161,a.__h.length&&l.push(a),_&&(a.__E=a.__=null)}catch(E){if(r.__v=null,c||i!=null)if(E.then){for(r.__u|=c?160:128;u&&u.nodeType==8&&u.nextSibling;)u=u.nextSibling;i[i.indexOf(u)]=null,r.__e=u}else{for(h=i.length;h--;)Ct(i[h]);bt(r)}else r.__e=n.__e,r.__k=n.__k,E.then||bt(r);H.__e(E,r,n)}else i==null&&r.__v==n.__v?(r.__k=n.__k,r.__e=n.__e):u=r.__e=Ur(n.__e,r,n,s,o,i,l,c,d);return(m=H.diffed)&&m(r),128&r.__u?void 0:u}function bt(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(bt))}function xr(t,r,n){for(var s=0;s<n.length;s++)Tt(n[s],n[++s],n[++s]);H.__c&&H.__c(r,t),t.some(function(o){try{t=o.__h,o.__h=[],t.some(function(i){i.call(o)})}catch(i){H.__e(i,o.__v)}})}function br(t){return typeof t!="object"||t==null||t.__b>0?t:Ne(t)?t.map(br):_e({},t)}function Ur(t,r,n,s,o,i,l,u,c){var d,m,a,g,y,v,T,_=n.props||rt,R=r.props,w=r.type;if(w=="svg"?o="http://www.w3.org/2000/svg":w=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),i!=null){for(d=0;d<i.length;d++)if((y=i[d])&&"setAttribute"in y==!!w&&(w?y.localName==w:y.nodeType==3)){t=y,i[d]=null;break}}if(t==null){if(w==null)return document.createTextNode(R);t=document.createElementNS(o,w,R.is&&R),u&&(H.__m&&H.__m(r,i),u=!1),i=null}if(w==null)_===R||u&&t.data==R||(t.data=R);else{if(i=i&&it.call(t.childNodes),!u&&i!=null)for(_={},d=0;d<t.attributes.length;d++)_[(y=t.attributes[d]).name]=y.value;for(d in _)y=_[d],d=="dangerouslySetInnerHTML"?a=y:d=="children"||d in R||d=="value"&&"defaultValue"in R||d=="checked"&&"defaultChecked"in R||Ue(t,d,null,y,o);for(d in R)y=R[d],d=="children"?g=y:d=="dangerouslySetInnerHTML"?m=y:d=="value"?v=y:d=="checked"?T=y:u&&typeof y!="function"||_[d]===y||Ue(t,d,y,_[d],o);if(m)u||a&&(m.__html==a.__html||m.__html==t.innerHTML)||(t.innerHTML=m.__html),r.__k=[];else if(a&&(t.innerHTML=""),mr(r.type=="template"?t.content:t,Ne(g)?g:[g],r,n,s,w=="foreignObject"?"http://www.w3.org/1999/xhtml":o,i,l,i?i[0]:n.__k&&De(n,0),u,c),i!=null)for(d=i.length;d--;)Ct(i[d]);u||(d="value",w=="progress"&&v==null?t.removeAttribute("value"):v!=null&&(v!==t[d]||w=="progress"&&!v||w=="option"&&v!=_[d])&&Ue(t,d,v,_[d],o),d="checked",T!=null&&T!=t[d]&&Ue(t,d,T,_[d],o))}return t}function Tt(t,r,n){try{if(typeof t=="function"){var s=typeof t.__u=="function";s&&t.__u(),s&&r==null||(t.__u=t(r))}else t.current=r}catch(o){H.__e(o,n)}}function vr(t,r,n){var s,o;if(H.unmount&&H.unmount(t),(s=t.ref)&&(s.current&&s.current!=t.__e||Tt(s,null,r)),(s=t.__c)!=null){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(i){H.__e(i,r)}s.base=s.__P=null}if(s=t.__k)for(o=0;o<s.length;o++)s[o]&&vr(s[o],r,n||typeof t.type!="function");n||Ct(t.__e),t.__c=t.__=t.__e=void 0}function Hr(t,r,n){return this.constructor(t,n)}function zr(t,r,n){var s,o,i,l;r==document&&(r=document.documentElement),H.__&&H.__(t,r),o=(s=!1)?null:r.__k,i=[],l=[],Mt(r,t=r.__k=xt(le,null,[t]),o||rt,rt,r.namespaceURI,o?null:r.firstChild?it.call(r.childNodes):null,i,o?o.__e:r.firstChild,s,l),xr(i,t,l)}it=nt.slice,H={__e:function(t,r,n,s){for(var o,i,l;r=r.__;)if((o=r.__c)&&!o.__)try{if((i=o.constructor)&&i.getDerivedStateFromError!=null&&(o.setState(i.getDerivedStateFromError(t)),l=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(t,s||{}),l=o.__d),l)return o.__E=o}catch(u){t=u}throw t}},dr=0,we.prototype.setState=function(t,r){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=_e({},this.state),typeof t=="function"&&(t=t(_e({},n),this.props)),t&&_e(n,t),t!=null&&this.__v&&(r&&this._sb.push(r),Dt(this))},we.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Dt(this))},we.prototype.render=le,Me=[],ur=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,pr=function(t,r){return t.__v.__b-r.__v.__b},st.__r=0,hr=/(PointerCapture)$|Capture$/i,St=0,mt=Pt(!1),ft=Pt(!0);var Xr=0;function e(t,r,n,s,o,i){r||(r={});var l,u,c=r;if("ref"in c)for(u in c={},r)u=="ref"?l=r[u]:c[u]=r[u];var d={type:t,props:c,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Xr,__i:-1,__u:0,__source:o,__self:i};if(typeof t=="function"&&(l=t.defaultProps))for(u in l)c[u]===void 0&&(c[u]=l[u]);return H.vnode&&H.vnode(d),d}var Le,se,at,It,Oe=0,yr=[],ie=H,jt=ie.__b,Lt=ie.__r,Ot=ie.diffed,Bt=ie.__c,Gt=ie.unmount,Nt=ie.__;function Et(t,r){ie.__h&&ie.__h(se,t,Oe||r),Oe=0;var n=se.__H||(se.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function P(t){return Oe=1,Wr(wr,t)}function Wr(t,r,n){var s=Et(Le++,2);if(s.t=t,!s.__c&&(s.__=[n?n(r):wr(void 0,r),function(u){var c=s.__N?s.__N[0]:s.__[0],d=s.t(c,u);c!==d&&(s.__N=[d,s.__[1]],s.__c.setState({}))}],s.__c=se,!se.__f)){var o=function(u,c,d){if(!s.__c.__H)return!0;var m=s.__c.__H.__.filter(function(g){return g.__c});if(m.every(function(g){return!g.__N}))return!i||i.call(this,u,c,d);var a=s.__c.props!==u;return m.some(function(g){if(g.__N){var y=g.__[0];g.__=g.__N,g.__N=void 0,y!==g.__[0]&&(a=!0)}}),i&&i.call(this,u,c,d)||a};se.__f=!0;var i=se.shouldComponentUpdate,l=se.componentWillUpdate;se.componentWillUpdate=function(u,c,d){if(this.__e){var m=i;i=void 0,o(u,c,d),i=m}l&&l.call(this,u,c,d)},se.shouldComponentUpdate=o}return s.__N||s.__}function fe(t,r){var n=Et(Le++,3);!ie.__s&&_r(n.__H,r)&&(n.__=t,n.u=r,se.__H.__h.push(n))}function be(t){return Oe=5,Te(function(){return{current:t}},[])}function Te(t,r){var n=Et(Le++,7);return _r(n.__H,r)&&(n.__=t(),n.__H=r,n.__h=t),n.__}function Ee(t,r){return Oe=8,Te(function(){return t},r)}function Yr(){for(var t;t=yr.shift();){var r=t.__H;if(t.__P&&r)try{r.__h.some(et),r.__h.some(vt),r.__h=[]}catch(n){r.__h=[],ie.__e(n,t.__v)}}}ie.__b=function(t){se=null,jt&&jt(t)},ie.__=function(t,r){t&&r.__k&&r.__k.__m&&(t.__m=r.__k.__m),Nt&&Nt(t,r)},ie.__r=function(t){Lt&&Lt(t),Le=0;var r=(se=t.__c).__H;r&&(at===se?(r.__h=[],se.__h=[],r.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(r.__h.some(et),r.__h.some(vt),r.__h=[],Le=0)),at=se},ie.diffed=function(t){Ot&&Ot(t);var r=t.__c;r&&r.__H&&(r.__H.__h.length&&(yr.push(r)!==1&&It===ie.requestAnimationFrame||((It=ie.requestAnimationFrame)||Vr)(Yr)),r.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),at=se=null},ie.__c=function(t,r){r.some(function(n){try{n.__h.some(et),n.__h=n.__h.filter(function(s){return!s.__||vt(s)})}catch(s){r.some(function(o){o.__h&&(o.__h=[])}),r=[],ie.__e(s,n.__v)}}),Bt&&Bt(t,r)},ie.unmount=function(t){Gt&&Gt(t);var r,n=t.__c;n&&n.__H&&(n.__H.__.some(function(s){try{et(s)}catch(o){r=o}}),n.__H=void 0,r&&ie.__e(r,n.__v))};var Ut=typeof requestAnimationFrame=="function";function Vr(t){var r,n=function(){clearTimeout(s),Ut&&cancelAnimationFrame(r),setTimeout(t)},s=setTimeout(n,35);Ut&&(r=requestAnimationFrame(n))}function et(t){var r=se,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),se=r}function vt(t){var r=se;t.__c=t.__(),se=r}function _r(t,r){return!t||t.length!==r.length||r.some(function(n,s){return n!==t[s]})}function wr(t,r){return typeof r=="function"?r(t):r}const qr=()=>{const r=new URLSearchParams(window.location.search).get("token");if(r){localStorage.setItem("jfl-token",r);const n=new URL(window.location.href);return n.searchParams.delete("token"),window.history.replaceState({},"",n.toString()),r}return localStorage.getItem("jfl-token")||""};let ct=null;function Be(){return ct||(ct=qr()),ct}async function Y(t,r={}){const n={"Content-Type":"application/json",...Be()?{Authorization:`Bearer ${Be()}`}:{},...r.headers||{}},s=await fetch(t,{...r,headers:n});if(s.status===401)throw new Error("Unauthorized");if(!s.ok)throw new Error(`API error: ${s.status}`);return s.json()}function kr(t,r,n){const s=`${t}${t.includes("?")?"&":"?"}token=${Be()}`,o=new EventSource(s);return o.onmessage=i=>{try{r(JSON.parse(i.data))}catch{}},o.onerror=i=>n==null?void 0:n(i),()=>o.close()}async function Jr(t,r,n,s,o,i){var a;const l={"Content-Type":"application/json",...Be()?{Authorization:`Bearer ${Be()}`}:{}},u=await fetch("/api/chat",{method:"POST",headers:l,body:JSON.stringify({message:t,history:r})});if(!u.ok){i(`API error: ${u.status}`);return}const c=(a=u.body)==null?void 0:a.getReader();if(!c){i("No response body");return}const d=new TextDecoder;let m="";for(;;){const{done:g,value:y}=await c.read();if(g)break;m+=d.decode(y,{stream:!0});const v=m.split(`
|
|
2
|
+
`);m=v.pop()||"";for(const T of v){if(!T.startsWith("data: "))continue;const _=T.slice(6);if(_==="[DONE]"){o();return}try{const R=JSON.parse(_);R.sources&&n(R.sources),R.delta&&s(R.delta)}catch{}}}o()}const j={status:()=>Y("/api/context/status"),events:(t=50,r)=>{let n=`/api/events?limit=${t}`;return r&&(n+=`&pattern=${encodeURIComponent(r)}`),Y(n)},leaderboard:()=>Y("/api/eval/leaderboard"),trajectory:(t,r="composite")=>Y(`/api/eval/trajectory?agent=${encodeURIComponent(t)}&metric=${r}`),journal:()=>Y("/api/context",{method:"POST",body:JSON.stringify({})}).then(t=>t.items||[]),search:t=>Y(`/api/context/search?q=${encodeURIComponent(t)}`),services:()=>Y("/api/services"),projects:()=>Y("/api/projects"),flows:()=>Y("/api/flows"),flowExecutions:()=>Y("/api/flows/executions"),approveFlow:(t,r)=>Y(`/api/flows/${encodeURIComponent(t)}/approve`,{method:"POST",body:JSON.stringify({trigger_event_id:r})}),memoryStatus:()=>Y("/api/memory/status"),memorySearch:(t,r)=>{const n={query:t};return r&&r!=="all"&&(n.type=r),Y("/api/memory/search",{method:"POST",body:JSON.stringify(n)})},publishEvent:(t,r,n="dashboard")=>Y("/api/events",{method:"POST",body:JSON.stringify({type:t,source:n,data:r})}),toggleFlow:(t,r)=>Y(`/api/flows/${encodeURIComponent(t)}/toggle`,{method:"POST",body:JSON.stringify({enabled:r})}),spawnAction:(t,r,n)=>Y("/api/actions/spawn",{method:"POST",body:JSON.stringify({command:t,args:r,event_type:n})}),predictions:()=>Y("/api/eval/predictions"),synopsis:(t=24)=>Y(`/api/synopsis?hours=${t}`),telemetryDigest:(t=168)=>Y(`/api/telemetry/digest?hours=${t}`),telemetryAgentStatus:()=>Y("/api/telemetry/agent"),telemetryAgentRun:()=>Y("/api/telemetry/agent/run",{method:"POST"}),childSynopsis:async(t,r=24)=>{try{const n=await fetch(`http://localhost:${t}/api/synopsis?hours=${r}`);return n.ok?n.json():null}catch{return null}},topology:()=>Y("/api/v1/topology"),autoresearchStatus:()=>Y("/api/v1/autoresearch/status"),evalEntries:(t=100)=>Y(`/api/eval/entries?limit=${t}`),rlAgents:()=>Y("/api/v1/agents"),rlExperiments:t=>Y(t?`/api/v1/experiments?agent=${t}`:"/api/v1/experiments"),rlSessions:()=>Y("/api/v1/sessions"),productContext:()=>Y("/api/v1/product-context"),findings:(t=!1,r=!1)=>{const n=new URLSearchParams;t&&n.set("refresh","true"),r&&n.set("include_dismissed","true");const s=n.toString();return Y(`/api/v1/findings${s?`?${s}`:""}`)},dismissFinding:t=>Y(`/api/v1/findings/${encodeURIComponent(t)}/dismiss`,{method:"POST"}),spawnFindingAgent:t=>Y(`/api/v1/findings/${encodeURIComponent(t)}/spawn`,{method:"POST"}),analyzeFindings:()=>Y("/api/v1/findings/analyze",{method:"POST"}),setupReport:()=>Y("/api/setup-report")};function ae({label:t,value:r,sub:n,trend:s,icon:o}){return e("div",{class:"bg-card rounded-lg border border-border p-4 animate-fade-in",children:[e("div",{class:"flex items-center justify-between mb-2",children:[e("span",{class:"text-xs text-muted-foreground uppercase tracking-wider",children:t}),o&&e("span",{class:"text-muted-foreground",children:o})]}),e("div",{class:"text-2xl font-semibold mono",children:r}),n&&e("div",{class:`text-xs mt-1 ${s==="up"?"text-success":s==="down"?"text-destructive":"text-muted-foreground"}`,children:n})]})}function Ge({data:t,width:r=120,height:n=32,color:s="var(--success)",className:o=""}){if(!t.length)return null;const i=Math.min(...t),u=Math.max(...t)-i||1,c=2,d=t.map((m,a)=>{const g=c+a/(t.length-1||1)*(r-c*2),y=n-c-(m-i)/u*(n-c*2);return`${g},${y}`}).join(" ");return e("svg",{width:r,height:n,class:o,viewBox:`0 0 ${r} ${n}`,children:[e("polyline",{points:d,fill:"none",stroke:s,"stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),e("circle",{cx:parseFloat(d.split(" ").pop().split(",")[0]),cy:parseFloat(d.split(" ").pop().split(",")[1]),r:"2.5",fill:s})]})}function G(t,r,n=[]){const[s,o]=P(null),[i,l]=P(!0),[u,c]=P(null),d=be(),m=Ee(()=>{t().then(a=>{o(a),c(null),l(!1)}).catch(a=>{c(a.message),l(!1)})},n);return fe(()=>(m(),d.current=setInterval(m,r),()=>clearInterval(d.current)),[m,r]),{data:s,loading:i,error:u,refetch:m}}function Ft(t,r){const[n,s]=P(!1);return fe(()=>{const o=localStorage.getItem("jfl-token")||"",i=`${t}${t.includes("?")?"&":"?"}token=${o}`,l=new EventSource(i);return l.onopen=()=>s(!0),l.onmessage=u=>{try{r(JSON.parse(u.data))}catch{}},l.onerror=()=>s(!1),()=>l.close()},[t]),{connected:n}}function M(...t){return t.filter(Boolean).join(" ")}function te(t){const r=Date.now()-new Date(t).getTime(),n=Math.floor(r/1e3);if(n<60)return`${n}s ago`;const s=Math.floor(n/60);if(s<60)return`${s}m ago`;const o=Math.floor(s/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}const Kr={ok:"bg-success",active:"bg-success",error:"bg-destructive",down:"bg-destructive",warning:"bg-warning",idle:"bg-muted-foreground"};function Se({status:t,label:r,pulse:n=!0}){return e("span",{class:"inline-flex items-center gap-1.5",children:[e("span",{class:M("inline-block w-2 h-2 rounded-full",Kr[t]||"bg-muted-foreground",n&&(t==="ok"||t==="active")&&"animate-pulse-dot")}),r&&e("span",{class:"text-xs text-muted-foreground",children:r})]})}const Qr={"eval:scored":"text-info","flow:triggered":"text-warning","journal:entry":"text-success","session:started":"text-accent-foreground","session:ended":"text-muted-foreground",error:"text-destructive"};function Zr({events:t,maxItems:r=20}){const n=t.slice(0,r);return n.length?e("div",{class:"space-y-1",children:n.map(s=>{var o,i,l;return e("div",{class:"flex items-start gap-3 py-2 px-3 rounded hover:bg-muted/30 transition-colors text-sm animate-fade-in",children:[e("span",{class:"text-[10px] text-muted-foreground mono whitespace-nowrap mt-0.5",children:te(s.ts)}),e("span",{class:`text-xs mono font-medium whitespace-nowrap ${Qr[s.type]||"text-foreground"}`,children:s.type}),e("span",{class:"text-xs text-muted-foreground truncate flex-1",children:[s.source,((o=s.data)==null?void 0:o.agent)&&` / ${s.data.agent}`,((i=s.data)==null?void 0:i.title)&&` — ${s.data.title}`,((l=s.data)==null?void 0:l.composite)!=null&&` (${Number(s.data.composite).toFixed(4)})`]})]},s.id)})}):e("div",{class:"text-sm text-muted-foreground py-8 text-center",children:"No events yet"})}function en({agent:t,onClick:r}){const n=t.composite!=null?t.composite.toFixed(4):"—",s=t.delta!=null?`${t.delta>=0?"+":""}${t.delta.toFixed(4)}`:null,o=t.delta!=null?t.delta>0?"up":t.delta<0?"down":"neutral":"neutral",i=o==="up"?"text-success":o==="down"?"text-destructive":"text-muted-foreground",l=Object.entries(t.metrics).filter(([u])=>u!=="composite");return e("button",{onClick:r,class:"w-full text-left bg-card rounded-lg border border-border p-4 hover:border-muted-foreground/40 transition-colors animate-fade-in",children:[e("div",{class:"flex items-center justify-between mb-3",children:[e("div",{class:"flex items-center gap-2",children:[e(Se,{status:"active"}),e("span",{class:"font-medium text-sm",children:t.agent})]}),t.model_version&&e("span",{class:"text-[10px] mono text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:t.model_version})]}),e("div",{class:"flex items-end justify-between",children:[e("div",{children:[e("div",{class:"text-2xl font-semibold mono",children:n}),s&&e("span",{class:`text-xs mono ${i}`,children:s})]}),t.trajectory.length>1&&e(Ge,{data:t.trajectory,color:o==="up"?"var(--success)":o==="down"?"var(--destructive)":"var(--info)"})]}),l.length>0&&e("div",{class:"mt-3 pt-3 border-t border-border grid grid-cols-2 gap-x-4 gap-y-1",children:l.map(([u,c])=>e("div",{class:"flex justify-between text-xs",children:[e("span",{class:"text-muted-foreground",children:u}),e("span",{class:"mono",children:typeof c=="number"?c.toFixed(4):c})]},u))})]})}const ee={card:"rgba(24, 24, 28, 0.95)",border:"rgba(60, 60, 60, 0.25)",text:"#f5f5f5",textMuted:"#8b8b8b",textDim:"#5a5a5a",data:"#4a7dfc",rl:"#a855f7",success:"#34d399",alert:"#f87171",orange:"#FF5722"};function Ht(t){return t.includes("error")||t.includes("fail")||t.includes("crash")||t.includes("regression")?"alert":t.includes("scored")||t.includes("success")||t.includes("complete")||t.includes("pass")?"success":t.includes("peter")||t.includes("rollout")||t.includes("experiment")||t.includes("rl:")?"rl":"data"}function dt(t){switch(t){case"alert":return ee.alert;case"success":return ee.success;case"rl":return ee.rl;default:return ee.data}}function tn(t){return!(t.type.startsWith("session:")||t.type.startsWith("hook:")||t.type==="heartbeat")}function rn(t){const r=t.source||"unknown";let n="system";const s=t.type.toLowerCase();return s.includes("eval:")||s.includes(":scored")?n=r.includes("eval")?"peter-parker":"eval-engine":s.includes("telemetry:")?n="peter-parker":s.includes("peter:")?s.includes("rollout")?n="stratus":s.includes("task")?n="eval-engine":n="agents":s.includes("stratus:")?n="eval-engine":s.includes("flow:")&&(n="flow-engine"),{source:r,destination:n}}function nn(t){const r=t.data||{};if(t.type==="eval:scored"){const n=r.agent||"agent",s=typeof r.composite=="number"?r.composite.toFixed(4):"—",o=typeof r.delta=="number"?r.delta>=0?`+${r.delta.toFixed(4)}`:r.delta.toFixed(4):null;return o?`${n} scored ${s} (${o})`:`${n} scored ${s}`}return t.type.includes("task-completed")?r.description||r.title||"Task completed":t.type.includes("insight")?r.summary||r.insight||"Insight generated":t.type.includes("flow:triggered")?`Flow "${r.flow||r.name||"flow"}" triggered`:t.type.includes("rollout")?r.description||"Rollout initiated":t.type.includes("regression")?r.message||"Regression detected":r.title||r.message||r.description||t.type.split(":").pop()||t.type}function sn({events:t,windowMs:r=6e4,buckets:n=12}){const s=Date.now(),o=r/n,i=Array(n).fill(0);for(const m of t){const a=s-new Date(m.ts).getTime();if(a<r){const g=Math.floor(a/o);g<n&&i[n-1-g]++}}const l=Math.max(...i,1),u=80,c=20,d=u/n-1;return e("svg",{width:u,height:c,class:"shrink-0",children:[i.map((m,a)=>{const g=m/l*(c-4),y=a*(d+1),v=c-g-2;return e("rect",{x:y,y:v,width:d,height:g,fill:ee.orange,opacity:.3+m/l*.7,rx:"1"},a)}),e("rect",{x:(n-1)*(d+1),y:c-i[n-1]/l*(c-4)-2,width:d,height:i[n-1]/l*(c-4),fill:ee.orange,rx:"1",children:e("animate",{attributeName:"opacity",values:"1;0.5;1",dur:"1s",repeatCount:"indefinite"})})]})}function on({events:t,maxEvents:r=50,useSSE:n=!0,collapsed:s,onToggleCollapse:o,className:i}){const[l,u]=P([]),[c,d]=P(!1),[m,a]=P(!1),g=be(null),y=be(!0),v=s??c,T=o??d,R=(t??l).filter(tn);fe(()=>{if(!n||t)return;const f=kr("/api/events/stream",x=>{a(!0);const I=x;u(h=>[I,...h].slice(0,r))},()=>a(!1));return()=>f()},[n,t,r]),fe(()=>{y.current&&g.current&&!v&&(g.current.scrollTop=0)},[R.length,v]);const w=Ee(()=>{g.current&&(y.current=g.current.scrollTop<10)},[]),A=R.length,S=R.filter(f=>Date.now()-new Date(f.ts).getTime()<6e4).length;return e("div",{class:M("rounded-lg overflow-hidden",i),style:{background:ee.card,border:`1px solid ${ee.border}`,backdropFilter:"blur(12px)"},children:[e("button",{onClick:()=>T(!v),class:"w-full flex items-center justify-between px-4 py-2.5 transition-colors",style:{background:"transparent",border:"none",borderBottom:v?"none":`1px solid ${ee.border}`},children:[e("div",{class:"flex items-center gap-3",children:[e("div",{class:"flex items-center gap-2",children:[e("span",{class:"w-2 h-2 rounded-full",style:{backgroundColor:m?ee.success:ee.textDim,boxShadow:m?`0 0 8px ${ee.success}`:"none"}}),e("span",{class:"text-xs font-semibold uppercase tracking-wider",style:{color:ee.text},children:"Flow Log"})]}),e("span",{class:"text-[10px] mono px-2 py-0.5 rounded-full",style:{background:`${ee.orange}15`,color:ee.orange,border:`1px solid ${ee.orange}25`},children:[S,"/min"]})]}),e("div",{class:"flex items-center gap-4",children:[e(sn,{events:R}),e("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:ee.textMuted,"stroke-width":"2",style:{transform:v?"rotate(0deg)":"rotate(180deg)",transition:"transform 0.2s ease"},children:e("path",{d:"M6 9l6 6 6-6"})})]})]}),!v&&e("div",{ref:g,onScroll:w,class:"overflow-y-auto animate-fade-in",style:{maxHeight:"240px"},children:R.length===0?e("div",{class:"px-4 py-6 text-center",children:e("span",{class:"text-xs",style:{color:ee.textMuted},children:m?"Waiting for events...":"Connecting to event stream..."})}):e("div",{class:"divide-y",style:{borderColor:`${ee.border}`},children:R.slice(0,20).map((f,x)=>{const I=Ht(f.type),h=dt(I),{source:C,destination:E}=rn(f),$=nn(f);return e("div",{class:"px-4 py-2 flex items-start gap-3 transition-colors hover:bg-white/[0.02]",style:{animation:x===0?"fade-in 0.2s ease":void 0,borderColor:ee.border},children:[e("span",{class:"text-[9px] mono shrink-0 w-12 mt-0.5",style:{color:ee.textDim},children:te(f.ts)}),e("div",{class:"flex items-center gap-1.5 shrink-0 min-w-[140px]",children:[e("span",{class:"text-[9px] mono truncate max-w-[50px]",style:{color:ee.textMuted},children:C.split("-")[0]}),e("svg",{width:"14",height:"8",viewBox:"0 0 14 8",class:"shrink-0",children:e("path",{d:"M0 4h10M8 1l3 3-3 3",fill:"none",stroke:h,"stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})}),e("span",{class:"text-[9px] mono truncate max-w-[50px]",style:{color:ee.textMuted},children:E.split("-")[0]})]}),e("span",{class:"text-[8px] mono px-1.5 py-0.5 rounded shrink-0 uppercase tracking-wider",style:{background:`${h}18`,color:h,border:`1px solid ${h}30`},children:I}),e("span",{class:"text-[10px] truncate flex-1",style:{color:ee.text},children:$})]},f.id||`${f.ts}-${x}`)})})}),v&&A>0&&e("div",{class:"px-4 py-1.5 flex items-center justify-between",children:[e("span",{class:"text-[9px] mono",style:{color:ee.textDim},children:[A," events buffered"]}),e("div",{class:"flex gap-1",children:["data","rl","success","alert"].map(f=>{const x=R.filter(I=>Ht(I.type)===f).length;return x===0?null:e("span",{class:"text-[8px] mono px-1 rounded",style:{background:`${dt(f)}15`,color:dt(f)},children:x},f)})})]})]})}const ge={border:"rgba(60, 60, 60, 0.25)",text:"#f5f5f5",textMuted:"#8b8b8b",textDim:"#5a5a5a",success:"#34d399",destructive:"#f87171",purple:"#a855f7",orange:"#FF5722"};function zt(t){switch(t){case"regression":return"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z";case"insight":return"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z";case"milestone":return"M5 3v4M3 5h4M6 17v4m-2-2h4m5-16l2.286 6.857L21 12l-5.714 2.143L13 21l-2.286-6.857L5 12l5.714-2.143L13 3z";case"success":return"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"}}function Ae(t){switch(t){case"regression":return ge.destructive;case"insight":return ge.purple;case"milestone":return ge.orange;case"success":return ge.success}}function ln(t){switch(t){case"regression":return`${ge.destructive}08`;case"insight":return`${ge.purple}08`;case"milestone":return`${ge.orange}08`;case"success":return`${ge.success}08`}}function an(t){const r=t.data||{},n=t.type.toLowerCase();if(n.includes("regression")||n==="eval:scored"&&r.delta<-.01)return{id:t.id,type:"regression",title:"Regression Detected",description:r.message||r.description||`Score dropped by ${Math.abs(r.delta||0).toFixed(4)}`,ts:t.ts,source:t.source,data:r};if(n.includes("insight")||n.includes("discovery")||n.includes("correlation"))return{id:t.id,type:"insight",title:r.title||"Cross-Service Insight",description:r.summary||r.insight||r.description||"New pattern detected",ts:t.ts,source:t.source,data:r};if(n.includes("milestone")||n.includes("first-positive")||n.includes("breakthrough"))return{id:t.id,type:"milestone",title:r.title||"Agent Milestone",description:r.description||r.message||"Achievement unlocked",ts:t.ts,source:t.source,data:r};if(n==="eval:scored"){const s=r.delta,o=r.composite;if(s>.02)return{id:t.id,type:"success",title:"Significant Improvement",description:`${r.agent||"Agent"} improved by +${s.toFixed(4)} to ${(o==null?void 0:o.toFixed(4))||"—"}`,ts:t.ts,source:t.source,data:r}}if(n.includes("test")&&(n.includes("added")||n.includes("created"))){const s=r.count||r.tests_added||1;return{id:t.id,type:"milestone",title:"Tests Added",description:`${s} new test${s>1?"s":""} added to coverage`,ts:t.ts,source:t.source,data:r}}return null}function cn({className:t,maxAlerts:r=5}){var m;const[n,s]=P(new Set),[o,i]=P([]),u=((m=G(()=>j.events(100),15e3).data)==null?void 0:m.events)||[];fe(()=>{const a=[],g=new Set;for(const y of u){if(g.has(y.id)||n.has(y.id))continue;g.add(y.id);const v=an(y);v&&a.push(v)}a.sort((y,v)=>new Date(v.ts).getTime()-new Date(y.ts).getTime()),i(a.slice(0,r))},[u,n,r]);const c=a=>{s(g=>new Set([...g,a]))},d=()=>{s(a=>new Set([...a,...o.map(g=>g.id)]))};return o.length===0?null:e("div",{class:M("rounded-lg overflow-hidden animate-fade-in",t),style:{background:ln(o[0].type),border:`1px solid ${Ae(o[0].type)}30`},children:[e("div",{class:"px-4 py-2.5 flex items-center justify-between",style:{borderBottom:`1px solid ${Ae(o[0].type)}20`},children:[e("div",{class:"flex items-center gap-2",children:[e("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:Ae(o[0].type),"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:e("path",{d:zt(o[0].type)})}),e("span",{class:"text-xs font-semibold uppercase tracking-wider",style:{color:Ae(o[0].type)},children:o.length===1?"Alert":`${o.length} Alerts`})]}),o.length>1&&e("button",{onClick:d,class:"text-[9px] mono px-2 py-0.5 rounded transition-colors",style:{color:ge.textMuted,background:"rgba(255,255,255,0.05)",border:"none"},children:"dismiss all"})]}),e("div",{class:"divide-y",style:{borderColor:`${ge.border}`},children:o.map((a,g)=>{const y=Ae(a.type);return e("div",{class:"px-4 py-3 flex items-start gap-3 transition-all",style:{animation:g===0?"fade-in 0.3s ease":void 0,background:g===0?`${y}05`:"transparent",borderColor:`${y}15`},children:[e("div",{class:"shrink-0 w-8 h-8 rounded-lg flex items-center justify-center",style:{background:`${y}15`,border:`1px solid ${y}25`},children:e("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:y,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:e("path",{d:zt(a.type)})})}),e("div",{class:"flex-1 min-w-0",children:[e("div",{class:"flex items-center gap-2 mb-0.5",children:[e("span",{class:"text-sm font-medium",style:{color:ge.text},children:a.title}),e("span",{class:"text-[9px] mono",style:{color:ge.textDim},children:te(a.ts)})]}),e("p",{class:"text-xs leading-relaxed",style:{color:ge.textMuted},children:a.description}),a.source&&e("span",{class:"text-[9px] mono mt-1 inline-block",style:{color:ge.textDim},children:["via ",a.source]})]}),e("button",{onClick:()=>c(a.id),class:"shrink-0 p-1.5 rounded transition-colors hover:bg-white/5",style:{color:ge.textMuted,background:"none",border:"none"},children:e("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:e("path",{d:"M18 6L6 18M6 6l12 12"})})})]},a.id)})})]})}function Sr({name:t}){return e("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"shrink-0",children:{dashboard:e(le,{children:[e("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),e("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),e("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),e("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]}),events:e("path",{d:"M13 2 3 14h9l-1 8 10-12h-9z"}),loop:e(le,{children:[e("circle",{cx:"7",cy:"12",r:"2"}),e("circle",{cx:"12",cy:"7",r:"2"}),e("circle",{cx:"17",cy:"10",r:"2"}),e("circle",{cx:"12",cy:"17",r:"2"}),e("path",{d:"M7 12l5-5M12 7l5 3M17 10l-5 7"})]}),topology:e(le,{children:[e("circle",{cx:"5",cy:"6",r:"2"}),e("circle",{cx:"12",cy:"4",r:"2"}),e("circle",{cx:"19",cy:"8",r:"2"}),e("circle",{cx:"7",cy:"18",r:"2"}),e("circle",{cx:"17",cy:"17",r:"2"}),e("path",{d:"M7 6l5-2M14 4l5 4M5 8l2 10M12 6l5 11M9 18h8"})]}),system:e(le,{children:[e("path",{d:"M3 3v18h18"}),e("path",{d:"m7 16 4-8 4 4 4-6"})]}),reviews:e(le,{children:[e("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e("path",{d:"M14 2v6h6"}),e("path",{d:"m9 15 2 2 4-4"})]}),chat:e("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"}),synopsis:e(le,{children:[e("path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"}),e("path",{d:"M8 7h6"}),e("path",{d:"M8 11h8"})]}),search:e(le,{children:[e("circle",{cx:"11",cy:"11",r:"8"}),e("path",{d:"m21 21-4.3-4.3"})]}),findings:e(le,{children:[e("circle",{cx:"12",cy:"12",r:"10"}),e("path",{d:"M12 8v4"}),e("path",{d:"M12 16h.01"})]})}[t]})}const dn=[{id:"overview",label:"Overview",icon:"dashboard"},{id:"activity",label:"Activity",icon:"events"},{id:"kanban",label:"Kanban",icon:"findings"},{id:"loop",label:"Loop",icon:"loop"},{id:"agents",label:"Agents",icon:"system"},{id:"experiments",label:"Experiments",icon:"system"},{id:"findings",label:"Findings",icon:"findings"},{id:"reviews",label:"Reviews",icon:"reviews"},{id:"services",label:"Services",icon:"dashboard"},{id:"journal",label:"Journal",icon:"synopsis"},{id:"events",label:"Events",icon:"events"},{id:"health",label:"Health",icon:"loop"},{id:"telemetry",label:"Telemetry",icon:"system"},{id:"chat",label:"Chat",icon:"chat"},{id:"synopsis",label:"Synopsis",icon:"synopsis"},{id:"topology",label:"Topology",icon:"topology"},{id:"system",label:"System",icon:"system"},{id:"flows",label:"Flows",icon:"loop"},{id:"setup-report",label:"Setup Report",icon:"findings"},{id:"system-graph",label:"System Graph",icon:"topology"}];function un({status:t,currentPage:r,setPage:n}){var m,a;const s=((m=t==null?void 0:t.config)==null?void 0:m.name)||"JFL",o=(t==null?void 0:t.status)||"unknown",i=(t==null?void 0:t.type)||"standalone",l=(t==null?void 0:t.children)||[],c=G(()=>j.leaderboard(),3e4).data||[],d=c.length>0?[...c].sort((g,y)=>(y.composite||0)-(g.composite||0))[0]:null;return e("aside",{class:"w-56 h-screen bg-sidebar flex flex-col fixed left-0 top-0 z-10 border-r border-sidebar-border",children:[e("div",{class:"px-4 pt-5 pb-4",children:[e("div",{class:"flex items-center gap-2.5",children:[e("div",{class:M("w-7 h-7 rounded-lg flex items-center justify-center text-xs font-bold",o==="ok"||o==="running"?"bg-success/15 text-success":"bg-warning/15 text-warning"),children:s.charAt(0).toUpperCase()}),e("div",{class:"min-w-0",children:[e("div",{class:"font-semibold text-sm text-sidebar-foreground truncate",children:s}),e("div",{class:"flex items-center gap-1.5 mt-0.5",children:[e("span",{class:"text-[10px] mono text-muted-foreground uppercase tracking-wider",children:i}),(t==null?void 0:t.port)&&e("span",{class:"text-[10px] mono text-muted-foreground",children:[":",t.port]})]})]})]}),(d==null?void 0:d.trajectory)&&d.trajectory.length>1&&e("div",{class:"mt-3 flex items-center gap-2",children:[e(Ge,{data:d.trajectory,width:100,height:20,color:d.delta!=null&&d.delta>0?"var(--success)":"var(--info)"}),e("span",{class:"text-[10px] mono tabular-nums text-muted-foreground",children:(a=d.composite)==null?void 0:a.toFixed(2)})]})]}),e("div",{class:"px-3 pb-3",children:e(pn,{setPage:n})}),e("nav",{class:"flex-1 overflow-y-auto pb-2",children:[dn.map(g=>e("button",{onClick:()=>n(g.id),class:M("w-full flex items-center gap-2.5 px-4 py-1.5 text-[13px] transition-colors relative",r===g.id?"text-sidebar-foreground font-medium bg-accent/60 before:absolute before:left-0 before:top-[5px] before:bottom-[5px] before:w-[2px] before:bg-info before:rounded-r":"text-muted-foreground hover:text-sidebar-foreground hover:bg-accent/30"),children:[e(Sr,{name:g.icon}),g.label]},g.id)),c.length>0&&e("div",{class:"mt-5",children:[e("div",{class:"px-4 pb-1 text-[10px] uppercase tracking-widest text-muted-foreground font-medium",children:"Agents"}),c.sort((g,y)=>(y.composite||0)-(g.composite||0)).slice(0,6).map(g=>{const y=g.delta!=null&&g.delta>0;return e("button",{onClick:()=>n("loop"),class:"w-full flex items-center gap-2.5 px-4 py-1 text-[13px] text-muted-foreground hover:text-sidebar-foreground transition-colors",children:[e("span",{class:M("w-[6px] h-[6px] rounded-full shrink-0",y?"bg-success":"bg-muted-foreground/50")}),e("span",{class:"truncate",children:g.agent}),g.composite!=null&&e("span",{class:"ml-auto mono text-[10px] tabular-nums",children:g.composite.toFixed(2)})]},g.agent)})]})]}),l.length>0&&e("div",{class:"border-t border-sidebar-border py-3 px-4",children:[e("div",{class:"text-[10px] uppercase tracking-widest text-muted-foreground font-medium mb-2",children:"Products"}),e("div",{class:"space-y-1.5",children:l.map(g=>e("div",{class:"flex items-center gap-2",children:[e("span",{class:M("w-[6px] h-[6px] rounded-full shrink-0",g.status==="ok"?"bg-success":g.status==="error"?"bg-destructive":"bg-muted-foreground/50")}),e("span",{class:"text-xs text-sidebar-foreground truncate flex-1",children:g.name}),e("span",{class:"text-[10px] mono text-muted-foreground",children:[":",g.port]})]},g.name))})]}),e("div",{class:"px-4 py-3 border-t border-sidebar-border",children:e("div",{class:"text-[10px] text-muted-foreground/60 mono",children:"jfl v0.3.0"})})]})}function pn({setPage:t}){const[r,n]=P(""),[s,o]=P([]),[i,l]=P(!1),u=async()=>{var c;if(r.trim()){l(!0);try{const d=await j.memorySearch(r.trim());o(((c=d.results)==null?void 0:c.slice(0,5))||[])}catch{o([])}l(!1)}};return e("div",{class:"relative",children:[e("div",{class:"flex items-center gap-1.5 bg-accent/40 rounded-md px-2.5 py-1.5 border border-sidebar-border/50 focus-within:border-info/50 transition-colors",children:[e(Sr,{name:"search"}),e("input",{type:"text",placeholder:"Search...",value:r,onInput:c=>n(c.target.value),onKeyDown:c=>c.key==="Enter"&&u(),class:"bg-transparent text-xs text-sidebar-foreground placeholder:text-muted-foreground/50 outline-none flex-1 min-w-0"}),i&&e("span",{class:"text-[10px] text-muted-foreground animate-pulse-dot",children:"..."})]}),s.length>0&&e("div",{class:"absolute top-full left-0 right-0 mt-1 bg-card border border-border rounded-md shadow-lg z-50 max-h-60 overflow-y-auto",children:s.map((c,d)=>{var m;return e("button",{onClick:()=>{o([]),n(""),t("activity")},class:"w-full text-left px-3 py-2 hover:bg-muted/30 transition-colors border-b border-border/30 last:border-0",children:[e("div",{class:"text-xs font-medium truncate",children:c.title||((m=c.content)==null?void 0:m.slice(0,60))}),e("div",{class:"flex items-center gap-2 mt-0.5",children:[c.type&&e("span",{class:"text-[10px] mono text-info",children:c.type}),c.relevance&&e("span",{class:M("text-[10px] mono",c.relevance==="high"?"text-success":"text-muted-foreground"),children:c.relevance})]})]},d)})})]})}function hn({status:t}){var C,E,$,b;const r=G(()=>j.events(100),1e4),n=G(()=>j.leaderboard(),15e3),s=G(()=>j.journal(),15e3),o=G(()=>j.synopsis(24),3e4),i=G(()=>j.memoryStatus(),3e4),l=G(()=>j.flowExecutions(),15e3),u=(t==null?void 0:t.type)||"standalone",c=t==null?void 0:t.config,d=(t==null?void 0:t.children)||[],m=((C=r.data)==null?void 0:C.events)||[],a=n.data||[],g=s.data||[],y=(t==null?void 0:t.sources)||{},v=Object.values(y).filter(Boolean).length,T=Object.keys(y).length,_=i.data,R=l.data,A=(Array.isArray(R)?R:(R==null?void 0:R.executions)||[]).filter(p=>p.gated),S=a.length>0?[...a].sort((p,k)=>(k.composite||0)-(p.composite||0))[0]:null,f=g.filter(p=>p.type!=="file").slice(0,5),x=m.filter(p=>!p.type.startsWith("session:")&&!p.type.startsWith("hook:")).slice(0,10),[I,h]=P(!1);return e("div",{class:"space-y-6",children:[e("div",{class:"flex items-center justify-between",children:[e("div",{children:[e("h1",{class:"text-xl font-semibold",children:(c==null?void 0:c.name)||"Dashboard"}),(c==null?void 0:c.description)&&e("p",{class:"text-sm text-muted-foreground mt-1",children:c.description})]}),e(gn,{})]}),e(cn,{maxAlerts:3}),e("div",{class:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e(ae,{label:"Sources",value:`${v}/${T}`,sub:"connected",trend:v===T?"up":"down"}),e(ae,{label:"Items",value:(t==null?void 0:t.itemCount)||0,sub:"indexed"}),e(ae,{label:"Agents",value:a.length,sub:S?`best: ${(E=S.composite)==null?void 0:E.toFixed(2)}`:"none",trend:(S==null?void 0:S.delta)!=null&&S.delta>0?"up":void 0}),e(ae,{label:"Memories",value:(_==null?void 0:_.total_memories)||0,sub:($=_==null?void 0:_.embeddings)!=null&&$.available?"with embeddings":"keyword only"})]}),A.length>0&&e("div",{class:"bg-warning/5 border border-warning/30 rounded-lg p-4",children:[e("h3",{class:"text-xs text-warning uppercase tracking-wider font-medium mb-2",children:["Actions Needed (",A.length,")"]}),e("div",{class:"space-y-1.5",children:A.map((p,k)=>e("div",{class:"flex items-center justify-between",children:[e("div",{class:"flex items-center gap-2",children:[e("span",{class:"w-1.5 h-1.5 rounded-full bg-warning animate-pulse"}),e("span",{class:"text-sm font-medium",children:p.flow}),e("span",{class:"text-[10px] mono text-muted-foreground",children:te(p.started_at)})]}),e("button",{onClick:()=>j.approveFlow(p.flow,p.trigger_event_id),class:"text-[10px] mono px-2 py-0.5 rounded bg-success/15 text-success hover:bg-success/25 transition-colors",children:"approve"})]},k))})]}),S&&e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("div",{class:"flex items-center justify-between mb-3",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider",children:"Top Agent"}),e("span",{class:"text-[10px] mono text-muted-foreground",children:[a.length," total"]})]}),e("div",{class:"flex items-center gap-4",children:[e("div",{children:[e("div",{class:"text-sm font-medium",children:S.agent}),e("div",{class:"flex items-center gap-2 mt-1",children:[e("span",{class:"text-2xl font-bold tabular-nums",children:(b=S.composite)==null?void 0:b.toFixed(4)}),S.delta!=null&&e("span",{class:M("text-sm mono",S.delta>=0?"text-success":"text-destructive"),children:[S.delta>=0?"+":"",S.delta.toFixed(4)]})]})]}),S.trajectory&&S.trajectory.length>1&&e(Ge,{data:S.trajectory,width:160,height:36,color:S.delta!=null&&S.delta>0?"var(--success)":"var(--info)"})]})]}),o.data&&e(mn,{data:o.data}),u==="portfolio"&&d.length>0&&e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:["Products (",d.length,")"]}),e("div",{class:"space-y-2",children:d.map(p=>e("div",{class:"flex items-center gap-3 text-sm",children:[e(Se,{status:p.status==="ok"?"ok":"error"}),e("span",{class:"font-medium",children:p.name}),e("span",{class:"text-[10px] mono text-muted-foreground",children:[":",p.port]}),p.status==="ok"&&e("a",{href:`http://localhost:${p.port}/dashboard/`,target:"_blank",rel:"noopener",class:"text-[10px] text-info hover:underline ml-auto",children:"Open"})]},p.name))})]}),e("div",{class:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:"Recent Journal"}),f.length>0?e("div",{class:"space-y-2",children:f.map((p,k)=>e("div",{class:"flex items-start gap-2 text-sm",children:[e("span",{class:"text-[10px] mono text-muted-foreground whitespace-nowrap mt-0.5 w-12 shrink-0",children:te(p.timestamp||p.ts)}),e("div",{class:"min-w-0",children:[e("div",{class:"truncate",children:p.title}),p.type&&e("span",{class:"text-[10px] mono text-info",children:p.type})]})]},k))}):e("div",{class:"text-sm text-muted-foreground",children:"No journal entries"})]}),e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:"Recent Events"}),x.length>0?e("div",{class:"space-y-2",children:x.map(p=>{var N;const k=p.data||{},L=p.type.startsWith("hook:")?`${k.tool_name||"tool"} ${(N=k.file_paths)!=null&&N.length?`on ${k.file_paths[0]}`:""}`:k.title||k.agent||p.source||p.type;return e("div",{class:"flex items-start gap-2 text-sm",children:[e("span",{class:"text-[10px] mono text-muted-foreground whitespace-nowrap mt-0.5 w-12 shrink-0",children:te(p.ts)}),e("div",{class:"min-w-0",children:e("div",{class:"flex items-center gap-2",children:[e("span",{class:"text-[10px] mono text-info whitespace-nowrap",children:p.type}),e("span",{class:"truncate text-muted-foreground",children:L})]})})]},p.id)})}):e("div",{class:"text-sm text-muted-foreground",children:"No events"})]})]}),e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:"Context Sources"}),e("div",{class:"grid grid-cols-2 md:grid-cols-4 gap-3",children:Object.entries(y).map(([p,k])=>e("div",{class:"flex items-center gap-2",children:[e("span",{class:M("w-1.5 h-1.5 rounded-full",k?"bg-success":"bg-destructive")}),e("span",{class:"text-sm capitalize",children:p}),e("span",{class:"text-[10px] text-muted-foreground",children:k?"ok":"disconnected"})]},p))})]}),e(on,{events:m,collapsed:I,onToggleCollapse:h})]})}function gn(){const[t,r]=P(null),n=[{label:"run eval",event:"eval:run-requested",data:{source:"dashboard"}},{label:"run peter",spawn:!0,command:"jfl",args:["peter","run"]}],s=async o=>{try{o.spawn?await j.spawnAction(o.command,o.args,o.event):await j.publishEvent(o.event,o.data||{}),r(o.label),setTimeout(()=>r(null),2e3)}catch(i){console.error("Action failed:",i)}};return e("div",{class:"flex items-center gap-2",children:n.map(o=>e("button",{onClick:()=>s(o),class:M("text-[10px] mono px-2 py-1 rounded transition-colors",t===o.label?"bg-success/15 text-success":"bg-muted text-muted-foreground hover:text-foreground hover:bg-muted/80"),children:t===o.label?"done":o.label},o.label))})}function mn({data:t}){const r=t.summary;return r.features+r.fixes+r.decisions+r.discoveries>0||t.commits.length>0?e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:["Work Summary ",e("span",{class:"text-[10px] font-normal",children:["last ",t.hours,"h"]})]}),e("div",{class:"grid grid-cols-2 md:grid-cols-5 gap-4 mb-4",children:[r.features>0&&e("div",{children:[e("div",{class:"text-lg font-semibold mono text-success",children:r.features}),e("div",{class:"text-[10px] text-muted-foreground uppercase",children:"Features"})]}),r.fixes>0&&e("div",{children:[e("div",{class:"text-lg font-semibold mono text-warning",children:r.fixes}),e("div",{class:"text-[10px] text-muted-foreground uppercase",children:"Fixes"})]}),r.decisions>0&&e("div",{children:[e("div",{class:"text-lg font-semibold mono text-info",children:r.decisions}),e("div",{class:"text-[10px] text-muted-foreground uppercase",children:"Decisions"})]}),r.discoveries>0&&e("div",{children:[e("div",{class:"text-lg font-semibold mono text-purple-400",children:r.discoveries}),e("div",{class:"text-[10px] text-muted-foreground uppercase",children:"Discoveries"})]}),t.commits.length>0&&e("div",{children:[e("div",{class:"text-lg font-semibold mono",children:t.commits.length}),e("div",{class:"text-[10px] text-muted-foreground uppercase",children:"Commits"})]})]}),t.commits.length>0&&e("div",{class:"border-t border-border pt-3",children:e("div",{class:"space-y-1",children:t.commits.slice(0,5).map(s=>e("div",{class:"flex items-center gap-2 text-xs",children:[e("span",{class:"mono text-muted-foreground text-[10px]",children:s.hash.slice(0,7)}),e("span",{class:"truncate",children:s.message}),e("span",{class:"text-[10px] text-muted-foreground ml-auto whitespace-nowrap",children:te(s.date)})]},s.hash))})}),r.incompleteItems.length>0&&e("div",{class:"border-t border-border pt-3 mt-3",children:[e("div",{class:"text-[10px] text-muted-foreground uppercase tracking-wider mb-2",children:"Incomplete"}),e("div",{class:"space-y-1",children:r.incompleteItems.slice(0,5).map((s,o)=>e("div",{class:"text-xs text-warning/80 flex items-center gap-1.5",children:[e("span",{class:"w-1 h-1 rounded-full bg-warning/60 shrink-0"}),s]},o))})]})]}):null}const Cr=["scout","planner","builder","reviewer","tester"],Mr={"cost-optimized":{scout:"haiku",planner:"sonnet",builder:"sonnet",reviewer:"sonnet",tester:"haiku"},balanced:{scout:"haiku",planner:"sonnet",builder:"sonnet",reviewer:"opus",tester:"sonnet"},"quality-first":{scout:"sonnet",planner:"opus",builder:"sonnet",reviewer:"opus",tester:"sonnet"}},yt={scout:"sonnet",planner:"opus",builder:"opus",reviewer:"opus",tester:"sonnet"},_t={haiku:"bg-success/15 text-success",sonnet:"bg-info/15 text-info",opus:"bg-purple-500/15 text-purple-400"},fn={scout:"Explores codebase, gathers context",planner:"Designs approach, breaks down tasks",builder:"Writes code, implements features",reviewer:"Reviews output, catches issues",tester:"Validates correctness, runs checks"};function xn(t){const r={};for(const n of t){const s=Object.keys(n.metrics).filter(i=>i!=="composite");let o="other";s.some(i=>["ndcg@10","mrr","precision@5"].includes(i))?o="ProductRank":s.some(i=>["avg_rank","keywords_ranked","rank_rate"].includes(i))&&(o="SEO"),r[o]||(r[o]=[]),r[o].push(n)}return r}function bn(){const t=G(()=>j.leaderboard(),15e3),[r,n]=P(null),s=t.data||[],o=xn(s);return e("div",{class:"space-y-6",children:[e("div",{class:"flex items-center justify-between",children:[e("h1",{class:"text-xl font-semibold",children:"Agents"}),e("span",{class:"text-sm text-muted-foreground",children:[s.length," tracked"]})]}),e(vn,{}),t.loading?e("div",{class:"text-sm text-muted-foreground",children:"Loading..."}):s.length===0?e("div",{class:"bg-card rounded-lg border border-border p-8 text-center",children:[e("div",{class:"text-muted-foreground text-sm",children:"No eval data yet"}),e("div",{class:"text-muted-foreground text-xs mt-1",children:"Run evaluations to see agent performance here"})]}):Object.entries(o).map(([i,l])=>e("section",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:[i,e("span",{class:"text-[10px] ml-2 normal-case",children:["(",l.length," agents)"]})]}),e("div",{class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:l.sort((u,c)=>(c.composite||0)-(u.composite||0)).map(u=>e(en,{agent:u,onClick:()=>n(u.agent===r?null:u.agent)},u.agent))}),r&&l.some(u=>u.agent===r)&&e(kn,{agentName:r})]},i))]})}function vn(){const[t,r]=P("balanced"),[n,s]=P(!1),[o,i]=P(!1),u=G(()=>j.events(50,"peter:*").then(a=>((a==null?void 0:a.events)||[]).filter(y=>y.type.startsWith("peter:"))),15e3).data||[],c=u.find(a=>a.type==="peter:started"),d=u.filter(a=>a.type==="peter:task-completed").length,m=c&&!u.some(a=>a.type==="peter:all-complete"&&a.ts>c.ts);return e("section",{children:[e("div",{class:"flex items-center justify-between mb-3",children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:["Peter Parker",e("span",{class:"text-[10px] ml-2 normal-case",children:"RL Orchestrator"})]}),m&&e("span",{class:"text-[10px] mono px-1.5 py-0.5 rounded bg-success/10 text-success uppercase animate-pulse-dot",children:"running"})]}),e("div",{class:"grid grid-cols-1 md:grid-cols-5 gap-3 mb-4",children:Cr.map(a=>{const g=Mr[t][a],y=yt[a],T=u.filter(_=>{var R,w;return((R=_.data)==null?void 0:R.agent_role)===a||((w=_.data)==null?void 0:w.role)===a})[0];return e("div",{class:"bg-card rounded-lg border border-border p-3 animate-fade-in",children:[e("div",{class:"flex items-center justify-between mb-2",children:[e("span",{class:"text-xs font-medium capitalize",children:a}),e("span",{class:M("text-[10px] mono px-1.5 py-0.5 rounded uppercase",_t[g]),children:g})]}),e("div",{class:"text-[10px] text-muted-foreground mb-2",children:fn[a]}),e("div",{class:"flex items-center justify-between pt-2 border-t border-border",children:[e("span",{class:"text-[10px] mono text-muted-foreground",children:["fallback: ",y]}),T&&e("span",{class:"text-[10px] mono text-muted-foreground",children:te(T.ts)})]})]},a)})}),e("div",{class:"flex items-center gap-2 mb-4",children:[e("span",{class:"text-xs text-muted-foreground",children:"Profile:"}),["cost-optimized","balanced","quality-first"].map(a=>e("button",{onClick:()=>r(a),class:M("text-[10px] mono px-2 py-1 rounded transition-colors",t===a?"bg-info/15 text-info":"bg-muted text-muted-foreground hover:text-foreground"),children:a},a)),e("button",{onClick:async()=>{try{await j.spawnAction("jfl",["peter","run","--profile",t],"peter:started"),i(!0),setTimeout(()=>i(!1),3e3)}catch(a){console.error("Failed to spawn:",a)}},class:M("text-[10px] mono px-2 py-1 rounded transition-colors",o?"bg-success/15 text-success":"bg-info/15 text-info hover:bg-info/25"),children:o?"spawned":"run peter"}),e("button",{onClick:()=>s(!n),class:"ml-auto text-[10px] mono text-muted-foreground hover:text-foreground transition-colors",children:[n?"hide":"show"," full table"]})]}),n&&e(yn,{activeProfile:t}),u.length>0?e("div",{class:"bg-card rounded-lg border border-border overflow-hidden",children:[e("div",{class:"px-3 py-2 border-b border-border flex items-center justify-between",children:[e("span",{class:"text-xs font-medium",children:"Event Log"}),e("span",{class:"text-[10px] mono text-muted-foreground",children:[d," tasks completed"]})]}),e("div",{class:"max-h-64 overflow-y-auto",children:e("table",{class:"w-full text-xs",children:e("tbody",{children:u.slice(0,20).map((a,g)=>e(wn,{event:a},g))})})})]}):e("div",{class:"bg-card rounded-lg border border-border/50 p-6 text-center",children:[e("div",{class:"text-muted-foreground text-sm",children:"No orchestrator activity yet"}),e("div",{class:"text-muted-foreground text-[10px] mt-1 mono",children:["jfl peter start --profile ",t]})]})]})}function yn({activeProfile:t}){const r=["cost-optimized","balanced","quality-first"];return e("div",{class:"bg-card rounded-lg border border-border overflow-hidden mb-4 animate-fade-in",children:e("table",{class:"w-full text-xs",children:[e("thead",{children:e("tr",{class:"border-b border-border text-muted-foreground",children:[e("th",{class:"text-left py-2 px-3 font-medium",children:"Role"}),r.map(n=>e("th",{class:M("text-center py-2 px-3 font-medium",n===t&&"text-info"),children:n.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" ")},n)),e("th",{class:"text-center py-2 px-3 font-medium",children:"Fallback"})]})}),e("tbody",{children:Cr.map(n=>e("tr",{class:"border-b border-border/50",children:[e("td",{class:"py-2 px-3 font-medium capitalize",children:n}),r.map(s=>{const o=Mr[s][n];return e("td",{class:"py-2 px-3 text-center",children:e("span",{class:M("text-[10px] mono px-1.5 py-0.5 rounded inline-block",_t[o],s===t&&"ring-1 ring-info/30"),children:o})},s)}),e("td",{class:"py-2 px-3 text-center",children:e("span",{class:M("text-[10px] mono px-1.5 py-0.5 rounded inline-block",_t[yt[n]]),children:yt[n]})})]},n))})]})})}const _n={"peter:started":{color:"text-info",label:"RUN STARTED"},"peter:task-selected":{color:"text-warning",label:"TASK SELECTED"},"peter:task-completed":{color:"text-success",label:"TASK DONE"},"peter:all-complete":{color:"text-success",label:"ALL COMPLETE"}};function wn({event:t}){const r=_n[t.type]||{color:"text-muted-foreground",label:t.type},n=t.data,s=n.task_name||n.bead_title||n.title||"",o=n.agent_role||n.role||"",i=n.model||n.execution_llm||"";return e("tr",{class:"border-b border-border/50 hover:bg-muted/20 transition-colors",children:[e("td",{class:M("py-1.5 px-3 mono whitespace-nowrap",r.color),children:r.label}),e("td",{class:"py-1.5 px-3 truncate max-w-48",children:s}),e("td",{class:"py-1.5 px-3 mono text-muted-foreground",children:[o&&e("span",{class:"capitalize",children:o}),i&&e("span",{class:"ml-2 text-[10px]",children:["(",i,")"]})]}),e("td",{class:"py-1.5 px-3 mono text-muted-foreground text-right whitespace-nowrap",children:te(t.ts)})]})}function kn({agentName:t}){var s;const r=G(()=>j.trajectory(t),3e4,[t]),n=((s=r.data)==null?void 0:s.points)||[];return e("div",{class:"bg-card rounded-lg border border-border p-4 mt-4 animate-fade-in",children:[e("h3",{class:"text-sm font-medium mb-3",children:[t," — Trajectory"]}),r.loading?e("div",{class:"text-sm text-muted-foreground",children:"Loading..."}):n.length===0?e("div",{class:"text-sm text-muted-foreground",children:"No trajectory data"}):e("div",{class:"max-h-48 overflow-y-auto",children:e("table",{class:"w-full text-xs",children:[e("thead",{children:e("tr",{class:"text-muted-foreground border-b border-border",children:[e("th",{class:"text-left py-1 font-medium",children:"Time"}),e("th",{class:"text-right py-1 font-medium",children:"Score"}),e("th",{class:"text-right py-1 font-medium",children:"Model"})]})}),e("tbody",{children:n.slice().reverse().slice(0,20).map((o,i)=>e("tr",{class:"border-b border-border/50",children:[e("td",{class:"py-1 mono text-muted-foreground",children:new Date(o.ts).toLocaleString()}),e("td",{class:"py-1 mono text-right",children:o.value.toFixed(4)}),e("td",{class:"py-1 mono text-right text-muted-foreground",children:o.model_version||"—"})]},i))})]})})]})}const Sn={critical:{bg:"bg-destructive/10",text:"text-destructive",icon:"🔴"},warning:{bg:"bg-warning/10",text:"text-warning",icon:"!"},info:{bg:"bg-info/10",text:"text-info",icon:"ℹ️"}},Cn={performance_regression:"Performance Regression",test_failure:"Test Failure",error_spike:"Error Spike",coverage_gap:"Coverage Gap",stale_code:"Stale Code",eval_plateau:"Eval Plateau"};function Mn(){var A;const[t,r]=P(!1),[n,s]=P(null),[o,i]=P(null),[l,u]=P(0),c=G(()=>j.findings(!1,t),3e4,[t,l]),d=async()=>{try{await j.analyzeFindings(),u(S=>S+1)}catch(S){console.error("Failed to analyze:",S)}},m=async S=>{s(S.id);try{await j.spawnFindingAgent(S.id),setTimeout(()=>s(null),3e3)}catch(f){console.error("Failed to spawn:",f),s(null)}},a=async S=>{i(S.id);try{await j.dismissFinding(S.id),u(f=>f+1)}catch(f){console.error("Failed to dismiss:",f)}i(null)},g=((A=c.data)==null?void 0:A.findings)||[],y=g.filter(S=>!S.dismissed),v=g.filter(S=>S.dismissed),T={critical:0,warning:1,info:2};y.sort((S,f)=>T[S.severity]-T[f.severity]);const _=y.filter(S=>S.severity==="critical").length,R=y.filter(S=>S.severity==="warning").length,w=y.filter(S=>S.severity==="info").length;return e("div",{class:"space-y-6",children:[e("div",{class:"flex items-center justify-between",children:[e("div",{children:[e("h1",{class:"text-xl font-semibold",children:"Findings"}),e("p",{class:"text-sm text-muted-foreground mt-1",children:"Automatically detected issues — click Fix to spawn an agent"})]}),e("div",{class:"flex items-center gap-2",children:[e("button",{onClick:d,class:"text-[10px] mono px-2 py-1 rounded bg-muted text-muted-foreground hover:text-foreground transition-colors",children:c.loading?"analyzing...":"re-analyze"}),e("button",{onClick:()=>r(!t),class:M("text-[10px] mono px-2 py-1 rounded transition-colors",t?"bg-info/15 text-info":"bg-muted text-muted-foreground hover:text-foreground"),children:t?"hide dismissed":"show dismissed"})]})]}),y.length>0&&e("div",{class:"flex items-center gap-4",children:[_>0&&e("div",{class:"flex items-center gap-1.5",children:[e("span",{class:"w-2 h-2 rounded-full bg-destructive"}),e("span",{class:"text-sm mono",children:[_," critical"]})]}),R>0&&e("div",{class:"flex items-center gap-1.5",children:[e("span",{class:"w-2 h-2 rounded-full bg-warning"}),e("span",{class:"text-sm mono",children:[R," warning"]})]}),w>0&&e("div",{class:"flex items-center gap-1.5",children:[e("span",{class:"w-2 h-2 rounded-full bg-info"}),e("span",{class:"text-sm mono",children:[w," info"]})]})]}),c.loading&&g.length===0?e("div",{class:"text-sm text-muted-foreground animate-pulse-dot",children:"Loading findings..."}):y.length===0&&!t?e("div",{class:"bg-card rounded-lg border border-border p-8 text-center",children:[e("div",{class:"text-success text-2xl mb-2",children:"✓"}),e("div",{class:"text-sm font-medium",children:"No active findings"}),e("div",{class:"text-xs text-muted-foreground mt-1",children:"Everything looks good! Run re-analyze to check again."})]}):e("div",{class:"space-y-4",children:[y.map(S=>e(Xt,{finding:S,spawning:n===S.id,dismissing:o===S.id,onSpawn:()=>m(S),onDismiss:()=>a(S)},S.id)),t&&v.length>0&&e(le,{children:[e("div",{class:"text-xs text-muted-foreground uppercase tracking-wider pt-4",children:["Dismissed (",v.length,")"]}),v.map(S=>e(Xt,{finding:S,spawning:!1,dismissing:!1,onSpawn:()=>{},onDismiss:()=>{},disabled:!0},S.id))]})]})]})}function Xt({finding:t,spawning:r,dismissing:n,onSpawn:s,onDismiss:o,disabled:i}){const[l,u]=P(!1),c=Sn[t.severity],d=Cn[t.type];return e("div",{class:M("bg-card rounded-lg border border-border overflow-hidden transition-all",t.dismissed&&"opacity-50"),children:e("div",{class:"p-4",children:[e("div",{class:"flex items-start gap-3",children:[e("span",{class:"text-lg leading-none",children:c.icon}),e("div",{class:"flex-1 min-w-0",children:[e("div",{class:"flex items-center gap-2 flex-wrap",children:[e("span",{class:M("font-medium",c.text),children:t.title}),e("span",{class:"text-[10px] mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:d})]}),e("p",{class:"text-sm text-muted-foreground mt-1",children:t.description}),t.scope_files.length>0&&e("div",{class:"mt-2",children:[e("button",{onClick:()=>u(!l),class:"text-[10px] mono text-info hover:underline",children:[l?"hide":"show"," ",t.scope_files.length," file",t.scope_files.length!==1?"s":""]}),l&&e("div",{class:"mt-2 p-2 bg-muted/30 rounded text-xs mono space-y-0.5 max-h-32 overflow-y-auto",children:t.scope_files.map((m,a)=>e("div",{class:"text-muted-foreground truncate",children:m},a))})]})]}),!i&&e("div",{class:"flex items-center gap-2 shrink-0",children:[t.agent_config&&e("button",{onClick:s,disabled:r,class:M("text-[10px] mono px-3 py-1.5 rounded transition-colors",r?"bg-success/15 text-success":"bg-info/15 text-info hover:bg-info/25"),children:r?"spawned!":"Fix"}),e("button",{onClick:o,disabled:n,class:"text-[10px] mono px-2 py-1.5 rounded bg-muted text-muted-foreground hover:text-foreground transition-colors",children:n?"...":"dismiss"})]})]}),t.agent_config&&e("div",{class:"flex items-center gap-4 mt-3 pt-3 border-t border-border text-[10px] mono text-muted-foreground",children:[e("span",{children:["target: ",t.agent_config.metric," ≥ ",t.agent_config.target]}),e("span",{children:["rounds: ",t.agent_config.rounds]}),e("span",{children:["eval: ",t.agent_config.eval_script]})]})]})})}function Tn(){const t=G(()=>j.journal(),1e4),[r,n]=P(""),[s,o]=P(null),i=t.data||[],l={};for(const a of i)l[a.type]=(l[a.type]||0)+1;const u=Object.entries(l).sort((a,g)=>g[1]-a[1]),c=Math.max(...Object.values(l),1),d={feature:"bg-success",fix:"bg-destructive",decision:"bg-warning",milestone:"bg-info",discovery:"bg-info/70",submission:"bg-accent",iteration:"bg-muted-foreground",spec:"bg-muted-foreground/70"},m=i.filter(a=>{var g,y;if(s&&a.type!==s)return!1;if(r){const v=r.toLowerCase();return a.title.toLowerCase().includes(v)||((g=a.content)==null?void 0:g.toLowerCase().includes(v))||((y=a.source)==null?void 0:y.toLowerCase().includes(v))}return!0});return e("div",{class:"space-y-5",children:[e("div",{class:"flex items-center justify-between",children:[e("h1",{class:"text-xl font-semibold",children:"Journal"}),e("span",{class:"text-sm text-muted-foreground",children:[m.length," entries"]})]}),e("div",{class:"relative",children:[e("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:[e("circle",{cx:"11",cy:"11",r:"8"}),e("path",{d:"m21 21-4.3-4.3"})]}),e("input",{type:"text",placeholder:"Search journal entries...",value:r,onInput:a=>n(a.target.value),class:"w-full bg-card border border-border rounded-lg pl-10 pr-4 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-info/50 transition-colors"})]}),u.length>0&&e("div",{class:"flex flex-wrap gap-1.5",children:[e("button",{onClick:()=>o(null),class:M("text-[11px] mono font-medium px-2 py-0.5 rounded-md transition-colors",s?"bg-muted/50 text-muted-foreground hover:text-foreground":"bg-foreground/10 text-foreground"),children:"all"}),u.map(([a,g])=>e("button",{onClick:()=>o(s===a?null:a),class:M("text-[11px] mono font-medium px-2 py-0.5 rounded-md transition-colors",s===a?"bg-foreground/10 text-foreground":"bg-muted/50 text-muted-foreground hover:text-foreground"),children:[a,e("span",{class:"ml-1 text-[10px] opacity-60",children:g})]},a))]}),u.length>0&&!r&&!s&&e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:"By Type"}),e("div",{class:"space-y-1.5",children:u.map(([a,g])=>e("div",{class:"flex items-center gap-3",children:[e("span",{class:`text-[10px] mono font-medium px-1.5 py-0.5 rounded ${d[a]||"bg-muted"} text-white min-w-16 text-center uppercase`,children:a}),e("div",{class:"flex-1 h-1.5 bg-muted rounded-full overflow-hidden",children:e("div",{class:`h-full rounded-full ${d[a]||"bg-muted-foreground"} transition-all`,style:{width:`${g/c*100}%`}})}),e("span",{class:"text-xs mono text-muted-foreground w-6 text-right",children:g})]},a))})]}),t.loading?e("div",{class:"text-sm text-muted-foreground animate-pulse-dot",children:"Loading journal..."}):m.length===0?e("div",{class:"bg-card rounded-lg border border-border p-8 text-center text-sm text-muted-foreground",children:r||s?"No matching entries":"No journal entries"}):e("div",{class:"space-y-1.5",children:m.map((a,g)=>e(En,{entry:a,highlight:r},`${a.timestamp}-${g}`))})]})}function En({entry:t,highlight:r}){const[n,s]=P(!1),i={feature:{bg:"bg-success/10",text:"text-success"},fix:{bg:"bg-destructive/10",text:"text-destructive"},decision:{bg:"bg-warning/10",text:"text-warning"},milestone:{bg:"bg-info/10",text:"text-info"},discovery:{bg:"bg-accent",text:"text-accent-foreground"}}[t.type]||{bg:"bg-muted",text:"text-muted-foreground"};return e("button",{onClick:()=>s(!n),class:"w-full text-left bg-card rounded-lg border border-border p-3 hover:border-border/80 transition-colors animate-fade-in",children:[e("div",{class:"flex items-center gap-2 mb-1",children:[e("span",{class:`text-[10px] mono font-medium px-1.5 py-0.5 rounded ${i.bg} ${i.text}`,children:t.type}),e("span",{class:"text-[10px] text-muted-foreground mono truncate",children:t.source}),e("span",{class:"text-[10px] text-muted-foreground ml-auto mono shrink-0",children:te(t.timestamp)})]}),e("div",{class:"text-sm font-medium",children:t.title}),t.content&&e("div",{class:M("text-xs text-muted-foreground mt-1",n?"":"line-clamp-2"),children:t.content})]})}const Fn=[{label:"All",pattern:""},{label:"Eval",pattern:"eval:*"},{label:"Session",pattern:"session:*"},{label:"Journal",pattern:"journal:*"},{label:"Peter",pattern:"peter:*"},{label:"Flow",pattern:"flow:*"},{label:"Service",pattern:"service:*"},{label:"Hook",pattern:"hook:*"}];function $n(){var m;const[t,r]=P([]),[n,s]=P(""),[o,i]=P(""),l=G(()=>j.events(100,n||void 0),1e4,[n]);Ft("/api/events/stream",Ee(a=>{r(g=>[a,...g].slice(0,50))},[]));const c=[...t,...((m=l.data)==null?void 0:m.events)||[]].filter((a,g,y)=>y.findIndex(v=>v.id===a.id)===g),d=n?c.filter(a=>{if(!n.includes("*"))return a.type===n;const g=n.replace("*","");return a.type.startsWith(g)}):c;return e("div",{class:"space-y-5",children:[e("div",{class:"flex items-center justify-between",children:[e("h1",{class:"text-xl font-semibold",children:"Events"}),e("div",{class:"flex items-center gap-3",children:[t.length>0&&e("span",{class:"text-xs text-success mono animate-pulse-dot",children:"LIVE"}),e("span",{class:"text-sm text-muted-foreground",children:[d.length," events"]})]})]}),e("div",{class:"space-y-2",children:[e("div",{class:"flex flex-wrap gap-1.5",children:Fn.map(a=>e("button",{onClick:()=>{s(a.pattern),i("")},class:M("text-[11px] mono font-medium px-2 py-0.5 rounded-md transition-colors",n===a.pattern?"bg-foreground/10 text-foreground":"bg-muted/50 text-muted-foreground hover:text-foreground"),children:a.label},a.pattern))}),e("div",{class:"relative",children:[e("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:[e("circle",{cx:"11",cy:"11",r:"8"}),e("path",{d:"m21 21-4.3-4.3"})]}),e("input",{type:"text",placeholder:"Custom pattern (e.g. peter:*, eval:scored)",value:o,onInput:a=>{const g=a.target.value;i(g),s(g)},class:"w-full bg-card border border-border rounded-lg pl-9 pr-4 py-1.5 text-xs mono text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-info/50 transition-colors"})]})]}),e("div",{class:"bg-card rounded-lg border border-border",children:l.loading&&d.length===0?e("div",{class:"p-4 text-sm text-muted-foreground animate-pulse-dot",children:"Loading events..."}):e(Zr,{events:d,maxItems:100})})]})}function Tr(t,r){return r.endsWith("*")?t.startsWith(r.slice(0,-1)):t===r}function Rn(t){var n,s;const r=[];for(const o of t)for(const i of t){if(o.name===i.name)continue;const l=((n=o.context_scope)==null?void 0:n.produces)||[],u=((s=i.context_scope)==null?void 0:s.consumes)||[];for(const c of l)for(const d of u)Tr(c,d)&&r.push({from:o.name,to:i.name,pattern:c})}return r}function $t(t){switch(t){case"web":return"bg-info/15 text-info";case"cli":return"bg-success/15 text-success";case"api":return"bg-warning/15 text-warning";case"library":return"bg-purple-500/15 text-purple-400";case"gtm":return"bg-pink-500/15 text-pink-400";default:return"bg-muted text-muted-foreground"}}function Dn({status:t}){var m,a;const r=G(()=>j.services(),1e4),n=(t==null?void 0:t.children)||[],s=(t==null?void 0:t.type)||"standalone",o=((m=t==null?void 0:t.config)==null?void 0:m.registered_services)||[],i=((a=t==null?void 0:t.config)==null?void 0:a.openclaw_agents)||[],l=r.data?Object.values(r.data):[],u=Rn(o),c={};if(s==="portfolio")for(const g of n){const y=g.name.replace("-gtm","");c[g.name]=l.filter(v=>v.name.startsWith(y))}const d=o.length+l.length+i.length;return e("div",{class:"space-y-6",children:[e("div",{class:"flex items-center justify-between",children:[e("h1",{class:"text-xl font-semibold",children:"Services"}),e("span",{class:"text-sm text-muted-foreground",children:[d," total"]})]}),o.length>0&&o.some(g=>g.context_scope)&&e(An,{services:o,flows:u,children:n}),u.length>0&&e("section",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:["Data Flows (",u.length,")"]}),e("div",{class:"bg-card rounded-lg border border-border overflow-hidden",children:u.map((g,y)=>e("div",{class:M("flex items-center gap-3 px-4 py-2 text-sm",y>0&&"border-t border-border/50"),children:[e("span",{class:"mono text-xs font-medium text-info min-w-40",children:g.pattern}),e("span",{class:"text-xs text-muted-foreground",children:g.from}),e("svg",{width:"16",height:"8",viewBox:"0 0 16 8",class:"shrink-0 text-muted-foreground",children:e("path",{d:"M0 4h12M10 1l3 3-3 3",fill:"none",stroke:"currentColor","stroke-width":"1.5"})}),e("span",{class:"text-xs text-muted-foreground",children:g.to})]},y))})]}),o.length>0&&e("section",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:["Registered Services (",o.length,")"]}),e("div",{class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:o.map(g=>e(Pn,{service:g},g.name))})]}),s==="portfolio"&&n.length>0&&n.map(g=>{const y=c[g.name]||[];return y.length===0?null:e("section",{children:[e("div",{class:"flex items-center gap-2 mb-3",children:[e(Se,{status:g.status}),e("h2",{class:"text-sm font-medium",children:g.name}),e("span",{class:"text-xs mono text-muted-foreground",children:[":",g.port]}),e("span",{class:"text-[10px] text-muted-foreground ml-2",children:[y.length," services"]})]}),e("div",{class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:y.map(v=>e(Wt,{service:v},v.name))})]},g.name)}),s!=="portfolio"&&l.length>0&&e("section",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:["Discovered (",l.length,")"]}),e("div",{class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:l.map(g=>e(Wt,{service:g},g.name))})]}),i.length>0&&e("section",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:["Openclaw Agents (",i.length,")"]}),e("div",{class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:i.map(g=>e(In,{agent:g},g.id))})]}),d===0&&e("div",{class:"bg-card rounded-lg border border-border p-8 text-center",children:[e("div",{class:"text-muted-foreground text-sm",children:"No services registered"}),e("div",{class:"text-muted-foreground text-xs mt-1 mono",children:"jfl services register <path>"})]})]})}function An({services:t,flows:r,children:n}){return e("section",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:"Context Scope"}),e("div",{class:"grid grid-cols-1 md:grid-cols-2 gap-4",children:t.filter(s=>s.context_scope).map(s=>{var d,m;const o=n.find(a=>a.name===s.name),i=((d=s.context_scope)==null?void 0:d.produces)||[],l=((m=s.context_scope)==null?void 0:m.consumes)||[],u=r.filter(a=>a.from===s.name),c=r.filter(a=>a.to===s.name);return e("div",{class:"bg-card rounded-lg border border-border p-4 animate-fade-in",children:[e("div",{class:"flex items-center justify-between mb-3",children:[e("div",{class:"flex items-center gap-2",children:[e(Se,{status:(o==null?void 0:o.status)==="ok"?"ok":"idle"}),e("span",{class:"font-medium text-sm",children:s.name})]}),e("div",{class:"flex items-center gap-1.5",children:[s.type&&e("span",{class:M("text-[10px] mono px-1.5 py-0.5 rounded uppercase",$t(s.type)),children:s.type}),o&&e("span",{class:"text-[10px] mono text-muted-foreground",children:[":",o.port]})]})]}),i.length>0&&e("div",{class:"mb-2",children:[e("div",{class:"text-[10px] text-muted-foreground uppercase tracking-wider mb-1",children:"Produces"}),e("div",{class:"flex flex-wrap gap-1",children:i.map(a=>{const g=u.some(y=>y.pattern===a);return e("span",{class:M("text-[10px] mono px-1.5 py-0.5 rounded",g?"bg-success/15 text-success":"bg-success/5 text-success/60"),children:a},a)})})]}),l.length>0&&e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase tracking-wider mb-1",children:"Consumes"}),e("div",{class:"flex flex-wrap gap-1",children:l.map(a=>{const g=c.some(y=>Tr(y.pattern,a));return e("span",{class:M("text-[10px] mono px-1.5 py-0.5 rounded",g?"bg-info/15 text-info":"bg-info/5 text-info/60"),children:a},a)})})]}),(u.length>0||c.length>0)&&e("div",{class:"mt-3 pt-2 border-t border-border",children:e("div",{class:"flex items-center gap-3 text-[10px] text-muted-foreground",children:[u.length>0&&e("span",{children:[u.length," outgoing"]}),c.length>0&&e("span",{children:[c.length," incoming"]})]})})]},s.name)})})]})}function Pn({service:t}){const r=t.path?t.path.replace(/^\/Users\/[^/]+\//,"~/").replace(/^\/home\/[^/]+\//,"~/"):null;return e("div",{class:"bg-card rounded-lg border border-border p-4 animate-fade-in",children:[e("div",{class:"flex items-center justify-between mb-1",children:[e("div",{class:"flex items-center gap-2",children:[e(Se,{status:t.status==="active"?"ok":"idle"}),e("span",{class:"font-medium text-sm",children:t.name})]}),t.type&&e("span",{class:M("text-[10px] mono px-1.5 py-0.5 rounded uppercase",$t(t.type)),children:t.type})]}),r&&e("div",{class:"text-[10px] mono text-muted-foreground mt-1 truncate",children:r}),t.context_scope&&e("div",{class:"mt-2 space-y-1",children:[t.context_scope.produces&&t.context_scope.produces.length>0&&e("div",{class:"flex flex-wrap gap-1",children:[e("span",{class:"text-[10px] text-muted-foreground mr-1",children:"produces:"}),t.context_scope.produces.map(n=>e("span",{class:"text-[10px] bg-success/10 text-success px-1.5 py-0.5 rounded mono",children:n},n))]}),t.context_scope.consumes&&t.context_scope.consumes.length>0&&e("div",{class:"flex flex-wrap gap-1",children:[e("span",{class:"text-[10px] text-muted-foreground mr-1",children:"consumes:"}),t.context_scope.consumes.map(n=>e("span",{class:"text-[10px] bg-info/10 text-info px-1.5 py-0.5 rounded mono",children:n},n))]})]})]})}function Wt({service:t}){return e("div",{class:"bg-card rounded-lg border border-border p-4 animate-fade-in",children:[e("div",{class:"flex items-center justify-between mb-1",children:[e("div",{class:"flex items-center gap-2",children:[e(Se,{status:t.status==="active"?"ok":"idle"}),e("span",{class:"font-medium text-sm",children:t.name})]}),t.type&&e("span",{class:M("text-[10px] mono px-1.5 py-0.5 rounded uppercase",$t(t.type)),children:t.type})]}),t.description&&e("p",{class:"text-xs text-muted-foreground mt-1",children:t.description})]})}function In({agent:t}){const r=t.registered_at?new Date(t.registered_at).toLocaleDateString():null;return e("div",{class:"bg-card rounded-lg border border-border p-4 animate-fade-in",children:[e("div",{class:"flex items-center justify-between mb-1",children:[e("div",{class:"flex items-center gap-2",children:[e("span",{class:"w-[6px] h-[6px] rounded-full bg-purple-400 shrink-0"}),e("span",{class:"font-medium text-sm",children:t.id})]}),e("span",{class:"text-[10px] mono bg-purple-500/15 text-purple-400 px-1.5 py-0.5 rounded uppercase",children:t.runtime})]}),r&&e("div",{class:"text-[10px] text-muted-foreground mt-1",children:["Registered ",r]})]})}function Yt(t){return t.gated?"pending_approval":t.error||t.actions_failed&&t.actions_failed>0?"failed":t.completed_at?"completed":"running"}function jn(){const t=G(()=>j.flows(),1e4),r=G(()=>j.flowExecutions(),1e4),n=t.data||[],s=r.data,o=Array.isArray(s)?s:(s==null?void 0:s.executions)||[],i=o.filter(l=>Yt(l)==="pending_approval");return e("div",{class:"space-y-6",children:[e("div",{class:"flex items-center justify-between",children:[e("h1",{class:"text-xl font-semibold",children:"Flows"}),e("span",{class:"text-sm text-muted-foreground",children:[n.length," defined"]})]}),i.length>0&&e("section",{children:[e("h2",{class:"text-sm font-medium text-warning uppercase tracking-wider mb-3",children:["Pending Approval (",i.length,")"]}),e("div",{class:"space-y-2",children:i.map((l,u)=>e(On,{exec:l},u))})]}),t.loading?e("div",{class:"text-sm text-muted-foreground animate-pulse-dot",children:"Loading flows..."}):n.length===0?e("div",{class:"bg-card rounded-lg border border-border p-8 text-center",children:[e("div",{class:"text-muted-foreground text-sm",children:"No flows configured"}),e("div",{class:"text-muted-foreground text-xs mt-1 mono",children:"jfl flows add"})]}):e("section",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:"Flow Definitions"}),e("div",{class:"grid grid-cols-1 md:grid-cols-2 gap-3",children:n.map(l=>e(Ln,{flow:l,execCount:o.filter(u=>u.flow===l.name).length},l.name))})]}),o.length>0&&e("section",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:["Execution History (",o.length,")"]}),e("div",{class:"bg-card rounded-lg border border-border overflow-hidden",children:e("table",{class:"w-full text-sm",children:[e("thead",{children:e("tr",{class:"border-b border-border text-xs text-muted-foreground",children:[e("th",{class:"text-left py-2 px-3 font-medium",children:"Flow"}),e("th",{class:"text-left py-2 px-3 font-medium",children:"Status"}),e("th",{class:"text-left py-2 px-3 font-medium hidden md:table-cell",children:"Trigger"}),e("th",{class:"text-right py-2 px-3 font-medium",children:"When"})]})}),e("tbody",{children:o.slice(0,25).map((l,u)=>{const c=Yt(l),d=c==="completed"?"text-success":c==="running"?"text-info animate-pulse-dot":c==="failed"?"text-destructive":c==="pending_approval"?"text-warning":"text-muted-foreground";return e("tr",{class:"border-b border-border/50 hover:bg-muted/20 transition-colors",children:[e("td",{class:"py-2 px-3 font-medium",children:l.flow}),e("td",{class:`py-2 px-3 mono text-xs ${d}`,children:c}),e("td",{class:"py-2 px-3 mono text-xs text-muted-foreground hidden md:table-cell truncate max-w-48",children:l.trigger_event_type||l.trigger_event_id}),e("td",{class:"py-2 px-3 mono text-xs text-muted-foreground text-right",children:te(l.started_at)})]},u)})})]})})]})]})}function Ln({flow:t,execCount:r}){var l,u,c;const n=typeof t.trigger=="string"?t.trigger:((l=t.trigger)==null?void 0:l.pattern)||"unknown",s=typeof t.trigger=="object"?(u=t.trigger)==null?void 0:u.source:void 0,o=t.enabled!==!1,i=(c=t.gate)==null?void 0:c.requires_approval;return e("div",{class:M("bg-card rounded-lg border border-border p-4 animate-fade-in",!o&&"opacity-50"),children:[e("div",{class:"flex items-center justify-between mb-2",children:[e("div",{class:"flex items-center gap-2",children:[e("span",{class:M("w-[6px] h-[6px] rounded-full",o?"bg-success":"bg-muted-foreground/50")}),e("span",{class:"font-medium text-sm",children:t.name})]}),e("div",{class:"flex items-center gap-1.5",children:[i&&e("span",{class:"text-[10px] mono px-1.5 py-0.5 rounded bg-warning/10 text-warning uppercase",children:"gated"}),e("button",{onClick:async d=>{d.stopPropagation();try{await j.toggleFlow(t.name,!o)}catch(m){console.error("Failed to toggle:",m)}},class:M("text-[10px] mono px-1.5 py-0.5 rounded uppercase cursor-pointer transition-colors",o?"bg-success/10 text-success hover:bg-success/20":"bg-muted text-muted-foreground hover:bg-muted/80"),children:o?"on":"off"})]})]}),e("div",{class:"flex items-center gap-2 mb-1",children:[e("span",{class:"text-xs mono text-info",children:n}),s&&e("span",{class:"text-[10px] mono text-muted-foreground",children:["from ",s]})]}),t.description&&e("div",{class:"text-xs text-muted-foreground mb-2",children:t.description}),e("div",{class:"flex items-center justify-between pt-2 border-t border-border",children:[e("div",{class:"flex flex-wrap gap-1",children:t.actions.map((d,m)=>e("span",{class:"text-[10px] mono bg-muted px-1.5 py-0.5 rounded",children:d.type},m))}),r>0&&e("span",{class:"text-[10px] text-muted-foreground",children:[r," runs"]})]})]})}function On({exec:t}){const r=async()=>{try{await j.approveFlow(t.flow,t.trigger_event_id)}catch(n){console.error("Failed to approve:",n)}};return e("div",{class:"bg-card rounded-lg border border-warning/30 p-4 animate-fade-in",children:e("div",{class:"flex items-center justify-between",children:[e("div",{children:[e("div",{class:"flex items-center gap-2 mb-1",children:[e("span",{class:"w-[6px] h-[6px] rounded-full bg-warning animate-pulse"}),e("span",{class:"font-medium text-sm",children:t.flow}),e("span",{class:"text-[10px] mono text-warning uppercase",children:"needs approval"})]}),e("div",{class:"text-xs mono text-muted-foreground",children:[t.trigger_event_type||t.trigger_event_id," — ",te(t.started_at)]})]}),e("button",{onClick:r,class:"px-3 py-1.5 text-xs font-medium rounded bg-success/15 text-success hover:bg-success/25 transition-colors",children:"Approve"})]})})}function Bn({status:t}){var u,c;const r=G(()=>j.projects(),15e3),n=G(()=>j.memoryStatus(),3e4),s=(t==null?void 0:t.sources)||{},o=Object.values(s).filter(Boolean).length,i=Object.keys(s).length,l=n.data;return e("div",{class:"space-y-6",children:[e("h1",{class:"text-xl font-semibold",children:"System Health"}),e("div",{class:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e(ae,{label:"Hub",value:(t==null?void 0:t.status)==="running"||(t==null?void 0:t.status)==="ok"?"OK":(t==null?void 0:t.status)||"--",sub:`port :${(t==null?void 0:t.port)||"--"}`,trend:(t==null?void 0:t.status)==="running"||(t==null?void 0:t.status)==="ok"?"up":"down"}),e(ae,{label:"Sources",value:`${o}/${i}`,sub:"connected",trend:o===i?"up":"down"}),e(ae,{label:"Items",value:(t==null?void 0:t.itemCount)||0,sub:"indexed"}),e(ae,{label:"Memories",value:(l==null?void 0:l.total_memories)||0,sub:(u=l==null?void 0:l.embeddings)!=null&&u.available?"with embeddings":"keyword only"})]}),e("section",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:"Context Sources"}),e("div",{class:"grid grid-cols-2 md:grid-cols-4 gap-3",children:Object.entries(s).map(([d,m])=>e("div",{class:"bg-card rounded-lg border border-border p-3 animate-fade-in",children:[e("div",{class:"flex items-center gap-2",children:[e("span",{class:M("w-[6px] h-[6px] rounded-full",m?"bg-success":"bg-destructive")}),e("span",{class:"text-sm font-medium capitalize",children:d})]}),e("div",{class:"text-[10px] text-muted-foreground mt-1",children:m?"connected":"disconnected"})]},d))})]}),l&&Object.keys(l.by_type||{}).length>0&&e("section",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:"Memory Index"}),e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("div",{class:"grid grid-cols-2 md:grid-cols-4 gap-4",children:Object.entries(l.by_type).map(([d,m])=>e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase",children:d}),e("div",{class:"text-lg font-semibold mono",children:m})]},d))}),e("div",{class:"mt-3 pt-3 border-t border-border flex items-center gap-4 text-xs text-muted-foreground",children:[l.embeddings&&e("span",{children:["Embeddings: ",l.embeddings.count," / ",l.total_memories]}),((c=l.date_range)==null?void 0:c.earliest)&&e("span",{children:["Range: ",new Date(l.date_range.earliest).toLocaleDateString()," - ",new Date(l.date_range.latest).toLocaleDateString()]})]})]})]}),r.data&&r.data.length>0&&e("section",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:["Tracked Projects (",r.data.length,")"]}),e("div",{class:"grid grid-cols-1 md:grid-cols-2 gap-3",children:r.data.map(d=>e("div",{class:"bg-card rounded-lg border border-border p-4 animate-fade-in",children:[e("div",{class:"flex items-center justify-between mb-1",children:[e("div",{class:"flex items-center gap-2",children:[e(Se,{status:d.status==="OK"?"ok":d.status==="error"?"error":"idle"}),e("span",{class:"font-medium text-sm",children:d.name})]}),e("span",{class:"text-xs mono text-muted-foreground",children:[":",d.port]})]}),e("div",{class:"text-xs text-muted-foreground mono truncate",children:d.path}),e("div",{class:"flex items-center gap-3 mt-1.5",children:[d.pid&&e("span",{class:"text-[10px] text-muted-foreground",children:["PID ",d.pid]}),d.port&&d.status==="OK"&&e("a",{href:`http://localhost:${d.port}/dashboard/`,target:"_blank",rel:"noopener",class:"text-[10px] text-info hover:underline",children:"Open Dashboard"})]})]},d.name))})]})]})}function Gn(){const t=G(()=>j.rlAgents().then(m=>m.agents),15e3),r=G(()=>j.rlSessions().then(m=>m.sessions),1e4),n=G(()=>j.productContext(),3e4),s=t.data||[],o=r.data||[],i=n.data||{context:null,updatedAt:null},l={};for(const m of o)l[m.agent]||(l[m.agent]=[]),l[m.agent].push(m);const u=o.reduce((m,a)=>m+a.rounds.length,0),c=o.reduce((m,a)=>m+a.rounds.filter(g=>g.kept).length,0),d=s.filter(m=>(l[m.name]||[]).length>0).length;return e("div",{class:"space-y-6",children:[e("div",{children:[e("h1",{class:"text-xl font-semibold",children:"Autoresearch"}),e("p",{class:"text-sm text-muted-foreground mt-1",children:"Scoped agents optimizing your services. Branches grow overnight, you review in the morning."})]}),e("div",{class:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e(He,{label:"Agents",value:s.length,sub:`${d} active`}),e(He,{label:"Sessions",value:o.length,sub:"completed"}),e(He,{label:"Rounds",value:u,sub:`${c} kept`,accent:c>0}),e(He,{label:"Hit Rate",value:u>0?`${Math.round(c/u*100)}%`:"—",sub:"improvements",accent:c>0})]}),e("div",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:"Agents"}),e("div",{class:"grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-4",children:s.map(m=>e(Nn,{agent:m,sessions:l[m.name]||[]},m.name))})]}),i.context&&e(Un,{context:i.context,updatedAt:i.updatedAt}),o.length>0&&e(Hn,{sessions:o})]})}function He({label:t,value:r,sub:n,accent:s}){return e("div",{class:"card p-4",children:[e("div",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-1",children:t}),e("div",{class:M("text-2xl font-bold tabular-nums",s?"text-green-400":""),children:r}),e("div",{class:"text-xs text-muted-foreground mt-0.5",children:n})]})}function Nn({agent:t,sessions:r}){var d,m,a,g;const n=r.flatMap(y=>y.rounds),s=n.filter(y=>y.kept),o=r[r.length-1],i=o==null?void 0:o.rounds[o.rounds.length-1],l=s.length>0?Math.max(...s.map(y=>Math.abs(y.delta))):0,u=s.length>0,c=(((m=(d=t.context_scope)==null?void 0:d.produces)==null?void 0:m.length)||0)+(((g=(a=t.context_scope)==null?void 0:a.consumes)==null?void 0:g.length)||0);return e("div",{class:M("card p-4 border-l-2",u?"border-l-green-500":"border-l-border"),children:[e("div",{class:"flex items-center justify-between mb-2",children:[e("h3",{class:"text-sm font-semibold",children:t.name}),e("span",{class:M("text-[10px] px-2 py-0.5 rounded font-mono",t.direction==="minimize"?"bg-green-500/10 text-green-400":"bg-purple-500/10 text-purple-400"),children:[t.direction==="minimize"?"↓":"↑"," ",t.metric]})]}),e("div",{class:"text-xs text-muted-foreground mb-3",children:[t.target_repo?`→ ${t.target_repo}`:"self"," · ",c," scope patterns"]}),e("div",{class:"grid grid-cols-3 gap-2 mb-3",children:[e(ut,{label:"rounds",value:n.length}),e(ut,{label:"kept",value:s.length,accent:u}),e(ut,{label:"best Δ",value:l>0?l.toFixed(0):"—",accent:u})]}),n.length>0&&e("div",{class:"flex gap-px h-5 items-end mb-2",children:n.slice(-15).map((y,v)=>e("div",{class:M("flex-1 min-w-1 rounded-sm transition-all",y.kept?"bg-green-500/70 h-full":"bg-red-500/50 h-2/5"),title:`R${y.round}: ${y.delta>0?"+":""}${y.delta.toFixed(1)} ${y.kept?"KEPT":"REVERTED"}`},v))}),i?e("div",{class:"text-[11px] text-muted-foreground border-t border-border pt-2 mt-1 tabular-nums",children:["Last: ",i.metric.toFixed(1)," (",i.delta>0?"+":"",i.delta.toFixed(1),")",e("span",{class:i.kept?"text-green-400":"text-red-400",children:[" ",i.kept?"✓":"✗"]}),i.timestamp&&e("span",{class:"ml-1",children:["· ",te(i.timestamp)]})]}):e("div",{class:"text-xs text-muted-foreground italic",children:"No experiments yet"})]})}function ut({label:t,value:r,accent:n}){return e("div",{class:"text-center",children:[e("div",{class:M("text-lg font-bold tabular-nums",n?"text-green-400":"text-foreground"),children:r}),e("div",{class:"text-[10px] text-muted-foreground",children:t})]})}function Un({context:t,updatedAt:r}){const n=t.replace(/^# Product Context\n\n_Synthesized.*?\n\n/,""),s=n.split(/^## /m).filter(Boolean).map(o=>{const i=o.split(`
|
|
3
|
+
`),l=i[0].trim(),u=i.slice(1).join(`
|
|
4
|
+
`).trim();return{title:l,body:u}});return e("div",{class:"card p-4",children:[e("div",{class:"flex items-center justify-between mb-3",children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:"Product Context"}),r&&e("span",{class:"text-[11px] text-muted-foreground",children:te(r)})]}),s.length>0?e("div",{class:"space-y-3",children:s.map((o,i)=>e("div",{children:[e("h3",{class:"text-xs font-semibold text-foreground mb-1",children:o.title}),e("div",{class:"text-xs text-muted-foreground leading-relaxed whitespace-pre-line",children:o.body.split(`
|
|
5
|
+
`).map((l,u)=>{const c=l.replace(/\*\*(.*?)\*\*/g,"$1");return l.startsWith("- ")?e("div",{class:"ml-2",children:["· ",c.replace(/^- /,"")]},u):c?e("div",{children:c},u):null})})]},i))}):e("div",{class:"text-xs text-muted-foreground whitespace-pre-line leading-relaxed",children:n})]})}function Hn({sessions:t}){return e("div",{class:"card p-4",children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:"Recent Sessions"}),e("div",{class:"overflow-x-auto",children:e("table",{class:"w-full text-xs",children:[e("thead",{children:e("tr",{class:"border-b border-border text-muted-foreground",children:[e("th",{class:"text-left py-2 px-2 font-medium",children:"Agent"}),e("th",{class:"text-center py-2 px-2 font-medium",children:"Rounds"}),e("th",{class:"text-center py-2 px-2 font-medium",children:"Kept"}),e("th",{class:"text-right py-2 px-2 font-medium",children:"Best Δ"}),e("th",{class:"text-left py-2 px-2 font-medium",children:"Results"})]})}),e("tbody",{children:t.slice(-10).reverse().map(r=>{const n=r.rounds.filter(o=>o.kept),s=n.length>0?Math.max(...n.map(o=>Math.abs(o.delta))):0;return e("tr",{class:"border-b border-border/50 hover:bg-muted/20",children:[e("td",{class:"py-2 px-2 font-medium",children:r.agent}),e("td",{class:"py-2 px-2 text-center text-muted-foreground tabular-nums",children:r.rounds.length}),e("td",{class:M("py-2 px-2 text-center tabular-nums",n.length>0?"text-green-400":"text-muted-foreground"),children:n.length}),e("td",{class:M("py-2 px-2 text-right tabular-nums",s>0?"text-green-400":"text-muted-foreground"),children:s>0?s.toFixed(1):"—"}),e("td",{class:"py-2 px-2",children:e("div",{class:"flex gap-1",children:r.rounds.map((o,i)=>e("span",{class:M("inline-block w-2 h-2 rounded-full",o.kept?"bg-green-500":"bg-red-500"),title:`R${o.round}: ${o.delta>0?"+":""}${o.delta.toFixed(1)}`},i))})})]},r.id)})})]})})]})}function zn(){const[t,r]=P(168),n=G(()=>j.telemetryDigest(t),3e4,[t]),s=G(()=>j.telemetryAgentStatus(),15e3),[o,i]=P(null),l=n.data,u=s.data,c=async()=>{var d;i("running...");try{const m=await j.telemetryAgentRun();i(`${((d=m.insights)==null?void 0:d.length)||0} insights`),setTimeout(()=>i(null),3e3)}catch{i("error"),setTimeout(()=>i(null),3e3)}};return e("div",{class:"space-y-6",children:[e("div",{class:"flex items-center justify-between",children:[e("div",{children:[e("h1",{class:"text-xl font-semibold",children:"Telemetry"}),e("p",{class:"text-sm text-muted-foreground mt-0.5",children:"Cost analysis, command usage, and system health"})]}),e("div",{class:"flex items-center gap-2",children:[24,72,168].map(d=>e("button",{onClick:()=>r(d),class:M("text-[10px] mono px-2 py-1 rounded transition-colors",t===d?"bg-info/15 text-info":"bg-muted text-muted-foreground hover:text-foreground"),children:d===24?"24h":d===72?"3d":"7d"},d))})]}),u&&e("div",{class:"bg-card rounded-lg border border-border p-3 flex items-center gap-4",children:[e("div",{class:"flex items-center gap-2",children:[e("span",{class:M("w-2 h-2 rounded-full",u.running?"bg-success animate-pulse-dot":"bg-muted-foreground/50")}),e("span",{class:"text-xs font-medium",children:"Telemetry Agent"})]}),e("div",{class:"flex items-center gap-4 text-[10px] text-muted-foreground mono",children:[e("span",{children:u.running?"active":"stopped"}),u.lastRun&&e("span",{children:["last: ",te(u.lastRun)]}),e("span",{children:["runs: ",u.runCount]}),e("span",{children:["patterns: ",u.lastInsights.length]})]}),e("button",{onClick:c,class:M("ml-auto text-[10px] mono px-2 py-1 rounded transition-colors",o?o==="error"?"bg-destructive/15 text-destructive":"bg-success/15 text-success":"bg-muted text-muted-foreground hover:text-foreground hover:bg-muted/80"),children:o||"run now"})]}),l?e(le,{children:[e("div",{class:"grid grid-cols-5 gap-4",children:[e(Pe,{label:"Events",value:l.totalEvents}),e(Pe,{label:"Cost",value:`$${l.totalCostUsd.toFixed(2)}`}),e(Pe,{label:"Sessions",value:l.sessions.started,sub:l.sessions.crashed>0?`${l.sessions.crashed} crashed`:"healthy",subColor:l.sessions.crashed>0?"text-destructive":"text-success"}),e(Pe,{label:"Flows",value:l.flows.triggered,sub:`${l.flows.completed} ok / ${l.flows.failed} fail`}),e(Pe,{label:"Errors",value:l.errors.total,subColor:l.errors.total>0?"text-destructive":"text-success",sub:l.errors.total===0?"clean":void 0})]}),e("div",{class:"grid grid-cols-2 gap-4",children:[e("div",{class:"bg-card rounded-lg border border-border p-4 animate-fade-in",children:[e("div",{class:"text-[10px] text-muted-foreground uppercase tracking-wider mb-3",children:"Hub Health"}),e("div",{class:"grid grid-cols-2 gap-3 text-xs",children:[e("div",{children:[e("span",{class:"text-muted-foreground",children:"Starts:"})," ",e("span",{class:"mono",children:l.hubHealth.starts})]}),e("div",{children:[e("span",{class:"text-muted-foreground",children:"Crashes:"})," ",e("span",{class:M("mono",l.hubHealth.crashes>0?"text-destructive":""),children:l.hubHealth.crashes})]}),e("div",{children:[e("span",{class:"text-muted-foreground",children:"MCP Calls:"})," ",e("span",{class:"mono",children:l.hubHealth.mcpCalls})]}),e("div",{children:[e("span",{class:"text-muted-foreground",children:"Avg Latency:"})," ",e("span",{class:"mono",children:[l.hubHealth.avgMcpLatencyMs.toFixed(0),"ms"]})]})]})]}),e("div",{class:"bg-card rounded-lg border border-border p-4 animate-fade-in",children:[e("div",{class:"text-[10px] text-muted-foreground uppercase tracking-wider mb-3",children:"Memory Health"}),e("div",{class:"grid grid-cols-2 gap-3 text-xs",children:[e("div",{children:[e("span",{class:"text-muted-foreground",children:"Index Runs:"})," ",e("span",{class:"mono",children:l.memoryHealth.indexRuns})]}),e("div",{children:[e("span",{class:"text-muted-foreground",children:"Indexed:"})," ",e("span",{class:"mono",children:l.memoryHealth.entriesIndexed})]}),e("div",{children:[e("span",{class:"text-muted-foreground",children:"Errors:"})," ",e("span",{class:M("mono",l.memoryHealth.errors>0?"text-destructive":""),children:l.memoryHealth.errors})]}),e("div",{children:[e("span",{class:"text-muted-foreground",children:"Avg Duration:"})," ",e("span",{class:"mono",children:[l.memoryHealth.avgDurationMs.toFixed(0),"ms"]})]})]})]})]}),e(Xn,{costs:l.costs,totalCost:l.totalCostUsd}),e(Wn,{commands:l.commands}),e(Yn,{flows:l.flows}),e(Vn,{hooks:l.hooks}),e(qn,{errors:l.errors}),e(Jn,{suggestions:l.suggestions})]}):e("div",{class:"bg-card rounded-lg border border-border p-8 text-center",children:e("div",{class:"text-muted-foreground text-sm",children:n.loading?"Loading telemetry...":"No telemetry data available"})})]})}function Pe({label:t,value:r,sub:n,subColor:s}){return e("div",{class:"bg-card rounded-lg border border-border p-4 animate-fade-in",children:[e("div",{class:"text-[10px] text-muted-foreground uppercase tracking-wider",children:t}),e("div",{class:"text-2xl font-bold mono mt-1",children:r}),n&&e("div",{class:M("text-[10px] mono mt-0.5",s||"text-muted-foreground"),children:n})]})}function Xn({costs:t,totalCost:r}){if(!t||t.length===0)return e("div",{class:"bg-card rounded-lg border border-border/50 p-6 text-center animate-fade-in",children:[e("div",{class:"text-muted-foreground text-xs",children:"No model cost data yet"}),e("div",{class:"text-[10px] text-muted-foreground/60 mt-1 mono",children:"Costs tracked automatically on LLM calls"})]});const n=[...t].sort((s,o)=>o.estimatedCostUsd-s.estimatedCostUsd);return e("div",{class:"bg-card rounded-lg border border-border overflow-hidden animate-fade-in",children:[e("div",{class:"px-3 py-2 border-b border-border flex items-center justify-between bg-muted/30",children:[e("span",{class:"text-xs font-medium uppercase tracking-wider",children:"Model Costs"}),e("span",{class:"text-xs mono text-warning",children:["$",r.toFixed(4)," total"]})]}),e("table",{class:"w-full text-xs",children:[e("thead",{children:e("tr",{class:"text-muted-foreground border-b border-border",children:[e("th",{class:"text-left py-2 px-3 font-medium",children:"Model"}),e("th",{class:"text-right py-2 px-3 font-medium",children:"Calls"}),e("th",{class:"text-right py-2 px-3 font-medium",children:"Tokens"}),e("th",{class:"text-right py-2 px-3 font-medium",children:"Cost"}),e("th",{class:"text-left py-2 px-3 font-medium w-48",children:"Share"})]})}),e("tbody",{children:n.map(s=>{const o=r>0?s.estimatedCostUsd/r*100:0;return e("tr",{class:"border-b border-border/50 hover:bg-muted/20 transition-colors",children:[e("td",{class:"py-1.5 px-3 mono",children:s.model}),e("td",{class:"py-1.5 px-3 mono text-right",children:s.calls}),e("td",{class:"py-1.5 px-3 mono text-right text-muted-foreground",children:s.totalTokens.toLocaleString()}),e("td",{class:"py-1.5 px-3 mono text-right text-warning",children:["$",s.estimatedCostUsd.toFixed(4)]}),e("td",{class:"py-1.5 px-3",children:e("div",{class:"h-1.5 bg-muted rounded-full overflow-hidden",children:e("div",{class:"h-full bg-info rounded-full transition-all",style:{width:`${Math.max(o,2)}%`}})})})]},s.model)})})]})]})}function Wn({commands:t}){if(!t||t.length===0)return e("div",{class:"bg-card rounded-lg border border-border/50 p-6 text-center animate-fade-in",children:e("div",{class:"text-muted-foreground text-xs",children:"No command usage data yet"})});const r=[...t].sort((n,s)=>s.count-n.count);return e("div",{class:"bg-card rounded-lg border border-border overflow-hidden animate-fade-in",children:[e("div",{class:"px-3 py-2 border-b border-border bg-muted/30",children:[e("span",{class:"text-xs font-medium uppercase tracking-wider",children:"Command Usage"}),e("span",{class:"text-[10px] text-muted-foreground ml-2",children:[r.length," commands"]})]}),e("table",{class:"w-full text-xs",children:[e("thead",{children:e("tr",{class:"text-muted-foreground border-b border-border",children:[e("th",{class:"text-left py-2 px-3 font-medium",children:"Command"}),e("th",{class:"text-right py-2 px-3 font-medium",children:"Count"}),e("th",{class:"text-right py-2 px-3 font-medium",children:"Avg Duration"}),e("th",{class:"text-right py-2 px-3 font-medium",children:"Success Rate"})]})}),e("tbody",{children:r.map(n=>e("tr",{class:"border-b border-border/50 hover:bg-muted/20 transition-colors",children:[e("td",{class:"py-1.5 px-3 mono",children:n.command}),e("td",{class:"py-1.5 px-3 mono text-right",children:n.count}),e("td",{class:"py-1.5 px-3 mono text-right text-muted-foreground",children:n.avgDurationMs>1e3?`${(n.avgDurationMs/1e3).toFixed(1)}s`:`${Math.round(n.avgDurationMs)}ms`}),e("td",{class:"py-1.5 px-3 mono text-right",children:e("span",{class:M(n.successRate>=.9?"text-success":n.successRate>=.7?"text-warning":"text-destructive"),children:[(n.successRate*100).toFixed(0),"%"]})})]},n.command))})]})]})}function Yn({flows:t}){const r=(t==null?void 0:t.byFlow)||{},n=Object.entries(r);return n.length===0&&t.triggered===0?null:e("div",{class:"bg-card rounded-lg border border-border overflow-hidden animate-fade-in",children:[e("div",{class:"px-3 py-2 border-b border-border flex items-center justify-between bg-muted/30",children:[e("span",{class:"text-xs font-medium uppercase tracking-wider",children:"Flow Activity"}),e("span",{class:"text-[10px] mono text-muted-foreground",children:[t.triggered," triggered / ",t.completed," completed / ",t.failed," failed"]})]}),n.length>0&&e("table",{class:"w-full text-xs",children:[e("thead",{children:e("tr",{class:"text-muted-foreground border-b border-border",children:[e("th",{class:"text-left py-2 px-3 font-medium",children:"Flow"}),e("th",{class:"text-right py-2 px-3 font-medium",children:"Triggered"}),e("th",{class:"text-right py-2 px-3 font-medium",children:"Completed"}),e("th",{class:"text-right py-2 px-3 font-medium",children:"Failed"})]})}),e("tbody",{children:n.sort(([,s],[,o])=>o.triggered-s.triggered).map(([s,o])=>e("tr",{class:"border-b border-border/50 hover:bg-muted/20 transition-colors",children:[e("td",{class:"py-1.5 px-3 mono",children:s}),e("td",{class:"py-1.5 px-3 mono text-right",children:o.triggered}),e("td",{class:"py-1.5 px-3 mono text-right text-success",children:o.completed}),e("td",{class:"py-1.5 px-3 mono text-right text-destructive",children:o.failed})]},s))})]})]})}function Vn({hooks:t}){if(t.received===0)return null;const r=Object.entries(t.byTool||{}).sort(([,s],[,o])=>o-s),n=Object.entries(t.byEvent||{}).sort(([,s],[,o])=>o-s);return e("div",{class:"bg-card rounded-lg border border-border overflow-hidden animate-fade-in",children:[e("div",{class:"px-3 py-2 border-b border-border bg-muted/30",children:[e("span",{class:"text-xs font-medium uppercase tracking-wider",children:"Hooks"}),e("span",{class:"text-[10px] text-muted-foreground ml-2",children:[t.received," received"]})]}),e("div",{class:"p-3 grid grid-cols-2 gap-4",children:[r.length>0&&e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase mb-2",children:"By Tool"}),r.slice(0,10).map(([s,o])=>e("div",{class:"flex items-center justify-between py-0.5 text-xs",children:[e("span",{class:"mono truncate",children:s}),e("span",{class:"mono text-muted-foreground tabular-nums",children:o})]},s))]}),n.length>0&&e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase mb-2",children:"By Event"}),n.slice(0,10).map(([s,o])=>e("div",{class:"flex items-center justify-between py-0.5 text-xs",children:[e("span",{class:"mono truncate",children:s}),e("span",{class:"mono text-muted-foreground tabular-nums",children:o})]},s))]})]}),t.fileHotspots&&t.fileHotspots.length>0&&e("div",{class:"px-3 pb-3 border-t border-border/30 pt-2",children:[e("div",{class:"text-[10px] text-muted-foreground uppercase mb-1.5",children:"File Hotspots"}),t.fileHotspots.slice(0,5).map((s,o)=>e("div",{class:"text-[10px] mono text-muted-foreground truncate py-0.5",children:s},o))]})]})}function qn({errors:t}){const r=Object.entries(t.byType||{});return t.total===0&&r.length===0?null:e("div",{class:"bg-card rounded-lg border border-border overflow-hidden animate-fade-in",children:[e("div",{class:"px-3 py-2 border-b border-border bg-muted/30",children:[e("span",{class:"text-xs font-medium uppercase tracking-wider",children:"Errors"}),e("span",{class:"text-[10px] text-destructive ml-2",children:[t.total," total"]})]}),e("div",{class:"p-3 space-y-1.5",children:r.sort(([,n],[,s])=>s-n).map(([n,s])=>e("div",{class:"flex items-center gap-3 text-xs",children:[e("span",{class:"mono text-destructive flex-1 truncate",children:n}),e("span",{class:"mono tabular-nums",children:[s,"x"]})]},n))})]})}function Jn({suggestions:t}){if(!t||t.length===0)return null;const r={high:"text-destructive border-destructive/30 bg-destructive/5",medium:"text-warning border-warning/30 bg-warning/5",low:"text-info border-info/30 bg-info/5"};return e("div",{class:"bg-card rounded-lg border border-border overflow-hidden animate-fade-in",children:[e("div",{class:"px-3 py-2 border-b border-border bg-muted/30",children:e("span",{class:"text-xs font-medium uppercase tracking-wider",children:"Suggestions"})}),e("div",{class:"p-3 space-y-2",children:t.map((n,s)=>e("div",{class:M("rounded-md border p-3",r[n.severity]||r.low),children:[e("div",{class:"flex items-center gap-2",children:[e("span",{class:"text-[10px] mono uppercase font-medium",children:n.severity}),e("span",{class:"text-xs",children:n.message})]}),n.fix&&e("div",{class:"text-[10px] mono mt-1 opacity-75",children:n.fix})]},s))})]})}const F={bg:"#191919",info:"#4a7dfc",infoGlow:"#4a7dfcaa",success:"#34d399",successGlow:"#34d39988",warning:"#eab308",warningGlow:"#eab30888",purple:"#a855f7",purpleGlow:"#a855f788",cyan:"#06b6d4",text:"#f5f5f5",textMuted:"#8b8b8b",textDim:"#5a5a5a",grid:"#2a2a2a"};function tt(t){switch(t){case"gtm":return{fill:F.cyan,glow:F.cyan+"88"};case"orchestrator":return{fill:F.purple,glow:F.purpleGlow};case"eval":return{fill:F.warning,glow:F.warningGlow};case"service":return{fill:F.success,glow:F.successGlow};default:return{fill:F.info,glow:F.infoGlow}}}function Kn(t,r=18){return t.length<=r?t:t.slice(0,r-1)+"…"}const me=new Set(["peter-parker","telemetry-agent","eval-engine","stratus"]),Er=36,Fr=32;function Ie(t){switch(t){case"running":return F.success;case"idle":return F.warning;default:return F.textDim}}function Vt(){const t=Date.now(),r=[{id:"telemetry-agent",label:"Telemetry Agent",type:"agent",status:"running",eventCount:142,lastAction:"telemetry:insight emitted",lastTs:new Date(t-45e3).toISOString(),reward:[.4,.5,.6,.55,.7,.65,.8]},{id:"peter-parker",label:"Peter Parker",type:"orchestrator",status:"running",eventCount:89,lastAction:"task dispatched to builder",lastTs:new Date(t-12e4).toISOString(),reward:[.3,.4,.5,.55,.6,.7,.75]},{id:"eval-engine",label:"Eval Engine",type:"eval",status:"running",eventCount:234,lastAction:"eval:scored lobsters-prg-0.6.0",lastTs:new Date(t-3e4).toISOString(),reward:[.6,.5,.7,.8,.75,.85,.9]},{id:"stratus",label:"Stratus API",type:"service",status:"running",eventCount:1203,lastAction:"rollout prediction served",lastTs:new Date(t-15e3).toISOString(),reward:[.5,.55,.6,.65,.7,.75,.8]}],n=[{id:"jfl-gtm",label:"JFL",type:"gtm",status:"running",eventCount:456,lastAction:"gtm:deploy",lastTs:new Date(t-6e4).toISOString(),reward:[.5,.6,.7,.65,.75,.8,.85]},{id:"productrank-gtm",label:"ProductRank",type:"gtm",status:"running",eventCount:312,lastAction:"gtm:train",lastTs:new Date(t-9e4).toISOString(),reward:[.4,.5,.55,.6,.7,.75,.8]},{id:"gatcha-gtm",label:"Gatcha",type:"gtm",status:"running",eventCount:198,lastAction:"gtm:eval",lastTs:new Date(t-3e4).toISOString(),reward:[.6,.55,.65,.7,.75,.8,.85]}],s=[{id:"jfl-gtm/context-hub",label:"Context Hub",type:"service",status:"running",eventCount:234,parentGtm:"jfl-gtm",reward:[.5,.6,.55,.7,.65,.75,.8]},{id:"jfl-gtm/memory-server",label:"Memory Server",type:"service",status:"running",eventCount:178,parentGtm:"jfl-gtm",reward:[.4,.5,.55,.6,.65,.7,.75]},{id:"jfl-gtm/journal-sync",label:"Journal Sync",type:"service",status:"running",eventCount:92,parentGtm:"jfl-gtm",reward:[.6,.55,.7,.65,.75,.8,.85]},{id:"jfl-gtm/skill-runner",label:"Skill Runner",type:"agent",status:"running",eventCount:156,parentGtm:"jfl-gtm",reward:[.45,.55,.6,.65,.7,.75,.8]},{id:"productrank-gtm/arena",label:"Arena",type:"eval",status:"running",eventCount:567,parentGtm:"productrank-gtm",reward:[.7,.65,.75,.8,.85,.9,.88]},{id:"productrank-gtm/ranker",label:"Ranker",type:"service",status:"running",eventCount:445,parentGtm:"productrank-gtm",reward:[.55,.6,.65,.7,.75,.8,.85]},{id:"productrank-gtm/scraper",label:"Scraper",type:"agent",status:"running",eventCount:289,parentGtm:"productrank-gtm",reward:[.5,.55,.6,.65,.7,.72,.75]},{id:"gatcha-gtm/game-engine",label:"Game Engine",type:"service",status:"running",eventCount:678,parentGtm:"gatcha-gtm",reward:[.6,.65,.7,.75,.8,.85,.88]},{id:"gatcha-gtm/nft-minter",label:"NFT Minter",type:"service",status:"running",eventCount:123,parentGtm:"gatcha-gtm",reward:[.5,.55,.6,.65,.68,.7,.75]},{id:"gatcha-gtm/matchmaker",label:"Matchmaker",type:"agent",status:"running",eventCount:234,parentGtm:"gatcha-gtm",reward:[.55,.6,.65,.7,.75,.78,.8]}],o=[];for(const l of r){const u=tt(l.type),c=l.type==="orchestrator"?32:l.type==="service"?28:24;o.push({...l,x:0,y:0,targetX:0,targetY:0,radius:c,baseRadius:c,color:u.fill,glowColor:u.glow,pulsePhase:Math.random()*Math.PI*2})}for(const l of n){const u=tt(l.type);o.push({...l,x:0,y:0,targetX:0,targetY:0,radius:Er,baseRadius:Fr,color:u.fill,glowColor:u.glow,pulsePhase:Math.random()*Math.PI*2,isGtm:!0,childCount:0,aggregateReward:l.reward})}for(const l of s){const u=tt(l.type),c=l.type==="eval"?24:l.type==="agent"?22:20;o.push({id:l.id,label:l.label,type:l.type,status:l.status,eventCount:l.eventCount,lastAction:`${l.type} activity`,lastTs:new Date(t-Math.random()*3e5).toISOString(),reward:l.reward,x:0,y:0,targetX:0,targetY:0,radius:c,baseRadius:c,color:u.fill,glowColor:u.glow,pulsePhase:Math.random()*Math.PI*2,parentGtm:l.parentGtm})}const i=[{id:"e1",source:"telemetry-agent",target:"peter-parker",eventType:"telemetry:insight",active:!0,lastFired:t-45e3,color:F.info,category:"data",particles:[]},{id:"e2",source:"peter-parker",target:"eval-engine",eventType:"peter:task-completed",active:!0,lastFired:t-12e4,color:F.purple,category:"rl",particles:[]},{id:"e3",source:"eval-engine",target:"telemetry-agent",eventType:"eval:scored",active:!0,lastFired:t-3e4,color:F.warning,category:"success",particles:[]},{id:"e4",source:"peter-parker",target:"stratus",eventType:"peter:rollout-request",active:!0,lastFired:t-15e3,color:F.purple,category:"rl",particles:[]},{id:"e5",source:"stratus",target:"eval-engine",eventType:"stratus:prediction",active:!0,lastFired:t-2e4,color:F.success,category:"success",particles:[]},{id:"e6",source:"jfl-gtm",target:"peter-parker",eventType:"gtm:request",active:!0,lastFired:t-35e3,color:F.info,category:"data",particles:[]},{id:"e7",source:"productrank-gtm",target:"eval-engine",eventType:"gtm:eval",active:!0,lastFired:t-55e3,color:F.warning,category:"success",particles:[]},{id:"e8",source:"gatcha-gtm",target:"stratus",eventType:"gtm:predict",active:!0,lastFired:t-25e3,color:F.success,category:"success",particles:[]},{id:"e9",source:"telemetry-agent",target:"jfl-gtm",eventType:"telemetry:metrics",active:!0,lastFired:t-4e4,color:F.info,category:"data",particles:[]},{id:"e10",source:"telemetry-agent",target:"productrank-gtm",eventType:"telemetry:metrics",active:!0,lastFired:t-5e4,color:F.info,category:"data",particles:[]},{id:"e11",source:"telemetry-agent",target:"gatcha-gtm",eventType:"telemetry:metrics",active:!0,lastFired:t-6e4,color:F.info,category:"data",particles:[]},{id:"e12",source:"jfl-gtm/context-hub",target:"jfl-gtm/memory-server",eventType:"context:sync",active:!0,lastFired:t-1e4,color:F.info,category:"data",particles:[]},{id:"e13",source:"jfl-gtm/memory-server",target:"jfl-gtm/journal-sync",eventType:"memory:write",active:!0,lastFired:t-15e3,color:F.info,category:"data",particles:[]},{id:"e14",source:"jfl-gtm/skill-runner",target:"jfl-gtm/context-hub",eventType:"skill:result",active:!0,lastFired:t-2e4,color:F.purple,category:"rl",particles:[]},{id:"e15",source:"productrank-gtm/arena",target:"productrank-gtm/ranker",eventType:"arena:score",active:!0,lastFired:t-12e3,color:F.warning,category:"success",particles:[]},{id:"e16",source:"productrank-gtm/scraper",target:"productrank-gtm/arena",eventType:"scraper:data",active:!0,lastFired:t-18e3,color:F.info,category:"data",particles:[]},{id:"e17",source:"gatcha-gtm/game-engine",target:"gatcha-gtm/matchmaker",eventType:"game:match",active:!0,lastFired:t-8e3,color:F.success,category:"success",particles:[]},{id:"e18",source:"gatcha-gtm/matchmaker",target:"gatcha-gtm/nft-minter",eventType:"match:reward",active:!0,lastFired:t-22e3,color:F.purple,category:"rl",particles:[]}];for(const l of i){const u=l.active?3+Math.floor(Math.random()*3):1;for(let c=0;c<u;c++)l.particles.push({t:Math.random(),speed:8e-4+Math.random()*.0015,size:2+Math.random()*2.5,alpha:.5+Math.random()*.5,trail:[]})}return{nodes:o,edges:i}}function Qn(t,r){const n=Date.now(),s=new Set;for(const l of t)(l.type==="gtm"||l.id.endsWith("-gtm"))&&s.add(l.id);const o=t.map(l=>{const u=l.type==="gtm"||l.id.endsWith("-gtm");let c;if(!u&&!me.has(l.id))if(l.id.includes("/"))c=l.id.split("/")[0];else for(const g of s){const y=g.replace(/-gtm$/,"");if(l.id.startsWith(y+"-")||l.id.startsWith(y+"/")){c=g;break}}const d=u?"gtm":l.type;let m;u?m=Fr:me.has(l.id)?m=28:l.type==="orchestrator"?m=26:m=22;const a=tt(d);return{id:l.id,label:l.label,type:d,status:l.status,eventCount:l.eventCount||Math.floor(Math.random()*200)+50,lastAction:`${l.type} activity`,lastTs:new Date(n-Math.random()*3e5).toISOString(),reward:Array.from({length:7},()=>.3+Math.random()*.5),x:0,y:0,targetX:0,targetY:0,radius:m,baseRadius:m,color:a.fill,glowColor:a.glow,pulsePhase:Math.random()*Math.PI*2,produces:l.produces,consumes:l.consumes,parentGtm:c,isGtm:u,childCount:0,aggregateReward:Array.from({length:7},()=>.3+Math.random()*.5)}}),i=r.map(l=>{const u=l.category==="success"?F.success:l.category==="rl"?F.purple:F.info,c={id:l.id,source:l.source,target:l.target,eventType:l.eventType,active:!0,lastFired:n-Math.random()*12e4,color:u,category:l.category,particles:[]},d=3+Math.floor(Math.random()*3);for(let m=0;m<d;m++)c.particles.push({t:Math.random(),speed:8e-4+Math.random()*.0015,size:2+Math.random()*2.5,alpha:.5+Math.random()*.5,trail:[]});return c});return{nodes:o,edges:i}}function ze(t,r,n,s,o){const i=r/2,l=n/2;if(t.length===0)return;const c=Math.min(r/1200,n/800,1),d=o||new Set,m=t.filter(f=>f.isGtm),a=t.filter(f=>me.has(f.id)),g=t.filter(f=>!f.isGtm&&!me.has(f.id)),y=new Map;for(const f of m)y.set(f.id,[]);for(const f of g)f.parentGtm&&y.has(f.parentGtm)&&y.get(f.parentGtm).push(f);for(const f of m){const x=y.get(f.id)||[];f.childCount=x.length,x.length>0&&(f.aggregateReward=x[0].reward.map((h,C)=>x.reduce(($,b)=>$+(b.reward[C]||0),0)/x.length));const I=d.has(f.id);f.radius=I?f.baseRadius:Er}const v=g.filter(f=>!f.parentGtm||!y.has(f.parentGtm)),T=m.filter(f=>d.has(f.id)),_=m.filter(f=>!d.has(f.id)),R=160;if(T.length===1){const f=T[0];f.targetX=i,f.targetY=l,f.x===0&&f.y===0&&(f.x=i+(Math.random()-.5)*40,f.y=l+(Math.random()-.5)*40);const x=y.get(f.id)||[],I=x.length;if(I>0){const C=Math.PI*2/I,E=-Math.PI/2;x.forEach(($,b)=>{const p=E+b*C,k=R*c+(b%2===0?15:-10);$.targetX=i+Math.cos(p)*k,$.targetY=l+Math.sin(p)*k,$.x===0&&$.y===0&&($.x=$.targetX+(Math.random()-.5)*30,$.y=$.targetY+(Math.random()-.5)*30)})}const h=Math.min(r,n)*.42;_.forEach((C,E)=>{const $=Math.PI*2*E/Math.max(_.length,1)-Math.PI/2;C.targetX=i+Math.cos($)*h,C.targetY=l+Math.sin($)*h,C.x===0&&C.y===0&&(C.x=C.targetX+(Math.random()-.5)*40,C.y=C.targetY+(Math.random()-.5)*40);const b=y.get(C.id)||[];for(const p of b)p.targetX=C.targetX,p.targetY=C.targetY,p.x===0&&p.y===0&&(p.x=p.targetX,p.y=p.targetY)})}else{const f=[{x:r*.22,y:n*.32},{x:r*.68,y:n*.38},{x:r*.45,y:n*.72}];m.forEach((x,I)=>{const h=d.has(x.id),C=f[I%f.length];x.targetX=C.x,x.targetY=C.y,x.x===0&&x.y===0&&(x.x=x.targetX+(Math.random()-.5)*40,x.y=x.targetY+(Math.random()-.5)*40);const E=y.get(x.id)||[];if(h&&E.length>0){const $=E.length,b=Math.PI*2/$,p=-Math.PI/2;E.forEach((k,L)=>{const N=p+L*b,U=R*c+(L%2===0?15:-10);k.targetX=x.targetX+Math.cos(N)*U,k.targetY=x.targetY+Math.sin(N)*U,k.x===0&&k.y===0&&(k.x=k.targetX+(Math.random()-.5)*30,k.y=k.targetY+(Math.random()-.5)*30)})}else for(const $ of E)$.targetX=x.targetX,$.targetY=x.targetY,$.x===0&&$.y===0&&($.x=$.targetX,$.y=$.targetY)})}if(a.length>0){const f=l-40,x=50*c,I=[{x:i,y:f-x*.5},{x:i+x,y:f+x*.3},{x:i,y:f+x*1.1},{x:i-x,y:f+x*.3}],h={"peter-parker":0,stratus:1,"eval-engine":2,"telemetry-agent":3};a.forEach((C,E)=>{const $=h[C.id]??E%4,b=I[$];C.targetX=b.x,C.targetY=b.y,C.x===0&&C.y===0&&(C.x=b.x+(Math.random()-.5)*20,C.y=b.y+(Math.random()-.5)*20)})}if(v.length>0){const f=Math.min(r,n)*.44,x=Math.PI*2/v.length,I=Math.PI/6;v.forEach((h,C)=>{const E=I+C*x;h.targetX=i+Math.cos(E)*f,h.targetY=l+Math.sin(E)*f,h.x===0&&h.y===0&&(h.x=h.targetX+(Math.random()-.5)*50,h.y=h.targetY+(Math.random()-.5)*50)})}const A=t.filter(f=>f.isGtm||me.has(f.id)||!f.parentGtm?!0:d.has(f.parentGtm));for(let f=0;f<6;f++)for(let x=0;x<A.length;x++)for(let I=x+1;I<A.length;I++){const h=A[x],C=A[I];if(h.isGtm&&C.parentGtm===h.id&&d.has(h.id)||C.isGtm&&h.parentGtm===C.id&&d.has(C.id))continue;const E=h.targetX-C.targetX,$=h.targetY-C.targetY,b=Math.sqrt(E*E+$*$),p=(h.radius+C.radius)*2.5;if(b<p&&b>0){const k=(p-b)*.2,L=E/b*k,N=$/b*k,U=h.isGtm||me.has(h.id),X=C.isGtm||me.has(C.id);U||(h.targetX+=L*(X?1:.5),h.targetY+=N*(X?1:.5)),X||(C.targetX-=L*(U?1:.5),C.targetY-=N*(U?1:.5))}}const S=60;for(const f of t)f.targetX=Math.max(S,Math.min(r-S,f.targetX)),f.targetY=Math.max(S,Math.min(n-S,f.targetY))}function je(t,r,n,s,o,i,l,u,c){const d=1-c;return[d*d*d*t+3*d*d*c*n+3*d*c*c*o+c*c*c*l,d*d*d*r+3*d*d*c*s+3*d*c*c*i+c*c*c*u]}function wt(t,r){const n=r.x-t.x,s=r.y-t.y,o=Math.sqrt(n*n+s*s),i=o>0?-s/o:0,l=o>0?n/o:0,u=Math.min(o*.25,70),c=(t.x+r.x)/2,d=(t.y+r.y)/2;return{sx:t.x,sy:t.y,c1x:c+i*u-n*.15,c1y:d+l*u-s*.15,c2x:c+i*u+n*.15,c2y:d+l*u+s*.15,ex:r.x,ey:r.y}}function he(t,r){const n=parseInt(t.slice(1,3),16),s=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16);return`rgba(${n}, ${s}, ${o}, ${r})`}function pt(t,r,n,s,o){return Math.max(0,Math.sqrt((t-n)**2+(r-s)**2)-o)}const Xe=`
|
|
6
|
+
attribute vec2 a_position;
|
|
7
|
+
void main() {
|
|
8
|
+
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
9
|
+
}
|
|
10
|
+
`,Zn=`
|
|
11
|
+
precision highp float;
|
|
12
|
+
uniform sampler2D u_scene;
|
|
13
|
+
uniform sampler2D u_bloom;
|
|
14
|
+
uniform vec2 u_resolution;
|
|
15
|
+
uniform float u_time;
|
|
16
|
+
|
|
17
|
+
float hash(vec2 p) {
|
|
18
|
+
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
void main() {
|
|
22
|
+
vec2 uv = gl_FragCoord.xy / u_resolution;
|
|
23
|
+
vec4 scene = texture2D(u_scene, uv);
|
|
24
|
+
vec4 bloom = texture2D(u_bloom, uv);
|
|
25
|
+
vec3 color = scene.rgb + bloom.rgb * 0.35;
|
|
26
|
+
float vignette = 1.0 - 0.4 * length((uv - 0.5) * 1.5);
|
|
27
|
+
color *= vignette;
|
|
28
|
+
float scan = 0.97 + 0.03 * sin(uv.y * u_resolution.y * 1.5 + u_time * 0.5);
|
|
29
|
+
color *= scan;
|
|
30
|
+
color += (hash(uv + u_time * 0.001) - 0.5) * 0.015;
|
|
31
|
+
color = pow(color, vec3(0.95));
|
|
32
|
+
gl_FragColor = vec4(color, 1.0);
|
|
33
|
+
}
|
|
34
|
+
`,es=`
|
|
35
|
+
precision highp float;
|
|
36
|
+
uniform sampler2D u_texture;
|
|
37
|
+
uniform vec2 u_resolution;
|
|
38
|
+
uniform float u_radius;
|
|
39
|
+
void main() {
|
|
40
|
+
vec2 uv = gl_FragCoord.xy / u_resolution;
|
|
41
|
+
float texelSize = 1.0 / u_resolution.x;
|
|
42
|
+
vec3 result = vec3(0.0);
|
|
43
|
+
float weights[5];
|
|
44
|
+
weights[0] = 0.227027;
|
|
45
|
+
weights[1] = 0.1945946;
|
|
46
|
+
weights[2] = 0.1216216;
|
|
47
|
+
weights[3] = 0.054054;
|
|
48
|
+
weights[4] = 0.016216;
|
|
49
|
+
result += texture2D(u_texture, uv).rgb * weights[0];
|
|
50
|
+
for (int i = 1; i < 5; i++) {
|
|
51
|
+
float offset = float(i) * texelSize * u_radius;
|
|
52
|
+
result += texture2D(u_texture, uv + vec2(offset, 0.0)).rgb * weights[i];
|
|
53
|
+
result += texture2D(u_texture, uv - vec2(offset, 0.0)).rgb * weights[i];
|
|
54
|
+
}
|
|
55
|
+
gl_FragColor = vec4(result, 1.0);
|
|
56
|
+
}
|
|
57
|
+
`,ts=`
|
|
58
|
+
precision highp float;
|
|
59
|
+
uniform sampler2D u_texture;
|
|
60
|
+
uniform vec2 u_resolution;
|
|
61
|
+
uniform float u_radius;
|
|
62
|
+
void main() {
|
|
63
|
+
vec2 uv = gl_FragCoord.xy / u_resolution;
|
|
64
|
+
float texelSize = 1.0 / u_resolution.y;
|
|
65
|
+
vec3 result = vec3(0.0);
|
|
66
|
+
float weights[5];
|
|
67
|
+
weights[0] = 0.227027;
|
|
68
|
+
weights[1] = 0.1945946;
|
|
69
|
+
weights[2] = 0.1216216;
|
|
70
|
+
weights[3] = 0.054054;
|
|
71
|
+
weights[4] = 0.016216;
|
|
72
|
+
result += texture2D(u_texture, uv).rgb * weights[0];
|
|
73
|
+
for (int i = 1; i < 5; i++) {
|
|
74
|
+
float offset = float(i) * texelSize * u_radius;
|
|
75
|
+
result += texture2D(u_texture, uv + vec2(0.0, offset)).rgb * weights[i];
|
|
76
|
+
result += texture2D(u_texture, uv - vec2(0.0, offset)).rgb * weights[i];
|
|
77
|
+
}
|
|
78
|
+
gl_FragColor = vec4(result, 1.0);
|
|
79
|
+
}
|
|
80
|
+
`,rs=`
|
|
81
|
+
precision highp float;
|
|
82
|
+
uniform sampler2D u_texture;
|
|
83
|
+
uniform vec2 u_resolution;
|
|
84
|
+
uniform float u_threshold;
|
|
85
|
+
void main() {
|
|
86
|
+
vec2 uv = gl_FragCoord.xy / u_resolution;
|
|
87
|
+
vec4 color = texture2D(u_texture, uv);
|
|
88
|
+
float brightness = dot(color.rgb, vec3(0.2126, 0.7152, 0.0722));
|
|
89
|
+
float contribution = smoothstep(u_threshold, u_threshold + 0.15, brightness);
|
|
90
|
+
gl_FragColor = vec4(color.rgb * contribution * 1.5, 1.0);
|
|
91
|
+
}
|
|
92
|
+
`;function qt(t,r,n){const s=t.createShader(n);return s?(t.shaderSource(s,r),t.compileShader(s),t.getShaderParameter(s,t.COMPILE_STATUS)?s:(console.error("Shader compile error:",t.getShaderInfoLog(s)),t.deleteShader(s),null)):null}function We(t,r,n){const s=qt(t,r,t.VERTEX_SHADER),o=qt(t,n,t.FRAGMENT_SHADER);if(!s||!o)return null;const i=t.createProgram();return i?(t.attachShader(i,s),t.attachShader(i,o),t.linkProgram(i),t.getProgramParameter(i,t.LINK_STATUS)?i:(console.error("Program link error:",t.getProgramInfoLog(i)),null)):null}function Ye(t,r,n){const s=t.createFramebuffer(),o=t.createTexture();return!s||!o?null:(t.bindTexture(t.TEXTURE_2D,o),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,r,n,0,t.RGBA,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindFramebuffer(t.FRAMEBUFFER,s),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,o,0),t.bindFramebuffer(t.FRAMEBUFFER,null),{fb:s,tex:o})}function ns(t,r,n,s){t.fillStyle=F.grid;for(let i=50;i<r;i+=50)for(let l=50;l<n;l+=50){const u=Math.sqrt((i-r/2)**2+(l-n/2)**2),c=Math.sin(s*3e-4+u*.004)*.3+.7;t.globalAlpha=.12*c,t.beginPath(),t.arc(i,l,.8,0,Math.PI*2),t.fill()}t.globalAlpha=1}function ss(t,r,n,s,o,i,l,u,c,d){var S,f;t.clearRect(0,0,r,n);const m=c||{scale:1,offsetX:0,offsetY:0},a=d||new Set,g=new Set,y=new Set,v=i||l;if(v)for(const x of o)(x.source===v||x.target===v)&&(g.add(x.source),g.add(x.target),y.add(x.id));ns(t,r,n,u),t.save(),t.translate(m.offsetX,m.offsetY),t.scale(m.scale,m.scale);const T=s.filter(x=>x.isGtm||me.has(x.id)||!x.parentGtm?!0:a.has(x.parentGtm)),_=s.filter(x=>x.isGtm),R=new Map(s.map(x=>[x.id,x]));for(const x of _){if(!a.has(x.id))continue;const h=s.filter(b=>b.parentGtm===x.id);if(h.length===0)continue;let C=0;for(const b of h){const p=b.x-x.x,k=b.y-x.y,L=Math.sqrt(p*p+k*k)+b.radius+20;C=Math.max(C,L)}const E=Math.max(C,80);t.save(),t.globalAlpha=.08,t.strokeStyle=x.color,t.lineWidth=1,t.setLineDash([8,12]),t.beginPath(),t.arc(x.x,x.y,E,0,Math.PI*2),t.stroke(),t.setLineDash([]);const $=t.createRadialGradient(x.x,x.y,0,x.x,x.y,E);$.addColorStop(0,he(x.color,.03)),$.addColorStop(.7,he(x.color,.015)),$.addColorStop(1,he(x.color,0)),t.fillStyle=$,t.beginPath(),t.arc(x.x,x.y,E,0,Math.PI*2),t.fill(),t.restore()}const w=s.filter(x=>me.has(x.id));if(w.length>1){let x=0,I=0;for(const $ of w)x+=$.x,I+=$.y;const h=x/w.length,C=I/w.length;let E=0;for(const $ of w){const b=$.x-h,p=$.y-C,k=Math.sqrt(b*b+p*p)+$.radius+15;E=Math.max(E,k)}t.save(),t.globalAlpha=.06,t.strokeStyle=F.purple,t.lineWidth=1,t.setLineDash([4,8]),t.beginPath(),t.arc(h,C,E,0,Math.PI*2),t.stroke(),t.setLineDash([]),t.restore()}const A=new Set;for(const x of o){let I=R.get(x.source),h=R.get(x.target);if(!I||!h)continue;const C=I.parentGtm&&!a.has(I.parentGtm),E=h.parentGtm&&!a.has(h.parentGtm);if(C){const D=R.get(I.parentGtm);D&&(I=D)}if(E){const D=R.get(h.parentGtm);D&&(h=D)}if(I.id===h.id)continue;const $=`${I.id}->${h.id}`,b=C||E;if(b){if(A.has($))continue;A.add($)}const p=y.has(x.id)||C&&x.source&&((S=R.get(x.source))==null?void 0:S.parentGtm)===I.id||E&&x.target&&((f=R.get(x.target))==null?void 0:f.parentGtm)===h.id,k=y.size>0&&!p,{sx:L,sy:N,c1x:U,c1y:X,c2x:Z,c2y:de,ex:ue,ey:ce}=wt(I,h),ve=Date.now()-x.lastFired,q=ve<5e3,Ce=q?1-ve/5e3:0,B=x.active?p?.8:.35:.08,W=k?.05:Math.min(1,B+Ce*.5),z=b?1.8:1;t.save(),t.globalAlpha=W*.4,t.strokeStyle=x.color,t.shadowColor=x.color,t.shadowBlur=p?20:q?14:8,t.lineWidth=(p?5:3)*z,t.beginPath(),t.moveTo(L,N),t.bezierCurveTo(U,X,Z,de,ue,ce),t.stroke(),t.restore(),t.save(),t.globalAlpha=W,t.strokeStyle=x.color,t.lineWidth=(p?2.5:1.2)*z,t.beginPath(),t.moveTo(L,N),t.bezierCurveTo(U,X,Z,de,ue,ce),t.stroke(),t.restore();const Q=.88,[re,oe]=je(L,N,U,X,Z,de,ue,ce,Q),[V,J]=je(L,N,U,X,Z,de,ue,ce,Q+.04),K=Math.atan2(J-oe,V-re),O=(p?9:6)*z;if(t.save(),t.globalAlpha=W,t.fillStyle=x.color,t.shadowColor=x.color,t.shadowBlur=6,t.translate(V,J),t.rotate(K),t.beginPath(),t.moveTo(0,0),t.lineTo(-O*1.2,-O*.5),t.lineTo(-O*1.2,O*.5),t.closePath(),t.fill(),t.restore(),x.active||q)for(const D of x.particles){const ne=k?.05:D.alpha*(p?1:.6);for(let ye=D.trail.length-1;ye>=0;ye--){const lt=D.trail[ye];t.save(),t.globalAlpha=lt.a*ne*.3,t.fillStyle=x.color,t.shadowColor=x.color,t.shadowBlur=D.size*2,t.beginPath(),t.arc(lt.x,lt.y,D.size*(1-ye*.1),0,Math.PI*2),t.fill(),t.restore()}const[pe,xe]=je(L,N,U,X,Z,de,ue,ce,D.t);t.save(),t.globalAlpha=ne,t.fillStyle="#ffffff",t.shadowColor=x.color,t.shadowBlur=D.size*6,t.beginPath(),t.arc(pe,xe,D.size*.6,0,Math.PI*2),t.fill(),t.restore(),t.save(),t.globalAlpha=ne*.7,t.fillStyle=x.color,t.shadowColor=x.color,t.shadowBlur=D.size*10,t.beginPath(),t.arc(pe,xe,D.size*1.2,0,Math.PI*2),t.fill(),t.restore()}}for(const x of T){const I=i===x.id,h=l===x.id,E=g.size>0&&!g.has(x.id)&&!I&&!h?.15:1,$=x.isGtm&&!a.has(x.id),b=Math.sin(u*.002+x.pulsePhase)*.15+.85,p=x.radius*(I?1.15:h?1.1:1);if(x.status==="running"||I||h){const N=p*(h?2.2:I?2:$?1.4:1.6)*b,U=t.createRadialGradient(x.x,x.y,p*.5,x.x,x.y,N);U.addColorStop(0,he(x.color,.15*E)),U.addColorStop(.5,he(x.color,.04*E)),U.addColorStop(1,he(x.color,0)),t.fillStyle=U,t.beginPath(),t.arc(x.x,x.y,N,0,Math.PI*2),t.fill()}if(x.isGtm){const N=p*($?1.3:1.6),U=(Math.sin(u*.002+x.pulsePhase)*.2+.4)*E;t.save(),t.globalAlpha=U*.25,t.strokeStyle=x.color,t.lineWidth=$?3:2.5,t.beginPath(),t.arc(x.x,x.y,N,0,Math.PI*2),t.stroke(),t.restore(),t.save(),t.globalAlpha=U*.15,t.strokeStyle=x.color,t.lineWidth=1,t.setLineDash([6,4]),t.beginPath(),t.arc(x.x,x.y,p*1.15,0,Math.PI*2),t.stroke(),t.setLineDash([]),t.restore()}else if(x.status==="running"){const N=(Math.sin(u*.003+x.pulsePhase)*.3+.5)*E,U=p*(1.5+Math.sin(u*.001+x.pulsePhase*2)*.3);t.save(),t.globalAlpha=N*.15,t.strokeStyle=x.color,t.lineWidth=1,t.setLineDash([4,6]),t.beginPath(),t.arc(x.x,x.y,U,0,Math.PI*2),t.stroke(),t.setLineDash([]),t.restore()}const k=t.createRadialGradient(x.x-p*.2,x.y-p*.2,0,x.x,x.y,p);k.addColorStop(0,he(x.color,.3*E)),k.addColorStop(.7,he(x.color,.12*E)),k.addColorStop(1,he(x.color,.05*E)),t.save(),t.fillStyle=k,t.shadowColor=x.color,t.shadowBlur=h?25:I?18:$?15:10,t.globalAlpha=E,t.beginPath(),t.arc(x.x,x.y,p,0,Math.PI*2),t.fill(),t.restore(),t.save(),t.globalAlpha=E*(h?.9:I?.7:.4),t.strokeStyle=x.color,t.lineWidth=h?2:1.2,t.beginPath(),t.arc(x.x,x.y,p,0,Math.PI*2),t.stroke(),t.restore();const L=t.createRadialGradient(x.x,x.y,0,x.x,x.y,p*.35);L.addColorStop(0,he("#ffffff",.6*E*b)),L.addColorStop(.5,he(x.color,.4*E*b)),L.addColorStop(1,he(x.color,0)),t.fillStyle=L,t.beginPath(),t.arc(x.x,x.y,p*.35,0,Math.PI*2),t.fill()}t.restore()}function Jt({data:t,color:r,width:n=48,height:s=16}){if(t.length<2)return null;const o=Math.max(...t),i=Math.min(...t),l=o-i||1,u=t.map((d,m)=>{const a=m/(t.length-1)*n,g=s-(d-i)/l*(s-2)-1;return`${a},${g}`}).join(" "),c=s-(t[t.length-1]-i)/l*(s-2)-1;return e("svg",{width:n,height:s,class:"shrink-0",children:[e("polyline",{points:u,fill:"none",stroke:r,"stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round",opacity:"0.7"}),e("circle",{cx:String(n),cy:String(c),r:"2",fill:r,children:e("animate",{attributeName:"opacity",values:"1;0.4;1",dur:"2s",repeatCount:"indefinite"})})]})}function os(){var x,I;const t=be(null),r=be(null),n=be(0),s=be(!0),o=be({nodes:[],edges:[],hoveredNode:null,selectedNode:null,dragging:null,dragOffset:{x:0,y:0},mouse:{x:0,y:0},time:0,liveEventQueue:[],offscreenCanvas:null,offscreenCtx:null,gl:null,programs:{threshold:null,blurH:null,blurV:null,composite:null},fbos:{scene:null,bright:null,pingpong:[null,null]},quadVBO:null,sceneTexture:null,fboWidth:0,fboHeight:0}),[i,l]=P(null),[u,c]=P(!1),[d,m]=P([]),[,a]=P(0),[g,y]=P([]),[v,T]=P(new Set),[_,R]=P({scale:1,offsetX:0,offsetY:0}),w=be(!1),A=be({x:0,y:0,offsetX:0,offsetY:0}),S=Ee(h=>{const C=o.current;if(!h||C.selectedNode===h.id)C.selectedNode=null,l(null);else{C.selectedNode=h.id;const E=C.edges.filter(k=>k.source===h.id||k.target===h.id),$=[];for(const k of E){const L=k.source===h.id,N=L?k.target:k.source,U=C.nodes.find(X=>X.id===N);U&&$.push({id:N,label:U.label,direction:L?"out":"in",eventType:k.eventType})}const b=d.filter(k=>{const L=k.type.toLowerCase(),N=h.id.toLowerCase();return L.includes(N.split("-")[0])||E.some(U=>L.startsWith(U.eventType.split(":")[0]))}).slice(0,8).map(k=>({type:k.type,ts:k.ts,data:"",source:void 0})),p=b.length>0?b:E.slice(0,5).map(k=>({type:k.eventType,ts:new Date(k.lastFired).toISOString(),data:`${k.source} -> ${k.target}`,source:k.source}));l({node:h,edges:E,recentEvents:p,connectedServices:$})}},[d]);fe(()=>{const h=t.current,C=r.current;if(!h||!C)return;const E=document.createElement("canvas"),$=E.getContext("2d");if(!$)return;const b=o.current;b.offscreenCanvas=E,b.offscreenCtx=$;const p=h.getContext("webgl",{alpha:!1,antialias:!1,premultipliedAlpha:!1});if(p){b.gl=p,b.programs.threshold=We(p,Xe,rs),b.programs.blurH=We(p,Xe,es),b.programs.blurV=We(p,Xe,ts),b.programs.composite=We(p,Xe,Zn);const B=new Float32Array([-1,-1,1,-1,-1,1,1,1]),W=p.createBuffer();p.bindBuffer(p.ARRAY_BUFFER,W),p.bufferData(p.ARRAY_BUFFER,B,p.STATIC_DRAW),b.quadVBO=W,b.sceneTexture=p.createTexture(),s.current=!0}else s.current=!1;const k=(B,W)=>{if(!p)return;const z=Math.floor(B/2),Q=Math.floor(W/2);b.fbos.scene=Ye(p,B,W),b.fbos.bright=Ye(p,z,Q),b.fbos.pingpong=[Ye(p,z,Q),Ye(p,z,Q)],b.fboWidth=B,b.fboHeight=W},L=()=>{const B=C.getBoundingClientRect(),W=Math.min(window.devicePixelRatio||1,2),z=Math.floor(B.width*W),Q=Math.floor(B.height*W);h.width=z,h.height=Q,h.style.width=B.width+"px",h.style.height=B.height+"px",E.width=z,E.height=Q,p&&(p.viewport(0,0,z,Q),k(z,Q)),j.topology().then(({nodes:re,edges:oe})=>{if(re.length>=6){const{nodes:J,edges:K}=Qn(re,oe);b.nodes=J,b.edges=K,c(!0)}else{const{nodes:J,edges:K}=Vt();b.nodes=J,b.edges=K}const V=C.getBoundingClientRect();ze(b.nodes,V.width,V.height,b.edges,v),y([...b.nodes]),a(J=>J+1)}).catch(()=>{if(b.nodes.length===0){const{nodes:re,edges:oe}=Vt();b.nodes=re,b.edges=oe}ze(b.nodes,B.width,B.height,b.edges,v),y([...b.nodes]),a(re=>re+1)})};L(),window.addEventListener("resize",L);const N=(B,W)=>{const{scale:z,offsetX:Q,offsetY:re}=_;return{x:(B-Q)/z,y:(W-re)/z}},U=B=>{const W=h.getBoundingClientRect(),z=B.clientX-W.left,Q=B.clientY-W.top;if(b.mouse={x:z,y:Q},w.current){const O=z-A.current.x,D=Q-A.current.y;R(ne=>({...ne,offsetX:A.current.offsetX+O,offsetY:A.current.offsetY+D}));return}const{x:re,y:oe}=N(z,Q);if(b.dragging){const O=b.nodes.find(D=>D.id===b.dragging);O&&(O.x=re-b.dragOffset.x,O.y=oe-b.dragOffset.y,O.targetX=O.x,O.targetY=O.y);return}const V=b.nodes.filter(O=>O.isGtm||me.has(O.id)||!O.parentGtm?!0:v.has(O.parentGtm));let J=null,K=1/0;for(const O of V){const D=pt(O.x,O.y,re,oe,O.radius*1.5);D<K&&D<20/_.scale&&(K=D,J=O)}b.hoveredNode=(J==null?void 0:J.id)||null,h.style.cursor=J?"pointer":w.current?"grabbing":"default"},X=B=>{const W=h.getBoundingClientRect(),z=B.clientX-W.left,Q=B.clientY-W.top,{x:re,y:oe}=N(z,Q),V=b.nodes.filter(K=>K.isGtm||me.has(K.id)||!K.parentGtm?!0:v.has(K.parentGtm));let J=null;for(const K of V)if(pt(K.x,K.y,re,oe,K.radius*1.5)<5/_.scale){J=K;break}J?(b.dragging=J.id,b.dragOffset={x:re-J.x,y:oe-J.y}):(w.current=!0,A.current={x:z,y:Q,offsetX:_.offsetX,offsetY:_.offsetY},h.style.cursor="grabbing")},Z=B=>{const W=b.dragging,z=w.current,Q=h.getBoundingClientRect(),re=B.clientX-Q.left,oe=B.clientY-Q.top,{x:V,y:J}=N(re,oe);if(z){const D=Math.sqrt((re-A.current.x)**2+(oe-A.current.y)**2);w.current=!1,h.style.cursor="default",D<5&&(b.selectedNode=null,l(null));return}if(W){const D=b.nodes.find(ne=>ne.id===W);if(b.dragging=null,D&&Math.sqrt((V-(b.dragOffset.x+D.targetX))**2+(J-(b.dragOffset.y+D.targetY))**2)<5/_.scale)if(D.isGtm){T(xe=>{const ye=new Set(xe);return ye.has(D.id)?ye.delete(D.id):ye.add(D.id),ye});const pe=C.getBoundingClientRect();setTimeout(()=>{ze(b.nodes,pe.width,pe.height,b.edges,v.has(D.id)?new Set([...v].filter(xe=>xe!==D.id)):new Set([...v,D.id])),a(xe=>xe+1)},10)}else S(D);return}const K=b.nodes.filter(D=>D.isGtm||me.has(D.id)||!D.parentGtm?!0:v.has(D.parentGtm));let O=null;for(const D of K)if(pt(D.x,D.y,V,J,D.radius*1.5)<5/_.scale){O=D;break}if(O)if(O.isGtm){T(ne=>{const pe=new Set(ne);return pe.has(O.id)?pe.delete(O.id):pe.add(O.id),pe});const D=C.getBoundingClientRect();setTimeout(()=>{ze(b.nodes,D.width,D.height,b.edges,v.has(O.id)?new Set([...v].filter(ne=>ne!==O.id)):new Set([...v,O.id])),a(ne=>ne+1)},10)}else S(O);else b.selectedNode=null,l(null)},de=B=>{B.preventDefault();const W=h.getBoundingClientRect(),z=B.clientX-W.left,Q=B.clientY-W.top,re=B.deltaY<0?1.1:.9,oe=Math.max(.3,Math.min(3,_.scale*re)),V=(z-_.offsetX)/_.scale,J=(Q-_.offsetY)/_.scale;R({scale:oe,offsetX:z-V*oe,offsetY:Q-J*oe})},ue=B=>{B.preventDefault(),R({scale:1,offsetX:0,offsetY:0})};h.addEventListener("mousemove",U),h.addEventListener("mousedown",X),h.addEventListener("mouseup",Z),h.addEventListener("wheel",de,{passive:!1}),h.addEventListener("dblclick",ue);function ce(B){if(!p||!b.quadVBO)return;p.useProgram(B),p.bindBuffer(p.ARRAY_BUFFER,b.quadVBO);const W=p.getAttribLocation(B,"a_position");p.enableVertexAttribArray(W),p.vertexAttribPointer(W,2,p.FLOAT,!1,0,0),p.drawArrays(p.TRIANGLE_STRIP,0,4)}let ve=performance.now();const q=B=>{const W=B-ve;ve=B,b.time=B;for(const V of b.nodes)b.dragging!==V.id&&(V.x+=(V.targetX-V.x)*.06,V.y+=(V.targetY-V.y)*.06);for(const V of b.edges){if(!V.active&&Date.now()-V.lastFired>1e4)continue;const J=b.nodes.find(D=>D.id===V.source),K=b.nodes.find(D=>D.id===V.target);if(!J||!K)continue;const O=wt(J,K);for(const D of V.particles){D.t+=D.speed*(W/16),D.t>1&&(D.t-=1,D.speed=8e-4+Math.random()*.0015,D.trail=[]);const[ne,pe]=je(O.sx,O.sy,O.c1x,O.c1y,O.c2x,O.c2y,O.ex,O.ey,D.t);D.trail.unshift({x:ne,y:pe,a:D.alpha}),D.trail.length>8&&D.trail.pop();for(let xe=0;xe<D.trail.length;xe++)D.trail[xe].a*=.82}}const z=Math.min(window.devicePixelRatio||1,2),Q=C.getBoundingClientRect(),re=Q.width,oe=Q.height;if($&&($.save(),$.scale(z,z),ss($,re,oe,b.nodes,b.edges,b.hoveredNode,b.selectedNode,B,_,v),$.restore()),p&&s.current&&b.sceneTexture&&b.fbos.scene&&b.fbos.bright&&b.fbos.pingpong[0]&&b.fbos.pingpong[1]){const V=b.fboWidth,J=b.fboHeight,K=Math.floor(V/2),O=Math.floor(J/2);p.bindTexture(p.TEXTURE_2D,b.sceneTexture),p.texImage2D(p.TEXTURE_2D,0,p.RGBA,p.RGBA,p.UNSIGNED_BYTE,E),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),b.programs.threshold&&(p.bindFramebuffer(p.FRAMEBUFFER,b.fbos.bright.fb),p.viewport(0,0,K,O),p.useProgram(b.programs.threshold),p.activeTexture(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,b.sceneTexture),p.uniform1i(p.getUniformLocation(b.programs.threshold,"u_texture"),0),p.uniform2f(p.getUniformLocation(b.programs.threshold,"u_resolution"),K,O),p.uniform1f(p.getUniformLocation(b.programs.threshold,"u_threshold"),.45),ce(b.programs.threshold));const D=4;for(let ne=0;ne<D;ne++){const pe=2+ne*1.5;if(b.programs.blurH){const xe=ne===0?b.fbos.bright:b.fbos.pingpong[1];p.bindFramebuffer(p.FRAMEBUFFER,b.fbos.pingpong[0].fb),p.viewport(0,0,K,O),p.useProgram(b.programs.blurH),p.activeTexture(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,xe.tex),p.uniform1i(p.getUniformLocation(b.programs.blurH,"u_texture"),0),p.uniform2f(p.getUniformLocation(b.programs.blurH,"u_resolution"),K,O),p.uniform1f(p.getUniformLocation(b.programs.blurH,"u_radius"),pe),ce(b.programs.blurH)}b.programs.blurV&&(p.bindFramebuffer(p.FRAMEBUFFER,b.fbos.pingpong[1].fb),p.viewport(0,0,K,O),p.useProgram(b.programs.blurV),p.activeTexture(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,b.fbos.pingpong[0].tex),p.uniform1i(p.getUniformLocation(b.programs.blurV,"u_texture"),0),p.uniform2f(p.getUniformLocation(b.programs.blurV,"u_resolution"),K,O),p.uniform1f(p.getUniformLocation(b.programs.blurV,"u_radius"),pe),ce(b.programs.blurV))}b.programs.composite&&(p.bindFramebuffer(p.FRAMEBUFFER,null),p.viewport(0,0,V,J),p.useProgram(b.programs.composite),p.activeTexture(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,b.sceneTexture),p.uniform1i(p.getUniformLocation(b.programs.composite,"u_scene"),0),p.activeTexture(p.TEXTURE1),p.bindTexture(p.TEXTURE_2D,b.fbos.pingpong[1].tex),p.uniform1i(p.getUniformLocation(b.programs.composite,"u_bloom"),1),p.uniform2f(p.getUniformLocation(b.programs.composite,"u_resolution"),V,J),p.uniform1f(p.getUniformLocation(b.programs.composite,"u_time"),B*.001),ce(b.programs.composite))}else if(!s.current){const V=h.getContext("2d");V&&E&&(V.clearRect(0,0,h.width,h.height),V.drawImage(E,0,0))}n.current=requestAnimationFrame(q)};n.current=requestAnimationFrame(q);let Ce=null;try{Ce=kr("/api/events/stream",B=>{c(!0);const W=B;m(z=>[{type:W.type,ts:W.ts},...z].slice(0,20));for(const z of b.edges)(W.type===z.eventType||W.type.startsWith(z.eventType.split(":")[0]+":"))&&(z.lastFired=Date.now(),z.active=!0,z.particles.push({t:0,speed:.003+Math.random()*.002,size:3.5,alpha:1,trail:[]}),setTimeout(()=>{z.particles.length>10&&z.particles.shift()},3e3))})}catch{}return()=>{window.removeEventListener("resize",L),h.removeEventListener("mousemove",U),h.removeEventListener("mousedown",X),h.removeEventListener("mouseup",Z),h.removeEventListener("wheel",de),h.removeEventListener("dblclick",ue),cancelAnimationFrame(n.current),Ce==null||Ce()}},[S,_,v]);const f=o.current;return e("div",{class:"flex h-[calc(100vh-3rem)] gap-0",children:[e("div",{ref:r,class:"flex-1 relative overflow-hidden",style:{background:F.bg},children:[e("style",{children:`
|
|
93
|
+
@keyframes topo-breathe {
|
|
94
|
+
0%, 100% { opacity: 0.25; }
|
|
95
|
+
50% { opacity: 0.5; }
|
|
96
|
+
}
|
|
97
|
+
@keyframes topo-float-1 {
|
|
98
|
+
0%, 100% { transform: translate(0, 0) scale(1); }
|
|
99
|
+
33% { transform: translate(25px, -18px) scale(1.05); }
|
|
100
|
+
66% { transform: translate(-12px, 14px) scale(0.95); }
|
|
101
|
+
}
|
|
102
|
+
@keyframes topo-float-2 {
|
|
103
|
+
0%, 100% { transform: translate(0, 0) scale(1); }
|
|
104
|
+
33% { transform: translate(-30px, 12px) scale(1.08); }
|
|
105
|
+
66% { transform: translate(18px, -24px) scale(0.92); }
|
|
106
|
+
}
|
|
107
|
+
@keyframes topo-float-3 {
|
|
108
|
+
0%, 100% { transform: translate(0, 0) scale(1); }
|
|
109
|
+
33% { transform: translate(14px, 22px) scale(0.96); }
|
|
110
|
+
66% { transform: translate(-22px, -14px) scale(1.04); }
|
|
111
|
+
}
|
|
112
|
+
.topo-orb-1 { animation: topo-float-1 12s ease-in-out infinite; }
|
|
113
|
+
.topo-orb-2 { animation: topo-float-2 15s ease-in-out infinite; }
|
|
114
|
+
.topo-orb-3 { animation: topo-float-3 18s ease-in-out infinite; }
|
|
115
|
+
@keyframes topo-status-pulse {
|
|
116
|
+
0%, 100% { box-shadow: 0 0 4px currentColor; opacity: 1; }
|
|
117
|
+
50% { box-shadow: 0 0 10px currentColor; opacity: 0.7; }
|
|
118
|
+
}
|
|
119
|
+
.topo-status-pulse { animation: topo-status-pulse 2s ease-in-out infinite; }
|
|
120
|
+
`}),e("div",{class:"absolute inset-0 pointer-events-none overflow-hidden",style:{zIndex:0},children:[e("div",{class:"absolute rounded-full topo-orb-1",style:{width:"360px",height:"360px",left:"12%",top:"18%",background:`radial-gradient(circle, ${he(F.info,.06)} 0%, transparent 70%)`,filter:"blur(40px)"}}),e("div",{class:"absolute rounded-full topo-orb-2",style:{width:"400px",height:"400px",right:"10%",bottom:"15%",background:`radial-gradient(circle, ${he(F.purple,.05)} 0%, transparent 70%)`,filter:"blur(50px)"}}),e("div",{class:"absolute rounded-full topo-orb-3",style:{width:"280px",height:"280px",left:"45%",top:"40%",background:`radial-gradient(circle, ${he(F.cyan,.04)} 0%, transparent 70%)`,filter:"blur(35px)"}})]}),e("canvas",{ref:t,class:"absolute inset-0 w-full h-full",style:{zIndex:1,pointerEvents:"none"}}),f.nodes.length>0&&e("div",{class:"absolute inset-0 pointer-events-none",style:{zIndex:5},children:[f.nodes.filter(h=>h.isGtm).map(h=>{const C=f.nodes.filter(b=>b.parentGtm===h.id);let E=h.y;for(const b of C)E=Math.min(E,b.y-b.radius);const $=E-45;return e("div",{class:"absolute",style:{left:`${h.x}px`,top:`${Math.max(20,$)}px`,transform:"translateX(-50%)"},children:e("span",{style:{fontSize:"9px",fontFamily:"'JetBrains Mono', monospace",fontWeight:600,padding:"3px 10px",borderRadius:"12px",color:h.color,background:"rgba(15, 15, 18, 0.7)",border:`1px solid ${h.color}30`,textTransform:"uppercase",letterSpacing:"1.5px"},children:h.label.replace(/-gtm$/i,"").toUpperCase()})},`cluster-${h.id}`)}),f.nodes.filter(h=>me.has(h.id)).length>1&&(()=>{const h=f.nodes.filter(p=>me.has(p.id));let C=0,E=1/0;for(const p of h)C+=p.x,E=Math.min(E,p.y-p.radius);const $=C/h.length,b=E-35;return e("div",{class:"absolute",style:{left:`${$}px`,top:`${Math.max(20,b)}px`,transform:"translateX(-50%)"},children:e("span",{style:{fontSize:"8px",fontFamily:"'JetBrains Mono', monospace",fontWeight:500,padding:"2px 8px",borderRadius:"10px",color:F.purple,background:"rgba(15, 15, 18, 0.6)",border:`1px solid ${F.purple}25`,textTransform:"uppercase",letterSpacing:"1px"},children:"SYSTEM"})})})()]}),g.length>0&&e("div",{class:"absolute inset-0 pointer-events-none",style:{zIndex:2,transform:`translate(${_.offsetX}px, ${_.offsetY}px) scale(${_.scale})`,transformOrigin:"0 0"},children:g.filter(h=>h.isGtm||me.has(h.id)||!h.parentGtm?!0:v.has(h.parentGtm)).map(h=>{const C=f.hoveredNode===h.id,E=f.selectedNode===h.id,$=f.hoveredNode||f.selectedNode,b=new Set;if($)for(const L of f.edges)(L.source===$||L.target===$)&&(b.add(L.source),b.add(L.target));const p=b.size>0&&!b.has(h.id)&&!C&&!E,k=h.isGtm&&!v.has(h.id);return e("div",{class:"absolute pointer-events-auto",style:{left:`${h.x}px`,top:`${h.y+h.radius+14}px`,transform:`translateX(-50%) scale(${1/_.scale})`,transformOrigin:"center top",transition:"opacity 0.3s ease",opacity:p?.15:C||E?1:.8,cursor:h.isGtm?"pointer":"default"},children:e("div",{style:{background:E?"rgba(18, 18, 22, 0.92)":"rgba(18, 18, 22, 0.75)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",border:`1px solid ${E?h.color+"55":C?h.color+"33":"rgba(255,255,255,0.06)"}`,borderRadius:"10px",padding:k?"10px 14px":"8px 12px",whiteSpace:"nowrap",boxShadow:E?`0 0 24px ${h.color}22, 0 4px 16px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06)`:"0 2px 10px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04)",transition:"border-color 0.25s ease, box-shadow 0.3s ease"},children:[e("div",{style:{display:"flex",alignItems:"center",gap:"7px"},children:[e("span",{class:M("topo-status-pulse"),style:{width:"7px",height:"7px",borderRadius:"50%",flexShrink:0,backgroundColor:Ie(h.status),color:Ie(h.status),display:(h.status==="running","block"),boxShadow:h.status==="running"?void 0:"none",animation:h.status==="running"?void 0:"none"}}),e("span",{style:{fontSize:k?"13px":h.isGtm?"12px":"11px",fontWeight:h.isGtm?700:600,color:F.text},children:Kn(h.label,h.isGtm?20:16)}),k&&h.childCount?e("span",{style:{fontSize:"9px",fontFamily:"'JetBrains Mono', monospace",padding:"2px 6px",borderRadius:"6px",backgroundColor:`${h.color}20`,color:h.color},children:[h.childCount," services"]}):e("span",{style:{fontSize:"8px",fontFamily:"'JetBrains Mono', monospace",padding:"1px 5px",borderRadius:"4px",backgroundColor:`${h.color}18`,color:h.color,textTransform:"uppercase",letterSpacing:"0.5px"},children:h.type})]}),e("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"5px",gap:"8px"},children:[e("span",{style:{fontSize:"9px",fontFamily:"'JetBrains Mono', monospace",color:F.textMuted},children:[h.eventCount," events"]}),e(Jt,{data:k&&h.aggregateReward?h.aggregateReward:h.reward,color:h.color,width:k?60:48,height:14})]}),k&&e("div",{style:{marginTop:"6px",fontSize:"8px",color:F.textDim,textAlign:"center"},children:"click to expand"})]})},h.id)})}),f.edges.length>0&&e("div",{class:"absolute inset-0 pointer-events-none",style:{zIndex:3,transform:`translate(${_.offsetX}px, ${_.offsetY}px) scale(${_.scale})`,transformOrigin:"0 0"},children:f.edges.map(h=>{const C=f.nodes.find(L=>L.id===h.source),E=f.nodes.find(L=>L.id===h.target);if(!C||!E||!(f.hoveredNode===h.source||f.hoveredNode===h.target||f.selectedNode===h.source||f.selectedNode===h.target))return null;const b=wt(C,E),[p,k]=je(b.sx,b.sy,b.c1x,b.c1y,b.c2x,b.c2y,b.ex,b.ey,.5);return e("div",{class:"absolute",style:{left:`${p}px`,top:`${k}px`,transform:`translate(-50%, -50%) scale(${1/_.scale})`},children:e("span",{style:{fontSize:"8px",fontFamily:"'JetBrains Mono', monospace",padding:"2px 6px",borderRadius:"5px",color:h.color,background:"rgba(15, 15, 18, 0.88)",border:`1px solid ${h.color}33`,backdropFilter:"blur(6px)",letterSpacing:"0.05em"},children:h.eventType})},h.id)})}),e("div",{class:"absolute top-5 left-5 flex items-center gap-3",style:{zIndex:10},children:[e("h1",{class:"text-base font-semibold tracking-tight",style:{color:F.text},children:"Agent Topology"}),e("span",{class:M("text-[9px] mono px-2 py-0.5 rounded-full tracking-widest uppercase",u?"text-success":"text-muted-foreground"),style:{background:u?"rgba(52, 211, 153, 0.1)":"rgba(90, 90, 90, 0.2)",border:`1px solid ${u?"rgba(52, 211, 153, 0.2)":"rgba(90, 90, 90, 0.15)"}`},children:u?"LIVE":"MOCK"})]}),e("div",{class:"absolute bottom-5 left-5 flex items-center gap-4",style:{zIndex:10},children:[{color:F.cyan,label:"GTM",isGtm:!0},{color:F.info,label:"Agent"},{color:F.purple,label:"Orchestrator"},{color:F.warning,label:"Eval"},{color:F.success,label:"Service"}].map(h=>e("div",{class:"flex items-center gap-1.5",children:[e("span",{style:{width:h.isGtm?"10px":"6px",height:h.isGtm?"10px":"6px",borderRadius:"50%",backgroundColor:h.color,boxShadow:`0 0 6px ${h.color}88`,border:h.isGtm?`1.5px solid ${h.color}`:"none"}}),e("span",{class:"text-[9px] uppercase tracking-wider",style:{color:F.textMuted},children:h.label})]},h.label))}),e("div",{class:"absolute bottom-5 flex items-center gap-4",style:{zIndex:10,right:i?"336px":"20px",transition:"right 0.3s ease"},children:[{color:F.info,label:"Data"},{color:F.success,label:"Success"},{color:F.purple,label:"RL"}].map(h=>e("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[e("svg",{width:"20",height:"4",style:{flexShrink:0},children:e("line",{x1:"0",y1:"2",x2:"20",y2:"2",stroke:h.color,"stroke-width":"1.5","stroke-dasharray":"6 4"})}),e("span",{class:"text-[9px]",style:{color:F.textMuted},children:h.label})]},h.label))}),d.length>0&&e("div",{class:"absolute bottom-5 max-w-60",style:{zIndex:10,right:i?"336px":"20px",bottom:"40px",transition:"right 0.3s ease"},children:[e("div",{class:"text-[9px] uppercase tracking-widest font-medium mb-1.5",style:{color:F.textDim},children:"Live Events"}),e("div",{class:"space-y-0.5 max-h-28 overflow-hidden",children:d.slice(0,6).map((h,C)=>e("div",{class:"text-[9px] mono truncate animate-fade-in",style:{opacity:1-C*.14,color:F.textDim},children:[e("span",{style:{color:F.info},children:h.type})," ",e("span",{style:{opacity:.5},children:te(h.ts)})]},`${h.ts}-${C}`))})]}),e("div",{class:"absolute",style:{right:i?"336px":"20px",bottom:"140px",width:"180px",height:"100px",background:"rgba(12, 12, 15, 0.85)",border:"1px solid rgba(60, 60, 60, 0.3)",borderRadius:"6px",overflow:"hidden",zIndex:10,transition:"right 0.3s ease"},onClick:h=>{const C=h.currentTarget.getBoundingClientRect(),E=h.clientX-C.left,$=h.clientY-C.top,b=o.current;if(b.nodes.length===0)return;let p=1/0,k=-1/0,L=1/0,N=-1/0;b.nodes.forEach(q=>{p=Math.min(p,q.x),k=Math.max(k,q.x),L=Math.min(L,q.y),N=Math.max(N,q.y)});const U=50;p-=U,k+=U,L-=U,N+=U;const X=k-p,Z=N-L,de=p+E/180*X,ue=L+$/100*Z,ce=t.current;if(!ce)return;const{scale:ve}=_;R({scale:ve,offsetX:ce.width/2-de*ve,offsetY:ce.height/2-ue*ve})},children:e("svg",{width:"180",height:"100",style:{display:"block"},children:(()=>{const h=o.current;if(h.nodes.length===0)return null;let C=1/0,E=-1/0,$=1/0,b=-1/0;h.nodes.forEach(q=>{C=Math.min(C,q.x),E=Math.max(E,q.x),$=Math.min($,q.y),b=Math.max(b,q.y)});const p=50;C-=p,E+=p,$-=p,b+=p;const k=E-C,L=b-$,N=h.nodes.filter(q=>q.isGtm||!q.parentGtm?!0:v.has(q.parentGtm)),U=q=>(q-C)/k*180,X=q=>(q-$)/L*100,Z=t.current,de=Z?-_.offsetX/_.scale:0,ue=Z?-_.offsetY/_.scale:0,ce=Z?Z.width/_.scale:k,ve=Z?Z.height/_.scale:L;return e(le,{children:[N.map(q=>{const B=q.isGtm&&!v.has(q.id)?5:q.isGtm?4:2;return e("circle",{cx:U(q.x),cy:X(q.y),r:B,fill:q.color,opacity:.8},q.id)}),e("rect",{x:U(de),y:X(ue),width:ce/k*180,height:ve/L*100,fill:"none",stroke:F.info,"stroke-width":"1",opacity:.6})]})})()})})]}),i&&e("div",{class:"w-80 overflow-y-auto animate-slide-in",style:{background:"rgba(18, 18, 22, 0.95)",borderLeft:"1px solid rgba(60, 60, 60, 0.2)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",flexShrink:0},children:[e("div",{class:"p-4",style:{borderBottom:"1px solid rgba(60, 60, 60, 0.2)"},children:[e("div",{class:"flex items-center justify-between mb-3",children:[e("div",{class:"flex items-center gap-2.5",children:[e("span",{class:"w-3 h-3 rounded-full",style:{backgroundColor:i.node.color,boxShadow:`0 0 10px ${i.node.color}66`}}),e("h2",{class:"font-semibold text-sm",style:{color:F.text},children:i.node.label})]}),e("button",{onClick:()=>{o.current.selectedNode=null,l(null)},class:"p-1 rounded transition-colors",style:{color:F.textMuted,background:"none",border:"none",cursor:"pointer"},children:e("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:e("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),e("div",{class:"flex items-center gap-2 flex-wrap",children:[e("span",{class:"text-[9px] mono px-2 py-0.5 rounded-full uppercase tracking-wider",style:{backgroundColor:Ie(i.node.status)+"15",color:Ie(i.node.status),border:`1px solid ${Ie(i.node.status)}22`},children:i.node.status}),e("span",{class:"text-[9px] mono px-2 py-0.5 rounded-full uppercase tracking-wider",style:{backgroundColor:i.node.color+"15",color:i.node.color,border:`1px solid ${i.node.color}22`},children:i.node.type})]}),(((x=i.node.produces)==null?void 0:x.length)||((I=i.node.consumes)==null?void 0:I.length))&&e("div",{class:"mt-3 space-y-2",children:[i.node.produces&&i.node.produces.length>0&&e("div",{children:[e("span",{class:"text-[8px] uppercase tracking-widest",style:{color:F.textDim},children:"produces"}),e("div",{class:"flex flex-wrap gap-1 mt-1",children:i.node.produces.map(h=>e("span",{class:"text-[8px] mono px-1.5 py-0.5 rounded",style:{background:`${F.success}15`,color:F.success,border:`1px solid ${F.success}25`},children:h},h))})]}),i.node.consumes&&i.node.consumes.length>0&&e("div",{children:[e("span",{class:"text-[8px] uppercase tracking-widest",style:{color:F.textDim},children:"consumes"}),e("div",{class:"flex flex-wrap gap-1 mt-1",children:i.node.consumes.map(h=>e("span",{class:"text-[8px] mono px-1.5 py-0.5 rounded",style:{background:`${F.info}15`,color:F.info,border:`1px solid ${F.info}25`},children:h},h))})]})]})]}),e("div",{class:"p-4 space-y-5",children:[e("div",{children:[e("div",{class:"text-[9px] uppercase tracking-widest font-medium mb-2.5",style:{color:F.textDim},children:"Stats"}),e("div",{class:"grid grid-cols-2 gap-2",children:[e("div",{class:"rounded-lg p-3",style:{background:"rgba(40, 40, 44, 0.4)",border:"1px solid rgba(60, 60, 60, 0.15)"},children:[e("div",{class:"text-[9px] uppercase tracking-wider",style:{color:F.textDim},children:"Events"}),e("div",{class:"text-lg font-semibold mono tabular-nums mt-1",style:{color:F.text},children:i.node.eventCount})]}),e("div",{class:"rounded-lg p-3",style:{background:"rgba(40, 40, 44, 0.4)",border:"1px solid rgba(60, 60, 60, 0.15)"},children:[e("div",{class:"text-[9px] uppercase tracking-wider",style:{color:F.textDim},children:"Connections"}),e("div",{class:"text-lg font-semibold mono tabular-nums mt-1",style:{color:F.text},children:i.edges.length})]})]})]}),e("div",{children:[e("div",{class:"text-[9px] uppercase tracking-widest font-medium mb-2",style:{color:F.textDim},children:"Reward Signal"}),e("div",{class:"rounded-lg p-3",style:{background:"rgba(40, 40, 44, 0.4)",border:"1px solid rgba(60, 60, 60, 0.15)"},children:[e(Jt,{data:i.node.reward,color:i.node.color,width:220,height:40}),e("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"6px"},children:[e("span",{class:"text-[9px] mono",style:{color:F.textMuted},children:"7 sessions"}),e("span",{class:"text-[9px] mono",style:{color:i.node.color},children:[(i.node.reward[i.node.reward.length-1]*100).toFixed(0),"%"]})]})]})]}),e("div",{children:[e("div",{class:"text-[9px] uppercase tracking-widest font-medium mb-2",style:{color:F.textDim},children:"Last Action"}),e("div",{class:"text-xs",style:{color:F.text,opacity:.8},children:i.node.lastAction}),e("div",{class:"text-[9px] mono mt-1",style:{color:F.textMuted},children:i.node.lastTs?te(i.node.lastTs):"--"})]}),e("div",{children:[e("div",{class:"text-[9px] uppercase tracking-widest font-medium mb-2",style:{color:F.textDim},children:["Connected Services (",i.connectedServices.length,")"]}),e("div",{class:"space-y-3",children:[i.connectedServices.filter(h=>h.direction==="in").length>0&&e("div",{children:[e("div",{class:"text-[8px] uppercase tracking-wider mb-1.5 flex items-center gap-1.5",style:{color:F.info},children:[e("svg",{width:"10",height:"6",viewBox:"0 0 10 6",children:e("path",{d:"M10 3H2M4 0.5L1 3l3 2.5",fill:"none",stroke:F.info,"stroke-width":"1.2"})}),"feeds into"]}),e("div",{class:"space-y-1",children:i.connectedServices.filter(h=>h.direction==="in").map(h=>e("div",{class:"flex items-center gap-2 text-xs pl-3",children:[e("span",{style:{color:F.text},children:h.label}),e("span",{class:"mono text-[8px] ml-auto",style:{color:F.textDim},children:h.eventType})]},h.id))})]}),i.connectedServices.filter(h=>h.direction==="out").length>0&&e("div",{children:[e("div",{class:"text-[8px] uppercase tracking-wider mb-1.5 flex items-center gap-1.5",style:{color:F.success},children:[e("svg",{width:"10",height:"6",viewBox:"0 0 10 6",children:e("path",{d:"M0 3h8M6 0.5l3 2.5-3 2.5",fill:"none",stroke:F.success,"stroke-width":"1.2"})}),"feeds out to"]}),e("div",{class:"space-y-1",children:i.connectedServices.filter(h=>h.direction==="out").map(h=>e("div",{class:"flex items-center gap-2 text-xs pl-3",children:[e("span",{style:{color:F.text},children:h.label}),e("span",{class:"mono text-[8px] ml-auto",style:{color:F.textDim},children:h.eventType})]},h.id))})]})]})]}),i.recentEvents.length>0&&e("div",{children:[e("div",{class:"text-[9px] uppercase tracking-widest font-medium mb-2",style:{color:F.textDim},children:"Recent Activity"}),e("div",{class:"space-y-1",children:i.recentEvents.map((h,C)=>e("div",{class:"flex items-center justify-between text-[9px]",children:[e("span",{class:"mono",style:{color:F.info},children:h.type}),e("span",{class:"mono",style:{color:F.textMuted},children:te(h.ts)})]},C))})]})]}),e("div",{class:"p-4",style:{borderTop:"1px solid rgba(60, 60, 60, 0.15)"},children:e("div",{class:"text-[8px] mono tracking-wider",style:{color:F.textDim,opacity:.5},children:"Canvas 2D + WebGL Bloom / 4-pass Gaussian"})})]})]})}function is(t,r){const n=[];for(const o of t){if(o.type==="session:started"||o.type==="session:ended")continue;const i=o.data||{};let l,u;if(o.type==="hook:tool-use"){const c=i.tool_name||"tool",d=i.file_paths||[];l=d.length>0?`${c} → ${d[0]}${d.length>1?` +${d.length-1}`:""}`:c,u=i.hook_event_name||o.source}else o.type==="hook:subagent-start"||o.type==="hook:subagent-stop"?(l=`Agent ${o.type==="hook:subagent-start"?"started":"stopped"}`,u=o.source):(l=i.title||o.type,u=i.summary||o.source);n.push({id:o.id,ts:o.ts,kind:"event",type:o.type,title:l,detail:u,source:o.source,data:o.data})}for(const o of r)o.type!=="file"&&n.push({id:`j-${o.timestamp}-${o.title}`,ts:o.timestamp,kind:"journal",type:o.type,title:o.title,detail:o.content,source:o.source});n.sort((o,i)=>i.ts.localeCompare(o.ts));const s=new Set;return n.filter(o=>{const i=`${o.kind}-${o.title}-${o.ts.slice(0,16)}`;return s.has(i)?!1:(s.add(i),!0)})}function ls(t){const r={},n=new Date().toISOString().slice(0,10),s=new Date(Date.now()-864e5).toISOString().slice(0,10);for(const o of t){const i=o.ts.slice(0,10),l=i===n?"Today":i===s?"Yesterday":i;r[l]||(r[l]=[]),r[l].push(o)}return r}const as=[{label:"All",filter:""},{label:"Eval",filter:"eval"},{label:"Agent",filter:"peter"},{label:"Decision",filter:"decision"},{label:"Feature",filter:"feature"},{label:"Fix",filter:"fix"},{label:"Flow",filter:"flow"},{label:"Telemetry",filter:"telemetry"}],cs={event:"●",journal:"◆"},ds={"eval:scored":"text-info","peter:pr-created":"text-warning","peter:pr-proposed":"text-warning","telemetry:insight":"text-accent-foreground","flow:triggered":"text-info/70","flow:completed":"text-success",feature:"text-success",fix:"text-destructive",decision:"text-warning",milestone:"text-info",discovery:"text-info/70"};function us(){var R;const[t,r]=P([]),[n,s]=P(""),[o,i]=P(""),[l,u]=P(new Set),c=G(()=>j.events(200),1e4),d=G(()=>j.journal(),1e4),m=Ft("/api/events/stream",Ee(w=>{r(A=>[w,...A].slice(0,50))},[])),g=[...t,...((R=c.data)==null?void 0:R.events)||[]].filter((w,A,S)=>S.findIndex(f=>f.id===w.id)===A),v=is(g,d.data||[]).filter(w=>{var A;if(n&&!w.type.toLowerCase().includes(n))return!1;if(o){const S=o.toLowerCase();return w.title.toLowerCase().includes(S)||((A=w.detail)==null?void 0:A.toLowerCase().includes(S))||w.type.toLowerCase().includes(S)}return!0}),T=ls(v),_=w=>{u(A=>{const S=new Set(A);return S.has(w)?S.delete(w):S.add(w),S})};return e("div",{class:"space-y-5",children:[e("div",{class:"flex items-center justify-between",children:[e("h1",{class:"text-xl font-semibold",children:"Activity"}),e("div",{class:"flex items-center gap-3",children:[m.connected&&e("span",{class:"text-xs text-success mono animate-pulse-dot",children:"LIVE"}),e("span",{class:"text-sm text-muted-foreground",children:[v.length," items"]})]})]}),e("div",{class:"relative",children:[e("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:[e("circle",{cx:"11",cy:"11",r:"8"}),e("path",{d:"m21 21-4.3-4.3"})]}),e("input",{type:"text",placeholder:"Search activity...",value:o,onInput:w=>i(w.target.value),class:"w-full bg-card border border-border rounded-lg pl-10 pr-4 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-info/50 transition-colors"})]}),e("div",{class:"flex flex-wrap gap-1.5",children:as.map(w=>e("button",{onClick:()=>s(n===w.filter?"":w.filter),class:M("text-[11px] mono font-medium px-2 py-0.5 rounded-md transition-colors",n===w.filter?"bg-foreground/10 text-foreground":"bg-muted/50 text-muted-foreground hover:text-foreground"),children:w.label},w.filter))}),Object.entries(T).map(([w,A])=>e("div",{children:[e("div",{class:"text-[10px] uppercase tracking-widest text-muted-foreground font-medium mb-2 sticky top-0 bg-background py-1",children:w}),e("div",{class:"space-y-0.5",children:A.map(S=>{var E,$,b;const f=l.has(S.id),x=ds[S.type]||"text-foreground",I=cs[S.kind]||"○",h=(E=S.data)==null?void 0:E.delta,C=(($=S.data)==null?void 0:$.improved)==="true"||((b=S.data)==null?void 0:b.improved)===!0;return e("button",{onClick:()=>_(S.id),class:"w-full text-left flex items-start gap-3 py-2 px-3 rounded hover:bg-muted/30 transition-colors animate-fade-in",children:[e("span",{class:"text-[10px] text-muted-foreground mono whitespace-nowrap mt-0.5 w-14 shrink-0",children:te(S.ts)}),e("span",{class:M("text-xs mt-0.5 shrink-0",S.kind==="journal"?"text-success":"text-info"),children:I}),e("div",{class:"flex-1 min-w-0",children:[e("div",{class:"flex items-center gap-2",children:[e("span",{class:M("text-xs mono font-medium whitespace-nowrap",x),children:S.type}),e("span",{class:"text-sm truncate",children:S.title}),h!=null&&e("span",{class:M("text-xs mono ml-auto shrink-0",C?"text-success":"text-destructive"),children:[h>=0?"+":"",Number(h).toFixed(3)]})]}),f&&S.detail&&e("div",{class:"text-xs text-muted-foreground mt-1 whitespace-pre-wrap",children:S.detail}),f&&S.files&&S.files.length>0&&e("div",{class:"flex flex-wrap gap-1 mt-1",children:S.files.map(p=>e("span",{class:"text-[10px] mono bg-muted/50 px-1.5 py-0.5 rounded",children:p},p))})]})]},S.id)})})]},w)),v.length===0&&e("div",{class:"bg-card rounded-lg border border-border p-8 text-center text-sm text-muted-foreground",children:o||n?"No matching activity":"No activity yet"})]})}function ps(t){if(!t)return;const r=t.match(/autoresearch-r(\d+)/);if(r)return`Round ${r[1]}`;let n=t.replace(/^pp\//,"").replace(/^feature\//,"").replace(/-\d{10,}$/,"").replace(/-/g," ");return n&&(n=n.charAt(0).toUpperCase()+n.slice(1)),n||void 0}function hs(t){return t.map(r=>{var n,s,o;return{ts:r.ts,branch:r.branch,prNumber:r.pr_number,delta:(n=r.delta)==null?void 0:n.composite,composite:r.composite,improved:r.improved,agent:r.agent,testsTotal:(s=r.metrics)==null?void 0:s.tests_total,testsPassed:(o=r.metrics)==null?void 0:o.tests_passed,description:ps(r.branch)||r.notes}})}function gs(){var w,A,S;const t=G(()=>j.events(500),15e3),r=G(()=>j.leaderboard(),15e3),n=G(()=>j.flowExecutions(),15e3),s=G(()=>j.evalEntries(100),15e3),o=((w=t.data)==null?void 0:w.events)||[],i=r.data||[],l=n.data||[],u=((A=s.data)==null?void 0:A.entries)||[],c=hs(u),d=o.filter(f=>f.type==="telemetry:insight").length,m=o.filter(f=>f.type.startsWith("peter:")).length,a=c.length,g=c.filter(f=>f.improved===!0).length,y=c.filter(f=>f.improved===!1).length,v=l.length,T=[...i].sort((f,x)=>(x.composite||0)-(f.composite||0))[0],_=(S=T==null?void 0:T.trajectory)==null?void 0:S[0],R=T==null?void 0:T.composite;return e("div",{class:"space-y-6",children:[e("div",{class:"flex items-center justify-between",children:[e("h1",{class:"text-xl font-semibold",children:"Self-Driving Loop"}),e("span",{class:"text-sm text-muted-foreground",children:[c.length," cycles"]})]}),_!=null&&R!=null&&e("div",{class:"bg-card rounded-lg border border-border p-4",children:e("div",{class:"flex items-center gap-4",children:[e("div",{children:[e("div",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-1",children:"Score"}),e("div",{class:"flex items-center gap-2",children:[e("span",{class:"text-2xl font-bold tabular-nums",children:R.toFixed(2)}),(()=>{const f=R-_;return e("span",{class:M("text-sm mono",f>=0?"text-success":"text-destructive"),children:[f>=0?"▲":"▼",f>=0?"+":"",f.toFixed(3)]})})()]})]}),(T==null?void 0:T.trajectory)&&T.trajectory.length>1&&e(Ge,{data:T.trajectory,width:200,height:40,color:R>=_?"var(--success)":"var(--destructive)"}),e("div",{class:"ml-auto",children:[e("div",{class:"w-40 h-3 bg-muted rounded-full overflow-hidden",children:e("div",{class:"h-full bg-success rounded-full transition-all",style:{width:`${Math.round(R*100)}%`}})}),e("div",{class:"text-[10px] text-muted-foreground text-right mt-0.5",children:[Math.round(R*100),"%"]})]})]})}),e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-4",children:"Pipeline"}),e("div",{class:"flex items-center justify-between text-center",children:[{label:"DETECT",count:d,color:"text-accent-foreground",detail:"insights"},{label:"PROPOSE",count:m,color:"text-warning",detail:"PRs"},{label:"EVAL",count:a,color:"text-info",detail:"runs"},{label:"MERGE",count:g,color:"text-success",detail:"merged"},{label:"LEARN",count:v,color:"text-info/70",detail:"flows"}].map((f,x)=>e("div",{class:"flex items-center",children:[x>0&&e("svg",{width:"24",height:"16",class:"text-muted-foreground/30 mx-1 shrink-0",children:e("path",{d:"M2 8h16M14 4l4 4-4 4",fill:"none",stroke:"currentColor","stroke-width":"1.5"})}),e("div",{children:[e("div",{class:M("text-2xl font-bold tabular-nums",f.color),children:f.count}),e("div",{class:"text-[10px] mono text-muted-foreground uppercase tracking-wider",children:f.label}),e("div",{class:"text-[10px] text-muted-foreground",children:f.detail})]})]},f.label))}),y>0&&e("div",{class:"flex items-center gap-2 mt-3 text-xs text-destructive",children:e("span",{class:"mono",children:[y," rejected"]})})]}),i.length>0&&e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:"Agents"}),e("div",{class:"space-y-2",children:i.sort((f,x)=>(x.composite||0)-(f.composite||0)).map(f=>e("div",{class:"flex items-center gap-3",children:[e("span",{class:M("w-2 h-2 rounded-full shrink-0",f.delta!=null&&f.delta>0?"bg-success":"bg-muted-foreground/50")}),e("span",{class:"text-sm font-medium flex-1 truncate",children:f.agent}),e("span",{class:"text-sm mono tabular-nums text-muted-foreground",children:f.composite!=null?f.composite.toFixed(4):"—"}),f.trajectory&&f.trajectory.length>1&&e(Ge,{data:f.trajectory,width:80,height:24})]},f.agent))})]}),c.length>0&&e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:"Recent Cycles"}),e("div",{class:"space-y-1",children:c.slice(0,20).map((f,x)=>e("div",{class:M("flex items-center gap-3 py-2 px-2 text-sm rounded -mx-2",f.improved===!0&&"bg-success/5",f.improved===!1&&"bg-destructive/5"),children:[e("span",{class:"text-[10px] text-muted-foreground mono w-12 shrink-0",children:te(f.ts)}),e("span",{class:M("w-2 h-2 rounded-full shrink-0",f.improved===!0?"bg-success":f.improved===!1?"bg-destructive":"bg-muted-foreground/50")}),e("span",{class:"truncate flex-1 text-foreground",title:f.branch||f.agent,children:f.description||f.branch||f.agent||"Eval run"}),f.composite!=null&&e("span",{class:"text-xs mono tabular-nums bg-muted px-1.5 py-0.5 rounded",children:f.composite.toFixed(2)}),f.delta!=null&&e("span",{class:M("text-xs mono tabular-nums px-1.5 py-0.5 rounded",f.delta>=0?"bg-success/20 text-success":"bg-destructive/20 text-destructive"),children:[f.delta>=0?"+":"",f.delta.toFixed(3)]}),f.testsTotal!=null&&e("span",{class:"text-[10px] text-muted-foreground mono whitespace-nowrap",children:[f.testsPassed!=null&&f.testsPassed!==f.testsTotal?`${f.testsPassed}/${f.testsTotal}`:`${f.testsTotal}`," tests"]}),f.prNumber&&e("span",{class:"text-[10px] mono text-muted-foreground",children:["#",f.prNumber]}),e("span",{class:M("text-[10px] mono w-14 text-right",f.improved===!0?"text-success":f.improved===!1?"text-destructive":"text-muted-foreground"),children:f.improved===!0?"✓ merged":f.improved===!1?"✗ rejected":"—"})]},`${f.ts}-${x}`))})]}),c.length===0&&e("div",{class:"bg-card rounded-lg border border-border p-8 text-center",children:[e("div",{class:"text-sm text-muted-foreground",children:"No eval cycles yet"}),e("div",{class:"text-xs text-muted-foreground/70 mt-1",children:["Run ",e("span",{class:"mono",children:'jfl peter pr --task "add tests"'})," to start the loop"]})]})]})}function ms(t){return t.gated?"pending":t.error||t.actions_failed&&t.actions_failed>0?"failed":t.completed_at?"completed":"running"}function fs({status:t}){var R;const[r,n]=P(24),s=G(()=>j.projects(),15e3),o=G(()=>j.memoryStatus(),3e4),i=G(()=>j.flows(),15e3),l=G(()=>j.flowExecutions(),15e3),u=G(()=>j.telemetryDigest(r),3e4,[r]);G(()=>j.telemetryAgentStatus(),15e3);const c=(t==null?void 0:t.sources)||{},d=Object.values(c).filter(Boolean).length,m=Object.keys(c).length,a=o.data,g=i.data||[],y=l.data,v=Array.isArray(y)?y:(y==null?void 0:y.executions)||[],T=v.filter(w=>ms(w)==="pending"),_=u.data;return e("div",{class:"space-y-6",children:[e("div",{class:"flex items-center justify-between",children:[e("h1",{class:"text-xl font-semibold",children:"System"}),e("span",{class:M("text-xs mono px-2 py-0.5 rounded",(t==null?void 0:t.status)==="running"||(t==null?void 0:t.status)==="ok"?"bg-success/10 text-success":"bg-destructive/10 text-destructive"),children:(t==null?void 0:t.status)||"unknown"})]}),e("div",{class:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e(ae,{label:"Hub",value:(t==null?void 0:t.status)==="running"||(t==null?void 0:t.status)==="ok"?"OK":(t==null?void 0:t.status)||"--",sub:`port :${(t==null?void 0:t.port)||"--"}`,trend:(t==null?void 0:t.status)==="running"||(t==null?void 0:t.status)==="ok"?"up":"down"}),e(ae,{label:"Sources",value:`${d}/${m}`,sub:"connected",trend:d===m?"up":"down"}),e(ae,{label:"Items",value:(t==null?void 0:t.itemCount)||0,sub:"indexed"}),e(ae,{label:"Memories",value:(a==null?void 0:a.total_memories)||0,sub:(R=a==null?void 0:a.embeddings)!=null&&R.available?"with embeddings":"keyword only"})]}),e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("div",{class:"flex items-center justify-between mb-3",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider",children:"Costs"}),e("div",{class:"flex gap-1",children:[24,72,168].map(w=>e("button",{onClick:()=>n(w),class:M("text-[10px] mono px-2 py-0.5 rounded transition-colors",r===w?"bg-foreground/10 text-foreground":"text-muted-foreground hover:text-foreground"),children:w===24?"24h":w===72?"3d":"7d"},w))})]}),_?e(le,{children:[e("div",{class:"text-2xl font-bold tabular-nums mb-3",children:["$",_.totalCostUsd.toFixed(2)]}),e("div",{class:"space-y-1.5",children:_.costs.sort((w,A)=>A.estimatedCostUsd-w.estimatedCostUsd).map(w=>{const A=_.totalCostUsd>0?w.estimatedCostUsd/_.totalCostUsd*100:0;return e("div",{class:"flex items-center gap-3 text-xs",children:[e("span",{class:"w-32 truncate mono text-muted-foreground",children:w.model}),e("div",{class:"flex-1 h-1.5 bg-muted rounded-full overflow-hidden",children:e("div",{class:"h-full bg-info rounded-full",style:{width:`${A}%`}})}),e("span",{class:"mono text-muted-foreground w-16 text-right",children:["$",w.estimatedCostUsd.toFixed(2)]}),e("span",{class:"text-muted-foreground/60 w-10 text-right",children:[A.toFixed(0),"%"]})]},w.model)})})]}):e("div",{class:"text-sm text-muted-foreground",children:"No cost data"})]}),e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("div",{class:"flex items-center justify-between mb-3",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider",children:["Flows (",g.length," defined, ",g.filter(w=>w.enabled!==!1).length," enabled)"]}),T.length>0&&e("span",{class:"text-[10px] mono text-warning",children:[T.length," pending"]})]}),T.length>0&&e("div",{class:"mb-3 space-y-1.5",children:T.map((w,A)=>e("div",{class:"flex items-center justify-between p-2 rounded border border-warning/30 bg-warning/5",children:[e("div",{class:"flex items-center gap-2",children:[e("span",{class:"w-1.5 h-1.5 rounded-full bg-warning animate-pulse"}),e("span",{class:"text-sm font-medium",children:w.flow}),e("span",{class:"text-[10px] mono text-muted-foreground",children:te(w.started_at)})]}),e("button",{onClick:()=>j.approveFlow(w.flow,w.trigger_event_id),class:"text-[10px] mono px-2 py-0.5 rounded bg-success/15 text-success hover:bg-success/25 transition-colors",children:"approve"})]},A))}),e("div",{class:"space-y-1",children:g.map(w=>{var x;const A=typeof w.trigger=="string"?w.trigger:((x=w.trigger)==null?void 0:x.pattern)||"",S=w.enabled!==!1,f=v.filter(I=>I.flow===w.name).length;return e("div",{class:M("flex items-center gap-3 py-1.5 text-sm",!S&&"opacity-40"),children:[e("span",{class:M("w-1.5 h-1.5 rounded-full",S?"bg-success":"bg-muted-foreground/50")}),e("span",{class:"font-medium flex-1 truncate",children:w.name}),e("span",{class:"text-[10px] mono text-info",children:A}),f>0&&e("span",{class:"text-[10px] text-muted-foreground",children:[f," runs"]}),e("button",{onClick:()=>j.toggleFlow(w.name,!S),class:M("text-[10px] mono px-1.5 py-0.5 rounded transition-colors",S?"bg-success/10 text-success":"bg-muted text-muted-foreground"),children:S?"on":"off"})]},w.name)})})]}),_&&e("div",{class:"grid grid-cols-2 gap-4",children:[e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-2",children:"Sessions"}),e("div",{class:"grid grid-cols-2 gap-2 text-sm",children:[e("div",{children:[e("span",{class:"text-muted-foreground",children:"Started:"}),e("span",{class:"ml-1 font-medium",children:_.sessions.started})]}),e("div",{children:[e("span",{class:"text-muted-foreground",children:"Ended:"}),e("span",{class:"ml-1 font-medium",children:_.sessions.ended})]}),e("div",{children:[e("span",{class:"text-muted-foreground",children:"Crashed:"}),e("span",{class:M("ml-1 font-medium",_.sessions.crashed>0?"text-destructive":""),children:_.sessions.crashed})]}),e("div",{children:[e("span",{class:"text-muted-foreground",children:"Avg:"}),e("span",{class:"ml-1 font-medium",children:[Math.round(_.sessions.avgDurationS/60),"m"]})]})]})]}),e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-2",children:"Errors"}),_.errors.total>0?e("div",{class:"space-y-1",children:Object.entries(_.errors.byType).map(([w,A])=>e("div",{class:"flex items-center justify-between text-sm",children:[e("span",{class:"text-muted-foreground truncate",children:w}),e("span",{class:"text-destructive mono",children:A})]},w))}):e("div",{class:"text-sm text-success",children:"No errors"})]})]}),e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:"Context Sources"}),e("div",{class:"grid grid-cols-2 md:grid-cols-4 gap-3",children:Object.entries(c).map(([w,A])=>e("div",{class:"flex items-center gap-2",children:[e("span",{class:M("w-1.5 h-1.5 rounded-full",A?"bg-success":"bg-destructive")}),e("span",{class:"text-sm capitalize",children:w}),e("span",{class:"text-[10px] text-muted-foreground",children:A?"ok":"down"})]},w))})]}),s.data&&s.data.length>0&&e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:["Tracked Projects (",s.data.length,")"]}),e("div",{class:"space-y-2",children:s.data.map(w=>e("div",{class:"flex items-center gap-3 text-sm",children:[e(Se,{status:w.status==="OK"?"ok":"error"}),e("span",{class:"font-medium",children:w.name}),e("span",{class:"text-[10px] mono text-muted-foreground",children:[":",w.port]}),w.status==="OK"&&e("a",{href:`http://localhost:${w.port}/dashboard/`,target:"_blank",rel:"noopener",class:"text-[10px] text-info hover:underline ml-auto",children:"Open"})]},w.name))})]})]})}function xs(t){const r=t.data||{},n=[];if(Array.isArray(r.findings))for(const s of r.findings)n.push({file:s.file||"unknown",line:s.line,severity:s.severity||"yellow",category:s.category||"general",message:s.message||"",suggestion:s.suggestion});return{id:t.id,ts:t.ts,pr:r.pr,branch:r.branch||r.ref,agent:r.agent||t.source,findings:n,summary:r.summary,source:t.source}}const $r={red:{bg:"bg-destructive/15",text:"text-destructive",label:"RED"},yellow:{bg:"bg-warning/15",text:"text-warning",label:"YLW"},green:{bg:"bg-success/15",text:"text-success",label:"OK"}},bs=[{label:"All",value:""},{label:"Red",value:"red"},{label:"Yellow",value:"yellow"},{label:"Green",value:"green"}];function vs(){var y;const[t,r]=P([]),[n,s]=P(""),[o,i]=P(new Set),l=G(()=>j.events(200,"review:*"),15e3);Ft("/api/events/stream",Ee(v=>{var _;const T=v;(_=T.type)!=null&&_.startsWith("review:")&&r(R=>[T,...R].slice(0,50))},[]));const c=[...t,...((y=l.data)==null?void 0:y.events)||[]].filter((v,T,_)=>_.findIndex(R=>R.id===v.id)===T),d=Te(()=>c.map(xs).sort((v,T)=>T.ts.localeCompare(v.ts)),[c]),m=n?d.filter(v=>v.findings.some(T=>T.severity===n)):d,a=Te(()=>{let v=0,T=0,_=0;for(const R of d)for(const w of R.findings)w.severity==="red"?v++:w.severity==="yellow"?T++:_++;return{red:v,yellow:T,green:_,total:d.length}},[d]),g=v=>{i(T=>{const _=new Set(T);return _.has(v)?_.delete(v):_.add(v),_})};return e("div",{class:"space-y-5",children:[e("div",{class:"flex items-center justify-between",children:[e("h1",{class:"text-xl font-semibold",children:"Reviews"}),e("div",{class:"flex items-center gap-3",children:[t.length>0&&e("span",{class:"text-xs text-success mono animate-pulse-dot",children:"LIVE"}),e("span",{class:"text-sm text-muted-foreground",children:[m.length," reviews"]})]})]}),e("div",{class:"grid grid-cols-4 gap-3",children:[e(Ve,{label:"Reviews",value:a.total,color:"text-foreground"}),e(Ve,{label:"Red Findings",value:a.red,color:"text-destructive"}),e(Ve,{label:"Yellow Findings",value:a.yellow,color:"text-warning"}),e(Ve,{label:"Green Findings",value:a.green,color:"text-success"})]}),e("div",{class:"flex flex-wrap gap-1.5",children:bs.map(v=>e("button",{onClick:()=>s(v.value),class:M("text-[11px] mono font-medium px-2 py-0.5 rounded-md transition-colors",n===v.value?"bg-foreground/10 text-foreground":"bg-muted/50 text-muted-foreground hover:text-foreground"),children:v.label},v.value))}),e("div",{class:"bg-card rounded-lg border border-border",children:l.loading&&m.length===0?e("div",{class:"p-4 text-sm text-muted-foreground animate-pulse-dot",children:"Loading reviews..."}):m.length===0?e("div",{class:"py-8 text-sm text-muted-foreground text-center",children:"No review events yet. Reviews appear when AI eval runs on PRs."}):e("div",{class:"divide-y divide-border/50",children:m.map(v=>e(ys,{review:v,expanded:o.has(v.id),onToggle:()=>g(v.id)},v.id))})})]})}function Ve({label:t,value:r,color:n}){return e("div",{class:"bg-card rounded-lg border border-border p-3",children:[e("div",{class:"text-[10px] text-muted-foreground uppercase tracking-wider",children:t}),e("div",{class:M("text-2xl font-semibold mono tabular-nums mt-1",n),children:r})]})}function ys({review:t,expanded:r,onToggle:n}){const s=t.findings.filter(l=>l.severity==="red").length,o=t.findings.filter(l=>l.severity==="yellow").length,i=t.findings.filter(l=>l.severity==="green").length;return e("div",{class:"animate-fade-in",children:[e("button",{onClick:n,class:"w-full flex items-center gap-3 px-4 py-3 hover:bg-muted/20 transition-colors text-left",children:[e("div",{class:"flex items-center gap-1.5 shrink-0",children:[s>0&&e(qe,{severity:"red",count:s}),o>0&&e(qe,{severity:"yellow",count:o}),i>0&&e(qe,{severity:"green",count:i}),t.findings.length===0&&e(qe,{severity:"green",count:0})]}),e("div",{class:"flex-1 min-w-0",children:[e("div",{class:"flex items-center gap-2",children:[t.pr&&e("span",{class:"text-xs mono font-medium text-info",children:["PR #",t.pr]}),t.branch&&e("span",{class:"text-xs mono text-muted-foreground truncate",children:t.branch})]}),t.summary&&e("div",{class:"text-xs text-muted-foreground mt-0.5 truncate",children:t.summary})]}),e("div",{class:"flex items-center gap-2 shrink-0",children:[e("span",{class:"text-[10px] mono text-muted-foreground",children:t.agent}),e("span",{class:"text-[10px] mono text-muted-foreground whitespace-nowrap",children:te(t.ts)}),e("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",class:M("text-muted-foreground transition-transform",r&&"rotate-180"),children:e("polyline",{points:"6 9 12 15 18 9"})})]})]}),r&&t.findings.length>0&&e("div",{class:"px-4 pb-3 space-y-1.5",children:t.findings.map((l,u)=>e(_s,{finding:l},u))})]})}function qe({severity:t,count:r}){const n=$r[t];return e("span",{class:M("text-[10px] mono font-medium px-1.5 py-0.5 rounded",n.bg,n.text),children:r>0?r:n.label})}function _s({finding:t}){const r=$r[t.severity];return e("div",{class:M("rounded-md px-3 py-2 text-xs",r.bg),children:[e("div",{class:"flex items-center gap-2",children:[e("span",{class:M("mono font-medium",r.text),children:r.label}),e("span",{class:"mono text-muted-foreground",children:[t.file,t.line&&`:${t.line}`]}),e("span",{class:"text-muted-foreground/60 mono",children:t.category})]}),e("div",{class:"mt-1 text-foreground",children:t.message}),t.suggestion&&e("div",{class:"mt-1 text-muted-foreground italic",children:t.suggestion})]})}function ws(){const[t,r]=P([]),[n,s]=P(""),[o,i]=P(!1),l=be(null),u=be(null);fe(()=>{var d;(d=l.current)==null||d.scrollIntoView({behavior:"smooth"})},[t]),fe(()=>{var d;(d=u.current)==null||d.focus()},[]);const c=async()=>{const d=n.trim();if(!d||o)return;const m={id:`u-${Date.now()}`,role:"user",content:d,ts:new Date().toISOString()},a=`a-${Date.now()}`,g={id:a,role:"assistant",content:"",ts:new Date().toISOString(),streaming:!0};r(v=>[...v,m,g]),s(""),i(!0);const y=t.filter(v=>!v.streaming).slice(-8).map(v=>({role:v.role,content:v.content}));await Jr(d,y,v=>{r(T=>T.map(_=>_.id===a?{..._,sources:v}:_))},v=>{r(T=>T.map(_=>_.id===a?{..._,content:_.content+v}:_))},()=>{r(v=>v.map(T=>T.id===a?{...T,streaming:!1}:T)),i(!1)},v=>{r(T=>T.map(_=>_.id===a?{..._,content:`Error: ${v}`,streaming:!1}:_)),i(!1)})};return e("div",{class:"flex flex-col h-[calc(100vh-3rem)]",children:[e("div",{class:"flex items-center justify-between mb-4",children:[e("h1",{class:"text-xl font-semibold",children:"Chat"}),e("div",{class:"flex items-center gap-2",children:[t.length>0&&e("button",{onClick:()=>r([]),class:"text-[10px] mono px-2 py-1 rounded bg-muted text-muted-foreground hover:text-foreground transition-colors",children:"clear"}),e("span",{class:"text-sm text-muted-foreground",children:[t.length," messages"]})]})]}),e("div",{class:"flex-1 overflow-y-auto space-y-4 pb-4",children:[t.length===0&&e("div",{class:"flex flex-col items-center justify-center h-full text-center",children:[e("div",{class:"text-muted-foreground/40 mb-4",children:e("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round",children:e("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),e("div",{class:"text-sm text-muted-foreground mb-1",children:"Ask about your project"}),e("div",{class:"text-xs text-muted-foreground/60 max-w-sm",children:"Answers grounded in your journal, knowledge base, and code context."}),e("div",{class:"flex flex-wrap gap-1.5 mt-4 justify-center",children:["What decisions were made recently?","What features were built this week?","What bugs were fixed?","Summarize the current roadmap"].map(d=>e("button",{onClick:()=>{var m;s(d),(m=u.current)==null||m.focus()},class:"text-[11px] mono px-2.5 py-1 rounded-md bg-muted/50 text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-colors",children:d},d))})]}),t.map(d=>e(ks,{message:d},d.id)),e("div",{ref:l})]}),e("div",{class:"border-t border-border pt-3",children:e("div",{class:"flex gap-2",children:[e("input",{ref:u,type:"text",placeholder:"Ask about your project...",value:n,onInput:d=>s(d.target.value),onKeyDown:d=>d.key==="Enter"&&c(),disabled:o,class:"flex-1 bg-card border border-border rounded-lg px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:border-info/50 transition-colors disabled:opacity-50"}),e("button",{onClick:c,disabled:o||!n.trim(),class:M("px-4 py-2.5 rounded-lg text-sm font-medium transition-colors",n.trim()&&!o?"bg-info text-white hover:bg-info/90":"bg-muted text-muted-foreground cursor-not-allowed"),children:e("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[e("path",{d:"M22 2 11 13"}),e("path",{d:"M22 2 15 22l-4-9-9-4z"})]})})]})})]})}function ks({message:t}){const r=t.role==="user",[n,s]=P(!1);return e("div",{class:M("flex gap-3 animate-fade-in",r&&"flex-row-reverse"),children:[e("div",{class:M("w-6 h-6 rounded-full flex items-center justify-center shrink-0 mt-0.5",r?"bg-foreground/10":"bg-info/15"),children:e("span",{class:M("text-[10px] font-bold",r?"text-foreground":"text-info"),children:r?"Y":"J"})}),e("div",{class:"max-w-[80%] space-y-2",children:[e("div",{class:M("rounded-lg px-3 py-2",r?"bg-foreground/5 border border-border":"bg-card border border-border"),children:[r?e("div",{class:"text-sm",children:t.content}):e("div",{class:"text-sm space-y-1.5",children:[t.content?t.content.split(`
|
|
121
|
+
`).map((o,i)=>o.trim()?o.startsWith("# ")?e("div",{class:"font-semibold text-sm mt-2 first:mt-0",children:o.slice(2)},i):o.startsWith("## ")?e("div",{class:"font-medium text-sm text-muted-foreground mt-2",children:o.slice(3)},i):o.startsWith("- ")?e("div",{class:"text-sm pl-3",children:[e("span",{class:"text-muted-foreground mr-1.5",children:"•"}),Kt(o.slice(2))]},i):e("div",{class:"text-sm",children:Kt(o)},i):e("div",{class:"h-2"},i)):t.streaming?e("span",{class:"text-muted-foreground animate-pulse-dot",children:"Thinking..."}):null,t.streaming&&t.content&&e("span",{class:"inline-block w-1.5 h-4 bg-info/60 animate-pulse ml-0.5 align-middle"})]}),e("div",{class:"flex items-center gap-2 mt-1.5",children:[e("span",{class:"text-[10px] text-muted-foreground/50 mono",children:te(t.ts)}),t.sources&&t.sources.length>0&&e("button",{onClick:()=>s(!n),class:"text-[10px] text-info/70 hover:text-info mono transition-colors",children:[t.sources.length," sources ",n?"▾":"▸"]})]})]}),n&&t.sources&&e("div",{class:"bg-card/50 border border-border/50 rounded-lg p-2 space-y-1.5 animate-fade-in",children:t.sources.map((o,i)=>e("div",{class:"flex items-start gap-2 text-[11px]",children:[e("span",{class:M("shrink-0 px-1.5 py-0.5 rounded mono uppercase text-[9px]",o.type==="decision"?"bg-warning/15 text-warning":o.type==="feature"?"bg-success/15 text-success":o.type==="fix"?"bg-destructive/15 text-destructive":"bg-info/15 text-info"),children:o.type||"ctx"}),e("div",{class:"min-w-0",children:[e("div",{class:"font-medium truncate",children:o.title}),o.content&&e("div",{class:"text-muted-foreground line-clamp-2 mt-0.5",children:o.content.slice(0,150)})]})]},i))})]})]})}function Kt(t){const r=[];let n=t,s=0;for(;n.length>0;){const o=n.match(/\*\*(.+?)\*\*/),i=n.match(/`(.+?)`/),l=(o==null?void 0:o.index)??1/0,u=(i==null?void 0:i.index)??1/0;if(l===1/0&&u===1/0){r.push(e("span",{children:n},s++));break}l<=u&&o?(l>0&&r.push(e("span",{children:n.slice(0,l)},s++)),r.push(e("span",{class:"font-medium",children:o[1]},s++)),n=n.slice(l+o[0].length)):i&&(u>0&&r.push(e("span",{children:n.slice(0,u)},s++)),r.push(e("span",{class:"mono text-info text-[10px] bg-info/10 px-1 py-0.5 rounded",children:i[1]},s++)),n=n.slice(u+i[0].length))}return e(le,{children:r})}function Ss({status:t}){var y;const[r,n]=P(24),[s,o]=P([]),[i,l]=P(!1),u=G(()=>j.synopsis(r),3e4,[r]),c=(t==null?void 0:t.children)||[],m=((t==null?void 0:t.type)||"standalone")==="portfolio"&&c.length>0;fe(()=>{if(!m)return;l(!0);const v=c.map(T=>({name:T.name,port:T.port,status:"loading",data:null}));o(v),Promise.all(c.map(async T=>{const _=await j.childSynopsis(T.port,r);return{name:T.name,port:T.port,status:_?"ok":"error",data:_}})).then(T=>{o(T),l(!1)})},[m,r,c.map(v=>v.port).join(",")]);const a=Cs(u.data,s);return e("div",{class:"space-y-5",children:[e("div",{class:"flex items-center justify-between",children:[e("h1",{class:"text-xl font-semibold",children:"Synopsis"}),e("div",{class:"flex items-center gap-2",children:[6,12,24,48,168].map(v=>e("button",{onClick:()=>n(v),class:M("text-[11px] mono font-medium px-2 py-0.5 rounded-md transition-colors",r===v?"bg-foreground/10 text-foreground":"bg-muted/50 text-muted-foreground hover:text-foreground"),children:[v,"h"]},v))})]}),m&&e("div",{class:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[e(Je,{label:"Features",value:a.features,color:"text-success"}),e(Je,{label:"Fixes",value:a.fixes,color:"text-warning"}),e(Je,{label:"Decisions",value:a.decisions,color:"text-info"}),e(Je,{label:"Commits",value:a.commits,color:"text-foreground"})]}),e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("div",{class:"flex items-center justify-between mb-3",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider",children:((y=t==null?void 0:t.config)==null?void 0:y.name)||"This Project"}),u.loading&&e("span",{class:"text-[10px] text-muted-foreground animate-pulse-dot",children:"loading..."})]}),u.data?e(Qt,{data:u.data}):e("div",{class:"text-sm text-muted-foreground",children:["No activity in the last ",r,"h"]})]}),m&&e("div",{class:"space-y-4",children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:["Products (",c.length,")"]}),s.map(v=>e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("div",{class:"flex items-center justify-between mb-3",children:[e("div",{class:"flex items-center gap-2",children:[e("span",{class:M("w-[6px] h-[6px] rounded-full shrink-0",v.status==="ok"?"bg-success":v.status==="loading"?"bg-muted-foreground/50 animate-pulse":"bg-destructive")}),e("h3",{class:"text-sm font-medium",children:v.name}),e("span",{class:"text-[10px] mono text-muted-foreground",children:[":",v.port]})]}),v.status==="loading"&&e("span",{class:"text-[10px] text-muted-foreground animate-pulse-dot",children:"loading..."})]}),v.data?e(Qt,{data:v.data}):v.status==="error"?e("div",{class:"text-xs text-muted-foreground",children:"Unable to fetch synopsis"}):null]},v.name))]}),!m&&u.data&&u.data.commits.length>0&&e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:"Commits"}),e("div",{class:"space-y-1.5",children:u.data.commits.map(v=>e("div",{class:"flex items-center gap-2 text-xs",children:[e("span",{class:"mono text-muted-foreground text-[10px] w-14 shrink-0",children:v.hash.slice(0,7)}),e("span",{class:"truncate flex-1",children:v.message}),e("span",{class:"text-[10px] mono text-muted-foreground",children:v.author}),e("span",{class:"text-[10px] text-muted-foreground whitespace-nowrap",children:te(v.date)})]},v.hash))})]})]})}function Je({label:t,value:r,color:n}){return e("div",{class:"bg-card rounded-lg border border-border p-3",children:[e("div",{class:"text-[10px] text-muted-foreground uppercase tracking-wider",children:t}),e("div",{class:M("text-2xl font-semibold mono tabular-nums mt-1",n),children:r}),e("div",{class:"text-[10px] text-muted-foreground",children:"across all projects"})]})}function Qt({data:t}){const r=t.summary,n=r.features+r.fixes+r.decisions+r.discoveries>0;return e("div",{class:"space-y-3",children:[n&&e("div",{class:"flex gap-4",children:[r.features>0&&e(Fe,{label:"features",value:r.features,color:"text-success"}),r.fixes>0&&e(Fe,{label:"fixes",value:r.fixes,color:"text-warning"}),r.decisions>0&&e(Fe,{label:"decisions",value:r.decisions,color:"text-info"}),r.discoveries>0&&e(Fe,{label:"discoveries",value:r.discoveries,color:"text-purple-400"}),t.commits.length>0&&e(Fe,{label:"commits",value:t.commits.length,color:"text-foreground"}),r.filesModified>0&&e(Fe,{label:"files",value:r.filesModified,color:"text-muted-foreground"})]}),t.journalEntries.length>0&&e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase tracking-wider mb-1.5",children:"Journal"}),e("div",{class:"space-y-1",children:t.journalEntries.slice(0,5).map((s,o)=>e("div",{class:"flex items-start gap-2 text-xs",children:[e("span",{class:M("text-[10px] mono px-1 py-0.5 rounded shrink-0",s.type==="feature"?"bg-success/15 text-success":s.type==="fix"?"bg-warning/15 text-warning":s.type==="decision"?"bg-info/15 text-info":"bg-muted text-muted-foreground"),children:s.type}),e("span",{class:"truncate",children:s.title}),e("span",{class:"text-[10px] text-muted-foreground whitespace-nowrap ml-auto",children:te(s.ts)})]},o))})]}),r.incompleteItems.length>0&&e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase tracking-wider mb-1.5",children:"Incomplete"}),e("div",{class:"space-y-1",children:r.incompleteItems.map((s,o)=>e("div",{class:"text-xs text-warning/80 flex items-center gap-1.5",children:[e("span",{class:"w-1 h-1 rounded-full bg-warning/60 shrink-0"}),s]},o))})]})]})}function Fe({label:t,value:r,color:n}){return e("div",{children:[e("div",{class:M("text-lg font-semibold mono tabular-nums",n),children:r}),e("div",{class:"text-[10px] text-muted-foreground uppercase",children:t})]})}function Cs(t,r){let n=0,s=0,o=0,i=0;const l=u=>{u&&(n+=u.summary.features,s+=u.summary.fixes,o+=u.summary.decisions,i+=u.commits.length)};l(t);for(const u of r)l(u.data);return{features:n,fixes:s,decisions:o,commits:i}}function Ms(){const r=G(()=>j.setupReport(),3e4).data;if(!r)return e("div",{class:"space-y-6",children:[e("h1",{class:"text-xl font-semibold",children:"Setup Report"}),e("div",{class:"bg-card rounded-lg border border-border p-8 text-center",children:e("div",{class:"text-muted-foreground text-sm",children:["No setup report found. Run ",e("code",{class:"bg-muted px-1.5 py-0.5 rounded text-xs",children:"jfl setup --force"})," to generate."]})})]});r.docHealth.bloatedDocs.length===0&&r.docHealth.staleDocs.length===0&&r.docHealth.missingDocs.length===0||r.docHealth.bloatedDocs.length>10;const n=r.docHealth.bloatedDocs.length+r.docHealth.staleDocs.length+r.docHealth.missingDocs.length;return e("div",{class:"space-y-6",children:[e("div",{class:"flex items-center justify-between",children:[e("h1",{class:"text-xl font-semibold",children:"Setup Report"}),e("span",{class:"text-xs text-muted-foreground mono",children:new Date(r.timestamp).toLocaleString()})]}),e("div",{class:"grid grid-cols-2 lg:grid-cols-5 gap-4",children:[e(ae,{label:"Readiness",value:`${r.context.readiness}%`,sub:`${r.context.sessions} sessions`,trend:r.context.readiness>=80?"up":r.context.readiness>=50?"flat":"down"}),e(ae,{label:"Services",value:r.systemModel.services,sub:`${r.systemModel.invariants} invariants`}),e(ae,{label:"Concurrency",value:r.systemModel.concurrencyPatterns,sub:"patterns detected",trend:r.systemModel.concurrencyPatterns>50?"down":"flat"}),e(ae,{label:"Agents",value:r.context.existingAgents.length,sub:"configured",trend:"up"}),e(ae,{label:"Doc Health",value:n,sub:"issues",trend:n===0?"up":n>10?"down":"flat"})]}),e("section",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:"System Model (TLA+)"}),e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("div",{class:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase",children:"Services"}),e("div",{class:"text-lg font-semibold mono",children:r.systemModel.services})]}),e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase",children:"State Variables"}),e("div",{class:"text-lg font-semibold mono",children:r.systemModel.stateVariables})]}),e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase",children:"Actions"}),e("div",{class:"text-lg font-semibold mono",children:r.systemModel.actions})]}),e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase",children:"Invariants"}),e("div",{class:"text-lg font-semibold mono",children:r.systemModel.invariants})]})]}),e("div",{class:"mt-3 pt-3 border-t border-border text-xs text-muted-foreground",children:["Run ",e("code",{class:"bg-muted px-1 py-0.5 rounded",children:"jfl verify"})," to check invariants with TLC model checker"]})]})]}),e("section",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:"Journal Insights"}),e("div",{class:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("div",{class:"flex items-center justify-between mb-2",children:[e("span",{class:"text-sm font-medium",children:"Revert Rate"}),e("span",{class:M("text-lg font-semibold mono",r.journalInsights.revertRate>.3?"text-destructive":r.journalInsights.revertRate>.1?"text-warning":"text-success"),children:[(r.journalInsights.revertRate*100).toFixed(1),"%"]})]}),r.journalInsights.topReverts.length>0&&e("div",{class:"space-y-1 mt-2",children:r.journalInsights.topReverts.slice(0,5).map(s=>e("div",{class:"flex items-center justify-between text-xs",children:[e("span",{class:"text-muted-foreground truncate",children:s.pattern}),e("span",{class:"mono text-destructive",children:[s.count," reverts"]})]},s.pattern))})]}),e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("span",{class:"text-sm font-medium",children:"File Hotspots"}),e("div",{class:"space-y-1.5 mt-2",children:r.journalInsights.hotspots.slice(0,6).map(s=>e("div",{class:"flex items-center justify-between text-xs",children:[e("span",{class:"text-muted-foreground truncate mono",children:s.path}),e("div",{class:"flex items-center gap-2",children:[e("span",{class:"mono",children:s.touches}),s.reverts>0&&e("span",{class:"text-destructive mono",children:["(",s.reverts," rev)"]})]})]},s.path))})]})]})]}),r.journalInsights.evalTrends.length>0&&e("section",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:"Agent Eval Trends"}),e("div",{class:"grid grid-cols-2 md:grid-cols-4 gap-3",children:r.journalInsights.evalTrends.map(s=>e("div",{class:"bg-card rounded-lg border border-border p-3 animate-fade-in",children:[e("div",{class:"flex items-center gap-2 mb-1",children:[e("span",{class:M("text-sm",s.trend==="improving"?"text-success":s.trend==="degrading"?"text-destructive":"text-muted-foreground"),children:s.trend==="improving"?"+":s.trend==="degrading"?"-":"="}),e("span",{class:"text-sm font-medium truncate",children:s.agent})]}),e("div",{class:"text-xs text-muted-foreground",children:[s.scores.length," evals · ",s.trend]})]},s.agent))})]}),e("section",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:["Doc Health",e("span",{class:"ml-2 text-xs font-normal",children:[r.docHealth.totalDocs," docs · ",r.docHealth.totalLines.toLocaleString()," lines · ",(r.docHealth.totalBytes/1024).toFixed(0),"KB"]})]}),e("div",{class:"grid grid-cols-1 md:grid-cols-3 gap-3 mb-4",children:[e("div",{class:M("bg-card rounded-lg border p-3",r.docHealth.bloatedDocs.length>0?"border-warning":"border-border"),children:[e("div",{class:"text-[10px] text-muted-foreground uppercase",children:["Bloated (",">","300 lines)"]}),e("div",{class:"text-lg font-semibold mono",children:r.docHealth.bloatedDocs.length})]}),e("div",{class:M("bg-card rounded-lg border p-3",r.docHealth.staleDocs.length>0?"border-warning":"border-border"),children:[e("div",{class:"text-[10px] text-muted-foreground uppercase",children:["Stale (",">","14 days)"]}),e("div",{class:"text-lg font-semibold mono",children:r.docHealth.staleDocs.length})]}),e("div",{class:M("bg-card rounded-lg border p-3",r.docHealth.missingDocs.length>0?"border-warning":"border-border"),children:[e("div",{class:"text-[10px] text-muted-foreground uppercase",children:"Missing"}),e("div",{class:"text-lg font-semibold mono",children:r.docHealth.missingDocs.length})]})]}),r.docHealth.bloatedDocs.length>0&&e("div",{class:"bg-card rounded-lg border border-border p-4 mb-3",children:[e("span",{class:"text-sm font-medium",children:"Bloated Docs"}),e("div",{class:"space-y-1 mt-2",children:r.docHealth.bloatedDocs.slice(0,10).map(s=>e("div",{class:"flex items-center justify-between text-xs",children:[e("span",{class:"text-muted-foreground truncate mono",children:s.path}),e("span",{class:"mono text-warning",children:[s.lines," lines"]})]},s.path))})]}),r.docHealth.recommendations.length>0&&e("div",{class:"bg-card rounded-lg border border-border p-4",children:[e("span",{class:"text-sm font-medium",children:"Recommendations"}),e("div",{class:"space-y-2 mt-2",children:r.docHealth.recommendations.slice(0,8).map((s,o)=>{const i={trim:"x",update:">",create:"+",archive:"~",split:"/",merge:"&"}[s.type]||"*";return e("div",{class:"flex items-start gap-2 text-xs",children:[e("span",{children:i}),e("div",{children:[e("span",{class:M("font-medium uppercase text-[10px] px-1 py-0.5 rounded mr-1",s.priority===1?"bg-destructive/20 text-destructive":s.priority===2?"bg-warning/20 text-warning":"bg-muted text-muted-foreground"),children:s.type}),e("span",{class:"mono",children:s.target}),e("div",{class:"text-muted-foreground mt-0.5",children:s.rationale})]})]},o)})})]})]}),e("section",{children:[e("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:["Configured Agents (",r.context.existingAgents.length,")"]}),e("div",{class:"flex flex-wrap gap-2",children:r.context.existingAgents.map(s=>e("span",{class:"bg-card border border-border rounded px-2 py-1 text-xs mono",children:s},s))})]})]})}function Ts(t,r,n){const s=r/2,o=n/2,i=t.filter(a=>a.type==="orchestrator"),l=t.filter(a=>a.type==="service"),u=t.filter(a=>a.type==="agent"),c=t.filter(a=>!["orchestrator","service","agent"].includes(a.type)),d=[],m=(a,g,y)=>{a.forEach((v,T)=>{const _=2*Math.PI*T/Math.max(a.length,1)-Math.PI/2;d.push({...v,x:s+g*Math.cos(_),y:o+g*Math.sin(_),ring:y})})};return m(i,0,0),m(l,Math.min(r,n)*.22,1),m([...u,...c],Math.min(r,n)*.38,2),d}const ke={orchestrator:{fill:"#FF3D00",glow:"#FF3D0080",edge:"#FF6E40"},service:{fill:"#00E5FF",glow:"#00E5FF60",edge:"#18FFFF"},agent:{fill:"#76FF03",glow:"#76FF0360",edge:"#B2FF59"},source:{fill:"#E040FB",glow:"#E040FB60",edge:"#EA80FC"},telemetry:{fill:"#FFD740",glow:"#FFD74060",edge:"#FFE57F"}},Es={running:1,stopped:.4,error:1,unknown:.3},Zt={orchestrator:"M0-7L1.8-2.2 7-2.2 2.9 1.2 4.3 6.8 0 3.5-4.3 6.8-2.9 1.2-7-2.2-1.8-2.2Z",service:"M-4-6.9L4-6.9 8 0 4 6.9-4 6.9-8 0Z",agent:"M-1-7H1L1.5-4.5 3.5-3.5 7-1V1L4.5 1.5 3.5 3.5 1 7H-1L-1.5 4.5-3.5 3.5-7 1V-1L-4.5-1.5-3.5-3.5Z",source:"M0-2A2 2 0 110 2 2 2 0 010-2ZM-4.5-4.5A7 7 0 000 7M4.5-4.5A7 7 0 010 7M-3-3A5 5 0 000 5M3-3A5 5 0 010 5",telemetry:"M-7 0H-4L-2-5 0 5 2-3 4 0H7"},er="sg-anim-styles";function Fs(){if(typeof document>"u"||document.getElementById(er))return;const t=document.createElement("style");t.id=er,t.textContent=`
|
|
122
|
+
@keyframes sg-pulse {
|
|
123
|
+
0%, 100% { r: var(--sg-r1); opacity: 0.35; }
|
|
124
|
+
50% { r: var(--sg-r2); opacity: 0.08; }
|
|
125
|
+
}
|
|
126
|
+
@keyframes sg-pulse-error {
|
|
127
|
+
0%, 100% { opacity: 0.7; }
|
|
128
|
+
50% { opacity: 0; }
|
|
129
|
+
}
|
|
130
|
+
@keyframes sg-particle {
|
|
131
|
+
0% { offset-distance: 0%; opacity: 0; }
|
|
132
|
+
10% { opacity: 1; }
|
|
133
|
+
90% { opacity: 1; }
|
|
134
|
+
100% { offset-distance: 100%; opacity: 0; }
|
|
135
|
+
}
|
|
136
|
+
@keyframes sg-node-breathe {
|
|
137
|
+
0%, 100% { filter: drop-shadow(0 0 4px var(--sg-glow)); }
|
|
138
|
+
50% { filter: drop-shadow(0 0 10px var(--sg-glow)); }
|
|
139
|
+
}
|
|
140
|
+
.sg-edge-particle {
|
|
141
|
+
offset-rotate: 0deg;
|
|
142
|
+
animation: sg-particle var(--sg-dur) linear infinite;
|
|
143
|
+
animation-delay: var(--sg-delay);
|
|
144
|
+
}
|
|
145
|
+
.sg-node-glow {
|
|
146
|
+
animation: sg-node-breathe 3s ease-in-out infinite;
|
|
147
|
+
}
|
|
148
|
+
.sg-pulse-ring {
|
|
149
|
+
animation: sg-pulse 3s ease-in-out infinite;
|
|
150
|
+
}
|
|
151
|
+
.sg-error-ring {
|
|
152
|
+
animation: sg-pulse-error 1s ease-in-out infinite;
|
|
153
|
+
}
|
|
154
|
+
`,document.head.appendChild(t)}function $s({nodes:t,edges:r,selected:n,onSelect:s,width:o,height:i}){fe(()=>Fs(),[]);const l=Te(()=>{const c=new Map;for(const d of t)c.set(d.id,d);return c},[t]),u=Te(()=>r.map((c,d)=>{const m=l.get(c.source),a=l.get(c.target);if(!m||!a)return null;const g=(m.x+a.x)/2,y=(m.y+a.y)/2,v=a.x-m.x,T=a.y-m.y,_=Math.sqrt(v*v+T*T),R=-T/(_||1),w=v/(_||1),A=(d%2===0?1:-1)*Math.min(_*.15,40),S=g+R*A,f=y+w*A,x=`M${m.x},${m.y} Q${S},${f} ${a.x},${a.y}`;return{...c,idx:d,sx:m.x,sy:m.y,tx:a.x,ty:a.y,cpx:S,cpy:f,pathD:x,srcType:m.type}}).filter(Boolean),[r,l]);return e("svg",{width:o,height:i,viewBox:`0 0 ${o} ${i}`,class:"select-none",onClick:()=>s(null),children:[e("defs",{children:[e("radialGradient",{id:"sg-bg-gradient",cx:"50%",cy:"50%",r:"60%",children:[e("stop",{offset:"0%",stopColor:"rgba(255,255,255,0.03)"}),e("stop",{offset:"100%",stopColor:"rgba(0,0,0,0)"})]}),Object.entries(ke).map(([c,d])=>e("filter",{id:`glow-${c}`,x:"-50%",y:"-50%",width:"200%",height:"200%",children:[e("feGaussianBlur",{in:"SourceGraphic",stdDeviation:"3",result:"blur"}),e("feFlood",{floodColor:d.fill,floodOpacity:"0.6",result:"color"}),e("feComposite",{in:"color",in2:"blur",operator:"in",result:"glow"}),e("feMerge",{children:[e("feMergeNode",{in:"glow"}),e("feMergeNode",{in:"SourceGraphic"})]})]},c)),Object.entries(ke).map(([c,d])=>e("filter",{id:`edge-glow-${c}`,x:"-20%",y:"-20%",width:"140%",height:"140%",children:[e("feGaussianBlur",{in:"SourceGraphic",stdDeviation:"2",result:"blur"}),e("feFlood",{floodColor:d.fill,floodOpacity:"0.4",result:"color"}),e("feComposite",{in:"color",in2:"blur",operator:"in",result:"glow"}),e("feMerge",{children:[e("feMergeNode",{in:"glow"}),e("feMergeNode",{in:"SourceGraphic"})]})]},`eg-${c}`)),u.map(c=>e("path",{id:`epath-${c.idx}`,d:`M${c.sx},${c.sy} L${c.tx},${c.ty}`},`p${c.idx}`))]}),e("rect",{width:o,height:i,fill:"url(#sg-bg-gradient)"}),e("circle",{cx:o/2,cy:i/2,r:Math.min(o,i)*.22,fill:"none",stroke:"rgba(255,255,255,0.04)",strokeDasharray:"2 6"}),e("circle",{cx:o/2,cy:i/2,r:Math.min(o,i)*.38,fill:"none",stroke:"rgba(255,255,255,0.04)",strokeDasharray:"2 6"}),e("g",{class:"edges",children:u.map(c=>{const d=n===c.source||n===c.target,m=ke[c.srcType]||ke.service;return e("g",{children:[d&&e("path",{d:c.pathD,fill:"none",stroke:m.edge,strokeWidth:6,opacity:.15,filter:`url(#edge-glow-${c.srcType})`}),e("path",{d:c.pathD,fill:"none",stroke:d?m.edge:`${m.fill}30`,strokeWidth:d?1.8:.8,class:"transition-all duration-300"})]},`e${c.idx}`)})}),e("g",{class:"particles",children:u.map(c=>{const d=ke[c.srcType]||ke.service;return[0,1,2].map(m=>e("circle",{r:"1.5",fill:d.edge,opacity:"0.8",class:"sg-edge-particle",style:{offsetPath:`path("${c.pathD}")`,"--sg-dur":`${3+m*1.2}s`,"--sg-delay":`${m*1.1}s`}},`pt${c.idx}-${m}`))})}),t.map(c=>{const d=ke[c.type]||ke.service,m=Es[c.status]||.3,a=n===c.id,g=c.ring===0?26:c.ring===1?20:16,y=g/10;return e("g",{class:"cursor-pointer",onClick:v=>{v.stopPropagation(),s(c.id)},children:[c.status==="running"&&e("circle",{cx:c.x,cy:c.y,fill:"none",stroke:d.fill,strokeWidth:1.5,class:"sg-pulse-ring",style:{"--sg-r1":`${g+5}px`,"--sg-r2":`${g+12}px`,r:g+5}}),c.status==="error"&&e("circle",{cx:c.x,cy:c.y,r:g+4,fill:"none",stroke:"#FF3366",strokeWidth:2,class:"sg-error-ring"}),e("circle",{cx:c.x,cy:c.y,r:g+3,fill:d.glow,opacity:c.status==="running"?.3:.1,class:c.status==="running"?"sg-node-glow":"",style:{"--sg-glow":d.fill}}),e("circle",{cx:c.x,cy:c.y,r:g,fill:a?d.fill:`${d.fill}18`,stroke:d.fill,strokeWidth:a?2.5:1.5,opacity:m,class:"transition-all duration-200"}),e("g",{transform:`translate(${c.x},${c.y}) scale(${y*.65})`,opacity:m,children:c.type==="source"?e("g",{fill:"none",stroke:a?"#09090B":d.fill,strokeWidth:"1.2",strokeLinecap:"round",children:[e("circle",{cx:"0",cy:"0",r:"2",fill:a?"#09090B":d.fill}),e("path",{d:"M-4.5-4.5A7 7 0 000 7"}),e("path",{d:"M4.5-4.5A7 7 0 010 7"}),e("path",{d:"M-3-3A5 5 0 000 5"}),e("path",{d:"M3-3A5 5 0 010 5"})]}):c.type==="telemetry"?e("path",{d:Zt.telemetry,fill:"none",stroke:a?"#09090B":d.fill,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}):e("path",{d:Zt[c.type],fill:a?"#09090B":d.fill,stroke:"none"})}),e("text",{x:c.x,y:c.y+g+14,textAnchor:"middle",fill:"rgba(255,255,255,0.7)",fontSize:c.ring===2?9:11,fontFamily:"JetBrains Mono, monospace",children:c.label.length>16?c.label.slice(0,14)+"…":c.label}),e("circle",{cx:c.x+g*.7,cy:c.y-g*.7,r:3,fill:c.status==="running"?"#00CC66":c.status==="error"?"#FF3366":"#666"})]},c.id)})]})}function Rs({node:t,report:r,edges:n}){if(t){const s=n.filter(i=>i.target===t.id),o=n.filter(i=>i.source===t.id);return e("div",{class:"space-y-4 animate-fade-in",children:[e("div",{class:"flex items-center gap-2",children:[e("span",{class:M("w-3 h-3 rounded-full",t.status==="running"?"bg-success":t.status==="error"?"bg-destructive":"bg-muted")}),e("h3",{class:"text-sm font-semibold",children:t.label}),e("span",{class:"text-xs text-muted-foreground",children:t.type})]}),e("div",{class:"grid grid-cols-2 gap-2 text-xs",children:[e("div",{class:"bg-muted/30 rounded p-2",children:[e("div",{class:"text-muted-foreground",children:"Status"}),e("div",{class:"font-medium",children:t.status})]}),e("div",{class:"bg-muted/30 rounded p-2",children:[e("div",{class:"text-muted-foreground",children:"Events"}),e("div",{class:"font-medium mono",children:t.eventCount})]})]}),o.length>0&&e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase mb-1",children:["Produces (",o.length,")"]}),e("div",{class:"space-y-0.5",children:o.slice(0,6).map((i,l)=>e("div",{class:"text-xs mono text-success/80",children:[i.event," → ",i.target]},l))})]}),s.length>0&&e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase mb-1",children:["Consumes (",s.length,")"]}),e("div",{class:"space-y-0.5",children:s.slice(0,6).map((i,l)=>e("div",{class:"text-xs mono text-blue-400/80",children:[i.source," → ",i.event]},l))})]}),t.produces.length>0&&e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase mb-1",children:"Event types"}),e("div",{class:"flex flex-wrap gap-1",children:t.produces.map(i=>e("span",{class:"text-[10px] mono bg-muted/50 px-1.5 py-0.5 rounded",children:i},i))})]})]})}return r?e("div",{class:"space-y-4",children:[e("h3",{class:"text-sm font-semibold",children:"System Overview"}),e("div",{class:"grid grid-cols-2 gap-2 text-xs",children:[e("div",{class:"bg-muted/30 rounded p-2",children:[e("div",{class:"text-muted-foreground",children:"Readiness"}),e("div",{class:"text-lg font-semibold mono text-success",children:[r.context.readiness,"%"]})]}),e("div",{class:"bg-muted/30 rounded p-2",children:[e("div",{class:"text-muted-foreground",children:"Services"}),e("div",{class:"text-lg font-semibold mono",children:r.systemModel.services})]}),e("div",{class:"bg-muted/30 rounded p-2",children:[e("div",{class:"text-muted-foreground",children:"Agents"}),e("div",{class:"text-lg font-semibold mono",children:r.context.existingAgents.length})]}),e("div",{class:"bg-muted/30 rounded p-2",children:[e("div",{class:"text-muted-foreground",children:"Invariants"}),e("div",{class:"text-lg font-semibold mono",children:r.systemModel.invariants})]})]}),e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase mb-1",children:"TLA+ Model"}),e("div",{class:"text-xs space-y-0.5",children:[e("div",{class:"flex justify-between",children:[e("span",{children:"State variables"}),e("span",{class:"mono",children:r.systemModel.stateVariables})]}),e("div",{class:"flex justify-between",children:[e("span",{children:"Actions"}),e("span",{class:"mono",children:r.systemModel.actions})]}),e("div",{class:"flex justify-between",children:[e("span",{children:"Concurrency patterns"}),e("span",{class:"mono text-warning",children:r.systemModel.concurrencyPatterns})]})]})]}),e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase mb-1",children:"Doc Health"}),e("div",{class:"text-xs space-y-0.5",children:[e("div",{class:"flex justify-between",children:[e("span",{children:"Total docs"}),e("span",{class:"mono",children:r.docHealth.totalDocs})]}),e("div",{class:"flex justify-between",children:[e("span",{children:"Bloated"}),e("span",{class:"mono text-warning",children:r.docHealth.bloatedDocs.length})]}),e("div",{class:"flex justify-between",children:[e("span",{children:"Recommendations"}),e("span",{class:"mono",children:r.docHealth.recommendations.length})]})]})]}),e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase mb-1",children:"Journal"}),e("div",{class:"text-xs space-y-0.5",children:[e("div",{class:"flex justify-between",children:[e("span",{children:"Sessions"}),e("span",{class:"mono",children:r.context.sessions})]}),e("div",{class:"flex justify-between",children:[e("span",{children:"Revert rate"}),e("span",{class:M("mono",r.journalInsights.revertRate>.1?"text-destructive":"text-success"),children:[(r.journalInsights.revertRate*100).toFixed(1),"%"]})]})]})]}),r.journalInsights.hotspots.length>0&&e("div",{children:[e("div",{class:"text-[10px] text-muted-foreground uppercase mb-1",children:"Hotspots"}),e("div",{class:"text-xs space-y-0.5",children:r.journalInsights.hotspots.slice(0,4).map(s=>e("div",{class:"flex justify-between",children:[e("span",{class:"mono truncate",children:s.path}),e("span",{class:"mono",children:s.touches})]},s.path))})]}),e("div",{class:"pt-2 border-t border-border text-[10px] text-muted-foreground",children:new Date(r.timestamp).toLocaleString()})]}):e("div",{class:"text-sm text-muted-foreground",children:["Click a node to see details. Run ",e("code",{class:"bg-muted px-1 py-0.5 rounded text-xs",children:"jfl setup"})," for full report."]})}function Ds(){return e("div",{class:"flex items-center gap-3 text-[10px] text-muted-foreground",children:[[{color:"#FF3D00",label:"Orchestrator"},{color:"#00E5FF",label:"Service"},{color:"#76FF03",label:"Agent"},{color:"#E040FB",label:"Source"},{color:"#FFD740",label:"Telemetry"}].map(r=>e("div",{class:"flex items-center gap-1",children:[e("span",{class:"w-2 h-2 rounded-full",style:{backgroundColor:r.color}}),r.label]},r.label)),e("div",{class:"flex items-center gap-1",children:[e("span",{class:"w-2 h-2 rounded-full bg-success"})," running"]}),e("div",{class:"flex items-center gap-1",children:[e("span",{class:"w-2 h-2 rounded-full bg-muted"})," stopped"]})]})}function As(){var m;const[t,r]=P(null),n=be(null),[s,o]=P({width:600,height:500}),i=G(()=>j.topology(),1e4),l=G(()=>j.setupReport(),3e4);fe(()=>{const a=n.current;if(!a)return;const g=new ResizeObserver(y=>{const{width:v,height:T}=y[0].contentRect;v>0&&T>0&&o({width:v,height:T})});return g.observe(a),()=>g.disconnect()},[]);const u=Te(()=>{var a;return(a=i.data)!=null&&a.nodes?Ts(i.data.nodes,s.width,s.height):[]},[i.data,s]),c=((m=i.data)==null?void 0:m.edges)||[],d=u.find(a=>a.id===t)||null;return e("div",{class:"h-full flex flex-col gap-3",children:[e("div",{class:"flex items-center justify-between",children:[e("h1",{class:"text-xl font-semibold",children:"System Graph"}),e(Ds,{})]}),e("div",{class:"flex-1 flex gap-4 min-h-0",children:[e("div",{ref:n,class:"flex-1 bg-card rounded-lg border border-border overflow-hidden relative",children:[u.length===0?e("div",{class:"flex items-center justify-center h-full text-sm text-muted-foreground",children:"No topology data. Start the context hub."}):e($s,{nodes:u,edges:c,selected:t,onSelect:r,width:s.width,height:s.height}),e("div",{class:"absolute bottom-3 left-3 flex items-center gap-1 text-[10px] text-muted-foreground bg-card/80 backdrop-blur px-2 py-1 rounded",children:[e("svg",{width:"6",height:"6",children:e("circle",{cx:"3",cy:"3",r:"3",fill:"#00CC66"})}),u.filter(a=>a.status==="running").length," running",e("span",{class:"mx-1",children:"·"}),u.length," total",e("span",{class:"mx-1",children:"·"}),c.length," connections"]})]}),e("div",{class:"w-72 bg-card rounded-lg border border-border p-4 overflow-y-auto",children:e(Rs,{node:d,report:l.data,edges:c})})]})]})}function Ps(t,r){for(var n in r)t[n]=r[n];return t}function tr(t,r){for(var n in t)if(n!=="__source"&&!(n in r))return!0;for(var s in r)if(s!=="__source"&&t[s]!==r[s])return!0;return!1}function rr(t,r){this.props=t,this.context=r}(rr.prototype=new we).isPureReactComponent=!0,rr.prototype.shouldComponentUpdate=function(t,r){return tr(this.props,t)||tr(this.state,r)};var nr=H.__b;H.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),nr&&nr(t)};var Is=H.__e;H.__e=function(t,r,n,s){if(t.then){for(var o,i=r;i=i.__;)if((o=i.__c)&&o.__c)return r.__e==null&&(r.__e=n.__e,r.__k=n.__k),o.__c(t,r)}Is(t,r,n,s)};var sr=H.unmount;function Rr(t,r,n){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(s){typeof s.__c=="function"&&s.__c()}),t.__c.__H=null),(t=Ps({},t)).__c!=null&&(t.__c.__P===n&&(t.__c.__P=r),t.__c.__e=!0,t.__c=null),t.__k=t.__k&&t.__k.map(function(s){return Rr(s,r,n)})),t}function Dr(t,r,n){return t&&n&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(s){return Dr(s,r,n)}),t.__c&&t.__c.__P===r&&(t.__e&&n.appendChild(t.__e),t.__c.__e=!0,t.__c.__P=n)),t}function ht(){this.__u=0,this.o=null,this.__b=null}function Ar(t){if(!t.__)return null;var r=t.__.__c;return r&&r.__a&&r.__a(t)}function Ke(){this.i=null,this.l=null}H.unmount=function(t){var r=t.__c;r&&(r.__z=!0),r&&r.__R&&r.__R(),r&&32&t.__u&&(t.type=null),sr&&sr(t)},(ht.prototype=new we).__c=function(t,r){var n=r.__c,s=this;s.o==null&&(s.o=[]),s.o.push(n);var o=Ar(s.__v),i=!1,l=function(){i||s.__z||(i=!0,n.__R=null,o?o(c):c())};n.__R=l;var u=n.__P;n.__P=null;var c=function(){if(!--s.__u){if(s.state.__a){var d=s.state.__a;s.__v.__k[0]=Dr(d,d.__c.__P,d.__c.__O)}var m;for(s.setState({__a:s.__b=null});m=s.o.pop();)m.__P=u,m.forceUpdate()}};s.__u++||32&r.__u||s.setState({__a:s.__b=s.__v.__k[0]}),t.then(l,l)},ht.prototype.componentWillUnmount=function(){this.o=[]},ht.prototype.render=function(t,r){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),s=this.__v.__k[0].__c;this.__v.__k[0]=Rr(this.__b,n,s.__O=s.__P)}this.__b=null}var o=r.__a&&xt(le,null,t.fallback);return o&&(o.__u&=-33),[xt(le,null,r.__a?null:t.children),o]};var or=function(t,r,n){if(++n[1]===n[0]&&t.l.delete(r),t.props.revealOrder&&(t.props.revealOrder[0]!=="t"||!t.l.size))for(n=t.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;t.i=n=n[2]}};(Ke.prototype=new we).__a=function(t){var r=this,n=Ar(r.__v),s=r.l.get(t);return s[0]++,function(o){var i=function(){r.props.revealOrder?(s.push(o),or(r,t,s)):o()};n?n(i):i()}},Ke.prototype.render=function(t){this.i=null,this.l=new Map;var r=ot(t.children);t.revealOrder&&t.revealOrder[0]==="b"&&r.reverse();for(var n=r.length;n--;)this.l.set(r[n],this.i=[1,0,this.i]);return t.children},Ke.prototype.componentDidUpdate=Ke.prototype.componentDidMount=function(){var t=this;this.l.forEach(function(r,n){or(t,n,r)})};var js=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,Ls=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Os=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Bs=/[A-Z0-9]/g,Gs=typeof document<"u",Ns=function(t){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(t)};we.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(t){Object.defineProperty(we.prototype,t,{configurable:!0,get:function(){return this["UNSAFE_"+t]},set:function(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})});var ir=H.event;function Us(){}function Hs(){return this.cancelBubble}function zs(){return this.defaultPrevented}H.event=function(t){return ir&&(t=ir(t)),t.persist=Us,t.isPropagationStopped=Hs,t.isDefaultPrevented=zs,t.nativeEvent=t};var Xs={enumerable:!1,configurable:!0,get:function(){return this.class}},lr=H.vnode;H.vnode=function(t){typeof t.type=="string"&&(function(r){var n=r.props,s=r.type,o={},i=s.indexOf("-")===-1;for(var l in n){var u=n[l];if(!(l==="value"&&"defaultValue"in n&&u==null||Gs&&l==="children"&&s==="noscript"||l==="class"||l==="className")){var c=l.toLowerCase();l==="defaultValue"&&"value"in n&&n.value==null?l="value":l==="download"&&u===!0?u="":c==="translate"&&u==="no"?u=!1:c[0]==="o"&&c[1]==="n"?c==="ondoubleclick"?l="ondblclick":c!=="onchange"||s!=="input"&&s!=="textarea"||Ns(n.type)?c==="onfocus"?l="onfocusin":c==="onblur"?l="onfocusout":Os.test(l)&&(l=c):c=l="oninput":i&&Ls.test(l)?l=l.replace(Bs,"-$&").toLowerCase():u===null&&(u=void 0),c==="oninput"&&o[l=c]&&(l="oninputCapture"),o[l]=u}}s=="select"&&o.multiple&&Array.isArray(o.value)&&(o.value=ot(n.children).forEach(function(d){d.props.selected=o.value.indexOf(d.props.value)!=-1})),s=="select"&&o.defaultValue!=null&&(o.value=ot(n.children).forEach(function(d){d.props.selected=o.multiple?o.defaultValue.indexOf(d.props.value)!=-1:o.defaultValue==d.props.value})),n.class&&!n.className?(o.class=n.class,Object.defineProperty(o,"className",Xs)):n.className&&(o.class=o.className=n.className),r.props=o})(t),t.$$typeof=js,lr&&lr(t)};var ar=H.__r;H.__r=function(t){ar&&ar(t),t.__c};var cr=H.diffed;H.diffed=function(t){cr&&cr(t);var r=t.props,n=t.__e;n!=null&&t.type==="textarea"&&"value"in r&&r.value!==n.value&&(n.value=r.value==null?"":r.value)};const kt=["backlog","in_progress","eval","done"],Pr={backlog:{label:"Backlog"},in_progress:{label:"In Progress"},eval:{label:"In Review"},done:{label:"Done"}},Ir={human:"#8b8b8b",agent:"#8b8b8b",setup:"#8b8b8b",verify:"#e5534b",findings:"#d29922"},Ws={10:"#e5534b",9:"#e5534b",8:"#d29922",7:"#d29922",6:"#d29922",5:"#8b8b8b",4:"#8b8b8b",3:"#8b8b8b",2:"#8b8b8b",1:"#8b8b8b",0:"#8b8b8b"};function jr({priority:t}){if(t===0)return null;const r=Ws[t]??"#8b8b8b",n=Math.min(4,Math.ceil(t/2.5));return e("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{flexShrink:0},children:[0,1,2,3].map(s=>e("rect",{x:s*4,y:12-(s+1)*3,width:"3",height:(s+1)*3,rx:"0.5",fill:s<n?r:"#2a2a2a"},s))})}function Lr(t){const r=Date.now()-new Date(t).getTime(),n=Math.floor(r/6e4);if(n<60)return`${n}m`;const s=Math.floor(n/60);return s<24?`${s}h`:`${Math.floor(s/24)}d`}function Ys({card:t,onClose:r,onMove:n}){var i,l;const s=t.links||{},o=s.pr||s.eval||s.journal||s.violation||s.session;return e("div",{style:{width:340,background:"#0a0a0a",borderLeft:"1px solid #1e1e1e",padding:"16px 20px",overflowY:"auto",flexShrink:0,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"},children:[e("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:16},children:[e("div",{style:{flex:1},children:[e("div",{style:{fontSize:15,fontWeight:500,color:"#e0e0e0",lineHeight:1.4},children:t.title}),e("div",{style:{fontSize:11,color:"#444",fontFamily:"monospace",marginTop:4},children:[t.url?e("a",{href:t.url,target:"_blank",rel:"noopener",style:{color:"#5c9eff",textDecoration:"none"},children:t.id}):t.id," · ",t.source," · ",Lr(t.createdAt)," ago"]})]}),e("button",{onClick:r,style:{background:"none",border:"none",color:"#555",cursor:"pointer",fontSize:16,padding:"0 0 0 8px"},children:"×"})]}),e("div",{style:{borderTop:"1px solid #1a1a1a",paddingTop:12,marginBottom:16},children:[e($e,{label:"Status",children:e("select",{value:t.column,onChange:u=>n(t.id,u.target.value),style:{background:"#111",border:"1px solid #1e1e1e",borderRadius:3,color:"#ccc",fontSize:12,padding:"2px 6px",fontFamily:"inherit"},children:kt.map(u=>e("option",{value:u,children:Pr[u].label},u))})}),e($e,{label:"Priority",children:e("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e(jr,{priority:t.priority}),e("span",{style:{fontSize:12,color:"#888"},children:["P",t.priority]})]})}),t.agent&&e($e,{label:"Assignee",children:e("span",{style:{fontSize:12,color:"#888"},children:t.agent})}),t.scope&&e($e,{label:"Scope",children:e("span",{style:{fontSize:12,color:"#5c9eff",fontFamily:"monospace"},children:t.scope})}),t.score!==null&&e($e,{label:"Score",children:e("span",{style:{fontSize:12,color:"#4ade80",fontFamily:"monospace"},children:t.score.toFixed(4)})}),e($e,{label:"Source",children:e("span",{style:{fontSize:11,color:Ir[t.source]??"#555",textTransform:"uppercase",letterSpacing:"0.04em"},children:t.source})})]}),((i=t.labels)==null?void 0:i.length)>0&&e("div",{style:{marginBottom:16},children:[e("div",{style:{fontSize:11,color:"#555",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6},children:"Labels"}),e("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:t.labels.map(u=>e("span",{style:{fontSize:11,color:"#888",background:"#161616",border:"1px solid #1e1e1e",borderRadius:3,padding:"1px 6px"},children:u},u))})]}),t.description&&e("div",{style:{marginBottom:16},children:[e("div",{style:{fontSize:11,color:"#555",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6},children:"Description"}),e("div",{style:{fontSize:13,color:"#999",lineHeight:1.5},children:t.description})]}),o&&e("div",{style:{marginBottom:16},children:[e("div",{style:{fontSize:11,color:"#555",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6},children:"Links"}),e("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[s.pr&&e(Re,{label:`PR #${s.pr}`,href:s.pr_url??`https://github.com/402goose/jfl-cli/pull/${s.pr}`}),s.eval&&e(Re,{label:`Eval: ${s.eval}`,onClick:()=>{}}),s.journal&&e(Re,{label:`Journal: ${s.journal}`,onClick:()=>{}}),s.violation&&e(Re,{label:`Violation: ${s.violation}`,onClick:()=>{}}),s.session&&e(Re,{label:`Session: ${s.session}`,onClick:()=>{}}),(l=s.docs)==null?void 0:l.map(u=>e(Re,{label:u,onClick:()=>{}},u))]})]}),e("div",{children:[e("div",{style:{fontSize:11,color:"#555",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6},children:"Activity"}),e("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e(gt,{text:`Created by ${t.source}`,time:t.createdAt}),t.agent&&t.column!=="backlog"&&e(gt,{text:`Picked by ${t.agent}`,time:t.updatedAt}),t.score!==null&&e(gt,{text:`Scored ${t.score.toFixed(4)}`,time:t.updatedAt})]})]})]})}function $e({label:t,children:r}){return e("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"5px 0"},children:[e("span",{style:{fontSize:12,color:"#555"},children:t}),r]})}function Re({label:t,href:r,onClick:n}){const s={fontSize:12,color:"#5c9eff",cursor:"pointer",background:"none",border:"none",padding:0,fontFamily:"inherit",textAlign:"left"};return r?e("a",{href:r,target:"_blank",rel:"noopener",style:{...s,textDecoration:"none"},children:[t," ↗"]}):e("button",{onClick:n,style:s,children:[t," →"]})}function gt({text:t,time:r}){return e("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e("span",{style:{fontSize:12,color:"#666"},children:t}),e("span",{style:{fontSize:11,color:"#333",fontFamily:"monospace"},children:Lr(r)})]})}function Vs({card:t,onDragStart:r,isDragging:n,isSelected:s,onClick:o}){var i;return e("div",{draggable:!0,onClick:o,onDragStart:l=>{l.dataTransfer.setData("text/plain",t.id),l.dataTransfer.effectAllowed="move",r(t.id)},style:{background:s?"#141414":n?"#1a1a1a":"transparent",borderLeft:s?"2px solid #5c9eff":"2px solid transparent",borderBottom:"1px solid #1e1e1e",padding:"10px 12px 10px 10px",cursor:"pointer",transition:"background 0.1s",opacity:n?.4:1},onMouseEnter:l=>{!n&&!s&&(l.currentTarget.style.background="#0e0e0e")},onMouseLeave:l=>{!n&&!s&&(l.currentTarget.style.background="transparent")},children:[e("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e(jr,{priority:t.priority}),e("span",{style:{fontSize:13,color:"#e0e0e0",fontWeight:400,flex:1,lineHeight:1.4},children:t.title})]}),e("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:5,marginLeft:22},children:[t.scope&&e("span",{style:{fontSize:10,color:"#5c9eff",fontFamily:"monospace"},children:t.scope}),t.source!=="human"&&e("span",{style:{fontSize:10,color:Ir[t.source]??"#555",textTransform:"uppercase",letterSpacing:"0.04em"},children:t.source}),(i=t.labels)==null?void 0:i.slice(0,2).map(l=>e("span",{style:{fontSize:10,color:"#666",background:"#161616",borderRadius:2,padding:"0 4px"},children:l},l)),t.agent&&e("span",{style:{fontSize:10,color:"#444"},children:t.agent}),t.score!==null&&e("span",{style:{fontSize:10,color:"#4ade80",fontFamily:"monospace"},children:t.score.toFixed(2)}),t.url?e("a",{href:t.url,target:"_blank",rel:"noopener",style:{fontSize:10,color:"#333",marginLeft:"auto",fontFamily:"monospace",textDecoration:"none"},onClick:l=>l.stopPropagation(),children:t.id}):e("span",{style:{fontSize:10,color:"#2a2a2a",marginLeft:"auto",fontFamily:"monospace"},children:t.id})]})]})}function qs(){var $,b,p;const[t,r]=P({backlog:[],in_progress:[],eval:[],done:[]}),[n,s]=P(""),[o,i]=P(!0),[l,u]=P(null),[c,d]=P(null),[m,a]=P(null),[g,y]=P(null),[v,T]=P(""),[_,R]=P({name:"",type:""}),[w,A]=P([]);fe(()=>{Y("/api/kanban/scopes").then(k=>{R(k.workspace??{name:"",type:""}),A(k.services??[])}).catch(()=>{})},[]);const S=Ee(async()=>{try{const k=new URLSearchParams;v&&k.set("scope",v),k.set("aggregate","true");const L=await Y(`/api/kanban?${k}`);r(L),u(null)}catch(k){u(k.message)}finally{i(!1)}},[v]);fe(()=>{S();const k=setInterval(S,5e3);return()=>clearInterval(k)},[S]);const f=async(k,L)=>{try{await Y("/api/kanban",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"move",id:k.replace("#",""),column:L})}),(g==null?void 0:g.id)===k&&y({...g,column:L}),await S()}catch{}},x=async()=>{if(n.trim())try{await Y("/api/kanban",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"create",title:n.trim(),scope:v||void 0})}),s(""),await S()}catch{}},I=kt.flatMap(k=>t[k]??[]),h=w.map(k=>k.name).filter(Boolean),C=I.length,E=((($=t.in_progress)==null?void 0:$.length)??0)+(((b=t.eval)==null?void 0:b.length)??0);return e("div",{style:{display:"flex",height:"calc(100vh - 48px)",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"},children:[e("div",{style:{flex:1,padding:"20px 24px",overflow:"auto"},children:[e("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[e("div",{children:[e("h1",{style:{fontSize:14,fontWeight:500,color:"#e0e0e0",margin:0,letterSpacing:"-0.01em"},children:"Issues"}),e("p",{style:{fontSize:12,color:"#444",marginTop:2,fontFamily:"monospace"},children:[C," total · ",E," active · ",((p=t.done)==null?void 0:p.length)??0," closed"]})]}),e("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[h.length>0&&e("select",{value:v,onChange:k=>T(k.target.value),style:{background:"#0a0a0a",border:"1px solid #1e1e1e",borderRadius:4,color:"#888",padding:"5px 8px",fontSize:12,fontFamily:"monospace"},children:[e("option",{value:"",children:"All scopes"}),h.map(k=>e("option",{value:k,children:k},k))]}),e("form",{onSubmit:k=>{k.preventDefault(),x()},style:{display:"flex",gap:6},children:[e("input",{value:n,onChange:k=>s(k.target.value),placeholder:"New issue…",style:{background:"#0a0a0a",border:"1px solid #1e1e1e",borderRadius:4,color:"#e0e0e0",padding:"5px 10px",fontSize:13,width:200,outline:"none",fontFamily:"inherit"},onFocus:k=>k.currentTarget.style.borderColor="#333",onBlur:k=>k.currentTarget.style.borderColor="#1e1e1e"}),e("button",{type:"submit",style:{background:"#e0e0e0",color:"#0a0a0a",border:"none",borderRadius:4,padding:"5px 12px",fontSize:13,cursor:"pointer",fontWeight:500,fontFamily:"inherit"},children:"Create"})]})]})]}),l&&e("div",{style:{color:"#e5534b",fontSize:12,marginBottom:12},children:l}),e("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:1,background:"#1e1e1e",borderRadius:6,overflow:"hidden",border:"1px solid #1e1e1e"},children:kt.map(k=>{const L=Pr[k],N=t[k]??[],U=m===k;return e("div",{onDragOver:X=>{X.preventDefault(),X.dataTransfer.dropEffect="move",a(k)},onDragEnter:X=>{X.preventDefault(),a(k)},onDragLeave:X=>{const Z=X.currentTarget.getBoundingClientRect(),{clientX:de,clientY:ue}=X;(de<Z.left||de>Z.right||ue<Z.top||ue>Z.bottom)&&a(null)},onDrop:X=>{X.preventDefault();const Z=X.dataTransfer.getData("text/plain");Z&&c&&f(Z,k),d(null),a(null)},style:{background:U?"#0f0f0f":"#0a0a0a",minHeight:400,transition:"background 0.1s"},children:[e("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 12px",borderBottom:"1px solid #1e1e1e"},children:[e("span",{style:{fontSize:12,fontWeight:500,color:"#888",textTransform:"uppercase",letterSpacing:"0.05em"},children:L.label}),e("span",{style:{fontSize:11,color:"#444",fontFamily:"monospace"},children:N.length})]}),N.length===0?e("div",{style:{fontSize:12,color:"#2a2a2a",textAlign:"center",padding:"40px 0"},children:U?"Drop here":"No issues"}):N.map(X=>e(Vs,{card:X,onDragStart:d,isDragging:c===X.id,isSelected:(g==null?void 0:g.id)===X.id,onClick:()=>y((g==null?void 0:g.id)===X.id?null:X)},X.id))]},k)})})]}),g&&e(Ys,{card:g,onClose:()=>y(null),onMove:f})]})}const Js={_startTime:Date.now(),_lastPage:"",pageView(t){const r=this._lastPage?Date.now()-this._startTime:0;this._lastPage&&r>1e3&&this._emit("dashboard:page-dwell",{page:this._lastPage,durationMs:r}),this._emit("dashboard:page-view",{page:t}),this._startTime=Date.now(),this._lastPage=t},click(t,r){this._emit("dashboard:click",{target:t,...r})},_emit(t,r){const n=new Date().toISOString(),s=localStorage.getItem("jfl-token")||"";fetch("/api/hooks",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify({type:t,source:"dashboard",data:r,ts:n})}).catch(()=>{}),fetch("https://jfl-platform.fly.dev/api/v1/telemetry/ingest",{method:"POST",headers:{"Content-Type":"application/json","x-jfl-install-id":"jfl-dashboard"},body:JSON.stringify({events:[{event_id:crypto.randomUUID(),ts:n,category:"dashboard",event:t,install_id:"jfl-dashboard",...r}]})}).catch(()=>{})}},Qe={overview:hn,activity:()=>e(us,{}),agents:()=>e(bn,{}),loop:()=>e(gs,{}),experiments:()=>e(Gn,{}),findings:()=>e(Mn,{}),journal:()=>e(Tn,{}),events:()=>e($n,{}),services:()=>e(Dn,{}),flows:()=>e(jn,{}),health:()=>e(Bn,{}),telemetry:()=>e(zn,{}),reviews:()=>e(vs,{}),chat:()=>e(ws,{}),synopsis:Ss,topology:os,system:fs,"setup-report":()=>e(Ms,{}),"system-graph":()=>e(As,{}),kanban:()=>e(qs,{})};function Ks(){const t=G(()=>j.status(),1e4),r=location.hash.replace("#/","")||"overview",[n,s]=P(r in Qe?r:"overview"),o=be(!0);if(fe(()=>{const l=()=>{const u=location.hash.replace("#/","")||"overview";u in Qe&&u!==n&&s(u)};return window.addEventListener("hashchange",l),()=>window.removeEventListener("hashchange",l)},[n]),fe(()=>{Js.pageView(n),o.current||(location.hash=`#/${n}`),o.current=!1},[n]),t.loading)return e("div",{class:"flex items-center justify-center h-screen",children:e("div",{class:"text-muted-foreground text-sm animate-pulse-dot",children:"Loading dashboard..."})});if(t.error)return e("div",{class:"flex items-center justify-center h-screen",children:e("div",{class:"text-center",children:[e("div",{class:"text-destructive text-sm font-medium",children:"Connection Error"}),e("div",{class:"text-muted-foreground text-xs mt-1",children:t.error}),e("div",{class:"text-muted-foreground text-xs mt-2 mono",children:"jfl context-hub start"})]})});const i=Qe[n]||Qe.overview;return e("div",{class:"flex min-h-screen",children:[e(un,{status:t.data,currentPage:n,setPage:l=>s(l)}),e("main",{class:"flex-1 ml-56 p-6",children:e(i,{status:t.data})})]})}zr(e(Ks,{}),document.getElementById("app"));
|